From 0277016bb5a33b412bd13af9905908524b709c7f Mon Sep 17 00:00:00 2001 From: usertam Date: Sat, 7 Jun 2025 20:41:30 +0800 Subject: [PATCH] Makefile.OSX: add -fptrauth-* flags for arm64e to work properly Particularly we need -fptrauth-calls, so when pthread_once indirectly calls ftpl_really_init, it won't fail PAC. --- src/Makefile.OSX | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Makefile.OSX b/src/Makefile.OSX index 9bdf922..e056f37 100644 --- a/src/Makefile.OSX +++ b/src/Makefile.OSX @@ -64,10 +64,16 @@ LIB_LDFLAGS += -dynamiclib -current_version 0.9.11 -compatibility_version 0.7 # Therefore, we now compile for two ABIs at the same time, producing a fat library of arm64e and arm64, # so in the end the OS gets to pick which architecture it wants at runtime. + +# In addition, we need to enable signing and authentication of indirect calls (-fptrauth-calls); +# otherwise in ftpl_init, pthread_once will indirectly call ftpl_really_init, which then fail PAC. +# Ideally this should be a compiler default for the arm64e ABI, but apparently not. + ARCH := $(shell uname -m) ifeq ($(ARCH),arm64) CFLAGS += -arch arm64e -arch arm64 + CFLAGS += -fptrauth-calls -fptrauth-returns endif SONAME = 1