mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
From NetBSD:
Deal with weak symbols when looking up in shared libraries; tested by marc@ miod@ and myself.
This commit is contained in:
parent
065907e528
commit
8981952434
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user