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
This commit is contained in:
Justine Tunney 2024-01-08 13:26:28 -08:00
parent 21093044c0
commit 6ab01716ce
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
5 changed files with 15 additions and 19 deletions

View file

@ -66,7 +66,7 @@ set -- --regex-c='/^extern [^(]*(\*const \([^)]*\))(/\1/b' "$@"
# struct WorstSoftwareEver;
set -- --regex-c='/^struct.*;$/uehocruehcroue/b' "$@"
exec $TAGS \
build/run $TAGS \
-e \
--langmap=c:.c.h \
--exclude=libc/nt/struct/imagefileheader.internal.h \

View file

@ -1,9 +1,8 @@
#!/bin/sh
if printf '%s\n' "$*" | grep aarch64 >/dev/null 2>&1; then
if [ ! -f o/third_party/qemu/qemu-aarch64 ]; then
make -j8 o/third_party/qemu/qemu-aarch64
fi
exec o/third_party/qemu/qemu-aarch64 "$@"
UNAMEM=$(uname -m)
UNAMES=$(uname -s)
if [ x"$UNAMES" = x"Darwin" ] && [ x"$UNAMEM" = x"arm64" ]; then
exec ape "$@"
else
exec "$@"
fi

View file

@ -43,13 +43,13 @@ _longjmp:
mov 48(%rdi),%r15
jmp *56(%rdi)
#elif defined(__aarch64__)
ldp x19,x20,[x0,#0]
ldp x21,x22,[x0,#16]
ldp x29,x30,[x0,#0]
ldp x2,x22,[x0,#16]
ldp x23,x24,[x0,#32]
ldp x25,x26,[x0,#48]
ldp x27,x28,[x0,#64]
ldp x29,x30,[x0,#80]
ldr x2,[x0,#104]
ldp x19,x20,[x0,#80]
ldr x21,[x0,#104]
mov sp,x2
ldp d8 ,d9,[x0,#112]
ldp d10,d11,[x0,#128]

View file

@ -44,14 +44,14 @@ _setjmp:
xor %eax,%eax
ret
#elif defined(__aarch64__)
stp x19,x20,[x0,#0]
stp x21,x22,[x0,#16]
mov x2,sp
stp x29,x30,[x0,#0]
stp x2,x22,[x0,#16]
stp x23,x24,[x0,#32]
stp x25,x26,[x0,#48]
stp x27,x28,[x0,#64]
stp x29,x30,[x0,#80]
mov x2,sp
str x2,[x0,#104]
stp x19,x20,[x0,#80]
str x21,[x0,#104]
stp d8,d9,[x0,#112]
stp d10,d11,[x0,#128]
stp d12,d13,[x0,#144]

View file

@ -1,8 +1,6 @@
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘
ifeq ($(MODE), )
PKGS += THIRD_PARTY_LIBCXXABI_TEST
THIRD_PARTY_LIBCXXABI_TEST_A = o/$(MODE)/third_party/libcxxabi/test/test.a
@ -109,6 +107,7 @@ THIRD_PARTY_LIBCXXABI_TEST_CHECKS = \
THIRD_PARTY_LIBCXXABI_TEST_DIRECTDEPS = \
LIBC_NEXGEN32E \
LIBC_LOG \
THIRD_PARTY_LIBCXX \
THIRD_PARTY_LIBCXXABI
@ -168,8 +167,6 @@ o/$(MODE)/third_party/libcxxabi/test/incomplete_type.sh.com.dbg: \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
endif
o/$(MODE)/third_party/libcxxabi/test/catch_multi_level_pointer.pass.o: private COPTS += -O0
o/$(MODE)/third_party/libcxxabi/test/catch_multi_level_pointer.pass.o: private QUOTA += -C30 -M4000m