summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2019-07-21 03:54:17 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2019-07-21 03:54:17 +0000
commit244289f2dc68e97ac98cbf4c8d7c7f6cdce80fff (patch)
tree91bb4b4b7ba246498c183ea37ce0581b7e05537e /libexec
parent7008829524759b347301fe53c3f85958ff850a81 (diff)
In 2004, we upgraded to binutils 2.14 with did -zcombreloc by default.
In 2013, I implemented the single-entry LRU cache that gets the maximal symbol reuse from combreloc. Since then, the ld.so generic relocation symcache has been a waste of CPU and memory with 0% hit-rate, so kill it. ok mpi@
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ld.so/dlfcn.c8
-rw-r--r--libexec/ld.so/loader.c31
-rw-r--r--libexec/ld.so/resolve.c49
-rw-r--r--libexec/ld.so/resolve.h5
4 files changed, 7 insertions, 86 deletions
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c
index 016e6316cc8..39fdf27457d 100644
--- a/libexec/ld.so/dlfcn.c
+++ b/libexec/ld.so/dlfcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dlfcn.c,v 1.102 2018/10/22 01:59:08 guenther Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.103 2019/07/21 03:54:16 guenther Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -526,12 +526,6 @@ _dl_show_objects(void)
}
_dl_tracefmt(outputfd, object, fmt1, fmt2, objtypename);
}
-
- if (_dl_symcachestat_lookups != 0)
- DL_DEB(("symcache lookups %d hits %d ratio %d% hits\n",
- _dl_symcachestat_lookups, _dl_symcachestat_hits,
- (_dl_symcachestat_hits * 100) /
- _dl_symcachestat_lookups));
}
lock_cb *
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index 7e8f60578cb..e7b4e031b54 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.182 2019/06/07 16:27:47 deraadt Exp $ */
+/* $OpenBSD: loader.c,v 1.183 2019/07/21 03:54:16 guenther Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -687,13 +687,9 @@ _dl_boot(const char **argv, char **envp, const long dyn_loff, long *dl_data)
return(dl_data[AUX_entry]);
}
-#define DL_SM_SYMBUF_CNT 512
-sym_cache _dl_sm_symcache_buffer[DL_SM_SYMBUF_CNT];
-
int
_dl_rtld(elf_object_t *object)
{
- size_t sz;
struct load_list *llist;
int fails = 0;
@@ -703,26 +699,6 @@ _dl_rtld(elf_object_t *object)
if (object->status & STAT_RELOC_DONE)
return 0;
- sz = 0;
- if (object->nchains < DL_SM_SYMBUF_CNT) {
- _dl_symcache = _dl_sm_symcache_buffer;
-// DL_DEB(("using static buffer for %d entries\n",
-// object->nchains));
- _dl_memset(_dl_symcache, 0,
- sizeof (sym_cache) * object->nchains);
- } else {
- sz = ELF_ROUND(sizeof (sym_cache) * object->nchains,
- _dl_pagesz);
-// DL_DEB(("allocating symcache sz %x with mmap\n", sz));
-
- _dl_symcache = (void *)_dl_mmap(0, sz, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANON, -1, 0);
- if (_dl_mmap_error(_dl_symcache)) {
- sz = 0;
- _dl_symcache = NULL;
- }
- }
-
/*
* Do relocation information first, then GOT.
*/
@@ -741,11 +717,6 @@ _dl_rtld(elf_object_t *object)
}
}
- if (_dl_symcache != NULL) {
- if (sz != 0)
- _dl_munmap( _dl_symcache, sz);
- _dl_symcache = NULL;
- }
if (fails == 0)
object->status |= STAT_RELOC_DONE;
diff --git a/libexec/ld.so/resolve.c b/libexec/ld.so/resolve.c
index 2574cc3b953..2b9874ba7b3 100644
--- a/libexec/ld.so/resolve.c
+++ b/libexec/ld.so/resolve.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.c,v 1.90 2019/07/14 03:23:12 guenther Exp $ */
+/* $OpenBSD: resolve.c,v 1.91 2019/07/21 03:54:16 guenther Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -518,60 +518,19 @@ _dl_remove_object(elf_object_t *object)
}
-sym_cache *_dl_symcache;
-int _dl_symcachestat_hits;
-int _dl_symcachestat_lookups;
-
-
Elf_Addr
_dl_find_symbol_bysym(elf_object_t *req_obj, unsigned int symidx,
- const Elf_Sym **this, int flags, const Elf_Sym *ref_sym, const elf_object_t **pobj)
+ const Elf_Sym **this, int flags, const Elf_Sym *ref_sym,
+ const elf_object_t **pobj)
{
- Elf_Addr ret;
const Elf_Sym *sym;
const char *symn;
- const elf_object_t *sobj;
-
- _dl_symcachestat_lookups ++;
- if (_dl_symcache != NULL &&
- symidx < req_obj->nchains &&
- _dl_symcache[symidx].obj != NULL &&
- _dl_symcache[symidx].sym != NULL &&
- _dl_symcache[symidx].flags == flags) {
-
- _dl_symcachestat_hits++;
- sobj = _dl_symcache[symidx].obj;
- *this = _dl_symcache[symidx].sym;
- if (pobj)
- *pobj = sobj;
- return sobj->obj_base;
- }
sym = req_obj->dyn.symtab;
sym += symidx;
symn = req_obj->dyn.strtab + sym->st_name;
- ret = _dl_find_symbol(symn, this, flags, ref_sym, req_obj, &sobj);
-
- if (pobj)
- *pobj = sobj;
-
- if (_dl_symcache != NULL && symidx < req_obj->nchains) {
-#if 0
- DL_DEB(("cache miss %d %p %p, %p %p %s %s %d %d %s\n",
- symidx,
- _dl_symcache[symidx].sym, *this,
- _dl_symcache[symidx].obj, sobj, sobj->load_name,
- sobj->dyn.strtab + (*this)->st_name,
- _dl_symcache[symidx].flags, flags, req_obj->load_name));
-#endif
-
- _dl_symcache[symidx].sym = *this;
- _dl_symcache[symidx].obj = sobj;
- _dl_symcache[symidx].flags = flags;
- }
-
- return ret;
+ return _dl_find_symbol(symn, this, flags, ref_sym, req_obj, pobj);
}
static int
diff --git a/libexec/ld.so/resolve.h b/libexec/ld.so/resolve.h
index 82ac21b487b..ac90ac4a0e7 100644
--- a/libexec/ld.so/resolve.h
+++ b/libexec/ld.so/resolve.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolve.h,v 1.92 2019/05/11 21:02:35 guenther Exp $ */
+/* $OpenBSD: resolve.h,v 1.93 2019/07/21 03:54:16 guenther Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -368,9 +368,6 @@ typedef struct sym_cache {
int flags;
} sym_cache;
-extern sym_cache *_dl_symcache;
-extern int _dl_symcachestat_hits;
-extern int _dl_symcachestat_lookups;
TAILQ_HEAD(dlochld, dep_node);
extern struct dlochld _dlopened_child_list;
__END_HIDDEN_DECLS