Skip to content

Commit 6ab0171

Browse files
committed
Fix aarch64 setjmp abi
We now store values in jmp_buf where the compiler wants them to be. This fixes code that calls __builtin_setjmp() and __builtin_longjmp() such as libunwind. All libcxxabi tests are now passing on ARM64. See #1076
1 parent 2109304 commit 6ab0171

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

build/htags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ set -- --regex-c='/^extern [^(]*(\*const \([^)]*\))(/\1/b' "$@"
6666
# struct WorstSoftwareEver;
6767
set -- --regex-c='/^struct.*;$/uehocruehcroue/b' "$@"
6868

69-
exec $TAGS \
69+
build/run $TAGS \
7070
-e \
7171
--langmap=c:.c.h \
7272
--exclude=libc/nt/struct/imagefileheader.internal.h \

build/run

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/bin/sh
2-
if printf '%s\n' "$*" | grep aarch64 >/dev/null 2>&1; then
3-
if [ ! -f o/third_party/qemu/qemu-aarch64 ]; then
4-
make -j8 o/third_party/qemu/qemu-aarch64
5-
fi
6-
exec o/third_party/qemu/qemu-aarch64 "$@"
2+
UNAMEM=$(uname -m)
3+
UNAMES=$(uname -s)
4+
if [ x"$UNAMES" = x"Darwin" ] && [ x"$UNAMEM" = x"arm64" ]; then
5+
exec ape "$@"
76
else
87
exec "$@"
98
fi

libc/nexgen32e/longjmp.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ _longjmp:
4343
mov 48(%rdi),%r15
4444
jmp *56(%rdi)
4545
#elif defined(__aarch64__)
46-
ldp x19,x20,[x0,#0]
47-
ldp x21,x22,[x0,#16]
46+
ldp x29,x30,[x0,#0]
47+
ldp x2,x22,[x0,#16]
4848
ldp x23,x24,[x0,#32]
4949
ldp x25,x26,[x0,#48]
5050
ldp x27,x28,[x0,#64]
51-
ldp x29,x30,[x0,#80]
52-
ldr x2,[x0,#104]
51+
ldp x19,x20,[x0,#80]
52+
ldr x21,[x0,#104]
5353
mov sp,x2
5454
ldp d8 ,d9,[x0,#112]
5555
ldp d10,d11,[x0,#128]

libc/nexgen32e/setjmp.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ _setjmp:
4444
xor %eax,%eax
4545
ret
4646
#elif defined(__aarch64__)
47-
stp x19,x20,[x0,#0]
48-
stp x21,x22,[x0,#16]
47+
mov x2,sp
48+
stp x29,x30,[x0,#0]
49+
stp x2,x22,[x0,#16]
4950
stp x23,x24,[x0,#32]
5051
stp x25,x26,[x0,#48]
5152
stp x27,x28,[x0,#64]
52-
stp x29,x30,[x0,#80]
53-
mov x2,sp
54-
str x2,[x0,#104]
53+
stp x19,x20,[x0,#80]
54+
str x21,[x0,#104]
5555
stp d8,d9,[x0,#112]
5656
stp d10,d11,[x0,#128]
5757
stp d12,d13,[x0,#144]

third_party/libcxxabi/test/BUILD.mk

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
22
#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘
33

4-
ifeq ($(MODE), )
5-
64
PKGS += THIRD_PARTY_LIBCXXABI_TEST
75

86
THIRD_PARTY_LIBCXXABI_TEST_A = o/$(MODE)/third_party/libcxxabi/test/test.a
@@ -109,6 +107,7 @@ THIRD_PARTY_LIBCXXABI_TEST_CHECKS = \
109107

110108
THIRD_PARTY_LIBCXXABI_TEST_DIRECTDEPS = \
111109
LIBC_NEXGEN32E \
110+
LIBC_LOG \
112111
THIRD_PARTY_LIBCXX \
113112
THIRD_PARTY_LIBCXXABI
114113

@@ -168,8 +167,6 @@ o/$(MODE)/third_party/libcxxabi/test/incomplete_type.sh.com.dbg: \
168167
$(APE_NO_MODIFY_SELF)
169168
@$(APELINK)
170169

171-
endif
172-
173170
o/$(MODE)/third_party/libcxxabi/test/catch_multi_level_pointer.pass.o: private COPTS += -O0
174171
o/$(MODE)/third_party/libcxxabi/test/catch_multi_level_pointer.pass.o: private QUOTA += -C30 -M4000m
175172

0 commit comments

Comments
 (0)