]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 17 Sep 2008 08:18:20 +0000 (08:18 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 17 Sep 2008 08:18:20 +0000 (08:18 +0000)
PR 6893 - Do not consider FDEs for discarded sections as invalid.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): New REQUIRE_CLEARED_RELOCS.
Consider FDEs with cleared relocations as valid and ignorable.

ld/testsuite/
* ld-elf/eh-group.exp, ld-elf/eh-group1.s, ld-elf/eh-group2.s: New test.

binutils/
Suppress warnings on NONE relocations to discarded sections.
* readelf.c (is_none_reloc): New function.
(debug_apply_relocations): Ignore is_none_reloc() relocations.

bfd/ChangeLog
bfd/elf-eh-frame.c
binutils/ChangeLog
binutils/readelf.c
ld/testsuite/ChangeLog

index 867bf844eeae16f5b17e6ceec51d41918e8711a1..1d88d99892a02b91d0c68598db07647cbd69588f 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       PR 6893 - Do not consider FDEs for discarded sections as invalid.
+       * elf-eh-frame.c (_bfd_elf_parse_eh_frame): New REQUIRE_CLEARED_RELOCS.
+       Consider FDEs with cleared relocations as valid and ignorable.
+
 2008-09-16  Alan Modra  <amodra@bigpond.net.au>
 
        PR 6844
index 7151a397635c583d7830959238184e8205d9c334..579a6b8967e72a4a67433f9134ffeb323366653f 100644 (file)
@@ -549,6 +549,16 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
             < (bfd_size_type) ((buf) - ehbuf)))        \
     cookie->rel++
 
+#define REQUIRE_CLEARED_RELOCS(buf)                    \
+  while (cookie->rel < cookie->relend                  \
+        && (cookie->rel->r_offset                      \
+            < (bfd_size_type) ((buf) - ehbuf)))        \
+    {                                                  \
+      REQUIRE (cookie->rel->r_info == 0);              \
+      REQUIRE (cookie->rel->r_addend == 0);            \
+      cookie->rel++;                                   \
+    }
+
 #define GET_RELOC(buf)                                 \
   ((cookie->rel < cookie->relend                       \
     && (cookie->rel->r_offset                          \
@@ -766,9 +776,14 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
 
          /* Chain together the FDEs for each section.  */
          rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, cookie);
-         REQUIRE (rsec && rsec->owner == abfd);
-         this_inf->u.fde.next_for_section = elf_fde_list (rsec);
-         elf_fde_list (rsec) = this_inf;
+         /* RSEC will be NULL if FDE was cleared out as it was belonging to
+            a discarded SHT_GROUP.  */
+         if (rsec)
+           {
+             REQUIRE (rsec->owner == abfd);
+             this_inf->u.fde.next_for_section = elf_fde_list (rsec);
+             elf_fde_list (rsec) = this_inf;
+           }
 
          /* Skip the initial location and address range.  */
          start = buf;
@@ -801,7 +816,17 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
          insns = buf;
 
          buf = last_fde + 4 + hdr_length;
-         SKIP_RELOCS (buf);
+
+         /* Cleared FDE?  The instructions will not be cleared but verify all
+            the relocation entries for them are cleared.  */
+         if (rsec == NULL)
+           {
+             REQUIRE_CLEARED_RELOCS (buf);
+           }
+         else
+           {
+             SKIP_RELOCS (buf);
+           }
        }
 
       /* Try to interpret the CFA instructions and find the first
index 39c23bd24849313feef2d90a8b699b33762f7a0a..e5fb8a47ad750da289d1f244f86af17f8473bc40 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Suppress warnings on NONE relocations to discarded sections.
+       * readelf.c (is_none_reloc): New function.
+       (debug_apply_relocations): Ignore is_none_reloc() relocations.
+
 2008-09-11  Alan Modra  <amodra@bigpond.net.au>
 
        * po/sv.po: Update.
index 9f1008ccf3a5df213b9600b969874fd16ef2a6a1..2d356a696261de8e4a6bd5185695f6cdbaac6b3c 100644 (file)
@@ -8284,6 +8284,53 @@ is_16bit_abs_reloc (unsigned int reloc_type)
     }
 }
 
+/* Returns TRUE iff RELOC_TYPE is a NONE relocation used for discarded
+   relocation entries (possibly formerly used for SHT_GROUP sections).  */
+
+static bfd_boolean
+is_none_reloc (unsigned int reloc_type)
+{
+  switch (elf_header.e_machine)
+    {
+    case EM_68K:
+      return reloc_type == 0; /* R_68K_NONE.  */
+    case EM_386:
+      return reloc_type == 0; /* R_386_NONE.  */
+    case EM_SPARC32PLUS:
+    case EM_SPARCV9:
+    case EM_SPARC:
+      return reloc_type == 0; /* R_SPARC_NONE.  */
+    case EM_MIPS:
+      return reloc_type == 0; /* R_MIPS_NONE.  */
+    case EM_PARISC:
+      return reloc_type == 0; /* R_PARISC_NONE.  */
+    case EM_ALPHA:
+      return reloc_type == 0; /* R_ALPHA_NONE.  */
+    case EM_PPC:
+      return reloc_type == 0; /* R_PPC_NONE.  */
+    case EM_PPC64:
+      return reloc_type == 0; /* R_PPC64_NONE.  */
+    case EM_ARM:
+      return reloc_type == 0; /* R_ARM_NONE.  */
+    case EM_IA_64:
+      return reloc_type == 0; /* R_IA64_NONE.  */
+    case EM_SH:
+      return reloc_type == 0; /* R_SH_NONE.  */
+    case EM_S390_OLD:
+    case EM_S390:
+      return reloc_type == 0; /* R_390_NONE.  */
+    case EM_CRIS:
+      return reloc_type == 0; /* R_CRIS_NONE.  */
+    case EM_X86_64:
+      return reloc_type == 0; /* R_X86_64_NONE.  */
+    case EM_MN10300:
+      return reloc_type == 0; /* R_MN10300_NONE.  */
+    case EM_M32R:
+      return reloc_type == 0; /* R_M32R_NONE.  */
+    }
+  return FALSE;
+}
+
 /* Uncompresses a section that was compressed using zlib, in place.
  * This is a copy of bfd_uncompress_section_contents, in bfd/compress.c  */
 
@@ -8419,6 +8466,9 @@ debug_apply_relocations (void *file,
 
          reloc_type = get_reloc_type (rp->r_info);
 
+         if (is_none_reloc (reloc_type))
+           continue;
+
          if (is_32bit_abs_reloc (reloc_type)
              || is_32bit_pcrel_reloc (reloc_type))
            reloc_size = 4;
index a2c3050051d8e1eabbea07fcc3757776e71f2c74..d7741219479c28ff539ed470e7040d9895d252e9 100644 (file)
@@ -1,3 +1,7 @@
+2008-09-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * ld-elf/eh-group.exp, ld-elf/eh-group1.s, ld-elf/eh-group2.s: New test.
+
 2008-08-26  Nick Clifton  <nickc@redhat.com>
 
        * ld-arm/arm-elf.exp: Add farcall-thumb-arm-short test.