From 04654ba7b57ccbf583db899a327f8f7000f90546 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Fri, 27 Jan 2023 23:51:20 -0800 Subject: [PATCH] tests: Update os-wrappers-test to build on non-ELF platforms The !ELF case just avoids the weak link-fu that was added to support sanitizers. Signed-off-by: Jeremy Huddleston Sequoia --- tests/os-wrappers-test.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/os-wrappers-test.c b/tests/os-wrappers-test.c index 717fc19f..50218594 100644 --- a/tests/os-wrappers-test.c +++ b/tests/os-wrappers-test.c @@ -47,6 +47,7 @@ static int fall_back; +#ifdef __ELF__ /* Play nice with sanitizers * * Sanitizers need to intercept syscalls in the compiler run-time library. As @@ -71,6 +72,13 @@ static int fall_back; #define REAL(func) (__interceptor_ ## func) ? \ __interceptor_ ## func : \ (__typeof__(&__interceptor_ ## func))dlsym(RTLD_NEXT, #func) +#else +#define DECL(ret_type, func, ...) \ + static ret_type (*real_ ## func)(__VA_ARGS__); \ + static int wrapped_calls_ ## func; + +#define REAL(func) (__typeof__(real_ ## func)) dlsym(RTLD_NEXT, #func) +#endif DECL(int, socket, int, int, int); DECL(int, fcntl, int, int, ...);