* elf-hppa.h (elf_hppa_relocate_section): Look up dyn_h for undefweak.
[external/binutils.git] / bfd / elf-hppa.h
1 /* Common code for PA ELF implementations.
2    Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
3
4 This file is part of BFD, the Binary File Descriptor library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19
20 #define ELF_HOWTO_TABLE_SIZE       R_PARISC_UNIMPLEMENTED + 1
21
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.  */
28 #if ARCH_SIZE == 64
29 #define ELF_R_TYPE(X)   ELF64_R_TYPE(X)
30 #define ELF_R_SYM(X)   ELF64_R_SYM(X)
31 #define elf_hppa_reloc_final_type elf64_hppa_reloc_final_type
32 #define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
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
36 #endif
37 #if ARCH_SIZE == 32
38 #define ELF_R_TYPE(X)   ELF32_R_TYPE(X)
39 #define ELF_R_SYM(X)   ELF32_R_SYM(X)
40 #define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type
41 #define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
42 #define elf_hppa_relocate_section elf32_hppa_relocate_section
43 #define bfd_elf_bfd_final_link bfd_elf32_bfd_final_link
44 #define elf_hppa_final_link elf32_hppa_final_link
45 #endif
46
47 static void elf_hppa_info_to_howto
48   PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
49
50 static void elf_hppa_info_to_howto_rel
51   PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
52
53 static reloc_howto_type * elf_hppa_reloc_type_lookup
54   PARAMS ((bfd *, bfd_reloc_code_real_type));
55
56 static bfd_boolean elf_hppa_is_local_label_name
57   PARAMS ((bfd *, const char *));
58
59 static bfd_boolean elf_hppa_fake_sections
60   PARAMS ((bfd *abfd, Elf_Internal_Shdr *, asection *));
61
62 static void elf_hppa_final_write_processing
63   PARAMS ((bfd *, bfd_boolean));
64
65 static int hppa_unwind_entry_compare
66   PARAMS ((const PTR, const PTR));
67
68 static bfd_boolean elf_hppa_sort_unwind
69   PARAMS ((bfd *));
70
71 #if ARCH_SIZE == 64
72 static bfd_boolean elf_hppa_add_symbol_hook
73   PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
74            const char **, flagword *, asection **, bfd_vma *));
75
76 static bfd_boolean elf_hppa_unmark_useless_dynamic_symbols
77   PARAMS ((struct elf_link_hash_entry *, PTR));
78
79 static bfd_boolean elf_hppa_remark_useless_dynamic_symbols
80   PARAMS ((struct elf_link_hash_entry *, PTR));
81
82 static bfd_boolean elf_hppa_is_dynamic_loader_symbol
83   PARAMS ((const char *));
84
85 static void elf_hppa_record_segment_addrs
86   PARAMS ((bfd *, asection *, PTR));
87
88 static bfd_boolean elf_hppa_final_link
89   PARAMS ((bfd *, struct bfd_link_info *));
90
91 static bfd_boolean elf_hppa_relocate_section
92   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
93            bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
94
95 static bfd_reloc_status_type elf_hppa_final_link_relocate
96   PARAMS ((Elf_Internal_Rela *, bfd *, bfd *, asection *,
97            bfd_byte *, bfd_vma, struct bfd_link_info *,
98            asection *, struct elf_link_hash_entry *,
99            struct elf64_hppa_dyn_hash_entry *));
100
101 static int elf_hppa_relocate_insn
102   PARAMS ((int, int, unsigned int));
103 #endif
104
105 /* ELF/PA relocation howto entries.  */
106
107 static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
108 {
109   { R_PARISC_NONE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
110     bfd_elf_generic_reloc, "R_PARISC_NONE", FALSE, 0, 0, FALSE },
111
112   /* The values in DIR32 are to placate the check in
113      _bfd_stab_section_find_nearest_line.  */
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 },
128   /* 8 */
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 },
145   /* 16 */
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 },
162   /* 24 */
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 },
179   /* 32 */
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 },
196   /* 40 */
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 },
213   /* 48 */
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 },
230   /* 56 */
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 },
247   /* 64 */
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 },
264   /* 72 */
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 },
281   /* 80 */
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 },
298   /* 88 */
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 },
315   /* 96 */
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 },
332   /* 104 */
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 },
349   /* 112 */
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 },
366   /* 120 */
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 },
383   /* 128 */
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 },
400   /* 136 */
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 },
417   /* 144 */
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 },
434   /* 152 */
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 },
451   /* 160 */
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 },
468   /* 168 */
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 },
485   /* 176 */
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 },
502   /* 184 */
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 },
519   /* 192 */
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 },
536   /* 200 */
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 },
553   /* 208 */
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 },
570   /* 216 */
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 },
587   /* 224 */
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 },
604   /* 232 */
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 },
609 };
610
611 #define OFFSET_14R_FROM_21L 4
612 #define OFFSET_14F_FROM_21L 5
613
614 /* Return the final relocation type for the given base type, instruction
615    format, and field selector.  */
616
617 elf_hppa_reloc_type
618 elf_hppa_reloc_final_type (abfd, base_type, format, field)
619      bfd *abfd;
620      elf_hppa_reloc_type base_type;
621      int format;
622      unsigned int field;
623 {
624   elf_hppa_reloc_type final_type = base_type;
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     {
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:
636     case R_HPPA_ABS_CALL:
637       switch (format)
638         {
639         case 14:
640           switch (field)
641             {
642             case e_fsel:
643               final_type = R_PARISC_DIR14F;
644               break;
645             case e_rsel:
646             case e_rrsel:
647             case e_rdsel:
648               final_type = R_PARISC_DIR14R;
649               break;
650             case e_rtsel:
651               final_type = R_PARISC_DLTIND14R;
652               break;
653             case e_rtpsel:
654               final_type = R_PARISC_LTOFF_FPTR14DR;
655               break;
656             case e_tsel:
657               final_type = R_PARISC_DLTIND14F;
658               break;
659             case e_rpsel:
660               final_type = R_PARISC_PLABEL14R;
661               break;
662             default:
663               return R_PARISC_NONE;
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:
675             case e_rdsel:
676               final_type = R_PARISC_DIR17R;
677               break;
678             default:
679               return R_PARISC_NONE;
680             }
681           break;
682
683         case 21:
684           switch (field)
685             {
686             case e_lsel:
687             case e_lrsel:
688             case e_ldsel:
689             case e_nlsel:
690             case e_nlrsel:
691               final_type = R_PARISC_DIR21L;
692               break;
693             case e_ltsel:
694               final_type = R_PARISC_DLTIND21L;
695               break;
696             case e_ltpsel:
697               final_type = R_PARISC_LTOFF_FPTR21L;
698               break;
699             case e_lpsel:
700               final_type = R_PARISC_PLABEL21L;
701               break;
702             default:
703               return R_PARISC_NONE;
704             }
705           break;
706
707         case 32:
708           switch (field)
709             {
710             case e_fsel:
711               final_type = R_PARISC_DIR32;
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)
716                 final_type = R_PARISC_SECREL32;
717               break;
718             case e_psel:
719               final_type = R_PARISC_PLABEL32;
720               break;
721             default:
722               return R_PARISC_NONE;
723             }
724           break;
725
726         case 64:
727           switch (field)
728             {
729             case e_fsel:
730               final_type = R_PARISC_DIR64;
731               break;
732             case e_psel:
733               final_type = R_PARISC_FPTR64;
734               break;
735             default:
736               return R_PARISC_NONE;
737             }
738           break;
739
740         default:
741           return R_PARISC_NONE;
742         }
743       break;
744
745     case R_HPPA_GOTOFF:
746       switch (format)
747         {
748         case 14:
749           switch (field)
750             {
751             case e_rsel:
752             case e_rrsel:
753             case e_rdsel:
754               /* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32  */
755               final_type = base_type + OFFSET_14R_FROM_21L;
756               break;
757             case e_fsel:
758               /* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32  */
759               final_type = base_type + OFFSET_14F_FROM_21L;
760               break;
761             default:
762               return R_PARISC_NONE;
763             }
764           break;
765
766         case 21:
767           switch (field)
768             {
769             case e_lsel:
770             case e_lrsel:
771             case e_ldsel:
772             case e_nlsel:
773             case e_nlrsel:
774               /* R_PARISC_DLTREL21L for elf64, R_PARISC_DPREL21L for elf32  */
775               final_type = base_type;
776               break;
777             default:
778               return R_PARISC_NONE;
779             }
780           break;
781
782         default:
783           return R_PARISC_NONE;
784         }
785       break;
786
787     case R_HPPA_PCREL_CALL:
788       switch (format)
789         {
790         case 12:
791           switch (field)
792             {
793             case e_fsel:
794               final_type = R_PARISC_PCREL12F;
795               break;
796             default:
797               return R_PARISC_NONE;
798             }
799           break;
800
801         case 14:
802           /* Contrary to appearances, these are not calls of any sort.
803              Rather, they are loads/stores with a pcrel reloc.  */
804           switch (field)
805             {
806             case e_rsel:
807             case e_rrsel:
808             case e_rdsel:
809               final_type = R_PARISC_PCREL14R;
810               break;
811             case e_fsel:
812               if (bfd_get_mach (abfd) < 25)
813                 final_type = R_PARISC_PCREL14F;
814               else
815                 final_type = R_PARISC_PCREL16F;
816               break;
817             default:
818               return R_PARISC_NONE;
819             }
820           break;
821
822         case 17:
823           switch (field)
824             {
825             case e_rsel:
826             case e_rrsel:
827             case e_rdsel:
828               final_type = R_PARISC_PCREL17R;
829               break;
830             case e_fsel:
831               final_type = R_PARISC_PCREL17F;
832               break;
833             default:
834               return R_PARISC_NONE;
835             }
836           break;
837
838         case 21:
839           switch (field)
840             {
841             case e_lsel:
842             case e_lrsel:
843             case e_ldsel:
844             case e_nlsel:
845             case e_nlrsel:
846               final_type = R_PARISC_PCREL21L;
847               break;
848             default:
849               return R_PARISC_NONE;
850             }
851           break;
852
853         case 22:
854           switch (field)
855             {
856             case e_fsel:
857               final_type = R_PARISC_PCREL22F;
858               break;
859             default:
860               return R_PARISC_NONE;
861             }
862           break;
863
864         default:
865           return R_PARISC_NONE;
866         }
867       break;
868
869     case R_PARISC_GNU_VTENTRY:
870     case R_PARISC_GNU_VTINHERIT:
871     case R_PARISC_SEGREL32:
872     case R_PARISC_SEGBASE:
873       /* The defaults are fine for these cases.  */
874       break;
875
876     default:
877       return R_PARISC_NONE;
878     }
879
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
886 elf_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
916   return final_types;
917 }
918
919 /* Translate from an elf into field into a howto relocation pointer.  */
920
921 static void
922 elf_hppa_info_to_howto (abfd, bfd_reloc, elf_reloc)
923      bfd *abfd ATTRIBUTE_UNUSED;
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
934 static void
935 elf_hppa_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
936      bfd *abfd ATTRIBUTE_UNUSED;
937      arelent *bfd_reloc;
938      Elf_Internal_Rela *elf_reloc;
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
948 static reloc_howto_type *
949 elf_hppa_reloc_type_lookup (abfd, code)
950      bfd *abfd ATTRIBUTE_UNUSED;
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 }
960
961 /* Return TRUE if SYM represents a local label symbol.  */
962
963 static bfd_boolean
964 elf_hppa_is_local_label_name (abfd, name)
965      bfd *abfd ATTRIBUTE_UNUSED;
966      const char *name;
967 {
968   if (name[0] == 'L' && name[1] == '$')
969     return 1;
970   return _bfd_elf_is_local_label_name (abfd, name);
971 }
972
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
976 static bfd_boolean
977 elf_hppa_fake_sections (abfd, hdr, sec)
978      bfd *abfd;
979      Elf_Internal_Shdr *hdr;
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     {
988       int indx;
989       asection *asec;
990 #if ARCH_SIZE == 64
991       hdr->sh_type = SHT_LOPROC + 1;
992 #else
993       hdr->sh_type = 1;
994 #endif
995       /* ?!? How are unwinds supposed to work for symbols in arbitrary
996          sections?  Or what if we have multiple .text sections in a single
997          .o file?  HP really messed up on this one.
998
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!  */
1004       for (asec = abfd->sections, indx = 1; asec; asec = asec->next, indx++)
1005         {
1006           if (asec->name && strcmp (asec->name, ".text") == 0)
1007             {
1008               hdr->sh_info = indx;
1009               break;
1010             }
1011         }
1012
1013       /* I have no idea if this is really necessary or what it means.  */
1014       hdr->sh_entsize = 4;
1015     }
1016   return TRUE;
1017 }
1018
1019 static void
1020 elf_hppa_final_write_processing (abfd, linker)
1021      bfd *abfd;
1022      bfd_boolean linker ATTRIBUTE_UNUSED;
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
1047 /* Comparison function for qsort to sort unwind section during a
1048    final link.  */
1049
1050 static int
1051 hppa_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
1073 static bfd_boolean elf_hppa_sort_unwind (abfd)
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)
1091         return FALSE;
1092
1093       if (! bfd_get_section_contents (abfd, s, contents, (file_ptr) 0, size))
1094         return FALSE;
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))
1099         return FALSE;
1100     }
1101
1102   return TRUE;
1103 }
1104
1105 #if ARCH_SIZE == 64
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
1110 static bfd_boolean
1111 elf_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;
1121
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;
1129
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
1137   return TRUE;
1138 }
1139
1140 static bfd_boolean
1141 elf_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
1147   if (h->root.type == bfd_link_hash_warning)
1148     h = (struct elf_link_hash_entry *) h->root.u.i.link;
1149
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
1155      libraries contain references to undefined symbols.
1156
1157      So we twiddle the flags associated with such symbols so that they
1158      will not trigger the warning.  ?!? FIXME.  This is horribly fragile.
1159
1160      Ultimately we should have better controls over the generic ELF BFD
1161      linker code.  */
1162   if (! info->relocatable
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
1173   return TRUE;
1174 }
1175
1176 static bfd_boolean
1177 elf_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
1183   if (h->root.type == bfd_link_hash_warning)
1184     h = (struct elf_link_hash_entry *) h->root.u.i.link;
1185
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
1194      will not trigger the warning.  ?!? FIXME.  This is horribly fragile.
1195
1196      Ultimately we should have better controls over the generic ELF BFD
1197      linker code.  */
1198   if (! info->relocatable
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
1210   return TRUE;
1211 }
1212
1213 static bfd_boolean
1214 elf_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
1230 /* Record the lowest address for the data and text segments.  */
1231 static void
1232 elf_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;
1239
1240   hppa_info = (struct elf64_hppa_link_hash_table *)data;
1241
1242   value = section->vma - section->filepos;
1243
1244   if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1245        == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1246       && value < hppa_info->text_segment_base)
1247     hppa_info->text_segment_base = value;
1248   else if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1249             == (SEC_ALLOC | SEC_LOAD))
1250            && value < hppa_info->data_segment_base)
1251     hppa_info->data_segment_base = value;
1252 }
1253
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
1260 static bfd_boolean
1261 elf_hppa_final_link (abfd, info)
1262      bfd *abfd;
1263      struct bfd_link_info *info;
1264 {
1265   bfd_boolean retval;
1266   struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
1267
1268   if (! info->relocatable)
1269     {
1270       struct elf_link_hash_entry *gp;
1271       bfd_vma gp_val;
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.  */
1277       gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
1278                                  FALSE, FALSE);
1279
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.  */
1286           gp->root.u.def.value += hppa_info->gp_offset;
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;
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
1300              that order) and set __gp to the base address of whichever
1301              section is found first.  */
1302
1303           sec = hppa_info->plt_sec;
1304           if (sec && ! (sec->flags & SEC_EXCLUDE))
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;
1311               if (!sec || (sec->flags & SEC_EXCLUDE))
1312                 sec = hppa_info->opd_sec;
1313               if (!sec || (sec->flags & SEC_EXCLUDE))
1314                 sec = bfd_get_section_by_name (abfd, ".data");
1315               if (!sec || (sec->flags & SEC_EXCLUDE))
1316                 return FALSE;
1317
1318               gp_val = sec->output_offset + sec->output_section->vma;
1319             }
1320         }
1321
1322       /* Install whatever value we found/computed for __gp.  */
1323       _bfd_set_gp_value (abfd, gp_val);
1324     }
1325
1326   /* We need to know the base of the text and data segments so that we
1327      can perform SEGREL relocations.  We will record the base addresses
1328      when we encounter the first SEGREL relocation.  */
1329   hppa_info->text_segment_base = (bfd_vma)-1;
1330   hppa_info->data_segment_base = (bfd_vma)-1;
1331
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
1345   /* Invoke the regular ELF backend linker to do all the work.  */
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
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
1357   return retval;
1358 }
1359
1360 /* Relocate an HPPA ELF section.  */
1361
1362 static bfd_boolean
1363 elf_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;
1377   struct elf64_hppa_link_hash_table *hppa_info;
1378
1379   if (info->relocatable)
1380     return TRUE;
1381
1382   hppa_info = elf64_hppa_hash_table (info);
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;
1390       reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
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;
1398       const char *dyn_name;
1399       char *dynh_buf = NULL;
1400       size_t dynh_buflen = 0;
1401       struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
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);
1407           return FALSE;
1408         }
1409
1410       /* This is a final link.  */
1411       r_symndx = ELF_R_SYM (rel->r_info);
1412       h = NULL;
1413       sym = NULL;
1414       sym_sec = NULL;
1415       if (r_symndx < symtab_hdr->sh_info)
1416         {
1417           /* This is a local symbol.  */
1418           sym = local_syms + r_symndx;
1419           sym_sec = local_sections[r_symndx];
1420           relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
1421
1422           /* If this symbol has an entry in the PA64 dynamic hash
1423              table, then get it.  */
1424           dyn_name = get_dyn_name (input_section, h, rel,
1425                                    &dynh_buf, &dynh_buflen);
1426           dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1427                                               dyn_name, FALSE, FALSE);
1428
1429         }
1430       else
1431         {
1432           /* This is not a local symbol.  */
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;
1444
1445               /* If this symbol has an entry in the PA64 dynamic hash
1446                  table, then get it.  */
1447               dyn_name = get_dyn_name (input_section, h, rel,
1448                                        &dynh_buf, &dynh_buflen);
1449               dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1450                                                   dyn_name, FALSE, FALSE);
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"),
1459                      bfd_archive_filename (input_bfd), h->root.root.string,
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;
1471             }
1472           /* Allow undefined symbols in shared libraries.  */
1473           else if (info->shared && !info->no_undefined
1474                    && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
1475             {
1476               if (info->symbolic)
1477                 (*info->callbacks->undefined_symbol)
1478                   (info, h->root.root.string, input_bfd,
1479                    input_section, rel->r_offset, FALSE);
1480
1481               /* If this symbol has an entry in the PA64 dynamic hash
1482                  table, then get it.  */
1483               dyn_name = get_dyn_name (input_section, h, rel,
1484                                        &dynh_buf, &dynh_buflen);
1485               dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1486                                                   dyn_name, FALSE, FALSE);
1487
1488               if (dyn_h == NULL)
1489                 {
1490                   (*_bfd_error_handler)
1491                     (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1492                      bfd_archive_filename (input_bfd), h->root.root.string,
1493                      bfd_get_section_name (input_bfd, input_section));
1494                 }
1495               relocation = 0;
1496             }
1497           else if (h->root.type == bfd_link_hash_undefweak)
1498             {
1499               dyn_name = get_dyn_name (input_section, h, rel,
1500                                        &dynh_buf, &dynh_buflen);
1501               dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1502                                                   dyn_name, FALSE, FALSE);
1503
1504               if (dyn_h == NULL)
1505                 {
1506                   (*_bfd_error_handler)
1507                     (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1508                      bfd_archive_filename (input_bfd), h->root.root.string,
1509                      bfd_get_section_name (input_bfd, input_section));
1510                 }
1511               relocation = 0;
1512             }
1513           else
1514             {
1515               /* Ignore dynamic loader defined symbols.  */
1516               if (elf_hppa_is_dynamic_loader_symbol (h->root.root.string))
1517                 relocation = 0;
1518               else
1519                 {
1520                   if (!((*info->callbacks->undefined_symbol)
1521                         (info, h->root.root.string, input_bfd,
1522                          input_section, rel->r_offset, TRUE)))
1523                     return FALSE;
1524                   break;
1525                 }
1526             }
1527         }
1528
1529       if (h != NULL)
1530         sym_name = h->root.root.string;
1531       else
1532         {
1533           sym_name = bfd_elf_string_from_elf_section (input_bfd,
1534                                                       symtab_hdr->sh_link,
1535                                                       sym->st_name);
1536           if (sym_name == NULL)
1537             return FALSE;
1538           if (*sym_name == '\0')
1539             sym_name = bfd_section_name (input_bfd, sym_sec);
1540         }
1541
1542       r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1543                                         input_section, contents,
1544                                         relocation, info, sym_sec,
1545                                         h, dyn_h);
1546
1547       if (r != bfd_reloc_ok)
1548         {
1549           switch (r)
1550             {
1551             default:
1552               abort ();
1553             case bfd_reloc_overflow:
1554               {
1555                 if (!((*info->callbacks->reloc_overflow)
1556                       (info, sym_name, howto->name, (bfd_vma) 0,
1557                         input_bfd, input_section, rel->r_offset)))
1558                   return FALSE;
1559               }
1560               break;
1561             }
1562         }
1563     }
1564   return TRUE;
1565 }
1566
1567 /* Compute the value for a relocation (REL) during a final link stage,
1568    then insert the value into the proper location in CONTENTS.
1569
1570    VALUE is a tentative value for the relocation and may be overridden
1571    and modified here based on the specific relocation to be performed.
1572
1573    For example we do conversions for PC-relative branches in this routine
1574    or redirection of calls to external routines to stubs.
1575
1576    The work of actually applying the relocation is left to a helper
1577    routine in an attempt to reduce the complexity and size of this
1578    function.  */
1579
1580 static bfd_reloc_status_type
1581 elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1582                               input_section, contents, value,
1583                               info, sym_sec, h, dyn_h)
1584      Elf_Internal_Rela *rel;
1585      bfd *input_bfd;
1586      bfd *output_bfd;
1587      asection *input_section;
1588      bfd_byte *contents;
1589      bfd_vma value;
1590      struct bfd_link_info *info;
1591      asection *sym_sec;
1592      struct elf_link_hash_entry *h ATTRIBUTE_UNUSED;
1593      struct elf64_hppa_dyn_hash_entry *dyn_h;
1594 {
1595   int insn;
1596   bfd_vma offset = rel->r_offset;
1597   bfd_signed_vma addend = rel->r_addend;
1598   reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
1599   unsigned int r_type = howto->type;
1600   bfd_byte *hit_data = contents + offset;
1601   struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
1602
1603   insn = bfd_get_32 (input_bfd, hit_data);
1604
1605   switch (r_type)
1606     {
1607     case R_PARISC_NONE:
1608       break;
1609
1610     /* Basic function call support.
1611
1612        Note for a call to a function defined in another dynamic library
1613        we want to redirect the call to a stub.  */
1614
1615     /* Random PC relative relocs.  */
1616     case R_PARISC_PCREL21L:
1617     case R_PARISC_PCREL14R:
1618     case R_PARISC_PCREL14F:
1619     case R_PARISC_PCREL14WR:
1620     case R_PARISC_PCREL14DR:
1621     case R_PARISC_PCREL16F:
1622     case R_PARISC_PCREL16WF:
1623     case R_PARISC_PCREL16DF:
1624       {
1625         /* If this is a call to a function defined in another dynamic
1626            library, then redirect the call to the local stub for this
1627            function.  */
1628         if (sym_sec == NULL || sym_sec->output_section == NULL)
1629           value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1630                    + hppa_info->stub_sec->output_section->vma);
1631
1632         /* Turn VALUE into a proper PC relative address.  */
1633         value -= (offset + input_section->output_offset
1634                   + input_section->output_section->vma);
1635
1636         /* Adjust for any field selectors.  */
1637         if (r_type == R_PARISC_PCREL21L)
1638           value = hppa_field_adjust (value, -8 + addend, e_lsel);
1639         else if (r_type == R_PARISC_PCREL14F
1640                  || r_type == R_PARISC_PCREL16F
1641                  || r_type == R_PARISC_PCREL16WF
1642                  || r_type == R_PARISC_PCREL16DF)
1643           value = hppa_field_adjust (value, -8 + addend, e_fsel);
1644         else
1645           value = hppa_field_adjust (value, -8 + addend, e_rsel);
1646
1647         /* Apply the relocation to the given instruction.  */
1648         insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1649         break;
1650       }
1651
1652     case R_PARISC_PCREL12F:
1653     case R_PARISC_PCREL22F:
1654     case R_PARISC_PCREL17F:
1655     case R_PARISC_PCREL22C:
1656     case R_PARISC_PCREL17C:
1657     case R_PARISC_PCREL17R:
1658       {
1659         /* If this is a call to a function defined in another dynamic
1660            library, then redirect the call to the local stub for this
1661            function.  */
1662         if (sym_sec == NULL || sym_sec->output_section == NULL)
1663           value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1664                    + hppa_info->stub_sec->output_section->vma);
1665
1666         /* Turn VALUE into a proper PC relative address.  */
1667         value -= (offset + input_section->output_offset
1668                   + input_section->output_section->vma);
1669
1670         /* Adjust for any field selectors.  */
1671         if (r_type == R_PARISC_PCREL17R)
1672           value = hppa_field_adjust (value, -8 + addend, e_rsel);
1673         else
1674           value = hppa_field_adjust (value, -8 + addend, e_fsel);
1675
1676         /* All branches are implicitly shifted by 2 places.  */
1677         value >>= 2;
1678
1679         /* Apply the relocation to the given instruction.  */
1680         insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1681         break;
1682       }
1683
1684     /* Indirect references to data through the DLT.  */
1685     case R_PARISC_DLTIND14R:
1686     case R_PARISC_DLTIND14F:
1687     case R_PARISC_DLTIND14DR:
1688     case R_PARISC_DLTIND14WR:
1689     case R_PARISC_DLTIND21L:
1690     case R_PARISC_LTOFF_FPTR14R:
1691     case R_PARISC_LTOFF_FPTR14DR:
1692     case R_PARISC_LTOFF_FPTR14WR:
1693     case R_PARISC_LTOFF_FPTR21L:
1694     case R_PARISC_LTOFF_FPTR16F:
1695     case R_PARISC_LTOFF_FPTR16WF:
1696     case R_PARISC_LTOFF_FPTR16DF:
1697     case R_PARISC_LTOFF_TP21L:
1698     case R_PARISC_LTOFF_TP14R:
1699     case R_PARISC_LTOFF_TP14F:
1700     case R_PARISC_LTOFF_TP14WR:
1701     case R_PARISC_LTOFF_TP14DR:
1702     case R_PARISC_LTOFF_TP16F:
1703     case R_PARISC_LTOFF_TP16WF:
1704     case R_PARISC_LTOFF_TP16DF:
1705     case R_PARISC_LTOFF16F:
1706     case R_PARISC_LTOFF16WF:
1707     case R_PARISC_LTOFF16DF:
1708       {
1709         /* If this relocation was against a local symbol, then we still
1710            have not set up the DLT entry (it's not convenient to do so
1711            in the "finalize_dlt" routine because it is difficult to get
1712            to the local symbol's value).
1713
1714            So, if this is a local symbol (h == NULL), then we need to
1715            fill in its DLT entry.
1716
1717            Similarly we may still need to set up an entry in .opd for
1718            a local function which had its address taken.  */
1719         if (dyn_h->h == NULL)
1720           {
1721             /* Now do .opd creation if needed.  */
1722             if (r_type == R_PARISC_LTOFF_FPTR14R
1723                 || r_type == R_PARISC_LTOFF_FPTR14DR
1724                 || r_type == R_PARISC_LTOFF_FPTR14WR
1725                 || r_type == R_PARISC_LTOFF_FPTR21L
1726                 || r_type == R_PARISC_LTOFF_FPTR16F
1727                 || r_type == R_PARISC_LTOFF_FPTR16WF
1728                 || r_type == R_PARISC_LTOFF_FPTR16DF)
1729               {
1730                 /* The first two words of an .opd entry are zero.  */
1731                 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset,
1732                         0, 16);
1733
1734                 /* The next word is the address of the function.  */
1735                 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
1736                             (hppa_info->opd_sec->contents
1737                              + dyn_h->opd_offset + 16));
1738
1739                 /* The last word is our local __gp value.  */
1740                 value = _bfd_get_gp_value
1741                           (hppa_info->opd_sec->output_section->owner);
1742                 bfd_put_64 (hppa_info->opd_sec->owner, value,
1743                             (hppa_info->opd_sec->contents
1744                              + dyn_h->opd_offset + 24));
1745
1746                 /* The DLT value is the address of the .opd entry.  */
1747                 value = (dyn_h->opd_offset
1748                          + hppa_info->opd_sec->output_offset
1749                          + hppa_info->opd_sec->output_section->vma);
1750                 addend = 0;
1751               }
1752
1753             bfd_put_64 (hppa_info->dlt_sec->owner,
1754                         value + addend,
1755                         hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1756           }
1757
1758         /* We want the value of the DLT offset for this symbol, not
1759            the symbol's actual address.  Note that __gp may not point
1760            to the start of the DLT, so we have to compute the absolute
1761            address, then subtract out the value of __gp.  */
1762         value = (dyn_h->dlt_offset
1763                  + hppa_info->dlt_sec->output_offset
1764                  + hppa_info->dlt_sec->output_section->vma);
1765         value -= _bfd_get_gp_value (output_bfd);
1766
1767         /* All DLTIND relocations are basically the same at this point,
1768            except that we need different field selectors for the 21bit
1769            version vs the 14bit versions.  */
1770         if (r_type == R_PARISC_DLTIND21L
1771             || r_type == R_PARISC_LTOFF_FPTR21L
1772             || r_type == R_PARISC_LTOFF_TP21L)
1773           value = hppa_field_adjust (value, 0, e_lsel);
1774         else if (r_type == R_PARISC_DLTIND14F
1775                  || r_type == R_PARISC_LTOFF_FPTR16F
1776                  || r_type == R_PARISC_LTOFF_FPTR16WF
1777                  || r_type == R_PARISC_LTOFF_FPTR16DF
1778                  || r_type == R_PARISC_LTOFF16F
1779                  || r_type == R_PARISC_LTOFF16DF
1780                  || r_type == R_PARISC_LTOFF16WF
1781                  || r_type == R_PARISC_LTOFF_TP16F
1782                  || r_type == R_PARISC_LTOFF_TP16WF
1783                  || r_type == R_PARISC_LTOFF_TP16DF)
1784           value = hppa_field_adjust (value, 0, e_fsel);
1785         else
1786           value = hppa_field_adjust (value, 0, e_rsel);
1787
1788         insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1789         break;
1790       }
1791
1792     case R_PARISC_DLTREL14R:
1793     case R_PARISC_DLTREL14F:
1794     case R_PARISC_DLTREL14DR:
1795     case R_PARISC_DLTREL14WR:
1796     case R_PARISC_DLTREL21L:
1797     case R_PARISC_DPREL21L:
1798     case R_PARISC_DPREL14WR:
1799     case R_PARISC_DPREL14DR:
1800     case R_PARISC_DPREL14R:
1801     case R_PARISC_DPREL14F:
1802     case R_PARISC_GPREL16F:
1803     case R_PARISC_GPREL16WF:
1804     case R_PARISC_GPREL16DF:
1805       {
1806         /* Subtract out the global pointer value to make value a DLT
1807            relative address.  */
1808         value -= _bfd_get_gp_value (output_bfd);
1809
1810         /* All DLTREL relocations are basically the same at this point,
1811            except that we need different field selectors for the 21bit
1812            version vs the 14bit versions.  */
1813         if (r_type == R_PARISC_DLTREL21L
1814             || r_type == R_PARISC_DPREL21L)
1815           value = hppa_field_adjust (value, addend, e_lrsel);
1816         else if (r_type == R_PARISC_DLTREL14F
1817                  || r_type == R_PARISC_DPREL14F
1818                  || r_type == R_PARISC_GPREL16F
1819                  || r_type == R_PARISC_GPREL16WF
1820                  || r_type == R_PARISC_GPREL16DF)
1821           value = hppa_field_adjust (value, addend, e_fsel);
1822         else
1823           value = hppa_field_adjust (value, addend, e_rrsel);
1824
1825         insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1826         break;
1827       }
1828
1829     case R_PARISC_DIR21L:
1830     case R_PARISC_DIR17R:
1831     case R_PARISC_DIR17F:
1832     case R_PARISC_DIR14R:
1833     case R_PARISC_DIR14F:
1834     case R_PARISC_DIR14WR:
1835     case R_PARISC_DIR14DR:
1836     case R_PARISC_DIR16F:
1837     case R_PARISC_DIR16WF:
1838     case R_PARISC_DIR16DF:
1839       {
1840         /* All DIR relocations are basically the same at this point,
1841            except that branch offsets need to be divided by four, and
1842            we need different field selectors.  Note that we don't
1843            redirect absolute calls to local stubs.  */
1844
1845         if (r_type == R_PARISC_DIR21L)
1846           value = hppa_field_adjust (value, addend, e_lrsel);
1847         else if (r_type == R_PARISC_DIR17F
1848                  || r_type == R_PARISC_DIR16F
1849                  || r_type == R_PARISC_DIR16WF
1850                  || r_type == R_PARISC_DIR16DF
1851                  || r_type == R_PARISC_DIR14F)
1852           value = hppa_field_adjust (value, addend, e_fsel);
1853         else
1854           value = hppa_field_adjust (value, addend, e_rrsel);
1855
1856         if (r_type == R_PARISC_DIR17R || r_type == R_PARISC_DIR17F)
1857           {
1858             /* All branches are implicitly shifted by 2 places.  */
1859             value >>= 2;
1860           }
1861
1862         insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1863         break;
1864       }
1865
1866     case R_PARISC_PLTOFF21L:
1867     case R_PARISC_PLTOFF14R:
1868     case R_PARISC_PLTOFF14F:
1869     case R_PARISC_PLTOFF14WR:
1870     case R_PARISC_PLTOFF14DR:
1871     case R_PARISC_PLTOFF16F:
1872     case R_PARISC_PLTOFF16WF:
1873     case R_PARISC_PLTOFF16DF:
1874       {
1875         /* We want the value of the PLT offset for this symbol, not
1876            the symbol's actual address.  Note that __gp may not point
1877            to the start of the DLT, so we have to compute the absolute
1878            address, then subtract out the value of __gp.  */
1879         value = (dyn_h->plt_offset
1880                  + hppa_info->plt_sec->output_offset
1881                  + hppa_info->plt_sec->output_section->vma);
1882         value -= _bfd_get_gp_value (output_bfd);
1883
1884         /* All PLTOFF relocations are basically the same at this point,
1885            except that we need different field selectors for the 21bit
1886            version vs the 14bit versions.  */
1887         if (r_type == R_PARISC_PLTOFF21L)
1888           value = hppa_field_adjust (value, addend, e_lrsel);
1889         else if (r_type == R_PARISC_PLTOFF14F
1890                  || r_type == R_PARISC_PLTOFF16F
1891                  || r_type == R_PARISC_PLTOFF16WF
1892                  || r_type == R_PARISC_PLTOFF16DF)
1893           value = hppa_field_adjust (value, addend, e_fsel);
1894         else
1895           value = hppa_field_adjust (value, addend, e_rrsel);
1896
1897         insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1898         break;
1899       }
1900
1901     case R_PARISC_LTOFF_FPTR32:
1902       {
1903         /* We may still need to create the FPTR itself if it was for
1904            a local symbol.  */
1905         if (dyn_h->h == NULL)
1906           {
1907             /* The first two words of an .opd entry are zero.  */
1908             memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1909
1910             /* The next word is the address of the function.  */
1911             bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
1912                         (hppa_info->opd_sec->contents
1913                          + dyn_h->opd_offset + 16));
1914
1915             /* The last word is our local __gp value.  */
1916             value = _bfd_get_gp_value
1917                       (hppa_info->opd_sec->output_section->owner);
1918             bfd_put_64 (hppa_info->opd_sec->owner, value,
1919                         hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1920
1921             /* The DLT value is the address of the .opd entry.  */
1922             value = (dyn_h->opd_offset
1923                      + hppa_info->opd_sec->output_offset
1924                      + hppa_info->opd_sec->output_section->vma);
1925
1926             bfd_put_64 (hppa_info->dlt_sec->owner,
1927                         value,
1928                         hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1929           }
1930
1931         /* We want the value of the DLT offset for this symbol, not
1932            the symbol's actual address.  Note that __gp may not point
1933            to the start of the DLT, so we have to compute the absolute
1934            address, then subtract out the value of __gp.  */
1935         value = (dyn_h->dlt_offset
1936                  + hppa_info->dlt_sec->output_offset
1937                  + hppa_info->dlt_sec->output_section->vma);
1938         value -= _bfd_get_gp_value (output_bfd);
1939         bfd_put_32 (input_bfd, value, hit_data);
1940         return bfd_reloc_ok;
1941       }
1942
1943     case R_PARISC_LTOFF_FPTR64:
1944     case R_PARISC_LTOFF_TP64:
1945       {
1946         /* We may still need to create the FPTR itself if it was for
1947            a local symbol.  */
1948         if (dyn_h->h == NULL && r_type == R_PARISC_LTOFF_FPTR64)
1949           {
1950             /* The first two words of an .opd entry are zero.  */
1951             memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1952
1953             /* The next word is the address of the function.  */
1954             bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
1955                         (hppa_info->opd_sec->contents
1956                          + dyn_h->opd_offset + 16));
1957
1958             /* The last word is our local __gp value.  */
1959             value = _bfd_get_gp_value
1960                       (hppa_info->opd_sec->output_section->owner);
1961             bfd_put_64 (hppa_info->opd_sec->owner, value,
1962                         hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1963
1964             /* The DLT value is the address of the .opd entry.  */
1965             value = (dyn_h->opd_offset
1966                      + hppa_info->opd_sec->output_offset
1967                      + hppa_info->opd_sec->output_section->vma);
1968
1969             bfd_put_64 (hppa_info->dlt_sec->owner,
1970                         value,
1971                         hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1972           }
1973
1974         /* We want the value of the DLT offset for this symbol, not
1975            the symbol's actual address.  Note that __gp may not point
1976            to the start of the DLT, so we have to compute the absolute
1977            address, then subtract out the value of __gp.  */
1978         value = (dyn_h->dlt_offset
1979                  + hppa_info->dlt_sec->output_offset
1980                  + hppa_info->dlt_sec->output_section->vma);
1981         value -= _bfd_get_gp_value (output_bfd);
1982         bfd_put_64 (input_bfd, value, hit_data);
1983         return bfd_reloc_ok;
1984       }
1985
1986     case R_PARISC_DIR32:
1987       bfd_put_32 (input_bfd, value + addend, hit_data);
1988       return bfd_reloc_ok;
1989
1990     case R_PARISC_DIR64:
1991       bfd_put_64 (input_bfd, value + addend, hit_data);
1992       return bfd_reloc_ok;
1993
1994     case R_PARISC_GPREL64:
1995       /* Subtract out the global pointer value to make value a DLT
1996          relative address.  */
1997       value -= _bfd_get_gp_value (output_bfd);
1998
1999       bfd_put_64 (input_bfd, value + addend, hit_data);
2000       return bfd_reloc_ok;
2001
2002     case R_PARISC_LTOFF64:
2003         /* We want the value of the DLT offset for this symbol, not
2004            the symbol's actual address.  Note that __gp may not point
2005            to the start of the DLT, so we have to compute the absolute
2006            address, then subtract out the value of __gp.  */
2007       value = (dyn_h->dlt_offset
2008                + hppa_info->dlt_sec->output_offset
2009                + hppa_info->dlt_sec->output_section->vma);
2010       value -= _bfd_get_gp_value (output_bfd);
2011
2012       bfd_put_64 (input_bfd, value + addend, hit_data);
2013       return bfd_reloc_ok;
2014
2015     case R_PARISC_PCREL32:
2016       {
2017         /* If this is a call to a function defined in another dynamic
2018            library, then redirect the call to the local stub for this
2019            function.  */
2020         if (sym_sec == NULL || sym_sec->output_section == NULL)
2021           value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
2022                    + hppa_info->stub_sec->output_section->vma);
2023
2024         /* Turn VALUE into a proper PC relative address.  */
2025         value -= (offset + input_section->output_offset
2026                   + input_section->output_section->vma);
2027
2028         value += addend;
2029         value -= 8;
2030         bfd_put_32 (input_bfd, value, hit_data);
2031         return bfd_reloc_ok;
2032       }
2033
2034     case R_PARISC_PCREL64:
2035       {
2036         /* If this is a call to a function defined in another dynamic
2037            library, then redirect the call to the local stub for this
2038            function.  */
2039         if (sym_sec == NULL || sym_sec->output_section == NULL)
2040           value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
2041                    + hppa_info->stub_sec->output_section->vma);
2042
2043         /* Turn VALUE into a proper PC relative address.  */
2044         value -= (offset + input_section->output_offset
2045                   + input_section->output_section->vma);
2046
2047         value += addend;
2048         value -= 8;
2049         bfd_put_64 (input_bfd, value, hit_data);
2050         return bfd_reloc_ok;
2051       }
2052
2053     case R_PARISC_FPTR64:
2054       {
2055         /* We may still need to create the FPTR itself if it was for
2056            a local symbol.  */
2057         if (dyn_h->h == NULL)
2058           {
2059             /* The first two words of an .opd entry are zero.  */
2060             memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
2061
2062             /* The next word is the address of the function.  */
2063             bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
2064                         (hppa_info->opd_sec->contents
2065                          + dyn_h->opd_offset + 16));
2066
2067             /* The last word is our local __gp value.  */
2068             value = _bfd_get_gp_value
2069                       (hppa_info->opd_sec->output_section->owner);
2070             bfd_put_64 (hppa_info->opd_sec->owner, value,
2071                         hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
2072           }
2073
2074         if (dyn_h->want_opd)
2075           /* We want the value of the OPD offset for this symbol.  */
2076           value = (dyn_h->opd_offset
2077                    + hppa_info->opd_sec->output_offset
2078                    + hppa_info->opd_sec->output_section->vma);
2079         else
2080           /* We want the address of the symbol.  */
2081           value += addend;
2082
2083         bfd_put_64 (input_bfd, value, hit_data);
2084         return bfd_reloc_ok;
2085       }
2086
2087     case R_PARISC_SECREL32:
2088       bfd_put_32 (input_bfd,
2089                   value + addend - sym_sec->output_section->vma,
2090                   hit_data);
2091       return bfd_reloc_ok;
2092
2093     case R_PARISC_SEGREL32:
2094     case R_PARISC_SEGREL64:
2095       {
2096         /* If this is the first SEGREL relocation, then initialize
2097            the segment base values.  */
2098         if (hppa_info->text_segment_base == (bfd_vma) -1)
2099           bfd_map_over_sections (output_bfd, elf_hppa_record_segment_addrs,
2100                                  hppa_info);
2101
2102         /* VALUE holds the absolute address.  We want to include the
2103            addend, then turn it into a segment relative address.
2104
2105            The segment is derived from SYM_SEC.  We assume that there are
2106            only two segments of note in the resulting executable/shlib.
2107            A readonly segment (.text) and a readwrite segment (.data).  */
2108         value += addend;
2109
2110         if (sym_sec->flags & SEC_CODE)
2111           value -= hppa_info->text_segment_base;
2112         else
2113           value -= hppa_info->data_segment_base;
2114
2115         if (r_type == R_PARISC_SEGREL32)
2116           bfd_put_32 (input_bfd, value, hit_data);
2117         else
2118           bfd_put_64 (input_bfd, value, hit_data);
2119         return bfd_reloc_ok;
2120       }
2121
2122     /* Something we don't know how to handle.  */
2123     default:
2124       return bfd_reloc_notsupported;
2125     }
2126
2127   /* Update the instruction word.  */
2128   bfd_put_32 (input_bfd, (bfd_vma) insn, hit_data);
2129   return bfd_reloc_ok;
2130 }
2131
2132 /* Relocate the given INSN.  VALUE should be the actual value we want
2133    to insert into the instruction, ie by this point we should not be
2134    concerned with computing an offset relative to the DLT, PC, etc.
2135    Instead this routine is meant to handle the bit manipulations needed
2136    to insert the relocation into the given instruction.  */
2137
2138 static int
2139 elf_hppa_relocate_insn (insn, sym_value, r_type)
2140      int insn;
2141      int sym_value;
2142      unsigned int r_type;
2143 {
2144   switch (r_type)
2145     {
2146     /* This is any 22 bit branch.  In PA2.0 syntax it corresponds to
2147        the "B" instruction.  */
2148     case R_PARISC_PCREL22F:
2149     case R_PARISC_PCREL22C:
2150       return (insn & ~0x3ff1ffd) | re_assemble_22 (sym_value);
2151
2152       /* This is any 12 bit branch.  */
2153     case R_PARISC_PCREL12F:
2154       return (insn & ~0x1ffd) | re_assemble_12 (sym_value);
2155
2156     /* This is any 17 bit branch.  In PA2.0 syntax it also corresponds
2157        to the "B" instruction as well as BE.  */
2158     case R_PARISC_PCREL17F:
2159     case R_PARISC_DIR17F:
2160     case R_PARISC_DIR17R:
2161     case R_PARISC_PCREL17C:
2162     case R_PARISC_PCREL17R:
2163       return (insn & ~0x1f1ffd) | re_assemble_17 (sym_value);
2164
2165     /* ADDIL or LDIL instructions.  */
2166     case R_PARISC_DLTREL21L:
2167     case R_PARISC_DLTIND21L:
2168     case R_PARISC_LTOFF_FPTR21L:
2169     case R_PARISC_PCREL21L:
2170     case R_PARISC_LTOFF_TP21L:
2171     case R_PARISC_DPREL21L:
2172     case R_PARISC_PLTOFF21L:
2173     case R_PARISC_DIR21L:
2174       return (insn & ~0x1fffff) | re_assemble_21 (sym_value);
2175
2176     /* LDO and integer loads/stores with 14 bit displacements.  */
2177     case R_PARISC_DLTREL14R:
2178     case R_PARISC_DLTREL14F:
2179     case R_PARISC_DLTIND14R:
2180     case R_PARISC_DLTIND14F:
2181     case R_PARISC_LTOFF_FPTR14R:
2182     case R_PARISC_PCREL14R:
2183     case R_PARISC_PCREL14F:
2184     case R_PARISC_LTOFF_TP14R:
2185     case R_PARISC_LTOFF_TP14F:
2186     case R_PARISC_DPREL14R:
2187     case R_PARISC_DPREL14F:
2188     case R_PARISC_PLTOFF14R:
2189     case R_PARISC_PLTOFF14F:
2190     case R_PARISC_DIR14R:
2191     case R_PARISC_DIR14F:
2192       return (insn & ~0x3fff) | low_sign_unext (sym_value, 14);
2193
2194     /* PA2.0W LDO and integer loads/stores with 16 bit displacements.  */
2195     case R_PARISC_LTOFF_FPTR16F:
2196     case R_PARISC_PCREL16F:
2197     case R_PARISC_LTOFF_TP16F:
2198     case R_PARISC_GPREL16F:
2199     case R_PARISC_PLTOFF16F:
2200     case R_PARISC_DIR16F:
2201     case R_PARISC_LTOFF16F:
2202       return (insn & ~0xffff) | re_assemble_16 (sym_value);
2203
2204     /* Doubleword loads and stores with a 14 bit displacement.  */
2205     case R_PARISC_DLTREL14DR:
2206     case R_PARISC_DLTIND14DR:
2207     case R_PARISC_LTOFF_FPTR14DR:
2208     case R_PARISC_LTOFF_FPTR16DF:
2209     case R_PARISC_PCREL14DR:
2210     case R_PARISC_PCREL16DF:
2211     case R_PARISC_LTOFF_TP14DR:
2212     case R_PARISC_LTOFF_TP16DF:
2213     case R_PARISC_DPREL14DR:
2214     case R_PARISC_GPREL16DF:
2215     case R_PARISC_PLTOFF14DR:
2216     case R_PARISC_PLTOFF16DF:
2217     case R_PARISC_DIR14DR:
2218     case R_PARISC_DIR16DF:
2219     case R_PARISC_LTOFF16DF:
2220       return (insn & ~0x3ff1) | (((sym_value & 0x2000) >> 13)
2221                                  | ((sym_value & 0x1ff8) << 1));
2222
2223     /* Floating point single word load/store instructions.  */
2224     case R_PARISC_DLTREL14WR:
2225     case R_PARISC_DLTIND14WR:
2226     case R_PARISC_LTOFF_FPTR14WR:
2227     case R_PARISC_LTOFF_FPTR16WF:
2228     case R_PARISC_PCREL14WR:
2229     case R_PARISC_PCREL16WF:
2230     case R_PARISC_LTOFF_TP14WR:
2231     case R_PARISC_LTOFF_TP16WF:
2232     case R_PARISC_DPREL14WR:
2233     case R_PARISC_GPREL16WF:
2234     case R_PARISC_PLTOFF14WR:
2235     case R_PARISC_PLTOFF16WF:
2236     case R_PARISC_DIR16WF:
2237     case R_PARISC_DIR14WR:
2238     case R_PARISC_LTOFF16WF:
2239       return (insn & ~0x3ff9) | (((sym_value & 0x2000) >> 13)
2240                                  | ((sym_value & 0x1ffc) << 1));
2241
2242     default:
2243       return insn;
2244     }
2245 }
2246 #endif