NetBSD Problem Report #44375

From tsutsui@ceres.dti.ne.jp  Wed Jan 12 11:42:12 2011
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 86BE663B89F
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 12 Jan 2011 11:42:12 +0000 (UTC)
Message-Id: <201101121142.p0CBg9US005542@mirage.localdomain>
Date: Wed, 12 Jan 2011 20:42:09 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@gnats.NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: NetBSD/mips 1.6 binary doesn't work on NetBSD/mips -current
X-Send-Pr-Version: 3.95

>Number:         44375
>Category:       port-mips
>Synopsis:       NetBSD/mips 1.6 binary doesn't work on NetBSD/mips -current
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-mips-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 12 11:45:00 +0000 2011
>Closed-Date:    Sun Jan 16 09:57:50 +0000 2011
>Last-Modified:  Sun Jan 16 09:57:50 +0000 2011
>Originator:     Izumi Tsutsui
>Release:        NetBSD 5.99.43
>Organization:
>Environment:

System: NetBSD/pmax 5.99.43 on GXemul and 3MIN, NetBSD/sgimips on O2
Architecture: mips
Machine: confirmed on pmax and sgimips, but maybe affects all mips ports

>Description:
NetBSD/mips 1.6 binaries doesn't work on recent NetBSD/mips 5.99.43
on a GENERIC kernel with options COMPAT_12 .. 50 due to "Exec format error."

>How-To-Repeat:
For a quick test:
- install gxemul
- fetch ftp://ftp.NetBSD.org/pub/NetBSD/misc/tsutsui/fsimage/pmax-201101090300Z.img.gz
- gunzip pmax-201101090300Z.img.gz
- gxemul -Xe 3max -d pmax-201101090300Z.img
- in gxemul window:
 login: root
  :
 # /echo-1.6
 /echo-1.6: Exec format error. Wrong Architecture.
 # file /echo-1.6
 /echo-1.6: ELF 32-bit LSB executable, MIPS, MIPS-I version 1 (SYSV), statically linked, for NetBSD, stripped
 # uname -a
 NetBSD  5.99.43 NetBSD 5.99.43 (GENERIC) #0: Sun Jan  9 03:13:28 UTDC 2011  builds@b7.netbsd.org:/home/builds/ab/HEAD/pmax/201101090300Z-obj/home/builds/ab/HEAD/src/sys/arch/pmax/compile/GENERIC pmax
 #

- Dynamic linked binares don't work either.
- Also happens on NetBSD/pmax on real 3MIN (R3000)
  and NetBSD/sgmips real O2 (R5000).
- Works fine on NetBSD/sgimips 5.99.22 kernel on the same O2.

>Fix:
Check arch/mips/mips/cpu_exec.c etc?

---
Izumi Tsutsui

>Release-Note:

>Audit-Trail:
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: port-mips/44375: NetBSD/mips 1.6 binary doesn't work on NetBSD/mips
	 -current
Date: Wed, 12 Jan 2011 23:25:52 +0900

 > >Synopsis:       NetBSD/mips 1.6 binary doesn't work on NetBSD/mips -current
  :
 > >Fix:
 > Check arch/mips/mips/cpu_exec.c etc?

 ENOEXEC here:
 ---
 int
 mips_netbsd_elf32_probe(struct lwp *l, struct exec_package *epp, void *eh0,
 	char *itp, vaddr_t *start_p)
 {
  :
 	switch (eh->e_flags & (EF_MIPS_ABI|EF_MIPS_ABI2)) {
 #if !defined(__mips_o32)
 	case EF_MIPS_ABI2:
  :
 #endif
 	case EF_MIPS_ABI_O32:
  :
 	default:
 		return ENOEXEC;
 	}
 ---

 eh->e_flags is 0x0056, so
 eh->e_flags & (EF_MIPS_ABI|EF_MIPS_ABI2) == 0.

 Needs "case 0:" inside COMPAT_16 for ancient ELF binaries?

 ---
 Izumi Tsutsui

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44375 CVS commit: src/sys/arch/mips/mips
Date: Sun, 16 Jan 2011 09:50:45 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Sun Jan 16 09:50:45 UTC 2011

 Modified Files:
 	src/sys/arch/mips/mips: cpu_exec.c

 Log Message:
 Make pre-2.0 ELF binaries (with gcc-2.95.3/binutils-2.11.2) actually work
 with options COMPAT_16.
 Tested on R3000 pmax and R5000 sgimips, closes PR port-mips/44375.


 To generate a diff of this commit:
 cvs rdiff -u -r1.59 -r1.60 src/sys/arch/mips/mips/cpu_exec.c

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

State-Changed-From-To: open->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 16 Jan 2011 18:57:50 +0900
State-Changed-Why:
Now it works.


>Unformatted:
 Fetched from HEAD/201101090300Z on daily build

NetBSD Home
NetBSD PR Database Search

(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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.