NetBSD Problem Report #53519

From www@NetBSD.org  Mon Aug 13 18:41:02 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 5F5F67A158
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 13 Aug 2018 18:41:02 +0000 (UTC)
Message-Id: <20180813184100.D073A7A210@mollari.NetBSD.org>
Date: Mon, 13 Aug 2018 18:41:00 +0000 (UTC)
From: nullnilaki@gmail.com
Reply-To: nullnilaki@gmail.com
To: gnats-bugs@NetBSD.org
Subject: aoutboot is broken since old NetBSD release.
X-Send-Pr-Version: www-1.0

>Number:         53519
>Category:       port-sgimips
>Synopsis:       aoutboot is broken since old NetBSD release.
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    tsutsui
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 13 18:45:00 +0000 2018
>Closed-Date:    Fri Nov 16 15:28:07 +0000 2018
>Last-Modified:  Fri Nov 16 15:28:07 +0000 2018
>Originator:     Naruaki Etomi
>Release:        NetBSD/sgimips 8.99.21
>Organization:
Japan
>Environment:
NetBSD  8.99.21 NetBSD 8.99.21 (GENERIC32_IP12) #1: Sun Aug 12 14:48:19 UTC 2018  naruaki@xserve:/usr/obj.sgimips/sys/arch/sgimips/compile/GENERIC32_IP2x sgimips

>Description:
Old Sgi machine (Indigo or Indy) don't understand ELF, so we may need an ECOFF binary.
However, "objcopy -O ecoff-bigmips" is broken.
As a result, aoutboot is broken.

# file aoutboot 
aoutboot: MIPSEB ECOFF executable (impure) stripped - version 0.0

>> hinv
                   System: IP22
                Processor: 180 Mhz R5000, with FPU
     Primary I-cache size: 32 Kbytes
     Primary D-cache size: 32 Kbytes
     Secondary cache size: 512 Kbytes
              Memory size: 192 Mbytes
                 Graphics: Indy 24-bit
                SCSI Disk: scsi(0)disk(4)
                    Audio: Iris Audio Processor: version A2 revision 4.1.0
>> 

Option? 5
Command Monitor.  Type "exit" to return to the menu.
>> bootp()aoutboot 
Obtaining aoutboot  from server xserve
49268+5136   
Exception: <vector=UTLB Miss>
Status register: 0x30004803<CU1,CU0,IM7,IM4,IPL=???,MODE=KERNEL,EXL,IE>
Cause register: 0x800c<CE=0,IP8,EXC=WMISS>
Exception PC: 0x9fc3ddac, Exception RA: 0x9fc2a528
exception, bad address: 0x0
Local I/O interrupt register 0: 0x8 <ENET>
Local I/O interrupt register 1: 0x80 <VR/GIO2>
  Saved user regs in hex (&gpda 0xa8740e48, &_regs 0xa8741048):
  arg: a8740000 0 382e3939 c400
  tmp: a8740000 1cc a8743ed8 1410 1410 a87487e0 0 887feca0
  sve: a8740000 3 400000 8000000 16 3f80 0 c000000
  t8 a8740000 t9 0 at 0 v0 0 v1 0 k1 0
  gp a8740000 fp 0 sp 0 ra 0

PANIC: Unexpected exception

>How-To-Repeat:

>Fix:
---------------------------------------------------------------------------------------------

diff -Naru src.orig/sys/arch/sgimips/stand/boot/Makefile src/sys/arch/sgimips/stand/boot/Makefile
--- src.orig/sys/arch/sgimips/stand/boot/Makefile	2011-02-28 04:54:52.000000000 +0000
+++ src/sys/arch/sgimips/stand/boot/Makefile	2018-08-12 05:34:29.870322920 +0000
@@ -12,10 +12,8 @@
 PROG=	aoutboot
 ${PROG}: ip2xboot ip3xboot
 .if ${MACHINE_ARCH} == "mipseb"
