From 86df96f6923cb6161b746b1f99378a1f9e1cc700 Mon Sep 17 00:00:00 2001 From: joerg Date: Fri, 18 Feb 2011 23:37:36 +0000 Subject: [PATCH] Allow building with the changed weakref semantic in GCC 4.2 and clang. --- lib/csu/common/crt0-common.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/csu/common/crt0-common.c b/lib/csu/common/crt0-common.c index 33b035c56fcf..12666f4f18eb 100644 --- a/lib/csu/common/crt0-common.c +++ b/lib/csu/common/crt0-common.c @@ -1,4 +1,4 @@ -/* $NetBSD: crt0-common.c,v 1.2 2011/02/08 02:03:13 matt Exp $ */ +/* $NetBSD: crt0-common.c,v 1.3 2011/02/18 23:37:36 joerg Exp $ */ /* * Copyright (c) 1998 Christos Zoulas @@ -36,7 +36,7 @@ */ #include -__RCSID("$NetBSD: crt0-common.c,v 1.2 2011/02/08 02:03:13 matt Exp $"); +__RCSID("$NetBSD: crt0-common.c,v 1.3 2011/02/18 23:37:36 joerg Exp $"); #include #include @@ -57,7 +57,14 @@ extern void _fini(void); * if we happen to be compiling without -static but with without any * 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 #ifdef MCRT0 extern void monstartup(u_long, u_long); @@ -104,7 +111,7 @@ ___start(int argc, char **argv, char **envp, if (ps_strings != NULL) __ps_strings = ps_strings; - if (&_DYNAMIC != NULL) { + if (&DYNAMIC_SYM != NULL) { if (obj == NULL) _FATAL("NULL Obj_Entry pointer in GOT\n"); if (obj->magic != RTLD_MAGIC)