X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:reply-to:to:subject
	:mime-version:content-type:content-transfer-encoding; q=dns; s=
	default; b=WAnN15l1g6BBfjbfLXDOhIWyIKnUG0CiKeX6v4dIKLyo/XKiQpszt
	c6L63VkE98nIxSozzma4TriXqbMf+1+0WnnpXLAcJT2OdfXD9eOBjt2+anZQ8Qql
	4F8LwJxT2jf6uaxarMilcdM8A+BqGFvzb9ylljuxhdq5UZotaY0ADc=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:reply-to:to:subject
	:mime-version:content-type:content-transfer-encoding; s=default;
	 bh=+bkiqWNM6LQfldSICnD4zD6DtjA=; b=q5fnhygrrWsrx1eyvsh7KAd35XEz
	lFam499EY6Skuljr+CAx7zUqX+H85eZmSzjshjOGKbmctf8u232UfYi5bPBg6Y/6
	P89XMoygPWr//fFGVOI6eK3Y7hDkqMT9MwYb5DAtkmf0RjuIx3QxVmLZl1WdrCpx
	N9kdARsFqLQAzsk=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=BAYES_50,FREEMAIL_FROM,LIBERO,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 spammy=H*R:D*it, H*MI:webmail, H*M:webmail, 0xc
X-HELO: libero.it
x-libjamoibt: 1601
X-CNFS-Analysis: v=2.1 cv=Ift6Ijea c=1 sm=1 tr=0 a=Rrm7V8oFhlmwWN/lK0VnQA==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=v-ufWWweVTUA:10 a=TUsnnyyE6y8A:10 a=w4O9Kvv5L38A:10 a=IkcTkHD0fZMA:10 a=yEKcN0wXg9gsks4NTVoA:9 a=QEXdDO2ut3YA:10
Message-ID: <2137976859.11219481456057694503.JavaMail.httpd@webmail-48.iol.local>
Date: Sun, 21 Feb 2016 13:28:14 +0100 (CET)
From: Carlo Bramini <carlo.bramix@libero.it>
Reply-To: Carlo Bramini <carlo.bramix@libero.it>
To: cygwin@cygwin.com
Subject: LIBGCC startup code: you cannot hide GetProcAddress@8 and GetModuleHandleA@4
MIME-Version: 1.0
Content-Type: text/plain;charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-SenderIP: 82.52.0.186
X-libjamv: AZBK2vFYPmc=
X-libjamsun: hRTD/hvPsLqjyzNu3kSt5j86Vn+JIF6A

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

