arc-plt.h revision 1.1.1.1.4.1 1 1.1 christos /* ARC-specific header file for PLT support.
2 1.1.1.1.4.1 christos Copyright (C) 2016-2017 Free Software Foundation, Inc.
3 1.1 christos Contributed by Cupertino Miranda (cmiranda (at) synopsys.com).
4 1.1 christos
5 1.1 christos This file is part of BFD, the Binary File Descriptor library.
6 1.1 christos
7 1.1 christos This program is free software; you can redistribute it and/or modify
8 1.1 christos it under the terms of the GNU General Public License as published by
9 1.1 christos the Free Software Foundation; either version 3 of the License, or
10 1.1 christos (at your option) any later version.
11 1.1 christos
12 1.1 christos This program is distributed in the hope that it will be useful,
13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos GNU General Public License for more details.
16 1.1 christos
17 1.1 christos You should have received a copy of the GNU General Public License
18 1.1 christos along with this program; if not, write to the Free Software
19 1.1 christos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 1.1 christos MA 02110-1301, USA. */
21 1.1 christos
22 1.1 christos #ifndef ARC_PLT_H
23 1.1 christos #define ARC_PLT_H
24 1.1 christos
25 1.1 christos #include <stdint.h>
26 1.1 christos
27 1.1 christos /* Instructions appear in memory as a sequence of half-words (16 bit);
28 1.1 christos individual half-words are represented on the target in target byte order.
29 1.1 christos We use 'unsigned short' on the host to represent the PLT templates,
30 1.1 christos and translate to target byte order as we copy to the target. */
31 1.1 christos typedef uint16_t insn_hword;
32 1.1 christos
33 1.1 christos enum plt_reloc_symbol
34 1.1 christos {
35 1.1 christos LAST_RELOC = 0,
36 1.1 christos
37 1.1 christos SGOT = 1,
38 1.1 christos
39 1.1 christos RELATIVE = (1 << 8),
40 1.1 christos RELATIVE_INSN_32 = (1 << 9),
41 1.1 christos RELATIVE_INSN_24 = (1 << 10),
42 1.1 christos
43 1.1 christos MIDDLE_ENDIAN = (1 << 11)
44 1.1 christos };
45 1.1 christos
46 1.1 christos #define IS_RELATIVE(S) ((S & (RELATIVE | RELATIVE_INSN_24 | RELATIVE_INSN_32)) != 0)
47 1.1 christos #define IS_INSN_32(S) ((S & RELATIVE_INSN_32) != 0)
48 1.1 christos #define IS_INSN_24(S) ((S & RELATIVE_INSN_24) != 0)
49 1.1 christos #define IS_MIDDLE_ENDIAN(S) ((S & MIDDLE_ENDIAN) != 0)
50 1.1 christos #define SYM_ONLY(S) (S & 0xFF)
51 1.1 christos
52 1.1 christos struct plt_reloc
53 1.1 christos {
54 1.1 christos bfd_vma offset;
55 1.1 christos bfd_vma size;
56 1.1 christos bfd_vma mask;
57 1.1 christos enum plt_reloc_symbol symbol;
58 1.1 christos bfd_vma addend;
59 1.1 christos };
60 1.1 christos
61 1.1 christos
62 1.1 christos #define PLT_TYPE_START(NAME) NAME,
63 1.1 christos #define PLT_TYPE_END(NAME)
64 1.1 christos #define PLT_ENTRY(...)
65 1.1 christos #define PLT_ELEM(...)
66 1.1 christos #define ENTRY_RELOC(...)
67 1.1 christos #define ELEM_RELOC(...)
68 1.1 christos
69 1.1 christos enum plt_types_enum
70 1.1 christos {
71 1.1 christos PLT_START = -1,
72 1.1 christos #include "arc-plt.def"
73 1.1 christos PLT_MAX
74 1.1 christos };
75 1.1 christos
76 1.1 christos #undef PLT_TYPE_START
77 1.1 christos #undef PLT_TYPE_END
78 1.1 christos #undef PLT_ENTRY
79 1.1 christos #undef PLT_ELEM
80 1.1 christos #undef ENTRY_RELOC
81 1.1 christos #undef ELEM_RELOC
82 1.1 christos
83 1.1 christos typedef insn_hword insn_hword_array[];
84 1.1 christos
85 1.1 christos struct plt_version_t
86 1.1 christos {
87 1.1 christos const insn_hword_array *entry;
88 1.1 christos const bfd_vma entry_size;
89 1.1 christos const insn_hword_array *elem;
90 1.1 christos const bfd_vma elem_size;
91 1.1 christos
92 1.1 christos const struct plt_reloc *entry_relocs;
93 1.1 christos const struct plt_reloc *elem_relocs;
94 1.1 christos };
95 1.1 christos
96 1.1 christos #define PLT_TYPE_START(NAME) \
97 1.1 christos const insn_hword NAME##_plt_entry[] = {
98 1.1 christos #define PLT_TYPE_END(NAME) };
99 1.1 christos #define PLT_ENTRY(...) __VA_ARGS__,
100 1.1 christos #define PLT_ELEM(...)
101 1.1 christos #define ENTRY_RELOC(...)
102 1.1 christos #define ELEM_RELOC(...)
103 1.1 christos
104 1.1 christos #include "arc-plt.def"
105 1.1 christos
106 1.1 christos #undef PLT_TYPE_START
107 1.1 christos #undef PLT_TYPE_END
108 1.1 christos #undef PLT_ENTRY
109 1.1 christos #undef PLT_ELEM
110 1.1 christos #undef ENTRY_RELOC
111 1.1 christos #undef ELEM_RELOC
112 1.1 christos
113 1.1 christos #define PLT_TYPE_START(NAME) \
114 1.1 christos const struct plt_reloc NAME##_plt_entry_relocs[] = {
115 1.1 christos #define PLT_TYPE_END(NAME) \
116 1.1 christos {0, 0, 0, LAST_RELOC, 0} \
117 1.1 christos };
118 1.1 christos #define PLT_ENTRY(...)
119 1.1 christos #define PLT_ELEM(...)
120 1.1 christos #define ENTRY_RELOC(...) { __VA_ARGS__ },
121 1.1 christos #define ELEM_RELOC(...)
122 1.1 christos
123 1.1 christos #include "arc-plt.def"
124 1.1 christos
125 1.1 christos #undef PLT_TYPE_START
126 1.1 christos #undef PLT_TYPE_END
127 1.1 christos #undef PLT_ENTRY
128 1.1 christos #undef PLT_ELEM
129 1.1 christos #undef ENTRY_RELOC
130 1.1 christos #undef ELEM_RELOC
131 1.1 christos
132 1.1 christos
133 1.1 christos #define PLT_TYPE_START(NAME) \
134 1.1 christos const insn_hword NAME##_plt_elem[] = {
135 1.1 christos #define PLT_TYPE_END(NAME) };
136 1.1 christos #define PLT_ENTRY(...)
137 1.1 christos #define PLT_ELEM(...) __VA_ARGS__,
138 1.1 christos #define ENTRY_RELOC(...)
139 1.1 christos #define ELEM_RELOC(...)
140 1.1 christos
141 1.1 christos #include "arc-plt.def"
142 1.1 christos
143 1.1 christos #undef PLT_TYPE_START
144 1.1 christos #undef PLT_TYPE_END
145 1.1 christos #undef PLT_ENTRY
146 1.1 christos #undef PLT_ELEM
147 1.1 christos #undef ENTRY_RELOC
148 1.1 christos #undef ELEM_RELOC
149 1.1 christos
150 1.1 christos #define PLT_TYPE_START(NAME) \
151 1.1 christos const struct plt_reloc NAME##_plt_elem_relocs[] = {
152 1.1 christos #define PLT_TYPE_END(NAME) \
153 1.1 christos {0, 0, 0, LAST_RELOC, 0} \
154 1.1 christos };
155 1.1 christos #define PLT_ENTRY(...)
156 1.1 christos #define PLT_ELEM(...)
157 1.1 christos #define ENTRY_RELOC(...)
158 1.1 christos #define ELEM_RELOC(...) { __VA_ARGS__ },
159 1.1 christos
160 1.1 christos #include "arc-plt.def"
161 1.1 christos
162 1.1 christos #undef PLT_TYPE_START
163 1.1 christos #undef PLT_TYPE_END
164 1.1 christos #undef PLT_ENTRY
165 1.1 christos #undef PLT_ELEM
166 1.1 christos #undef ENTRY_RELOC
167 1.1 christos #undef ELEM_RELOC
168 1.1 christos
169 1.1 christos
170 1.1 christos #define PLT_TYPE_START(NAME) \
171 1.1 christos { \
172 1.1 christos .entry = &NAME##_plt_entry, \
173 1.1 christos .entry_size = sizeof (NAME##_plt_entry), \
174 1.1 christos .elem = &NAME##_plt_elem, \
175 1.1 christos .elem_size = sizeof (NAME##_plt_elem), \
176 1.1 christos .entry_relocs = NAME##_plt_entry_relocs, \
177 1.1 christos .elem_relocs = NAME##_plt_elem_relocs
178 1.1 christos #define PLT_TYPE_END(NAME) },
179 1.1 christos #define PLT_ENTRY(...)
180 1.1 christos #define PLT_ELEM(...)
181 1.1 christos #define ENTRY_RELOC(...)
182 1.1 christos #define ELEM_RELOC(...)
183 1.1 christos struct plt_version_t plt_versions[PLT_MAX] = {
184 1.1 christos
185 1.1 christos #include "arc-plt.def"
186 1.1 christos
187 1.1 christos };
188 1.1 christos #undef PLT_TYPE_START
189 1.1 christos #undef PLT_TYPE_END
190 1.1 christos #undef PLT_ENTRY
191 1.1 christos #undef PLT_ELEM
192 1.1 christos #undef ENTRY_RELOC
193 1.1 christos #undef ELEM_RELOC
194 1.1 christos
195 1.1 christos
196 1.1 christos #endif /* ARC_PLT_H */
197