From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30406 invoked by alias); 28 Mar 2005 01:58:00 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 29760 invoked from network); 28 Mar 2005 01:57:56 -0000 Received: from unknown (205.217.158.180) by sourceware.org with QMTP; 28 Mar 2005 01:57:56 -0000 Received: (qmail 19860 invoked by uid 10); 28 Mar 2005 01:57:55 -0000 Received: (qmail 27838 invoked by uid 500); 28 Mar 2005 01:57:46 -0000 Mail-Followup-To: binutils@sources.redhat.com, bahadir.balban@gmail.com To: Bahadir Balban Cc: binutils@sources.redhat.com Subject: Re: what are weak external symbols? References: <7ac1e90c0503261346244d052f@mail.gmail.com> From: Ian Lance Taylor Date: Mon, 28 Mar 2005 14:19:00 -0000 In-Reply-To: <7ac1e90c0503261346244d052f@mail.gmail.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2005-03/txt/msg00811.txt.bz2 Bahadir Balban writes: > In summary it says that weak external symbols is a concept to avoid > linking with unused parts of a library. The printf example is given: > floating-point routines (namely fcvt) are referred as weak references > by printf, such that when printf is used in a routine that didn't use > fcvt, reference to fcvt resolves to zero and no error is produced from > this. > > Now the questions: > > 1) Is my summary above correct? Pretty much. Instead of "a routine that didn't use fcvt" I would say "a program that didn't use fcvt." > 2) Is this a case such that, these fcvt routines are explicitly > defined in printf as weak references? If so, how do you define it as > such in C source? Or perhaps you use a linker flag when you create the > library? Search for weak here: http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Function-Attributes.html#Function-Attributes Other compilers have other mechanisms. Ian