generalize ELF hash table types not to assume 32-bit entries
authorRich Felker <dalias@aerifal.cx>
Fri, 11 Nov 2016 17:30:24 +0000 (12:30 -0500)
committerRich Felker <dalias@aerifal.cx>
Fri, 11 Nov 2016 17:46:06 +0000 (12:46 -0500)
alpha and s390x gratuitously use 64-bit entries (wasting 2x space and
cache utilization) despite the values always being 32-bit.

based on patch by Bobby Bingham, with changes suggested by Alexander
Monakov to use the public Elf_Symndx type from link.h (and make it
properly variable by arch) rather than adding new internal
infrastructure for handling the type.

arch/generic/bits/link.h [new file with mode: 0644]
include/link.h
ldso/dynlink.c
src/internal/vdso.c

diff --git a/arch/generic/bits/link.h b/arch/generic/bits/link.h
new file mode 100644 (file)
index 0000000..4a94d8f
--- /dev/null
@@ -0,0 +1 @@
+typedef uint32_t Elf_Symndx;
index 9349cddd5da7de4f7fa3e2abbda8cdad07d47151..815018594c777b1513911cc04157e71fb7572015 100644 (file)
@@ -16,8 +16,7 @@ extern "C" {
 #define ElfW(type) Elf32_ ## type
 #endif
 
-/* this is the same everywhere except alpha and s390 */
-typedef uint32_t Elf_Symndx;
+#include <bits/link.h>
 
 struct dl_phdr_info {
        ElfW(Addr) dlpi_addr;
index acb73bc245a02269aba80ee70eae64082f326e2d..ad49cac28ccd12f8c1e937b4931a2bad1a7ddd00 100644 (file)
@@ -54,7 +54,7 @@ struct dso {
        size_t phentsize;
        int refcnt;
        Sym *syms;
-       uint32_t *hashtab;
+       Elf_Symndx *hashtab;
        uint32_t *ghashtab;
        int16_t *versym;
        char *strings;
@@ -206,7 +206,7 @@ static Sym *sysv_lookup(const char *s, uint32_t h, struct dso *dso)
 {
        size_t i;
        Sym *syms = dso->syms;
-       uint32_t *hashtab = dso->hashtab;
+       Elf_Symndx *hashtab = dso->hashtab;
        char *strings = dso->strings;
        for (i=hashtab[2+h%hashtab[0]]; i; i=hashtab[2+hashtab[0]+i]) {
                if ((!dso->versym || dso->versym[i] >= 0)
index 6ae0212e5c1ee7a784fa71dfb80981fa9bc8ffd7..a4862171e306d58082df8190410a6f8ce409438d 100644 (file)
@@ -1,4 +1,5 @@
 #include <elf.h>
+#include <link.h>
 #include <limits.h>
 #include <stdint.h>
 #include <string.h>
@@ -57,7 +58,7 @@ void *__vdsosym(const char *vername, const char *name)
 
        char *strings = 0;
        Sym *syms = 0;
-       uint32_t *hashtab = 0;
+       Elf_Symndx *hashtab = 0;
        uint16_t *versym = 0;
        Verdef *verdef = 0;