NetBSD Problem Report #49806
From www@NetBSD.org Wed Apr 1 09:51:19 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 9127AA654C
for <gnats-bugs@gnats.NetBSD.org>; Wed, 1 Apr 2015 09:51:19 +0000 (UTC)
Message-Id: <20150401095118.42BFFA65BB@mollari.NetBSD.org>
Date: Wed, 1 Apr 2015 09:51:18 +0000 (UTC)
From: macallan@netbsd.org
Reply-To: macallan@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: binaries linked with -static-libgcc crash on MIPS
X-Send-Pr-Version: www-1.0
>Number: 49806
>Category: port-mips
>Synopsis: binaries linked with -static-libgcc crash on MIPS
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-mips-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Apr 01 09:55:00 +0000 2015
>Closed-Date: Sun May 03 05:45:33 +0000 2015
>Last-Modified: Sun May 03 05:45:33 +0000 2015
>Originator: Michael Lorenz
>Release: -current
>Organization:
>Environment:
NetBSD ci20 7.99.7 NetBSD 7.99.7 (CI20) #1: Sun Mar 29 05:19:00 EDT 2015 ml@blackbush:/home/build/obj_evbmips32/sys/arch/evbmips/compile/CI20 evbmips
NetBSD moonshine 7.99.5 NetBSD 7.99.5 (O2) #1: Fri Feb 27 08:50:00 EST 2015 ml@blackbush:/stuff/build/obj_sgimips/sys/arch/sgimips/compile/O2 sgimips
>Description:
Some tests in gcc's configure script fail like this:
cc -pipe -O2 -static-libstdc++ -static-libgcc -o test test.c
./test
Bus error (core dumped)
( specifically the one trying to figure out what size long longs are but I don't think this matters )
On sgimips the fault happens in rtld_start() from /usr/libexec/ld.elf_so with memory at the fault address inaccessible, on mips32 it looks somewhat different:
Program received signal SIGBUS, Bus error.
0x00400608 in ?? ()
(gdb) disassemble 0x004005f0, +100
Dump of assembler code from 0x4005f0 to 0x400654:
0x004005f0: 0x5f5f0061
0x004005f4: 0x5f737362
0x004005f8: 0x72617473
0x004005fc: 0x665f0074
0x00400600: 0x737362
0x00400604: 0x646e655f
=> 0x00400608: bgtz zero,0x400e0c
0x0040060c <_init+4>: 0x9c88373c
0x00400610 <_init+8>: lwr zero,8487(t7)
0x00400614 <_init+12>: cache 0x1f,-6141(t7)
0x00400618 <_init+16>: cache 0x0,5159(t8)
0x0040061c <_init+20>: 0xb00000af
0x00400620 <_init+24>: lb zero,8623(a0)
0x00400624: 0xe02103
0x00400628: lwr zero,11266(t4)
(gdb) disassemble 0x00400e0c, +100
Dump of assembler code from 0x400e0c to 0x400e70:
0x00400e0c: jal 0x107434
0x00400e10: ldc3 $0,0(s0)
0x00400e14: 0xedf
0x00400e18: nop
0x00400e1c: sdc3 $31,-1(ra)
On both machines the binary works fine without -static-libgcc.
The same happens with binaries linked with -lexecinfo, which keeps things like cmake from building.
>How-To-Repeat:
build.sh tools or build pkgsrc/lang/cmake on evbmips-el or sgimips, likely other mips as well
>Fix:
>Release-Note:
>Audit-Trail:
From: Michael <macallan@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-mips/49806: binaries linked with -static-libgcc crash on
MIPS
Date: Wed, 1 Apr 2015 07:50:24 -0400
this appears to be the root cause:
Disassembly of section .init:
00400609 <_init>:
400609: 0002 addiu s0,sp,8
40060b: 3c1c ld s0,224(a0)
40060d: 86a7 lb a1,7(a2)
40060f: 279c beqz a3,400549 <_DYNAMIC+0x399>
400611: e021 addu s0,s1
...
without -static-libgcc _init looks like this:
Disassembly of section .init:
00400698 <_init>:
400698: 3c1c0002 lui gp,0x2
40069c: 279c8828 addiu gp,gp,-30680
4006a0: 0399e021 addu gp,gp,t9
4006a4: 27bdffe8 addiu sp,sp,-24
4006a8: afbf0014 sw ra,20(sp)
4006ac: afb00000 sw s0,0(sp)
( thanks skrll@ )
State-Changed-From-To: open->closed
State-Changed-By: macallan@NetBSD.org
State-Changed-When: Sun, 03 May 2015 05:45:33 +0000
State-Changed-Why:
fixed by this commit:
Module Name: src
Committed By: matt
Date: Fri May 1 21:35:56 UTC 2015
Modified Files:
src/lib/csu/arch/mips: crti.S
Log Message:
Make sure .init and .fini are word (4byte) aligned.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/csu/arch/mips/crti.S
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.