diff options
Diffstat (limited to 'elf/dl-lookup.c')
-rw-r--r-- | elf/dl-lookup.c | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index f577759a9d..68ecc6179f 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -1,5 +1,5 @@ /* Look up a symbol in the loaded objects. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -47,23 +47,6 @@ struct sym_val }; -#define make_string(string, rest...) \ - ({ \ - const char *all[] = { string, ## rest }; \ - size_t len, cnt; \ - char *result, *cp; \ - \ - len = 1; \ - for (cnt = 0; cnt < sizeof (all) / sizeof (all[0]); ++cnt) \ - len += strlen (all[cnt]); \ - \ - cp = result = alloca (len); \ - for (cnt = 0; cnt < sizeof (all) / sizeof (all[0]); ++cnt) \ - cp = __stpcpy (cp, all[cnt]); \ - \ - result; \ - }) - /* Statistics function. */ #ifdef SHARED # define bump_num_relocations() ++GL(dl_num_relocations) @@ -93,6 +76,7 @@ check_match (const char *const undef_name, unsigned int stt = ELFW(ST_TYPE) (sym->st_info); assert (ELF_RTYPE_CLASS_PLT == 1); if (__glibc_unlikely ((sym->st_value == 0 /* No value. */ + && sym->st_shndx != SHN_ABS && stt != STT_TLS) || ELF_MACHINE_SYM_NO_MATCH (sym) || (type_class & (sym->st_shndx == SHN_UNDEF)))) @@ -516,6 +500,10 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, #endif } + /* Hidden and internal symbols are local, ignore them. */ + if (__glibc_unlikely (dl_symbol_visibility_binds_local_p (sym))) + goto skip; + switch (ELFW(ST_BIND) (sym->st_info)) { case STB_WEAK: @@ -573,7 +561,6 @@ dl_new_hash (const char *s) /* Add extra dependency on MAP to UNDEF_MAP. */ static int -internal_function add_dependency (struct link_map *undef_map, struct link_map *map, int flags) { struct link_map *runp; @@ -783,7 +770,6 @@ add_dependency (struct link_map *undef_map, struct link_map *map, int flags) } static void -internal_function _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, const ElfW(Sym) **ref, struct sym_val *value, const struct r_found_version *version, int type_class, @@ -797,7 +783,6 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, or in any function which gets called. If this would happen the audit code might create a thread which can throw off all the scope locking. */ lookup_t -internal_function _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, const ElfW(Sym) **ref, struct r_scope_elem *symbol_scope[], @@ -839,17 +824,16 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, for unversioned lookups. */ assert (version != NULL); const char *reference_name = undef_map ? undef_map->l_name : ""; - + struct dl_exception exception; /* XXX We cannot translate the message. */ - _dl_signal_cerror (0, DSO_FILENAME (reference_name), - N_("relocation error"), - make_string ("symbol ", undef_name, ", version ", - version->name, - " not defined in file ", - version->filename, - " with link time reference", - res == -2 - ? " (no version symbols)" : "")); + _dl_exception_create_format + (&exception, DSO_FILENAME (reference_name), + "symbol %s version %s not defined in file %s" + " with link time reference%s", + undef_name, version->name, version->filename, + res == -2 ? " (no version symbols)" : ""); + _dl_signal_cexception (0, &exception, N_("relocation error")); + _dl_exception_free (&exception); *ref = NULL; return 0; } @@ -858,7 +842,6 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, if (__glibc_unlikely (current_value.s == NULL)) { if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK) - && skip_map == NULL && !(GLRO(dl_debug_mask) & DL_DEBUG_UNUSED)) { /* We could find no value for a strong reference. */ @@ -866,12 +849,14 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, const char *versionstr = version ? ", version " : ""; const char *versionname = (version && version->name ? version->name : ""); - + struct dl_exception exception; /* XXX We cannot translate the message. */ - _dl_signal_cerror (0, DSO_FILENAME (reference_name), - N_("symbol lookup error"), - make_string ("undefined symbol: ", undef_name, - versionstr, versionname)); + _dl_exception_create_format + (&exception, DSO_FILENAME (reference_name), + "undefined symbol: %s%s%s", + undef_name, versionstr, versionname); + _dl_signal_cexception (0, &exception, N_("symbol lookup error")); + _dl_exception_free (&exception); } *ref = NULL; return 0; @@ -948,19 +933,14 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, /* Cache the location of MAP's hash table. */ void -internal_function _dl_setup_hash (struct link_map *map) { Elf_Symndx *hash; - if (__glibc_likely (map->l_info[DT_ADDRTAGIDX (DT_GNU_HASH) + DT_NUM - + DT_THISPROCNUM + DT_VERSIONTAGNUM - + DT_EXTRANUM + DT_VALNUM] != NULL)) + if (__glibc_likely (map->l_info[ADDRIDX (DT_GNU_HASH)] != NULL)) { Elf32_Word *hash32 - = (void *) D_PTR (map, l_info[DT_ADDRTAGIDX (DT_GNU_HASH) + DT_NUM - + DT_THISPROCNUM + DT_VERSIONTAGNUM - + DT_EXTRANUM + DT_VALNUM]); + = (void *) D_PTR (map, l_info[ADDRIDX (DT_GNU_HASH)]); map->l_nbuckets = *hash32++; Elf32_Word symbias = *hash32++; Elf32_Word bitmask_nwords = *hash32++; @@ -992,7 +972,6 @@ _dl_setup_hash (struct link_map *map) static void -internal_function _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, const ElfW(Sym) **ref, struct sym_val *value, const struct r_found_version *version, int type_class, |