diff options
Diffstat (limited to 'bfd/elf32-cr16c.c')
-rw-r--r-- | bfd/elf32-cr16c.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/bfd/elf32-cr16c.c b/bfd/elf32-cr16c.c index 2ca0ad3..eb85bd3 100644 --- a/bfd/elf32-cr16c.c +++ b/bfd/elf32-cr16c.c @@ -1,5 +1,5 @@ /* BFD back-end for National Semiconductor's CR16C ELF - Copyright 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -692,26 +692,6 @@ elf32_cr16c_relocate_section (bfd *output_bfd, r_type = ELF32_R_TYPE (rel->r_info); howto = elf_howto_table + r_type; - if (info->relocatable) - { - /* This is a relocatable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ h = NULL; sym = NULL; sec = NULL; @@ -731,6 +711,28 @@ elf32_cr16c_relocate_section (bfd *output_bfd, unresolved_reloc, warned); } + if (sec != NULL && elf_discarded_section (sec)) + { + /* For relocs against symbols from removed linkonce sections, + or sections discarded by a linker script, we just want the + section contents zeroed. Avoid any special processing. */ + _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset); + rel->r_info = 0; + rel->r_addend = 0; + continue; + } + + if (info->relocatable) + { + /* This is a relocatable link. We don't have to change + anything, unless the reloc is against a section symbol, + in which case we have to adjust according to where the + section symbol winds up in the output section. */ + if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION) + rel->r_addend += sec->output_offset; + continue; + } + r = cr16c_elf_final_link_relocate (howto, input_bfd, output_bfd, input_section, contents, rel->r_offset, |