This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Discrepancy with .reloc section between PE and PE+ emulations when linking -r.
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: binutils at sourceware dot org
- Date: Fri, 13 Feb 2009 03:54:17 +0000
- Subject: Re: Discrepancy with .reloc section between PE and PE+ emulations when linking -r.
- References: <4994E930.5000601@gmail.com>
Dave Korn wrote:
> The code looks suggestive like maybe someone reversed the ordering of the if
> () conditions, in order that they could both share the same call to
> pep_dll_build_sections in their then clauses, requiring them to change the
> #ifdef test in the pe.em version into an #ifndef in pep.em, and then maybe
> cut-n-pastoed that "#ifndef" to wrap the "else ... pep_exe_build_sections"
> clause, but it could be entirely deliberate and correct for all I know. I
> have tested changing the second "#ifndef" in the pep.em snippet to "#ifdef",
> and that gets me a relocatable object with a .reloc section, as on plain old
> PE32, but I'm not sure yet if it's right;
Actually, I'm starting to think it's not, and that PE+ has it right. The
spec says "6.6. The .reloc Section (Image Only)", and running "objdump -p" on
the PE+-built reocatable works fine, but running the same command on the PE
targeted version produces ...
/usr/build/obj-binutils-clean/ld $ ../binutils/objdump -p tmpdir/dump.r
tmpdir/dump.r: file format pe-i386
Characteristics 0x105
relocations stripped
line numbers stripped
32 bit words
[ ... snip ... ]
PE File Base Relocations (interpreted .reloc section contents)
Virtual Address: 00000000 Chunk size 11468808 (0xaf0008) Number of fixups 5734400
reloc 0 offset 0 [ 0] ABSOLUTE
reloc 1 offset 0 [ 0] ABSOLUTE
reloc 2 offset 51 [ 51] ABSOLUTE
reloc 3 offset 0 [ 0] ABSOLUTE
reloc 4 offset 0 [ 0] ABSOLUTE
reloc 5 offset 0 [ 0] ABSOLUTE
reloc 6 offset 8 [ 8] ABSOLUTE
reloc 7 offset af [ af] ABSOLUTE
reloc 8 offset 0 [ 0] ABSOLUTE
reloc 9 offset 0 [ 0] ABSOLUTE
reloc 10 offset 41 [ 41] ABSOLUTE
reloc 11 offset 0 [ 0] ABSOLUTE
reloc 12 offset 0 [ 0] ABSOLUTE
reloc 13 offset 0 [ 0] ABSOLUTE
reloc 14 offset 0 [ 0] ABSOLUTE
reloc 15 offset 0 [ 0] ABSOLUTE
reloc 16 offset 0 [ 0] ABSOLUTE
reloc 17 offset 0 [ 0] ABSOLUTE
reloc 18 offset 0 [ 0] ABSOLUTE
reloc 19 offset 0 [ 0] ABSOLUTE
[ ... snip many many lines ... ]
reloc 60674 offset 0 [ 0] ABSOLUTE
reloc 60675 offset 0 [ 0] ABSOLUTE
reloc 60676 offset 0 [ 0] ABSOLUTE
reloc 60677 offset 0 [ 0] ABSOLUTE
reloc 60678 offset 0 [ 0] ABSOLUTE
reloc 60679 offset 0 [ 0] ABSOLUTE
reloc 60680 offset 0 [ 0] ABSOLUTE
reloc 60681 offset 0 [ 0] ABSOLUTE
reloc 60682 offset 0 [ 0] ABSOLUTE
reloc 60683 offset 0 [ 0] ABSOLUTE
reloc 60684 offset 0 [ 0] ABSOLUTE
reloc 60685 offset 0 [ 0] ABSOLUTE
reloc 60686 offset 0 [ 0] ABSOLUTE
reloc 60687 offset 0 [ 0] ABSOLUTE
1 [main] objdump 2144 _cygtls::handle_exceptions: Error while dumping
state (probably corrupted stack)
Segmentation fault (core dumped)
So, it starts to look like pe.em shouldn't be doing this for a relocatable
link, rather than that pep.em should, and like I need to adjust the
troublesome long section name tests mentioned in my other recent post to
remove the check for the presence of a .reloc section, yesnomaybe?
cheers,
DaveK