This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

mingw weak linking weirdness


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?


Attachment: signature.asc
Description: OpenPGP digital signature


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