* configure.in (elf): Add elf-ifunc.lo.
* configure: Regenerated.
* Makefile.in: Likewise.
* elf-bfd.h (elf_link_hash_table): Add sgot, sgotplt,
srelgot, splt, srelplt, igotplt, iplt, irelplt and irelifunc.
* elf32-i386.c (elf_i386_link_hash_table): Remove sgot,
sgotplt, srelgot, splt, srelplt, igotplt, iplt, irelplt and
irelifunc.
(elf_i386_link_hash_table_create): Likewise.
(elf_i386_create_dynamic_sections): Likewise.
(elf_i386_check_relocs): Likewise.
(elf_i386_allocate_dynrelocs): Likewise.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Likewise.
(elf_i386_finish_dynamic_symbol): Likewise.
(elf_i386_finish_dynamic_sections): Likewise.
(elf_i386_create_got_section): Removed.
* elf64-x86-64.c (elf64_x86_64_link_hash_table): Remove sgot,
sgotplt, srelgot, splt, srelplt, igotplt, iplt, irelplt and
irelifunc.
(elf64_x86_64_compute_jump_table_size): Updated.
(elf64_x86_64_link_hash_table_create): Likewise.
(elf64_x86_64_create_dynamic_sections): Likewise.
(elf64_x86_64_check_relocs): Likewise.
(elf64_x86_64_allocate_dynrelocs): Likewise.
(elf64_x86_64_size_dynamic_sections): Likewise.
(elf64_x86_64_relocate_section): Likewise.
(elf64_x86_64_finish_dynamic_symbol): Likewise.
(elf64_x86_64_finish_dynamic_sections): Likewise.
(elf64_x86_64_create_got_section): Removed.
* elflink.c (_bfd_elf_create_got_section): Use log_file_align
for pointer alignment. Set up section pointers.
(_bfd_elf_create_dynamic_sections): Likewise.
(_bfd_elf_create_ifunc_sections): Moved to ...
* elf-ifunc.c: Here. New.
* Makefile.am (BFD32_BACKENDS): Add elf-ifunc.lo.
(BFD32_BACKENDS_CFILES): Add elf-ifunc.c.
Run "make dep-am".
+2009-06-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ * configure.in (elf): Add elf-ifunc.lo.
+
+ * configure: Regenerated.
+ * Makefile.in: Likewise.
+
+ * elf-bfd.h (elf_link_hash_table): Add sgot, sgotplt,
+ srelgot, splt, srelplt, igotplt, iplt, irelplt and irelifunc.
+
+ * elf32-i386.c (elf_i386_link_hash_table): Remove sgot,
+ sgotplt, srelgot, splt, srelplt, igotplt, iplt, irelplt and
+ irelifunc.
+ (elf_i386_link_hash_table_create): Likewise.
+ (elf_i386_create_dynamic_sections): Likewise.
+ (elf_i386_check_relocs): Likewise.
+ (elf_i386_allocate_dynrelocs): Likewise.
+ (elf_i386_size_dynamic_sections): Likewise.
+ (elf_i386_relocate_section): Likewise.
+ (elf_i386_finish_dynamic_symbol): Likewise.
+ (elf_i386_finish_dynamic_sections): Likewise.
+ (elf_i386_create_got_section): Removed.
+
+ * elf64-x86-64.c (elf64_x86_64_link_hash_table): Remove sgot,
+ sgotplt, srelgot, splt, srelplt, igotplt, iplt, irelplt and
+ irelifunc.
+ (elf64_x86_64_compute_jump_table_size): Updated.
+ (elf64_x86_64_link_hash_table_create): Likewise.
+ (elf64_x86_64_create_dynamic_sections): Likewise.
+ (elf64_x86_64_check_relocs): Likewise.
+ (elf64_x86_64_allocate_dynrelocs): Likewise.
+ (elf64_x86_64_size_dynamic_sections): Likewise.
+ (elf64_x86_64_relocate_section): Likewise.
+ (elf64_x86_64_finish_dynamic_symbol): Likewise.
+ (elf64_x86_64_finish_dynamic_sections): Likewise.
+ (elf64_x86_64_create_got_section): Removed.
+
+ * elflink.c (_bfd_elf_create_got_section): Use log_file_align
+ for pointer alignment. Set up section pointers.
+ (_bfd_elf_create_dynamic_sections): Likewise.
+ (_bfd_elf_create_ifunc_sections): Moved to ...
+ * elf-ifunc.c: Here. New.
+
+ * Makefile.am (BFD32_BACKENDS): Add elf-ifunc.lo.
+ (BFD32_BACKENDS_CFILES): Add elf-ifunc.c.
+ Run "make dep-am".
+
2009-06-16 Doug Kwan <dougkwan@google.com>
- * elf32-arm.c (cortex_a8_erratum_scan): Change type of offset
- to bfd_signed_vma. Cast constant operands which are used in
- offset related expressions to bfd_signed_vma type as appropriate.
+ * elf32-arm.c (cortex_a8_erratum_scan): Change type of offset
+ to bfd_signed_vma. Cast constant operands which are used in
+ offset related expressions to bfd_signed_vma type as appropriate.
2009-06-16 Maciej W. Rozycki <macro@linux-mips.org>
ecofflink.lo \
elf-attrs.lo \
elf-eh-frame.lo \
+ elf-ifunc.lo \
elf-m10200.lo \
elf-m10300.lo \
elf-strtab.lo \
ecofflink.c \
elf-attrs.c \
elf-eh-frame.c \
+ elf-ifunc.c \
elf-m10200.c \
elf-m10300.c \
elf-strtab.c \
$(INCDIR)/filenames.h \
$(INCDIR)/hashtab.h \
elf-bfd.h
+elf-ifunc.lo: \
+ elf-ifunc.c \
+ $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/internal.h \
+ $(INCDIR)/filenames.h \
+ $(INCDIR)/hashtab.h \
+ $(INCDIR)/libiberty.h \
+ $(INCDIR)/objalloc.h \
+ $(INCDIR)/safe-ctype.h \
+ elf-bfd.h
elf-m10200.lo: \
elf-m10200.c \
$(INCDIR)/bfdlink.h \
ecofflink.lo \
elf-attrs.lo \
elf-eh-frame.lo \
+ elf-ifunc.lo \
elf-m10200.lo \
elf-m10300.lo \
elf-strtab.lo \
ecofflink.c \
elf-attrs.c \
elf-eh-frame.c \
+ elf-ifunc.c \
elf-m10200.c \
elf-m10300.c \
elf-strtab.c \
$(INCDIR)/filenames.h \
$(INCDIR)/hashtab.h \
elf-bfd.h
+elf-ifunc.lo: \
+ elf-ifunc.c \
+ $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/external.h \
+ $(INCDIR)/elf/internal.h \
+ $(INCDIR)/filenames.h \
+ $(INCDIR)/hashtab.h \
+ $(INCDIR)/libiberty.h \
+ $(INCDIR)/objalloc.h \
+ $(INCDIR)/safe-ctype.h \
+ elf-bfd.h
elf-m10200.lo: \
elf-m10200.c \
$(INCDIR)/bfdlink.h \
# Target backend .o files.
tb=
-elf="elf.lo elflink.lo elf-attrs.lo elf-strtab.lo elf-eh-frame.lo dwarf1.lo"
+elf="elf.lo elflink.lo elf-attrs.lo elf-ifunc.lo elf-strtab.lo
+ elf-eh-frame.lo dwarf1.lo"
for vec in $selvecs
do
# Target backend .o files.
tb=
-elf="elf.lo elflink.lo elf-attrs.lo elf-strtab.lo elf-eh-frame.lo dwarf1.lo"
+elf="elf.lo elflink.lo elf-attrs.lo elf-ifunc.lo elf-strtab.lo
+ elf-eh-frame.lo dwarf1.lo"
for vec in $selvecs
do
/* A linked list of BFD's loaded in the link. */
struct elf_link_loaded_list *loaded;
+
+ /* Short-cuts to get to dynamic linker sections. */
+ asection *sgot;
+ asection *sgotplt;
+ asection *srelgot;
+ asection *splt;
+ asection *srelplt;
+ asection *igotplt;
+ asection *iplt;
+ asection *irelplt;
+ asection *irelifunc;
};
/* Look up an entry in an ELF linker hash table. */
--- /dev/null
+/* ELF STT_GNU_IFUNC support.
+ Copyright 2009
+ Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#define ARCH_SIZE 0
+#include "elf-bfd.h"
+#include "safe-ctype.h"
+#include "libiberty.h"
+#include "objalloc.h"
+
+/* Create sections needed by STT_GNU_IFUNC symbol. */
+
+bfd_boolean
+_bfd_elf_create_ifunc_sections (bfd *abfd, struct bfd_link_info *info)
+{
+ flagword flags, pltflags;
+ asection *s;
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ struct elf_link_hash_table *htab = elf_hash_table (info);
+
+ if (htab->irelifunc != NULL || htab->iplt != NULL)
+ return TRUE;
+
+ flags = bed->dynamic_sec_flags;
+ pltflags = flags;
+ if (bed->plt_not_loaded)
+ /* We do not clear SEC_ALLOC here because we still want the OS to
+ allocate space for the section; it's just that there's nothing
+ to read in from the object file. */
+ pltflags &= ~ (SEC_CODE | SEC_LOAD | SEC_HAS_CONTENTS);
+ else
+ pltflags |= SEC_ALLOC | SEC_CODE | SEC_LOAD;
+ if (bed->plt_readonly)
+ pltflags |= SEC_READONLY;
+
+ if (info->shared)
+ {
+ /* We need to create .rel[a].ifunc for shared objects. */
+ const char *rel_sec = (bed->rela_plts_and_copies_p
+ ? ".rela.ifunc" : ".rel.ifunc");
+
+ s = bfd_make_section_with_flags (abfd, rel_sec,
+ flags | SEC_READONLY);
+ if (s == NULL
+ || ! bfd_set_section_alignment (abfd, s,
+ bed->s->log_file_align))
+ return FALSE;
+ htab->irelifunc = s;
+ }
+ else
+ {
+ /* We need to create .iplt, .rel[a].iplt, .igot and .igot.plt
+ for static executables. */
+ s = bfd_make_section_with_flags (abfd, ".iplt", pltflags);
+ if (s == NULL
+ || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+ return FALSE;
+ htab->iplt = s;
+
+ s = bfd_make_section_with_flags (abfd,
+ (bed->rela_plts_and_copies_p
+ ? ".rela.iplt" : ".rel.iplt"),
+ flags | SEC_READONLY);
+ if (s == NULL
+ || ! bfd_set_section_alignment (abfd, s,
+ bed->s->log_file_align))
+ return FALSE;
+ htab->irelplt = s;
+
+ /* We don't need the .igot section if we have the .igot.plt
+ section. */
+ if (bed->want_got_plt)
+ s = bfd_make_section_with_flags (abfd, ".igot.plt", flags);
+ else
+ s = bfd_make_section_with_flags (abfd, ".igot", flags);
+ if (s == NULL
+ || !bfd_set_section_alignment (abfd, s,
+ bed->s->log_file_align))
+ return FALSE;
+ htab->igotplt = s;
+ }
+
+ return TRUE;
+}
struct elf_link_hash_table elf;
/* Short-cuts to get to dynamic linker sections. */
- asection *sgot;
- asection *sgotplt;
- asection *srelgot;
- asection *splt;
- asection *srelplt;
asection *sdynbss;
asection *srelbss;
- asection *igotplt;
- asection *iplt;
- asection *irelplt;
- asection *irelifunc;
/* The (unloaded but important) .rel.plt.unloaded section on VxWorks. */
asection *srelplt2;
return NULL;
}
- ret->sgot = NULL;
- ret->sgotplt = NULL;
- ret->srelgot = NULL;
- ret->splt = NULL;
- ret->srelplt = NULL;
ret->sdynbss = NULL;
ret->srelbss = NULL;
- ret->igotplt= NULL;
- ret->iplt = NULL;
- ret->irelplt= NULL;
- ret->irelifunc = NULL;
ret->tls_ldm_got.refcount = 0;
ret->next_tls_desc_index = 0;
ret->sgotplt_jump_table_size = 0;
_bfd_generic_link_hash_table_free (hash);
}
-/* Create .got, .gotplt, and .rel.got sections in DYNOBJ, and set up
- shortcuts to them in our hash table. */
-
-static bfd_boolean
-elf_i386_create_got_section (bfd *dynobj, struct bfd_link_info *info)
-{
- struct elf_i386_link_hash_table *htab;
-
- if (! _bfd_elf_create_got_section (dynobj, info))
- return FALSE;
-
- htab = elf_i386_hash_table (info);
- htab->sgot = bfd_get_section_by_name (dynobj, ".got");
- htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
- if (!htab->sgot || !htab->sgotplt)
- abort ();
-
- htab->srelgot = bfd_make_section_with_flags (dynobj, ".rel.got",
- (SEC_ALLOC | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED
- | SEC_READONLY));
- if (htab->srelgot == NULL
- || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
- return FALSE;
- return TRUE;
-}
-
/* Create .plt, .rel.plt, .got, .got.plt, .rel.got, .dynbss, and
.rel.bss sections in DYNOBJ, and set up shortcuts to them in our
hash table. */
{
struct elf_i386_link_hash_table *htab;
- htab = elf_i386_hash_table (info);
- if (!htab->sgot && !elf_i386_create_got_section (dynobj, info))
- return FALSE;
-
if (!_bfd_elf_create_dynamic_sections (dynobj, info))
return FALSE;
- htab->splt = bfd_get_section_by_name (dynobj, ".plt");
- htab->srelplt = bfd_get_section_by_name (dynobj, ".rel.plt");
+ htab = elf_i386_hash_table (info);
htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
if (!info->shared)
htab->srelbss = bfd_get_section_by_name (dynobj, ".rel.bss");
- if (!htab->splt || !htab->srelplt || !htab->sdynbss
+ if (!htab->sdynbss
|| (!info->shared && !htab->srelbss))
abort ();
if (htab->is_vxworks
- && !elf_vxworks_create_dynamic_sections (dynobj, info, &htab->srelplt2))
+ && !elf_vxworks_create_dynamic_sections (dynobj, info,
+ &htab->srelplt2))
return FALSE;
return TRUE;
case R_386_PLT32:
case R_386_GOT32:
case R_386_GOTOFF:
- if (htab->irelifunc == NULL && htab->iplt == NULL)
- {
- if (!_bfd_elf_create_ifunc_sections (abfd, info))
- return FALSE;
-
- if (info->shared)
- {
- htab->irelifunc = bfd_get_section_by_name (abfd,
- ".rel.ifunc");
- if (!htab->irelifunc)
- abort ();
- }
- else
- {
- htab->iplt = bfd_get_section_by_name (abfd, ".iplt");
- htab->irelplt = bfd_get_section_by_name (abfd,
- ".rel.iplt");
- htab->igotplt = bfd_get_section_by_name (abfd,
- ".igot.plt");
- if (!htab->iplt
- || !htab->irelplt
- || !htab->igotplt)
- abort ();
- }
- }
+ if (!_bfd_elf_create_ifunc_sections (abfd, info))
+ return FALSE;
break;
}
case R_386_GOT32:
case R_386_GOTOFF:
h->got.refcount += 1;
- if (htab->sgot == NULL
- && !elf_i386_create_got_section (htab->elf.dynobj,
+ if (htab->elf.sgot == NULL
+ && !_bfd_elf_create_got_section (htab->elf.dynobj,
info))
return FALSE;
break;
case R_386_GOTOFF:
case R_386_GOTPC:
create_got:
- if (htab->sgot == NULL)
+ if (htab->elf.sgot == NULL)
{
if (htab->elf.dynobj == NULL)
htab->elf.dynobj = abfd;
- if (!elf_i386_create_got_section (htab->elf.dynobj, info))
+ if (!_bfd_elf_create_got_section (htab->elf.dynobj, info))
return FALSE;
}
if (r_type != R_386_TLS_IE)
/* When building a static executable, use .iplt, .igot.plt and
.rel.iplt sections for STT_GNU_IFUNC symbols. */
- if (htab->splt != NULL)
+ if (htab->elf.splt != NULL)
{
- plt = htab->splt;
- gotplt = htab->sgotplt;
- relplt = htab->srelplt;
+ plt = htab->elf.splt;
+ gotplt = htab->elf.sgotplt;
+ relplt = htab->elf.srelplt;
/* If this is the first .plt entry, make room for the special
first entry. */
}
else
{
- plt = htab->iplt;
- gotplt = htab->igotplt;
- relplt = htab->irelplt;
+ plt = htab->elf.iplt;
+ gotplt = htab->elf.igotplt;
+ relplt = htab->elf.irelplt;
}
/* Don't update value of STT_GNU_IFUNC symbol to PLT. We need
/* Finally, allocate space. */
for (p = eh->dyn_relocs; p != NULL; p = p->next)
- htab->irelifunc->size += p->count * sizeof (Elf32_External_Rel);
+ htab->elf.irelifunc->size += p->count * sizeof (Elf32_External_Rel);
/* For STT_GNU_IFUNC symbol, .got.plt has the real function
addres and .got has the PLT entry adddress. We will load
|| (!info->shared
&& !h->pointer_equality_needed)
|| (info->executable && info->shared)
- || htab->sgot == NULL)
+ || htab->elf.sgot == NULL)
{
/* Use .got.plt. */
h->got.offset = (bfd_vma) -1;
}
else
{
- h->got.offset = htab->sgot->size;
- htab->sgot->size += 4;
+ h->got.offset = htab->elf.sgot->size;
+ htab->elf.sgot->size += 4;
if (info->shared)
- htab->srelgot->size += sizeof (Elf32_External_Rel);
+ htab->elf.srelgot->size += sizeof (Elf32_External_Rel);
}
return TRUE;
if (info->shared
|| 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
first entry. */
/* We also need to make an entry in the .got.plt section, which
will be placed in the .got section by the linker script. */
- htab->sgotplt->size += 4;
+ htab->elf.sgotplt->size += 4;
/* We also need to make an entry in the .rel.plt section. */
- htab->srelplt->size += sizeof (Elf32_External_Rel);
+ htab->elf.srelplt->size += sizeof (Elf32_External_Rel);
htab->next_tls_desc_index++;
if (htab->is_vxworks && !info->shared)
return FALSE;
}
- s = htab->sgot;
+ s = htab->elf.sgot;
if (GOT_TLS_GDESC_P (tls_type))
{
- eh->tlsdesc_got = htab->sgotplt->size
+ eh->tlsdesc_got = htab->elf.sgotplt->size
- elf_i386_compute_jump_table_size (htab);
- htab->sgotplt->size += 8;
+ htab->elf.sgotplt->size += 8;
h->got.offset = (bfd_vma) -2;
}
if (! GOT_TLS_GDESC_P (tls_type)
need two), R_386_TLS_GD needs one if local symbol and two if
global. */
if (tls_type == GOT_TLS_IE_BOTH)
- htab->srelgot->size += 2 * sizeof (Elf32_External_Rel);
+ htab->elf.srelgot->size += 2 * sizeof (Elf32_External_Rel);
else if ((GOT_TLS_GD_P (tls_type) && h->dynindx == -1)
|| (tls_type & GOT_TLS_IE))
- htab->srelgot->size += sizeof (Elf32_External_Rel);
+ htab->elf.srelgot->size += sizeof (Elf32_External_Rel);
else if (GOT_TLS_GD_P (tls_type))
- htab->srelgot->size += 2 * sizeof (Elf32_External_Rel);
+ htab->elf.srelgot->size += 2 * sizeof (Elf32_External_Rel);
else if (! GOT_TLS_GDESC_P (tls_type)
&& (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak)
&& (info->shared
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
- htab->srelgot->size += sizeof (Elf32_External_Rel);
+ htab->elf.srelgot->size += sizeof (Elf32_External_Rel);
if (GOT_TLS_GDESC_P (tls_type))
- htab->srelplt->size += sizeof (Elf32_External_Rel);
+ htab->elf.srelplt->size += sizeof (Elf32_External_Rel);
}
else
h->got.offset = (bfd_vma) -1;
end_local_got = local_got + locsymcount;
local_tls_type = elf_i386_local_got_tls_type (ibfd);
local_tlsdesc_gotent = elf_i386_local_tlsdesc_gotent (ibfd);
- s = htab->sgot;
- srel = htab->srelgot;
+ s = htab->elf.sgot;
+ srel = htab->elf.srelgot;
for (; local_got < end_local_got;
++local_got, ++local_tls_type, ++local_tlsdesc_gotent)
{
{
if (GOT_TLS_GDESC_P (*local_tls_type))
{
- *local_tlsdesc_gotent = htab->sgotplt->size
+ *local_tlsdesc_gotent = htab->elf.sgotplt->size
- elf_i386_compute_jump_table_size (htab);
- htab->sgotplt->size += 8;
+ htab->elf.sgotplt->size += 8;
*local_got = (bfd_vma) -2;
}
if (! GOT_TLS_GDESC_P (*local_tls_type)
|| ! GOT_TLS_GDESC_P (*local_tls_type))
srel->size += sizeof (Elf32_External_Rel);
if (GOT_TLS_GDESC_P (*local_tls_type))
- htab->srelplt->size += sizeof (Elf32_External_Rel);
+ htab->elf.srelplt->size += sizeof (Elf32_External_Rel);
}
}
else
{
/* Allocate 2 got entries and 1 dynamic reloc for R_386_TLS_LDM
relocs. */
- htab->tls_ldm_got.offset = htab->sgot->size;
- htab->sgot->size += 8;
- htab->srelgot->size += sizeof (Elf32_External_Rel);
+ htab->tls_ldm_got.offset = htab->elf.sgot->size;
+ htab->elf.sgot->size += 8;
+ htab->elf.srelgot->size += sizeof (Elf32_External_Rel);
}
else
htab->tls_ldm_got.offset = -1;
it's not incremented, so in order to compute the space reserved
for them, it suffices to multiply the reloc count by the jump
slot size. */
- if (htab->srelplt)
+ if (htab->elf.srelplt)
htab->sgotplt_jump_table_size = htab->next_tls_desc_index * 4;
/* We now have determined the sizes of the various dynamic sections.
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
- if (s == htab->splt
- || s == htab->sgot
- || s == htab->sgotplt
- || s == htab->iplt
- || s == htab->igotplt
+ if (s == htab->elf.splt
+ || s == htab->elf.sgot
+ || s == htab->elf.sgotplt
+ || s == htab->elf.iplt
+ || s == htab->elf.igotplt
|| s == htab->sdynbss)
{
/* Strip this section if we don't need it; see the
}
else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rel"))
{
- if (s->size != 0 && s != htab->srelplt && s != htab->srelplt2)
+ if (s->size != 0
+ && s != htab->elf.srelplt
+ && s != htab->srelplt2)
relocs = TRUE;
/* We use the reloc_count field as a counter if we need
return FALSE;
}
- if (htab->splt->size != 0)
+ if (htab->elf.splt->size != 0)
{
if (!add_dynamic_entry (DT_PLTGOT, 0)
|| !add_dynamic_entry (DT_PLTRELSZ, 0)
abort ();
/* STT_GNU_IFUNC symbol must go through PLT. */
- if (htab->splt != NULL)
+ if (htab->elf.splt != NULL)
{
- plt = htab->splt;
- gotplt = htab->sgotplt;
+ plt = htab->elf.splt;
+ gotplt = htab->elf.sgotplt;
}
else
{
- plt = htab->iplt;
- gotplt = htab->igotplt;
+ plt = htab->elf.iplt;
+ gotplt = htab->elf.igotplt;
}
relocation = (plt->output_section->vma
else
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
- sreloc = htab->irelifunc;
+ sreloc = htab->elf.irelifunc;
loc = sreloc->contents;
loc += (sreloc->reloc_count++
* sizeof (Elf32_External_Rel));
goto do_relocation;
case R_386_GOT32:
- base_got = htab->sgot;
+ base_got = htab->elf.sgot;
off = h->got.offset;
if (base_got == NULL)
even just remember the offset, as finish_dynamic_symbol
would use that as offset into .got. */
- if (htab->splt != NULL)
+ if (htab->elf.splt != NULL)
{
plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
off = (plt_index + 3) * 4;
- base_got = htab->sgotplt;
+ base_got = htab->elf.sgotplt;
}
else
{
plt_index = h->plt.offset / PLT_ENTRY_SIZE;
off = plt_index * 4;
- base_got = htab->igotplt;
+ base_got = htab->elf.igotplt;
}
if (h->dynindx == -1
relocation = off;
/* Adjust for static executables. */
- if (htab->splt == NULL)
+ if (htab->elf.splt == NULL)
relocation += gotplt->output_offset;
}
else
- gotplt->output_section->vma
- gotplt->output_offset);
/* Adjust for static executables. */
- if (htab->splt == NULL)
+ if (htab->elf.splt == NULL)
relocation += gotplt->output_offset;
}
case R_386_GOT32:
/* Relocation is to the entry for this symbol in the global
offset table. */
- if (htab->sgot == NULL)
+ if (htab->elf.sgot == NULL)
abort ();
if (h != NULL)
else
{
bfd_put_32 (output_bfd, relocation,
- htab->sgot->contents + off);
+ htab->elf.sgot->contents + off);
h->got.offset |= 1;
}
}
else
{
bfd_put_32 (output_bfd, relocation,
- htab->sgot->contents + off);
+ htab->elf.sgot->contents + off);
if (info->shared)
{
Elf_Internal_Rela outrel;
bfd_byte *loc;
- s = htab->srelgot;
+ s = htab->elf.srelgot;
if (s == NULL)
abort ();
- outrel.r_offset = (htab->sgot->output_section->vma
- + htab->sgot->output_offset
+ outrel.r_offset = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset
+ off);
outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
loc = s->contents;
if (off >= (bfd_vma) -2)
abort ();
- relocation = htab->sgot->output_section->vma
- + htab->sgot->output_offset + off
- - htab->sgotplt->output_section->vma
- - htab->sgotplt->output_offset;
+ relocation = htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off
+ - htab->elf.sgotplt->output_section->vma
+ - htab->elf.sgotplt->output_offset;
break;
case R_386_GOTOFF:
defined _GLOBAL_OFFSET_TABLE_ in a different way, as is
permitted by the ABI, we might have to change this
calculation. */
- relocation -= htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset;
+ relocation -= htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset;
break;
case R_386_GOTPC:
/* Use global offset table as symbol value. */
- relocation = htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset;
+ relocation = htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset;
unresolved_reloc = FALSE;
break;
break;
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
happens when statically linking PIC code, or when
break;
}
- relocation = (htab->splt->output_section->vma
- + htab->splt->output_offset
+ relocation = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ h->plt.offset);
unresolved_reloc = FALSE;
break;
}
}
- if (htab->sgot == NULL)
+ if (htab->elf.sgot == NULL)
abort ();
if (h != NULL)
int dr_type, indx;
asection *sreloc;
- if (htab->srelgot == NULL)
+ if (htab->elf.srelgot == NULL)
abort ();
indx = h && h->dynindx != -1 ? h->dynindx : 0;
{
outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_DESC);
BFD_ASSERT (htab->sgotplt_jump_table_size + offplt + 8
- <= htab->sgotplt->size);
- outrel.r_offset = (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ <= htab->elf.sgotplt->size);
+ outrel.r_offset = (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ offplt
+ htab->sgotplt_jump_table_size);
- sreloc = htab->srelplt;
+ sreloc = htab->elf.srelplt;
loc = sreloc->contents;
loc += (htab->next_tls_desc_index++
* sizeof (Elf32_External_Rel));
BFD_ASSERT (! unresolved_reloc);
bfd_put_32 (output_bfd,
relocation - elf_i386_dtpoff_base (info),
- htab->sgotplt->contents + offplt
+ htab->elf.sgotplt->contents + offplt
+ htab->sgotplt_jump_table_size + 4);
}
else
{
bfd_put_32 (output_bfd, 0,
- htab->sgotplt->contents + offplt
+ htab->elf.sgotplt->contents + offplt
+ htab->sgotplt_jump_table_size + 4);
}
}
- sreloc = htab->srelgot;
+ sreloc = htab->elf.srelgot;
- outrel.r_offset = (htab->sgot->output_section->vma
- + htab->sgot->output_offset + off);
+ outrel.r_offset = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off);
if (GOT_TLS_GD_P (tls_type))
dr_type = R_386_TLS_DTPMOD32;
if (dr_type == R_386_TLS_TPOFF && indx == 0)
bfd_put_32 (output_bfd,
relocation - elf_i386_dtpoff_base (info),
- htab->sgot->contents + off);
+ htab->elf.sgot->contents + off);
else if (dr_type == R_386_TLS_TPOFF32 && indx == 0)
bfd_put_32 (output_bfd,
elf_i386_dtpoff_base (info) - relocation,
- htab->sgot->contents + off);
+ htab->elf.sgot->contents + off);
else if (dr_type != R_386_TLS_DESC)
bfd_put_32 (output_bfd, 0,
- htab->sgot->contents + off);
+ htab->elf.sgot->contents + off);
outrel.r_info = ELF32_R_INFO (indx, dr_type);
loc = sreloc->contents;
BFD_ASSERT (! unresolved_reloc);
bfd_put_32 (output_bfd,
relocation - elf_i386_dtpoff_base (info),
- htab->sgot->contents + off + 4);
+ htab->elf.sgot->contents + off + 4);
}
else
{
bfd_put_32 (output_bfd, 0,
- htab->sgot->contents + off + 4);
+ htab->elf.sgot->contents + off + 4);
outrel.r_info = ELF32_R_INFO (indx,
R_386_TLS_DTPOFF32);
outrel.r_offset += 4;
(indx == 0
? relocation - elf_i386_dtpoff_base (info)
: 0),
- htab->sgot->contents + off + 4);
+ htab->elf.sgot->contents + off + 4);
outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_TPOFF);
outrel.r_offset += 4;
sreloc->reloc_count++;
}
else if (r_type == ELF32_R_TYPE (rel->r_info))
{
- bfd_vma g_o_t = htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset;
- relocation = htab->sgot->output_section->vma
- + htab->sgot->output_offset + off - g_o_t;
+ bfd_vma g_o_t = htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset;
+ relocation = htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off - g_o_t;
if ((r_type == R_386_TLS_IE || r_type == R_386_TLS_GOTIE)
&& tls_type == GOT_TLS_IE_BOTH)
relocation += 4;
if (tls_type == GOT_TLS_IE_POS)
contents[roff + 6] = 0x03;
bfd_put_32 (output_bfd,
- htab->sgot->output_section->vma
- + htab->sgot->output_offset + off
- - htab->sgotplt->output_section->vma
- - htab->sgotplt->output_offset,
+ htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off
+ - htab->elf.sgotplt->output_section->vma
+ - htab->elf.sgotplt->output_offset,
contents + roff + 8);
/* Skip R_386_PLT32. */
rel++;
off += 4;
bfd_put_32 (output_bfd,
- htab->sgot->output_section->vma
- + htab->sgot->output_offset + off
- - htab->sgotplt->output_section->vma
- - htab->sgotplt->output_offset,
+ htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off
+ - htab->elf.sgotplt->output_section->vma
+ - htab->elf.sgotplt->output_offset,
contents + roff);
continue;
}
continue;
}
- if (htab->sgot == NULL)
+ if (htab->elf.sgot == NULL)
abort ();
off = htab->tls_ldm_got.offset;
Elf_Internal_Rela outrel;
bfd_byte *loc;
- if (htab->srelgot == NULL)
+ if (htab->elf.srelgot == NULL)
abort ();
- outrel.r_offset = (htab->sgot->output_section->vma
- + htab->sgot->output_offset + off);
+ outrel.r_offset = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off);
bfd_put_32 (output_bfd, 0,
- htab->sgot->contents + off);
+ htab->elf.sgot->contents + off);
bfd_put_32 (output_bfd, 0,
- htab->sgot->contents + off + 4);
+ htab->elf.sgot->contents + off + 4);
outrel.r_info = ELF32_R_INFO (0, R_386_TLS_DTPMOD32);
- loc = htab->srelgot->contents;
- loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
+ loc = htab->elf.srelgot->contents;
+ loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
htab->tls_ldm_got.offset |= 1;
}
- relocation = htab->sgot->output_section->vma
- + htab->sgot->output_offset + off
- - htab->sgotplt->output_section->vma
- - htab->sgotplt->output_offset;
+ relocation = htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off
+ - htab->elf.sgotplt->output_section->vma
+ - htab->elf.sgotplt->output_offset;
unresolved_reloc = FALSE;
break;
/* When building a static executable, use .iplt, .igot.plt and
.rel.iplt sections for STT_GNU_IFUNC symbols. */
- if (htab->splt != NULL)
+ if (htab->elf.splt != NULL)
{
- plt = htab->splt;
- gotplt = htab->sgotplt;
- relplt = htab->srelplt;
+ plt = htab->elf.splt;
+ gotplt = htab->elf.sgotplt;
+ relplt = htab->elf.srelplt;
}
else
{
- plt = htab->iplt;
- gotplt = htab->igotplt;
- relplt = htab->irelplt;
+ plt = htab->elf.iplt;
+ gotplt = htab->elf.igotplt;
+ relplt = htab->elf.irelplt;
}
/* This symbol has an entry in the procedure linkage table. Set
For static executables, we don't reserve anything. */
- if (plt == htab->splt)
+ if (plt == htab->elf.splt)
{
plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
got_offset = (plt_index + 3) * 4;
loc = (htab->srelplt2->contents + reloc_index
* sizeof (Elf32_External_Rel));
- rel.r_offset = (htab->splt->output_section->vma
- + htab->splt->output_offset
+ rel.r_offset = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ h->plt.offset + 2),
rel.r_info = ELF32_R_INFO (htab->elf.hgot->indx, R_386_32);
bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
/* Create the R_386_32 relocation referencing the beginning of
the PLT for this GOT entry. */
- rel.r_offset = (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ rel.r_offset = (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ got_offset);
rel.r_info = ELF32_R_INFO (htab->elf.hplt->indx, R_386_32);
bfd_elf32_swap_reloc_out (output_bfd, &rel,
}
/* Don't fill PLT entry for static executables. */
- if (plt == htab->splt)
+ if (plt == htab->elf.splt)
{
bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rel),
plt->contents + h->plt.offset + 7);
/* This symbol has an entry in the global offset table. Set it
up. */
- if (htab->sgot == NULL || htab->srelgot == NULL)
+ if (htab->elf.sgot == NULL || htab->elf.srelgot == NULL)
abort ();
- rel.r_offset = (htab->sgot->output_section->vma
- + htab->sgot->output_offset
+ rel.r_offset = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset
+ (h->got.offset & ~(bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the
/* For non-shared object, we can't use .got.plt, which
contains the real function addres if we need pointer
equality. We load the GOT entry with the PLT entry. */
- asection *plt = htab->splt ? htab->splt : htab->iplt;
+ asection *plt = htab->elf.splt ? htab->elf.splt : htab->elf.iplt;
bfd_put_32 (output_bfd,
(plt->output_section->vma
+ plt->output_offset + h->plt.offset),
- htab->sgot->contents + h->got.offset);
+ htab->elf.sgot->contents + h->got.offset);
return TRUE;
}
}
BFD_ASSERT((h->got.offset & 1) == 0);
do_glob_dat:
bfd_put_32 (output_bfd, (bfd_vma) 0,
- htab->sgot->contents + h->got.offset);
+ htab->elf.sgot->contents + h->got.offset);
rel.r_info = ELF32_R_INFO (h->dynindx, R_386_GLOB_DAT);
}
- loc = htab->srelgot->contents;
- loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
+ loc = htab->elf.srelgot->contents;
+ loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
}
{
Elf32_External_Dyn *dyncon, *dynconend;
- if (sdyn == NULL || htab->sgot == NULL)
+ if (sdyn == NULL || htab->elf.sgot == NULL)
abort ();
dyncon = (Elf32_External_Dyn *) sdyn->contents;
continue;
case DT_PLTGOT:
- s = htab->sgotplt;
+ s = htab->elf.sgotplt;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_JMPREL:
- s = htab->srelplt;
+ s = htab->elf.srelplt;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case DT_PLTRELSZ:
- s = htab->srelplt;
+ s = htab->elf.srelplt;
dyn.d_un.d_val = s->size;
break;
what Solaris does. However, UnixWare can not handle
that case. Therefore, we override the DT_RELSZ entry
here to make it not include the JMPREL relocs. */
- s = htab->srelplt;
+ s = htab->elf.srelplt;
if (s == NULL)
continue;
dyn.d_un.d_val -= s->size;
/* We may not be using the standard ELF linker script.
If .rel.plt is the first .rel section, we adjust
DT_REL to not include it. */
- s = htab->srelplt;
+ s = htab->elf.srelplt;
if (s == NULL)
continue;
if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset)
}
/* Fill in the first entry in the procedure linkage table. */
- if (htab->splt && htab->splt->size > 0)
+ if (htab->elf.splt && htab->elf.splt->size > 0)
{
if (info->shared)
{
- memcpy (htab->splt->contents, elf_i386_pic_plt0_entry,
+ memcpy (htab->elf.splt->contents, elf_i386_pic_plt0_entry,
sizeof (elf_i386_pic_plt0_entry));
- memset (htab->splt->contents + sizeof (elf_i386_pic_plt0_entry),
+ memset (htab->elf.splt->contents + sizeof (elf_i386_pic_plt0_entry),
htab->plt0_pad_byte,
PLT_ENTRY_SIZE - sizeof (elf_i386_pic_plt0_entry));
}
else
{
- memcpy (htab->splt->contents, elf_i386_plt0_entry,
+ memcpy (htab->elf.splt->contents, elf_i386_plt0_entry,
sizeof(elf_i386_plt0_entry));
- memset (htab->splt->contents + sizeof (elf_i386_plt0_entry),
+ memset (htab->elf.splt->contents + sizeof (elf_i386_plt0_entry),
htab->plt0_pad_byte,
PLT_ENTRY_SIZE - sizeof (elf_i386_plt0_entry));
bfd_put_32 (output_bfd,
- (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ 4),
- htab->splt->contents + 2);
+ htab->elf.splt->contents + 2);
bfd_put_32 (output_bfd,
- (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ 8),
- htab->splt->contents + 8);
+ htab->elf.splt->contents + 8);
if (htab->is_vxworks)
{
/* Generate a relocation for _GLOBAL_OFFSET_TABLE_ + 4.
On IA32 we use REL relocations so the addend goes in
the PLT directly. */
- rel.r_offset = (htab->splt->output_section->vma
- + htab->splt->output_offset
+ rel.r_offset = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ 2);
rel.r_info = ELF32_R_INFO (htab->elf.hgot->indx, R_386_32);
bfd_elf32_swap_reloc_out (output_bfd, &rel,
htab->srelplt2->contents);
/* Generate a relocation for _GLOBAL_OFFSET_TABLE_ + 8. */
- rel.r_offset = (htab->splt->output_section->vma
- + htab->splt->output_offset
+ rel.r_offset = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ 8);
rel.r_info = ELF32_R_INFO (htab->elf.hgot->indx, R_386_32);
bfd_elf32_swap_reloc_out (output_bfd, &rel,
/* UnixWare sets the entsize of .plt to 4, although that doesn't
really seem like the right value. */
- elf_section_data (htab->splt->output_section)
+ elf_section_data (htab->elf.splt->output_section)
->this_hdr.sh_entsize = 4;
/* Correct the .rel.plt.unloaded relocations. */
if (htab->is_vxworks && !info->shared)
{
- int num_plts = (htab->splt->size / PLT_ENTRY_SIZE) - 1;
+ int num_plts = (htab->elf.splt->size / PLT_ENTRY_SIZE) - 1;
unsigned char *p;
p = htab->srelplt2->contents;
}
}
- if (htab->sgotplt)
+ if (htab->elf.sgotplt)
{
/* 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,
(sdyn == NULL ? 0
: sdyn->output_section->vma + sdyn->output_offset),
- htab->sgotplt->contents);
- bfd_put_32 (output_bfd, 0, htab->sgotplt->contents + 4);
- bfd_put_32 (output_bfd, 0, htab->sgotplt->contents + 8);
+ htab->elf.sgotplt->contents);
+ bfd_put_32 (output_bfd, 0, htab->elf.sgotplt->contents + 4);
+ bfd_put_32 (output_bfd, 0, htab->elf.sgotplt->contents + 8);
}
- elf_section_data (htab->sgotplt->output_section)->this_hdr.sh_entsize = 4;
+ elf_section_data (htab->elf.sgotplt->output_section)->this_hdr.sh_entsize = 4;
}
- if (htab->sgot && htab->sgot->size > 0)
- elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4;
+ if (htab->elf.sgot && htab->elf.sgot->size > 0)
+ elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = 4;
/* Fill PLT and GOT entries for local STT_GNU_IFUNC symbols. */
htab_traverse (htab->loc_hash_table,
struct elf_link_hash_table elf;
/* Short-cuts to get to dynamic linker sections. */
- asection *sgot;
- asection *sgotplt;
- asection *srelgot;
- asection *splt;
- asection *srelplt;
asection *sdynbss;
asection *srelbss;
- asection *igotplt;
- asection *iplt;
- asection *irelplt;
- asection *irelifunc;
/* The offset into splt of the PLT entry for the TLS descriptor
resolver. Special values are 0, if not necessary (or not found
((struct elf64_x86_64_link_hash_table *) ((p)->hash))
#define elf64_x86_64_compute_jump_table_size(htab) \
- ((htab)->srelplt->reloc_count * GOT_ENTRY_SIZE)
+ ((htab)->elf.srelplt->reloc_count * GOT_ENTRY_SIZE)
/* Create an entry in an x86-64 ELF linker hash table. */
return NULL;
}
- ret->sgot = NULL;
- ret->sgotplt = NULL;
- ret->srelgot = NULL;
- ret->splt = NULL;
- ret->srelplt = NULL;
ret->sdynbss = NULL;
ret->srelbss = NULL;
- ret->igotplt= NULL;
- ret->iplt = NULL;
- ret->irelplt= NULL;
- ret->irelifunc = NULL;
ret->sym_sec.abfd = NULL;
ret->tlsdesc_plt = 0;
ret->tlsdesc_got = 0;
_bfd_generic_link_hash_table_free (hash);
}
-/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
- shortcuts to them in our hash table. */
-
-static bfd_boolean
-elf64_x86_64_create_got_section (bfd *dynobj, struct bfd_link_info *info)
-{
- struct elf64_x86_64_link_hash_table *htab;
-
- if (! _bfd_elf_create_got_section (dynobj, info))
- return FALSE;
-
- htab = elf64_x86_64_hash_table (info);
- htab->sgot = bfd_get_section_by_name (dynobj, ".got");
- htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
- if (!htab->sgot || !htab->sgotplt)
- abort ();
-
- htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
- (SEC_ALLOC | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED
- | SEC_READONLY));
- if (htab->srelgot == NULL
- || ! bfd_set_section_alignment (dynobj, htab->srelgot, 3))
- return FALSE;
- return TRUE;
-}
-
/* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
.rela.bss sections in DYNOBJ, and set up shortcuts to them in our
hash table. */
{
struct elf64_x86_64_link_hash_table *htab;
- htab = elf64_x86_64_hash_table (info);
- if (!htab->sgot && !elf64_x86_64_create_got_section (dynobj, info))
- return FALSE;
-
if (!_bfd_elf_create_dynamic_sections (dynobj, info))
return FALSE;
- htab->splt = bfd_get_section_by_name (dynobj, ".plt");
- htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
+ htab = elf64_x86_64_hash_table (info);
htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
if (!info->shared)
htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
- if (!htab->splt || !htab->srelplt || !htab->sdynbss
+ if (!htab->sdynbss
|| (!info->shared && !htab->srelbss))
abort ();
case R_X86_64_PLT32:
case R_X86_64_GOTPCREL:
case R_X86_64_GOTPCREL64:
- if (htab->irelifunc == NULL && htab->iplt == NULL)
- {
- if (!_bfd_elf_create_ifunc_sections (abfd, info))
- return FALSE;
-
- if (info->shared)
- {
- htab->irelifunc = bfd_get_section_by_name (abfd,
- ".rela.ifunc");
- if (!htab->irelifunc)
- abort ();
- }
- else
- {
- htab->iplt = bfd_get_section_by_name (abfd, ".iplt");
- htab->irelplt = bfd_get_section_by_name (abfd,
- ".rela.iplt");
- htab->igotplt = bfd_get_section_by_name (abfd,
- ".igot.plt");
- if (!htab->iplt
- || !htab->irelplt
- || !htab->igotplt)
- abort ();
- }
- }
+ if (!_bfd_elf_create_ifunc_sections (abfd, info))
+ return FALSE;
break;
}
case R_X86_64_GOTPCREL:
case R_X86_64_GOTPCREL64:
h->got.refcount += 1;
- if (htab->sgot == NULL
- && !elf64_x86_64_create_got_section (htab->elf.dynobj,
- info))
+ if (htab->elf.sgot == NULL
+ && !_bfd_elf_create_got_section (htab->elf.dynobj,
+ info))
return FALSE;
break;
}
case R_X86_64_GOTPC32:
case R_X86_64_GOTPC64:
create_got:
- if (htab->sgot == NULL)
+ if (htab->elf.sgot == NULL)
{
if (htab->elf.dynobj == NULL)
htab->elf.dynobj = abfd;
- if (!elf64_x86_64_create_got_section (htab->elf.dynobj,
- info))
+ if (!_bfd_elf_create_got_section (htab->elf.dynobj,
+ info))
return FALSE;
}
break;
/* When building a static executable, use .iplt, .igot.plt and
.rela.iplt sections for STT_GNU_IFUNC symbols. */
- if (htab->splt != NULL)
+ if (htab->elf.splt != NULL)
{
- plt = htab->splt;
- gotplt = htab->sgotplt;
- relplt = htab->srelplt;
+ plt = htab->elf.splt;
+ gotplt = htab->elf.sgotplt;
+ relplt = htab->elf.srelplt;
/* If this is the first .plt entry, make room for the special
first entry. */
}
else
{
- plt = htab->iplt;
- gotplt = htab->igotplt;
- relplt = htab->irelplt;
+ plt = htab->elf.iplt;
+ gotplt = htab->elf.igotplt;
+ relplt = htab->elf.irelplt;
}
/* Don't update value of STT_GNU_IFUNC symbol to PLT. We need
/* Finally, allocate space. */
for (p = eh->dyn_relocs; p != NULL; p = p->next)
- htab->irelifunc->size += p->count * sizeof (Elf64_External_Rela);
+ htab->elf.irelifunc->size
+ += p->count * sizeof (Elf64_External_Rela);
/* For STT_GNU_IFUNC symbol, .got.plt has the real function
addres and .got has the PLT entry adddress. We will load
|| (!info->shared
&& !h->pointer_equality_needed)
|| (info->executable && info->shared)
- || htab->sgot == NULL)
+ || htab->elf.sgot == NULL)
{
/* Use .got.plt. */
h->got.offset = (bfd_vma) -1;
}
else
{
- h->got.offset = htab->sgot->size;
- htab->sgot->size += GOT_ENTRY_SIZE;
+ h->got.offset = htab->elf.sgot->size;
+ htab->elf.sgot->size += GOT_ENTRY_SIZE;
if (info->shared)
- htab->srelgot->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
}
return TRUE;
if (info->shared
|| 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
first entry. */
/* We also need to make an entry in the .got.plt section, which
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. */
- htab->srelplt->size += sizeof (Elf64_External_Rela);
- htab->srelplt->reloc_count++;
+ htab->elf.srelplt->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelplt->reloc_count++;
}
else
{
if (GOT_TLS_GDESC_P (tls_type))
{
- eh->tlsdesc_got = htab->sgotplt->size
+ eh->tlsdesc_got = htab->elf.sgotplt->size
- elf64_x86_64_compute_jump_table_size (htab);
- htab->sgotplt->size += 2 * GOT_ENTRY_SIZE;
+ htab->elf.sgotplt->size += 2 * GOT_ENTRY_SIZE;
h->got.offset = (bfd_vma) -2;
}
if (! GOT_TLS_GDESC_P (tls_type)
|| GOT_TLS_GD_P (tls_type))
{
- s = htab->sgot;
+ s = htab->elf.sgot;
h->got.offset = s->size;
s->size += GOT_ENTRY_SIZE;
if (GOT_TLS_GD_P (tls_type))
R_X86_64_GOTTPOFF needs one dynamic relocation. */
if ((GOT_TLS_GD_P (tls_type) && h->dynindx == -1)
|| tls_type == GOT_TLS_IE)
- htab->srelgot->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
else if (GOT_TLS_GD_P (tls_type))
- htab->srelgot->size += 2 * sizeof (Elf64_External_Rela);
+ htab->elf.srelgot->size += 2 * sizeof (Elf64_External_Rela);
else if (! GOT_TLS_GDESC_P (tls_type)
&& (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak)
&& (info->shared
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
- htab->srelgot->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
if (GOT_TLS_GDESC_P (tls_type))
{
- htab->srelplt->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelplt->size += sizeof (Elf64_External_Rela);
htab->tlsdesc_plt = (bfd_vma) -1;
}
}
end_local_got = local_got + locsymcount;
local_tls_type = elf64_x86_64_local_got_tls_type (ibfd);
local_tlsdesc_gotent = elf64_x86_64_local_tlsdesc_gotent (ibfd);
- s = htab->sgot;
- srel = htab->srelgot;
+ s = htab->elf.sgot;
+ srel = htab->elf.srelgot;
for (; local_got < end_local_got;
++local_got, ++local_tls_type, ++local_tlsdesc_gotent)
{
{
if (GOT_TLS_GDESC_P (*local_tls_type))
{
- *local_tlsdesc_gotent = htab->sgotplt->size
+ *local_tlsdesc_gotent = htab->elf.sgotplt->size
- elf64_x86_64_compute_jump_table_size (htab);
- htab->sgotplt->size += 2 * GOT_ENTRY_SIZE;
+ htab->elf.sgotplt->size += 2 * GOT_ENTRY_SIZE;
*local_got = (bfd_vma) -2;
}
if (! GOT_TLS_GDESC_P (*local_tls_type)
{
if (GOT_TLS_GDESC_P (*local_tls_type))
{
- htab->srelplt->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelplt->size
+ += sizeof (Elf64_External_Rela);
htab->tlsdesc_plt = (bfd_vma) -1;
}
if (! GOT_TLS_GDESC_P (*local_tls_type)
{
/* Allocate 2 got entries and 1 dynamic reloc for R_X86_64_TLSLD
relocs. */
- htab->tls_ld_got.offset = htab->sgot->size;
- htab->sgot->size += 2 * GOT_ENTRY_SIZE;
- htab->srelgot->size += sizeof (Elf64_External_Rela);
+ htab->tls_ld_got.offset = htab->elf.sgot->size;
+ htab->elf.sgot->size += 2 * GOT_ENTRY_SIZE;
+ htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
}
else
htab->tls_ld_got.offset = -1;
it's not incremented, so in order to compute the space reserved
for them, it suffices to multiply the reloc count by the jump
slot size. */
- if (htab->srelplt)
+ if (htab->elf.srelplt)
htab->sgotplt_jump_table_size
= elf64_x86_64_compute_jump_table_size (htab);
htab->tlsdesc_plt = 0;
else
{
- htab->tlsdesc_got = htab->sgot->size;
- htab->sgot->size += GOT_ENTRY_SIZE;
+ htab->tlsdesc_got = htab->elf.sgot->size;
+ htab->elf.sgot->size += GOT_ENTRY_SIZE;
/* Reserve room for the initial entry.
FIXME: we could probably do away with it in this case. */
- if (htab->splt->size == 0)
- htab->splt->size += PLT_ENTRY_SIZE;
- htab->tlsdesc_plt = htab->splt->size;
- htab->splt->size += PLT_ENTRY_SIZE;
+ if (htab->elf.splt->size == 0)
+ htab->elf.splt->size += PLT_ENTRY_SIZE;
+ htab->tlsdesc_plt = htab->elf.splt->size;
+ htab->elf.splt->size += PLT_ENTRY_SIZE;
}
}
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
- if (s == htab->splt
- || s == htab->sgot
- || s == htab->sgotplt
- || s == htab->iplt
- || s == htab->igotplt
+ if (s == htab->elf.splt
+ || s == htab->elf.sgot
+ || s == htab->elf.sgotplt
+ || s == htab->elf.iplt
+ || s == htab->elf.igotplt
|| s == htab->sdynbss)
{
/* Strip this section if we don't need it; see the
}
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;
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
- if (s != htab->srelplt)
+ if (s != htab->elf.srelplt)
s->reloc_count = 0;
}
else
return FALSE;
}
- if (htab->splt->size != 0)
+ if (htab->elf.splt->size != 0)
{
if (!add_dynamic_entry (DT_PLTGOT, 0)
|| !add_dynamic_entry (DT_PLTRELSZ, 0)
abort ();
/* STT_GNU_IFUNC symbol must go through PLT. */
- plt = htab->splt ? htab->splt : htab->iplt;
+ plt = htab->elf.splt ? htab->elf.splt : htab->elf.iplt;
relocation = (plt->output_section->vma
+ plt->output_offset + h->plt.offset);
outrel.r_addend = 0;
}
- sreloc = htab->irelifunc;
+ sreloc = htab->elf.irelifunc;
loc = sreloc->contents;
loc += (sreloc->reloc_count++
* sizeof (Elf64_External_Rela));
case R_X86_64_GOTPCREL:
case R_X86_64_GOTPCREL64:
- base_got = htab->sgot;
+ base_got = htab->elf.sgot;
off = h->got.offset;
if (base_got == NULL)
even just remember the offset, as finish_dynamic_symbol
would use that as offset into .got. */
- if (htab->splt != NULL)
+ if (htab->elf.splt != NULL)
{
plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
off = (plt_index + 3) * GOT_ENTRY_SIZE;
- base_got = htab->sgotplt;
+ base_got = htab->elf.sgotplt;
}
else
{
plt_index = h->plt.offset / PLT_ENTRY_SIZE;
off = plt_index * GOT_ENTRY_SIZE;
- base_got = htab->igotplt;
+ base_got = htab->elf.igotplt;
}
if (h->dynindx == -1
&& r_type != R_X86_64_GOTPCREL64)
{
asection *gotplt;
- if (htab->splt != NULL)
- gotplt = htab->sgotplt;
+ if (htab->elf.splt != NULL)
+ gotplt = htab->elf.sgotplt;
else
- gotplt = htab->igotplt;
+ gotplt = htab->elf.igotplt;
relocation -= (gotplt->output_section->vma
- gotplt->output_offset);
}
offset, if this symbol got a PLT entry (it was global).
Additionally if it's computed from the PLT entry, then that
GOT offset is relative to .got.plt, not to .got. */
- base_got = htab->sgot;
+ base_got = htab->elf.sgot;
- if (htab->sgot == NULL)
+ if (htab->elf.sgot == NULL)
abort ();
if (h != NULL)
.got. */
bfd_vma plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
off = (plt_index + 3) * GOT_ENTRY_SIZE;
- base_got = htab->sgotplt;
+ base_got = htab->elf.sgotplt;
}
dyn = htab->elf.dynamic_sections_created;
/* We need to generate a R_X86_64_RELATIVE reloc
for the dynamic linker. */
- s = htab->srelgot;
+ s = htab->elf.srelgot;
if (s == NULL)
abort ();
relocation = base_got->output_section->vma
+ base_got->output_offset + off;
if (r_type != R_X86_64_GOTPCREL && r_type != R_X86_64_GOTPCREL64)
- relocation -= htab->sgotplt->output_section->vma
- - htab->sgotplt->output_offset;
+ relocation -= htab->elf.sgotplt->output_section->vma
+ - htab->elf.sgotplt->output_offset;
break;
defined _GLOBAL_OFFSET_TABLE_ in a different way, as is
permitted by the ABI, we might have to change this
calculation. */
- relocation -= htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset;
+ relocation -= htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset;
break;
case R_X86_64_GOTPC32:
case R_X86_64_GOTPC64:
/* Use global offset table as symbol value. */
- relocation = htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset;
+ relocation = htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset;
unresolved_reloc = FALSE;
break;
if (h != NULL
/* See PLT32 handling. */
&& h->plt.offset != (bfd_vma) -1
- && htab->splt != NULL)
+ && htab->elf.splt != NULL)
{
- relocation = (htab->splt->output_section->vma
- + htab->splt->output_offset
+ relocation = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ h->plt.offset);
unresolved_reloc = FALSE;
}
- relocation -= htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset;
+ relocation -= htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset;
break;
case R_X86_64_PLT32:
break;
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
happens when statically linking PIC code, or when
break;
}
- relocation = (htab->splt->output_section->vma
- + htab->splt->output_offset
+ relocation = (htab->elf.splt->output_section->vma
+ + htab->elf.splt->output_offset
+ h->plt.offset);
unresolved_reloc = FALSE;
break;
BFD_ASSERT (FALSE);
}
- if (htab->sgot == NULL)
+ if (htab->elf.sgot == NULL)
abort ();
if (h != NULL)
int dr_type, indx;
asection *sreloc;
- if (htab->srelgot == NULL)
+ if (htab->elf.srelgot == NULL)
abort ();
indx = h && h->dynindx != -1 ? h->dynindx : 0;
{
outrel.r_info = ELF64_R_INFO (indx, R_X86_64_TLSDESC);
BFD_ASSERT (htab->sgotplt_jump_table_size + offplt
- + 2 * GOT_ENTRY_SIZE <= htab->sgotplt->size);
- outrel.r_offset = (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ + 2 * GOT_ENTRY_SIZE <= htab->elf.sgotplt->size);
+ outrel.r_offset = (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ offplt
+ htab->sgotplt_jump_table_size);
- sreloc = htab->srelplt;
+ sreloc = htab->elf.srelplt;
loc = sreloc->contents;
loc += sreloc->reloc_count++
* sizeof (Elf64_External_Rela);
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
}
- sreloc = htab->srelgot;
+ sreloc = htab->elf.srelgot;
- outrel.r_offset = (htab->sgot->output_section->vma
- + htab->sgot->output_offset + off);
+ outrel.r_offset = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off);
if (GOT_TLS_GD_P (tls_type))
dr_type = R_X86_64_DTPMOD64;
else
dr_type = R_X86_64_TPOFF64;
- bfd_put_64 (output_bfd, 0, htab->sgot->contents + off);
+ bfd_put_64 (output_bfd, 0, htab->elf.sgot->contents + off);
outrel.r_addend = 0;
if ((dr_type == R_X86_64_TPOFF64
|| dr_type == R_X86_64_TLSDESC) && indx == 0)
BFD_ASSERT (! unresolved_reloc);
bfd_put_64 (output_bfd,
relocation - elf64_x86_64_dtpoff_base (info),
- htab->sgot->contents + off + GOT_ENTRY_SIZE);
+ htab->elf.sgot->contents + off + GOT_ENTRY_SIZE);
}
else
{
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 (indx,
R_X86_64_DTPOFF64);
outrel.r_offset += GOT_ENTRY_SIZE;
{
if (r_type == R_X86_64_GOTPC32_TLSDESC
|| r_type == R_X86_64_TLSDESC_CALL)
- relocation = htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ relocation = htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ offplt + htab->sgotplt_jump_table_size;
else
- relocation = htab->sgot->output_section->vma
- + htab->sgot->output_offset + off;
+ relocation = htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off;
unresolved_reloc = FALSE;
}
else
"\x64\x48\x8b\x04\x25\0\0\0\0\x48\x03\x05\0\0\0",
16);
- relocation = (htab->sgot->output_section->vma
- + htab->sgot->output_offset + off
+ relocation = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off
- roff
- input_section->output_section->vma
- input_section->output_offset
bfd_put_8 (output_bfd, 0x8b, contents + roff - 2);
bfd_put_32 (output_bfd,
- htab->sgot->output_section->vma
- + htab->sgot->output_offset + off
+ htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off
- rel->r_offset
- input_section->output_section->vma
- input_section->output_offset
continue;
}
- if (htab->sgot == NULL)
+ if (htab->elf.sgot == NULL)
abort ();
off = htab->tls_ld_got.offset;
Elf_Internal_Rela outrel;
bfd_byte *loc;
- if (htab->srelgot == NULL)
+ if (htab->elf.srelgot == NULL)
abort ();
- outrel.r_offset = (htab->sgot->output_section->vma
- + htab->sgot->output_offset + off);
+ outrel.r_offset = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off);
bfd_put_64 (output_bfd, 0,
- htab->sgot->contents + off);
+ htab->elf.sgot->contents + off);
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_X86_64_DTPMOD64);
outrel.r_addend = 0;
- loc = htab->srelgot->contents;
- loc += htab->srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
+ loc = htab->elf.srelgot->contents;
+ loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
htab->tls_ld_got.offset |= 1;
}
- relocation = htab->sgot->output_section->vma
- + htab->sgot->output_offset + off;
+ relocation = htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset + off;
unresolved_reloc = FALSE;
break;
/* When building a static executable, use .iplt, .igot.plt and
.rela.iplt sections for STT_GNU_IFUNC symbols. */
- if (htab->splt != NULL)
+ if (htab->elf.splt != NULL)
{
- plt = htab->splt;
- gotplt = htab->sgotplt;
- relplt = htab->srelplt;
+ plt = htab->elf.splt;
+ gotplt = htab->elf.sgotplt;
+ relplt = htab->elf.srelplt;
}
else
{
- plt = htab->iplt;
- gotplt = htab->igotplt;
- relplt = htab->irelplt;
+ plt = htab->elf.iplt;
+ gotplt = htab->elf.igotplt;
+ relplt = htab->elf.irelplt;
}
/* This symbol has an entry in the procedure linkage table. Set
For static executables, we don't reserve anything. */
- if (plt == htab->splt)
+ if (plt == htab->elf.splt)
{
plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
plt->contents + h->plt.offset + 2);
/* Don't fill PLT entry for static executables. */
- if (plt == htab->splt)
+ if (plt == htab->elf.splt)
{
/* Put relocation index. */
bfd_put_32 (output_bfd, plt_index,
/* This symbol has an entry in the global offset table. Set it
up. */
- if (htab->sgot == NULL || htab->srelgot == NULL)
+ if (htab->elf.sgot == NULL || htab->elf.srelgot == NULL)
abort ();
- rela.r_offset = (htab->sgot->output_section->vma
- + htab->sgot->output_offset
+ rela.r_offset = (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset
+ (h->got.offset &~ (bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the
/* For non-shared object, we can't use .got.plt, which
contains the real function addres if we need pointer
equality. We load the GOT entry with the PLT entry. */
- asection *plt = htab->splt ? htab->splt : htab->iplt;
+ asection *plt = htab->elf.splt ? htab->elf.splt : htab->elf.iplt;
bfd_put_64 (output_bfd, (plt->output_section->vma
+ plt->output_offset
+ h->plt.offset),
- htab->sgot->contents + h->got.offset);
+ htab->elf.sgot->contents + h->got.offset);
return TRUE;
}
}
BFD_ASSERT((h->got.offset & 1) == 0);
do_glob_dat:
bfd_put_64 (output_bfd, (bfd_vma) 0,
- htab->sgot->contents + h->got.offset);
+ htab->elf.sgot->contents + h->got.offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_GLOB_DAT);
rela.r_addend = 0;
}
- loc = htab->srelgot->contents;
- loc += htab->srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
+ loc = htab->elf.srelgot->contents;
+ loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
}
{
Elf64_External_Dyn *dyncon, *dynconend;
- if (sdyn == NULL || htab->sgot == NULL)
+ if (sdyn == NULL || htab->elf.sgot == NULL)
abort ();
dyncon = (Elf64_External_Dyn *) sdyn->contents;
continue;
case DT_PLTGOT:
- s = htab->sgotplt;
+ s = htab->elf.sgotplt;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
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;
case DT_PLTRELSZ:
- s = htab->srelplt->output_section;
+ s = htab->elf.srelplt->output_section;
dyn.d_un.d_val = s->size;
break;
linker script arranges for .rela.plt to follow all
other relocation sections, we don't have to worry
about changing the DT_RELA entry. */
- if (htab->srelplt != NULL)
+ if (htab->elf.srelplt != NULL)
{
- s = htab->srelplt->output_section;
+ s = htab->elf.srelplt->output_section;
dyn.d_un.d_val -= s->size;
}
break;
case DT_TLSDESC_PLT:
- s = htab->splt;
+ s = htab->elf.splt;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
+ htab->tlsdesc_plt;
break;
case DT_TLSDESC_GOT:
- s = htab->sgot;
+ s = htab->elf.sgot;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
+ htab->tlsdesc_got;
break;
}
/* 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 the first entry in the procedure linkage table. */
- memcpy (htab->splt->contents, elf64_x86_64_plt0_entry,
+ memcpy (htab->elf.splt->contents, elf64_x86_64_plt0_entry,
PLT_ENTRY_SIZE);
/* Add offset for pushq GOT+8(%rip), since the instruction
uses 6 bytes subtract this value. */
bfd_put_32 (output_bfd,
- (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ 8
- - htab->splt->output_section->vma
- - htab->splt->output_offset
+ - htab->elf.splt->output_section->vma
+ - htab->elf.splt->output_offset
- 6),
- htab->splt->contents + 2);
+ htab->elf.splt->contents + 2);
/* Add offset for jmp *GOT+16(%rip). The 12 is the offset to
the end of the instruction. */
bfd_put_32 (output_bfd,
- (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ 16
- - htab->splt->output_section->vma
- - htab->splt->output_offset
+ - htab->elf.splt->output_section->vma
+ - htab->elf.splt->output_offset
- 12),
- htab->splt->contents + 8);
+ htab->elf.splt->contents + 8);
- elf_section_data (htab->splt->output_section)->this_hdr.sh_entsize =
+ elf_section_data (htab->elf.splt->output_section)->this_hdr.sh_entsize =
PLT_ENTRY_SIZE;
if (htab->tlsdesc_plt)
{
bfd_put_64 (output_bfd, (bfd_vma) 0,
- htab->sgot->contents + htab->tlsdesc_got);
+ htab->elf.sgot->contents + htab->tlsdesc_got);
- memcpy (htab->splt->contents + htab->tlsdesc_plt,
+ memcpy (htab->elf.splt->contents + htab->tlsdesc_plt,
elf64_x86_64_plt0_entry,
PLT_ENTRY_SIZE);
/* Add offset for pushq GOT+8(%rip), since the
instruction uses 6 bytes subtract this value. */
bfd_put_32 (output_bfd,
- (htab->sgotplt->output_section->vma
- + htab->sgotplt->output_offset
+ (htab->elf.sgotplt->output_section->vma
+ + htab->elf.sgotplt->output_offset
+ 8
- - htab->splt->output_section->vma
- - htab->splt->output_offset
+ - htab->elf.splt->output_section->vma
+ - htab->elf.splt->output_offset
- htab->tlsdesc_plt
- 6),
- htab->splt->contents + htab->tlsdesc_plt + 2);
+ htab->elf.splt->contents + htab->tlsdesc_plt + 2);
/* Add offset for jmp *GOT+TDG(%rip), where TGD stands for
htab->tlsdesc_got. The 12 is the offset to the end of
the instruction. */
bfd_put_32 (output_bfd,
- (htab->sgot->output_section->vma
- + htab->sgot->output_offset
+ (htab->elf.sgot->output_section->vma
+ + htab->elf.sgot->output_offset
+ htab->tlsdesc_got
- - htab->splt->output_section->vma
- - htab->splt->output_offset
+ - htab->elf.splt->output_section->vma
+ - htab->elf.splt->output_offset
- htab->tlsdesc_plt
- 12),
- htab->splt->contents + htab->tlsdesc_plt + 8);
+ htab->elf.splt->contents + htab->tlsdesc_plt + 8);
}
}
}
- if (htab->sgotplt)
+ if (htab->elf.sgotplt)
{
/* Fill in the first three entries in the global offset table. */
- if (htab->sgotplt->size > 0)
+ if (htab->elf.sgotplt->size > 0)
{
/* Set the first entry in the global offset table to the address of
the dynamic section. */
if (sdyn == NULL)
- bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents);
+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents);
else
bfd_put_64 (output_bfd,
sdyn->output_section->vma + sdyn->output_offset,
- htab->sgotplt->contents);
+ htab->elf.sgotplt->contents);
/* Write GOT[1] and GOT[2], needed for the dynamic linker. */
- bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + GOT_ENTRY_SIZE);
- bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + GOT_ENTRY_SIZE*2);
+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + GOT_ENTRY_SIZE);
+ bfd_put_64 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + GOT_ENTRY_SIZE*2);
}
- elf_section_data (htab->sgotplt->output_section)->this_hdr.sh_entsize =
+ elf_section_data (htab->elf.sgotplt->output_section)->this_hdr.sh_entsize =
GOT_ENTRY_SIZE;
}
- if (htab->sgot && htab->sgot->size > 0)
- elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize
+ if (htab->elf.sgot && htab->elf.sgot->size > 0)
+ elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize
= GOT_ENTRY_SIZE;
/* Fill PLT and GOT entries for local STT_GNU_IFUNC symbols. */
asection *s;
struct elf_link_hash_entry *h;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
- int ptralign;
+ struct elf_link_hash_table *htab = elf_hash_table (info);
/* This function may be called more than once. */
s = bfd_get_section_by_name (abfd, ".got");
if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
return TRUE;
- switch (bed->s->arch_size)
- {
- case 32:
- ptralign = 2;
- break;
-
- case 64:
- ptralign = 3;
- break;
-
- default:
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
-
flags = bed->dynamic_sec_flags;
s = bfd_make_section_with_flags (abfd, ".got", flags);
if (s == NULL
- || !bfd_set_section_alignment (abfd, s, ptralign))
+ || !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
+ htab->sgot = s;
+
+ s = bfd_make_section_with_flags (abfd,
+ (bed->rela_plts_and_copies_p
+ ? ".rela.got" : ".rel.got"),
+ (bed->dynamic_sec_flags
+ | SEC_READONLY));
+ if (s == NULL
+ || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+ return FALSE;
+ htab->srelgot = s;
if (bed->want_got_plt)
{
s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
if (s == NULL
- || !bfd_set_section_alignment (abfd, s, ptralign))
+ || !bfd_set_section_alignment (abfd, s,
+ bed->s->log_file_align))
return FALSE;
+ htab->sgotplt = s;
}
if (bed->want_got_sym)
(or .got.plt) section. We don't do this in the linker script
because we don't want to define the symbol if we are not creating
a global offset table. */
- h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_");
+ h = _bfd_elf_define_linkage_sym (abfd, info, s,
+ "_GLOBAL_OFFSET_TABLE_");
elf_hash_table (info)->hgot = h;
if (h == NULL)
return FALSE;
struct elf_link_hash_entry *h;
asection *s;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ struct elf_link_hash_table *htab = elf_hash_table (info);
/* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
.rel[a].bss sections. */
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
return FALSE;
+ htab->splt = s;
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
.plt section. */
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
+ htab->srelplt = s;
if (! _bfd_elf_create_got_section (abfd, info))
return FALSE;
return reloc_sec;
}
-
-/* Create sections needed by STT_GNU_IFUNC symbol. */
-
-bfd_boolean
-_bfd_elf_create_ifunc_sections (bfd *abfd, struct bfd_link_info *info)
-{
- flagword flags, pltflags;
- int ptralign;
- asection *s;
- const struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- flags = bed->dynamic_sec_flags;
- pltflags = flags;
- if (bed->plt_not_loaded)
- /* We do not clear SEC_ALLOC here because we still want the OS to
- allocate space for the section; it's just that there's nothing
- to read in from the object file. */
- pltflags &= ~ (SEC_CODE | SEC_LOAD | SEC_HAS_CONTENTS);
- else
- pltflags |= SEC_ALLOC | SEC_CODE | SEC_LOAD;
- if (bed->plt_readonly)
- pltflags |= SEC_READONLY;
-
- if (info->shared)
- {
- /* We need to create .rel[a].ifunc for shared objects. */
- const char *rel_sec = (bed->rela_plts_and_copies_p
- ? ".rela.ifunc" : ".rel.ifunc");
-
- /* This function should be called only once. */
- s = bfd_get_section_by_name (abfd, rel_sec);
- if (s != NULL)
- abort ();
-
- s = bfd_make_section_with_flags (abfd, rel_sec,
- flags | SEC_READONLY);
- if (s == NULL
- || ! bfd_set_section_alignment (abfd, s,
- bed->s->log_file_align))
- return FALSE;
- }
- else
- {
- /* This function should be called only once. */
- s = bfd_get_section_by_name (abfd, ".iplt");
- if (s != NULL)
- abort ();
-
- /* We need to create .iplt, .rel[a].iplt, .igot and .igot.plt
- for static executables. */
- s = bfd_make_section_with_flags (abfd, ".iplt", pltflags);
- if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
- return FALSE;
-
- s = bfd_make_section_with_flags (abfd,
- (bed->rela_plts_and_copies_p
- ? ".rela.iplt" : ".rel.iplt"),
- flags | SEC_READONLY);
- if (s == NULL
- || ! bfd_set_section_alignment (abfd, s,
- bed->s->log_file_align))
- return FALSE;
-
- switch (bed->s->arch_size)
- {
- case 32:
- ptralign = 2;
- break;
-
- case 64:
- ptralign = 3;
- break;
-
- default:
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
-
- /* We don't need the .igot section if we have the .igot.plt
- section. */
- if (bed->want_got_plt)
- s = bfd_make_section_with_flags (abfd, ".igot.plt", flags);
- else
- s = bfd_make_section_with_flags (abfd, ".igot", flags);
- if (s == NULL
- || !bfd_set_section_alignment (abfd, s, ptralign))
- return FALSE;
- }
-
- return TRUE;
-}