Skip to content

Commit b418ea1

Browse files
committed
generalize ELF hash table types not to assume 32-bit entries
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.
1 parent 4078a5c commit b418ea1

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

arch/generic/bits/link.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
typedef uint32_t Elf_Symndx;

include/link.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ extern "C" {
1616
#define ElfW(type) Elf32_ ## type
1717
#endif
1818

19-
/* this is the same everywhere except alpha and s390 */
20-
typedef uint32_t Elf_Symndx;
19+
#include <bits/link.h>
2120

2221
struct dl_phdr_info {
2322
ElfW(Addr) dlpi_addr;

ldso/dynlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct dso {
5454
size_t phentsize;
5555
int refcnt;
5656
Sym *syms;
57-
uint32_t *hashtab;
57+
Elf_Symndx *hashtab;
5858
uint32_t *ghashtab;
5959
int16_t *versym;
6060
char *strings;
@@ -206,7 +206,7 @@ static Sym *sysv_lookup(const char *s, uint32_t h, struct dso *dso)
206206
{
207207
size_t i;
208208
Sym *syms = dso->syms;
209-
uint32_t *hashtab = dso->hashtab;
209+
Elf_Symndx *hashtab = dso->hashtab;
210210
char *strings = dso->strings;
211211
for (i=hashtab[2+h%hashtab[0]]; i; i=hashtab[2+hashtab[0]+i]) {
212212
if ((!dso->versym || dso->versym[i] >= 0)

src/internal/vdso.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <elf.h>
2+
#include <link.h>
23
#include <limits.h>
34
#include <stdint.h>
45
#include <string.h>
@@ -57,7 +58,7 @@ void *__vdsosym(const char *vername, const char *name)
5758

5859
char *strings = 0;
5960
Sym *syms = 0;
60-
uint32_t *hashtab = 0;
61+
Elf_Symndx *hashtab = 0;
6162
uint16_t *versym = 0;
6263
Verdef *verdef = 0;
6364

0 commit comments

Comments
 (0)