summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/ld
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-02-14 04:25:33 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-02-14 04:25:33 +0000
commit8fed9fb1cd2f9fa7b95713d8780fd00dce3c9832 (patch)
tree6ac07769da145b8d36b7ef4a663d67c1d9275825 /gnu/usr.bin/ld
parent9e50dc6ac12dc1f620e3f3bc57e3491cd679c137 (diff)
From NetBSD:
Deal with weak symbols when looking up in shared libraries; tested by marc@ miod@ and myself.
Diffstat (limited to 'gnu/usr.bin/ld')
-rw-r--r--gnu/usr.bin/ld/rtld/rtld.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/gnu/usr.bin/ld/rtld/rtld.c b/gnu/usr.bin/ld/rtld/rtld.c
index 471e6fcf908..0709ea4c414 100644
--- a/gnu/usr.bin/ld/rtld/rtld.c
+++ b/gnu/usr.bin/ld/rtld/rtld.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld.c,v 1.20 2001/11/08 07:40:25 fgsch Exp $ */
+/* $OpenBSD: rtld.c,v 1.21 2002/02/14 04:25:32 fgsch Exp $ */
/* $NetBSD: rtld.c,v 1.43 1996/01/14 00:35:17 pk Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
@@ -974,8 +974,9 @@ lookup(name, src_map, strong)
int strong;
{
long common_size = 0;
- struct so_map *smp;
+ struct so_map *smp, *weak_smp;
struct rt_symbol *rtsp;
+ struct nzlist *weak_np = 0;
if ((rtsp = lookup_rts(name)) != NULL) {
/* Common symbol is not a member of particular shlib. */
@@ -983,6 +984,8 @@ lookup(name, src_map, strong)
return rtsp->rt_sp;
}
+ weak_smp = NULL; /* XXX - gcc! */
+
/*
* Search all maps for a definition of NAME
*/
@@ -1072,11 +1075,21 @@ restart:
continue;
}
}
+ if (N_BIND(&np->nlist) == BIND_WEAK && weak_np == 0) {
+ weak_np = np;
+ weak_smp = smp;
+ continue;
+ }
*src_map = smp;
return np;
}
+ if (weak_np) {
+ *src_map = weak_smp;
+ return weak_np;
+ }
+
if (common_size == 0)
/* Not found */
return NULL;