-	${OBJCOPY} --impure -O ecoff-bigmips \
-		-R .pdr -R .mdebug.nabi32 -R .mdebug.abi32 \
-		-R .comment -R .ident \
-		ip2xboot ${.TARGET}
+	cp ip2xboot ip2xboot.tmp
+	${ELF2ECOFF} ip2xboot.tmp ${.TARGET}
 .else
 	touch ${.TARGET}
 .endif
@@ -26,6 +24,8 @@

 CLEANFILES+=	ip2xboot.map ip3xboot.map

+CLEANFILES+=	ip2xboot.tmp
+
 .include "../Makefile.booters"

 ip3xboot: ${OBJS} ${LIBS}

---------------------------------------------------------------------------------------------

# file aoutboot 
aoutboot: MIPSEB ECOFF executable (impure) not stripped - version 2.10

>> bootp()aoutboot 
Obtaining aoutboot from server xserve
54400+0+1792 entry: 0x88002000

NetBSD/sgimips 8.99.21 Bootstrap, Revision 1.5 (Sun Aug 12 15:55:30 UTC 2018)


Please set the OSLoadPartition environment variable.
Error freeing load list node.
Unable to execute bootp()aoutboot 


*Tested on Indy and Indigo R4000.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: port-sgimips-maintainer->tsutsui
Responsible-Changed-By: tsutsui@NetBSD.org
Responsible-Changed-When: Sun, 02 Sep 2018 10:33:52 +0000
Responsible-Changed-Why:
I'll handle this.


State-Changed-From-To: open->analyzed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 02 Sep 2018 10:33:52 +0000
State-Changed-Why:
Confirmed as objcopy issue. I'll note it later.


