ia64/xen-unstable

changeset 4452:26c1fc477929

bitkeeper revision 1.1236.1.206 (424fd1e3OF1dIgDtN9JonRnCv2YHrQ)

Clean up symtab loading in elf loader.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@viper.(none)
date Sun Apr 03 11:22:11 2005 +0000 (2005-04-03)
parents 372c77915c16
children 7d50508a59d1
files tools/libxc/xc_linux_build.c tools/libxc/xc_vmx_build.c xen/arch/x86/domain_build.c xen/common/elf.c xen/include/xen/elf.h xen/include/xen/sched.h
line diff
     1.1 --- a/tools/libxc/xc_linux_build.c	Sun Apr 03 11:20:01 2005 +0000
     1.2 +++ b/tools/libxc/xc_linux_build.c	Sun Apr 03 11:22:11 2005 +0000
     1.3 @@ -22,8 +22,7 @@ struct domain_setup_info
     1.4      unsigned long v_kernend;
     1.5      unsigned long v_kernentry;
     1.6  
     1.7 -    unsigned int load_bsd_symtab;
     1.8 -
     1.9 +    unsigned int  load_symtab;
    1.10      unsigned long symtab_addr;
    1.11      unsigned long symtab_len;
    1.12  };
    1.13 @@ -34,7 +33,7 @@ parseelfimage(
    1.14  static int
    1.15  loadelfimage(
    1.16      char *elfbase, int xch, u32 dom, unsigned long *parray,
    1.17 -    unsigned long vstart);
    1.18 +    struct domain_setup_info *dsi);
    1.19  static int
    1.20  loadelfsymtab(
    1.21      char *elfbase, int xch, u32 dom, unsigned long *parray,
    1.22 @@ -87,9 +86,6 @@ static int setup_guest(int xc_handle,
    1.23      if ( rc != 0 )
    1.24          goto error_out;
    1.25  
    1.26 -    if (dsi.load_bsd_symtab)
    1.27 -        loadelfsymtab(image, xc_handle, dom, NULL, &dsi);
    1.28 -
    1.29      if ( (dsi.v_start & (PAGE_SIZE-1)) != 0 )
    1.30      {
    1.31          PERROR("Guest OS must load to a page boundary.\n");
    1.32 @@ -160,10 +156,7 @@ static int setup_guest(int xc_handle,
    1.33          goto error_out;
    1.34      }
    1.35  
    1.36 -    loadelfimage(image, xc_handle, dom, page_array, dsi.v_start);
    1.37 -
    1.38 -    if (dsi.load_bsd_symtab)
    1.39 -        loadelfsymtab(image, xc_handle, dom, page_array, &dsi);
    1.40 +    loadelfimage(image, xc_handle, dom, page_array, &dsi);
    1.41  
    1.42      /* Load the initial ramdisk image. */
    1.43      if ( initrd_len != 0 )
    1.44 @@ -581,13 +574,14 @@ static int parseelfimage(char *elfbase,
    1.45          dsi->v_start = strtoul(p+10, &p, 0);
    1.46  
    1.47      if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
    1.48 -        dsi->load_bsd_symtab = 1;
    1.49 +        dsi->load_symtab = 1;
    1.50  
    1.51      dsi->v_kernstart = kernstart;
    1.52      dsi->v_kernend   = kernend;
    1.53      dsi->v_kernentry = ehdr->e_entry;
    1.54 +    dsi->v_end       = dsi->v_kernend;
    1.55  
    1.56 -    dsi->v_end       = dsi->v_kernend;
    1.57 +    loadelfsymtab(elfbase, 0, 0, NULL, dsi);
    1.58  
    1.59      return 0;
    1.60  }
    1.61 @@ -595,7 +589,7 @@ static int parseelfimage(char *elfbase,
    1.62  static int
    1.63  loadelfimage(
    1.64      char *elfbase, int xch, u32 dom, unsigned long *parray,
    1.65 -    unsigned long vstart)
    1.66 +    struct domain_setup_info *dsi)
    1.67  {
    1.68      Elf_Ehdr *ehdr = (Elf_Ehdr *)elfbase;
    1.69      Elf_Phdr *phdr;
    1.70 @@ -612,7 +606,7 @@ loadelfimage(
    1.71          
    1.72          for ( done = 0; done < phdr->p_filesz; done += chunksz )
    1.73          {
    1.74 -            pa = (phdr->p_paddr + done) - vstart;
    1.75 +            pa = (phdr->p_paddr + done) - dsi->v_start;
    1.76              va = xc_map_foreign_range(
    1.77                  xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
    1.78              chunksz = phdr->p_filesz - done;
    1.79 @@ -625,7 +619,7 @@ loadelfimage(
    1.80  
    1.81          for ( ; done < phdr->p_memsz; done += chunksz )
    1.82          {
    1.83 -            pa = (phdr->p_paddr + done) - vstart;
    1.84 +            pa = (phdr->p_paddr + done) - dsi->v_start;
    1.85              va = xc_map_foreign_range(
    1.86                  xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]);
    1.87              chunksz = phdr->p_memsz - done;
    1.88 @@ -636,6 +630,8 @@ loadelfimage(
    1.89          }
    1.90      }
    1.91  
    1.92 +    loadelfsymtab(elfbase, xch, dom, parray, dsi);
    1.93 +
    1.94      return 0;
    1.95  }
    1.96  
    1.97 @@ -652,6 +648,9 @@ loadelfsymtab(
    1.98      char *p;
    1.99      int h, i;
   1.100  
   1.101 +    if ( !dsi->load_symtab )
   1.102 +        return 0;
   1.103 +
   1.104      p = malloc(sizeof(int) + sizeof(Elf_Ehdr) +
   1.105                 ehdr->e_shnum * sizeof(Elf_Shdr));
   1.106      if (p == NULL)
     2.1 --- a/tools/libxc/xc_vmx_build.c	Sun Apr 03 11:20:01 2005 +0000
     2.2 +++ b/tools/libxc/xc_vmx_build.c	Sun Apr 03 11:22:11 2005 +0000
     2.3 @@ -26,11 +26,6 @@ struct domain_setup_info
     2.4      unsigned long v_kernstart;
     2.5      unsigned long v_kernend;
     2.6      unsigned long v_kernentry;
     2.7 -
     2.8 -    unsigned int load_bsd_symtab;
     2.9 -
    2.10 -    unsigned long symtab_addr;
    2.11 -    unsigned long symtab_len;
    2.12  };
    2.13  
    2.14  static int
    2.15 @@ -40,10 +35,6 @@ static int
    2.16  loadelfimage(
    2.17      char *elfbase, int xch, u32 dom, unsigned long *parray,
    2.18      unsigned long vstart);
    2.19 -static int
    2.20 -loadelfsymtab(
    2.21 -    char *elfbase, int xch, u32 dom, unsigned long *parray,
    2.22 -    struct domain_setup_info *dsi);
    2.23  
    2.24  static void build_e820map(struct mem_map *mem_mapp, unsigned long mem_size)
    2.25  {
    2.26 @@ -193,13 +184,9 @@ static int setup_guest(int xc_handle,
    2.27  
    2.28      memset(&dsi, 0, sizeof(struct domain_setup_info));
    2.29  
    2.30 -    rc = parseelfimage(image, image_size, &dsi);
    2.31 -    if ( rc != 0 )
    2.32 +    if ( (rc = parseelfimage(image, image_size, &dsi)) != 0 )
    2.33          goto error_out;
    2.34  
    2.35 -    if (dsi.load_bsd_symtab)
    2.36 -        loadelfsymtab(image, xc_handle, dom, NULL, &dsi);
    2.37 -
    2.38      if ( (dsi.v_start & (PAGE_SIZE-1)) != 0 )
    2.39      {
    2.40          PERROR("Guest OS must load to a page boundary.\n");
    2.41 @@ -269,9 +256,6 @@ static int setup_guest(int xc_handle,
    2.42  
    2.43      loadelfimage(image, xc_handle, dom, page_array, dsi.v_start);
    2.44  
    2.45 -    if (dsi.load_bsd_symtab)
    2.46 -        loadelfsymtab(image, xc_handle, dom, page_array, &dsi);
    2.47 -
    2.48      /* Load the initial ramdisk image. */
    2.49      if ( initrd_len != 0 )
    2.50      {
    2.51 @@ -708,7 +692,6 @@ static int parseelfimage(char *elfbase,
    2.52      }
    2.53  
    2.54      dsi->v_start = 0x00000000;
    2.55 -    dsi->load_bsd_symtab = 0;
    2.56  
    2.57      dsi->v_kernstart = kernstart - LINUX_PAGE_OFFSET;
    2.58      dsi->v_kernend   = kernend - LINUX_PAGE_OFFSET;
    2.59 @@ -769,101 +752,3 @@ loadelfimage(
    2.60  
    2.61      return 0;
    2.62  }
    2.63 -
    2.64 -
    2.65 -#define ELFROUND (ELFSIZE / 8)
    2.66 -
    2.67 -static int
    2.68 -loadelfsymtab(
    2.69 -    char *elfbase, int xch, u32 dom, unsigned long *parray,
    2.70 -    struct domain_setup_info *dsi)
    2.71 -{
    2.72 -    Elf_Ehdr *ehdr = (Elf_Ehdr *)elfbase, *sym_ehdr;
    2.73 -    Elf_Shdr *shdr;
    2.74 -    unsigned long maxva, symva;
    2.75 -    char *p;
    2.76 -    int h, i;
    2.77 -
    2.78 -    p = malloc(sizeof(int) + sizeof(Elf_Ehdr) +
    2.79 -               ehdr->e_shnum * sizeof(Elf_Shdr));
    2.80 -    if (p == NULL)
    2.81 -        return 0;
    2.82 -
    2.83 -    maxva = (dsi->v_kernend + ELFROUND - 1) & ~(ELFROUND - 1);
    2.84 -    symva = maxva;
    2.85 -    maxva += sizeof(int);
    2.86 -    dsi->symtab_addr = maxva;
    2.87 -    dsi->symtab_len = 0;
    2.88 -    maxva += sizeof(Elf_Ehdr) + ehdr->e_shnum * sizeof(Elf_Shdr);
    2.89 -    maxva = (maxva + ELFROUND - 1) & ~(ELFROUND - 1);
    2.90 -
    2.91 -    shdr = (Elf_Shdr *)(p + sizeof(int) + sizeof(Elf_Ehdr));
    2.92 -    memcpy(shdr, elfbase + ehdr->e_shoff, ehdr->e_shnum * sizeof(Elf_Shdr));
    2.93 -
    2.94 -    for ( h = 0; h < ehdr->e_shnum; h++ ) 
    2.95 -    {
    2.96 -        if ( shdr[h].sh_type == SHT_STRTAB )
    2.97 -        {
    2.98 -            /* Look for a strtab @i linked to symtab @h. */
    2.99 -            for ( i = 0; i < ehdr->e_shnum; i++ )
   2.100 -                if ( (shdr[i].sh_type == SHT_SYMTAB) &&
   2.101 -                     (shdr[i].sh_link == h) )
   2.102 -                    break;
   2.103 -            /* Skip symtab @h if we found no corresponding strtab @i. */
   2.104 -            if ( i == ehdr->e_shnum )
   2.105 -            {
   2.106 -                shdr[h].sh_offset = 0;
   2.107 -                continue;
   2.108 -            }
   2.109 -        }
   2.110 -
   2.111 -        if ( (shdr[h].sh_type == SHT_STRTAB) ||
   2.112 -             (shdr[h].sh_type == SHT_SYMTAB) )
   2.113 -        {
   2.114 -            if ( parray != NULL )
   2.115 -                xc_map_memcpy(maxva, elfbase + shdr[h].sh_offset, shdr[h].sh_size,
   2.116 -                           xch, dom, parray, dsi->v_start);
   2.117 -
   2.118 -            /* Mangled to be based on ELF header location. */
   2.119 -            shdr[h].sh_offset = maxva - dsi->symtab_addr;
   2.120 -
   2.121 -            dsi->symtab_len += shdr[h].sh_size;
   2.122 -            maxva += shdr[h].sh_size;
   2.123 -            maxva = (maxva + ELFROUND - 1) & ~(ELFROUND - 1);
   2.124 -        }
   2.125 -
   2.126 -        shdr[h].sh_name = 0;  /* Name is NULL. */
   2.127 -    }
   2.128 -
   2.129 -    if ( dsi->symtab_len == 0 )
   2.130 -    {
   2.131 -        dsi->symtab_addr = 0;
   2.132 -        goto out;
   2.133 -    }
   2.134 -
   2.135 -    if ( parray != NULL )
   2.136 -    {
   2.137 -        *(int *)p = maxva - dsi->symtab_addr;
   2.138 -        sym_ehdr = (Elf_Ehdr *)(p + sizeof(int));
   2.139 -        memcpy(sym_ehdr, ehdr, sizeof(Elf_Ehdr));
   2.140 -        sym_ehdr->e_phoff = 0;
   2.141 -        sym_ehdr->e_shoff = sizeof(Elf_Ehdr);
   2.142 -        sym_ehdr->e_phentsize = 0;
   2.143 -        sym_ehdr->e_phnum = 0;
   2.144 -        sym_ehdr->e_shstrndx = SHN_UNDEF;
   2.145 -
   2.146 -        /* Copy total length, crafted ELF header and section header table */
   2.147 -        xc_map_memcpy(symva, p, sizeof(int) + sizeof(Elf_Ehdr) +
   2.148 -                   ehdr->e_shnum * sizeof(Elf_Shdr), xch, dom, parray,
   2.149 -                   dsi->v_start);
   2.150 -    }
   2.151 -
   2.152 -    dsi->symtab_len = maxva - dsi->symtab_addr;
   2.153 -    dsi->v_end = round_pgup(maxva);
   2.154 -
   2.155 - out:
   2.156 -    if ( p != NULL )
   2.157 -        free(p);
   2.158 -
   2.159 -    return 0;
   2.160 -}
     3.1 --- a/xen/arch/x86/domain_build.c	Sun Apr 03 11:20:01 2005 +0000
     3.2 +++ b/xen/arch/x86/domain_build.c	Sun Apr 03 11:22:11 2005 +0000
     3.3 @@ -111,6 +111,8 @@ int construct_dom0(struct domain *d,
     3.4          BUG();
     3.5  
     3.6      memset(&dsi, 0, sizeof(struct domain_setup_info));
     3.7 +    dsi.image_addr = (unsigned long)image_start;
     3.8 +    dsi.image_len  = image_len;
     3.9  
    3.10      printk("*** LOADING DOMAIN 0 ***\n");
    3.11  
    3.12 @@ -125,13 +127,9 @@ int construct_dom0(struct domain *d,
    3.13      alloc_start = page_to_phys(page);
    3.14      alloc_end   = alloc_start + (d->tot_pages << PAGE_SHIFT);
    3.15      
    3.16 -    rc = parseelfimage(image_start, image_len, &dsi);
    3.17 -    if ( rc != 0 )
    3.18 +    if ( (rc = parseelfimage(&dsi)) != 0 )
    3.19          return rc;
    3.20  
    3.21 -    if (dsi.load_bsd_symtab)
    3.22 -        loadelfsymtab(image_start, 0, &dsi);
    3.23 -
    3.24      /* Align load address to 4MB boundary. */
    3.25      dsi.v_start &= ~((1UL<<22)-1);
    3.26  
    3.27 @@ -424,10 +422,7 @@ int construct_dom0(struct domain *d,
    3.28      write_ptbase(ed);
    3.29  
    3.30      /* Copy the OS image and free temporary buffer. */
    3.31 -    (void)loadelfimage(image_start);
    3.32 -
    3.33 -    if (dsi.load_bsd_symtab)
    3.34 -        loadelfsymtab(image_start, 1, &dsi);
    3.35 +    (void)loadelfimage(&dsi);
    3.36  
    3.37      init_domheap_pages(
    3.38          _image_start, (_image_start+image_len+PAGE_SIZE-1) & PAGE_MASK);
     4.1 --- a/xen/common/elf.c	Sun Apr 03 11:20:01 2005 +0000
     4.2 +++ b/xen/common/elf.c	Sun Apr 03 11:22:11 2005 +0000
     4.3 @@ -17,33 +17,33 @@
     4.4  #define FORCE_XENELF_IMAGE 0
     4.5  #endif
     4.6  
     4.7 +static void loadelfsymtab(struct domain_setup_info *dsi, int doload);
     4.8  static inline int is_loadable_phdr(Elf_Phdr *phdr)
     4.9  {
    4.10      return ((phdr->p_type == PT_LOAD) &&
    4.11              ((phdr->p_flags & (PF_W|PF_X)) != 0));
    4.12  }
    4.13  
    4.14 -int parseelfimage(char *elfbase, 
    4.15 -                  unsigned long elfsize,
    4.16 -                  struct domain_setup_info *dsi)
    4.17 +int parseelfimage(struct domain_setup_info *dsi)
    4.18  {
    4.19 -    Elf_Ehdr *ehdr = (Elf_Ehdr *)elfbase;
    4.20 +    Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr;
    4.21      Elf_Phdr *phdr;
    4.22      Elf_Shdr *shdr;
    4.23      unsigned long kernstart = ~0UL, kernend=0UL;
    4.24      char *shstrtab, *guestinfo=NULL, *p;
    4.25 +    char *elfbase = (char *)dsi->image_addr;
    4.26      int h;
    4.27  
    4.28      if ( !elf_sanity_check(ehdr) )
    4.29          return -EINVAL;
    4.30  
    4.31 -    if ( (ehdr->e_phoff + (ehdr->e_phnum * ehdr->e_phentsize)) > elfsize )
    4.32 +    if ( (ehdr->e_phoff + (ehdr->e_phnum*ehdr->e_phentsize)) > dsi->image_len )
    4.33      {
    4.34          printk("ELF program headers extend beyond end of image.\n");
    4.35          return -EINVAL;
    4.36      }
    4.37  
    4.38 -    if ( (ehdr->e_shoff + (ehdr->e_shnum * ehdr->e_shentsize)) > elfsize )
    4.39 +    if ( (ehdr->e_shoff + (ehdr->e_shnum*ehdr->e_shentsize)) > dsi->image_len )
    4.40      {
    4.41          printk("ELF section headers extend beyond end of image.\n");
    4.42          return -EINVAL;
    4.43 @@ -120,22 +120,23 @@ int parseelfimage(char *elfbase,
    4.44              dsi->v_start = simple_strtoul(p+10, &p, 0);
    4.45  
    4.46          if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
    4.47 -            dsi->load_bsd_symtab = 1;
    4.48 -
    4.49 +            dsi->load_symtab = 1;
    4.50      }
    4.51  
    4.52      dsi->v_kernstart = kernstart;
    4.53      dsi->v_kernend   = kernend;
    4.54      dsi->v_kernentry = ehdr->e_entry;
    4.55 +    dsi->v_end       = dsi->v_kernend;
    4.56  
    4.57 -    dsi->v_end       = dsi->v_kernend;
    4.58 +    loadelfsymtab(dsi, 0);
    4.59  
    4.60      return 0;
    4.61  }
    4.62  
    4.63 -int loadelfimage(char *elfbase)
    4.64 +int loadelfimage(struct domain_setup_info *dsi)
    4.65  {
    4.66 -    Elf_Ehdr *ehdr = (Elf_Ehdr *)elfbase;
    4.67 +    char *elfbase = (char *)dsi->image_addr;
    4.68 +    Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr;
    4.69      Elf_Phdr *phdr;
    4.70      int h;
    4.71    
    4.72 @@ -152,19 +153,24 @@ int loadelfimage(char *elfbase)
    4.73                     phdr->p_memsz - phdr->p_filesz);
    4.74      }
    4.75  
    4.76 +    loadelfsymtab(dsi, 1);
    4.77 +
    4.78      return 0;
    4.79  }
    4.80  
    4.81  #define ELFROUND (ELFSIZE / 8)
    4.82  
    4.83 -int loadelfsymtab(char *elfbase, int doload, struct domain_setup_info *dsi)
    4.84 +static void loadelfsymtab(struct domain_setup_info *dsi, int doload)
    4.85  {
    4.86 -    Elf_Ehdr *ehdr = (Elf_Ehdr *)elfbase, *sym_ehdr;
    4.87 +    Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr, *sym_ehdr;
    4.88      Elf_Shdr *shdr;
    4.89      unsigned long maxva, symva;
    4.90 -    char *p;
    4.91 +    char *p, *elfbase = (char *)dsi->image_addr;
    4.92      int h, i;
    4.93  
    4.94 +    if ( !dsi->load_symtab )
    4.95 +        return;
    4.96 +
    4.97      maxva = (dsi->v_kernend + ELFROUND - 1) & ~(ELFROUND - 1);
    4.98      symva = maxva;
    4.99      maxva += sizeof(int);
   4.100 @@ -172,14 +178,16 @@ int loadelfsymtab(char *elfbase, int dol
   4.101      dsi->symtab_len = 0;
   4.102      maxva += sizeof(Elf_Ehdr) + ehdr->e_shnum * sizeof(Elf_Shdr);
   4.103      maxva = (maxva + ELFROUND - 1) & ~(ELFROUND - 1);
   4.104 -    if (doload) {
   4.105 -	p = (void *)symva;
   4.106 -
   4.107 -	shdr = (Elf_Shdr *)(p + sizeof(int) + sizeof(Elf_Ehdr));
   4.108 -	memcpy(shdr, elfbase + ehdr->e_shoff, ehdr->e_shnum * sizeof(Elf_Shdr));
   4.109 -    } else {
   4.110 -	shdr = (Elf_Shdr *)(elfbase + ehdr->e_shoff);
   4.111 -	p = NULL; /* XXX: gcc */
   4.112 +    if ( doload )
   4.113 +    {
   4.114 +        p = (void *)symva;
   4.115 +        shdr = (Elf_Shdr *)(p + sizeof(int) + sizeof(Elf_Ehdr));
   4.116 +        memcpy(shdr, elfbase + ehdr->e_shoff, ehdr->e_shnum*sizeof(Elf_Shdr));
   4.117 +    } 
   4.118 +    else
   4.119 +    {
   4.120 +        p = NULL;
   4.121 +        shdr = (Elf_Shdr *)(elfbase + ehdr->e_shoff);
   4.122      }
   4.123  
   4.124      for ( h = 0; h < ehdr->e_shnum; h++ ) 
   4.125 @@ -194,9 +202,9 @@ int loadelfsymtab(char *elfbase, int dol
   4.126              /* Skip symtab @h if we found no corresponding strtab @i. */
   4.127              if ( i == ehdr->e_shnum )
   4.128              {
   4.129 -		if (doload) {
   4.130 -		    shdr[h].sh_offset = 0;
   4.131 -		}
   4.132 +                if (doload) {
   4.133 +                    shdr[h].sh_offset = 0;
   4.134 +                }
   4.135                  continue;
   4.136              }
   4.137          }
   4.138 @@ -204,49 +212,43 @@ int loadelfsymtab(char *elfbase, int dol
   4.139          if ( (shdr[h].sh_type == SHT_STRTAB) ||
   4.140               (shdr[h].sh_type == SHT_SYMTAB) )
   4.141          {
   4.142 -	    if (doload) {
   4.143 -		memcpy((void *)maxva, elfbase + shdr[h].sh_offset,
   4.144 -		    shdr[h].sh_size);
   4.145 +            if (doload) {
   4.146 +                memcpy((void *)maxva, elfbase + shdr[h].sh_offset,
   4.147 +                       shdr[h].sh_size);
   4.148  
   4.149 -		/* Mangled to be based on ELF header location. */
   4.150 -		shdr[h].sh_offset = maxva - dsi->symtab_addr;
   4.151 +                /* Mangled to be based on ELF header location. */
   4.152 +                shdr[h].sh_offset = maxva - dsi->symtab_addr;
   4.153  
   4.154 -	    }
   4.155 -	    dsi->symtab_len += shdr[h].sh_size;
   4.156 -	    maxva += shdr[h].sh_size;
   4.157 -	    maxva = (maxva + ELFROUND - 1) & ~(ELFROUND - 1);
   4.158 +            }
   4.159 +            dsi->symtab_len += shdr[h].sh_size;
   4.160 +            maxva += shdr[h].sh_size;
   4.161 +            maxva = (maxva + ELFROUND - 1) & ~(ELFROUND - 1);
   4.162          }
   4.163  
   4.164 -        if (doload) {
   4.165 -	    shdr[h].sh_name = 0;  /* Name is NULL. */
   4.166 -	}
   4.167 +        if ( doload )
   4.168 +            shdr[h].sh_name = 0;  /* Name is NULL. */
   4.169      }
   4.170  
   4.171      if ( dsi->symtab_len == 0 )
   4.172      {
   4.173          dsi->symtab_addr = 0;
   4.174 -        goto out;
   4.175 +        return;
   4.176      }
   4.177  
   4.178 -    if (doload) {
   4.179 -	*(int *)p = maxva - dsi->symtab_addr;
   4.180 -	sym_ehdr = (Elf_Ehdr *)(p + sizeof(int));
   4.181 -	memcpy(sym_ehdr, ehdr, sizeof(Elf_Ehdr));
   4.182 -	sym_ehdr->e_phoff = 0;
   4.183 -	sym_ehdr->e_shoff = sizeof(Elf_Ehdr);
   4.184 -	sym_ehdr->e_phentsize = 0;
   4.185 -	sym_ehdr->e_phnum = 0;
   4.186 -	sym_ehdr->e_shstrndx = SHN_UNDEF;
   4.187 +    if ( doload )
   4.188 +    {
   4.189 +        *(int *)p = maxva - dsi->symtab_addr;
   4.190 +        sym_ehdr = (Elf_Ehdr *)(p + sizeof(int));
   4.191 +        memcpy(sym_ehdr, ehdr, sizeof(Elf_Ehdr));
   4.192 +        sym_ehdr->e_phoff = 0;
   4.193 +        sym_ehdr->e_shoff = sizeof(Elf_Ehdr);
   4.194 +        sym_ehdr->e_phentsize = 0;
   4.195 +        sym_ehdr->e_phnum = 0;
   4.196 +        sym_ehdr->e_shstrndx = SHN_UNDEF;
   4.197      }
   4.198  
   4.199 -#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK) /* XXX */
   4.200 -
   4.201      dsi->symtab_len = maxva - dsi->symtab_addr;
   4.202 -    dsi->v_end = round_pgup(maxva);
   4.203 -
   4.204 - out:
   4.205 -
   4.206 -    return 0;
   4.207 +    dsi->v_end      = maxva;
   4.208  }
   4.209  
   4.210  /*
     5.1 --- a/xen/include/xen/elf.h	Sun Apr 03 11:20:01 2005 +0000
     5.2 +++ b/xen/include/xen/elf.h	Sun Apr 03 11:22:11 2005 +0000
     5.3 @@ -526,9 +526,8 @@ typedef struct {
     5.4  #endif
     5.5  
     5.6  struct domain_setup_info;
     5.7 -extern int loadelfimage(char *);
     5.8 -extern int loadelfsymtab(char *, int, struct domain_setup_info *);
     5.9 -extern int parseelfimage(char *, unsigned long, struct domain_setup_info *);
    5.10 +extern int loadelfimage(struct domain_setup_info *);
    5.11 +extern int parseelfimage(struct domain_setup_info *);
    5.12  
    5.13  #ifdef Elf_Ehdr
    5.14  extern int elf_sanity_check(Elf_Ehdr *ehdr);
     6.1 --- a/xen/include/xen/sched.h	Sun Apr 03 11:20:01 2005 +0000
     6.2 +++ b/xen/include/xen/sched.h	Sun Apr 03 11:22:11 2005 +0000
     6.3 @@ -151,14 +151,17 @@ struct domain
     6.4  
     6.5  struct domain_setup_info
     6.6  {
     6.7 +    /* Initialised by caller. */
     6.8 +    unsigned long image_addr;
     6.9 +    unsigned long image_len;
    6.10 +    /* Initialised by loader: Public. */
    6.11      unsigned long v_start;
    6.12      unsigned long v_end;
    6.13      unsigned long v_kernstart;
    6.14      unsigned long v_kernend;
    6.15      unsigned long v_kernentry;
    6.16 -
    6.17 -    unsigned int load_bsd_symtab;
    6.18 -
    6.19 +    /* Initialised by loader: Private. */
    6.20 +    unsigned int  load_symtab;
    6.21      unsigned long symtab_addr;
    6.22      unsigned long symtab_len;
    6.23  };