public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* LIBGCC startup code: you cannot hide GetProcAddress@8 and GetModuleHandleA@4
@ 2016-02-21 12:28 Carlo Bramini
  0 siblings, 0 replies; only message in thread
From: Carlo Bramini @ 2016-02-21 12:28 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-02-21 12:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-21 12:28 LIBGCC startup code: you cannot hide GetProcAddress@8 and GetModuleHandleA@4 Carlo Bramini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).