unsigned int *r_type, int tls_type,
const Elf_Internal_Rela *rel,
const Elf_Internal_Rela *relend,
- struct elf_link_hash_entry *h)
+ struct elf_link_hash_entry *h,
+ unsigned long r_symndx)
{
unsigned int from_type = *r_type;
unsigned int to_type = from_type;
case R_X86_64_GOTPC32_TLSDESC:
case R_X86_64_TLSDESC_CALL:
case R_X86_64_GOTTPOFF:
- if (!info->shared)
+ if (info->executable)
{
if (h == NULL)
to_type = R_X86_64_TPOFF32;
{
unsigned int new_to_type = to_type;
- if (!info->shared
+ if (info->executable
&& h != NULL
&& h->dynindx == -1
&& tls_type == GOT_TLS_IE)
break;
case R_X86_64_TLSLD:
- if (!info->shared)
+ if (info->executable)
to_type = R_X86_64_TPOFF32;
break;
from_type, rel, relend))
{
reloc_howto_type *from, *to;
+ const char *name;
from = elf64_x86_64_rtype_to_howto (abfd, from_type);
to = elf64_x86_64_rtype_to_howto (abfd, to_type);
+ if (h)
+ name = h->root.root.string;
+ else
+ {
+ Elf_Internal_Sym *isym;
+ struct elf64_x86_64_link_hash_table *htab;
+ htab = elf64_x86_64_hash_table (info);
+ isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+ abfd, r_symndx);
+ name = bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL);
+ }
+
(*_bfd_error_handler)
(_("%B: TLS transition from %s to %s against `%s' at 0x%lx "
"in section `%A' failed"),
- abfd, sec, from->name, to->name,
- h ? h->root.root.string : "a local symbol",
+ abfd, sec, from->name, to->name, name,
(unsigned long) rel->r_offset);
bfd_set_error (bfd_error_bad_value);
return FALSE;
const Elf_Internal_Rela *rel;
const Elf_Internal_Rela *rel_end;
asection *sreloc;
- Elf_Internal_Sym *isymbuf;
if (info->relocatable)
return TRUE;
htab = elf64_x86_64_hash_table (info);
symtab_hdr = &elf_symtab_hdr (abfd);
- isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
sym_hashes = elf_sym_hashes (abfd);
sreloc = NULL;
unsigned int r_type;
unsigned long r_symndx;
struct elf_link_hash_entry *h;
+ Elf_Internal_Sym *isym;
+ const char *name;
r_symndx = ELF64_R_SYM (rel->r_info);
r_type = ELF64_R_TYPE (rel->r_info);
if (r_symndx < symtab_hdr->sh_info)
{
/* A local symbol. */
- Elf_Internal_Sym *isym;
-
- /* Read this BFD's local symbols. */
- if (isymbuf == NULL)
- {
- if (isymbuf == NULL)
- isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
- symtab_hdr->sh_info, 0,
- NULL, NULL, NULL);
- if (isymbuf == NULL)
- return FALSE;
- }
+ isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+ abfd, r_symndx);
+ if (isym == NULL)
+ return FALSE;
/* Check relocation against local STT_GNU_IFUNC symbol. */
- isym = isymbuf + r_symndx;
if (ELF64_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
{
h = elf64_x86_64_get_local_sym_hash (htab, abfd, rel,
TRUE);
if (h == NULL)
- goto error_return;
+ return FALSE;
/* Fake a STT_GNU_IFUNC symbol. */
h->type = STT_GNU_IFUNC;
}
else
{
+ isym = NULL;
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
case R_X86_64_GOTPCREL:
case R_X86_64_GOTPCREL64:
if (!_bfd_elf_create_ifunc_sections (abfd, info))
- goto error_return;
+ return FALSE;
break;
}
{
/* It is referenced by a non-shared object. */
h->ref_regular = 1;
+ h->needs_plt = 1;
/* STT_GNU_IFUNC symbol must go through PLT. */
h->plt.refcount += 1;
switch (r_type)
{
default:
+ if (h->root.root.string)
+ name = h->root.root.string;
+ else
+ name = bfd_elf_sym_name (abfd, symtab_hdr, isym,
+ NULL);
(*_bfd_error_handler)
(_("%B: relocation %s against STT_GNU_IFUNC "
"symbol `%s' isn't handled by %s"), abfd,
x86_64_elf_howto_table[r_type].name,
- (h->root.root.string
- ? h->root.root.string : "a local symbol"),
- __FUNCTION__);
+ name, __FUNCTION__);
bfd_set_error (bfd_error_bad_value);
- goto error_return;
+ return FALSE;
case R_X86_64_64:
h->non_got_ref = 1;
(abfd, info, sec, sreloc,
&((struct elf64_x86_64_link_hash_entry *) h)->dyn_relocs);
if (sreloc == NULL)
- goto error_return;
+ return FALSE;
}
break;
if (htab->elf.sgot == NULL
&& !_bfd_elf_create_got_section (htab->elf.dynobj,
info))
- goto error_return;
+ return FALSE;
break;
}
if (! elf64_x86_64_tls_transition (info, abfd, sec, NULL,
symtab_hdr, sym_hashes,
&r_type, GOT_UNKNOWN,
- rel, rel_end, h))
- goto error_return;
+ rel, rel_end, h, r_symndx))
+ return FALSE;
switch (r_type)
{
goto create_got;
case R_X86_64_TPOFF32:
- if (info->shared)
+ if (!info->executable)
{
+ if (h)
+ name = h->root.root.string;
+ else
+ name = bfd_elf_sym_name (abfd, symtab_hdr, isym,
+ NULL);
(*_bfd_error_handler)
(_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
abfd,
- x86_64_elf_howto_table[r_type].name,
- (h) ? h->root.root.string : "a local symbol");
+ x86_64_elf_howto_table[r_type].name, name);
bfd_set_error (bfd_error_bad_value);
- goto error_return;
+ return FALSE;
}
break;
case R_X86_64_GOTTPOFF:
- if (info->shared)
+ if (!info->executable)
info->flags |= DF_STATIC_TLS;
/* Fall through */
local_got_refcounts = ((bfd_signed_vma *)
bfd_zalloc (abfd, size));
if (local_got_refcounts == NULL)
- goto error_return;
+ return FALSE;
elf_local_got_refcounts (abfd) = local_got_refcounts;
elf64_x86_64_local_tlsdesc_gotent (abfd)
= (bfd_vma *) (local_got_refcounts + symtab_hdr->sh_info);
tls_type |= old_tls_type;
else
{
+ if (h)
+ name = h->root.root.string;
+ else
+ name = bfd_elf_sym_name (abfd, symtab_hdr,
+ isym, NULL);
(*_bfd_error_handler)
(_("%B: '%s' accessed both as normal and thread local symbol"),
- abfd, h ? h->root.root.string : "<local>");
- goto error_return;
+ abfd, name);
+ return FALSE;
}
}
htab->elf.dynobj = abfd;
if (!_bfd_elf_create_got_section (htab->elf.dynobj,
info))
- goto error_return;
+ return FALSE;
}
break;
&& (sec->flags & SEC_ALLOC) != 0
&& (sec->flags & SEC_READONLY) != 0)
{
+ if (h)
+ name = h->root.root.string;
+ else
+ name = bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL);
(*_bfd_error_handler)
(_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
- abfd,
- x86_64_elf_howto_table[r_type].name,
- (h) ? h->root.root.string : "a local symbol");
+ abfd, x86_64_elf_howto_table[r_type].name, name);
bfd_set_error (bfd_error_bad_value);
- goto error_return;
+ return FALSE;
}
/* Fall through. */
(sec, htab->elf.dynobj, 3, abfd, /*rela?*/ TRUE);
if (sreloc == NULL)
- goto error_return;
+ return FALSE;
}
/* If this is a global symbol, we count the number of
p = ((struct elf_dyn_relocs *)
bfd_alloc (htab->elf.dynobj, amt));
if (p == NULL)
- goto error_return;
+ return FALSE;
p->next = *head;
*head = p;
p->sec = sec;
Reconstruct it for later use during GC. */
case R_X86_64_GNU_VTINHERIT:
if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
- goto error_return;
+ return FALSE;
break;
/* This relocation describes which C++ vtable entries are actually
BFD_ASSERT (h != NULL);
if (h != NULL
&& !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
- goto error_return;
+ return FALSE;
break;
default:
}
}
- if (isymbuf != NULL
- && (unsigned char *) isymbuf != symtab_hdr->contents)
- {
- if (!info->keep_memory)
- free (isymbuf);
- else
- {
- /* Cache the symbols for elf_link_input_bfd. */
- symtab_hdr->contents = (unsigned char *) isymbuf;
- }
- }
-
return TRUE;
-
-error_return:
- if (isymbuf != NULL
- && (unsigned char *) isymbuf != symtab_hdr->contents)
- free (isymbuf);
- return FALSE;
}
/* Return the section that should be marked against GC for a given
if (! elf64_x86_64_tls_transition (info, abfd, sec, NULL,
symtab_hdr, sym_hashes,
&r_type, GOT_UNKNOWN,
- rel, relend, h))
+ rel, relend, h, r_symndx))
return FALSE;
switch (r_type)
/* If R_X86_64_GOTTPOFF symbol is now local to the binary,
make it a R_X86_64_TPOFF32 requiring no GOT entry. */
if (h->got.refcount > 0
- && !info->shared
+ && info->executable
&& h->dynindx == -1
&& elf64_x86_64_hash_entry (h)->tls_type == GOT_TLS_IE)
{
&sec, rel);
/* Relocate against local STT_GNU_IFUNC symbol. */
- if (ELF64_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
+ if (!info->relocatable
+ && ELF64_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
{
h = elf64_x86_64_get_local_sym_hash (htab, input_bfd,
rel, FALSE);
{
asection *plt;
bfd_vma plt_index;
+ const char *name;
if ((input_section->flags & SEC_ALLOC) == 0
|| h->plt.offset == (bfd_vma) -1)
switch (r_type)
{
default:
+ if (h->root.root.string)
+ name = h->root.root.string;
+ else
+ name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
+ NULL);
(*_bfd_error_handler)
(_("%B: relocation %s against STT_GNU_IFUNC "
"symbol `%s' isn't handled by %s"), input_bfd,
x86_64_elf_howto_table[r_type].name,
- (h->root.root.string
- ? h->root.root.string : "a local symbol"),
- __FUNCTION__);
+ name, __FUNCTION__);
bfd_set_error (bfd_error_bad_value);
return FALSE;
case R_X86_64_64:
if (rel->r_addend != 0)
{
+ if (h->root.root.string)
+ name = h->root.root.string;
+ else
+ name = bfd_elf_sym_name (input_bfd, symtab_hdr,
+ sym, NULL);
(*_bfd_error_handler)
(_("%B: relocation %s against STT_GNU_IFUNC "
"symbol `%s' has non-zero addend: %d"),
input_bfd, x86_64_elf_howto_table[r_type].name,
- (h->root.root.string
- ? h->root.root.string : "a local symbol"),
- rel->r_addend);
+ name, rel->r_addend);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
input_section, contents,
symtab_hdr, sym_hashes,
&r_type, tls_type, rel,
- relend, h))
+ relend, h, r_symndx))
return FALSE;
if (r_type == R_X86_64_TPOFF32)
input_section, contents,
symtab_hdr, sym_hashes,
&r_type, GOT_UNKNOWN,
- rel, relend, h))
+ rel, relend, h, r_symndx))
return FALSE;
if (r_type != R_X86_64_TLSLD)
break;
case R_X86_64_DTPOFF32:
- if (info->shared || (input_section->flags & SEC_CODE) == 0)
+ if (!info->executable|| (input_section->flags & SEC_CODE) == 0)
relocation -= elf64_x86_64_dtpoff_base (info);
else
relocation = elf64_x86_64_tpoff (info, relocation);
break;
case R_X86_64_TPOFF32:
- BFD_ASSERT (! info->shared);
+ BFD_ASSERT (info->executable);
relocation = elf64_x86_64_tpoff (info, relocation);
break;
#define elf64_bed elf64_x86_64_fbsd_bed
#include "elf64-target.h"
+
+/* Intel L1OM support. */
+
+static bfd_boolean
+elf64_l1om_elf_object_p (bfd *abfd)
+{
+ /* Set the right machine number for an L1OM elf64 file. */
+ bfd_default_set_arch_mach (abfd, bfd_arch_l1om, bfd_mach_l1om);
+ return TRUE;
+}
+
+#undef TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM bfd_elf64_l1om_vec
+#undef TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME "elf64-l1om"
+#undef ELF_ARCH
+#define ELF_ARCH bfd_arch_l1om
+
+#undef ELF_MACHINE_CODE
+#define ELF_MACHINE_CODE EM_L1OM
+
+#undef ELF_OSABI
+
+#undef elf64_bed
+#define elf64_bed elf64_l1om_bed
+
+#undef elf_backend_object_p
+#define elf_backend_object_p elf64_l1om_elf_object_p
+
+#undef elf_backend_post_process_headers
+
+#include "elf64-target.h"
+
+/* FreeBSD L1OM support. */
+
+#undef TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM bfd_elf64_l1om_freebsd_vec
+#undef TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME "elf64-l1om-freebsd"
+
+#undef ELF_OSABI
+#define ELF_OSABI ELFOSABI_FREEBSD
+
+#undef elf64_bed
+#define elf64_bed elf64_l1om_fbsd_bed
+
+#undef elf_backend_post_process_headers
+#define elf_backend_post_process_headers _bfd_elf_set_osabi
+
+#include "elf64-target.h"