ia64/xen-unstable

changeset 14416:5bc5ed857cc6

hvmloader: Simplify 32bit-bios relocator.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kfraser@localhost.localdomain
date Thu Mar 15 10:38:06 2007 +0000 (2007-03-15)
parents aa6914c527e1
children 8fa17d1560a9
files tools/firmware/hvmloader/32bitbios_support.c
line diff
     1.1 --- a/tools/firmware/hvmloader/32bitbios_support.c	Thu Mar 15 10:36:10 2007 +0000
     1.2 +++ b/tools/firmware/hvmloader/32bitbios_support.c	Thu Mar 15 10:38:06 2007 +0000
     1.3 @@ -45,16 +45,11 @@ static int relocate_elf(unsigned char *e
     1.4          return -1;
     1.5      }
     1.6  
     1.7 -    for (i = 0; i < ehdr->e_shnum; i++) {
     1.8 -        if (!(shdr[i]).sh_flags & SHF_ALLOC) {
     1.9 -            shdr[i].sh_addr = 0;
    1.10 -            continue;
    1.11 -        }
    1.12 +    for (i = 0; i < ehdr->e_shnum; i++)
    1.13          shdr[i].sh_addr = (Elf32_Addr)&elfarray[shdr[i].sh_offset];
    1.14 -    }
    1.15  
    1.16      for (i = 0; i < ehdr->e_shnum; i++) {
    1.17 -        if (shdr[i].sh_type == SHT_REL && shdr[i].sh_addr != 0) {
    1.18 +        if (shdr[i].sh_type == SHT_REL) {
    1.19              Elf32_Shdr *targetsec = (Elf32_Shdr *)&(shdr[shdr[i].sh_info]);
    1.20              Elf32_Shdr *symtabsec = (Elf32_Shdr *)&(shdr[shdr[i].sh_link]);
    1.21              Elf32_Sym  *syms      = (Elf32_Sym *)symtabsec->sh_addr;
    1.22 @@ -62,6 +57,10 @@ static int relocate_elf(unsigned char *e
    1.23              unsigned char *code   = (unsigned char *)targetsec->sh_addr;
    1.24              int j;
    1.25  
    1.26 +            /* must not have been stripped */
    1.27 +            if (shdr[i].sh_size == 0)
    1.28 +                return -6;
    1.29 +
    1.30              for (j = 0; j < shdr[i].sh_size / sizeof(Elf32_Rel); j++) {
    1.31                  int idx           = ELF32_R_SYM(rels[j].r_info);
    1.32                  Elf32_Sym *symbol = &syms[idx];