1 /* Common code for PA ELF implementations.
2 Copyright (C) 1999-2022 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
21 #define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
23 /* This file is included by multiple PA ELF BFD backends with different
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. */
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
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
46 /* ELF/PA relocation howto entries. */
48 static reloc_howto_type elf_hppa_howto_table
[ELF_HOWTO_TABLE_SIZE
] =
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)
54 /* The values in DIR32 are to placate the check in
55 _bfd_stab_section_find_nearest_line. */
56 HOW (R_PARISC_NONE
, 0, 0, false, dont
, 0),
57 HOW (R_PARISC_DIR32
, 4, 32, false, bitfield
, 0xffffffff),
58 HOW (R_PARISC_DIR21L
, 4, 21, false, bitfield
, 0),
59 HOW (R_PARISC_DIR17R
, 4, 17, false, bitfield
, 0),
60 HOW (R_PARISC_DIR17F
, 4, 17, false, bitfield
, 0),
61 HOW (R_PARISC_UNIMPLEMENTED
, 0, 0, false, bitfield
, 0),
62 HOW (R_PARISC_DIR14R
, 4, 14, false, bitfield
, 0),
63 HOW (R_PARISC_DIR14F
, 4, 14, false, bitfield
, 0),
65 HOW (R_PARISC_PCREL12F
, 4, 12, true, bitfield
, 0),
66 HOW (R_PARISC_PCREL32
, 4, 32, true, bitfield
, 0),
67 HOW (R_PARISC_PCREL21L
, 4, 21, true, bitfield
, 0),
68 HOW (R_PARISC_PCREL17R
, 4, 17, true, bitfield
, 0),
69 HOW (R_PARISC_PCREL17F
, 4, 17, true, bitfield
, 0),
70 HOW (R_PARISC_PCREL17C
, 4, 17, true, bitfield
, 0),
71 HOW (R_PARISC_PCREL14R
, 4, 14, true, bitfield
, 0),
72 HOW (R_PARISC_PCREL14F
, 4, 14, true, bitfield
, 0),
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
, 4, 21, false, bitfield
, 0),
77 HOW (R_PARISC_DPREL14WR
, 4, 14, false, bitfield
, 0),
78 HOW (R_PARISC_DPREL14DR
, 4, 14, false, bitfield
, 0),
79 HOW (R_PARISC_UNIMPLEMENTED
, 0, 0, false, bitfield
, 0),
80 HOW (R_PARISC_DPREL14R
, 4, 14, false, bitfield
, 0),
81 HOW (R_PARISC_DPREL14F
, 4, 14, false, bitfield
, 0),
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
, 4, 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
, 4, 14, false, bitfield
, 0),
90 HOW (R_PARISC_DLTREL14F
, 4, 14, false, bitfield
, 0),
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
, 4, 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
, 4, 14, false, bitfield
, 0),
99 HOW (R_PARISC_DLTIND14F
, 4, 14, false, bitfield
, 0),
101 HOW (R_PARISC_SETBASE
, 0, 0, false, bitfield
, 0),
102 HOW (R_PARISC_SECREL32
, 4, 32, false, bitfield
, 0xffffffff),
103 HOW (R_PARISC_BASEREL21L
, 4, 21, false, bitfield
, 0),
104 HOW (R_PARISC_BASEREL17R
, 4, 17, false, bitfield
, 0),
105 HOW (R_PARISC_BASEREL17F
, 4, 17, false, bitfield
, 0),
106 HOW (R_PARISC_UNIMPLEMENTED
, 0, 0, false, bitfield
, 0),
107 HOW (R_PARISC_BASEREL14R
, 4, 14, false, bitfield
, 0),
108 HOW (R_PARISC_BASEREL14F
, 4, 14, false, bitfield
, 0),
110 HOW (R_PARISC_SEGBASE
, 0, 0, false, bitfield
, 0),
111 HOW (R_PARISC_SEGREL32
, 4, 32, false, bitfield
, 0),
112 HOW (R_PARISC_PLTOFF21L
, 4, 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
, 4, 14, false, bitfield
, 0),
117 HOW (R_PARISC_PLTOFF14F
, 4, 14, false, bitfield
, 0),
119 HOW (R_PARISC_UNIMPLEMENTED
, 0, 0, false, bitfield
, 0),
120 HOW (R_PARISC_LTOFF_FPTR32
, 4, 32, false, bitfield
, 0),
121 HOW (R_PARISC_LTOFF_FPTR21L
, 4, 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
, 4, 14, false, bitfield
, 0),
126 HOW (R_PARISC_UNIMPLEMENTED
, 0, 0, false, bitfield
, 0),
128 HOW (R_PARISC_FPTR64
, 8, 64, false, bitfield
, 0),
129 HOW (R_PARISC_PLABEL32
, 4, 32, false, bitfield
, 0),
130 HOW (R_PARISC_PLABEL21L
, 4, 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
, 4, 14, false, bitfield
, 0),
135 HOW (R_PARISC_UNIMPLEMENTED
, 0, 0, false, bitfield
, 0),
137 HOW (R_PARISC_PCREL64
, 8, 64, false, bitfield
, 0),
138 HOW (R_PARISC_PCREL22C
, 4, 22, false, bitfield
, 0),
139 HOW (R_PARISC_PCREL22F
, 4, 22, false, bitfield
, 0),
140 HOW (R_PARISC_PCREL14WR
, 4, 14, false, bitfield
, 0),
141 HOW (R_PARISC_PCREL14DR
, 4, 14, false, bitfield
, 0),
142 HOW (R_PARISC_PCREL16F
, 4, 16, false, bitfield
, 0),
143 HOW (R_PARISC_PCREL16WF
, 4, 16, false, bitfield
, 0),
144 HOW (R_PARISC_PCREL16DF
, 4, 16, false, bitfield
, 0),
146 HOW (R_PARISC_DIR64
, 8, 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
, 4, 14, false, bitfield
, 0),
150 HOW (R_PARISC_DIR14DR
, 4, 14, false, bitfield
, 0),
151 HOW (R_PARISC_DIR16F
, 4, 16, false, bitfield
, 0),
152 HOW (R_PARISC_DIR16WF
, 4, 16, false, bitfield
, 0),
153 HOW (R_PARISC_DIR16DF
, 4, 16, false, bitfield
, 0),
155 HOW (R_PARISC_GPREL64
, 8, 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
, 4, 14, false, bitfield
, 0),
159 HOW (R_PARISC_DLTREL14DR
, 4, 14, false, bitfield
, 0),
160 HOW (R_PARISC_GPREL16F
, 4, 16, false, bitfield
, 0),
161 HOW (R_PARISC_GPREL16WF
, 4, 16, false, bitfield
, 0),
162 HOW (R_PARISC_GPREL16DF
, 4, 16, false, bitfield
, 0),
164 HOW (R_PARISC_LTOFF64
, 8, 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
, 4, 14, false, bitfield
, 0),
168 HOW (R_PARISC_DLTIND14DR
, 4, 14, false, bitfield
, 0),
169 HOW (R_PARISC_LTOFF16F
, 4, 16, false, bitfield
, 0),
170 HOW (R_PARISC_LTOFF16WF
, 4, 16, false, bitfield
, 0),
171 HOW (R_PARISC_LTOFF16DF
, 4, 16, false, bitfield
, 0),
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
, 4, 14, false, bitfield
, 0),
176 HOW (R_PARISC_BASEREL14DR
, 4, 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),
182 HOW (R_PARISC_SEGREL64
, 8, 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
, 4, 14, false, bitfield
, 0),
186 HOW (R_PARISC_PLTOFF14DR
, 4, 14, false, bitfield
, 0),
187 HOW (R_PARISC_PLTOFF16F
, 4, 16, false, bitfield
, 0),
188 HOW (R_PARISC_PLTOFF16WF
, 4, 16, false, bitfield
, 0),
189 HOW (R_PARISC_PLTOFF16DF
, 4, 16, false, bitfield
, 0),
191 HOW (R_PARISC_LTOFF_FPTR64
, 8, 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
, 4, 14, false, bitfield
, 0),
195 HOW (R_PARISC_LTOFF_FPTR14DR
, 4, 14, false, bitfield
, 0),
196 HOW (R_PARISC_LTOFF_FPTR16F
, 4, 16, false, bitfield
, 0),
197 HOW (R_PARISC_LTOFF_FPTR16WF
, 4, 16, false, bitfield
, 0),
198 HOW (R_PARISC_LTOFF_FPTR16DF
, 4, 16, false, bitfield
, 0),
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),
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),
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),
227 HOW (R_PARISC_UNIMPLEMENTED
, 0, 0, false, dont
, 0),
228 HOW (R_PARISC_TPREL32
, 4, 32, false, dont
, 0),
229 HOW (R_PARISC_TPREL21L
, 4, 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
, 4, 14, false, bitfield
, 0),
234 HOW (R_PARISC_UNIMPLEMENTED
, 0, 0, false, dont
, 0),
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
, 4, 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
, 4, 14, false, bitfield
, 0),
243 HOW (R_PARISC_LTOFF_TP14F
, 4, 14, false, bitfield
, 0),
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),
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),
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),
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),
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),
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),
299 HOW (R_PARISC_TPREL64
, 8, 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
, 4, 14, false, dont
, 0),
303 HOW (R_PARISC_TPREL14DR
, 4, 14, false, bitfield
, 0),
304 HOW (R_PARISC_TPREL16F
, 4, 16, false, bitfield
, 0),
305 HOW (R_PARISC_TPREL16WF
, 4, 16, false, dont
, 0),
306 HOW (R_PARISC_TPREL16DF
, 4, 16, false, bitfield
, 0),
308 HOW (R_PARISC_LTOFF_TP64
, 8, 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
, 4, 14, false, bitfield
, 0),
312 HOW (R_PARISC_LTOFF_TP14DR
, 4, 14, false, bitfield
, 0),
313 HOW (R_PARISC_LTOFF_TP16F
, 4, 16, false, dont
, 0),
314 HOW (R_PARISC_LTOFF_TP16WF
, 4, 16, false, bitfield
, 0),
315 HOW (R_PARISC_LTOFF_TP16DF
, 4, 16, false, bitfield
, 0),
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
, 4, 21, false, bitfield
, 0),
320 HOW (R_PARISC_TLS_GD14R
, 4, 14, false, bitfield
, 0),
321 HOW (R_PARISC_TLS_GDCALL
, 0, 0, false, dont
, 0),
322 HOW (R_PARISC_TLS_LDM21L
, 4, 21, false, bitfield
, 0),
323 HOW (R_PARISC_TLS_LDM14R
, 4, 14, false, bitfield
, 0),
324 HOW (R_PARISC_TLS_LDMCALL
, 0, 0, false, dont
, 0),
326 HOW (R_PARISC_TLS_LDO21L
, 4, 21, false, bitfield
, 0),
327 HOW (R_PARISC_TLS_LDO14R
, 4, 14, false, bitfield
, 0),
328 HOW (R_PARISC_TLS_DTPMOD32
, 4, 32, false, bitfield
, 0),
329 HOW (R_PARISC_TLS_DTPMOD64
, 8, 64, false, bitfield
, 0),
330 HOW (R_PARISC_TLS_DTPOFF32
, 4, 32, false, bitfield
, 0),
331 HOW (R_PARISC_TLS_DTPOFF64
, 8, 64, false, bitfield
, 0)
335 #define OFFSET_14R_FROM_21L 4
336 #define OFFSET_14F_FROM_21L 5
338 /* Return the final relocation type for the given base type, instruction
339 format, and field selector. */
342 elf_hppa_reloc_final_type (bfd
*abfd
,
343 elf_hppa_reloc_type base_type
,
347 elf_hppa_reloc_type final_type
= base_type
;
349 /* Just a tangle of nested switch statements to deal with the braindamage
350 that a different field selector means a completely different relocation
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. */
359 case R_HPPA_ABS_CALL
:
366 final_type
= R_PARISC_DIR14F
;
371 final_type
= R_PARISC_DIR14R
;
374 final_type
= R_PARISC_DLTIND14R
;
377 final_type
= R_PARISC_LTOFF_FPTR14DR
;
380 final_type
= R_PARISC_DLTIND14F
;
383 final_type
= R_PARISC_PLABEL14R
;
386 return R_PARISC_NONE
;
394 final_type
= R_PARISC_DIR17F
;
399 final_type
= R_PARISC_DIR17R
;
402 return R_PARISC_NONE
;
414 final_type
= R_PARISC_DIR21L
;
417 final_type
= R_PARISC_DLTIND21L
;
420 final_type
= R_PARISC_LTOFF_FPTR21L
;
423 final_type
= R_PARISC_PLABEL21L
;
426 return R_PARISC_NONE
;
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
;
442 final_type
= R_PARISC_PLABEL32
;
445 return R_PARISC_NONE
;
453 final_type
= R_PARISC_DIR64
;
456 final_type
= R_PARISC_FPTR64
;
459 return R_PARISC_NONE
;
464 return R_PARISC_NONE
;
477 /* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32. */
478 final_type
= base_type
+ OFFSET_14R_FROM_21L
;
481 /* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32. */
482 final_type
= base_type
+ OFFSET_14F_FROM_21L
;
485 return R_PARISC_NONE
;
497 /* R_PARISC_DLTREL21L for elf64, R_PARISC_DPREL21L for elf32. */
498 final_type
= base_type
;
501 return R_PARISC_NONE
;
509 final_type
= R_PARISC_GPREL64
;
512 return R_PARISC_NONE
;
517 return R_PARISC_NONE
;
521 case R_HPPA_PCREL_CALL
:
528 final_type
= R_PARISC_PCREL12F
;
531 return R_PARISC_NONE
;
536 /* Contrary to appearances, these are not calls of any sort.
537 Rather, they are loads/stores with a pcrel reloc. */
543 final_type
= R_PARISC_PCREL14R
;
546 if (bfd_get_mach (abfd
) < 25)
547 final_type
= R_PARISC_PCREL14F
;
549 final_type
= R_PARISC_PCREL16F
;
552 return R_PARISC_NONE
;
562 final_type
= R_PARISC_PCREL17R
;
565 final_type
= R_PARISC_PCREL17F
;
568 return R_PARISC_NONE
;
580 final_type
= R_PARISC_PCREL21L
;
583 return R_PARISC_NONE
;
591 final_type
= R_PARISC_PCREL22F
;
594 return R_PARISC_NONE
;
602 final_type
= R_PARISC_PCREL32
;
605 return R_PARISC_NONE
;
613 final_type
= R_PARISC_PCREL64
;
616 return R_PARISC_NONE
;
621 return R_PARISC_NONE
;
625 case R_PARISC_TLS_GD21L
:
630 final_type
= R_PARISC_TLS_GD21L
;
634 final_type
= R_PARISC_TLS_GD14R
;
637 return R_PARISC_NONE
;
641 case R_PARISC_TLS_LDM21L
:
646 final_type
= R_PARISC_TLS_LDM21L
;
650 final_type
= R_PARISC_TLS_LDM14R
;
653 return R_PARISC_NONE
;
657 case R_PARISC_TLS_LDO21L
:
661 final_type
= R_PARISC_TLS_LDO21L
;
664 final_type
= R_PARISC_TLS_LDO14R
;
667 return R_PARISC_NONE
;
671 case R_PARISC_TLS_IE21L
:
676 final_type
= R_PARISC_TLS_IE21L
;
680 final_type
= R_PARISC_TLS_IE14R
;
683 return R_PARISC_NONE
;
687 case R_PARISC_TLS_LE21L
:
691 final_type
= R_PARISC_TLS_LE21L
;
694 final_type
= R_PARISC_TLS_LE14R
;
697 return R_PARISC_NONE
;
701 case R_PARISC_SEGREL32
:
708 final_type
= R_PARISC_SEGREL32
;
711 return R_PARISC_NONE
;
719 final_type
= R_PARISC_SEGREL64
;
722 return R_PARISC_NONE
;
727 return R_PARISC_NONE
;
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. */
738 return R_PARISC_NONE
;
744 /* Return one (or more) BFD relocations which implement the base
745 relocation with modifications based on format and field. */
747 elf_hppa_reloc_type
**
748 _bfd_elf_hppa_gen_reloc_type (bfd
*abfd
,
749 elf_hppa_reloc_type base_type
,
752 int ignore ATTRIBUTE_UNUSED
,
753 asymbol
*sym ATTRIBUTE_UNUSED
)
755 elf_hppa_reloc_type
*finaltype
;
756 elf_hppa_reloc_type
**final_types
;
757 size_t amt
= sizeof (elf_hppa_reloc_type
*) * 2;
759 /* Allocate slots for the BFD relocation. */
760 final_types
= bfd_alloc (abfd
, amt
);
761 if (final_types
== NULL
)
764 /* Allocate space for the relocation itself. */
765 amt
= sizeof (elf_hppa_reloc_type
);
766 finaltype
= bfd_alloc (abfd
, amt
);
767 if (finaltype
== NULL
)
770 /* Some reasonable defaults. */
771 final_types
[0] = finaltype
;
772 final_types
[1] = NULL
;
774 *finaltype
= elf_hppa_reloc_final_type (abfd
, base_type
, format
, field
);
779 /* Translate from an elf into field into a howto relocation pointer. */
782 elf_hppa_info_to_howto (bfd
*abfd
,
784 Elf_Internal_Rela
*elf_reloc
)
786 unsigned int r_type
= ELF32_R_TYPE (elf_reloc
->r_info
);
787 unsigned int type
= r_type
;
788 reloc_howto_type
*howto
= NULL
;
790 if (r_type
< (unsigned int) R_PARISC_UNIMPLEMENTED
)
792 howto
= &elf_hppa_howto_table
[r_type
];
795 if (type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
797 /* xgettext:c-format */
798 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
800 bfd_set_error (bfd_error_bad_value
);
803 bfd_reloc
->howto
= howto
;
807 /* Translate from an elf into field into a howto relocation pointer. */
810 elf_hppa_info_to_howto_rel (bfd
*abfd
,
812 Elf_Internal_Rela
*elf_reloc
)
814 unsigned int r_type
= ELF_R_TYPE (elf_reloc
->r_info
);
815 unsigned int type
= r_type
;
816 reloc_howto_type
*howto
= NULL
;
818 if (r_type
< (unsigned int) R_PARISC_UNIMPLEMENTED
)
820 howto
= &elf_hppa_howto_table
[r_type
];
823 if (type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
825 /* xgettext:c-format */
826 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
828 bfd_set_error (bfd_error_bad_value
);
831 bfd_reloc
->howto
= howto
;
835 /* Return the address of the howto table entry to perform the CODE
836 relocation for an ARCH machine. */
838 static reloc_howto_type
*
839 elf_hppa_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
840 bfd_reloc_code_real_type code
)
842 if ((int) code
< (int) R_PARISC_UNIMPLEMENTED
)
844 BFD_ASSERT ((int) elf_hppa_howto_table
[(int) code
].type
== (int) code
);
845 return &elf_hppa_howto_table
[(int) code
];
850 static reloc_howto_type
*
851 elf_hppa_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
857 i
< sizeof (elf_hppa_howto_table
) / sizeof (elf_hppa_howto_table
[0]);
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
];
866 /* Return TRUE if SYM represents a local label symbol. */
869 elf_hppa_is_local_label_name (bfd
*abfd ATTRIBUTE_UNUSED
, const char *name
)
871 if (name
[0] == 'L' && name
[1] == '$')
873 return _bfd_elf_is_local_label_name (abfd
, name
);
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. */
880 elf_hppa_fake_sections (bfd
*abfd
, Elf_Internal_Shdr
*hdr
, asection
*sec
)
884 name
= bfd_section_name (sec
);
886 if (strcmp (name
, ".PARISC.unwind") == 0)
892 hdr
->sh_type
= SHT_PARISC_UNWIND
;
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
;
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.
902 Ugh. We can not use elf_section_data (sec)->this_idx at this
903 point because it is not initialized yet.
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
++)
909 if (asec
->name
&& strcmp (asec
->name
, ".text") == 0)
912 hdr
->sh_flags
|= SHF_INFO_LINK
;
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. */
927 elf_hppa_final_write_processing (bfd
*abfd
)
929 int mach
= bfd_get_mach (abfd
);
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
);
937 elf_elfheader (abfd
)->e_flags
|= EFA_PARISC_1_0
;
939 elf_elfheader (abfd
)->e_flags
|= EFA_PARISC_1_1
;
941 elf_elfheader (abfd
)->e_flags
|= EFA_PARISC_2_0
;
943 elf_elfheader (abfd
)->e_flags
|= (EF_PARISC_WIDE
945 /* The GNU tools have trapped without
946 option since 1993, so need to take
947 a step backwards with the ELF
949 | EF_PARISC_TRAPNIL
);
950 return _bfd_elf_final_write_processing (abfd
);
953 /* Comparison function for qsort to sort unwind section during a
957 hppa_unwind_entry_compare (const void *a
, const void *b
)
959 const bfd_byte
*ap
, *bp
;
960 unsigned long av
, bv
;
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];
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];
974 return av
< bv
? -1 : av
> bv
? 1 : 0;
978 elf_hppa_sort_unwind (bfd
*abfd
)
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");
992 if (!bfd_malloc_and_get_section (abfd
, s
, &contents
))
996 qsort (contents
, (size_t) (size
/ 16), 16, hppa_unwind_entry_compare
);
998 if (! bfd_set_section_contents (abfd
, s
, contents
, (file_ptr
) 0, size
))
1005 /* What to do when ld finds relocations against symbols defined in
1006 discarded sections. */
1009 elf_hppa_action_discarded (asection
*sec
)
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)
1016 if (strcmp (".PARISC.unwind", sec
->name
) == 0)
1019 return _bfd_elf_default_action_discarded (sec
);