This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ATTRIBUTE_WEAK


> >
> >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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]