Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src Pull up following revision(s) (requested by skrll in tick...



details:   https://anonhg.NetBSD.org/src/rev/9fc5d6d3a2ea
branches:  netbsd-9
changeset: 1002344:9fc5d6d3a2ea
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Aug 08 10:22:04 2021 +0000

description:
Pull up following revision(s) (requested by skrll in ticket #1329):

        lib/libc/arch/arm/gen/swapcontext.S: revision 1.18
        sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divsi3.S: revision 1.2
        sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divsi3.S: revision 1.3
        sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cfcmp.S: revision 1.2
        sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cfcmp.S: revision 1.3
        lib/libc/arch/arm/sys/__clone.S: revision 1.10
        lib/libc/arch/arm/sys/__clone.S: revision 1.11
        sys/external/bsd/compiler_rt/dist/lib/builtins/arm/modsi3.S: revision 1.2
        lib/libc/arch/arm/sys/__clone.S: revision 1.12
        sys/external/bsd/compiler_rt/dist/lib/builtins/arm/modsi3.S: revision 1.3
        lib/libc/arch/arm/sys/__clone.S: revision 1.13
        lib/libc/arch/arm/sys/__clone.S: revision 1.14
        sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divmodsi4.S: revision 1.2
        sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divmodsi4.S: revision 1.3
        lib/libc/arch/arm/gen/swapcontext.S: revision 1.16
        lib/libc/arch/arm/gen/swapcontext.S: revision 1.17

Align sp to 8-byte boundary as required by EABI.

This is especially important for non-leaf functions; GCC optimizes codes
based on assumption that sp is aligned properly.

Mostly fix broken earmv5 userland compiled by GCC10 due to alignment
faults in ld.elf_so, where {ld,st}rd are used for [sp, #8x].

No regression for ATF is observed for earmv[67]{,hf}{,eb}.

Align sp to 8-byte boundary as required by EABI.
IIUC, this change only affects libc compiled for ``Thumb-mode userland'',
which we've not officially supported yet.

Fix previous. For Thumb-1:
- sp cannot be manipulated directly
- {add,sub}s should be used instead of {add,sub}

Trailing whitespace

The _INVOKE_CERROR macro deals with thumb so simplify the code (at the
expense of a couple more instructions).

Do previous differently by pushing even number of registers and remove
strange r7 usage.

Do previous differtly by pushing two registers in the same way as the
_INVOKE_CERROR macro

diffstat:

 lib/libc/arch/arm/gen/swapcontext.S                              |   8 ++--
 lib/libc/arch/arm/sys/__clone.S                                  |  16 +++------
 sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cfcmp.S |  10 +++--
 sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divmodsi4.S   |   5 +-
 sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divsi3.S      |   5 +-
 sys/external/bsd/compiler_rt/dist/lib/builtins/arm/modsi3.S      |   5 +-
 6 files changed, 22 insertions(+), 27 deletions(-)

diffs (159 lines):

diff -r 5493df153d44 -r 9fc5d6d3a2ea lib/libc/arch/arm/gen/swapcontext.S
--- a/lib/libc/arch/arm/gen/swapcontext.S       Sun Aug 08 10:11:39 2021 +0000
+++ b/lib/libc/arch/arm/gen/swapcontext.S       Sun Aug 08 10:22:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: swapcontext.S,v 1.15 2018/11/21 21:01:41 skrll Exp $   */
+/*     $NetBSD: swapcontext.S,v 1.15.2.1 2021/08/08 10:22:04 martin Exp $      */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "assym.h"
 
 #if defined(LIBC_SCCS) && !defined(lint)
-        RCSID("$NetBSD: swapcontext.S,v 1.15 2018/11/21 21:01:41 skrll Exp $")
+        RCSID("$NetBSD: swapcontext.S,v 1.15.2.1 2021/08/08 10:22:04 martin Exp $")
 #endif /* LIBC_SCCS && !lint */
 
 ENTRY(swapcontext)
@@ -84,9 +84,9 @@
 #if !defined(__thumb__) || defined(_ARM_ARCH_T2)
        b       PLT_SYM(_C_LABEL(setcontext))
 #else
-       push    {lr}
+       push    {r3, lr}
        bl      PLT_SYM(_C_LABEL(setcontext))
-       pop     {pc}
+       pop     {r3, pc}
 #endif
 #if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__)
        .cfi_endproc
diff -r 5493df153d44 -r 9fc5d6d3a2ea lib/libc/arch/arm/sys/__clone.S
--- a/lib/libc/arch/arm/sys/__clone.S   Sun Aug 08 10:11:39 2021 +0000
+++ b/lib/libc/arch/arm/sys/__clone.S   Sun Aug 08 10:22:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: __clone.S,v 1.9 2013/11/30 20:20:42 joerg Exp $ */
+/* $NetBSD: __clone.S,v 1.9.28.1 2021/08/08 10:22:04 martin Exp $ */
 
 /*
  * Copyright (c) 2001 Christopher Gilbert
@@ -55,21 +55,17 @@
 
        /* place the func and its arg onto the child's stack */
 #if !defined(__thumb__) || defined(_ARM_ARCH_T2)
-       stmfd   r1!, {r0, r3} 
+       stmfd   r1!, {r0, r3}
 #else
        subs    r1, r1, #8
-       stmia   r1!, {r0, r3} 
+       stmia   r1!, {r0, r3}
 #endif
-       
+
        /* syscall expects (flags, stack) */
        mov     r0, r2
 
        SYSTRAP(__clone)
-#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
        _INVOKE_CERROR()
-#else
-       bcs     .Lcerror
-#endif
 
        /*
         * r1 and r0 are the same as from fork:
@@ -121,8 +117,8 @@
        b       CERROR
 #else
 .Lcerror:
-       push    {lr}
+       push    {r3, lr}
        bl      CERROR
-       pop     {pc}
+       pop     {r3, pc}
 #endif
 END(__clone)
diff -r 5493df153d44 -r 9fc5d6d3a2ea sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cfcmp.S
--- a/sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cfcmp.S  Sun Aug 08 10:11:39 2021 +0000
+++ b/sys/external/bsd/compiler_rt/dist/lib/builtins/arm/aeabi_cfcmp.S  Sun Aug 08 10:22:04 2021 +0000
@@ -27,10 +27,11 @@
         .syntax unified
         .p2align 2
 DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmpeq)
-        push {r0-r3, lr}
+        // Save ip to ensure stack alignment (could be any register)
+        push {r0-r3, ip, lr}
         bl __aeabi_cfcmpeq_check_nan
         cmp r0, #1
-        pop {r0-r3, lr}
+        pop {r0-r3, ip, lr}
 
         // NaN has been ruled out, so __aeabi_cfcmple can't trap
         bne __aeabi_cfcmple
@@ -55,7 +56,8 @@
 DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmple)
         // Per the RTABI, this function must preserve r0-r11.
         // Save lr in the same instruction for compactness
-        push {r0-r3, lr}
+        // Save ip to ensure stack alignment (could be any register)
+        push {r0-r3, ip, lr}
 
         bl __aeabi_fcmplt
         cmp r0, #1
@@ -70,7 +72,7 @@
 
 1:
         msr CPSR_f, ip
-        pop {r0-r3}
+        pop {r0-r3, ip}
         POP_PC()
 END_COMPILERRT_FUNCTION(__aeabi_cfcmple)
 
diff -r 5493df153d44 -r 9fc5d6d3a2ea sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divmodsi4.S
--- a/sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divmodsi4.S    Sun Aug 08 10:11:39 2021 +0000
+++ b/sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divmodsi4.S    Sun Aug 08 10:22:04 2021 +0000
@@ -16,10 +16,9 @@
 #include "../assembly.h"
 
 #define ESTABLISH_FRAME    \
-    push   {r4-r7, lr}   ;\
-    add     r7,     sp, #12
+    push   {r4-r6, lr}
 #define CLEAR_FRAME_AND_RETURN \
-    pop    {r4-r7, pc}
+    pop    {r4-r6, pc}
 
        .syntax unified
        .text
diff -r 5493df153d44 -r 9fc5d6d3a2ea sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divsi3.S
--- a/sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divsi3.S       Sun Aug 08 10:11:39 2021 +0000
+++ b/sys/external/bsd/compiler_rt/dist/lib/builtins/arm/divsi3.S       Sun Aug 08 10:22:04 2021 +0000
@@ -15,10 +15,9 @@
 #include "../assembly.h"
 
 #define ESTABLISH_FRAME \
-    push   {r4, r7, lr}    ;\
-    add     r7,     sp, #4
+    push   {r4, lr}
 #define CLEAR_FRAME_AND_RETURN \
-    pop    {r4, r7, pc}
+    pop    {r4, pc}
 
        .syntax unified
        .text
diff -r 5493df153d44 -r 9fc5d6d3a2ea sys/external/bsd/compiler_rt/dist/lib/builtins/arm/modsi3.S
--- a/sys/external/bsd/compiler_rt/dist/lib/builtins/arm/modsi3.S       Sun Aug 08 10:11:39 2021 +0000
+++ b/sys/external/bsd/compiler_rt/dist/lib/builtins/arm/modsi3.S       Sun Aug 08 10:22:04 2021 +0000
@@ -15,10 +15,9 @@
 #include "../assembly.h"
 
 #define ESTABLISH_FRAME \
-    push   {r4, r7, lr}    ;\
-    add     r7,     sp, #4
+    push   {r4, lr}
 #define CLEAR_FRAME_AND_RETURN \
-    pop    {r4, r7, pc}
+    pop    {r4, pc}
 
        .syntax unified
        .text



Home | Main Index | Thread Index | Old Index