18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci#ifndef PARSE_VDSO_H
48c2ecf20Sopenharmony_ci#define PARSE_VDSO_H
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <stdint.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/*
98c2ecf20Sopenharmony_ci * To use this vDSO parser, first call one of the vdso_init_* functions.
108c2ecf20Sopenharmony_ci * If you've already parsed auxv, then pass the value of AT_SYSINFO_EHDR
118c2ecf20Sopenharmony_ci * to vdso_init_from_sysinfo_ehdr.  Otherwise pass auxv to vdso_init_from_auxv.
128c2ecf20Sopenharmony_ci * Then call vdso_sym for each symbol you want.  For example, to look up
138c2ecf20Sopenharmony_ci * gettimeofday on x86_64, use:
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci *     <some pointer> = vdso_sym("LINUX_2.6", "gettimeofday");
168c2ecf20Sopenharmony_ci * or
178c2ecf20Sopenharmony_ci *     <some pointer> = vdso_sym("LINUX_2.6", "__vdso_gettimeofday");
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * vdso_sym will return 0 if the symbol doesn't exist or if the init function
208c2ecf20Sopenharmony_ci * failed or was not called.  vdso_sym is a little slow, so its return value
218c2ecf20Sopenharmony_ci * should be cached.
228c2ecf20Sopenharmony_ci *
238c2ecf20Sopenharmony_ci * vdso_sym is threadsafe; the init functions are not.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * These are the prototypes:
268c2ecf20Sopenharmony_ci */
278c2ecf20Sopenharmony_civoid *vdso_sym(const char *version, const char *name);
288c2ecf20Sopenharmony_civoid vdso_init_from_sysinfo_ehdr(uintptr_t base);
298c2ecf20Sopenharmony_civoid vdso_init_from_auxv(void *auxv);
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#endif
32