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]

PE bug: bad DataDirectory.


I'm surprised that this has stood undetected as long as it has. It
should be killing all the various users of PE, or is something done so
they don't need the import table that I don't know about. (If a DLL ever
gets relocated, I'm sure that they won't run.)

The symptom is that all linked files (at least on Interix) won't run. (I
suspect they won't run on any of the other "on windows" packages
either, but have no proof.)   The problem is that the DataDirectory
entries for the import table are zeroed, so the program thinks it has no
import table (wreaking all sorts of havoc).

This is exhibited by, but not properly caused by:

2002-07-16  Moritz Jodeit  <moritz@jodeit.org>

        * peXXigen.c (_bfd_XXi_swap_aouthdr_out): Correct order of
memset args.

Moritz's fix is unquestionably correct, but it turns out that the memset
shouldn't be there in the first place!  (Or some deeper change needs to
be
made.)

Scenario: ldwrite calls _bfd_coff_final_link which calls
_bfd_pei_final_link_postscript. _bfd_pei_final_link_postscript fills in
the import table entries for the .idata section.

*Subsequently* main calls bfd_close calls coff_write_object_contents
calls _bfd_pei_swap_aouthdr_out.  The memset in
_bfd_pei_swap_aouthdr_out zeros out the work that
_bfd_pei_final_link_postscript did.  Oops.

The old (incorrect) code has been doing nothing for years (because it
had a zero bytecount), which may be exactly what's needed.  (That is,
the fix is to remove the memset and the associated comment.) However,
such a change feels a bit "hackish" to me, but I can't really identify
to myself as to why.  (It may be "just me", so this is a call for a
sanity check by others.)

Donn


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