From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36365 invoked by alias); 14 May 2015 02:50:16 -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 36354 invoked by uid 89); 14 May 2015 02:50:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-la0-f46.google.com Received: from mail-la0-f46.google.com (HELO mail-la0-f46.google.com) (209.85.215.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 14 May 2015 02:50:14 +0000 Received: by layy10 with SMTP id y10so48862070lay.0 for ; Wed, 13 May 2015 19:50:10 -0700 (PDT) X-Received: by 10.112.156.97 with SMTP id wd1mr1359587lbb.30.1431571810510; Wed, 13 May 2015 19:50:10 -0700 (PDT) Received: from octofox.metropolis ([5.19.183.212]) by mx.google.com with ESMTPSA id at2sm5646485lbc.12.2015.05.13.19.50.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 May 2015 19:50:09 -0700 (PDT) From: Max Filippov To: binutils@sourceware.org Cc: Sterling Augustine , David Weatherford , Marc Gauthier , linux-xtensa@linux-xtensa.org, Max Filippov Subject: [PATCH] xtensa: fix localized symbol refcounting with --gc-sections Date: Thu, 14 May 2015 02:50:00 -0000 Message-Id: <1431571796-27930-1-git-send-email-jcmvbkbc@gmail.com> X-IsSubscribed: yes X-SW-Source: 2015-05/txt/msg00123.txt.bz2 elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were made local, that results in link failure with the following message: BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line 3372 in elf_xtensa_finish_dynamic_sections elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by relocation type. Relocation types are not changed when symbol becomes local, but its PLT references are added to GOT references and plt.refcount is set to 0. Such symbol cannot be unreferences in the elf_xtensa_gc_sweep_hook and its extra references make calculated GOT relocations section size not match number of GOT relocations. Fix it by treating PLT reference as GOT reference when plt.refcount is not positive. 2015-05-14 Max Filippov bfd/ * elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference as GOT reference when plt.refcount is not positive. --- bfd/elf32-xtensa.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 53af1c6..2523670 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -1360,10 +1360,14 @@ elf_xtensa_gc_sweep_hook (bfd *abfd, { if (is_plt) { + /* If the symbol has been localized its plt.refcount got moved + to got.refcount. Handle it as GOT. */ if (h->plt.refcount > 0) h->plt.refcount--; + else + is_got = TRUE; } - else if (is_got) + if (is_got) { if (h->got.refcount > 0) h->got.refcount--; -- 1.8.1.4