aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-sh64.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf64-sh64.c')
-rw-r--r--bfd/elf64-sh64.c101
1 files changed, 29 insertions, 72 deletions
diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c
index 81cfa00..352fd29 100644
--- a/bfd/elf64-sh64.c
+++ b/bfd/elf64-sh64.c
@@ -1432,7 +1432,6 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
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;
@@ -1442,12 +1441,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
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;
@@ -1794,11 +1789,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
/* 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)
@@ -1817,11 +1809,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
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)
{
@@ -1913,7 +1902,7 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
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
@@ -1946,11 +1935,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
/* 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
@@ -1971,11 +1957,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
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;
@@ -2009,11 +1992,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
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
@@ -2376,8 +2356,6 @@ sh_elf64_check_relocs (bfd *abfd, struct bfd_link_info *info,
asection *srelgot;
asection *sreloc;
- sgot = NULL;
- srelgot = NULL;
sreloc = NULL;
if (bfd_link_relocatable (info))
@@ -2472,29 +2450,9 @@ sh_elf64_check_relocs (bfd *abfd, struct bfd_link_info *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)
{
@@ -3267,7 +3225,7 @@ sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info *info,
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
@@ -3295,13 +3253,13 @@ sh64_elf64_adjust_dynamic_symbol (struct bfd_link_info *info,
/* 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);
@@ -3421,7 +3379,7 @@ sh64_elf64_size_dynamic_sections (bfd *output_bfd,
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;
}
@@ -3590,9 +3548,9 @@ sh64_elf64_finish_dynamic_symbol (bfd *output_bfd,
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
@@ -3693,8 +3651,8 @@ sh64_elf64_finish_dynamic_symbol (bfd *output_bfd,
/* 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
@@ -3772,7 +3730,7 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd,
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");
@@ -3819,19 +3777,18 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd,
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;
@@ -3846,7 +3803,7 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd,
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");
+ s = elf_hash_table (info)->srelplt;
if (s != NULL)
dyn.d_un.d_val -= s->size;
bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -3855,7 +3812,7 @@ sh64_elf64_finish_dynamic_sections (bfd *output_bfd,
}
/* 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))