tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Weak reference interface
Hi all,
attached patch unifies the handled for __weak_reference to make it
compatible with both older and newer GCC versions as well as clang.
Please give it some testing.
Joerg
Index: crypto/external/bsd/libsaslc/dist/src/mech.c
===================================================================
RCS file:
/home/joerg/repo/netbsd/src/crypto/external/bsd/libsaslc/dist/src/mech.c,v
retrieving revision 1.6
diff -u -p -r1.6 mech.c
--- crypto/external/bsd/libsaslc/dist/src/mech.c 14 Feb 2011 12:45:31
-0000 1.6
+++ crypto/external/bsd/libsaslc/dist/src/mech.c 20 Feb 2011 22:10:52
-0000
@@ -51,29 +51,29 @@ __RCSID("$NetBSD: mech.c,v 1.6 2011/02/1
#include "saslc_private.h"
/* mechanisms */
-extern const saslc__mech_t saslc__mech_anonymous
+__weakref_visible const saslc__mech_t weak_saslc__mech_anonymous
__weak_reference(saslc__mech_anonymous);
-extern const saslc__mech_t saslc__mech_crammd5
+__weakref_visible const saslc__mech_t weak_saslc__mech_crammd5
__weak_reference(saslc__mech_crammd5);
-extern const saslc__mech_t saslc__mech_digestmd5
+__weakref_visible const saslc__mech_t weak_saslc__mech_digestmd5
__weak_reference(saslc__mech_digestmd5);
-extern const saslc__mech_t saslc__mech_external
+__weakref_visible const saslc__mech_t weak_saslc__mech_external
__weak_reference(saslc__mech_external);
-extern const saslc__mech_t saslc__mech_gssapi
+__weakref_visible const saslc__mech_t weak_saslc__mech_gssapi
__weak_reference(saslc__mech_gssapi);
-extern const saslc__mech_t saslc__mech_login
+__weakref_visible const saslc__mech_t weak_saslc__mech_login
__weak_reference(saslc__mech_login);
-extern const saslc__mech_t saslc__mech_plain
+__weakref_visible const saslc__mech_t weak_saslc__mech_plain
__weak_reference(saslc__mech_plain);
static const saslc__mech_t *saslc__mechanisms[] = {
- &saslc__mech_anonymous,
- &saslc__mech_crammd5,
- &saslc__mech_digestmd5,
- &saslc__mech_external,
- &saslc__mech_gssapi,
- &saslc__mech_login,
- &saslc__mech_plain,
+ &weak_saslc__mech_anonymous,
+ &weak_saslc__mech_crammd5,
+ &weak_saslc__mech_digestmd5,
+ &weak_saslc__mech_external,
+ &weak_saslc__mech_gssapi,
+ &weak_saslc__mech_login,
+ &weak_saslc__mech_plain,
};
/*
Index: lib/csu/alpha/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/alpha/crt0.c,v
retrieving revision 1.24
diff -u -p -r1.24 crt0.c
--- lib/csu/alpha/crt0.c 26 Jul 2003 19:24:25 -0000 1.24
+++ lib/csu/alpha/crt0.c 20 Feb 2011 06:08:08 -0000
@@ -65,7 +65,7 @@ __start(sp, cleanup, obj, ps_strings)
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
Index: lib/csu/arm_elf/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/arm_elf/crt0.c,v
retrieving revision 1.7
diff -u -p -r1.7 crt0.c
--- lib/csu/arm_elf/crt0.c 21 Jun 2008 00:52:52 -0000 1.7
+++ lib/csu/arm_elf/crt0.c 20 Feb 2011 06:08:17 -0000
@@ -89,7 +89,7 @@ ___start(int argc, char **argv, char **e
#ifdef DYNAMIC
/* ld(1) convention: if DYNAMIC = 0 then statically linked */
- if (&_DYNAMIC)
+ if (&rtld_DYNAMIC)
_rtld_setup(cleanup, obj);
#endif /* DYNAMIC */
Index: lib/csu/common/crt0-common.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/common/crt0-common.c,v
retrieving revision 1.3
diff -u -p -r1.3 crt0-common.c
--- lib/csu/common/crt0-common.c 18 Feb 2011 23:37:36 -0000 1.3
+++ lib/csu/common/crt0-common.c 20 Feb 2011 22:01:54 -0000
@@ -58,13 +58,7 @@ extern void _fini(void);
* shared libs present, things will still work.
*/
-#if __GNUC_PREREQ__(4,2)
-static int rtld_DYNAMIC __attribute__((__weakref__, __alias__("_DYNAMIC")));
-#define DYNAMIC_SYM rtld_DYNAMIC
-#else
-extern int _DYNAMIC __weak_reference(_DYNAMIC);
-#define DYNAMIC_SYM _DYNAMIC
-#endif
+__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
#ifdef MCRT0
extern void monstartup(u_long, u_long);
@@ -111,7 +105,7 @@ ___start(int argc, char **argv, char **e
if (ps_strings != NULL)
__ps_strings = ps_strings;
- if (&DYNAMIC_SYM != NULL) {
+ if (&rtld_DYNAMIC != NULL) {
if (obj == NULL)
_FATAL("NULL Obj_Entry pointer in GOT\n");
if (obj->magic != RTLD_MAGIC)
Index: lib/csu/common_elf/common.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/common_elf/common.h,v
retrieving revision 1.13
diff -u -p -r1.13 common.h
--- lib/csu/common_elf/common.h 14 Dec 2009 01:04:02 -0000 1.13
+++ lib/csu/common_elf/common.h 20 Feb 2011 22:01:57 -0000
@@ -81,7 +81,7 @@ void _rtld_setup(void (*)(void), const O
* if we happen to be compiling without -static but with without any
* shared libs present, things will still work.
*/
-extern int _DYNAMIC __weak_reference(_DYNAMIC);
+__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
#endif /* DYNAMIC */
#ifdef MCRT0
Index: lib/csu/hppa/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/hppa/crt0.c,v
retrieving revision 1.7
diff -u -p -r1.7 crt0.c
--- lib/csu/hppa/crt0.c 26 Aug 2004 21:07:14 -0000 1.7
+++ lib/csu/hppa/crt0.c 20 Feb 2011 06:08:36 -0000
@@ -110,7 +110,7 @@ ___start(struct ps_strings *ps_strings,
* For now, we take the easy way out and compare &_DYNAMIC
* to %dp, as well as to NULL.
*/
- if (&_DYNAMIC != NULL && (int)&_DYNAMIC != dp)
+ if (&rtld_DYNAMIC != NULL && (int)&rtld_DYNAMIC != dp)
_rtld_setup(cleanup, obj);
#endif
Index: lib/csu/ia64/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/ia64/crt0.c,v
retrieving revision 1.2
diff -u -p -r1.2 crt0.c
--- lib/csu/ia64/crt0.c 15 Sep 2006 05:29:44 -0000 1.2
+++ lib/csu/ia64/crt0.c 20 Feb 2011 06:08:42 -0000
@@ -72,7 +72,7 @@ __start(char **sp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
Index: lib/csu/m68k_elf/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/m68k_elf/crt0.c,v
retrieving revision 1.11
diff -u -p -r1.11 crt0.c
--- lib/csu/m68k_elf/crt0.c 26 Aug 2004 21:09:52 -0000 1.11
+++ lib/csu/m68k_elf/crt0.c 20 Feb 2011 06:08:45 -0000
@@ -75,7 +75,7 @@ __start(int argc, char **argv, char **en
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
Index: lib/csu/mips/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/mips/crt0.c,v
retrieving revision 1.21
diff -u -p -r1.21 crt0.c
--- lib/csu/mips/crt0.c 23 Jan 2011 06:25:57 -0000 1.21
+++ lib/csu/mips/crt0.c 20 Feb 2011 06:08:48 -0000
@@ -142,7 +142,7 @@ __start(uintptr_t sp,
* XXX If we were loaded by that loader, just abort
* XXX the rtld setup.
*/
- if (&_DYNAMIC != NULL && cleanup != NULL && obj != NULL)
+ if (&rtld_DYNAMIC != NULL && cleanup != NULL && obj != NULL)
_rtld_setup(cleanup, obj);
#endif
}
Index: lib/csu/powerpc/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/powerpc/crt0.c,v
retrieving revision 1.26
diff -u -p -r1.26 crt0.c
--- lib/csu/powerpc/crt0.c 18 May 2006 17:54:19 -0000 1.26
+++ lib/csu/powerpc/crt0.c 20 Feb 2011 22:02:00 -0000
@@ -41,8 +41,8 @@
* Small Data Area designators. If not defined, will show up as being
* at address zero.
*/
-extern int _SDA_BASE_[] __weak_reference(_SDA_BASE_);
-extern int _SDA2_BASE_[] __weak_reference(_SDA2_BASE_);
+__weakref_visible int rtld_SDA_BASE_[] __weak_reference(_SDA_BASE_);
+__weakref_visible int rtld_SDA2_BASE_[] __weak_reference(_SDA2_BASE_);
/*
* First 5 arguments are specified by the PowerPC SVR4 ABI. The
@@ -64,10 +64,10 @@ _start(int argc, char **argv, char **env
* _SDA_BASE is defined in the SVR4 ABI for PPC.
* _SDA2_BASE is defined in the E[mbedded] ABI for PPC.
*/
- __asm( "lis %r13,_SDA_BASE_@ha;"
- "addi %r13,%r13,_SDA_BASE_@l;"
- "lis %r2,_SDA2_BASE_@ha;"
- "addi %r2,%r2,_SDA2_BASE_@l" );
+ __asm( "lis %r13,rtld_SDA_BASE_@ha;"
+ "addi %r13,%r13,rtld_SDA_BASE_@l;"
+ "lis %r2,rtld_SDA2_BASE_@ha;"
+ "addi %r2,%r2,rtld_SDA2_BASE_@l" );
if ((namep = argv[0]) != NULL) { /* NULL ptr if argc = 0 */
if ((__progname = _strrchr(namep, '/')) == NULL)
@@ -82,7 +82,7 @@ _start(int argc, char **argv, char **env
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
Index: lib/csu/powerpc64/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/powerpc64/crt0.c,v
retrieving revision 1.2
diff -u -p -r1.2 crt0.c
--- lib/csu/powerpc64/crt0.c 1 Jul 2006 01:39:17 -0000 1.2
+++ lib/csu/powerpc64/crt0.c 20 Feb 2011 06:09:00 -0000
@@ -74,7 +74,7 @@ _start(int argc, char **argv, char **env
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
Index: lib/csu/sh3_elf/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/sh3_elf/crt0.c,v
retrieving revision 1.10
diff -u -p -r1.10 crt0.c
--- lib/csu/sh3_elf/crt0.c 26 Aug 2004 21:16:41 -0000 1.10
+++ lib/csu/sh3_elf/crt0.c 20 Feb 2011 06:09:04 -0000
@@ -69,7 +69,7 @@ ___start(int argc, char **argv, char **e
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
Index: lib/csu/sparc64/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/sparc64/crt0.c,v
retrieving revision 1.24
diff -u -p -r1.24 crt0.c
--- lib/csu/sparc64/crt0.c 24 Dec 2005 21:38:40 -0000 1.24
+++ lib/csu/sparc64/crt0.c 20 Feb 2011 06:09:09 -0000
@@ -94,7 +94,7 @@ ___start(char **sp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
Index: lib/csu/sparc_elf/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/sparc_elf/crt0.c,v
retrieving revision 1.12
diff -u -p -r1.12 crt0.c
--- lib/csu/sparc_elf/crt0.c 26 Aug 2004 21:18:36 -0000 1.12
+++ lib/csu/sparc_elf/crt0.c 20 Feb 2011 06:09:12 -0000
@@ -79,7 +79,7 @@ ___start(int argc, char **argv, char **e
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
Index: lib/csu/vax_elf/crt0.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/vax_elf/crt0.c,v
retrieving revision 1.10
diff -u -p -r1.10 crt0.c
--- lib/csu/vax_elf/crt0.c 26 Aug 2004 21:24:09 -0000 1.10
+++ lib/csu/vax_elf/crt0.c 20 Feb 2011 06:09:15 -0000
@@ -76,7 +76,7 @@ ___start(int argc, char **argv, char **e
__ps_strings = ps_strings;
#ifdef DYNAMIC
- if (&_DYNAMIC != NULL)
+ if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
Index: lib/libc/net/nsdispatch.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libc/net/nsdispatch.c,v
retrieving revision 1.35
diff -u -p -r1.35 nsdispatch.c
--- lib/libc/net/nsdispatch.c 18 Feb 2011 23:41:57 -0000 1.35
+++ lib/libc/net/nsdispatch.c 20 Feb 2011 22:02:03 -0000
@@ -174,12 +174,9 @@ static mutex_t _ns_drec_lock = MUTEX_INI
*/
#ifndef __ELF__
#define is_dynamic() (0) /* don't bother - switch to
ELF! */
-#elif __GNUC_PREREQ__(4,2)
-static int rtld_DYNAMIC __attribute__((__weakref__, __alias__("_DYNAMIC")));
-#define is_dynamic() (&rtld_DYNAMIC != NULL)
#else
-extern int _DYNAMIC __weak_reference(_DYNAMIC);
-#define is_dynamic() (&_DYNAMIC != NULL)
+__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
+#define is_dynamic() (&rtld_DYNAMIC != NULL)
#endif
Index: lib/libedit/vi.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/libedit/vi.c,v
retrieving revision 1.33
diff -u -p -r1.33 vi.c
--- lib/libedit/vi.c 17 Feb 2011 16:44:48 -0000 1.33
+++ lib/libedit/vi.c 20 Feb 2011 22:01:47 -0000
@@ -919,12 +919,8 @@ vi_comment_out(EditLine *el, Int c)
* this is against historical precedent...
*/
#ifdef __weak_reference
-#if __GNUC_PREREQ__(4,2)
-extern char *get_alias_text(const char *) __attribute__((__weak__));
-static char *my_get_alias_text(const char *) __attribute__((__weakref__,
__alias__("get_alias_text")));
-#else
-extern char *get_alias_text(const char *) __weak_reference(get_alias_text);
-#endif
+__weakref_visible char *my_get_alias_text(const char *)
+ __weak_reference(get_alias_text);
#endif
protected el_action_t
/*ARGSUSED*/
@@ -934,22 +930,16 @@ vi_alias(EditLine *el, Int c)
char alias_name[3];
char *alias_text;
-#if __GNUC_PREREQ__(4,2)
if (my_get_alias_text == 0) {
return CC_ERROR;
}
-#else
- if (get_alias_text == 0) {
- return CC_ERROR;
- }
-#endif
alias_name[0] = '_';
alias_name[2] = 0;
if (el_getc(el, &alias_name[1]) != 1)
return CC_ERROR;
- alias_text = get_alias_text(alias_name);
+ alias_text = my_get_alias_text(alias_name);
if (alias_text != NULL)
FUN(el,push)(el, ct_decode_string(alias_text, &el->el_scratch));
return CC_NORM;
Index: sys/sys/cdefs_elf.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/sys/cdefs_elf.h,v
retrieving revision 1.35
diff -u -p -r1.35 cdefs_elf.h
--- sys/sys/cdefs_elf.h 17 Feb 2011 21:06:26 -0000 1.35
+++ sys/sys/cdefs_elf.h 20 Feb 2011 22:01:52 -0000
@@ -65,11 +65,17 @@
__asm(".weak " _C_LABEL_STRING(#sym));
#if __GNUC_PREREQ__(4, 0)
-#define __weak_reference(sym) __attribute__((__weakref__))
+#define __weak_reference(sym) __attribute__((__weakref__(#sym)))
#else
#define __weak_reference(sym) ; __asm(".weak " _C_LABEL_STRING(#sym))
#endif
+#if __GNUC_PREREQ__(4, 2)
+#define __weakref_visible static
+#else
+#define __weakref_visible extern
+#endif
+
#define __warn_references(sym,msg)
\
__asm(".pushsection .gnu.warning." #sym "\n" \
".ascii \"" msg "\"\n" \
Home |
Main Index |
Thread Index |
Old Index