From 40e77dad836abf130bf49af1838d108f0fc2e94e Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 25 Sep 2019 15:15:52 -0400 Subject: [PATCH] musl [PATCH] arm: fix setjmp and longjmp asm for armv8-a From: Szabolcs Nagy armv8 removed the coprocessor instructions other than cp14, so on an armv8 system the related hwcaps should never be set. new llvm complains about the use of coprocessor instructions in armv8-a mode (even though they are never executed at runtime), so ifdef them out when musl is built for armv8. i think the patch looks ok --- lib/libc/musl/src/setjmp/arm/{longjmp.s => longjmp.S} | 7 +++++++ lib/libc/musl/src/setjmp/arm/{setjmp.s => setjmp.S} | 7 +++++++ src/install_files.h | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) rename lib/libc/musl/src/setjmp/arm/{longjmp.s => longjmp.S} (87%) rename lib/libc/musl/src/setjmp/arm/{setjmp.s => setjmp.S} (88%) diff --git a/lib/libc/musl/src/setjmp/arm/longjmp.s b/lib/libc/musl/src/setjmp/arm/longjmp.S similarity index 87% rename from lib/libc/musl/src/setjmp/arm/longjmp.s rename to lib/libc/musl/src/setjmp/arm/longjmp.S index 76cc2920a3c9f0654fde5a9c6006afb9169f3666..8df0b8190dd7c8f8be90f6c089b7469c43d7a373 100644 --- a/lib/libc/musl/src/setjmp/arm/longjmp.s +++ b/lib/libc/musl/src/setjmp/arm/longjmp.S @@ -16,11 +16,14 @@ longjmp: ldr r2,1f ldr r1,[r1,r2] +#if __ARM_ARCH < 8 tst r1,#0x260 beq 3f + // HWCAP_ARM_FPA tst r1,#0x20 beq 2f ldc p2, cr4, [ip], #48 +#endif 2: tst r1,#0x40 beq 2f .fpu vfp @@ -28,6 +31,8 @@ longjmp: .fpu softvfp .eabi_attribute 10, 0 .eabi_attribute 27, 0 +#if __ARM_ARCH < 8 + // HWCAP_ARM_IWMMXT 2: tst r1,#0x200 beq 3f ldcl p1, cr10, [ip], #8 @@ -36,6 +41,8 @@ longjmp: ldcl p1, cr13, [ip], #8 ldcl p1, cr14, [ip], #8 ldcl p1, cr15, [ip], #8 +#endif +2: 3: bx lr .hidden __hwcap diff --git a/lib/libc/musl/src/setjmp/arm/setjmp.s b/lib/libc/musl/src/setjmp/arm/setjmp.S similarity index 88% rename from lib/libc/musl/src/setjmp/arm/setjmp.s rename to lib/libc/musl/src/setjmp/arm/setjmp.S index 011315b70f94b2e3d5cdc5d86d2333a34a1fb442..45731d228e80fb236b98d2f614a1c29854beea3a 100644 --- a/lib/libc/musl/src/setjmp/arm/setjmp.s +++ b/lib/libc/musl/src/setjmp/arm/setjmp.S @@ -18,11 +18,14 @@ setjmp: ldr r2,1f ldr r1,[r1,r2] +#if __ARM_ARCH < 8 tst r1,#0x260 beq 3f + // HWCAP_ARM_FPA tst r1,#0x20 beq 2f stc p2, cr4, [ip], #48 +#endif 2: tst r1,#0x40 beq 2f .fpu vfp @@ -30,6 +33,8 @@ setjmp: .fpu softvfp .eabi_attribute 10, 0 .eabi_attribute 27, 0 +#if __ARM_ARCH < 8 + // HWCAP_ARM_IWMMXT 2: tst r1,#0x200 beq 3f stcl p1, cr10, [ip], #8 @@ -38,6 +43,8 @@ setjmp: stcl p1, cr13, [ip], #8 stcl p1, cr14, [ip], #8 stcl p1, cr15, [ip], #8 +#endif +2: 3: bx lr .hidden __hwcap diff --git a/src/install_files.h b/src/install_files.h index 138d0f5278a75557f023b830b466468ac24bbcde..5e89c07b54f6fdbf85dcad7c60670b78e93633e7 100644 --- a/src/install_files.h +++ b/src/install_files.h @@ -1155,8 +1155,8 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/select/select.c", "musl/src/setjmp/aarch64/longjmp.s", "musl/src/setjmp/aarch64/setjmp.s", -"musl/src/setjmp/arm/longjmp.s", -"musl/src/setjmp/arm/setjmp.s", +"musl/src/setjmp/arm/longjmp.S", +"musl/src/setjmp/arm/setjmp.S", "musl/src/setjmp/i386/longjmp.s", "musl/src/setjmp/i386/setjmp.s", "musl/src/setjmp/longjmp.c", -- 2.54.0