/* Create an entry in an i386 ELF linker hash table. */
static struct bfd_hash_entry *
-link_hash_newfunc (struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string)
+elf_i386_link_hash_newfunc (struct bfd_hash_entry *entry,
+ struct bfd_hash_table *table,
+ const char *string)
{
/* Allocate the structure if it has not already been allocated by a
subclass. */
if (ret == NULL)
return NULL;
- if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
+ if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd,
+ elf_i386_link_hash_newfunc,
sizeof (struct elf_i386_link_hash_entry)))
{
free (ret);
shortcuts to them in our hash table. */
static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
+elf_i386_create_got_section (bfd *dynobj, struct bfd_link_info *info)
{
struct elf_i386_link_hash_table *htab;
struct elf_i386_link_hash_table *htab;
htab = elf_i386_hash_table (info);
- if (!htab->sgot && !create_got_section (dynobj, info))
+ if (!htab->sgot && !elf_i386_create_got_section (dynobj, info))
return FALSE;
if (!_bfd_elf_create_dynamic_sections (dynobj, info))
{
if (htab->elf.dynobj == NULL)
htab->elf.dynobj = abfd;
- if (!create_got_section (htab->elf.dynobj, info))
+ if (!elf_i386_create_got_section (htab->elf.dynobj, info))
return FALSE;
}
if (r_type != R_386_TLS_IE)
dynamic relocs. */
static bfd_boolean
-allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
+elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
{
struct bfd_link_info *info;
struct elf_i386_link_hash_table *htab;
/* Find any dynamic relocs that apply to read-only sections. */
static bfd_boolean
-readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf)
+elf_i386_readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf)
{
struct elf_i386_link_hash_entry *eh;
struct elf_i386_dyn_relocs *p;
/* Allocate global sym .plt and .got entries, and space for global
sym dynamic relocs. */
- elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
+ elf_link_hash_traverse (&htab->elf, elf_i386_allocate_dynrelocs, info);
/* For every jump slot reserved in the sgotplt, reloc_count is
incremented. However, when we reserve space for TLS descriptors,
/* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0)
- elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info);
+ elf_link_hash_traverse (&htab->elf,
+ elf_i386_readonly_dynrelocs, info);
if ((info->flags & DF_TEXTREL) != 0)
{
multiple times, it is idempotent. */
static void
-set_tls_module_base (struct bfd_link_info *info)
+elf_i386_set_tls_module_base (struct bfd_link_info *info)
{
struct bfd_link_hash_entry *base;
This is PT_TLS segment p_vaddr. */
static bfd_vma
-dtpoff_base (struct bfd_link_info *info)
+elf_i386_dtpoff_base (struct bfd_link_info *info)
{
/* If tls_sec is NULL, we should have signalled an error already. */
if (elf_hash_table (info)->tls_sec == NULL)
if STT_TLS virtual address is ADDRESS. */
static bfd_vma
-tpoff (struct bfd_link_info *info, bfd_vma address)
+elf_i386_tpoff (struct bfd_link_info *info, bfd_vma address)
{
struct elf_link_hash_table *htab = elf_hash_table (info);
&& !strcmp (input_section->output_section->name,
".tls_vars"));
- set_tls_module_base (info);
+ elf_i386_set_tls_module_base (info);
rel = relocs;
relend = relocs + input_section->reloc_count;
"\x65\xa1\0\0\0\0\x81\xe8\0\0\0", 12);
roff = rel->r_offset + 6;
}
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd, elf_i386_tpoff (info, relocation),
contents + roff);
/* Skip R_386_PC32/R_386_PLT32. */
rel++;
below with 0x86. */
bfd_put_8 (output_bfd, val ^ 0x86,
contents + roff - 1);
- bfd_put_32 (output_bfd, -tpoff (info, relocation),
+ bfd_put_32 (output_bfd, -elf_i386_tpoff (info, relocation),
contents + roff);
continue;
}
break;
}
}
- bfd_put_32 (output_bfd, -tpoff (info, relocation),
+ bfd_put_32 (output_bfd, -elf_i386_tpoff (info, relocation),
contents + rel->r_offset);
continue;
}
else
BFD_FAIL ();
if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GOTIE)
- bfd_put_32 (output_bfd, -tpoff (info, relocation),
+ bfd_put_32 (output_bfd, -elf_i386_tpoff (info, relocation),
contents + rel->r_offset);
else
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd, elf_i386_tpoff (info, relocation),
contents + rel->r_offset);
continue;
}
{
BFD_ASSERT (! unresolved_reloc);
bfd_put_32 (output_bfd,
- relocation - dtpoff_base (info),
+ relocation - elf_i386_dtpoff_base (info),
htab->sgotplt->contents + offplt
+ htab->sgotplt_jump_table_size + 4);
}
dr_type = R_386_TLS_TPOFF32;
if (dr_type == R_386_TLS_TPOFF && indx == 0)
- bfd_put_32 (output_bfd, relocation - dtpoff_base (info),
+ bfd_put_32 (output_bfd,
+ relocation - elf_i386_dtpoff_base (info),
htab->sgot->contents + off);
else if (dr_type == R_386_TLS_TPOFF32 && indx == 0)
- bfd_put_32 (output_bfd, dtpoff_base (info) - relocation,
+ bfd_put_32 (output_bfd,
+ elf_i386_dtpoff_base (info) - relocation,
htab->sgot->contents + off);
else if (dr_type != R_386_TLS_DESC)
bfd_put_32 (output_bfd, 0,
{
BFD_ASSERT (! unresolved_reloc);
bfd_put_32 (output_bfd,
- relocation - dtpoff_base (info),
+ relocation - elf_i386_dtpoff_base (info),
htab->sgot->contents + off + 4);
}
else
else if (tls_type == GOT_TLS_IE_BOTH)
{
bfd_put_32 (output_bfd,
- indx == 0 ? relocation - dtpoff_base (info) : 0,
+ (indx == 0
+ ? relocation - elf_i386_dtpoff_base (info)
+ : 0),
htab->sgot->contents + off + 4);
outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_TPOFF);
outrel.r_offset += 4;
case R_386_TLS_LDO_32:
if (info->shared || (input_section->flags & SEC_CODE) == 0)
- relocation -= dtpoff_base (info);
+ relocation -= elf_i386_dtpoff_base (info);
else
/* When converting LDO to LE, we must negate. */
- relocation = -tpoff (info, relocation);
+ relocation = -elf_i386_tpoff (info, relocation);
break;
case R_386_TLS_LE_32:
if (indx)
continue;
else if (r_type == R_386_TLS_LE_32)
- relocation = dtpoff_base (info) - relocation;
+ relocation = elf_i386_dtpoff_base (info) - relocation;
else
- relocation -= dtpoff_base (info);
+ relocation -= elf_i386_dtpoff_base (info);
}
else if (r_type == R_386_TLS_LE_32)
- relocation = tpoff (info, relocation);
+ relocation = elf_i386_tpoff (info, relocation);
else
- relocation = -tpoff (info, relocation);
+ relocation = -elf_i386_tpoff (info, relocation);
break;
default:
/* Create an entry in an x86-64 ELF linker hash table. */
static struct bfd_hash_entry *
-link_hash_newfunc (struct bfd_hash_entry *entry, struct bfd_hash_table *table,
- const char *string)
+elf64_x86_64_link_hash_newfunc (struct bfd_hash_entry *entry,
+ struct bfd_hash_table *table,
+ const char *string)
{
/* Allocate the structure if it has not already been allocated by a
subclass. */
if (ret == NULL)
return NULL;
- if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
+ if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd,
+ elf64_x86_64_link_hash_newfunc,
sizeof (struct elf64_x86_64_link_hash_entry)))
{
free (ret);
shortcuts to them in our hash table. */
static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
+elf64_x86_64_create_got_section (bfd *dynobj, struct bfd_link_info *info)
{
struct elf64_x86_64_link_hash_table *htab;
struct elf64_x86_64_link_hash_table *htab;
htab = elf64_x86_64_hash_table (info);
- if (!htab->sgot && !create_got_section (dynobj, info))
+ if (!htab->sgot && !elf64_x86_64_create_got_section (dynobj, info))
return FALSE;
if (!_bfd_elf_create_dynamic_sections (dynobj, info))
{
if (htab->elf.dynobj == NULL)
htab->elf.dynobj = abfd;
- if (!create_got_section (htab->elf.dynobj, info))
+ if (!elf64_x86_64_create_got_section (htab->elf.dynobj,
+ info))
return FALSE;
}
break;
dynamic relocs. */
static bfd_boolean
-allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+elf64_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
{
struct bfd_link_info *info;
struct elf64_x86_64_link_hash_table *htab;
/* Find any dynamic relocs that apply to read-only sections. */
static bfd_boolean
-readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+elf64_x86_64_readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf)
{
struct elf64_x86_64_link_hash_entry *eh;
struct elf64_x86_64_dyn_relocs *p;
/* Allocate global sym .plt and .got entries, and space for global
sym dynamic relocs. */
- elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
+ elf_link_hash_traverse (&htab->elf, elf64_x86_64_allocate_dynrelocs,
+ info);
/* For every jump slot reserved in the sgotplt, reloc_count is
incremented. However, when we reserve space for TLS descriptors,
/* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0)
- elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info);
+ elf_link_hash_traverse (&htab->elf,
+ elf64_x86_64_readonly_dynrelocs,
+ info);
if ((info->flags & DF_TEXTREL) != 0)
{
multiple times, it is idempotent. */
static void
-set_tls_module_base (struct bfd_link_info *info)
+elf64_x86_64_set_tls_module_base (struct bfd_link_info *info)
{
struct bfd_link_hash_entry *base;
This is PT_TLS segment p_vaddr. */
static bfd_vma
-dtpoff_base (struct bfd_link_info *info)
+elf64_x86_64_dtpoff_base (struct bfd_link_info *info)
{
/* If tls_sec is NULL, we should have signalled an error already. */
if (elf_hash_table (info)->tls_sec == NULL)
if STT_TLS virtual address is ADDRESS. */
static bfd_vma
-tpoff (struct bfd_link_info *info, bfd_vma address)
+elf64_x86_64_tpoff (struct bfd_link_info *info, bfd_vma address)
{
struct elf_link_hash_table *htab = elf_hash_table (info);
local_got_offsets = elf_local_got_offsets (input_bfd);
local_tlsdesc_gotents = elf64_x86_64_local_tlsdesc_gotent (input_bfd);
- set_tls_module_base (info);
+ elf64_x86_64_set_tls_module_base (info);
rel = relocs;
relend = relocs + input_section->reloc_count;
memcpy (contents + roff - 4,
"\x64\x48\x8b\x04\x25\0\0\0\0\x48\x8d\x80\0\0\0",
16);
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd,
+ elf64_x86_64_tpoff (info, relocation),
contents + roff + 8);
/* Skip R_X86_64_PC32/R_X86_64_PLT32. */
rel++;
bfd_put_8 (output_bfd, 0xc7, contents + roff - 2);
bfd_put_8 (output_bfd, 0xc0 | ((val >> 3) & 7),
contents + roff - 1);
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd,
+ elf64_x86_64_tpoff (info, relocation),
contents + roff);
continue;
}
bfd_put_8 (output_bfd, 0x80 | reg | (reg << 3),
contents + roff - 1);
}
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd,
+ elf64_x86_64_tpoff (info, relocation),
contents + roff);
continue;
}
BFD_ASSERT (loc + sizeof (Elf64_External_Rela)
<= sreloc->contents + sreloc->size);
if (indx == 0)
- outrel.r_addend = relocation - dtpoff_base (info);
+ outrel.r_addend = relocation - elf64_x86_64_dtpoff_base (info);
else
outrel.r_addend = 0;
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
outrel.r_addend = 0;
if ((dr_type == R_X86_64_TPOFF64
|| dr_type == R_X86_64_TLSDESC) && indx == 0)
- outrel.r_addend = relocation - dtpoff_base (info);
+ outrel.r_addend = relocation - elf64_x86_64_dtpoff_base (info);
outrel.r_info = ELF64_R_INFO (indx, dr_type);
loc = sreloc->contents;
{
BFD_ASSERT (! unresolved_reloc);
bfd_put_64 (output_bfd,
- relocation - dtpoff_base (info),
+ relocation - elf64_x86_64_dtpoff_base (info),
htab->sgot->contents + off + GOT_ENTRY_SIZE);
}
else
case R_X86_64_DTPOFF32:
if (info->shared || (input_section->flags & SEC_CODE) == 0)
- relocation -= dtpoff_base (info);
+ relocation -= elf64_x86_64_dtpoff_base (info);
else
- relocation = tpoff (info, relocation);
+ relocation = elf64_x86_64_tpoff (info, relocation);
break;
case R_X86_64_TPOFF32:
BFD_ASSERT (! info->shared);
- relocation = tpoff (info, relocation);
+ relocation = elf64_x86_64_tpoff (info, relocation);
break;
default: