delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/04/07/12:44:59

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <4BBCBADA.2090504@gmail.com>
Date: Wed, 07 Apr 2010 18:03:22 +0100
From: Dave Korn <dave DOT korn DOT cygwin AT googlemail DOT com>
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: weak symbols on Cygwin
References: <4BBB31C6 DOT 7080703 AT redhat DOT com> <201004070141 DOT 36284 DOT bruno AT clisp DOT org> <4BBBF5C2 DOT 30102 AT gmail DOT com> <201004071106 DOT 11471 DOT bruno AT clisp DOT org>
In-Reply-To: <201004071106.11471.bruno@clisp.org>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 07/04/2010 10:06, Bruno Haible wrote:

> Thanks for these explanations. So, "#pragma weak" is very different on PE 
> systems than on ELF systems.

  Well, to be pedantically precise, "#pragma weak" is basically the same: it
shuts the linker up from complaining about a symbol if no definition is
provided at link time.  But it has downstream (from the linker) consequences
owing to the linker on PE being obliged to resolve everything and the linker
on ELF not having to.

> I was implicitly hoping that - gcc would collect all weak-declared symbols
> in some table, and generate code so that the reference to these symbols
> makes an indirection through this table, - the Cygwin runtime would call
> dlsym or GetProcAddress at startup and fill in addresses into said table.

  This is basically what the static linker (ld) and runtime loader (ld.so)
co-operate to achieve on ELF.  It is very likely possible to support something
like that on Cygwin, but it'd take some work to implement.

> I've got some code, written for ELF platforms, that detects whether the
> pthread library (often a separate library from libc) is linked, by doing
> 
> #pragma weak pthread_cancel bool pthread_in_use = (pthread_cancel != NULL);

  And you really need to determine this dynamically at runtime rather than
statically at configure time?  Fair enough; in that case I think Chuck's
suggestion that you use configure to choose between the runtime check on ELF
platforms and a statically-configured runtime-constant value on PE platforms
is probably the best solution.

    cheers,
      DaveK



--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019