This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ATTRIBUTE_WEAK
- To: hjl at lucon dot org (H.J. Lu)
- Subject: Re: ATTRIBUTE_WEAK
- From: Jeffrey A Law <law at hurl dot cygnus dot com>
- Date: Wed, 24 Feb 1999 23:33:23 -0700
- cc: egcs at egcs dot cygnus dot com
- Reply-To: law at cygnus dot com
In message <m10Fie3-000390C@ocean.lucon.org>you write:
> Could you please show me how to use __attribute__ ((weak))? The code
> below doesn't make "foo" weak. BTW,
>
[ ... ]
> --
> H.J. Lu (hjl@gnu.org)
> ---
> extern void foo () __attribute__ ((weak));
>
> bar ()
> {
> if (foo) foo ();
> }
This is the right way to get a weak declaration. It didn't work because of
a trivial bug. I've fixed that bug on the release branch (and will fix it
shortly in the mainline tree).
With the fix I get:
.file "foo.c"
.version "01.01"
gcc2_compiled.:
.text
.align 4
.globl bar
.type bar,@function
bar:
pushl %ebp
movl %esp,%ebp
movl $foo,%eax
testl %eax,%eax
je .L2
call foo
.L2:
movl %ebp,%esp
popl %ebp
ret
.Lfe1:
.size bar,.Lfe1-bar
.weak foo
Which is the same code I get if I use a #pragma instead.
jeff