This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


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

binutils auto-import bug


With regards to the auto-imported array access bug (not the memory leak 
problem), Paul S. has returned, and submitted a patch to binutils 
mailing list to "fix" it.

I've tested it and it seems to "work", so I'm recommending application.

The reason for the quotation marks is: Paul's patch doesn't actually fix 
the bug.  It just detects the condition that *causes* the bug, prints a 
diagnostic message, and exits with error.

Thus, it refuses to silently create buggy code.  This is good.  It 
doesn't allow you to compile/linkto a DLL "just like linux shared libs" 
(because it doesn't really fix the bug; it just posts a sign saying 
"pothole here").  This is bad.

However, Paul makes a good argument that constant-offset indexing into 
an array exported by a shared lib (DLL) is really bad programming 
anyway, and should be fixed (in the client code).  However, this same 
bug bites you with exported structs (which is NOT bad programming) 
However, when porting a client/DLL to cygwin, at least you can now use a 
constant "#define" idiom for CYGWIN rather than the "if building the DLL 
.... else if linking to DLL .... else if building/linkingto a static lib 
...." gobbledygook.

#ifdef __CYGWIN__
    <type> local_array[];
    <struct_type> * local_struct;
    local_array = imported_array;
    local_struct = &imported_struct;
    <access local_array and local_struct->X  instead of imported_array 
and imported_struct.X (note the '->' vs. '.')>
#else
...
#fi

(Actually, the __CYGWIN__ code is not that terrible, you *could* use it 
for all platforms...Many projects have been willing to completely remove 
data exports from their shared libs in favor of set_ and get_ functional 
interfaces, in order to allow mingw builds to work.  This sort of change 
presented above is minor compared to that, and may be acceptable to a 
lot of projects.)

This is meant as a heads up; for more info check out the thread on the 
binutils list.

--Chuck


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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