Subject: exec_linux_elf lkm fix for 64bit archs
To: NetBSD current <current-users@netbsd.org>
From: Nicolas Joly <njoly@pasteur.fr>
List: current-users
Date: 09/13/2007 13:54:44
--y0ulUmNC+osPPQO6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


Hi,

I just made the following set of changes to make `exec_linux_elf' lkm
work on amd64, and possibly other 64bit platforms (alpha, sparc64)
... In the mean time i have the needed `compat_linux' amd64 lkm, but
it may need some more work/cleanup.

Does this one looks ok ?

Thanks.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.

--y0ulUmNC+osPPQO6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="netbsd-lkmexeclinuxelf.diff"

Index: sys/lkm/exec/Makefile
===================================================================
RCS file: /cvsroot/src/sys/lkm/exec/Makefile,v
retrieving revision 1.14
diff -u -r1.14 Makefile
--- sys/lkm/exec/Makefile	24 Mar 2002 15:01:57 -0000	1.14
+++ sys/lkm/exec/Makefile	13 Sep 2007 11:39:28 -0000
@@ -1,5 +1,9 @@
 #	$NetBSD: Makefile,v 1.14 2002/03/24 15:01:57 kent Exp $
 
+.if ${MACHINE} == "amd64"
+SUBDIR+=	linux_elf
+.endif
+
 .if ${MACHINE} == "i386"
 SUBDIR+=	freebsd_aout freebsd_elf linux_elf svr4_elf pecoff
 .endif
Index: sys/lkm/exec/linux_elf/Makefile
===================================================================
RCS file: /cvsroot/src/sys/lkm/exec/linux_elf/Makefile,v
retrieving revision 1.9
diff -u -r1.9 Makefile
--- sys/lkm/exec/linux_elf/Makefile	12 May 2007 10:45:01 -0000	1.9
+++ sys/lkm/exec/linux_elf/Makefile	13 Sep 2007 11:39:28 -0000
@@ -3,6 +3,7 @@
 .include "../Makefile.inc"
 
 .PATH:	$S/compat/linux/common
+.PATH:	$S/compat/linux/arch/${MACHINE}
 .PATH:	$S/compat/linux/arch/${MACHINE_ARCH}
 
 CPPFLAGS+=	-nostdinc -D_KERNEL -DEXEC_ELF32 -DEXEC_ELF64
@@ -11,13 +12,15 @@
 
 SRCS=	lkminit_exec.c
 
-.if ${MACHINE} == "i386"
+.if ${MACHINE} == "amd64" || ${MACHINE} == "i386"
 SRCS+=	linux_exec_machdep.c
 .endif
 
-.if ${MACHINE} == "alpha" || ${MACHINE} == "sparc64"
+.if ${MACHINE} == "alpha" || ${MACHINE} == "amd64" || ${MACHINE} == "sparc64"
+CPPFLAGS+=	-DELFSIZE=64
 SRCS+=	linux_exec_elf64.c
 .else
+CPPFLAGS+=	-DELFSIZE=32
 SRCS+=	linux_exec_elf32.c
 .endif
 
Index: sys/lkm/exec/linux_elf/lkminit_exec.c
===================================================================
RCS file: /cvsroot/src/sys/lkm/exec/linux_elf/lkminit_exec.c,v
retrieving revision 1.10
diff -u -r1.10 lkminit_exec.c
--- sys/lkm/exec/linux_elf/lkminit_exec.c	11 Dec 2005 12:24:48 -0000	1.10
+++ sys/lkm/exec/linux_elf/lkminit_exec.c	13 Sep 2007 11:39:28 -0000
@@ -48,7 +48,6 @@
 #include <sys/signalvar.h>
 
 #include <machine/elf_machdep.h>
-#define ELFSIZE	32
 #include <sys/exec_elf.h>
 
 #include <compat/linux/common/linux_exec.h>
@@ -56,7 +55,7 @@
 int exec_linux_elf_lkmentry __P((struct lkm_table *, int, int));
 
 static struct execsw exec_linux_elf =
-	/* Linux Elf32 */
+	/* Linux Elf */
 	{ sizeof (Elf_Ehdr),
 	  ELFNAME2(exec,makecmds),
 	  { ELFNAME2(linux,probe) },
@@ -65,7 +64,7 @@
 	  LINUX_ELF_AUX_ARGSIZ,
 	  ELFNAME2(linux,copyargs),
 	  NULL,
-	  coredump_elf32,	/* XXX ELF64? */
+	  ELFNAMEEND(coredump),
 	  linux_exec_setup_stack };
 
 /*

--y0ulUmNC+osPPQO6--