Skip to content

Commit 14be4e6

Browse files
Jens Remuszx2c4
authored andcommitted
selftests: vDSO: fix ELF hash table entry size for s390x
The vDSO self tests fail on s390x for a vDSO linked with the GNU linker ld as follows: # ./vdso_test_gettimeofday Floating point exception (core dumped) On s390x the ELF hash table entries are 64 bits instead of 32 bits in size (see Glibc sysdeps/unix/sysv/linux/s390/bits/elfclass.h). Fixes: 4072341 ("kselftest: Enable vDSO test on non x86 platforms") Reported-by: Heiko Carstens <[email protected]> Tested-by: Heiko Carstens <[email protected]> Signed-off-by: Jens Remus <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 8072b39 commit 14be4e6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tools/testing/selftests/vDSO/parse_vdso.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
#define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x)
3737
#define ELF(x) ELF_BITS_XFORM(ELF_BITS, x)
3838

39+
#ifdef __s390x__
40+
#define ELF_HASH_ENTRY ELF(Xword)
41+
#else
42+
#define ELF_HASH_ENTRY ELF(Word)
43+
#endif
44+
3945
static struct vdso_info
4046
{
4147
bool valid;
@@ -47,8 +53,8 @@ static struct vdso_info
4753
/* Symbol table */
4854
ELF(Sym) *symtab;
4955
const char *symstrings;
50-
ELF(Word) *bucket, *chain;
51-
ELF(Word) nbucket, nchain;
56+
ELF_HASH_ENTRY *bucket, *chain;
57+
ELF_HASH_ENTRY nbucket, nchain;
5258

5359
/* Version table */
5460
ELF(Versym) *versym;
@@ -115,7 +121,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base)
115121
/*
116122
* Fish out the useful bits of the dynamic table.
117123
*/
118-
ELF(Word) *hash = 0;
124+
ELF_HASH_ENTRY *hash = 0;
119125
vdso_info.symstrings = 0;
120126
vdso_info.symtab = 0;
121127
vdso_info.versym = 0;
@@ -133,7 +139,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base)
133139
+ vdso_info.load_offset);
134140
break;
135141
case DT_HASH:
136-
hash = (ELF(Word) *)
142+
hash = (ELF_HASH_ENTRY *)
137143
((uintptr_t)dyn[i].d_un.d_ptr
138144
+ vdso_info.load_offset);
139145
break;

0 commit comments

Comments
 (0)