X-Git-Url: http://drtracing.org/?a=blobdiff_plain;ds=sidebyside;f=bfd%2Felf32-m32r.c;h=edd04b91d9d771472c2cd05368bb1f5b0063ebae;hb=39aa149769fd05fb6fade43bd41c1d7b6d63d06b;hp=2801f0443acce9f3b53c99b52207199f5135bbcc;hpb=2dcf00ce6c001c42c89e6f6baace708b706994f2;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 2801f0443a..edd04b91d9 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1,5 +1,5 @@ /* M32R-specific support for 32-bit ELF. - Copyright (C) 1996-2018 Free Software Foundation, Inc. + Copyright (C) 1996-2019 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -1272,7 +1272,7 @@ bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an M32R ELF reloc. */ -static void +static bfd_boolean m32r_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) @@ -1283,21 +1283,34 @@ m32r_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, if (r_type > (unsigned int) R_M32R_GNU_VTENTRY) { /* xgettext:c-format */ - _bfd_error_handler (_("%pB: invalid M32R reloc number: %d"), abfd, r_type); - r_type = 0; + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &m32r_elf_howto_table[r_type]; + return TRUE; } -static void +static bfd_boolean m32r_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) { - BFD_ASSERT ((ELF32_R_TYPE(dst->r_info) == (unsigned int) R_M32R_NONE) - || ((ELF32_R_TYPE(dst->r_info) > (unsigned int) R_M32R_GNU_VTENTRY) - && (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_M32R_max))); - cache_ptr->howto = &m32r_elf_howto_table[ELF32_R_TYPE(dst->r_info)]; + unsigned int r_type = ELF32_R_TYPE (dst->r_info); + + if (r_type == (unsigned int) R_M32R_NONE + || ((r_type > (unsigned int) R_M32R_GNU_VTENTRY) + && (r_type < (unsigned int) R_M32R_max))) + { + cache_ptr->howto = &m32r_elf_howto_table[r_type]; + return TRUE; + } + + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); + bfd_set_error (bfd_error_bad_value); + return FALSE; } @@ -1309,7 +1322,7 @@ _bfd_m32r_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, int *retval) { - if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0) + if (strcmp (bfd_section_name (sec), ".scommon") == 0) { *retval = SHN_M32R_SCOMMON; return TRUE; @@ -1394,7 +1407,7 @@ m32r_elf_add_symbol_hook (bfd *abfd, flags); if (s == NULL) return FALSE; - if (! bfd_set_section_alignment (abfd, s, 2)) + if (!bfd_set_section_alignment (s, 2)) return FALSE; } @@ -1610,7 +1623,7 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags); htab->root.splt = s; if (s == NULL - || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) + || !bfd_set_section_alignment (s, bed->plt_alignment)) return FALSE; if (bed->want_plt_sym) @@ -1641,7 +1654,7 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) flags | SEC_READONLY); htab->root.srelplt = s; if (s == NULL - || ! bfd_set_section_alignment (abfd, s, ptralign)) + || !bfd_set_section_alignment (s, ptralign)) return FALSE; if (htab->root.sgot == NULL @@ -1680,7 +1693,7 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) flags | SEC_READONLY); htab->srelbss = s; if (s == NULL - || ! bfd_set_section_alignment (abfd, s, ptralign)) + || !bfd_set_section_alignment (s, ptralign)) return FALSE; } } @@ -2221,7 +2234,7 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Strip this section if we don't need it; see the comment below. */ } - else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) + else if (CONST_STRNEQ (bfd_section_name (s), ".rela")) { if (s->size != 0 && s != htab->root.srelplt) relocs = TRUE; @@ -2401,7 +2414,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, if (r_type < 0 || r_type >= (int) R_M32R_max) { /* xgettext:c-format */ - _bfd_error_handler (_("%pB: unknown relocation type %d"), + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), input_bfd, (int) r_type); bfd_set_error (bfd_error_bad_value); ret = FALSE; @@ -2941,7 +2954,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, const char *name; BFD_ASSERT (sec != NULL); - name = bfd_get_section_name (sec->owner, sec); + name = bfd_section_name (sec); if ( strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0 @@ -2968,7 +2981,8 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, { _bfd_error_handler /* xgettext:c-format */ - (_("%pB: The target (%s) of an %s relocation is in the wrong section (%pA)"), + (_("%pB: the target (%s) of an %s relocation" + " is in the wrong section (%pA)"), input_bfd, sym_name, m32r_elf_howto_table[(int) r_type].name, @@ -3008,7 +3022,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, name = (bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link, sym->st_name)); if (name == NULL || *name == '\0') - name = bfd_section_name (input_bfd, sec); + name = bfd_section_name (sec); } if (errmsg != NULL) @@ -3389,9 +3403,8 @@ m32r_elf_object_p (bfd *abfd) /* Store the machine number in the flags field. */ -static void -m32r_elf_final_write_processing (bfd *abfd, - bfd_boolean linker ATTRIBUTE_UNUSED) +static bfd_boolean +m32r_elf_final_write_processing (bfd *abfd) { unsigned long val; @@ -3405,6 +3418,7 @@ m32r_elf_final_write_processing (bfd *abfd, elf_elfheader (abfd)->e_flags &=~ EF_M32R_ARCH; elf_elfheader (abfd)->e_flags |= val; + return _bfd_elf_final_write_processing (abfd); } /* Function to keep M32R specific file flags. */ @@ -3470,7 +3484,7 @@ m32r_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) || ((in_flags & EF_M32R_ARCH) == E_M32R2_ARCH)) { _bfd_error_handler - (_("%pB: Instruction set mismatch with previous modules"), ibfd); + (_("%pB: instruction set mismatch with previous modules"), ibfd); bfd_set_error (bfd_error_bad_value); return FALSE; @@ -3793,15 +3807,11 @@ m32r_elf_check_relocs (bfd *abfd, /* This relocation describes which C++ vtable entries are actually used. Record for later use during GC. */ case R_M32R_GNU_VTENTRY: - BFD_ASSERT (h != NULL); - if (h != NULL - && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset)) + if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset)) return FALSE; break; case R_M32R_RELA_GNU_VTENTRY: - BFD_ASSERT (h != NULL); - if (h != NULL - && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) + if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) return FALSE; break; }