public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: PR ld/13177: garbage collector retains zombie references to external libraries
@ 2011-09-14 19:14 H.J. Lu
  2011-09-15  0:25 ` Alan Modra
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: H.J. Lu @ 2011-09-14 19:14 UTC (permalink / raw)
  To: binutils

Hi,

We shoul also remove symbols without PLT nor GOT references from dynamic
symbol table.  OK to install?

Thanks.


H.J.
---
bfd/

2011-09-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13177
	* elflink.c (elf_gc_sweep_symbol): Also hide symbols without PLT
	nor GOT references.

ld/testsuite/

2011-09-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13177
	* ld-elf/pr13177.d: New.
	* ld-elf/pr13177.s: Likewise.

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 528f705..5a703b3 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11694,13 +11694,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);
     }
 
diff --git a/ld/testsuite/ld-elf/pr13177.d b/ld/testsuite/ld-elf/pr13177.d
new file mode 100644
index 0000000..425a239
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr13177.d
@@ -0,0 +1,11 @@
+#source: pr13177.s
+#ld: --gc-sections -shared
+#readelf: -s -D --wide
+#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-*
+#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-*
+# generic linker targets don't support --gc-sections, nor do a bunch of others
+
+#failif
+#...
+.*: 0+0 +0 +NOTYPE +GLOBAL +DEFAULT +UND bar
+#...
diff --git a/ld/testsuite/ld-elf/pr13177.s b/ld/testsuite/ld-elf/pr13177.s
new file mode 100644
index 0000000..25232ba
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr13177.s
@@ -0,0 +1,9 @@
+	.section .text.foo,"ax",%progbits
+	.globl	foo
+	.type	foo, %function
+foo:
+	.byte 0
+	.section .text.opt_out,"ax",%progbits
+	.type	opt_out, %function
+opt_out:
+	.dc.a bar

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-10-19  7:20 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-14 19:14 PATCH: PR ld/13177: garbage collector retains zombie references to external libraries H.J. Lu
2011-09-15  0:25 ` Alan Modra
2011-09-15  0:47   ` H.J. Lu
2011-09-16  0:52     ` Alan Modra
2011-10-17  7:29       ` Alan Modra
2011-10-17 13:50         ` Alan Modra
2011-10-17 17:21         ` H.J. Lu
2011-10-17 22:59           ` Alan Modra
2011-10-18 19:08             ` H.J. Lu
2011-10-19  7:20               ` Alan Modra
2011-09-16  6:21 ` Regressions with "PATCH: PR ld/13177: garbage collector retains zombie references to external libraries" Hans-Peter Nilsson
2011-09-16 14:45   ` H.J. Lu
2011-09-16 16:08     ` H.J. Lu
2011-09-16 17:13       ` Hans-Peter Nilsson
2011-09-16 16:24   ` H.J. Lu
2011-10-14  7:01     ` Fix for cris-* regressions with "PATCH: PR ld/13177" Hans-Peter Nilsson
2011-10-14  8:07       ` Tristan Gingold
2011-09-28 18:32 ` Regression: --gc-sections: local symbol `_dl_argv@@GLIBC_PRIVATE' in ld.so is referenced by DSO (PR ld/13232) [Re: PATCH: PR ld/13177: garbage collector retains zombie references to external libraries] Jan Kratochvil
2011-09-28 18:46   ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).