This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: objdump prints PE relocations with --private-headers, not --reloc


Pavel Roskin <proski@gnu.org> writes:

> As you can see, use of --emit-reloc affects the output of "objdump -r",
> but not "objdump -R".

Well, yes.  I think the relocations emitted using the --emit-reloc
option should be dumped by objdump -r.  That is because those relocs
have the format of those handled by the program linker, not the
dynamic linker.

Note that the GNU binutils do not support --emit-reloc for the PE
format.  --emit-relocs only works for ELF.

> 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:

How is the .reloc section generated when it is present?

I'm not surprised that objdump -R doesn't print it.  I just think that
if it is printed, it should be printed by objdump -R, not objdump -r.

> > 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".

Even without --emit-reloc, the ELF format will put relocations in the
executable if any shared libraries are involved in the link.  For ELF,
those relocations are very similar but not identical to the
relocations used in object files.  objdump -R dumps these dynamic
relocations.

The --emit-reloc option tells the linker to leave the ordinary
relocations in the executable as well.  This information is not used
by the dynamic linker, but may be used by tools which optimize the
resulting 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.

You're right, there is no logic there.  If you want to implement
--emit-reloc for PE, then I think it should produce relocations which
have the same format as relocations in an object file.  That is, they
should be referenced by s_relptr and s_nreloc fields of a section
header.  I don't think they should be in a .reloc section.  I don't
know how .reloc sections are normally generated in PE, but I doubt it
is through anything like the --emit-reloc option for ELF.  Anyhow, if
you implement --emit-reloc for PE, and you do as I suggest and emit
the relocations using s_relptr and s_nreloc, then I agree that those
relocations should be dumped by objdump -r.

If the .reloc section normally appears in PE executables, however it
is created, then I think those relocations should be dumped by objdump
-R.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]