From mboxrd@z Thu Jan 1 00:00:00 1970 From: DJ Delorie To: cwilson@ece.gatech.edu Cc: binutils@sources.redhat.com, cygwin@cygwin.com Subject: Re: [aida_s@mx12.freecom.ne.jp: A serious bug of "ld --enable-auto-import"] Date: Sat, 25 Aug 2001 23:14:00 -0000 Message-id: <200108260613.CAA28557@envy.delorie.com> References: <3B8884F6.80708@ece.gatech.edu> <200108260530.BAA28221@envy.delorie.com> <3B888D76.6090102@ece.gatech.edu> X-SW-Source: 2001-08/msg00599.html > Anyway, I'm confused. The .o file already contains the "12" (actually, > 0c 00 00 00 in on-disk byte order), so gas has already done its work -- > properly. The problem occurs during the linking step -- ld is ignoring > the offset stored within the opcode and is blindly stuffing in the > relocation address without adding the offset. Ok, a couple of things: In make_import_fixup in ld/emultempl/pe.em, it uses rel->addend without also checking for the inline offset. For formats that use an inline addend, rel->addend may be zero. Addends are very tricky in PE. There's lots of comments about adding, subtracting, adding, subtracting, etc, in various places in the code. I don't think an import library *can* specify an offset to be added at runtime. From my understanding of the dll import/export system, windows simply places the address of the thing being imported in the location indicated.