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]

Re: Serious bug in auto-import


Hello Charles,

Charles Wilson wrote on Tuesday, August 28, 2001:

CW> Paul,

CW> Please take a look at the thread "[aida_s@mx12.freecom.ne.jp: A serious
CW> bug of "ld --enable-auto-import"]" starting here:

CW> http://sources.redhat.com/ml/binutils/2001-08/msg00595.html

CW> This is a confirmed bug.  I've tried to analyze it but I can't really
CW> come up with a fix; I wonder if a fix is possible at all.  If this
CW> problem can't be fixed, I'm going to have to recommend removing the
CW> auto-import stuff. (Yes, it's that serious.)

CW> PLEASE take a look and at least let me know you've seen it; it was
CW> originally reported early Friday morning to the cygwin-apps list, and
CW> moved to the binutils list on Saturday.

    I'm sorry, I was on vacation abroad.

    Yes, the weird stuff. Of course, I though about the issue when
started to work on auto-import, but my reasoning was misgone along the
lines which were evident in this thread too: I confused *relocs* and
*import thunks*. The former support addends, the latter - no. Well, I
never bothered to check issue afterwards.

     How disabling such a misfeature can be? Well, my opinion is that
sample code far-fetched and presents, err, bad software design. The
only sane usage of accessing external array with constant indexes I
can imagine is something like

          extern double world_transform_matrix[3][3];
          ...

     I doubt much code uses such a horror, so losing ability to auto-import
contant-offset array for me is not a big loss. Much more pitiful fact
is that it also applies to accessing global extern struct's - I bet
periodically code which does that will be hit. Well, nothing comes for
free.

     Actions to be taken: well, I don't think it's productive idea,
having hit some particular difficulty, give up entirely thing which
otherwise works well. Imho, the better idea is to make quick surgery
to localize the problem. That's exactly what attached patch does:

====
#include <stdio.h>
extern struct
{
  int a;
  int b;
} st;

int main(void){
        printf("%d\n", st.b);
        printf("%d\n", st.a);
}
====

gcc -s -Wl,--enable-auto-import -o hello.exe hello.o -L. -lhwstr
Warning: resolving _st by linking to __imp__st (auto-import)
hello.o(.text+0x13):hello.c: aggregate 'st' is referenced in direct addressing m
ode with constant offset - auto-import failed. Workarounds: a) mark the symbol w
ith __declspec(dllimport); b) use auxiliary variable
make: *** [hello.exe] Hangup


CW> --Chuck


--
Paul Sokolovsky, IT Specialist
http://www.brainbench.com/transcript.jsp?pid=11135

ld.diff.20010909

ChangeLog.20010909


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