PR ld/13177
authorAlan Modra <amodra@gmail.com>
Wed, 19 Oct 2011 07:17:21 +0000 (07:17 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 19 Oct 2011 07:17:21 +0000 (07:17 +0000)
bfd/
* elflink.c (_bfd_elf_gc_mark_rsec): Set symbol "mark".
(elf_gc_sweep_symbol): Don't test plt/got refcounts, instead test
"mark".  Hide undefweak too.  Clear def_regular and ref_regular.
* elf-m10300.c (mn10300_elf_relocate_section): Ignore unresolved
reloc errors from garbage-collected code.
* elf32-arm.c (elf32_arm_relocate_section): Likewise.
* elf32-bfin.c (bfin_relocate_section): Likewise.
(bfinfdpic_relocate_section): Likewise.
* elf32-cris.c (cris_elf_relocate_section): Likewise.
* elf32-frv.c (elf32_frv_relocate_section): Likewise.
* elf32-i386.c (elf_i386_relocate_section): Likewise.
* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
* elf32-s390.c (elf_s390_relocate_section): Likewise.
* elf32-sh.c (sh_elf_relocate_section): Likewise.
* elf32-spu.c (spu_elf_relocate_section): Likewise.
* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
* elf64-s390.c (elf_s390_relocate_section): Likewise.
* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
ld/testsuite/
* ld-elf/elf.exp: Move test for shared lib support..
* lib/ld-lib.exp (check_shared_lib_support): ..to here. Add m68hc1*,
and s/ms1/mt/.
(check_gc_sections_available): Match hppa*64 not hppa64.  Comment.
* ld-gc/libpersonality.s: New.
* ld-gc/personality.s, * ld-gc/personality.d: New.
* ld-gc/gc.exp: Run personality test.

30 files changed:
bfd/ChangeLog
bfd/elf-m10300.c
bfd/elf32-arm.c
bfd/elf32-bfin.c
bfd/elf32-cris.c
bfd/elf32-frv.c
bfd/elf32-i386.c
bfd/elf32-m32r.c
bfd/elf32-m68k.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-sh.c
bfd/elf32-spu.c
bfd/elf32-tilepro.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elf64-sh64.c
bfd/elf64-x86-64.c
bfd/elflink.c
bfd/elfxx-sparc.c
bfd/elfxx-tilegx.c
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/elf.exp
ld/testsuite/ld-gc/gc.exp
ld/testsuite/ld-gc/libpersonality.s [new file with mode: 0644]
ld/testsuite/ld-gc/personality.d [new file with mode: 0644]
ld/testsuite/ld-gc/personality.s [new file with mode: 0644]
ld/testsuite/lib/ld-lib.exp

index ec54e217ecf5fe92394f8a5cb0c34c9fea17821b..38ddcab6bca2dee93b825098e1b0a923b91eddea 100644 (file)
@@ -1,3 +1,33 @@
+2011-10-19  Alan Modra  <amodra@gmail.com>
+
+       PR ld/13177
+       * elflink.c (_bfd_elf_gc_mark_rsec): Set symbol "mark".
+       (elf_gc_sweep_symbol): Don't test plt/got refcounts, instead test
+       "mark".  Hide undefweak too.  Clear def_regular and ref_regular.
+       * elf-m10300.c (mn10300_elf_relocate_section): Ignore unresolved
+       reloc errors from garbage-collected code.
+       * elf32-arm.c (elf32_arm_relocate_section): Likewise.
+       * elf32-bfin.c (bfin_relocate_section): Likewise.
+       (bfinfdpic_relocate_section): Likewise.
+       * elf32-cris.c (cris_elf_relocate_section): Likewise.
+       * elf32-frv.c (elf32_frv_relocate_section): Likewise.
+       * elf32-i386.c (elf_i386_relocate_section): Likewise.
+       * elf32-m32r.c (m32r_elf_relocate_section): Likewise.
+       * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+       * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+       * elf32-s390.c (elf_s390_relocate_section): Likewise.
+       * elf32-sh.c (sh_elf_relocate_section): Likewise.
+       * elf32-spu.c (spu_elf_relocate_section): Likewise.
+       * elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
+       * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
+       * elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
+       * elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
+       * elf64-s390.c (elf_s390_relocate_section): Likewise.
+       * elf64-sh64.c (sh_elf64_relocate_section): Likewise.
+       * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+       * elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
+       * elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
+
 2011-10-19  Alan Modra  <amodra@gmail.com>
 
        PR ld/13311
index 8276a2fb0bfdff24a07d475fd21d58c9a0655aa9..c2dc5835ea65977d786303320cb9d3645514ef76 100644 (file)
@@ -1499,7 +1499,10 @@ mn10300_elf_relocate_section (bfd *output_bfd,
               obscure cases sec->output_section will be NULL.  */
            relocation = 0;
 
-         else if (!info->relocatable && unresolved_reloc)
+         else if (!info->relocatable && unresolved_reloc
+                  && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                              rel->r_offset) != (bfd_vma) -1)
+
            (*_bfd_error_handler)
              (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
               input_bfd,
index bcf0aac3196befd2b4668898fa457e8035c590dc..b32163e93cb4c7a6cfed4966bc0faa366df6cf24 100644 (file)
@@ -10386,7 +10386,9 @@ elf32_arm_relocate_section (bfd *                  output_bfd,
         not process them.  */
       if (unresolved_reloc
           && !((input_section->flags & SEC_DEBUGGING) != 0
-               && h->def_dynamic))
+               && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        {
          (*_bfd_error_handler)
            (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
index b112dfc267f5fad95d85f98d2c6821c77524f73c..f88e5d49919367fbe22b4a74e62611c58dbaa665 100644 (file)
@@ -1585,7 +1585,9 @@ bfin_relocate_section (bfd * output_bfd,
          because such sections are not SEC_ALLOC and thus ld.so will
          not process them.  */
       if (unresolved_reloc
-         && !((input_section->flags & SEC_DEBUGGING) != 0 && h->def_dynamic))
+         && !((input_section->flags & SEC_DEBUGGING) != 0 && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        {
          (*_bfd_error_handler)
            (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"),
@@ -2731,7 +2733,9 @@ bfinfdpic_relocate_section (bfd * output_bfd,
        default:
        non_fdpic:
          picrel = NULL;
-         if (h && ! BFINFDPIC_SYM_LOCAL (info, h))
+         if (h && ! BFINFDPIC_SYM_LOCAL (info, h)
+             && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                         rel->r_offset) != (bfd_vma) -1)
            {
              info->callbacks->warning
                (info, _("relocation references symbol not defined in the module"),
index 243a8ec140d5468fd8933d6b2889aa06180b6e08..033d1c8b7919bc238077f9d435adfe61256389bb 100644 (file)
@@ -1166,7 +1166,11 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                      || r_type == R_CRIS_16_PCREL
                      || r_type == R_CRIS_32_PCREL))
                relocation = 0;
-             else if (!info->relocatable && unresolved_reloc)
+             else if (!info->relocatable && unresolved_reloc
+                      && (_bfd_elf_section_offset (output_bfd, info,
+                                                   input_section,
+                                                   rel->r_offset)
+                          != (bfd_vma) -1))
                {
                  _bfd_error_handler
                    (_("%B, section %A: unresolvable relocation %s against symbol `%s'"),
index 7f3c4dd23ebcca41d3aa4c83d1e09c722734b5fa..e4e7f2408ce04881e1624e59d251579ad547800b 100644 (file)
@@ -2896,7 +2896,10 @@ elf32_frv_relocate_section (output_bfd, info, input_bfd, input_section,
        default:
        non_fdpic:
          picrel = NULL;
-         if (h && ! FRVFDPIC_SYM_LOCAL (info, h))
+         if (h
+             && ! FRVFDPIC_SYM_LOCAL (info, h)
+             && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                         rel->r_offset) != (bfd_vma) -1)
            {
              info->callbacks->einfo
                (_("%H: relocation references symbol"
index 38c7c5a61098339926fa754338f9aadc5b90e32a..74343560fdcbf8f5e7436f8466142a3385160c48 100644 (file)
@@ -4244,7 +4244,9 @@ elf_i386_relocate_section (bfd *output_bfd,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        {
          (*_bfd_error_handler)
            (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
index 51ef61e6b4980b1165628a3e747ada923a2692c2..37d995d14c362308fa3c95ad5433d530c1da2067 100644 (file)
@@ -2589,7 +2589,11 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                relocation = (h->root.u.def.value
                              + sec->output_section->vma
                              + sec->output_offset);
-             else if (!info->relocatable)
+             else if (!info->relocatable
+                      && (_bfd_elf_section_offset (output_bfd, info,
+                                                   input_section,
+                                                   rel->r_offset)
+                          != (bfd_vma) -1))
                {
                  (*_bfd_error_handler)
                    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
index 612525c2ad6ce11ebe022fcdd8096134abd46f96..8c935485facbbd47489ba8a48a024b96c1efe4aa 100644 (file)
@@ -4148,7 +4148,9 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        {
          (*_bfd_error_handler)
            (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
index cfb473479f9dc84f0d61fe71d0d9ebc1b3335d59..ab50f1a9ed25520248f4d68d5ca035c23369ef7a 100644 (file)
@@ -8150,7 +8150,9 @@ ppc_elf_relocate_section (bfd *output_bfd,
 
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        {
          info->callbacks->einfo
            (_("%P: %H: unresolvable %s relocation against symbol `%s'\n"),
index 98437d0df903af2b533930ec91acb398b7c54aad..2cfd53ee1b032b22230ade30d7116c5036faee5c 100644 (file)
@@ -2996,7 +2996,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        (*_bfd_error_handler)
          (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
           input_bfd,
index ca2c4af9058d8c518ffac0768df8fab084ee17ad..780a3bf6b0fd898b52b0a04dfa0631633db848c5 100644 (file)
@@ -4208,7 +4208,11 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                                 STT_DATALABEL on the way to it.  */
                              | ((h->other & STO_SH5_ISA32) != 0
                                 && ! seen_stt_datalabel));
-             else if (!info->relocatable)
+             else if (!info->relocatable
+                      && (_bfd_elf_section_offset (output_bfd, info,
+                                                   input_section,
+                                                   rel->r_offset)
+                          != (bfd_vma) -1))
                {
                  (*_bfd_error_handler)
                    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
index ae3ed10c4ed1b066d7f1d21f17c755abc201046c..cff91858eda8c4c118b9fece33342593e94ce80a 100644 (file)
@@ -5000,7 +5000,9 @@ spu_elf_relocate_section (bfd *output_bfd,
       else if (is_ea_sym)
        unresolved_reloc = TRUE;
 
-      if (unresolved_reloc)
+      if (unresolved_reloc
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        {
          (*_bfd_error_handler)
            (_("%B(%s+0x%lx): unresolvable %s relocation against symbol `%s'"),
index f2aed9cf1e15af0bb8cac652cecd12079fc7980d..7b08aff04ed59ad5118bd00e90adb928cc978cad 100644 (file)
@@ -3110,7 +3110,9 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        (*_bfd_error_handler)
          (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
           input_bfd,
index c6e4fb43a01cd26fbc4ceafce5e10f219a21cdff..877ab6ffcfe953c2005192d74bd103c733458254 100644 (file)
@@ -3058,7 +3058,9 @@ elf_xtensa_relocate_section (bfd *output_bfd,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        {
          (*_bfd_error_handler)
            (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
index 528476bdddf680256fa5edf566ab07fd91fc85ba..94ea6858d5bdd22abd5a393e8bf0762ab52d7a42 100644 (file)
@@ -4213,6 +4213,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
       bfd_vma value;
       bfd_vma addend;
       bfd_boolean dynamic_symbol_p;
+      bfd_boolean unresolved_reloc = FALSE;
       bfd_boolean undef_weak_ref = FALSE;
       unsigned long r_type;
 
@@ -4294,7 +4295,6 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
       else
        {
          bfd_boolean warned;
-         bfd_boolean unresolved_reloc;
          struct elf_link_hash_entry *hh;
          struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
 
@@ -4527,7 +4527,12 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
            else if (info->shared
                     && r_symndx != STN_UNDEF
                     && (input_section->flags & SEC_ALLOC)
-                    && !undef_weak_ref)
+                    && !undef_weak_ref
+                    && !(unresolved_reloc
+                         && (_bfd_elf_section_offset (output_bfd, info,
+                                                      input_section,
+                                                      rel->r_offset)
+                             == (bfd_vma) -1)))
              {
                if (r_type == R_ALPHA_REFLONG)
                  {
@@ -4573,7 +4578,11 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
          /* ??? .eh_frame references to discarded sections will be smashed
             to relocations against SHN_UNDEF.  The .eh_frame format allows
             NULL to be encoded as 0 in any format, so this works here.  */
-         if (r_symndx == STN_UNDEF)
+         if (r_symndx == STN_UNDEF
+             || (unresolved_reloc
+                 && _bfd_elf_section_offset (output_bfd, info,
+                                             input_section,
+                                             rel->r_offset) == (bfd_vma) -1))
            howto = (elf64_alpha_howto_table
                     + (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG));
          goto default_reloc;
index 837568cef186ef3be0c9210409e0cbd3b91a3d63..dfe10fa28c705e5c9ee573cc8ff7b9179a786f0a 100644 (file)
@@ -13459,7 +13459,9 @@ ppc64_elf_relocate_section (bfd *output_bfd,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->elf.def_dynamic))
+              && h->elf.def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        {
          info->callbacks->einfo
            (_("%P: %H: unresolvable %s relocation against symbol `%s'\n"),
index 9884da03b61482c907c93756193f375dfbfa613b..7d3e8821d93843ae7834a5279ee5b73fafe985b1 100644 (file)
@@ -2971,7 +2971,9 @@ elf_s390_relocate_section (bfd *output_bfd,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        (*_bfd_error_handler)
          (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
           input_bfd,
index bbef2a216cf86bbc111584d14259d8e4bd0e8d25..920247726763975d5bebcaf9b07686a0bae35841 100644 (file)
@@ -1630,7 +1630,11 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                                 STT_DATALABEL on the way to it.  */
                              | ((h->other & STO_SH5_ISA32) != 0
                                 && ! seen_stt_datalabel));
-             else if (!info->relocatable)
+             else if (!info->relocatable
+                      && (_bfd_elf_section_offset (output_bfd, info,
+                                                   input_section,
+                                                   rel->r_offset)
+                          != (bfd_vma) -1))
                {
                  (*_bfd_error_handler)
                    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
index 238c7bd29b6fc2f4e3c74210af7142a8764b51e9..092f447f495d2a39e61f1dd4d4bace34543f57b6 100644 (file)
@@ -4103,7 +4103,9 @@ elf_x86_64_relocate_section (bfd *output_bfd,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        (*_bfd_error_handler)
          (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
           input_bfd,
index 9956e814817b5888901a7e436fa004737ba440ea..4f55d9aa151bf68838d6c5b0d289e698e6f13254 100644 (file)
@@ -11577,6 +11577,7 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
       while (h->root.type == bfd_link_hash_indirect
             || h->root.type == bfd_link_hash_warning)
        h = (struct elf_link_hash_entry *) h->root.u.i.link;
+      h->mark = 1;
       return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL);
     }
 
@@ -11724,19 +11725,20 @@ struct elf_gc_sweep_symbol_info
 static bfd_boolean
 elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
 {
-  if (((h->root.type == bfd_link_hash_defined
-       || h->root.type == bfd_link_hash_defweak)
-       && !h->root.u.def.section->gc_mark
-       && (!(h->root.u.def.section->owner->flags & DYNAMIC)
-          || (h->plt.refcount <= 0
-              && h->got.refcount <= 0)))
-      || (h->root.type == bfd_link_hash_undefined
-         && h->plt.refcount <= 0
-         && h->got.refcount <= 0))
-    {
-      struct elf_gc_sweep_symbol_info *inf =
-       (struct elf_gc_sweep_symbol_info *) data;
+  if (!h->mark
+      && (((h->root.type == bfd_link_hash_defined
+           || h->root.type == bfd_link_hash_defweak)
+          && !h->root.u.def.section->gc_mark)
+         || h->root.type == bfd_link_hash_undefined
+         || h->root.type == bfd_link_hash_undefweak))
+    {
+      struct elf_gc_sweep_symbol_info *inf;
+
+      inf = (struct elf_gc_sweep_symbol_info *) data;
       (*inf->hide_symbol) (inf->info, h, TRUE);
+      h->def_regular = 0;
+      h->ref_regular = 0;
+      h->ref_regular_nonweak = 0;
     }
 
   return TRUE;
index 9a151247d1b40e369ec519d8241dac5935d0f5c8..fe18a62cc99a87f45acdf5f80b3eace521367396 100644 (file)
@@ -3828,7 +3828,9 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        (*_bfd_error_handler)
          (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
           input_bfd,
index c484562da922e8eac44fca3dadc13e697bb1e23d..2aaa3d317570a6172cd351cda540a28182bde4d6 100644 (file)
@@ -3493,7 +3493,9 @@ tilegx_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        (*_bfd_error_handler)
          (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
           input_bfd,
index 791250803dbe2b5dd8b4be8e742e133f1f0dbdf4..26ea036975a728fb4050220a02635b3917e45e5e 100644 (file)
@@ -1,3 +1,13 @@
+2011-10-19  Alan Modra  <amodra@gmail.com>
+
+       * ld-elf/elf.exp: Move test for shared lib support..
+       * lib/ld-lib.exp (check_shared_lib_support): ..to here. Add m68hc1*,
+       and s/ms1/mt/.
+       (check_gc_sections_available): Match hppa*64 not hppa64.  Comment.
+       * ld-gc/libpersonality.s: New.
+       * ld-gc/personality.s, * ld-gc/personality.d: New.
+       * ld-gc/gc.exp: Run personality test.
+
 2011-10-18  David S. Miller  <davem@davemloft.net>
 
        * ld-sparc/tlssunbin32.dd: Update for TLS call relaxation fix
index b993c965f3633af94297b09e568b4866ecd8bcb9..42b554138b38dc2549093f9f048009c68273c53b 100644 (file)
@@ -58,40 +58,7 @@ if { ![istarget hppa64*-hpux*] } {
 # should not seg-fault whilst creating the binary.
 #
 # Only run the test on targets thats support creating shared libraries.
-if {    ! [istarget arc-*-*]
-     && ! [istarget avr-*-*]
-     && ! [istarget cr16-*-*]
-     && ! [istarget cris*-*-*]
-     && ! [istarget crx-*-*]
-     && ! [istarget d10v-*-*]
-     && ! [istarget d30v-*-*]
-     && ! [istarget dlx-*-*]
-     && ! [istarget fr30-*-*]
-     && ! [istarget frv-*-*]
-     && ! [istarget h8300-*-*]
-     && ! [istarget i860-*-*]
-     && ! [istarget i960-*-*]
-     && ! [istarget ip2k-*-*]
-     && ! [istarget iq2000-*-*]
-     && ! [istarget lm32-*-*]
-     && ! [istarget m32c-*-*]
-     && ! [istarget m32r-*-*]
-     && ! [istarget mcore*-*-*]
-     && ! [istarget mep-*-*]
-     && ! [istarget microblaze-*-*]
-     && ! [istarget mn10200-*-*]
-     && ! [istarget moxie-*-*]
-     && ! [istarget ms1-*-*]
-     && ! [istarget msp430-*-*]
-     && ! [istarget openrisc-*-*]
-     && ! [istarget or32-*-*]
-     && ! [istarget pj-*-*]
-     && ! [istarget rx-*-*]
-     && ! [istarget spu-*-*]
-     && ! [istarget v850*-*-*]
-     && ! [istarget xstormy16-*-*]
-     && ! [istarget *-*-irix*]
-     && ! [istarget *-*-rtems] } {
+if { [check_shared_lib_support] } then {
   run_ld_link_tests {
       {"Build shared library for next test"
        "-shared" "" "note-3.s" {} "note-3.so" }
index b7d6dffd90bcb876a5ed78c121ee13318fd3be9b..57f0ec3f7c95ea87036bf0b1b43caf05c508ffdc 100644 (file)
@@ -97,6 +97,20 @@ test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func"
 run_dump_test "noent"
 run_dump_test "abi-note"
 run_dump_test "start"
+
+if { [is_elf_format] && [check_shared_lib_support] } then {
+    set gasopt ""
+    if { [istarget tic6x-*] } then {
+       set gasopt "-mpic -mpid=near"
+    }
+    if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/libpersonality.s tmpdir/libpersonality.o]
+       || ![ld_simple_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then {
+       fail libpersonality
+    } else {
+       run_dump_test "personality"
+    }
+}
+
 if { [is_remote host] || [which $CC] != 0 } {
     if { [istarget "*-*-linux*"]
         || [istarget "*-*-gnu*"] } {
diff --git a/ld/testsuite/ld-gc/libpersonality.s b/ld/testsuite/ld-gc/libpersonality.s
new file mode 100644 (file)
index 0000000..b19ce2b
--- /dev/null
@@ -0,0 +1,11 @@
+       .weak   __gxx_personality_v0
+       .type   __gxx_personality_v0,%function
+__gxx_personality_v0:
+       .long 0
+       .size   __gxx_personality_v0, . - __gxx_personality_v0
+
+       .globl  __gxx_personality_v1
+       .type   __gxx_personality_v1,%function
+__gxx_personality_v1:
+       .long 0
+       .size   __gxx_personality_v1, . - __gxx_personality_v1
diff --git a/ld/testsuite/ld-gc/personality.d b/ld/testsuite/ld-gc/personality.d
new file mode 100644 (file)
index 0000000..89fe8b4
--- /dev/null
@@ -0,0 +1,10 @@
+#name: --gc-sections with __gxx_personality
+#ld: --gc-sections -e main -L tmpdir -lpersonality
+#nm: -n
+#xfail: bfin-*-* cris*-*-* frv-*-* mn10300-*-* vax-*-* xtensa-*-*
+# above targets don't support cfi
+
+#failif
+#...
+.*gxx_personality.*
+#...
diff --git a/ld/testsuite/ld-gc/personality.s b/ld/testsuite/ld-gc/personality.s
new file mode 100644 (file)
index 0000000..6fac355
--- /dev/null
@@ -0,0 +1,28 @@
+       .section        .text.loseme,"ax",%progbits
+       .globl  loseme
+       .type   loseme,%function
+loseme:
+       .cfi_startproc
+       .cfi_personality 0,__gxx_personality_v0
+       .long 0
+       .cfi_endproc
+       .size loseme, . - loseme
+
+       .section        .text.loseme2,"ax",%progbits
+       .globl  loseme2
+       .type   loseme2,%function
+loseme2:
+       .cfi_startproc
+       .cfi_personality 0,__gxx_personality_v1
+       .long 0
+       .cfi_endproc
+       .size loseme2, . - loseme2
+
+       .section        .text.main,"ax",%progbits
+       .globl  main
+       .type   main, %function
+main:
+       .cfi_startproc
+       .long 0
+       .cfi_endproc
+       .size main, . - main
index 3e77a5a4220ba84c554150e6aa95876d0f09aa3b..e76459185e143f48491a8772cf77daf2cb8799d8 100644 (file)
@@ -1418,7 +1418,7 @@ proc check_gc_sections_available { } {
             || [istarget or32-*-*]
             || [istarget pj*-*-*]
             || [istarget alpha-*-*]
-            || [istarget hppa64-*-*]
+            || [istarget hppa*64-*-*]
             || [istarget i370-*-*]
             || [istarget i860-*-*]
             || [istarget ia64-*-*]
@@ -1439,6 +1439,8 @@ proc check_gc_sections_available { } {
        }
 
        # Check if the ld used by gcc supports --gc-sections.
+       # FIXME: this test is useless since ld --help always says
+       # --gc-sections is available
        set ld_output [remote_exec host $ld "--help"]
        if { [ string first "--gc-sections" $ld_output ] >= 0 } {
            set gc_sections_available_saved 1
@@ -1449,6 +1451,50 @@ proc check_gc_sections_available { } {
     return $gc_sections_available_saved
 }
 
+# Returns true if -shared is supported on the target
+# Only used and accurate for ELF targets at the moment
+
+proc check_shared_lib_support { } {
+    if {![istarget arc-*-*]
+        && ![istarget avr-*-*]
+        && ![istarget cr16-*-*]
+        && ![istarget cris*-*-*]
+        && ![istarget crx-*-*]
+        && ![istarget d10v-*-*]
+        && ![istarget d30v-*-*]
+        && ![istarget dlx-*-*]
+        && ![istarget fr30-*-*]
+        && ![istarget frv-*-*]
+        && ![istarget h8300-*-*]
+        && ![istarget i860-*-*]
+        && ![istarget i960-*-*]
+        && ![istarget ip2k-*-*]
+        && ![istarget iq2000-*-*]
+        && ![istarget lm32-*-*]
+        && ![istarget m32c-*-*]
+        && ![istarget m32r-*-*]
+        && ![istarget m68hc1*-*-*]
+        && ![istarget mcore*-*-*]
+        && ![istarget mep-*-*]
+        && ![istarget microblaze-*-*]
+        && ![istarget mn10200-*-*]
+        && ![istarget moxie-*-*]
+        && ![istarget msp430-*-*]
+        && ![istarget mt-*-*]
+        && ![istarget openrisc-*-*]
+        && ![istarget or32-*-*]
+        && ![istarget pj-*-*]
+        && ![istarget rx-*-*]
+        && ![istarget spu-*-*]
+        && ![istarget v850*-*-*]
+        && ![istarget xstormy16-*-*]
+        && ![istarget *-*-irix*]
+        && ![istarget *-*-rtems] } {
+       return 1
+    }
+    return 0
+}
+
 # Returns true if the target ld supports the plugin API.
 proc check_plugin_api_available { } {
     global plugin_api_available_saved
This page took 0.108393 seconds and 4 git commands to generate.