From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2063) id 21C4E384D1A7; Wed, 8 Mar 2023 07:00:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21C4E384D1A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678258812; bh=clnzEnfomWU6NoWBFQFleESyXWwGYRUQfuegqr9cc8A=; h=From:To:Subject:Date:From; b=WmghQY/gg+WTLRbWavhgyKt3cj+6VzfRtkdrQ71C02/kSVvPTVMUvm8UYhVtqCx0g YbVUmd5Lz9Z2CC/YnIyme/Xu8Vjoy2V82MShG9ZM/3QfFXZOVrLL86N95Pz4CGLz+2 1i2DXWUEABpAvdB75RKqFsOCPDr5OFSQMW+8bfh0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Kewen Lin To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6545] libgcc, rs6000: Fix bump size for powerpc64 elfv1 ABI [PR108727] X-Act-Checkin: gcc X-Git-Author: Kewen Lin X-Git-Refname: refs/heads/master X-Git-Oldrev: 2a2a159f7bd9d929ce457937f669ed2dd6ebccec X-Git-Newrev: 15b83b69ca99d97643075776ba94f2dd1f05b46e Message-Id: <20230308070012.21C4E384D1A7@sourceware.org> Date: Wed, 8 Mar 2023 07:00:12 +0000 (GMT) List-Id: https://gcc.gnu.org/g:15b83b69ca99d97643075776ba94f2dd1f05b46e commit r13-6545-g15b83b69ca99d97643075776ba94f2dd1f05b46e Author: Kewen Lin Date: Wed Mar 8 00:57:21 2023 -0600 libgcc, rs6000: Fix bump size for powerpc64 elfv1 ABI [PR108727] As PR108727 shows, when cleanup code called by the stack unwinder calls function _Unwind_Resume, it goes via plt stub like: function 00000000.plt_call._Unwind_Resume: => 0x0000000010003580 <+0>: std r2,40(r1) 0x0000000010003584 <+4>: ld r12,-31760(r2) 0x0000000010003588 <+8>: mtctr r12 0x000000001000358c <+12>: ld r2,-31752(r2) 0x0000000010003590 <+16>: cmpldi r2,0 0x0000000010003594 <+20>: bnectr+ 0x0000000010003598 <+24>: b 0x100031a4 <_Unwind_Resume@plt> It wants to save TOC base (r2) to r1 + 40, but we only bump the stack segment by 32 bytes as follows: stdu %r29,-32(%r3) It means the access is out of the stack segment allocated by __generic_morestack, once the touch area isn't writable like this failure shows, it would cause segment fault. So fix the bump size with one reasonable value PARAMS. PR libgcc/108727 libgcc/ChangeLog: * config/rs6000/morestack.S (__morestack): Use PARAMS for new stack bump size. Diff: --- libgcc/config/rs6000/morestack.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgcc/config/rs6000/morestack.S b/libgcc/config/rs6000/morestack.S index 5e7ad133303..f2fea6abb10 100644 --- a/libgcc/config/rs6000/morestack.S +++ b/libgcc/config/rs6000/morestack.S @@ -205,12 +205,12 @@ ENTRY0(__morestack) bl JUMP_TARGET(__generic_morestack) # Start using new stack - stdu %r29,-32(%r3) # back-chain + stdu %r29,-PARAMS(%r3) # back-chain mr %r1,%r3 # Set __private_ss stack guard for the new stack. ld %r12,NEWSTACKSIZE_SAVE(%r29) # modified size - addi %r3,%r3,BACKOFF-32 + addi %r3,%r3,BACKOFF-PARAMS sub %r3,%r3,%r12 # Note that a signal frame has $pc pointing at the instruction # where the signal occurred. For something like a timer