PR ld/13177
[deliverable/binutils-gdb.git] / bfd / elflink.c
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;
This page took 0.025553 seconds and 4 git commands to generate.