From d06eeaf617a23e92c4b17b61ff07c121cc4b7d8f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 13 Apr 2002 16:03:18 +0000 Subject: [PATCH] Adjust all callers of do_lookup. Change _dl_do_lookup to also take the new parameter and pass it on. Change 'explicit' parameter of _dl_lookup_symbol and _dl_lookup_versioned_symbol to flags. Adjust tests. --- elf/dl-lookup.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index 5fa50fc457f..6c6b06c5ccd 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -184,7 +184,7 @@ static int internal_function _dl_do_lookup (const char *undef_name, unsigned long int hash, const ElfW(Sym) *ref, struct sym_val *result, - struct r_scope_elem *scope, size_t i, + struct r_scope_elem *scope, size_t i, int flags, struct link_map *skip, int type_class); static int internal_function @@ -202,7 +202,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 type_class, int explicit) + int type_class, int flags) { unsigned long int hash = _dl_elf_hash (undef_name); struct sym_val current_value = { NULL, NULL }; @@ -213,8 +213,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, hash, *ref, ¤t_value, *scope, 0, NULL, - type_class)) + if (do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0, flags, + NULL, type_class)) { /* We have to check whether this would bind UNDEF_MAP to an object in the global scope which was dynamically loaded. In this case @@ -223,7 +223,7 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map, if (__builtin_expect (current_value.m->l_type == lt_loaded, 0) /* Don't do this for explicit lookups as opposed to implicit runtime lookups. */ - && ! explicit + && (flags & DL_LOOKUP_ADD_DEPENDENCY) != 0 /* Add UNDEF_MAP to the dependencies. */ && add_dependency (undef_map, current_value.m) < 0) /* Something went wrong. Perhaps the object we tried to reference @@ -277,7 +277,7 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map, for (scope = symbol_scope; *scope; ++scope) if (_dl_do_lookup (undef_name, hash, *ref, &protected_value, *scope, - 0, NULL, ELF_RTYPE_CLASS_PLT)) + 0, flags, NULL, ELF_RTYPE_CLASS_PLT)) break; if (protected_value.s == NULL || protected_value.m == undef_map) @@ -318,10 +318,10 @@ _dl_lookup_symbol_skip (const char *undef_name, assert (i < (*scope)->r_nlist); if (! _dl_do_lookup (undef_name, hash, *ref, ¤t_value, *scope, i, - skip_map, 0)) + DL_LOOKUP_RETURN_NEWEST, skip_map, 0)) while (*++scope) if (_dl_do_lookup (undef_name, hash, *ref, ¤t_value, *scope, 0, - skip_map, 0)) + DL_LOOKUP_RETURN_NEWEST, skip_map, 0)) break; if (__builtin_expect (current_value.s == NULL, 0)) @@ -353,10 +353,12 @@ _dl_lookup_symbol_skip (const char *undef_name, if (i >= (*scope)->r_nlist || !_dl_do_lookup (undef_name, hash, *ref, &protected_value, *scope, - i, skip_map, ELF_RTYPE_CLASS_PLT)) + i, DL_LOOKUP_RETURN_NEWEST, skip_map, + ELF_RTYPE_CLASS_PLT)) while (*++scope) if (_dl_do_lookup (undef_name, hash, *ref, &protected_value, *scope, - 0, skip_map, ELF_RTYPE_CLASS_PLT)) + 0, DL_LOOKUP_RETURN_NEWEST, skip_map, + ELF_RTYPE_CLASS_PLT)) break; if (protected_value.s == NULL || protected_value.m == undef_map) @@ -381,7 +383,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 type_class, int explicit) + int type_class, int flags) { unsigned long int hash = _dl_elf_hash (undef_name); struct sym_val current_value = { NULL, NULL }; @@ -390,6 +392,9 @@ _dl_lookup_versioned_symbol (const char *undef_name, ++_dl_num_relocations; + /* No other flag than DL_LOOKUP_ADD_DEPENDENCY is allowed. */ + assert (flags == 0 || flags == DL_LOOKUP_ADD_DEPENDENCY); + /* Search the relevant loaded objects for a definition. */ for (scope = symbol_scope; *scope; ++scope) { @@ -404,7 +409,7 @@ _dl_lookup_versioned_symbol (const char *undef_name, if (__builtin_expect (current_value.m->l_type == lt_loaded, 0) /* Don't do this for explicit lookups as opposed to implicit runtime lookups. */ - && ! explicit + && flags != 0 /* Add UNDEF_MAP to the dependencies. */ && add_dependency (undef_map, current_value.m) < 0) /* Something went wrong. Perhaps the object we tried to reference @@ -621,10 +626,10 @@ static int internal_function _dl_do_lookup (const char *undef_name, unsigned long int hash, const ElfW(Sym) *ref, struct sym_val *result, - struct r_scope_elem *scope, size_t i, + struct r_scope_elem *scope, size_t i, int flags, struct link_map *skip, int type_class) { - return do_lookup (undef_name, hash, ref, result, scope, i, skip, + return do_lookup (undef_name, hash, ref, result, scope, i, flags, skip, type_class); } -- 2.47.2