Commit fcd18783 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Andrei Vagin

zdtm/vdso01/ia32: add ia32 test version

Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 6ae6cbdf
...@@ -18,6 +18,47 @@ ...@@ -18,6 +18,47 @@
const char *test_doc = "Check if we can use vDSO using direct vDSO calls\n"; const char *test_doc = "Check if we can use vDSO using direct vDSO calls\n";
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org"; const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org";
#ifdef __i386__
# define Ehdr_t Elf32_Ehdr
# define Sym_t Elf32_Sym
# define Phdr_t Elf32_Phdr
# define Word_t Elf32_Word
# define Dyn_t Elf32_Dyn
# define ELF_ST_TYPE ELF32_ST_TYPE
# define ELF_ST_BIND ELF32_ST_BIND
const char elf_ident[] = {
0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#else /* non-i386 */
# define Ehdr_t Elf64_Ehdr
# define Sym_t Elf64_Sym
# define Phdr_t Elf64_Phdr
# define Word_t Elf64_Word
# define Dyn_t Elf64_Dyn
# ifndef ELF_ST_TYPE
# define ELF_ST_TYPE ELF64_ST_TYPE
# endif
# ifndef ELF_ST_BIND
# define ELF_ST_BIND ELF64_ST_BIND
# endif
/*
* See Elf specification for this magic values.
*/
const char elf_ident[] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#endif
typedef int (__vdso_clock_gettime_t)(clockid_t clock, struct timespec *ts); typedef int (__vdso_clock_gettime_t)(clockid_t clock, struct timespec *ts);
typedef long (__vdso_getcpu_t)(unsigned *cpu, unsigned *node, void *unused); typedef long (__vdso_getcpu_t)(unsigned *cpu, unsigned *node, void *unused);
typedef int (__vdso_gettimeofday_t)(struct timeval *tv, struct timezone *tz); typedef int (__vdso_gettimeofday_t)(struct timeval *tv, struct timezone *tz);
...@@ -96,27 +137,19 @@ static unsigned long elf_hash(const unsigned char *name) ...@@ -96,27 +137,19 @@ static unsigned long elf_hash(const unsigned char *name)
static int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t) static int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
{ {
Elf64_Phdr *dynamic = NULL, *load = NULL; Phdr_t *dynamic = NULL, *load = NULL;
Elf64_Ehdr *ehdr = (void *)mem; Ehdr_t *ehdr = (void *)mem;
Elf64_Dyn *dyn_strtab = NULL; Dyn_t *dyn_strtab = NULL;
Elf64_Dyn *dyn_symtab = NULL; Dyn_t *dyn_symtab = NULL;
Elf64_Dyn *dyn_strsz = NULL; Dyn_t *dyn_strsz = NULL;
Elf64_Dyn *dyn_syment = NULL; Dyn_t *dyn_syment = NULL;
Elf64_Dyn *dyn_hash = NULL; Dyn_t *dyn_hash = NULL;
Elf64_Word *hash = NULL; Word_t *hash = NULL;
Elf64_Phdr *phdr; Phdr_t *phdr;
Elf64_Dyn *d; Dyn_t *d;
Elf64_Word *bucket, *chain; Word_t *bucket, *chain;
Elf64_Word nbucket, nchain; Word_t nbucket, nchain;
/*
* See Elf specification for this magic values.
*/
const char elf_ident[] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
char *dynsymbol_names; char *dynsymbol_names;
unsigned int i, j, k; unsigned int i, j, k;
...@@ -214,15 +247,15 @@ static int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t) ...@@ -214,15 +247,15 @@ static int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
k = elf_hash((const unsigned char *)vdso_symbols[i]); k = elf_hash((const unsigned char *)vdso_symbols[i]);
for (j = bucket[k % nbucket]; j < nchain && chain[j] != STN_UNDEF; j = chain[j]) { for (j = bucket[k % nbucket]; j < nchain && chain[j] != STN_UNDEF; j = chain[j]) {
Elf64_Sym *sym = (void *)&mem[dyn_symtab->d_un.d_ptr - load->p_vaddr]; Sym_t *sym = (void *)&mem[dyn_symtab->d_un.d_ptr - load->p_vaddr];
char *name; char *name;
sym = &sym[j]; sym = &sym[j];
if (__ptr_oob(sym, mem, size)) if (__ptr_oob(sym, mem, size))
continue; continue;
if (ELF64_ST_TYPE(sym->st_info) != STT_FUNC && if (ELF_ST_TYPE(sym->st_info) != STT_FUNC &&
ELF64_ST_BIND(sym->st_info) != STB_GLOBAL) ELF_ST_BIND(sym->st_info) != STB_GLOBAL)
continue; continue;
name = &dynsymbol_names[sym->st_name]; name = &dynsymbol_names[sym->st_name];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment