]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
More improveents to exception handling table printing and checking.
authorUlrich Drepper <drepper@redhat.com>
Sun, 18 Jan 2009 00:06:42 +0000 (16:06 -0800)
committerUlrich Drepper <drepper@redhat.com>
Sun, 18 Jan 2009 00:06:42 +0000 (16:06 -0800)
src/ChangeLog
src/elflint.c
src/readelf.c

index 97fd4495a9e66046165815d8f072e0bbaac1c0ec..9a0774d0ee14edfc3c897d206d6307ecfa5cd283 100644 (file)
@@ -1,5 +1,11 @@
 2009-01-17  Ulrich Drepper  <drepper@redhat.com>
 
+       * readelf.c (print_debug_exception_table): Show target of ar_disp
+       field.
+
+       * elflint.c (check_program_header): Add most consistency checks for
+       PT_GNU_EH_FRAME entry.
+
        * addr2line.c: Use ARGP_PROGRAM_VERSION_HOOK_DEF and
        ARGP_PROGRAM_BUG_ADDRESS_DEF.
        * ar.c: Likewise.
@@ -11,6 +17,7 @@
        * objdump.c: Likewise.
        * ranlib.c: Likewise.
        * readelf.c: Likewise.
+
        * size.c: Likewise.
        * strings.c: Likewise.
        * strip.c: Likewise.
index 19299023729f97675fd4fe8137795549f1696c5b..f31b75c1fce9f1177486fc7b25b8714d5d3bbb77 100644 (file)
@@ -4199,10 +4199,11 @@ program header offset in ELF header and PHDR entry do not match"));
          /* If there is an .eh_frame_hdr section it must be
             referenced by this program header entry.  */
          Elf_Scn *scn = NULL;
+         GElf_Shdr shdr_mem;
+         GElf_Shdr *shdr = NULL;
          while ((scn = elf_nextscn (ebl->elf, scn)) != NULL)
            {
-             GElf_Shdr shdr_mem;
-             GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+             shdr = gelf_getshdr (scn, &shdr_mem);
              if (shdr != NULL && shdr->sh_type == SHT_PROGBITS
                  && ! strcmp (".eh_frame_hdr",
                               elf_strptr (ebl->elf, shstrndx, shdr->sh_name)))
@@ -4222,12 +4223,25 @@ call frame search table size mismatch in program and section header\n"));
          if ((phdr->p_flags & PF_R) == 0)
            ERROR (gettext ("\
 call frame search table must be allocated\n"));
+         else if (shdr != NULL && (shdr->sh_flags & SHF_ALLOC) != 0)
+           ERROR (gettext ("\
+section [%2zu] '%s' must be allocated\n"), elf_ndxscn (scn), ".eh_frame_hdr");
+
          if ((phdr->p_flags & PF_W) != 0)
            ERROR (gettext ("\
 call frame search table must not be writable\n"));
+         else if (shdr != NULL && (shdr->sh_flags & SHF_WRITE) != 0)
+           ERROR (gettext ("\
+section [%2zu] '%s' must not be writable\n"),
+                  elf_ndxscn (scn), ".eh_frame_hdr");
+
          if ((phdr->p_flags & PF_X) != 0)
            ERROR (gettext ("\
 call frame search table must not be executable\n"));
+         else if (shdr != NULL && (shdr->sh_flags & SHF_EXECINSTR) != 0)
+           ERROR (gettext ("\
+section [%2zu] '%s' must not be executable\n"),
+                  elf_ndxscn (scn), ".eh_frame_hdr");
 
          /* Remember which entry this is.  */
          pt_gnu_eh_frame_pndx = cnt;
@@ -4253,10 +4267,9 @@ program header entry %d: file offset and virtual address not module of alignment
 
 
 static void
-check_exception_data (Ebl *ebl, GElf_Ehdr *ehdr)
+check_exception_data (Ebl *ebl __attribute__ ((unused)),
+                     GElf_Ehdr *ehdr __attribute__ ((unused)))
 {
-  ebl;
-  ehdr;
 }
 
 
index a3223eb40366ee8cda67ba6671d23baae63a41a0..e0165366606607804650bb3ec2b1b38113b6a897 100644 (file)
@@ -6185,9 +6185,16 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
          int ar_disp;
          get_sleb128 (ar_disp, readp);
 
-         printf (" [%4u] ar_filter:  %d\n"
-                 "        ar_disp:    %d\n",
-                 u++, ar_filter, ar_disp);
+         printf (" [%4u] ar_filter:  % d\n"
+                 "        ar_disp:    % -5d",
+                 u, ar_filter, ar_disp);
+         if (abs (ar_disp) & 1)
+           printf (" -> [%4u]\n", u + (ar_disp + 1) / 2);
+         else if (ar_disp != 0)
+           puts (" -> ???");
+         else
+           putchar_unlocked ('\n');
+         ++u;
        }
       while (readp < action_table_end);
     }