summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-01-25 14:37:17 +0100
committerMark Wielaard <[email protected]>2018-01-25 14:37:17 +0100
commit4407903a7433327dbeda74519d036fc82ef64de3 (patch)
tree1ad3284b16d1ebbc02eff82a1e5a0600a552b89b
parente98f032d293a8ea8ea2b25949d7f452603e644d9 (diff)
tests: Check symtabshdr instead of symtabndx in elfstrmerge.c.
Some gcc omptimization levels (-Og in particular) didn't see that when symtabndx != 0, then symtabshdr was certain to be initialized. Change the symtabndx == 0 check to symtabshdr == NULL and initialize symtabshdr to work around that. Signed-off-by: Mark Wielaard <[email protected]>
-rw-r--r--tests/ChangeLog11
-rw-r--r--tests/elfstrmerge.c4
2 files changed, 10 insertions, 5 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 758f20e6..be203adf 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-25 Mark Wielaard <[email protected]>
+
+ * elfstrmerge.c (main): Initialize and check symtabshdr instead of
+ symtabndx.
+
2018-01-14 Petr Machata <[email protected]>
* testfile-sizes4.o.bz2: New test file.
@@ -12,9 +17,9 @@
2017-12-11 Dima Kogan <[email protected]>
- * run-aggregate-size.sh: Added check for multi-dimensional arrays.
- * run-peel-type.sh: Likewise.
- * testfile-sizes3.o.bz2: Likewise.
+ * run-aggregate-size.sh: Added check for multi-dimensional arrays.
+ * run-peel-type.sh: Likewise.
+ * testfile-sizes3.o.bz2: Likewise.
2017-12-07 Mark Wielaard <[email protected]>
diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
index 8d5b53cb..6924d0e9 100644
--- a/tests/elfstrmerge.c
+++ b/tests/elfstrmerge.c
@@ -195,7 +195,7 @@ main (int argc, char **argv)
size_t symtabndx = 0;
Elf_Scn *symtabscn = NULL;
GElf_Shdr symtabshdr_mem;
- GElf_Shdr *symtabshdr;
+ GElf_Shdr *symtabshdr = NULL;
while ((symtabscn = elf_nextscn (elf, symtabscn)) != NULL)
{
symtabshdr = gelf_getshdr (symtabscn, &symtabshdr_mem);
@@ -210,7 +210,7 @@ main (int argc, char **argv)
}
}
- if (symtabndx == 0)
+ if (symtabshdr == NULL)
fail ("No symtab found", fname);
if ((symtabshdr->sh_flags & SHF_ALLOC) != 0)