public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "linkw at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgcc/108727] gcc.dg/split-5.c fails on power 9 BE
Date: Fri, 03 Mar 2023 10:20:02 +0000	[thread overview]
Message-ID: <bug-108727-4-db1WIol7Jj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108727-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108727

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amodra at gcc dot gnu.org,
                   |                            |amodra at gmail dot com,
                   |                            |segher at gcc dot gnu.org

--- Comment #2 from Kewen Lin <linkw at gcc dot gnu.org> ---
This is one bug in libgcc morestack support (powerpc64 elfv1 ABI specific):

The segfault happens on:

Dump of assembler code for 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>
   0x000000001000359c <+28>:    .long 0x0

The target address of std at 0x0000000010003580 is 0x7ffff72e0008, which isn't
writable as the following mappings:

   0x7ffff40f0000     0x7ffff72e0000  0x31f0000        0x0  rw-p
   0x7ffff72e0000     0x7ffff72f0000    0x10000        0x0  ---p

For the stack segment returned from __generic_morestack, we adjust it by 32
bytes:

   bl JUMP_TARGET(__generic_morestack)

   # Start using new stack
   stdu %r29,-32(%r3)           # back-chain
   mr %r1,%r3

but it isn't enough for powerpc64 elfv1 ABI as the TOC base save slot is with
offset 40.

The fix can be to use PARAMS like:

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

============================================================

Hi Alan, does the above fix look reasonable to you?

  parent reply	other threads:[~2023-03-03 10:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 20:45 [Bug testsuite/108727] New: " seurer at gcc dot gnu.org
2023-03-01  6:03 ` [Bug testsuite/108727] " linkw at gcc dot gnu.org
2023-03-03 10:20 ` linkw at gcc dot gnu.org [this message]
2023-03-03 12:58 ` [Bug libgcc/108727] " amodra at gmail dot com
2023-03-06 11:01 ` linkw at gcc dot gnu.org
2023-03-08  7:00 ` cvs-commit at gcc dot gnu.org
2023-03-08  8:11 ` linkw at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108727-4-db1WIol7Jj@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).