From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25869 invoked by alias); 4 Jun 2005 19:58:38 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 25859 invoked by uid 22791); 4 Jun 2005 19:58:33 -0000 Received: from sccrmhc14.comcast.net (HELO sccrmhc14.comcast.net) (204.127.202.59) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sat, 04 Jun 2005 19:58:33 +0000 Received: from lucon.org ([24.6.212.230]) by comcast.net (sccrmhc14) with ESMTP id <2005060419583101400dkbv2e>; Sat, 4 Jun 2005 19:58:31 +0000 Received: by lucon.org (Postfix, from userid 1000) id E857464607; Sat, 4 Jun 2005 12:58:30 -0700 (PDT) Date: Sat, 04 Jun 2005 19:58:00 -0000 From: "H. J. Lu" To: binutils@sources.redhat.com Subject: Re: PATCH: PR 992: regression: ld selective1 and selective2 fails, cris-elf Message-ID: <20050604195830.GA8719@lucon.org> References: <20050604063551.GA16809@lucon.org> <20050604134530.GA3137@lucon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050604134530.GA3137@lucon.org> User-Agent: Mutt/1.4.1i X-SW-Source: 2005-06/txt/msg00076.txt.bz2 On Sat, Jun 04, 2005 at 06:45:30AM -0700, H. J. Lu wrote: > On Fri, Jun 03, 2005 at 11:35:51PM -0700, H. J. Lu wrote: > > The updated patch of > > > > http://sourceware.org/ml/binutils/2005-06/msg00030.html > > > > should also fix PR 992. > > > > > > We need to check if the current section isn't abs section before > settig SEC_KEEP. > > We should set SEC_KEEP on current section only if the symbol will be defined. H.J. ---- ld/ 2005-06-04 H.J. Lu * ldexp.c (exp_mark_used_section): Set SEC_KEEP on current section only if the symbol will be defined. ld/testsuite/ 2005-06-04 H.J. Lu * ld-cris/hiddef1.d: Undo the last change. * ld-cris/libdso-10.d: Likewise. * ld-cris/libdso-2.d: Likewise. --- ld/ldexp.c.base 2005-06-04 10:53:29.000000000 -0700 +++ ld/ldexp.c 2005-06-04 12:48:58.000000000 -0700 @@ -1247,24 +1247,33 @@ exp_mark_used_section (etree_type *tree, if (tree->assign.dst[0] != '.' || tree->assign.dst[1] != 0) { etree_value_type result; + bfd_boolean create = tree->type.node_class == etree_assign; + struct bfd_link_hash_entry *h; result = exp_fold_tree_1 (tree->assign.src, current_section, lang_allocating_phase_enum, dot, &dot, TRUE); - if (current_section != bfd_abs_section_ptr) + + /* We mark the current section SEC_KEEP only if the symbol + will be defined. */ + if (!create) + h = bfd_link_hash_lookup (link_info.hash, tree->assign.dst, + create, FALSE, TRUE); + else + h = NULL; + + if ((create || h) + && current_section != bfd_abs_section_ptr) current_section->flags |= SEC_KEEP; + if (result.valid_p) { - bfd_boolean create; - struct bfd_link_hash_entry *h; - if (tree->type.node_class == etree_assign) - create = TRUE; - else - create = FALSE; - h = bfd_link_hash_lookup (link_info.hash, tree->assign.dst, - create, FALSE, TRUE); + if (create) + h = bfd_link_hash_lookup (link_info.hash, + tree->assign.dst, create, + FALSE, TRUE); if (h == NULL) { if (create) --- ld/testsuite/ld-cris/hiddef1.d.base 2005-06-04 12:52:23.000000000 -0700 +++ ld/testsuite/ld-cris/hiddef1.d 2005-06-04 12:48:14.000000000 -0700 @@ -14,7 +14,7 @@ # and sections change, make sure that there's no .plt and that # dsofn is hidden (not exported as a dynamic symbol). -There are 12 section headers, starting at offset 0x[0-9a-f]+: +There are 11 section headers, starting at offset 0x[0-9a-f]+: #... \[[ 0-9]+\] \.got PROGBITS [0-9a-f]+ [0-9a-f]+ 0+10 04 WA 0 0 4 #... @@ -24,5 +24,5 @@ Relocation section '\.rela\.dyn' at offs #... Symbol table '\.dynsym' contains 9 entries: #... -Symbol table '\.symtab' contains 20 entries: +Symbol table '\.symtab' contains 19 entries: #pass --- ld/testsuite/ld-cris/libdso-10.d.base 2005-06-04 12:52:23.000000000 -0700 +++ ld/testsuite/ld-cris/libdso-10.d 2005-06-04 12:48:14.000000000 -0700 @@ -35,7 +35,5 @@ Idx Name Size VMA LM CONTENTS, ALLOC, LOAD, DATA 5 \.got 0+c 0+21e0 0+21e0 0+1e0 2\*\*2 CONTENTS, ALLOC, LOAD, DATA - 6 \.data 0+ 0+21ec 0+21ec 0+1ec 2\*\*0 - CONTENTS, ALLOC, LOAD, DATA - 7 \.bss 0+14 0+21ec 0+21ec 0+1ec 2\*\*0 + 6 \.bss 0+14 0+21ec 0+21ec 0+1ec 2\*\*0 ALLOC --- ld/testsuite/ld-cris/libdso-2.d.base 2005-06-04 12:52:23.000000000 -0700 +++ ld/testsuite/ld-cris/libdso-2.d 2005-06-04 12:48:14.000000000 -0700 @@ -10,7 +10,7 @@ # entries. This formerly SEGV:ed because .rela.got was created # too late to have it mapped to an output section. -There are 15 section headers.* +There are 14 section headers.* #... \[ 1\] \.hash HASH .* \[ 2\] \.dynsym DYNSYM .* @@ -21,11 +21,10 @@ There are 15 section headers.* \[ 7\] \.text PROGBITS .* \[ 8\] \.dynamic DYNAMIC .* \[ 9\] \.got PROGBITS .* - \[10\] \.data PROGBITS .* - \[11\] \.bss NOBITS .* - \[12\] \.shstrtab STRTAB .* - \[13\] \.symtab SYMTAB .* - \[14\] \.strtab STRTAB .* + \[10\] \.bss NOBITS .* + \[11\] \.shstrtab STRTAB .* + \[12\] \.symtab SYMTAB .* + \[13\] \.strtab STRTAB .* #... Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 1 entries: #... @@ -35,12 +34,12 @@ Symbol table '\.dynsym' contains 6 entri Num: Value Size Type Bind Vis Ndx Name 0: 0+ 0 NOTYPE LOCAL DEFAULT UND 1: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 7 - 2: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 10 - 3: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 11 + 2: [0-9a-f]+ 0 NOTYPE LOCAL DEFAULT UND + 3: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 10 4: 0+ 0 OBJECT GLOBAL DEFAULT ABS TST1 5: 0+188 0 FUNC GLOBAL DEFAULT 7 export_1@@TST1 -Symbol table '\.symtab' contains 23 entries: +Symbol table '\.symtab' contains 22 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0+ 0 NOTYPE LOCAL DEFAULT UND 1: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 1 @@ -56,12 +55,11 @@ Symbol table '\.symtab' contains 23 entr 11: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 11 12: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 12 13: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 13 - 14: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 14 - 15: 0+2198 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC - 16: 0+2230 0 NOTYPE LOCAL DEFAULT ABS __bss_start - 17: 0+2230 0 NOTYPE LOCAL DEFAULT ABS _edata - 18: 0+2220 0 OBJECT LOCAL HIDDEN ABS _GLOBAL_OFFSET_TABLE_ - 19: 0+2240 0 NOTYPE LOCAL DEFAULT ABS _end - 20: 0+184 0 FUNC LOCAL DEFAULT 7 dsofn - 21: 0+ 0 OBJECT GLOBAL DEFAULT ABS TST1 - 22: 0+188 0 FUNC GLOBAL DEFAULT 7 export_1 + 14: 0+2198 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC + 15: 0+2230 0 NOTYPE LOCAL DEFAULT ABS __bss_start + 16: 0+2230 0 NOTYPE LOCAL DEFAULT ABS _edata + 17: 0+2220 0 OBJECT LOCAL HIDDEN ABS _GLOBAL_OFFSET_TABLE_ + 18: 0+2240 0 NOTYPE LOCAL DEFAULT ABS _end + 19: 0+184 0 FUNC LOCAL DEFAULT 7 dsofn + 20: 0+ 0 OBJECT GLOBAL DEFAULT ABS TST1 + 21: 0+188 0 FUNC GLOBAL DEFAULT 7 export_1