aboutsummaryrefslogtreecommitdiff
path: root/bfd/arc-plt.h
diff options
context:
space:
mode:
authorMiranda Cupertino <Cupertino.Miranda@synopsys.com>2016-01-19 15:25:58 +0000
committerNick Clifton <nickc@redhat.com>2016-01-19 15:25:58 +0000
commit34e967a5f3ac5fd0353731a259e358d462823290 (patch)
tree35296c70f96fcc39f3196a8d54a09a047ace5e27 /bfd/arc-plt.h
parentc2f4122d5cc2a21a441470336c8637b6a6965c6e (diff)
downloadgdb-34e967a5f3ac5fd0353731a259e358d462823290.zip
gdb-34e967a5f3ac5fd0353731a259e358d462823290.tar.gz
gdb-34e967a5f3ac5fd0353731a259e358d462823290.tar.bz2
Add PIC and TLS support to the ARC target.
bfd/ChangeLog: * arc-plt.def: New file. * arc-plt.h: Likewise. * elf32-arc.c (elf_arc_abs_plt0_entry, elf_arc_abs_pltn_entry, elf_arcV2_abs_plt0_entry, elf_arcV2_abs_pltn_entry, elf_arc_pic_plt0_entry, elf_arc_pic_pltn_entry, elf_arcV2_pic_plt0_entry, elf_arcV2_pic_pltn_entry): Remove. (name_for_global_symbol): Added. (ADD_RELA): Helper to create dynamic relocs. (new_got_entry_to_list): Create a new got entry in linked list. (symbol_has_entry_of_type): Search for specific type of entry in list. (is_reloc_for_GOT): return FALSE for any TLS related relocs. (is_reloc_for_TLS, arc_elf_set_private_flags) (arc_elf_print_private_bfd_data, arc_elf_copy_private_bfd_data) (arc_elf_merge_private_bfd_data): New functions. (debug_arc_reloc): Cleaned debug info printing. (PDATA reloc): Changed not to perform address alignment. (reverse_me): Added. Fix for ARC_32 relocs. (arc_do_relocation): Return bfd_reloc_of when no relocation should occur. (arc_get_local_got_ents): Renamed from arc_get_local_got_offsets. Changed function to access an array of list of GOT entries instead of just an array of offsets. (elf_arc_relocate_section): Added support for PIC and TLS related relocations. (elf_arc_check_relocs): Likewise. (elf_arc_adjust_dynamic_symbol, elf_arc_finish_dynamic_symbol, (elf_arc_finish_dynamic_sections): Likewise (arc_create_dynamic_sections): Modified conditions to create dynamic sections. (ADD_SYMBOL_REF_SEC_AND_RELOC): New macro. (plt_do_relocs_for_symbol, relocate_plt_for_symbol) (relocate_plt_for_entry): Changed to support new way to define PLT related code. (add_symbol_to_plt): Likewise. (arc_elf_link_hash_table_create): New function. include/ChangeLog: * elf/arc-reloc.def (ARC_32, ARC_GOTPC, ARC_TLS_GD_GOT) (ARC_TLS_IE_GOT, ARC_TLS_DTPOFF, ARC_TLS_DTPOFF_S9, ARC_TLS_LE_S9) (ARC_TLS_LE_32): Fixed formula. (ARC_TLS_GD_LD): Use new special function. * opcode/arc-func.h: Changed all the replacement functions to clear the patching bits before doing an or it with the value argument.
Diffstat (limited to 'bfd/arc-plt.h')
-rw-r--r--bfd/arc-plt.h196
1 files changed, 196 insertions, 0 deletions
diff --git a/bfd/arc-plt.h b/bfd/arc-plt.h
new file mode 100644
index 0000000..fec461d
--- /dev/null
+++ b/bfd/arc-plt.h
@@ -0,0 +1,196 @@
+/* ARC-specific header file for PLT support.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ Contributed by Cupertino Miranda (cmiranda@synopsys.com).
+
+ 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. */
+
+#ifndef ARC_PLT_H
+#define ARC_PLT_H
+
+#include <stdint.h>
+
+/* Instructions appear in memory as a sequence of half-words (16 bit);
+ individual half-words are represented on the target in target byte order.
+ We use 'unsigned short' on the host to represent the PLT templates,
+ and translate to target byte order as we copy to the target. */
+typedef uint16_t insn_hword;
+
+enum plt_reloc_symbol
+{
+ LAST_RELOC = 0,
+
+ SGOT = 1,
+
+ RELATIVE = (1 << 8),
+ RELATIVE_INSN_32 = (1 << 9),
+ RELATIVE_INSN_24 = (1 << 10),
+
+ MIDDLE_ENDIAN = (1 << 11)
+};
+
+#define IS_RELATIVE(S) ((S & (RELATIVE | RELATIVE_INSN_24 | RELATIVE_INSN_32)) != 0)
+#define IS_INSN_32(S) ((S & RELATIVE_INSN_32) != 0)
+#define IS_INSN_24(S) ((S & RELATIVE_INSN_24) != 0)
+#define IS_MIDDLE_ENDIAN(S) ((S & MIDDLE_ENDIAN) != 0)
+#define SYM_ONLY(S) (S & 0xFF)
+
+struct plt_reloc
+{
+ bfd_vma offset;
+ bfd_vma size;
+ bfd_vma mask;
+ enum plt_reloc_symbol symbol;
+ bfd_vma addend;
+};
+
+
+#define PLT_TYPE_START(NAME) NAME,
+#define PLT_TYPE_END(NAME)
+#define PLT_ENTRY(...)
+#define PLT_ELEM(...)
+#define ENTRY_RELOC(...)
+#define ELEM_RELOC(...)
+
+enum plt_types_enum
+{
+ PLT_START = -1,
+#include "arc-plt.def"
+ PLT_MAX
+};
+
+#undef PLT_TYPE_START
+#undef PLT_TYPE_END
+#undef PLT_ENTRY
+#undef PLT_ELEM
+#undef ENTRY_RELOC
+#undef ELEM_RELOC
+
+typedef insn_hword insn_hword_array[];
+
+struct plt_version_t
+{
+ const insn_hword_array *entry;
+ const bfd_vma entry_size;
+ const insn_hword_array *elem;
+ const bfd_vma elem_size;
+
+ const struct plt_reloc *entry_relocs;
+ const struct plt_reloc *elem_relocs;
+};
+
+#define PLT_TYPE_START(NAME) \
+ const insn_hword NAME##_plt_entry[] = {
+#define PLT_TYPE_END(NAME) };
+#define PLT_ENTRY(...) __VA_ARGS__,
+#define PLT_ELEM(...)
+#define ENTRY_RELOC(...)
+#define ELEM_RELOC(...)
+
+#include "arc-plt.def"
+
+#undef PLT_TYPE_START
+#undef PLT_TYPE_END
+#undef PLT_ENTRY
+#undef PLT_ELEM
+#undef ENTRY_RELOC
+#undef ELEM_RELOC
+
+#define PLT_TYPE_START(NAME) \
+ const struct plt_reloc NAME##_plt_entry_relocs[] = {
+#define PLT_TYPE_END(NAME) \
+ {0, 0, 0, LAST_RELOC, 0} \
+ };
+#define PLT_ENTRY(...)
+#define PLT_ELEM(...)
+#define ENTRY_RELOC(...) { __VA_ARGS__ },
+#define ELEM_RELOC(...)
+
+#include "arc-plt.def"
+
+#undef PLT_TYPE_START
+#undef PLT_TYPE_END
+#undef PLT_ENTRY
+#undef PLT_ELEM
+#undef ENTRY_RELOC
+#undef ELEM_RELOC
+
+
+#define PLT_TYPE_START(NAME) \
+ const insn_hword NAME##_plt_elem[] = {
+#define PLT_TYPE_END(NAME) };
+#define PLT_ENTRY(...)
+#define PLT_ELEM(...) __VA_ARGS__,
+#define ENTRY_RELOC(...)
+#define ELEM_RELOC(...)
+
+#include "arc-plt.def"
+
+#undef PLT_TYPE_START
+#undef PLT_TYPE_END
+#undef PLT_ENTRY
+#undef PLT_ELEM
+#undef ENTRY_RELOC
+#undef ELEM_RELOC
+
+#define PLT_TYPE_START(NAME) \
+ const struct plt_reloc NAME##_plt_elem_relocs[] = {
+#define PLT_TYPE_END(NAME) \
+ {0, 0, 0, LAST_RELOC, 0} \
+ };
+#define PLT_ENTRY(...)
+#define PLT_ELEM(...)
+#define ENTRY_RELOC(...)
+#define ELEM_RELOC(...) { __VA_ARGS__ },
+
+#include "arc-plt.def"
+
+#undef PLT_TYPE_START
+#undef PLT_TYPE_END
+#undef PLT_ENTRY
+#undef PLT_ELEM
+#undef ENTRY_RELOC
+#undef ELEM_RELOC
+
+
+#define PLT_TYPE_START(NAME) \
+ { \
+ .entry = &NAME##_plt_entry, \
+ .entry_size = sizeof (NAME##_plt_entry), \
+ .elem = &NAME##_plt_elem, \
+ .elem_size = sizeof (NAME##_plt_elem), \
+ .entry_relocs = NAME##_plt_entry_relocs, \
+ .elem_relocs = NAME##_plt_elem_relocs
+#define PLT_TYPE_END(NAME) },
+#define PLT_ENTRY(...)
+#define PLT_ELEM(...)
+#define ENTRY_RELOC(...)
+#define ELEM_RELOC(...)
+struct plt_version_t plt_versions[PLT_MAX] = {
+
+#include "arc-plt.def"
+
+};
+#undef PLT_TYPE_START
+#undef PLT_TYPE_END
+#undef PLT_ENTRY
+#undef PLT_ELEM
+#undef ENTRY_RELOC
+#undef ELEM_RELOC
+
+
+#endif /* ARC_PLT_H */