/* SuperH SH64-specific support for 64-bit ELF
- Copyright (C) 2000-2016 Free Software Foundation, Inc.
+ Copyright (C) 2000-2017 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes;
Elf_Internal_Rela *rel, *relend;
- bfd *dynobj;
bfd_vma *local_got_offsets;
asection *sgot;
asection *sgotplt;
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (input_bfd);
- dynobj = elf_hash_table (info)->dynobj;
local_got_offsets = elf_local_got_offsets (input_bfd);
- sgot = NULL;
- sgotplt = NULL;
- splt = NULL;
sreloc = NULL;
rel = relocs;
/* Relocation is to the entry for this symbol in the global
offset table extension for the procedure linkage table. */
- if (sgotplt == NULL)
- {
- sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
- BFD_ASSERT (sgotplt != NULL);
- }
+ sgotplt = elf_hash_table (info)->sgotplt;
+ BFD_ASSERT (sgotplt != NULL);
relocation = (sgotplt->output_offset
+ ((h->plt.offset / elf_sh64_sizeof_plt (info)
case R_SH_GOT10BY8:
/* Relocation is to the entry for this symbol in the global
offset table. */
- if (sgot == NULL)
- {
- sgot = bfd_get_linker_section (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
+ sgot = elf_hash_table (info)->sgot;
+ BFD_ASSERT (sgot != NULL);
if (h != NULL)
{
Elf_Internal_Rela outrel;
bfd_byte *loc;
- s = bfd_get_linker_section (dynobj, ".rela.got");
+ s = elf_hash_table (info)->srelgot;
BFD_ASSERT (s != NULL);
outrel.r_offset = (sgot->output_section->vma
/* Relocation is relative to the start of the global offset
table. */
- if (sgot == NULL)
- {
- sgot = bfd_get_linker_section (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
+ sgot = elf_hash_table (info)->sgot;
+ BFD_ASSERT (sgot != NULL);
/* Note that sgot->output_offset is not involved in this
calculation. We always want the start of .got. If we
case R_SH_GOTPC_HI16:
/* Use global offset table as symbol value. */
- if (sgot == NULL)
- {
- sgot = bfd_get_linker_section (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
+ sgot = elf_hash_table (info)->sgot;
+ BFD_ASSERT (sgot != NULL);
relocation = sgot->output_section->vma;
goto final_link_relocate;
}
- if (splt == NULL)
- {
- splt = bfd_get_linker_section (dynobj, ".plt");
- BFD_ASSERT (splt != NULL);
- }
+ splt = elf_hash_table (info)->splt;
+ BFD_ASSERT (splt != NULL);
relocation = (splt->output_section->vma
+ splt->output_offset
asection *srelgot;
asection *sreloc;
- sgot = NULL;
- srelgot = NULL;
sreloc = NULL;
if (bfd_link_relocatable (info))
case R_SH_GOT10BY8:
/* This symbol requires a global offset table entry. */
- if (sgot == NULL)
- {
- sgot = bfd_get_linker_section (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- if (srelgot == NULL
- && (h != NULL || bfd_link_pic (info)))
- {
- srelgot = bfd_get_linker_section (dynobj, ".rela.got");
- if (srelgot == NULL)
- {
- flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY | SEC_LINKER_CREATED
- | SEC_READONLY);
- srelgot = bfd_make_section_anyway_with_flags (dynobj,
- ".rela.got",
- flags);
- if (srelgot == NULL
- || ! bfd_set_section_alignment (dynobj, srelgot, 2))
- return FALSE;
- }
- }
+ sgot = elf_hash_table (info)->sgot;
+ srelgot = elf_hash_table (info)->srelgot;
+ BFD_ASSERT (sgot != NULL && srelgot != NULL);
if (h != NULL)
{
return FALSE;
}
- s = bfd_get_linker_section (dynobj, ".plt");
+ s = elf_hash_table (info)->splt;
BFD_ASSERT (s != NULL);
/* If this is the first .plt entry, make room for the special
/* We also need to make an entry in the .got.plt section, which
will be placed in the .got section by the linker script. */
- s = bfd_get_linker_section (dynobj, ".got.plt");
+ s = elf_hash_table (info)->sgotplt;
BFD_ASSERT (s != NULL);
s->size += 8;
/* We also need to make an entry in the .rela.plt section. */
- s = bfd_get_linker_section (dynobj, ".rela.plt");
+ s = elf_hash_table (info)->srelplt;
BFD_ASSERT (s != NULL);
s->size += sizeof (Elf64_External_Rela);
not actually use these entries. Reset the size of .rela.got,
which will cause it to get stripped from the output file
below. */
- s = bfd_get_linker_section (dynobj, ".rela.got");
+ s = elf_hash_table (info)->srelgot;
if (s != NULL)
s->size = 0;
}
BFD_ASSERT (h->dynindx != -1);
- splt = bfd_get_linker_section (dynobj, ".plt");
- sgot = bfd_get_linker_section (dynobj, ".got.plt");
- srel = bfd_get_linker_section (dynobj, ".rela.plt");
+ splt = elf_hash_table (info)->splt;
+ sgot = elf_hash_table (info)->sgotplt;
+ srel = elf_hash_table (info)->srelplt;
BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
/* Get the index in the procedure linkage table which
/* This symbol has an entry in the global offset table. Set it
up. */
- sgot = bfd_get_linker_section (dynobj, ".got");
- srel = bfd_get_linker_section (dynobj, ".rela.got");
+ sgot = elf_hash_table (info)->sgot;
+ srel = elf_hash_table (info)->srelgot;
BFD_ASSERT (sgot != NULL && srel != NULL);
rel.r_offset = (sgot->output_section->vma
dynobj = elf_hash_table (info)->dynobj;
- sgot = bfd_get_linker_section (dynobj, ".got.plt");
+ sgot = elf_hash_table (info)->sgotplt;
BFD_ASSERT (sgot != NULL);
sdyn = bfd_get_linker_section (dynobj, ".dynamic");
break;
case DT_PLTGOT:
- name = ".got.plt";
+ s = elf_hash_table (info)->sgotplt;
goto get_vma;
case DT_JMPREL:
- name = ".rela.plt";
+ s = elf_hash_table (info)->srelplt;
get_vma:
- s = bfd_get_linker_section (dynobj, name);
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
case DT_PLTRELSZ:
- s = bfd_get_linker_section (dynobj, ".rela.plt");
+ s = elf_hash_table (info)->srelplt;
dyn.d_un.d_val = s->size;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
break;
-
- case DT_RELASZ:
- /* My reading of the SVR4 ABI indicates that the
- procedure linkage table relocs (DT_JMPREL) should be
- included in the overall relocs (DT_RELA). This is
- what Solaris does. However, UnixWare can not handle
- that case. Therefore, we override the DT_RELASZ entry
- here to make it not include the JMPREL relocs. Since
- the linker script arranges for .rela.plt to follow all
- other relocation sections, we don't have to worry
- about changing the DT_RELA entry. */
- s = bfd_get_linker_section (dynobj, ".rela.plt");
- if (s != NULL)
- dyn.d_un.d_val -= s->size;
- bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
}
}
/* Fill in the first entry in the procedure linkage table. */
- splt = bfd_get_linker_section (dynobj, ".plt");
+ splt = elf_hash_table (info)->splt;
if (splt && splt->size > 0)
{
if (bfd_link_pic (info))
#define elf_backend_plt_readonly 1
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size 24
+#define elf_backend_dtrel_excludes_plt 1
#include "elf64-target.h"