summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/alpha
diff options
context:
space:
mode:
authorjdp <jdp@FreeBSD.org>2001-05-05 23:21:05 +0000
committerjdp <jdp@FreeBSD.org>2001-05-05 23:21:05 +0000
commit66a962ce675f3386156405c78fe7d7a1e6a852bb (patch)
tree661ed94ee85164ded5139aff0e44eefd488583a9 /libexec/rtld-elf/alpha
parentda4bd71ba54c6cef03c8b248a7dd42b16a7b348e (diff)
downloadFreeBSD-src-66a962ce675f3386156405c78fe7d7a1e6a852bb.zip
FreeBSD-src-66a962ce675f3386156405c78fe7d7a1e6a852bb.tar.gz
Performance improvements for the ELF dynamic linker. These
particularly help programs which load many shared libraries with a lot of relocations. Large C++ programs such as are found in KDE are a prime example. While relocating a shared object, maintain a vector of symbols which have already been looked up, directly indexed by symbol number. Typically, symbols which are referenced by a relocation entry are referenced by many of them. This is the same optimization I made to the a.out dynamic linker in 1995 (rtld.c revision 1.30). Also, compare the first character of a sought-after symbol with its symbol table entry before calling strcmp(). On a PII/400 these changes reduce the start-up time of a typical KDE program from 833 msec (elapsed) to 370 msec. MFC after: 5 days
Diffstat (limited to 'libexec/rtld-elf/alpha')
-rw-r--r--libexec/rtld-elf/alpha/reloc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/libexec/rtld-elf/alpha/reloc.c b/libexec/rtld-elf/alpha/reloc.c
index e27f922..f963476 100644
--- a/libexec/rtld-elf/alpha/reloc.c
+++ b/libexec/rtld-elf/alpha/reloc.c
@@ -71,6 +71,11 @@ static int
reloc_non_plt_obj(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela)
{
Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rela->r_offset);
+ SymCache *cache;
+
+ cache = (SymCache *)alloca(obj->nchains * sizeof(SymCache));
+ if (cache != NULL)
+ memset(cache, 0, obj->nchains * sizeof(SymCache));
switch (ELF_R_TYPE(rela->r_info)) {
@@ -82,7 +87,7 @@ reloc_non_plt_obj(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela)
const Obj_Entry *defobj;
def = find_symdef(ELF_R_SYM(rela->r_info), obj,
- &defobj, false);
+ &defobj, false, cache);
if (def == NULL)
return -1;
store64(where,
@@ -97,7 +102,7 @@ reloc_non_plt_obj(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela)
Elf_Addr val;
def = find_symdef(ELF_R_SYM(rela->r_info), obj,
- &defobj, false);
+ &defobj, false, cache);
if (def == NULL)
return -1;
val = (Elf_Addr) (defobj->relocbase + def->st_value +
@@ -228,7 +233,8 @@ reloc_jmpslots(Obj_Entry *obj)
assert(ELF_R_TYPE(rel->r_info) == R_ALPHA_JMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true);
+ def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true,
+ NULL);
if (def == NULL)
return -1;
reloc_jmpslot(where,
@@ -246,7 +252,8 @@ reloc_jmpslots(Obj_Entry *obj)
assert(ELF_R_TYPE(rela->r_info) == R_ALPHA_JMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
- def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, true);
+ def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, true,
+ NULL);
if (def == NULL)
return -1;
reloc_jmpslot(where,
OpenPOWER on IntegriCloud