Subject: elf2ecoff patches for sgimips
To: None <port-sgimips@netbsd.org, port-pmax@netbsd.org, port-mips@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: port-pmax
Date: 03/16/2002 19:07:47
--C7zPtVaVf+AK4Oqc
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

[resent because of typo in To:. Sorry ]
Hi,
the attached patch makes the in-tree elf2ecoff produce a working kernel
image from a elf kernel sgimips. It should still work MIPSEL ports, but
I can't test it.

Any objections if I commit this patch ?

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
--


--C7zPtVaVf+AK4Oqc
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

? obj
Index: elf2ecoff.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/elf2ecoff/elf2ecoff.c,v
retrieving revision 1.14
diff -u -r1.14 elf2ecoff.c
--- elf2ecoff.c	2000/03/13 23:22:51	1.14
+++ elf2ecoff.c	2002/03/16 18:00:55
@@ -288,7 +288,16 @@
 	memset(&ep.a.cprmask, 0, sizeof ep.a.cprmask);
 	ep.a.gp_value = 0;	/* unused. */
 
-	ep.f.f_magic = ECOFF_MAGIC_MIPSEL;
+	if (ex.e_ident[EI_DATA] == ELFDATA2LSB)
+		ep.f.f_magic = ECOFF_MAGIC_MIPSEL;
+	else if (ex.e_ident[EI_DATA] == ELFDATA2MSB)
+		ep.f.f_magic = ECOFF_MAGIC_MIPSEB;
+	else {
+		fprintf(stderr, "invalid ELF byte order %d\n",
+		    ex.e_ident[EI_DATA]);
+		exit(1);
+	}
+
 	ep.f.f_nscns = 6;
 	ep.f.f_timdat = 0;	/* bogus */
 	ep.f.f_symptr = 0;

--C7zPtVaVf+AK4Oqc--