public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PR ld/16643: ARM: BFD_ASSERT when only ref to a GC'd symbol is in a stripped section
@ 2014-02-27 23:07 Roland McGrath
  2014-02-28  0:25 ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: Roland McGrath @ 2014-02-27 23:07 UTC (permalink / raw)
  To: binutils

Below is a patch that adds a test case for bug 16643, which I've just
filed.  I don't have a fix.  I'm seeking advice on what the proper fix
might be.

The case is under --gc-sections --strip-all.  My test is doing -shared
mostly just because that's what the original case was doing, but it
actually doesn't matter whether it's -shared or a normal final link.

The situation is that there is a symbol, defined in a section that will be
GC'd, whose only reference is in a non-GC'd but non-allocated section that
will be stripped.  (In the real case, it was in .debug_info as part of the
real DWARF data.)  It hits this assert:
	  /* If PLT refcount book-keeping is wrong and too low, we'll
	     see a zero value (going to -1) for the root PLT reference
	     count.  */
	  if (root_plt->refcount >= 0)
	    {
	      BFD_ASSERT (root_plt->refcount != 0);
	      root_plt->refcount -= 1;
	    }
(elf32-arm.c:12445 in today's trunk).  This hits in the call to
elf32_arm_gc_sweep_hook for the input .debug_blah section (the
non-allocated section containing a reference to the symbol), which will be
stripped from the output.  Without --strip-all, the assert does not hit.

I haven't had much luck trying to figure out where the PLT refcount is
supposed to be maintained in general.  Apparently, something about
--strip-all mode affects how this bookkeeping gets done.  Can anyone point
me to where the actual bug here might be?


Thanks,
Roland


ld/testsuite/
2014-02-27  Roland McGrath  <mcgrathr@google.com>

	PR ld/16643
	* ld-arm/gc-hidden-strip.d: New file.
	* ld-arm/gc-hidden-strip-unused.s: New file.
	* ld-arm/gc-hidden-strip-main.s: New file.
	* ld-arm/arm-elf.exp: Run the new test.

--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -842,3 +842,4 @@ if { ![istarget "arm*-*-nacl*"] } {
 }
 run_dump_test "unresolved-2"
 run_dump_test "gc-hidden-1"
+run_dump_test "gc-hidden-strip"
--- /dev/null
+++ b/ld/testsuite/ld-arm/gc-hidden-strip-main.s
@@ -0,0 +1,6 @@
+	.text
+	.globl foo
+	.type foo, %function
+foo:
+	bx lr
+	.size foo, . - foo
--- /dev/null
+++ b/ld/testsuite/ld-arm/gc-hidden-strip-unused.s
@@ -0,0 +1,11 @@
+	.section .data.unused_item,"aw",%progbits
+	.p2align 2
+	.global unused_item
+	.hidden	unused_item
+	.type unused_item, %object
+	.size unused_item, 4
+unused_item:
+	.word 1
+
+	.section .debug_blah,"",%progbits
+	.word unused_item
--- /dev/null
+++ b/ld/testsuite/ld-arm/gc-hidden-strip.d
@@ -0,0 +1,15 @@
+#source: gc-hidden-strip-main.s
+#source: gc-hidden-strip-unused.s
+#ld: --gc-sections --shared --strip-all
+#objdump: -RT
+# This test is only valid on ELF based ports.
+# not-target: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix*
+
+# See PR ld/16643: the only reference to a GC'd symbol is in a stripped
+# section, trigging a BFD_ASSERT.
+
+.*:     file format elf32-.*
+
+DYNAMIC SYMBOL TABLE:
+0+[0-9a-f]+ l\s+d\s+\.text\s+0+\s+\.text
+#pass

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

end of thread, other threads:[~2014-03-06 17:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-27 23:07 PR ld/16643: ARM: BFD_ASSERT when only ref to a GC'd symbol is in a stripped section Roland McGrath
2014-02-28  0:25 ` Alan Modra
2014-02-28 17:44   ` Roland McGrath
2014-03-05 18:07     ` Roland McGrath
2014-03-06  8:18       ` Tristan Gingold
2014-03-06 17:54         ` Roland McGrath
2014-03-06  8:55       ` Nicholas Clifton
2014-03-06 17:50         ` Roland McGrath

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).