[gcc r14-7089] strub: Only unbias stack point for SPARC_STACK_BOUNDARY_HACK [PR113100]

Kewen Lin linkw@gcc.gnu.org
Wed Jan 10 05:05:45 GMT 2024


https://gcc.gnu.org/g:cb62101787555b7b32607b431fdfe6fcc8f3830f

commit r14-7089-gcb62101787555b7b32607b431fdfe6fcc8f3830f
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Tue Jan 9 23:05:13 2024 -0600

    strub: Only unbias stack point for SPARC_STACK_BOUNDARY_HACK [PR113100]
    
    As PR113100 shows, the unbiasing introduced by r14-6737 can
    cause the scrubbing to overrun and screw some critical data
    on stack like saved toc base consequently cause segfault.
    
    By checking PR112917, IMHO we should keep this unbiasing
    guarded under SPARC_STACK_BOUNDARY_HACK (TARGET_ARCH64 &&
    TARGET_STACK_BIAS), similar to some existing code special
    treating SPARC stack bias.
    
            PR middle-end/113100
    
    gcc/ChangeLog:
    
            * builtins.cc (expand_builtin_stack_address): Guard stack point
            adjustment with SPARC_STACK_BOUNDARY_HACK.

Diff:
---
 gcc/builtins.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index d1767596ced..09f2354f114 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -5450,6 +5450,7 @@ expand_builtin_stack_address ()
   rtx ret = convert_to_mode (ptr_mode, copy_to_reg (stack_pointer_rtx),
 			     STACK_UNSIGNED);
 
+#ifdef SPARC_STACK_BOUNDARY_HACK
   /* Unbias the stack pointer, bringing it to the boundary between the
      stack area claimed by the active function calling this builtin,
      and stack ranges that could get clobbered if it called another
@@ -5476,7 +5477,9 @@ expand_builtin_stack_address ()
      (caller) function's active area as well, whereas those pushed or
      allocated temporarily for a call are regarded as part of the
      callee's stack range, rather than the caller's.  */
-  ret = plus_constant (ptr_mode, ret, STACK_POINTER_OFFSET);
+  if (SPARC_STACK_BOUNDARY_HACK)
+    ret = plus_constant (ptr_mode, ret, STACK_POINTER_OFFSET);
+#endif
 
   return force_reg (ptr_mode, ret);
 }


More information about the Gcc-cvs mailing list