This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: objdump prints PE relocations with --private-headers, not --reloc
On Thu, 30 Oct 2003, Ian Lance Taylor wrote:
> Note that relocations in an executable file should not normally be
> dumped by objdump -r (--reloc), they should be dumped by objdump -R
> (--dynamic-reloc).
OK, I've just tested in on GNU/Linux i686:
$ gcc -o hello hello.c
$ objdump -r hello
hello: file format elf32-i386
$ objdump -R hello
hello: file format elf32-i386
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
08049508 R_386_GLOB_DAT __gmon_start__
08049500 R_386_JUMP_SLOT __libc_start_main
08049504 R_386_JUMP_SLOT printf
$ gcc -o hello hello.c -Wl,--emit-reloc
$ objdump -r hello
hello: file format elf32-i386
RELOCATION RECORDS FOR [.init]:
OFFSET TYPE VALUE
00000007 R_386_PC32 .text
0000000c R_386_PC32 .text
00000011 R_386_PC32 .text
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
0000000c R_386_32 __libc_csu_fini
00000011 R_386_32 __libc_csu_init
00000018 R_386_32 main
0000001d R_386_PC32 __libc_start_main@@GLIBC_2.0
00000031 R_386_GOTPC _GLOBAL_OFFSET_TABLE_
00000037 R_386_GOT32 __gmon_start__
[dozens of lines skipped]
$ objdump -R hello
hello: file format elf32-i386
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
08049508 R_386_GLOB_DAT __gmon_start__
08049500 R_386_JUMP_SLOT __libc_start_main
08049504 R_386_JUMP_SLOT printf
As you can see, use of --emit-reloc affects the output of "objdump -r",
but not "objdump -R".
What I'm interested in is the data from the .reloc section in PE files.
Normally the .reloc section is missing. Regardless of whether the reloc
section is present, "objdump -r" and "objdump -R" don't print relocations:
$ /home/proski/src/binutils/binutils/objdump -r test-reloc.exe
test-reloc.exe: file format pei-i386
$ /home/proski/src/binutils/binutils/objdump -R test-reloc.exe
test-reloc.exe: file format pei-i386
/home/proski/src/binutils/binutils/objdump: test-reloc.exe: not a dynamic
object
/home/proski/src/binutils/binutils/objdump: test-reloc.exe: Invalid
operation
> Executable file relocation information is not the same as object file
> relocation information. The latter is processed by the program linker,
> the former by the dynamic linker. That's why we have different options
> in objdump to dump them.
>
> It would be appropriate for objdump -R to dump dynamic relocations for
> PE executables.
I'm confused by the fact that in case of ELF format, --emit-reloc affects
the symbols shown by "objdump -r", and --emit-reloc means "leave
relocations in the final executable".
Now, in case of PE files I also want to leave relocations in the final
executable, so I'm going to use --emit-reloc for that. But you are
suggesting that the relocations created by --emit-reloc should be listed
by "objdump -R". I don't see any logic here.
--
Regards,
Pavel Roskin