Skip to content

Commit

Permalink
py/nlraarch64: Add underscore prefix to function symbols for Darwin ABI.
Browse files Browse the repository at this point in the history
The proper way to do this is to test for __APPLE__ and __MACH__, where
__APPLE__ tests for an Apple OS and __MACH__ tests that it is based on CMU
Mach.  Using both tests ensures that just Darwin (Apple's open source base
for MacOS, iOS, etc.) is recognized. __APPLE__ by itself will test for any
Apple OS, which can include older OS 7-9 and any future Apple OS. __MACH__
tests for any OS based on CMU Mach, including Darwin and GNU Hurd.

Fixes #7232.
  • Loading branch information
Bob Abeles authored and dpgeorge committed May 18, 2021
1 parent 6d2680f commit 126b1c7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions py/nlraarch64.c
Expand Up @@ -34,8 +34,13 @@
// Implemented purely as inline assembly; inside a function, we have to deal with undoing the prologue, restoring
// SP and LR. This way, we don't.
__asm(
#if defined(__APPLE__) && defined(__MACH__)
"_nlr_push: \n"
".global _nlr_push \n"
#else
"nlr_push: \n"
".global nlr_push \n"
#endif
"mov x9, sp \n"
"stp lr, x9, [x0, #16]\n" // 16 == offsetof(nlr_buf_t, regs)
"stp x19, x20, [x0, #32]\n"
Expand All @@ -44,7 +49,11 @@ __asm(
"stp x25, x26, [x0, #80]\n"
"stp x27, x28, [x0, #96]\n"
"str x29, [x0, #112]\n"
#if defined(__APPLE__) && defined(__MACH__)
"b _nlr_push_tail \n" // do the rest in C
#else
"b nlr_push_tail \n" // do the rest in C
#endif
);

NORETURN void nlr_jump(void *val) {
Expand Down

0 comments on commit 126b1c7

Please sign in to comment.