public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Charles S. Wilson" <cwilson@ece.gatech.edu>
To: binutils@sources.redhat.com
Cc: cygwin@cygwin.com
Subject: Re: [aida_s@mx12.freecom.ne.jp: A serious bug of "ld --enable-auto-import"]
Date: Sat, 25 Aug 2001 22:11:00 -0000	[thread overview]
Message-ID: <3B8884F6.80708@ece.gatech.edu> (raw)

Confirmed bug.  (using the same example posted in the original report) 
the auto-import stuff is ignoring the "+12" in this asm statement:

movb $33,_hwstr1+12

The .o file (disassembled) shows:

hello.o:     file format pe-i386
Disassembly of section .text:
00000000 <_main>:
    0:   55                      push   %ebp
    1:   89 e5                   mov    %esp,%ebp
    3:   83 ec 18                sub    $0x18,%esp
    6:   e8 00 00 00 00          call   b <_main+0xb>
    b:   c6 05 0c 00 00 00 21    movb   $0x21,0xc
   12:   c7 45 fc 00 00 00 00    movl   $0x0,0xfffffffc(%ebp)
   19:   8b 45 fc                mov    0xfffffffc(%ebp),%eax
   1c:   83 c0 0a                add    $0xa,%eax
   1f:   c6 00 21                movb   $0x21,(%eax)
   22:   83 c4 f4                add    $0xfffffff4,%esp
   25:   68 00 00 00 00          push   $0x0
   2a:   e8 00 00 00 00          call   2f <_main+0x2f>
   2f:   83 c4 10                add    $0x10,%esp
   32:   83 c4 f4                add    $0xfffffff4,%esp
   35:   68 00 00 00 00          push   $0x0
   3a:   e8 00 00 00 00          call   3f <_main+0x3f>
   3f:   83 c4 10                add    $0x10,%esp
   42:   31 c0                   xor    %eax,%eax
   44:   eb 02                   jmp    48 <_main+0x48>
   46:   89 f6                   mov    %esi,%esi
   48:   89 ec                   mov    %ebp,%esp
   4a:   5d                      pop    %ebp
   4b:   c3                      ret

And the .relocs section of hello.o sez:

hello.o:     file format pe-i386
RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE              VALUE
00000007 DISP32            ___main
0000000d dir32             _hwstr1
00000015 dir32             _hwstr2
00000026 dir32             _hwstr1
0000002b DISP32            _puts
00000036 dir32             _hwstr2
0000003b DISP32            _puts

RELOCATION RECORDS FOR [.stab]:
OFFSET   TYPE              VALUE
00000014 dir32             .text
00000020 dir32             .text
00000590 dir32             .text
00000644 dir32             .text

------------------------------------

so, what *should* happen is that in hello.o at offset 0x00d, the address 
of _hwstr1  should be added to the current contents of 0x00d--0x010 (0c 
00 00 00).  What currently happens is that 0x00d--0x010 is simply 
replaced by the address of _hwstr1 and the 0000000c is just thrown away.

Using --enable-extra-pe-debug when linking, I see this output (format is 
<symbol>@<offset>: add=< arelent->addend >)

pe_find_data_imports:_hwstr1
->__head_cyghwstr_dll
arelent: _hwstr1@0xd: add=0  <<<< this should be "add=12", right?
arelent: _hwstr1@0x26: add=0
pe_find_data_imports:_hwstr2
->__head_cyghwstr_dll
arelent: _hwstr2@0x15: add=0
arelent: _hwstr2@0x36: add=0

Unfortunately, that's as far as I can go.  I don't know where the 
arelent structure gets filled with the approprate data from the .o, so I 
can't track down WHY the "12" isn't going into (arelent)->addend.

Can anyone else shed some light, here?

--Chuck

             reply	other threads:[~2001-08-25 22:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-25 22:11 Charles S. Wilson [this message]
2001-08-25 22:30 ` DJ Delorie
2001-08-25 22:47   ` Charles Wilson
2001-08-25 23:14     ` DJ Delorie
2001-08-26  8:10       ` Charles Wilson
2001-08-26  8:43         ` DJ Delorie
2001-08-26  9:04           ` Charles Wilson
2001-08-26  9:43             ` DJ Delorie
2001-08-26 15:35               ` Charles Wilson
2001-08-26 12:27             ` Kurt Roeckx
  -- strict thread matches above, loose matches on Subject: below --
2001-08-25 10:50 Christopher Faylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B8884F6.80708@ece.gatech.edu \
    --to=cwilson@ece.gatech.edu \
    --cc=binutils@sources.redhat.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).