|
|
|
|
|
|
|
|
|
|
xen-ia64-devel
[Xen-devel] [patch] architecture-specific ELF header checking
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@xxxxxxxxxx>
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
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- [Xen-devel] [patch] architecture-specific ELF header checking,
Hollis Blanchard <=
|
|
|
|
|