|
|
|
@ -384,11 +384,19 @@ static int parse_elf(struct elf_info *info, const char *filename) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
/* Fix endianness in ELF header */ |
|
|
|
|
hdr->e_shoff = TO_NATIVE(hdr->e_shoff); |
|
|
|
|
hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); |
|
|
|
|
hdr->e_shnum = TO_NATIVE(hdr->e_shnum); |
|
|
|
|
hdr->e_machine = TO_NATIVE(hdr->e_machine); |
|
|
|
|
hdr->e_type = TO_NATIVE(hdr->e_type); |
|
|
|
|
hdr->e_type = TO_NATIVE(hdr->e_type); |
|
|
|
|
hdr->e_machine = TO_NATIVE(hdr->e_machine); |
|
|
|
|
hdr->e_version = TO_NATIVE(hdr->e_version); |
|
|
|
|
hdr->e_entry = TO_NATIVE(hdr->e_entry); |
|
|
|
|
hdr->e_phoff = TO_NATIVE(hdr->e_phoff); |
|
|
|
|
hdr->e_shoff = TO_NATIVE(hdr->e_shoff); |
|
|
|
|
hdr->e_flags = TO_NATIVE(hdr->e_flags); |
|
|
|
|
hdr->e_ehsize = TO_NATIVE(hdr->e_ehsize); |
|
|
|
|
hdr->e_phentsize = TO_NATIVE(hdr->e_phentsize); |
|
|
|
|
hdr->e_phnum = TO_NATIVE(hdr->e_phnum); |
|
|
|
|
hdr->e_shentsize = TO_NATIVE(hdr->e_shentsize); |
|
|
|
|
hdr->e_shnum = TO_NATIVE(hdr->e_shnum); |
|
|
|
|
hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); |
|
|
|
|
sechdrs = (void *)hdr + hdr->e_shoff; |
|
|
|
|
info->sechdrs = sechdrs; |
|
|
|
|
|
|
|
|
@ -402,13 +410,16 @@ static int parse_elf(struct elf_info *info, const char *filename) |
|
|
|
|
|
|
|
|
|
/* Fix endianness in section headers */ |
|
|
|
|
for (i = 0; i < hdr->e_shnum; i++) { |
|
|
|
|
sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); |
|
|
|
|
sechdrs[i].sh_offset = TO_NATIVE(sechdrs[i].sh_offset); |
|
|
|
|
sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); |
|
|
|
|
sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); |
|
|
|
|
sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); |
|
|
|
|
sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info); |
|
|
|
|
sechdrs[i].sh_addr = TO_NATIVE(sechdrs[i].sh_addr); |
|
|
|
|
sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); |
|
|
|
|
sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); |
|
|
|
|
sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags); |
|
|
|
|
sechdrs[i].sh_addr = TO_NATIVE(sechdrs[i].sh_addr); |
|
|
|
|
sechdrs[i].sh_offset = TO_NATIVE(sechdrs[i].sh_offset); |
|
|
|
|
sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); |
|
|
|
|
sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); |
|
|
|
|
sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info); |
|
|
|
|
sechdrs[i].sh_addralign = TO_NATIVE(sechdrs[i].sh_addralign); |
|
|
|
|
sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize); |
|
|
|
|
} |
|
|
|
|
/* Find symbol table. */ |
|
|
|
|
for (i = 1; i < hdr->e_shnum; i++) { |
|
|
|
@ -716,7 +727,17 @@ int match(const char *sym, const char * const pat[]) |
|
|
|
|
|
|
|
|
|
/* sections that we do not want to do full section mismatch check on */ |
|
|
|
|
static const char *section_white_list[] = |
|
|
|
|
{ ".comment", ".debug*", ".stab*", ".note*", ".got*", ".toc*", NULL }; |
|
|
|
|
{ |
|
|
|
|
".comment*", |
|
|
|
|
".debug*", |
|
|
|
|
".mdebug*", /* alpha, score, mips etc. */ |
|
|
|
|
".pdr", /* alpha, score, mips etc. */ |
|
|
|
|
".stab*", |
|
|
|
|
".note*", |
|
|
|
|
".got*", |
|
|
|
|
".toc*", |
|
|
|
|
NULL |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This is used to find sections missing the SHF_ALLOC flag. |
|
|
|
|