From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28990 invoked by alias); 10 May 2011 22:30:14 -0000 Received: (qmail 28961 invoked by uid 22791); 10 May 2011 22:30:12 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 22:29:57 +0000 Received: from kpbe18.cbf.corp.google.com (kpbe18.cbf.corp.google.com [172.25.105.82]) by smtp-out.google.com with ESMTP id p4AMTuBe026573 for ; Tue, 10 May 2011 15:29:56 -0700 Received: from gxk22 (gxk22.prod.google.com [10.202.11.22]) by kpbe18.cbf.corp.google.com with ESMTP id p4AMTtpx019139 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 10 May 2011 15:29:55 -0700 Received: by gxk22 with SMTP id 22so3060508gxk.2 for ; Tue, 10 May 2011 15:29:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.101.207.30 with SMTP id j30mr5242927anq.86.1305066595168; Tue, 10 May 2011 15:29:55 -0700 (PDT) Received: by 10.100.131.8 with HTTP; Tue, 10 May 2011 15:29:55 -0700 (PDT) In-Reply-To: References: <1265843004.2150.342.camel@dp690-dev5v4> <1267053412.6817.190.camel@dp690-dev5v4> Date: Tue, 10 May 2011 22:30:00 -0000 Message-ID: Subject: Re: [GOLD][PATCH PROPOSAL] prevent discarding of needed local symbols for the relocatable objects From: Cary Coutant To: Ian Lance Taylor Cc: vkutuzov@accesssoftek.com, binutils Content-Type: text/plain; charset=ISO-8859-1 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: 2011-05/txt/msg00126.txt.bz2 I think this part of the patch may have broken -s: @@ -1937,16 +1938,16 @@ Sized_relobj::write_lo st_shndx = out_sections[st_shndx]->out_shndx(); if (st_shndx >= elfcpp::SHN_LORESERVE) { - if (lv.needs_output_symtab_entry() && !strip_all) + if (lv.has_output_symtab_entry()) symtab_xindex->add(lv.output_symtab_index(), st_shndx); - if (lv.needs_output_dynsym_entry()) + if (lv.has_output_dynsym_entry()) dynsym_xindex->add(lv.output_dynsym_index(), st_shndx); st_shndx = elfcpp::SHN_XINDEX; } } // Write the symbol to the output symbol table. - if (!strip_all && lv.needs_output_symtab_entry()) + if (lv.has_output_symtab_entry()) { elfcpp::Sym_write osym(ov); Even with -s, do_finalize_local_symbols() is going to count local symbols and assign them indexes in the symbol table, and lv.has_output_symtab_entry() will return true. write_local_symbols will then try to write out a local symbol table entry, and will fail an assertion here: osym.put_st_name(sympool->get_offset(name)); Interestingly, the assertion at the bottom of the loop will not trigger: if (output_size > 0) { gold_assert(ov - oview == output_size); of->write_output_view(symtab_off + this->local_symbol_offset_, output_size, oview); } because output_local_symbol_count and output_size were set to 0 by the test for the -s option. This patch fixes the problem. Is this OK, or were you thinking that do_finalize_local_symbols() shouldn't even assign the symbol index when -s is set? -cary * object.cc (write_local_symbols): Check for strip_all when writing symbols. Index: object.cc =================================================================== RCS file: /cvs/src/src/gold/object.cc,v retrieving revision 1.138 diff -u -p -r1.138 object.cc --- object.cc 18 Apr 2011 05:39:43 -0000 1.138 +++ object.cc 10 May 2011 22:26:23 -0000 @@ -2302,7 +2302,7 @@ Sized_relobj::write_lo st_shndx = out_sections[st_shndx]->out_shndx(); if (st_shndx >= elfcpp::SHN_LORESERVE) { - if (lv.has_output_symtab_entry()) + if (lv.has_output_symtab_entry() && !strip_all) symtab_xindex->add(lv.output_symtab_index(), st_shndx); if (lv.has_output_dynsym_entry()) dynsym_xindex->add(lv.output_dynsym_index(), st_shndx); @@ -2311,7 +2311,7 @@ Sized_relobj::write_lo } // Write the symbol to the output symbol table. - if (lv.has_output_symtab_entry()) + if (!strip_all && lv.has_output_symtab_entry()) { elfcpp::Sym_write osym(ov);