summaryrefslogtreecommitdiffstats
path: root/libebl/eblsectionstripp.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-08-01 16:51:03 +0200
committerMark Wielaard <[email protected]>2018-09-13 14:30:30 +0200
commit68e8b84743bdb389776e3aa2bae27aba7f435fdb (patch)
tree57b5c8ff6a38c61e0c7d63dc4b0bc234ef011ebb /libebl/eblsectionstripp.c
parent19756e7fb614831f4a5f5ff5b996675fae638782 (diff)
libebl: Use elf_getshdrstrndx in ebl_section_strip_p.
The ebl_section_strip_p function used the Ehdr e_shstrndx field to get at the name of the (debug) sections. This is not correct if there are more than SHN_LORESERVE sections. Use elf_getshdrstrndx to get at the shstrtab section. And drop the Ehdr argument that isn't necessary anymore. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libebl/eblsectionstripp.c')
-rw-r--r--libebl/eblsectionstripp.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libebl/eblsectionstripp.c b/libebl/eblsectionstripp.c
index c6cda63a..a5624ffe 100644
--- a/libebl/eblsectionstripp.c
+++ b/libebl/eblsectionstripp.c
@@ -35,7 +35,7 @@
bool
-ebl_section_strip_p (Ebl *ebl, const GElf_Ehdr *ehdr, const GElf_Shdr *shdr,
+ebl_section_strip_p (Ebl *ebl, const GElf_Shdr *shdr,
const char *name, bool remove_comment,
bool only_remove_debug)
{
@@ -53,7 +53,10 @@ ebl_section_strip_p (Ebl *ebl, const GElf_Ehdr *ehdr, const GElf_Shdr *shdr,
GElf_Shdr *shdr_l = gelf_getshdr (scn_l, &shdr_mem_l);
if (shdr_l != NULL)
{
- const char *s_l = elf_strptr (ebl->elf, ehdr->e_shstrndx,
+ size_t shstrndx;
+ if (elf_getshdrstrndx (ebl->elf, &shstrndx) != 0)
+ return false;
+ const char *s_l = elf_strptr (ebl->elf, shstrndx,
shdr_l->sh_name);
if (s_l != NULL && ebl_debugscn_p (ebl, s_l))
return true;