From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30252 invoked by alias); 27 Feb 2014 23:07:39 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 30238 invoked by uid 89); 27 Feb 2014 23:07:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ie0-f182.google.com Received: from mail-ie0-f182.google.com (HELO mail-ie0-f182.google.com) (209.85.223.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 27 Feb 2014 23:07:37 +0000 Received: by mail-ie0-f182.google.com with SMTP id tp5so2760829ieb.27 for ; Thu, 27 Feb 2014 15:07:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=yj7LLeCQIY7JFZMeV7VZ+u5+o5v3JQfBXvn0ws/E3uA=; b=Z+RZb11ugEeUBHb4veyFW+94kQRE3UIks1qD1v0aSl9+qdsgGLmi6fl+V2uwoVVwUa 8ws4eO/A74l+MuIVSvJONPlSyC0sDqH5xmqTNOCmPdfrgjuoLQEWh3BBpbVB8ht4agV1 0jZ504C5ztapMjicjODMR7wpWTyNOP36OiIOe51ysts/jcR22xu7JT1CGsE+qtD+gUqd o5h5luM8AaZRltCYSB9IMw6cWAIiGH7mRbPsyt7b15ny6rWWAlrz6NRmTPMsJNThftBW FwjNAh20+aflHHZqM+Vygt+PU9k2JWfXZyq5W/4qGOskmTg68MssabSrh04q1IKb98LZ v61Q== X-Gm-Message-State: ALoCoQm5fLrs7Yo2kzr7e85GpTKojCfgxWuEqPRZDdXNgGSln1HH6VZ+KyFq0gjGzxRlhXIuw2eMrHKZj9OBgElRwqY7xoUBogAs2idyUOlhNdUu9GSI+Kd+oUL3HBNZqfW4DhfTKuY3nkTpLTH3NaGOCAbSFKS90i4Ssd9+r+2dzae+Jer25KkrU1Hx/EcbPCNSYhOr2NgLx+pGShNgoryMUWxG0SIQng== X-Received: by 10.42.40.83 with SMTP id k19mr7977505ice.3.1393542455265; Thu, 27 Feb 2014 15:07:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.240.3 with HTTP; Thu, 27 Feb 2014 15:07:15 -0800 (PST) From: Roland McGrath Date: Thu, 27 Feb 2014 23:07:00 -0000 Message-ID: Subject: PR ld/16643: ARM: BFD_ASSERT when only ref to a GC'd symbol is in a stripped section To: "binutils@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2014-02/txt/msg00171.txt.bz2 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 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