From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: nullnilaki@gmail.com, tsutsui@ceres.dti.ne.jp
Subject: Re: port-sgimips/53519 (aoutboot is broken since old NetBSD release.)
Date: Sun, 2 Sep 2018 20:22:35 +0900

 > Confirmed as objcopy issue. I'll note it later.

 The original ip2xboot from NetBSD 8.0 has the following sections:

 ---
 /s/src/obj.sgimips/tooldir.NetBSD-8.0-i386/bin/mipseb--netbsd-size -A ip2xboot.elf
 ip2xboot.elf  :
 section            size                   addr
 .text             46240   18446744071696293888
 .text.startup       828   18446744071696340128
 .rodata            4796   18446744071696340960
 .reginfo             24   18446744071696345756
 .MIPS.abiflags       24   18446744071696345784
 .data               336   18446744071696345808
 .sbss              1148   18446744071696346144
 .bss                640   18446744071696347296
 .pdr               5152                      0
 .gnu.attributes      16                      0
 .comment             33                      0
 .ident               62                      0
 Total             59299
 ---

 An aoutboot binary (actually ecoff binary) converted by objcopy(1) has
 the following sections:

 ---
 % /s/src/obj.sgimips/tooldir.NetBSD-8.0-i386/bin/mipseb--netbsd-size -A aoutboot-objcopy
 aoutboot-objcopy  :
 section     size         addr
 .text      46240   2281709568
 .text.st     828   2281755808
 .rodata     4800   2281756640
 .reginfo      24   2281761436
 .MIPS.ab      24   2281761464
 .data        336   2281761488
 .sbss       1148   2281761824
 .bss         640   2281762976
 .gnu.att      16            0
 Total      54056
 ---

 ARCBIOS loads this binary (and fails) as reported in the PR:

 ---
 >> bootp()aoutboot
 Setting $netaddr to 192.168.20.39 (from server mirage)
 Obtaining aoutboot from server mirage
 47068+5200   
 Exception: <vector=UTLB Miss>
 Status register: 0x30004803<CU1,CU0,IM7,IM4,IPL=???,MODE=KERNEL,EXL,IE>
 Cause register: 0x800c<CE=0,IP8,EXC=WMISS>
 Exception PC: 0x9fc3ddac, Exception RA: 0x9fc2a528
 exception, bad address: 0x0
 Local I/O interrupt register 0: 0x8 <ENET>
 Local I/O interrupt register 1: 0x80 <VR/GIO2>
   Saved user regs in hex (&gpda 0xa8740e48, &_regs 0xa8741048):
   arg: a8740000 4e657442 53442f73 ba00
   tmp: a8740000 64 a8743ed8 1450 1450 a87487e0 0 887feca0
   sve: a8740000 3 400000 8000000 16 3f80 0 c000000
   t8 a8740000 t9 0 at 0 v0 0 v1 0 k1 0
   gp a8740000 fp 0 sp 0 ra 0

 PANIC: Unexpected exception

 [Press reset or ENTER to restart.]
 ---

 "47068" seems:
   46240 (.text)
 + 828 (.text.startup).

 "5200" seems:
   4800 (.rodata)
 + 24 (.reginfo)
 + 24 (MIPS.abiflags)
 + 336 (.data)
 + alignment?

 There is no info about .bss.

 I removed the extra .gnu.attributes section (that has no valid address)
 by -R option then it went a bit further, but ARCBIOS still fails
 to execute it:

 ---
 aoutboot-objdump-no-gnu.attributes  :
 section     size         addr
 .text      46240   2281709568
 .text.st     828   2281755808
 .rodata     4800   2281756640
 .reginfo      24   2281761436
 .MIPS.ab      24   2281761464
 .data        336   2281761488
 .sbss       1148   2281761824
 .bss         640   2281762976
 Total      54040

 ---
 >> bootp()aoutboot
 Setting $netaddr to 192.168.20.39 (from server mirage)
 Obtaining aoutboot from server mirage
 47068+5184+1788 entry: 0x88002000
 g...
 g...

 Exception: <vector=UTLB Miss>
 Status register: 0x30004803<CU1,CU0,IM7,IM4,IPL=???,MODE=KERNEL,EXL,IE>
 Cause register: 0x8008<CE=0,IP8,EXC=RMISS>
 Exception PC: 0x880024b0, Exception RA: 0x8800d544
 exception, bad address: 0x0
 Local I/O interrupt register 1: 0x80 <VR/GIO2>
   Saved user regs in hex (&gpda 0xa8740e48, &_regs 0xa8741048):
   arg: a8740000 196 0 1
   tmp: a8740000 88010000 887fe894 88010000 7 ffffffff 76 88010000
   sve: a8740000 3 400000 8000000 16 3f80 0 c000000
   t8 a8740000 t9 0 at 0 v0 0 v1 0 k1 0
   gp a8740000 fp 0 sp 0 ra 0

 PANIC: Unexpected exception

 [Press reset or ENTER to restart.]
 ---

 The failed address 0x880024b0 is in getopt() and the exception is caused
 by a NULL pointer dereference, so I guess some data is not loaded correctly.

 An aoutboot binaryconverted by elf2ecoff(1) has the following
 simple sections:

 ---
 % /s/src/obj.sgimips/tooldir.NetBSD-8.0-i386/bin/mipseb--netbsd-size -A aoutboot-elf2ecoff
 aoutboot-elf2ecoff  :
 section    size         addr
 .text   52256   2281709568
 .data       0   2281761824
 .bss     1792   2281761824
             0            0
             0            0
             0            0
 Total   54048
 ---

 ARCBIOS loads this binary (and executes successfully) as the following:

 ---
 >> bootp()aoutboot
 Setting $netaddr to 192.168.20.39 (from server mirage)
 Obtaining aoutboot from server mirage
 52256+0+1792 entry: 0x88002000

 NetBSD/sgimips 8.0 Bootstrap, Revision 1.5 (Sat Sep  1 18:49:55 UTC 2018)

 devopen: scsi(0)disk(1)rdisk(0)partition(0) type scsi file /netbsd
 4908464+131360 [267552+259212]=0x54f6c4
 ---

 "52256" is .text. It seems merged from all sections except .sbss and .bss
 (for simplicity?):
   46240 (.text)
 + 828 (.text.startup)
 + 4800 (.rodata)
 + 24 (.reginfo)
 + 24 (MIPS.abiflags)
 + 336 (.data)
 + alignment?

 The next "0" means there is no .data section
 (because it's merged into .text).

 The last "1792" seems .sbss (1148) + .bss (640) + alignemnt.


 I wonder if we can deal these annoying sections in ldscript for objcopy,
 but I think it's much easier to use our traditional elf2ecoff,
 as pmax and luna68k (using elf2aout) etc. do.

 A bit off-topic, but probably NetBSD/arc has the same problem.
 At least, we have to remove the .gnu.attributes section in
 sys/arch/arc/stand/boot/Makefile.

 ---
 Izumi Tsutsui

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53519 CVS commit: src/sys/arch/sgimips/stand/boot
Date: Sun, 2 Sep 2018 12:06:17 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Sun Sep  2 12:06:17 UTC 2018

 Modified Files:
 	src/sys/arch/sgimips/stand/boot: Makefile

 Log Message:
 Use elf2ecoff(1) rather than objcopy(1) to generat ecoff for old machines.

 objcopy(1) was used instead of elf2ecoff(1) since Makefile rev 1.9:
  http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sgimips/stand/boot/Makefile#rev1.9
 but it looks ELF binaries generated by recent binutils are too complicated
 to convert them to ecoff for old machines by objcopy(1).

 Reported by Naruaki Etomi in PR port-sgimips/53519.
 Should be pulled up to at least netbsd-8.


 To generate a diff of this commit:
 cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sgimips/stand/boot/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: analyzed->needs-pullups
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 02 Sep 2018 12:30:32 +0000
State-Changed-Why:


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 09 Sep 2018 04:52:30 +0000
State-Changed-Why:
[pullup-8 #1017] [pullup-7 #1637]


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53519 CVS commit: [netbsd-7] src
Date: Tue, 30 Oct 2018 19:02:51 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Tue Oct 30 19:02:51 UTC 2018

 Modified Files:
 	src/distrib/sgimips/instkernel [netbsd-7]: Makefile
 	src/sys/arch/sgimips/conf [netbsd-7]: INSTALL32_IP2x
 	src/sys/arch/sgimips/stand/boot [netbsd-7]: Makefile

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #1637):

 	sys/arch/sgimips/conf/INSTALL32_IP2x: revision 1.10
 	sys/arch/sgimips/stand/boot/Makefile: revision 1.20
 	distrib/sgimips/instkernel/Makefile: revision 1.13

 Disable misc options to shrink an INSTALL kernel for IP2x.

 The ARC BIOS on Indy seems to have ~8MB limit.

 Fixes PR port-sgimips/53378 from Naruaki Etomi.
 Should be pulled up to netbsd-7 and netbsd-8.

  -

 Use elf2ecoff(1) rather than objcopy(1) to generat ecoff for old machines.
 objcopy(1) was used instead of elf2ecoff(1) since Makefile rev 1.9:

  http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sgimips/stand/boot/Makefile#rev1.9

 but it looks ELF binaries generated by recent binutils are too complicated
 to convert them to ecoff for old machines by objcopy(1).

 Reported by Naruaki Etomi in PR port-sgimips/53519.

 Should be pulled up to at least netbsd-8.

  -

 Use elf2ecoff(1) rather than objcopy(1) to generate ecoff kernel.

 Reported by Naruaki Etomi in PR port-sgimips/53518.
 Should be pulled up to netbsd-7 and netbsd-8.


 To generate a diff of this commit:
 cvs rdiff -u -r1.11 -r1.11.4.1 src/distrib/sgimips/instkernel/Makefile
 cvs rdiff -u -r1.9 -r1.9.22.1 src/sys/arch/sgimips/conf/INSTALL32_IP2x
 cvs rdiff -u -r1.19 -r1.19.30.1 src/sys/arch/sgimips/stand/boot/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Fri, 16 Nov 2018 15:28:07 +0000
State-Changed-Why:
Pullups complete.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.