From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11116 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: musl segfaulting when compiled with -O2 Date: Tue, 7 Mar 2017 21:28:27 -0500 Message-ID: <20170308022827.GW1520@brightrain.aerifal.cx> References: <20170307203234.GC18936@gmail.com> <20170307203905.GT1520@brightrain.aerifal.cx> <20170307205529.GD18936@gmail.com> <20170307214540.GU1520@brightrain.aerifal.cx> <20170308011842.GI2082@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MW5yreqqjyrRcusr" X-Trace: blaine.gmane.org 1488940124 24755 195.159.176.226 (8 Mar 2017 02:28:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 8 Mar 2017 02:28:44 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11131-gllmg-musl=m.gmane.org@lists.openwall.com Wed Mar 08 03:28:40 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1clRL9-0005T1-HB for gllmg-musl@m.gmane.org; Wed, 08 Mar 2017 03:28:35 +0100 Original-Received: (qmail 14228 invoked by uid 550); 8 Mar 2017 02:28:39 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14202 invoked from network); 8 Mar 2017 02:28:39 -0000 Content-Disposition: inline In-Reply-To: <20170308011842.GI2082@port70.net> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11116 Archived-At: --MW5yreqqjyrRcusr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Mar 08, 2017 at 02:18:43AM +0100, Szabolcs Nagy wrote: > * Rich Felker [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 > 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. Does the attached patch fix it? Rich --MW5yreqqjyrRcusr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ppc64_crash.diff" diff --git a/arch/powerpc64/reloc.h b/arch/powerpc64/reloc.h index e1bad00..faf70ac 100644 --- a/arch/powerpc64/reloc.h +++ b/arch/powerpc64/reloc.h @@ -27,6 +27,6 @@ " bl 1f \n" \ " .long " #sym "-. \n" \ "1: mflr %1 \n" \ - " lwz %0, 0(%1) \n" \ + " lwa %0, 0(%1) \n" \ " add %0, %0, %1 \n" \ : "=r"(*(fp)), "=r"((long){0}) : : "memory", "lr" ) --MW5yreqqjyrRcusr--