162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci#ifndef PARSE_VDSO_H
462306a36Sopenharmony_ci#define PARSE_VDSO_H
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#include <stdint.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci/*
962306a36Sopenharmony_ci * To use this vDSO parser, first call one of the vdso_init_* functions.
1062306a36Sopenharmony_ci * If you've already parsed auxv, then pass the value of AT_SYSINFO_EHDR
1162306a36Sopenharmony_ci * to vdso_init_from_sysinfo_ehdr.  Otherwise pass auxv to vdso_init_from_auxv.
1262306a36Sopenharmony_ci * Then call vdso_sym for each symbol you want.  For example, to look up
1362306a36Sopenharmony_ci * gettimeofday on x86_64, use:
1462306a36Sopenharmony_ci *
1562306a36Sopenharmony_ci *     <some pointer> = vdso_sym("LINUX_2.6", "gettimeofday");
1662306a36Sopenharmony_ci * or
1762306a36Sopenharmony_ci *     <some pointer> = vdso_sym("LINUX_2.6", "__vdso_gettimeofday");
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci * vdso_sym will return 0 if the symbol doesn't exist or if the init function
2062306a36Sopenharmony_ci * failed or was not called.  vdso_sym is a little slow, so its return value
2162306a36Sopenharmony_ci * should be cached.
2262306a36Sopenharmony_ci *
2362306a36Sopenharmony_ci * vdso_sym is threadsafe; the init functions are not.
2462306a36Sopenharmony_ci *
2562306a36Sopenharmony_ci * These are the prototypes:
2662306a36Sopenharmony_ci */
2762306a36Sopenharmony_civoid *vdso_sym(const char *version, const char *name);
2862306a36Sopenharmony_civoid vdso_init_from_sysinfo_ehdr(uintptr_t base);
2962306a36Sopenharmony_civoid vdso_init_from_auxv(void *auxv);
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#endif
32