This is the mail archive of the
cygwin
mailing list for the Cygwin project.
LIBGCC startup code: you cannot hide GetProcAddress at 8 and GetModuleHandleA at 4
- From: Carlo Bramini <carlo dot bramix at libero dot it>
- To: cygwin at cygwin dot com
- Date: Sun, 21 Feb 2016 13:28:14 +0100 (CET)
- Subject: LIBGCC startup code: you cannot hide GetProcAddress at 8 and GetModuleHandleA at 4
- Authentication-results: sourceware.org; auth=none
- Reply-to: Carlo Bramini <carlo dot bramix at libero dot it>
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
code.
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
way.
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
Sincerely,
Carlo Bramini.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple