Subject: Re: 4.3-reno binaries on NetBSD
To: None <mirian@cosmic.com>
From: Christian Groessler <cpg@aladdin.de>
List: port-vax
Date: 12/31/2000 18:24:13
Hi,

I managed to get the binaries from 4.3quasijarus0a to run on NetBSD
(1.5). Please find my patch attached.

There were 2 problems:
        - the a_midmag (a_magic) entry in the a.out header
        - the first page of the executable

The current a_midmag is defined as always big_endian, regardless of
the system's endianness. In the quasijarus version it's simply the
system's endianness, same in the 4.3reno version. (At least I found
nothing in the 4.3QJ and CSRG 4.3reno sources which would indicate an
endianness aware access.)

This also means that the binaries distributed with the CSRG CD 4.3reno
version aren't vax, as they are big-endian.


The problem with the 1st page (1K) of the executable is that it
shouldn't be loaded into progam memory. I haven't found the place in
the 4.3QJ sources where the 1st page gets dropped, but this doesn't
mean much, since I'm not familar with the paging code...

But when not loading the first 1K of the file, which contain the a.out
header and only 0s, the executables work.

My patch is only a hack for now, but maybe it can be converted to a
kernel config option? (After people knowing more than me about the
kernel and executable formats etc. have looked at it...)

regards,
chris

----------------------
Index: vax1k_exec.c
===================================================================
RCS file: /net/swamp/zeug/netbsd-rsync/main/syssrc/sys/compat/vax1k/vax1k_exec.c,v
retrieving revision 1.1
diff -u -r1.1 vax1k_exec.c
--- vax1k_exec.c	1998/08/21 13:25:47	1.1
+++ vax1k_exec.c	2001/01/01 01:28:39
@@ -72,7 +72,7 @@
 	struct proc *p;
 	struct exec_package *epp;
 {
-	u_long midmag, magic;
+	u_long midmag, magic, midmag2;
 	u_short mid;
 	int error;
 	struct exec *execp = epp->ep_hdr;
@@ -80,6 +80,12 @@
 	if (epp->ep_hdrvalid < sizeof(struct exec))
 		return ENOEXEC;
 
+	midmag2 = execp->a_midmag;
+	if (midmag2 == ZMAGIC) {
+		error = exec_vax1k_prep_anymagic(p, epp, 0x400);
+		goto cont;
+	}	
+
 	midmag = ntohl(execp->a_midmag);
 	mid = (midmag >> 16) & 0x3ff;
 	magic = midmag & 0xffff;
@@ -100,6 +106,7 @@
 		error = ENOEXEC;
 	}
 
+	cont:
 	if (error)
 		kill_vmcmds(&epp->ep_vmcmds);
 
----------------------