diff options
author | Mark Wielaard <mark@klomp.org> | 2018-08-04 22:32:56 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-09-13 14:30:30 +0200 |
commit | 19756e7fb614831f4a5f5ff5b996675fae638782 (patch) | |
tree | 33062e42d1e7065b9c65c424ad3595e081e3b69e /backends | |
parent | ba2a7f4fa5f453c2b0a729bf519240a8f66a1867 (diff) | |
download | elfutils-19756e7fb614831f4a5f5ff5b996675fae638782.tar.gz |
backends: Use elf_getshdrstrndx to find .odp section in ppc64_init
The .odp section is found by name. But ppc64_init used the e_shstrndx
Ehdr field for that. This is wrong if the file contains more than
SHN_LORESERVE sections. Use elf_getshdrstrndx instead to find the
shstrtab section.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'backends')
-rw-r--r-- | backends/ChangeLog | 4 | ||||
-rw-r--r-- | backends/ppc64_init.c | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog index ada349fe..fdff3021 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,5 +1,9 @@ 2018-09-12 Mark Wielaard <mark@klomp.org> + * ppc64_init.c (ppc64_init): Use elf_getshdrstrndx. + +2018-09-12 Mark Wielaard <mark@klomp.org> + * aarch64_symbol.c (aarch64_check_special_symbol): Drop ehdr argument, use elf_getshdrstrndx. * alpha_symbol.c (alpha_check_special_symbol): Drop ehdr argument. diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c index e5670338..3db5e766 100644 --- a/backends/ppc64_init.c +++ b/backends/ppc64_init.c @@ -80,7 +80,9 @@ ppc64_init (Elf *elf __attribute__ ((unused)), if (elf != NULL) { GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (elf, &ehdr_mem); - if (ehdr != NULL && ehdr->e_type != ET_REL) + size_t shstrndx; + if (ehdr != NULL && ehdr->e_type != ET_REL + && elf_getshdrstrndx (elf, &shstrndx) == 0) { /* We could also try through DT_PPC64_OPD and DT_PPC64_OPDSZ. */ GElf_Shdr opd_shdr_mem, *opd_shdr; @@ -93,7 +95,7 @@ ppc64_init (Elf *elf __attribute__ ((unused)), && opd_shdr->sh_type == SHT_PROGBITS && opd_shdr->sh_size > 0) { - const char *name = elf_strptr (elf, ehdr->e_shstrndx, + const char *name = elf_strptr (elf, shstrndx, opd_shdr->sh_name); if (name != NULL && strcmp (name, ".opd") == 0) { |