X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-lm32.c;h=c329af95002c28c81e8652fcdad0e1d7d8afc2ec;hb=9e7028aa1e788d666bad91fb20159da6c95bbab1;hp=07279ed73837354caa6f0d130cec1f1c74760707;hpb=0aa13feeeb78fc9323bee329c4d91c30f25de121;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 07279ed738..c329af9500 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -1,5 +1,5 @@ /* Lattice Mico32-specific support for 32-bit ELF - Copyright (C) 2008-2018 Free Software Foundation, Inc. + Copyright (C) 2008-2020 Free Software Foundation, Inc. Contributed by Jon Beniston This file is part of BFD, the Binary File Descriptor library. @@ -195,8 +195,7 @@ create_rofixup_section (bfd *dynobj, struct bfd_link_info *info) | SEC_LINKER_CREATED | SEC_READONLY)); if (lm32fdpic_fixup32_section (info) == NULL - || ! bfd_set_section_alignment (dynobj, - lm32fdpic_fixup32_section (info), 2)) + || !bfd_set_section_alignment (lm32fdpic_fixup32_section (info), 2)) return FALSE; return TRUE; @@ -525,7 +524,7 @@ lm32_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for an Lattice Mico32 ELF reloc. */ -static void +static bfd_boolean lm32_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) @@ -538,9 +537,11 @@ lm32_info_to_howto_rela (bfd *abfd, /* xgettext:c-format */ _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); - r_type = 0; + bfd_set_error (bfd_error_bad_value); + return FALSE; } cache_ptr->howto = &lm32_elf_howto_table[r_type]; + return TRUE; } /* Set the right machine number for an Lattice Mico32 ELF file. */ @@ -553,8 +554,8 @@ lm32_elf_object_p (bfd *abfd) /* Set machine type flags just before file is written out. */ -static void -lm32_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) +static bfd_boolean +lm32_elf_final_write_processing (bfd *abfd) { elf_elfheader (abfd)->e_machine = EM_LATTICEMICO32; elf_elfheader (abfd)->e_flags &=~ EF_LM32_MACH; @@ -566,6 +567,7 @@ lm32_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) default: abort (); } + return _bfd_elf_final_write_processing (abfd); } /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a @@ -818,7 +820,7 @@ lm32_elf_relocate_section (bfd *output_bfd, relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); name = bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link, sym->st_name); - name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name; + name = name == NULL ? bfd_section_name (sec) : name; } else { @@ -996,7 +998,9 @@ lm32_elf_relocate_section (bfd *output_bfd, /* Addend should be zero. */ if (rel->r_addend != 0) - _bfd_error_handler (_("internal error: addend should be zero for R_LM32_16_GOT")); + _bfd_error_handler + (_("internal error: addend should be zero for %s"), + "R_LM32_16_GOT"); r = _bfd_final_link_relocate (howto, input_bfd, @@ -1031,7 +1035,7 @@ lm32_elf_relocate_section (bfd *output_bfd, if ((!h) || (h && h->root.type != bfd_link_hash_undefweak)) { /* Only create .rofixup entries for relocs in loadable sections. */ - if ((bfd_get_section_flags (output_bfd, input_section->output_section) + if ((bfd_section_flags (input_section->output_section) & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD)) { @@ -1074,7 +1078,8 @@ lm32_elf_relocate_section (bfd *output_bfd, const char *msg = NULL; arelent bfd_reloc; - lm32_info_to_howto_rela (input_bfd, &bfd_reloc, rel); + if (! lm32_info_to_howto_rela (input_bfd, &bfd_reloc, rel)) + continue; howto = bfd_reloc.howto; if (h != NULL) @@ -1084,7 +1089,7 @@ lm32_elf_relocate_section (bfd *output_bfd, 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); } switch (r) @@ -1439,7 +1444,8 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd, FALSE, FALSE, TRUE); if (hend && (hend->type == bfd_link_hash_defined - || hend->type == bfd_link_hash_defweak)) + || hend->type == bfd_link_hash_defweak) + && hend->u.def.section->output_section != NULL) { bfd_vma value = lm32fdpic_fixup32_section (info)->output_section->vma @@ -2113,7 +2119,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd, /* 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; @@ -2248,7 +2254,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd, /* Don't generate entries for weak symbols. */ if (!h || (h && h->root.type != bfd_link_hash_undefweak)) { - if (!discarded_section (s) && !((bfd_get_section_flags (ibfd, s) & SEC_ALLOC) == 0)) + if (!discarded_section (s) && !((bfd_section_flags (s) & SEC_ALLOC) == 0)) { switch (ELF32_R_TYPE (internal_relocs->r_info)) { @@ -2270,7 +2276,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd, if (!strcmp (current->name, h->root.root.string)) break; } - if (!current && !discarded_section (s) && (bfd_get_section_flags (ibfd, s) & SEC_ALLOC)) + if (!current && !discarded_section (s) && (bfd_section_flags (s) & SEC_ALLOC)) { /* Will this have an entry in the GOT. */ if (ELF32_R_TYPE (internal_relocs->r_info) == R_LM32_16_GOT) @@ -2370,7 +2376,7 @@ lm32_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) @@ -2401,7 +2407,7 @@ lm32_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 @@ -2440,7 +2446,7 @@ lm32_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; } } @@ -2566,7 +2572,7 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd) #define bfd_elf32_bfd_reloc_type_lookup lm32_reloc_type_lookup #define bfd_elf32_bfd_reloc_name_lookup lm32_reloc_name_lookup #define elf_info_to_howto lm32_info_to_howto_rela -#define elf_info_to_howto_rel 0 +#define elf_info_to_howto_rel NULL #define elf_backend_rela_normal 1 #define elf_backend_object_p lm32_elf_object_p #define elf_backend_final_write_processing lm32_elf_final_write_processing