X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-cr16c.c;h=508ed2b4138062af501dc3653a2e44954fbf8f66;hb=5430098f1807e084fe4ff5057040d68435f3d8a2;hp=18d4ade82df691a6f1c0102f3f8e8762183e3283;hpb=aa820537ead0135a7c38c619039dce8a6fc74ed1;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-cr16c.c b/bfd/elf32-cr16c.c index 18d4ade82d..508ed2b413 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, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2004-2017 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -28,14 +28,14 @@ #define USE_REL 1 /* CR16C uses REL relocations instead of RELA. */ -/* The following definition is based on EMPTY_HOWTO macro, +/* The following definition is based on EMPTY_HOWTO macro, but also initiates the "name" field in HOWTO struct. */ #define ONLY_NAME_HOWTO(C) \ HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \ STRINGX(C), FALSE, 0, 0, FALSE) /* reloc_map_index array maps CRASM relocation type into a BFD - relocation enum. The array's indices are synchronized with + relocation enum. The array's indices are synchronized with RINDEX_16C_* indices, created in include/elf/cr16c.h. The array is used in: 1. elf32-cr16c.c : elf_cr16c_reloc_type_lookup(). @@ -180,7 +180,12 @@ elf_cr16c_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, { unsigned int r_type = ELF32_R_TYPE (dst->r_info); - BFD_ASSERT (r_type < (unsigned int) RINDEX_16C_MAX); + if (r_type >= RINDEX_16C_MAX) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%B: invalid CR16C reloc number: %d"), abfd, r_type); + r_type = 0; + } cache_ptr->howto = &elf_howto_table[r_type]; } @@ -204,7 +209,6 @@ cr16c_elf_final_link_relocate (reloc_howto_type *howto, unsigned long format, addr_type, code_factor; unsigned short size; unsigned short r_type; - asymbol *symbol = NULL; unsigned long disp20_opcod; char neg = 0; @@ -224,9 +228,6 @@ cr16c_elf_final_link_relocate (reloc_howto_type *howto, addr_type = r_type & R_ADDRTYPE; code_factor = ((addr_type == R_CODE_ADDR) ? 1 : 0); - if (sym_sec) - symbol = sym_sec->symbol; - switch (format) { case R_NUMBER: @@ -718,26 +719,19 @@ elf32_cr16c_relocate_section (bfd *output_bfd, } else { - bfd_boolean unresolved_reloc, warned; + bfd_boolean unresolved_reloc, warned, ignored; RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, r_symndx, symtab_hdr, sym_hashes, h, sec, relocation, - unresolved_reloc, warned); + unresolved_reloc, warned, ignored); } - 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 (sec != NULL && discarded_section (sec)) + RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, + rel, 1, relend, howto, 0, contents); - if (info->relocatable) + if (bfd_link_relocatable (info)) { /* This is a relocatable link. We don't have to change anything, unless the reloc is against a section symbol, @@ -772,18 +766,14 @@ elf32_cr16c_relocate_section (bfd *output_bfd, switch (r) { case bfd_reloc_overflow: - if (!((*info->callbacks->reloc_overflow) - (info, (h ? &h->root : NULL), name, howto->name, - (bfd_vma) 0, input_bfd, input_section, - rel->r_offset))) - return FALSE; + (*info->callbacks->reloc_overflow) + (info, (h ? &h->root : NULL), name, howto->name, + (bfd_vma) 0, input_bfd, input_section, rel->r_offset); break; case bfd_reloc_undefined: - if (!((*info->callbacks->undefined_symbol) - (info, name, input_bfd, input_section, - rel->r_offset, TRUE))) - return FALSE; + (*info->callbacks->undefined_symbol) + (info, name, input_bfd, input_section, rel->r_offset, TRUE); break; case bfd_reloc_outofrange: @@ -803,10 +793,8 @@ elf32_cr16c_relocate_section (bfd *output_bfd, /* fall through */ common_error: - if (!((*info->callbacks->warning) - (info, msg, name, input_bfd, input_section, - rel->r_offset))) - return FALSE; + (*info->callbacks->warning) (info, msg, name, input_bfd, + input_section, rel->r_offset); break; } } @@ -950,7 +938,7 @@ elf32_cr16c_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED } /* Definitions for setting CR16C target vector. */ -#define TARGET_LITTLE_SYM bfd_elf32_cr16c_vec +#define TARGET_LITTLE_SYM cr16c_elf32_vec #define TARGET_LITTLE_NAME "elf32-cr16c" #define ELF_ARCH bfd_arch_cr16c #define ELF_MACHINE_CODE EM_CR