Skip to content

Commit

Permalink
only add the attribute on aarch64, i guess
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrewh committed Dec 27, 2024
1 parent a4c71c2 commit e95e36a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/unix/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions core/unix/os_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
3 changes: 2 additions & 1 deletion core/unix/preload.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "configure.h"
#include "globals_shared.h"
#include "../config.h"
#include "os_public.h"
#include <stdio.h>
/* for getpid */
#include <unistd.h>
Expand Down Expand Up @@ -137,7 +138,7 @@ take_over(const char *pname)
return true;
}

int
INITIALIZER_ATTRIBUTES int
#if INIT_BEFORE_LIBC
_init(int argc, char *arg0, ...)
{
Expand Down

0 comments on commit e95e36a

Please sign in to comment.