From 56f8a310d8a139944242373690497d0bd9b9696e Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 3 Jun 2005 04:00:18 +0000 Subject: PR 568 * elf32-i386.c (elf_i386_relocate_section): Handle zero symndx for all reloc types. Apply from mainline: 2005-05-12 H.J. Lu * elf32-i386.c (elf_i386_relocate_section): Allow R_386_GOTOFF against protected function when building executable. --- bfd/ChangeLog | 13 ++++++++++++- bfd/elf32-i386.c | 31 ++++++++++++++++--------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bd81db1f8a5..24b318f65d5 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,4 +1,15 @@ -2005-06-02 Alan Modra +2005-06-03 Alan Modra + + PR 568 + * elf32-i386.c (elf_i386_relocate_section): Handle zero symndx + for all reloc types. + + Apply from mainline: + 2005-05-12 H.J. Lu + * elf32-i386.c (elf_i386_relocate_section): Allow R_386_GOTOFF + against protected function when building executable. + +2005-06-03 Alan Modra * elf64-ppc.c (add_symbol_adjust): Set sym visibility to most restrictive of func code and func descr for undefined syms as well diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 9bab9be1244..66b94932774 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2177,6 +2177,21 @@ elf_i386_relocate_section (bfd *output_bfd, unresolved_reloc, warned); } + if (r_symndx == 0) + { + /* r_symndx will be zero only for relocs against symbols from + removed linkonce sections, or sections discarded by a linker + script. For these relocs, we just want the section contents + zeroed. Avoid any special processing in the switch below. */ + r_type = R_386_NONE; + + relocation = 0; + if (howto->pc_relative) + relocation = (input_section->output_section->vma + + input_section->output_offset + + rel->r_offset); + } + switch (r_type) { case R_386_GOT32: @@ -2278,6 +2293,7 @@ elf_i386_relocate_section (bfd *output_bfd, for shared library since it may not be local when used as function address. */ if (info->shared + && !info->executable && h && h->def_regular && h->type == STT_FUNC @@ -2332,21 +2348,6 @@ elf_i386_relocate_section (bfd *output_bfd, case R_386_32: case R_386_PC32: - /* r_symndx will be zero only for relocs against symbols - from removed linkonce sections, or sections discarded by - a linker script. */ - if (r_symndx == 0) - { - /* Zero the section contents. eh_frame generated by old - versions of gcc isn't edited by elf-eh-frame.c, so - FDEs for discarded linkonce functions might remain. - Putting zeros here will zero such FDE's address range. - This is a hint to unwinders and other consumers of - exception handling info that the FDE is invalid. */ - bfd_put_32 (input_bfd, 0, contents + rel->r_offset); - break; - } - if ((input_section->flags & SEC_ALLOC) == 0) break; -- cgit v1.2.1