]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fix handling of debuginfo files when checking exception handling tables.
authorUlrich Drepper <drepper@redhat.com>
Wed, 21 Jan 2009 23:02:03 +0000 (15:02 -0800)
committerUlrich Drepper <drepper@redhat.com>
Wed, 21 Jan 2009 23:02:03 +0000 (15:02 -0800)
src/ChangeLog
src/elflint.c

index 9814eb8cc41acabafdb34e108392a1c6e224ca2b..a8453be2e3624e1a1fe6185a0b54059a9d4474f1 100644 (file)
@@ -1,7 +1,7 @@
 2009-01-21  Ulrich Drepper  <drepper@redhat.com>
 
        * elflint.c (check_program_header): Fix typo in .eh_frame_hdr section
-       test.
+       test.  Handle debuginfo files.
        (check_exception_data): First sanity test.
 
 2009-01-17  Ulrich Drepper  <drepper@redhat.com>
index 3beac4646a36c77e35f4d9bae50e49c5e93e43ef..826d94c3dbfd0d3ea05b1001bf150c43bcb1833b 100644 (file)
@@ -4201,47 +4201,66 @@ program header offset in ELF header and PHDR entry do not match"));
          Elf_Scn *scn = NULL;
          GElf_Shdr shdr_mem;
          GElf_Shdr *shdr = NULL;
+         bool any = false;
          while ((scn = elf_nextscn (ebl->elf, scn)) != NULL)
            {
+             any = true;
              shdr = gelf_getshdr (scn, &shdr_mem);
-             if (shdr != NULL && shdr->sh_type == SHT_PROGBITS
+             if (shdr != NULL
+                 && shdr->sh_type == (is_debuginfo
+                                      ? SHT_NOBITS : SHT_PROGBITS)
                  && ! strcmp (".eh_frame_hdr",
                               elf_strptr (ebl->elf, shstrndx, shdr->sh_name)))
                {
-                 if (phdr->p_offset != shdr->sh_offset)
-                   ERROR (gettext ("\
+                 if (! is_debuginfo)
+                   {
+                     if (phdr->p_offset != shdr->sh_offset)
+                       ERROR (gettext ("\
 call frame search table reference in program header has wrong offset\n"));
-                 if (phdr->p_memsz != shdr->sh_size)
-                   ERROR (gettext ("\
+                     if (phdr->p_memsz != shdr->sh_size)
+                       ERROR (gettext ("\
 call frame search table size mismatch in program and section header\n"));
+                   }
                  break;
                }
            }
 
-         /* The section must be allocated and not be writable and
-            executable.  */
-         if ((phdr->p_flags & PF_R) == 0)
-           ERROR (gettext ("\
+         if (scn == NULL)
+           {
+             /* If there is no section header table we don't
+                complain.  But if there is one there should be an
+                entry for .eh_frame_hdr.  */
+             if (any)
+               ERROR (gettext ("\
+PT_GNU_EH_FRAME present but no .eh_frame_hdr section\n"));
+           }
+         else
+           {
+             /* The section must be allocated and not be writable and
+                executable.  */
+             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 ("\
+             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 ("\
+             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 ("\
+             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");
+                      elf_ndxscn (scn), ".eh_frame_hdr");
 
-         if ((phdr->p_flags & PF_X) != 0)
-           ERROR (gettext ("\
+             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 ("\
+             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");
+                      elf_ndxscn (scn), ".eh_frame_hdr");
+           }
 
          /* Remember which entry this is.  */
          pt_gnu_eh_frame_pndx = cnt;