mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: musl segfaulting when compiled with -O2
Date: Wed, 8 Mar 2017 02:18:43 +0100	[thread overview]
Message-ID: <20170308011842.GI2082@port70.net> (raw)
In-Reply-To: <20170307214540.GU1520@brightrain.aerifal.cx>

* Rich Felker <dalias@libc.org> [2017-03-07 16:45:40 -0500]:
> On Tue, Mar 07, 2017 at 05:55:29PM -0300, Breno Leitao wrote:
> >   $ wget http://cdn-fastly.deb.debian.org/debian/pool/main/m/musl/musl_1.1.16-2_ppc64el.deb
> > 
> >   $ dpkg-deb -x musl_1.1.16-2_ppc64el.deb .
> > 
> >   $ lib/powerpc64le-linux-musl/libc.so 
> > [2]    25672 segmentation fault (core dumped) lib/powerpc64le-linux-musl/libc.so
> 
> Can you do a register dump and a dissassembly dump and around the
> point that crashes? The Debian package is fully stripped (lacks debug
> symbols) so it's hard to follow what it's doing, but I didn't see
> anything obviously wrong.
> 
> Rich

i used qemu-ppc64le -singlestep -d in_asm,cpu to debug this

the relevant code is the end of _dlstart_c:
...
   8c574:       09 00 00 48     bl      8c57c <writev+0x28c>
   8c578:       28 98 fa ff     fsub    f31,f26,f19
   8c57c:       a6 02 48 7d     mflr    r10
   8c580:       00 00 2a 81     lwz     r9,0(r10)
   8c584:       14 52 29 7d     add     r9,r9,r10
   8c588:       a6 03 29 7d     mtctr   r9
   8c58c:       18 00 41 f8     std     r2,24(r1)
   8c590:       78 3b e4 7c     mr      r4,r7
   8c594:       78 4b 2c 7d     mr      r12,r9
   8c598:       21 04 80 4e     bctrl

it's a pc relative address load and jump (to call __dls2):

   bl 1f
   data          // data == 0xfffa9828
1: mflr r10      // r10 = &data == 0x8c57c
   lwz r9,0(r10) // r9 = *r10 (== data)
   add r9,r9,r10 // r9 += r10 (== 0xfffa9828+0x8c57c = 0x100035da0)
   mtctr r9      // ctr = r9 (== 0x100035da0)
   std r2,24(r1)
   mr r4,r7
   mr r12,r9
   bctrl         // ctr(r12,r4)

it seems __dls2 is at 0x35da0 so the pc relative data
should have been signextended.


  reply	other threads:[~2017-03-08  1:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07 20:32 Breno Leitao
2017-03-07 20:39 ` Rich Felker
2017-03-07 20:55   ` Breno Leitao
2017-03-07 21:45     ` Rich Felker
2017-03-08  1:18       ` Szabolcs Nagy [this message]
2017-03-08  2:28         ` Rich Felker
2017-03-08 14:19           ` Breno Leitao
2017-03-08 18:39             ` Rich Felker

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=20170308011842.GI2082@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).