mingw weak linking weirdness
JonY
jon_y@users.sourceforge.net
Sat Nov 26 12:21:00 GMT 2011
Hi,
I found some strange behavior in the inter-module linking, linking
passes, but the symbol address is bound to 0x0 at runtime. Here are some
example codes:
----- a.c -----
int a() __attribute__((weak));
int a(){return 1;}
----- a.c -----
----- b.c -----
#include <stdio.h>
int a() __attribute__((weak));
int main(){
printf("%d\n",a());
return 0;
}
----- b.c -----
Linking with "gcc b.o a.o" causes the program to crash with a call to
0x0. However "gcc a.o b.o" linking works fine. Experience shows that the
former is the correct way to link since module b depends on a.
Strangely, trying it for x86_64-w64-mingw32 target works perfectly,
problem is only for the 32bit mingw32 target.
Tested with binutils 2.22.51.20111125. Any ideas?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20111126/7b780d56/attachment.sig>
More information about the Binutils
mailing list