On 25/10/2023 14:10, Aditya Deshpande wrote:
$(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c $(OUTPUT)/vdso_test_getcpu: parse_vdso.c vdso_test_getcpu.c $(OUTPUT)/vdso_test_abi: parse_vdso.c vdso_test_abi.c diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/selftests/vDSO/vdso_config.h index cdfed403ba13..90082a60a2b1 100644 --- a/tools/testing/selftests/vDSO/vdso_config.h +++ b/tools/testing/selftests/vDSO/vdso_config.h
I'm confused, vdso_test_gettimeofday.c doesn't seem to be including this file?
That's strange, especially given that the disassembly of the built test shows a call to getauxptr(). Nevertheless, I'll explicitly include vdso_config.h in the tests that use this get_sysinfo_ehdr()
You might have missed a warning (I recommend building with -Werror). Calling an undeclared function is actually legal in C, though it's not a good idea for various reasons.
+#define get_sysinfo_ehdr() (getauxptr(AT_SYSINFO_EHDR))
Using inline functions is generally preferred over macros, if possible, which seems to be the case here. Something like:
static inline uintptr_t get_sysinfo_ehdr(void)
Makes sense, however wouldn't we use just inline rather than static inline as this function will be used across different .c files?
inline is a bit of a nightmare in C, as illustrated by the GCC manual [1]. The TL;DR is that you almost always want static inline, as it doesn't incur any linkage trouble.
Kevin