From 46c063c6f939b410ece1edcf63c312d8283de4eb Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 20 Nov 2017 11:01:28 +0100 Subject: lib: Fix init and fini ELF sections for OS X OS X uses a different syntax for specifying ELF sections. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/dev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/dev.c b/src/lib/dev.c index 35a2328c..3c81d1db 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -468,8 +468,16 @@ static void fini(void) pthread_rwlock_destroy(&ai.lock); } -__attribute__((section(".init_array"))) __typeof__(init) * __init = init; -__attribute__((section(".fini_array"))) __typeof__(fini) * __fini = fini; +#if defined(__MACH__) && defined(__APPLE__) +#define INIT_SECTION "__DATA, __mod_init_func" +#define FINI_SECTION "__DATA, __mod_term_func" +#else +#define INIT_SECTION ".init_array" +#define FINI_SECTION ".fini_array" +#endif + +__attribute__((section(INIT_SECTION))) __typeof__(init) * __init = init; +__attribute__((section(FINI_SECTION))) __typeof__(fini) * __fini = fini; int flow_accept(qosspec_t * qs, const struct timespec * timeo) -- cgit v1.2.3