ia64/xen-unstable

changeset 15706:9f939ff527ee

Merge with ppc/xen-unstable.hg
author kfraser@localhost.localdomain
date Thu Aug 02 16:03:35 2007 +0100 (2007-08-02)
parents 04fb85a46dc5 7ee30cf72fd3
children a451b0ab40d9
files
line diff
     1.1 --- a/extras/mini-os/Makefile	Thu Aug 02 09:54:18 2007 -0500
     1.2 +++ b/extras/mini-os/Makefile	Thu Aug 02 16:03:35 2007 +0100
     1.3 @@ -123,3 +123,7 @@ cscope:
     1.4  tags:
     1.5  	$(all_sources) | xargs ctags
     1.6  
     1.7 +.PHONY: TAGS
     1.8 +TAGS:
     1.9 +	$(all_sources) | xargs etags
    1.10 +
     2.1 --- a/extras/mini-os/arch/x86/Makefile	Thu Aug 02 09:54:18 2007 -0500
     2.2 +++ b/extras/mini-os/arch/x86/Makefile	Thu Aug 02 16:03:35 2007 +0100
     2.3 @@ -3,6 +3,9 @@
     2.4  # It's is used for x86_32, x86_32y and x86_64
     2.5  #
     2.6  
     2.7 +XEN_ROOT = ../../../..
     2.8 +include $(XEN_ROOT)/Config.mk
     2.9 +
    2.10  # include arch.mk has to be before mini-os.mk!
    2.11  
    2.12  include arch.mk
     3.1 --- a/extras/mini-os/arch/x86/mm.c	Thu Aug 02 09:54:18 2007 -0500
     3.2 +++ b/extras/mini-os/arch/x86/mm.c	Thu Aug 02 16:03:35 2007 +0100
     3.3 @@ -405,9 +405,9 @@ void *map_frames(unsigned long *f, unsig
     3.4  
     3.5  void arch_init_p2m(unsigned long max_pfn)
     3.6  {
     3.7 -#define L1_P2M_SHIFT    10
     3.8 -#define L2_P2M_SHIFT    20    
     3.9 -#define L3_P2M_SHIFT    30    
    3.10 +#define L1_P2M_SHIFT    9
    3.11 +#define L2_P2M_SHIFT    18    
    3.12 +#define L3_P2M_SHIFT    27    
    3.13  #define L1_P2M_ENTRIES  (1 << L1_P2M_SHIFT)    
    3.14  #define L2_P2M_ENTRIES  (1 << (L2_P2M_SHIFT - L1_P2M_SHIFT))    
    3.15  #define L3_P2M_ENTRIES  (1 << (L3_P2M_SHIFT - L2_P2M_SHIFT))    
     4.1 --- a/tools/xenstore/utils.c	Thu Aug 02 09:54:18 2007 -0500
     4.2 +++ b/tools/xenstore/utils.c	Thu Aug 02 16:03:35 2007 +0100
     4.3 @@ -10,19 +10,18 @@
     4.4  #include <signal.h>
     4.5  #include "utils.h"
     4.6  
     4.7 -void xprintf(const char *fmt, ...)
     4.8 +static void default_xprintf(const char *fmt, ...)
     4.9  {
    4.10  	va_list args;
    4.11  
    4.12 -	if (!stderr)
    4.13 -		return; /* could trace()? */
    4.14 -
    4.15  	va_start(args, fmt);
    4.16  	vfprintf(stderr, fmt, args);
    4.17  	va_end(args);
    4.18  	fflush(stderr);
    4.19  }
    4.20  
    4.21 +void (*xprintf)(const char *fmt, ...) = default_xprintf;
    4.22 +
    4.23  void barf(const char *fmt, ...)
    4.24  {
    4.25  	char *str;
     5.1 --- a/tools/xenstore/utils.h	Thu Aug 02 09:54:18 2007 -0500
     5.2 +++ b/tools/xenstore/utils.h	Thu Aug 02 16:03:35 2007 +0100
     5.3 @@ -24,7 +24,7 @@ static inline bool strends(const char *a
     5.4  void barf(const char *fmt, ...) __attribute__((noreturn));
     5.5  void barf_perror(const char *fmt, ...) __attribute__((noreturn));
     5.6  
     5.7 -void xprintf(const char *fmt, ...);
     5.8 +void (*xprintf)(const char *fmt, ...);
     5.9  
    5.10  #define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)
    5.11  
     6.1 --- a/tools/xenstore/xenstored_core.c	Thu Aug 02 09:54:18 2007 -0500
     6.2 +++ b/tools/xenstore/xenstored_core.c	Thu Aug 02 16:03:35 2007 +0100
     6.3 @@ -1880,14 +1880,14 @@ int main(int argc, char *argv[])
     6.4  
     6.5  	/* close stdin/stdout now we're ready to accept connections */
     6.6  	if (dofork) {
     6.7 -		close(STDIN_FILENO);
     6.8 -		close(STDOUT_FILENO);
     6.9 -		close(STDERR_FILENO);
    6.10 -
    6.11 -		/* Get ourselves a nice xenstored crash if these are used. */
    6.12 -		stdin = NULL;
    6.13 -		stdout = NULL;
    6.14 -		stderr = NULL;
    6.15 +		int devnull = open("/dev/null", O_RDWR);
    6.16 +		if (devnull == -1)
    6.17 +			barf_perror("Could not open /dev/null\n");
    6.18 +		close(STDIN_FILENO);  dup2(STDIN_FILENO, devnull);
    6.19 +		close(STDOUT_FILENO); dup2(STDOUT_FILENO, devnull);
    6.20 +		close(STDERR_FILENO); dup2(STDERR_FILENO, devnull);
    6.21 +		close(devnull);
    6.22 +		xprintf = trace;
    6.23  	}
    6.24  
    6.25  	signal(SIGHUP, trigger_reopen_log);
     7.1 --- a/xen/arch/x86/domain_build.c	Thu Aug 02 09:54:18 2007 -0500
     7.2 +++ b/xen/arch/x86/domain_build.c	Thu Aug 02 16:03:35 2007 +0100
     7.3 @@ -316,9 +316,9 @@ int __init construct_dom0(
     7.4             parms.pae       ? ", PAE"  : "",
     7.5             elf_msb(&elf)   ? "msb"    : "lsb",
     7.6             elf.pstart, elf.pend);
     7.7 -    if ( parms.bsd_symtab )
     7.8 +    if ( elf.bsd_symtab_pstart )
     7.9          printk(" Dom0 symbol map 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
    7.10 -               elf.sstart, elf.send);
    7.11 +               elf.bsd_symtab_pstart, elf.bsd_symtab_pend);
    7.12  
    7.13      if ( !compatible )
    7.14      {
    7.15 @@ -388,7 +388,7 @@ int __init construct_dom0(
    7.16      v_start          = parms.virt_base;
    7.17      vkern_start      = parms.virt_kstart;
    7.18      vkern_end        = parms.virt_kend;
    7.19 -    vinitrd_start    = round_pgup(parms.virt_end);
    7.20 +    vinitrd_start    = round_pgup(vkern_end);
    7.21      vinitrd_end      = vinitrd_start + initrd_len;
    7.22      vphysmap_start   = round_pgup(vinitrd_end);
    7.23      vphysmap_end     = vphysmap_start + (nr_pages * (!is_pv_32on64_domain(d) ?
    7.24 @@ -798,7 +798,7 @@ int __init construct_dom0(
    7.25  
    7.26      /* Copy the OS image and free temporary buffer. */
    7.27      elf.dest = (void*)vkern_start;
    7.28 -    elf_xen_dom_load_binary(&elf, &parms);
    7.29 +    elf_load_binary(&elf);
    7.30  
    7.31      if ( UNSET_ADDR != parms.virt_hypercall )
    7.32      {
     8.1 --- a/xen/common/libelf/libelf-dominfo.c	Thu Aug 02 09:54:18 2007 -0500
     8.2 +++ b/xen/common/libelf/libelf-dominfo.c	Thu Aug 02 16:03:35 2007 +0100
     8.3 @@ -333,99 +333,6 @@ static int elf_xen_note_check(struct elf
     8.4      return 0;
     8.5  }
     8.6  
     8.7 -
     8.8 -static void elf_xen_loadsymtab(struct elf_binary *elf,
     8.9 -                               struct elf_dom_parms *parms)
    8.10 -{
    8.11 -    unsigned long maxva, len;
    8.12 -
    8.13 -    if ( !parms->bsd_symtab )
    8.14 -        return;
    8.15 -
    8.16 -    /* Calculate the required additional kernel space for the elf image */
    8.17 -
    8.18 -    /* The absolute base address of the elf image */
    8.19 -    maxva = elf_round_up(elf, parms->virt_kend);
    8.20 -    maxva += sizeof(long); /* Space to store the size of the elf image */
    8.21 -    /* Space for the elf and elf section headers */
    8.22 -    maxva += (elf_uval(elf, elf->ehdr, e_ehsize) +
    8.23 -              elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize));
    8.24 -    maxva = elf_round_up(elf, maxva);
    8.25 -
    8.26 -    /* Space for the symbol and string tabs */
    8.27 -    len = (unsigned long)elf->send - (unsigned long)elf->sstart;
    8.28 -    maxva = elf_round_up(elf, maxva + len);
    8.29 -
    8.30 -    /* The address the kernel must expanded to */
    8.31 -    parms->virt_end = maxva;
    8.32 -}
    8.33 -
    8.34 -int elf_xen_dom_load_binary(struct elf_binary *elf,
    8.35 -                            struct elf_dom_parms *parms)
    8.36 -{
    8.37 -    elf_ehdr *sym_ehdr;
    8.38 -    unsigned long shdr, symtab_addr;
    8.39 -    unsigned long maxva, symbase;
    8.40 -    uint8_t i;
    8.41 -    char *p;
    8.42 -
    8.43 -    elf_load_binary(elf);
    8.44 -
    8.45 -    if ( !parms->bsd_symtab )
    8.46 -        return 0;
    8.47 -
    8.48 -#define elf_hdr_elm(_elf, _hdr, _elm, _val)     \
    8.49 -do {                                            \
    8.50 -    if ( elf_64bit(_elf) )                      \
    8.51 -        (_hdr)->e64._elm = _val;                \
    8.52 -    else                                        \
    8.53 -        (_hdr)->e32._elm = _val;                \
    8.54 -} while ( 0 )
    8.55 -
    8.56 -    /* ehdr right after the kernel image (4 byte aligned) */
    8.57 -    symbase = elf_round_up(elf, parms->virt_kend);
    8.58 -    symtab_addr = maxva = symbase + sizeof(long);
    8.59 -
    8.60 -    /* Set up Elf header. */
    8.61 -    sym_ehdr = (elf_ehdr *)symtab_addr;
    8.62 -    maxva = elf_copy_ehdr(elf, sym_ehdr);
    8.63 -
    8.64 -    elf_hdr_elm(elf, sym_ehdr, e_phoff, 0);
    8.65 -    elf_hdr_elm(elf, sym_ehdr, e_shoff, elf_uval(elf, elf->ehdr, e_ehsize));
    8.66 -    elf_hdr_elm(elf, sym_ehdr, e_phentsize, 0);
    8.67 -    elf_hdr_elm(elf, sym_ehdr, e_phnum, 0);
    8.68 -
    8.69 -    /* Copy Elf section headers. */
    8.70 -    shdr = maxva;
    8.71 -    maxva = elf_copy_shdr(elf, (elf_shdr *)shdr);
    8.72 -
    8.73 -    for ( i = 0; i < elf_shdr_count(elf); i++ )
    8.74 -    {
    8.75 -        uint8_t type;
    8.76 -        unsigned long tmp;
    8.77 -        type = elf_uval(elf, (elf_shdr *)shdr, sh_type);
    8.78 -        if ( (type == SHT_STRTAB) || (type == SHT_SYMTAB) )
    8.79 -        {
    8.80 -             elf_msg(elf, "%s: shdr %i at 0x%p -> 0x%p\n", __func__, i,
    8.81 -                     elf_section_start(elf, (elf_shdr *)shdr), (void *)maxva);
    8.82 -             tmp = elf_copy_section(elf, (elf_shdr *)shdr, (void *)maxva);
    8.83 -             /* Mangled to be based on ELF header location. */
    8.84 -             elf_hdr_elm(elf, (elf_shdr *)shdr, sh_offset,
    8.85 -                         maxva - symtab_addr);
    8.86 -             maxva = tmp;
    8.87 -        }
    8.88 -        shdr += elf_uval(elf, elf->ehdr, e_shentsize);
    8.89 -    }
    8.90 -
    8.91 -    /* Write down the actual sym size. */
    8.92 -    p = (char *)symbase;
    8.93 -    *(long *)p = maxva - symtab_addr; /* sym size */
    8.94 -
    8.95 -#undef elf_ehdr_elm
    8.96 -
    8.97 -    return 0;
    8.98 -}
    8.99 -
   8.100  static int elf_xen_addr_calc_check(struct elf_binary *elf,
   8.101                                     struct elf_dom_parms *parms)
   8.102  {
   8.103 @@ -467,13 +374,16 @@ static int elf_xen_addr_calc_check(struc
   8.104      parms->virt_offset = parms->virt_base - parms->elf_paddr_offset;
   8.105      parms->virt_kstart = elf->pstart + parms->virt_offset;
   8.106      parms->virt_kend   = elf->pend   + parms->virt_offset;
   8.107 -    parms->virt_end    = parms->virt_kend;
   8.108  
   8.109      if ( parms->virt_entry == UNSET_ADDR )
   8.110          parms->virt_entry = elf_uval(elf, elf->ehdr, e_entry);
   8.111  
   8.112      if ( parms->bsd_symtab )
   8.113 -        elf_xen_loadsymtab(elf, parms);
   8.114 +    {
   8.115 +        elf_parse_bsdsyms(elf, parms->virt_kend);
   8.116 +        if ( elf->bsd_symtab_pend )
   8.117 +            parms->virt_kend = elf->bsd_symtab_pend + parms->virt_offset;
   8.118 +    }
   8.119  
   8.120      elf_msg(elf, "%s: addresses:\n", __FUNCTION__);
   8.121      elf_msg(elf, "    virt_base        = 0x%" PRIx64 "\n", parms->virt_base);
   8.122 @@ -481,14 +391,12 @@ static int elf_xen_addr_calc_check(struc
   8.123      elf_msg(elf, "    virt_offset      = 0x%" PRIx64 "\n", parms->virt_offset);
   8.124      elf_msg(elf, "    virt_kstart      = 0x%" PRIx64 "\n", parms->virt_kstart);
   8.125      elf_msg(elf, "    virt_kend        = 0x%" PRIx64 "\n", parms->virt_kend);
   8.126 -    elf_msg(elf, "    virt_end         = 0x%" PRIx64 "\n", parms->virt_end);
   8.127      elf_msg(elf, "    virt_entry       = 0x%" PRIx64 "\n", parms->virt_entry);
   8.128  
   8.129      if ( (parms->virt_kstart > parms->virt_kend) ||
   8.130           (parms->virt_entry < parms->virt_kstart) ||
   8.131           (parms->virt_entry > parms->virt_kend) ||
   8.132 -         (parms->virt_base > parms->virt_kstart) ||
   8.133 -         (parms->virt_kend > parms->virt_end) )
   8.134 +         (parms->virt_base > parms->virt_kstart) )
   8.135      {
   8.136          elf_err(elf, "%s: ERROR: ELF start or entries are out of bounds.\n",
   8.137                  __FUNCTION__);
     9.1 --- a/xen/common/libelf/libelf-loader.c	Thu Aug 02 09:54:18 2007 -0500
     9.2 +++ b/xen/common/libelf/libelf-loader.c	Thu Aug 02 16:03:35 2007 +0100
     9.3 @@ -10,8 +10,6 @@ int elf_init(struct elf_binary *elf, con
     9.4  {
     9.5      const elf_shdr *shdr;
     9.6      uint64_t i, count, section, offset;
     9.7 -    uint64_t low = -1;
     9.8 -    uint64_t high = 0;
     9.9  
    9.10      if ( !elf_is_elfbinary(image) )
    9.11      {
    9.12 @@ -22,14 +20,10 @@ int elf_init(struct elf_binary *elf, con
    9.13      memset(elf, 0, sizeof(*elf));
    9.14      elf->image = image;
    9.15      elf->size = size;
    9.16 -    elf->ehdr = (elf_ehdr *) image;
    9.17 +    elf->ehdr = (elf_ehdr *)image;
    9.18      elf->class = elf->ehdr->e32.e_ident[EI_CLASS];
    9.19      elf->data = elf->ehdr->e32.e_ident[EI_DATA];
    9.20  
    9.21 -#ifdef VERBOSE
    9.22 -    elf_set_verbose(elf);
    9.23 -#endif
    9.24 -
    9.25      /* Sanity check phdr. */
    9.26      offset = elf_uval(elf, elf->ehdr, e_phoff) +
    9.27          elf_uval(elf, elf->ehdr, e_phentsize) * elf_phdr_count(elf);
    9.28 @@ -60,43 +54,18 @@ int elf_init(struct elf_binary *elf, con
    9.29      count = elf_shdr_count(elf);
    9.30      for ( i = 0; i < count; i++ )
    9.31      {
    9.32 -        const char *sh_symend, *sh_strend;
    9.33 -
    9.34          shdr = elf_shdr_by_index(elf, i);
    9.35          if ( elf_uval(elf, shdr, sh_type) != SHT_SYMTAB )
    9.36              continue;
    9.37          elf->sym_tab = shdr;
    9.38 -        sh_symend = (const char *)elf_section_end(elf, shdr);
    9.39          shdr = elf_shdr_by_index(elf, elf_uval(elf, shdr, sh_link));
    9.40          if ( shdr == NULL )
    9.41          {
    9.42              elf->sym_tab = NULL;
    9.43 -            sh_symend = 0;
    9.44              continue;
    9.45          }
    9.46          elf->sym_strtab = elf_section_start(elf, shdr);
    9.47 -        sh_strend = (const char *)elf_section_end(elf, shdr);
    9.48 -
    9.49 -        if ( low > (unsigned long)elf->sym_tab )
    9.50 -            low = (unsigned long)elf->sym_tab;
    9.51 -        if ( low > (unsigned long)shdr )
    9.52 -            low = (unsigned long)shdr;
    9.53 -
    9.54 -        if ( high < ((unsigned long)sh_symend) )
    9.55 -            high = (unsigned long)sh_symend;
    9.56 -        if ( high < ((unsigned long)sh_strend) )
    9.57 -            high = (unsigned long)sh_strend;
    9.58 -
    9.59 -        elf_msg(elf, "%s: shdr: sym_tab=%p size=0x%" PRIx64 "\n",
    9.60 -                __FUNCTION__, elf->sym_tab,
    9.61 -                elf_uval(elf, elf->sym_tab, sh_size));
    9.62 -        elf_msg(elf, "%s: shdr: str_tab=%p size=0x%" PRIx64 "\n",
    9.63 -                __FUNCTION__, elf->sym_strtab, elf_uval(elf, shdr, sh_size));
    9.64 -
    9.65 -        elf->sstart = low;
    9.66 -        elf->send = high;
    9.67 -        elf_msg(elf, "%s: symbol map: 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
    9.68 -                __FUNCTION__, elf->sstart, elf->send);
    9.69 +        break;
    9.70      }
    9.71  
    9.72      return 0;
    9.73 @@ -115,6 +84,101 @@ void elf_set_verbose(struct elf_binary *
    9.74  }
    9.75  #endif
    9.76  
    9.77 +/* Calculate the required additional kernel space for the elf image */
    9.78 +void elf_parse_bsdsyms(struct elf_binary *elf, uint64_t pstart)
    9.79 +{
    9.80 +    uint64_t sz;
    9.81 +    const elf_shdr *shdr;
    9.82 +    int i, type;
    9.83 +
    9.84 +    if ( !elf->sym_tab )
    9.85 +        return;
    9.86 +
    9.87 +    pstart = elf_round_up(elf, pstart);
    9.88 +
    9.89 +    /* Space to store the size of the elf image */
    9.90 +    sz = sizeof(uint32_t);
    9.91 +
    9.92 +    /* Space for the elf and elf section headers */
    9.93 +    sz += (elf_uval(elf, elf->ehdr, e_ehsize) +
    9.94 +           elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize));
    9.95 +    sz = elf_round_up(elf, sz);
    9.96 +
    9.97 +    /* Space for the symbol and string tables. */
    9.98 +    for ( i = 0; i < elf_shdr_count(elf); i++ )
    9.99 +    {
   9.100 +        shdr = elf_shdr_by_index(elf, i);
   9.101 +        type = elf_uval(elf, (elf_shdr *)shdr, sh_type);
   9.102 +        if ( (type == SHT_STRTAB) || (type == SHT_SYMTAB) )
   9.103 +            sz = elf_round_up(elf, sz + elf_uval(elf, shdr, sh_size));
   9.104 +    }
   9.105 +
   9.106 +    elf->bsd_symtab_pstart = pstart;
   9.107 +    elf->bsd_symtab_pend   = pstart + sz;
   9.108 +}
   9.109 +
   9.110 +static void elf_load_bsdsyms(struct elf_binary *elf)
   9.111 +{
   9.112 +    elf_ehdr *sym_ehdr;
   9.113 +    unsigned long sz;
   9.114 +    char *maxva, *symbase, *symtab_addr;
   9.115 +    elf_shdr *shdr;
   9.116 +    int i, type;
   9.117 +
   9.118 +    if ( !elf->bsd_symtab_pstart )
   9.119 +        return;
   9.120 +
   9.121 +#define elf_hdr_elm(_elf, _hdr, _elm, _val)     \
   9.122 +do {                                            \
   9.123 +    if ( elf_64bit(_elf) )                      \
   9.124 +        (_hdr)->e64._elm = _val;                \
   9.125 +    else                                        \
   9.126 +        (_hdr)->e32._elm = _val;                \
   9.127 +} while ( 0 )
   9.128 +
   9.129 +    symbase = elf_get_ptr(elf, elf->bsd_symtab_pstart);
   9.130 +    symtab_addr = maxva = symbase + sizeof(uint32_t);
   9.131 +
   9.132 +    /* Set up Elf header. */
   9.133 +    sym_ehdr = (elf_ehdr *)symtab_addr;
   9.134 +    sz = elf_uval(elf, elf->ehdr, e_ehsize);
   9.135 +    memcpy(sym_ehdr, elf->ehdr, sz);
   9.136 +    maxva += sz; /* no round up */
   9.137 +
   9.138 +    elf_hdr_elm(elf, sym_ehdr, e_phoff, 0);
   9.139 +    elf_hdr_elm(elf, sym_ehdr, e_shoff, elf_uval(elf, elf->ehdr, e_ehsize));
   9.140 +    elf_hdr_elm(elf, sym_ehdr, e_phentsize, 0);
   9.141 +    elf_hdr_elm(elf, sym_ehdr, e_phnum, 0);
   9.142 +
   9.143 +    /* Copy Elf section headers. */
   9.144 +    shdr = (elf_shdr *)maxva;
   9.145 +    sz = elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize);
   9.146 +    memcpy(shdr, elf->image + elf_uval(elf, elf->ehdr, e_shoff), sz);
   9.147 +    maxva = (char *)(long)elf_round_up(elf, (long)maxva + sz);
   9.148 +
   9.149 +    for ( i = 0; i < elf_shdr_count(elf); i++ )
   9.150 +    {
   9.151 +        type = elf_uval(elf, shdr, sh_type);
   9.152 +        if ( (type == SHT_STRTAB) || (type == SHT_SYMTAB) )
   9.153 +        {
   9.154 +             elf_msg(elf, "%s: shdr %i at 0x%p -> 0x%p\n", __func__, i,
   9.155 +                     elf_section_start(elf, shdr), maxva);
   9.156 +             sz = elf_uval(elf, shdr, sh_size);
   9.157 +             memcpy(maxva, elf_section_start(elf, shdr), sz);
   9.158 +             /* Mangled to be based on ELF header location. */
   9.159 +             elf_hdr_elm(elf, shdr, sh_offset, maxva - symtab_addr);
   9.160 +             maxva = (char *)(long)elf_round_up(elf, (long)maxva + sz);
   9.161 +        }
   9.162 +        shdr = (elf_shdr *)((long)shdr +
   9.163 +                            (long)elf_uval(elf, elf->ehdr, e_shentsize));
   9.164 +    }
   9.165 +
   9.166 +    /* Write down the actual sym size. */
   9.167 +    *(uint32_t *)symbase = maxva - symtab_addr;
   9.168 +
   9.169 +#undef elf_ehdr_elm
   9.170 +}
   9.171 +
   9.172  void elf_parse_binary(struct elf_binary *elf)
   9.173  {
   9.174      const elf_phdr *phdr;
   9.175 @@ -165,6 +229,8 @@ void elf_load_binary(struct elf_binary *
   9.176          memcpy(dest, elf->image + offset, filesz);
   9.177          memset(dest + filesz, 0, memsz - filesz);
   9.178      }
   9.179 +
   9.180 +    elf_load_bsdsyms(elf);
   9.181  }
   9.182  
   9.183  void *elf_get_ptr(struct elf_binary *elf, unsigned long addr)
    10.1 --- a/xen/common/libelf/libelf-tools.c	Thu Aug 02 09:54:18 2007 -0500
    10.2 +++ b/xen/common/libelf/libelf-tools.c	Thu Aug 02 16:03:35 2007 +0100
    10.3 @@ -238,36 +238,6 @@ int elf_phdr_is_loadable(struct elf_bina
    10.4      return ((p_type == PT_LOAD) && (p_flags & (PF_W | PF_X)) != 0);
    10.5  }
    10.6  
    10.7 -unsigned long
    10.8 -elf_copy_ehdr(struct elf_binary *elf, void *dest)
    10.9 -{
   10.10 -    uint64_t size;
   10.11 -
   10.12 -    size = elf_uval(elf, elf->ehdr, e_ehsize);
   10.13 -    memcpy(dest, elf->ehdr, size);
   10.14 -    return elf_round_up(elf, (unsigned long)(dest) + size);
   10.15 -}
   10.16 -
   10.17 -unsigned long
   10.18 -elf_copy_shdr(struct elf_binary *elf, void *dest)
   10.19 -{
   10.20 -    uint64_t size;
   10.21 -
   10.22 -    size = elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize);
   10.23 -    memcpy(dest, elf->image + elf_uval(elf, elf->ehdr, e_shoff), size);
   10.24 -    return elf_round_up(elf, (unsigned long)(dest) + size);
   10.25 -}
   10.26 -
   10.27 -unsigned long
   10.28 -elf_copy_section(struct elf_binary *elf, const elf_shdr *shdr, void *dest)
   10.29 -{
   10.30 -    uint64_t size;
   10.31 -
   10.32 -    size = elf_uval(elf, shdr, sh_size);
   10.33 -    memcpy(dest, elf_section_start(elf, shdr), size);
   10.34 -    return elf_round_up(elf, (unsigned long)(dest) + size);
   10.35 -}
   10.36 -
   10.37  /*
   10.38   * Local variables:
   10.39   * mode: C
    11.1 --- a/xen/include/public/libelf.h	Thu Aug 02 09:54:18 2007 -0500
    11.2 +++ b/xen/include/public/libelf.h	Thu Aug 02 16:03:35 2007 +0100
    11.3 @@ -65,12 +65,13 @@ struct elf_binary {
    11.4  
    11.5      /* loaded to */
    11.6      char *dest;
    11.7 -    uint64_t sstart;
    11.8 -    uint64_t send;
    11.9      uint64_t pstart;
   11.10      uint64_t pend;
   11.11      uint64_t reloc_offset;
   11.12  
   11.13 +    uint64_t bsd_symtab_pstart;
   11.14 +    uint64_t bsd_symtab_pend;
   11.15 +
   11.16  #ifndef __XEN__
   11.17      /* misc */
   11.18      FILE *log;
   11.19 @@ -150,11 +151,6 @@ const elf_note *elf_note_next(struct elf
   11.20  int elf_is_elfbinary(const void *image);
   11.21  int elf_phdr_is_loadable(struct elf_binary *elf, const elf_phdr * phdr);
   11.22  
   11.23 -unsigned long elf_copy_ehdr(struct elf_binary *elf, void *dest);
   11.24 -unsigned long elf_copy_shdr(struct elf_binary *elf, void *dest);
   11.25 -unsigned long elf_copy_section(struct elf_binary *elf,
   11.26 -                               const elf_shdr *shdr, void *dest);
   11.27 -
   11.28  /* ------------------------------------------------------------------------ */
   11.29  /* xc_libelf_loader.c                                                       */
   11.30  
   11.31 @@ -171,6 +167,8 @@ void elf_load_binary(struct elf_binary *
   11.32  void *elf_get_ptr(struct elf_binary *elf, unsigned long addr);
   11.33  uint64_t elf_lookup_addr(struct elf_binary *elf, const char *symbol);
   11.34  
   11.35 +void elf_parse_bsdsyms(struct elf_binary *elf, uint64_t pstart); /* private */
   11.36 +
   11.37  /* ------------------------------------------------------------------------ */
   11.38  /* xc_libelf_relocate.c                                                     */
   11.39  
   11.40 @@ -221,8 +219,7 @@ struct elf_dom_parms {
   11.41      /* calculated */
   11.42      uint64_t virt_offset;
   11.43      uint64_t virt_kstart;
   11.44 -    uint64_t virt_kend; /* end of kernel image */
   11.45 -    uint64_t virt_end;  /* end of kernel symtab (== virt_kend if none) */
   11.46 +    uint64_t virt_kend;
   11.47  };
   11.48  
   11.49  static inline void elf_xen_feature_set(int nr, uint32_t * addr)
   11.50 @@ -245,7 +242,4 @@ int elf_xen_parse_guest_info(struct elf_
   11.51  int elf_xen_parse(struct elf_binary *elf,
   11.52                    struct elf_dom_parms *parms);
   11.53  
   11.54 -int elf_xen_dom_load_binary(struct elf_binary *elf,
   11.55 -                            struct elf_dom_parms *parms);
   11.56 -
   11.57  #endif /* __XC_LIBELF__ */