From e95e36a795768d6c64b431b01cd1cd9c74bb1824 Mon Sep 17 00:00:00 2001 From: Andrew Haberlandt Date: Fri, 27 Dec 2024 04:01:44 -0500 Subject: [PATCH] only add the attribute on aarch64, i guess --- core/unix/os.c | 3 ++- core/unix/os_public.h | 6 ++++++ core/unix/preload.c | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/unix/os.c b/core/unix/os.c index cf490d602d3..500814b024f 100644 --- a/core/unix/os.c +++ b/core/unix/os.c @@ -784,7 +784,8 @@ static init_fn_t #else /* If we're a normal shared object, then we override _init. */ -int _init(int argc, char **argv, char **envp) +INITIALIZER_ATTRIBUTES int +_init(int argc, char **argv, char **envp) { # ifdef ANDROID /* i#1862: the Android loader passes *nothing* to lib init routines. We diff --git a/core/unix/os_public.h b/core/unix/os_public.h index 84899bcec88..e10f73a93e5 100644 --- a/core/unix/os_public.h +++ b/core/unix/os_public.h @@ -242,4 +242,10 @@ typedef kernel_sigcontext_t sigcontext_t; # define SC_RETURN_REG SC_A0 #endif /* X86/ARM */ +#if defined(MACOS) && defined(AARCH64) + #define INITIALIZER_ATTRIBUTES __attribute__((constructor)) +#else + #define INITIALIZER_ATTRIBUTES +#endif + #endif /* _OS_PUBLIC_H_ 1 */ diff --git a/core/unix/preload.c b/core/unix/preload.c index 934e71546fe..48fb62e83ca 100644 --- a/core/unix/preload.c +++ b/core/unix/preload.c @@ -50,6 +50,7 @@ #include "configure.h" #include "globals_shared.h" #include "../config.h" +#include "os_public.h" #include /* for getpid */ #include @@ -137,7 +138,7 @@ take_over(const char *pname) return true; } -int +INITIALIZER_ATTRIBUTES int #if INIT_BEFORE_LIBC _init(int argc, char *arg0, ...) {