Skip to content

Commit

Permalink
Make the static analyzer happier in aarch64-darwin (JuliaLang#51861)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaraldi committed Oct 25, 2023
1 parent 6e5dd59 commit b5a531a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/debug-registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ class JITDebugInfoRegistry

struct libc_frames_t {
#if defined(_OS_DARWIN_) && defined(LLVM_SHLIB)
std::atomic<void(*)(void*)> libc_register_frame_{nullptr};
std::atomic<void(*)(void*)> libc_deregister_frame_{nullptr};
typedef void (*frame_register_func)(void *) JL_NOTSAFEPOINT;
std::atomic<frame_register_func> libc_register_frame_{nullptr};
std::atomic<frame_register_func> libc_deregister_frame_{nullptr};

void libc_register_frame(const char *Entry) JL_NOTSAFEPOINT;

Expand Down
4 changes: 2 additions & 2 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ static int lookup_pointer(
#if defined(_OS_DARWIN_) && defined(LLVM_SHLIB)

void JITDebugInfoRegistry::libc_frames_t::libc_register_frame(const char *Entry) {
auto libc_register_frame_ = jl_atomic_load_relaxed(&this->libc_register_frame_);
frame_register_func libc_register_frame_ = jl_atomic_load_relaxed(&this->libc_register_frame_);
if (!libc_register_frame_) {
libc_register_frame_ = (void(*)(void*))dlsym(RTLD_NEXT, "__register_frame");
jl_atomic_store_release(&this->libc_register_frame_, libc_register_frame_);
Expand All @@ -562,7 +562,7 @@ void JITDebugInfoRegistry::libc_frames_t::libc_register_frame(const char *Entry)
}

void JITDebugInfoRegistry::libc_frames_t::libc_deregister_frame(const char *Entry) {
auto libc_deregister_frame_ = jl_atomic_load_relaxed(&this->libc_deregister_frame_);
frame_register_func libc_deregister_frame_ = jl_atomic_load_relaxed(&this->libc_deregister_frame_);
if (!libc_deregister_frame_) {
libc_deregister_frame_ = (void(*)(void*))dlsym(RTLD_NEXT, "__deregister_frame");
jl_atomic_store_release(&this->libc_deregister_frame_, libc_deregister_frame_);
Expand Down
10 changes: 5 additions & 5 deletions src/stackwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ _os_tsd_get_direct(unsigned long slot)
// Unconditionally defined ptrauth_strip (instead of using the ptrauth.h header)
// since libsystem will likely be compiled with -mbranch-protection, and we currently are not.
// code from https://github.com/llvm/llvm-project/blob/7714e0317520207572168388f22012dd9e152e9e/compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
static inline uint64_t ptrauth_strip(uint64_t __value, unsigned int __key) {
static inline uint64_t ptrauth_strip(uint64_t __value, unsigned int __key) JL_NOTSAFEPOINT {
// On the stack the link register is protected with Pointer
// Authentication Code when compiled with -mbranch-protection.
// Let's strip the PAC unconditionally because xpaclri is in the NOP space,
Expand All @@ -809,7 +809,7 @@ static inline uint64_t ptrauth_strip(uint64_t __value, unsigned int __key) {

__attribute__((always_inline, pure))
static __inline__ void**
_os_tsd_get_base(void)
_os_tsd_get_base(void) JL_NOTSAFEPOINT
{
#if defined(__arm__)
uintptr_t tsd;
Expand All @@ -831,22 +831,22 @@ _os_tsd_get_base(void)
#ifdef _os_tsd_get_base
__attribute__((always_inline))
static __inline__ void*
_os_tsd_get_direct(unsigned long slot)
_os_tsd_get_direct(unsigned long slot) JL_NOTSAFEPOINT
{
return _os_tsd_get_base()[slot];
}
#endif

__attribute__((always_inline, pure))
static __inline__ uintptr_t
_os_ptr_munge_token(void)
_os_ptr_munge_token(void) JL_NOTSAFEPOINT
{
return (uintptr_t)_os_tsd_get_direct(__TSD_PTR_MUNGE);
}

__attribute__((always_inline, pure))
JL_UNUSED static __inline__ uintptr_t
_os_ptr_munge(uintptr_t ptr)
_os_ptr_munge(uintptr_t ptr) JL_NOTSAFEPOINT
{
return ptr ^ _os_ptr_munge_token();
}
Expand Down

0 comments on commit b5a531a

Please sign in to comment.