diff options
authorRobert Yang <liezhi.yang@windriver.com>2018-08-15 17:53:43 +0800
committerMark Hatle <mark.hatle@windriver.com>2018-08-29 11:24:22 -0400
commitedea9e6c3bbe64fcdfc9d092e148161ef95ecf3c (patch)
parent15e9461b1a1e7424a221201df93d9dd5dc211e22 (diff)
src/dso.c: use ehdr.e_shstrndx as index
According to struct elf32_hd, the e_shnum is section header number, and the index is e_shstrndx, not e_shnum. This can fix segmention fault when handle libqb.so.0.18.2 from libqb_1.0.3. It fails to handle libqb.so.0.18.2 and get errors: Symbol section index outside of section numbers Then segmentation fault, this is because the e_shnum is 34, while e_shstrndx is 27 (it would be 33 when no errors), I've checked several elf files to confirm that the ones after e_shstrndx is NULL, so use e_shstrndx should be correct. Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2 files changed, 4 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index fbc9a2b..7ce7778 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2018-08-29 Robert Yang <liezhi.yang@windriver.com>
+ * src/dso.c: use ehdr.e_shstrndx as index
2017-06-20 Andrew Stubbs <ams@codesourcery.com>
* src/arch-x86_64.c (x86_64_prelink_conflict_rela): Also convert
R_X86_64_32 conflicts to R_X86_64_IRELATIVE for ifuncs.
diff --git a/src/dso.c b/src/dso.c
index ae5e04d..c59d81f 100644
--- a/src/dso.c
+++ b/src/dso.c
@@ -1659,7 +1659,7 @@ close_dso_1 (DSO *dso)
int i;
- for (i = 1; i < dso->ehdr.e_shnum; ++i)
+ for (i = 1; i < dso->ehdr.e_shstrndx; ++i)
Elf_Scn *scn = dso->scn[i];
Elf_Data *data = NULL;