i just wrote a simple c program and then generated a relocatable object file to have more understanding on different aspect of object file this is the source code :
int main(void)
{
static int a = 1 ;
int b = 2 ;
b = a + b ;
return 0;
}
the question is why in the data section contain assembly instruction :
0000000000000000 <a.0>:
0: 01 00 add %eax,(%rax)
i was expecting that the data section will contain the address of initialized data
I run gcc on wsl2 ubuntu and this the command : gcc -o file.c file.o
You're showing that it starts with 01 00
.
0: 01 00 add %eax,(%rax)
^^^^^
This is exactly how one would expect it to start. (The next two bytes are going to be 00 00
.) Sure, if you interpret that as code, it would be add %eax,(%rax)
. But it's not code. It's a 32-bit signed integer.