* what are weak external symbols?
@ 2005-03-28 2:08 Bahadir Balban
2005-03-28 14:19 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Bahadir Balban @ 2005-03-28 2:08 UTC (permalink / raw)
To: binutils
Hi,
I'm reading the book "Linkers and Loaders" and weak external symbols
are not so clearly explained (for me at least).
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?
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?
I thought this question best fits the binutils list, sorry if I'm off-topic.
Many thanks,
Bahadir
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: what are weak external symbols?
2005-03-28 2:08 what are weak external symbols? Bahadir Balban
@ 2005-03-28 14:19 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2005-03-28 14:19 UTC (permalink / raw)
To: Bahadir Balban; +Cc: binutils
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-03-28 1:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-28 2:08 what are weak external symbols? Bahadir Balban
2005-03-28 14:19 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).