]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: Make sure phdr2_mem lifetime/scope equals phdr2 pointer.
authorMark Wielaard <mjw@redhat.com>
Thu, 18 Jun 2015 18:24:39 +0000 (20:24 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 19 Jun 2015 11:10:22 +0000 (13:10 +0200)
We dont' want GCC to dispose or reuse phdr2_mem stack memory while phdr2
is pointing to it.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/readelf.c

index d11b0e6b590e94e0f4cfc2e49362dd0c21ee666f..80e451cef00b56dc770d0ccc3712baf8370d99b6 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-18  Mark Wielaard  <mjw@redhat.com>
+
+       * readelf.c (print_phdr): Make sure phdr2_mem lifetime/scope equals
+       phdr2 pointer.
+
 2015-06-18  Mark Wielaard  <mjw@redhat.com>
 
        * readelf.c (handle_gnu_hash): Free lengths on invalid_data.
index 9afe8dba47f0a651a8043aa0dddb9482b7ec96f2..d3c2b6b4a4f289094ccd05a1db1f517137ea3aef 100644 (file)
@@ -1315,10 +1315,10 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr)
                {
                  /* Determine the segment this section is part of.  */
                  size_t cnt2;
+                 GElf_Phdr phdr2_mem;
                  GElf_Phdr *phdr2 = NULL;
                  for (cnt2 = 0; cnt2 < phnum; ++cnt2)
                    {
-                     GElf_Phdr phdr2_mem;
                      phdr2 = gelf_getphdr (ebl->elf, cnt2, &phdr2_mem);
 
                      if (phdr2 != NULL && phdr2->p_type == PT_LOAD