From 83b89087cf717b455598eee2fb5ddb4d5465a6a0 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 27 Jun 2009 16:07:10 +0000 Subject: bfd/ 2009-06-27 H.J. Lu 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 PR ld/10337 * ld-ifunc/binutils.exp: New. --- bfd/elf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bfd/elf.c') diff --git a/bfd/elf.c b/bfd/elf.c index e377d68..7f74236 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 -- cgit v1.1