From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30009 invoked by alias); 11 Dec 2007 01:14:47 -0000 Received: (qmail 30000 invoked by uid 22791); 11 Dec 2007 01:14:46 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 11 Dec 2007 01:14:42 +0000 Received: (qmail 5748 invoked from network); 11 Dec 2007 01:14:40 -0000 Received: from unknown (HELO ?192.168.89.128?) (clm@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Dec 2007 01:14:40 -0000 Message-ID: <475DE46C.8060700@codesourcery.com> Date: Tue, 11 Dec 2007 01:14:00 -0000 From: Catherine Moore User-Agent: Thunderbird 2.0.0.6 (X11/20071022) MIME-Version: 1.0 To: binutils@sourceware.org CC: Catherine Moore Subject: [Patch] Prevent cloned symbols from being assigned to the wrong section Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 2007-12/txt/msg00054.txt.bz2 This patch fixes a problem that was showing up when the directive .set was used to redefine a symbol. The symbol was being placed in the symbol table instead of the absolute section. This eventually caused problems when the executable was stripped. The solution is to prevent the copying of the shndx in elf_copy_private_symbol_data if the shndx is undefined. Okay to commit? Thanks, Catherine bfd/ChangeLog: * elf.c (_bfd_elf_copy_private_symbol_data): Don't copy shndx if the symbol's section is the undefined section. gas/testsuite/ChangeLog: elf/symtab.s: New test. elf/symtab.d: New expected output. elf/elf.exp: Run the new symbtab test. Index: bfd/elf.c =================================================================== RCS file: /cvs/src/src/bfd/elf.c,v retrieving revision 1.425 diff -p -r1.425 elf.c *** bfd/elf.c 10 Dec 2007 23:44:23 -0000 1.425 --- bfd/elf.c 11 Dec 2007 00:12:55 -0000 *************** _bfd_elf_copy_private_symbol_data (bfd * *** 6046,6051 **** --- 6046,6052 ---- osym = elf_symbol_from (obfd, osymarg); if (isym != NULL + && isym->internal_elf_sym.st_shndx != 0 && osym != NULL && bfd_is_abs_section (isym->symbol.section)) { Index: gas/testsuite/gas/elf/elf.exp =================================================================== RCS file: /cvs/src/src/gas/testsuite/gas/elf/elf.exp,v retrieving revision 1.45 diff -p -r1.45 elf.exp *** gas/testsuite/gas/elf/elf.exp 30 Nov 2007 23:47:55 -0000 1.45 --- gas/testsuite/gas/elf/elf.exp 11 Dec 2007 00:12:55 -0000 *************** if { ([istarget "*-*-*elf*"] *** 109,114 **** --- 109,115 ---- run_dump_test "section4" run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\"" run_dump_test "struct" + run_dump_test "symtab" run_dump_test "symver" run_elf_list_test "type" "" "" "-s" "| grep \"1 \\\[FONTC\\\]\"" run_dump_test "section6" Index: gas/testsuite/gas/elf/symtab.d =================================================================== RCS file: gas/testsuite/gas/elf/symtab.d diff -N gas/testsuite/gas/elf/symtab.d *** /dev/null 1 Jan 1970 00:00:00 -0000 --- gas/testsuite/gas/elf/symtab.d 11 Dec 2007 00:12:55 -0000 *************** *** 0 **** --- 1,6 ---- + #readelf: -s + #name: .set with expression + + #... + .*ABS.*shift.* + #pass Index: gas/testsuite/gas/elf/symtab.s =================================================================== RCS file: gas/testsuite/gas/elf/symtab.s diff -N gas/testsuite/gas/elf/symtab.s *** /dev/null 1 Jan 1970 00:00:00 -0000 --- gas/testsuite/gas/elf/symtab.s 11 Dec 2007 00:12:55 -0000 *************** *** 0 **** --- 1,5 ---- + .text + .global foo + foo: + .set shift, 32 + .set shift, shift - 1