summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2006-05-06 21:01:31 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2006-05-06 21:01:31 +0000
commita306371e0b29cdcce70e52413724e64eee634918 (patch)
treee81ef45912d4e09c2afbfd98269f5082dce2d855
parentd09449bf7d4d5000014dd1a06db6de40a99c1aa9 (diff)
If there is a conflict between two symbols, and one of the symbols is a
reference to the local object, go ahead and save save the local symbol in the library cache, a fixup will be generated in any binary which overrides the symbol, however, the rest of the program which do not override the symbol will not have to pay for the fixup. Cuts about of prebind data here by 32%
-rw-r--r--libexec/ld.so/prebind/prebind.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/libexec/ld.so/prebind/prebind.c b/libexec/ld.so/prebind/prebind.c
index 83d9f99cd02..9b05fd1836d 100644
--- a/libexec/ld.so/prebind/prebind.c
+++ b/libexec/ld.so/prebind/prebind.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: prebind.c,v 1.11 2006/05/05 16:46:03 drahn Exp $ */
+/* $OpenBSD: prebind.c,v 1.12 2006/05/06 21:01:30 drahn Exp $ */
/*
* Copyright (c) 2006 Dale Rahn <drahn@dalerahn.com>
*
@@ -1066,12 +1066,7 @@ elf_newbin(void)
* It probably would be interesting to modify this to keep the most
* common entry as a library cache, and only have a fixup in programs
* where the symbol is overridden.
- *
- * Note 1: If 'merge' mode is ever written, this will need to keep
- * the 'cached' copies symbols and do fixups for the rest, regardless
- * of conflicts
- *
- * Note 2: This is run once each for the (got)symcache and pltsymcache
+ * This is run once each for the (got)symcache and pltsymcache
*/
struct elf_object badobj_store;
@@ -1117,8 +1112,25 @@ elf_copy_syms(struct symcache_noflag *tcache, struct symcache_noflag *scache,
scache[i].sym->st_name +
scache[i].obj->dyn.strtab);
#endif
- tcache[i].obj = badobj;
- tcache[i].sym = NULL;
+ /*
+ * if one of the symbol entries
+ * happens to be a self reference
+ * go ahead and keep that reference
+ * prevents some instances of fixups
+ * for every binary, eg one program
+ * overriding malloc() will not make
+ * ever binary have a fixup for libc
+ * references to malloc()
+ */
+ if (scache[i].obj == obj) {
+ tcache[i].obj = scache[i].obj;
+ tcache[i].sym = scache[i].sym;
+ } else if (tcache[i].obj == obj) {
+ /* no change necessary */
+ } else {
+ tcache[i].obj = badobj;
+ tcache[i].sym = NULL;
+ }
}
} else {
if (scache[i].obj != prog) {
@@ -1128,8 +1140,8 @@ elf_copy_syms(struct symcache_noflag *tcache, struct symcache_noflag *scache,
scache[i].sym->st_name +
scache[i].obj->dyn.strtab);
#endif
- tcache[i].sym = scache[i].sym;
tcache[i].obj = scache[i].obj;
+ tcache[i].sym = scache[i].sym;
}
}