2012-03-30 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>

* elf64-s390.c: Use the section pointer shortcuts in
	elf_link_hash_table and remove them from the target specific
	variant.
	* elf32-s390.c: Likewise.
This commit is contained in:
Andreas Krebbel
2012-03-30 13:37:13 +00:00
parent 9aa174530d
commit f41345a758
3 changed files with 244 additions and 247 deletions

View File

@ -1,3 +1,10 @@
2012-03-30 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* elf64-s390.c: Use the section pointer shortcuts in
elf_link_hash_table and remove them from the target specific
variant.
* elf32-s390.c: Likewise.
2012-03-30 Andreas Krebbel <Andreas.Krebbel@de.ibm.com> 2012-03-30 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* elf64-s390.c (elf_s390x_plt_entry, elf_s390x_first_plt_entry): * elf64-s390.c (elf_s390x_plt_entry, elf_s390x_first_plt_entry):

View File

@ -747,11 +747,6 @@ struct elf_s390_link_hash_table
struct elf_link_hash_table elf; struct elf_link_hash_table elf;
/* Short-cuts to get to dynamic linker sections. */ /* Short-cuts to get to dynamic linker sections. */
asection *sgot;
asection *sgotplt;
asection *srelgot;
asection *splt;
asection *srelplt;
asection *sdynbss; asection *sdynbss;
asection *srelbss; asection *srelbss;
@ -824,11 +819,11 @@ elf_s390_link_hash_table_create (abfd)
return NULL; return NULL;
} }
ret->sgot = NULL; ret->elf.sgot = NULL;
ret->sgotplt = NULL; ret->elf.sgotplt = NULL;
ret->srelgot = NULL; ret->elf.srelgot = NULL;
ret->splt = NULL; ret->elf.splt = NULL;
ret->srelplt = NULL; ret->elf.srelplt = NULL;
ret->sdynbss = NULL; ret->sdynbss = NULL;
ret->srelbss = NULL; ret->srelbss = NULL;
ret->tls_ldm_got.refcount = 0; ret->tls_ldm_got.refcount = 0;
@ -851,10 +846,10 @@ create_got_section (dynobj, info)
return FALSE; return FALSE;
htab = elf_s390_hash_table (info); htab = elf_s390_hash_table (info);
htab->sgot = bfd_get_section_by_name (dynobj, ".got"); htab->elf.sgot = bfd_get_section_by_name (dynobj, ".got");
htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); htab->elf.sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); htab->elf.srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
if (!htab->sgot || !htab->sgotplt || !htab->srelgot) if (!htab->elf.sgot || !htab->elf.sgotplt || !htab->elf.srelgot)
abort (); abort ();
return TRUE; return TRUE;
@ -872,19 +867,19 @@ elf_s390_create_dynamic_sections (dynobj, info)
struct elf_s390_link_hash_table *htab; struct elf_s390_link_hash_table *htab;
htab = elf_s390_hash_table (info); htab = elf_s390_hash_table (info);
if (!htab->sgot && !create_got_section (dynobj, info)) if (!htab->elf.sgot && !create_got_section (dynobj, info))
return FALSE; return FALSE;
if (!_bfd_elf_create_dynamic_sections (dynobj, info)) if (!_bfd_elf_create_dynamic_sections (dynobj, info))
return FALSE; return FALSE;
htab->splt = bfd_get_section_by_name (dynobj, ".plt"); htab->elf.splt = bfd_get_section_by_name (dynobj, ".plt");
htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt"); htab->elf.srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
if (!info->shared) if (!info->shared)
htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss"); htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
if (!htab->splt || !htab->srelplt || !htab->sdynbss if (!htab->elf.splt || !htab->elf.srelplt || !htab->sdynbss
|| (!info->shared && !htab->srelbss)) || (!info->shared && !htab->srelbss))
abort (); abort ();
@ -1086,7 +1081,7 @@ elf_s390_check_relocs (abfd, info, sec, relocs)
case R_390_GOTOFF32: case R_390_GOTOFF32:
case R_390_GOTPC: case R_390_GOTPC:
case R_390_GOTPCDBL: case R_390_GOTPCDBL:
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
{ {
if (htab->elf.dynobj == NULL) if (htab->elf.dynobj == NULL)
htab->elf.dynobj = abfd; htab->elf.dynobj = abfd;
@ -1737,7 +1732,7 @@ allocate_dynrelocs (h, inf)
if (info->shared if (info->shared
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
{ {
asection *s = htab->splt; asection *s = htab->elf.splt;
/* If this is the first .plt entry, make room for the special /* If this is the first .plt entry, make room for the special
first entry. */ first entry. */
@ -1763,10 +1758,10 @@ allocate_dynrelocs (h, inf)
/* We also need to make an entry in the .got.plt section, which /* We also need to make an entry in the .got.plt section, which
will be placed in the .got section by the linker script. */ will be placed in the .got section by the linker script. */
htab->sgotplt->size += GOT_ENTRY_SIZE; htab->elf.sgotplt->size += GOT_ENTRY_SIZE;
/* We also need to make an entry in the .rela.plt section. */ /* We also need to make an entry in the .rela.plt section. */
htab->srelplt->size += sizeof (Elf32_External_Rela); htab->elf.srelplt->size += sizeof (Elf32_External_Rela);
} }
else else
{ {
@ -1796,8 +1791,8 @@ allocate_dynrelocs (h, inf)
to be stored somewhere. The immediate value in the instruction to be stored somewhere. The immediate value in the instruction
is not bit enough so the value is stored in the got. */ is not bit enough so the value is stored in the got. */
{ {
h->got.offset = htab->sgot->size; h->got.offset = htab->elf.sgot->size;
htab->sgot->size += GOT_ENTRY_SIZE; htab->elf.sgot->size += GOT_ENTRY_SIZE;
} }
else else
h->got.offset = (bfd_vma) -1; h->got.offset = (bfd_vma) -1;
@ -1817,7 +1812,7 @@ allocate_dynrelocs (h, inf)
return FALSE; return FALSE;
} }
s = htab->sgot; s = htab->elf.sgot;
h->got.offset = s->size; h->got.offset = s->size;
s->size += GOT_ENTRY_SIZE; s->size += GOT_ENTRY_SIZE;
/* R_390_TLS_GD32 needs 2 consecutive GOT slots. */ /* R_390_TLS_GD32 needs 2 consecutive GOT slots. */
@ -1828,14 +1823,14 @@ allocate_dynrelocs (h, inf)
R_390_TLS_GD32 needs one if local symbol and two if global. */ R_390_TLS_GD32 needs one if local symbol and two if global. */
if ((tls_type == GOT_TLS_GD && h->dynindx == -1) if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
|| tls_type >= GOT_TLS_IE) || tls_type >= GOT_TLS_IE)
htab->srelgot->size += sizeof (Elf32_External_Rela); htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
else if (tls_type == GOT_TLS_GD) else if (tls_type == GOT_TLS_GD)
htab->srelgot->size += 2 * sizeof (Elf32_External_Rela); htab->elf.srelgot->size += 2 * sizeof (Elf32_External_Rela);
else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak) || h->root.type != bfd_link_hash_undefweak)
&& (info->shared && (info->shared
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
htab->srelgot->size += sizeof (Elf32_External_Rela); htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
} }
else else
h->got.offset = (bfd_vma) -1; h->got.offset = (bfd_vma) -1;
@ -2034,8 +2029,8 @@ elf_s390_size_dynamic_sections (output_bfd, info)
locsymcount = symtab_hdr->sh_info; locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount; end_local_got = local_got + locsymcount;
local_tls_type = elf_s390_local_got_tls_type (ibfd); local_tls_type = elf_s390_local_got_tls_type (ibfd);
s = htab->sgot; s = htab->elf.sgot;
srela = htab->srelgot; srela = htab->elf.srelgot;
for (; local_got < end_local_got; ++local_got, ++local_tls_type) for (; local_got < end_local_got; ++local_got, ++local_tls_type)
{ {
if (*local_got > 0) if (*local_got > 0)
@ -2056,9 +2051,9 @@ elf_s390_size_dynamic_sections (output_bfd, info)
{ {
/* Allocate 2 got entries and 1 dynamic reloc for R_390_TLS_LDM32 /* Allocate 2 got entries and 1 dynamic reloc for R_390_TLS_LDM32
relocs. */ relocs. */
htab->tls_ldm_got.offset = htab->sgot->size; htab->tls_ldm_got.offset = htab->elf.sgot->size;
htab->sgot->size += 2 * GOT_ENTRY_SIZE; htab->elf.sgot->size += 2 * GOT_ENTRY_SIZE;
htab->srelgot->size += sizeof (Elf32_External_Rela); htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
} }
else else
htab->tls_ldm_got.offset = -1; htab->tls_ldm_got.offset = -1;
@ -2075,9 +2070,9 @@ elf_s390_size_dynamic_sections (output_bfd, info)
if ((s->flags & SEC_LINKER_CREATED) == 0) if ((s->flags & SEC_LINKER_CREATED) == 0)
continue; continue;
if (s == htab->splt if (s == htab->elf.splt
|| s == htab->sgot || s == htab->elf.sgot
|| s == htab->sgotplt || s == htab->elf.sgotplt
|| s == htab->sdynbss) || s == htab->sdynbss)
{ {
/* Strip this section if we don't need it; see the /* Strip this section if we don't need it; see the
@ -2143,7 +2138,7 @@ elf_s390_size_dynamic_sections (output_bfd, info)
return FALSE; return FALSE;
} }
if (htab->splt->size != 0) if (htab->elf.splt->size != 0)
{ {
if (!add_dynamic_entry (DT_PLTGOT, 0) if (!add_dynamic_entry (DT_PLTGOT, 0)
|| !add_dynamic_entry (DT_PLTRELSZ, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0)
@ -2343,7 +2338,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
if (r_type == R_390_GOTPLTENT) if (r_type == R_390_GOTPLTENT)
relocation += htab->sgot->output_section->vma; relocation += htab->elf.sgot->output_section->vma;
break; break;
} }
/* Fall through. */ /* Fall through. */
@ -2355,7 +2350,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
case R_390_GOTENT: case R_390_GOTENT:
/* Relocation is to the entry for this symbol in the global /* Relocation is to the entry for this symbol in the global
offset table. */ offset table. */
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
abort (); abort ();
if (h != NULL) if (h != NULL)
@ -2387,7 +2382,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
else else
{ {
bfd_put_32 (output_bfd, relocation, bfd_put_32 (output_bfd, relocation,
htab->sgot->contents + off); htab->elf.sgot->contents + off);
h->got.offset |= 1; h->got.offset |= 1;
} }
} }
@ -2409,7 +2404,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
else else
{ {
bfd_put_32 (output_bfd, relocation, bfd_put_32 (output_bfd, relocation,
htab->sgot->contents + off); htab->elf.sgot->contents + off);
if (info->shared) if (info->shared)
{ {
@ -2417,12 +2412,12 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela outrel; Elf_Internal_Rela outrel;
bfd_byte *loc; bfd_byte *loc;
srelgot = htab->srelgot; srelgot = htab->elf.srelgot;
if (srelgot == NULL) if (srelgot == NULL)
abort (); abort ();
outrel.r_offset = (htab->sgot->output_section->vma outrel.r_offset = (htab->elf.sgot->output_section->vma
+ htab->sgot->output_offset + htab->elf.sgot->output_offset
+ off); + off);
outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE); outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
outrel.r_addend = relocation; outrel.r_addend = relocation;
@ -2438,7 +2433,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
if (off >= (bfd_vma) -2) if (off >= (bfd_vma) -2)
abort (); abort ();
relocation = htab->sgot->output_offset + off; relocation = htab->elf.sgot->output_offset + off;
/* For @GOTENT the relocation is against the offset between /* For @GOTENT the relocation is against the offset between
the instruction and the symbols entry in the GOT and not the instruction and the symbols entry in the GOT and not
@ -2446,7 +2441,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
add the vma of the GOT to get the correct value. */ add the vma of the GOT to get the correct value. */
if ( r_type == R_390_GOTENT if ( r_type == R_390_GOTENT
|| r_type == R_390_GOTPLTENT) || r_type == R_390_GOTPLTENT)
relocation += htab->sgot->output_section->vma; relocation += htab->elf.sgot->output_section->vma;
break; break;
@ -2460,13 +2455,13 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
defined _GLOBAL_OFFSET_TABLE in a different way, as is defined _GLOBAL_OFFSET_TABLE in a different way, as is
permitted by the ABI, we might have to change this permitted by the ABI, we might have to change this
calculation. */ calculation. */
relocation -= htab->sgot->output_section->vma; relocation -= htab->elf.sgot->output_section->vma;
break; break;
case R_390_GOTPC: case R_390_GOTPC:
case R_390_GOTPCDBL: case R_390_GOTPCDBL:
/* Use global offset table as symbol value. */ /* Use global offset table as symbol value. */
relocation = htab->sgot->output_section->vma; relocation = htab->elf.sgot->output_section->vma;
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -2482,7 +2477,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
break; break;
if (h->plt.offset == (bfd_vma) -1 if (h->plt.offset == (bfd_vma) -1
|| htab->splt == NULL) || htab->elf.splt == NULL)
{ {
/* We didn't make a PLT entry for this symbol. This /* We didn't make a PLT entry for this symbol. This
happens when statically linking PIC code, or when happens when statically linking PIC code, or when
@ -2490,8 +2485,8 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
break; break;
} }
relocation = (htab->splt->output_section->vma relocation = (htab->elf.splt->output_section->vma
+ htab->splt->output_offset + htab->elf.splt->output_offset
+ h->plt.offset); + h->plt.offset);
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -2505,16 +2500,16 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
this symbol resolve the symbol directly. */ this symbol resolve the symbol directly. */
if ( h == NULL if ( h == NULL
|| h->plt.offset == (bfd_vma) -1 || h->plt.offset == (bfd_vma) -1
|| htab->splt == NULL) || htab->elf.splt == NULL)
{ {
relocation -= htab->sgot->output_section->vma; relocation -= htab->elf.sgot->output_section->vma;
break; break;
} }
relocation = (htab->splt->output_section->vma relocation = (htab->elf.splt->output_section->vma
+ htab->splt->output_offset + htab->elf.splt->output_offset
+ h->plt.offset + h->plt.offset
- htab->sgot->output_section->vma); - htab->elf.sgot->output_section->vma);
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -2691,7 +2686,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
continue; continue;
} }
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
abort (); abort ();
if (h != NULL) if (h != NULL)
@ -2714,11 +2709,11 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
bfd_byte *loc; bfd_byte *loc;
int dr_type, indx; int dr_type, indx;
if (htab->srelgot == NULL) if (htab->elf.srelgot == NULL)
abort (); abort ();
outrel.r_offset = (htab->sgot->output_section->vma outrel.r_offset = (htab->elf.sgot->output_section->vma
+ htab->sgot->output_offset + off); + htab->elf.sgot->output_offset + off);
indx = h && h->dynindx != -1 ? h->dynindx : 0; indx = h && h->dynindx != -1 ? h->dynindx : 0;
if (r_type == R_390_TLS_GD32) if (r_type == R_390_TLS_GD32)
@ -2730,8 +2725,8 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
else else
outrel.r_addend = 0; outrel.r_addend = 0;
outrel.r_info = ELF32_R_INFO (indx, dr_type); outrel.r_info = ELF32_R_INFO (indx, dr_type);
loc = htab->srelgot->contents; loc = htab->elf.srelgot->contents;
loc += htab->srelgot->reloc_count++ loc += htab->elf.srelgot->reloc_count++
* sizeof (Elf32_External_Rela); * sizeof (Elf32_External_Rela);
bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
@ -2742,14 +2737,14 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
BFD_ASSERT (! unresolved_reloc); BFD_ASSERT (! unresolved_reloc);
bfd_put_32 (output_bfd, bfd_put_32 (output_bfd,
relocation - dtpoff_base (info), relocation - dtpoff_base (info),
htab->sgot->contents + off + GOT_ENTRY_SIZE); htab->elf.sgot->contents + off + GOT_ENTRY_SIZE);
} }
else else
{ {
outrel.r_info = ELF32_R_INFO (indx, R_390_TLS_DTPOFF); outrel.r_info = ELF32_R_INFO (indx, R_390_TLS_DTPOFF);
outrel.r_offset += GOT_ENTRY_SIZE; outrel.r_offset += GOT_ENTRY_SIZE;
outrel.r_addend = 0; outrel.r_addend = 0;
htab->srelgot->reloc_count++; htab->elf.srelgot->reloc_count++;
loc += sizeof (Elf32_External_Rela); loc += sizeof (Elf32_External_Rela);
bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
} }
@ -2765,14 +2760,14 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
abort (); abort ();
if (r_type == ELF32_R_TYPE (rel->r_info)) if (r_type == ELF32_R_TYPE (rel->r_info))
{ {
relocation = htab->sgot->output_offset + off; relocation = htab->elf.sgot->output_offset + off;
if (r_type == R_390_TLS_IE32 || r_type == R_390_TLS_IEENT) if (r_type == R_390_TLS_IE32 || r_type == R_390_TLS_IEENT)
relocation += htab->sgot->output_section->vma; relocation += htab->elf.sgot->output_section->vma;
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
} }
else else
{ {
bfd_put_32 (output_bfd, htab->sgot->output_offset + off, bfd_put_32 (output_bfd, htab->elf.sgot->output_offset + off,
contents + rel->r_offset); contents + rel->r_offset);
continue; continue;
} }
@ -2797,15 +2792,15 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
goto emit_tls_relocs; goto emit_tls_relocs;
} }
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
abort (); abort ();
BFD_ASSERT (! unresolved_reloc); BFD_ASSERT (! unresolved_reloc);
bfd_put_32 (output_bfd, -tpoff (info, relocation), bfd_put_32 (output_bfd, -tpoff (info, relocation),
htab->sgot->contents + off); htab->elf.sgot->contents + off);
relocation = htab->sgot->output_offset + off; relocation = htab->elf.sgot->output_offset + off;
if (r_type == R_390_TLS_IEENT) if (r_type == R_390_TLS_IEENT)
relocation += htab->sgot->output_section->vma; relocation += htab->elf.sgot->output_section->vma;
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -2816,7 +2811,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
and the value will turn out zero. */ and the value will turn out zero. */
continue; continue;
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
abort (); abort ();
off = htab->tls_ldm_got.offset; off = htab->tls_ldm_got.offset;
@ -2827,23 +2822,23 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
Elf_Internal_Rela outrel; Elf_Internal_Rela outrel;
bfd_byte *loc; bfd_byte *loc;
if (htab->srelgot == NULL) if (htab->elf.srelgot == NULL)
abort (); abort ();
outrel.r_offset = (htab->sgot->output_section->vma outrel.r_offset = (htab->elf.sgot->output_section->vma
+ htab->sgot->output_offset + off); + htab->elf.sgot->output_offset + off);
bfd_put_32 (output_bfd, 0, bfd_put_32 (output_bfd, 0,
htab->sgot->contents + off + GOT_ENTRY_SIZE); htab->elf.sgot->contents + off + GOT_ENTRY_SIZE);
outrel.r_info = ELF32_R_INFO (0, R_390_TLS_DTPMOD); outrel.r_info = ELF32_R_INFO (0, R_390_TLS_DTPMOD);
outrel.r_addend = 0; outrel.r_addend = 0;
loc = htab->srelgot->contents; loc = htab->elf.srelgot->contents;
loc += htab->srelgot->reloc_count++ loc += htab->elf.srelgot->reloc_count++
* sizeof (Elf32_External_Rela); * sizeof (Elf32_External_Rela);
bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
htab->tls_ldm_got.offset |= 1; htab->tls_ldm_got.offset |= 1;
} }
relocation = htab->sgot->output_offset + off; relocation = htab->elf.sgot->output_offset + off;
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -3131,9 +3126,9 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym)
/* This symbol has an entry in the procedure linkage table. Set /* This symbol has an entry in the procedure linkage table. Set
it up. */ it up. */
if (h->dynindx == -1 if (h->dynindx == -1
|| htab->splt == NULL || htab->elf.splt == NULL
|| htab->sgotplt == NULL || htab->elf.sgotplt == NULL
|| htab->srelplt == NULL) || htab->elf.srelplt == NULL)
abort (); abort ();
/* Calc. index no. /* Calc. index no.
@ -3156,25 +3151,25 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym)
/* Fill in the entry in the procedure linkage table. */ /* Fill in the entry in the procedure linkage table. */
if (!info->shared) if (!info->shared)
{ {
memcpy (htab->splt->contents + h->plt.offset, elf_s390_plt_entry, memcpy (htab->elf.splt->contents + h->plt.offset, elf_s390_plt_entry,
PLT_ENTRY_SIZE); PLT_ENTRY_SIZE);
/* Adjust jump to the first plt entry. */ /* Adjust jump to the first plt entry. */
bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16), bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
htab->splt->contents + h->plt.offset + 20); htab->elf.splt->contents + h->plt.offset + 20);
/* Push the GOT offset field. */ /* Push the GOT offset field. */
bfd_put_32 (output_bfd, bfd_put_32 (output_bfd,
(htab->sgotplt->output_section->vma (htab->elf.sgotplt->output_section->vma
+ htab->sgotplt->output_offset + htab->elf.sgotplt->output_offset
+ got_offset), + got_offset),
htab->splt->contents + h->plt.offset + 24); htab->elf.splt->contents + h->plt.offset + 24);
} }
else if (got_offset < 4096) else if (got_offset < 4096)
{ {
/* The GOT offset is small enough to be used directly as /* The GOT offset is small enough to be used directly as
displacement. */ displacement. */
memcpy (htab->splt->contents + h->plt.offset, memcpy (htab->elf.splt->contents + h->plt.offset,
elf_s390_plt_pic12_entry, elf_s390_plt_pic12_entry,
PLT_ENTRY_SIZE); PLT_ENTRY_SIZE);
@ -3182,63 +3177,63 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym)
value comes from the first word of the plt entry. Look value comes from the first word of the plt entry. Look
at the elf_s390_plt_pic16_entry content. */ at the elf_s390_plt_pic16_entry content. */
bfd_put_16 (output_bfd, (bfd_vma)0xc000 | got_offset, bfd_put_16 (output_bfd, (bfd_vma)0xc000 | got_offset,
htab->splt->contents + h->plt.offset + 2); htab->elf.splt->contents + h->plt.offset + 2);
/* Adjust the jump to the first plt entry. */ /* Adjust the jump to the first plt entry. */
bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16), bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
htab->splt->contents + h->plt.offset + 20); htab->elf.splt->contents + h->plt.offset + 20);
} }
else if (got_offset < 32768) else if (got_offset < 32768)
{ {
/* The GOT offset is too big for a displacement but small /* The GOT offset is too big for a displacement but small
enough to be a signed 16 bit immediate value as it can be enough to be a signed 16 bit immediate value as it can be
used in an lhi instruction. */ used in an lhi instruction. */
memcpy (htab->splt->contents + h->plt.offset, memcpy (htab->elf.splt->contents + h->plt.offset,
elf_s390_plt_pic16_entry, elf_s390_plt_pic16_entry,
PLT_ENTRY_SIZE); PLT_ENTRY_SIZE);
/* Put in the GOT offset for the lhi instruction. */ /* Put in the GOT offset for the lhi instruction. */
bfd_put_16 (output_bfd, (bfd_vma)got_offset, bfd_put_16 (output_bfd, (bfd_vma)got_offset,
htab->splt->contents + h->plt.offset + 2); htab->elf.splt->contents + h->plt.offset + 2);
/* Adjust the jump to the first plt entry. */ /* Adjust the jump to the first plt entry. */
bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16), bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
htab->splt->contents + h->plt.offset + 20); htab->elf.splt->contents + h->plt.offset + 20);
} }
else else
{ {
memcpy (htab->splt->contents + h->plt.offset, memcpy (htab->elf.splt->contents + h->plt.offset,
elf_s390_plt_pic_entry, elf_s390_plt_pic_entry,
PLT_ENTRY_SIZE); PLT_ENTRY_SIZE);
/* Adjust the jump to the first plt entry. */ /* Adjust the jump to the first plt entry. */
bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16), bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
htab->splt->contents + h->plt.offset + 20); htab->elf.splt->contents + h->plt.offset + 20);
/* Push the GOT offset field. */ /* Push the GOT offset field. */
bfd_put_32 (output_bfd, got_offset, bfd_put_32 (output_bfd, got_offset,
htab->splt->contents + h->plt.offset + 24); htab->elf.splt->contents + h->plt.offset + 24);
} }
/* Insert offset into reloc. table here. */ /* Insert offset into reloc. table here. */
bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela), bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela),
htab->splt->contents + h->plt.offset + 28); htab->elf.splt->contents + h->plt.offset + 28);
/* Fill in the entry in the global offset table. /* Fill in the entry in the global offset table.
Points to instruction after GOT offset. */ Points to instruction after GOT offset. */
bfd_put_32 (output_bfd, bfd_put_32 (output_bfd,
(htab->splt->output_section->vma (htab->elf.splt->output_section->vma
+ htab->splt->output_offset + htab->elf.splt->output_offset
+ h->plt.offset + h->plt.offset
+ 12), + 12),
htab->sgotplt->contents + got_offset); htab->elf.sgotplt->contents + got_offset);
/* Fill in the entry in the .rela.plt section. */ /* Fill in the entry in the .rela.plt section. */
rela.r_offset = (htab->sgotplt->output_section->vma rela.r_offset = (htab->elf.sgotplt->output_section->vma
+ htab->sgotplt->output_offset + htab->elf.sgotplt->output_offset
+ got_offset); + got_offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT); rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT);
rela.r_addend = 0; rela.r_addend = 0;
loc = htab->srelplt->contents + plt_index * sizeof (Elf32_External_Rela); loc = htab->elf.srelplt->contents + plt_index * sizeof (Elf32_External_Rela);
bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
if (!h->def_regular) if (!h->def_regular)
@ -3263,11 +3258,11 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym)
/* This symbol has an entry in the global offset table. Set it /* This symbol has an entry in the global offset table. Set it
up. */ up. */
if (htab->sgot == NULL || htab->srelgot == NULL) if (htab->elf.sgot == NULL || htab->elf.srelgot == NULL)
abort (); abort ();
rela.r_offset = (htab->sgot->output_section->vma rela.r_offset = (htab->elf.sgot->output_section->vma
+ htab->sgot->output_offset + htab->elf.sgot->output_offset
+ (h->got.offset &~ (bfd_vma) 1)); + (h->got.offset &~ (bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the /* If this is a static link, or it is a -Bsymbolic link and the
@ -3289,13 +3284,13 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym)
else else
{ {
BFD_ASSERT((h->got.offset & 1) == 0); BFD_ASSERT((h->got.offset & 1) == 0);
bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgot->contents + h->got.offset); bfd_put_32 (output_bfd, (bfd_vma) 0, htab->elf.sgot->contents + h->got.offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_390_GLOB_DAT); rela.r_info = ELF32_R_INFO (h->dynindx, R_390_GLOB_DAT);
rela.r_addend = 0; rela.r_addend = 0;
} }
loc = htab->srelgot->contents; loc = htab->elf.srelgot->contents;
loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela); loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
} }
@ -3370,7 +3365,7 @@ elf_s390_finish_dynamic_sections (output_bfd, info)
{ {
Elf32_External_Dyn *dyncon, *dynconend; Elf32_External_Dyn *dyncon, *dynconend;
if (sdyn == NULL || htab->sgot == NULL) if (sdyn == NULL || htab->elf.sgot == NULL)
abort (); abort ();
dyncon = (Elf32_External_Dyn *) sdyn->contents; dyncon = (Elf32_External_Dyn *) sdyn->contents;
@ -3388,15 +3383,15 @@ elf_s390_finish_dynamic_sections (output_bfd, info)
continue; continue;
case DT_PLTGOT: case DT_PLTGOT:
dyn.d_un.d_ptr = htab->sgot->output_section->vma; dyn.d_un.d_ptr = htab->elf.sgot->output_section->vma;
break; break;
case DT_JMPREL: case DT_JMPREL:
dyn.d_un.d_ptr = htab->srelplt->output_section->vma; dyn.d_un.d_ptr = htab->elf.srelplt->output_section->vma;
break; break;
case DT_PLTRELSZ: case DT_PLTRELSZ:
s = htab->srelplt->output_section; s = htab->elf.srelplt->output_section;
dyn.d_un.d_val = s->size; dyn.d_un.d_val = s->size;
break; break;
} }
@ -3405,45 +3400,45 @@ elf_s390_finish_dynamic_sections (output_bfd, info)
} }
/* Fill in the special first entry in the procedure linkage table. */ /* Fill in the special first entry in the procedure linkage table. */
if (htab->splt && htab->splt->size > 0) if (htab->elf.splt && htab->elf.splt->size > 0)
{ {
memset (htab->splt->contents, 0, PLT_FIRST_ENTRY_SIZE); memset (htab->elf.splt->contents, 0, PLT_FIRST_ENTRY_SIZE);
if (info->shared) if (info->shared)
{ {
memcpy (htab->splt->contents, elf_s390_plt_pic_first_entry, memcpy (htab->elf.splt->contents, elf_s390_plt_pic_first_entry,
PLT_FIRST_ENTRY_SIZE); PLT_FIRST_ENTRY_SIZE);
} }
else else
{ {
memcpy (htab->splt->contents, elf_s390_plt_first_entry, memcpy (htab->elf.splt->contents, elf_s390_plt_first_entry,
PLT_FIRST_ENTRY_SIZE); PLT_FIRST_ENTRY_SIZE);
bfd_put_32 (output_bfd, bfd_put_32 (output_bfd,
htab->sgotplt->output_section->vma htab->elf.sgotplt->output_section->vma
+ htab->sgotplt->output_offset, + htab->elf.sgotplt->output_offset,
htab->splt->contents + 24); htab->elf.splt->contents + 24);
} }
elf_section_data (htab->splt->output_section) elf_section_data (htab->elf.splt->output_section)
->this_hdr.sh_entsize = 4; ->this_hdr.sh_entsize = 4;
} }
} }
if (htab->sgotplt) if (htab->elf.sgotplt)
{ {
/* Fill in the first three entries in the global offset table. */ /* Fill in the first three entries in the global offset table. */
if (htab->sgotplt->size > 0) if (htab->elf.sgotplt->size > 0)
{ {
bfd_put_32 (output_bfd, bfd_put_32 (output_bfd,
(sdyn == NULL ? (bfd_vma) 0 (sdyn == NULL ? (bfd_vma) 0
: sdyn->output_section->vma + sdyn->output_offset), : sdyn->output_section->vma + sdyn->output_offset),
htab->sgotplt->contents); htab->elf.sgotplt->contents);
/* One entry for shared object struct ptr. */ /* One entry for shared object struct ptr. */
bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 4); bfd_put_32 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + 4);
/* One entry for _dl_runtime_resolve. */ /* One entry for _dl_runtime_resolve. */
bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 8); bfd_put_32 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + 8);
} }
elf_section_data (htab->sgotplt->output_section) elf_section_data (htab->elf.sgotplt->output_section)
->this_hdr.sh_entsize = 4; ->this_hdr.sh_entsize = 4;
} }
return TRUE; return TRUE;

