Correct spelling of "relocatable".
[deliverable/binutils-gdb.git] / bfd / elf-hppa.h
CommitLineData
9e103c9c 1/* Common code for PA ELF implementations.
1049f94e 2 Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
9e103c9c
JL
3
4This file is part of BFD, the Binary File Descriptor library.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20#define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
21
2eb429af
JL
22/* This file is included by multiple PA ELF BFD backends with different
23 sizes.
24
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. */
9e103c9c
JL
28#if ARCH_SIZE == 64
29#define ELF_R_TYPE(X) ELF64_R_TYPE(X)
2eb429af 30#define ELF_R_SYM(X) ELF64_R_SYM(X)
189c6563 31#define elf_hppa_reloc_final_type elf64_hppa_reloc_final_type
9e103c9c 32#define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
2eb429af
JL
33#define elf_hppa_relocate_section elf64_hppa_relocate_section
34#define bfd_elf_bfd_final_link bfd_elf64_bfd_final_link
35#define elf_hppa_final_link elf64_hppa_final_link
9e103c9c
JL
36#endif
37#if ARCH_SIZE == 32
38#define ELF_R_TYPE(X) ELF32_R_TYPE(X)
2eb429af 39#define ELF_R_SYM(X) ELF32_R_SYM(X)
189c6563 40#define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type
9e103c9c 41#define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
2eb429af
JL
42#define elf_hppa_relocate_section elf32_hppa_relocate_section
43#define bfd_elf_bfd_final_link bfd_elf32_bfd_final_link
44#define elf_hppa_final_link elf32_hppa_final_link
9e103c9c
JL
45#endif
46
3f9b03b5
AM
47static void elf_hppa_info_to_howto
48 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
49
50static void elf_hppa_info_to_howto_rel
947216bf 51 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
3f9b03b5
AM
52
53static reloc_howto_type * elf_hppa_reloc_type_lookup
54 PARAMS ((bfd *, bfd_reloc_code_real_type));
2eb429af 55
b34976b6 56static bfd_boolean elf_hppa_is_local_label_name
3f9b03b5
AM
57 PARAMS ((bfd *, const char *));
58
b34976b6 59static bfd_boolean elf_hppa_fake_sections
947216bf 60 PARAMS ((bfd *abfd, Elf_Internal_Shdr *, asection *));
3f9b03b5 61
3f9b03b5 62static void elf_hppa_final_write_processing
b34976b6 63 PARAMS ((bfd *, bfd_boolean));
2eb429af 64
46fe4e66
AM
65static int hppa_unwind_entry_compare
66 PARAMS ((const PTR, const PTR));
67
b34976b6 68static bfd_boolean elf_hppa_sort_unwind
46fe4e66
AM
69 PARAMS ((bfd *));
70
49bd834c 71#if ARCH_SIZE == 64
b34976b6 72static bfd_boolean elf_hppa_add_symbol_hook
f273939b 73 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
2eb429af
JL
74 const char **, flagword *, asection **, bfd_vma *));
75
b34976b6 76static bfd_boolean elf_hppa_unmark_useless_dynamic_symbols
af7dc644
JL
77 PARAMS ((struct elf_link_hash_entry *, PTR));
78
b34976b6 79static bfd_boolean elf_hppa_remark_useless_dynamic_symbols
af7dc644
JL
80 PARAMS ((struct elf_link_hash_entry *, PTR));
81
b34976b6 82static bfd_boolean elf_hppa_is_dynamic_loader_symbol
1bf42538
JL
83 PARAMS ((const char *));
84
2ec0dd12
JL
85static void elf_hppa_record_segment_addrs
86 PARAMS ((bfd *, asection *, PTR));
87
b34976b6 88static bfd_boolean elf_hppa_final_link
3f9b03b5
AM
89 PARAMS ((bfd *, struct bfd_link_info *));
90
b34976b6 91static bfd_boolean elf_hppa_relocate_section
3f9b03b5 92 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
46fe4e66 93 bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
3f9b03b5
AM
94
95static bfd_reloc_status_type elf_hppa_final_link_relocate
96 PARAMS ((Elf_Internal_Rela *, bfd *, bfd *, asection *,
46fe4e66
AM
97 bfd_byte *, bfd_vma, struct bfd_link_info *,
98 asection *, struct elf_link_hash_entry *,
3f9b03b5
AM
99 struct elf64_hppa_dyn_hash_entry *));
100
dc810e39
AM
101static int elf_hppa_relocate_insn
102 PARAMS ((int, int, unsigned int));
3f9b03b5
AM
103#endif
104
9e103c9c
JL
105/* ELF/PA relocation howto entries. */
106
107static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
108{
b34976b6
AM
109 { R_PARISC_NONE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
110 bfd_elf_generic_reloc, "R_PARISC_NONE", FALSE, 0, 0, FALSE },
9e103c9c
JL
111
112 /* The values in DIR32 are to placate the check in
113 _bfd_stab_section_find_nearest_line. */
b34976b6
AM
114 { R_PARISC_DIR32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
115 bfd_elf_generic_reloc, "R_PARISC_DIR32", FALSE, 0, 0xffffffff, FALSE },
116 { R_PARISC_DIR21L, 0, 0, 21, FALSE, 0, complain_overflow_bitfield,
117 bfd_elf_generic_reloc, "R_PARISC_DIR21L", FALSE, 0, 0, FALSE },
118 { R_PARISC_DIR17R, 0, 0, 17, FALSE, 0, complain_overflow_bitfield,
119 bfd_elf_generic_reloc, "R_PARISC_DIR17R", FALSE, 0, 0, FALSE },
120 { R_PARISC_DIR17F, 0, 0, 17, FALSE, 0, complain_overflow_bitfield,
121 bfd_elf_generic_reloc, "R_PARISC_DIR17F", FALSE, 0, 0, FALSE },
122 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
123 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
124 { R_PARISC_DIR14R, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
125 bfd_elf_generic_reloc, "R_PARISC_DIR14R", FALSE, 0, 0, FALSE },
126 { R_PARISC_DIR14F, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
127 bfd_elf_generic_reloc, "R_PARISC_DIR14F", FALSE, 0, 0, FALSE },
49bd834c 128 /* 8 */
b34976b6
AM
129 { R_PARISC_PCREL12F, 0, 0, 12, TRUE, 0, complain_overflow_bitfield,
130 bfd_elf_generic_reloc, "R_PARISC_PCREL12F", FALSE, 0, 0, FALSE },
131 { R_PARISC_PCREL32, 0, 0, 32, TRUE, 0, complain_overflow_bitfield,
132 bfd_elf_generic_reloc, "R_PARISC_PCREL32", FALSE, 0, 0, FALSE },
133 { R_PARISC_PCREL21L, 0, 0, 21, TRUE, 0, complain_overflow_bitfield,
134 bfd_elf_generic_reloc, "R_PARISC_PCREL21L", FALSE, 0, 0, FALSE },
135 { R_PARISC_PCREL17R, 0, 0, 17, TRUE, 0, complain_overflow_bitfield,
136 bfd_elf_generic_reloc, "R_PARISC_PCREL17R", FALSE, 0, 0, FALSE },
137 { R_PARISC_PCREL17F, 0, 0, 17, TRUE, 0, complain_overflow_bitfield,
138 bfd_elf_generic_reloc, "R_PARISC_PCREL17F", FALSE, 0, 0, FALSE },
139 { R_PARISC_PCREL17C, 0, 0, 17, TRUE, 0, complain_overflow_bitfield,
140 bfd_elf_generic_reloc, "R_PARISC_PCREL17C", FALSE, 0, 0, FALSE },
141 { R_PARISC_PCREL14R, 0, 0, 14, TRUE, 0, complain_overflow_bitfield,
142 bfd_elf_generic_reloc, "R_PARISC_PCREL14R", FALSE, 0, 0, FALSE },
143 { R_PARISC_PCREL14F, 0, 0, 14, TRUE, 0, complain_overflow_bitfield,
144 bfd_elf_generic_reloc, "R_PARISC_PCREL14F", FALSE, 0, 0, FALSE },
49bd834c 145 /* 16 */
b34976b6
AM
146 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
147 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_DPREL21L, 0, 0, 21, FALSE, 0, complain_overflow_bitfield,
151 bfd_elf_generic_reloc, "R_PARISC_DPREL21L", FALSE, 0, 0, FALSE },
152 { R_PARISC_DPREL14WR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
153 bfd_elf_generic_reloc, "R_PARISC_DPREL14WR", FALSE, 0, 0, FALSE },
154 { R_PARISC_DPREL14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
155 bfd_elf_generic_reloc, "R_PARISC_DPREL14DR", FALSE, 0, 0, FALSE },
156 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
157 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
158 { R_PARISC_DPREL14R, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
159 bfd_elf_generic_reloc, "R_PARISC_DPREL14R", FALSE, 0, 0, FALSE },
160 { R_PARISC_DPREL14F, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
161 bfd_elf_generic_reloc, "R_PARISC_DPREL14F", FALSE, 0, 0, FALSE },
49bd834c 162 /* 24 */
b34976b6
AM
163 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
164 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_DLTREL21L, 0, 0, 21, FALSE, 0, complain_overflow_bitfield,
168 bfd_elf_generic_reloc, "R_PARISC_DLTREL21L", FALSE, 0, 0, FALSE },
169 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
170 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_DLTREL14R, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
176 bfd_elf_generic_reloc, "R_PARISC_DLTREL14R", FALSE, 0, 0, FALSE },
177 { R_PARISC_DLTREL14F, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
178 bfd_elf_generic_reloc, "R_PARISC_DLTREL14F", FALSE, 0, 0, FALSE },
49bd834c 179 /* 32 */
b34976b6
AM
180 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
181 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_DLTIND21L, 0, 0, 21, FALSE, 0, complain_overflow_bitfield,
185 bfd_elf_generic_reloc, "R_PARISC_DLTIND21L", FALSE, 0, 0, FALSE },
186 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
187 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_DLTIND14R, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
193 bfd_elf_generic_reloc, "R_PARISC_DLTIND14R", FALSE, 0, 0, FALSE },
194 { R_PARISC_DLTIND14F, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
195 bfd_elf_generic_reloc, "R_PARISC_DLTIND14F", FALSE, 0, 0, FALSE },
49bd834c 196 /* 40 */
b34976b6
AM
197 { R_PARISC_SETBASE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
198 bfd_elf_generic_reloc, "R_PARISC_SETBASE", FALSE, 0, 0, FALSE },
199 { R_PARISC_SECREL32, 0, 0, 32, FALSE, 0, complain_overflow_bitfield,
200 bfd_elf_generic_reloc, "R_PARISC_SECREL32", FALSE, 0, 0, FALSE },
201 { R_PARISC_BASEREL21L, 0, 0, 21, FALSE, 0, complain_overflow_bitfield,
202 bfd_elf_generic_reloc, "R_PARISC_BASEREL21L", FALSE, 0, 0, FALSE },
203 { R_PARISC_BASEREL17R, 0, 0, 17, FALSE, 0, complain_overflow_bitfield,
204 bfd_elf_generic_reloc, "R_PARISC_BASEREL17R", FALSE, 0, 0, FALSE },
205 { R_PARISC_BASEREL17F, 0, 0, 17, FALSE, 0, complain_overflow_bitfield,
206 bfd_elf_generic_reloc, "R_PARISC_BASEREL17F", FALSE, 0, 0, FALSE },
207 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
208 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
209 { R_PARISC_BASEREL14R, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
210 bfd_elf_generic_reloc, "R_PARISC_BASEREL14R", FALSE, 0, 0, FALSE },
211 { R_PARISC_BASEREL14F, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
212 bfd_elf_generic_reloc, "R_PARISC_BASEREL14F", FALSE, 0, 0, FALSE },
49bd834c 213 /* 48 */
b34976b6
AM
214 { R_PARISC_SEGBASE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
215 bfd_elf_generic_reloc, "R_PARISC_SEGBASE", FALSE, 0, 0, FALSE },
216 { R_PARISC_SEGREL32, 0, 0, 32, FALSE, 0, complain_overflow_bitfield,
217 bfd_elf_generic_reloc, "R_PARISC_SEGREL32", FALSE, 0, 0, FALSE },
218 { R_PARISC_PLTOFF21L, 0, 0, 21, FALSE, 0, complain_overflow_bitfield,
219 bfd_elf_generic_reloc, "R_PARISC_PLTOFF21L", FALSE, 0, 0, FALSE },
220 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
221 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_PLTOFF14R, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
227 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14R", FALSE, 0, 0, FALSE },
228 { R_PARISC_PLTOFF14F, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
229 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14F", FALSE, 0, 0, FALSE },
49bd834c 230 /* 56 */
b34976b6
AM
231 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
232 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
233 { R_PARISC_LTOFF_FPTR32, 0, 0, 32, FALSE, 0, complain_overflow_bitfield,
234 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR32", FALSE, 0, 0, FALSE },
235 { R_PARISC_LTOFF_FPTR21L, 0, 0, 21, FALSE, 0, complain_overflow_bitfield,
236 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR21L", FALSE, 0, 0, FALSE },
237 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
238 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_LTOFF_FPTR14R, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
244 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14R", FALSE, 0, 0, FALSE },
245 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
246 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 247 /* 64 */
b34976b6
AM
248 { R_PARISC_FPTR64, 0, 0, 64, FALSE, 0, complain_overflow_bitfield,
249 bfd_elf_generic_reloc, "R_PARISC_FPTR64", FALSE, 0, 0, FALSE },
250 { R_PARISC_PLABEL32, 0, 0, 32, FALSE, 0, complain_overflow_bitfield,
251 bfd_elf_generic_reloc, "R_PARISC_PLABEL32", FALSE, 0, 0, FALSE },
252 { R_PARISC_PLABEL21L, 0, 0, 21, FALSE, 0, complain_overflow_bitfield,
253 bfd_elf_generic_reloc, "R_PARISC_PLABEL21L", FALSE, 0, 0, FALSE },
254 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
255 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_PLABEL14R, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
261 bfd_elf_generic_reloc, "R_PARISC_PLABEL14R", FALSE, 0, 0, FALSE },
262 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
263 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 264 /* 72 */
b34976b6
AM
265 { R_PARISC_PCREL64, 0, 0, 64, FALSE, 0, complain_overflow_bitfield,
266 bfd_elf_generic_reloc, "R_PARISC_PCREL64", FALSE, 0, 0, FALSE },
267 { R_PARISC_PCREL22C, 0, 0, 22, FALSE, 0, complain_overflow_bitfield,
268 bfd_elf_generic_reloc, "R_PARISC_PCREL22C", FALSE, 0, 0, FALSE },
269 { R_PARISC_PCREL22F, 0, 0, 22, FALSE, 0, complain_overflow_bitfield,
270 bfd_elf_generic_reloc, "R_PARISC_PCREL22F", FALSE, 0, 0, FALSE },
271 { R_PARISC_PCREL14WR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
272 bfd_elf_generic_reloc, "R_PARISC_PCREL14WR", FALSE, 0, 0, FALSE },
273 { R_PARISC_PCREL14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
274 bfd_elf_generic_reloc, "R_PARISC_PCREL14DR", FALSE, 0, 0, FALSE },
275 { R_PARISC_PCREL16F, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
276 bfd_elf_generic_reloc, "R_PARISC_PCREL16F", FALSE, 0, 0, FALSE },
277 { R_PARISC_PCREL16WF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
278 bfd_elf_generic_reloc, "R_PARISC_PCREL16WF", FALSE, 0, 0, FALSE },
279 { R_PARISC_PCREL16DF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
280 bfd_elf_generic_reloc, "R_PARISC_PCREL16DF", FALSE, 0, 0, FALSE },
49bd834c 281 /* 80 */
b34976b6
AM
282 { R_PARISC_DIR64, 0, 0, 64, FALSE, 0, complain_overflow_bitfield,
283 bfd_elf_generic_reloc, "R_PARISC_DIR64", FALSE, 0, 0, FALSE },
284 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
285 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_DIR14WR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
289 bfd_elf_generic_reloc, "R_PARISC_DIR14WR", FALSE, 0, 0, FALSE },
290 { R_PARISC_DIR14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
291 bfd_elf_generic_reloc, "R_PARISC_DIR14DR", FALSE, 0, 0, FALSE },
292 { R_PARISC_DIR16F, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
293 bfd_elf_generic_reloc, "R_PARISC_DIR16F", FALSE, 0, 0, FALSE },
294 { R_PARISC_DIR16WF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
295 bfd_elf_generic_reloc, "R_PARISC_DIR16WF", FALSE, 0, 0, FALSE },
296 { R_PARISC_DIR16DF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
297 bfd_elf_generic_reloc, "R_PARISC_DIR16DF", FALSE, 0, 0, FALSE },
49bd834c 298 /* 88 */
b34976b6
AM
299 { R_PARISC_GPREL64, 0, 0, 64, FALSE, 0, complain_overflow_bitfield,
300 bfd_elf_generic_reloc, "R_PARISC_GPREL64", FALSE, 0, 0, FALSE },
301 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
302 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_DLTREL14WR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
306 bfd_elf_generic_reloc, "R_PARISC_DLTREL14WR", FALSE, 0, 0, FALSE },
307 { R_PARISC_DLTREL14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
308 bfd_elf_generic_reloc, "R_PARISC_DLTREL14DR", FALSE, 0, 0, FALSE },
309 { R_PARISC_GPREL16F, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
310 bfd_elf_generic_reloc, "R_PARISC_GPREL16F", FALSE, 0, 0, FALSE },
311 { R_PARISC_GPREL16WF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
312 bfd_elf_generic_reloc, "R_PARISC_GPREL16WF", FALSE, 0, 0, FALSE },
313 { R_PARISC_GPREL16DF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
314 bfd_elf_generic_reloc, "R_PARISC_GPREL16DF", FALSE, 0, 0, FALSE },
49bd834c 315 /* 96 */
b34976b6
AM
316 { R_PARISC_LTOFF64, 0, 0, 64, FALSE, 0, complain_overflow_bitfield,
317 bfd_elf_generic_reloc, "R_PARISC_LTOFF64", FALSE, 0, 0, FALSE },
318 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
319 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_DLTIND14WR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
323 bfd_elf_generic_reloc, "R_PARISC_DLTIND14WR", FALSE, 0, 0, FALSE },
324 { R_PARISC_DLTIND14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
325 bfd_elf_generic_reloc, "R_PARISC_DLTIND14DR", FALSE, 0, 0, FALSE },
326 { R_PARISC_LTOFF16F, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
327 bfd_elf_generic_reloc, "R_PARISC_LTOFF16F", FALSE, 0, 0, FALSE },
328 { R_PARISC_LTOFF16WF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
329 bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF", FALSE, 0, 0, FALSE },
330 { R_PARISC_LTOFF16DF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
331 bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF", FALSE, 0, 0, FALSE },
49bd834c 332 /* 104 */
b34976b6
AM
333 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
334 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_BASEREL14WR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
338 bfd_elf_generic_reloc, "R_PARISC_BASEREL14WR", FALSE, 0, 0, FALSE },
339 { R_PARISC_BASEREL14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
340 bfd_elf_generic_reloc, "R_PARISC_BASEREL14DR", FALSE, 0, 0, FALSE },
341 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
342 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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 },
49bd834c 349 /* 112 */
b34976b6
AM
350 { R_PARISC_SEGREL64, 0, 0, 64, FALSE, 0, complain_overflow_bitfield,
351 bfd_elf_generic_reloc, "R_PARISC_SEGREL64", FALSE, 0, 0, FALSE },
352 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
353 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_PLTOFF14WR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
357 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14WR", FALSE, 0, 0, FALSE },
358 { R_PARISC_PLTOFF14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
359 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14DR", FALSE, 0, 0, FALSE },
360 { R_PARISC_PLTOFF16F, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
361 bfd_elf_generic_reloc, "R_PARISC_PLTOFF16F", FALSE, 0, 0, FALSE },
362 { R_PARISC_PLTOFF16WF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
363 bfd_elf_generic_reloc, "R_PARISC_PLTOFF16WF", FALSE, 0, 0, FALSE },
364 { R_PARISC_PLTOFF16DF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
365 bfd_elf_generic_reloc, "R_PARISC_PLTOFF16DF", FALSE, 0, 0, FALSE },
49bd834c 366 /* 120 */
b34976b6
AM
367 { R_PARISC_LTOFF_FPTR64, 0, 0, 64, FALSE, 0, complain_overflow_bitfield,
368 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
369 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, 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_LTOFF_FPTR14WR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
374 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14WR", FALSE, 0, 0, FALSE },
375 { R_PARISC_LTOFF_FPTR14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
376 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14DR", FALSE, 0, 0, FALSE },
377 { R_PARISC_LTOFF_FPTR16F, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
378 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16F", FALSE, 0, 0, FALSE },
379 { R_PARISC_LTOFF_FPTR16WF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
380 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16WF", FALSE, 0, 0, FALSE },
381 { R_PARISC_LTOFF_FPTR16DF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
382 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 383 /* 128 */
b34976b6
AM
384 { R_PARISC_COPY, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
385 bfd_elf_generic_reloc, "R_PARISC_COPY", FALSE, 0, 0, FALSE },
386 { R_PARISC_IPLT, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
387 bfd_elf_generic_reloc, "R_PARISC_IPLT", FALSE, 0, 0, FALSE },
388 { R_PARISC_EPLT, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
389 bfd_elf_generic_reloc, "R_PARISC_EPLT", FALSE, 0, 0, FALSE },
390 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
391 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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 },
49bd834c 400 /* 136 */
b34976b6
AM
401 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
402 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
403 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
404 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
405 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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_dont,
410 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
411 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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 },
49bd834c 417 /* 144 */
b34976b6
AM
418 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
419 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_dont,
425 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
426 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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_dont,
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 },
49bd834c 434 /* 152 */
b34976b6
AM
435 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
436 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
437 { R_PARISC_TPREL32, 0, 0, 32, FALSE, 0, complain_overflow_dont,
438 bfd_elf_generic_reloc, "R_PARISC_TPREL32", FALSE, 0, 0, FALSE },
439 { R_PARISC_TPREL21L, 0, 0, 21, FALSE, 0, complain_overflow_dont,
440 bfd_elf_generic_reloc, "R_PARISC_TPREL21L", FALSE, 0, 0, FALSE },
441 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
442 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_TPREL14R, 0, 0, 14, FALSE, 0, complain_overflow_dont,
448 bfd_elf_generic_reloc, "R_PARISC_TPREL14R", FALSE, 0, 0, FALSE },
449 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
450 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 451 /* 160 */
b34976b6
AM
452 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
453 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_LTOFF_TP21L, 0, 0, 21, FALSE, 0, complain_overflow_bitfield,
457 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP21L", FALSE, 0, 0, FALSE },
458 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
459 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
460 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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_LTOFF_TP14R, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
465 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
466 { R_PARISC_LTOFF_TP14F, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
467 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14F", FALSE, 0, 0, FALSE },
49bd834c 468 /* 168 */
b34976b6
AM
469 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
470 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_dont,
476 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
477 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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 },
49bd834c 485 /* 176 */
b34976b6
AM
486 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
487 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_dont,
491 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
492 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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_dont,
497 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
498 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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 },
49bd834c 502 /* 184 */
b34976b6
AM
503 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
504 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_dont,
512 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
513 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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_dont,
518 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 519 /* 192 */
b34976b6
AM
520 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
521 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
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_dont,
533 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
534 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
535 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 536 /* 200 */
b34976b6
AM
537 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
538 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
539 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
540 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
541 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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 },
49bd834c 553 /* 208 */
b34976b6
AM
554 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
555 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
556 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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_dont,
563 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
564 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
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 },
49bd834c 570 /* 216 */
b34976b6
AM
571 { R_PARISC_TPREL64, 0, 0, 64, FALSE, 0, complain_overflow_bitfield,
572 bfd_elf_generic_reloc, "R_PARISC_TPREL64", FALSE, 0, 0, FALSE },
573 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
574 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_TPREL14WR, 0, 0, 14, FALSE, 0, complain_overflow_dont,
578 bfd_elf_generic_reloc, "R_PARISC_TPREL14WR", FALSE, 0, 0, FALSE },
579 { R_PARISC_TPREL14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
580 bfd_elf_generic_reloc, "R_PARISC_TPREL14DR", FALSE, 0, 0, FALSE },
581 { R_PARISC_TPREL16F, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
582 bfd_elf_generic_reloc, "R_PARISC_TPREL16F", FALSE, 0, 0, FALSE },
583 { R_PARISC_TPREL16WF, 0, 0, 16, FALSE, 0, complain_overflow_dont,
584 bfd_elf_generic_reloc, "R_PARISC_TPREL16WF", FALSE, 0, 0, FALSE },
585 { R_PARISC_TPREL16DF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
586 bfd_elf_generic_reloc, "R_PARISC_TPREL16DF", FALSE, 0, 0, FALSE },
49bd834c 587 /* 224 */
b34976b6
AM
588 { R_PARISC_LTOFF_TP64, 0, 0, 64, FALSE, 0, complain_overflow_bitfield,
589 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP64", FALSE, 0, 0, FALSE },
590 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
591 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", 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_LTOFF_TP14WR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
595 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14WR", FALSE, 0, 0, FALSE },
596 { R_PARISC_LTOFF_TP14DR, 0, 0, 14, FALSE, 0, complain_overflow_bitfield,
597 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14DR", FALSE, 0, 0, FALSE },
598 { R_PARISC_LTOFF_TP16F, 0, 0, 16, FALSE, 0, complain_overflow_dont,
599 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16F", FALSE, 0, 0, FALSE },
600 { R_PARISC_LTOFF_TP16WF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
601 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16WF", FALSE, 0, 0, FALSE },
602 { R_PARISC_LTOFF_TP16DF, 0, 0, 16, FALSE, 0, complain_overflow_bitfield,
603 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16DF", FALSE, 0, 0, FALSE },
49bd834c 604 /* 232 */
b34976b6
AM
605 { R_PARISC_GNU_VTENTRY, 0, 0, 0, FALSE, 0, complain_overflow_dont,
606 bfd_elf_generic_reloc, "R_PARISC_GNU_VTENTRY", FALSE, 0, 0, FALSE },
607 { R_PARISC_GNU_VTINHERIT, 0, 0, 0, FALSE, 0, complain_overflow_dont,
608 bfd_elf_generic_reloc, "R_PARISC_GNU_VTINHERIT", FALSE, 0, 0, FALSE },
9e103c9c
JL
609};
610
6e2bf930
JL
611#define OFFSET_14R_FROM_21L 4
612#define OFFSET_14F_FROM_21L 5
613
189c6563
AM
614/* Return the final relocation type for the given base type, instruction
615 format, and field selector. */
9e103c9c 616
189c6563
AM
617elf_hppa_reloc_type
618elf_hppa_reloc_final_type (abfd, base_type, format, field)
9e103c9c
JL
619 bfd *abfd;
620 elf_hppa_reloc_type base_type;
621 int format;
edd21aca 622 unsigned int field;
9e103c9c 623{
189c6563 624 elf_hppa_reloc_type final_type = base_type;
9e103c9c
JL
625
626 /* Just a tangle of nested switch statements to deal with the braindamage
627 that a different field selector means a completely different relocation
628 for PA ELF. */
629 switch (base_type)
630 {
0d571602
JL
631 /* We have been using generic relocation types. However, that may not
632 really make sense. Anyway, we need to support both R_PARISC_DIR64
633 and R_PARISC_DIR32 here. */
634 case R_PARISC_DIR32:
635 case R_PARISC_DIR64:
9e103c9c
JL
636 case R_HPPA_ABS_CALL:
637 switch (format)
638 {
639 case 14:
640 switch (field)
641 {
47d89dba
AM
642 case e_fsel:
643 final_type = R_PARISC_DIR14F;
644 break;
9e103c9c
JL
645 case e_rsel:
646 case e_rrsel:
47d89dba 647 case e_rdsel:
9e103c9c
JL
648 final_type = R_PARISC_DIR14R;
649 break;
650 case e_rtsel:
f31cedf7 651 final_type = R_PARISC_DLTIND14R;
9e103c9c 652 break;
36860900
JL
653 case e_rtpsel:
654 final_type = R_PARISC_LTOFF_FPTR14DR;
655 break;
9e103c9c 656 case e_tsel:
f31cedf7 657 final_type = R_PARISC_DLTIND14F;
9e103c9c
JL
658 break;
659 case e_rpsel:
660 final_type = R_PARISC_PLABEL14R;
661 break;
662 default:
189c6563 663 return R_PARISC_NONE;
9e103c9c
JL
664 }
665 break;
666
667 case 17:
668 switch (field)
669 {
670 case e_fsel:
671 final_type = R_PARISC_DIR17F;
672 break;
673 case e_rsel:
674 case e_rrsel:
47d89dba 675 case e_rdsel:
9e103c9c
JL
676 final_type = R_PARISC_DIR17R;
677 break;
678 default:
189c6563 679 return R_PARISC_NONE;
9e103c9c
JL
680 }
681 break;
682
683 case 21:
684 switch (field)
685 {
686 case e_lsel:
687 case e_lrsel:
47d89dba 688 case e_ldsel:
edd21aca
AM
689 case e_nlsel:
690 case e_nlrsel:
9e103c9c
JL
691 final_type = R_PARISC_DIR21L;
692 break;
693 case e_ltsel:
f31cedf7 694 final_type = R_PARISC_DLTIND21L;
9e103c9c 695 break;
36860900
JL
696 case e_ltpsel:
697 final_type = R_PARISC_LTOFF_FPTR21L;
698 break;
9e103c9c
JL
699 case e_lpsel:
700 final_type = R_PARISC_PLABEL21L;
701 break;
702 default:
189c6563 703 return R_PARISC_NONE;
9e103c9c
JL
704 }
705 break;
706
707 case 32:
708 switch (field)
709 {
710 case e_fsel:
711 final_type = R_PARISC_DIR32;
432bdd91
JL
712 /* When in 64bit mode, a 32bit relocation is supposed to
713 be a section relative relocation. Dwarf2 (for example)
714 uses 32bit section relative relocations. */
715 if (bfd_get_arch_info (abfd)->bits_per_address != 32)
46fe4e66 716 final_type = R_PARISC_SECREL32;
9e103c9c
JL
717 break;
718 case e_psel:
719 final_type = R_PARISC_PLABEL32;
720 break;
721 default:
189c6563 722 return R_PARISC_NONE;
9e103c9c
JL
723 }
724 break;
725
6e2bf930
JL
726 case 64:
727 switch (field)
728 {
729 case e_fsel:
730 final_type = R_PARISC_DIR64;
731 break;
732 case e_psel:
36860900
JL
733 final_type = R_PARISC_FPTR64;
734 break;
6e2bf930 735 default:
189c6563 736 return R_PARISC_NONE;
6e2bf930
JL
737 }
738 break;
739
9e103c9c 740 default:
189c6563 741 return R_PARISC_NONE;
9e103c9c
JL
742 }
743 break;
744
9e103c9c
JL
745 case R_HPPA_GOTOFF:
746 switch (format)
747 {
748 case 14:
749 switch (field)
750 {
751 case e_rsel:
752 case e_rrsel:
47d89dba 753 case e_rdsel:
edd21aca 754 /* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32 */
6e2bf930 755 final_type = base_type + OFFSET_14R_FROM_21L;
9e103c9c
JL
756 break;
757 case e_fsel:
edd21aca 758 /* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32 */
6e2bf930 759 final_type = base_type + OFFSET_14F_FROM_21L;
9e103c9c
JL
760 break;
761 default:
189c6563 762 return R_PARISC_NONE;
9e103c9c
JL
763 }
764 break;
765
766 case 21:
767 switch (field)
768 {
9e103c9c 769 case e_lsel:
edd21aca 770 case e_lrsel:
47d89dba 771 case e_ldsel:
edd21aca
AM
772 case e_nlsel:
773 case e_nlrsel:
774 /* R_PARISC_DLTREL21L for elf64, R_PARISC_DPREL21L for elf32 */
6e2bf930 775 final_type = base_type;
9e103c9c
JL
776 break;
777 default:
189c6563 778 return R_PARISC_NONE;
9e103c9c
JL
779 }
780 break;
781
782 default:
189c6563 783 return R_PARISC_NONE;
9e103c9c
JL
784 }
785 break;
786
9e103c9c
JL
787 case R_HPPA_PCREL_CALL:
788 switch (format)
789 {
49bd834c
AM
790 case 12:
791 switch (field)
792 {
793 case e_fsel:
794 final_type = R_PARISC_PCREL12F;
795 break;
796 default:
189c6563 797 return R_PARISC_NONE;
49bd834c
AM
798 }
799 break;
800
9e103c9c 801 case 14:
49bd834c
AM
802 /* Contrary to appearances, these are not calls of any sort.
803 Rather, they are loads/stores with a pcrel reloc. */
9e103c9c
JL
804 switch (field)
805 {
806 case e_rsel:
807 case e_rrsel:
47d89dba 808 case e_rdsel:
9e103c9c
JL
809 final_type = R_PARISC_PCREL14R;
810 break;
811 case e_fsel:
ba94744e
AM
812 if (bfd_get_mach (abfd) < 25)
813 final_type = R_PARISC_PCREL14F;
814 else
815 final_type = R_PARISC_PCREL16F;
9e103c9c
JL
816 break;
817 default:
189c6563 818 return R_PARISC_NONE;
9e103c9c
JL
819 }
820 break;
821
822 case 17:
823 switch (field)
824 {
825 case e_rsel:
826 case e_rrsel:
47d89dba 827 case e_rdsel:
9e103c9c
JL
828 final_type = R_PARISC_PCREL17R;
829 break;
830 case e_fsel:
831 final_type = R_PARISC_PCREL17F;
832 break;
833 default:
189c6563 834 return R_PARISC_NONE;
9e103c9c
JL
835 }
836 break;
837
edd21aca 838 case 21:
341362b5
JL
839 switch (field)
840 {
edd21aca
AM
841 case e_lsel:
842 case e_lrsel:
47d89dba 843 case e_ldsel:
edd21aca
AM
844 case e_nlsel:
845 case e_nlrsel:
846 final_type = R_PARISC_PCREL21L;
341362b5
JL
847 break;
848 default:
189c6563 849 return R_PARISC_NONE;
341362b5
JL
850 }
851 break;
852
edd21aca 853 case 22:
9e103c9c
JL
854 switch (field)
855 {
edd21aca
AM
856 case e_fsel:
857 final_type = R_PARISC_PCREL22F;
9e103c9c
JL
858 break;
859 default:
189c6563 860 return R_PARISC_NONE;
9e103c9c
JL
861 }
862 break;
863
864 default:
189c6563 865 return R_PARISC_NONE;
9e103c9c
JL
866 }
867 break;
868
49bd834c
AM
869 case R_PARISC_GNU_VTENTRY:
870 case R_PARISC_GNU_VTINHERIT:
fc91f658
JL
871 case R_PARISC_SEGREL32:
872 case R_PARISC_SEGBASE:
873 /* The defaults are fine for these cases. */
874 break;
875
9e103c9c 876 default:
189c6563 877 return R_PARISC_NONE;
9e103c9c
JL
878 }
879
189c6563
AM
880 return final_type;
881}
882
883/* Return one (or more) BFD relocations which implement the base
884 relocation with modifications based on format and field. */
885
886elf_hppa_reloc_type **
887_bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
888 bfd *abfd;
889 elf_hppa_reloc_type base_type;
890 int format;
891 unsigned int field;
892 int ignore ATTRIBUTE_UNUSED;
893 asymbol *sym ATTRIBUTE_UNUSED;
894{
895 elf_hppa_reloc_type *finaltype;
896 elf_hppa_reloc_type **final_types;
897 bfd_size_type amt = sizeof (elf_hppa_reloc_type *) * 2;
898
899 /* Allocate slots for the BFD relocation. */
900 final_types = (elf_hppa_reloc_type **) bfd_alloc (abfd, amt);
901 if (final_types == NULL)
902 return NULL;
903
904 /* Allocate space for the relocation itself. */
905 amt = sizeof (elf_hppa_reloc_type);
906 finaltype = (elf_hppa_reloc_type *) bfd_alloc (abfd, amt);
907 if (finaltype == NULL)
908 return NULL;
909
910 /* Some reasonable defaults. */
911 final_types[0] = finaltype;
912 final_types[1] = NULL;
913
914 *finaltype = elf_hppa_reloc_final_type (abfd, base_type, format, field);
915
9e103c9c
JL
916 return final_types;
917}
918
919/* Translate from an elf into field into a howto relocation pointer. */
920
921static void
922elf_hppa_info_to_howto (abfd, bfd_reloc, elf_reloc)
3f9b03b5 923 bfd *abfd ATTRIBUTE_UNUSED;
9e103c9c
JL
924 arelent *bfd_reloc;
925 Elf_Internal_Rela *elf_reloc;
926{
927 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
928 < (unsigned int) R_PARISC_UNIMPLEMENTED);
929 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
930}
931
932/* Translate from an elf into field into a howto relocation pointer. */
933
934static void
935elf_hppa_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
3f9b03b5 936 bfd *abfd ATTRIBUTE_UNUSED;
9e103c9c 937 arelent *bfd_reloc;
947216bf 938 Elf_Internal_Rela *elf_reloc;
9e103c9c
JL
939{
940 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
941 < (unsigned int) R_PARISC_UNIMPLEMENTED);
942 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
943}
944
945/* Return the address of the howto table entry to perform the CODE
946 relocation for an ARCH machine. */
947
948static reloc_howto_type *
949elf_hppa_reloc_type_lookup (abfd, code)
3f9b03b5 950 bfd *abfd ATTRIBUTE_UNUSED;
9e103c9c
JL
951 bfd_reloc_code_real_type code;
952{
953 if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
954 {
955 BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
956 return &elf_hppa_howto_table[(int) code];
957 }
958 return NULL;
959}
95cbae0b 960
b34976b6 961/* Return TRUE if SYM represents a local label symbol. */
432bdd91 962
b34976b6 963static bfd_boolean
432bdd91
JL
964elf_hppa_is_local_label_name (abfd, name)
965 bfd *abfd ATTRIBUTE_UNUSED;
966 const char *name;
967{
49bd834c
AM
968 if (name[0] == 'L' && name[1] == '$')
969 return 1;
970 return _bfd_elf_is_local_label_name (abfd, name);
432bdd91
JL
971}
972
052e120f
JL
973/* Set the correct type for an ELF section. We do this by the
974 section name, which is a hack, but ought to work. */
975
b34976b6 976static bfd_boolean
052e120f
JL
977elf_hppa_fake_sections (abfd, hdr, sec)
978 bfd *abfd;
947216bf 979 Elf_Internal_Shdr *hdr;
052e120f
JL
980 asection *sec;
981{
982 register const char *name;
983
984 name = bfd_get_section_name (abfd, sec);
985
986 if (strcmp (name, ".PARISC.unwind") == 0)
987 {
1ca74062 988 int indx;
edd21aca 989 asection *asec;
3f9b03b5 990#if ARCH_SIZE == 64
052e120f 991 hdr->sh_type = SHT_LOPROC + 1;
3f9b03b5
AM
992#else
993 hdr->sh_type = 1;
994#endif
052e120f
JL
995 /* ?!? How are unwinds supposed to work for symbols in arbitrary
996 sections? Or what if we have multiple .text sections in a single
be7582f3 997 .o file? HP really messed up on this one.
052e120f 998
1ca74062
JL
999 Ugh. We can not use elf_section_data (sec)->this_idx at this
1000 point because it is not initialized yet.
1001
1002 So we (gasp) recompute it here. Hopefully nobody ever changes the
1003 way sections are numbered in elf.c! */
edd21aca 1004 for (asec = abfd->sections, indx = 1; asec; asec = asec->next, indx++)
1ca74062 1005 {
edd21aca 1006 if (asec->name && strcmp (asec->name, ".text") == 0)
1ca74062
JL
1007 {
1008 hdr->sh_info = indx;
1009 break;
1010 }
1011 }
be7582f3 1012
052e120f
JL
1013 /* I have no idea if this is really necessary or what it means. */
1014 hdr->sh_entsize = 4;
1015 }
b34976b6 1016 return TRUE;
052e120f
JL
1017}
1018
3f9b03b5
AM
1019static void
1020elf_hppa_final_write_processing (abfd, linker)
1021 bfd *abfd;
b34976b6 1022 bfd_boolean linker ATTRIBUTE_UNUSED;
3f9b03b5
AM
1023{
1024 int mach = bfd_get_mach (abfd);
1025
1026 elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL
1027 | EF_PARISC_EXT | EF_PARISC_LSB
1028 | EF_PARISC_WIDE | EF_PARISC_NO_KABP
1029 | EF_PARISC_LAZYSWAP);
1030
1031 if (mach == 10)
1032 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0;
1033 else if (mach == 11)
1034 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1;
1035 else if (mach == 20)
1036 elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0;
1037 else if (mach == 25)
1038 elf_elfheader (abfd)->e_flags |= (EF_PARISC_WIDE
1039 | EFA_PARISC_2_0
1040 /* The GNU tools have trapped without
1041 option since 1993, so need to take
1042 a step backwards with the ELF
1043 based toolchains. */
1044 | EF_PARISC_TRAPNIL);
1045}
1046
46fe4e66
AM
1047/* Comparison function for qsort to sort unwind section during a
1048 final link. */
1049
1050static int
1051hppa_unwind_entry_compare (a, b)
1052 const PTR a;
1053 const PTR b;
1054{
1055 const bfd_byte *ap, *bp;
1056 unsigned long av, bv;
1057
1058 ap = (const bfd_byte *) a;
1059 av = (unsigned long) ap[0] << 24;
1060 av |= (unsigned long) ap[1] << 16;
1061 av |= (unsigned long) ap[2] << 8;
1062 av |= (unsigned long) ap[3];
1063
1064 bp = (const bfd_byte *) b;
1065 bv = (unsigned long) bp[0] << 24;
1066 bv |= (unsigned long) bp[1] << 16;
1067 bv |= (unsigned long) bp[2] << 8;
1068 bv |= (unsigned long) bp[3];
1069
1070 return av < bv ? -1 : av > bv ? 1 : 0;
1071}
1072
b34976b6 1073static bfd_boolean elf_hppa_sort_unwind (abfd)
46fe4e66
AM
1074 bfd *abfd;
1075{
1076 asection *s;
1077
1078 /* Magic section names, but this is much safer than having
1079 relocate_section remember where SEGREL32 relocs occurred.
1080 Consider what happens if someone inept creates a linker script
1081 that puts unwind information in .text. */
1082 s = bfd_get_section_by_name (abfd, ".PARISC.unwind");
1083 if (s != NULL)
1084 {
1085 bfd_size_type size;
1086 char *contents;
1087
1088 size = s->_raw_size;
1089 contents = bfd_malloc (size);
1090 if (contents == NULL)
b34976b6 1091 return FALSE;
46fe4e66
AM
1092
1093 if (! bfd_get_section_contents (abfd, s, contents, (file_ptr) 0, size))
b34976b6 1094 return FALSE;
46fe4e66
AM
1095
1096 qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare);
1097
1098 if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size))
b34976b6 1099 return FALSE;
46fe4e66
AM
1100 }
1101
b34976b6 1102 return TRUE;
46fe4e66
AM
1103}
1104
49bd834c 1105#if ARCH_SIZE == 64
2eb429af
JL
1106/* Hook called by the linker routine which adds symbols from an object
1107 file. HP's libraries define symbols with HP specific section
1108 indices, which we have to handle. */
1109
b34976b6 1110static bfd_boolean
2eb429af
JL
1111elf_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
1112 bfd *abfd;
1113 struct bfd_link_info *info ATTRIBUTE_UNUSED;
1114 const Elf_Internal_Sym *sym;
1115 const char **namep ATTRIBUTE_UNUSED;
1116 flagword *flagsp ATTRIBUTE_UNUSED;
1117 asection **secp;
1118 bfd_vma *valp;
1119{
1120 int index = sym->st_shndx;
be7582f3 1121
2eb429af
JL
1122 switch (index)
1123 {
1124 case SHN_PARISC_ANSI_COMMON:
1125 *secp = bfd_make_section_old_way (abfd, ".PARISC.ansi.common");
1126 (*secp)->flags |= SEC_IS_COMMON;
1127 *valp = sym->st_size;
1128 break;
be7582f3 1129
2eb429af
JL
1130 case SHN_PARISC_HUGE_COMMON:
1131 *secp = bfd_make_section_old_way (abfd, ".PARISC.huge.common");
1132 (*secp)->flags |= SEC_IS_COMMON;
1133 *valp = sym->st_size;
1134 break;
1135 }
1136
b34976b6 1137 return TRUE;
2eb429af
JL
1138}
1139
b34976b6 1140static bfd_boolean
af7dc644
JL
1141elf_hppa_unmark_useless_dynamic_symbols (h, data)
1142 struct elf_link_hash_entry *h;
1143 PTR data;
1144{
1145 struct bfd_link_info *info = (struct bfd_link_info *)data;
1146
e92d460e
AM
1147 if (h->root.type == bfd_link_hash_warning)
1148 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1149
af7dc644
JL
1150 /* If we are not creating a shared library, and this symbol is
1151 referenced by a shared library but is not defined anywhere, then
1152 the generic code will warn that it is undefined.
1153
1154 This behavior is undesirable on HPs since the standard shared
3f9b03b5 1155 libraries contain references to undefined symbols.
af7dc644
JL
1156
1157 So we twiddle the flags associated with such symbols so that they
3f9b03b5 1158 will not trigger the warning. ?!? FIXME. This is horribly fragile.
af7dc644
JL
1159
1160 Ultimately we should have better controls over the generic ELF BFD
1161 linker code. */
1049f94e 1162 if (! info->relocatable
af7dc644
JL
1163 && ! (info->shared
1164 && !info->no_undefined)
1165 && h->root.type == bfd_link_hash_undefined
1166 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
1167 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
1168 {
1169 h->elf_link_hash_flags &= ~ELF_LINK_HASH_REF_DYNAMIC;
1170 h->elf_link_hash_flags |= 0x8000;
1171 }
1172
b34976b6 1173 return TRUE;
af7dc644
JL
1174}
1175
b34976b6 1176static bfd_boolean
af7dc644
JL
1177elf_hppa_remark_useless_dynamic_symbols (h, data)
1178 struct elf_link_hash_entry *h;
1179 PTR data;
1180{
1181 struct bfd_link_info *info = (struct bfd_link_info *)data;
1182
e92d460e
AM
1183 if (h->root.type == bfd_link_hash_warning)
1184 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1185
af7dc644
JL
1186 /* If we are not creating a shared library, and this symbol is
1187 referenced by a shared library but is not defined anywhere, then
1188 the generic code will warn that it is undefined.
1189
1190 This behavior is undesirable on HPs since the standard shared
1191 libraries contain reerences to undefined symbols.
1192
1193 So we twiddle the flags associated with such symbols so that they
228d307f 1194 will not trigger the warning. ?!? FIXME. This is horribly fragile.
af7dc644
JL
1195
1196 Ultimately we should have better controls over the generic ELF BFD
1197 linker code. */
1049f94e 1198 if (! info->relocatable
af7dc644
JL
1199 && ! (info->shared
1200 && !info->no_undefined)
1201 && h->root.type == bfd_link_hash_undefined
1202 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
1203 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
1204 && (h->elf_link_hash_flags & 0x8000) != 0)
1205 {
1206 h->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC;
1207 h->elf_link_hash_flags &= ~0x8000;
1208 }
1209
b34976b6 1210 return TRUE;
af7dc644
JL
1211}
1212
b34976b6 1213static bfd_boolean
1bf42538
JL
1214elf_hppa_is_dynamic_loader_symbol (name)
1215 const char * name;
1216{
1217 return (! strcmp (name, "__CPU_REVISION")
1218 || ! strcmp (name, "__CPU_KEYBITS_1")
1219 || ! strcmp (name, "__SYSTEM_ID_D")
1220 || ! strcmp (name, "__FPU_MODEL")
1221 || ! strcmp (name, "__FPU_REVISION")
1222 || ! strcmp (name, "__ARGC")
1223 || ! strcmp (name, "__ARGV")
1224 || ! strcmp (name, "__ENVP")
1225 || ! strcmp (name, "__TLS_SIZE_D")
1226 || ! strcmp (name, "__LOAD_INFO")
1227 || ! strcmp (name, "__systab"));
1228}
1229
2ec0dd12
JL
1230/* Record the lowest address for the data and text segments. */
1231static void
1232elf_hppa_record_segment_addrs (abfd, section, data)
1233 bfd *abfd ATTRIBUTE_UNUSED;
1234 asection *section;
1235 PTR data;
1236{
1237 struct elf64_hppa_link_hash_table *hppa_info;
1238 bfd_vma value;
a7c10850 1239
2ec0dd12
JL
1240 hppa_info = (struct elf64_hppa_link_hash_table *)data;
1241
1242 value = section->vma - section->filepos;
1243
edd21aca 1244 if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
2ec0dd12
JL
1245 == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1246 && value < hppa_info->text_segment_base)
1247 hppa_info->text_segment_base = value;
edd21aca
AM
1248 else if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1249 == (SEC_ALLOC | SEC_LOAD))
1250 && value < hppa_info->data_segment_base)
2ec0dd12
JL
1251 hppa_info->data_segment_base = value;
1252}
1253
2eb429af
JL
1254/* Called after we have seen all the input files/sections, but before
1255 final symbol resolution and section placement has been determined.
1256
1257 We use this hook to (possibly) provide a value for __gp, then we
1258 fall back to the generic ELF final link routine. */
1259
b34976b6 1260static bfd_boolean
2eb429af
JL
1261elf_hppa_final_link (abfd, info)
1262 bfd *abfd;
1263 struct bfd_link_info *info;
1264{
b34976b6 1265 bfd_boolean retval;
edd21aca 1266 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
af7dc644 1267
1049f94e 1268 if (! info->relocatable)
2eb429af 1269 {
2eb429af 1270 struct elf_link_hash_entry *gp;
19ef5465 1271 bfd_vma gp_val;
1209c612
JL
1272
1273 /* The linker script defines a value for __gp iff it was referenced
1274 by one of the objects being linked. First try to find the symbol
1275 in the hash table. If that fails, just compute the value __gp
1276 should have had. */
b34976b6
AM
1277 gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
1278 FALSE, FALSE);
2eb429af 1279
1209c612
JL
1280 if (gp)
1281 {
1282
1283 /* Adjust the value of __gp as we may want to slide it into the
1284 .plt section so that the stubs can access PLT entries without
1285 using an addil sequence. */
edd21aca 1286 gp->root.u.def.value += hppa_info->gp_offset;
1209c612
JL
1287
1288 gp_val = (gp->root.u.def.section->output_section->vma
1289 + gp->root.u.def.section->output_offset
1290 + gp->root.u.def.value);
1291 }
1292 else
1293 {
1294 asection *sec;
1209c612
JL
1295
1296 /* First look for a .plt section. If found, then __gp is the
1297 address of the .plt + gp_offset.
1298
1299 If no .plt is found, then look for .dlt, .opd and .data (in
d663e1cd
JL
1300 that order) and set __gp to the base address of whichever
1301 section is found first. */
1209c612
JL
1302
1303 sec = hppa_info->plt_sec;
d663e1cd 1304 if (sec && ! (sec->flags & SEC_EXCLUDE))
1209c612
JL
1305 gp_val = (sec->output_offset
1306 + sec->output_section->vma
1307 + hppa_info->gp_offset);
1308 else
1309 {
1310 sec = hppa_info->dlt_sec;
d663e1cd 1311 if (!sec || (sec->flags & SEC_EXCLUDE))
1209c612 1312 sec = hppa_info->opd_sec;
d663e1cd 1313 if (!sec || (sec->flags & SEC_EXCLUDE))
1209c612 1314 sec = bfd_get_section_by_name (abfd, ".data");
d663e1cd 1315 if (!sec || (sec->flags & SEC_EXCLUDE))
b34976b6 1316 return FALSE;
1209c612
JL
1317
1318 gp_val = sec->output_offset + sec->output_section->vma;
1319 }
1320 }
2eb429af 1321
1209c612 1322 /* Install whatever value we found/computed for __gp. */
2eb429af
JL
1323 _bfd_set_gp_value (abfd, gp_val);
1324 }
1325
2ec0dd12 1326 /* We need to know the base of the text and data segments so that we
edd21aca 1327 can perform SEGREL relocations. We will record the base addresses
2ec0dd12 1328 when we encounter the first SEGREL relocation. */
edd21aca
AM
1329 hppa_info->text_segment_base = (bfd_vma)-1;
1330 hppa_info->data_segment_base = (bfd_vma)-1;
2ec0dd12 1331
af7dc644
JL
1332 /* HP's shared libraries have references to symbols that are not
1333 defined anywhere. The generic ELF BFD linker code will complaim
1334 about such symbols.
1335
1336 So we detect the losing case and arrange for the flags on the symbol
1337 to indicate that it was never referenced. This keeps the generic
1338 ELF BFD link code happy and appears to not create any secondary
1339 problems. Ultimately we need a way to control the behavior of the
1340 generic ELF BFD link code better. */
1341 elf_link_hash_traverse (elf_hash_table (info),
1342 elf_hppa_unmark_useless_dynamic_symbols,
1343 info);
1344
2eb429af 1345 /* Invoke the regular ELF backend linker to do all the work. */
af7dc644
JL
1346 retval = bfd_elf_bfd_final_link (abfd, info);
1347
1348 elf_link_hash_traverse (elf_hash_table (info),
1349 elf_hppa_remark_useless_dynamic_symbols,
1350 info);
1351
46fe4e66
AM
1352 /* If we're producing a final executable, sort the contents of the
1353 unwind section. */
1354 if (retval)
1355 retval = elf_hppa_sort_unwind (abfd);
1356
af7dc644 1357 return retval;
2eb429af
JL
1358}
1359
1360/* Relocate an HPPA ELF section. */
1361
b34976b6 1362static bfd_boolean
2eb429af
JL
1363elf_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
1364 contents, relocs, local_syms, local_sections)
1365 bfd *output_bfd;
1366 struct bfd_link_info *info;
1367 bfd *input_bfd;
1368 asection *input_section;
1369 bfd_byte *contents;
1370 Elf_Internal_Rela *relocs;
1371 Elf_Internal_Sym *local_syms;
1372 asection **local_sections;
1373{
1374 Elf_Internal_Shdr *symtab_hdr;
1375 Elf_Internal_Rela *rel;
1376 Elf_Internal_Rela *relend;
f0fe0e16
AM
1377 struct elf64_hppa_link_hash_table *hppa_info;
1378
1049f94e 1379 if (info->relocatable)
b34976b6 1380 return TRUE;
2eb429af 1381
f0fe0e16 1382 hppa_info = elf64_hppa_hash_table (info);
2eb429af
JL
1383 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1384
1385 rel = relocs;
1386 relend = relocs + input_section->reloc_count;
1387 for (; rel < relend; rel++)
1388 {
1389 int r_type;
b2e311df 1390 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
2eb429af
JL
1391 unsigned long r_symndx;
1392 struct elf_link_hash_entry *h;
1393 Elf_Internal_Sym *sym;
1394 asection *sym_sec;
1395 bfd_vma relocation;
1396 bfd_reloc_status_type r;
1397 const char *sym_name;
edd21aca 1398 const char *dyn_name;
be7582f3
JL
1399 char *dynh_buf = NULL;
1400 size_t dynh_buflen = 0;
1401 struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
2eb429af
JL
1402
1403 r_type = ELF_R_TYPE (rel->r_info);
1404 if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
1405 {
1406 bfd_set_error (bfd_error_bad_value);
b34976b6 1407 return FALSE;
2eb429af 1408 }
2eb429af 1409
2eb429af 1410 /* This is a final link. */
f0fe0e16 1411 r_symndx = ELF_R_SYM (rel->r_info);
2eb429af
JL
1412 h = NULL;
1413 sym = NULL;
1414 sym_sec = NULL;
1415 if (r_symndx < symtab_hdr->sh_info)
1416 {
be7582f3 1417 /* This is a local symbol. */
2eb429af
JL
1418 sym = local_syms + r_symndx;
1419 sym_sec = local_sections[r_symndx];
f8df10f4 1420 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
be7582f3
JL
1421
1422 /* If this symbol has an entry in the PA64 dynamic hash
1423 table, then get it. */
0ba2a60e 1424 dyn_name = get_dyn_name (input_section, h, rel,
be7582f3
JL
1425 &dynh_buf, &dynh_buflen);
1426 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
b34976b6 1427 dyn_name, FALSE, FALSE);
be7582f3 1428
2eb429af
JL
1429 }
1430 else
1431 {
be7582f3 1432 /* This is not a local symbol. */
2eb429af
JL
1433 long indx;
1434
1435 indx = r_symndx - symtab_hdr->sh_info;
1436 h = elf_sym_hashes (input_bfd)[indx];
1437 while (h->root.type == bfd_link_hash_indirect
1438 || h->root.type == bfd_link_hash_warning)
1439 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1440 if (h->root.type == bfd_link_hash_defined
1441 || h->root.type == bfd_link_hash_defweak)
1442 {
1443 sym_sec = h->root.u.def.section;
be7582f3 1444
be7582f3
JL
1445 /* If this symbol has an entry in the PA64 dynamic hash
1446 table, then get it. */
0ba2a60e 1447 dyn_name = get_dyn_name (input_section, h, rel,
be7582f3
JL
1448 &dynh_buf, &dynh_buflen);
1449 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
b34976b6 1450 dyn_name, FALSE, FALSE);
be7582f3
JL
1451
1452 /* If we have a relocation against a symbol defined in a
1453 shared library and we have not created an entry in the
1454 PA64 dynamic symbol hash table for it, then we lose. */
1455 if (sym_sec->output_section == NULL && dyn_h == NULL)
1456 {
1457 (*_bfd_error_handler)
1458 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
8f615d07 1459 bfd_archive_filename (input_bfd), h->root.root.string,
be7582f3
JL
1460 bfd_get_section_name (input_bfd, input_section));
1461 relocation = 0;
1462 }
1463 else if (sym_sec->output_section)
1464 relocation = (h->root.u.def.value
1465 + sym_sec->output_offset
1466 + sym_sec->output_section->vma);
1467 /* Value will be provided via one of the offsets in the
1468 dyn_h hash table entry. */
1469 else
1470 relocation = 0;
2eb429af 1471 }
dfec422f 1472 /* Allow undefined symbols in shared libraries. */
46fe4e66 1473 else if (info->shared && !info->no_undefined
3a27a730 1474 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
dfec422f 1475 {
5cc7c785
L
1476 if (info->symbolic)
1477 (*info->callbacks->undefined_symbol)
1478 (info, h->root.root.string, input_bfd,
b34976b6 1479 input_section, rel->r_offset, FALSE);
5cc7c785 1480
dfec422f
JL
1481 /* If this symbol has an entry in the PA64 dynamic hash
1482 table, then get it. */
0ba2a60e 1483 dyn_name = get_dyn_name (input_section, h, rel,
dfec422f
JL
1484 &dynh_buf, &dynh_buflen);
1485 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
b34976b6 1486 dyn_name, FALSE, FALSE);
dfec422f
JL
1487
1488 if (dyn_h == NULL)
1489 {
1490 (*_bfd_error_handler)
1491 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
8f615d07 1492 bfd_archive_filename (input_bfd), h->root.root.string,
dfec422f
JL
1493 bfd_get_section_name (input_bfd, input_section));
1494 relocation = 0;
1495 }
1496 relocation = 0;
1497 }
2eb429af
JL
1498 else if (h->root.type == bfd_link_hash_undefweak)
1499 relocation = 0;
1500 else
1501 {
1bf42538
JL
1502 /* Ignore dynamic loader defined symbols. */
1503 if (elf_hppa_is_dynamic_loader_symbol (h->root.root.string))
1504 relocation = 0;
1505 else
1506 {
1507 if (!((*info->callbacks->undefined_symbol)
1508 (info, h->root.root.string, input_bfd,
b34976b6
AM
1509 input_section, rel->r_offset, TRUE)))
1510 return FALSE;
1bf42538
JL
1511 break;
1512 }
2eb429af
JL
1513 }
1514 }
1515
1516 if (h != NULL)
1517 sym_name = h->root.root.string;
1518 else
1519 {
1520 sym_name = bfd_elf_string_from_elf_section (input_bfd,
1521 symtab_hdr->sh_link,
1522 sym->st_name);
1523 if (sym_name == NULL)
b34976b6 1524 return FALSE;
2eb429af
JL
1525 if (*sym_name == '\0')
1526 sym_name = bfd_section_name (input_bfd, sym_sec);
1527 }
1528
be7582f3 1529 r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
2eb429af 1530 input_section, contents,
be7582f3
JL
1531 relocation, info, sym_sec,
1532 h, dyn_h);
2eb429af
JL
1533
1534 if (r != bfd_reloc_ok)
1535 {
1536 switch (r)
1537 {
1538 default:
1539 abort ();
1540 case bfd_reloc_overflow:
1541 {
1542 if (!((*info->callbacks->reloc_overflow)
1543 (info, sym_name, howto->name, (bfd_vma) 0,
1544 input_bfd, input_section, rel->r_offset)))
b34976b6 1545 return FALSE;
2eb429af
JL
1546 }
1547 break;
1548 }
1549 }
1550 }
b34976b6 1551 return TRUE;
2eb429af
JL
1552}
1553
be7582f3 1554/* Compute the value for a relocation (REL) during a final link stage,
a7c10850 1555 then insert the value into the proper location in CONTENTS.
be7582f3
JL
1556
1557 VALUE is a tentative value for the relocation and may be overridden
1558 and modified here based on the specific relocation to be performed.
1559
1560 For example we do conversions for PC-relative branches in this routine
a7c10850 1561 or redirection of calls to external routines to stubs.
be7582f3
JL
1562
1563 The work of actually applying the relocation is left to a helper
1564 routine in an attempt to reduce the complexity and size of this
1565 function. */
2eb429af
JL
1566
1567static bfd_reloc_status_type
be7582f3
JL
1568elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1569 input_section, contents, value,
1570 info, sym_sec, h, dyn_h)
1571 Elf_Internal_Rela *rel;
2eb429af 1572 bfd *input_bfd;
be7582f3 1573 bfd *output_bfd;
2eb429af
JL
1574 asection *input_section;
1575 bfd_byte *contents;
2eb429af 1576 bfd_vma value;
2eb429af
JL
1577 struct bfd_link_info *info;
1578 asection *sym_sec;
edd21aca 1579 struct elf_link_hash_entry *h ATTRIBUTE_UNUSED;
be7582f3 1580 struct elf64_hppa_dyn_hash_entry *dyn_h;
2eb429af 1581{
dc810e39 1582 int insn;
be7582f3 1583 bfd_vma offset = rel->r_offset;
dc810e39 1584 bfd_signed_vma addend = rel->r_addend;
be7582f3 1585 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
3f9b03b5 1586 unsigned int r_type = howto->type;
2eb429af 1587 bfd_byte *hit_data = contents + offset;
be7582f3 1588 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
2eb429af
JL
1589
1590 insn = bfd_get_32 (input_bfd, hit_data);
1591
2eb429af
JL
1592 switch (r_type)
1593 {
1594 case R_PARISC_NONE:
1595 break;
1596
ba94744e 1597 /* Basic function call support.
3f9b03b5
AM
1598
1599 Note for a call to a function defined in another dynamic library
1600 we want to redirect the call to a stub. */
1601
571047ad 1602 /* Random PC relative relocs. */
b233eaab
JL
1603 case R_PARISC_PCREL21L:
1604 case R_PARISC_PCREL14R:
1605 case R_PARISC_PCREL14F:
571047ad
JL
1606 case R_PARISC_PCREL14WR:
1607 case R_PARISC_PCREL14DR:
1608 case R_PARISC_PCREL16F:
1609 case R_PARISC_PCREL16WF:
1610 case R_PARISC_PCREL16DF:
1611 {
571047ad
JL
1612 /* If this is a call to a function defined in another dynamic
1613 library, then redirect the call to the local stub for this
1614 function. */
dfec422f
JL
1615 if (sym_sec == NULL || sym_sec->output_section == NULL)
1616 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1617 + hppa_info->stub_sec->output_section->vma);
a7c10850 1618
571047ad
JL
1619 /* Turn VALUE into a proper PC relative address. */
1620 value -= (offset + input_section->output_offset
1621 + input_section->output_section->vma);
1622
1623 /* Adjust for any field selectors. */
3f9b03b5
AM
1624 if (r_type == R_PARISC_PCREL21L)
1625 value = hppa_field_adjust (value, -8 + addend, e_lsel);
1626 else if (r_type == R_PARISC_PCREL14F
1627 || r_type == R_PARISC_PCREL16F
1628 || r_type == R_PARISC_PCREL16WF
1629 || r_type == R_PARISC_PCREL16DF)
1630 value = hppa_field_adjust (value, -8 + addend, e_fsel);
1631 else
1632 value = hppa_field_adjust (value, -8 + addend, e_rsel);
571047ad
JL
1633
1634 /* Apply the relocation to the given instruction. */
dc810e39 1635 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
571047ad
JL
1636 break;
1637 }
1638
49bd834c 1639 case R_PARISC_PCREL12F:
2eb429af
JL
1640 case R_PARISC_PCREL22F:
1641 case R_PARISC_PCREL17F:
571047ad
JL
1642 case R_PARISC_PCREL22C:
1643 case R_PARISC_PCREL17C:
1644 case R_PARISC_PCREL17R:
2eb429af 1645 {
be7582f3
JL
1646 /* If this is a call to a function defined in another dynamic
1647 library, then redirect the call to the local stub for this
1648 function. */
dfec422f 1649 if (sym_sec == NULL || sym_sec->output_section == NULL)
6a0b9871
JL
1650 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1651 + hppa_info->stub_sec->output_section->vma);
a7c10850 1652
be7582f3
JL
1653 /* Turn VALUE into a proper PC relative address. */
1654 value -= (offset + input_section->output_offset
1655 + input_section->output_section->vma);
1656
1657 /* Adjust for any field selectors. */
70d72e0e
AM
1658 if (r_type == R_PARISC_PCREL17R)
1659 value = hppa_field_adjust (value, -8 + addend, e_rsel);
1660 else
1661 value = hppa_field_adjust (value, -8 + addend, e_fsel);
2eb429af 1662
be7582f3
JL
1663 /* All branches are implicitly shifted by 2 places. */
1664 value >>= 2;
2eb429af 1665
be7582f3 1666 /* Apply the relocation to the given instruction. */
dc810e39 1667 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
2eb429af
JL
1668 break;
1669 }
1670
be7582f3
JL
1671 /* Indirect references to data through the DLT. */
1672 case R_PARISC_DLTIND14R:
571047ad 1673 case R_PARISC_DLTIND14F:
be7582f3
JL
1674 case R_PARISC_DLTIND14DR:
1675 case R_PARISC_DLTIND14WR:
1676 case R_PARISC_DLTIND21L:
e5bb3efc
JL
1677 case R_PARISC_LTOFF_FPTR14R:
1678 case R_PARISC_LTOFF_FPTR14DR:
1679 case R_PARISC_LTOFF_FPTR14WR:
1680 case R_PARISC_LTOFF_FPTR21L:
1681 case R_PARISC_LTOFF_FPTR16F:
1682 case R_PARISC_LTOFF_FPTR16WF:
1683 case R_PARISC_LTOFF_FPTR16DF:
b233eaab
JL
1684 case R_PARISC_LTOFF_TP21L:
1685 case R_PARISC_LTOFF_TP14R:
1686 case R_PARISC_LTOFF_TP14F:
1687 case R_PARISC_LTOFF_TP14WR:
1688 case R_PARISC_LTOFF_TP14DR:
1689 case R_PARISC_LTOFF_TP16F:
1690 case R_PARISC_LTOFF_TP16WF:
1691 case R_PARISC_LTOFF_TP16DF:
b7263961
JL
1692 case R_PARISC_LTOFF16F:
1693 case R_PARISC_LTOFF16WF:
1694 case R_PARISC_LTOFF16DF:
c8933571 1695 {
6a0b9871 1696 /* If this relocation was against a local symbol, then we still
edd21aca 1697 have not set up the DLT entry (it's not convenient to do so
6a0b9871
JL
1698 in the "finalize_dlt" routine because it is difficult to get
1699 to the local symbol's value).
1700
1701 So, if this is a local symbol (h == NULL), then we need to
a7c10850 1702 fill in its DLT entry.
e48c661e
JL
1703
1704 Similarly we may still need to set up an entry in .opd for
1705 a local function which had its address taken. */
6a0b9871
JL
1706 if (dyn_h->h == NULL)
1707 {
1bf42538 1708 /* Now do .opd creation if needed. */
e48c661e
JL
1709 if (r_type == R_PARISC_LTOFF_FPTR14R
1710 || r_type == R_PARISC_LTOFF_FPTR14DR
1711 || r_type == R_PARISC_LTOFF_FPTR14WR
1712 || r_type == R_PARISC_LTOFF_FPTR21L
1713 || r_type == R_PARISC_LTOFF_FPTR16F
1714 || r_type == R_PARISC_LTOFF_FPTR16WF
1715 || r_type == R_PARISC_LTOFF_FPTR16DF)
1716 {
1717 /* The first two words of an .opd entry are zero. */
1718 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset,
1719 0, 16);
1720
1721 /* The next word is the address of the function. */
1bf42538 1722 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
e48c661e
JL
1723 (hppa_info->opd_sec->contents
1724 + dyn_h->opd_offset + 16));
1725
1726 /* The last word is our local __gp value. */
1727 value = _bfd_get_gp_value
1728 (hppa_info->opd_sec->output_section->owner);
1729 bfd_put_64 (hppa_info->opd_sec->owner, value,
1730 (hppa_info->opd_sec->contents
1731 + dyn_h->opd_offset + 24));
1bf42538
JL
1732
1733 /* The DLT value is the address of the .opd entry. */
1734 value = (dyn_h->opd_offset
1735 + hppa_info->opd_sec->output_offset
1736 + hppa_info->opd_sec->output_section->vma);
1737 addend = 0;
e48c661e 1738 }
1bf42538
JL
1739
1740 bfd_put_64 (hppa_info->dlt_sec->owner,
1741 value + addend,
1742 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
6a0b9871
JL
1743 }
1744
be7582f3 1745 /* We want the value of the DLT offset for this symbol, not
19ef5465
JL
1746 the symbol's actual address. Note that __gp may not point
1747 to the start of the DLT, so we have to compute the absolute
1748 address, then subtract out the value of __gp. */
1749 value = (dyn_h->dlt_offset
1750 + hppa_info->dlt_sec->output_offset
1751 + hppa_info->dlt_sec->output_section->vma);
1752 value -= _bfd_get_gp_value (output_bfd);
1753
be7582f3
JL
1754 /* All DLTIND relocations are basically the same at this point,
1755 except that we need different field selectors for the 21bit
1756 version vs the 14bit versions. */
e5bb3efc 1757 if (r_type == R_PARISC_DLTIND21L
b233eaab
JL
1758 || r_type == R_PARISC_LTOFF_FPTR21L
1759 || r_type == R_PARISC_LTOFF_TP21L)
1bf42538 1760 value = hppa_field_adjust (value, 0, e_lsel);
571047ad
JL
1761 else if (r_type == R_PARISC_DLTIND14F
1762 || r_type == R_PARISC_LTOFF_FPTR16F
1763 || r_type == R_PARISC_LTOFF_FPTR16WF
b233eaab 1764 || r_type == R_PARISC_LTOFF_FPTR16DF
b7263961
JL
1765 || r_type == R_PARISC_LTOFF16F
1766 || r_type == R_PARISC_LTOFF16DF
1767 || r_type == R_PARISC_LTOFF16WF
b233eaab
JL
1768 || r_type == R_PARISC_LTOFF_TP16F
1769 || r_type == R_PARISC_LTOFF_TP16WF
1770 || r_type == R_PARISC_LTOFF_TP16DF)
1bf42538 1771 value = hppa_field_adjust (value, 0, e_fsel);
be7582f3 1772 else
1bf42538 1773 value = hppa_field_adjust (value, 0, e_rsel);
be7582f3 1774
dc810e39 1775 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
c8933571
JL
1776 break;
1777 }
1778
be7582f3 1779 case R_PARISC_DLTREL14R:
571047ad 1780 case R_PARISC_DLTREL14F:
be7582f3
JL
1781 case R_PARISC_DLTREL14DR:
1782 case R_PARISC_DLTREL14WR:
c8933571 1783 case R_PARISC_DLTREL21L:
6849fb4d
JL
1784 case R_PARISC_DPREL21L:
1785 case R_PARISC_DPREL14WR:
1786 case R_PARISC_DPREL14DR:
1787 case R_PARISC_DPREL14R:
1788 case R_PARISC_DPREL14F:
1789 case R_PARISC_GPREL16F:
1790 case R_PARISC_GPREL16WF:
1791 case R_PARISC_GPREL16DF:
c8933571 1792 {
be7582f3
JL
1793 /* Subtract out the global pointer value to make value a DLT
1794 relative address. */
1795 value -= _bfd_get_gp_value (output_bfd);
1796
1797 /* All DLTREL relocations are basically the same at this point,
1798 except that we need different field selectors for the 21bit
1799 version vs the 14bit versions. */
6849fb4d
JL
1800 if (r_type == R_PARISC_DLTREL21L
1801 || r_type == R_PARISC_DPREL21L)
be7582f3 1802 value = hppa_field_adjust (value, addend, e_lrsel);
6849fb4d
JL
1803 else if (r_type == R_PARISC_DLTREL14F
1804 || r_type == R_PARISC_DPREL14F
1805 || r_type == R_PARISC_GPREL16F
1806 || r_type == R_PARISC_GPREL16WF
1807 || r_type == R_PARISC_GPREL16DF)
571047ad 1808 value = hppa_field_adjust (value, addend, e_fsel);
be7582f3
JL
1809 else
1810 value = hppa_field_adjust (value, addend, e_rrsel);
1811
dc810e39 1812 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
c8933571
JL
1813 break;
1814 }
1815
b7263961
JL
1816 case R_PARISC_DIR21L:
1817 case R_PARISC_DIR17R:
1818 case R_PARISC_DIR17F:
1819 case R_PARISC_DIR14R:
47d89dba 1820 case R_PARISC_DIR14F:
b7263961
JL
1821 case R_PARISC_DIR14WR:
1822 case R_PARISC_DIR14DR:
1823 case R_PARISC_DIR16F:
1824 case R_PARISC_DIR16WF:
1825 case R_PARISC_DIR16DF:
1826 {
1827 /* All DIR relocations are basically the same at this point,
70d72e0e
AM
1828 except that branch offsets need to be divided by four, and
1829 we need different field selectors. Note that we don't
1830 redirect absolute calls to local stubs. */
3f9b03b5 1831
b7263961
JL
1832 if (r_type == R_PARISC_DIR21L)
1833 value = hppa_field_adjust (value, addend, e_lrsel);
1834 else if (r_type == R_PARISC_DIR17F
1835 || r_type == R_PARISC_DIR16F
1836 || r_type == R_PARISC_DIR16WF
47d89dba
AM
1837 || r_type == R_PARISC_DIR16DF
1838 || r_type == R_PARISC_DIR14F)
b7263961
JL
1839 value = hppa_field_adjust (value, addend, e_fsel);
1840 else
1841 value = hppa_field_adjust (value, addend, e_rrsel);
1842
70d72e0e
AM
1843 if (r_type == R_PARISC_DIR17R || r_type == R_PARISC_DIR17F)
1844 {
1845 /* All branches are implicitly shifted by 2 places. */
1846 value >>= 2;
1847 }
1848
dc810e39 1849 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
b7263961
JL
1850 break;
1851 }
1852
8267b155
JL
1853 case R_PARISC_PLTOFF21L:
1854 case R_PARISC_PLTOFF14R:
1855 case R_PARISC_PLTOFF14F:
1856 case R_PARISC_PLTOFF14WR:
1857 case R_PARISC_PLTOFF14DR:
1858 case R_PARISC_PLTOFF16F:
1859 case R_PARISC_PLTOFF16WF:
1860 case R_PARISC_PLTOFF16DF:
1861 {
1862 /* We want the value of the PLT offset for this symbol, not
19ef5465
JL
1863 the symbol's actual address. Note that __gp may not point
1864 to the start of the DLT, so we have to compute the absolute
1865 address, then subtract out the value of __gp. */
1866 value = (dyn_h->plt_offset
1867 + hppa_info->plt_sec->output_offset
1868 + hppa_info->plt_sec->output_section->vma);
1869 value -= _bfd_get_gp_value (output_bfd);
8267b155
JL
1870
1871 /* All PLTOFF relocations are basically the same at this point,
1872 except that we need different field selectors for the 21bit
1873 version vs the 14bit versions. */
1874 if (r_type == R_PARISC_PLTOFF21L)
1875 value = hppa_field_adjust (value, addend, e_lrsel);
1876 else if (r_type == R_PARISC_PLTOFF14F
1877 || r_type == R_PARISC_PLTOFF16F
1878 || r_type == R_PARISC_PLTOFF16WF
1879 || r_type == R_PARISC_PLTOFF16DF)
1880 value = hppa_field_adjust (value, addend, e_fsel);
1881 else
1882 value = hppa_field_adjust (value, addend, e_rrsel);
1883
dc810e39 1884 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
8267b155
JL
1885 break;
1886 }
1887
e5bb3efc
JL
1888 case R_PARISC_LTOFF_FPTR32:
1889 {
e48c661e
JL
1890 /* We may still need to create the FPTR itself if it was for
1891 a local symbol. */
1892 if (dyn_h->h == NULL)
1893 {
1894 /* The first two words of an .opd entry are zero. */
1895 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1896
1897 /* The next word is the address of the function. */
1bf42538 1898 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
e48c661e
JL
1899 (hppa_info->opd_sec->contents
1900 + dyn_h->opd_offset + 16));
1901
1902 /* The last word is our local __gp value. */
1903 value = _bfd_get_gp_value
1904 (hppa_info->opd_sec->output_section->owner);
1905 bfd_put_64 (hppa_info->opd_sec->owner, value,
1906 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1bf42538
JL
1907
1908 /* The DLT value is the address of the .opd entry. */
1909 value = (dyn_h->opd_offset
1910 + hppa_info->opd_sec->output_offset
1911 + hppa_info->opd_sec->output_section->vma);
1912
1913 bfd_put_64 (hppa_info->dlt_sec->owner,
1914 value,
1915 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
e48c661e
JL
1916 }
1917
e5bb3efc 1918 /* We want the value of the DLT offset for this symbol, not
19ef5465
JL
1919 the symbol's actual address. Note that __gp may not point
1920 to the start of the DLT, so we have to compute the absolute
1921 address, then subtract out the value of __gp. */
1922 value = (dyn_h->dlt_offset
1923 + hppa_info->dlt_sec->output_offset
1924 + hppa_info->dlt_sec->output_section->vma);
1925 value -= _bfd_get_gp_value (output_bfd);
e5bb3efc
JL
1926 bfd_put_32 (input_bfd, value, hit_data);
1927 return bfd_reloc_ok;
1928 }
1929
e5bb3efc 1930 case R_PARISC_LTOFF_FPTR64:
b233eaab 1931 case R_PARISC_LTOFF_TP64:
e5bb3efc 1932 {
e48c661e
JL
1933 /* We may still need to create the FPTR itself if it was for
1934 a local symbol. */
1935 if (dyn_h->h == NULL && r_type == R_PARISC_LTOFF_FPTR64)
1936 {
1937 /* The first two words of an .opd entry are zero. */
1938 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1939
1940 /* The next word is the address of the function. */
1bf42538 1941 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
e48c661e
JL
1942 (hppa_info->opd_sec->contents
1943 + dyn_h->opd_offset + 16));
1944
1945 /* The last word is our local __gp value. */
1946 value = _bfd_get_gp_value
1947 (hppa_info->opd_sec->output_section->owner);
1948 bfd_put_64 (hppa_info->opd_sec->owner, value,
1949 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1bf42538
JL
1950
1951 /* The DLT value is the address of the .opd entry. */
1952 value = (dyn_h->opd_offset
1953 + hppa_info->opd_sec->output_offset
1954 + hppa_info->opd_sec->output_section->vma);
1955
1956 bfd_put_64 (hppa_info->dlt_sec->owner,
1957 value,
1958 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
e48c661e
JL
1959 }
1960
e5bb3efc 1961 /* We want the value of the DLT offset for this symbol, not
19ef5465
JL
1962 the symbol's actual address. Note that __gp may not point
1963 to the start of the DLT, so we have to compute the absolute
1964 address, then subtract out the value of __gp. */
1965 value = (dyn_h->dlt_offset
1966 + hppa_info->dlt_sec->output_offset
1967 + hppa_info->dlt_sec->output_section->vma);
1968 value -= _bfd_get_gp_value (output_bfd);
e5bb3efc
JL
1969 bfd_put_64 (input_bfd, value, hit_data);
1970 return bfd_reloc_ok;
1971 }
1972
1973 case R_PARISC_DIR32:
571047ad 1974 bfd_put_32 (input_bfd, value + addend, hit_data);
e5bb3efc
JL
1975 return bfd_reloc_ok;
1976
1977 case R_PARISC_DIR64:
571047ad 1978 bfd_put_64 (input_bfd, value + addend, hit_data);
e5bb3efc
JL
1979 return bfd_reloc_ok;
1980
6849fb4d
JL
1981 case R_PARISC_GPREL64:
1982 /* Subtract out the global pointer value to make value a DLT
1983 relative address. */
1984 value -= _bfd_get_gp_value (output_bfd);
6849fb4d
JL
1985
1986 bfd_put_64 (input_bfd, value + addend, hit_data);
1987 return bfd_reloc_ok;
1988
b7263961 1989 case R_PARISC_LTOFF64:
19ef5465
JL
1990 /* We want the value of the DLT offset for this symbol, not
1991 the symbol's actual address. Note that __gp may not point
1992 to the start of the DLT, so we have to compute the absolute
1993 address, then subtract out the value of __gp. */
1994 value = (dyn_h->dlt_offset
1995 + hppa_info->dlt_sec->output_offset
1996 + hppa_info->dlt_sec->output_section->vma);
1997 value -= _bfd_get_gp_value (output_bfd);
b7263961
JL
1998
1999 bfd_put_64 (input_bfd, value + addend, hit_data);
2000 return bfd_reloc_ok;
2001
571047ad
JL
2002 case R_PARISC_PCREL32:
2003 {
2004 /* If this is a call to a function defined in another dynamic
2005 library, then redirect the call to the local stub for this
2006 function. */
dfec422f
JL
2007 if (sym_sec == NULL || sym_sec->output_section == NULL)
2008 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
2009 + hppa_info->stub_sec->output_section->vma);
a7c10850 2010
571047ad
JL
2011 /* Turn VALUE into a proper PC relative address. */
2012 value -= (offset + input_section->output_offset
2013 + input_section->output_section->vma);
2014
b233eaab 2015 value += addend;
571047ad 2016 value -= 8;
edd21aca 2017 bfd_put_32 (input_bfd, value, hit_data);
571047ad
JL
2018 return bfd_reloc_ok;
2019 }
2020
2021 case R_PARISC_PCREL64:
2022 {
2023 /* If this is a call to a function defined in another dynamic
2024 library, then redirect the call to the local stub for this
2025 function. */
dfec422f
JL
2026 if (sym_sec == NULL || sym_sec->output_section == NULL)
2027 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
2028 + hppa_info->stub_sec->output_section->vma);
a7c10850 2029
571047ad
JL
2030 /* Turn VALUE into a proper PC relative address. */
2031 value -= (offset + input_section->output_offset
2032 + input_section->output_section->vma);
2033
b233eaab 2034 value += addend;
571047ad
JL
2035 value -= 8;
2036 bfd_put_64 (input_bfd, value, hit_data);
2037 return bfd_reloc_ok;
2038 }
2039
e5bb3efc 2040 case R_PARISC_FPTR64:
e48c661e
JL
2041 {
2042 /* We may still need to create the FPTR itself if it was for
2043 a local symbol. */
2044 if (dyn_h->h == NULL)
2045 {
2046 /* The first two words of an .opd entry are zero. */
2047 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
2048
2049 /* The next word is the address of the function. */
1bf42538 2050 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
e48c661e
JL
2051 (hppa_info->opd_sec->contents
2052 + dyn_h->opd_offset + 16));
2053
2054 /* The last word is our local __gp value. */
2055 value = _bfd_get_gp_value
2056 (hppa_info->opd_sec->output_section->owner);
2057 bfd_put_64 (hppa_info->opd_sec->owner, value,
2058 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
2059 }
2060
d663e1cd
JL
2061 if (dyn_h->want_opd)
2062 /* We want the value of the OPD offset for this symbol. */
2063 value = (dyn_h->opd_offset
2064 + hppa_info->opd_sec->output_offset
2065 + hppa_info->opd_sec->output_section->vma);
2066 else
2067 /* We want the address of the symbol. */
2068 value += addend;
a7c10850 2069
1bf42538 2070 bfd_put_64 (input_bfd, value, hit_data);
e48c661e
JL
2071 return bfd_reloc_ok;
2072 }
e5bb3efc 2073
228d307f
JL
2074 case R_PARISC_SECREL32:
2075 bfd_put_32 (input_bfd,
edd21aca 2076 value + addend - sym_sec->output_section->vma,
228d307f
JL
2077 hit_data);
2078 return bfd_reloc_ok;
2079
2080 case R_PARISC_SEGREL32:
2ec0dd12
JL
2081 case R_PARISC_SEGREL64:
2082 {
2083 /* If this is the first SEGREL relocation, then initialize
2084 the segment base values. */
2085 if (hppa_info->text_segment_base == (bfd_vma) -1)
2086 bfd_map_over_sections (output_bfd, elf_hppa_record_segment_addrs,
edd21aca 2087 hppa_info);
2ec0dd12
JL
2088
2089 /* VALUE holds the absolute address. We want to include the
2090 addend, then turn it into a segment relative address.
2091
2092 The segment is derived from SYM_SEC. We assume that there are
2093 only two segments of note in the resulting executable/shlib.
2094 A readonly segment (.text) and a readwrite segment (.data). */
2095 value += addend;
2096
2097 if (sym_sec->flags & SEC_CODE)
2098 value -= hppa_info->text_segment_base;
2099 else
2100 value -= hppa_info->data_segment_base;
2101
2102 if (r_type == R_PARISC_SEGREL32)
2103 bfd_put_32 (input_bfd, value, hit_data);
2104 else
2105 bfd_put_64 (input_bfd, value, hit_data);
46fe4e66 2106 return bfd_reloc_ok;
2ec0dd12 2107 }
228d307f 2108
2eb429af
JL
2109 /* Something we don't know how to handle. */
2110 default:
228d307f 2111 return bfd_reloc_notsupported;
2eb429af
JL
2112 }
2113
2114 /* Update the instruction word. */
dc810e39 2115 bfd_put_32 (input_bfd, (bfd_vma) insn, hit_data);
edd21aca 2116 return bfd_reloc_ok;
2eb429af
JL
2117}
2118
be7582f3
JL
2119/* Relocate the given INSN. VALUE should be the actual value we want
2120 to insert into the instruction, ie by this point we should not be
2121 concerned with computing an offset relative to the DLT, PC, etc.
2122 Instead this routine is meant to handle the bit manipulations needed
2123 to insert the relocation into the given instruction. */
2eb429af 2124
dc810e39 2125static int
be7582f3 2126elf_hppa_relocate_insn (insn, sym_value, r_type)
dc810e39
AM
2127 int insn;
2128 int sym_value;
3f9b03b5 2129 unsigned int r_type;
2eb429af 2130{
c8933571 2131 switch (r_type)
2eb429af 2132 {
49bd834c 2133 /* This is any 22 bit branch. In PA2.0 syntax it corresponds to
be7582f3 2134 the "B" instruction. */
c8933571 2135 case R_PARISC_PCREL22F:
571047ad 2136 case R_PARISC_PCREL22C:
dc810e39 2137 return (insn & ~0x3ff1ffd) | re_assemble_22 (sym_value);
2eb429af 2138
49bd834c
AM
2139 /* This is any 12 bit branch. */
2140 case R_PARISC_PCREL12F:
dc810e39 2141 return (insn & ~0x1ffd) | re_assemble_12 (sym_value);
49bd834c
AM
2142
2143 /* This is any 17 bit branch. In PA2.0 syntax it also corresponds
2144 to the "B" instruction as well as BE. */
be7582f3 2145 case R_PARISC_PCREL17F:
c8933571 2146 case R_PARISC_DIR17F:
b7263961 2147 case R_PARISC_DIR17R:
571047ad
JL
2148 case R_PARISC_PCREL17C:
2149 case R_PARISC_PCREL17R:
dc810e39 2150 return (insn & ~0x1f1ffd) | re_assemble_17 (sym_value);
2eb429af 2151
be7582f3 2152 /* ADDIL or LDIL instructions. */
c8933571 2153 case R_PARISC_DLTREL21L:
be7582f3 2154 case R_PARISC_DLTIND21L:
e5bb3efc 2155 case R_PARISC_LTOFF_FPTR21L:
b233eaab
JL
2156 case R_PARISC_PCREL21L:
2157 case R_PARISC_LTOFF_TP21L:
6849fb4d 2158 case R_PARISC_DPREL21L:
8267b155 2159 case R_PARISC_PLTOFF21L:
b7263961 2160 case R_PARISC_DIR21L:
dc810e39 2161 return (insn & ~0x1fffff) | re_assemble_21 (sym_value);
be7582f3 2162
49bd834c 2163 /* LDO and integer loads/stores with 14 bit displacements. */
c8933571 2164 case R_PARISC_DLTREL14R:
084d930b 2165 case R_PARISC_DLTREL14F:
be7582f3
JL
2166 case R_PARISC_DLTIND14R:
2167 case R_PARISC_DLTIND14F:
e5bb3efc 2168 case R_PARISC_LTOFF_FPTR14R:
b233eaab 2169 case R_PARISC_PCREL14R:
571047ad 2170 case R_PARISC_PCREL14F:
b233eaab
JL
2171 case R_PARISC_LTOFF_TP14R:
2172 case R_PARISC_LTOFF_TP14F:
6849fb4d
JL
2173 case R_PARISC_DPREL14R:
2174 case R_PARISC_DPREL14F:
8267b155
JL
2175 case R_PARISC_PLTOFF14R:
2176 case R_PARISC_PLTOFF14F:
b7263961 2177 case R_PARISC_DIR14R:
47d89dba 2178 case R_PARISC_DIR14F:
ba94744e
AM
2179 return (insn & ~0x3fff) | low_sign_unext (sym_value, 14);
2180
2181 /* PA2.0W LDO and integer loads/stores with 16 bit displacements. */
2182 case R_PARISC_LTOFF_FPTR16F:
2183 case R_PARISC_PCREL16F:
2184 case R_PARISC_LTOFF_TP16F:
2185 case R_PARISC_GPREL16F:
2186 case R_PARISC_PLTOFF16F:
b7263961
JL
2187 case R_PARISC_DIR16F:
2188 case R_PARISC_LTOFF16F:
ba94744e 2189 return (insn & ~0xffff) | re_assemble_16 (sym_value);
be7582f3 2190
49bd834c 2191 /* Doubleword loads and stores with a 14 bit displacement. */
11c19a4e 2192 case R_PARISC_DLTREL14DR:
be7582f3 2193 case R_PARISC_DLTIND14DR:
e5bb3efc
JL
2194 case R_PARISC_LTOFF_FPTR14DR:
2195 case R_PARISC_LTOFF_FPTR16DF:
571047ad
JL
2196 case R_PARISC_PCREL14DR:
2197 case R_PARISC_PCREL16DF:
b233eaab
JL
2198 case R_PARISC_LTOFF_TP14DR:
2199 case R_PARISC_LTOFF_TP16DF:
6849fb4d
JL
2200 case R_PARISC_DPREL14DR:
2201 case R_PARISC_GPREL16DF:
8267b155
JL
2202 case R_PARISC_PLTOFF14DR:
2203 case R_PARISC_PLTOFF16DF:
b7263961
JL
2204 case R_PARISC_DIR14DR:
2205 case R_PARISC_DIR16DF:
2206 case R_PARISC_LTOFF16DF:
dc810e39
AM
2207 return (insn & ~0x3ff1) | (((sym_value & 0x2000) >> 13)
2208 | ((sym_value & 0x1ff8) << 1));
11c19a4e 2209
be7582f3 2210 /* Floating point single word load/store instructions. */
11c19a4e 2211 case R_PARISC_DLTREL14WR:
be7582f3 2212 case R_PARISC_DLTIND14WR:
e5bb3efc
JL
2213 case R_PARISC_LTOFF_FPTR14WR:
2214 case R_PARISC_LTOFF_FPTR16WF:
571047ad
JL
2215 case R_PARISC_PCREL14WR:
2216 case R_PARISC_PCREL16WF:
b233eaab
JL
2217 case R_PARISC_LTOFF_TP14WR:
2218 case R_PARISC_LTOFF_TP16WF:
6849fb4d
JL
2219 case R_PARISC_DPREL14WR:
2220 case R_PARISC_GPREL16WF:
8267b155
JL
2221 case R_PARISC_PLTOFF14WR:
2222 case R_PARISC_PLTOFF16WF:
b7263961
JL
2223 case R_PARISC_DIR16WF:
2224 case R_PARISC_DIR14WR:
2225 case R_PARISC_LTOFF16WF:
dc810e39
AM
2226 return (insn & ~0x3ff9) | (((sym_value & 0x2000) >> 13)
2227 | ((sym_value & 0x1ffc) << 1));
be7582f3 2228
2eb429af
JL
2229 default:
2230 return insn;
2231 }
2232}
3f9b03b5 2233#endif
This page took 0.331972 seconds and 4 git commands to generate.