Mar 27, 2012 at 9:10am UTC
I read the ELF file format. I have a question. the symbol table save symbol for relocation when linking. Why local variables are saved in symbol table?
see the next prrogram.
double enLargeOrg(double size){
static int rate = 8;
return rate * size;
}
double enLargePear(double size){
static int rate = 12;
return rate * size;
}
int main(){
printf("Orange size is %f\n",enLargeOrg(3.4));
printf("Pear size is %f\n",enLargePear(5.6));
return 1;
}
use gcc to compile to get the executable file test.
The .data section in test is :
test: file format elf32-i386
Disassembly of section .data:
0804953c <__data_start>:
...
08049544 <p.0>:
8049544: 2c 96 04 08 ,...
08049548 <completed.1>:
8049548: 00 00 00 00 ....
0804954c <force_to_data>:
804954c: 08 00 00 00 ....
08049550 <rate.1>:
8049550: 0c 00 00 00 ....
804954c save the value of rate in enLargeOrg. But in symbol table, its name is "rate.0". What does the "force_to_data" mean?