This is the mail archive of the cygwin 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]
Other format: [Raw text]

LIBGCC startup code: you cannot hide GetProcAddress at 8 and GetModuleHandleA at 4

Let's assume to have this simple C source code:

void * __stdcall GetProcAddress( int hModule, char * function )
    return 0;

void * __stdcall GetModuleHandleA( char * Module )
    return 0;

int main()
    return 0;

if you try to compile it, you will get:

/usr/lib/w32api/libkernel32.a(deijs00581.o):(.text+0x0): multiple definition 
of `GetProcAddress@8'
/tmp/ccMGY4R3.o:t.c:(.text+0x0): first defined here
/usr/lib/w32api/libkernel32.a(deijs00533.o):(.text+0x0): multiple definition 
of `GetModuleHandleA@4'
/tmp/ccMGY4R3.o:t.c:(.text+0xc): first defined here
collect2: error: ld returned 1 exit status

In my opinion, it is a bug or, if you prefer, a limitation in the startup 
I think that this happens because gcc/config/i386/cygming-crtbegin.c always 
uses GetProcAddress() and GetModuleHandleA() API, even when you feed -static 
option at command line.
I understand that there are not too much ways for importing stuff from 
cyggcc_s-1.dll, but I think this limitation could be also overcome in a simple 
Perhaps, besides crtbegin.o and crtbeginS.o, CYGWIN toolchain should also 
allow use crtbeginT.o (it seems to me that it is actually missing), for having 
the real static linking when you provide "-static" on the command line. The 
source file with an additional #ifdef...#endif will just call 
__register_frame_info, _Jv_RegisterClasses and __deregister_frame_info 
functions without much worries.

I'm using:
gcc version 5.3.0 (GCC)
but it also happens with GCC4


Carlo Bramini.

Problem reports:
Unsubscribe info:

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