ia64/xen-unstable

changeset 10390:1650e07c9e52

[TOOLS][BUILDER] Extend Elf header checks for multiple architectures.
Based on a patch from Hollis Blanchard.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@dhcp93.uk.xensource.com
date Tue Jun 13 14:36:04 2006 +0100 (2006-06-13)
parents ac5e98c1c466
children 91d2f2258c56
files tools/libxc/xc_elf.h tools/libxc/xc_load_elf.c xen/include/xen/elf.h
line diff
     1.1 --- a/tools/libxc/xc_elf.h	Tue Jun 13 14:08:37 2006 +0100
     1.2 +++ b/tools/libxc/xc_elf.h	Tue Jun 13 14:36:04 2006 +0100
     1.3 @@ -170,13 +170,14 @@ typedef struct {
     1.4  #define EM_PARISC	15		/* HPPA */
     1.5  #define EM_SPARC32PLUS	18		/* Enhanced instruction set SPARC */
     1.6  #define EM_PPC		20		/* PowerPC */
     1.7 +#define EM_PPC64	21		/* PowerPC 64-bit */
     1.8  #define EM_ARM		40		/* Advanced RISC Machines ARM */
     1.9  #define EM_ALPHA	41		/* DEC ALPHA */
    1.10  #define EM_SPARCV9	43		/* SPARC version 9 */
    1.11  #define EM_ALPHA_EXP	0x9026		/* DEC ALPHA */
    1.12 +#define EM_IA_64	50		/* Intel Merced */
    1.13  #define EM_X86_64	62		/* AMD x86-64 architecture */
    1.14  #define EM_VAX		75		/* DEC VAX */
    1.15 -#define EM_NUM		15		/* number of machine types */
    1.16  
    1.17  /* Version */
    1.18  #define EV_NONE		0		/* Invalid */
     2.1 --- a/tools/libxc/xc_load_elf.c	Tue Jun 13 14:08:37 2006 +0100
     2.2 +++ b/tools/libxc/xc_load_elf.c	Tue Jun 13 14:36:04 2006 +0100
     2.3 @@ -22,6 +22,24 @@ loadelfsymtab(
     2.4      const char *image, int xch, uint32_t dom, xen_pfn_t *parray,
     2.5      struct domain_setup_info *dsi);
     2.6  
     2.7 +/*
     2.8 + * Elf header attributes we require for each supported host platform.
     2.9 + * These are checked in parseelfimage().
    2.10 + */
    2.11 +#if defined(__ia64__)
    2.12 +#define ELFCLASS   ELFCLASS64
    2.13 +#define ELFDATA    ELFDATA2LSB
    2.14 +#define ELFMACHINE EM_IA_64
    2.15 +#elif defined(__i386__)
    2.16 +#define ELFCLASS   ELFCLASS32
    2.17 +#define ELFDATA    ELFDATA2LSB
    2.18 +#define ELFMACHINE EM_386
    2.19 +#elif defined(__x86_64__)
    2.20 +#define ELFCLASS   ELFCLASS64
    2.21 +#define ELFDATA    ELFDATA2LSB
    2.22 +#define ELFMACHINE EM_X86_64
    2.23 +#endif
    2.24 +
    2.25  int probe_elf(const char *image,
    2.26                unsigned long image_size,
    2.27                struct load_funcs *load_funcs)
    2.28 @@ -61,16 +79,10 @@ static int parseelfimage(const char *ima
    2.29          return -EINVAL;
    2.30      }
    2.31  
    2.32 -    if (
    2.33 -#if defined(__i386__)
    2.34 -        (ehdr->e_ident[EI_CLASS] != ELFCLASS32) ||
    2.35 -        (ehdr->e_machine != EM_386) ||
    2.36 -#elif defined(__x86_64__)
    2.37 -        (ehdr->e_ident[EI_CLASS] != ELFCLASS64) ||
    2.38 -        (ehdr->e_machine != EM_X86_64) ||
    2.39 -#endif
    2.40 -        (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) ||
    2.41 -        (ehdr->e_type != ET_EXEC) )
    2.42 +    if ( (ehdr->e_ident[EI_CLASS] != ELFCLASS) ||
    2.43 +         (ehdr->e_machine != ELFMACHINE) ||
    2.44 +         (ehdr->e_ident[EI_DATA] != ELFDATA) ||
    2.45 +         (ehdr->e_type != ET_EXEC) )
    2.46      {
    2.47          ERROR("Kernel not a Xen-compatible Elf image.");
    2.48          return -EINVAL;
     3.1 --- a/xen/include/xen/elf.h	Tue Jun 13 14:08:37 2006 +0100
     3.2 +++ b/xen/include/xen/elf.h	Tue Jun 13 14:36:04 2006 +0100
     3.3 @@ -178,9 +178,9 @@ typedef struct {
     3.4  #define EM_ALPHA	41		/* DEC ALPHA */
     3.5  #define EM_SPARCV9	43		/* SPARC version 9 */
     3.6  #define EM_ALPHA_EXP	0x9026		/* DEC ALPHA */
     3.7 +#define EM_IA_64	50		/* Intel Merced */
     3.8  #define EM_X86_64	62		/* AMD x86-64 architecture */
     3.9  #define EM_VAX		75		/* DEC VAX */
    3.10 -#define EM_NUM		15		/* number of machine types */
    3.11  
    3.12  /* Version */
    3.13  #define EV_NONE		0		/* Invalid */