summaryrefslogtreecommitdiffstats
path: root/tests/elfstrmerge.c
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 /tests/elfstrmerge.c
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]>
Diffstat (limited to 'tests/elfstrmerge.c')
-rw-r--r--tests/elfstrmerge.c4
1 files changed, 2 insertions, 2 deletions
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)