[C] Global variable and sections .BSS and .DATA

Hi

Sometime ago I saw somewhere that it is possible to have two variables with same name in two different sections .BSS and .Data inside one ELF binary file. The trick was to declare variables as extern/static,perhaps initialized and uninitialized. I really don't remember how to achieve similar results.

I can't find article about that, maybe someone of you has some detail, perhaps, can point me to the that.
 
akil said:
Sometime ago I saw somewhere that it is possible to have two variables with same name in two different sections .BSS and .Data inside one ELF binary file. The trick was to declare variables as extern/static,perhaps initialized and uninitialized. I really don't remember how to achieve similar results.
It's called scope, or better, the scope of a variable.

http://icecube.wisc.edu/~dglo/c_class/scope.html
 
Yes, that's true. But I really believe that there is a way to put it into the BSS and DATA section same global variable and that is not connected with the scope, but I don't remember how to achieve that. Normally global uninitialized variable is placed into .data section, in case of initialized .bss section is used, so how to put same variable into the both sections? This is my question. I think that it is possible with extern/const/static? but how.
 
Back
Top