1/* Common code for PA ELF implementations.
2   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
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
49static 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
584elf_hppa_reloc_type
585elf_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	default:
749	  return R_PARISC_NONE;
750	}
751      break;
752
753    case R_HPPA_PCREL_CALL:
754      switch (format)
755	{
756	case 12:
757	  switch (field)
758	    {
759	    case e_fsel:
760	      final_type = R_PARISC_PCREL12F;
761	      break;
762	    default:
763	      return R_PARISC_NONE;
764	    }
765	  break;
766
767	case 14:
768	  /* Contrary to appearances, these are not calls of any sort.
769	     Rather, they are loads/stores with a pcrel reloc.  */
770	  switch (field)
771	    {
772	    case e_rsel:
773	    case e_rrsel:
774	    case e_rdsel:
775	      final_type = R_PARISC_PCREL14R;
776	      break;
777	    case e_fsel:
778	      if (bfd_get_mach (abfd) < 25)
779		final_type = R_PARISC_PCREL14F;
780	      else
781		final_type = R_PARISC_PCREL16F;
782	      break;
783	    default:
784	      return R_PARISC_NONE;
785	    }
786	  break;
787
788	case 17:
789	  switch (field)
790	    {
791	    case e_rsel:
792	    case e_rrsel:
793	    case e_rdsel:
794	      final_type = R_PARISC_PCREL17R;
795	      break;
796	    case e_fsel:
797	      final_type = R_PARISC_PCREL17F;
798	      break;
799	    default:
800	      return R_PARISC_NONE;
801	    }
802	  break;
803
804	case 21:
805	  switch (field)
806	    {
807	    case e_lsel:
808	    case e_lrsel:
809	    case e_ldsel:
810	    case e_nlsel:
811	    case e_nlrsel:
812	      final_type = R_PARISC_PCREL21L;
813	      break;
814	    default:
815	      return R_PARISC_NONE;
816	    }
817	  break;
818
819	case 22:
820	  switch (field)
821	    {
822	    case e_fsel:
823	      final_type = R_PARISC_PCREL22F;
824	      break;
825	    default:
826	      return R_PARISC_NONE;
827	    }
828	  break;
829
830	case 32:
831	  switch (field)
832	    {
833	    case e_fsel:
834	      final_type = R_PARISC_PCREL32;
835	      break;
836	    default:
837	      return R_PARISC_NONE;
838	    }
839	  break;
840
841	case 64:
842	  switch (field)
843	    {
844	    case e_fsel:
845	      final_type = R_PARISC_PCREL64;
846	      break;
847	    default:
848	      return R_PARISC_NONE;
849	    }
850	  break;
851
852	default:
853	  return R_PARISC_NONE;
854	}
855      break;
856
857    case R_PARISC_TLS_GD21L:
858      switch (field)
859	{
860	  case e_ltsel:
861	  case e_lrsel:
862	    final_type = R_PARISC_TLS_GD21L;
863	    break;
864	  case e_rtsel:
865	  case e_rrsel:
866	    final_type = R_PARISC_TLS_GD14R;
867	    break;
868	  default:
869	    return R_PARISC_NONE;
870	}
871      break;
872
873    case R_PARISC_TLS_LDM21L:
874      switch (field)
875	{
876	  case e_ltsel:
877	  case e_lrsel:
878	    final_type = R_PARISC_TLS_LDM21L;
879	    break;
880	  case e_rtsel:
881	  case e_rrsel:
882	    final_type = R_PARISC_TLS_LDM14R;
883	    break;
884	  default:
885	    return R_PARISC_NONE;
886	}
887      break;
888
889    case R_PARISC_TLS_LDO21L:
890      switch (field)
891	{
892	  case e_lrsel:
893	    final_type = R_PARISC_TLS_LDO21L;
894	    break;
895	  case e_rrsel:
896	    final_type = R_PARISC_TLS_LDO14R;
897	    break;
898	  default:
899	    return R_PARISC_NONE;
900	}
901      break;
902
903    case R_PARISC_TLS_IE21L:
904      switch (field)
905	{
906	  case e_ltsel:
907	  case e_lrsel:
908	    final_type = R_PARISC_TLS_IE21L;
909	    break;
910	  case e_rtsel:
911	  case e_rrsel:
912	    final_type = R_PARISC_TLS_IE14R;
913	    break;
914	  default:
915	    return R_PARISC_NONE;
916	}
917      break;
918
919    case R_PARISC_TLS_LE21L:
920      switch (field)
921	{
922	  case e_lrsel:
923	    final_type = R_PARISC_TLS_LE21L;
924	    break;
925	  case e_rrsel:
926	    final_type = R_PARISC_TLS_LE14R;
927	    break;
928	  default:
929	    return R_PARISC_NONE;
930	}
931      break;
932
933    case R_PARISC_GNU_VTENTRY:
934    case R_PARISC_GNU_VTINHERIT:
935    case R_PARISC_SEGREL32:
936    case R_PARISC_SEGBASE:
937      /* The defaults are fine for these cases.  */
938      break;
939
940    default:
941      return R_PARISC_NONE;
942    }
943
944  return final_type;
945}
946
947/* Return one (or more) BFD relocations which implement the base
948   relocation with modifications based on format and field.  */
949
950elf_hppa_reloc_type **
951_bfd_elf_hppa_gen_reloc_type (bfd *abfd,
952			      elf_hppa_reloc_type base_type,
953			      int format,
954			      unsigned int field,
955			      int ignore ATTRIBUTE_UNUSED,
956			      asymbol *sym ATTRIBUTE_UNUSED)
957{
958  elf_hppa_reloc_type *finaltype;
959  elf_hppa_reloc_type **final_types;
960  bfd_size_type amt = sizeof (elf_hppa_reloc_type *) * 2;
961
962  /* Allocate slots for the BFD relocation.  */
963  final_types = bfd_alloc (abfd, amt);
964  if (final_types == NULL)
965    return NULL;
966
967  /* Allocate space for the relocation itself.  */
968  amt = sizeof (elf_hppa_reloc_type);
969  finaltype = bfd_alloc (abfd, amt);
970  if (finaltype == NULL)
971    return NULL;
972
973  /* Some reasonable defaults.  */
974  final_types[0] = finaltype;
975  final_types[1] = NULL;
976
977  *finaltype = elf_hppa_reloc_final_type (abfd, base_type, format, field);
978
979  return final_types;
980}
981
982/* Translate from an elf into field into a howto relocation pointer.  */
983
984static void
985elf_hppa_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
986			arelent *bfd_reloc,
987			Elf_Internal_Rela *elf_reloc)
988{
989  BFD_ASSERT (ELF_R_TYPE (elf_reloc->r_info)
990	      < (unsigned int) R_PARISC_UNIMPLEMENTED);
991  bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
992}
993
994/* Translate from an elf into field into a howto relocation pointer.  */
995
996static void
997elf_hppa_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
998			    arelent *bfd_reloc,
999			    Elf_Internal_Rela *elf_reloc)
1000{
1001  BFD_ASSERT (ELF_R_TYPE (elf_reloc->r_info)
1002	      < (unsigned int) R_PARISC_UNIMPLEMENTED);
1003  bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
1004}
1005
1006/* Return the address of the howto table entry to perform the CODE
1007   relocation for an ARCH machine.  */
1008
1009static reloc_howto_type *
1010elf_hppa_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
1011			    bfd_reloc_code_real_type code)
1012{
1013  if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
1014    {
1015      BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
1016      return &elf_hppa_howto_table[(int) code];
1017    }
1018  return NULL;
1019}
1020
1021static reloc_howto_type *
1022elf_hppa_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
1023			    const char *r_name)
1024{
1025  unsigned int i;
1026
1027  for (i = 0;
1028       i < sizeof (elf_hppa_howto_table) / sizeof (elf_hppa_howto_table[0]);
1029       i++)
1030    if (elf_hppa_howto_table[i].name != NULL
1031	&& strcasecmp (elf_hppa_howto_table[i].name, r_name) == 0)
1032      return &elf_hppa_howto_table[i];
1033
1034  return NULL;
1035}
1036
1037/* Return TRUE if SYM represents a local label symbol.  */
1038
1039static bfd_boolean
1040elf_hppa_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
1041{
1042  if (name[0] == 'L' && name[1] == '$')
1043    return TRUE;
1044  return _bfd_elf_is_local_label_name (abfd, name);
1045}
1046
1047/* Set the correct type for an ELF section.  We do this by the
1048   section name, which is a hack, but ought to work.  */
1049
1050static bfd_boolean
1051elf_hppa_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec)
1052{
1053  const char *name;
1054
1055  name = bfd_get_section_name (abfd, sec);
1056
1057  if (strcmp (name, ".PARISC.unwind") == 0)
1058    {
1059      int indx;
1060      asection *asec;
1061
1062#if ARCH_SIZE == 64
1063      hdr->sh_type = SHT_LOPROC + 1;
1064#else
1065      hdr->sh_type = 1;
1066#endif
1067      /* ?!? How are unwinds supposed to work for symbols in arbitrary
1068	 sections?  Or what if we have multiple .text sections in a single
1069	 .o file?  HP really messed up on this one.
1070
1071	 Ugh.  We can not use elf_section_data (sec)->this_idx at this
1072	 point because it is not initialized yet.
1073
1074	 So we (gasp) recompute it here.  Hopefully nobody ever changes the
1075	 way sections are numbered in elf.c!  */
1076      for (asec = abfd->sections, indx = 1; asec; asec = asec->next, indx++)
1077	{
1078	  if (asec->name && strcmp (asec->name, ".text") == 0)
1079	    {
1080	      hdr->sh_info = indx;
1081	      break;
1082	    }
1083	}
1084
1085      /* I have no idea if this is really necessary or what it means.  */
1086      hdr->sh_entsize = 4;
1087    }
1088  return TRUE;
1089}
1090
1091static void
1092elf_hppa_final_write_processing (bfd *abfd,
1093				 bfd_boolean linker ATTRIBUTE_UNUSED)
1094{
1095  int mach = bfd_get_mach (abfd);
1096
1097  elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL
1098				     | EF_PARISC_EXT | EF_PARISC_LSB
1099				     | EF_PARISC_WIDE | EF_PARISC_NO_KABP
1100				     | EF_PARISC_LAZYSWAP);
1101
1102  if (mach == 10)
1103    elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0;
1104  else if (mach == 11)
1105    elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1;
1106  else if (mach == 20)
1107    elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0;
1108  else if (mach == 25)
1109    elf_elfheader (abfd)->e_flags |= (EF_PARISC_WIDE
1110				      | EFA_PARISC_2_0
1111				      /* The GNU tools have trapped without
1112					 option since 1993, so need to take
1113					 a step backwards with the ELF
1114					 based toolchains.  */
1115				      | EF_PARISC_TRAPNIL);
1116}
1117
1118/* Comparison function for qsort to sort unwind section during a
1119   final link.  */
1120
1121static int
1122hppa_unwind_entry_compare (const void *a, const void *b)
1123{
1124  const bfd_byte *ap, *bp;
1125  unsigned long av, bv;
1126
1127  ap = a;
1128  av = (unsigned long) ap[0] << 24;
1129  av |= (unsigned long) ap[1] << 16;
1130  av |= (unsigned long) ap[2] << 8;
1131  av |= (unsigned long) ap[3];
1132
1133  bp = b;
1134  bv = (unsigned long) bp[0] << 24;
1135  bv |= (unsigned long) bp[1] << 16;
1136  bv |= (unsigned long) bp[2] << 8;
1137  bv |= (unsigned long) bp[3];
1138
1139  return av < bv ? -1 : av > bv ? 1 : 0;
1140}
1141
1142static bfd_boolean
1143elf_hppa_sort_unwind (bfd *abfd)
1144{
1145  asection *s;
1146
1147  /* Magic section names, but this is much safer than having
1148     relocate_section remember where SEGREL32 relocs occurred.
1149     Consider what happens if someone inept creates a linker script
1150     that puts unwind information in .text.  */
1151  s = bfd_get_section_by_name (abfd, ".PARISC.unwind");
1152  if (s != NULL)
1153    {
1154      bfd_size_type size;
1155      bfd_byte *contents;
1156
1157      if (!bfd_malloc_and_get_section (abfd, s, &contents))
1158	return FALSE;
1159
1160      size = s->size;
1161      qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare);
1162
1163      if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size))
1164	return FALSE;
1165    }
1166
1167  return TRUE;
1168}
1169
1170/* What to do when ld finds relocations against symbols defined in
1171   discarded sections.  */
1172
1173static unsigned int
1174elf_hppa_action_discarded (asection *sec)
1175{
1176  if (strcmp (".PARISC.unwind", sec->name) == 0)
1177    return 0;
1178
1179  return _bfd_elf_default_action_discarded (sec);
1180}
1181
1182#if ARCH_SIZE == 64
1183/* Hook called by the linker routine which adds symbols from an object
1184   file.  HP's libraries define symbols with HP specific section
1185   indices, which we have to handle.  */
1186
1187static bfd_boolean
1188elf_hppa_add_symbol_hook (bfd *abfd,
1189			  struct bfd_link_info *info ATTRIBUTE_UNUSED,
1190			  Elf_Internal_Sym *sym,
1191			  const char **namep ATTRIBUTE_UNUSED,
1192			  flagword *flagsp ATTRIBUTE_UNUSED,
1193			  asection **secp,
1194			  bfd_vma *valp)
1195{
1196  int index = sym->st_shndx;
1197
1198  switch (index)
1199    {
1200    case SHN_PARISC_ANSI_COMMON:
1201      *secp = bfd_make_section_old_way (abfd, ".PARISC.ansi.common");
1202      (*secp)->flags |= SEC_IS_COMMON;
1203      *valp = sym->st_size;
1204      break;
1205
1206    case SHN_PARISC_HUGE_COMMON:
1207      *secp = bfd_make_section_old_way (abfd, ".PARISC.huge.common");
1208      (*secp)->flags |= SEC_IS_COMMON;
1209      *valp = sym->st_size;
1210      break;
1211    }
1212
1213  return TRUE;
1214}
1215
1216static bfd_boolean
1217elf_hppa_unmark_useless_dynamic_symbols (struct elf_link_hash_entry *h,
1218					 void *data)
1219{
1220  struct bfd_link_info *info = data;
1221
1222  if (h->root.type == bfd_link_hash_warning)
1223    h = (struct elf_link_hash_entry *) h->root.u.i.link;
1224
1225  /* If we are not creating a shared library, and this symbol is
1226     referenced by a shared library but is not defined anywhere, then
1227     the generic code will warn that it is undefined.
1228
1229     This behavior is undesirable on HPs since the standard shared
1230     libraries contain references to undefined symbols.
1231
1232     So we twiddle the flags associated with such symbols so that they
1233     will not trigger the warning.  ?!? FIXME.  This is horribly fragile.
1234
1235     Ultimately we should have better controls over the generic ELF BFD
1236     linker code.  */
1237  if (! info->relocatable
1238      && info->unresolved_syms_in_shared_libs != RM_IGNORE
1239      && h->root.type == bfd_link_hash_undefined
1240      && h->ref_dynamic
1241      && !h->ref_regular)
1242    {
1243      h->ref_dynamic = 0;
1244      h->pointer_equality_needed = 1;
1245    }
1246
1247  return TRUE;
1248}
1249
1250static bfd_boolean
1251elf_hppa_remark_useless_dynamic_symbols (struct elf_link_hash_entry *h,
1252					 void *data)
1253{
1254  struct bfd_link_info *info = data;
1255
1256  if (h->root.type == bfd_link_hash_warning)
1257    h = (struct elf_link_hash_entry *) h->root.u.i.link;
1258
1259  /* If we are not creating a shared library, and this symbol is
1260     referenced by a shared library but is not defined anywhere, then
1261     the generic code will warn that it is undefined.
1262
1263     This behavior is undesirable on HPs since the standard shared
1264     libraries contain references to undefined symbols.
1265
1266     So we twiddle the flags associated with such symbols so that they
1267     will not trigger the warning.  ?!? FIXME.  This is horribly fragile.
1268
1269     Ultimately we should have better controls over the generic ELF BFD
1270     linker code.  */
1271  if (! info->relocatable
1272      && info->unresolved_syms_in_shared_libs != RM_IGNORE
1273      && h->root.type == bfd_link_hash_undefined
1274      && !h->ref_dynamic
1275      && !h->ref_regular
1276      && h->pointer_equality_needed)
1277    {
1278      h->ref_dynamic = 1;
1279      h->pointer_equality_needed = 0;
1280    }
1281
1282  return TRUE;
1283}
1284
1285static bfd_boolean
1286elf_hppa_is_dynamic_loader_symbol (const char *name)
1287{
1288  return (! strcmp (name, "__CPU_REVISION")
1289	  || ! strcmp (name, "__CPU_KEYBITS_1")
1290	  || ! strcmp (name, "__SYSTEM_ID_D")
1291	  || ! strcmp (name, "__FPU_MODEL")
1292	  || ! strcmp (name, "__FPU_REVISION")
1293	  || ! strcmp (name, "__ARGC")
1294	  || ! strcmp (name, "__ARGV")
1295	  || ! strcmp (name, "__ENVP")
1296	  || ! strcmp (name, "__TLS_SIZE_D")
1297	  || ! strcmp (name, "__LOAD_INFO")
1298	  || ! strcmp (name, "__systab"));
1299}
1300
1301/* Record the lowest address for the data and text segments.  */
1302static void
1303elf_hppa_record_segment_addrs (bfd *abfd ATTRIBUTE_UNUSED,
1304			       asection *section,
1305			       void *data)
1306{
1307  struct elf64_hppa_link_hash_table *hppa_info;
1308  bfd_vma value;
1309
1310  hppa_info = data;
1311
1312  value = section->vma - section->filepos;
1313
1314  if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1315       == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1316      && value < hppa_info->text_segment_base)
1317    hppa_info->text_segment_base = value;
1318  else if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1319	    == (SEC_ALLOC | SEC_LOAD))
1320	   && value < hppa_info->data_segment_base)
1321    hppa_info->data_segment_base = value;
1322}
1323
1324/* Called after we have seen all the input files/sections, but before
1325   final symbol resolution and section placement has been determined.
1326
1327   We use this hook to (possibly) provide a value for __gp, then we
1328   fall back to the generic ELF final link routine.  */
1329
1330static bfd_boolean
1331elf_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
1332{
1333  bfd_boolean retval;
1334  struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
1335
1336  if (! info->relocatable)
1337    {
1338      struct elf_link_hash_entry *gp;
1339      bfd_vma gp_val;
1340
1341      /* The linker script defines a value for __gp iff it was referenced
1342	 by one of the objects being linked.  First try to find the symbol
1343	 in the hash table.  If that fails, just compute the value __gp
1344	 should have had.  */
1345      gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
1346				 FALSE, FALSE);
1347
1348      if (gp)
1349	{
1350
1351	  /* Adjust the value of __gp as we may want to slide it into the
1352	     .plt section so that the stubs can access PLT entries without
1353	     using an addil sequence.  */
1354	  gp->root.u.def.value += hppa_info->gp_offset;
1355
1356	  gp_val = (gp->root.u.def.section->output_section->vma
1357		    + gp->root.u.def.section->output_offset
1358		    + gp->root.u.def.value);
1359	}
1360      else
1361	{
1362	  asection *sec;
1363
1364	  /* First look for a .plt section.  If found, then __gp is the
1365	     address of the .plt + gp_offset.
1366
1367	     If no .plt is found, then look for .dlt, .opd and .data (in
1368	     that order) and set __gp to the base address of whichever
1369	     section is found first.  */
1370
1371	  sec = hppa_info->plt_sec;
1372	  if (sec && ! (sec->flags & SEC_EXCLUDE))
1373	    gp_val = (sec->output_offset
1374		      + sec->output_section->vma
1375		      + hppa_info->gp_offset);
1376	  else
1377	    {
1378	      sec = hppa_info->dlt_sec;
1379	      if (!sec || (sec->flags & SEC_EXCLUDE))
1380		sec = hppa_info->opd_sec;
1381	      if (!sec || (sec->flags & SEC_EXCLUDE))
1382		sec = bfd_get_section_by_name (abfd, ".data");
1383	      if (!sec || (sec->flags & SEC_EXCLUDE))
1384		gp_val = 0;
1385	      else
1386		gp_val = sec->output_offset + sec->output_section->vma;
1387	    }
1388	}
1389
1390      /* Install whatever value we found/computed for __gp.  */
1391      _bfd_set_gp_value (abfd, gp_val);
1392    }
1393
1394  /* We need to know the base of the text and data segments so that we
1395     can perform SEGREL relocations.  We will record the base addresses
1396     when we encounter the first SEGREL relocation.  */
1397  hppa_info->text_segment_base = (bfd_vma)-1;
1398  hppa_info->data_segment_base = (bfd_vma)-1;
1399
1400  /* HP's shared libraries have references to symbols that are not
1401     defined anywhere.  The generic ELF BFD linker code will complain
1402     about such symbols.
1403
1404     So we detect the losing case and arrange for the flags on the symbol
1405     to indicate that it was never referenced.  This keeps the generic
1406     ELF BFD link code happy and appears to not create any secondary
1407     problems.  Ultimately we need a way to control the behavior of the
1408     generic ELF BFD link code better.  */
1409  elf_link_hash_traverse (elf_hash_table (info),
1410			  elf_hppa_unmark_useless_dynamic_symbols,
1411			  info);
1412
1413  /* Invoke the regular ELF backend linker to do all the work.  */
1414  retval = bfd_elf_final_link (abfd, info);
1415
1416  elf_link_hash_traverse (elf_hash_table (info),
1417			  elf_hppa_remark_useless_dynamic_symbols,
1418			  info);
1419
1420  /* If we're producing a final executable, sort the contents of the
1421     unwind section. */
1422  if (retval)
1423    retval = elf_hppa_sort_unwind (abfd);
1424
1425  return retval;
1426}
1427
1428/* Relocate the given INSN.  VALUE should be the actual value we want
1429   to insert into the instruction, ie by this point we should not be
1430   concerned with computing an offset relative to the DLT, PC, etc.
1431   Instead this routine is meant to handle the bit manipulations needed
1432   to insert the relocation into the given instruction.  */
1433
1434static int
1435elf_hppa_relocate_insn (int insn, int sym_value, unsigned int r_type)
1436{
1437  switch (r_type)
1438    {
1439    /* This is any 22 bit branch.  In PA2.0 syntax it corresponds to
1440       the "B" instruction.  */
1441    case R_PARISC_PCREL22F:
1442    case R_PARISC_PCREL22C:
1443      return (insn & ~0x3ff1ffd) | re_assemble_22 (sym_value);
1444
1445      /* This is any 12 bit branch.  */
1446    case R_PARISC_PCREL12F:
1447      return (insn & ~0x1ffd) | re_assemble_12 (sym_value);
1448
1449    /* This is any 17 bit branch.  In PA2.0 syntax it also corresponds
1450       to the "B" instruction as well as BE.  */
1451    case R_PARISC_PCREL17F:
1452    case R_PARISC_DIR17F:
1453    case R_PARISC_DIR17R:
1454    case R_PARISC_PCREL17C:
1455    case R_PARISC_PCREL17R:
1456      return (insn & ~0x1f1ffd) | re_assemble_17 (sym_value);
1457
1458    /* ADDIL or LDIL instructions.  */
1459    case R_PARISC_DLTREL21L:
1460    case R_PARISC_DLTIND21L:
1461    case R_PARISC_LTOFF_FPTR21L:
1462    case R_PARISC_PCREL21L:
1463    case R_PARISC_LTOFF_TP21L:
1464    case R_PARISC_DPREL21L:
1465    case R_PARISC_PLTOFF21L:
1466    case R_PARISC_DIR21L:
1467      return (insn & ~0x1fffff) | re_assemble_21 (sym_value);
1468
1469    /* LDO and integer loads/stores with 14 bit displacements.  */
1470    case R_PARISC_DLTREL14R:
1471    case R_PARISC_DLTREL14F:
1472    case R_PARISC_DLTIND14R:
1473    case R_PARISC_DLTIND14F:
1474    case R_PARISC_LTOFF_FPTR14R:
1475    case R_PARISC_PCREL14R:
1476    case R_PARISC_PCREL14F:
1477    case R_PARISC_LTOFF_TP14R:
1478    case R_PARISC_LTOFF_TP14F:
1479    case R_PARISC_DPREL14R:
1480    case R_PARISC_DPREL14F:
1481    case R_PARISC_PLTOFF14R:
1482    case R_PARISC_PLTOFF14F:
1483    case R_PARISC_DIR14R:
1484    case R_PARISC_DIR14F:
1485      return (insn & ~0x3fff) | low_sign_unext (sym_value, 14);
1486
1487    /* PA2.0W LDO and integer loads/stores with 16 bit displacements.  */
1488    case R_PARISC_LTOFF_FPTR16F:
1489    case R_PARISC_PCREL16F:
1490    case R_PARISC_LTOFF_TP16F:
1491    case R_PARISC_GPREL16F:
1492    case R_PARISC_PLTOFF16F:
1493    case R_PARISC_DIR16F:
1494    case R_PARISC_LTOFF16F:
1495      return (insn & ~0xffff) | re_assemble_16 (sym_value);
1496
1497    /* Doubleword loads and stores with a 14 bit displacement.  */
1498    case R_PARISC_DLTREL14DR:
1499    case R_PARISC_DLTIND14DR:
1500    case R_PARISC_LTOFF_FPTR14DR:
1501    case R_PARISC_LTOFF_FPTR16DF:
1502    case R_PARISC_PCREL14DR:
1503    case R_PARISC_PCREL16DF:
1504    case R_PARISC_LTOFF_TP14DR:
1505    case R_PARISC_LTOFF_TP16DF:
1506    case R_PARISC_DPREL14DR:
1507    case R_PARISC_GPREL16DF:
1508    case R_PARISC_PLTOFF14DR:
1509    case R_PARISC_PLTOFF16DF:
1510    case R_PARISC_DIR14DR:
1511    case R_PARISC_DIR16DF:
1512    case R_PARISC_LTOFF16DF:
1513      return (insn & ~0x3ff1) | (((sym_value & 0x2000) >> 13)
1514				 | ((sym_value & 0x1ff8) << 1));
1515
1516    /* Floating point single word load/store instructions.  */
1517    case R_PARISC_DLTREL14WR:
1518    case R_PARISC_DLTIND14WR:
1519    case R_PARISC_LTOFF_FPTR14WR:
1520    case R_PARISC_LTOFF_FPTR16WF:
1521    case R_PARISC_PCREL14WR:
1522    case R_PARISC_PCREL16WF:
1523    case R_PARISC_LTOFF_TP14WR:
1524    case R_PARISC_LTOFF_TP16WF:
1525    case R_PARISC_DPREL14WR:
1526    case R_PARISC_GPREL16WF:
1527    case R_PARISC_PLTOFF14WR:
1528    case R_PARISC_PLTOFF16WF:
1529    case R_PARISC_DIR16WF:
1530    case R_PARISC_DIR14WR:
1531    case R_PARISC_LTOFF16WF:
1532      return (insn & ~0x3ff9) | (((sym_value & 0x2000) >> 13)
1533				 | ((sym_value & 0x1ffc) << 1));
1534
1535    default:
1536      return insn;
1537    }
1538}
1539
1540/* Compute the value for a relocation (REL) during a final link stage,
1541   then insert the value into the proper location in CONTENTS.
1542
1543   VALUE is a tentative value for the relocation and may be overridden
1544   and modified here based on the specific relocation to be performed.
1545
1546   For example we do conversions for PC-relative branches in this routine
1547   or redirection of calls to external routines to stubs.
1548
1549   The work of actually applying the relocation is left to a helper
1550   routine in an attempt to reduce the complexity and size of this
1551   function.  */
1552
1553static bfd_reloc_status_type
1554elf_hppa_final_link_relocate (Elf_Internal_Rela *rel,
1555			      bfd *input_bfd,
1556			      bfd *output_bfd,
1557			      asection *input_section,
1558			      bfd_byte *contents,
1559			      bfd_vma value,
1560			      struct bfd_link_info *info,
1561			      asection *sym_sec,
1562			      struct elf_link_hash_entry *h ATTRIBUTE_UNUSED,
1563			      struct elf64_hppa_dyn_hash_entry *dyn_h)
1564{
1565  int insn;
1566  bfd_vma offset = rel->r_offset;
1567  bfd_signed_vma addend = rel->r_addend;
1568  reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
1569  unsigned int r_type = howto->type;
1570  bfd_byte *hit_data = contents + offset;
1571  struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
1572
1573  insn = bfd_get_32 (input_bfd, hit_data);
1574
1575  switch (r_type)
1576    {
1577    case R_PARISC_NONE:
1578      break;
1579
1580    /* Basic function call support.
1581
1582       Note for a call to a function defined in another dynamic library
1583       we want to redirect the call to a stub.  */
1584
1585    /* Random PC relative relocs.  */
1586    case R_PARISC_PCREL21L:
1587    case R_PARISC_PCREL14R:
1588    case R_PARISC_PCREL14F:
1589    case R_PARISC_PCREL14WR:
1590    case R_PARISC_PCREL14DR:
1591    case R_PARISC_PCREL16F:
1592    case R_PARISC_PCREL16WF:
1593    case R_PARISC_PCREL16DF:
1594      {
1595	/* If this is a call to a function defined in another dynamic
1596	   library, then redirect the call to the local stub for this
1597	   function.  */
1598	if (sym_sec == NULL || sym_sec->output_section == NULL)
1599	  value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1600		   + hppa_info->stub_sec->output_section->vma);
1601
1602	/* Turn VALUE into a proper PC relative address.  */
1603	value -= (offset + input_section->output_offset
1604		  + input_section->output_section->vma);
1605
1606	/* Adjust for any field selectors.  */
1607	if (r_type == R_PARISC_PCREL21L)
1608	  value = hppa_field_adjust (value, -8 + addend, e_lsel);
1609	else if (r_type == R_PARISC_PCREL14F
1610		 || r_type == R_PARISC_PCREL16F
1611		 || r_type == R_PARISC_PCREL16WF
1612		 || r_type == R_PARISC_PCREL16DF)
1613	  value = hppa_field_adjust (value, -8 + addend, e_fsel);
1614	else
1615	  value = hppa_field_adjust (value, -8 + addend, e_rsel);
1616
1617	/* Apply the relocation to the given instruction.  */
1618	insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1619	break;
1620      }
1621
1622    case R_PARISC_PCREL12F:
1623    case R_PARISC_PCREL22F:
1624    case R_PARISC_PCREL17F:
1625    case R_PARISC_PCREL22C:
1626    case R_PARISC_PCREL17C:
1627    case R_PARISC_PCREL17R:
1628      {
1629	/* If this is a call to a function defined in another dynamic
1630	   library, then redirect the call to the local stub for this
1631	   function.  */
1632	if (sym_sec == NULL || sym_sec->output_section == NULL)
1633	  value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1634		   + hppa_info->stub_sec->output_section->vma);
1635
1636	/* Turn VALUE into a proper PC relative address.  */
1637	value -= (offset + input_section->output_offset
1638		  + input_section->output_section->vma);
1639
1640	/* Adjust for any field selectors.  */
1641	if (r_type == R_PARISC_PCREL17R)
1642	  value = hppa_field_adjust (value, -8 + addend, e_rsel);
1643	else
1644	  value = hppa_field_adjust (value, -8 + addend, e_fsel);
1645
1646	/* All branches are implicitly shifted by 2 places.  */
1647	value >>= 2;
1648
1649	/* Apply the relocation to the given instruction.  */
1650	insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1651	break;
1652      }
1653
1654    /* Indirect references to data through the DLT.  */
1655    case R_PARISC_DLTIND14R:
1656    case R_PARISC_DLTIND14F:
1657    case R_PARISC_DLTIND14DR:
1658    case R_PARISC_DLTIND14WR:
1659    case R_PARISC_DLTIND21L:
1660    case R_PARISC_LTOFF_FPTR14R:
1661    case R_PARISC_LTOFF_FPTR14DR:
1662    case R_PARISC_LTOFF_FPTR14WR:
1663    case R_PARISC_LTOFF_FPTR21L:
1664    case R_PARISC_LTOFF_FPTR16F:
1665    case R_PARISC_LTOFF_FPTR16WF:
1666    case R_PARISC_LTOFF_FPTR16DF:
1667    case R_PARISC_LTOFF_TP21L:
1668    case R_PARISC_LTOFF_TP14R:
1669    case R_PARISC_LTOFF_TP14F:
1670    case R_PARISC_LTOFF_TP14WR:
1671    case R_PARISC_LTOFF_TP14DR:
1672    case R_PARISC_LTOFF_TP16F:
1673    case R_PARISC_LTOFF_TP16WF:
1674    case R_PARISC_LTOFF_TP16DF:
1675    case R_PARISC_LTOFF16F:
1676    case R_PARISC_LTOFF16WF:
1677    case R_PARISC_LTOFF16DF:
1678      {
1679	/* If this relocation was against a local symbol, then we still
1680	   have not set up the DLT entry (it's not convenient to do so
1681	   in the "finalize_dlt" routine because it is difficult to get
1682	   to the local symbol's value).
1683
1684	   So, if this is a local symbol (h == NULL), then we need to
1685	   fill in its DLT entry.
1686
1687	   Similarly we may still need to set up an entry in .opd for
1688	   a local function which had its address taken.  */
1689	if (dyn_h->h == NULL)
1690	  {
1691	    /* Now do .opd creation if needed.  */
1692	    if (r_type == R_PARISC_LTOFF_FPTR14R
1693		|| r_type == R_PARISC_LTOFF_FPTR14DR
1694		|| r_type == R_PARISC_LTOFF_FPTR14WR
1695		|| r_type == R_PARISC_LTOFF_FPTR21L
1696		|| r_type == R_PARISC_LTOFF_FPTR16F
1697		|| r_type == R_PARISC_LTOFF_FPTR16WF
1698		|| r_type == R_PARISC_LTOFF_FPTR16DF)
1699	      {
1700		/* The first two words of an .opd entry are zero.  */
1701		memset (hppa_info->opd_sec->contents + dyn_h->opd_offset,
1702			0, 16);
1703
1704		/* The next word is the address of the function.  */
1705		bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
1706			    (hppa_info->opd_sec->contents
1707			     + dyn_h->opd_offset + 16));
1708
1709		/* The last word is our local __gp value.  */
1710		value = _bfd_get_gp_value
1711			  (hppa_info->opd_sec->output_section->owner);
1712		bfd_put_64 (hppa_info->opd_sec->owner, value,
1713			    (hppa_info->opd_sec->contents
1714			     + dyn_h->opd_offset + 24));
1715
1716		/* The DLT value is the address of the .opd entry.  */
1717		value = (dyn_h->opd_offset
1718			 + hppa_info->opd_sec->output_offset
1719			 + hppa_info->opd_sec->output_section->vma);
1720		addend = 0;
1721	      }
1722
1723	    bfd_put_64 (hppa_info->dlt_sec->owner,
1724			value + addend,
1725			hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1726	  }
1727
1728	/* We want the value of the DLT offset for this symbol, not
1729	   the symbol's actual address.  Note that __gp may not point
1730	   to the start of the DLT, so we have to compute the absolute
1731	   address, then subtract out the value of __gp.  */
1732	value = (dyn_h->dlt_offset
1733		 + hppa_info->dlt_sec->output_offset
1734		 + hppa_info->dlt_sec->output_section->vma);
1735	value -= _bfd_get_gp_value (output_bfd);
1736
1737	/* All DLTIND relocations are basically the same at this point,
1738	   except that we need different field selectors for the 21bit
1739	   version vs the 14bit versions.  */
1740	if (r_type == R_PARISC_DLTIND21L
1741	    || r_type == R_PARISC_LTOFF_FPTR21L
1742	    || r_type == R_PARISC_LTOFF_TP21L)
1743	  value = hppa_field_adjust (value, 0, e_lsel);
1744	else if (r_type == R_PARISC_DLTIND14F
1745		 || r_type == R_PARISC_LTOFF_FPTR16F
1746		 || r_type == R_PARISC_LTOFF_FPTR16WF
1747		 || r_type == R_PARISC_LTOFF_FPTR16DF
1748		 || r_type == R_PARISC_LTOFF16F
1749		 || r_type == R_PARISC_LTOFF16DF
1750		 || r_type == R_PARISC_LTOFF16WF
1751		 || r_type == R_PARISC_LTOFF_TP16F
1752		 || r_type == R_PARISC_LTOFF_TP16WF
1753		 || r_type == R_PARISC_LTOFF_TP16DF)
1754	  value = hppa_field_adjust (value, 0, e_fsel);
1755	else
1756	  value = hppa_field_adjust (value, 0, e_rsel);
1757
1758	insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1759	break;
1760      }
1761
1762    case R_PARISC_DLTREL14R:
1763    case R_PARISC_DLTREL14F:
1764    case R_PARISC_DLTREL14DR:
1765    case R_PARISC_DLTREL14WR:
1766    case R_PARISC_DLTREL21L:
1767    case R_PARISC_DPREL21L:
1768    case R_PARISC_DPREL14WR:
1769    case R_PARISC_DPREL14DR:
1770    case R_PARISC_DPREL14R:
1771    case R_PARISC_DPREL14F:
1772    case R_PARISC_GPREL16F:
1773    case R_PARISC_GPREL16WF:
1774    case R_PARISC_GPREL16DF:
1775      {
1776	/* Subtract out the global pointer value to make value a DLT
1777	   relative address.  */
1778	value -= _bfd_get_gp_value (output_bfd);
1779
1780	/* All DLTREL relocations are basically the same at this point,
1781	   except that we need different field selectors for the 21bit
1782	   version vs the 14bit versions.  */
1783	if (r_type == R_PARISC_DLTREL21L
1784	    || r_type == R_PARISC_DPREL21L)
1785	  value = hppa_field_adjust (value, addend, e_lrsel);
1786	else if (r_type == R_PARISC_DLTREL14F
1787		 || r_type == R_PARISC_DPREL14F
1788		 || r_type == R_PARISC_GPREL16F
1789		 || r_type == R_PARISC_GPREL16WF
1790		 || r_type == R_PARISC_GPREL16DF)
1791	  value = hppa_field_adjust (value, addend, e_fsel);
1792	else
1793	  value = hppa_field_adjust (value, addend, e_rrsel);
1794
1795	insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1796	break;
1797      }
1798
1799    case R_PARISC_DIR21L:
1800    case R_PARISC_DIR17R:
1801    case R_PARISC_DIR17F:
1802    case R_PARISC_DIR14R:
1803    case R_PARISC_DIR14F:
1804    case R_PARISC_DIR14WR:
1805    case R_PARISC_DIR14DR:
1806    case R_PARISC_DIR16F:
1807    case R_PARISC_DIR16WF:
1808    case R_PARISC_DIR16DF:
1809      {
1810	/* All DIR relocations are basically the same at this point,
1811	   except that branch offsets need to be divided by four, and
1812	   we need different field selectors.  Note that we don't
1813	   redirect absolute calls to local stubs.  */
1814
1815	if (r_type == R_PARISC_DIR21L)
1816	  value = hppa_field_adjust (value, addend, e_lrsel);
1817	else if (r_type == R_PARISC_DIR17F
1818		 || r_type == R_PARISC_DIR16F
1819		 || r_type == R_PARISC_DIR16WF
1820		 || r_type == R_PARISC_DIR16DF
1821		 || r_type == R_PARISC_DIR14F)
1822	  value = hppa_field_adjust (value, addend, e_fsel);
1823	else
1824	  value = hppa_field_adjust (value, addend, e_rrsel);
1825
1826	if (r_type == R_PARISC_DIR17R || r_type == R_PARISC_DIR17F)
1827	  /* All branches are implicitly shifted by 2 places.  */
1828	  value >>= 2;
1829
1830	insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1831	break;
1832      }
1833
1834    case R_PARISC_PLTOFF21L:
1835    case R_PARISC_PLTOFF14R:
1836    case R_PARISC_PLTOFF14F:
1837    case R_PARISC_PLTOFF14WR:
1838    case R_PARISC_PLTOFF14DR:
1839    case R_PARISC_PLTOFF16F:
1840    case R_PARISC_PLTOFF16WF:
1841    case R_PARISC_PLTOFF16DF:
1842      {
1843	/* We want the value of the PLT offset for this symbol, not
1844	   the symbol's actual address.  Note that __gp may not point
1845	   to the start of the DLT, so we have to compute the absolute
1846	   address, then subtract out the value of __gp.  */
1847	value = (dyn_h->plt_offset
1848		 + hppa_info->plt_sec->output_offset
1849		 + hppa_info->plt_sec->output_section->vma);
1850	value -= _bfd_get_gp_value (output_bfd);
1851
1852	/* All PLTOFF relocations are basically the same at this point,
1853	   except that we need different field selectors for the 21bit
1854	   version vs the 14bit versions.  */
1855	if (r_type == R_PARISC_PLTOFF21L)
1856	  value = hppa_field_adjust (value, addend, e_lrsel);
1857	else if (r_type == R_PARISC_PLTOFF14F
1858		 || r_type == R_PARISC_PLTOFF16F
1859		 || r_type == R_PARISC_PLTOFF16WF
1860		 || r_type == R_PARISC_PLTOFF16DF)
1861	  value = hppa_field_adjust (value, addend, e_fsel);
1862	else
1863	  value = hppa_field_adjust (value, addend, e_rrsel);
1864
1865	insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
1866	break;
1867      }
1868
1869    case R_PARISC_LTOFF_FPTR32:
1870      {
1871	/* We may still need to create the FPTR itself if it was for
1872	   a local symbol.  */
1873	if (dyn_h->h == NULL)
1874	  {
1875	    /* The first two words of an .opd entry are zero.  */
1876	    memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1877
1878	    /* The next word is the address of the function.  */
1879	    bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
1880			(hppa_info->opd_sec->contents
1881			 + dyn_h->opd_offset + 16));
1882
1883	    /* The last word is our local __gp value.  */
1884	    value = _bfd_get_gp_value
1885		      (hppa_info->opd_sec->output_section->owner);
1886	    bfd_put_64 (hppa_info->opd_sec->owner, value,
1887			hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1888
1889	    /* The DLT value is the address of the .opd entry.  */
1890	    value = (dyn_h->opd_offset
1891		     + hppa_info->opd_sec->output_offset
1892		     + hppa_info->opd_sec->output_section->vma);
1893
1894	    bfd_put_64 (hppa_info->dlt_sec->owner,
1895			value,
1896			hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1897	  }
1898
1899	/* We want the value of the DLT offset for this symbol, not
1900	   the symbol's actual address.  Note that __gp may not point
1901	   to the start of the DLT, so we have to compute the absolute
1902	   address, then subtract out the value of __gp.  */
1903	value = (dyn_h->dlt_offset
1904		 + hppa_info->dlt_sec->output_offset
1905		 + hppa_info->dlt_sec->output_section->vma);
1906	value -= _bfd_get_gp_value (output_bfd);
1907	bfd_put_32 (input_bfd, value, hit_data);
1908	return bfd_reloc_ok;
1909      }
1910
1911    case R_PARISC_LTOFF_FPTR64:
1912    case R_PARISC_LTOFF_TP64:
1913      {
1914	/* We may still need to create the FPTR itself if it was for
1915	   a local symbol.  */
1916	if (dyn_h->h == NULL && r_type == R_PARISC_LTOFF_FPTR64)
1917	  {
1918	    /* The first two words of an .opd entry are zero.  */
1919	    memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1920
1921	    /* The next word is the address of the function.  */
1922	    bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
1923			(hppa_info->opd_sec->contents
1924			 + dyn_h->opd_offset + 16));
1925
1926	    /* The last word is our local __gp value.  */
1927	    value = _bfd_get_gp_value
1928		      (hppa_info->opd_sec->output_section->owner);
1929	    bfd_put_64 (hppa_info->opd_sec->owner, value,
1930			hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1931
1932	    /* The DLT value is the address of the .opd entry.  */
1933	    value = (dyn_h->opd_offset
1934		     + hppa_info->opd_sec->output_offset
1935		     + hppa_info->opd_sec->output_section->vma);
1936
1937	    bfd_put_64 (hppa_info->dlt_sec->owner,
1938			value,
1939			hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1940	  }
1941
1942	/* We want the value of the DLT offset for this symbol, not
1943	   the symbol's actual address.  Note that __gp may not point
1944	   to the start of the DLT, so we have to compute the absolute
1945	   address, then subtract out the value of __gp.  */
1946	value = (dyn_h->dlt_offset
1947		 + hppa_info->dlt_sec->output_offset
1948		 + hppa_info->dlt_sec->output_section->vma);
1949	value -= _bfd_get_gp_value (output_bfd);
1950	bfd_put_64 (input_bfd, value, hit_data);
1951	return bfd_reloc_ok;
1952      }
1953
1954    case R_PARISC_DIR32:
1955      bfd_put_32 (input_bfd, value + addend, hit_data);
1956      return bfd_reloc_ok;
1957
1958    case R_PARISC_DIR64:
1959      bfd_put_64 (input_bfd, value + addend, hit_data);
1960      return bfd_reloc_ok;
1961
1962    case R_PARISC_GPREL64:
1963      /* Subtract out the global pointer value to make value a DLT
1964	 relative address.  */
1965      value -= _bfd_get_gp_value (output_bfd);
1966
1967      bfd_put_64 (input_bfd, value + addend, hit_data);
1968      return bfd_reloc_ok;
1969
1970    case R_PARISC_LTOFF64:
1971	/* We want the value of the DLT offset for this symbol, not
1972	   the symbol's actual address.  Note that __gp may not point
1973	   to the start of the DLT, so we have to compute the absolute
1974	   address, then subtract out the value of __gp.  */
1975      value = (dyn_h->dlt_offset
1976	       + hppa_info->dlt_sec->output_offset
1977	       + hppa_info->dlt_sec->output_section->vma);
1978      value -= _bfd_get_gp_value (output_bfd);
1979
1980      bfd_put_64 (input_bfd, value + addend, hit_data);
1981      return bfd_reloc_ok;
1982
1983    case R_PARISC_PCREL32:
1984      {
1985	/* If this is a call to a function defined in another dynamic
1986	   library, then redirect the call to the local stub for this
1987	   function.  */
1988	if (sym_sec == NULL || sym_sec->output_section == NULL)
1989	  value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1990		   + hppa_info->stub_sec->output_section->vma);
1991
1992	/* Turn VALUE into a proper PC relative address.  */
1993	value -= (offset + input_section->output_offset
1994		  + input_section->output_section->vma);
1995
1996	value += addend;
1997	value -= 8;
1998	bfd_put_32 (input_bfd, value, hit_data);
1999	return bfd_reloc_ok;
2000      }
2001
2002    case R_PARISC_PCREL64:
2003      {
2004	/* If this is a call to a function defined in another dynamic
2005	   library, then redirect the call to the local stub for this
2006	   function.  */
2007	if (sym_sec == NULL || sym_sec->output_section == NULL)
2008	  value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
2009		   + hppa_info->stub_sec->output_section->vma);
2010
2011	/* Turn VALUE into a proper PC relative address.  */
2012	value -= (offset + input_section->output_offset
2013		  + input_section->output_section->vma);
2014
2015	value += addend;
2016	value -= 8;
2017	bfd_put_64 (input_bfd, value, hit_data);
2018	return bfd_reloc_ok;
2019      }
2020
2021    case R_PARISC_FPTR64:
2022      {
2023	/* We may still need to create the FPTR itself if it was for
2024	   a local symbol.  */
2025	if (dyn_h->h == NULL)
2026	  {
2027	    /* The first two words of an .opd entry are zero.  */
2028	    memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
2029
2030	    /* The next word is the address of the function.  */
2031	    bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
2032			(hppa_info->opd_sec->contents
2033			 + dyn_h->opd_offset + 16));
2034
2035	    /* The last word is our local __gp value.  */
2036	    value = _bfd_get_gp_value
2037		      (hppa_info->opd_sec->output_section->owner);
2038	    bfd_put_64 (hppa_info->opd_sec->owner, value,
2039			hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
2040	  }
2041
2042	if (dyn_h->want_opd)
2043	  /* We want the value of the OPD offset for this symbol.  */
2044	  value = (dyn_h->opd_offset
2045		   + hppa_info->opd_sec->output_offset
2046		   + hppa_info->opd_sec->output_section->vma);
2047	else
2048	  /* We want the address of the symbol.  */
2049	  value += addend;
2050
2051	bfd_put_64 (input_bfd, value, hit_data);
2052	return bfd_reloc_ok;
2053      }
2054
2055    case R_PARISC_SECREL32:
2056      bfd_put_32 (input_bfd,
2057		  value + addend - sym_sec->output_section->vma,
2058		  hit_data);
2059      return bfd_reloc_ok;
2060
2061    case R_PARISC_SEGREL32:
2062    case R_PARISC_SEGREL64:
2063      {
2064	/* If this is the first SEGREL relocation, then initialize
2065	   the segment base values.  */
2066	if (hppa_info->text_segment_base == (bfd_vma) -1)
2067	  bfd_map_over_sections (output_bfd, elf_hppa_record_segment_addrs,
2068				 hppa_info);
2069
2070	/* VALUE holds the absolute address.  We want to include the
2071	   addend, then turn it into a segment relative address.
2072
2073	   The segment is derived from SYM_SEC.  We assume that there are
2074	   only two segments of note in the resulting executable/shlib.
2075	   A readonly segment (.text) and a readwrite segment (.data).  */
2076	value += addend;
2077
2078	if (sym_sec->flags & SEC_CODE)
2079	  value -= hppa_info->text_segment_base;
2080	else
2081	  value -= hppa_info->data_segment_base;
2082
2083	if (r_type == R_PARISC_SEGREL32)
2084	  bfd_put_32 (input_bfd, value, hit_data);
2085	else
2086	  bfd_put_64 (input_bfd, value, hit_data);
2087	return bfd_reloc_ok;
2088      }
2089
2090    /* Something we don't know how to handle.  */
2091    default:
2092      return bfd_reloc_notsupported;
2093    }
2094
2095  /* Update the instruction word.  */
2096  bfd_put_32 (input_bfd, (bfd_vma) insn, hit_data);
2097  return bfd_reloc_ok;
2098}
2099
2100/* Relocate an HPPA ELF section.  */
2101
2102static bfd_boolean
2103elf_hppa_relocate_section (bfd *output_bfd,
2104			   struct bfd_link_info *info,
2105			   bfd *input_bfd,
2106			   asection *input_section,
2107			   bfd_byte *contents,
2108			   Elf_Internal_Rela *relocs,
2109			   Elf_Internal_Sym *local_syms,
2110			   asection **local_sections)
2111{
2112  Elf_Internal_Shdr *symtab_hdr;
2113  Elf_Internal_Rela *rel;
2114  Elf_Internal_Rela *relend;
2115  struct elf64_hppa_link_hash_table *hppa_info;
2116
2117  hppa_info = elf64_hppa_hash_table (info);
2118  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
2119
2120  rel = relocs;
2121  relend = relocs + input_section->reloc_count;
2122  for (; rel < relend; rel++)
2123    {
2124      int r_type;
2125      reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
2126      unsigned long r_symndx;
2127      struct elf_link_hash_entry *h;
2128      Elf_Internal_Sym *sym;
2129      asection *sym_sec;
2130      bfd_vma relocation;
2131      bfd_reloc_status_type r;
2132      const char *dyn_name;
2133      char *dynh_buf = NULL;
2134      size_t dynh_buflen = 0;
2135      struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
2136
2137      r_type = ELF_R_TYPE (rel->r_info);
2138      if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
2139	{
2140	  bfd_set_error (bfd_error_bad_value);
2141	  return FALSE;
2142	}
2143
2144      /* This is a final link.  */
2145      r_symndx = ELF_R_SYM (rel->r_info);
2146      h = NULL;
2147      sym = NULL;
2148      sym_sec = NULL;
2149      if (r_symndx < symtab_hdr->sh_info)
2150	{
2151	  /* This is a local symbol.  */
2152	  sym = local_syms + r_symndx;
2153	  sym_sec = local_sections[r_symndx];
2154	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sym_sec, rel);
2155
2156	  /* If this symbol has an entry in the PA64 dynamic hash
2157	     table, then get it.  */
2158	  dyn_name = get_dyn_name (input_bfd, h, rel,
2159				   &dynh_buf, &dynh_buflen);
2160	  dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
2161					      dyn_name, FALSE, FALSE);
2162
2163	}
2164      else
2165	{
2166	  /* This is not a local symbol.  */
2167	  long indx;
2168
2169	  relocation = 0;
2170	  indx = r_symndx - symtab_hdr->sh_info;
2171	  h = elf_sym_hashes (input_bfd)[indx];
2172	  while (h->root.type == bfd_link_hash_indirect
2173		 || h->root.type == bfd_link_hash_warning)
2174	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
2175	  if (h->root.type == bfd_link_hash_defined
2176	      || h->root.type == bfd_link_hash_defweak)
2177	    {
2178	      sym_sec = h->root.u.def.section;
2179
2180	      /* If this symbol has an entry in the PA64 dynamic hash
2181		 table, then get it.  */
2182	      dyn_name = get_dyn_name (input_bfd, h, rel,
2183				       &dynh_buf, &dynh_buflen);
2184	      dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
2185						  dyn_name, FALSE, FALSE);
2186
2187	      /* If we have a relocation against a symbol defined in a
2188		 shared library and we have not created an entry in the
2189		 PA64 dynamic symbol hash table for it, then we lose.  */
2190	      if (!info->relocatable
2191		  && sym_sec->output_section == NULL && dyn_h == NULL)
2192		{
2193		  (*_bfd_error_handler)
2194		    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
2195		     input_bfd,
2196		     input_section,
2197		     (long) rel->r_offset,
2198		     howto->name,
2199		     h->root.root.string);
2200		}
2201	      else if (sym_sec->output_section)
2202		relocation = (h->root.u.def.value
2203			      + sym_sec->output_offset
2204			      + sym_sec->output_section->vma);
2205	    }
2206	  else if (info->unresolved_syms_in_objects == RM_IGNORE
2207		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
2208	    {
2209	      /* If this symbol has an entry in the PA64 dynamic hash
2210		 table, then get it.  */
2211	      dyn_name = get_dyn_name (input_bfd, h, rel,
2212				       &dynh_buf, &dynh_buflen);
2213	      dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
2214						  dyn_name, FALSE, FALSE);
2215
2216	      if (!info->relocatable && dyn_h == NULL)
2217		{
2218		  (*_bfd_error_handler)
2219		    (_("%B(%A): warning: unresolvable relocation against symbol `%s'"),
2220		     input_bfd, input_section, h->root.root.string);
2221		}
2222	    }
2223	  else if (h->root.type == bfd_link_hash_undefweak)
2224            {
2225	      dyn_name = get_dyn_name (input_bfd, h, rel,
2226				       &dynh_buf, &dynh_buflen);
2227	      dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
2228						  dyn_name, FALSE, FALSE);
2229
2230	      if (!info->relocatable && dyn_h == NULL)
2231		{
2232		  (*_bfd_error_handler)
2233		    (_("%B(%A): warning: unresolvable relocation against symbol `%s'"),
2234		     input_bfd, input_section, h->root.root.string);
2235		}
2236	    }
2237	  else if (!info->relocatable)
2238	    {
2239	      /* Ignore dynamic loader defined symbols.  */
2240	      if (!elf_hppa_is_dynamic_loader_symbol (h->root.root.string))
2241		{
2242		  if (!((*info->callbacks->undefined_symbol)
2243			(info, h->root.root.string, input_bfd,
2244			 input_section, rel->r_offset,
2245			 (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
2246			  || ELF_ST_VISIBILITY (h->other)))))
2247		    return FALSE;
2248		  break;
2249		}
2250	    }
2251	}
2252
2253      if (sym_sec != NULL && elf_discarded_section (sym_sec))
2254	{
2255	  /* For relocs against symbols from removed linkonce sections,
2256	     or sections discarded by a linker script, we just want the
2257	     section contents zeroed.  Avoid any special processing.  */
2258	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
2259	  rel->r_info = 0;
2260	  rel->r_addend = 0;
2261	  continue;
2262	}
2263
2264      if (info->relocatable)
2265	continue;
2266
2267      r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
2268					input_section, contents,
2269					relocation, info, sym_sec,
2270					h, dyn_h);
2271
2272      if (r != bfd_reloc_ok)
2273	{
2274	  switch (r)
2275	    {
2276	    default:
2277	      abort ();
2278	    case bfd_reloc_overflow:
2279	      {
2280		const char *sym_name;
2281
2282		if (h != NULL)
2283		  sym_name = NULL;
2284		else
2285		  {
2286		    sym_name = bfd_elf_string_from_elf_section (input_bfd,
2287								symtab_hdr->sh_link,
2288								sym->st_name);
2289		    if (sym_name == NULL)
2290		      return FALSE;
2291		    if (*sym_name == '\0')
2292		      sym_name = bfd_section_name (input_bfd, sym_sec);
2293		  }
2294
2295		if (!((*info->callbacks->reloc_overflow)
2296		      (info, (h ? &h->root : NULL), sym_name,
2297		       howto->name, (bfd_vma) 0, input_bfd,
2298		       input_section, rel->r_offset)))
2299		  return FALSE;
2300	      }
2301	      break;
2302	    }
2303	}
2304    }
2305  return TRUE;
2306}
2307
2308#endif /* ARCH_SIZE == 64 */
2309