diff --git a/arm-multilib/json/multilib.json b/arm-multilib/json/multilib.json index bc24d620..73d1bc95 100644 --- a/arm-multilib/json/multilib.json +++ b/arm-multilib/json/multilib.json @@ -10,7 +10,7 @@ "json": "aarch64a.json", "flags": "--target=aarch64-unknown-none-elf -fno-exceptions -fno-rtti" }, - { + { "variant": "aarch64a_be_exn_rtti", "json": "aarch64a_be_exn_rtti.json", "flags": "--target=aarch64_be-unknown-none-elf" @@ -20,6 +20,16 @@ "json": "aarch64a_be.json", "flags": "--target=aarch64_be-unknown-none-elf -fno-exceptions -fno-rtti" }, + { + "variant": "aarch64a_strictalign_exn_rtti", + "json": "aarch64a_strictalign_exn_rtti.json", + "flags": "--target=aarch64-unknown-none-elf -mno-unaligned-access" + }, + { + "variant": "aarch64a_strictalign", + "json": "aarch64a_strictalign.json", + "flags": "--target=aarch64-unknown-none-elf -mno-unaligned-access -fno-exceptions -fno-rtti" + }, { "variant": "armv4t_exn_rtti", "json": "armv4t_exn_rtti.json", diff --git a/arm-multilib/json/variants/aarch64a_strictalign.json b/arm-multilib/json/variants/aarch64a_strictalign.json new file mode 100644 index 00000000..98cc33c1 --- /dev/null +++ b/arm-multilib/json/variants/aarch64a_strictalign.json @@ -0,0 +1,40 @@ +{ + "args": { + "common": { + "TARGET_ARCH": "aarch64a", + "VARIANT": "aarch64a_strictalign", + "COMPILE_FLAGS": "-march=armv8-a -mno-unaligned-access", + "ENABLE_EXCEPTIONS": "OFF", + "ENABLE_RTTI": "OFF", + "TEST_EXECUTOR": "fvp", + "FVP_MODEL": "aem-a", + "FVP_CONFIG": "v8a-aarch64", + "BOOT_FLASH_ADDRESS": "0x80000000", + "BOOT_FLASH_SIZE": "0x1000", + "FLASH_ADDRESS": "0x80001000", + "FLASH_SIZE": "0xfff000", + "RAM_ADDRESS": "0x81000000", + "RAM_SIZE": "0x1000000", + "STACK_SIZE": "8K" + }, + "picolibc": { + "PICOLIBC_BUILD_TYPE": "release", + "ENABLE_CXX_LIBS": "ON", + "ENABLE_LIBC_TESTS": "ON", + "ENABLE_COMPILER_RT_TESTS": "OFF", + "ENABLE_LIBCXX_TESTS": "OFF" + }, + "newlib": { + "ENABLE_CXX_LIBS": "ON", + "ENABLE_LIBC_TESTS": "OFF", + "ENABLE_COMPILER_RT_TESTS": "OFF", + "ENABLE_LIBCXX_TESTS": "OFF" + }, + "llvmlibc": { + "ENABLE_CXX_LIBS": "OFF", + "ENABLE_LIBC_TESTS": "OFF", + "ENABLE_COMPILER_RT_TESTS": "OFF", + "ENABLE_LIBCXX_TESTS": "OFF" + } + } +} diff --git a/arm-multilib/json/variants/aarch64a_strictalign_exn_rtti.json b/arm-multilib/json/variants/aarch64a_strictalign_exn_rtti.json new file mode 100644 index 00000000..1f579b9c --- /dev/null +++ b/arm-multilib/json/variants/aarch64a_strictalign_exn_rtti.json @@ -0,0 +1,40 @@ +{ + "args": { + "common": { + "TARGET_ARCH": "aarch64a", + "VARIANT": "aarch64a_strictalign_exn_rtti", + "COMPILE_FLAGS": "-march=armv8-a -mno-unaligned-access", + "ENABLE_EXCEPTIONS": "ON", + "ENABLE_RTTI": "ON", + "TEST_EXECUTOR": "fvp", + "FVP_MODEL": "aem-a", + "FVP_CONFIG": "v8a-aarch64", + "BOOT_FLASH_ADDRESS": "0x80000000", + "BOOT_FLASH_SIZE": "0x1000", + "FLASH_ADDRESS": "0x80001000", + "FLASH_SIZE": "0xfff000", + "RAM_ADDRESS": "0x81000000", + "RAM_SIZE": "0x1000000", + "STACK_SIZE": "8K" + }, + "picolibc": { + "PICOLIBC_BUILD_TYPE": "release", + "ENABLE_CXX_LIBS": "ON", + "ENABLE_LIBC_TESTS": "ON", + "ENABLE_COMPILER_RT_TESTS": "OFF", + "ENABLE_LIBCXX_TESTS": "OFF" + }, + "newlib": { + "ENABLE_CXX_LIBS": "ON", + "ENABLE_LIBC_TESTS": "OFF", + "ENABLE_COMPILER_RT_TESTS": "OFF", + "ENABLE_LIBCXX_TESTS": "OFF" + }, + "llvmlibc": { + "ENABLE_CXX_LIBS": "OFF", + "ENABLE_LIBC_TESTS": "OFF", + "ENABLE_COMPILER_RT_TESTS": "OFF", + "ENABLE_LIBCXX_TESTS": "OFF" + } + } +} diff --git a/patches/picolibc/0001-Enable-libcxx-builds.patch b/patches/picolibc/0001-Enable-libcxx-builds.patch index 4ff07a16..7960ca12 100644 --- a/patches/picolibc/0001-Enable-libcxx-builds.patch +++ b/patches/picolibc/0001-Enable-libcxx-builds.patch @@ -1,7 +1,7 @@ -From 42f07bef7775a1387f9707e959f8b6782f9d6808 Mon Sep 17 00:00:00 2001 +From 028fe75e045951a9d091008a85971523358160db Mon Sep 17 00:00:00 2001 From: Simi Pallipurath Date: Thu, 14 Nov 2024 10:07:08 +0000 -Subject: [PATCH 1/2] [PATCH 1/2] Enable libcxx builds +Subject: Enable libcxx builds Modifications to build config and linker script required to enable libc++ builds. @@ -47,3 +47,6 @@ index 7b63ba172..cda5e1e7e 100644 *(.gnu.linkonce.t.*) KEEP (*(.fini .fini.*)) @PREFIX@__text_end = .; +-- +2.39.5 (Apple Git-154) + diff --git a/patches/picolibc/0002-Add-bootcode-for-AArch64-FVPs.patch b/patches/picolibc/0002-Add-bootcode-for-AArch64-FVPs.patch index f94b977d..6cd23938 100644 --- a/patches/picolibc/0002-Add-bootcode-for-AArch64-FVPs.patch +++ b/patches/picolibc/0002-Add-bootcode-for-AArch64-FVPs.patch @@ -1,7 +1,7 @@ -From 3b0b62ce6d81211a71eebe63b4b4ef0732da93ef Mon Sep 17 00:00:00 2001 +From 58451642e678817d8822b04b8ff07ee4758a8f10 Mon Sep 17 00:00:00 2001 From: Simi Pallipurath -Date: Mon, 25 Nov 2024 11:13:50 +0000 -Subject: [PATCH 2/2] [PATCH 2/2] Add bootcode for AArch64 FVPs +Date: Thu, 14 Nov 2024 10:12:33 +0000 +Subject: Add bootcode for AArch64 FVPs The AArch64 FVP (Fixed Virtual Platform) models differ from QEMU in a few ways which affect the crt0 code: @@ -886,4 +886,3 @@ index 76965990f..be8f875be 100644 endforeach -- 2.34.1 - diff --git a/patches/picolibc/0003-Add-support-for-strict-align-no-unaligned-access-in-.patch b/patches/picolibc/0003-Add-support-for-strict-align-no-unaligned-access-in-.patch new file mode 100644 index 00000000..eb366cc6 --- /dev/null +++ b/patches/picolibc/0003-Add-support-for-strict-align-no-unaligned-access-in-.patch @@ -0,0 +1,431 @@ +From 79f3ce1b5f730b0293e8452d4e028e34c0e71736 Mon Sep 17 00:00:00 2001 +From: Lucas Prates +Date: Mon, 11 Nov 2024 16:37:04 +0000 +Subject: Add support for strict-align/no-unaligned-access in AArch64 + +--- + newlib/libc/machine/aarch64/memchr-stub.c | 2 +- + newlib/libc/machine/aarch64/memchr.S | 2 +- + newlib/libc/machine/aarch64/memcmp-stub.c | 2 +- + newlib/libc/machine/aarch64/memcmp.S | 2 +- + newlib/libc/machine/aarch64/memcpy-stub.c | 2 +- + newlib/libc/machine/aarch64/memcpy.S | 2 +- + newlib/libc/machine/aarch64/memmove-stub.c | 2 +- + newlib/libc/machine/aarch64/memrchr-stub.c | 2 +- + newlib/libc/machine/aarch64/memrchr.S | 2 +- + newlib/libc/machine/aarch64/memset-stub.c | 2 +- + newlib/libc/machine/aarch64/memset.S | 2 +- + newlib/libc/machine/aarch64/rawmemchr-stub.c | 2 +- + newlib/libc/machine/aarch64/rawmemchr.S | 2 +- + newlib/libc/machine/aarch64/stpcpy-stub.c | 2 +- + newlib/libc/machine/aarch64/strchr-stub.c | 2 +- + newlib/libc/machine/aarch64/strchr.S | 2 +- + newlib/libc/machine/aarch64/strchrnul-stub.c | 2 +- + newlib/libc/machine/aarch64/strchrnul.S | 2 +- + newlib/libc/machine/aarch64/strcmp-stub.c | 2 +- + newlib/libc/machine/aarch64/strcmp.S | 2 +- + newlib/libc/machine/aarch64/strcpy-stub.c | 2 +- + newlib/libc/machine/aarch64/strcpy.S | 2 +- + newlib/libc/machine/aarch64/strlen-stub.c | 2 +- + newlib/libc/machine/aarch64/strlen.S | 2 +- + newlib/libc/machine/aarch64/strncmp-stub.c | 2 +- + newlib/libc/machine/aarch64/strncmp.S | 2 +- + newlib/libc/machine/aarch64/strnlen-stub.c | 2 +- + newlib/libc/machine/aarch64/strnlen.S | 2 +- + newlib/libc/machine/aarch64/strrchr-stub.c | 2 +- + newlib/libc/machine/aarch64/strrchr.S | 2 +- + 30 files changed, 30 insertions(+), 30 deletions(-) + +diff --git a/newlib/libc/machine/aarch64/memchr-stub.c b/newlib/libc/machine/aarch64/memchr-stub.c +index c887bc62f..735fc9d31 100644 +--- a/newlib/libc/machine/aarch64/memchr-stub.c ++++ b/newlib/libc/machine/aarch64/memchr-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + # include "../../string/memchr.c" + #else + /* See memchr.S */ +diff --git a/newlib/libc/machine/aarch64/memchr.S b/newlib/libc/machine/aarch64/memchr.S +index 29fc3c3c8..70686a8da 100644 +--- a/newlib/libc/machine/aarch64/memchr.S ++++ b/newlib/libc/machine/aarch64/memchr.S +@@ -7,7 +7,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See memchr-stub.c */ + #else + /* Assumptions: +diff --git a/newlib/libc/machine/aarch64/memcmp-stub.c b/newlib/libc/machine/aarch64/memcmp-stub.c +index af0cebf37..11aa224dc 100644 +--- a/newlib/libc/machine/aarch64/memcmp-stub.c ++++ b/newlib/libc/machine/aarch64/memcmp-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + # include "../../string/memcmp.c" + #else + /* See memcmp.S */ +diff --git a/newlib/libc/machine/aarch64/memcmp.S b/newlib/libc/machine/aarch64/memcmp.S +index 11352ff21..2c9c8e9e3 100644 +--- a/newlib/libc/machine/aarch64/memcmp.S ++++ b/newlib/libc/machine/aarch64/memcmp.S +@@ -6,7 +6,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See memcmp-stub.c */ + #else + +diff --git a/newlib/libc/machine/aarch64/memcpy-stub.c b/newlib/libc/machine/aarch64/memcpy-stub.c +index 145f638da..df8bcf588 100644 +--- a/newlib/libc/machine/aarch64/memcpy-stub.c ++++ b/newlib/libc/machine/aarch64/memcpy-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined (__ARM_FEATURE_UNALIGNED) + # include "../../string/memcpy.c" + #else + /* See memcpy.S */ +diff --git a/newlib/libc/machine/aarch64/memcpy.S b/newlib/libc/machine/aarch64/memcpy.S +index 39ff69a16..11e573ee0 100644 +--- a/newlib/libc/machine/aarch64/memcpy.S ++++ b/newlib/libc/machine/aarch64/memcpy.S +@@ -13,7 +13,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_FEATURE_UNALIGNED) + /* See memcpy-stub.c */ + #else + #include "asmdefs.h" +diff --git a/newlib/libc/machine/aarch64/memmove-stub.c b/newlib/libc/machine/aarch64/memmove-stub.c +index 41fd6643c..8498d3459 100644 +--- a/newlib/libc/machine/aarch64/memmove-stub.c ++++ b/newlib/libc/machine/aarch64/memmove-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_FEATURE_UNALIGNED) + # include "../../string/memmove.c" + #else + /* See memcpy.S */ +diff --git a/newlib/libc/machine/aarch64/memrchr-stub.c b/newlib/libc/machine/aarch64/memrchr-stub.c +index 63504543c..b9dc29211 100644 +--- a/newlib/libc/machine/aarch64/memrchr-stub.c ++++ b/newlib/libc/machine/aarch64/memrchr-stub.c +@@ -6,7 +6,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + #include "../../string/memrchr.c" + #else + /* See memrchr.S */ +diff --git a/newlib/libc/machine/aarch64/memrchr.S b/newlib/libc/machine/aarch64/memrchr.S +index a843de79e..d442e3d13 100644 +--- a/newlib/libc/machine/aarch64/memrchr.S ++++ b/newlib/libc/machine/aarch64/memrchr.S +@@ -13,7 +13,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See memrchr-stub.c */ + #else + #include "asmdefs.h" +diff --git a/newlib/libc/machine/aarch64/memset-stub.c b/newlib/libc/machine/aarch64/memset-stub.c +index e7e8b54f7..3c51d470f 100644 +--- a/newlib/libc/machine/aarch64/memset-stub.c ++++ b/newlib/libc/machine/aarch64/memset-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + # include "../../string/memset.c" + #else + /* See memset.S */ +diff --git a/newlib/libc/machine/aarch64/memset.S b/newlib/libc/machine/aarch64/memset.S +index 87a419964..7bb4525f4 100644 +--- a/newlib/libc/machine/aarch64/memset.S ++++ b/newlib/libc/machine/aarch64/memset.S +@@ -13,7 +13,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See memset-stub.c */ + #else + #include "asmdefs.h" +diff --git a/newlib/libc/machine/aarch64/rawmemchr-stub.c b/newlib/libc/machine/aarch64/rawmemchr-stub.c +index 032e0560c..c57f3ec30 100644 +--- a/newlib/libc/machine/aarch64/rawmemchr-stub.c ++++ b/newlib/libc/machine/aarch64/rawmemchr-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_FEATURE_UNALIGNED) + # include "../../string/rawmemchr.c" + #else + /* See rawmemchr.S. */ +diff --git a/newlib/libc/machine/aarch64/rawmemchr.S b/newlib/libc/machine/aarch64/rawmemchr.S +index dc4b257dd..4b114e746 100644 +--- a/newlib/libc/machine/aarch64/rawmemchr.S ++++ b/newlib/libc/machine/aarch64/rawmemchr.S +@@ -32,7 +32,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_FEATURE_UNALIGNED) + /* See rawmemchr-stub.c. */ + #else + +diff --git a/newlib/libc/machine/aarch64/stpcpy-stub.c b/newlib/libc/machine/aarch64/stpcpy-stub.c +index 045f1a551..d7fe3066a 100644 +--- a/newlib/libc/machine/aarch64/stpcpy-stub.c ++++ b/newlib/libc/machine/aarch64/stpcpy-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined (__ARM_FEATURE_UNALIGNED) + # include "../../string/stpcpy.c" + #else + /* See stpcpy.S */ +diff --git a/newlib/libc/machine/aarch64/strchr-stub.c b/newlib/libc/machine/aarch64/strchr-stub.c +index b9ae08393..90eb01da2 100644 +--- a/newlib/libc/machine/aarch64/strchr-stub.c ++++ b/newlib/libc/machine/aarch64/strchr-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined (__ARM_FEATURE_UNALIGNED) + # include "../../string/strchr.c" + #else + /* See strchr.S */ +diff --git a/newlib/libc/machine/aarch64/strchr.S b/newlib/libc/machine/aarch64/strchr.S +index a735889b1..6e3575aa0 100644 +--- a/newlib/libc/machine/aarch64/strchr.S ++++ b/newlib/libc/machine/aarch64/strchr.S +@@ -28,7 +28,7 @@ + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See strchr-stub.c */ + #else + +diff --git a/newlib/libc/machine/aarch64/strchrnul-stub.c b/newlib/libc/machine/aarch64/strchrnul-stub.c +index aa1208cbb..e88cee2c6 100644 +--- a/newlib/libc/machine/aarch64/strchrnul-stub.c ++++ b/newlib/libc/machine/aarch64/strchrnul-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + # include "../../string/strchrnul.c" + #else + /* See strchrnul.S */ +diff --git a/newlib/libc/machine/aarch64/strchrnul.S b/newlib/libc/machine/aarch64/strchrnul.S +index c60cef7d0..3a0b1dfde 100644 +--- a/newlib/libc/machine/aarch64/strchrnul.S ++++ b/newlib/libc/machine/aarch64/strchrnul.S +@@ -28,7 +28,7 @@ + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See strchrnul-stub.c */ + #else + +diff --git a/newlib/libc/machine/aarch64/strcmp-stub.c b/newlib/libc/machine/aarch64/strcmp-stub.c +index 652e4f651..c8d60c56d 100644 +--- a/newlib/libc/machine/aarch64/strcmp-stub.c ++++ b/newlib/libc/machine/aarch64/strcmp-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined (__ARM_FEATURE_UNALIGNED) + # include "../../string/strcmp.c" + #else + /* See strcmp.S */ +diff --git a/newlib/libc/machine/aarch64/strcmp.S b/newlib/libc/machine/aarch64/strcmp.S +index 641d6ae22..82635762b 100644 +--- a/newlib/libc/machine/aarch64/strcmp.S ++++ b/newlib/libc/machine/aarch64/strcmp.S +@@ -7,7 +7,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_FEATURE_UNALIGNED) + /* See strcmp-stub.c */ + #else + +diff --git a/newlib/libc/machine/aarch64/strcpy-stub.c b/newlib/libc/machine/aarch64/strcpy-stub.c +index 4cfa19e9c..4f9a95100 100644 +--- a/newlib/libc/machine/aarch64/strcpy-stub.c ++++ b/newlib/libc/machine/aarch64/strcpy-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined (__ARM_FEATURE_UNALIGNED) + # include "../../string/strcpy.c" + #else + /* See strcpy.S */ +diff --git a/newlib/libc/machine/aarch64/strcpy.S b/newlib/libc/machine/aarch64/strcpy.S +index 62e5f3f37..eecb81bb5 100644 +--- a/newlib/libc/machine/aarch64/strcpy.S ++++ b/newlib/libc/machine/aarch64/strcpy.S +@@ -28,7 +28,7 @@ + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See strcpy-stub.c */ + #else + +diff --git a/newlib/libc/machine/aarch64/strlen-stub.c b/newlib/libc/machine/aarch64/strlen-stub.c +index 3d9c3876c..ec44c927c 100644 +--- a/newlib/libc/machine/aarch64/strlen-stub.c ++++ b/newlib/libc/machine/aarch64/strlen-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + # include "../../string/strlen.c" + #else + /* See strlen.S */ +diff --git a/newlib/libc/machine/aarch64/strlen.S b/newlib/libc/machine/aarch64/strlen.S +index 8e1a7cb7a..5204ad80d 100644 +--- a/newlib/libc/machine/aarch64/strlen.S ++++ b/newlib/libc/machine/aarch64/strlen.S +@@ -25,7 +25,7 @@ + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See strlen-stub.c */ + #else + +diff --git a/newlib/libc/machine/aarch64/strncmp-stub.c b/newlib/libc/machine/aarch64/strncmp-stub.c +index 504c12d7b..6751bad38 100644 +--- a/newlib/libc/machine/aarch64/strncmp-stub.c ++++ b/newlib/libc/machine/aarch64/strncmp-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined (__ARM_FEATURE_UNALIGNED) + # include "../../string/strncmp.c" + #else + /* See strncmp.S */ +diff --git a/newlib/libc/machine/aarch64/strncmp.S b/newlib/libc/machine/aarch64/strncmp.S +index b2470a408..34c8bbec2 100644 +--- a/newlib/libc/machine/aarch64/strncmp.S ++++ b/newlib/libc/machine/aarch64/strncmp.S +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_FEATURE_UNALIGNED) + /* See strncmp-stub.c */ + #else + +diff --git a/newlib/libc/machine/aarch64/strnlen-stub.c b/newlib/libc/machine/aarch64/strnlen-stub.c +index 2f50cdbdf..b1757b1ff 100644 +--- a/newlib/libc/machine/aarch64/strnlen-stub.c ++++ b/newlib/libc/machine/aarch64/strnlen-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + # include "../../string/strnlen.c" + #else + /* See strnlen.S */ +diff --git a/newlib/libc/machine/aarch64/strnlen.S b/newlib/libc/machine/aarch64/strnlen.S +index e64137665..40fbeafb0 100644 +--- a/newlib/libc/machine/aarch64/strnlen.S ++++ b/newlib/libc/machine/aarch64/strnlen.S +@@ -28,7 +28,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See strnlen-stub.c */ + #else + +diff --git a/newlib/libc/machine/aarch64/strrchr-stub.c b/newlib/libc/machine/aarch64/strrchr-stub.c +index b8fe32f75..362a7086b 100644 +--- a/newlib/libc/machine/aarch64/strrchr-stub.c ++++ b/newlib/libc/machine/aarch64/strrchr-stub.c +@@ -26,7 +26,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined (__ARM_FEATURE_UNALIGNED) + # include "../../string/strrchr.c" + #else + /* See strrchr.S */ +diff --git a/newlib/libc/machine/aarch64/strrchr.S b/newlib/libc/machine/aarch64/strrchr.S +index 1fccba9f8..2f0cdc0c7 100644 +--- a/newlib/libc/machine/aarch64/strrchr.S ++++ b/newlib/libc/machine/aarch64/strrchr.S +@@ -29,7 +29,7 @@ + + #include + +-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) ++#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) || !defined(__ARM_NEON) || !defined(__ARM_FEATURE_UNALIGNED) + /* See strrchr-stub.c */ + #else + +-- +2.39.5 (Apple Git-154) + diff --git a/patches/picolibc/0004-ARM-AARCH64-BootCode-Changes-to-enable-the-Alignment.patch b/patches/picolibc/0004-ARM-AARCH64-BootCode-Changes-to-enable-the-Alignment.patch new file mode 100644 index 00000000..0a0bd275 --- /dev/null +++ b/patches/picolibc/0004-ARM-AARCH64-BootCode-Changes-to-enable-the-Alignment.patch @@ -0,0 +1,68 @@ +From 11abbd6533eeacbb000fc19bd07316e11fcb6fea Mon Sep 17 00:00:00 2001 +From: Simi Pallipurath +Date: Tue, 26 Nov 2024 15:20:50 +0000 +Subject: [ARM/AARCH64] BootCode Changes to enable the Alignment Check + bit and disable the unaligned access bit + +We need changes in both Arm/AArch64 bootcode in +order for the -mno-unaligned-access to work. + +We need to enable the Alignment Check bit in the +System Control Register (SCTLR) which is the +Bit 1 (A) and it turn on alignment fault checking +for data accesses . If an unaligned data access +occurs, an alignment fault exception will be generated. + +Also need to disable the Unaligned Access Enable(U) bit +in the System Control Register (SCTLR). As a result, +unaligned data accesses will generate an alignment fault exception. +--- + picocrt/machine/aarch64/crt0.c | 7 ++++++- + picocrt/machine/arm/crt0.c | 6 ++++++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/picocrt/machine/aarch64/crt0.c b/picocrt/machine/aarch64/crt0.c +index dfe838111..885282f4d 100644 +--- a/picocrt/machine/aarch64/crt0.c ++++ b/picocrt/machine/aarch64/crt0.c +@@ -144,7 +144,12 @@ void _cstart(void) + */ + __asm__("mrs %x0, sctlr_"BOOT_EL"" : "=r" (sctlr)); + sctlr |= SCTLR_ICACHE | SCTLR_C | SCTLR_MMU; +- sctlr &= ~(SCTLR_A | SCTLR_WXN); ++ #ifdef __ARM_FEATURE_UNALIGNED ++ sctlr &= ~SCTLR_A; ++ #else ++ sctlr |= SCTLR_A; ++ #endif ++ sctlr &= ~SCTLR_WXN; + __asm__("msr sctlr_"BOOT_EL", %x0" :: "r" (sctlr)); + __asm__("isb\n"); + +diff --git a/picocrt/machine/arm/crt0.c b/picocrt/machine/arm/crt0.c +index 60efafc9c..e27ccb6a9 100644 +--- a/picocrt/machine/arm/crt0.c ++++ b/picocrt/machine/arm/crt0.c +@@ -246,6 +246,8 @@ _cstart(void) + #define SCTLR_BRANCH_PRED (1 << 11) + #define SCTLR_ICACHE (1 << 12) + #define SCTLR_TRE (1 << 28) ++#define SCTLR_A (1 << 1) ++#define SCTLR_U (1 << 22) + + uint32_t mmfr0; + __asm__("mrc p15, 0, %0, c0, c1, 4" : "=r" (mmfr0)); +@@ -280,6 +282,10 @@ _cstart(void) + uint32_t sctlr; + __asm__("mrc p15, 0, %0, c1, c0, 0" : "=r" (sctlr)); + sctlr |= SCTLR_ICACHE | SCTLR_BRANCH_PRED | SCTLR_DATA_L2 | SCTLR_MMU; ++ #ifndef __ARM_FEATURE_UNALIGNED ++ sctlr |= SCTLR_A; ++ sctlr &= ~SCTLR_U; ++ #endif + sctlr &= ~SCTLR_TRE; + __asm__("mcr p15, 0, %0, c1, c0, 0\n" :: "r" (sctlr)); + __asm__("isb\n"); +-- +2.34.1 +