From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27070 invoked by alias); 11 Feb 2010 02:14:41 -0000 Received: (qmail 27060 invoked by uid 22791); 11 Feb 2010 02:14:39 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Feb 2010 02:14:35 +0000 Received: from spaceape11.eur.corp.google.com (spaceape11.eur.corp.google.com [172.28.16.145]) by smtp-out.google.com with ESMTP id o1B2EW61004159 for ; Thu, 11 Feb 2010 02:14:32 GMT Received: from qyk2 (qyk2.prod.google.com [10.241.83.130]) by spaceape11.eur.corp.google.com with ESMTP id o1B2EUOj009316 for ; Wed, 10 Feb 2010 18:14:31 -0800 Received: by qyk2 with SMTP id 2so477098qyk.20 for ; Wed, 10 Feb 2010 18:14:30 -0800 (PST) Received: by 10.224.79.10 with SMTP id n10mr611198qak.315.1265854470660; Wed, 10 Feb 2010 18:14:30 -0800 (PST) Received: from coign.google.com ([67.218.110.41]) by mx.google.com with ESMTPS id 22sm1191391qyk.14.2010.02.10.18.14.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Feb 2010 18:14:29 -0800 (PST) To: vkutuzov@accesssoftek.com Cc: binutils Subject: Re: {GOLD][PATCH PROPOSAL] prevent discarding of needed local symbols for the relocatable objects References: <1265843004.2150.342.camel@dp690-dev5v4> From: Ian Lance Taylor Date: Thu, 11 Feb 2010 02:14:00 -0000 In-Reply-To: <1265843004.2150.342.camel@dp690-dev5v4> (Viktor Kutuzov's message of "Wed\, 10 Feb 2010 15\:03\:24 -0800") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-System-Of-Record: true 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/msg00227.txt.bz2 Viktor Kutuzov writes: > 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. Thanks, but this patch doesn't work. It fails the testsuite. The problem is that at the time your patch checks needs_output_symtab_entry, it will always return true. needs_output_symtab_entry will only return false if set_no_output_symtab_entry has been called, and that only happens at the end of the loop you patched. I think what we need to do here is mark the local symbol as appropriate in scan_relocatable_relocs. The use of the output_symtab_index_ field right now is a bit complicated. It is initialized to 0. In Sized_relobj::do_count_local_symbols we set the field to -1 if the symbol is not needed. In Sized_relobj::do_finalize_local_symbols, if the field is still 0, we set it to the index in the output file. Perhaps we should change that 0 == uninitialized, -1 == no index, -2 == needs index. Then do_finalize_local_symbols should never see 0. Ian