Question on objdump option --adjust-vma
Jens Remus
jremus@linux.ibm.com
Fri May 16 14:51:08 GMT 2025
Is it on purpose that objdump option --adjust-vma (in contract to
objcopy option --adjust-vma) only affects section addresses but not
symbol values?
Background:
A colleague of mine tried to use objdump option --adjust-vma to obtain a
disassembly of the s390 Linux Kernel vmlinux adjusted by KASLR offset
for debugging purposes. On s390 the Linux Kernel is compiled as PIC
(-fPIC) and linked as PDE (-no-pie) and relocates itself using
information extracted from the use of --emit-relocs.
Output of objdump without --adjust-vma for reference:
$ objdump -d vmlinux
...
0000000000100000 <startup_continue>:
100000: a7 29 00 00 lghi %r2,0
100004: c0 e0 00 b2 7e fe larl %r14,174fe00 <init_task>
...
Output from objdump with --adjust-vma, that does not show the expected
symbol information:
$ objdump -d --adjust-vma=0x3ffe0000000 vmlinux
...
000003ffe0100000 <_etext+0x3ffdf062000>: <-- ?
3ffe0100000: a7 29 00 00 lghi %r2,0
3ffe0100004: c0 e0 00 b2 7e fe larl %r14,3ffe174fe00 <__bss_stop+0x3ffdfc73e00> <-- ?
...
We found that objdump option --adjust-vma apparently only adjusts the
section addresses, but not the symbol values. This kind of unexpected
behavior is probably documented as such in the objdump man page:
"When dumping information, first add offset to all the section
addresses. This is useful if the section addresses do not correspond
to the symbol table, which can happen when putting sections at
particular addresses when using a format which can not represent
section addresses, such as a.out."
As a workaround my colleague found that a combination of objcopy with
option --adjust-vma and objdump does the trick:
$ objcopy --adjust-vma=0x3ffe0000000 vmlinux vmlinux_temp
$ objdump -d vmlinux_temp
...
000003ffe0100000 <startup_continue>: <--- !
3ffe0100000: a7 29 00 00 lghi %r2,0
3ffe0100004: c0 e0 00 b2 7e fe larl %r14,3ffe174fe00 <init_task> <--- !
...
Btw. LLVM objdump behaves even differently from Binutils objdump,
which seems broken to me (disassembly of PC-relative instructions
does not respect the adjusted section address):
$ llvm-objdump -d --adjust-vma=0x3ffe0000000 vmlinux
...
000003ffe0100000 <startup_continue>: <--- !
3ffe0100000: a7 29 00 00 lghi %r2, 0
3ffe0100004: c0 e0 00 b2 7e fe larl %r14, 0x174fe00 <--- ?
...
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des
Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der
Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
More information about the Binutils
mailing list