/* X86-64 specific support for ELF
- Copyright (C) 2000-2014 Free Software Foundation, Inc.
+ Copyright (C) 2000-2015 Free Software Foundation, Inc.
Contributed by Jan Hubicka <jh@suse.cz>.
This file is part of BFD, the Binary File Descriptor library.
special_function, name, partial_inplace, src_mask, dst_mask, pcrel_offset. */
static reloc_howto_type x86_64_elf_howto_table[] =
{
- HOWTO(R_X86_64_NONE, 0, 0, 0, FALSE, 0, complain_overflow_dont,
+ HOWTO(R_X86_64_NONE, 0, 3, 0, FALSE, 0, complain_overflow_dont,
bfd_elf_generic_reloc, "R_X86_64_NONE", FALSE, 0x00000000, 0x00000000,
FALSE),
HOWTO(R_X86_64_64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
return TRUE;
}
+/* Rename some of the generic section flags to better document how they
+ are used here. */
+#define need_convert_mov_to_lea sec_flg0
+
/* Look through the relocs for a section during the first phase, and
calculate needed space in the global offset table, procedure
linkage table, and dynamic reloc sections. */
plt_got_align))
return FALSE;
}
+
+ if (r_type == R_X86_64_GOTPCREL
+ && (h == NULL || h->type != STT_GNU_IFUNC))
+ sec->need_convert_mov_to_lea = 1;
}
return TRUE;
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
return FALSE;
}
- /* For PIE, discard space for relocs against symbols which
- turn out to need copy relocs. */
+ /* For PIE, discard space for pc-relative relocs against
+ symbols which turn out to need copy relocs. */
else if (info->executable
&& (h->needs_copy || eh->needs_copy)
&& h->def_dynamic
&& !h->def_regular)
- eh->dyn_relocs = NULL;
+ {
+ struct elf_dyn_relocs **pp;
+
+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+ {
+ if (p->pc_count != 0)
+ *pp = p->next;
+ else
+ pp = &p->next;
+ }
+ }
}
}
else if (ELIMINATE_COPY_RELOCS)
info->flags |= DF_TEXTREL;
- if (info->warn_shared_textrel && info->shared)
- info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"),
+ if ((info->warn_shared_textrel && info->shared)
+ || info->error_textrel)
+ info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'\n"),
p->sec->owner, h->root.root.string,
p->sec);
if (!is_elf_hash_table (link_info->hash))
return FALSE;
- /* Nothing to do if there are no codes, no relocations or no output. */
+ /* Nothing to do if there is no need or no output. */
if ((sec->flags & (SEC_CODE | SEC_RELOC)) != (SEC_CODE | SEC_RELOC)
- || sec->reloc_count == 0
+ || sec->need_convert_mov_to_lea == 0
|| bfd_is_abs_section (sec->output_section))
return TRUE;
&& (info->flags & DF_TEXTREL) == 0)
{
info->flags |= DF_TEXTREL;
- if (info->warn_shared_textrel && info->shared)
- info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'.\n"),
+ if ((info->warn_shared_textrel && info->shared)
+ || info->error_textrel)
+ info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'\n"),
p->sec->owner, p->sec);
}
}
tlsbase = (struct elf_link_hash_entry *)bh;
tlsbase->def_regular = 1;
tlsbase->other = STV_HIDDEN;
+ tlsbase->root.linker_def = 1;
(*bed->elf_backend_hide_symbol) (info, tlsbase, TRUE);
}
}
case R_X86_64_PC16:
case R_X86_64_PC32:
case R_X86_64_PC32_BND:
+ /* Don't complain about -fPIC if the symbol is undefined when
+ building executable. */
if (info->shared
&& (input_section->flags & SEC_ALLOC) != 0
&& (input_section->flags & SEC_READONLY) != 0
- && h != NULL)
+ && h != NULL
+ && !(info->executable
+ && h->root.type == bfd_link_hash_undefined))
{
bfd_boolean fail = FALSE;
bfd_boolean branch
break;
/* Don't copy a pc-relative relocation into the output file
- if the symbol needs copy reloc. */
+ if the symbol needs copy reloc or the symbol is undefined
+ when building executable. */
if ((info->shared
&& !(info->executable
&& h != NULL
- && (h->needs_copy || eh->needs_copy)
+ && (h->needs_copy
+ || eh->needs_copy
+ || h->root.type == bfd_link_hash_undefined)
&& IS_X86_64_PCREL_TYPE (r_type))
&& (h == NULL
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
if (plt_sym_val == NULL)
goto bad_return;
- for (i = 0; i < count; i++, p++)
+ for (i = 0; i < count; i++)
plt_sym_val[i] = -1;
plt_offset = bed->plt_entry_size;
{
long reloc_index;
+ /* Skip unknown relocation. */
+ if (p->howto == NULL)
+ continue;
+
if (p->howto->type != R_X86_64_JUMP_SLOT
&& p->howto->type != R_X86_64_IRELATIVE)
continue;
#define elf_backend_got_header_size (GOT_ENTRY_SIZE*3)
#define elf_backend_rela_normal 1
#define elf_backend_plt_alignment 4
+#define elf_backend_extern_protected_data 1
#define elf_info_to_howto elf_x86_64_info_to_howto