Skip to content

Commit

Permalink
selftests: vdso_test: support ARM64 targets
Browse files Browse the repository at this point in the history
ARM64's vDSO exports its gettimeofday() implementation with a different
name (__kernel_gettimeofday) and version (LINUX_2.6.39) from other
architectures.  Add a corresponding special-case to vdso_test.

Signed-off-by: Greg Hackmann <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
greghackmann authored and Shuah Khan committed Nov 15, 2017
1 parent 8d17a6f commit 2650554
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tools/testing/selftests/vDSO/vdso_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ extern void *vdso_sym(const char *version, const char *name);
extern void vdso_init_from_sysinfo_ehdr(uintptr_t base);
extern void vdso_init_from_auxv(void *auxv);

/*
* ARM64's vDSO exports its gettimeofday() implementation with a different
* name and version from other architectures, so we need to handle it as
* a special case.
*/
#if defined(__aarch64__)
const char *version = "LINUX_2.6.39";
const char *name = "__kernel_gettimeofday";
#else
const char *version = "LINUX_2.6";
const char *name = "__vdso_gettimeofday";
#endif

int main(int argc, char **argv)
{
unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
Expand All @@ -31,10 +44,10 @@ int main(int argc, char **argv)

/* Find gettimeofday. */
typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
gtod_t gtod = (gtod_t)vdso_sym("LINUX_2.6", "__vdso_gettimeofday");
gtod_t gtod = (gtod_t)vdso_sym(version, name);

if (!gtod) {
printf("Could not find __vdso_gettimeofday\n");
printf("Could not find %s\n", name);
return 1;
}

Expand All @@ -45,7 +58,7 @@ int main(int argc, char **argv)
printf("The time is %lld.%06lld\n",
(long long)tv.tv_sec, (long long)tv.tv_usec);
} else {
printf("__vdso_gettimeofday failed\n");
printf("%s failed\n", name);
}

return 0;
Expand Down

0 comments on commit 2650554

Please sign in to comment.