[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [TOOLS][BUILDER] Extend Elf header checks for multiple architectures.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxxxx
# Node ID 1650e07c9e5261dc823e156dc0a9350e98f870bc
# Parent  ac5e98c1c46692083ca76a1cb4ad66c5bc37e9d5
[TOOLS][BUILDER] Extend Elf header checks for multiple architectures.
Based on a patch from Hollis Blanchard.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/libxc/xc_elf.h      |    3 ++-
 tools/libxc/xc_load_elf.c |   32 ++++++++++++++++++++++----------
 xen/include/xen/elf.h     |    2 +-
 3 files changed, 25 insertions(+), 12 deletions(-)

diff -r ac5e98c1c466 -r 1650e07c9e52 tools/libxc/xc_elf.h
--- a/tools/libxc/xc_elf.h      Tue Jun 13 14:08:37 2006 +0100
+++ b/tools/libxc/xc_elf.h      Tue Jun 13 14:36:04 2006 +0100
@@ -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 ac5e98c1c466 -r 1650e07c9e52 tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c Tue Jun 13 14:08:37 2006 +0100
+++ b/tools/libxc/xc_load_elf.c Tue Jun 13 14:36:04 2006 +0100
@@ -21,6 +21,24 @@ loadelfsymtab(
 loadelfsymtab(
     const char *image, int xch, uint32_t dom, xen_pfn_t *parray,
     struct domain_setup_info *dsi);
+
+/*
+ * Elf header attributes we require for each supported host platform.
+ * These are checked in parseelfimage().
+ */
+#if defined(__ia64__)
+#define ELFCLASS   ELFCLASS64
+#define ELFDATA    ELFDATA2LSB
+#define ELFMACHINE EM_IA_64
+#elif defined(__i386__)
+#define ELFCLASS   ELFCLASS32
+#define ELFDATA    ELFDATA2LSB
+#define ELFMACHINE EM_386
+#elif defined(__x86_64__)
+#define ELFCLASS   ELFCLASS64
+#define ELFDATA    ELFDATA2LSB
+#define ELFMACHINE EM_X86_64
+#endif
 
 int probe_elf(const char *image,
               unsigned long image_size,
@@ -61,16 +79,10 @@ static int parseelfimage(const char *ima
         return -EINVAL;
     }
 
-    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_type != ET_EXEC) )
+    if ( (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.");
         return -EINVAL;
diff -r ac5e98c1c466 -r 1650e07c9e52 xen/include/xen/elf.h
--- a/xen/include/xen/elf.h     Tue Jun 13 14:08:37 2006 +0100
+++ b/xen/include/xen/elf.h     Tue Jun 13 14:36:04 2006 +0100
@@ -178,9 +178,9 @@ typedef struct {
 #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 */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.