View File

@ -658,11 +658,6 @@ struct elf_s390_link_hash_table
struct elf_link_hash_table elf; struct elf_link_hash_table elf;
/* Short-cuts to get to dynamic linker sections. */ /* Short-cuts to get to dynamic linker sections. */
asection *sgot;
asection *sgotplt;
asection *srelgot;
asection *splt;
asection *srelplt;
asection *sdynbss; asection *sdynbss;
asection *srelbss; asection *srelbss;
@ -735,11 +730,11 @@ elf_s390_link_hash_table_create (abfd)
return NULL; return NULL;
} }
ret->sgot = NULL; ret->elf.sgot = NULL;
ret->sgotplt = NULL; ret->elf.sgotplt = NULL;
ret->srelgot = NULL; ret->elf.srelgot = NULL;
ret->splt = NULL; ret->elf.splt = NULL;
ret->srelplt = NULL; ret->elf.srelplt = NULL;
ret->sdynbss = NULL; ret->sdynbss = NULL;
ret->srelbss = NULL; ret->srelbss = NULL;
ret->tls_ldm_got.refcount = 0; ret->tls_ldm_got.refcount = 0;
@ -764,10 +759,10 @@ create_got_section (bfd *dynobj,
if (htab == NULL) if (htab == NULL)
return FALSE; return FALSE;
htab->sgot = bfd_get_section_by_name (dynobj, ".got"); htab->elf.sgot = bfd_get_section_by_name (dynobj, ".got");
htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); htab->elf.sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); htab->elf.srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
if (!htab->sgot || !htab->sgotplt || !htab->srelgot) if (!htab->elf.sgot || !htab->elf.sgotplt || !htab->elf.srelgot)
abort (); abort ();
return TRUE; return TRUE;
} }
@ -786,19 +781,19 @@ elf_s390_create_dynamic_sections (bfd *dynobj,
if (htab == NULL) if (htab == NULL)
return FALSE; return FALSE;
if (!htab->sgot && !create_got_section (dynobj, info)) if (!htab->elf.sgot && !create_got_section (dynobj, info))
return FALSE; return FALSE;
if (!_bfd_elf_create_dynamic_sections (dynobj, info)) if (!_bfd_elf_create_dynamic_sections (dynobj, info))
return FALSE; return FALSE;
htab->splt = bfd_get_section_by_name (dynobj, ".plt"); htab->elf.splt = bfd_get_section_by_name (dynobj, ".plt");
htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt"); htab->elf.srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
if (!info->shared) if (!info->shared)
htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss"); htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
if (!htab->splt || !htab->srelplt || !htab->sdynbss if (!htab->elf.splt || !htab->elf.srelplt || !htab->sdynbss
|| (!info->shared && !htab->srelbss)) || (!info->shared && !htab->srelbss))
abort (); abort ();
@ -1006,7 +1001,7 @@ elf_s390_check_relocs (bfd *abfd,
case R_390_GOTOFF64: case R_390_GOTOFF64:
case R_390_GOTPC: case R_390_GOTPC:
case R_390_GOTPCDBL: case R_390_GOTPCDBL:
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
{ {
if (htab->elf.dynobj == NULL) if (htab->elf.dynobj == NULL)
htab->elf.dynobj = abfd; htab->elf.dynobj = abfd;
@ -1679,7 +1674,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h,
if (info->shared if (info->shared
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
{ {
asection *s = htab->splt; asection *s = htab->elf.splt;
/* If this is the first .plt entry, make room for the special /* If this is the first .plt entry, make room for the special
first entry. */ first entry. */
@ -1705,10 +1700,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h,
/* We also need to make an entry in the .got.plt section, which /* We also need to make an entry in the .got.plt section, which
will be placed in the .got section by the linker script. */ will be placed in the .got section by the linker script. */
htab->sgotplt->size += GOT_ENTRY_SIZE; htab->elf.sgotplt->size += GOT_ENTRY_SIZE;
/* We also need to make an entry in the .rela.plt section. */ /* We also need to make an entry in the .rela.plt section. */
htab->srelplt->size += sizeof (Elf64_External_Rela); htab->elf.srelplt->size += sizeof (Elf64_External_Rela);
} }
else else
{ {
@ -1738,8 +1733,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h,
to be stored somewhere. The immediate value in the instruction to be stored somewhere. The immediate value in the instruction
is not bit enough so the value is stored in the got. */ is not bit enough so the value is stored in the got. */
{ {
h->got.offset = htab->sgot->size; h->got.offset = htab->elf.sgot->size;
htab->sgot->size += GOT_ENTRY_SIZE; htab->elf.sgot->size += GOT_ENTRY_SIZE;
} }
else else
h->got.offset = (bfd_vma) -1; h->got.offset = (bfd_vma) -1;
@ -1759,7 +1754,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h,
return FALSE; return FALSE;
} }
s = htab->sgot; s = htab->elf.sgot;
h->got.offset = s->size; h->got.offset = s->size;
s->size += GOT_ENTRY_SIZE; s->size += GOT_ENTRY_SIZE;
/* R_390_TLS_GD64 needs 2 consecutive GOT slots. */ /* R_390_TLS_GD64 needs 2 consecutive GOT slots. */
@ -1770,14 +1765,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *h,
R_390_TLS_GD64 needs one if local symbol and two if global. */ R_390_TLS_GD64 needs one if local symbol and two if global. */
if ((tls_type == GOT_TLS_GD && h->dynindx == -1) if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
|| tls_type >= GOT_TLS_IE) || tls_type >= GOT_TLS_IE)
htab->srelgot->size += sizeof (Elf64_External_Rela); htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
else if (tls_type == GOT_TLS_GD) else if (tls_type == GOT_TLS_GD)
htab->srelgot->size += 2 * sizeof (Elf64_External_Rela); htab->elf.srelgot->size += 2 * sizeof (Elf64_External_Rela);
else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak) || h->root.type != bfd_link_hash_undefweak)
&& (info->shared && (info->shared
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
htab->srelgot->size += sizeof (Elf64_External_Rela); htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
} }
else else
h->got.offset = (bfd_vma) -1; h->got.offset = (bfd_vma) -1;
@ -1977,8 +1972,8 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
locsymcount = symtab_hdr->sh_info; locsymcount = symtab_hdr->sh_info;
end_local_got = local_got + locsymcount; end_local_got = local_got + locsymcount;
local_tls_type = elf_s390_local_got_tls_type (ibfd); local_tls_type = elf_s390_local_got_tls_type (ibfd);
s = htab->sgot; s = htab->elf.sgot;
srela = htab->srelgot; srela = htab->elf.srelgot;
for (; local_got < end_local_got; ++local_got, ++local_tls_type) for (; local_got < end_local_got; ++local_got, ++local_tls_type)
{ {
if (*local_got > 0) if (*local_got > 0)
@ -1999,9 +1994,9 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
{ {
/* Allocate 2 got entries and 1 dynamic reloc for R_390_TLS_LDM64 /* Allocate 2 got entries and 1 dynamic reloc for R_390_TLS_LDM64
relocs. */ relocs. */
htab->tls_ldm_got.offset = htab->sgot->size; htab->tls_ldm_got.offset = htab->elf.sgot->size;
htab->sgot->size += 2 * GOT_ENTRY_SIZE; htab->elf.sgot->size += 2 * GOT_ENTRY_SIZE;
htab->srelgot->size += sizeof (Elf64_External_Rela); htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
} }
else else
htab->tls_ldm_got.offset = -1; htab->tls_ldm_got.offset = -1;
@ -2018,9 +2013,9 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if ((s->flags & SEC_LINKER_CREATED) == 0) if ((s->flags & SEC_LINKER_CREATED) == 0)
continue; continue;
if (s == htab->splt if (s == htab->elf.splt
|| s == htab->sgot || s == htab->elf.sgot
|| s == htab->sgotplt || s == htab->elf.sgotplt
|| s == htab->sdynbss) || s == htab->sdynbss)
{ {
/* Strip this section if we don't need it; see the /* Strip this section if we don't need it; see the
@ -2028,7 +2023,7 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
} }
else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
{ {
if (s->size != 0 && s != htab->srelplt) if (s->size != 0 && s != htab->elf.srelplt)
relocs = TRUE; relocs = TRUE;
/* We use the reloc_count field as a counter if we need /* We use the reloc_count field as a counter if we need
@ -2086,7 +2081,7 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
return FALSE; return FALSE;
} }
if (htab->splt->size != 0) if (htab->elf.splt->size != 0)
{ {
if (!add_dynamic_entry (DT_PLTGOT, 0) if (!add_dynamic_entry (DT_PLTGOT, 0)
|| !add_dynamic_entry (DT_PLTRELSZ, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0)
@ -2288,7 +2283,7 @@ elf_s390_relocate_section (bfd *output_bfd,
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
if (r_type == R_390_GOTPLTENT) if (r_type == R_390_GOTPLTENT)
relocation += htab->sgot->output_section->vma; relocation += htab->elf.sgot->output_section->vma;
break; break;
} }
/* Fall through. */ /* Fall through. */
@ -2301,7 +2296,7 @@ elf_s390_relocate_section (bfd *output_bfd,
case R_390_GOTENT: case R_390_GOTENT:
/* Relocation is to the entry for this symbol in the global /* Relocation is to the entry for this symbol in the global
offset table. */ offset table. */
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
abort (); abort ();
if (h != NULL) if (h != NULL)
@ -2333,7 +2328,7 @@ elf_s390_relocate_section (bfd *output_bfd,
else else
{ {
bfd_put_64 (output_bfd, relocation, bfd_put_64 (output_bfd, relocation,
htab->sgot->contents + off); htab->elf.sgot->contents + off);
h->got.offset |= 1; h->got.offset |= 1;
} }
} }
@ -2355,7 +2350,7 @@ elf_s390_relocate_section (bfd *output_bfd,
else else
{ {
bfd_put_64 (output_bfd, relocation, bfd_put_64 (output_bfd, relocation,
htab->sgot->contents + off); htab->elf.sgot->contents + off);
if (info->shared) if (info->shared)
{ {
@ -2363,12 +2358,12 @@ elf_s390_relocate_section (bfd *output_bfd,
Elf_Internal_Rela outrel; Elf_Internal_Rela outrel;
bfd_byte *loc; bfd_byte *loc;
s = htab->srelgot; s = htab->elf.srelgot;
if (s == NULL) if (s == NULL)
abort (); abort ();
outrel.r_offset = (htab->sgot->output_section->vma outrel.r_offset = (htab->elf.sgot->output_section->vma
+ htab->sgot->output_offset + htab->elf.sgot->output_offset
+ off); + off);
outrel.r_info = ELF64_R_INFO (0, R_390_RELATIVE); outrel.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
outrel.r_addend = relocation; outrel.r_addend = relocation;
@ -2384,7 +2379,7 @@ elf_s390_relocate_section (bfd *output_bfd,
if (off >= (bfd_vma) -2) if (off >= (bfd_vma) -2)
abort (); abort ();
relocation = htab->sgot->output_offset + off; relocation = htab->elf.sgot->output_offset + off;
/* For @GOTENT the relocation is against the offset between /* For @GOTENT the relocation is against the offset between
the instruction and the symbols entry in the GOT and not the instruction and the symbols entry in the GOT and not
@ -2392,7 +2387,7 @@ elf_s390_relocate_section (bfd *output_bfd,
add the vma of the GOT to get the correct value. */ add the vma of the GOT to get the correct value. */
if ( r_type == R_390_GOTENT if ( r_type == R_390_GOTENT
|| r_type == R_390_GOTPLTENT) || r_type == R_390_GOTPLTENT)
relocation += htab->sgot->output_section->vma; relocation += htab->elf.sgot->output_section->vma;
break; break;
@ -2407,13 +2402,13 @@ elf_s390_relocate_section (bfd *output_bfd,
defined _GLOBAL_OFFSET_TABLE in a different way, as is defined _GLOBAL_OFFSET_TABLE in a different way, as is
permitted by the ABI, we might have to change this permitted by the ABI, we might have to change this
calculation. */ calculation. */
relocation -= htab->sgot->output_section->vma; relocation -= htab->elf.sgot->output_section->vma;
break; break;
case R_390_GOTPC: case R_390_GOTPC:
case R_390_GOTPCDBL: case R_390_GOTPCDBL:
/* Use global offset table as symbol value. */ /* Use global offset table as symbol value. */
relocation = htab->sgot->output_section->vma; relocation = htab->elf.sgot->output_section->vma;
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -2430,7 +2425,7 @@ elf_s390_relocate_section (bfd *output_bfd,
break; break;
if (h->plt.offset == (bfd_vma) -1 if (h->plt.offset == (bfd_vma) -1
|| htab->splt == NULL) || htab->elf.splt == NULL)
{ {
/* We didn't make a PLT entry for this symbol. This /* We didn't make a PLT entry for this symbol. This
happens when statically linking PIC code, or when happens when statically linking PIC code, or when
@ -2438,8 +2433,8 @@ elf_s390_relocate_section (bfd *output_bfd,
break; break;
} }
relocation = (htab->splt->output_section->vma relocation = (htab->elf.splt->output_section->vma
+ htab->splt->output_offset + htab->elf.splt->output_offset
+ h->plt.offset); + h->plt.offset);
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -2454,16 +2449,16 @@ elf_s390_relocate_section (bfd *output_bfd,
this symbol resolve the symbol directly. */ this symbol resolve the symbol directly. */
if ( h == NULL if ( h == NULL
|| h->plt.offset == (bfd_vma) -1 || h->plt.offset == (bfd_vma) -1
|| htab->splt == NULL) || htab->elf.splt == NULL)
{ {
relocation -= htab->sgot->output_section->vma; relocation -= htab->elf.sgot->output_section->vma;
break; break;
} }
relocation = (htab->splt->output_section->vma relocation = (htab->elf.splt->output_section->vma
+ htab->splt->output_offset + htab->elf.splt->output_offset
+ h->plt.offset + h->plt.offset
- htab->sgot->output_section->vma); - htab->elf.sgot->output_section->vma);
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -2646,7 +2641,7 @@ elf_s390_relocate_section (bfd *output_bfd,
continue; continue;
} }
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
abort (); abort ();
if (h != NULL) if (h != NULL)
@ -2669,11 +2664,11 @@ elf_s390_relocate_section (bfd *output_bfd,
bfd_byte *loc; bfd_byte *loc;
int dr_type, indx; int dr_type, indx;
if (htab->srelgot == NULL) if (htab->elf.srelgot == NULL)
abort (); abort ();
outrel.r_offset = (htab->sgot->output_section->vma outrel.r_offset = (htab->elf.sgot->output_section->vma
+ htab->sgot->output_offset + off); + htab->elf.sgot->output_offset + off);
indx = h && h->dynindx != -1 ? h->dynindx : 0; indx = h && h->dynindx != -1 ? h->dynindx : 0;
if (r_type == R_390_TLS_GD64) if (r_type == R_390_TLS_GD64)
@ -2685,8 +2680,8 @@ elf_s390_relocate_section (bfd *output_bfd,
else else
outrel.r_addend = 0; outrel.r_addend = 0;
outrel.r_info = ELF64_R_INFO (indx, dr_type); outrel.r_info = ELF64_R_INFO (indx, dr_type);
loc = htab->srelgot->contents; loc = htab->elf.srelgot->contents;
loc += htab->srelgot->reloc_count++ loc += htab->elf.srelgot->reloc_count++
* sizeof (Elf64_External_Rela); * sizeof (Elf64_External_Rela);
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
@ -2697,14 +2692,14 @@ elf_s390_relocate_section (bfd *output_bfd,
BFD_ASSERT (! unresolved_reloc); BFD_ASSERT (! unresolved_reloc);
bfd_put_64 (output_bfd, bfd_put_64 (output_bfd,
relocation - dtpoff_base (info), relocation - dtpoff_base (info),
htab->sgot->contents + off + GOT_ENTRY_SIZE); htab->elf.sgot->contents + off + GOT_ENTRY_SIZE);
} }
else else
{ {
outrel.r_info = ELF64_R_INFO (indx, R_390_TLS_DTPOFF); outrel.r_info = ELF64_R_INFO (indx, R_390_TLS_DTPOFF);
outrel.r_offset += GOT_ENTRY_SIZE; outrel.r_offset += GOT_ENTRY_SIZE;
outrel.r_addend = 0; outrel.r_addend = 0;
htab->srelgot->reloc_count++; htab->elf.srelgot->reloc_count++;
loc += sizeof (Elf64_External_Rela); loc += sizeof (Elf64_External_Rela);
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
} }
@ -2720,14 +2715,14 @@ elf_s390_relocate_section (bfd *output_bfd,
abort (); abort ();
if (r_type == ELF64_R_TYPE (rel->r_info)) if (r_type == ELF64_R_TYPE (rel->r_info))
{ {
relocation = htab->sgot->output_offset + off; relocation = htab->elf.sgot->output_offset + off;
if (r_type == R_390_TLS_IE64 || r_type == R_390_TLS_IEENT) if (r_type == R_390_TLS_IE64 || r_type == R_390_TLS_IEENT)
relocation += htab->sgot->output_section->vma; relocation += htab->elf.sgot->output_section->vma;
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
} }
else else
{ {
bfd_put_64 (output_bfd, htab->sgot->output_offset + off, bfd_put_64 (output_bfd, htab->elf.sgot->output_offset + off,
contents + rel->r_offset); contents + rel->r_offset);
continue; continue;
} }
@ -2752,15 +2747,15 @@ elf_s390_relocate_section (bfd *output_bfd,
goto emit_tls_relocs; goto emit_tls_relocs;
} }
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
abort (); abort ();
BFD_ASSERT (! unresolved_reloc); BFD_ASSERT (! unresolved_reloc);
bfd_put_64 (output_bfd, -tpoff (info, relocation), bfd_put_64 (output_bfd, -tpoff (info, relocation),
htab->sgot->contents + off); htab->elf.sgot->contents + off);
relocation = htab->sgot->output_offset + off; relocation = htab->elf.sgot->output_offset + off;
if (r_type == R_390_TLS_IEENT) if (r_type == R_390_TLS_IEENT)
relocation += htab->sgot->output_section->vma; relocation += htab->elf.sgot->output_section->vma;
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -2771,7 +2766,7 @@ elf_s390_relocate_section (bfd *output_bfd,
and the value will turn out zero. */ and the value will turn out zero. */
continue; continue;
if (htab->sgot == NULL) if (htab->elf.sgot == NULL)
abort (); abort ();
off = htab->tls_ldm_got.offset; off = htab->tls_ldm_got.offset;
@ -2782,23 +2777,23 @@ elf_s390_relocate_section (bfd *output_bfd,
Elf_Internal_Rela outrel; Elf_Internal_Rela outrel;
bfd_byte *loc; bfd_byte *loc;
if (htab->srelgot == NULL) if (htab->elf.srelgot == NULL)
abort (); abort ();
outrel.r_offset = (htab->sgot->output_section->vma outrel.r_offset = (htab->elf.sgot->output_section->vma
+ htab->sgot->output_offset + off); + htab->elf.sgot->output_offset + off);
bfd_put_64 (output_bfd, 0, bfd_put_64 (output_bfd, 0,
htab->sgot->contents + off + GOT_ENTRY_SIZE); htab->elf.sgot->contents + off + GOT_ENTRY_SIZE);
outrel.r_info = ELF64_R_INFO (0, R_390_TLS_DTPMOD); outrel.r_info = ELF64_R_INFO (0, R_390_TLS_DTPMOD);
outrel.r_addend = 0; outrel.r_addend = 0;
loc = htab->srelgot->contents; loc = htab->elf.srelgot->contents;
loc += htab->srelgot->reloc_count++ loc += htab->elf.srelgot->reloc_count++
* sizeof (Elf64_External_Rela); * sizeof (Elf64_External_Rela);
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
htab->tls_ldm_got.offset |= 1; htab->tls_ldm_got.offset |= 1;
} }
relocation = htab->sgot->output_offset + off; relocation = htab->elf.sgot->output_offset + off;
unresolved_reloc = FALSE; unresolved_reloc = FALSE;
break; break;
@ -3043,9 +3038,9 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
it up. */ it up. */
if (h->dynindx == -1 if (h->dynindx == -1
|| htab->splt == NULL || htab->elf.splt == NULL
|| htab->sgotplt == NULL || htab->elf.sgotplt == NULL
|| htab->srelplt == NULL) || htab->elf.srelplt == NULL)
abort (); abort ();
/* Calc. index no. /* Calc. index no.
@ -3057,39 +3052,39 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
got_offset = (plt_index + 3) * GOT_ENTRY_SIZE; got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
/* Fill in the blueprint of a PLT. */ /* Fill in the blueprint of a PLT. */
memcpy (htab->splt->contents + h->plt.offset, elf_s390x_plt_entry, memcpy (htab->elf.splt->contents + h->plt.offset, elf_s390x_plt_entry,
PLT_ENTRY_SIZE); PLT_ENTRY_SIZE);
/* Fixup the relative address to the GOT entry */ /* Fixup the relative address to the GOT entry */
bfd_put_32 (output_bfd, bfd_put_32 (output_bfd,
(htab->sgotplt->output_section->vma + (htab->elf.sgotplt->output_section->vma +
htab->sgotplt->output_offset + got_offset htab->elf.sgotplt->output_offset + got_offset
- (htab->splt->output_section->vma + h->plt.offset))/2, - (htab->elf.splt->output_section->vma + h->plt.offset))/2,
htab->splt->contents + h->plt.offset + 2); htab->elf.splt->contents + h->plt.offset + 2);
/* Fixup the relative branch to PLT 0 */ /* Fixup the relative branch to PLT 0 */
bfd_put_32 (output_bfd, - (PLT_FIRST_ENTRY_SIZE + bfd_put_32 (output_bfd, - (PLT_FIRST_ENTRY_SIZE +
(PLT_ENTRY_SIZE * plt_index) + 22)/2, (PLT_ENTRY_SIZE * plt_index) + 22)/2,
htab->splt->contents + h->plt.offset + 24); htab->elf.splt->contents + h->plt.offset + 24);
/* Fixup offset into symbol table */ /* Fixup offset into symbol table */
bfd_put_32 (output_bfd, plt_index * sizeof (Elf64_External_Rela), bfd_put_32 (output_bfd, plt_index * sizeof (Elf64_External_Rela),
htab->splt->contents + h->plt.offset + 28); htab->elf.splt->contents + h->plt.offset + 28);
/* Fill in the entry in the global offset table. /* Fill in the entry in the global offset table.
Points to instruction after GOT offset. */ Points to instruction after GOT offset. */
bfd_put_64 (output_bfd, bfd_put_64 (output_bfd,
(htab->splt->output_section->vma (htab->elf.splt->output_section->vma
+ htab->splt->output_offset + htab->elf.splt->output_offset
+ h->plt.offset + h->plt.offset
+ 14), + 14),
htab->sgotplt->contents + got_offset); htab->elf.sgotplt->contents + got_offset);
/* Fill in the entry in the .rela.plt section. */ /* Fill in the entry in the .rela.plt section. */
rela.r_offset = (htab->sgotplt->output_section->vma rela.r_offset = (htab->elf.sgotplt->output_section->vma
+ htab->sgotplt->output_offset + htab->elf.sgotplt->output_offset
+ got_offset); + got_offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_390_JMP_SLOT); rela.r_info = ELF64_R_INFO (h->dynindx, R_390_JMP_SLOT);
rela.r_addend = 0; rela.r_addend = 0;
loc = htab->srelplt->contents + plt_index * sizeof (Elf64_External_Rela); loc = htab->elf.srelplt->contents + plt_index * sizeof (Elf64_External_Rela);
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc); bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
if (!h->def_regular) if (!h->def_regular)
@ -3113,11 +3108,11 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
/* This symbol has an entry in the global offset table. Set it /* This symbol has an entry in the global offset table. Set it
up. */ up. */
if (htab->sgot == NULL || htab->srelgot == NULL) if (htab->elf.sgot == NULL || htab->elf.srelgot == NULL)
abort (); abort ();
rela.r_offset = (htab->sgot->output_section->vma rela.r_offset = (htab->elf.sgot->output_section->vma
+ htab->sgot->output_offset + htab->elf.sgot->output_offset
+ (h->got.offset &~ (bfd_vma) 1)); + (h->got.offset &~ (bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the /* If this is a static link, or it is a -Bsymbolic link and the
@ -3139,13 +3134,13 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
else else
{ {
BFD_ASSERT((h->got.offset & 1) == 0); BFD_ASSERT((h->got.offset & 1) == 0);
bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgot->contents + h->got.offset); bfd_put_64 (output_bfd, (bfd_vma) 0, htab->elf.sgot->contents + h->got.offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_390_GLOB_DAT); rela.r_info = ELF64_R_INFO (h->dynindx, R_390_GLOB_DAT);
rela.r_addend = 0; rela.r_addend = 0;
} }
loc = htab->srelgot->contents; loc = htab->elf.srelgot->contents;
loc += htab->srelgot->reloc_count++ * sizeof (Elf64_External_Rela); loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc); bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
} }
@ -3222,7 +3217,7 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
{ {
Elf64_External_Dyn *dyncon, *dynconend; Elf64_External_Dyn *dyncon, *dynconend;
if (sdyn == NULL || htab->sgot == NULL) if (sdyn == NULL || htab->elf.sgot == NULL)
abort (); abort ();
dyncon = (Elf64_External_Dyn *) sdyn->contents; dyncon = (Elf64_External_Dyn *) sdyn->contents;
@ -3240,15 +3235,15 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
continue; continue;
case DT_PLTGOT: case DT_PLTGOT:
dyn.d_un.d_ptr = htab->sgot->output_section->vma; dyn.d_un.d_ptr = htab->elf.sgot->output_section->vma;
break; break;
case DT_JMPREL: case DT_JMPREL:
dyn.d_un.d_ptr = htab->srelplt->output_section->vma; dyn.d_un.d_ptr = htab->elf.srelplt->output_section->vma;
break; break;
case DT_PLTRELSZ: case DT_PLTRELSZ:
s = htab->srelplt->output_section; s = htab->elf.srelplt->output_section;
dyn.d_un.d_val = s->size; dyn.d_un.d_val = s->size;
break; break;
@ -3260,7 +3255,7 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
linker script arranges for .rela.plt to follow all linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry other relocation sections, we don't have to worry
about changing the DT_RELA entry. */ about changing the DT_RELA entry. */
s = htab->srelplt->output_section; s = htab->elf.srelplt->output_section;
dyn.d_un.d_val -= s->size; dyn.d_un.d_val -= s->size;
break; break;
} }
@ -3269,38 +3264,38 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
} }
/* Fill in the special first entry in the procedure linkage table. */ /* Fill in the special first entry in the procedure linkage table. */
if (htab->splt && htab->splt->size > 0) if (htab->elf.splt && htab->elf.splt->size > 0)
{ {
/* fill in blueprint for plt 0 entry */ /* fill in blueprint for plt 0 entry */
memcpy (htab->splt->contents, elf_s390x_first_plt_entry, memcpy (htab->elf.splt->contents, elf_s390x_first_plt_entry,
PLT_FIRST_ENTRY_SIZE); PLT_FIRST_ENTRY_SIZE);
/* Fixup relative address to start of GOT */ /* Fixup relative address to start of GOT */
bfd_put_32 (output_bfd, bfd_put_32 (output_bfd,
(htab->sgotplt->output_section->vma + (htab->elf.sgotplt->output_section->vma +
htab->sgotplt->output_offset htab->elf.sgotplt->output_offset
- htab->splt->output_section->vma - 6)/2, - htab->elf.splt->output_section->vma - 6)/2,
htab->splt->contents + 8); htab->elf.splt->contents + 8);
} }
elf_section_data (htab->splt->output_section) elf_section_data (htab->elf.splt->output_section)
->this_hdr.sh_entsize = PLT_ENTRY_SIZE; ->this_hdr.sh_entsize = PLT_ENTRY_SIZE;
} }
if (htab->sgotplt) if (htab->elf.sgotplt)
{ {
/* Fill in the first three entries in the global offset table. */ /* Fill in the first three entries in the global offset table. */
if (htab->sgotplt->size > 0) if (htab->elf.sgotplt->size > 0)
{ {
bfd_put_64 (output_bfd, bfd_put_64 (output_bfd,
(sdyn == NULL ? (bfd_vma) 0 (sdyn == NULL ? (bfd_vma) 0
: sdyn->output_section->vma + sdyn->output_offset), : sdyn->output_section->vma + sdyn->output_offset),
htab->sgotplt->contents); htab->elf.sgotplt->contents);
/* One entry for shared object struct ptr. */ /* One entry for shared object struct ptr. */
bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 8); bfd_put_64 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + 8);
/* One entry for _dl_runtime_resolve. */ /* One entry for _dl_runtime_resolve. */
bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 12); bfd_put_64 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + 12);
} }
elf_section_data (htab->sgot->output_section) elf_section_data (htab->elf.sgot->output_section)
->this_hdr.sh_entsize = 8; ->this_hdr.sh_entsize = 8;
} }
return TRUE; return TRUE;