From: Catherine Moore <clm@codesourcery.com>
To: binutils@sourceware.org
Cc: Catherine Moore <clm@codesourcery.com>
Subject: [Patch] Prevent cloned symbols from being assigned to the wrong section
Date: Tue, 11 Dec 2007 01:14:00 -0000 [thread overview]
Message-ID: <475DE46C.8060700@codesourcery.com> (raw)
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
next reply other threads:[~2007-12-11 1:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-11 1:14 Catherine Moore [this message]
2007-12-11 1:32 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=475DE46C.8060700@codesourcery.com \
--to=clm@codesourcery.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).