This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ATTRIBUTE_WEAK
- To: Franz dot Sirl-kernel at lauterbach dot com (Franz Sirl)
- Subject: Re: ATTRIBUTE_WEAK
- From: hjl at lucon dot org (H.J. Lu)
- Date: Wed, 24 Feb 1999 15:23:20 -0800 (PST)
- Cc: law at cygnus dot com, egcs at egcs dot cygnus dot com
> >
> >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.
>
> This is what glibc-2.1 uses:
>
> # ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
> # define weak_extern_asm(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
> # define weak_alias_asm(original, alias) \
> asm (".weakext " __SYMBOL_PREFIX #alias ", " __SYMBOL_PREFIX #original);
> # else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
> # define weak_extern_asm(symbol) asm (".weak " __SYMBOL_PREFIX #symbol);
> # define weak_alias_asm(original, alias) \
> asm (".weak " __SYMBOL_PREFIX #alias "\n" \
> __SYMBOL_PREFIX #alias " = " __SYMBOL_PREFIX #original);
> # endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
>
> # define weak_alias(o, a) weak_alias_asm (o, a)
> # define weak_extern(symbol) weak_extern_asm (symbol)
>
>
IMHO, it is no better than
#pragma weak foo
I am looking for an attribute solution.
--
H.J. Lu (hjl@gnu.org)