From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21879 invoked by alias); 10 Feb 2010 23:03:33 -0000 Received: (qmail 21780 invoked by uid 22791); 10 Feb 2010 23:03:32 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,HK_OBFDOM X-Spam-Check-By: sourceware.org Received: from mail.accesssoftek.com (HELO mail.accesssoftek.com) (63.145.236.71) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Feb 2010 23:03:28 +0000 Received: from [192.168.159.141] (172.16.0.1) by mail.accesssoftek.com (172.16.0.71) with Microsoft SMTP Server (TLS) id 8.2.234.1; Wed, 10 Feb 2010 15:01:09 -0800 Subject: {GOLD][PATCH PROPOSAL] prevent discarding of needed local symbols for the relocatable objects From: Viktor Kutuzov Reply-To: vkutuzov@accesssoftek.com To: Ian Lance Taylor CC: binutils Content-Type: multipart/mixed; boundary="=-CO2FLMdw+O7aDHspl7GC" Date: Wed, 10 Feb 2010 23:03:00 -0000 Message-ID: <1265843004.2150.342.camel@dp690-dev5v4> MIME-Version: 1.0 X-IsSubscribed: yes 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 X-SW-Source: 2010-02/txt/msg00212.txt.bz2 --=-CO2FLMdw+O7aDHspl7GC Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 765 Hi Ian, I'm trying to cross build llvm and llvm-gcc on Linux for ARM by using GOLD as the linker. This has exposed some problems we have in GOLD. One of them related to the assert in the relocate_for_relocatable() method (target-reloc.h, line 557): new_symndx = object->symtab_index(r_sym); gold_assert(new_symndx != -1U); This assert gets triggered when the build links glibc with the -r -X flags (remove local symbols). This happens because with the given -X option GOLD removes all local symbols, including those which still needed to resolve static relocs later. LD keeps that kind of local symbols in the symbol table even if -X requested. I guess GOLD should do the same. Please find attached the patch that fixes this issue. Thank you, Viktor. --=-CO2FLMdw+O7aDHspl7GC Content-Disposition: attachment; filename="binutils-gold-prevent_discard_needed_local_symbols.patch" Content-Type: text/x-patch; name="binutils-gold-prevent_discard_needed_local_symbols.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 881 Index: object.cc =================================================================== RCS file: /cvs/src/src/gold/object.cc,v retrieving revision 1.118 diff -u -p -r1.118 object.cc --- object.cc 15 Jan 2010 01:44:22 -0000 1.118 +++ object.cc 10 Feb 2010 19:26:16 -0000 @@ -1609,9 +1609,13 @@ Sized_relobj::do_count // - the symbol has a name. // // We do not discard a symbol if it needs a dynamic symbol entry. + // Also, if we are generating a relocatable output file, then + // some of the local symbols may be required by relocs; we output them + // below if they are needed. if (discard_locals && sym.get_st_type() != elfcpp::STT_FILE && !lv.needs_output_dynsym_entry() + && !lv.needs_output_symtab_entry() && parameters->target().is_local_label_name(name)) { lv.set_no_output_symtab_entry(); --=-CO2FLMdw+O7aDHspl7GC--