diff options
author | Radek Bartoň <radek.barton@microsoft.com> | 2025-07-24 12:36:02 +0200 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2025-07-25 12:14:34 -0500 |
commit | 038afec1ef9e1f083fa23dea46a2304c260896da (patch) | |
tree | 185fac45c1a8454a09dbaf0531787f97cd2cecf8 /newlib/libc | |
parent | 9dc32c0299199a1e6b531ad5860ecac2931f358e (diff) | |
download | newlib-038afec1ef9e1f083fa23dea46a2304c260896da.zip newlib-038afec1ef9e1f083fa23dea46a2304c260896da.tar.gz newlib-038afec1ef9e1f083fa23dea46a2304c260896da.tar.bz2 |
newlib: libc: return back support for AArch64 ILP32
This patch is returning back support for AArch64 ILP32 ABI that was
removed in de479a54e22e8fcb6262639a8e67fe8b00a27c37 commit but is needed
to ensure source code compatibility with GCC 14.
The change in newlib/libc/machine/aarch64/asmdefs.h makes it
out-of-the-sync with the current upstream implementation in
https://github.com/ARM-software/optimized-routines repository.
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/machine/aarch64/asmdefs.h | 48 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/memchr.S | 2 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/memcmp.S | 4 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/memcpy.S | 3 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/memrchr.S | 1 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/memset.S | 3 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/strchr.S | 1 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/strchrnul.S | 1 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/strcmp.S | 2 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/strcpy.S | 2 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/strlen.S | 1 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/strncmp.S | 3 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/strnlen.S | 2 | ||||
-rw-r--r-- | newlib/libc/machine/aarch64/strrchr.S | 1 |
14 files changed, 64 insertions, 10 deletions
diff --git a/newlib/libc/machine/aarch64/asmdefs.h b/newlib/libc/machine/aarch64/asmdefs.h index 6c99fa7..2aaa459 100644 --- a/newlib/libc/machine/aarch64/asmdefs.h +++ b/newlib/libc/machine/aarch64/asmdefs.h @@ -30,18 +30,32 @@ #define FEATURE_1_PAC 2 /* Add a NT_GNU_PROPERTY_TYPE_0 note. */ +#ifdef __ILP32__ #define GNU_PROPERTY(type, value) \ - .section .note.gnu.property, "a" SEP \ - .p2align 3 SEP \ - .word 4 SEP \ - .word 16 SEP \ - .word 5 SEP \ - .asciz "GNU" SEP \ - .word type SEP \ - .word 4 SEP \ - .word value SEP \ - .word 0 SEP \ + .section .note.gnu.property, "a"; \ + .p2align 2; \ + .word 4; \ + .word 12; \ + .word 5; \ + .asciz "GNU"; \ + .word type; \ + .word 4; \ + .word value; \ .text +#else +#define GNU_PROPERTY(type, value) \ + .section .note.gnu.property, "a"; \ + .p2align 3; \ + .word 4; \ + .word 16; \ + .word 5; \ + .asciz "GNU"; \ + .word type; \ + .word 4; \ + .word value; \ + .word 0; \ + .text +#endif /* If set then the GNU Property Note section will be added to mark objects to support BTI and PAC-RET. */ @@ -88,4 +102,18 @@ GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC) #define L(l) .L ## l +#ifdef __ILP32__ + /* Sanitize padding bits of pointer arguments as per aapcs64 */ +#define PTR_ARG(n) mov w##n, w##n +#else +#define PTR_ARG(n) +#endif + +#ifdef __ILP32__ + /* Sanitize padding bits of size arguments as per aapcs64 */ +#define SIZE_ARG(n) mov w##n, w##n +#else +#define SIZE_ARG(n) +#endif + #endif diff --git a/newlib/libc/machine/aarch64/memchr.S b/newlib/libc/machine/aarch64/memchr.S index 074a004..a0f305e 100644 --- a/newlib/libc/machine/aarch64/memchr.S +++ b/newlib/libc/machine/aarch64/memchr.S @@ -50,6 +50,8 @@ */ ENTRY (memchr) + PTR_ARG (0) + SIZE_ARG (2) /* Do not dereference srcin if no bytes to compare. */ cbz cntin, L(zero_length) /* diff --git a/newlib/libc/machine/aarch64/memcmp.S b/newlib/libc/machine/aarch64/memcmp.S index 2a9c446..18874d3 100644 --- a/newlib/libc/machine/aarch64/memcmp.S +++ b/newlib/libc/machine/aarch64/memcmp.S @@ -34,6 +34,10 @@ ENTRY (memcmp) + PTR_ARG (0) + PTR_ARG (1) + SIZE_ARG (2) + cmp limit, 16 b.lo L(less16) ldp data1, data3, [src1] diff --git a/newlib/libc/machine/aarch64/memcpy.S b/newlib/libc/machine/aarch64/memcpy.S index 252d245..248e784 100644 --- a/newlib/libc/machine/aarch64/memcpy.S +++ b/newlib/libc/machine/aarch64/memcpy.S @@ -58,6 +58,9 @@ ENTRY_ALIAS (memmove) ENTRY (memcpy) + PTR_ARG (0) + PTR_ARG (1) + SIZE_ARG (2) add srcend, src, count add dstend, dstin, count cmp count, 128 diff --git a/newlib/libc/machine/aarch64/memrchr.S b/newlib/libc/machine/aarch64/memrchr.S index 2525cf1..ba9915c 100644 --- a/newlib/libc/machine/aarch64/memrchr.S +++ b/newlib/libc/machine/aarch64/memrchr.S @@ -45,6 +45,7 @@ exactly which byte matched. */ ENTRY (memrchr) + PTR_ARG (0) add end, srcin, cntin sub endm1, end, 1 bic src, endm1, 15 diff --git a/newlib/libc/machine/aarch64/memset.S b/newlib/libc/machine/aarch64/memset.S index 5bf4851..ca76439 100644 --- a/newlib/libc/machine/aarch64/memset.S +++ b/newlib/libc/machine/aarch64/memset.S @@ -25,6 +25,9 @@ #define zva_val x5 ENTRY (memset) + PTR_ARG (0) + SIZE_ARG (2) + dup v0.16B, valw add dstend, dstin, count diff --git a/newlib/libc/machine/aarch64/strchr.S b/newlib/libc/machine/aarch64/strchr.S index a4e089b..500d9af 100644 --- a/newlib/libc/machine/aarch64/strchr.S +++ b/newlib/libc/machine/aarch64/strchr.S @@ -54,6 +54,7 @@ /* Locals and temporaries. */ ENTRY (strchr) + PTR_ARG (0) /* Magic constant 0xc0300c03 to allow us to identify which lane matches the requested byte. Even bits are set if the character matches, odd bits if either the char is NUL or matches. */ diff --git a/newlib/libc/machine/aarch64/strchrnul.S b/newlib/libc/machine/aarch64/strchrnul.S index 4d6093b..ceaf4dc 100644 --- a/newlib/libc/machine/aarch64/strchrnul.S +++ b/newlib/libc/machine/aarch64/strchrnul.S @@ -50,6 +50,7 @@ /* Locals and temporaries. */ ENTRY (strchrnul) + PTR_ARG (0) /* Magic constant 0x40100401 to allow us to identify which lane matches the termination condition. */ mov wtmp2, #0x0401 diff --git a/newlib/libc/machine/aarch64/strcmp.S b/newlib/libc/machine/aarch64/strcmp.S index 1d85da4..691a176 100644 --- a/newlib/libc/machine/aarch64/strcmp.S +++ b/newlib/libc/machine/aarch64/strcmp.S @@ -54,6 +54,8 @@ ENTRY (strcmp) + PTR_ARG (0) + PTR_ARG (1) sub off2, src2, src1 mov zeroones, REP8_01 and tmp, src1, 7 diff --git a/newlib/libc/machine/aarch64/strcpy.S b/newlib/libc/machine/aarch64/strcpy.S index 1f5f707..57c46f3 100644 --- a/newlib/libc/machine/aarch64/strcpy.S +++ b/newlib/libc/machine/aarch64/strcpy.S @@ -55,6 +55,8 @@ exactly which byte matched. */ ENTRY (STRCPY) + PTR_ARG (0) + PTR_ARG (1) bic src, srcin, 15 ld1 {vdata.16b}, [src] cmeq vhas_nul.16b, vdata.16b, 0 diff --git a/newlib/libc/machine/aarch64/strlen.S b/newlib/libc/machine/aarch64/strlen.S index a3345a3..68a6f35 100644 --- a/newlib/libc/machine/aarch64/strlen.S +++ b/newlib/libc/machine/aarch64/strlen.S @@ -78,6 +78,7 @@ character, return the length, if not, continue in the main loop. */ ENTRY (strlen) + PTR_ARG (0) and tmp1, srcin, MIN_PAGE_SIZE - 1 cmp tmp1, MIN_PAGE_SIZE - 32 b.hi L(page_cross) diff --git a/newlib/libc/machine/aarch64/strncmp.S b/newlib/libc/machine/aarch64/strncmp.S index 6b1994e..3736955 100644 --- a/newlib/libc/machine/aarch64/strncmp.S +++ b/newlib/libc/machine/aarch64/strncmp.S @@ -58,6 +58,9 @@ #endif ENTRY (strncmp) + PTR_ARG (0) + PTR_ARG (1) + SIZE_ARG (2) cbz limit, L(ret0) eor tmp1, src1, src2 mov zeroones, #REP8_01 diff --git a/newlib/libc/machine/aarch64/strnlen.S b/newlib/libc/machine/aarch64/strnlen.S index dc9fcb2..091002e 100644 --- a/newlib/libc/machine/aarch64/strnlen.S +++ b/newlib/libc/machine/aarch64/strnlen.S @@ -39,6 +39,8 @@ identifies the first zero byte. */ ENTRY (strnlen) + PTR_ARG (0) + SIZE_ARG (1) bic src, srcin, 15 cbz cntin, L(nomatch) ld1 {vdata.16b}, [src] diff --git a/newlib/libc/machine/aarch64/strrchr.S b/newlib/libc/machine/aarch64/strrchr.S index 67013e3..b057422 100644 --- a/newlib/libc/machine/aarch64/strrchr.S +++ b/newlib/libc/machine/aarch64/strrchr.S @@ -58,6 +58,7 @@ identify exactly which byte is causing the termination, and why. */ ENTRY (strrchr) + PTR_ARG (0) /* Magic constant 0x40100401 to allow us to identify which lane matches the requested byte. Magic constant 0x80200802 used similarly for NUL termination. */ |