Run --gc-sections tests only if supported.
[deliverable/binutils-gdb.git] / bfd / elflink.c
index 25601042401a116cdbdd8975f9f59ee6e9356ba6..5d181f7993c2fe76fdcd03cf19efeac6c2bb8ab5 100644 (file)
@@ -1238,7 +1238,6 @@ _bfd_elf_merge_symbol (bfd *abfd,
        {
          h->def_dynamic = 0;
          h->ref_dynamic = 1;
-         h->dynamic_def = 1;
        }
       /* FIXME: Should we check type and size for protected symbol?  */
       h->size = 0;
@@ -4353,7 +4352,6 @@ error_free_dyn:
                    {
                      h->def_dynamic = 0;
                      h->ref_dynamic = 1;
-                     h->dynamic_def = 1;
                    }
                }
              if (! info->executable
@@ -4366,7 +4364,10 @@ error_free_dyn:
              if (! definition)
                h->ref_dynamic = 1;
              else
-               h->def_dynamic = 1;
+               {
+                 h->def_dynamic = 1;
+                 h->dynamic_def = 1;
+               }
              if (h->def_regular
                  || h->ref_regular
                  || (h->u.weakdef != NULL
@@ -11667,9 +11668,10 @@ _bfd_elf_gc_mark_extra_sections (struct bfd_link_info *info,
        continue;
 
       /* Keep debug and special sections like .comment when they are
-        not part of a group.  */
+        not part of a group, or when we have single-member groups.  */
       for (isec = ibfd->sections; isec != NULL; isec = isec->next)
-       if (elf_next_in_group (isec) == NULL
+       if ((elf_next_in_group (isec) == NULL
+            || elf_next_in_group (isec) == isec)
            && ((isec->flags & SEC_DEBUGGING) != 0
                || (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0))
          isec->gc_mark = 1;
@@ -11689,13 +11691,18 @@ 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))
+  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;
+       (struct elf_gc_sweep_symbol_info *) data;
       (*inf->hide_symbol) (inf->info, h, TRUE);
     }
 
@@ -11909,8 +11916,9 @@ bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf)
              && h->def_regular
              && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
              && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
-             && !bfd_hide_sym_by_version (info->version_info,
-                                          h->root.root.string))))
+             && (strchr (h->root.root.string, ELF_VER_CHR) != NULL
+                 || !bfd_hide_sym_by_version (info->version_info,
+                                              h->root.root.string)))))
     h->root.u.def.section->flags |= SEC_KEEP;
 
   return TRUE;
This page took 0.02414 seconds and 4 git commands to generate.