Subject: Re: CVS commit: src/lib/csu/i386_elf
To: Christos Zoulas <christos@zoulas.com>
From: Jason Thorpe <thorpej@shagadelic.org>
List: source-changes
Date: 05/17/2006 13:30:29
On May 17, 2006, at 1:12 PM, Christos Zoulas wrote:

> You need to __attribute__((__weakref__)) all such symbols, and then it
> works again :-)

I would suggest the following, then:

Define a new macro in cdefs_elf.h:

#if __GNUC_PREREQ__(4, 0)	/* or whatever version __weakref__ first  
appeared */
#define	__weak_reference	__attribute__((__weakref__))
#define	__weak_extern(sym)	/* nothing - deprecated - will remove in  
NetBSD 5.0 */
#else
#define	__weak_reference	/* nothing */
#define	__weak_extern(sym)	__asm(".weak " _C_LABEL_STRING(#sym));
#endif


Find all the places that use __weak_extern().  Change them from:

extern int _DYNAMIC;
__weak_extern(_DYNAMIC);

to:

extern int _DYNAMIC __weak_reference;
#ifdef __weak_extern
__weak_extern(_DYNAMIC);
#endif

...so that code can continue to build with the old compiler for one  
more cycle and continue to build without the compatibility definition  
after 5.0.

(I'm assuming that __weakref__ will take care of doing the ".weak  
sym" dance in the assembly code for you...)

-- thorpej