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