All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] architecture-specific ELF header checking
@ 2006-06-12 20:12 Hollis Blanchard
  2006-06-13  9:15 ` Keir Fraser
  0 siblings, 1 reply; 7+ messages in thread
From: Hollis Blanchard @ 2006-06-12 20:12 UTC (permalink / raw)
  To: xen-devel; +Cc: xen-ia64-devel

This patch has only been compile-tested on x86, but it should be pretty
straightforward. It could break IA64 since it adds checks they weren't
doing before, but I would expect their ELF binaries are labeled
properly.

Also, EM_NUM was wrong, but never used. It might be worth it to pull in
a fresh copy of xc_elf.h from wherever it came from.



Check ELF header fields without ifdefs.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>

diff -r 34ff26fb2240 config/ia64.mk
--- a/config/ia64.mk	Mon Jun 12 12:01:32 2006 +0100
+++ b/config/ia64.mk	Mon Jun 12 15:04:35 2006 -0500
@@ -2,3 +2,4 @@ CONFIG_IOEMU := y
 CONFIG_IOEMU := y
 
 LIBDIR := lib
+CFLAGS += -DELFCLASS=ELFCLASS64 -DELFDATA=ELFDATA2LSB -DELFMACHINE=EM_IA_64
diff -r 34ff26fb2240 config/x86_32.mk
--- a/config/x86_32.mk	Mon Jun 12 12:01:32 2006 +0100
+++ b/config/x86_32.mk	Mon Jun 12 15:04:35 2006 -0500
@@ -5,5 +5,6 @@ CONFIG_IOEMU := y
 CONFIG_IOEMU := y
 CONFIG_MBOOTPACK := y
 
-CFLAGS += -m32 -march=i686
+CFLAGS += -m32 -march=i686 \
+	-DELFCLASS=ELFCLASS32 -DELFDATA=ELFDATA2LSB -DELFMACHINE=EM_386
 LIBDIR := lib
diff -r 34ff26fb2240 config/x86_64.mk
--- a/config/x86_64.mk	Mon Jun 12 12:01:32 2006 +0100
+++ b/config/x86_64.mk	Mon Jun 12 15:04:35 2006 -0500
@@ -5,5 +5,6 @@ CONFIG_IOEMU := y
 CONFIG_IOEMU := y
 CONFIG_MBOOTPACK := y
 
-CFLAGS += -m64
+CFLAGS += -m64 \
+	-DELFCLASS=ELFCLASS64 -DELFDATA=ELFDATA2LSB -DELFMACHINE=EM_X86_64
 LIBDIR = lib64
diff -r 34ff26fb2240 tools/libxc/xc_elf.h
--- a/tools/libxc/xc_elf.h	Mon Jun 12 12:01:32 2006 +0100
+++ b/tools/libxc/xc_elf.h	Mon Jun 12 15:04:35 2006 -0500
@@ -170,13 +170,14 @@ typedef struct {
 #define EM_PARISC	15		/* HPPA */
 #define EM_SPARC32PLUS	18		/* Enhanced instruction set SPARC */
 #define EM_PPC		20		/* PowerPC */
+#define EM_PPC64	21		/* PowerPC 64-bit */
 #define EM_ARM		40		/* Advanced RISC Machines ARM */
 #define EM_ALPHA	41		/* DEC ALPHA */
 #define EM_SPARCV9	43		/* SPARC version 9 */
 #define EM_ALPHA_EXP	0x9026		/* DEC ALPHA */
+#define EM_IA_64	50		/* Intel Merced */
 #define EM_X86_64	62		/* AMD x86-64 architecture */
 #define EM_VAX		75		/* DEC VAX */
-#define EM_NUM		15		/* number of machine types */
 
 /* Version */
 #define EV_NONE		0		/* Invalid */
diff -r 34ff26fb2240 tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c	Mon Jun 12 12:01:32 2006 +0100
+++ b/tools/libxc/xc_load_elf.c	Mon Jun 12 15:04:35 2006 -0500
@@ -62,14 +62,9 @@ static int parseelfimage(const char *ima
     }
 
     if (
-#if defined(__i386__)
-        (ehdr->e_ident[EI_CLASS] != ELFCLASS32) ||
-        (ehdr->e_machine != EM_386) ||
-#elif defined(__x86_64__)
-        (ehdr->e_ident[EI_CLASS] != ELFCLASS64) ||
-        (ehdr->e_machine != EM_X86_64) ||
-#endif
-        (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) ||
+        (ehdr->e_ident[EI_CLASS] != ELFCLASS) ||
+        (ehdr->e_machine != ELFMACHINE) ||
+        (ehdr->e_ident[EI_DATA] != ELFDATA) ||
         (ehdr->e_type != ET_EXEC) )
     {
         ERROR("Kernel not a Xen-compatible Elf image.");


-- 
Hollis Blanchard
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-06-15 14:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-12 20:12 [patch] architecture-specific ELF header checking Hollis Blanchard
2006-06-13  9:15 ` Keir Fraser
2006-06-13 15:17   ` Hollis Blanchard
2006-06-13 15:42     ` Keir Fraser
2006-06-13 15:58       ` Hollis Blanchard
2006-06-14  7:39       ` Gerd Hoffmann
2006-06-15 14:50         ` Hollis Blanchard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.