Re: ELF final_write_processing
[deliverable/binutils-gdb.git] / bfd / elf-hppa.h
CommitLineData
9e103c9c 1/* Common code for PA ELF implementations.
82704155 2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
9e103c9c 3
9b52905e 4 This file is part of BFD, the Binary File Descriptor library.
9e103c9c 5
9b52905e
NC
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
cd123cb7 8 the Free Software Foundation; either version 3 of the License, or
9b52905e 9 (at your option) any later version.
9e103c9c 10
9b52905e
NC
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
9e103c9c 15
9b52905e
NC
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
cd123cb7
NC
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
9e103c9c
JL
20
21#define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
22
2eb429af
JL
23/* This file is included by multiple PA ELF BFD backends with different
24 sizes.
25
26 Most of the routines are written to be size independent, but sometimes
27 external constraints require 32 or 64 bit specific code. We remap
28 the definitions/functions as necessary here. */
9e103c9c 29#if ARCH_SIZE == 64
07d6d2b8
AM
30#define ELF_R_TYPE(X) ELF64_R_TYPE(X)
31#define ELF_R_SYM(X) ELF64_R_SYM(X)
9b52905e
NC
32#define elf_hppa_reloc_final_type elf64_hppa_reloc_final_type
33#define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
34#define elf_hppa_relocate_section elf64_hppa_relocate_section
07d6d2b8 35#define elf_hppa_final_link elf64_hppa_final_link
9e103c9c
JL
36#endif
37#if ARCH_SIZE == 32
07d6d2b8
AM
38#define ELF_R_TYPE(X) ELF32_R_TYPE(X)
39#define ELF_R_SYM(X) ELF32_R_SYM(X)
9b52905e
NC
40#define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type
41#define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
42#define elf_hppa_relocate_section elf32_hppa_relocate_section
07d6d2b8 43#define elf_hppa_final_link elf32_hppa_final_link
3f9b03b5
AM
44#endif
45
9e103c9c
JL
46/* ELF/PA relocation howto entries. */
47
48static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
49{
487096bf
AM
50#define HOW(type, size, bitsize, pc_rel, complain, mask) \
51 HOWTO (type, 0, size, bitsize, pc_rel, 0, complain_overflow_ ## complain, \
52 bfd_elf_generic_reloc, #type, FALSE, 0, mask, FALSE)
9e103c9c
JL
53
54 /* The values in DIR32 are to placate the check in
55 _bfd_stab_section_find_nearest_line. */
487096bf
AM
56 HOW (R_PARISC_NONE, 3, 0, FALSE, dont, 0),
57 HOW (R_PARISC_DIR32, 2, 32, FALSE, bitfield, 0xffffffff),
58 HOW (R_PARISC_DIR21L, 2, 21, FALSE, bitfield, 0),
59 HOW (R_PARISC_DIR17R, 2, 17, FALSE, bitfield, 0),
60 HOW (R_PARISC_DIR17F, 2, 17, FALSE, bitfield, 0),
61 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
62 HOW (R_PARISC_DIR14R, 2, 14, FALSE, bitfield, 0),
63 HOW (R_PARISC_DIR14F, 2, 14, FALSE, bitfield, 0),
49bd834c 64 /* 8 */
487096bf
AM
65 HOW (R_PARISC_PCREL12F, 2, 12, TRUE, bitfield, 0),
66 HOW (R_PARISC_PCREL32, 2, 32, TRUE, bitfield, 0),
67 HOW (R_PARISC_PCREL21L, 2, 21, TRUE, bitfield, 0),
68 HOW (R_PARISC_PCREL17R, 2, 17, TRUE, bitfield, 0),
69 HOW (R_PARISC_PCREL17F, 2, 17, TRUE, bitfield, 0),
70 HOW (R_PARISC_PCREL17C, 2, 17, TRUE, bitfield, 0),
71 HOW (R_PARISC_PCREL14R, 2, 14, TRUE, bitfield, 0),
72 HOW (R_PARISC_PCREL14F, 2, 14, TRUE, bitfield, 0),
49bd834c 73 /* 16 */
487096bf
AM
74 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
75 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
76 HOW (R_PARISC_DPREL21L, 2, 21, FALSE, bitfield, 0),
77 HOW (R_PARISC_DPREL14WR, 2, 14, FALSE, bitfield, 0),
78 HOW (R_PARISC_DPREL14DR, 2, 14, FALSE, bitfield, 0),
79 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
80 HOW (R_PARISC_DPREL14R, 2, 14, FALSE, bitfield, 0),
81 HOW (R_PARISC_DPREL14F, 2, 14, FALSE, bitfield, 0),
49bd834c 82 /* 24 */
487096bf
AM
83 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
84 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
85 HOW (R_PARISC_DLTREL21L, 2, 21, FALSE, bitfield, 0),
86 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
87 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
88 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
89 HOW (R_PARISC_DLTREL14R, 2, 14, FALSE, bitfield, 0),
90 HOW (R_PARISC_DLTREL14F, 2, 14, FALSE, bitfield, 0),
49bd834c 91 /* 32 */
487096bf
AM
92 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
93 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
94 HOW (R_PARISC_DLTIND21L, 2, 21, FALSE, bitfield, 0),
95 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
96 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
97 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
98 HOW (R_PARISC_DLTIND14R, 2, 14, FALSE, bitfield, 0),
99 HOW (R_PARISC_DLTIND14F, 2, 14, FALSE, bitfield, 0),
49bd834c 100 /* 40 */
487096bf
AM
101 HOW (R_PARISC_SETBASE, 0, 0, FALSE, bitfield, 0),
102 HOW (R_PARISC_SECREL32, 2, 32, FALSE, bitfield, 0xffffffff),
103 HOW (R_PARISC_BASEREL21L, 2, 21, FALSE, bitfield, 0),
104 HOW (R_PARISC_BASEREL17R, 2, 17, FALSE, bitfield, 0),
105 HOW (R_PARISC_BASEREL17F, 2, 17, FALSE, bitfield, 0),
106 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
107 HOW (R_PARISC_BASEREL14R, 2, 14, FALSE, bitfield, 0),
108 HOW (R_PARISC_BASEREL14F, 2, 14, FALSE, bitfield, 0),
49bd834c 109 /* 48 */
487096bf
AM
110 HOW (R_PARISC_SEGBASE, 0, 0, FALSE, bitfield, 0),
111 HOW (R_PARISC_SEGREL32, 2, 32, FALSE, bitfield, 0),
112 HOW (R_PARISC_PLTOFF21L, 2, 21, FALSE, bitfield, 0),
113 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
114 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
115 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
116 HOW (R_PARISC_PLTOFF14R, 2, 14, FALSE, bitfield, 0),
117 HOW (R_PARISC_PLTOFF14F, 2, 14, FALSE, bitfield, 0),
49bd834c 118 /* 56 */
487096bf
AM
119 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
120 HOW (R_PARISC_LTOFF_FPTR32, 2, 32, FALSE, bitfield, 0),
121 HOW (R_PARISC_LTOFF_FPTR21L, 2, 21, FALSE, bitfield, 0),
122 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
123 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
124 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
125 HOW (R_PARISC_LTOFF_FPTR14R, 2, 14, FALSE, bitfield, 0),
126 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 127 /* 64 */
487096bf
AM
128 HOW (R_PARISC_FPTR64, 4, 64, FALSE, bitfield, 0),
129 HOW (R_PARISC_PLABEL32, 2, 32, FALSE, bitfield, 0),
130 HOW (R_PARISC_PLABEL21L, 2, 21, FALSE, bitfield, 0),
131 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
132 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
133 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
134 HOW (R_PARISC_PLABEL14R, 2, 14, FALSE, bitfield, 0),
135 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 136 /* 72 */
487096bf
AM
137 HOW (R_PARISC_PCREL64, 4, 64, FALSE, bitfield, 0),
138 HOW (R_PARISC_PCREL22C, 2, 22, FALSE, bitfield, 0),
139 HOW (R_PARISC_PCREL22F, 2, 22, FALSE, bitfield, 0),
140 HOW (R_PARISC_PCREL14WR, 2, 14, FALSE, bitfield, 0),
141 HOW (R_PARISC_PCREL14DR, 2, 14, FALSE, bitfield, 0),
142 HOW (R_PARISC_PCREL16F, 2, 16, FALSE, bitfield, 0),
143 HOW (R_PARISC_PCREL16WF, 2, 16, FALSE, bitfield, 0),
144 HOW (R_PARISC_PCREL16DF, 2, 16, FALSE, bitfield, 0),
49bd834c 145 /* 80 */
487096bf
AM
146 HOW (R_PARISC_DIR64, 4, 64, FALSE, bitfield, 0),
147 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
148 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
149 HOW (R_PARISC_DIR14WR, 2, 14, FALSE, bitfield, 0),
150 HOW (R_PARISC_DIR14DR, 2, 14, FALSE, bitfield, 0),
151 HOW (R_PARISC_DIR16F, 2, 16, FALSE, bitfield, 0),
152 HOW (R_PARISC_DIR16WF, 2, 16, FALSE, bitfield, 0),
153 HOW (R_PARISC_DIR16DF, 2, 16, FALSE, bitfield, 0),
49bd834c 154 /* 88 */
487096bf
AM
155 HOW (R_PARISC_GPREL64, 4, 64, FALSE, bitfield, 0),
156 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
157 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
158 HOW (R_PARISC_DLTREL14WR, 2, 14, FALSE, bitfield, 0),
159 HOW (R_PARISC_DLTREL14DR, 2, 14, FALSE, bitfield, 0),
160 HOW (R_PARISC_GPREL16F, 2, 16, FALSE, bitfield, 0),
161 HOW (R_PARISC_GPREL16WF, 2, 16, FALSE, bitfield, 0),
162 HOW (R_PARISC_GPREL16DF, 2, 16, FALSE, bitfield, 0),
49bd834c 163 /* 96 */
487096bf
AM
164 HOW (R_PARISC_LTOFF64, 4, 64, FALSE, bitfield, 0),
165 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
166 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
167 HOW (R_PARISC_DLTIND14WR, 2, 14, FALSE, bitfield, 0),
168 HOW (R_PARISC_DLTIND14DR, 2, 14, FALSE, bitfield, 0),
169 HOW (R_PARISC_LTOFF16F, 2, 16, FALSE, bitfield, 0),
170 HOW (R_PARISC_LTOFF16WF, 2, 16, FALSE, bitfield, 0),
171 HOW (R_PARISC_LTOFF16DF, 2, 16, FALSE, bitfield, 0),
49bd834c 172 /* 104 */
487096bf
AM
173 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
174 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
175 HOW (R_PARISC_BASEREL14WR, 2, 14, FALSE, bitfield, 0),
176 HOW (R_PARISC_BASEREL14DR, 2, 14, FALSE, bitfield, 0),
177 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
178 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
179 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
180 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 181 /* 112 */
487096bf
AM
182 HOW (R_PARISC_SEGREL64, 4, 64, FALSE, bitfield, 0),
183 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
184 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
185 HOW (R_PARISC_PLTOFF14WR, 2, 14, FALSE, bitfield, 0),
186 HOW (R_PARISC_PLTOFF14DR, 2, 14, FALSE, bitfield, 0),
187 HOW (R_PARISC_PLTOFF16F, 2, 16, FALSE, bitfield, 0),
188 HOW (R_PARISC_PLTOFF16WF, 2, 16, FALSE, bitfield, 0),
189 HOW (R_PARISC_PLTOFF16DF, 2, 16, FALSE, bitfield, 0),
49bd834c 190 /* 120 */
487096bf
AM
191 HOW (R_PARISC_LTOFF_FPTR64, 4, 64, FALSE, bitfield, 0),
192 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
193 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
194 HOW (R_PARISC_LTOFF_FPTR14WR, 2, 14, FALSE, bitfield, 0),
195 HOW (R_PARISC_LTOFF_FPTR14DR, 2, 14, FALSE, bitfield, 0),
196 HOW (R_PARISC_LTOFF_FPTR16F, 2, 16, FALSE, bitfield, 0),
197 HOW (R_PARISC_LTOFF_FPTR16WF, 2, 16, FALSE, bitfield, 0),
198 HOW (R_PARISC_LTOFF_FPTR16DF, 2, 16, FALSE, bitfield, 0),
49bd834c 199 /* 128 */
487096bf
AM
200 HOW (R_PARISC_COPY, 0, 0, FALSE, bitfield, 0),
201 HOW (R_PARISC_IPLT, 0, 0, FALSE, bitfield, 0),
202 HOW (R_PARISC_EPLT, 0, 0, FALSE, bitfield, 0),
203 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
204 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
205 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
206 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
207 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 208 /* 136 */
487096bf
AM
209 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
210 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
211 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
212 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
213 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
214 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
215 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
216 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 217 /* 144 */
487096bf
AM
218 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
219 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
220 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
221 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
222 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
223 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
224 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
225 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
49bd834c 226 /* 152 */
487096bf
AM
227 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
228 HOW (R_PARISC_TPREL32, 2, 32, FALSE, dont, 0),
229 HOW (R_PARISC_TPREL21L, 2, 21, FALSE, bitfield, 0),
230 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
231 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
232 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
233 HOW (R_PARISC_TPREL14R, 2, 14, FALSE, bitfield, 0),
234 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
49bd834c 235 /* 160 */
487096bf
AM
236 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
237 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
238 HOW (R_PARISC_LTOFF_TP21L, 2, 21, FALSE, bitfield, 0),
239 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
240 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
241 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
242 HOW (R_PARISC_LTOFF_TP14R, 2, 14, FALSE, bitfield, 0),
243 HOW (R_PARISC_LTOFF_TP14F, 2, 14, FALSE, bitfield, 0),
49bd834c 244 /* 168 */
487096bf
AM
245 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
246 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
247 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
248 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
249 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
250 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
251 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
252 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 253 /* 176 */
487096bf
AM
254 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
255 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
256 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
257 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
258 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
259 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
260 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
261 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 262 /* 184 */
487096bf
AM
263 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
264 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
265 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
266 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
267 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
268 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
269 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
270 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
49bd834c 271 /* 192 */
487096bf
AM
272 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
273 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
274 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
275 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
276 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
277 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
278 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
279 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 280 /* 200 */
487096bf
AM
281 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
282 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
283 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
284 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
285 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
286 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
287 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
288 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 289 /* 208 */
487096bf
AM
290 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
291 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
292 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
293 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
294 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, dont, 0),
295 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
296 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
297 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
49bd834c 298 /* 216 */
487096bf
AM
299 HOW (R_PARISC_TPREL64, 4, 64, FALSE, bitfield, 0),
300 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
301 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
302 HOW (R_PARISC_TPREL14WR, 2, 14, FALSE, dont, 0),
303 HOW (R_PARISC_TPREL14DR, 2, 14, FALSE, bitfield, 0),
304 HOW (R_PARISC_TPREL16F, 2, 16, FALSE, bitfield, 0),
305 HOW (R_PARISC_TPREL16WF, 2, 16, FALSE, dont, 0),
306 HOW (R_PARISC_TPREL16DF, 2, 16, FALSE, bitfield, 0),
49bd834c 307 /* 224 */
487096bf
AM
308 HOW (R_PARISC_LTOFF_TP64, 4, 64, FALSE, bitfield, 0),
309 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
310 HOW (R_PARISC_UNIMPLEMENTED, 0, 0, FALSE, bitfield, 0),
311 HOW (R_PARISC_LTOFF_TP14WR, 2, 14, FALSE, bitfield, 0),
312 HOW (R_PARISC_LTOFF_TP14DR, 2, 14, FALSE, bitfield, 0),
313 HOW (R_PARISC_LTOFF_TP16F, 2, 16, FALSE, dont, 0),
314 HOW (R_PARISC_LTOFF_TP16WF, 2, 16, FALSE, bitfield, 0),
315 HOW (R_PARISC_LTOFF_TP16DF, 2, 16, FALSE, bitfield, 0),
49bd834c 316 /* 232 */
487096bf
AM
317 HOW (R_PARISC_GNU_VTENTRY, 0, 0, FALSE, dont, 0),
318 HOW (R_PARISC_GNU_VTINHERIT, 0, 0, FALSE, dont, 0),
319 HOW (R_PARISC_TLS_GD21L, 2, 21, FALSE, bitfield, 0),
320 HOW (R_PARISC_TLS_GD14R, 2, 14, FALSE, bitfield, 0),
321 HOW (R_PARISC_TLS_GDCALL, 0, 0, FALSE, dont, 0),
322 HOW (R_PARISC_TLS_LDM21L, 2, 21, FALSE, bitfield, 0),
323 HOW (R_PARISC_TLS_LDM14R, 2, 14, FALSE, bitfield, 0),
324 HOW (R_PARISC_TLS_LDMCALL, 0, 0, FALSE, dont, 0),
9b52905e 325 /* 240 */
487096bf
AM
326 HOW (R_PARISC_TLS_LDO21L, 2, 21, FALSE, bitfield, 0),
327 HOW (R_PARISC_TLS_LDO14R, 2, 14, FALSE, bitfield, 0),
328 HOW (R_PARISC_TLS_DTPMOD32, 2, 32, FALSE, bitfield, 0),
329 HOW (R_PARISC_TLS_DTPMOD64, 4, 64, FALSE, bitfield, 0),
330 HOW (R_PARISC_TLS_DTPOFF32, 2, 32, FALSE, bitfield, 0),
331 HOW (R_PARISC_TLS_DTPOFF64, 4, 64, FALSE, bitfield, 0)
332#undef HOW
9e103c9c
JL
333};
334
6e2bf930
JL
335#define OFFSET_14R_FROM_21L 4
336#define OFFSET_14F_FROM_21L 5
337
189c6563
AM
338/* Return the final relocation type for the given base type, instruction
339 format, and field selector. */
9e103c9c 340
189c6563 341elf_hppa_reloc_type
c39a58e6
AM
342elf_hppa_reloc_final_type (bfd *abfd,
343 elf_hppa_reloc_type base_type,
344 int format,
345 unsigned int field)
9e103c9c 346{
189c6563 347 elf_hppa_reloc_type final_type = base_type;
9e103c9c
JL
348
349 /* Just a tangle of nested switch statements to deal with the braindamage
350 that a different field selector means a completely different relocation
351 for PA ELF. */
352 switch (base_type)
353 {
9b52905e
NC
354 /* We have been using generic relocation types. However, that may not
355 really make sense. Anyway, we need to support both R_PARISC_DIR64
356 and R_PARISC_DIR32 here. */
0d571602
JL
357 case R_PARISC_DIR32:
358 case R_PARISC_DIR64:
9e103c9c
JL
359 case R_HPPA_ABS_CALL:
360 switch (format)
361 {
362 case 14:
363 switch (field)
364 {
47d89dba
AM
365 case e_fsel:
366 final_type = R_PARISC_DIR14F;
367 break;
9e103c9c
JL
368 case e_rsel:
369 case e_rrsel:
47d89dba 370 case e_rdsel:
9e103c9c
JL
371 final_type = R_PARISC_DIR14R;
372 break;
373 case e_rtsel:
f31cedf7 374 final_type = R_PARISC_DLTIND14R;
9e103c9c 375 break;
36860900
JL
376 case e_rtpsel:
377 final_type = R_PARISC_LTOFF_FPTR14DR;
378 break;
9e103c9c 379 case e_tsel:
f31cedf7 380 final_type = R_PARISC_DLTIND14F;
9e103c9c
JL
381 break;
382 case e_rpsel:
383 final_type = R_PARISC_PLABEL14R;
384 break;
385 default:
189c6563 386 return R_PARISC_NONE;
9e103c9c
JL
387 }
388 break;
389
390 case 17:
391 switch (field)
392 {
393 case e_fsel:
394 final_type = R_PARISC_DIR17F;
395 break;
396 case e_rsel:
397 case e_rrsel:
47d89dba 398 case e_rdsel:
9e103c9c
JL
399 final_type = R_PARISC_DIR17R;
400 break;
401 default:
189c6563 402 return R_PARISC_NONE;
9e103c9c
JL
403 }
404 break;
405
406 case 21:
407 switch (field)
408 {
409 case e_lsel:
410 case e_lrsel:
47d89dba 411 case e_ldsel:
edd21aca
AM
412 case e_nlsel:
413 case e_nlrsel:
9e103c9c
JL
414 final_type = R_PARISC_DIR21L;
415 break;
416 case e_ltsel:
f31cedf7 417 final_type = R_PARISC_DLTIND21L;
9e103c9c 418 break;
36860900
JL
419 case e_ltpsel:
420 final_type = R_PARISC_LTOFF_FPTR21L;
421 break;
9e103c9c
JL
422 case e_lpsel:
423 final_type = R_PARISC_PLABEL21L;
424 break;
425 default:
189c6563 426 return R_PARISC_NONE;
9e103c9c
JL
427 }
428 break;
429
430 case 32:
431 switch (field)
432 {
433 case e_fsel:
434 final_type = R_PARISC_DIR32;
432bdd91
JL
435 /* When in 64bit mode, a 32bit relocation is supposed to
436 be a section relative relocation. Dwarf2 (for example)
437 uses 32bit section relative relocations. */
30d10e9e 438 if (bfd_arch_bits_per_address (abfd) != 32)
46fe4e66 439 final_type = R_PARISC_SECREL32;
9e103c9c
JL
440 break;
441 case e_psel:
442 final_type = R_PARISC_PLABEL32;
443 break;
444 default:
189c6563 445 return R_PARISC_NONE;
9e103c9c
JL
446 }
447 break;
448
6e2bf930
JL
449 case 64:
450 switch (field)
451 {
452 case e_fsel:
453 final_type = R_PARISC_DIR64;
454 break;
455 case e_psel:
36860900
JL
456 final_type = R_PARISC_FPTR64;
457 break;
6e2bf930 458 default:
189c6563 459 return R_PARISC_NONE;
6e2bf930
JL
460 }
461 break;
462
9e103c9c 463 default:
189c6563 464 return R_PARISC_NONE;
9e103c9c
JL
465 }
466 break;
467
9e103c9c
JL
468 case R_HPPA_GOTOFF:
469 switch (format)
470 {
471 case 14:
472 switch (field)
473 {
474 case e_rsel:
475 case e_rrsel:
47d89dba 476 case e_rdsel:
9b52905e 477 /* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32. */
6e2bf930 478 final_type = base_type + OFFSET_14R_FROM_21L;
9e103c9c
JL
479 break;
480 case e_fsel:
9b52905e 481 /* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32. */
6e2bf930 482 final_type = base_type + OFFSET_14F_FROM_21L;
9e103c9c
JL
483 break;
484 default:
189c6563 485 return R_PARISC_NONE;
9e103c9c
JL
486 }
487 break;
488
489 case 21:
490 switch (field)
491 {
9e103c9c 492 case e_lsel:
edd21aca 493 case e_lrsel:
47d89dba 494 case e_ldsel:
edd21aca
AM
495 case e_nlsel:
496 case e_nlrsel:
9b52905e 497 /* R_PARISC_DLTREL21L for elf64, R_PARISC_DPREL21L for elf32. */
6e2bf930 498 final_type = base_type;
9e103c9c
JL
499 break;
500 default:
189c6563 501 return R_PARISC_NONE;
9e103c9c
JL
502 }
503 break;
504
6bba1048
DA
505 case 64:
506 switch (field)
507 {
508 case e_fsel:
509 final_type = R_PARISC_GPREL64;
510 break;
511 default:
512 return R_PARISC_NONE;
513 }
514 break;
515
9e103c9c 516 default:
189c6563 517 return R_PARISC_NONE;
9e103c9c
JL
518 }
519 break;
520
9e103c9c
JL
521 case R_HPPA_PCREL_CALL:
522 switch (format)
523 {
49bd834c
AM
524 case 12:
525 switch (field)
526 {
527 case e_fsel:
528 final_type = R_PARISC_PCREL12F;
529 break;
530 default:
189c6563 531 return R_PARISC_NONE;
49bd834c
AM
532 }
533 break;
534
9e103c9c 535 case 14:
49bd834c
AM
536 /* Contrary to appearances, these are not calls of any sort.
537 Rather, they are loads/stores with a pcrel reloc. */
9e103c9c
JL
538 switch (field)
539 {
540 case e_rsel:
541 case e_rrsel:
47d89dba 542 case e_rdsel:
9e103c9c
JL
543 final_type = R_PARISC_PCREL14R;
544 break;
545 case e_fsel:
ba94744e
AM
546 if (bfd_get_mach (abfd) < 25)
547 final_type = R_PARISC_PCREL14F;
548 else
549 final_type = R_PARISC_PCREL16F;
9e103c9c
JL
550 break;
551 default:
189c6563 552 return R_PARISC_NONE;
9e103c9c
JL
553 }
554 break;
555
556 case 17:
557 switch (field)
558 {
559 case e_rsel:
560 case e_rrsel:
47d89dba 561 case e_rdsel:
9e103c9c
JL
562 final_type = R_PARISC_PCREL17R;
563 break;
564 case e_fsel:
565 final_type = R_PARISC_PCREL17F;
566 break;
567 default:
189c6563 568 return R_PARISC_NONE;
9e103c9c
JL
569 }
570 break;
571
edd21aca 572 case 21:
341362b5
JL
573 switch (field)
574 {
edd21aca
AM
575 case e_lsel:
576 case e_lrsel:
47d89dba 577 case e_ldsel:
edd21aca
AM
578 case e_nlsel:
579 case e_nlrsel:
580 final_type = R_PARISC_PCREL21L;
341362b5
JL
581 break;
582 default:
189c6563 583 return R_PARISC_NONE;
341362b5
JL
584 }
585 break;
586
edd21aca 587 case 22:
9e103c9c
JL
588 switch (field)
589 {
edd21aca
AM
590 case e_fsel:
591 final_type = R_PARISC_PCREL22F;
9e103c9c
JL
592 break;
593 default:
189c6563 594 return R_PARISC_NONE;
9e103c9c
JL
595 }
596 break;
597
9992270f
DA
598 case 32:
599 switch (field)
600 {
601 case e_fsel:
602 final_type = R_PARISC_PCREL32;
603 break;
604 default:
605 return R_PARISC_NONE;
606 }
607 break;
608
609 case 64:
610 switch (field)
611 {
612 case e_fsel:
613 final_type = R_PARISC_PCREL64;
614 break;
615 default:
616 return R_PARISC_NONE;
617 }
618 break;
619
9e103c9c 620 default:
189c6563 621 return R_PARISC_NONE;
9e103c9c
JL
622 }
623 break;
624
9b52905e
NC
625 case R_PARISC_TLS_GD21L:
626 switch (field)
627 {
628 case e_ltsel:
629 case e_lrsel:
630 final_type = R_PARISC_TLS_GD21L;
631 break;
632 case e_rtsel:
633 case e_rrsel:
634 final_type = R_PARISC_TLS_GD14R;
635 break;
636 default:
637 return R_PARISC_NONE;
638 }
639 break;
640
641 case R_PARISC_TLS_LDM21L:
642 switch (field)
643 {
644 case e_ltsel:
645 case e_lrsel:
646 final_type = R_PARISC_TLS_LDM21L;
647 break;
648 case e_rtsel:
649 case e_rrsel:
650 final_type = R_PARISC_TLS_LDM14R;
651 break;
652 default:
653 return R_PARISC_NONE;
654 }
655 break;
656
657 case R_PARISC_TLS_LDO21L:
658 switch (field)
659 {
660 case e_lrsel:
661 final_type = R_PARISC_TLS_LDO21L;
662 break;
663 case e_rrsel:
664 final_type = R_PARISC_TLS_LDO14R;
665 break;
666 default:
667 return R_PARISC_NONE;
668 }
669 break;
670
671 case R_PARISC_TLS_IE21L:
672 switch (field)
673 {
674 case e_ltsel:
675 case e_lrsel:
676 final_type = R_PARISC_TLS_IE21L;
677 break;
678 case e_rtsel:
679 case e_rrsel:
680 final_type = R_PARISC_TLS_IE14R;
681 break;
682 default:
683 return R_PARISC_NONE;
684 }
685 break;
686
687 case R_PARISC_TLS_LE21L:
688 switch (field)
689 {
690 case e_lrsel:
691 final_type = R_PARISC_TLS_LE21L;
692 break;
693 case e_rrsel:
694 final_type = R_PARISC_TLS_LE14R;
695 break;
696 default:
697 return R_PARISC_NONE;
698 }
699 break;
700
6bba1048
DA
701 case R_PARISC_SEGREL32:
702 switch (format)
703 {
704 case 32:
705 switch (field)
706 {
707 case e_fsel:
708 final_type = R_PARISC_SEGREL32;
709 break;
710 default:
711 return R_PARISC_NONE;
712 }
713 break;
714
715 case 64:
716 switch (field)
717 {
718 case e_fsel:
719 final_type = R_PARISC_SEGREL64;
720 break;
721 default:
722 return R_PARISC_NONE;
723 }
724 break;
725
726 default:
727 return R_PARISC_NONE;
728 }
729 break;
730
49bd834c
AM
731 case R_PARISC_GNU_VTENTRY:
732 case R_PARISC_GNU_VTINHERIT:
fc91f658
JL
733 case R_PARISC_SEGBASE:
734 /* The defaults are fine for these cases. */
735 break;
736
9e103c9c 737 default:
189c6563 738 return R_PARISC_NONE;
9e103c9c
JL
739 }
740
189c6563
AM
741 return final_type;
742}
743
744/* Return one (or more) BFD relocations which implement the base
745 relocation with modifications based on format and field. */
746
747elf_hppa_reloc_type **
c39a58e6
AM
748_bfd_elf_hppa_gen_reloc_type (bfd *abfd,
749 elf_hppa_reloc_type base_type,
750 int format,
751 unsigned int field,
752 int ignore ATTRIBUTE_UNUSED,
753 asymbol *sym ATTRIBUTE_UNUSED)
189c6563
AM
754{
755 elf_hppa_reloc_type *finaltype;
756 elf_hppa_reloc_type **final_types;
757 bfd_size_type amt = sizeof (elf_hppa_reloc_type *) * 2;
758
759 /* Allocate slots for the BFD relocation. */
c39a58e6 760 final_types = bfd_alloc (abfd, amt);
189c6563
AM
761 if (final_types == NULL)
762 return NULL;
763
764 /* Allocate space for the relocation itself. */
765 amt = sizeof (elf_hppa_reloc_type);
c39a58e6 766 finaltype = bfd_alloc (abfd, amt);
189c6563
AM
767 if (finaltype == NULL)
768 return NULL;
769
770 /* Some reasonable defaults. */
771 final_types[0] = finaltype;
772 final_types[1] = NULL;
773
774 *finaltype = elf_hppa_reloc_final_type (abfd, base_type, format, field);
775
9e103c9c
JL
776 return final_types;
777}
778
779/* Translate from an elf into field into a howto relocation pointer. */
780
f3185997 781static bfd_boolean
8b6a949a 782elf_hppa_info_to_howto (bfd *abfd,
c39a58e6
AM
783 arelent *bfd_reloc,
784 Elf_Internal_Rela *elf_reloc)
9e103c9c 785{
f3185997 786 unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info);
8ee55178 787 unsigned int type = r_type;
0e8452bb 788 reloc_howto_type *howto = NULL;
f3185997 789
8ee55178
MR
790 if (r_type < (unsigned int) R_PARISC_UNIMPLEMENTED)
791 {
792 howto = &elf_hppa_howto_table[r_type];
793 type = howto->type;
794 }
795 if (type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
f3185997
NC
796 {
797 /* xgettext:c-format */
798 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
799 abfd, r_type);
800 bfd_set_error (bfd_error_bad_value);
801 return FALSE;
802 }
8ee55178 803 bfd_reloc->howto = howto;
f3185997 804 return TRUE;
9e103c9c
JL
805}
806
807/* Translate from an elf into field into a howto relocation pointer. */
808
f3185997
NC
809static bfd_boolean
810elf_hppa_info_to_howto_rel (bfd *abfd,
c39a58e6
AM
811 arelent *bfd_reloc,
812 Elf_Internal_Rela *elf_reloc)
9e103c9c 813{
f3185997 814 unsigned int r_type = ELF_R_TYPE (elf_reloc->r_info);
8ee55178 815 unsigned int type = r_type;
0e8452bb 816 reloc_howto_type *howto = NULL;
f3185997 817
8ee55178
MR
818 if (r_type < (unsigned int) R_PARISC_UNIMPLEMENTED)
819 {
820 howto = &elf_hppa_howto_table[r_type];
821 type = howto->type;
822 }
823 if (type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
f3185997
NC
824 {
825 /* xgettext:c-format */
d81270c3
MR
826 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
827 abfd, r_type);
f3185997
NC
828 bfd_set_error (bfd_error_bad_value);
829 return FALSE;
830 }
8ee55178 831 bfd_reloc->howto = howto;
f3185997 832 return TRUE;
9e103c9c
JL
833}
834
835/* Return the address of the howto table entry to perform the CODE
836 relocation for an ARCH machine. */
837
838static reloc_howto_type *
c39a58e6
AM
839elf_hppa_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
840 bfd_reloc_code_real_type code)
9e103c9c
JL
841{
842 if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
843 {
844 BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
845 return &elf_hppa_howto_table[(int) code];
846 }
847 return NULL;
848}
95cbae0b 849
157090f7
AM
850static reloc_howto_type *
851elf_hppa_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
852 const char *r_name)
853{
854 unsigned int i;
855
856 for (i = 0;
857 i < sizeof (elf_hppa_howto_table) / sizeof (elf_hppa_howto_table[0]);
858 i++)
859 if (elf_hppa_howto_table[i].name != NULL
860 && strcasecmp (elf_hppa_howto_table[i].name, r_name) == 0)
861 return &elf_hppa_howto_table[i];
862
863 return NULL;
864}
865
b34976b6 866/* Return TRUE if SYM represents a local label symbol. */
432bdd91 867
b34976b6 868static bfd_boolean
c39a58e6 869elf_hppa_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
432bdd91 870{
49bd834c 871 if (name[0] == 'L' && name[1] == '$')
9b52905e 872 return TRUE;
49bd834c 873 return _bfd_elf_is_local_label_name (abfd, name);
432bdd91
JL
874}
875
052e120f
JL
876/* Set the correct type for an ELF section. We do this by the
877 section name, which is a hack, but ought to work. */
878
b34976b6 879static bfd_boolean
c39a58e6 880elf_hppa_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec)
052e120f 881{
c39a58e6 882 const char *name;
052e120f
JL
883
884 name = bfd_get_section_name (abfd, sec);
885
886 if (strcmp (name, ".PARISC.unwind") == 0)
887 {
1ca74062 888 int indx;
edd21aca 889 asection *asec;
9b52905e 890
3f9b03b5 891#if ARCH_SIZE == 64
6f4286c4 892 hdr->sh_type = SHT_PARISC_UNWIND;
3f9b03b5 893#else
6f4286c4
HD
894 /* Note - it is not clear why this is not SHT_PARISC_UNWIND as well.
895 Presumably it is a historical constraint, so leave it as it is. */
896 hdr->sh_type = SHT_PROGBITS;
3f9b03b5 897#endif
052e120f
JL
898 /* ?!? How are unwinds supposed to work for symbols in arbitrary
899 sections? Or what if we have multiple .text sections in a single
be7582f3 900 .o file? HP really messed up on this one.
052e120f 901
1ca74062
JL
902 Ugh. We can not use elf_section_data (sec)->this_idx at this
903 point because it is not initialized yet.
904
905 So we (gasp) recompute it here. Hopefully nobody ever changes the
906 way sections are numbered in elf.c! */
edd21aca 907 for (asec = abfd->sections, indx = 1; asec; asec = asec->next, indx++)
1ca74062 908 {
edd21aca 909 if (asec->name && strcmp (asec->name, ".text") == 0)
1ca74062
JL
910 {
911 hdr->sh_info = indx;
7bd9df3b 912 hdr->sh_flags |= SHF_INFO_LINK;
1ca74062
JL
913 break;
914 }
915 }
be7582f3 916
6f4286c4
HD
917 /* The unwind table entries are 16 bytes long, so it is not clear
918 why this field is set to 4. (The ELF spec says that the sh_entsize
919 field is a byte quantity, but this is a processor specific section,
920 so it is allowed to change the rules). Leave as it is for now. */
052e120f
JL
921 hdr->sh_entsize = 4;
922 }
b34976b6 923 return TRUE;
052e120f
JL
924}
925
3f9b03b5 926static void
06f44071 927elf_hppa_final_write_processing (bfd *abfd, bfd_boolean linker)
3f9b03b5
AM
928{
929 int mach = bfd_get_mach (abfd);
930
931 elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL
932 | EF_PARISC_EXT | EF_PARISC_LSB
933 | EF_PARISC_WIDE | EF_PARISC_NO_KABP
934 | EF_PARISC_LAZYSWAP);
935
936 if (mach == 10)
937 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0;
938 else if (mach == 11)
939 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1;
940 else if (mach == 20)
941 elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0;
942 else if (mach == 25)
943 elf_elfheader (abfd)->e_flags |= (EF_PARISC_WIDE
944 | EFA_PARISC_2_0
945 /* The GNU tools have trapped without
946 option since 1993, so need to take
947 a step backwards with the ELF
948 based toolchains. */
949 | EF_PARISC_TRAPNIL);
06f44071 950 _bfd_elf_final_write_processing (abfd, linker);
3f9b03b5
AM
951}
952
46fe4e66
AM
953/* Comparison function for qsort to sort unwind section during a
954 final link. */
955
956static int
c39a58e6 957hppa_unwind_entry_compare (const void *a, const void *b)
46fe4e66
AM
958{
959 const bfd_byte *ap, *bp;
960 unsigned long av, bv;
961
c39a58e6 962 ap = a;
46fe4e66
AM
963 av = (unsigned long) ap[0] << 24;
964 av |= (unsigned long) ap[1] << 16;
965 av |= (unsigned long) ap[2] << 8;
966 av |= (unsigned long) ap[3];
967
c39a58e6 968 bp = b;
46fe4e66
AM
969 bv = (unsigned long) bp[0] << 24;
970 bv |= (unsigned long) bp[1] << 16;
971 bv |= (unsigned long) bp[2] << 8;
972 bv |= (unsigned long) bp[3];
973
974 return av < bv ? -1 : av > bv ? 1 : 0;
975}
976
9b52905e
NC
977static bfd_boolean
978elf_hppa_sort_unwind (bfd *abfd)
46fe4e66
AM
979{
980 asection *s;
981
982 /* Magic section names, but this is much safer than having
983 relocate_section remember where SEGREL32 relocs occurred.
984 Consider what happens if someone inept creates a linker script
985 that puts unwind information in .text. */
986 s = bfd_get_section_by_name (abfd, ".PARISC.unwind");
987 if (s != NULL)
988 {
989 bfd_size_type size;
eea6121a 990 bfd_byte *contents;
46fe4e66 991
eea6121a 992 if (!bfd_malloc_and_get_section (abfd, s, &contents))
b34976b6 993 return FALSE;
46fe4e66 994
eea6121a 995 size = s->size;
46fe4e66
AM
996 qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare);
997
998 if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size))
b34976b6 999 return FALSE;
46fe4e66
AM
1000 }
1001
b34976b6 1002 return TRUE;
46fe4e66
AM
1003}
1004
8a696751
AM
1005/* What to do when ld finds relocations against symbols defined in
1006 discarded sections. */
1007
1008static unsigned int
1009elf_hppa_action_discarded (asection *sec)
1010{
da6e19a9
JDA
1011 /* Ignore relocations in .data.rel.ro.local. This section can contain
1012 PLABEL32 relocations to functions in discarded COMDAT groups. */
1013 if (strcmp (".data.rel.ro.local", sec->name) == 0)
1014 return 0;
1015
8a696751
AM
1016 if (strcmp (".PARISC.unwind", sec->name) == 0)
1017 return 0;
1018
1019 return _bfd_elf_default_action_discarded (sec);
1020}
This page took 1.001981 seconds and 4 git commands to generate.