X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9xTKL3R4OlBCAU6/lWb5 X-RZG-CLASS-ID: mo00 From: Bruno Haible To: Eric Blake , Dave Korn , cygwin AT cygwin DOT com Subject: Re: weak symbols on Cygwin Date: Wed, 7 Apr 2010 01:41:35 +0200 User-Agent: KMail/1.9.9 References: <4BBB31C6 DOT 7080703 AT redhat DOT com> In-Reply-To: <4BBB31C6.7080703@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201004070141.36284.bruno@clisp.org> Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hi Dave, Dave Korn wrote: > >> These were all due to the fact that gcc 4.3.x on Cygwin 1.7.2 > >> accepts "#pragma weak foo", but the symbol foo then evaluates > >> to the NULL address, even if foo is defined in libc. > > > > Dave, are weak symbols something that should work on cygwin with new > > enough binutils/gcc? Or is this an indicator of a gcc bug, for silently > > accepting #pragma weak foo that it can't support? > > Weak symbols work on Cygwin, but the semantics of undefined weak symbols > aren't identical to ELF platforms: a weak reference won't pull in an archive > member that wouldn't otherwise be linked; the implications in relation to > import libraries should be fairly obvious. I don't know what semantics is implemented by "#pragma weak" on Cygwin. On ELF platforms, I use "#pragma weak" in order to detect whether a symbol is defined in the libraries which are linked in with the executable (including libc). This does not work on Cygwin: this program ====================================================== #include extern void gurky (void); #pragma weak fputs #pragma weak gurky int main () { printf ("fputs %s, gurky %s\n", fputs != NULL ? "present" : "missing", gurky != NULL ? "present" : "missing"); return 0; } ====================================================== compiled and run with $ gcc -o foo foo.c -Wall $ ./foo prints on glibc systems: fputs present, gurky missing but on Cygwin 1.7.2: fputs missing, gurky missing With this inability to distinguish present from missing libc symbols, "#pragma weak" is useless to me on Cygwin. Bruno -- 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