This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: what are weak external symbols?
- From: Ian Lance Taylor <ian at airs dot com>
- To: Bahadir Balban <bahadir dot balban at gmail dot com>
- Cc: binutils at sources dot redhat dot com
- Date: 27 Mar 2005 20:57:46 -0500
- Subject: Re: what are weak external symbols?
- References: <7ac1e90c0503261346244d052f@mail.gmail.com>
Bahadir Balban <bahadir.balban@gmail.com> 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