NetBSD Problem Report #8575

Received: (qmail 13600 invoked from network); 7 Oct 1999 12:25:26 -0000
Message-Id: <199910071224.VAA18359@mirage.ceres.dti.ne.jp>
Date: Thu, 7 Oct 1999 21:24:56 +0900 (JST)
From: 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: MI loadfile() cannot load NMAGIC a.out kernel
X-Send-Pr-Version: 3.95

>Number:         8575
>Category:       bin
>Synopsis:       MI loadfile() cannot load NMAGIC a.out kernel
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 07 05:35:00 +0000 1999
>Closed-Date:    Fri Oct 08 04:22:08 +0000 1999
>Last-Modified:  Fri Oct 08 04:23:29 +0000 1999
>Originator:     Izumi Tsutsui
>Release:        NetBSD-current 1.4K 19990918
>Organization:
Izumi Tsutsui	Himeji City, Japan
>Environment:
System: NetBSD 1.4K a.out

>Description:
MI loadfile() does not handle NMAGIC a.out files correctly
so it cannot load them.

>How-To-Repeat:
Use MI loadfile() to load a NMAGIC a.out kernel.
Currently sparc /boot uses MI loadfile()
and also supports a.out kernel.

>Fix:
* Don't count a.out header size on loading a NMAGIC file
* Fix text segment alignment code (from itohy@netbsd.org)

--- /sys/lib/libsa/loadfile.c.orig	1999/09/11 15:58:02
+++ /sys/lib/libsa/loadfile.c	1999/10/07 12:01:30
@@ -450,8 +450,8 @@
 	u_long magic = N_GETMAGIC(*x);
 	int sub;

-	/* In OMAGIC, exec header isn't part of text segment */
-	if (magic == OMAGIC)
+	/* In OMAGIC and NMAGIC, exec header isn't part of text segment */
+	if (magic == OMAGIC || magic == NMAGIC)
 		sub = 0;
 	else
 		sub = sizeof(*x);
@@ -468,7 +468,7 @@
 	 * The kernel may use this to verify that the
 	 * symbols were loaded by this boot program.
 	 */
-	if (magic == OMAGIC) {
+	if (magic == OMAGIC || magic == NMAGIC) {
 		if (flags & LOAD_HDR)
 			BCOPY(x, maxp - sizeof(*x), sizeof(*x));
 	}
@@ -502,7 +502,7 @@
 	 * Provide alignment if required
 	 */
 	if (magic == ZMAGIC || magic == NMAGIC) {
-		int size = (int)maxp & __LDPGSZ;
+		int size = -(unsigned int)maxp & (__LDPGSZ - 1);

 		if (flags & LOAD_TEXTA) {
 			PROGRESS(("/%d", size));
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: itohy 
State-Changed-When: Thu Oct 7 21:22:08 PDT 1999 
State-Changed-Why:  
patch applied. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.