LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

How do you view relocation entries in an object file?

readelf -r lists relocation entries (offset, type, symbol, addend); objdump -dr shows them inline next to the disassembly.

$ readelf -r main.o
Relocation section '.rela.text' at offset 0x1e8:
  Offset     Info           Type              Symbol
000000000f  00050000002a R_X86_64_PC32     buf-0x4
000000001e  000600000004 R_X86_64_PLT32    swap-0x4

Relocation section '.rela.data' at offset 0x218:
  Offset     Info           Type              Symbol
000000000  000500000001 R_X86_64_64       buf+0x0

Or with objdump for inline view:

$ objdump -dr main.o
0000000000000000 <main>:
   0: 55                    push   %rbp
   ...
   f: 48 8b 05 00 00 00 00  mov    0x0(%rip),%rax
                  12: R_X86_64_PC32    buf-0x4
  16: e8 00 00 00 00        callq  1b <main+0x1b>
                  17: R_X86_64_PLT32   swap-0x4

Understanding the output:

  • Offset: Where in the section to patch
  • Type: How to calculate the final value
  • Symbol: What symbol is referenced
  • Addend: Constant to add (often -4 for PC-relative)

Tip: The -d flag in objdump shows disassembly; -r shows relocations inline with the code.

Go deeper:

From Quiz: REVE1 / Program Execution | Updated: Jul 10, 2026