Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update.
2000-08-26  Ulrich Drepper  <drepper@redhat.com>

	* elf/Makefile (distribute): Add unloadmod.c, reldepmod1.c,
	reldepmod2.c, reldepmod3.c, and reldepmod4.c.
	(tests): Add unload, reldep, reldep2, and reldep3.
	(modules-names): Add unloadmod, reldepmod1, reldepmod2, reldepmod3,
	and reldepmod4.
	Add rules to build and run unload, reldep, reldep2, and reldep3.
	* elf/dl-lookup.c (_dl_lookup_symbol): Add new parameter explicit.
	Don't create relocation dependency if it is nonzero.
	(_dl_lookup_symbol_skip): Remove relocation dependency stuff.  This
	can never happen here.
	(_dl_lookup_versioned_symbol): Add new parameter explicit.
	Don't create relocation dependency if it is nonzero.
	(_dl_lookup_versioned_symbol_skip): Remove relocation dependency
	stuff.  This can never happen here.
	* sysdeps/generic/ldsodefs.h: Change prototypes.
	* elf/dl-reloc.c (RESOLVE_MAP): Pass 0 in explicit parameter to
	_dl_lookup_up and _dl_lookup_versioned_symbol.
	(RESOLV): Likewise.
	* elf/dl-runtime.c (fixup): Likewise.
	(profile_fixup): Likewise.
	* elf/dl-libc.c (do_dlsym): Pass 1 in explicit parameter to
	_dl_lookup_symbol.
	* elf/dl-symbol.c (_dl_symbol_value): Likewise.
	* elf/rtld.c (dl_main): Likewise.
	* elf/dl-sym.c (_dl_sym): Pass 1 in explicit parameter to
	_dl_lookup_symbol if handle is not RTLD_DEFAULT.  Always compute
	and pass down the caller map.
	(_dl_vsym): Likewise.
	* elf/reldep.c: New file.
	* elf/reldep2.c: New file.
	* elf/reldep3.c: New file.
	* elf/reldepmod1.c: New file.
	* elf/reldepmod2.c: New file.
	* elf/reldepmod3.c: New file.
	* elf/reldepmod4.c: New file.
	* elf/unload.c: New file.
	* elf/unloadmod.c: New file.

	* elf/do-lookup.h: Remove unused undef_name parameter.
	* elf/dl-lookup.c: Adjust callers.
  • Loading branch information
Ulrich Drepper committed Aug 26, 2000
1 parent 36466e6 commit 2b7238d
Show file tree
Hide file tree
Showing 20 changed files with 590 additions and 157 deletions.
43 changes: 43 additions & 0 deletions ChangeLog
@@ -1,3 +1,46 @@
2000-08-26 Ulrich Drepper <drepper@redhat.com>

* elf/Makefile (distribute): Add unloadmod.c, reldepmod1.c,
reldepmod2.c, reldepmod3.c, and reldepmod4.c.
(tests): Add unload, reldep, reldep2, and reldep3.
(modules-names): Add unloadmod, reldepmod1, reldepmod2, reldepmod3,
and reldepmod4.
Add rules to build and run unload, reldep, reldep2, and reldep3.
* elf/dl-lookup.c (_dl_lookup_symbol): Add new parameter explicit.
Don't create relocation dependency if it is nonzero.
(_dl_lookup_symbol_skip): Remove relocation dependency stuff. This
can never happen here.
(_dl_lookup_versioned_symbol): Add new parameter explicit.
Don't create relocation dependency if it is nonzero.
(_dl_lookup_versioned_symbol_skip): Remove relocation dependency
stuff. This can never happen here.
* sysdeps/generic/ldsodefs.h: Change prototypes.
* elf/dl-reloc.c (RESOLVE_MAP): Pass 0 in explicit parameter to
_dl_lookup_up and _dl_lookup_versioned_symbol.
(RESOLV): Likewise.
* elf/dl-runtime.c (fixup): Likewise.
(profile_fixup): Likewise.
* elf/dl-libc.c (do_dlsym): Pass 1 in explicit parameter to
_dl_lookup_symbol.
* elf/dl-symbol.c (_dl_symbol_value): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/dl-sym.c (_dl_sym): Pass 1 in explicit parameter to
_dl_lookup_symbol if handle is not RTLD_DEFAULT. Always compute
and pass down the caller map.
(_dl_vsym): Likewise.
* elf/reldep.c: New file.
* elf/reldep2.c: New file.
* elf/reldep3.c: New file.
* elf/reldepmod1.c: New file.
* elf/reldepmod2.c: New file.
* elf/reldepmod3.c: New file.
* elf/reldepmod4.c: New file.
* elf/unload.c: New file.
* elf/unloadmod.c: New file.

