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