* gas/cris/rd-bcnst.d, gas/cris/rd-bcnst.d: New test.
[binutils.git] / bfd / elf-hppa.h
blob263e9ac5033a4e2035373fa753535e56225237db
1 /* Common code for PA ELF implementations.
2 Copyright 1999, 2000, 2001, 2002 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
22 /* This file is included by multiple PA ELF BFD backends with different
23 sizes.
25 Most of the routines are written to be size independent, but sometimes
26 external constraints require 32 or 64 bit specific code. We remap
27 the definitions/functions as necessary here. */
28 #if ARCH_SIZE == 64
29 #define ELF_R_TYPE(X) ELF64_R_TYPE(X)
30 #define ELF_R_SYM(X) ELF64_R_SYM(X)
31 #define elf_hppa_internal_shdr Elf64_Internal_Shdr
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 bfd_elf_bfd_final_link bfd_elf64_bfd_final_link
36 #define elf_hppa_final_link elf64_hppa_final_link
37 #endif
38 #if ARCH_SIZE == 32
39 #define ELF_R_TYPE(X) ELF32_R_TYPE(X)
40 #define ELF_R_SYM(X) ELF32_R_SYM(X)
41 #define elf_hppa_internal_shdr Elf32_Internal_Shdr
42 #define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type
43 #define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
44 #define elf_hppa_relocate_section elf32_hppa_relocate_section
45 #define bfd_elf_bfd_final_link bfd_elf32_bfd_final_link
46 #define elf_hppa_final_link elf32_hppa_final_link
47 #endif
49 static void elf_hppa_info_to_howto
50 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
52 static void elf_hppa_info_to_howto_rel
53 PARAMS ((bfd *, arelent *, Elf_Internal_Rel *));
55 static reloc_howto_type * elf_hppa_reloc_type_lookup
56 PARAMS ((bfd *, bfd_reloc_code_real_type));
58 static boolean elf_hppa_is_local_label_name
59 PARAMS ((bfd *, const char *));
61 static boolean elf_hppa_fake_sections
62 PARAMS ((bfd *abfd, elf_hppa_internal_shdr *, asection *));
64 static void elf_hppa_final_write_processing
65 PARAMS ((bfd *, boolean));
67 static int hppa_unwind_entry_compare
68 PARAMS ((const PTR, const PTR));
70 static boolean elf_hppa_sort_unwind
71 PARAMS ((bfd *));
73 #if ARCH_SIZE == 64
74 static boolean elf_hppa_add_symbol_hook
75 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
76 const char **, flagword *, asection **, bfd_vma *));
78 static boolean elf_hppa_unmark_useless_dynamic_symbols
79 PARAMS ((struct elf_link_hash_entry *, PTR));
81 static boolean elf_hppa_remark_useless_dynamic_symbols
82 PARAMS ((struct elf_link_hash_entry *, PTR));
84 static boolean elf_hppa_is_dynamic_loader_symbol
85 PARAMS ((const char *));
87 static void elf_hppa_record_segment_addrs
88 PARAMS ((bfd *, asection *, PTR));
90 static boolean elf_hppa_final_link
91 PARAMS ((bfd *, struct bfd_link_info *));
93 static boolean elf_hppa_relocate_section
94 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
95 bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
97 static bfd_reloc_status_type elf_hppa_final_link_relocate
98 PARAMS ((Elf_Internal_Rela *, bfd *, bfd *, asection *,
99 bfd_byte *, bfd_vma, struct bfd_link_info *,
100 asection *, struct elf_link_hash_entry *,
101 struct elf64_hppa_dyn_hash_entry *));
103 static int elf_hppa_relocate_insn
104 PARAMS ((int, int, unsigned int));
105 #endif
107 /* ELF/PA relocation howto entries. */
109 static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
111 { R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield,
112 bfd_elf_generic_reloc, "R_PARISC_NONE", false, 0, 0, false },
114 /* The values in DIR32 are to placate the check in
115 _bfd_stab_section_find_nearest_line. */
116 { R_PARISC_DIR32, 0, 2, 32, false, 0, complain_overflow_bitfield,
117 bfd_elf_generic_reloc, "R_PARISC_DIR32", false, 0, 0xffffffff, false },
118 { R_PARISC_DIR21L, 0, 0, 21, false, 0, complain_overflow_bitfield,
119 bfd_elf_generic_reloc, "R_PARISC_DIR21L", false, 0, 0, false },
120 { R_PARISC_DIR17R, 0, 0, 17, false, 0, complain_overflow_bitfield,
121 bfd_elf_generic_reloc, "R_PARISC_DIR17R", false, 0, 0, false },
122 { R_PARISC_DIR17F, 0, 0, 17, false, 0, complain_overflow_bitfield,
123 bfd_elf_generic_reloc, "R_PARISC_DIR17F", false, 0, 0, false },
124 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
125 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
126 { R_PARISC_DIR14R, 0, 0, 14, false, 0, complain_overflow_bitfield,
127 bfd_elf_generic_reloc, "R_PARISC_DIR14R", false, 0, 0, false },
128 { R_PARISC_DIR14F, 0, 0, 14, false, 0, complain_overflow_bitfield,
129 bfd_elf_generic_reloc, "R_PARISC_DIR14F", false, 0, 0, false },
130 /* 8 */
131 { R_PARISC_PCREL12F, 0, 0, 12, true, 0, complain_overflow_bitfield,
132 bfd_elf_generic_reloc, "R_PARISC_PCREL12F", false, 0, 0, false },
133 { R_PARISC_PCREL32, 0, 0, 32, true, 0, complain_overflow_bitfield,
134 bfd_elf_generic_reloc, "R_PARISC_PCREL32", false, 0, 0, false },
135 { R_PARISC_PCREL21L, 0, 0, 21, true, 0, complain_overflow_bitfield,
136 bfd_elf_generic_reloc, "R_PARISC_PCREL21L", false, 0, 0, false },
137 { R_PARISC_PCREL17R, 0, 0, 17, true, 0, complain_overflow_bitfield,
138 bfd_elf_generic_reloc, "R_PARISC_PCREL17R", false, 0, 0, false },
139 { R_PARISC_PCREL17F, 0, 0, 17, true, 0, complain_overflow_bitfield,
140 bfd_elf_generic_reloc, "R_PARISC_PCREL17F", false, 0, 0, false },
141 { R_PARISC_PCREL17C, 0, 0, 17, true, 0, complain_overflow_bitfield,
142 bfd_elf_generic_reloc, "R_PARISC_PCREL17C", false, 0, 0, false },
143 { R_PARISC_PCREL14R, 0, 0, 14, true, 0, complain_overflow_bitfield,
144 bfd_elf_generic_reloc, "R_PARISC_PCREL14R", false, 0, 0, false },
145 { R_PARISC_PCREL14F, 0, 0, 14, true, 0, complain_overflow_bitfield,
146 bfd_elf_generic_reloc, "R_PARISC_PCREL14F", false, 0, 0, false },
147 /* 16 */
148 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
149 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
150 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
151 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
152 { R_PARISC_DPREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield,
153 bfd_elf_generic_reloc, "R_PARISC_DPREL21L", false, 0, 0, false },
154 { R_PARISC_DPREL14WR, 0, 0, 14, false, 0, complain_overflow_bitfield,
155 bfd_elf_generic_reloc, "R_PARISC_DPREL14WR", false, 0, 0, false },
156 { R_PARISC_DPREL14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
157 bfd_elf_generic_reloc, "R_PARISC_DPREL14DR", false, 0, 0, false },
158 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
159 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
160 { R_PARISC_DPREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield,
161 bfd_elf_generic_reloc, "R_PARISC_DPREL14R", false, 0, 0, false },
162 { R_PARISC_DPREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield,
163 bfd_elf_generic_reloc, "R_PARISC_DPREL14F", false, 0, 0, false },
164 /* 24 */
165 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
166 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
167 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
168 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
169 { R_PARISC_DLTREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield,
170 bfd_elf_generic_reloc, "R_PARISC_DLTREL21L", false, 0, 0, false },
171 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
172 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
173 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
174 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
175 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
176 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
177 { R_PARISC_DLTREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield,
178 bfd_elf_generic_reloc, "R_PARISC_DLTREL14R", false, 0, 0, false },
179 { R_PARISC_DLTREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield,
180 bfd_elf_generic_reloc, "R_PARISC_DLTREL14F", false, 0, 0, false },
181 /* 32 */
182 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
183 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
184 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
185 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
186 { R_PARISC_DLTIND21L, 0, 0, 21, false, 0, complain_overflow_bitfield,
187 bfd_elf_generic_reloc, "R_PARISC_DLTIND21L", false, 0, 0, false },
188 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
189 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
190 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
191 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
192 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
193 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
194 { R_PARISC_DLTIND14R, 0, 0, 14, false, 0, complain_overflow_bitfield,
195 bfd_elf_generic_reloc, "R_PARISC_DLTIND14R", false, 0, 0, false },
196 { R_PARISC_DLTIND14F, 0, 0, 14, false, 0, complain_overflow_bitfield,
197 bfd_elf_generic_reloc, "R_PARISC_DLTIND14F", false, 0, 0, false },
198 /* 40 */
199 { R_PARISC_SETBASE, 0, 0, 0, false, 0, complain_overflow_bitfield,
200 bfd_elf_generic_reloc, "R_PARISC_SETBASE", false, 0, 0, false },
201 { R_PARISC_SECREL32, 0, 0, 32, false, 0, complain_overflow_bitfield,
202 bfd_elf_generic_reloc, "R_PARISC_SECREL32", false, 0, 0, false },
203 { R_PARISC_BASEREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield,
204 bfd_elf_generic_reloc, "R_PARISC_BASEREL21L", false, 0, 0, false },
205 { R_PARISC_BASEREL17R, 0, 0, 17, false, 0, complain_overflow_bitfield,
206 bfd_elf_generic_reloc, "R_PARISC_BASEREL17R", false, 0, 0, false },
207 { R_PARISC_BASEREL17F, 0, 0, 17, false, 0, complain_overflow_bitfield,
208 bfd_elf_generic_reloc, "R_PARISC_BASEREL17F", false, 0, 0, false },
209 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
210 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
211 { R_PARISC_BASEREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield,
212 bfd_elf_generic_reloc, "R_PARISC_BASEREL14R", false, 0, 0, false },
213 { R_PARISC_BASEREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield,
214 bfd_elf_generic_reloc, "R_PARISC_BASEREL14F", false, 0, 0, false },
215 /* 48 */
216 { R_PARISC_SEGBASE, 0, 0, 0, false, 0, complain_overflow_bitfield,
217 bfd_elf_generic_reloc, "R_PARISC_SEGBASE", false, 0, 0, false },
218 { R_PARISC_SEGREL32, 0, 0, 32, false, 0, complain_overflow_bitfield,
219 bfd_elf_generic_reloc, "R_PARISC_SEGREL32", false, 0, 0, false },
220 { R_PARISC_PLTOFF21L, 0, 0, 21, false, 0, complain_overflow_bitfield,
221 bfd_elf_generic_reloc, "R_PARISC_PLTOFF21L", false, 0, 0, false },
222 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
223 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
224 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
225 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
226 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
227 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
228 { R_PARISC_PLTOFF14R, 0, 0, 14, false, 0, complain_overflow_bitfield,
229 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14R", false, 0, 0, false },
230 { R_PARISC_PLTOFF14F, 0, 0, 14, false, 0, complain_overflow_bitfield,
231 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14F", false, 0, 0, false },
232 /* 56 */
233 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
234 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
235 { R_PARISC_LTOFF_FPTR32, 0, 0, 32, false, 0, complain_overflow_bitfield,
236 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR32", false, 0, 0, false },
237 { R_PARISC_LTOFF_FPTR21L, 0, 0, 21, false, 0, complain_overflow_bitfield,
238 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR21L", false, 0, 0, false },
239 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
240 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
241 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
242 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
243 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
244 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
245 { R_PARISC_LTOFF_FPTR14R, 0, 0, 14, false, 0, complain_overflow_bitfield,
246 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14R", false, 0, 0, false },
247 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
248 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
249 /* 64 */
250 { R_PARISC_FPTR64, 0, 0, 64, false, 0, complain_overflow_bitfield,
251 bfd_elf_generic_reloc, "R_PARISC_FPTR64", false, 0, 0, false },
252 { R_PARISC_PLABEL32, 0, 0, 32, false, 0, complain_overflow_bitfield,
253 bfd_elf_generic_reloc, "R_PARISC_PLABEL32", false, 0, 0, false },
254 { R_PARISC_PLABEL21L, 0, 0, 21, false, 0, complain_overflow_bitfield,
255 bfd_elf_generic_reloc, "R_PARISC_PLABEL21L", false, 0, 0, false },
256 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
257 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
258 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
259 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
260 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
261 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
262 { R_PARISC_PLABEL14R, 0, 0, 14, false, 0, complain_overflow_bitfield,
263 bfd_elf_generic_reloc, "R_PARISC_PLABEL14R", false, 0, 0, false },
264 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
265 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
266 /* 72 */
267 { R_PARISC_PCREL64, 0, 0, 64, false, 0, complain_overflow_bitfield,
268 bfd_elf_generic_reloc, "R_PARISC_PCREL64", false, 0, 0, false },
269 { R_PARISC_PCREL22C, 0, 0, 22, false, 0, complain_overflow_bitfield,
270 bfd_elf_generic_reloc, "R_PARISC_PCREL22C", false, 0, 0, false },
271 { R_PARISC_PCREL22F, 0, 0, 22, false, 0, complain_overflow_bitfield,
272 bfd_elf_generic_reloc, "R_PARISC_PCREL22F", false, 0, 0, false },
273 { R_PARISC_PCREL14WR, 0, 0, 14, false, 0, complain_overflow_bitfield,
274 bfd_elf_generic_reloc, "R_PARISC_PCREL14WR", false, 0, 0, false },
275 { R_PARISC_PCREL14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
276 bfd_elf_generic_reloc, "R_PARISC_PCREL14DR", false, 0, 0, false },
277 { R_PARISC_PCREL16F, 0, 0, 16, false, 0, complain_overflow_bitfield,
278 bfd_elf_generic_reloc, "R_PARISC_PCREL16F", false, 0, 0, false },
279 { R_PARISC_PCREL16WF, 0, 0, 16, false, 0, complain_overflow_bitfield,
280 bfd_elf_generic_reloc, "R_PARISC_PCREL16WF", false, 0, 0, false },
281 { R_PARISC_PCREL16DF, 0, 0, 16, false, 0, complain_overflow_bitfield,
282 bfd_elf_generic_reloc, "R_PARISC_PCREL16DF", false, 0, 0, false },
283 /* 80 */
284 { R_PARISC_DIR64, 0, 0, 64, false, 0, complain_overflow_bitfield,
285 bfd_elf_generic_reloc, "R_PARISC_DIR64", false, 0, 0, false },
286 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
287 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
288 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
289 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
290 { R_PARISC_DIR14WR, 0, 0, 14, false, 0, complain_overflow_bitfield,
291 bfd_elf_generic_reloc, "R_PARISC_DIR14WR", false, 0, 0, false },
292 { R_PARISC_DIR14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
293 bfd_elf_generic_reloc, "R_PARISC_DIR14DR", false, 0, 0, false },
294 { R_PARISC_DIR16F, 0, 0, 16, false, 0, complain_overflow_bitfield,
295 bfd_elf_generic_reloc, "R_PARISC_DIR16F", false, 0, 0, false },
296 { R_PARISC_DIR16WF, 0, 0, 16, false, 0, complain_overflow_bitfield,
297 bfd_elf_generic_reloc, "R_PARISC_DIR16WF", false, 0, 0, false },
298 { R_PARISC_DIR16DF, 0, 0, 16, false, 0, complain_overflow_bitfield,
299 bfd_elf_generic_reloc, "R_PARISC_DIR16DF", false, 0, 0, false },
300 /* 88 */
301 { R_PARISC_GPREL64, 0, 0, 64, false, 0, complain_overflow_bitfield,
302 bfd_elf_generic_reloc, "R_PARISC_GPREL64", false, 0, 0, false },
303 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
304 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
305 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
306 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
307 { R_PARISC_DLTREL14WR, 0, 0, 14, false, 0, complain_overflow_bitfield,
308 bfd_elf_generic_reloc, "R_PARISC_DLTREL14WR", false, 0, 0, false },
309 { R_PARISC_DLTREL14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
310 bfd_elf_generic_reloc, "R_PARISC_DLTREL14DR", false, 0, 0, false },
311 { R_PARISC_GPREL16F, 0, 0, 16, false, 0, complain_overflow_bitfield,
312 bfd_elf_generic_reloc, "R_PARISC_GPREL16F", false, 0, 0, false },
313 { R_PARISC_GPREL16WF, 0, 0, 16, false, 0, complain_overflow_bitfield,
314 bfd_elf_generic_reloc, "R_PARISC_GPREL16WF", false, 0, 0, false },
315 { R_PARISC_GPREL16DF, 0, 0, 16, false, 0, complain_overflow_bitfield,
316 bfd_elf_generic_reloc, "R_PARISC_GPREL16DF", false, 0, 0, false },
317 /* 96 */
318 { R_PARISC_LTOFF64, 0, 0, 64, false, 0, complain_overflow_bitfield,
319 bfd_elf_generic_reloc, "R_PARISC_LTOFF64", false, 0, 0, false },
320 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
321 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
322 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
323 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
324 { R_PARISC_DLTIND14WR, 0, 0, 14, false, 0, complain_overflow_bitfield,
325 bfd_elf_generic_reloc, "R_PARISC_DLTIND14WR", false, 0, 0, false },
326 { R_PARISC_DLTIND14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
327 bfd_elf_generic_reloc, "R_PARISC_DLTIND14DR", false, 0, 0, false },
328 { R_PARISC_LTOFF16F, 0, 0, 16, false, 0, complain_overflow_bitfield,
329 bfd_elf_generic_reloc, "R_PARISC_LTOFF16F", false, 0, 0, false },
330 { R_PARISC_LTOFF16WF, 0, 0, 16, false, 0, complain_overflow_bitfield,
331 bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF", false, 0, 0, false },
332 { R_PARISC_LTOFF16DF, 0, 0, 16, false, 0, complain_overflow_bitfield,
333 bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF", false, 0, 0, false },
334 /* 104 */
335 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
336 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
337 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
338 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
339 { R_PARISC_BASEREL14WR, 0, 0, 14, false, 0, complain_overflow_bitfield,
340 bfd_elf_generic_reloc, "R_PARISC_BASEREL14WR", false, 0, 0, false },
341 { R_PARISC_BASEREL14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
342 bfd_elf_generic_reloc, "R_PARISC_BASEREL14DR", false, 0, 0, false },
343 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
344 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
345 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
346 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
347 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
348 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
349 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
350 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
351 /* 112 */
352 { R_PARISC_SEGREL64, 0, 0, 64, false, 0, complain_overflow_bitfield,
353 bfd_elf_generic_reloc, "R_PARISC_SEGREL64", false, 0, 0, false },
354 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
355 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
356 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
357 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
358 { R_PARISC_PLTOFF14WR, 0, 0, 14, false, 0, complain_overflow_bitfield,
359 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14WR", false, 0, 0, false },
360 { R_PARISC_PLTOFF14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
361 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14DR", false, 0, 0, false },
362 { R_PARISC_PLTOFF16F, 0, 0, 16, false, 0, complain_overflow_bitfield,
363 bfd_elf_generic_reloc, "R_PARISC_PLTOFF16F", false, 0, 0, false },
364 { R_PARISC_PLTOFF16WF, 0, 0, 16, false, 0, complain_overflow_bitfield,
365 bfd_elf_generic_reloc, "R_PARISC_PLTOFF16WF", false, 0, 0, false },
366 { R_PARISC_PLTOFF16DF, 0, 0, 16, false, 0, complain_overflow_bitfield,
367 bfd_elf_generic_reloc, "R_PARISC_PLTOFF16DF", false, 0, 0, false },
368 /* 120 */
369 { R_PARISC_LTOFF_FPTR64, 0, 0, 64, false, 0, complain_overflow_bitfield,
370 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
371 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
372 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
373 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
374 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
375 { R_PARISC_LTOFF_FPTR14WR, 0, 0, 14, false, 0, complain_overflow_bitfield,
376 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14WR", false, 0, 0, false },
377 { R_PARISC_LTOFF_FPTR14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
378 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14DR", false, 0, 0, false },
379 { R_PARISC_LTOFF_FPTR16F, 0, 0, 16, false, 0, complain_overflow_bitfield,
380 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16F", false, 0, 0, false },
381 { R_PARISC_LTOFF_FPTR16WF, 0, 0, 16, false, 0, complain_overflow_bitfield,
382 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16WF", false, 0, 0, false },
383 { R_PARISC_LTOFF_FPTR16DF, 0, 0, 16, false, 0, complain_overflow_bitfield,
384 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
385 /* 128 */
386 { R_PARISC_COPY, 0, 0, 0, false, 0, complain_overflow_bitfield,
387 bfd_elf_generic_reloc, "R_PARISC_COPY", false, 0, 0, false },
388 { R_PARISC_IPLT, 0, 0, 0, false, 0, complain_overflow_bitfield,
389 bfd_elf_generic_reloc, "R_PARISC_IPLT", false, 0, 0, false },
390 { R_PARISC_EPLT, 0, 0, 0, false, 0, complain_overflow_bitfield,
391 bfd_elf_generic_reloc, "R_PARISC_EPLT", false, 0, 0, false },
392 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
393 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
394 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
395 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
396 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
397 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
398 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
399 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
400 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
401 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
402 /* 136 */
403 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
404 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
405 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
406 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
407 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
408 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
409 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
410 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
411 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
412 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
413 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
414 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
415 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
416 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
417 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
418 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
419 /* 144 */
420 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
421 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
422 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
423 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
424 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
425 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
426 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
427 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
428 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
429 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
430 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
431 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
432 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
433 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
434 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
435 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
436 /* 152 */
437 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
438 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
439 { R_PARISC_TPREL32, 0, 0, 32, false, 0, complain_overflow_dont,
440 bfd_elf_generic_reloc, "R_PARISC_TPREL32", false, 0, 0, false },
441 { R_PARISC_TPREL21L, 0, 0, 21, false, 0, complain_overflow_dont,
442 bfd_elf_generic_reloc, "R_PARISC_TPREL21L", false, 0, 0, false },
443 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
444 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
445 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
446 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
447 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
448 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
449 { R_PARISC_TPREL14R, 0, 0, 14, false, 0, complain_overflow_dont,
450 bfd_elf_generic_reloc, "R_PARISC_TPREL14R", false, 0, 0, false },
451 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
452 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
453 /* 160 */
454 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
455 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
456 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
457 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
458 { R_PARISC_LTOFF_TP21L, 0, 0, 21, false, 0, complain_overflow_bitfield,
459 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP21L", false, 0, 0, false },
460 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
461 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
462 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
463 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
464 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
465 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
466 { R_PARISC_LTOFF_TP14R, 0, 0, 14, false, 0, complain_overflow_bitfield,
467 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
468 { R_PARISC_LTOFF_TP14F, 0, 0, 14, false, 0, complain_overflow_bitfield,
469 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14F", false, 0, 0, false },
470 /* 168 */
471 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
472 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
473 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
474 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
475 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
476 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
477 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
478 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
479 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
480 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
481 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
482 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
483 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
484 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
485 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
486 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
487 /* 176 */
488 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
489 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
490 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
491 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
492 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
493 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
494 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
495 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
496 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
497 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
498 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
499 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
500 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
501 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
502 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
503 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
504 /* 184 */
505 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
506 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
507 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
508 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
509 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
510 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
511 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
512 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
513 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
514 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
515 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
516 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
517 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
518 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
519 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
520 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
521 /* 192 */
522 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
523 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
524 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
525 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
526 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
527 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
528 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
529 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
530 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
531 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
532 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
533 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
534 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
535 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
536 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
537 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
538 /* 200 */
539 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
540 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
541 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
542 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
543 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
544 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
545 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
546 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
547 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
548 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
549 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
550 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
551 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
552 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
553 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
554 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
555 /* 208 */
556 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
557 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
558 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
559 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
560 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
561 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
562 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
563 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
564 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont,
565 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
566 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
567 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
568 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
569 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
570 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
571 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
572 /* 216 */
573 { R_PARISC_TPREL64, 0, 0, 64, false, 0, complain_overflow_bitfield,
574 bfd_elf_generic_reloc, "R_PARISC_TPREL64", false, 0, 0, false },
575 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
576 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
577 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
578 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
579 { R_PARISC_TPREL14WR, 0, 0, 14, false, 0, complain_overflow_dont,
580 bfd_elf_generic_reloc, "R_PARISC_TPREL14WR", false, 0, 0, false },
581 { R_PARISC_TPREL14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
582 bfd_elf_generic_reloc, "R_PARISC_TPREL14DR", false, 0, 0, false },
583 { R_PARISC_TPREL16F, 0, 0, 16, false, 0, complain_overflow_bitfield,
584 bfd_elf_generic_reloc, "R_PARISC_TPREL16F", false, 0, 0, false },
585 { R_PARISC_TPREL16WF, 0, 0, 16, false, 0, complain_overflow_dont,
586 bfd_elf_generic_reloc, "R_PARISC_TPREL16WF", false, 0, 0, false },
587 { R_PARISC_TPREL16DF, 0, 0, 16, false, 0, complain_overflow_bitfield,
588 bfd_elf_generic_reloc, "R_PARISC_TPREL16DF", false, 0, 0, false },
589 /* 224 */
590 { R_PARISC_LTOFF_TP64, 0, 0, 64, false, 0, complain_overflow_bitfield,
591 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP64", false, 0, 0, false },
592 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
593 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
594 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield,
595 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", false, 0, 0, false },
596 { R_PARISC_LTOFF_TP14WR, 0, 0, 14, false, 0, complain_overflow_bitfield,
597 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14WR", false, 0, 0, false },
598 { R_PARISC_LTOFF_TP14DR, 0, 0, 14, false, 0, complain_overflow_bitfield,
599 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14DR", false, 0, 0, false },
600 { R_PARISC_LTOFF_TP16F, 0, 0, 16, false, 0, complain_overflow_dont,
601 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16F", false, 0, 0, false },
602 { R_PARISC_LTOFF_TP16WF, 0, 0, 16, false, 0, complain_overflow_bitfield,
603 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16WF", false, 0, 0, false },
604 { R_PARISC_LTOFF_TP16DF, 0, 0, 16, false, 0, complain_overflow_bitfield,
605 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16DF", false, 0, 0, false },
606 /* 232 */
607 { R_PARISC_GNU_VTENTRY, 0, 0, 0, false, 0, complain_overflow_dont,
608 bfd_elf_generic_reloc, "R_PARISC_GNU_VTENTRY", false, 0, 0, false },
609 { R_PARISC_GNU_VTINHERIT, 0, 0, 0, false, 0, complain_overflow_dont,
610 bfd_elf_generic_reloc, "R_PARISC_GNU_VTINHERIT", false, 0, 0, false },
613 #define OFFSET_14R_FROM_21L 4
614 #define OFFSET_14F_FROM_21L 5
616 /* Return the final relocation type for the given base type, instruction
617 format, and field selector. */
619 elf_hppa_reloc_type
620 elf_hppa_reloc_final_type (abfd, base_type, format, field)
621 bfd *abfd;
622 elf_hppa_reloc_type base_type;
623 int format;
624 unsigned int field;
626 elf_hppa_reloc_type final_type = base_type;
628 /* Just a tangle of nested switch statements to deal with the braindamage
629 that a different field selector means a completely different relocation
630 for PA ELF. */
631 switch (base_type)
633 /* We have been using generic relocation types. However, that may not
634 really make sense. Anyway, we need to support both R_PARISC_DIR64
635 and R_PARISC_DIR32 here. */
636 case R_PARISC_DIR32:
637 case R_PARISC_DIR64:
638 case R_HPPA_ABS_CALL:
639 switch (format)
641 case 14:
642 switch (field)
644 case e_fsel:
645 final_type = R_PARISC_DIR14F;
646 break;
647 case e_rsel:
648 case e_rrsel:
649 case e_rdsel:
650 final_type = R_PARISC_DIR14R;
651 break;
652 case e_rtsel:
653 final_type = R_PARISC_DLTIND14R;
654 break;
655 case e_rtpsel:
656 final_type = R_PARISC_LTOFF_FPTR14DR;
657 break;
658 case e_tsel:
659 final_type = R_PARISC_DLTIND14F;
660 break;
661 case e_rpsel:
662 final_type = R_PARISC_PLABEL14R;
663 break;
664 default:
665 return R_PARISC_NONE;
667 break;
669 case 17:
670 switch (field)
672 case e_fsel:
673 final_type = R_PARISC_DIR17F;
674 break;
675 case e_rsel:
676 case e_rrsel:
677 case e_rdsel:
678 final_type = R_PARISC_DIR17R;
679 break;
680 default:
681 return R_PARISC_NONE;
683 break;
685 case 21:
686 switch (field)
688 case e_lsel:
689 case e_lrsel:
690 case e_ldsel:
691 case e_nlsel:
692 case e_nlrsel:
693 final_type = R_PARISC_DIR21L;
694 break;
695 case e_ltsel:
696 final_type = R_PARISC_DLTIND21L;
697 break;
698 case e_ltpsel:
699 final_type = R_PARISC_LTOFF_FPTR21L;
700 break;
701 case e_lpsel:
702 final_type = R_PARISC_PLABEL21L;
703 break;
704 default:
705 return R_PARISC_NONE;
707 break;
709 case 32:
710 switch (field)
712 case e_fsel:
713 final_type = R_PARISC_DIR32;
714 /* When in 64bit mode, a 32bit relocation is supposed to
715 be a section relative relocation. Dwarf2 (for example)
716 uses 32bit section relative relocations. */
717 if (bfd_get_arch_info (abfd)->bits_per_address != 32)
718 final_type = R_PARISC_SECREL32;
719 break;
720 case e_psel:
721 final_type = R_PARISC_PLABEL32;
722 break;
723 default:
724 return R_PARISC_NONE;
726 break;
728 case 64:
729 switch (field)
731 case e_fsel:
732 final_type = R_PARISC_DIR64;
733 break;
734 case e_psel:
735 final_type = R_PARISC_FPTR64;
736 break;
737 default:
738 return R_PARISC_NONE;
740 break;
742 default:
743 return R_PARISC_NONE;
745 break;
747 case R_HPPA_GOTOFF:
748 switch (format)
750 case 14:
751 switch (field)
753 case e_rsel:
754 case e_rrsel:
755 case e_rdsel:
756 /* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32 */
757 final_type = base_type + OFFSET_14R_FROM_21L;
758 break;
759 case e_fsel:
760 /* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32 */
761 final_type = base_type + OFFSET_14F_FROM_21L;
762 break;
763 default:
764 return R_PARISC_NONE;
766 break;
768 case 21:
769 switch (field)
771 case e_lsel:
772 case e_lrsel:
773 case e_ldsel:
774 case e_nlsel:
775 case e_nlrsel:
776 /* R_PARISC_DLTREL21L for elf64, R_PARISC_DPREL21L for elf32 */
777 final_type = base_type;
778 break;
779 default:
780 return R_PARISC_NONE;
782 break;
784 default:
785 return R_PARISC_NONE;
787 break;
789 case R_HPPA_PCREL_CALL:
790 switch (format)
792 case 12:
793 switch (field)
795 case e_fsel:
796 final_type = R_PARISC_PCREL12F;
797 break;
798 default:
799 return R_PARISC_NONE;
801 break;
803 case 14:
804 /* Contrary to appearances, these are not calls of any sort.
805 Rather, they are loads/stores with a pcrel reloc. */
806 switch (field)
808 case e_rsel:
809 case e_rrsel:
810 case e_rdsel:
811 final_type = R_PARISC_PCREL14R;
812 break;
813 case e_fsel:
814 if (bfd_get_mach (abfd) < 25)
815 final_type = R_PARISC_PCREL14F;
816 else
817 final_type = R_PARISC_PCREL16F;
818 break;
819 default:
820 return R_PARISC_NONE;
822 break;
824 case 17:
825 switch (field)
827 case e_rsel:
828 case e_rrsel:
829 case e_rdsel:
830 final_type = R_PARISC_PCREL17R;
831 break;
832 case e_fsel:
833 final_type = R_PARISC_PCREL17F;
834 break;
835 default:
836 return R_PARISC_NONE;
838 break;
840 case 21:
841 switch (field)
843 case e_lsel:
844 case e_lrsel:
845 case e_ldsel:
846 case e_nlsel:
847 case e_nlrsel:
848 final_type = R_PARISC_PCREL21L;
849 break;
850 default:
851 return R_PARISC_NONE;
853 break;
855 case 22:
856 switch (field)
858 case e_fsel:
859 final_type = R_PARISC_PCREL22F;
860 break;
861 default:
862 return R_PARISC_NONE;
864 break;
866 default:
867 return R_PARISC_NONE;
869 break;
871 case R_PARISC_GNU_VTENTRY:
872 case R_PARISC_GNU_VTINHERIT:
873 case R_PARISC_SEGREL32:
874 case R_PARISC_SEGBASE:
875 /* The defaults are fine for these cases. */
876 break;
878 default:
879 return R_PARISC_NONE;
882 return final_type;
885 /* Return one (or more) BFD relocations which implement the base
886 relocation with modifications based on format and field. */
888 elf_hppa_reloc_type **
889 _bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
890 bfd *abfd;
891 elf_hppa_reloc_type base_type;
892 int format;
893 unsigned int field;
894 int ignore ATTRIBUTE_UNUSED;
895 asymbol *sym ATTRIBUTE_UNUSED;
897 elf_hppa_reloc_type *finaltype;
898 elf_hppa_reloc_type **final_types;
899 bfd_size_type amt = sizeof (elf_hppa_reloc_type *) * 2;
901 /* Allocate slots for the BFD relocation. */
902 final_types = (elf_hppa_reloc_type **) bfd_alloc (abfd, amt);
903 if (final_types == NULL)
904 return NULL;
906 /* Allocate space for the relocation itself. */
907 amt = sizeof (elf_hppa_reloc_type);
908 finaltype = (elf_hppa_reloc_type *) bfd_alloc (abfd, amt);
909 if (finaltype == NULL)
910 return NULL;
912 /* Some reasonable defaults. */
913 final_types[0] = finaltype;
914 final_types[1] = NULL;
916 *finaltype = elf_hppa_reloc_final_type (abfd, base_type, format, field);
918 return final_types;
921 /* Translate from an elf into field into a howto relocation pointer. */
923 static void
924 elf_hppa_info_to_howto (abfd, bfd_reloc, elf_reloc)
925 bfd *abfd ATTRIBUTE_UNUSED;
926 arelent *bfd_reloc;
927 Elf_Internal_Rela *elf_reloc;
929 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
930 < (unsigned int) R_PARISC_UNIMPLEMENTED);
931 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
934 /* Translate from an elf into field into a howto relocation pointer. */
936 static void
937 elf_hppa_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
938 bfd *abfd ATTRIBUTE_UNUSED;
939 arelent *bfd_reloc;
940 Elf_Internal_Rel *elf_reloc;
942 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
943 < (unsigned int) R_PARISC_UNIMPLEMENTED);
944 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
947 /* Return the address of the howto table entry to perform the CODE
948 relocation for an ARCH machine. */
950 static reloc_howto_type *
951 elf_hppa_reloc_type_lookup (abfd, code)
952 bfd *abfd ATTRIBUTE_UNUSED;
953 bfd_reloc_code_real_type code;
955 if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
957 BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
958 return &elf_hppa_howto_table[(int) code];
960 return NULL;
963 /* Return true if SYM represents a local label symbol. */
965 static boolean
966 elf_hppa_is_local_label_name (abfd, name)
967 bfd *abfd ATTRIBUTE_UNUSED;
968 const char *name;
970 if (name[0] == 'L' && name[1] == '$')
971 return 1;
972 return _bfd_elf_is_local_label_name (abfd, name);
975 /* Set the correct type for an ELF section. We do this by the
976 section name, which is a hack, but ought to work. */
978 static boolean
979 elf_hppa_fake_sections (abfd, hdr, sec)
980 bfd *abfd;
981 elf_hppa_internal_shdr *hdr;
982 asection *sec;
984 register const char *name;
986 name = bfd_get_section_name (abfd, sec);
988 if (strcmp (name, ".PARISC.unwind") == 0)
990 int indx;
991 asection *asec;
992 #if ARCH_SIZE == 64
993 hdr->sh_type = SHT_LOPROC + 1;
994 #else
995 hdr->sh_type = 1;
996 #endif
997 /* ?!? How are unwinds supposed to work for symbols in arbitrary
998 sections? Or what if we have multiple .text sections in a single
999 .o file? HP really messed up on this one.
1001 Ugh. We can not use elf_section_data (sec)->this_idx at this
1002 point because it is not initialized yet.
1004 So we (gasp) recompute it here. Hopefully nobody ever changes the
1005 way sections are numbered in elf.c! */
1006 for (asec = abfd->sections, indx = 1; asec; asec = asec->next, indx++)
1008 if (asec->name && strcmp (asec->name, ".text") == 0)
1010 hdr->sh_info = indx;
1011 break;
1015 /* I have no idea if this is really necessary or what it means. */
1016 hdr->sh_entsize = 4;
1018 return true;
1021 static void
1022 elf_hppa_final_write_processing (abfd, linker)
1023 bfd *abfd;
1024 boolean linker ATTRIBUTE_UNUSED;
1026 int mach = bfd_get_mach (abfd);
1028 elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL
1029 | EF_PARISC_EXT | EF_PARISC_LSB
1030 | EF_PARISC_WIDE | EF_PARISC_NO_KABP
1031 | EF_PARISC_LAZYSWAP);
1033 if (mach == 10)
1034 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0;
1035 else if (mach == 11)
1036 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1;
1037 else if (mach == 20)
1038 elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0;
1039 else if (mach == 25)
1040 elf_elfheader (abfd)->e_flags |= (EF_PARISC_WIDE
1041 | EFA_PARISC_2_0
1042 /* The GNU tools have trapped without
1043 option since 1993, so need to take
1044 a step backwards with the ELF
1045 based toolchains. */
1046 | EF_PARISC_TRAPNIL);
1049 /* Comparison function for qsort to sort unwind section during a
1050 final link. */
1052 static int
1053 hppa_unwind_entry_compare (a, b)
1054 const PTR a;
1055 const PTR b;
1057 const bfd_byte *ap, *bp;
1058 unsigned long av, bv;
1060 ap = (const bfd_byte *) a;
1061 av = (unsigned long) ap[0] << 24;
1062 av |= (unsigned long) ap[1] << 16;
1063 av |= (unsigned long) ap[2] << 8;
1064 av |= (unsigned long) ap[3];
1066 bp = (const bfd_byte *) b;
1067 bv = (unsigned long) bp[0] << 24;
1068 bv |= (unsigned long) bp[1] << 16;
1069 bv |= (unsigned long) bp[2] << 8;
1070 bv |= (unsigned long) bp[3];
1072 return av < bv ? -1 : av > bv ? 1 : 0;
1075 static boolean elf_hppa_sort_unwind (abfd)
1076 bfd *abfd;
1078 asection *s;
1080 /* Magic section names, but this is much safer than having
1081 relocate_section remember where SEGREL32 relocs occurred.
1082 Consider what happens if someone inept creates a linker script
1083 that puts unwind information in .text. */
1084 s = bfd_get_section_by_name (abfd, ".PARISC.unwind");
1085 if (s != NULL)
1087 bfd_size_type size;
1088 char *contents;
1090 size = s->_raw_size;
1091 contents = bfd_malloc (size);
1092 if (contents == NULL)
1093 return false;
1095 if (! bfd_get_section_contents (abfd, s, contents, (file_ptr) 0, size))
1096 return false;
1098 qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare);
1100 if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size))
1101 return false;
1104 return true;
1107 #if ARCH_SIZE == 64
1108 /* Hook called by the linker routine which adds symbols from an object
1109 file. HP's libraries define symbols with HP specific section
1110 indices, which we have to handle. */
1112 static boolean
1113 elf_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
1114 bfd *abfd;
1115 struct bfd_link_info *info ATTRIBUTE_UNUSED;
1116 const Elf_Internal_Sym *sym;
1117 const char **namep ATTRIBUTE_UNUSED;
1118 flagword *flagsp ATTRIBUTE_UNUSED;
1119 asection **secp;
1120 bfd_vma *valp;
1122 int index = sym->st_shndx;
1124 switch (index)
1126 case SHN_PARISC_ANSI_COMMON:
1127 *secp = bfd_make_section_old_way (abfd, ".PARISC.ansi.common");
1128 (*secp)->flags |= SEC_IS_COMMON;
1129 *valp = sym->st_size;
1130 break;
1132 case SHN_PARISC_HUGE_COMMON:
1133 *secp = bfd_make_section_old_way (abfd, ".PARISC.huge.common");
1134 (*secp)->flags |= SEC_IS_COMMON;
1135 *valp = sym->st_size;
1136 break;
1139 return true;
1142 static boolean
1143 elf_hppa_unmark_useless_dynamic_symbols (h, data)
1144 struct elf_link_hash_entry *h;
1145 PTR data;
1147 struct bfd_link_info *info = (struct bfd_link_info *)data;
1149 if (h->root.type == bfd_link_hash_warning)
1150 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1152 /* If we are not creating a shared library, and this symbol is
1153 referenced by a shared library but is not defined anywhere, then
1154 the generic code will warn that it is undefined.
1156 This behavior is undesirable on HPs since the standard shared
1157 libraries contain references to undefined symbols.
1159 So we twiddle the flags associated with such symbols so that they
1160 will not trigger the warning. ?!? FIXME. This is horribly fragile.
1162 Ultimately we should have better controls over the generic ELF BFD
1163 linker code. */
1164 if (! info->relocateable
1165 && ! (info->shared
1166 && !info->no_undefined)
1167 && h->root.type == bfd_link_hash_undefined
1168 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
1169 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
1171 h->elf_link_hash_flags &= ~ELF_LINK_HASH_REF_DYNAMIC;
1172 h->elf_link_hash_flags |= 0x8000;
1175 return true;
1178 static boolean
1179 elf_hppa_remark_useless_dynamic_symbols (h, data)
1180 struct elf_link_hash_entry *h;
1181 PTR data;
1183 struct bfd_link_info *info = (struct bfd_link_info *)data;
1185 if (h->root.type == bfd_link_hash_warning)
1186 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1188 /* If we are not creating a shared library, and this symbol is
1189 referenced by a shared library but is not defined anywhere, then
1190 the generic code will warn that it is undefined.
1192 This behavior is undesirable on HPs since the standard shared
1193 libraries contain reerences to undefined symbols.
1195 So we twiddle the flags associated with such symbols so that they
1196 will not trigger the warning. ?!? FIXME. This is horribly fragile.
1198 Ultimately we should have better controls over the generic ELF BFD
1199 linker code. */
1200 if (! info->relocateable
1201 && ! (info->shared
1202 && !info->no_undefined)
1203 && h->root.type == bfd_link_hash_undefined
1204 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
1205 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
1206 && (h->elf_link_hash_flags & 0x8000) != 0)
1208 h->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC;
1209 h->elf_link_hash_flags &= ~0x8000;
1212 return true;
1215 static boolean
1216 elf_hppa_is_dynamic_loader_symbol (name)
1217 const char * name;
1219 return (! strcmp (name, "__CPU_REVISION")
1220 || ! strcmp (name, "__CPU_KEYBITS_1")
1221 || ! strcmp (name, "__SYSTEM_ID_D")
1222 || ! strcmp (name, "__FPU_MODEL")
1223 || ! strcmp (name, "__FPU_REVISION")
1224 || ! strcmp (name, "__ARGC")
1225 || ! strcmp (name, "__ARGV")
1226 || ! strcmp (name, "__ENVP")
1227 || ! strcmp (name, "__TLS_SIZE_D")
1228 || ! strcmp (name, "__LOAD_INFO")
1229 || ! strcmp (name, "__systab"));
1232 /* Record the lowest address for the data and text segments. */
1233 static void
1234 elf_hppa_record_segment_addrs (abfd, section, data)
1235 bfd *abfd ATTRIBUTE_UNUSED;
1236 asection *section;
1237 PTR data;
1239 struct elf64_hppa_link_hash_table *hppa_info;
1240 bfd_vma value;
1242 hppa_info = (struct elf64_hppa_link_hash_table *)data;
1244 value = section->vma - section->filepos;
1246 if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1247 == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1248 && value < hppa_info->text_segment_base)
1249 hppa_info->text_segment_base = value;
1250 else if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1251 == (SEC_ALLOC | SEC_LOAD))
1252 && value < hppa_info->data_segment_base)
1253 hppa_info->data_segment_base = value;
1256 /* Called after we have seen all the input files/sections, but before
1257 final symbol resolution and section placement has been determined.
1259 We use this hook to (possibly) provide a value for __gp, then we
1260 fall back to the generic ELF final link routine. */
1262 static boolean
1263 elf_hppa_final_link (abfd, info)
1264 bfd *abfd;
1265 struct bfd_link_info *info;
1267 boolean retval;
1268 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
1270 if (! info->relocateable)
1272 struct elf_link_hash_entry *gp;
1273 bfd_vma gp_val;
1275 /* The linker script defines a value for __gp iff it was referenced
1276 by one of the objects being linked. First try to find the symbol
1277 in the hash table. If that fails, just compute the value __gp
1278 should have had. */
1279 gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", false,
1280 false, false);
1282 if (gp)
1285 /* Adjust the value of __gp as we may want to slide it into the
1286 .plt section so that the stubs can access PLT entries without
1287 using an addil sequence. */
1288 gp->root.u.def.value += hppa_info->gp_offset;
1290 gp_val = (gp->root.u.def.section->output_section->vma
1291 + gp->root.u.def.section->output_offset
1292 + gp->root.u.def.value);
1294 else
1296 asection *sec;
1298 /* First look for a .plt section. If found, then __gp is the
1299 address of the .plt + gp_offset.
1301 If no .plt is found, then look for .dlt, .opd and .data (in
1302 that order) and set __gp to the base address of whichever
1303 section is found first. */
1305 sec = hppa_info->plt_sec;
1306 if (sec && ! (sec->flags & SEC_EXCLUDE))
1307 gp_val = (sec->output_offset
1308 + sec->output_section->vma
1309 + hppa_info->gp_offset);
1310 else
1312 sec = hppa_info->dlt_sec;
1313 if (!sec || (sec->flags & SEC_EXCLUDE))
1314 sec = hppa_info->opd_sec;
1315 if (!sec || (sec->flags & SEC_EXCLUDE))
1316 sec = bfd_get_section_by_name (abfd, ".data");
1317 if (!sec || (sec->flags & SEC_EXCLUDE))
1318 return false;
1320 gp_val = sec->output_offset + sec->output_section->vma;
1324 /* Install whatever value we found/computed for __gp. */
1325 _bfd_set_gp_value (abfd, gp_val);
1328 /* We need to know the base of the text and data segments so that we
1329 can perform SEGREL relocations. We will record the base addresses
1330 when we encounter the first SEGREL relocation. */
1331 hppa_info->text_segment_base = (bfd_vma)-1;
1332 hppa_info->data_segment_base = (bfd_vma)-1;
1334 /* HP's shared libraries have references to symbols that are not
1335 defined anywhere. The generic ELF BFD linker code will complaim
1336 about such symbols.
1338 So we detect the losing case and arrange for the flags on the symbol
1339 to indicate that it was never referenced. This keeps the generic
1340 ELF BFD link code happy and appears to not create any secondary
1341 problems. Ultimately we need a way to control the behavior of the
1342 generic ELF BFD link code better. */
1343 elf_link_hash_traverse (elf_hash_table (info),
1344 elf_hppa_unmark_useless_dynamic_symbols,
1345 info);
1347 /* Invoke the regular ELF backend linker to do all the work. */
1348 retval = bfd_elf_bfd_final_link (abfd, info);
1350 elf_link_hash_traverse (elf_hash_table (info),
1351 elf_hppa_remark_useless_dynamic_symbols,
1352 info);
1354 /* If we're producing a final executable, sort the contents of the
1355 unwind section. */
1356 if (retval)
1357 retval = elf_hppa_sort_unwind (abfd);
1359 return retval;
1362 /* Relocate an HPPA ELF section. */
1364 static boolean
1365 elf_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
1366 contents, relocs, local_syms, local_sections)
1367 bfd *output_bfd;
1368 struct bfd_link_info *info;
1369 bfd *input_bfd;
1370 asection *input_section;
1371 bfd_byte *contents;
1372 Elf_Internal_Rela *relocs;
1373 Elf_Internal_Sym *local_syms;
1374 asection **local_sections;
1376 Elf_Internal_Shdr *symtab_hdr;
1377 Elf_Internal_Rela *rel;
1378 Elf_Internal_Rela *relend;
1379 struct elf64_hppa_link_hash_table *hppa_info;
1381 if (info->relocateable)
1382 return true;
1384 hppa_info = elf64_hppa_hash_table (info);
1385 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1387 rel = relocs;
1388 relend = relocs + input_section->reloc_count;
1389 for (; rel < relend; rel++)
1391 int r_type;
1392 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
1393 unsigned long r_symndx;
1394 struct elf_link_hash_entry *h;
1395 Elf_Internal_Sym *sym;
1396 asection *sym_sec;
1397 bfd_vma relocation;
1398 bfd_reloc_status_type r;
1399 const char *sym_name;
1400 const char *dyn_name;
1401 char *dynh_buf = NULL;
1402 size_t dynh_buflen = 0;
1403 struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
1405 r_type = ELF_R_TYPE (rel->r_info);
1406 if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
1408 bfd_set_error (bfd_error_bad_value);
1409 return false;
1412 /* This is a final link. */
1413 r_symndx = ELF_R_SYM (rel->r_info);
1414 h = NULL;
1415 sym = NULL;
1416 sym_sec = NULL;
1417 if (r_symndx < symtab_hdr->sh_info)
1419 /* This is a local symbol. */
1420 sym = local_syms + r_symndx;
1421 sym_sec = local_sections[r_symndx];
1422 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
1424 /* If this symbol has an entry in the PA64 dynamic hash
1425 table, then get it. */
1426 dyn_name = get_dyn_name (input_section, h, rel,
1427 &dynh_buf, &dynh_buflen);
1428 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1429 dyn_name, false, false);
1432 else
1434 /* This is not a local symbol. */
1435 long indx;
1437 indx = r_symndx - symtab_hdr->sh_info;
1438 h = elf_sym_hashes (input_bfd)[indx];
1439 while (h->root.type == bfd_link_hash_indirect
1440 || h->root.type == bfd_link_hash_warning)
1441 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1442 if (h->root.type == bfd_link_hash_defined
1443 || h->root.type == bfd_link_hash_defweak)
1445 sym_sec = h->root.u.def.section;
1447 /* If this symbol has an entry in the PA64 dynamic hash
1448 table, then get it. */
1449 dyn_name = get_dyn_name (input_section, h, rel,
1450 &dynh_buf, &dynh_buflen);
1451 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1452 dyn_name, false, false);
1454 /* If we have a relocation against a symbol defined in a
1455 shared library and we have not created an entry in the
1456 PA64 dynamic symbol hash table for it, then we lose. */
1457 if (sym_sec->output_section == NULL && dyn_h == NULL)
1459 (*_bfd_error_handler)
1460 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1461 bfd_archive_filename (input_bfd), h->root.root.string,
1462 bfd_get_section_name (input_bfd, input_section));
1463 relocation = 0;
1465 else if (sym_sec->output_section)
1466 relocation = (h->root.u.def.value
1467 + sym_sec->output_offset
1468 + sym_sec->output_section->vma);
1469 /* Value will be provided via one of the offsets in the
1470 dyn_h hash table entry. */
1471 else
1472 relocation = 0;
1474 /* Allow undefined symbols in shared libraries. */
1475 else if (info->shared && !info->no_undefined
1476 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
1478 if (info->symbolic)
1479 (*info->callbacks->undefined_symbol)
1480 (info, h->root.root.string, input_bfd,
1481 input_section, rel->r_offset, false);
1483 /* If this symbol has an entry in the PA64 dynamic hash
1484 table, then get it. */
1485 dyn_name = get_dyn_name (input_section, h, rel,
1486 &dynh_buf, &dynh_buflen);
1487 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1488 dyn_name, false, false);
1490 if (dyn_h == NULL)
1492 (*_bfd_error_handler)
1493 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1494 bfd_archive_filename (input_bfd), h->root.root.string,
1495 bfd_get_section_name (input_bfd, input_section));
1496 relocation = 0;
1498 relocation = 0;
1500 else if (h->root.type == bfd_link_hash_undefweak)
1501 relocation = 0;
1502 else
1504 /* Ignore dynamic loader defined symbols. */
1505 if (elf_hppa_is_dynamic_loader_symbol (h->root.root.string))
1506 relocation = 0;
1507 else
1509 if (!((*info->callbacks->undefined_symbol)
1510 (info, h->root.root.string, input_bfd,
1511 input_section, rel->r_offset, true)))
1512 return false;
1513 break;
1518 if (h != NULL)
1519 sym_name = h->root.root.string;
1520 else
1522 sym_name = bfd_elf_string_from_elf_section (input_bfd,
1523 symtab_hdr->sh_link,
1524 sym->st_name);
1525 if (sym_name == NULL)
1526 return false;
1527 if (*sym_name == '\0')
1528 sym_name = bfd_section_name (input_bfd, sym_sec);
1531 r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1532 input_section, contents,
1533 relocation, info, sym_sec,
1534 h, dyn_h);
1536 if (r != bfd_reloc_ok)
1538 switch (r)
1540 default:
1541 abort ();
1542 case bfd_reloc_overflow:
1544 if (!((*info->callbacks->reloc_overflow)
1545 (info, sym_name, howto->name, (bfd_vma) 0,
1546 input_bfd, input_section, rel->r_offset)))
1547 return false;
1549 break;
1553 return true;
1556 /* Compute the value for a relocation (REL) during a final link stage,
1557 then insert the value into the proper location in CONTENTS.
1559 VALUE is a tentative value for the relocation and may be overridden
1560 and modified here based on the specific relocation to be performed.
1562 For example we do conversions for PC-relative branches in this routine
1563 or redirection of calls to external routines to stubs.
1565 The work of actually applying the relocation is left to a helper
1566 routine in an attempt to reduce the complexity and size of this
1567 function. */
1569 static bfd_reloc_status_type
1570 elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1571 input_section, contents, value,
1572 info, sym_sec, h, dyn_h)
1573 Elf_Internal_Rela *rel;
1574 bfd *input_bfd;
1575 bfd *output_bfd;
1576 asection *input_section;
1577 bfd_byte *contents;
1578 bfd_vma value;
1579 struct bfd_link_info *info;
1580 asection *sym_sec;
1581 struct elf_link_hash_entry *h ATTRIBUTE_UNUSED;
1582 struct elf64_hppa_dyn_hash_entry *dyn_h;
1584 int insn;
1585 bfd_vma offset = rel->r_offset;
1586 bfd_signed_vma addend = rel->r_addend;
1587 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
1588 unsigned int r_type = howto->type;
1589 bfd_byte *hit_data = contents + offset;
1590 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
1592 insn = bfd_get_32 (input_bfd, hit_data);
1594 switch (r_type)
1596 case R_PARISC_NONE:
1597 break;
1599 /* Basic function call support.
1601 Note for a call to a function defined in another dynamic library
1602 we want to redirect the call to a stub. */
1604 /* Random PC relative relocs. */
1605 case R_PARISC_PCREL21L:
1606 case R_PARISC_PCREL14R:
1607 case R_PARISC_PCREL14F:
1608 case R_PARISC_PCREL14WR:
1609 case R_PARISC_PCREL14DR:
1610 case R_PARISC_PCREL16F:
1611 case R_PARISC_PCREL16WF:
1612 case R_PARISC_PCREL16DF:
1614 /* If this is a call to a function defined in another dynamic
1615 library, then redirect the call to the local stub for this
1616 function. */
1617 if (sym_sec == NULL || sym_sec->output_section == NULL)
1618 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1619 + hppa_info->stub_sec->output_section->vma);
1621 /* Turn VALUE into a proper PC relative address. */
1622 value -= (offset + input_section->output_offset
1623 + input_section->output_section->vma);
1625 /* Adjust for any field selectors. */
1626 if (r_type == R_PARISC_PCREL21L)
1627 value = hppa_field_adjust (value, -8 + addend, e_lsel);
1628 else if (r_type == R_PARISC_PCREL14F
1629 || r_type == R_PARISC_PCREL16F
1630 || r_type == R_PARISC_PCREL16WF
1631 || r_type == R_PARISC_PCREL16DF)
1632 value = hppa_field_adjust (value, -8 + addend, e_fsel);
1633 else
1634 value = hppa_field_adjust (value, -8 + addend, e_rsel);
1636 /* Apply the relocation to the given instruction. */
1637 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1638 break;
1641 case R_PARISC_PCREL12F:
1642 case R_PARISC_PCREL22F:
1643 case R_PARISC_PCREL17F:
1644 case R_PARISC_PCREL22C:
1645 case R_PARISC_PCREL17C:
1646 case R_PARISC_PCREL17R:
1648 /* If this is a call to a function defined in another dynamic
1649 library, then redirect the call to the local stub for this
1650 function. */
1651 if (sym_sec == NULL || sym_sec->output_section == NULL)
1652 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1653 + hppa_info->stub_sec->output_section->vma);
1655 /* Turn VALUE into a proper PC relative address. */
1656 value -= (offset + input_section->output_offset
1657 + input_section->output_section->vma);
1659 /* Adjust for any field selectors. */
1660 if (r_type == R_PARISC_PCREL17R)
1661 value = hppa_field_adjust (value, -8 + addend, e_rsel);
1662 else
1663 value = hppa_field_adjust (value, -8 + addend, e_fsel);
1665 /* All branches are implicitly shifted by 2 places. */
1666 value >>= 2;
1668 /* Apply the relocation to the given instruction. */
1669 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1670 break;
1673 /* Indirect references to data through the DLT. */
1674 case R_PARISC_DLTIND14R:
1675 case R_PARISC_DLTIND14F:
1676 case R_PARISC_DLTIND14DR:
1677 case R_PARISC_DLTIND14WR:
1678 case R_PARISC_DLTIND21L:
1679 case R_PARISC_LTOFF_FPTR14R:
1680 case R_PARISC_LTOFF_FPTR14DR:
1681 case R_PARISC_LTOFF_FPTR14WR:
1682 case R_PARISC_LTOFF_FPTR21L:
1683 case R_PARISC_LTOFF_FPTR16F:
1684 case R_PARISC_LTOFF_FPTR16WF:
1685 case R_PARISC_LTOFF_FPTR16DF:
1686 case R_PARISC_LTOFF_TP21L:
1687 case R_PARISC_LTOFF_TP14R:
1688 case R_PARISC_LTOFF_TP14F:
1689 case R_PARISC_LTOFF_TP14WR:
1690 case R_PARISC_LTOFF_TP14DR:
1691 case R_PARISC_LTOFF_TP16F:
1692 case R_PARISC_LTOFF_TP16WF:
1693 case R_PARISC_LTOFF_TP16DF:
1694 case R_PARISC_LTOFF16F:
1695 case R_PARISC_LTOFF16WF:
1696 case R_PARISC_LTOFF16DF:
1698 /* If this relocation was against a local symbol, then we still
1699 have not set up the DLT entry (it's not convenient to do so
1700 in the "finalize_dlt" routine because it is difficult to get
1701 to the local symbol's value).
1703 So, if this is a local symbol (h == NULL), then we need to
1704 fill in its DLT entry.
1706 Similarly we may still need to set up an entry in .opd for
1707 a local function which had its address taken. */
1708 if (dyn_h->h == NULL)
1710 /* Now do .opd creation if needed. */
1711 if (r_type == R_PARISC_LTOFF_FPTR14R
1712 || r_type == R_PARISC_LTOFF_FPTR14DR
1713 || r_type == R_PARISC_LTOFF_FPTR14WR
1714 || r_type == R_PARISC_LTOFF_FPTR21L
1715 || r_type == R_PARISC_LTOFF_FPTR16F
1716 || r_type == R_PARISC_LTOFF_FPTR16WF
1717 || r_type == R_PARISC_LTOFF_FPTR16DF)
1719 /* The first two words of an .opd entry are zero. */
1720 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset,
1721 0, 16);
1723 /* The next word is the address of the function. */
1724 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
1725 (hppa_info->opd_sec->contents
1726 + dyn_h->opd_offset + 16));
1728 /* The last word is our local __gp value. */
1729 value = _bfd_get_gp_value
1730 (hppa_info->opd_sec->output_section->owner);
1731 bfd_put_64 (hppa_info->opd_sec->owner, value,
1732 (hppa_info->opd_sec->contents
1733 + dyn_h->opd_offset + 24));
1735 /* The DLT value is the address of the .opd entry. */
1736 value = (dyn_h->opd_offset
1737 + hppa_info->opd_sec->output_offset
1738 + hppa_info->opd_sec->output_section->vma);
1739 addend = 0;
1742 bfd_put_64 (hppa_info->dlt_sec->owner,
1743 value + addend,
1744 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1747 /* We want the value of the DLT offset for this symbol, not
1748 the symbol's actual address. Note that __gp may not point
1749 to the start of the DLT, so we have to compute the absolute
1750 address, then subtract out the value of __gp. */
1751 value = (dyn_h->dlt_offset
1752 + hppa_info->dlt_sec->output_offset
1753 + hppa_info->dlt_sec->output_section->vma);
1754 value -= _bfd_get_gp_value (output_bfd);
1756 /* All DLTIND relocations are basically the same at this point,
1757 except that we need different field selectors for the 21bit
1758 version vs the 14bit versions. */
1759 if (r_type == R_PARISC_DLTIND21L
1760 || r_type == R_PARISC_LTOFF_FPTR21L
1761 || r_type == R_PARISC_LTOFF_TP21L)
1762 value = hppa_field_adjust (value, 0, e_lsel);
1763 else if (r_type == R_PARISC_DLTIND14F
1764 || r_type == R_PARISC_LTOFF_FPTR16F
1765 || r_type == R_PARISC_LTOFF_FPTR16WF
1766 || r_type == R_PARISC_LTOFF_FPTR16DF
1767 || r_type == R_PARISC_LTOFF16F
1768 || r_type == R_PARISC_LTOFF16DF
1769 || r_type == R_PARISC_LTOFF16WF
1770 || r_type == R_PARISC_LTOFF_TP16F
1771 || r_type == R_PARISC_LTOFF_TP16WF
1772 || r_type == R_PARISC_LTOFF_TP16DF)
1773 value = hppa_field_adjust (value, 0, e_fsel);
1774 else
1775 value = hppa_field_adjust (value, 0, e_rsel);
1777 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1778 break;
1781 case R_PARISC_DLTREL14R:
1782 case R_PARISC_DLTREL14F:
1783 case R_PARISC_DLTREL14DR:
1784 case R_PARISC_DLTREL14WR:
1785 case R_PARISC_DLTREL21L:
1786 case R_PARISC_DPREL21L:
1787 case R_PARISC_DPREL14WR:
1788 case R_PARISC_DPREL14DR:
1789 case R_PARISC_DPREL14R:
1790 case R_PARISC_DPREL14F:
1791 case R_PARISC_GPREL16F:
1792 case R_PARISC_GPREL16WF:
1793 case R_PARISC_GPREL16DF:
1795 /* Subtract out the global pointer value to make value a DLT
1796 relative address. */
1797 value -= _bfd_get_gp_value (output_bfd);
1799 /* All DLTREL relocations are basically the same at this point,
1800 except that we need different field selectors for the 21bit
1801 version vs the 14bit versions. */
1802 if (r_type == R_PARISC_DLTREL21L
1803 || r_type == R_PARISC_DPREL21L)
1804 value = hppa_field_adjust (value, addend, e_lrsel);
1805 else if (r_type == R_PARISC_DLTREL14F
1806 || r_type == R_PARISC_DPREL14F
1807 || r_type == R_PARISC_GPREL16F
1808 || r_type == R_PARISC_GPREL16WF
1809 || r_type == R_PARISC_GPREL16DF)
1810 value = hppa_field_adjust (value, addend, e_fsel);
1811 else
1812 value = hppa_field_adjust (value, addend, e_rrsel);
1814 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1815 break;
1818 case R_PARISC_DIR21L:
1819 case R_PARISC_DIR17R:
1820 case R_PARISC_DIR17F:
1821 case R_PARISC_DIR14R:
1822 case R_PARISC_DIR14F:
1823 case R_PARISC_DIR14WR:
1824 case R_PARISC_DIR14DR:
1825 case R_PARISC_DIR16F:
1826 case R_PARISC_DIR16WF:
1827 case R_PARISC_DIR16DF:
1829 /* All DIR relocations are basically the same at this point,
1830 except that branch offsets need to be divided by four, and
1831 we need different field selectors. Note that we don't
1832 redirect absolute calls to local stubs. */
1834 if (r_type == R_PARISC_DIR21L)
1835 value = hppa_field_adjust (value, addend, e_lrsel);
1836 else if (r_type == R_PARISC_DIR17F
1837 || r_type == R_PARISC_DIR16F
1838 || r_type == R_PARISC_DIR16WF
1839 || r_type == R_PARISC_DIR16DF
1840 || r_type == R_PARISC_DIR14F)
1841 value = hppa_field_adjust (value, addend, e_fsel);
1842 else
1843 value = hppa_field_adjust (value, addend, e_rrsel);
1845 if (r_type == R_PARISC_DIR17R || r_type == R_PARISC_DIR17F)
1847 /* All branches are implicitly shifted by 2 places. */
1848 value >>= 2;
1851 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1852 break;
1855 case R_PARISC_PLTOFF21L:
1856 case R_PARISC_PLTOFF14R:
1857 case R_PARISC_PLTOFF14F:
1858 case R_PARISC_PLTOFF14WR:
1859 case R_PARISC_PLTOFF14DR:
1860 case R_PARISC_PLTOFF16F:
1861 case R_PARISC_PLTOFF16WF:
1862 case R_PARISC_PLTOFF16DF:
1864 /* We want the value of the PLT offset for this symbol, not
1865 the symbol's actual address. Note that __gp may not point
1866 to the start of the DLT, so we have to compute the absolute
1867 address, then subtract out the value of __gp. */
1868 value = (dyn_h->plt_offset
1869 + hppa_info->plt_sec->output_offset
1870 + hppa_info->plt_sec->output_section->vma);
1871 value -= _bfd_get_gp_value (output_bfd);
1873 /* All PLTOFF relocations are basically the same at this point,
1874 except that we need different field selectors for the 21bit
1875 version vs the 14bit versions. */
1876 if (r_type == R_PARISC_PLTOFF21L)
1877 value = hppa_field_adjust (value, addend, e_lrsel);
1878 else if (r_type == R_PARISC_PLTOFF14F
1879 || r_type == R_PARISC_PLTOFF16F
1880 || r_type == R_PARISC_PLTOFF16WF
1881 || r_type == R_PARISC_PLTOFF16DF)
1882 value = hppa_field_adjust (value, addend, e_fsel);
1883 else
1884 value = hppa_field_adjust (value, addend, e_rrsel);
1886 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1887 break;
1890 case R_PARISC_LTOFF_FPTR32:
1892 /* We may still need to create the FPTR itself if it was for
1893 a local symbol. */
1894 if (dyn_h->h == NULL)
1896 /* The first two words of an .opd entry are zero. */
1897 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1899 /* The next word is the address of the function. */
1900 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
1901 (hppa_info->opd_sec->contents
1902 + dyn_h->opd_offset + 16));
1904 /* The last word is our local __gp value. */
1905 value = _bfd_get_gp_value
1906 (hppa_info->opd_sec->output_section->owner);
1907 bfd_put_64 (hppa_info->opd_sec->owner, value,
1908 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1910 /* The DLT value is the address of the .opd entry. */
1911 value = (dyn_h->opd_offset
1912 + hppa_info->opd_sec->output_offset
1913 + hppa_info->opd_sec->output_section->vma);
1915 bfd_put_64 (hppa_info->dlt_sec->owner,
1916 value,
1917 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1920 /* We want the value of the DLT offset for this symbol, not
1921 the symbol's actual address. Note that __gp may not point
1922 to the start of the DLT, so we have to compute the absolute
1923 address, then subtract out the value of __gp. */
1924 value = (dyn_h->dlt_offset
1925 + hppa_info->dlt_sec->output_offset
1926 + hppa_info->dlt_sec->output_section->vma);
1927 value -= _bfd_get_gp_value (output_bfd);
1928 bfd_put_32 (input_bfd, value, hit_data);
1929 return bfd_reloc_ok;
1932 case R_PARISC_LTOFF_FPTR64:
1933 case R_PARISC_LTOFF_TP64:
1935 /* We may still need to create the FPTR itself if it was for
1936 a local symbol. */
1937 if (dyn_h->h == NULL && r_type == R_PARISC_LTOFF_FPTR64)
1939 /* The first two words of an .opd entry are zero. */
1940 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1942 /* The next word is the address of the function. */
1943 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
1944 (hppa_info->opd_sec->contents
1945 + dyn_h->opd_offset + 16));
1947 /* The last word is our local __gp value. */
1948 value = _bfd_get_gp_value
1949 (hppa_info->opd_sec->output_section->owner);
1950 bfd_put_64 (hppa_info->opd_sec->owner, value,
1951 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1953 /* The DLT value is the address of the .opd entry. */
1954 value = (dyn_h->opd_offset
1955 + hppa_info->opd_sec->output_offset
1956 + hppa_info->opd_sec->output_section->vma);
1958 bfd_put_64 (hppa_info->dlt_sec->owner,
1959 value,
1960 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1963 /* We want the value of the DLT offset for this symbol, not
1964 the symbol's actual address. Note that __gp may not point
1965 to the start of the DLT, so we have to compute the absolute
1966 address, then subtract out the value of __gp. */
1967 value = (dyn_h->dlt_offset
1968 + hppa_info->dlt_sec->output_offset
1969 + hppa_info->dlt_sec->output_section->vma);
1970 value -= _bfd_get_gp_value (output_bfd);
1971 bfd_put_64 (input_bfd, value, hit_data);
1972 return bfd_reloc_ok;
1975 case R_PARISC_DIR32:
1976 bfd_put_32 (input_bfd, value + addend, hit_data);
1977 return bfd_reloc_ok;
1979 case R_PARISC_DIR64:
1980 bfd_put_64 (input_bfd, value + addend, hit_data);
1981 return bfd_reloc_ok;
1983 case R_PARISC_GPREL64:
1984 /* Subtract out the global pointer value to make value a DLT
1985 relative address. */
1986 value -= _bfd_get_gp_value (output_bfd);
1988 bfd_put_64 (input_bfd, value + addend, hit_data);
1989 return bfd_reloc_ok;
1991 case R_PARISC_LTOFF64:
1992 /* We want the value of the DLT offset for this symbol, not
1993 the symbol's actual address. Note that __gp may not point
1994 to the start of the DLT, so we have to compute the absolute
1995 address, then subtract out the value of __gp. */
1996 value = (dyn_h->dlt_offset
1997 + hppa_info->dlt_sec->output_offset
1998 + hppa_info->dlt_sec->output_section->vma);
1999 value -= _bfd_get_gp_value (output_bfd);
2001 bfd_put_64 (input_bfd, value + addend, hit_data);
2002 return bfd_reloc_ok;
2004 case R_PARISC_PCREL32:
2006 /* If this is a call to a function defined in another dynamic
2007 library, then redirect the call to the local stub for this
2008 function. */
2009 if (sym_sec == NULL || sym_sec->output_section == NULL)
2010 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
2011 + hppa_info->stub_sec->output_section->vma);
2013 /* Turn VALUE into a proper PC relative address. */
2014 value -= (offset + input_section->output_offset
2015 + input_section->output_section->vma);
2017 value += addend;
2018 value -= 8;
2019 bfd_put_32 (input_bfd, value, hit_data);
2020 return bfd_reloc_ok;
2023 case R_PARISC_PCREL64:
2025 /* If this is a call to a function defined in another dynamic
2026 library, then redirect the call to the local stub for this
2027 function. */
2028 if (sym_sec == NULL || sym_sec->output_section == NULL)
2029 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
2030 + hppa_info->stub_sec->output_section->vma);
2032 /* Turn VALUE into a proper PC relative address. */
2033 value -= (offset + input_section->output_offset
2034 + input_section->output_section->vma);
2036 value += addend;
2037 value -= 8;
2038 bfd_put_64 (input_bfd, value, hit_data);
2039 return bfd_reloc_ok;
2042 case R_PARISC_FPTR64:
2044 /* We may still need to create the FPTR itself if it was for
2045 a local symbol. */
2046 if (dyn_h->h == NULL)
2048 /* The first two words of an .opd entry are zero. */
2049 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
2051 /* The next word is the address of the function. */
2052 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
2053 (hppa_info->opd_sec->contents
2054 + dyn_h->opd_offset + 16));
2056 /* The last word is our local __gp value. */
2057 value = _bfd_get_gp_value
2058 (hppa_info->opd_sec->output_section->owner);
2059 bfd_put_64 (hppa_info->opd_sec->owner, value,
2060 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
2063 if (dyn_h->want_opd)
2064 /* We want the value of the OPD offset for this symbol. */
2065 value = (dyn_h->opd_offset
2066 + hppa_info->opd_sec->output_offset
2067 + hppa_info->opd_sec->output_section->vma);
2068 else
2069 /* We want the address of the symbol. */
2070 value += addend;
2072 bfd_put_64 (input_bfd, value, hit_data);
2073 return bfd_reloc_ok;
2076 case R_PARISC_SECREL32:
2077 bfd_put_32 (input_bfd,
2078 value + addend - sym_sec->output_section->vma,
2079 hit_data);
2080 return bfd_reloc_ok;
2082 case R_PARISC_SEGREL32:
2083 case R_PARISC_SEGREL64:
2085 /* If this is the first SEGREL relocation, then initialize
2086 the segment base values. */
2087 if (hppa_info->text_segment_base == (bfd_vma) -1)
2088 bfd_map_over_sections (output_bfd, elf_hppa_record_segment_addrs,
2089 hppa_info);
2091 /* VALUE holds the absolute address. We want to include the
2092 addend, then turn it into a segment relative address.
2094 The segment is derived from SYM_SEC. We assume that there are
2095 only two segments of note in the resulting executable/shlib.
2096 A readonly segment (.text) and a readwrite segment (.data). */
2097 value += addend;
2099 if (sym_sec->flags & SEC_CODE)
2100 value -= hppa_info->text_segment_base;
2101 else
2102 value -= hppa_info->data_segment_base;
2104 if (r_type == R_PARISC_SEGREL32)
2105 bfd_put_32 (input_bfd, value, hit_data);
2106 else
2107 bfd_put_64 (input_bfd, value, hit_data);
2108 return bfd_reloc_ok;
2111 /* Something we don't know how to handle. */
2112 default:
2113 return bfd_reloc_notsupported;
2116 /* Update the instruction word. */
2117 bfd_put_32 (input_bfd, (bfd_vma) insn, hit_data);
2118 return bfd_reloc_ok;
2121 /* Relocate the given INSN. VALUE should be the actual value we want
2122 to insert into the instruction, ie by this point we should not be
2123 concerned with computing an offset relative to the DLT, PC, etc.
2124 Instead this routine is meant to handle the bit manipulations needed
2125 to insert the relocation into the given instruction. */
2127 static int
2128 elf_hppa_relocate_insn (insn, sym_value, r_type)
2129 int insn;
2130 int sym_value;
2131 unsigned int r_type;
2133 switch (r_type)
2135 /* This is any 22 bit branch. In PA2.0 syntax it corresponds to
2136 the "B" instruction. */
2137 case R_PARISC_PCREL22F:
2138 case R_PARISC_PCREL22C:
2139 return (insn & ~0x3ff1ffd) | re_assemble_22 (sym_value);
2141 /* This is any 12 bit branch. */
2142 case R_PARISC_PCREL12F:
2143 return (insn & ~0x1ffd) | re_assemble_12 (sym_value);
2145 /* This is any 17 bit branch. In PA2.0 syntax it also corresponds
2146 to the "B" instruction as well as BE. */
2147 case R_PARISC_PCREL17F:
2148 case R_PARISC_DIR17F:
2149 case R_PARISC_DIR17R:
2150 case R_PARISC_PCREL17C:
2151 case R_PARISC_PCREL17R:
2152 return (insn & ~0x1f1ffd) | re_assemble_17 (sym_value);
2154 /* ADDIL or LDIL instructions. */
2155 case R_PARISC_DLTREL21L:
2156 case R_PARISC_DLTIND21L:
2157 case R_PARISC_LTOFF_FPTR21L:
2158 case R_PARISC_PCREL21L:
2159 case R_PARISC_LTOFF_TP21L:
2160 case R_PARISC_DPREL21L:
2161 case R_PARISC_PLTOFF21L:
2162 case R_PARISC_DIR21L:
2163 return (insn & ~0x1fffff) | re_assemble_21 (sym_value);
2165 /* LDO and integer loads/stores with 14 bit displacements. */
2166 case R_PARISC_DLTREL14R:
2167 case R_PARISC_DLTREL14F:
2168 case R_PARISC_DLTIND14R:
2169 case R_PARISC_DLTIND14F:
2170 case R_PARISC_LTOFF_FPTR14R:
2171 case R_PARISC_PCREL14R:
2172 case R_PARISC_PCREL14F:
2173 case R_PARISC_LTOFF_TP14R:
2174 case R_PARISC_LTOFF_TP14F:
2175 case R_PARISC_DPREL14R:
2176 case R_PARISC_DPREL14F:
2177 case R_PARISC_PLTOFF14R:
2178 case R_PARISC_PLTOFF14F:
2179 case R_PARISC_DIR14R:
2180 case R_PARISC_DIR14F:
2181 return (insn & ~0x3fff) | low_sign_unext (sym_value, 14);
2183 /* PA2.0W LDO and integer loads/stores with 16 bit displacements. */
2184 case R_PARISC_LTOFF_FPTR16F:
2185 case R_PARISC_PCREL16F:
2186 case R_PARISC_LTOFF_TP16F:
2187 case R_PARISC_GPREL16F:
2188 case R_PARISC_PLTOFF16F:
2189 case R_PARISC_DIR16F:
2190 case R_PARISC_LTOFF16F:
2191 return (insn & ~0xffff) | re_assemble_16 (sym_value);
2193 /* Doubleword loads and stores with a 14 bit displacement. */
2194 case R_PARISC_DLTREL14DR:
2195 case R_PARISC_DLTIND14DR:
2196 case R_PARISC_LTOFF_FPTR14DR:
2197 case R_PARISC_LTOFF_FPTR16DF:
2198 case R_PARISC_PCREL14DR:
2199 case R_PARISC_PCREL16DF:
2200 case R_PARISC_LTOFF_TP14DR:
2201 case R_PARISC_LTOFF_TP16DF:
2202 case R_PARISC_DPREL14DR:
2203 case R_PARISC_GPREL16DF:
2204 case R_PARISC_PLTOFF14DR:
2205 case R_PARISC_PLTOFF16DF:
2206 case R_PARISC_DIR14DR:
2207 case R_PARISC_DIR16DF:
2208 case R_PARISC_LTOFF16DF:
2209 return (insn & ~0x3ff1) | (((sym_value & 0x2000) >> 13)
2210 | ((sym_value & 0x1ff8) << 1));
2212 /* Floating point single word load/store instructions. */
2213 case R_PARISC_DLTREL14WR:
2214 case R_PARISC_DLTIND14WR:
2215 case R_PARISC_LTOFF_FPTR14WR:
2216 case R_PARISC_LTOFF_FPTR16WF:
2217 case R_PARISC_PCREL14WR:
2218 case R_PARISC_PCREL16WF:
2219 case R_PARISC_LTOFF_TP14WR:
2220 case R_PARISC_LTOFF_TP16WF:
2221 case R_PARISC_DPREL14WR:
2222 case R_PARISC_GPREL16WF:
2223 case R_PARISC_PLTOFF14WR:
2224 case R_PARISC_PLTOFF16WF:
2225 case R_PARISC_DIR16WF:
2226 case R_PARISC_DIR14WR:
2227 case R_PARISC_LTOFF16WF:
2228 return (insn & ~0x3ff9) | (((sym_value & 0x2000) >> 13)
2229 | ((sym_value & 0x1ffc) << 1));
2231 default:
2232 return insn;
2235 #endif