* elf/do-lookup.h: Remove unused undef_name parameter.
* elf/dl-lookup.c: Adjust callers.

2000-08-25 Ulrich Drepper <drepper@redhat.com>

* iconv/gconv_trans.c (__gconv_transliterate): Pass NULL instead of
Expand Down
26 changes: 20 additions & 6 deletions elf/Makefile
Expand Up @@ -41,13 +41,14 @@ distribute := $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
do-lookup.h dl-lookupcfg.h sprof.c gen-trusted-dirs.awk \
testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
testobj6.c testobj1_1.c failobj.c \
testobj6.c testobj1_1.c failobj.c unloadmod.c \
ldconfig.h ldconfig.c cache.c readlib.c readelflib.c \
dep1.c dep2.c dep3.c dep4.c dl-dtprocnum.h \
vismain.c vismod1.c vismod2.c vismod3.c \
constload2.c constload3.c filtmod1.c filtmod2.c \
nodlopenmod.c nodelete.c nodelmod1.c nodelmod2.c \
nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h
nodelmod3.c nodelmod4.c nodlopen.c dl-osinfo.h \
reldepmod1.c reldepmod2.c reldepmod3.c reldepmod4.c

include ../Makeconfig

Expand Down Expand Up @@ -87,18 +88,19 @@ endif

ifeq (yes,$(build-shared))
tests = loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
constload1 order $(tests-vis-$(have-protected)) noload filter \
$(tests-nodelete-$(have-z-nodelete)) \
constload1 order $(tests-vis-$(have-protected)) noload filter unload \
reldep reldep2 reldep3 $(tests-nodelete-$(have-z-nodelete)) \
$(tests-nodlopen-$(have-z-nodlopen))
tests-vis-yes = vismain
tests-nodelete-yes = nodelete
tests-nodlopen-yes = nodlopen
endif
modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
testobj1_1 failobj constload2 constload3 \
testobj1_1 failobj constload2 constload3 unloadmod \
dep1 dep2 dep3 dep4 $(modules-vis-$(have-protected)) \
$(modules-nodelete-$(have-z-nodelete)) \
$(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2
$(modules-nodlopen-$(have-z-nodlopen)) filtmod1 filtmod2 \
reldepmod1 reldepmod2 reldepmod3 reldepmod4
modules-vis-yes = vismod1 vismod2 vismod3
modules-nodelete-yes = nodelmod1 nodelmod2 nodelmod3 nodelmod4
modules-nodlopen-yes = nodlopenmod
Expand Down Expand Up @@ -319,3 +321,15 @@ $(objpfx)filtmod1.so: $(objpfx)filtmod1.os $(objpfx)filtmod2.so
-Wl,-rpath-link=$(rpath-link) \
$< -Wl,-F,$(objpfx)filtmod2.so
$(objpfx)filter: $(objpfx)filtmod1.so

$(objpfx)unload: $(libdl)
$(objpfx)unload.out: $(objpfx)unloadmod.so

$(objpfx)reldep: $(libdl)
$(objpfx)reldep.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod2.so

$(objpfx)reldep2: $(libdl)
$(objpfx)reldep2.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod3.so

$(objpfx)reldep3: $(libdl)
$(objpfx)reldep3.out: $(objpfx)reldepmod1.so $(objpfx)reldepmod4.so
2 changes: 1 addition & 1 deletion elf/dl-libc.c
Expand Up @@ -84,7 +84,7 @@ do_dlsym (void *ptr)
struct do_dlsym_args *args = (struct do_dlsym_args *) ptr;
args->ref = NULL;
args->loadbase = _dl_lookup_symbol (args->name, args->map, &args->ref,
args->map->l_local_scope, 0);
args->map->l_local_scope, 0, 1);
}

