public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [COMMITTED] tests: Check symtabshdr instead of symtabndx in elfstrmerge.c.
Date: Thu, 25 Jan 2018 13:41:00 -0000	[thread overview]
Message-ID: <1516887649-21906-1-git-send-email-mark@klomp.org> (raw)

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 <mark@klomp.org>
---
 tests/ChangeLog     | 11 ++++++++---
 tests/elfstrmerge.c |  4 ++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 758f20e..be203ad 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-25  Mark Wielaard  <mark@klomp.org>
+
+	* elfstrmerge.c (main): Initialize and check symtabshdr instead of
+	symtabndx.
+
 2018-01-14  Petr Machata  <pmachata@gmail.com>
 
 	* testfile-sizes4.o.bz2: New test file.
 
diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
index 8d5b53c..6924d0e 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)
-- 
1.8.3.1

                 reply	other threads:[~2018-01-25 13:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516887649-21906-1-git-send-email-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).