summaryrefslogtreecommitdiffstats
path: root/libebl
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-08-01 16:51:03 +0200
committerMark Wielaard <mark@klomp.org>2018-09-13 14:30:30 +0200
commit68e8b84743bdb389776e3aa2bae27aba7f435fdb (patch)
tree57b5c8ff6a38c61e0c7d63dc4b0bc234ef011ebb /libebl
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 <mark@klomp.org>
Diffstat (limited to 'libebl')
-rw-r--r--libebl/ChangeLog6
-rw-r--r--libebl/eblsectionstripp.c7
-rw-r--r--libebl/libebl.h2
3 files changed, 12 insertions, 3 deletions
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 574aae6e..d36a2681 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,5 +1,11 @@
2018-09-12 Mark Wielaard <mark@klomp.org>
+ * eblsectionstripp.c (ebl_section_strip_p): Drop ehdr argument.
+ Use elf_getshdrstrndx.
+ * libebl.h (ebl_section_strip_p): Drop ehdr argument.
+
+2018-09-12 Mark Wielaard <mark@klomp.org>
+
* ebl-hooks.h (check_special_symbol): Drop ehdr argument.
* ebl_check_special_symbol.c (ebl_check_special_symbol): Likewise.
* eblopenbackend.c (default_check_special_symbol): Likewise.
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;
diff --git a/libebl/libebl.h b/libebl/libebl.h
index 0e1f41be..5abc02d8 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -205,7 +205,7 @@ extern bool ebl_none_reloc_p (Ebl *ebl, int reloc);
extern bool ebl_relative_reloc_p (Ebl *ebl, int reloc);
/* Check whether section should be stripped. */
-extern bool ebl_section_strip_p (Ebl *ebl, const GElf_Ehdr *ehdr,
+extern bool ebl_section_strip_p (Ebl *ebl,
const GElf_Shdr *shdr, const char *name,
bool remove_comment, bool only_remove_debug);