static void
Expand Down
149 changes: 40 additions & 109 deletions elf/dl-lookup.c
Expand Up @@ -190,7 +190,7 @@ lookup_t
internal_function
_dl_lookup_symbol (const char *undef_name, struct link_map *undef_map,
const ElfW(Sym) **ref, struct r_scope_elem *symbol_scope[],
int reloc_type)
int reloc_type, int explicit)
{
const char *reference_name = undef_map ? undef_map->l_name : NULL;
const unsigned long int hash = _dl_elf_hash (undef_name);
Expand All @@ -204,8 +204,8 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map,

/* Search the relevant loaded objects for a definition. */
for (scope = symbol_scope; *scope; ++scope)
if (do_lookup (undef_name, undef_map, hash, *ref, &current_value,
*scope, 0, NULL, noexec, noplt))
if (do_lookup (undef_name, hash, *ref, &current_value, *scope, 0, NULL,
noexec, noplt))
{
/* We have to check whether this would bind UNDEF_MAP to an object
in the global scope which was dynamically loaded. In this case
Expand All @@ -215,12 +215,15 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map,
&& (__builtin_expect (current_value.m->l_type, lt_library)
== lt_loaded)
&& undef_map != current_value.m
/* Don't do this for explicit lookups as opposed to implicit
runtime lookups. */
&& __builtin_expect (! explicit, 1)
/* Add UNDEF_MAP to the dependencies. */
&& add_dependency (undef_map, current_value.m) < 0)
/* Something went wrong. Perhaps the object we tried to reference
was just removed. Try finding another definition. */
return _dl_lookup_symbol (undef_name, undef_map, ref, symbol_scope,
reloc_type);
reloc_type, 0);

break;
}
Expand Down Expand Up @@ -262,8 +265,8 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map,
struct sym_val protected_value = { NULL, NULL };

for (scope = symbol_scope; *scope; ++scope)
if (do_lookup (undef_name, undef_map, hash, *ref,
&protected_value, *scope, 0, NULL, 0, 1))
if (do_lookup (undef_name, hash, *ref, &protected_value, *scope, 0,
NULL, 0, 1))
break;

