version 1.5, 2017/09/29 16:05:53 |
version 1.6, 2017/09/30 10:15:59 |
|
|
if ((sh->sh_offset + sh->sh_size) > filesize) |
if ((sh->sh_offset + sh->sh_size) > filesize) |
continue; |
continue; |
|
|
|
if (sh->sh_entsize == 0) |
|
continue; |
|
|
if (strncmp(shstab + sh->sh_name, ELF_SYMTAB, snlen) == 0) { |
if (strncmp(shstab + sh->sh_name, ELF_SYMTAB, snlen) == 0) { |
if (symtab != NULL) |
if (symtab != NULL) |
*symtab = (Elf_Sym *)(p + sh->sh_offset); |
*symtab = (Elf_Sym *)(p + sh->sh_offset); |
|
|
|
|
/* Find the given section. */ |
/* Find the given section. */ |
for (i = 0; i < eh->e_shnum; i++) { |
for (i = 0; i < eh->e_shnum; i++) { |
|
if ((eh->e_shoff + i * eh->e_shentsize) > filesize) |
|
continue; |
|
|
sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize); |
sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize); |
|
|
if ((sh->sh_link >= eh->e_shnum) || (sh->sh_name >= shstabsz)) |
if ((sh->sh_link >= eh->e_shnum) || (sh->sh_name >= shstabsz)) |
|
|
|
|
/* Apply possible relocation. */ |
/* Apply possible relocation. */ |
for (i = 0; i < eh->e_shnum; i++) { |
for (i = 0; i < eh->e_shnum; i++) { |
|
if ((eh->e_shoff + i * eh->e_shentsize) > filesize) |
|
continue; |
|
|
sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize); |
sh = (Elf_Shdr *)(p + eh->e_shoff + i * eh->e_shentsize); |
|
|
if (sh->sh_size == 0) |
if (sh->sh_size == 0) |
|
|
if ((sh->sh_info != sidx) || (sh->sh_link != symtabidx)) |
if ((sh->sh_info != sidx) || (sh->sh_link != symtabidx)) |
continue; |
continue; |
|
|
|
if ((sh->sh_offset + sh->sh_size) > filesize) |
|
continue; |
|
|
switch (sh->sh_type) { |
switch (sh->sh_type) { |
case SHT_RELA: |
case SHT_RELA: |
rela = (Elf_RelA *)(p + sh->sh_offset); |
rela = (Elf_RelA *)(p + sh->sh_offset); |
|
|
roff = rela[j].r_offset; |
roff = rela[j].r_offset; |
if (rsym >= nsymb) |
if (rsym >= nsymb) |
continue; |
continue; |
|
if (roff >= filesize) |
|
continue; |
sym = &symtab[rsym]; |
sym = &symtab[rsym]; |
value = sym->st_value + rela[j].r_addend; |
value = sym->st_value + rela[j].r_addend; |
|
|
|
|
rtyp = ELF_R_TYPE(rel[j].r_info); |
rtyp = ELF_R_TYPE(rel[j].r_info); |
roff = rel[j].r_offset; |
roff = rel[j].r_offset; |
if (rsym >= nsymb) |
if (rsym >= nsymb) |
|
continue; |
|
if (roff >= filesize) |
continue; |
continue; |
sym = &symtab[rsym]; |
sym = &symtab[rsym]; |
value = sym->st_value; |
value = sym->st_value; |