1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) 2020 Linaro Limited. All rights reserved. 4 * Author: Viresh Kumar <viresh.kumar@linaro.org> 5 */ 6 7 #ifndef PARSE_VDSO_H__ 8 #define PARSE_VDSO_H__ 9 10 #include <stdint.h> 11 12 /* 13 * To use this vDSO parser, first call one of the vdso_init_* functions. 14 * If you've already parsed auxv, then pass the value of AT_SYSINFO_EHDR 15 * to vdso_init_from_sysinfo_ehdr. Otherwise pass auxv to vdso_init_from_auxv. 16 * Then call vdso_sym for each symbol you want. For example, to look up 17 * gettimeofday on x86_64, use: 18 * 19 * <some pointer> = vdso_sym("LINUX_2.6", "gettimeofday"); 20 * or 21 * <some pointer> = vdso_sym("LINUX_2.6", "__vdso_gettimeofday"); 22 * 23 * vdso_sym will return 0 if the symbol doesn't exist or if the init function 24 * failed or was not called. vdso_sym is a little slow, so its return value 25 * should be cached. 26 * 27 * vdso_sym is threadsafe; the init functions are not. 28 * 29 * These are the prototypes: 30 */ 31 32 #include <time.h> 33 34 extern void vdso_init_from_auxv(void *auxv); 35 extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); 36 extern void *vdso_sym(const char *version, const char *name); 37 38 typedef int (*gettime_t)(clockid_t clk_id, void *ts); 39 void find_clock_gettime_vdso(gettime_t *ptr_vdso_gettime, 40 gettime_t *ptr_vdso_gettime64); 41 #endif /* PARSE_VDSO_H__ */ 42