X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=bfd%2Felf32-arc.c;h=4d9d6b999285e0ded9601b265e098a88c07c4de6;hb=abebb03c3af215d7542f5e6b71d78823b15220d5;hp=91537efd8410dde9bc51b0e9071323f4c7a93026;hpb=fd3619828e94a24a92cddec42cbc0ab33352eeb4;p=binutils-gdb.git diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index 91537efd841..4d9d6b99928 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -1,5 +1,5 @@ /* ARC-specific support for 32-bit ELF - Copyright (C) 1994-2019 Free Software Foundation, Inc. + Copyright (C) 1994-2020 Free Software Foundation, Inc. Contributed by Cupertino Miranda (cmiranda@synopsys.com). This file is part of BFD, the Binary File Descriptor library. @@ -184,9 +184,6 @@ struct elf_arc_link_hash_entry { struct elf_link_hash_entry root; - /* Track dynamic relocs copied for this symbol. */ - struct elf_dyn_relocs *dyn_relocs; - struct got_entry *got_ents; }; @@ -340,7 +337,6 @@ elf_arc_link_hash_newfunc (struct bfd_hash_entry *entry, table, string)); if (ret != NULL) { - ret->dyn_relocs = NULL; ret->got_ents = NULL; } @@ -1255,11 +1251,11 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data, else \ ARC_DEBUG ("symbol_section->vma = NULL\n"); \ if (input_section->output_section != NULL) \ - ARC_DEBUG ("symbol_section->vma = %#lx\n", \ + ARC_DEBUG ("input_section->vma = %#lx\n", \ input_section->output_section->vma \ + input_section->output_offset); \ else \ - ARC_DEBUG ("symbol_section->vma = NULL\n"); \ + ARC_DEBUG ("input_section->vma = NULL\n"); \ ARC_DEBUG ("PCL = %#lx\n", P); \ ARC_DEBUG ("P = %#lx\n", P); \ ARC_DEBUG ("G = %#lx\n", G); \ @@ -1786,6 +1782,7 @@ elf_arc_relocate_section (bfd * output_bfd, case R_ARC_PC32: case R_ARC_32_PCREL: if (bfd_link_pic (info) + && (input_section->flags & SEC_ALLOC) != 0 && (!IS_ARC_PCREL_TYPE (r_type) || (h != NULL && h->dynindx != -1 @@ -2710,7 +2707,6 @@ elf_arc_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, bfd *dynobj; asection *s; bfd_boolean relocs_exist = FALSE; - bfd_boolean reltext_exist = FALSE; struct elf_link_hash_table *htab = elf_hash_table (info); dynobj = htab->dynobj; @@ -2765,29 +2761,7 @@ elf_arc_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, else if (strncmp (s->name, ".rela", 5) == 0) { if (s->size != 0 && s != htab->srelplt) - { - if (!reltext_exist) - { - const char *name = s->name + 5; - bfd *ibfd; - for (ibfd = info->input_bfds; ibfd; ibfd = ibfd->link.next) - if (bfd_get_flavour (ibfd) == bfd_target_elf_flavour - && ibfd->flags & DYNAMIC) - { - asection *target = bfd_get_section_by_name (ibfd, name); - if (target != NULL - && elf_section_data (target)->sreloc == s - && ((target->output_section->flags - & (SEC_READONLY | SEC_ALLOC)) - == (SEC_READONLY | SEC_ALLOC))) - { - reltext_exist = TRUE; - break; - } - } - } - relocs_exist = TRUE; - } + relocs_exist = TRUE; /* We use the reloc_count field as a counter if we need to copy relocs into the output file. */ @@ -2814,33 +2788,7 @@ elf_arc_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, return FALSE; } - if (htab->dynamic_sections_created) - { - /* TODO: Check if this is needed. */ - if (!bfd_link_pic (info)) - if (!_bfd_elf_add_dynamic_entry (info, DT_DEBUG, 0)) - return FALSE; - - if (htab->splt && (htab->splt->flags & SEC_EXCLUDE) == 0) - if (!_bfd_elf_add_dynamic_entry (info, DT_PLTGOT, 0) - || !_bfd_elf_add_dynamic_entry (info, DT_PLTRELSZ, 0) - || !_bfd_elf_add_dynamic_entry (info, DT_PLTREL, DT_RELA) - || !_bfd_elf_add_dynamic_entry (info, DT_JMPREL, 0)) - return FALSE; - - if (relocs_exist) - if (!_bfd_elf_add_dynamic_entry (info, DT_RELA, 0) - || !_bfd_elf_add_dynamic_entry (info, DT_RELASZ, 0) - || !_bfd_elf_add_dynamic_entry (info, DT_RELAENT, - sizeof (Elf32_External_Rela))) - return FALSE; - - if (reltext_exist) - if (!_bfd_elf_add_dynamic_entry (info, DT_TEXTREL, 0)) - return FALSE; - } - - return TRUE; + return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs_exist); } @@ -3128,21 +3076,17 @@ arc_elf_relax_section (bfd *abfd, asection *sec, elf_section_data (sec)->this_hdr.contents = contents; } - if (internal_relocs != NULL - && elf_section_data (sec)->relocs != internal_relocs) + if (elf_section_data (sec)->relocs != internal_relocs) free (internal_relocs); return TRUE; error_return: - if (isymbuf != NULL - && symtab_hdr->contents != (unsigned char *) isymbuf) + if (symtab_hdr->contents != (unsigned char *) isymbuf) free (isymbuf); - if (contents != NULL - && elf_section_data (sec)->this_hdr.contents != contents) + if (elf_section_data (sec)->this_hdr.contents != contents) free (contents); - if (internal_relocs != NULL - && elf_section_data (sec)->relocs != internal_relocs) + if (elf_section_data (sec)->relocs != internal_relocs) free (internal_relocs); return FALSE;