if (protected_value.s == NULL || protected_value.m == undef_map)
Expand Down Expand Up @@ -303,47 +306,13 @@ _dl_lookup_symbol_skip (const char *undef_name,
for (i = 0; (*scope)->r_duplist[i] != skip_map; ++i)
assert (i < (*scope)->r_nduplist);

if (i < (*scope)->r_nlist
&& do_lookup (undef_name, undef_map, hash, *ref, &current_value,
*scope, i, skip_map, 0, 0))
{
/* We have to check whether this would bind UNDEF_MAP to an object
in the global scope which was dynamically loaded. In this case
we have to prevent the latter from being unloaded unless the
UNDEF_MAP object is also unloaded. */
if (current_value.m->l_global
&& (__builtin_expect (current_value.m->l_type, lt_library)
== lt_loaded)
&& undef_map != current_value.m
/* Add UNDEF_MAP to the dependencies. */
&& add_dependency (undef_map, current_value.m) < 0)
/* Something went wrong. Perhaps the object we tried to reference
was just removed. Try finding another definition. */
return _dl_lookup_symbol_skip (undef_name, undef_map, ref,
symbol_scope, skip_map);
}
else
while (i >= (*scope)->r_nlist
|| ! do_lookup (undef_name, hash, *ref, &current_value, *scope, i,
skip_map, 0, 0))
while (*++scope)
if (do_lookup (undef_name, undef_map, hash, *ref, &current_value,
*scope, 0, skip_map, 0, 0))
{
/* We have to check whether this would bind UNDEF_MAP to an object
in the global scope which was dynamically loaded. In this case
we have to prevent the latter from being unloaded unless the
UNDEF_MAP object is also unloaded. */
if (__builtin_expect (current_value.m->l_global, 0)
&& (__builtin_expect (current_value.m->l_type, lt_library)
== lt_loaded)
&& undef_map != current_value.m
/* Add UNDEF_MAP to the dependencies. */
&& add_dependency (undef_map, current_value.m) < 0)
/* Something went wrong. Perhaps the object we tried to reference
was just removed. Try finding another definition. */
return _dl_lookup_symbol_skip (undef_name, undef_map, ref,
symbol_scope, skip_map);

break;
}
if (do_lookup (undef_name, hash, *ref, &current_value, *scope, 0,
skip_map, 0, 0))
break;

if (__builtin_expect (current_value.s == NULL, 0))
{
Expand All @@ -370,16 +339,16 @@ _dl_lookup_symbol_skip (const char *undef_name,
}
else
{
/* It is very tricky. We need to figure out what value to
return for the protected symbol */
/* It is very tricky. We need to figure out what value to
return for the protected symbol. */
struct sym_val protected_value = { NULL, NULL };

if (i >= (*scope)->r_nlist
|| !do_lookup (undef_name, undef_map, hash, *ref, &protected_value,
*scope, i, skip_map, 0, 1))
|| !do_lookup (undef_name, hash, *ref, &protected_value, *scope, i,
skip_map, 0, 1))
while (*++scope)
if (do_lookup (undef_name, undef_map, hash, *ref, &protected_value,
*scope, 0, skip_map, 0, 1))
if (do_lookup (undef_name, hash, *ref, &protected_value, *scope, 0,
skip_map, 0, 1))
break;

if (protected_value.s == NULL || protected_value.m == undef_map)
Expand All @@ -404,7 +373,7 @@ _dl_lookup_versioned_symbol (const char *undef_name,
struct link_map *undef_map, const ElfW(Sym) **ref,
struct r_scope_elem *symbol_scope[],
const struct r_found_version *version,
int reloc_type)
int reloc_type, int explicit)
{
const char *reference_name = undef_map ? undef_map->l_name : NULL;
const unsigned long int hash = _dl_elf_hash (undef_name);
Expand All @@ -419,9 +388,8 @@ _dl_lookup_versioned_symbol (const char *undef_name,
/* Search the relevant loaded objects for a definition. */
for (scope = symbol_scope; *scope; ++scope)
{
int res = do_lookup_versioned (undef_name, undef_map, hash, *ref,
&current_value, *scope, 0, version, NULL,
noexec, noplt);
int res = do_lookup_versioned (undef_name, hash, *ref, &current_value,
*scope, 0, version, NULL, noexec, noplt);
if (res > 0)
{
/* We have to check whether this would bind UNDEF_MAP to an object
Expand All @@ -432,13 +400,16 @@ _dl_lookup_versioned_symbol (const char *undef_name,
&& (__builtin_expect (current_value.m->l_type, lt_library)
== lt_loaded)
&& undef_map != current_value.m
/* Don't do this for explicit lookups as opposed to implicit
runtime lookups. */
&& __builtin_expect (! explicit, 1)
/* Add UNDEF_MAP to the dependencies. */
&& add_dependency (undef_map, current_value.m) < 0)
/* Something went wrong. Perhaps the object we tried to reference
was just removed. Try finding another definition. */
return _dl_lookup_versioned_symbol (undef_name, undef_map, ref,
symbol_scope, version,
reloc_type);
reloc_type, 0);

break;
}
Expand Down Expand Up @@ -502,9 +473,8 @@ _dl_lookup_versioned_symbol (const char *undef_name,
struct sym_val protected_value = { NULL, NULL };

for (scope = symbol_scope; *scope; ++scope)
if (do_lookup_versioned (undef_name, undef_map, hash, *ref,
&protected_value, *scope, 0, version, NULL,
0, 1))
if (do_lookup_versioned (undef_name, hash, *ref, &protected_value,
*scope, 0, version, NULL, 0, 1))
break;

if (protected_value.s == NULL || protected_value.m == undef_map)
Expand Down Expand Up @@ -543,50 +513,13 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
for (i = 0; (*scope)->r_duplist[i] != skip_map; ++i)
assert (i < (*scope)->r_nduplist);

if (i < (*scope)->r_nlist
&& do_lookup_versioned (undef_name, undef_map, hash, *ref,
&current_value, *scope, i, version, skip_map,
0, 0))
{
/* We have to check whether this would bind UNDEF_MAP to an object
in the global scope which was dynamically loaded. In this case
we have to prevent the latter from being unloaded unless the
UNDEF_MAP object is also unloaded. */
if (__builtin_expect (current_value.m->l_global, 0)
&& (__builtin_expect (current_value.m->l_type, lt_library)
== lt_loaded)
&& undef_map != current_value.m
/* Add UNDEF_MAP to the dependencies. */
&& add_dependency (undef_map, current_value.m) < 0)
/* Something went wrong. Perhaps the object we tried to reference
was just removed. Try finding another definition. */
return _dl_lookup_versioned_symbol_skip (undef_name, undef_map, ref,
symbol_scope, version,
skip_map);
}
else
if (i >= (*scope)->r_nlist
|| ! do_lookup_versioned (undef_name, hash, *ref, &current_value,
*scope, i, version, skip_map, 0, 0))
while (*++scope)
if (do_lookup_versioned (undef_name, undef_map, hash, *ref,
&current_value, *scope, 0, version, skip_map,
0, 0))
{
/* We have to check whether this would bind UNDEF_MAP to an object
in the global scope which was dynamically loaded. In this case
we have to prevent the latter from being unloaded unless the
UNDEF_MAP object is also unloaded. */
if (current_value.m->l_global
&& (__builtin_expect (current_value.m->l_type, lt_library)
== lt_loaded)
&& undef_map != current_value.m
/* Add UNDEF_MAP to the dependencies. */
&& add_dependency (undef_map, current_value.m) < 0)
/* Something went wrong. Perhaps the object we tried to reference
was just removed. Try finding another definition. */
return _dl_lookup_versioned_symbol_skip (undef_name, undef_map,
ref, symbol_scope,
version, skip_map);
break;
}
if (do_lookup_versioned (undef_name, hash, *ref, &current_value, *scope,
0, version, skip_map, 0, 0))
break;

if (__builtin_expect (current_value.s == NULL, 0))
{
Expand Down Expand Up @@ -631,13 +564,11 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
struct sym_val protected_value = { NULL, NULL };

if (i >= (*scope)->r_nlist
|| !do_lookup_versioned (undef_name, undef_map, hash, *ref,
&protected_value, *scope, i, version,
skip_map, 0, 1))
|| !do_lookup_versioned (undef_name, hash, *ref, &protected_value,
*scope, i, version, skip_map, 0, 1))
while (*++scope)
if (do_lookup_versioned (undef_name, undef_map, hash, *ref,
&protected_value, *scope, 0, version,
skip_map, 0, 1))
if (do_lookup_versioned (undef_name, hash, *ref, &protected_value,
*scope, 0, version, skip_map, 0, 1))
break;

if (protected_value.s == NULL || protected_value.m == undef_map)
Expand Down
8 changes: 4 additions & 4 deletions elf/dl-reloc.c
Expand Up @@ -75,17 +75,17 @@ cannot make segment writable for relocation"));
(ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL \
? ((version) != NULL && (version)->hash != 0 \
? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, l, (ref), \
scope, (version), (flags)) \
scope, (version), (flags), 0) \
: _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), scope, \
(flags))) \
(flags), 0)) \
: l)
#define RESOLVE(ref, version, flags) \
(ELFW(ST_BIND) ((*ref)->st_info) != STB_LOCAL \
? ((version) != NULL && (version)->hash != 0 \
? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, l, (ref), \
scope, (version), (flags)) \
scope, (version), (flags), 0) \
: _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), scope, \
(flags))) \
(flags), 0)) \
: l->l_addr)

#include "dynamic-link.h"
Expand Down

0 comments on commit 2b7238d

Please sign in to comment.