code: plan9front

Download patch

ref: 91ae69be3306c807ae5bfa7d1b7ced8c239f9214
parent: 98b8e7609c725beeb7520863b3d0e07d95396e05
author: Jacob Moody <moody@posixcafe.org>
date: Tue May 9 16:02:13 EDT 2023

libmach: remove obsolete fishy case in mips header parsing

This code seems to be for the specific case of when
mips 3000 binaries were being run on a mips 4000 kernel.
As far as I know, our only current mips magic refers to the
5000 (at least), and the 4000 specific magic formats are mostly a relic.
There is currently no bootable system in which this code
path is correct. In any case, hardcoding /proc/1 is not the solution.

--- a/sys/src/libmach/executable.c
+++ b/sys/src/libmach/executable.c
@@ -248,27 +248,6 @@
 
 Mach	*mach = &mi386;			/* Global current machine table */
 
-static ExecTable*
-couldbe4k(ExecTable *mp)
-{
-	Dir *d;
-	ExecTable *f;
-
-	if((d=dirstat("/proc/1/regs")) == nil)
-		return mp;
-	if(d->length < 32*8){		/* R3000 */
-		free(d);
-		return mp;
-	}
-	free(d);
-	for (f = exectab; f->magic; f++)
-		if(f->magic == M_MAGIC) {
-			f->name = "mips plan 9 executable on mips2 kernel";
-			return f;
-		}
-	return mp;
-}
-
 int
 crackhdr(int fd, Fhdr *fp)
 {
@@ -301,9 +280,6 @@
 		if(mp->_magic){
 			if(mp->magic != (magic & ~DYN_MAGIC))
 				continue;
-
-			if(mp->magic == V_MAGIC)
-				mp = couldbe4k(mp);
 
 			if ((magic & DYN_MAGIC) && mp->dlmname != nil)
 				fp->name = mp->dlmname;