From 680254fe22215c1f41f247d085c5cac5783b73f5 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 26 Aug 2001 10:50:26 +0000 Subject: Update. * include/link.h (struct link_map): Add l_lookup_cache element. * elf/dl-reloc.c (RESOLVE): Add symbol caching here. (RESOLVE_MAP): Likewise. (_dl_relocate_object): Remove cache initialization. * elf/dl-lookup.c: Rip out cache handling code. * sysdeps/generic/ldsodefs.h: Remove lookup_cache struct and variable declarations. * elf/dl-lookup.c (_dl_lookup_symbol): Reorder some conditions and remove some __builtin_expect. (_dl_lookup_versioned_symbol): Likewise. R_386_RELATIVE handling for ld.so startup. Reduce RTLD_BOOTSTRAP case to almost no code. --- elf/dl-reloc.c | 55 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 16 deletions(-) (limited to 'elf/dl-reloc.c') diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index 99cb18962d..276aea094b 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -27,6 +27,9 @@ #include #include "dynamic-link.h" +/* Statistics function. */ +unsigned long int _dl_num_cache_relocations; + void _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], @@ -74,31 +77,51 @@ cannot make segment writable for relocation")); /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code. */ #define RESOLVE_MAP(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), 0) \ - : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), scope, \ - (flags), 0)) \ + ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0) \ + && elf_machine_lookup_noexec_p (flags) == l->l_lookup_cache.noexec \ + && elf_machine_lookup_noplt_p (flags) == l->l_lookup_cache.noplt) \ + ? (++_dl_num_cache_relocations, \ + (*ref) = l->l_lookup_cache.ret, \ + l->l_lookup_cache.value) \ + : ({ lookup_t _lr; \ + l->l_lookup_cache.sym = (*ref); \ + l->l_lookup_cache.noexec = elf_machine_lookup_noexec_p (flags); \ + l->l_lookup_cache.noplt = elf_machine_lookup_noplt_p (flags); \ + _lr = ((version) != NULL && (version)->hash != 0 \ + ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, \ + l, (ref), scope, \ + (version), (flags), 0) \ + : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), \ + scope, (flags), 0)); \ + l->l_lookup_cache.ret = (*ref); \ + l->l_lookup_cache.value = _lr; })) \ : 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), 0) \ - : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), scope, \ - (flags), 0)) \ + ? ((__builtin_expect ((*ref) == l->l_lookup_cache.sym, 0) \ + && elf_machine_lookup_noexec_p (flags) == l->l_lookup_cache.noexec \ + && elf_machine_lookup_noplt_p (flags) == l->l_lookup_cache.noplt) \ + ? (++_dl_num_cache_relocations, \ + (*ref) = l->l_lookup_cache.ret, \ + l->l_lookup_cache.value) \ + : ({ lookup_t _lr; \ + l->l_lookup_cache.sym = (*ref); \ + l->l_lookup_cache.noexec = elf_machine_lookup_noexec_p (flags); \ + l->l_lookup_cache.noplt = elf_machine_lookup_noplt_p (flags); \ + _lr = ((version) != NULL && (version)->hash != 0 \ + ? _dl_lookup_versioned_symbol (strtab + (*ref)->st_name, \ + l, (ref), scope, \ + (version), (flags), 0) \ + : _dl_lookup_symbol (strtab + (*ref)->st_name, l, (ref), \ + scope, (flags), 0)); \ + l->l_lookup_cache.ret = (*ref); \ + l->l_lookup_cache.value = _lr; })) \ : l->l_addr) #include "dynamic-link.h" - /* Start symbol lookup caching for this object. */ - _dl_lookup_cache.map = l; - _dl_lookup_cache_versioned.map = l; ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling); - _dl_lookup_cache.map = NULL; - _dl_lookup_cache_versioned.map = NULL; - if (__builtin_expect (consider_profiling, 0)) { /* Allocate the array which will contain the already found -- cgit v1.2.3