ia64/xen-unstable

changeset 11283:cc006f78cbe2

[TOOLS] Cleanups to domU ELF loader.

- Remove debugging statements.
- Cope better with archtectures where neither ELF notes or __xen_guest
are needed or required.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Wed Aug 23 18:35:21 2006 +0100 (2006-08-23)
parents d389123fad85
children 2eb8efcc70d1
files tools/libxc/xc_load_bin.c tools/libxc/xc_load_elf.c tools/libxc/xg_private.h
line diff
     1.1 --- a/tools/libxc/xc_load_bin.c	Wed Aug 23 17:25:11 2006 +0100
     1.2 +++ b/tools/libxc/xc_load_bin.c	Wed Aug 23 18:35:21 2006 +0100
     1.3 @@ -227,7 +227,7 @@ static int parsebinimage(const char *ima
     1.4      dsi->v_kernstart = dsi->v_start;
     1.5      dsi->v_kernend = dsi->v_end;
     1.6      dsi->v_kernentry = image_info->entry_addr;
     1.7 -    dsi->__xen_guest_string = "";
     1.8 +    dsi->__xen_guest_string = NULL;
     1.9  
    1.10      return 0;
    1.11  }
     2.1 --- a/tools/libxc/xc_load_elf.c	Wed Aug 23 17:25:11 2006 +0100
     2.2 +++ b/tools/libxc/xc_load_elf.c	Wed Aug 23 18:35:21 2006 +0100
     2.3 @@ -109,15 +109,13 @@ static const char *xen_guest_string(stru
     2.4  {
     2.5      const char *p = xen_guest_lookup(dsi, type);
     2.6  
     2.7 -    DPRINTF("found __xen_guest entry for type %#x = \"%s\"\n",
     2.8 -            type, p);
     2.9 -
    2.10      /*
    2.11       * We special case this since the __xen_guest_section treats the
    2.12       * mere precense of the BSD_SYMTAB string as true or false.
    2.13       */
    2.14      if ( type == XEN_ELFNOTE_BSD_SYMTAB )
    2.15          return p ? "yes" : "no";
    2.16 +
    2.17      return p;
    2.18  }
    2.19  
    2.20 @@ -141,9 +139,6 @@ static unsigned long long xen_guest_nume
    2.21      if (type == XEN_ELFNOTE_HYPERCALL_PAGE)
    2.22          value = dsi->v_start + (value<<PAGE_SHIFT);
    2.23  
    2.24 -    DPRINTF("found __xen_guest entry for type %#x = %#llx\n",
    2.25 -            type, value);
    2.26 -
    2.27      *defined = 1;
    2.28      return value;
    2.29  }
    2.30 @@ -177,6 +172,9 @@ static Elf_Note *xen_elfnote_lookup(stru
    2.31  {
    2.32      Elf_Note *note;
    2.33  
    2.34 +    if ( !dsi->__elfnote_section )
    2.35 +        return NULL;
    2.36 +
    2.37      for ( note = (Elf_Note *)dsi->__elfnote_section;
    2.38            note < (Elf_Note *)dsi->__elfnote_section_end;
    2.39            note = ELFNOTE_NEXT(note) )
    2.40 @@ -188,7 +186,6 @@ static Elf_Note *xen_elfnote_lookup(stru
    2.41              return note;
    2.42      }
    2.43  
    2.44 -    DPRINTF("unable to find Xen ELF note with type %#x\n", type);
    2.45      return NULL;
    2.46  }
    2.47  
    2.48 @@ -203,9 +200,6 @@ const char *xen_elfnote_string(struct do
    2.49      if ( note == NULL )
    2.50          return NULL;
    2.51  
    2.52 -    DPRINTF("found Xen ELF note type %#x = \"%s\"\n",
    2.53 -            type, (char *)ELFNOTE_DESC(note));
    2.54 -
    2.55      return (const char *)ELFNOTE_DESC(note);
    2.56  }
    2.57  
    2.58 @@ -297,7 +291,6 @@ static int parseelfimage(const char *ima
    2.59          shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
    2.60          if ( !is_xen_elfnote_section(image, shdr) )
    2.61              continue;
    2.62 -        DPRINTF("found note section containing Xen entries\n");
    2.63          dsi->__elfnote_section = (void *)image + shdr->sh_offset;
    2.64          dsi->__elfnote_section_end =
    2.65              (void *)image + shdr->sh_offset + shdr->sh_size;
    2.66 @@ -312,7 +305,6 @@ static int parseelfimage(const char *ima
    2.67              shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
    2.68              if ( is_xen_guest_section(shdr, shstrtab) )
    2.69              {
    2.70 -                DPRINTF("found a legacy __xen_guest section\n");
    2.71                  dsi->__xen_guest_string = (char *)image + shdr->sh_offset;
    2.72                  break;
    2.73              }
    2.74 @@ -343,16 +335,18 @@ static int parseelfimage(const char *ima
    2.75      }
    2.76      else
    2.77      {
    2.78 -#ifdef __ia64__
    2.79 -        dsi->__elfnote_section = NULL;
    2.80 -        dsi->__xen_guest_string = "";
    2.81 -#else
    2.82 +#if defined(__x86_64__) || defined(__i386__)
    2.83          ERROR("Not a Xen-ELF image: "
    2.84                "No ELF notes or '__xen_guest' section found.");
    2.85          return -EINVAL;
    2.86  #endif
    2.87      }
    2.88  
    2.89 +    /*
    2.90 +     * If we have ELF notes then PAE=yes implies that we must support
    2.91 +     * the extended cr3 syntax. Otherwise we need to find the
    2.92 +     * [extended-cr3] syntax in the __xen_guest string.
    2.93 +     */
    2.94      dsi->pae_kernel = PAEKERN_no;
    2.95      if ( dsi->__elfnote_section )
    2.96      {
     3.1 --- a/tools/libxc/xg_private.h	Wed Aug 23 17:25:11 2006 +0100
     3.2 +++ b/tools/libxc/xg_private.h	Wed Aug 23 18:35:21 2006 +0100
     3.3 @@ -159,7 +159,7 @@ struct domain_setup_info
     3.4       * pickup the correct one and retain backwards compatibility.
     3.5       */
     3.6      void *__elfnote_section, *__elfnote_section_end;
     3.7 -    char *__xen_guest_string;
     3.8 +    const char *__xen_guest_string;
     3.9  };
    3.10  
    3.11  typedef int (*parseimagefunc)(const char *image, unsigned long image_size,