summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2009-06-27 16:07:06 +0000
committerH.J. Lu <hjl@lucon.org>2009-06-27 16:07:06 +0000
commita916c09fae5e53a420f4819a7cd400a62dcc5aef (patch)
treedbf9feab2af85d775fc20982d29039a06d74c2c1
parentf92e90deab7715f37f990d2c0e8dd770bbd972de (diff)
downloadgdb-a916c09fae5e53a420f4819a7cd400a62dcc5aef.tar.gz
bfd/
2009-06-27 H.J. Lu <hongjiu.lu@intel.com> PR ld/10337 * elf.c (bfd_section_from_shdr): Don't change sh_link for SHT_REL/SHT_RELA sections on executable nor shared library. Treat SHT_REL/SHT_RELA sections with sh_link set to SHN_UNDEF as a normal section. ld/testsuite/ 2009-06-27 H.J. Lu <hongjiu.lu@intel.com> PR ld/10337 * ld-ifunc/binutils.exp: New.
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elf.c11
2 files changed, 16 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 017a740d560..8708dc95ca8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-27 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/10337
+ * elf.c (bfd_section_from_shdr): Don't change sh_link for
+ SHT_REL/SHT_RELA sections on executable nor shared library.
+ Treat SHT_REL/SHT_RELA sections with sh_link set to SHN_UNDEF
+ as a normal section.
+
2009-06-25 Nick Clifton <nickc@redhat.com>
* elf-m10300.c (mn10300_elf_relax_section): Handle non-section
diff --git a/bfd/elf.c b/bfd/elf.c
index e377d68fa46..7f74236302c 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1728,8 +1728,11 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
reject them, but, unfortunately, some people need to use
them. We scan through the section headers; if we find only
one suitable symbol table, we clobber the sh_link to point
- to it. I hope this doesn't break anything. */
- if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_SYMTAB
+ to it. I hope this doesn't break anything.
+
+ Don't do it on executable nor shared library. */
+ if ((abfd->flags & (DYNAMIC | EXEC_P)) == 0
+ && elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_SYMTAB
&& elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_DYNSYM)
{
unsigned int scan;
@@ -1764,8 +1767,10 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
represent such a section, so at least for now, we don't
try. We just present it as a normal section. We also
can't use it as a reloc section if it points to the null
- section, an invalid section, or another reloc section. */
+ section, an invalid section, another reloc section, or its
+ sh_link points to the null section. */
if (hdr->sh_link != elf_onesymtab (abfd)
+ || hdr->sh_link == SHN_UNDEF
|| hdr->sh_info == SHN_UNDEF
|| hdr->sh_info >= num_sec
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL