summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Machata <[email protected]>2011-03-17 13:17:35 +0100
committerPetr Machata <[email protected]>2011-03-17 13:17:35 +0100
commitdc69d5d8136f4615aa238d2f0eb355e7e48710c2 (patch)
treed0cdc1a3d2149bee3648741e64c6688e20b45410
parent66a96a2d8162601ed99dc04c6fa6ecd6ee14a7f4 (diff)
dwarflint: More thorough validation of ELF sections
-rw-r--r--dwarflint/sections.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/dwarflint/sections.cc b/dwarflint/sections.cc
index d5736c4b..4a8f6401 100644
--- a/dwarflint/sections.cc
+++ b/dwarflint/sections.cc
@@ -250,12 +250,7 @@ namespace
REALLOC (file, sec);
file->sec[file->size++].id = sec_invalid;
- bool check_rel = true;
-
- /* Try to obtain .shstrtab, which we will need in following. If
- we fail, elf is broken. */
- Elf_Scn *shstrscn = elf_getscn (elf, file->ehdr.e_shstrndx);
- if (shstrscn == NULL || elf_rawdata (shstrscn, NULL) == NULL)
+ if (false)
{
invalid_elf:
wr_error () << "Broken ELF: " << elf_errmsg (-1) << "."
@@ -263,6 +258,11 @@ namespace
goto close_and_out;
}
+ /* Check that the ELF file is sound. */
+ for (Elf_Scn *scn = NULL; (scn = elf_nextscn (elf, scn)); )
+ if (elf_rawdata (scn, NULL) == NULL)
+ goto invalid_elf;
+
for (Elf_Scn *scn = NULL; (scn = elf_nextscn (elf, scn)); )
{
REALLOC (file, sec);
@@ -366,7 +366,7 @@ namespace
if (it->second.secndx != 0)
file->debugsec[it->second.id] = file->sec + it->second.secndx;
- if (check_rel)
+ if (true)
{
Elf_Data *reloc_symdata = NULL;
if (reloc_symtab != NULL)