Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf-hppa.h
1 /* Common code for PA ELF implementations.
2 Copyright (C) 1999-2021 Free Software Foundation, Inc.
3
4 This file is part of BFD, the Binary File Descriptor library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
20
21 #define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
22
23 /* This file is included by multiple PA ELF BFD backends with different
24 sizes.
25
26 Most of the routines are written to be size independent, but sometimes
27 external constraints require 32 or 64 bit specific code. We remap
28 the definitions/functions as necessary here. */
29 #if ARCH_SIZE == 64
30 #define ELF_R_TYPE(X) ELF64_R_TYPE(X)
31 #define ELF_R_SYM(X) ELF64_R_SYM(X)
32 #define elf_hppa_reloc_final_type elf64_hppa_reloc_final_type
33 #define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
34 #define elf_hppa_relocate_section elf64_hppa_relocate_section
35 #define elf_hppa_final_link elf64_hppa_final_link
36 #endif
37 #if ARCH_SIZE == 32
38 #define ELF_R_TYPE(X) ELF32_R_TYPE(X)
39 #define ELF_R_SYM(X) ELF32_R_SYM(X)
40 #define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type
41 #define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
42 #define elf_hppa_relocate_section elf32_hppa_relocate_section
43 #define elf_hppa_final_link elf32_hppa_final_link
44 #endif
45
46 /* ELF/PA relocation howto entries. */
47
48 static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
49 {
50 #define HOW(type, size, bitsize, pc_rel, complain, mask) \
51 HOWTO (type, 0, size, bitsize, pc_rel, 0, complain_overflow_ ## complain, \
52 bfd_elf_generic_reloc, #type, false, 0, mask, false)
53
54 /* The values in DIR32 are to placate the check in
55 _bfd_stab_section_find_nearest_line. */
56 HOW (R_PARISC_NONE, 3, 0, false, dont, 0),
57 HOW (R_PARISC_DIR32, 2, 32, false, bitfield, 0xffffffff),
58 HOW (R_PARISC_DIR21L, 2, 21, false, bitfield, 0),
59 HOW (R_PARISC_DIR17R, 2, 17, false, bitfield, 0),
60 HOW (R_PARISC_DIR17F, 2, 17, false, bitfield, 0),
61 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
62 HOW (R_PARISC_DIR14R, 2, 14, false, bitfield, 0),
63 HOW (R_PARISC_DIR14F, 2, 14, false, bitfield, 0),
64 /* 8 */
65 HOW (R_PARISC_PCREL12F, 2, 12, true, bitfield, 0),
66 HOW (R_PARISC_PCREL32, 2, 32, true, bitfield, 0),
67 HOW (R_PARISC_PCREL21L, 2, 21, true, bitfield, 0),
68 HOW (R_PARISC_PCREL17R, 2, 17, true, bitfield, 0),
69 HOW (R_PARISC_PCREL17F, 2, 17, true, bitfield, 0),
70 HOW (R_PARISC_PCREL17C, 2, 17, true, bitfield, 0),
71 HOW (R_PARISC_PCREL14R, 2, 14, true, bitfield, 0),
72 HOW (R_PARISC_PCREL14F, 2, 14, true, bitfield, 0),
73 /* 16 */
74 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
75 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
76 HOW (R_PARISC_DPREL21L, 2, 21, false, bitfield, 0),
77 HOW (R_PARISC_DPREL14WR, 2, 14, false, bitfield, 0),
78 HOW (R_PARISC_DPREL14DR, 2, 14, false, bitfield, 0),
79 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
80 HOW (R_PARISC_DPREL14R, 2, 14, false, bitfield, 0),
81 HOW (R_PARISC_DPREL14F, 2, 14, false, bitfield, 0),
82 /* 24 */
83 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
84 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
85 HOW (R_PARISC_DLTREL21L, 2, 21, false, bitfield, 0),
86 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
87 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
88 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
89 HOW (R_PARISC_DLTREL14R, 2, 14, false, bitfield, 0),
90 HOW (R_PARISC_DLTREL14F, 2, 14, false, bitfield, 0),
91 /* 32 */
92 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
93 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
94 HOW (R_PARISC_DLTIND21L, 2, 21, false, bitfield, 0),
95 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
96 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
97 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
98 HOW (R_PARISC_DLTIND14R, 2, 14, false, bitfield, 0),
99 HOW (R_PARISC_DLTIND14F, 2, 14, false, bitfield, 0),
100 /* 40 */
101 HOW (R_PARISC_SETBASE, 0, 0, false, bitfield, 0),
102 HOW (R_PARISC_SECREL32, 2, 32, false, bitfield, 0xffffffff),
103 HOW (R_PARISC_BASEREL21L, 2, 21, false, bitfield, 0),
104 HOW (R_PARISC_BASEREL17R, 2, 17, false, bitfield, 0),
105 HOW (R_PARISC_BASEREL17F, 2, 17, false, bitfield, 0),
106 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
107 HOW (R_PARISC_BASEREL14R, 2, 14, false, bitfield, 0),
108 HOW (R_PARISC_BASEREL14F, 2, 14, false, bitfield, 0),
109 /* 48 */
110 HOW (R_PARISC_SEGBASE, 0, 0, false, bitfield, 0),
111 HOW (R_PARISC_SEGREL32, 2, 32, false, bitfield, 0),
112 HOW (R_PARISC_PLTOFF21L, 2, 21, false, bitfield, 0),
113 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
114 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
115 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
116 HOW (R_PARISC_PLTOFF14R, 2, 14, false, bitfield, 0),
117 HOW (R_PARISC_PLTOFF14F, 2, 14, false, bitfield, 0),
118 /* 56 */
119 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
120 HOW (R_PARISC_LTOFF_FPTR32, 2, 32, false, bitfield, 0),
121 HOW (R_PARISC_LTOFF_FPTR21L, 2, 21, false, bitfield, 0),
122 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
123 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
124 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
125 HOW (R_PARISC_LTOFF_FPTR14R, 2, 14, false, bitfield, 0),
126 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
127 /* 64 */
128 HOW (R_PARISC_FPTR64, 4, 64, false, bitfield, 0),
129 HOW (R_PARISC_PLABEL32, 2, 32, false, bitfield, 0),
130 HOW (R_PARISC_PLABEL21L, 2, 21, false, bitfield, 0),
131 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
132 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
133 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
134 HOW (R_PARISC_PLABEL14R, 2, 14, false, bitfield, 0),
135 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
136 /* 72 */
137 HOW (R_PARISC_PCREL64, 4, 64, false, bitfield, 0),
138 HOW (R_PARISC_PCREL22C, 2, 22, false, bitfield, 0),
139 HOW (R_PARISC_PCREL22F, 2, 22, false, bitfield, 0),
140 HOW (R_PARISC_PCREL14WR, 2, 14, false, bitfield, 0),
141 HOW (R_PARISC_PCREL14DR, 2, 14, false, bitfield, 0),
142 HOW (R_PARISC_PCREL16F, 2, 16, false, bitfield, 0),
143 HOW (R_PARISC_PCREL16WF, 2, 16, false, bitfield, 0),
144 HOW (R_PARISC_PCREL16DF, 2, 16, false, bitfield, 0),
145 /* 80 */
146 HOW (R_PARISC_DIR64, 4, 64, false, bitfield, 0),
147 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
148 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
149 HOW (R_PARISC_DIR14WR, 2, 14, false, bitfield, 0),
150 HOW (R_PARISC_DIR14DR, 2, 14, false, bitfield, 0),
151 HOW (R_PARISC_DIR16F, 2, 16, false, bitfield, 0),
152 HOW (R_PARISC_DIR16WF, 2, 16, false, bitfield, 0),
153 HOW (R_PARISC_DIR16DF, 2, 16, false, bitfield, 0),
154 /* 88 */
155 HOW (R_PARISC_GPREL64, 4, 64, false, bitfield, 0),
156 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
157 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
158 HOW (R_PARISC_DLTREL14WR, 2, 14, false, bitfield, 0),
159 HOW (R_PARISC_DLTREL14DR, 2, 14, false, bitfield, 0),
160 HOW (R_PARISC_GPREL16F, 2, 16, false, bitfield, 0),
161 HOW (R_PARISC_GPREL16WF, 2, 16, false, bitfield, 0),
162 HOW (R_PARISC_GPREL16DF, 2, 16, false, bitfield, 0),
163 /* 96 */
164 HOW (R_PARISC_LTOFF64, 4, 64, false, bitfield, 0),
165 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
166 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
167 HOW (R_PARISC_DLTIND14WR, 2, 14, false, bitfield, 0),
168 HOW (R_PARISC_DLTIND14DR, 2, 14, false, bitfield, 0),
169 HOW (R_PARISC_LTOFF16F, 2, 16, false, bitfield, 0),
170 HOW (R_PARISC_LTOFF16WF, 2, 16, false, bitfield, 0),
171 HOW (R_PARISC_LTOFF16DF, 2, 16, false, bitfield, 0),
172 /* 104 */
173 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
174 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
175 HOW (R_PARISC_BASEREL14WR, 2, 14, false, bitfield, 0),
176 HOW (R_PARISC_BASEREL14DR, 2, 14, false, bitfield, 0),
177 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
178 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
179 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
180 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
181 /* 112 */
182 HOW (R_PARISC_SEGREL64, 4, 64, false, bitfield, 0),
183 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
184 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
185 HOW (R_PARISC_PLTOFF14WR, 2, 14, false, bitfield, 0),
186 HOW (R_PARISC_PLTOFF14DR, 2, 14, false, bitfield, 0),
187 HOW (R_PARISC_PLTOFF16F, 2, 16, false, bitfield, 0),
188 HOW (R_PARISC_PLTOFF16WF, 2, 16, false, bitfield, 0),
189 HOW (R_PARISC_PLTOFF16DF, 2, 16, false, bitfield, 0),
190 /* 120 */
191 HOW (R_PARISC_LTOFF_FPTR64, 4, 64, false, bitfield, 0),
192 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
193 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
194 HOW (R_PARISC_LTOFF_FPTR14WR, 2, 14, false, bitfield, 0),
195 HOW (R_PARISC_LTOFF_FPTR14DR, 2, 14, false, bitfield, 0),
196 HOW (R_PARISC_LTOFF_FPTR16F, 2, 16, false, bitfield, 0),
197 HOW (R_PARISC_LTOFF_FPTR16WF, 2, 16, false, bitfield, 0),
198 HOW (R_PARISC_LTOFF_FPTR16DF, 2, 16, false, bitfield, 0),
199 /* 128 */
200 HOW (R_PARISC_COPY, 0, 0, false, bitfield, 0),
201 HOW (R_PARISC_IPLT, 0, 0, false, bitfield, 0),
202 HOW (R_PARISC_EPLT, 0, 0, false, bitfield, 0),
203 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
204 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
205 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
206 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
207 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
208 /* 136 */
209 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
210 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
211 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
212 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
213 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
214 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
215 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
216 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
217 /* 144 */
218 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
219 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
220 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
221 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
222 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
223 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
224 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
225 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
226 /* 152 */
227 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
228 HOW (R_PARISC_TPREL32, 2, 32, false, dont, 0),
229 HOW (R_PARISC_TPREL21L, 2, 21, false, bitfield, 0),
230 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
231 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
232 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
233 HOW (R_PARISC_TPREL14R, 2, 14, false, bitfield, 0),
234 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
235 /* 160 */
236 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
237 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
238 HOW (R_PARISC_LTOFF_TP21L, 2, 21, false, bitfield, 0),
239 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
240 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
241 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
242 HOW (R_PARISC_LTOFF_TP14R, 2, 14, false, bitfield, 0),
243 HOW (R_PARISC_LTOFF_TP14F, 2, 14, false, bitfield, 0),
244 /* 168 */
245 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
246 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
247 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
248 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
249 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
250 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
251 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
252 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
253 /* 176 */
254 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
255 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
256 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
257 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
258 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
259 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
260 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
261 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
262 /* 184 */
263 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
264 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
265 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
266 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
267 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
268 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
269 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
270 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
271 /* 192 */
272 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
273 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
274 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
275 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
276 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
277 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
278 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
279 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
280 /* 200 */
281 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
282 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
283 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
284 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
285 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
286 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
287 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
288 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
289 /* 208 */
290 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
291 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
292 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
293 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
294 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, dont, 0),
295 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
296 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
297 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
298 /* 216 */
299 HOW (R_PARISC_TPREL64, 4, 64, false, bitfield, 0),
300 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
301 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
302 HOW (R_PARISC_TPREL14WR, 2, 14, false, dont, 0),
303 HOW (R_PARISC_TPREL14DR, 2, 14, false, bitfield, 0),
304 HOW (R_PARISC_TPREL16F, 2, 16, false, bitfield, 0),
305 HOW (R_PARISC_TPREL16WF, 2, 16, false, dont, 0),
306 HOW (R_PARISC_TPREL16DF, 2, 16, false, bitfield, 0),
307 /* 224 */
308 HOW (R_PARISC_LTOFF_TP64, 4, 64, false, bitfield, 0),
309 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
310 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, false, bitfield, 0),
311 HOW (R_PARISC_LTOFF_TP14WR, 2, 14, false, bitfield, 0),
312 HOW (R_PARISC_LTOFF_TP14DR, 2, 14, false, bitfield, 0),
313 HOW (R_PARISC_LTOFF_TP16F, 2, 16, false, dont, 0),
314 HOW (R_PARISC_LTOFF_TP16WF, 2, 16, false, bitfield, 0),
315 HOW (R_PARISC_LTOFF_TP16DF, 2, 16, false, bitfield, 0),
316 /* 232 */
317 HOW (R_PARISC_GNU_VTENTRY, 0, 0, false, dont, 0),
318 HOW (R_PARISC_GNU_VTINHERIT, 0, 0, false, dont, 0),
319 HOW (R_PARISC_TLS_GD21L, 2, 21, false, bitfield, 0),
320 HOW (R_PARISC_TLS_GD14R, 2, 14, false, bitfield, 0),
321 HOW (R_PARISC_TLS_GDCALL, 0, 0, false, dont, 0),
322 HOW (R_PARISC_TLS_LDM21L, 2, 21, false, bitfield, 0),
323 HOW (R_PARISC_TLS_LDM14R, 2, 14, false, bitfield, 0),
324 HOW (R_PARISC_TLS_LDMCALL, 0, 0, false, dont, 0),
325 /* 240 */
326 HOW (R_PARISC_TLS_LDO21L, 2, 21, false, bitfield, 0),
327 HOW (R_PARISC_TLS_LDO14R, 2, 14, false, bitfield, 0),
328 HOW (R_PARISC_TLS_DTPMOD32, 2, 32, false, bitfield, 0),
329 HOW (R_PARISC_TLS_DTPMOD64, 4, 64, false, bitfield, 0),
330 HOW (R_PARISC_TLS_DTPOFF32, 2, 32, false, bitfield, 0),
331 HOW (R_PARISC_TLS_DTPOFF64, 4, 64, false, bitfield, 0)
332 #undef HOW
333 };
334
335 #define OFFSET_14R_FROM_21L 4
336 #define OFFSET_14F_FROM_21L 5
337
338 /* Return the final relocation type for the given base type, instruction
339 format, and field selector. */
340
341 elf_hppa_reloc_type
342 elf_hppa_reloc_final_type (bfd *abfd,
343 elf_hppa_reloc_type base_type,
344 int format,
345 unsigned int field)
346 {
347 elf_hppa_reloc_type final_type = base_type;
348
349 /* Just a tangle of nested switch statements to deal with the braindamage
350 that a different field selector means a completely different relocation
351 for PA ELF. */
352 switch (base_type)
353 {
354 /* We have been using generic relocation types. However, that may not
355 really make sense. Anyway, we need to support both R_PARISC_DIR64
356 and R_PARISC_DIR32 here. */
357 case R_PARISC_DIR32:
358 case R_PARISC_DIR64:
359 case R_HPPA_ABS_CALL:
360 switch (format)
361 {
362 case 14:
363 switch (field)
364 {
365 case e_fsel:
366 final_type = R_PARISC_DIR14F;
367 break;
368 case e_rsel:
369 case e_rrsel:
370 case e_rdsel:
371 final_type = R_PARISC_DIR14R;
372 break;
373 case e_rtsel:
374 final_type = R_PARISC_DLTIND14R;
375 break;
376 case e_rtpsel:
377 final_type = R_PARISC_LTOFF_FPTR14DR;
378 break;
379 case e_tsel:
380 final_type = R_PARISC_DLTIND14F;
381 break;
382 case e_rpsel:
383 final_type = R_PARISC_PLABEL14R;
384 break;
385 default:
386 return R_PARISC_NONE;
387 }
388 break;
389
390 case 17:
391 switch (field)
392 {
393 case e_fsel:
394 final_type = R_PARISC_DIR17F;
395 break;
396 case e_rsel:
397 case e_rrsel:
398 case e_rdsel:
399 final_type = R_PARISC_DIR17R;
400 break;
401 default:
402 return R_PARISC_NONE;
403 }
404 break;
405
406 case 21:
407 switch (field)
408 {
409 case e_lsel:
410 case e_lrsel:
411 case e_ldsel:
412 case e_nlsel:
413 case e_nlrsel:
414 final_type = R_PARISC_DIR21L;
415 break;
416 case e_ltsel:
417 final_type = R_PARISC_DLTIND21L;
418 break;
419 case e_ltpsel:
420 final_type = R_PARISC_LTOFF_FPTR21L;
421 break;
422 case e_lpsel:
423 final_type = R_PARISC_PLABEL21L;
424 break;
425 default:
426 return R_PARISC_NONE;
427 }
428 break;
429
430 case 32:
431 switch (field)
432 {
433 case e_fsel:
434 final_type = R_PARISC_DIR32;
435 /* When in 64bit mode, a 32bit relocation is supposed to
436 be a section relative relocation. Dwarf2 (for example)
437 uses 32bit section relative relocations. */
438 if (bfd_arch_bits_per_address (abfd) != 32)
439 final_type = R_PARISC_SECREL32;
440 break;
441 case e_psel:
442 final_type = R_PARISC_PLABEL32;
443 break;
444 default:
445 return R_PARISC_NONE;
446 }
447 break;
448
449 case 64:
450 switch (field)
451 {
452 case e_fsel:
453 final_type = R_PARISC_DIR64;
454 break;
455 case e_psel:
456 final_type = R_PARISC_FPTR64;
457 break;
458 default:
459 return R_PARISC_NONE;
460 }
461 break;
462
463 default:
464 return R_PARISC_NONE;
465 }
466 break;
467
468 case R_HPPA_GOTOFF:
469 switch (format)
470 {
471 case 14:
472 switch (field)
473 {
474 case e_rsel:
475 case e_rrsel:
476 case e_rdsel:
477 /* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32. */
478 final_type = base_type + OFFSET_14R_FROM_21L;
479 break;
480 case e_fsel:
481 /* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32. */
482 final_type = base_type + OFFSET_14F_FROM_21L;
483 break;
484 default:
485 return R_PARISC_NONE;
486 }
487 break;
488
489 case 21:
490 switch (field)
491 {
492 case e_lsel:
493 case e_lrsel:
494 case e_ldsel:
495 case e_nlsel:
496 case e_nlrsel:
497 /* R_PARISC_DLTREL21L for elf64, R_PARISC_DPREL21L for elf32. */
498 final_type = base_type;
499 break;
500 default:
501 return R_PARISC_NONE;
502 }
503 break;
504
505 case 64:
506 switch (field)
507 {
508 case e_fsel:
509 final_type = R_PARISC_GPREL64;
510 break;
511 default:
512 return R_PARISC_NONE;
513 }
514 break;
515
516 default:
517 return R_PARISC_NONE;
518 }
519 break;
520
521 case R_HPPA_PCREL_CALL:
522 switch (format)
523 {
524 case 12:
525 switch (field)
526 {
527 case e_fsel:
528 final_type = R_PARISC_PCREL12F;
529 break;
530 default:
531 return R_PARISC_NONE;
532 }
533 break;
534
535 case 14:
536 /* Contrary to appearances, these are not calls of any sort.
537 Rather, they are loads/stores with a pcrel reloc. */
538 switch (field)
539 {
540 case e_rsel:
541 case e_rrsel:
542 case e_rdsel:
543 final_type = R_PARISC_PCREL14R;
544 break;
545 case e_fsel:
546 if (bfd_get_mach (abfd) < 25)
547 final_type = R_PARISC_PCREL14F;
548 else
549 final_type = R_PARISC_PCREL16F;
550 break;
551 default:
552 return R_PARISC_NONE;
553 }
554 break;
555
556 case 17:
557 switch (field)
558 {
559 case e_rsel:
560 case e_rrsel:
561 case e_rdsel:
562 final_type = R_PARISC_PCREL17R;
563 break;
564 case e_fsel:
565 final_type = R_PARISC_PCREL17F;
566 break;
567 default:
568 return R_PARISC_NONE;
569 }
570 break;
571
572 case 21:
573 switch (field)
574 {
575 case e_lsel:
576 case e_lrsel:
577 case e_ldsel:
578 case e_nlsel:
579 case e_nlrsel:
580 final_type = R_PARISC_PCREL21L;
581 break;
582 default:
583 return R_PARISC_NONE;
584 }
585 break;
586
587 case 22:
588 switch (field)
589 {
590 case e_fsel:
591 final_type = R_PARISC_PCREL22F;
592 break;
593 default:
594 return R_PARISC_NONE;
595 }
596 break;
597
598 case 32:
599 switch (field)
600 {
601 case e_fsel:
602 final_type = R_PARISC_PCREL32;
603 break;
604 default:
605 return R_PARISC_NONE;
606 }
607 break;
608
609 case 64:
610 switch (field)
611 {
612 case e_fsel:
613 final_type = R_PARISC_PCREL64;
614 break;
615 default:
616 return R_PARISC_NONE;
617 }
618 break;
619
620 default:
621 return R_PARISC_NONE;
622 }
623 break;
624
625 case R_PARISC_TLS_GD21L:
626 switch (field)
627 {
628 case e_ltsel:
629 case e_lrsel:
630 final_type = R_PARISC_TLS_GD21L;
631 break;
632 case e_rtsel:
633 case e_rrsel:
634 final_type = R_PARISC_TLS_GD14R;
635 break;
636 default:
637 return R_PARISC_NONE;
638 }
639 break;
640
641 case R_PARISC_TLS_LDM21L:
642 switch (field)
643 {
644 case e_ltsel:
645 case e_lrsel:
646 final_type = R_PARISC_TLS_LDM21L;
647 break;
648 case e_rtsel:
649 case e_rrsel:
650 final_type = R_PARISC_TLS_LDM14R;
651 break;
652 default:
653 return R_PARISC_NONE;
654 }
655 break;
656
657 case R_PARISC_TLS_LDO21L:
658 switch (field)
659 {
660 case e_lrsel:
661 final_type = R_PARISC_TLS_LDO21L;
662 break;
663 case e_rrsel:
664 final_type = R_PARISC_TLS_LDO14R;
665 break;
666 default:
667 return R_PARISC_NONE;
668 }
669 break;
670
671 case R_PARISC_TLS_IE21L:
672 switch (field)
673 {
674 case e_ltsel:
675 case e_lrsel:
676 final_type = R_PARISC_TLS_IE21L;
677 break;
678 case e_rtsel:
679 case e_rrsel:
680 final_type = R_PARISC_TLS_IE14R;
681 break;
682 default:
683 return R_PARISC_NONE;
684 }
685 break;
686
687 case R_PARISC_TLS_LE21L:
688 switch (field)
689 {
690 case e_lrsel:
691 final_type = R_PARISC_TLS_LE21L;
692 break;
693 case e_rrsel:
694 final_type = R_PARISC_TLS_LE14R;
695 break;
696 default:
697 return R_PARISC_NONE;
698 }
699 break;
700
701 case R_PARISC_SEGREL32:
702 switch (format)
703 {
704 case 32:
705 switch (field)
706 {
707 case e_fsel:
708 final_type = R_PARISC_SEGREL32;
709 break;
710 default:
711 return R_PARISC_NONE;
712 }
713 break;
714
715 case 64:
716 switch (field)
717 {
718 case e_fsel:
719 final_type = R_PARISC_SEGREL64;
720 break;
721 default:
722 return R_PARISC_NONE;
723 }
724 break;
725
726 default:
727 return R_PARISC_NONE;
728 }
729 break;
730
731 case R_PARISC_GNU_VTENTRY:
732 case R_PARISC_GNU_VTINHERIT:
733 case R_PARISC_SEGBASE:
734 /* The defaults are fine for these cases. */
735 break;
736
737 default:
738 return R_PARISC_NONE;
739 }
740
741 return final_type;
742 }
743
744 /* Return one (or more) BFD relocations which implement the base
745 relocation with modifications based on format and field. */
746
747 elf_hppa_reloc_type **
748 _bfd_elf_hppa_gen_reloc_type (bfd *abfd,
749 elf_hppa_reloc_type base_type,
750 int format,
751 unsigned int field,
752 int ignore ATTRIBUTE_UNUSED,
753 asymbol *sym ATTRIBUTE_UNUSED)
754 {
755 elf_hppa_reloc_type *finaltype;
756 elf_hppa_reloc_type **final_types;
757 size_t amt = sizeof (elf_hppa_reloc_type *) * 2;
758
759 /* Allocate slots for the BFD relocation. */
760 final_types = bfd_alloc (abfd, amt);
761 if (final_types == NULL)
762 return NULL;
763
764 /* Allocate space for the relocation itself. */
765 amt = sizeof (elf_hppa_reloc_type);
766 finaltype = bfd_alloc (abfd, amt);
767 if (finaltype == NULL)
768 return NULL;
769
770 /* Some reasonable defaults. */
771 final_types[0] = finaltype;
772 final_types[1] = NULL;
773
774 *finaltype = elf_hppa_reloc_final_type (abfd, base_type, format, field);
775
776 return final_types;
777 }
778
779 /* Translate from an elf into field into a howto relocation pointer. */
780
781 static bool
782 elf_hppa_info_to_howto (bfd *abfd,
783 arelent *bfd_reloc,
784 Elf_Internal_Rela *elf_reloc)
785 {
786 unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info);
787 unsigned int type = r_type;
788 reloc_howto_type *howto = NULL;
789
790 if (r_type < (unsigned int) R_PARISC_UNIMPLEMENTED)
791 {
792 howto = &elf_hppa_howto_table[r_type];
793 type = howto->type;
794 }
795 if (type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
796 {
797 /* xgettext:c-format */
798 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
799 abfd, r_type);
800 bfd_set_error (bfd_error_bad_value);
801 return false;
802 }
803 bfd_reloc->howto = howto;
804 return true;
805 }
806
807 /* Translate from an elf into field into a howto relocation pointer. */
808
809 static bool
810 elf_hppa_info_to_howto_rel (bfd *abfd,
811 arelent *bfd_reloc,
812 Elf_Internal_Rela *elf_reloc)
813 {
814 unsigned int r_type = ELF_R_TYPE (elf_reloc->r_info);
815 unsigned int type = r_type;
816 reloc_howto_type *howto = NULL;
817
818 if (r_type < (unsigned int) R_PARISC_UNIMPLEMENTED)
819 {
820 howto = &elf_hppa_howto_table[r_type];
821 type = howto->type;
822 }
823 if (type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
824 {
825 /* xgettext:c-format */
826 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
827 abfd, r_type);
828 bfd_set_error (bfd_error_bad_value);
829 return false;
830 }
831 bfd_reloc->howto = howto;
832 return true;
833 }
834
835 /* Return the address of the howto table entry to perform the CODE
836 relocation for an ARCH machine. */
837
838 static reloc_howto_type *
839 elf_hppa_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
840 bfd_reloc_code_real_type code)
841 {
842 if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
843 {
844 BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
845 return &elf_hppa_howto_table[(int) code];
846 }
847 return NULL;
848 }
849
850 static reloc_howto_type *
851 elf_hppa_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
852 const char *r_name)
853 {
854 unsigned int i;
855
856 for (i = 0;
857 i < sizeof (elf_hppa_howto_table) / sizeof (elf_hppa_howto_table[0]);
858 i++)
859 if (elf_hppa_howto_table[i].name != NULL
860 && strcasecmp (elf_hppa_howto_table[i].name, r_name) == 0)
861 return &elf_hppa_howto_table[i];
862
863 return NULL;
864 }
865
866 /* Return TRUE if SYM represents a local label symbol. */
867
868 static bool
869 elf_hppa_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
870 {
871 if (name[0] == 'L' && name[1] == '$')
872 return true;
873 return _bfd_elf_is_local_label_name (abfd, name);
874 }
875
876 /* Set the correct type for an ELF section. We do this by the
877 section name, which is a hack, but ought to work. */
878
879 static bool
880 elf_hppa_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec)
881 {
882 const char *name;
883
884 name = bfd_section_name (sec);
885
886 if (strcmp (name, ".PARISC.unwind") == 0)
887 {
888 int indx;
889 asection *asec;
890
891 #if ARCH_SIZE == 64
892 hdr->sh_type = SHT_PARISC_UNWIND;
893 #else
894 /* Note - it is not clear why this is not SHT_PARISC_UNWIND as well.
895 Presumably it is a historical constraint, so leave it as it is. */
896 hdr->sh_type = SHT_PROGBITS;
897 #endif
898 /* ?!? How are unwinds supposed to work for symbols in arbitrary
899 sections? Or what if we have multiple .text sections in a single
900 .o file? HP really messed up on this one.
901
902 Ugh. We can not use elf_section_data (sec)->this_idx at this
903 point because it is not initialized yet.
904
905 So we (gasp) recompute it here. Hopefully nobody ever changes the
906 way sections are numbered in elf.c! */
907 for (asec = abfd->sections, indx = 1; asec; asec = asec->next, indx++)
908 {
909 if (asec->name && strcmp (asec->name, ".text") == 0)
910 {
911 hdr->sh_info = indx;
912 hdr->sh_flags |= SHF_INFO_LINK;
913 break;
914 }
915 }
916
917 /* The unwind table entries are 16 bytes long, so it is not clear
918 why this field is set to 4. (The ELF spec says that the sh_entsize
919 field is a byte quantity, but this is a processor specific section,
920 so it is allowed to change the rules). Leave as it is for now. */
921 hdr->sh_entsize = 4;
922 }
923 return true;
924 }
925
926 static bool
927 elf_hppa_final_write_processing (bfd *abfd)
928 {
929 int mach = bfd_get_mach (abfd);
930
931 elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL
932 | EF_PARISC_EXT | EF_PARISC_LSB
933 | EF_PARISC_WIDE | EF_PARISC_NO_KABP
934 | EF_PARISC_LAZYSWAP);
935
936 if (mach == 10)
937 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0;
938 else if (mach == 11)
939 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1;
940 else if (mach == 20)
941 elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0;
942 else if (mach == 25)
943 elf_elfheader (abfd)->e_flags |= (EF_PARISC_WIDE
944 | EFA_PARISC_2_0
945 /* The GNU tools have trapped without
946 option since 1993, so need to take
947 a step backwards with the ELF
948 based toolchains. */
949 | EF_PARISC_TRAPNIL);
950 return _bfd_elf_final_write_processing (abfd);
951 }
952
953 /* Comparison function for qsort to sort unwind section during a
954 final link. */
955
956 static int
957 hppa_unwind_entry_compare (const void *a, const void *b)
958 {
959 const bfd_byte *ap, *bp;
960 unsigned long av, bv;
961
962 ap = a;
963 av = (unsigned long) ap[0] << 24;
964 av |= (unsigned long) ap[1] << 16;
965 av |= (unsigned long) ap[2] << 8;
966 av |= (unsigned long) ap[3];
967
968 bp = b;
969 bv = (unsigned long) bp[0] << 24;
970 bv |= (unsigned long) bp[1] << 16;
971 bv |= (unsigned long) bp[2] << 8;
972 bv |= (unsigned long) bp[3];
973
974 return av < bv ? -1 : av > bv ? 1 : 0;
975 }
976
977 static bool
978 elf_hppa_sort_unwind (bfd *abfd)
979 {
980 asection *s;
981
982 /* Magic section names, but this is much safer than having
983 relocate_section remember where SEGREL32 relocs occurred.
984 Consider what happens if someone inept creates a linker script
985 that puts unwind information in .text. */
986 s = bfd_get_section_by_name (abfd, ".PARISC.unwind");
987 if (s != NULL)
988 {
989 bfd_size_type size;
990 bfd_byte *contents;
991
992 if (!bfd_malloc_and_get_section (abfd, s, &contents))
993 return false;
994
995 size = s->size;
996 qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare);
997
998 if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size))
999 return false;
1000 }
1001
1002 return true;
1003 }
1004
1005 /* What to do when ld finds relocations against symbols defined in
1006 discarded sections. */
1007
1008 static unsigned int
1009 elf_hppa_action_discarded (asection *sec)
1010 {
1011 /* Ignore relocations in .data.rel.ro.local. This section can contain
1012 PLABEL32 relocations to functions in discarded COMDAT groups. */
1013 if (strcmp (".data.rel.ro.local", sec->name) == 0)
1014 return 0;
1015
1016 if (strcmp (".PARISC.unwind", sec->name) == 0)
1017 return 0;
1018
1019 return _bfd_elf_default_action_discarded (sec);
1020 }
This page took 0.128275 seconds and 4 git commands to generate.