This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ATTRIBUTE_WEAK
- To: oliva at dcc dot unicamp dot br
- Subject: Re: ATTRIBUTE_WEAK
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Wed, 24 Feb 1999 23:24:15 +0100
- CC: hjl at lucon dot org, bcurrie at tssc dot co dot nz, law at cygnus dot com, egcs at egcs dot cygnus dot com
- References: <m10FlJ4-000390C@ocean.lucon.org> <or90dnfqxb.fsf@araguaia.dcc.unicamp.br>
> AFAIK, weak applies only to definitions, not to external references.
> What do you mean with a weak external reference, after all?
HJ already provided an example:
#pragma weak foo
extern void foo ();
bar (){
if (foo) foo ();
}
On i586-pc-linux-gnu, I get
bar:
...
movl $foo,%eax
testl %eax,%eax
je .L3
call foo
.L3:
...
.weak foo
I.e. a weak external does not need to be defined; if it is not
defined, it's address is 0. It's a cool feature, and I'd say not
supporting it with __attribute__ is a bug.
Regards,
Martin