4 ms·
That's objdump's default format when outputting relocations together with the disassembly. As you have already found out, the code is compiled with dummy values
by cnvogel 12y ago
That's objdump's default format when outputting relocations together with the disassembly. As you have already found out, the code is compiled with dummy values for the actual addresses being accessed or jumped to, and the reloacation table instructs the linker to overwrite these dummy values with the actual addresses, once they are known.
R_X86_64_GOTPCREL is a constant defined in /usr/include/elf.h (I think it's from libbdf, the library dealing with the different file formats binutils understand).
#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative
offset to GOT */
Here's another example, with the invocation of objdump:
$ cat hackernews.c
int
doit(int a)
{
return blah(a);
}
$ cc -Os -c hackernews.c
$ objdump -r -S hackernews.o
hackernews.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <doit>:
0: 31 c0 xor %eax,%eax
2: e9 00 00 00 00 jmpq 7 <doit+0x7>
3: R_X86_64_PC32 blah-0x4
on ARM (raspberry pi, the relocation looks a little bit different)
$ objdump -r -S hackernews.o
hackernews.o: file format elf32-littlearm
Disassembly of section .text:
00000000 <doit>:
0: eafffffe b 0 <blah>
0: R_ARM_JUMP24 blah
#define R_ARM_JUMP24 29 /* PC relative 24 bit
(B, BL<cond>). */
To only see the relocation table, use "objdump --relocs":
hackernews.o: file format elf32-littlearm
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000000 R_ARM_JUMP24 blah
- gsg 12y agoBy the way, I believe the zeros are addends and not actually dummy values. This is a bit strange because ELF has existing provisions for relocations with addends, but there it is.
- acqq 12y agoThanks! So it's objdump producing something nobody who doesn't debug linker's rellocation code needs. Is there an option "make sane output"? I guess gcc's -S option would make something prettier?