summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2017-04-05 17:09:27 +0200
committerMark Wielaard <mark@klomp.org>2017-04-05 17:09:27 +0200
commitcaf135b7f49f9f3499c952b352493cf561ae12bd (patch)
treed259d672bd575361f126bab6f779e8355bd73e61 /src
parentf339da994fda25b51cddc3d88182f249b75f89ff (diff)
downloadelfutils-caf135b7f49f9f3499c952b352493cf561ae12bd.tar.gz
elflint: Support checking ELF files with compressed sections.
Simply unconditionally uncompress any section to make sure indexes between sections check out. Add some testcases with various compressed sections. https://sourceware.org/bugzilla/show_bug.cgi?id=21332 Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/elflint.c7
2 files changed, 10 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e022503b..a1bec198 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-05 Mark Wielaard <mark@klomp.org>
+
+ * elflint.c (check_elf_header): Decompress all sections.
+
2017-03-28 Mark Wielaard <mark@klomp.org>
* elflint (check_group): Don't check if there is no flag word.
diff --git a/src/elflint.c b/src/elflint.c
index e0c65b6a..51e53c23 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -456,7 +456,9 @@ invalid number of section header table entries\n"));
ERROR (gettext ("invalid section header index\n"));
}
- /* Check the shdrs actually exist. */
+ /* Check the shdrs actually exist. And uncompress them before
+ further checking. Indexes between sections reference the
+ uncompressed data. */
unsigned int scnt;
Elf_Scn *scn = NULL;
for (scnt = 1; scnt < shnum; ++scnt)
@@ -464,6 +466,9 @@ invalid number of section header table entries\n"));
scn = elf_nextscn (ebl->elf, scn);
if (scn == NULL)
break;
+ /* If the section wasn't compressed this does nothing, but
+ returns an error. We don't care. */
+ elf_compress (scn, 0, 0);
}
if (scnt < shnum)
ERROR (gettext ("Can only check %u headers, shnum was %u\n"), scnt, shnum);