Commit | Line | Data |
---|---|---|
4c85cbfa | 1 | /* BFD back-end for HP PA-RISC ELF files. |
31dabb6c | 2 | Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc. |
4c85cbfa KR |
3 | |
4 | Written by | |
e8f2240a | 5 | |
4c85cbfa KR |
6 | Center for Software Science |
7 | Department of Computer Science | |
8 | University of Utah | |
9 | ||
10 | This file is part of BFD, the Binary File Descriptor library. | |
11 | ||
12 | This program is free software; you can redistribute it and/or modify | |
13 | it under the terms of the GNU General Public License as published by | |
14 | the Free Software Foundation; either version 2 of the License, or | |
15 | (at your option) any later version. | |
16 | ||
17 | This program is distributed in the hope that it will be useful, | |
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | GNU General Public License for more details. | |
21 | ||
22 | You should have received a copy of the GNU General Public License | |
23 | along with this program; if not, write to the Free Software | |
a9713b91 | 24 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
4c85cbfa KR |
25 | |
26 | #include "bfd.h" | |
27 | #include "sysdep.h" | |
24f13b03 | 28 | #include "bfdlink.h" |
4c85cbfa KR |
29 | #include "libbfd.h" |
30 | #include "obstack.h" | |
a9713b91 | 31 | #include "elf-bfd.h" |
4c85cbfa | 32 | |
b68a74d1 JL |
33 | /* The internal type of a symbol table extension entry. */ |
34 | typedef unsigned long symext_entryS; | |
35 | ||
36 | /* The external type of a symbol table extension entry. */ | |
37 | #define ELF32_PARISC_SX_SIZE (4) | |
38 | #define ELF32_PARISC_SX_GET(bfd, addr) bfd_h_get_32 ((bfd), (addr)) | |
39 | #define ELF32_PARISC_SX_PUT(bfd, val, addr) \ | |
40 | bfd_h_put_32 ((bfd), (val), (addr)) | |
4c85cbfa | 41 | |
24f13b03 ILT |
42 | /* HPPA symbol table extension entry types */ |
43 | enum elf32_hppa_symextn_types | |
44 | { | |
45 | PARISC_SXT_NULL, | |
46 | PARISC_SXT_SYMNDX, | |
47 | PARISC_SXT_ARG_RELOC, | |
48 | }; | |
4c85cbfa | 49 | |
24f13b03 | 50 | /* These macros compose and decompose the value of a symextn entry: |
4c85cbfa | 51 | |
24f13b03 ILT |
52 | entry_type = ELF32_PARISC_SX_TYPE(word); |
53 | entry_value = ELF32_PARISC_SX_VAL(word); | |
54 | word = ELF32_PARISC_SX_WORD(type,val); */ | |
55 | ||
56 | #define ELF32_PARISC_SX_TYPE(p) ((p) >> 24) | |
57 | #define ELF32_PARISC_SX_VAL(p) ((p) & 0xFFFFFF) | |
58 | #define ELF32_PARISC_SX_WORD(type,val) (((type) << 24) + (val & 0xFFFFFF)) | |
59 | ||
60 | /* The following was added facilitate implementation of the .hppa_symextn | |
61 | section. This section is built after the symbol table is built in the | |
62 | elf_write_object_contents routine (called from bfd_close). It is built | |
63 | so late because it requires information that is not known until | |
64 | the symbol and string table sections have been allocated, and | |
65 | the symbol table has been built. */ | |
66 | ||
67 | #define SYMEXTN_SECTION_NAME ".PARISC.symext" | |
68 | ||
24f13b03 ILT |
69 | struct symext_chain |
70 | { | |
71 | symext_entryS entry; | |
72 | struct symext_chain *next; | |
73 | }; | |
74 | ||
75 | typedef struct symext_chain symext_chainS; | |
76 | ||
77 | /* We use three different hash tables to hold information for | |
78 | linking PA ELF objects. | |
79 | ||
80 | The first is the elf32_hppa_link_hash_table which is derived | |
81 | from the standard ELF linker hash table. We use this as a place to | |
82 | attach other hash tables and static information. | |
83 | ||
84 | The second is the stub hash table which is derived from the | |
85 | base BFD hash table. The stub hash table holds the information | |
86 | necessary to build the linker stubs during a link. | |
87 | ||
88 | The last hash table keeps track of argument location information needed | |
89 | to build hash tables. Each function with nonzero argument location | |
90 | bits will have an entry in this table. */ | |
91 | ||
92 | /* Hash table for linker stubs. */ | |
93 | ||
94 | struct elf32_hppa_stub_hash_entry | |
95 | { | |
96 | /* Base hash table entry structure, we can get the name of the stub | |
97 | (and thus know exactly what actions it performs) from the base | |
98 | hash table entry. */ | |
99 | struct bfd_hash_entry root; | |
100 | ||
101 | /* Offset of the beginning of this stub. */ | |
102 | bfd_vma offset; | |
103 | ||
104 | /* Given the symbol's value and its section we can determine its final | |
105 | value when building the stubs (so the stub knows where to jump. */ | |
106 | symvalue target_value; | |
107 | asection *target_section; | |
108 | }; | |
109 | ||
110 | struct elf32_hppa_stub_hash_table | |
111 | { | |
112 | /* The hash table itself. */ | |
113 | struct bfd_hash_table root; | |
114 | ||
115 | /* The stub BFD. */ | |
116 | bfd *stub_bfd; | |
117 | ||
118 | /* Where to place the next stub. */ | |
119 | bfd_byte *location; | |
120 | ||
121 | /* Current offset in the stub section. */ | |
122 | unsigned int offset; | |
123 | ||
124 | }; | |
125 | ||
126 | /* Hash table for argument location information. */ | |
127 | ||
128 | struct elf32_hppa_args_hash_entry | |
e08b9ad7 | 129 | { |
24f13b03 ILT |
130 | /* Base hash table entry structure. */ |
131 | struct bfd_hash_entry root; | |
132 | ||
133 | /* The argument location bits for this entry. */ | |
134 | int arg_bits; | |
135 | }; | |
e08b9ad7 | 136 | |
24f13b03 ILT |
137 | struct elf32_hppa_args_hash_table |
138 | { | |
139 | /* The hash table itself. */ | |
140 | struct bfd_hash_table root; | |
141 | }; | |
e08b9ad7 | 142 | |
24f13b03 | 143 | struct elf32_hppa_link_hash_entry |
e08b9ad7 | 144 | { |
24f13b03 ILT |
145 | struct elf_link_hash_entry root; |
146 | }; | |
147 | ||
148 | struct elf32_hppa_link_hash_table | |
e08b9ad7 | 149 | { |
24f13b03 ILT |
150 | /* The main hash table. */ |
151 | struct elf_link_hash_table root; | |
152 | ||
153 | /* The stub hash table. */ | |
154 | struct elf32_hppa_stub_hash_table *stub_hash_table; | |
155 | ||
156 | /* The argument relocation bits hash table. */ | |
157 | struct elf32_hppa_args_hash_table *args_hash_table; | |
158 | ||
159 | /* A count of the number of output symbols. */ | |
160 | unsigned int output_symbol_count; | |
161 | ||
162 | /* Stuff so we can handle DP relative relocations. */ | |
163 | long global_value; | |
164 | int global_sym_defined; | |
165 | }; | |
166 | ||
e08b9ad7 JL |
167 | /* FIXME. */ |
168 | #define ARGUMENTS 0 | |
169 | #define RETURN_VALUE 1 | |
170 | ||
24f13b03 | 171 | /* The various argument relocations that may be performed. */ |
e08b9ad7 JL |
172 | typedef enum |
173 | { | |
174 | /* No relocation. */ | |
24f13b03 ILT |
175 | NO, |
176 | /* Relocate 32 bits from GR to FP register. */ | |
177 | GF, | |
178 | /* Relocate 64 bits from a GR pair to FP pair. */ | |
179 | GD, | |
180 | /* Relocate 32 bits from FP to GR. */ | |
181 | FG, | |
182 | /* Relocate 64 bits from FP pair to GR pair. */ | |
183 | DG, | |
e08b9ad7 JL |
184 | } arg_reloc_type; |
185 | ||
e08b9ad7 JL |
186 | /* What is being relocated (eg which argument or the return value). */ |
187 | typedef enum | |
188 | { | |
24f13b03 | 189 | ARG0, ARG1, ARG2, ARG3, RET, |
e08b9ad7 JL |
190 | } arg_reloc_location; |
191 | ||
e08b9ad7 | 192 | |
24f13b03 | 193 | /* ELF32/HPPA relocation support |
e08b9ad7 | 194 | |
24f13b03 ILT |
195 | This file contains ELF32/HPPA relocation support as specified |
196 | in the Stratus FTX/Golf Object File Format (SED-1762) dated | |
197 | February 1994. */ | |
198 | ||
199 | #include "elf32-hppa.h" | |
200 | #include "hppa_stubs.h" | |
4c85cbfa | 201 | |
4991ebb9 ILT |
202 | static bfd_reloc_status_type hppa_elf_reloc |
203 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
4c85cbfa | 204 | |
24f13b03 | 205 | static unsigned long hppa_elf_relocate_insn |
f5bfdacd JL |
206 | PARAMS ((bfd *, asection *, unsigned long, unsigned long, long, |
207 | long, unsigned long, unsigned long, unsigned long)); | |
208 | ||
f5bfdacd JL |
209 | static bfd_reloc_status_type hppa_elf_reloc |
210 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd*, char **)); | |
211 | ||
31dabb6c | 212 | static reloc_howto_type * elf_hppa_reloc_type_lookup |
7ed5e970 | 213 | PARAMS ((bfd *, bfd_reloc_code_real_type)); |
f5bfdacd | 214 | |
24f13b03 ILT |
215 | static boolean elf32_hppa_set_section_contents |
216 | PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); | |
e08b9ad7 | 217 | |
24f13b03 ILT |
218 | static void elf_info_to_howto |
219 | PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); | |
e08b9ad7 | 220 | |
24f13b03 | 221 | static boolean elf32_hppa_backend_symbol_table_processing |
a9713b91 | 222 | PARAMS ((bfd *, elf_symbol_type *, unsigned int)); |
e08b9ad7 | 223 | |
24f13b03 ILT |
224 | static void elf32_hppa_backend_begin_write_processing |
225 | PARAMS ((bfd *, struct bfd_link_info *)); | |
e08b9ad7 | 226 | |
24f13b03 ILT |
227 | static void elf32_hppa_backend_final_write_processing |
228 | PARAMS ((bfd *, boolean)); | |
e08b9ad7 | 229 | |
24f13b03 ILT |
230 | static void add_entry_to_symext_chain |
231 | PARAMS ((bfd *, unsigned int, unsigned int, symext_chainS **, | |
232 | symext_chainS **)); | |
e08b9ad7 | 233 | |
24f13b03 ILT |
234 | static void |
235 | elf_hppa_tc_make_sections PARAMS ((bfd *, symext_chainS *)); | |
e08b9ad7 | 236 | |
24f13b03 | 237 | static boolean hppa_elf_is_local_label PARAMS ((bfd *, asymbol *)); |
e08b9ad7 | 238 | |
24f13b03 ILT |
239 | static boolean elf32_hppa_add_symbol_hook |
240 | PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, | |
241 | const char **, flagword *, asection **, bfd_vma *)); | |
e08b9ad7 | 242 | |
24f13b03 | 243 | static bfd_reloc_status_type elf32_hppa_bfd_final_link_relocate |
31dabb6c | 244 | PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *, |
24f13b03 ILT |
245 | bfd_byte *, bfd_vma, bfd_vma, bfd_vma, struct bfd_link_info *, |
246 | asection *, const char *, int)); | |
e08b9ad7 | 247 | |
24f13b03 ILT |
248 | static struct bfd_link_hash_table *elf32_hppa_link_hash_table_create |
249 | PARAMS ((bfd *)); | |
e08b9ad7 | 250 | |
24f13b03 ILT |
251 | static struct bfd_hash_entry * |
252 | elf32_hppa_stub_hash_newfunc | |
253 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); | |
e08b9ad7 | 254 | |
24f13b03 ILT |
255 | static struct bfd_hash_entry * |
256 | elf32_hppa_args_hash_newfunc | |
257 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); | |
e08b9ad7 | 258 | |
24f13b03 ILT |
259 | static boolean |
260 | elf32_hppa_relocate_section | |
261 | PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, | |
eb4267a3 | 262 | bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); |
e08b9ad7 | 263 | |
24f13b03 ILT |
264 | static boolean |
265 | elf32_hppa_stub_hash_table_init | |
266 | PARAMS ((struct elf32_hppa_stub_hash_table *, bfd *, | |
267 | struct bfd_hash_entry *(*) PARAMS ((struct bfd_hash_entry *, | |
268 | struct bfd_hash_table *, | |
269 | const char *)))); | |
e08b9ad7 | 270 | |
24f13b03 ILT |
271 | static boolean |
272 | elf32_hppa_build_one_stub PARAMS ((struct bfd_hash_entry *, PTR)); | |
e08b9ad7 | 273 | |
24f13b03 ILT |
274 | static boolean |
275 | elf32_hppa_read_symext_info | |
276 | PARAMS ((bfd *, Elf_Internal_Shdr *, struct elf32_hppa_args_hash_table *, | |
5874427f | 277 | Elf_Internal_Sym *)); |
e08b9ad7 | 278 | |
24f13b03 ILT |
279 | static unsigned int elf32_hppa_size_of_stub |
280 | PARAMS ((unsigned int, unsigned int, bfd_vma, bfd_vma, const char *)); | |
459ae909 | 281 | |
24f13b03 ILT |
282 | static boolean elf32_hppa_arg_reloc_needed |
283 | PARAMS ((unsigned int, unsigned int, arg_reloc_type [])); | |
459ae909 | 284 | |
24f13b03 ILT |
285 | static void elf32_hppa_name_of_stub |
286 | PARAMS ((unsigned int, unsigned int, bfd_vma, bfd_vma, char *)); | |
459ae909 | 287 | |
24f13b03 | 288 | static boolean elf32_hppa_size_symext PARAMS ((struct bfd_hash_entry *, PTR)); |
459ae909 | 289 | |
24f13b03 ILT |
290 | static boolean elf32_hppa_link_output_symbol_hook |
291 | PARAMS ((bfd *, struct bfd_link_info *, const char *, | |
292 | Elf_Internal_Sym *, asection *)); | |
25057836 | 293 | |
e08b9ad7 JL |
294 | /* ELF/PA relocation howto entries. */ |
295 | ||
d9ad93bc | 296 | static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] = |
4c85cbfa | 297 | { |
459ae909 JL |
298 | {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_NONE"}, |
299 | {R_PARISC_DIR32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR32"}, | |
300 | {R_PARISC_DIR21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR21L"}, | |
301 | {R_PARISC_DIR17R, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR17R"}, | |
302 | {R_PARISC_DIR17F, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR17F"}, | |
303 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
304 | {R_PARISC_DIR14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR14R"}, | |
305 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
306 | ||
307 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
308 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
309 | {R_PARISC_PCREL21L, 0, 0, 21, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL21L"}, | |
310 | {R_PARISC_PCREL17R, 0, 0, 17, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL17R"}, | |
311 | {R_PARISC_PCREL17F, 0, 0, 17, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL17F"}, | |
312 | {R_PARISC_PCREL17C, 0, 0, 17, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL17C"}, | |
313 | {R_PARISC_PCREL14R, 0, 0, 14, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL14R"}, | |
314 | {R_PARISC_PCREL14F, 0, 0, 14, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL14F"}, | |
315 | ||
316 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
317 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
318 | {R_PARISC_DPREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DPREL21L"}, | |
319 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
320 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
321 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
322 | {R_PARISC_DPREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DPREL14R"}, | |
323 | {R_PARISC_DPREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DPREL14F"}, | |
324 | ||
325 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
326 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
327 | {R_PARISC_DLTREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTREL21L"}, | |
328 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
329 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
330 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
331 | {R_PARISC_DLTREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTREL14R"}, | |
332 | {R_PARISC_DLTREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTREL14F"}, | |
333 | ||
334 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
335 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
336 | {R_PARISC_DLTIND21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTIND21L"}, | |
337 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
338 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
339 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
340 | {R_PARISC_DLTIND14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTIND14R"}, | |
341 | {R_PARISC_DLTIND14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTIND14F"}, | |
342 | ||
343 | {R_PARISC_SETBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_SETBASE"}, | |
344 | {R_PARISC_BASEREL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL32"}, | |
345 | {R_PARISC_BASEREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL21L"}, | |
346 | {R_PARISC_BASEREL17R, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL17R"}, | |
347 | {R_PARISC_BASEREL17F, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL17F"}, | |
348 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
349 | {R_PARISC_BASEREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL14R"}, | |
350 | {R_PARISC_BASEREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL14F"}, | |
351 | ||
352 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
353 | {R_PARISC_TEXTREL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_TEXTREL32"}, | |
354 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
355 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
356 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
357 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
358 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
359 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
360 | ||
361 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
362 | {R_PARISC_DATAREL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
363 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
364 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
365 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
366 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
367 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
368 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
369 | ||
370 | ||
371 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
372 | {R_PARISC_PLABEL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLABEL32"}, | |
373 | {R_PARISC_PLABEL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLABEL21L"}, | |
374 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
375 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
376 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
377 | {R_PARISC_PLABEL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLABEL14R"}, | |
378 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
379 | ||
380 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
381 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
382 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
383 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
384 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
385 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
386 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
387 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
388 | ||
389 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
390 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
391 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
392 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
393 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
394 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
395 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
396 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
397 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
398 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
399 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
400 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
401 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
402 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
403 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
404 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
405 | ||
406 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
407 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
408 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
409 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
410 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
411 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
412 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
413 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
414 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
415 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
416 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
417 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
418 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
419 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
420 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
421 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
422 | ||
423 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
424 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
425 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
426 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
427 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
428 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
429 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
430 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
431 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
432 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
433 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
434 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
435 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
436 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
437 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
438 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
439 | ||
440 | ||
441 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
442 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
443 | {R_PARISC_PLTIND21L, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLTIND21L"}, | |
444 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
445 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
446 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"}, | |
447 | {R_PARISC_PLTIND14R, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLTIND14R"}, | |
448 | {R_PARISC_PLTIND14F, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLTIND14F"}, | |
449 | ||
450 | ||
451 | {R_PARISC_COPY, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_COPY"}, | |
452 | {R_PARISC_GLOB_DAT, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_GLOB_DAT"}, | |
453 | {R_PARISC_JMP_SLOT, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_JMP_SLOT"}, | |
454 | {R_PARISC_RELATIVE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_RELATIVE"}, | |
459ae909 JL |
455 | |
456 | {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"}, | |
e8f2240a | 457 | }; |
4c85cbfa | 458 | |
24f13b03 ILT |
459 | /* Where (what register type) is an argument comming from? */ |
460 | typedef enum | |
461 | { | |
462 | AR_NO, | |
463 | AR_GR, | |
464 | AR_FR, | |
465 | AR_FU, | |
466 | AR_FPDBL1, | |
467 | AR_FPDBL2, | |
468 | } arg_location; | |
469 | ||
470 | /* Horizontal represents the callee's argument location information, | |
471 | vertical represents caller's argument location information. Value at a | |
472 | particular X,Y location represents what (if any) argument relocation | |
473 | needs to be performed to make caller and callee agree. */ | |
474 | ||
475 | static CONST arg_reloc_type arg_mismatches[6][6] = | |
476 | { | |
477 | {NO, NO, NO, NO, NO, NO}, | |
478 | {NO, NO, GF, NO, GD, NO}, | |
479 | {NO, FG, NO, NO, NO, NO}, | |
480 | {NO, NO, NO, NO, NO, NO}, | |
481 | {NO, DG, NO, NO, NO, NO}, | |
482 | {NO, DG, NO, NO, NO, NO}, | |
483 | }; | |
484 | ||
485 | /* Likewise, but reversed for the return value. */ | |
486 | static CONST arg_reloc_type ret_mismatches[6][6] = | |
487 | { | |
488 | {NO, NO, NO, NO, NO, NO}, | |
489 | {NO, NO, FG, NO, DG, NO}, | |
490 | {NO, GF, NO, NO, NO, NO}, | |
491 | {NO, NO, NO, NO, NO, NO}, | |
492 | {NO, GD, NO, NO, NO, NO}, | |
493 | {NO, GD, NO, NO, NO, NO}, | |
494 | }; | |
495 | ||
496 | /* Misc static crud for symbol extension records. */ | |
d9ad93bc KR |
497 | static symext_chainS *symext_rootP; |
498 | static symext_chainS *symext_lastP; | |
b68a74d1 | 499 | static bfd_size_type symext_chain_size; |
24f13b03 ILT |
500 | |
501 | /* FIXME: We should be able to try this static variable! */ | |
b68a74d1 | 502 | static bfd_byte *symextn_contents; |
e08b9ad7 | 503 | |
24f13b03 ILT |
504 | |
505 | /* For linker stub hash tables. */ | |
506 | #define elf32_hppa_stub_hash_lookup(table, string, create, copy) \ | |
507 | ((struct elf32_hppa_stub_hash_entry *) \ | |
508 | bfd_hash_lookup (&(table)->root, (string), (create), (copy))) | |
509 | ||
510 | #define elf32_hppa_stub_hash_traverse(table, func, info) \ | |
511 | (bfd_hash_traverse \ | |
512 | (&(table)->root, \ | |
513 | (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \ | |
514 | (info))) | |
515 | ||
516 | /* For linker args hash tables. */ | |
517 | #define elf32_hppa_args_hash_lookup(table, string, create, copy) \ | |
518 | ((struct elf32_hppa_args_hash_entry *) \ | |
519 | bfd_hash_lookup (&(table)->root, (string), (create), (copy))) | |
520 | ||
521 | #define elf32_hppa_args_hash_traverse(table, func, info) \ | |
522 | (bfd_hash_traverse \ | |
523 | (&(table)->root, \ | |
524 | (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \ | |
525 | (info))) | |
526 | ||
527 | #define elf32_hppa_args_hash_table_init(table, newfunc) \ | |
528 | (bfd_hash_table_init \ | |
529 | (&(table)->root, \ | |
530 | (struct bfd_hash_entry *(*) PARAMS ((struct bfd_hash_entry *, \ | |
531 | struct bfd_hash_table *, \ | |
532 | const char *))) (newfunc))) | |
533 | ||
534 | /* For HPPA linker hash table. */ | |
535 | ||
536 | #define elf32_hppa_link_hash_lookup(table, string, create, copy, follow)\ | |
537 | ((struct elf32_hppa_link_hash_entry *) \ | |
538 | elf_link_hash_lookup (&(table)->root, (string), (create), \ | |
539 | (copy), (follow))) | |
540 | ||
541 | #define elf32_hppa_link_hash_traverse(table, func, info) \ | |
542 | (elf_link_hash_traverse \ | |
543 | (&(table)->root, \ | |
544 | (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \ | |
545 | (info))) | |
546 | ||
547 | /* Get the PA ELF linker hash table from a link_info structure. */ | |
548 | ||
549 | #define elf32_hppa_hash_table(p) \ | |
550 | ((struct elf32_hppa_link_hash_table *) ((p)->hash)) | |
551 | ||
552 | ||
553 | /* Extract specific argument location bits for WHICH from | |
554 | the full argument location in AR. */ | |
555 | #define EXTRACT_ARBITS(ar, which) ((ar) >> (8 - ((which) * 2))) & 3 | |
556 | ||
557 | /* Assorted hash table functions. */ | |
558 | ||
559 | /* Initialize an entry in the stub hash table. */ | |
560 | ||
561 | static struct bfd_hash_entry * | |
562 | elf32_hppa_stub_hash_newfunc (entry, table, string) | |
563 | struct bfd_hash_entry *entry; | |
564 | struct bfd_hash_table *table; | |
565 | const char *string; | |
566 | { | |
567 | struct elf32_hppa_stub_hash_entry *ret; | |
568 | ||
569 | ret = (struct elf32_hppa_stub_hash_entry *) entry; | |
570 | ||
571 | /* Allocate the structure if it has not already been allocated by a | |
572 | subclass. */ | |
573 | if (ret == NULL) | |
574 | ret = ((struct elf32_hppa_stub_hash_entry *) | |
575 | bfd_hash_allocate (table, | |
576 | sizeof (struct elf32_hppa_stub_hash_entry))); | |
577 | if (ret == NULL) | |
a9713b91 | 578 | return NULL; |
24f13b03 ILT |
579 | |
580 | /* Call the allocation method of the superclass. */ | |
581 | ret = ((struct elf32_hppa_stub_hash_entry *) | |
582 | bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); | |
583 | ||
584 | if (ret) | |
585 | { | |
586 | /* Initialize the local fields. */ | |
587 | ret->offset = 0; | |
588 | ret->target_value = 0; | |
589 | ret->target_section = NULL; | |
590 | } | |
591 | ||
592 | return (struct bfd_hash_entry *) ret; | |
593 | } | |
594 | ||
595 | /* Initialize a stub hash table. */ | |
596 | ||
597 | static boolean | |
598 | elf32_hppa_stub_hash_table_init (table, stub_bfd, newfunc) | |
599 | struct elf32_hppa_stub_hash_table *table; | |
600 | bfd *stub_bfd; | |
601 | struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *, | |
602 | struct bfd_hash_table *, | |
603 | const char *)); | |
604 | { | |
605 | table->offset = 0; | |
606 | table->location = 0; | |
607 | table->stub_bfd = stub_bfd; | |
608 | return (bfd_hash_table_init (&table->root, newfunc)); | |
609 | } | |
610 | ||
611 | /* Initialize an entry in the argument location hash table. */ | |
612 | ||
613 | static struct bfd_hash_entry * | |
614 | elf32_hppa_args_hash_newfunc (entry, table, string) | |
615 | struct bfd_hash_entry *entry; | |
616 | struct bfd_hash_table *table; | |
617 | const char *string; | |
618 | { | |
619 | struct elf32_hppa_args_hash_entry *ret; | |
620 | ||
621 | ret = (struct elf32_hppa_args_hash_entry *) entry; | |
622 | ||
623 | /* Allocate the structure if it has not already been allocated by a | |
624 | subclass. */ | |
625 | if (ret == NULL) | |
626 | ret = ((struct elf32_hppa_args_hash_entry *) | |
627 | bfd_hash_allocate (table, | |
628 | sizeof (struct elf32_hppa_args_hash_entry))); | |
629 | if (ret == NULL) | |
a9713b91 | 630 | return NULL; |
24f13b03 ILT |
631 | |
632 | /* Call the allocation method of the superclass. */ | |
633 | ret = ((struct elf32_hppa_args_hash_entry *) | |
634 | bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); | |
635 | ||
636 | /* Initialize the local fields. */ | |
637 | if (ret) | |
638 | ret->arg_bits = 0; | |
639 | ||
640 | return (struct bfd_hash_entry *) ret; | |
641 | } | |
642 | ||
643 | /* Create the derived linker hash table. The PA ELF port uses the derived | |
644 | hash table to keep information specific to the PA ELF linker (without | |
645 | using static variables). */ | |
646 | ||
647 | static struct bfd_link_hash_table * | |
648 | elf32_hppa_link_hash_table_create (abfd) | |
649 | bfd *abfd; | |
650 | { | |
651 | struct elf32_hppa_link_hash_table *ret; | |
652 | ||
653 | ret = ((struct elf32_hppa_link_hash_table *) | |
654 | bfd_alloc (abfd, sizeof (struct elf32_hppa_link_hash_table))); | |
655 | if (ret == NULL) | |
a9713b91 | 656 | return NULL; |
24f13b03 ILT |
657 | if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, |
658 | _bfd_elf_link_hash_newfunc)) | |
659 | { | |
660 | bfd_release (abfd, ret); | |
661 | return NULL; | |
662 | } | |
663 | ret->stub_hash_table = NULL; | |
664 | ret->args_hash_table = NULL; | |
665 | ret->output_symbol_count = 0; | |
666 | ret->global_value = 0; | |
667 | ret->global_sym_defined = 0; | |
668 | ||
669 | return &ret->root.root; | |
670 | } | |
e8f2240a | 671 | |
f5bfdacd | 672 | /* Relocate the given INSN given the various input parameters. |
e8f2240a | 673 | |
f5bfdacd | 674 | FIXME: endianness and sizeof (long) issues abound here. */ |
4c85cbfa KR |
675 | |
676 | static unsigned long | |
f5bfdacd JL |
677 | hppa_elf_relocate_insn (abfd, input_sect, insn, address, sym_value, |
678 | r_addend, r_format, r_field, pcrel) | |
f4bd7a8f DM |
679 | bfd *abfd; |
680 | asection *input_sect; | |
681 | unsigned long insn; | |
682 | unsigned long address; | |
f4bd7a8f DM |
683 | long sym_value; |
684 | long r_addend; | |
f5bfdacd JL |
685 | unsigned long r_format; |
686 | unsigned long r_field; | |
687 | unsigned long pcrel; | |
4c85cbfa | 688 | { |
e8f2240a KR |
689 | unsigned char opcode = get_opcode (insn); |
690 | long constant_value; | |
e8f2240a KR |
691 | |
692 | switch (opcode) | |
693 | { | |
694 | case LDO: | |
695 | case LDB: | |
696 | case LDH: | |
697 | case LDW: | |
698 | case LDWM: | |
699 | case STB: | |
700 | case STH: | |
701 | case STW: | |
702 | case STWM: | |
f5bfdacd JL |
703 | case COMICLR: |
704 | case SUBI: | |
705 | case ADDIT: | |
706 | case ADDI: | |
707 | case LDIL: | |
708 | case ADDIL: | |
7218bb04 | 709 | constant_value = HPPA_R_CONSTANT (r_addend); |
e8f2240a KR |
710 | |
711 | if (pcrel) | |
712 | sym_value -= address; | |
e8f2240a | 713 | |
e8f2240a | 714 | sym_value = hppa_field_adjust (sym_value, constant_value, r_field); |
f5bfdacd | 715 | return hppa_rebuild_insn (abfd, insn, sym_value, r_format); |
e8f2240a KR |
716 | |
717 | case BL: | |
718 | case BE: | |
719 | case BLE: | |
e8f2240a KR |
720 | /* XXX computing constant_value is not needed??? */ |
721 | constant_value = assemble_17 ((insn & 0x001f0000) >> 16, | |
722 | (insn & 0x00001ffc) >> 2, | |
723 | insn & 1); | |
f5bfdacd | 724 | |
e8f2240a KR |
725 | constant_value = (constant_value << 15) >> 15; |
726 | if (pcrel) | |
727 | { | |
728 | sym_value -= | |
729 | address + input_sect->output_offset | |
730 | + input_sect->output_section->vma; | |
731 | sym_value = hppa_field_adjust (sym_value, -8, r_field); | |
732 | } | |
733 | else | |
734 | sym_value = hppa_field_adjust (sym_value, constant_value, r_field); | |
4c85cbfa | 735 | |
f5bfdacd | 736 | return hppa_rebuild_insn (abfd, insn, sym_value >> 2, r_format); |
4c85cbfa | 737 | |
e8f2240a KR |
738 | default: |
739 | if (opcode == 0) | |
740 | { | |
7218bb04 | 741 | constant_value = HPPA_R_CONSTANT (r_addend); |
e8f2240a | 742 | |
f5bfdacd JL |
743 | if (pcrel) |
744 | sym_value -= address; | |
745 | ||
e8f2240a KR |
746 | return hppa_field_adjust (sym_value, constant_value, r_field); |
747 | } | |
748 | else | |
f5bfdacd | 749 | abort (); |
e8f2240a | 750 | } |
4c85cbfa KR |
751 | } |
752 | ||
24f13b03 | 753 | /* Relocate an HPPA ELF section. */ |
f5bfdacd | 754 | |
24f13b03 ILT |
755 | static boolean |
756 | elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, | |
eb4267a3 | 757 | contents, relocs, local_syms, local_sections) |
24f13b03 ILT |
758 | bfd *output_bfd; |
759 | struct bfd_link_info *info; | |
760 | bfd *input_bfd; | |
761 | asection *input_section; | |
762 | bfd_byte *contents; | |
763 | Elf_Internal_Rela *relocs; | |
764 | Elf_Internal_Sym *local_syms; | |
765 | asection **local_sections; | |
e8f2240a | 766 | { |
24f13b03 ILT |
767 | Elf_Internal_Shdr *symtab_hdr; |
768 | Elf_Internal_Rela *rel; | |
769 | Elf_Internal_Rela *relend; | |
770 | ||
771 | symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; | |
772 | ||
773 | rel = relocs; | |
774 | relend = relocs + input_section->reloc_count; | |
775 | for (; rel < relend; rel++) | |
776 | { | |
777 | int r_type; | |
31dabb6c | 778 | reloc_howto_type *howto; |
a9713b91 | 779 | unsigned long r_symndx; |
24f13b03 ILT |
780 | struct elf_link_hash_entry *h; |
781 | Elf_Internal_Sym *sym; | |
782 | asection *sym_sec; | |
783 | bfd_vma relocation; | |
784 | bfd_reloc_status_type r; | |
785 | const char *sym_name; | |
786 | ||
787 | r_type = ELF32_R_TYPE (rel->r_info); | |
788 | if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED) | |
789 | { | |
790 | bfd_set_error (bfd_error_bad_value); | |
791 | return false; | |
792 | } | |
793 | howto = elf_hppa_howto_table + r_type; | |
794 | ||
795 | r_symndx = ELF32_R_SYM (rel->r_info); | |
796 | ||
797 | if (info->relocateable) | |
798 | { | |
799 | /* This is a relocateable link. We don't have to change | |
800 | anything, unless the reloc is against a section symbol, | |
801 | in which case we have to adjust according to where the | |
802 | section symbol winds up in the output section. */ | |
803 | if (r_symndx < symtab_hdr->sh_info) | |
804 | { | |
805 | sym = local_syms + r_symndx; | |
806 | if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) | |
807 | { | |
808 | sym_sec = local_sections[r_symndx]; | |
809 | rel->r_addend += sym_sec->output_offset; | |
810 | } | |
811 | } | |
812 | ||
813 | continue; | |
814 | } | |
815 | ||
816 | /* This is a final link. */ | |
817 | h = NULL; | |
818 | sym = NULL; | |
819 | sym_sec = NULL; | |
820 | if (r_symndx < symtab_hdr->sh_info) | |
821 | { | |
822 | sym = local_syms + r_symndx; | |
823 | sym_sec = local_sections[r_symndx]; | |
824 | relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION | |
825 | ? 0 : sym->st_value) | |
826 | + sym_sec->output_offset | |
827 | + sym_sec->output_section->vma); | |
828 | } | |
829 | else | |
830 | { | |
831 | long indx; | |
832 | ||
833 | indx = r_symndx - symtab_hdr->sh_info; | |
834 | h = elf_sym_hashes (input_bfd)[indx]; | |
31dabb6c JL |
835 | if (h->root.type == bfd_link_hash_defined |
836 | || h->root.type == bfd_link_hash_defweak) | |
24f13b03 ILT |
837 | { |
838 | sym_sec = h->root.u.def.section; | |
839 | relocation = (h->root.u.def.value | |
840 | + sym_sec->output_offset | |
841 | + sym_sec->output_section->vma); | |
842 | } | |
31dabb6c | 843 | else if (h->root.type == bfd_link_hash_undefweak) |
24f13b03 ILT |
844 | relocation = 0; |
845 | else | |
846 | { | |
847 | if (!((*info->callbacks->undefined_symbol) | |
848 | (info, h->root.root.string, input_bfd, | |
849 | input_section, rel->r_offset))) | |
850 | return false; | |
6cb964d4 | 851 | break; |
24f13b03 ILT |
852 | } |
853 | } | |
854 | ||
855 | if (h != NULL) | |
856 | sym_name = h->root.root.string; | |
857 | else | |
858 | { | |
ede4eed4 KR |
859 | sym_name = bfd_elf_string_from_elf_section (input_bfd, |
860 | symtab_hdr->sh_link, | |
861 | sym->st_name); | |
24f13b03 ILT |
862 | if (sym_name == NULL) |
863 | return false; | |
864 | if (*sym_name == '\0') | |
865 | sym_name = bfd_section_name (input_bfd, sym_sec); | |
866 | } | |
867 | ||
868 | /* If args_hash_table is NULL, then we have encountered some | |
869 | kind of link error (ex. undefined symbols). Do not try to | |
870 | apply any relocations, continue the loop so we can notify | |
871 | the user of several errors in a single attempted link. */ | |
872 | if (elf32_hppa_hash_table (info)->args_hash_table == NULL) | |
873 | continue; | |
874 | ||
875 | r = elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, | |
876 | input_section, contents, | |
877 | rel->r_offset, relocation, | |
878 | rel->r_addend, info, sym_sec, | |
879 | sym_name, h == NULL); | |
880 | ||
881 | if (r != bfd_reloc_ok) | |
882 | { | |
883 | switch (r) | |
884 | { | |
31dabb6c JL |
885 | /* This can happen for DP relative relocs if $global$ is |
886 | undefined. This is a panic situation so we don't try | |
887 | to continue. */ | |
888 | case bfd_reloc_undefined: | |
889 | case bfd_reloc_notsupported: | |
890 | if (!((*info->callbacks->undefined_symbol) | |
891 | (info, "$global$", input_bfd, | |
892 | input_section, rel->r_offset))) | |
893 | return false; | |
894 | return false; | |
24f13b03 ILT |
895 | case bfd_reloc_dangerous: |
896 | { | |
897 | /* We use this return value to indicate that we performed | |
898 | a "dangerous" relocation. This doesn't mean we did | |
899 | the wrong thing, it just means there may be some cleanup | |
900 | that needs to be done here. | |
901 | ||
902 | In particular we had to swap the last call insn and its | |
903 | delay slot. If the delay slot insn needed a relocation, | |
904 | then we'll need to adjust the next relocation entry's | |
905 | offset to account for the fact that the insn moved. | |
906 | ||
907 | This hair wouldn't be necessary if we inserted stubs | |
908 | between procedures and used a "bl" to get to the stub. */ | |
909 | if (rel != relend) | |
910 | { | |
911 | Elf_Internal_Rela *next_rel = rel + 1; | |
912 | ||
913 | if (rel->r_offset + 4 == next_rel->r_offset) | |
914 | next_rel->r_offset -= 4; | |
915 | } | |
916 | break; | |
917 | } | |
918 | default: | |
919 | case bfd_reloc_outofrange: | |
920 | case bfd_reloc_overflow: | |
921 | { | |
922 | if (!((*info->callbacks->reloc_overflow) | |
923 | (info, sym_name, howto->name, (bfd_vma) 0, | |
924 | input_bfd, input_section, rel->r_offset))) | |
925 | return false; | |
926 | } | |
927 | break; | |
928 | } | |
929 | } | |
930 | } | |
931 | ||
932 | return true; | |
4c85cbfa KR |
933 | } |
934 | ||
f5bfdacd | 935 | /* Return one (or more) BFD relocations which implement the base |
e08b9ad7 | 936 | relocation with modifications based on format and field. */ |
4c85cbfa | 937 | |
e8f2240a | 938 | elf32_hppa_reloc_type ** |
a9713b91 | 939 | hppa_elf_gen_reloc_type (abfd, base_type, format, field, ignore) |
e8f2240a KR |
940 | bfd *abfd; |
941 | elf32_hppa_reloc_type base_type; | |
942 | int format; | |
943 | int field; | |
a9713b91 | 944 | int ignore; |
4c85cbfa | 945 | { |
e8f2240a KR |
946 | elf32_hppa_reloc_type *finaltype; |
947 | elf32_hppa_reloc_type **final_types; | |
e8f2240a | 948 | |
f5bfdacd JL |
949 | /* Allocate slots for the BFD relocation. */ |
950 | final_types = (elf32_hppa_reloc_type **) | |
951 | bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type *) * 2); | |
24f13b03 ILT |
952 | if (final_types == NULL) |
953 | return NULL; | |
e8f2240a | 954 | |
f5bfdacd JL |
955 | /* Allocate space for the relocation itself. */ |
956 | finaltype = (elf32_hppa_reloc_type *) | |
957 | bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type)); | |
24f13b03 ILT |
958 | if (finaltype == NULL) |
959 | return NULL; | |
e8f2240a | 960 | |
f5bfdacd | 961 | /* Some reasonable defaults. */ |
e8f2240a KR |
962 | final_types[0] = finaltype; |
963 | final_types[1] = NULL; | |
964 | ||
965 | #define final_type finaltype[0] | |
966 | ||
967 | final_type = base_type; | |
968 | ||
f5bfdacd JL |
969 | /* Just a tangle of nested switch statements to deal with the braindamage |
970 | that a different field selector means a completely different relocation | |
971 | for PA ELF. */ | |
e8f2240a KR |
972 | switch (base_type) |
973 | { | |
974 | case R_HPPA: | |
24f13b03 | 975 | case R_HPPA_ABS_CALL: |
e8f2240a KR |
976 | switch (format) |
977 | { | |
e8f2240a KR |
978 | case 14: |
979 | switch (field) | |
980 | { | |
981 | case e_rsel: | |
e8f2240a | 982 | case e_rrsel: |
459ae909 | 983 | final_type = R_PARISC_DIR14R; |
e8f2240a | 984 | break; |
459ae909 JL |
985 | case e_rtsel: |
986 | final_type = R_PARISC_DLTREL14R; | |
e8f2240a | 987 | break; |
e8f2240a | 988 | case e_tsel: |
459ae909 | 989 | final_type = R_PARISC_DLTREL14F; |
a36b6f1d | 990 | break; |
459ae909 JL |
991 | case e_rpsel: |
992 | final_type = R_PARISC_PLABEL14R; | |
a36b6f1d | 993 | break; |
e8f2240a | 994 | default: |
24f13b03 | 995 | return NULL; |
e8f2240a KR |
996 | } |
997 | break; | |
f5bfdacd | 998 | |
e8f2240a KR |
999 | case 17: |
1000 | switch (field) | |
1001 | { | |
1002 | case e_fsel: | |
459ae909 | 1003 | final_type = R_PARISC_DIR17F; |
e8f2240a KR |
1004 | break; |
1005 | case e_rsel: | |
e8f2240a | 1006 | case e_rrsel: |
459ae909 | 1007 | final_type = R_PARISC_DIR17R; |
e8f2240a | 1008 | break; |
e8f2240a | 1009 | default: |
24f13b03 | 1010 | return NULL; |
e8f2240a KR |
1011 | } |
1012 | break; | |
f5bfdacd | 1013 | |
e8f2240a KR |
1014 | case 21: |
1015 | switch (field) | |
1016 | { | |
1017 | case e_lsel: | |
e8f2240a | 1018 | case e_lrsel: |
459ae909 | 1019 | final_type = R_PARISC_DIR21L; |
e8f2240a | 1020 | break; |
a36b6f1d | 1021 | case e_ltsel: |
459ae909 JL |
1022 | final_type = R_PARISC_DLTREL21L; |
1023 | break; | |
1024 | case e_lpsel: | |
1025 | final_type = R_PARISC_PLABEL21L; | |
a36b6f1d | 1026 | break; |
e8f2240a | 1027 | default: |
24f13b03 | 1028 | return NULL; |
e8f2240a KR |
1029 | } |
1030 | break; | |
f5bfdacd | 1031 | |
e8f2240a KR |
1032 | case 32: |
1033 | switch (field) | |
1034 | { | |
1035 | case e_fsel: | |
459ae909 | 1036 | final_type = R_PARISC_DIR32; |
e8f2240a KR |
1037 | break; |
1038 | case e_psel: | |
459ae909 | 1039 | final_type = R_PARISC_PLABEL32; |
a36b6f1d | 1040 | break; |
e8f2240a | 1041 | default: |
24f13b03 | 1042 | return NULL; |
e8f2240a KR |
1043 | } |
1044 | break; | |
f5bfdacd | 1045 | |
e8f2240a | 1046 | default: |
24f13b03 | 1047 | return NULL; |
e8f2240a KR |
1048 | } |
1049 | break; | |
f5bfdacd JL |
1050 | |
1051 | ||
e8f2240a KR |
1052 | case R_HPPA_GOTOFF: |
1053 | switch (format) | |
1054 | { | |
e8f2240a KR |
1055 | case 14: |
1056 | switch (field) | |
1057 | { | |
1058 | case e_rsel: | |
e8f2240a | 1059 | case e_rrsel: |
459ae909 | 1060 | final_type = R_PARISC_DPREL14R; |
e8f2240a KR |
1061 | break; |
1062 | case e_fsel: | |
459ae909 | 1063 | final_type = R_PARISC_DPREL14F; |
e8f2240a | 1064 | break; |
e8f2240a | 1065 | default: |
24f13b03 | 1066 | return NULL; |
e8f2240a KR |
1067 | } |
1068 | break; | |
f5bfdacd | 1069 | |
e8f2240a KR |
1070 | case 21: |
1071 | switch (field) | |
1072 | { | |
e8f2240a | 1073 | case e_lrsel: |
e8f2240a | 1074 | case e_lsel: |
459ae909 | 1075 | final_type = R_PARISC_DPREL21L; |
e8f2240a | 1076 | break; |
e8f2240a | 1077 | default: |
24f13b03 | 1078 | return NULL; |
e8f2240a KR |
1079 | } |
1080 | break; | |
f5bfdacd | 1081 | |
e8f2240a | 1082 | default: |
24f13b03 | 1083 | return NULL; |
e8f2240a KR |
1084 | } |
1085 | break; | |
f5bfdacd JL |
1086 | |
1087 | ||
459ae909 | 1088 | case R_HPPA_PCREL_CALL: |
e8f2240a KR |
1089 | switch (format) |
1090 | { | |
e8f2240a KR |
1091 | case 14: |
1092 | switch (field) | |
1093 | { | |
1094 | case e_rsel: | |
e8f2240a | 1095 | case e_rrsel: |
459ae909 | 1096 | final_type = R_PARISC_PCREL14R; |
e8f2240a KR |
1097 | break; |
1098 | case e_fsel: | |
459ae909 | 1099 | final_type = R_PARISC_PCREL14F; |
e8f2240a | 1100 | break; |
e8f2240a | 1101 | default: |
24f13b03 | 1102 | return NULL; |
e8f2240a KR |
1103 | } |
1104 | break; | |
f5bfdacd | 1105 | |
e8f2240a KR |
1106 | case 17: |
1107 | switch (field) | |
1108 | { | |
1109 | case e_rsel: | |
e8f2240a | 1110 | case e_rrsel: |
459ae909 | 1111 | final_type = R_PARISC_PCREL17R; |
e8f2240a KR |
1112 | break; |
1113 | case e_fsel: | |
459ae909 | 1114 | final_type = R_PARISC_PCREL17F; |
e8f2240a | 1115 | break; |
e8f2240a | 1116 | default: |
24f13b03 | 1117 | return NULL; |
e8f2240a KR |
1118 | } |
1119 | break; | |
f5bfdacd | 1120 | |
e8f2240a KR |
1121 | case 21: |
1122 | switch (field) | |
1123 | { | |
1124 | case e_lsel: | |
e8f2240a | 1125 | case e_lrsel: |
459ae909 | 1126 | final_type = R_PARISC_PCREL21L; |
e8f2240a | 1127 | break; |
e8f2240a | 1128 | default: |
24f13b03 | 1129 | return NULL; |
e8f2240a KR |
1130 | } |
1131 | break; | |
f5bfdacd | 1132 | |
e8f2240a | 1133 | default: |
24f13b03 | 1134 | return NULL; |
e8f2240a KR |
1135 | } |
1136 | break; | |
f5bfdacd | 1137 | |
e8f2240a | 1138 | default: |
24f13b03 | 1139 | return NULL; |
e8f2240a KR |
1140 | } |
1141 | ||
1142 | return final_types; | |
4c85cbfa KR |
1143 | } |
1144 | ||
e8f2240a KR |
1145 | #undef final_type |
1146 | ||
24f13b03 | 1147 | /* Set the contents of a particular section at a particular location. */ |
4c85cbfa | 1148 | |
24f13b03 ILT |
1149 | static boolean |
1150 | elf32_hppa_set_section_contents (abfd, section, location, offset, count) | |
4861ac76 | 1151 | bfd *abfd; |
24f13b03 ILT |
1152 | sec_ptr section; |
1153 | PTR location; | |
1154 | file_ptr offset; | |
1155 | bfd_size_type count; | |
e8f2240a | 1156 | { |
24f13b03 ILT |
1157 | /* Ignore write requests for the symbol extension section until we've |
1158 | had the chance to rebuild it ourselves. */ | |
1159 | if (!strcmp (section->name, ".PARISC.symextn") && !symext_chain_size) | |
1160 | return true; | |
1161 | else | |
ede4eed4 KR |
1162 | return _bfd_elf_set_section_contents (abfd, section, location, |
1163 | offset, count); | |
24f13b03 ILT |
1164 | } |
1165 | ||
1166 | /* Translate from an elf into field into a howto relocation pointer. */ | |
1167 | ||
1168 | static void | |
1169 | elf_info_to_howto (abfd, cache_ptr, dst) | |
1170 | bfd *abfd; | |
1171 | arelent *cache_ptr; | |
1172 | Elf32_Internal_Rela *dst; | |
1173 | { | |
1174 | BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_PARISC_UNIMPLEMENTED); | |
1175 | cache_ptr->howto = &elf_hppa_howto_table[ELF32_R_TYPE (dst->r_info)]; | |
1176 | } | |
1177 | ||
1178 | ||
1179 | /* Actually perform a relocation. NOTE this is (mostly) superceeded | |
1180 | by elf32_hppa_bfd_final_link_relocate which is called by the new | |
1181 | fast linker. */ | |
1182 | ||
1183 | static bfd_reloc_status_type | |
1184 | hppa_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, | |
1185 | error_message) | |
1186 | bfd *abfd; | |
1187 | arelent *reloc_entry; | |
1188 | asymbol *symbol_in; | |
1189 | PTR data; | |
1190 | asection *input_section; | |
1191 | bfd *output_bfd; | |
1192 | char **error_message; | |
1193 | { | |
1194 | /* It is no longer valid to call hppa_elf_reloc when creating | |
1195 | a final executable. */ | |
e8f2240a KR |
1196 | if (output_bfd) |
1197 | { | |
e8f2240a | 1198 | reloc_entry->address += input_section->output_offset; |
459ae909 JL |
1199 | |
1200 | /* Work around lossage in generic elf code to write relocations. | |
1201 | (maps different section symbols into the same symbol index). */ | |
1202 | if ((symbol_in->flags & BSF_SECTION_SYM) | |
1203 | && symbol_in->section) | |
1204 | reloc_entry->addend += symbol_in->section->output_offset; | |
e8f2240a KR |
1205 | return bfd_reloc_ok; |
1206 | } | |
24f13b03 ILT |
1207 | else |
1208 | { | |
1209 | *error_message = (char *) "Unsupported call to hppa_elf_reloc"; | |
1210 | return bfd_reloc_notsupported; | |
1211 | } | |
1212 | } | |
e8f2240a | 1213 | |
24f13b03 ILT |
1214 | /* Actually perform a relocation as part of a final link. This can get |
1215 | rather hairy when linker stubs are needed. */ | |
e8f2240a | 1216 | |
24f13b03 ILT |
1217 | static bfd_reloc_status_type |
1218 | elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd, | |
1219 | input_section, contents, offset, value, | |
1220 | addend, info, sym_sec, sym_name, is_local) | |
31dabb6c | 1221 | reloc_howto_type *howto; |
24f13b03 ILT |
1222 | bfd *input_bfd; |
1223 | bfd *output_bfd; | |
1224 | asection *input_section; | |
1225 | bfd_byte *contents; | |
1226 | bfd_vma offset; | |
1227 | bfd_vma value; | |
1228 | bfd_vma addend; | |
1229 | struct bfd_link_info *info; | |
1230 | asection *sym_sec; | |
1231 | const char *sym_name; | |
1232 | int is_local; | |
1233 | { | |
1234 | unsigned long insn; | |
1235 | unsigned long r_type = howto->type; | |
1236 | unsigned long r_format = howto->bitsize; | |
1237 | unsigned long r_field = e_fsel; | |
5874427f | 1238 | bfd_byte *hit_data = contents + offset; |
24f13b03 | 1239 | boolean r_pcrel = howto->pc_relative; |
e8f2240a | 1240 | |
24f13b03 | 1241 | insn = bfd_get_32 (input_bfd, hit_data); |
f5bfdacd | 1242 | |
24f13b03 ILT |
1243 | /* Make sure we have a value for $global$. FIXME isn't this effectively |
1244 | just like the gp pointer on MIPS? Can we use those routines for this | |
1245 | purpose? */ | |
1246 | if (!elf32_hppa_hash_table (info)->global_sym_defined) | |
e8f2240a | 1247 | { |
24f13b03 ILT |
1248 | struct elf_link_hash_entry *h; |
1249 | asection *sec; | |
1250 | ||
1251 | h = elf_link_hash_lookup (elf_hash_table (info), "$global$", false, | |
1252 | false, false); | |
e8f2240a | 1253 | |
24f13b03 ILT |
1254 | /* If there isn't a $global$, then we're in deep trouble. */ |
1255 | if (h == NULL) | |
1256 | return bfd_reloc_notsupported; | |
1257 | ||
31dabb6c JL |
1258 | /* If $global$ isn't a defined symbol, then we're still in deep |
1259 | trouble. */ | |
1260 | if (h->root.type != bfd_link_hash_defined) | |
1261 | return bfd_reloc_undefined; | |
1262 | ||
24f13b03 ILT |
1263 | sec = h->root.u.def.section; |
1264 | elf32_hppa_hash_table (info)->global_value = (h->root.u.def.value | |
b68a74d1 | 1265 | + sec->output_section->vma |
24f13b03 ILT |
1266 | + sec->output_offset); |
1267 | elf32_hppa_hash_table (info)->global_sym_defined = 1; | |
1268 | } | |
e8f2240a | 1269 | |
e8f2240a KR |
1270 | switch (r_type) |
1271 | { | |
459ae909 | 1272 | case R_PARISC_NONE: |
e8f2240a | 1273 | break; |
4861ac76 | 1274 | |
459ae909 JL |
1275 | case R_PARISC_DIR32: |
1276 | case R_PARISC_DIR17F: | |
459ae909 | 1277 | case R_PARISC_PCREL17C: |
e8f2240a KR |
1278 | r_field = e_fsel; |
1279 | goto do_basic_type_1; | |
459ae909 JL |
1280 | case R_PARISC_DIR21L: |
1281 | case R_PARISC_PCREL21L: | |
e8f2240a KR |
1282 | r_field = e_lrsel; |
1283 | goto do_basic_type_1; | |
459ae909 JL |
1284 | case R_PARISC_DIR17R: |
1285 | case R_PARISC_PCREL17R: | |
1286 | case R_PARISC_DIR14R: | |
1287 | case R_PARISC_PCREL14R: | |
e8f2240a | 1288 | r_field = e_rrsel; |
459ae909 | 1289 | goto do_basic_type_1; |
e8f2240a | 1290 | |
24f13b03 ILT |
1291 | /* For all the DP relative relocations, we need to examine the symbol's |
1292 | section. If it's a code section, then "data pointer relative" makes | |
1293 | no sense. In that case we don't adjust the "value", and for 21 bit | |
1294 | addil instructions, we change the source addend register from %dp to | |
6cb964d4 | 1295 | %r0. */ |
459ae909 | 1296 | case R_PARISC_DPREL21L: |
e8f2240a | 1297 | r_field = e_lrsel; |
24f13b03 | 1298 | if (sym_sec->flags & SEC_CODE) |
9a688057 | 1299 | { |
c2730ba3 | 1300 | if ((insn & 0xfc000000) >> 26 == 0xa |
9a688057 JL |
1301 | && (insn & 0x03e00000) >> 21 == 0x1b) |
1302 | insn &= ~0x03e00000; | |
1303 | } | |
24f13b03 ILT |
1304 | else |
1305 | value -= elf32_hppa_hash_table (info)->global_value; | |
459ae909 JL |
1306 | goto do_basic_type_1; |
1307 | case R_PARISC_DPREL14R: | |
e8f2240a | 1308 | r_field = e_rrsel; |
24f13b03 ILT |
1309 | if ((sym_sec->flags & SEC_CODE) == 0) |
1310 | value -= elf32_hppa_hash_table (info)->global_value; | |
459ae909 JL |
1311 | goto do_basic_type_1; |
1312 | case R_PARISC_DPREL14F: | |
e8f2240a | 1313 | r_field = e_fsel; |
24f13b03 ILT |
1314 | if ((sym_sec->flags & SEC_CODE) == 0) |
1315 | value -= elf32_hppa_hash_table (info)->global_value; | |
459ae909 | 1316 | goto do_basic_type_1; |
4861ac76 | 1317 | |
24f13b03 ILT |
1318 | /* These cases are separate as they may involve a lot more work |
1319 | to deal with linker stubs. */ | |
1320 | case R_PARISC_PLABEL32: | |
1321 | case R_PARISC_PLABEL21L: | |
1322 | case R_PARISC_PLABEL14R: | |
1323 | case R_PARISC_PCREL17F: | |
1324 | { | |
1325 | bfd_vma location; | |
1326 | unsigned int len, caller_args, callee_args; | |
1327 | arg_reloc_type arg_reloc_types[5]; | |
1328 | struct elf32_hppa_args_hash_table *args_hash_table; | |
1329 | struct elf32_hppa_args_hash_entry *args_hash; | |
1330 | char *new_name, *stub_name; | |
1331 | ||
1332 | /* Get the field selector right. We'll need it in a minute. */ | |
1333 | if (r_type == R_PARISC_PCREL17F | |
1334 | || r_type == R_PARISC_PLABEL32) | |
1335 | r_field = e_fsel; | |
1336 | else if (r_type == R_PARISC_PLABEL21L) | |
1337 | r_field = e_lrsel; | |
1338 | else if (r_type == R_PARISC_PLABEL14R) | |
1339 | r_field = e_rrsel; | |
1340 | ||
1341 | /* Find out where we are and where we're going. */ | |
1342 | location = (offset + | |
1343 | input_section->output_offset + | |
1344 | input_section->output_section->vma); | |
1345 | ||
1346 | /* Now look for the argument relocation bits associated with the | |
1347 | target. */ | |
1348 | len = strlen (sym_name) + 1; | |
1349 | if (is_local) | |
1350 | len += 9; | |
1351 | new_name = malloc (len); | |
1352 | if (!new_name) | |
1353 | { | |
1354 | bfd_set_error (bfd_error_no_memory); | |
1355 | return bfd_reloc_notsupported; | |
1356 | } | |
1357 | strcpy (new_name, sym_name); | |
e8f2240a | 1358 | |
24f13b03 ILT |
1359 | /* Local symbols have unique IDs. */ |
1360 | if (is_local) | |
1361 | sprintf (new_name + len - 10, "_%08x", (int)sym_sec); | |
e8f2240a | 1362 | |
24f13b03 | 1363 | args_hash_table = elf32_hppa_hash_table (info)->args_hash_table; |
4861ac76 | 1364 | |
24f13b03 ILT |
1365 | args_hash = elf32_hppa_args_hash_lookup (args_hash_table, |
1366 | new_name, false, false); | |
1367 | if (args_hash == NULL) | |
1368 | callee_args = 0; | |
1369 | else | |
1370 | callee_args = args_hash->arg_bits; | |
7218bb04 | 1371 | |
24f13b03 ILT |
1372 | /* If this is a CALL relocation, then get the caller's bits |
1373 | from the addend. Else use the magic 0x155 value for PLABELS. | |
1374 | ||
1375 | Also we don't care about the destination (value) for PLABELS. */ | |
1376 | if (r_type == R_PARISC_PCREL17F) | |
1377 | caller_args = HPPA_R_ARG_RELOC (addend); | |
1378 | else | |
1379 | { | |
1380 | caller_args = 0x155; | |
1381 | location = value; | |
1382 | } | |
1383 | ||
1384 | /* Any kind of linker stub needed? */ | |
1385 | if (((int)(value - location) > 0x3ffff) | |
1386 | || ((int)(value - location) < (int)0xfffc0000) | |
1387 | || elf32_hppa_arg_reloc_needed (caller_args, callee_args, | |
1388 | arg_reloc_types)) | |
1389 | { | |
1390 | struct elf32_hppa_stub_hash_table *stub_hash_table; | |
1391 | struct elf32_hppa_stub_hash_entry *stub_hash; | |
1392 | asection *stub_section; | |
7218bb04 | 1393 | |
24f13b03 | 1394 | /* Build a name for the stub. */ |
f5bfdacd | 1395 | |
24f13b03 ILT |
1396 | len = strlen (new_name); |
1397 | len += 23; | |
1398 | stub_name = malloc (len); | |
1399 | if (!stub_name) | |
1400 | { | |
1401 | bfd_set_error (bfd_error_no_memory); | |
1402 | return bfd_reloc_notsupported; | |
1403 | } | |
1404 | elf32_hppa_name_of_stub (caller_args, callee_args, | |
1405 | location, value, stub_name); | |
1406 | strcat (stub_name, new_name); | |
1407 | free (new_name); | |
1408 | ||
1409 | stub_hash_table = elf32_hppa_hash_table (info)->stub_hash_table; | |
1410 | ||
1411 | stub_hash | |
1412 | = elf32_hppa_stub_hash_lookup (stub_hash_table, stub_name, | |
1413 | false, false); | |
1414 | ||
1415 | /* We're done with that name. */ | |
1416 | free (stub_name); | |
1417 | ||
1418 | /* The stub BFD only has one section. */ | |
1419 | stub_section = stub_hash_table->stub_bfd->sections; | |
1420 | ||
1421 | if (stub_hash != NULL) | |
1422 | { | |
1423 | ||
1424 | if (r_type == R_PARISC_PCREL17F) | |
1425 | { | |
1426 | unsigned long delay_insn; | |
1427 | unsigned int opcode, rtn_reg, ldo_target_reg, ldo_src_reg; | |
1428 | ||
1429 | /* We'll need to peek at the next insn. */ | |
1430 | delay_insn = bfd_get_32 (input_bfd, hit_data + 4); | |
1431 | opcode = get_opcode (delay_insn); | |
1432 | ||
1433 | /* We also need to know the return register for this | |
1434 | call. */ | |
1435 | rtn_reg = (insn & 0x03e00000) >> 21; | |
1436 | ||
1437 | ldo_src_reg = (delay_insn & 0x03e00000) >> 21; | |
1438 | ldo_target_reg = (delay_insn & 0x001f0000) >> 16; | |
1439 | ||
1440 | /* Munge up the value and other parameters for | |
1441 | hppa_elf_relocate_insn. */ | |
1442 | ||
1443 | value = (stub_hash->offset | |
1444 | + stub_section->output_offset | |
1445 | + stub_section->output_section->vma); | |
1446 | ||
1447 | r_format = 17; | |
1448 | r_field = e_fsel; | |
1449 | r_pcrel = 0; | |
1450 | addend = 0; | |
1451 | ||
1452 | /* We need to peek at the delay insn and determine if | |
1453 | we'll need to swap the branch and its delay insn. */ | |
1454 | if ((insn & 2) | |
1455 | || (opcode == LDO | |
1456 | && ldo_target_reg == rtn_reg) | |
1457 | || (delay_insn == 0x08000240)) | |
1458 | { | |
1459 | /* No need to swap the branch and its delay slot, but | |
1460 | we do need to make sure to jump past the return | |
1461 | pointer update in the stub. */ | |
1462 | value += 4; | |
1463 | ||
1464 | /* If the delay insn does a return pointer adjustment, | |
1465 | then we have to make sure it stays valid. */ | |
1466 | if (opcode == LDO | |
1467 | && ldo_target_reg == rtn_reg) | |
1468 | { | |
1469 | delay_insn &= 0xfc00ffff; | |
1470 | delay_insn |= ((31 << 21) | (31 << 16)); | |
1471 | bfd_put_32 (input_bfd, delay_insn, hit_data + 4); | |
1472 | } | |
1473 | /* Use a BLE to reach the stub. */ | |
1474 | insn = BLE_SR4_R0; | |
1475 | } | |
1476 | else | |
1477 | { | |
1478 | /* Wonderful, we have to swap the call insn and its | |
1479 | delay slot. */ | |
1480 | bfd_put_32 (input_bfd, delay_insn, hit_data); | |
1481 | /* Use a BLE,n to reach the stub. */ | |
1482 | insn = (BLE_SR4_R0 | 0x2); | |
1483 | bfd_put_32 (input_bfd, insn, hit_data + 4); | |
1484 | insn = hppa_elf_relocate_insn (input_bfd, | |
1485 | input_section, | |
1486 | insn, offset + 4, | |
1487 | value, addend, | |
1488 | r_format, r_field, | |
1489 | r_pcrel); | |
1490 | /* Update the instruction word. */ | |
1491 | bfd_put_32 (input_bfd, insn, hit_data + 4); | |
1492 | return bfd_reloc_dangerous; | |
1493 | } | |
1494 | } | |
1495 | else | |
1496 | { | |
1497 | /* PLABEL stuff is easy. */ | |
1498 | ||
1499 | value = (stub_hash->offset | |
1500 | + stub_section->output_offset | |
1501 | + stub_section->output_section->vma); | |
1502 | /* We don't need the RP adjustment for PLABELs. */ | |
1503 | value += 4; | |
1504 | if (r_type == R_PARISC_PLABEL32) | |
1505 | r_format = 32; | |
1506 | else if (r_type == R_PARISC_PLABEL21L) | |
1507 | r_format = 21; | |
1508 | else if (r_type == R_PARISC_PLABEL14R) | |
1509 | r_format = 14; | |
1510 | ||
1511 | r_pcrel = 0; | |
1512 | addend = 0; | |
1513 | } | |
7218bb04 | 1514 | } |
4861ac76 | 1515 | else |
24f13b03 ILT |
1516 | return bfd_reloc_notsupported; |
1517 | } | |
1518 | goto do_basic_type_1; | |
1519 | } | |
1520 | ||
1521 | do_basic_type_1: | |
1522 | insn = hppa_elf_relocate_insn (input_bfd, input_section, insn, | |
1523 | offset, value, addend, r_format, | |
1524 | r_field, r_pcrel); | |
d9ad93bc | 1525 | break; |
24f13b03 | 1526 | |
f5bfdacd | 1527 | /* Something we don't know how to handle. */ |
e8f2240a | 1528 | default: |
f5bfdacd | 1529 | return bfd_reloc_notsupported; |
e8f2240a KR |
1530 | } |
1531 | ||
4861ac76 | 1532 | /* Update the instruction word. */ |
24f13b03 | 1533 | bfd_put_32 (input_bfd, insn, hit_data); |
e8f2240a | 1534 | return (bfd_reloc_ok); |
e8f2240a KR |
1535 | } |
1536 | ||
f5bfdacd JL |
1537 | /* Return the address of the howto table entry to perform the CODE |
1538 | relocation for an ARCH machine. */ | |
1539 | ||
31dabb6c | 1540 | static reloc_howto_type * |
7ed5e970 ILT |
1541 | elf_hppa_reloc_type_lookup (abfd, code) |
1542 | bfd *abfd; | |
e8f2240a KR |
1543 | bfd_reloc_code_real_type code; |
1544 | { | |
459ae909 | 1545 | if ((int) code < (int) R_PARISC_UNIMPLEMENTED) |
e8f2240a KR |
1546 | { |
1547 | BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code); | |
1548 | return &elf_hppa_howto_table[(int) code]; | |
1549 | } | |
f5bfdacd | 1550 | return NULL; |
e8f2240a KR |
1551 | } |
1552 | ||
25057836 JL |
1553 | /* Return true if SYM represents a local label symbol. */ |
1554 | ||
1555 | static boolean | |
1556 | hppa_elf_is_local_label (abfd, sym) | |
1557 | bfd *abfd; | |
1558 | asymbol *sym; | |
1559 | { | |
1560 | return (sym->name[0] == 'L' && sym->name[1] == '$'); | |
1561 | } | |
e8f2240a | 1562 | |
459ae909 JL |
1563 | /* Do any backend specific processing when beginning to write an object |
1564 | file. For PA ELF we need to determine the size of the symbol extension | |
1565 | section *before* any other output processing happens. */ | |
1566 | ||
1567 | static void | |
24f13b03 | 1568 | elf32_hppa_backend_begin_write_processing (abfd, info) |
459ae909 | 1569 | bfd *abfd; |
24f13b03 | 1570 | struct bfd_link_info *info; |
459ae909 | 1571 | { |
24f13b03 | 1572 | unsigned int i; |
459ae909 JL |
1573 | asection *symextn_sec; |
1574 | ||
24f13b03 ILT |
1575 | /* Size up the symbol extension section. */ |
1576 | if ((abfd->outsymbols == NULL | |
1577 | && info == NULL) | |
1578 | || symext_chain_size != 0) | |
459ae909 JL |
1579 | return; |
1580 | ||
24f13b03 | 1581 | if (info == NULL) |
459ae909 | 1582 | { |
24f13b03 ILT |
1583 | /* We were not called from the BFD ELF linker code, so we need |
1584 | to examine the output BFD's outsymbols. | |
459ae909 | 1585 | |
24f13b03 ILT |
1586 | Note we can not build the symbol extensions now as the symbol |
1587 | map hasn't been set up. */ | |
1588 | for (i = 0; i < abfd->symcount; i++) | |
1589 | { | |
1590 | elf_symbol_type *symbol = (elf_symbol_type *)abfd->outsymbols[i]; | |
459ae909 | 1591 | |
24f13b03 ILT |
1592 | /* Only functions ever need an entry in the symbol extension |
1593 | section. */ | |
1594 | if (!(symbol->symbol.flags & BSF_FUNCTION)) | |
1595 | continue; | |
1596 | ||
1597 | /* And only if they specify the locations of their arguments. */ | |
1598 | if (symbol->tc_data.hppa_arg_reloc == 0) | |
1599 | continue; | |
1600 | ||
1601 | /* Yup. This function symbol needs an entry. */ | |
b68a74d1 | 1602 | symext_chain_size += 2 * ELF32_PARISC_SX_SIZE; |
24f13b03 ILT |
1603 | } |
1604 | } | |
1605 | else if (info->relocateable == true) | |
1606 | { | |
1607 | struct elf32_hppa_args_hash_table *table; | |
1608 | table = elf32_hppa_hash_table (info)->args_hash_table; | |
459ae909 | 1609 | |
24f13b03 ILT |
1610 | /* Determine the size of the symbol extension section. */ |
1611 | elf32_hppa_args_hash_traverse (table, | |
1612 | elf32_hppa_size_symext, | |
1613 | &symext_chain_size); | |
459ae909 JL |
1614 | } |
1615 | ||
1616 | /* Now create the section and set its size. We'll fill in the | |
1617 | contents later. */ | |
1618 | symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME); | |
1619 | if (symextn_sec == NULL) | |
24f13b03 ILT |
1620 | symextn_sec = bfd_make_section (abfd, SYMEXTN_SECTION_NAME); |
1621 | ||
1622 | bfd_set_section_flags (abfd, symextn_sec, | |
1623 | SEC_LOAD | SEC_HAS_CONTENTS | SEC_DATA); | |
1624 | symextn_sec->output_section = symextn_sec; | |
1625 | symextn_sec->output_offset = 0; | |
1626 | bfd_set_section_alignment (abfd, symextn_sec, 2); | |
1627 | bfd_set_section_size (abfd, symextn_sec, symext_chain_size); | |
1628 | } | |
1629 | ||
1630 | /* Called for each entry in the args location hash table. For each | |
1631 | entry we bump the size pointer by 2 records (16 bytes). */ | |
1632 | ||
1633 | static boolean | |
1634 | elf32_hppa_size_symext (gen_entry, in_args) | |
1635 | struct bfd_hash_entry *gen_entry; | |
1636 | PTR in_args; | |
1637 | { | |
b68a74d1 | 1638 | bfd_size_type *sizep = (bfd_size_type *)in_args; |
24f13b03 | 1639 | |
b68a74d1 | 1640 | *sizep += 2 * ELF32_PARISC_SX_SIZE; |
24f13b03 ILT |
1641 | return true; |
1642 | } | |
1643 | ||
1644 | /* Backend routine called by the linker for each output symbol. | |
1645 | ||
1646 | For PA ELF we use this opportunity to add an appropriate entry | |
1647 | to the symbol extension chain for function symbols. */ | |
1648 | ||
1649 | static boolean | |
1650 | elf32_hppa_link_output_symbol_hook (abfd, info, name, sym, section) | |
1651 | bfd *abfd; | |
1652 | struct bfd_link_info *info; | |
1653 | const char *name; | |
1654 | Elf_Internal_Sym *sym; | |
1655 | asection *section; | |
1656 | { | |
1657 | char *new_name; | |
1658 | unsigned int len, index; | |
1659 | struct elf32_hppa_args_hash_table *args_hash_table; | |
1660 | struct elf32_hppa_args_hash_entry *args_hash; | |
1661 | ||
1662 | /* If the args hash table is NULL, then we've encountered an error | |
1663 | of some sorts (for example, an undefined symbol). In that case | |
1664 | we've got nothing else to do. | |
1665 | ||
1666 | NOTE: elf_link_output_symbol will abort if we return false here! */ | |
1667 | if (elf32_hppa_hash_table (info)->args_hash_table == NULL) | |
1668 | return true; | |
1669 | ||
1670 | index = elf32_hppa_hash_table (info)->output_symbol_count++; | |
1671 | ||
1672 | /* We need to look up this symbol in the args hash table to see if | |
1673 | it has argument relocation bits. */ | |
1674 | if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) | |
1675 | return true; | |
1676 | ||
1677 | /* We know it's a function symbol of some kind. */ | |
1678 | len = strlen (name) + 1; | |
1679 | if (ELF_ST_BIND (sym->st_info) == STB_LOCAL) | |
1680 | len += 9; | |
1681 | ||
1682 | new_name = malloc (len); | |
1683 | if (new_name == NULL) | |
459ae909 | 1684 | { |
24f13b03 ILT |
1685 | bfd_set_error (bfd_error_no_memory); |
1686 | return false; | |
459ae909 JL |
1687 | } |
1688 | ||
24f13b03 ILT |
1689 | strcpy (new_name, name); |
1690 | if (ELF_ST_BIND (sym->st_info) == STB_LOCAL) | |
1691 | sprintf (new_name + len - 10, "_%08x", (int)section); | |
1692 | ||
1693 | /* Now that we have the unique name, we can look it up in the | |
1694 | args hash table. */ | |
1695 | args_hash_table = elf32_hppa_hash_table (info)->args_hash_table; | |
1696 | args_hash = elf32_hppa_args_hash_lookup (args_hash_table, new_name, | |
1697 | false, false); | |
1698 | free (new_name); | |
1699 | if (args_hash == NULL) | |
1700 | return true; | |
1701 | ||
1702 | /* We know this symbol has arg reloc bits. */ | |
1703 | add_entry_to_symext_chain (abfd, args_hash->arg_bits, | |
1704 | index, &symext_rootP, &symext_lastP); | |
1705 | return true; | |
459ae909 JL |
1706 | } |
1707 | ||
1708 | /* Perform any processing needed late in the object file writing process. | |
1709 | For PA ELF we build and set the contents of the symbol extension | |
1710 | section. */ | |
1711 | ||
1712 | static void | |
24f13b03 | 1713 | elf32_hppa_backend_final_write_processing (abfd, linker) |
459ae909 | 1714 | bfd *abfd; |
24f13b03 | 1715 | boolean linker; |
459ae909 JL |
1716 | { |
1717 | asection *symextn_sec; | |
b68a74d1 | 1718 | unsigned int i; |
459ae909 JL |
1719 | |
1720 | /* Now build the symbol extension section. */ | |
1721 | if (symext_chain_size == 0) | |
24f13b03 | 1722 | return; |
459ae909 | 1723 | |
24f13b03 | 1724 | if (! linker) |
459ae909 | 1725 | { |
24f13b03 ILT |
1726 | /* We were not called from the backend linker, so we still need |
1727 | to build the symbol extension chain. | |
459ae909 | 1728 | |
24f13b03 ILT |
1729 | Look at each symbol, adding the appropriate information to the |
1730 | symbol extension section list as necessary. */ | |
1731 | for (i = 0; i < abfd->symcount; i++) | |
1732 | { | |
1733 | elf_symbol_type *symbol = (elf_symbol_type *) abfd->outsymbols[i]; | |
459ae909 | 1734 | |
24f13b03 ILT |
1735 | /* Only functions ever need an entry in the symbol extension |
1736 | section. */ | |
1737 | if (!(symbol->symbol.flags & BSF_FUNCTION)) | |
1738 | continue; | |
1739 | ||
1740 | /* And only if they specify the locations of their arguments. */ | |
1741 | if (symbol->tc_data.hppa_arg_reloc == 0) | |
1742 | continue; | |
459ae909 | 1743 | |
24f13b03 ILT |
1744 | /* Add this symbol's information to the chain. */ |
1745 | add_entry_to_symext_chain (abfd, symbol->tc_data.hppa_arg_reloc, | |
b68a74d1 | 1746 | symbol->symbol.udata.i, &symext_rootP, |
24f13b03 ILT |
1747 | &symext_lastP); |
1748 | } | |
459ae909 JL |
1749 | } |
1750 | ||
24f13b03 | 1751 | /* Now fill in the contents of the symbol extension section. */ |
459ae909 JL |
1752 | elf_hppa_tc_make_sections (abfd, symext_rootP); |
1753 | ||
1754 | /* And attach that as the section's contents. */ | |
1755 | symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME); | |
1756 | if (symextn_sec == (asection *) 0) | |
1757 | abort(); | |
1758 | ||
1759 | symextn_sec->contents = (void *)symextn_contents; | |
24f13b03 ILT |
1760 | |
1761 | bfd_set_section_contents (abfd, symextn_sec, symextn_sec->contents, | |
459ae909 JL |
1762 | symextn_sec->output_offset, symextn_sec->_raw_size); |
1763 | } | |
1764 | ||
f5bfdacd JL |
1765 | /* Update the symbol extention chain to include the symbol pointed to |
1766 | by SYMBOLP if SYMBOLP is a function symbol. Used internally and by GAS. */ | |
e8f2240a | 1767 | |
459ae909 | 1768 | static void |
24f13b03 | 1769 | add_entry_to_symext_chain (abfd, arg_reloc, sym_idx, symext_root, symext_last) |
f4bd7a8f | 1770 | bfd *abfd; |
24f13b03 ILT |
1771 | unsigned int arg_reloc; |
1772 | unsigned int sym_idx; | |
f5bfdacd JL |
1773 | symext_chainS **symext_root; |
1774 | symext_chainS **symext_last; | |
e8f2240a KR |
1775 | { |
1776 | symext_chainS *symextP; | |
3a70b01d | 1777 | |
f5bfdacd | 1778 | /* Allocate memory and initialize this entry. */ |
e8f2240a | 1779 | symextP = (symext_chainS *) bfd_alloc (abfd, sizeof (symext_chainS) * 2); |
9783e04a | 1780 | if (!symextP) |
a9713b91 | 1781 | abort(); /* FIXME */ |
e8f2240a | 1782 | |
459ae909 | 1783 | symextP[0].entry = ELF32_PARISC_SX_WORD (PARISC_SXT_SYMNDX, sym_idx); |
e8f2240a KR |
1784 | symextP[0].next = &symextP[1]; |
1785 | ||
459ae909 | 1786 | symextP[1].entry = ELF32_PARISC_SX_WORD (PARISC_SXT_ARG_RELOC, arg_reloc); |
e8f2240a KR |
1787 | symextP[1].next = NULL; |
1788 | ||
f5bfdacd JL |
1789 | /* Now update the chain itself so it can be walked later to build |
1790 | the symbol extension section. */ | |
1791 | if (*symext_root == NULL) | |
e8f2240a | 1792 | { |
f5bfdacd JL |
1793 | *symext_root = &symextP[0]; |
1794 | *symext_last = &symextP[1]; | |
e8f2240a KR |
1795 | } |
1796 | else | |
1797 | { | |
f5bfdacd JL |
1798 | (*symext_last)->next = &symextP[0]; |
1799 | *symext_last = &symextP[1]; | |
e8f2240a KR |
1800 | } |
1801 | } | |
1802 | ||
24f13b03 | 1803 | /* Build the symbol extension section. */ |
e8f2240a | 1804 | |
459ae909 | 1805 | static void |
f5bfdacd | 1806 | elf_hppa_tc_make_sections (abfd, symext_root) |
f4bd7a8f | 1807 | bfd *abfd; |
f5bfdacd | 1808 | symext_chainS *symext_root; |
e8f2240a KR |
1809 | { |
1810 | symext_chainS *symextP; | |
24f13b03 | 1811 | unsigned int i; |
e8f2240a KR |
1812 | asection *symextn_sec; |
1813 | ||
e8f2240a | 1814 | symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME); |
f5bfdacd JL |
1815 | |
1816 | /* Grab some memory for the contents of the symbol extension section | |
1817 | itself. */ | |
b68a74d1 JL |
1818 | symextn_contents = (bfd_byte *) bfd_zalloc (abfd, |
1819 | symextn_sec->_raw_size); | |
9783e04a | 1820 | if (!symextn_contents) |
a9713b91 | 1821 | abort(); /* FIXME */ |
e8f2240a | 1822 | |
459ae909 | 1823 | /* Fill in the contents of the symbol extension chain. */ |
f5bfdacd | 1824 | for (i = 0, symextP = symext_root; symextP; symextP = symextP->next, ++i) |
b68a74d1 JL |
1825 | ELF32_PARISC_SX_PUT (abfd, (bfd_vma) symextP->entry, |
1826 | symextn_contents + i * ELF32_PARISC_SX_SIZE); | |
e8f2240a KR |
1827 | |
1828 | return; | |
1829 | } | |
1830 | ||
24f13b03 ILT |
1831 | /* Do some PA ELF specific work after reading in the symbol table. |
1832 | In particular attach the argument relocation from the | |
1833 | symbol extension section to the appropriate symbols. */ | |
e8f2240a | 1834 | |
24f13b03 ILT |
1835 | static boolean |
1836 | elf32_hppa_backend_symbol_table_processing (abfd, esyms,symcnt) | |
e8f2240a | 1837 | bfd *abfd; |
24f13b03 | 1838 | elf_symbol_type *esyms; |
a9713b91 | 1839 | unsigned int symcnt; |
e8f2240a | 1840 | { |
24f13b03 ILT |
1841 | Elf32_Internal_Shdr *symextn_hdr = |
1842 | bfd_elf_find_section (abfd, SYMEXTN_SECTION_NAME); | |
1843 | unsigned int i, current_sym_idx = 0; | |
1844 | ||
1845 | /* If no symbol extension existed, then all symbol extension information | |
1846 | is assumed to be zero. */ | |
1847 | if (symextn_hdr == NULL) | |
e8f2240a | 1848 | { |
24f13b03 ILT |
1849 | for (i = 0; i < symcnt; i++) |
1850 | esyms[i].tc_data.hppa_arg_reloc = 0; | |
1851 | return (true); | |
1852 | } | |
e8f2240a | 1853 | |
24f13b03 ILT |
1854 | /* FIXME: Why not use bfd_get_section_contents here? Also should give |
1855 | memory back when we're done. */ | |
1856 | /* Allocate a buffer of the appropriate size for the symextn section. */ | |
1857 | symextn_hdr->contents = bfd_zalloc(abfd,symextn_hdr->sh_size); | |
1858 | if (!symextn_hdr->contents) | |
a9713b91 | 1859 | return false; |
e8f2240a | 1860 | |
24f13b03 ILT |
1861 | /* Read in the symextn section. */ |
1862 | if (bfd_seek (abfd, symextn_hdr->sh_offset, SEEK_SET) == -1) | |
1863 | return false; | |
b68a74d1 JL |
1864 | if (bfd_read ((PTR) symextn_hdr->contents, 1, symextn_hdr->sh_size, abfd) |
1865 | != symextn_hdr->sh_size) | |
24f13b03 | 1866 | return false; |
e8f2240a | 1867 | |
24f13b03 ILT |
1868 | /* Parse entries in the symbol extension section, updating the symtab |
1869 | entries as we go */ | |
b68a74d1 | 1870 | for (i = 0; i < symextn_hdr->sh_size / ELF32_PARISC_SX_SIZE; i++) |
24f13b03 | 1871 | { |
b68a74d1 JL |
1872 | symext_entryS se = |
1873 | ELF32_PARISC_SX_GET (abfd, | |
1874 | (symextn_hdr->contents | |
1875 | + i * ELF32_PARISC_SX_SIZE)); | |
1876 | unsigned int se_value = ELF32_PARISC_SX_VAL (se); | |
1877 | unsigned int se_type = ELF32_PARISC_SX_TYPE (se); | |
e8f2240a | 1878 | |
24f13b03 ILT |
1879 | switch (se_type) |
1880 | { | |
1881 | case PARISC_SXT_NULL: | |
1882 | break; | |
e8f2240a | 1883 | |
24f13b03 ILT |
1884 | case PARISC_SXT_SYMNDX: |
1885 | if (se_value >= symcnt) | |
1886 | { | |
1887 | bfd_set_error (bfd_error_bad_value); | |
1888 | return (false); | |
1889 | } | |
1890 | current_sym_idx = se_value - 1; | |
1891 | break; | |
1892 | ||
1893 | case PARISC_SXT_ARG_RELOC: | |
1894 | esyms[current_sym_idx].tc_data.hppa_arg_reloc = se_value; | |
1895 | break; | |
1896 | ||
1897 | default: | |
1898 | bfd_set_error (bfd_error_bad_value); | |
1899 | return (false); | |
1900 | } | |
e8f2240a | 1901 | } |
24f13b03 | 1902 | return (true); |
e8f2240a KR |
1903 | } |
1904 | ||
24f13b03 ILT |
1905 | /* Read and attach the symbol extension information for the symbols |
1906 | in INPUT_BFD to the argument location hash table. Handle locals | |
1907 | if DO_LOCALS is true; likewise for globals when DO_GLOBALS is true. */ | |
1908 | ||
1909 | static boolean | |
5874427f | 1910 | elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table, local_syms) |
24f13b03 ILT |
1911 | bfd *input_bfd; |
1912 | Elf_Internal_Shdr *symtab_hdr; | |
1913 | struct elf32_hppa_args_hash_table *args_hash_table; | |
1914 | Elf_Internal_Sym *local_syms; | |
e8f2240a | 1915 | { |
24f13b03 | 1916 | asection *symextn_sec; |
b68a74d1 | 1917 | bfd_byte *contents; |
24f13b03 | 1918 | unsigned int i, n_entries, current_index = 0; |
e8f2240a | 1919 | |
24f13b03 ILT |
1920 | /* Get the symbol extension section for this BFD. If no section exists |
1921 | then there's nothing to do. Likewise if the section exists, but | |
1922 | has no contents. */ | |
1923 | symextn_sec = bfd_get_section_by_name (input_bfd, SYMEXTN_SECTION_NAME); | |
1924 | if (symextn_sec == NULL) | |
1925 | return true; | |
e8f2240a | 1926 | |
24f13b03 ILT |
1927 | /* Done separately so we can turn off SEC_HAS_CONTENTS (see below). */ |
1928 | if (symextn_sec->_raw_size == 0) | |
3a70b01d | 1929 | { |
24f13b03 ILT |
1930 | symextn_sec->flags &= ~SEC_HAS_CONTENTS; |
1931 | return true; | |
3a70b01d | 1932 | } |
24f13b03 | 1933 | |
a9713b91 | 1934 | contents = (bfd_byte *) malloc ((size_t) symextn_sec->_raw_size); |
24f13b03 | 1935 | if (contents == NULL) |
3a70b01d | 1936 | { |
f5bfdacd | 1937 | bfd_set_error (bfd_error_no_memory); |
24f13b03 | 1938 | return false; |
3a70b01d | 1939 | } |
e8f2240a | 1940 | |
24f13b03 ILT |
1941 | /* How gross. We turn off SEC_HAS_CONTENTS for the input symbol extension |
1942 | sections to keep the generic ELF/BFD code from trying to do anything | |
1943 | with them. We have to undo that hack temporarily so that we can read | |
1944 | in the contents with the generic code. */ | |
1945 | symextn_sec->flags |= SEC_HAS_CONTENTS; | |
1946 | if (bfd_get_section_contents (input_bfd, symextn_sec, contents, | |
1947 | 0, symextn_sec->_raw_size) == false) | |
3a70b01d | 1948 | { |
24f13b03 ILT |
1949 | symextn_sec->flags &= ~SEC_HAS_CONTENTS; |
1950 | free (contents); | |
1951 | return false; | |
3a70b01d KR |
1952 | } |
1953 | ||
24f13b03 ILT |
1954 | /* Gross. Turn off SEC_HAS_CONTENTS for the input symbol extension |
1955 | sections (see above). */ | |
1956 | symextn_sec->flags &= ~SEC_HAS_CONTENTS; | |
e8f2240a | 1957 | |
b68a74d1 | 1958 | n_entries = symextn_sec->_raw_size / ELF32_PARISC_SX_SIZE; |
24f13b03 | 1959 | for (i = 0; i < n_entries; i++) |
e8f2240a | 1960 | { |
b68a74d1 JL |
1961 | symext_entryS entry = |
1962 | ELF32_PARISC_SX_GET (input_bfd, contents + i * ELF32_PARISC_SX_SIZE); | |
24f13b03 ILT |
1963 | unsigned int value = ELF32_PARISC_SX_VAL (entry); |
1964 | unsigned int type = ELF32_PARISC_SX_TYPE (entry); | |
1965 | struct elf32_hppa_args_hash_entry *args_hash; | |
e8f2240a | 1966 | |
24f13b03 | 1967 | switch (type) |
e8f2240a | 1968 | { |
24f13b03 ILT |
1969 | case PARISC_SXT_NULL: |
1970 | break; | |
e8f2240a | 1971 | |
24f13b03 ILT |
1972 | case PARISC_SXT_SYMNDX: |
1973 | if (value >= symtab_hdr->sh_size / sizeof (Elf32_External_Sym)) | |
80425e6c | 1974 | { |
24f13b03 ILT |
1975 | bfd_set_error (bfd_error_bad_value); |
1976 | free (contents); | |
1977 | return false; | |
80425e6c | 1978 | } |
24f13b03 ILT |
1979 | current_index = value; |
1980 | break; | |
e8f2240a | 1981 | |
24f13b03 | 1982 | case PARISC_SXT_ARG_RELOC: |
5874427f | 1983 | if (current_index < symtab_hdr->sh_info) |
326e32d7 | 1984 | { |
24f13b03 ILT |
1985 | Elf_Internal_Shdr *hdr; |
1986 | char *new_name; | |
1987 | const char *sym_name; | |
1988 | asection *sym_sec; | |
1989 | unsigned int len; | |
1990 | ||
1991 | hdr = elf_elfsections (input_bfd)[local_syms[current_index].st_shndx]; | |
1992 | sym_sec = hdr->bfd_section; | |
ede4eed4 | 1993 | sym_name = bfd_elf_string_from_elf_section (input_bfd, |
24f13b03 ILT |
1994 | symtab_hdr->sh_link, |
1995 | local_syms[current_index].st_name); | |
1996 | len = strlen (sym_name) + 10; | |
1997 | new_name = malloc (len); | |
1998 | if (new_name == NULL) | |
1999 | { | |
2000 | bfd_set_error (bfd_error_no_memory); | |
2001 | free (contents); | |
2002 | return false; | |
2003 | } | |
2004 | strcpy (new_name, sym_name); | |
2005 | sprintf (new_name + len - 10, "_%08x", (int)sym_sec); | |
2006 | ||
2007 | /* This is a global symbol with argument location info. | |
2008 | We need to enter it into the hash table. */ | |
2009 | args_hash = elf32_hppa_args_hash_lookup (args_hash_table, | |
2010 | new_name, true, | |
2011 | true); | |
2012 | free (new_name); | |
2013 | if (args_hash == NULL) | |
2014 | { | |
2015 | free (contents); | |
2016 | return false; | |
2017 | } | |
2018 | args_hash->arg_bits = value; | |
2019 | break; | |
326e32d7 | 2020 | } |
5874427f | 2021 | else if (current_index >= symtab_hdr->sh_info) |
e8f2240a | 2022 | { |
24f13b03 ILT |
2023 | struct elf_link_hash_entry *h; |
2024 | ||
2025 | current_index -= symtab_hdr->sh_info; | |
2026 | h = elf_sym_hashes(input_bfd)[current_index]; | |
2027 | /* This is a global symbol with argument location | |
2028 | information. We need to enter it into the hash table. */ | |
2029 | args_hash = elf32_hppa_args_hash_lookup (args_hash_table, | |
2030 | h->root.root.string, | |
2031 | true, true); | |
2032 | if (args_hash == NULL) | |
e8f2240a | 2033 | { |
24f13b03 ILT |
2034 | bfd_set_error (bfd_error_bad_value); |
2035 | free (contents); | |
2036 | return false; | |
e8f2240a | 2037 | } |
24f13b03 ILT |
2038 | args_hash->arg_bits = value; |
2039 | break; | |
e8f2240a | 2040 | } |
24f13b03 ILT |
2041 | else |
2042 | break; | |
e8f2240a | 2043 | |
24f13b03 ILT |
2044 | default: |
2045 | bfd_set_error (bfd_error_bad_value); | |
2046 | free (contents); | |
2047 | return false; | |
e8f2240a KR |
2048 | } |
2049 | } | |
24f13b03 ILT |
2050 | free (contents); |
2051 | return true; | |
e8f2240a KR |
2052 | } |
2053 | ||
24f13b03 ILT |
2054 | /* Undo the generic ELF code's subtraction of section->vma from the |
2055 | value of each external symbol. */ | |
d9ad93bc | 2056 | |
24f13b03 ILT |
2057 | static boolean |
2058 | elf32_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) | |
2059 | bfd *abfd; | |
2060 | struct bfd_link_info *info; | |
2061 | const Elf_Internal_Sym *sym; | |
2062 | const char **namep; | |
2063 | flagword *flagsp; | |
2064 | asection **secp; | |
2065 | bfd_vma *valp; | |
d9ad93bc | 2066 | { |
24f13b03 ILT |
2067 | *valp += (*secp)->vma; |
2068 | return true; | |
e8f2240a KR |
2069 | } |
2070 | ||
24f13b03 ILT |
2071 | /* Determine the name of the stub needed to perform a call assuming the |
2072 | argument relocation bits for caller and callee are in CALLER and CALLEE | |
2073 | for a call from LOCATION to DESTINATION. Copy the name into STUB_NAME. */ | |
e08b9ad7 | 2074 | |
24f13b03 ILT |
2075 | static void |
2076 | elf32_hppa_name_of_stub (caller, callee, location, destination, stub_name) | |
2077 | unsigned int caller, callee; | |
2078 | bfd_vma location, destination; | |
2079 | char *stub_name; | |
e8f2240a | 2080 | { |
24f13b03 | 2081 | arg_reloc_type arg_reloc_types[5]; |
e08b9ad7 | 2082 | |
24f13b03 | 2083 | if (elf32_hppa_arg_reloc_needed (caller, callee, arg_reloc_types)) |
e8f2240a | 2084 | { |
24f13b03 ILT |
2085 | arg_reloc_location i; |
2086 | /* Fill in the basic template. */ | |
2087 | strcpy (stub_name, "__XX_XX_XX_XX_XX_stub_"); | |
e8f2240a | 2088 | |
24f13b03 ILT |
2089 | /* Now fix the specifics. */ |
2090 | for (i = ARG0; i <= RET; i++) | |
2091 | switch (arg_reloc_types[i]) | |
2092 | { | |
2093 | case NO: | |
2094 | stub_name[3 * i + 2] = 'N'; | |
2095 | stub_name[3 * i + 3] = 'O'; | |
2096 | break; | |
2097 | case GF: | |
2098 | stub_name[3 * i + 2] = 'G'; | |
2099 | stub_name[3 * i + 3] = 'F'; | |
2100 | break; | |
2101 | case FG: | |
2102 | stub_name[3 * i + 2] = 'F'; | |
2103 | stub_name[3 * i + 3] = 'G'; | |
2104 | break; | |
2105 | case GD: | |
2106 | stub_name[3 * i + 2] = 'G'; | |
2107 | stub_name[3 * i + 3] = 'D'; | |
2108 | break; | |
2109 | case DG: | |
2110 | stub_name[3 * i + 2] = 'D'; | |
2111 | stub_name[3 * i + 3] = 'G'; | |
2112 | break; | |
2113 | } | |
e08b9ad7 | 2114 | } |
e08b9ad7 | 2115 | else |
24f13b03 ILT |
2116 | strcpy (stub_name, "_____long_branch_stub_"); |
2117 | } | |
e08b9ad7 | 2118 | |
24f13b03 ILT |
2119 | /* Determine if an argument relocation stub is needed to perform a |
2120 | call assuming the argument relocation bits for caller and callee | |
2121 | are in CALLER and CALLEE. Place the type of relocations (if any) | |
2122 | into stub_types_p. */ | |
e8f2240a | 2123 | |
24f13b03 ILT |
2124 | static boolean |
2125 | elf32_hppa_arg_reloc_needed (caller, callee, stub_types) | |
2126 | unsigned int caller, callee; | |
2127 | arg_reloc_type stub_types[5]; | |
2128 | { | |
2129 | /* Special case for no relocations. */ | |
2130 | if (caller == 0 || callee == 0) | |
2131 | return 0; | |
3a70b01d KR |
2132 | else |
2133 | { | |
24f13b03 ILT |
2134 | arg_location caller_loc[5]; |
2135 | arg_location callee_loc[5]; | |
2136 | ||
2137 | /* Extract the location information for the argument and return | |
2138 | value on both the caller and callee sides. */ | |
2139 | caller_loc[ARG0] = EXTRACT_ARBITS (caller, ARG0); | |
2140 | callee_loc[ARG0] = EXTRACT_ARBITS (callee, ARG0); | |
2141 | caller_loc[ARG1] = EXTRACT_ARBITS (caller, ARG1); | |
2142 | callee_loc[ARG1] = EXTRACT_ARBITS (callee, ARG1); | |
2143 | caller_loc[ARG2] = EXTRACT_ARBITS (caller, ARG2); | |
2144 | callee_loc[ARG2] = EXTRACT_ARBITS (callee, ARG2); | |
2145 | caller_loc[ARG3] = EXTRACT_ARBITS (caller, ARG3); | |
2146 | callee_loc[ARG3] = EXTRACT_ARBITS (callee, ARG3); | |
2147 | caller_loc[RET] = EXTRACT_ARBITS (caller, RET); | |
2148 | callee_loc[RET] = EXTRACT_ARBITS (callee, RET); | |
2149 | ||
2150 | /* Check some special combinations. This is necessary to | |
2151 | deal with double precision FP arguments. */ | |
2152 | if (caller_loc[ARG0] == AR_FU || caller_loc[ARG1] == AR_FU) | |
9783e04a | 2153 | { |
24f13b03 ILT |
2154 | caller_loc[ARG0] = AR_FPDBL1; |
2155 | caller_loc[ARG1] = AR_NO; | |
9783e04a | 2156 | } |
24f13b03 | 2157 | if (caller_loc[ARG2] == AR_FU || caller_loc[ARG3] == AR_FU) |
9783e04a | 2158 | { |
24f13b03 ILT |
2159 | caller_loc[ARG2] = AR_FPDBL2; |
2160 | caller_loc[ARG3] = AR_NO; | |
9783e04a | 2161 | } |
24f13b03 | 2162 | if (callee_loc[ARG0] == AR_FU || callee_loc[ARG1] == AR_FU) |
6e58a4e5 | 2163 | { |
24f13b03 ILT |
2164 | callee_loc[ARG0] = AR_FPDBL1; |
2165 | callee_loc[ARG1] = AR_NO; | |
6e58a4e5 | 2166 | } |
24f13b03 | 2167 | if (callee_loc[ARG2] == AR_FU || callee_loc[ARG3] == AR_FU) |
3a70b01d | 2168 | { |
24f13b03 ILT |
2169 | callee_loc[ARG2] = AR_FPDBL2; |
2170 | callee_loc[ARG3] = AR_NO; | |
2171 | } | |
e8f2240a | 2172 | |
24f13b03 ILT |
2173 | /* Now look up any relocation needed for each argument and the |
2174 | return value. */ | |
2175 | stub_types[ARG0] = arg_mismatches[caller_loc[ARG0]][callee_loc[ARG0]]; | |
2176 | stub_types[ARG1] = arg_mismatches[caller_loc[ARG1]][callee_loc[ARG1]]; | |
2177 | stub_types[ARG2] = arg_mismatches[caller_loc[ARG2]][callee_loc[ARG2]]; | |
2178 | stub_types[ARG3] = arg_mismatches[caller_loc[ARG3]][callee_loc[ARG3]]; | |
2179 | stub_types[RET] = ret_mismatches[caller_loc[RET]][callee_loc[RET]]; | |
2180 | ||
2181 | return (stub_types[ARG0] != NO | |
2182 | || stub_types[ARG1] != NO | |
2183 | || stub_types[ARG2] != NO | |
2184 | || stub_types[ARG3] != NO | |
2185 | || stub_types[RET] != NO); | |
2186 | } | |
2187 | } | |
4861ac76 | 2188 | |
24f13b03 ILT |
2189 | /* Compute the size of the stub needed to call from LOCATION to DESTINATION |
2190 | (a function named SYM_NAME), with argument relocation bits CALLER and | |
2191 | CALLEE. Return zero if no stub is needed to perform such a call. */ | |
e08b9ad7 | 2192 | |
24f13b03 ILT |
2193 | static unsigned int |
2194 | elf32_hppa_size_of_stub (callee, caller, location, destination, sym_name) | |
2195 | unsigned int callee, caller; | |
2196 | bfd_vma location, destination; | |
2197 | const char *sym_name; | |
2198 | { | |
2199 | arg_reloc_type arg_reloc_types[5]; | |
2200 | ||
2201 | /* Determine if a long branch or argument relocation stub is needed. | |
2202 | If an argument relocation stub is needed, the relocation will be | |
2203 | stored into arg_reloc_types. */ | |
2204 | if (!(((int)(location - destination) > 0x3ffff) | |
2205 | || ((int)(location - destination) < (int)0xfffc0000) | |
2206 | || elf32_hppa_arg_reloc_needed (caller, callee, arg_reloc_types))) | |
2207 | return 0; | |
e08b9ad7 | 2208 | |
24f13b03 ILT |
2209 | /* Some kind of stub is needed. Determine how big it needs to be. |
2210 | First check for argument relocation stubs as they also handle | |
2211 | long calls. Then check for long calls to millicode and finally | |
2212 | the normal long calls. */ | |
2213 | if (arg_reloc_types[ARG0] != NO | |
2214 | || arg_reloc_types[ARG1] != NO | |
2215 | || arg_reloc_types[ARG2] != NO | |
2216 | || arg_reloc_types[ARG3] != NO | |
2217 | || arg_reloc_types[RET] != NO) | |
2218 | { | |
2219 | /* Some kind of argument relocation stub is needed. */ | |
2220 | unsigned int len = 16; | |
2221 | arg_reloc_location i; | |
2222 | ||
2223 | /* Each GR or FG relocation takes 2 insns, each GD or DG | |
2224 | relocation takes 3 insns. Plus 4 more insns for the | |
2225 | RP adjustment, ldil & (be | ble) and copy. */ | |
2226 | for (i = ARG0; i <= RET; i++) | |
2227 | switch (arg_reloc_types[i]) | |
2228 | { | |
2229 | case GF: | |
2230 | case FG: | |
2231 | len += 8; | |
2232 | break; | |
e08b9ad7 | 2233 | |
24f13b03 ILT |
2234 | case GD: |
2235 | case DG: | |
2236 | len += 12; | |
2237 | break; | |
e08b9ad7 | 2238 | |
24f13b03 ILT |
2239 | default: |
2240 | break; | |
2241 | } | |
2242 | ||
2243 | /* Extra instructions are needed if we're relocating a return value. */ | |
2244 | if (arg_reloc_types[RET] != NO) | |
2245 | len += 12; | |
2246 | ||
2247 | return len; | |
2248 | } | |
2249 | else if (!strncmp ("$$", sym_name, 2) | |
2250 | && strcmp ("$$dyncall", sym_name)) | |
2251 | return 12; | |
2252 | else | |
2253 | return 16; | |
2254 | } | |
e08b9ad7 | 2255 | |
24f13b03 ILT |
2256 | /* Build one linker stub as defined by the stub hash table entry GEN_ENTRY. |
2257 | IN_ARGS contains the stub BFD and link info pointers. */ | |
2258 | ||
2259 | static boolean | |
2260 | elf32_hppa_build_one_stub (gen_entry, in_args) | |
2261 | struct bfd_hash_entry *gen_entry; | |
2262 | PTR in_args; | |
2263 | { | |
2264 | void **args = (void **)in_args; | |
2265 | bfd *stub_bfd = (bfd *)args[0]; | |
2266 | struct bfd_link_info *info = (struct bfd_link_info *)args[1]; | |
2267 | struct elf32_hppa_stub_hash_entry *entry; | |
2268 | struct elf32_hppa_stub_hash_table *stub_hash_table; | |
2269 | bfd_byte *loc; | |
2270 | symvalue sym_value; | |
2271 | const char *sym_name; | |
2272 | ||
2273 | /* Initialize pointers to the stub hash table, the particular entry we | |
2274 | are building a stub for, and where (in memory) we should place the stub | |
2275 | instructions. */ | |
2276 | entry = (struct elf32_hppa_stub_hash_entry *)gen_entry; | |
2277 | stub_hash_table = elf32_hppa_hash_table(info)->stub_hash_table; | |
2278 | loc = stub_hash_table->location; | |
2279 | ||
2280 | /* Make a note of the offset within the stubs for this entry. */ | |
2281 | entry->offset = stub_hash_table->offset; | |
2282 | ||
2283 | /* The symbol's name starts at offset 22. */ | |
2284 | sym_name = entry->root.string + 22; | |
2285 | ||
2286 | sym_value = (entry->target_value | |
2287 | + entry->target_section->output_offset | |
2288 | + entry->target_section->output_section->vma); | |
2289 | ||
2290 | if (strncmp ("_____long_branch_stub_", entry->root.string, 22)) | |
2291 | { | |
2292 | /* This must be an argument or return value relocation stub. */ | |
2293 | unsigned long insn; | |
2294 | arg_reloc_location i; | |
2295 | bfd_byte *begin_loc = loc; | |
2296 | ||
2297 | /* First the return pointer adjustment. Depending on exact calling | |
2298 | sequence this instruction may be skipped. */ | |
2299 | bfd_put_32 (stub_bfd, LDO_M4_R31_R31, loc); | |
2300 | loc += 4; | |
2301 | ||
2302 | /* If we are relocating a return value, then we're going to have | |
2303 | to return into the stub. So we have to save off the user's | |
2304 | return pointer into the stack at RP'. */ | |
2305 | if (strncmp (entry->root.string + 14, "NO", 2)) | |
2306 | { | |
2307 | bfd_put_32 (stub_bfd, STW_R31_M8R30, loc); | |
2308 | loc += 4; | |
e08b9ad7 JL |
2309 | } |
2310 | ||
24f13b03 ILT |
2311 | /* Iterate over the argument relocations, emitting instructions |
2312 | to move them around as necessary. */ | |
2313 | for (i = ARG0; i <= ARG3; i++) | |
4861ac76 | 2314 | { |
24f13b03 | 2315 | if (!strncmp (entry->root.string + 3 * i + 2, "GF", 2)) |
e08b9ad7 | 2316 | { |
24f13b03 ILT |
2317 | bfd_put_32 (stub_bfd, STW_ARG_M16R30 | ((26 - i) << 16), loc); |
2318 | bfd_put_32 (stub_bfd, FLDW_M16R30_FARG | (4 + i), loc + 4); | |
2319 | loc += 8; | |
e08b9ad7 | 2320 | } |
24f13b03 | 2321 | else if (!strncmp (entry->root.string + 3 * i + 2, "FG", 2)) |
e08b9ad7 | 2322 | { |
24f13b03 ILT |
2323 | bfd_put_32 (stub_bfd, FSTW_FARG_M16R30 | (4 + i), loc); |
2324 | bfd_put_32 (stub_bfd, LDW_M16R30_ARG | ((26 - i) << 16), loc + 4); | |
2325 | loc += 8; | |
e08b9ad7 | 2326 | } |
24f13b03 | 2327 | else if (!strncmp (entry->root.string + 3 * i + 2, "GD", 2)) |
e8f2240a | 2328 | { |
24f13b03 ILT |
2329 | bfd_put_32 (stub_bfd, STW_ARG_M12R30 | ((26 - i) << 16), loc); |
2330 | bfd_put_32 (stub_bfd, STW_ARG_M16R30 | ((25 - i) << 16), loc + 4); | |
2331 | bfd_put_32 (stub_bfd, FLDD_M16R30_FARG | (5 + i), loc + 8); | |
2332 | loc += 12; | |
e08b9ad7 | 2333 | } |
24f13b03 | 2334 | else if (!strncmp (entry->root.string + 3 * i + 2, "DG", 2)) |
e08b9ad7 | 2335 | { |
24f13b03 ILT |
2336 | bfd_put_32 (stub_bfd, FSTD_FARG_M16R30 | (5 + i), loc); |
2337 | bfd_put_32 (stub_bfd, LDW_M12R30_ARG | ((26 - i) << 16), loc + 4); | |
2338 | bfd_put_32 (stub_bfd, LDW_M16R30_ARG | ((25 - i) << 16), loc + 8); | |
2339 | loc += 12; | |
e8f2240a | 2340 | } |
e8f2240a | 2341 | } |
e8f2240a | 2342 | |
24f13b03 ILT |
2343 | /* Load the high bits of the target address into %r1. */ |
2344 | insn = hppa_rebuild_insn (stub_bfd, LDIL_R1, | |
2345 | hppa_field_adjust (sym_value, 0, e_lrsel), 21); | |
2346 | bfd_put_32 (stub_bfd, insn, loc); | |
2347 | loc += 4; | |
e8f2240a | 2348 | |
24f13b03 ILT |
2349 | /* If we are relocating a return value, then we're going to have |
2350 | to return into the stub, then perform the return value relocation. */ | |
2351 | if (strncmp (entry->root.string + 14, "NO", 2)) | |
e8f2240a | 2352 | { |
24f13b03 ILT |
2353 | /* To return to the stub we "ble" to the target and copy the return |
2354 | pointer from %r31 into %r2. */ | |
2355 | insn = hppa_rebuild_insn (stub_bfd, | |
2356 | BLE_SR4_R1, | |
2357 | hppa_field_adjust (sym_value, 0, | |
2358 | e_rrsel) >> 2, | |
2359 | 17); | |
2360 | bfd_put_32 (stub_bfd, insn, loc); | |
2361 | bfd_put_32 (stub_bfd, COPY_R31_R2, loc + 4); | |
2362 | ||
2363 | /* Reload the return pointer for our caller from the stack. */ | |
2364 | bfd_put_32 (stub_bfd, LDW_M8R30_R31, loc + 8); | |
2365 | loc += 12; | |
2366 | ||
2367 | /* Perform the return value relocation. */ | |
2368 | if (!strncmp (entry->root.string + 14, "GF", 2)) | |
e8f2240a | 2369 | { |
24f13b03 ILT |
2370 | bfd_put_32 (stub_bfd, STW_ARG_M16R30 | (28 << 16), loc); |
2371 | bfd_put_32 (stub_bfd, FLDW_M16R30_FARG | 4, loc + 4); | |
2372 | loc += 8; | |
e8f2240a | 2373 | } |
24f13b03 | 2374 | else if (!strncmp (entry->root.string + 14, "FG", 2)) |
e8f2240a | 2375 | { |
24f13b03 ILT |
2376 | bfd_put_32 (stub_bfd, FSTW_FARG_M16R30 | 4, loc); |
2377 | bfd_put_32 (stub_bfd, LDW_M16R30_ARG | (28 << 16), loc + 4); | |
2378 | loc += 8; | |
e8f2240a | 2379 | } |
24f13b03 | 2380 | else if (!strncmp (entry->root.string + 2, "GD", 2)) |
e8f2240a | 2381 | { |
24f13b03 ILT |
2382 | bfd_put_32 (stub_bfd, STW_ARG_M12R30 | (28 << 16), loc); |
2383 | bfd_put_32 (stub_bfd, STW_ARG_M16R30 | (29 << 16), loc + 4); | |
2384 | bfd_put_32 (stub_bfd, FLDD_M16R30_FARG | 4, loc + 8); | |
2385 | loc += 12; | |
e8f2240a | 2386 | } |
24f13b03 | 2387 | else if (!strncmp (entry->root.string + 2, "DG", 2)) |
e8f2240a | 2388 | { |
24f13b03 ILT |
2389 | bfd_put_32 (stub_bfd, FSTD_FARG_M16R30 | 4, loc); |
2390 | bfd_put_32 (stub_bfd, LDW_M12R30_ARG | (28 << 16), loc + 4); | |
2391 | bfd_put_32 (stub_bfd, LDW_M16R30_ARG | (29 << 16), loc + 8); | |
2392 | loc += 12; | |
e8f2240a | 2393 | } |
24f13b03 ILT |
2394 | /* Branch back to the user's code now. */ |
2395 | bfd_put_32 (stub_bfd, BV_N_0_R31, loc); | |
2396 | loc += 4; | |
2397 | } | |
2398 | else | |
2399 | { | |
2400 | /* No return value relocation, so we can simply "be" to the | |
2401 | target and copy out return pointer into %r2. */ | |
2402 | insn = hppa_rebuild_insn (stub_bfd, BE_SR4_R1, | |
2403 | hppa_field_adjust (sym_value, 0, | |
2404 | e_rrsel) >> 2, 17); | |
2405 | bfd_put_32 (stub_bfd, insn, loc); | |
2406 | bfd_put_32 (stub_bfd, COPY_R31_R2, loc + 4); | |
2407 | loc += 8; | |
2408 | } | |
e8f2240a | 2409 | |
24f13b03 ILT |
2410 | /* Update the location and offsets. */ |
2411 | stub_hash_table->location += (loc - begin_loc); | |
2412 | stub_hash_table->offset += (loc - begin_loc); | |
2413 | } | |
2414 | else | |
2415 | { | |
2416 | /* Create one of two variant long branch stubs. One for $$dyncall and | |
2417 | normal calls, the other for calls to millicode. */ | |
2418 | unsigned long insn; | |
2419 | int millicode_call = 0; | |
2420 | ||
2421 | if (!strncmp ("$$", sym_name, 2) && strcmp ("$$dyncall", sym_name)) | |
2422 | millicode_call = 1; | |
2423 | ||
2424 | /* First the return pointer adjustment. Depending on exact calling | |
2425 | sequence this instruction may be skipped. */ | |
2426 | bfd_put_32 (stub_bfd, LDO_M4_R31_R31, loc); | |
2427 | ||
2428 | /* The next two instructions are the long branch itself. A long branch | |
2429 | is formed with "ldil" loading the upper bits of the target address | |
2430 | into a register, then branching with "be" which adds in the lower bits. | |
2431 | Long branches to millicode nullify the delay slot of the "be". */ | |
2432 | insn = hppa_rebuild_insn (stub_bfd, LDIL_R1, | |
2433 | hppa_field_adjust (sym_value, 0, e_lrsel), 21); | |
2434 | bfd_put_32 (stub_bfd, insn, loc + 4); | |
2435 | insn = hppa_rebuild_insn (stub_bfd, BE_SR4_R1 | (millicode_call ? 2 : 0), | |
2436 | hppa_field_adjust (sym_value, 0, e_rrsel) >> 2, | |
2437 | 17); | |
2438 | bfd_put_32 (stub_bfd, insn, loc + 8); | |
2439 | ||
2440 | if (!millicode_call) | |
2441 | { | |
2442 | /* The sequence to call this stub places the return pointer into %r31, | |
2443 | the final target expects the return pointer in %r2, so copy the | |
2444 | return pointer into the proper register. */ | |
2445 | bfd_put_32 (stub_bfd, COPY_R31_R2, loc + 12); | |
2446 | ||
2447 | /* Update the location and offsets. */ | |
2448 | stub_hash_table->location += 16; | |
2449 | stub_hash_table->offset += 16; | |
e8f2240a | 2450 | } |
24f13b03 ILT |
2451 | else |
2452 | { | |
2453 | /* Update the location and offsets. */ | |
2454 | stub_hash_table->location += 12; | |
2455 | stub_hash_table->offset += 12; | |
2456 | } | |
2457 | ||
e8f2240a | 2458 | } |
24f13b03 | 2459 | return true; |
e8f2240a KR |
2460 | } |
2461 | ||
24f13b03 | 2462 | /* External entry points for sizing and building linker stubs. */ |
d9ad93bc | 2463 | |
24f13b03 ILT |
2464 | /* Build all the stubs associated with the current output file. The |
2465 | stubs are kept in a hash table attached to the main linker hash | |
2466 | table. This is called via hppaelf_finish in the linker. */ | |
e08b9ad7 | 2467 | |
24f13b03 ILT |
2468 | boolean |
2469 | elf32_hppa_build_stubs (stub_bfd, info) | |
2470 | bfd *stub_bfd; | |
2471 | struct bfd_link_info *info; | |
d9ad93bc | 2472 | { |
24f13b03 ILT |
2473 | /* The stub BFD only has one section. */ |
2474 | asection *stub_sec = stub_bfd->sections; | |
2475 | struct elf32_hppa_stub_hash_table *table; | |
2476 | unsigned int size; | |
2477 | void *args[2]; | |
2478 | ||
2479 | /* So we can pass both the BFD for the stubs and the link info | |
2480 | structure to the routine which actually builds stubs. */ | |
2481 | args[0] = stub_bfd; | |
2482 | args[1] = info; | |
2483 | ||
2484 | /* Allocate memory to hold the linker stubs. */ | |
2485 | size = bfd_section_size (stub_bfd, stub_sec); | |
2486 | stub_sec->contents = (unsigned char *) bfd_zalloc (stub_bfd, size); | |
2487 | if (stub_sec->contents == NULL) | |
a9713b91 | 2488 | return false; |
24f13b03 ILT |
2489 | table = elf32_hppa_hash_table(info)->stub_hash_table; |
2490 | table->location = stub_sec->contents; | |
d9ad93bc | 2491 | |
24f13b03 ILT |
2492 | /* Build the stubs as directed by the stub hash table. */ |
2493 | elf32_hppa_stub_hash_traverse (table, elf32_hppa_build_one_stub, args); | |
d9ad93bc | 2494 | |
24f13b03 | 2495 | return true; |
d9ad93bc KR |
2496 | } |
2497 | ||
24f13b03 | 2498 | /* Determine and set the size of the stub section for a final link. |
e08b9ad7 | 2499 | |
24f13b03 ILT |
2500 | The basic idea here is to examine all the relocations looking for |
2501 | PC-relative calls to a target that is unreachable with a "bl" | |
2502 | instruction or calls where the caller and callee disagree on the | |
2503 | location of their arguments or return value. */ | |
e8f2240a | 2504 | |
24f13b03 ILT |
2505 | boolean |
2506 | elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info) | |
d9ad93bc | 2507 | bfd *stub_bfd; |
e8f2240a | 2508 | bfd *output_bfd; |
4991ebb9 | 2509 | struct bfd_link_info *link_info; |
e8f2240a | 2510 | { |
24f13b03 | 2511 | bfd *input_bfd; |
ede4eed4 | 2512 | asection *section, *stub_sec = 0; |
24f13b03 | 2513 | Elf_Internal_Shdr *symtab_hdr; |
77712cf0 | 2514 | Elf_Internal_Sym *local_syms, *isym, **all_local_syms; |
24f13b03 | 2515 | Elf32_External_Sym *ext_syms, *esym; |
77712cf0 | 2516 | unsigned int i, index, bfd_count = 0; |
24f13b03 ILT |
2517 | struct elf32_hppa_stub_hash_table *stub_hash_table = 0; |
2518 | struct elf32_hppa_args_hash_table *args_hash_table = 0; | |
2519 | ||
2520 | /* Create and initialize the stub hash table. */ | |
2521 | stub_hash_table = ((struct elf32_hppa_stub_hash_table *) | |
2522 | malloc (sizeof (struct elf32_hppa_stub_hash_table))); | |
2523 | if (!stub_hash_table) | |
e8f2240a | 2524 | { |
24f13b03 ILT |
2525 | bfd_set_error (bfd_error_no_memory); |
2526 | goto error_return; | |
2527 | } | |
e08b9ad7 | 2528 | |
24f13b03 ILT |
2529 | if (!elf32_hppa_stub_hash_table_init (stub_hash_table, stub_bfd, |
2530 | elf32_hppa_stub_hash_newfunc)) | |
2531 | goto error_return; | |
4c85cbfa | 2532 | |
24f13b03 ILT |
2533 | /* Likewise for the argument location hash table. */ |
2534 | args_hash_table = ((struct elf32_hppa_args_hash_table *) | |
2535 | malloc (sizeof (struct elf32_hppa_args_hash_table))); | |
2536 | if (!args_hash_table) | |
2537 | { | |
2538 | bfd_set_error (bfd_error_no_memory); | |
2539 | goto error_return; | |
e8f2240a | 2540 | } |
e08b9ad7 | 2541 | |
24f13b03 ILT |
2542 | if (!elf32_hppa_args_hash_table_init (args_hash_table, |
2543 | elf32_hppa_args_hash_newfunc)) | |
2544 | goto error_return; | |
4c85cbfa | 2545 | |
24f13b03 ILT |
2546 | /* Attach the hash tables to the main hash table. */ |
2547 | elf32_hppa_hash_table(link_info)->stub_hash_table = stub_hash_table; | |
2548 | elf32_hppa_hash_table(link_info)->args_hash_table = args_hash_table; | |
d9ad93bc | 2549 | |
5874427f | 2550 | /* Count the number of input BFDs. */ |
24f13b03 ILT |
2551 | for (input_bfd = link_info->input_bfds; |
2552 | input_bfd != NULL; | |
2553 | input_bfd = input_bfd->link_next) | |
5874427f JL |
2554 | bfd_count++; |
2555 | ||
2556 | /* We want to read in symbol extension records only once. To do this | |
2557 | we need to read in the local symbols in parallel and save them for | |
2558 | later use; so hold pointers to the local symbols in an array. */ | |
2559 | all_local_syms | |
2560 | = (Elf_Internal_Sym **) malloc (sizeof (Elf_Internal_Sym *) * bfd_count); | |
2561 | if (all_local_syms == NULL) | |
d9ad93bc | 2562 | { |
5874427f JL |
2563 | bfd_set_error (bfd_error_no_memory); |
2564 | goto error_return; | |
d9ad93bc | 2565 | } |
5874427f | 2566 | memset (all_local_syms, 0, sizeof (Elf_Internal_Sym *) * bfd_count); |
4c85cbfa | 2567 | |
5874427f JL |
2568 | /* Walk over all the input BFDs adding entries to the args hash table |
2569 | for all the external functions. */ | |
77712cf0 | 2570 | for (input_bfd = link_info->input_bfds, index = 0; |
24f13b03 | 2571 | input_bfd != NULL; |
77712cf0 | 2572 | input_bfd = input_bfd->link_next, index++) |
e8f2240a | 2573 | { |
24f13b03 ILT |
2574 | /* We'll need the symbol table in a second. */ |
2575 | symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; | |
2576 | if (symtab_hdr->sh_info == 0) | |
2577 | continue; | |
d9ad93bc | 2578 | |
24f13b03 ILT |
2579 | /* We need an array of the local symbols attached to the input bfd. |
2580 | Unfortunately, we're going to have to read & swap them in. */ | |
2581 | local_syms | |
2582 | = (Elf_Internal_Sym *)malloc (symtab_hdr->sh_info | |
2583 | * sizeof (Elf_Internal_Sym)); | |
2584 | if (local_syms == NULL) | |
2585 | { | |
2586 | bfd_set_error (bfd_error_no_memory); | |
5874427f | 2587 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2588 | if (all_local_syms[i]) |
2589 | free (all_local_syms[i]); | |
2590 | free (all_local_syms); | |
24f13b03 ILT |
2591 | goto error_return; |
2592 | } | |
77712cf0 | 2593 | all_local_syms[index] = local_syms; |
e08b9ad7 | 2594 | |
24f13b03 ILT |
2595 | ext_syms |
2596 | = (Elf32_External_Sym *)malloc (symtab_hdr->sh_info | |
2597 | * sizeof (Elf32_External_Sym)); | |
2598 | if (ext_syms == NULL) | |
2599 | { | |
2600 | bfd_set_error (bfd_error_no_memory); | |
5874427f | 2601 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2602 | if (all_local_syms[i]) |
2603 | free (all_local_syms[i]); | |
2604 | free (all_local_syms); | |
24f13b03 ILT |
2605 | goto error_return; |
2606 | } | |
d9ad93bc | 2607 | |
24f13b03 ILT |
2608 | if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 |
2609 | || bfd_read (ext_syms, 1, | |
2610 | (symtab_hdr->sh_info | |
2611 | * sizeof (Elf32_External_Sym)), input_bfd) | |
2612 | != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))) | |
2613 | { | |
5874427f | 2614 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2615 | if (all_local_syms[i]) |
2616 | free (all_local_syms[i]); | |
2617 | free (all_local_syms); | |
24f13b03 ILT |
2618 | free (ext_syms); |
2619 | goto error_return; | |
2620 | } | |
d9ad93bc | 2621 | |
24f13b03 ILT |
2622 | /* Swap the local symbols in. */ |
2623 | isym = local_syms; | |
2624 | esym = ext_syms; | |
2625 | for (i = 0; i < symtab_hdr->sh_info; i++, esym++, isym++) | |
2626 | bfd_elf32_swap_symbol_in (input_bfd, esym, isym); | |
d9ad93bc | 2627 | |
24f13b03 ILT |
2628 | /* Now we can free the external symbols. */ |
2629 | free (ext_syms); | |
d9ad93bc | 2630 | |
24f13b03 | 2631 | if (elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table, |
5874427f | 2632 | local_syms) == false) |
24f13b03 | 2633 | { |
5874427f | 2634 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2635 | if (all_local_syms[i]) |
2636 | free (all_local_syms[i]); | |
2637 | free (all_local_syms); | |
24f13b03 ILT |
2638 | goto error_return; |
2639 | } | |
5874427f | 2640 | } |
d9ad93bc | 2641 | |
5874427f JL |
2642 | /* Magic as we know the stub bfd only has one section. */ |
2643 | stub_sec = stub_bfd->sections; | |
2644 | ||
2645 | /* If generating a relocateable output file, then we don't | |
2646 | have to examine the relocs. */ | |
2647 | if (link_info->relocateable) | |
2648 | { | |
2649 | for (i = 0; i < bfd_count; i++) | |
77712cf0 JL |
2650 | if (all_local_syms[i]) |
2651 | free (all_local_syms[i]); | |
2652 | free (all_local_syms); | |
5874427f JL |
2653 | return true; |
2654 | } | |
2655 | ||
2656 | /* Now that we have argument location information for all the global | |
2657 | functions we can start looking for stubs. */ | |
77712cf0 | 2658 | for (input_bfd = link_info->input_bfds, index = 0; |
5874427f | 2659 | input_bfd != NULL; |
77712cf0 | 2660 | input_bfd = input_bfd->link_next, index++) |
5874427f | 2661 | { |
5874427f JL |
2662 | /* We'll need the symbol table in a second. */ |
2663 | symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; | |
2664 | if (symtab_hdr->sh_info == 0) | |
2665 | continue; | |
2666 | ||
77712cf0 | 2667 | local_syms = all_local_syms[index]; |
d9ad93bc | 2668 | |
24f13b03 ILT |
2669 | /* Walk over each section attached to the input bfd. */ |
2670 | for (section = input_bfd->sections; | |
2671 | section != NULL; | |
2672 | section = section->next) | |
2673 | { | |
2674 | Elf_Internal_Shdr *input_rel_hdr; | |
2675 | Elf32_External_Rela *external_relocs, *erelaend, *erela; | |
2676 | Elf_Internal_Rela *internal_relocs, *irelaend, *irela; | |
2677 | ||
2678 | /* If there aren't any relocs, then there's nothing to do. */ | |
2679 | if ((section->flags & SEC_RELOC) == 0 | |
2680 | || section->reloc_count == 0) | |
2681 | continue; | |
2682 | ||
2683 | /* Allocate space for the external relocations. */ | |
2684 | external_relocs | |
2685 | = (Elf32_External_Rela *) malloc (section->reloc_count * sizeof (Elf32_External_Rela)); | |
2686 | if (external_relocs == NULL) | |
d9ad93bc | 2687 | { |
24f13b03 | 2688 | bfd_set_error (bfd_error_no_memory); |
5874427f | 2689 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2690 | if (all_local_syms[i]) |
2691 | free (all_local_syms[i]); | |
2692 | free (all_local_syms); | |
24f13b03 | 2693 | goto error_return; |
d9ad93bc | 2694 | } |
d9ad93bc | 2695 | |
24f13b03 ILT |
2696 | /* Likewise for the internal relocations. */ |
2697 | internal_relocs | |
2698 | = (Elf_Internal_Rela *) malloc (section->reloc_count * sizeof (Elf_Internal_Rela)); | |
2699 | if (internal_relocs == NULL) | |
2700 | { | |
2701 | bfd_set_error (bfd_error_no_memory); | |
2702 | free (external_relocs); | |
5874427f | 2703 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2704 | if (all_local_syms[i]) |
2705 | free (all_local_syms[i]); | |
2706 | free (all_local_syms); | |
24f13b03 ILT |
2707 | goto error_return; |
2708 | } | |
d9ad93bc | 2709 | |
24f13b03 ILT |
2710 | /* Read in the external relocs. */ |
2711 | input_rel_hdr = &elf_section_data (section)->rel_hdr; | |
2712 | if (bfd_seek (input_bfd, input_rel_hdr->sh_offset, SEEK_SET) != 0 | |
2713 | || bfd_read (external_relocs, 1, input_rel_hdr->sh_size, | |
2714 | input_bfd) != input_rel_hdr->sh_size) | |
2715 | { | |
2716 | free (external_relocs); | |
2717 | free (internal_relocs); | |
5874427f | 2718 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2719 | if (all_local_syms[i]) |
2720 | free (all_local_syms[i]); | |
2721 | free (all_local_syms); | |
24f13b03 ILT |
2722 | goto error_return; |
2723 | } | |
d9ad93bc | 2724 | |
24f13b03 ILT |
2725 | /* Swap in the relocs. */ |
2726 | erela = external_relocs; | |
2727 | erelaend = erela + section->reloc_count; | |
2728 | irela = internal_relocs; | |
2729 | for (; erela < erelaend; erela++, irela++) | |
2730 | bfd_elf32_swap_reloca_in (input_bfd, erela, irela); | |
d9ad93bc | 2731 | |
24f13b03 ILT |
2732 | /* We're done with the external relocs, free them. */ |
2733 | free (external_relocs); | |
d9ad93bc | 2734 | |
24f13b03 ILT |
2735 | /* Now examine each relocation. */ |
2736 | irela = internal_relocs; | |
2737 | irelaend = irela + section->reloc_count; | |
2738 | for (; irela < irelaend; irela++) | |
d9ad93bc | 2739 | { |
a9713b91 ILT |
2740 | long r_type, callee_args, caller_args, size_of_stub; |
2741 | unsigned long r_index; | |
24f13b03 ILT |
2742 | struct elf_link_hash_entry *hash; |
2743 | struct elf32_hppa_stub_hash_entry *stub_hash; | |
2744 | struct elf32_hppa_args_hash_entry *args_hash; | |
2745 | Elf_Internal_Sym *sym; | |
2746 | asection *sym_sec; | |
2747 | const char *sym_name; | |
2748 | symvalue sym_value; | |
2749 | bfd_vma location, destination; | |
2750 | char *new_name = NULL; | |
2751 | ||
2752 | r_type = ELF32_R_TYPE (irela->r_info); | |
2753 | r_index = ELF32_R_SYM (irela->r_info); | |
2754 | ||
2755 | if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED) | |
2756 | { | |
2757 | bfd_set_error (bfd_error_bad_value); | |
2758 | free (internal_relocs); | |
5874427f | 2759 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2760 | if (all_local_syms[i]) |
2761 | free (all_local_syms[i]); | |
2762 | free (all_local_syms); | |
24f13b03 ILT |
2763 | goto error_return; |
2764 | } | |
2765 | ||
2766 | /* Only look for stubs on call instructions or plabel | |
2767 | references. */ | |
2768 | if (r_type != R_PARISC_PCREL17F | |
2769 | && r_type != R_PARISC_PLABEL32 | |
2770 | && r_type != R_PARISC_PLABEL21L | |
2771 | && r_type != R_PARISC_PLABEL14R) | |
2772 | continue; | |
2773 | ||
2774 | /* Now determine the call target, its name, value, section | |
2775 | and argument relocation bits. */ | |
2776 | hash = NULL; | |
2777 | sym = NULL; | |
2778 | sym_sec = NULL; | |
2779 | if (r_index < symtab_hdr->sh_info) | |
d9ad93bc | 2780 | { |
24f13b03 ILT |
2781 | /* It's a local symbol. */ |
2782 | Elf_Internal_Shdr *hdr; | |
2783 | ||
2784 | sym = local_syms + r_index; | |
2785 | hdr = elf_elfsections (input_bfd)[sym->st_shndx]; | |
2786 | sym_sec = hdr->bfd_section; | |
ede4eed4 KR |
2787 | sym_name = bfd_elf_string_from_elf_section (input_bfd, |
2788 | symtab_hdr->sh_link, | |
2789 | sym->st_name); | |
24f13b03 ILT |
2790 | sym_value = (ELF_ST_TYPE (sym->st_info) == STT_SECTION |
2791 | ? 0 : sym->st_value); | |
2792 | destination = (sym_value | |
2793 | + sym_sec->output_offset | |
2794 | + sym_sec->output_section->vma); | |
2795 | ||
2796 | /* Tack on an ID so we can uniquely identify this local | |
2797 | symbol in the stub or arg info hash tables. */ | |
2798 | new_name = malloc (strlen (sym_name) + 10); | |
2799 | if (new_name == 0) | |
d9ad93bc | 2800 | { |
24f13b03 ILT |
2801 | bfd_set_error (bfd_error_bad_value); |
2802 | free (internal_relocs); | |
5874427f | 2803 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2804 | if (all_local_syms[i]) |
2805 | free (all_local_syms[i]); | |
2806 | free (all_local_syms); | |
24f13b03 | 2807 | goto error_return; |
d9ad93bc | 2808 | } |
24f13b03 ILT |
2809 | sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec); |
2810 | sym_name = new_name; | |
d9ad93bc | 2811 | } |
24f13b03 | 2812 | else |
d9ad93bc | 2813 | { |
24f13b03 ILT |
2814 | /* It's an external symbol. */ |
2815 | long index; | |
2816 | ||
2817 | index = r_index - symtab_hdr->sh_info; | |
2818 | hash = elf_sym_hashes (input_bfd)[index]; | |
31dabb6c JL |
2819 | if (hash->root.type == bfd_link_hash_defined |
2820 | || hash->root.type == bfd_link_hash_defweak) | |
24f13b03 ILT |
2821 | { |
2822 | sym_sec = hash->root.u.def.section; | |
2823 | sym_name = hash->root.root.string; | |
2824 | sym_value = hash->root.u.def.value; | |
2825 | destination = (sym_value | |
2826 | + sym_sec->output_offset | |
2827 | + sym_sec->output_section->vma); | |
2828 | } | |
2829 | else | |
2830 | { | |
2831 | bfd_set_error (bfd_error_bad_value); | |
2832 | free (internal_relocs); | |
5874427f | 2833 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2834 | if (all_local_syms[i]) |
2835 | free (all_local_syms[i]); | |
2836 | free (all_local_syms); | |
24f13b03 ILT |
2837 | goto error_return; |
2838 | } | |
d9ad93bc KR |
2839 | } |
2840 | ||
24f13b03 ILT |
2841 | args_hash = elf32_hppa_args_hash_lookup (args_hash_table, |
2842 | sym_name, false, false); | |
d9ad93bc | 2843 | |
24f13b03 ILT |
2844 | /* Get both caller and callee argument information. */ |
2845 | if (args_hash == NULL) | |
2846 | callee_args = 0; | |
d9ad93bc | 2847 | else |
24f13b03 ILT |
2848 | callee_args = args_hash->arg_bits; |
2849 | ||
2850 | /* For calls get the caller's bits from the addend of | |
2851 | the call relocation. For PLABELS the caller's bits | |
2852 | are assumed to have all args & return values in general | |
2853 | registers (0x155). */ | |
2854 | if (r_type == R_PARISC_PCREL17F) | |
2855 | caller_args = HPPA_R_ARG_RELOC (irela->r_addend); | |
2856 | else | |
2857 | caller_args = 0x155; | |
2858 | ||
2859 | /* Now determine where the call point is. */ | |
2860 | location = (section->output_offset | |
2861 | + section->output_section->vma | |
2862 | + irela->r_offset); | |
2863 | ||
2864 | /* We only care about the destination for PCREL function | |
2865 | calls (eg. we don't care for PLABELS). */ | |
2866 | if (r_type != R_PARISC_PCREL17F) | |
2867 | location = destination; | |
2868 | ||
2869 | /* Determine what (if any) linker stub is needed and its | |
2870 | size (in bytes). */ | |
2871 | size_of_stub = elf32_hppa_size_of_stub (callee_args, | |
2872 | caller_args, | |
2873 | location, | |
2874 | destination, | |
2875 | sym_name); | |
2876 | if (size_of_stub != 0) | |
2877 | { | |
2878 | char *stub_name; | |
2879 | unsigned int len; | |
d9ad93bc | 2880 | |
24f13b03 ILT |
2881 | /* Get the name of this stub. */ |
2882 | len = strlen (sym_name); | |
2883 | len += 23; | |
d9ad93bc | 2884 | |
24f13b03 ILT |
2885 | stub_name = malloc (len); |
2886 | if (!stub_name) | |
2887 | { | |
2888 | bfd_set_error (bfd_error_no_memory); | |
d9ad93bc | 2889 | |
24f13b03 ILT |
2890 | /* Because sym_name was mallocd above for local |
2891 | symbols. */ | |
2892 | if (r_index < symtab_hdr->sh_info) | |
2893 | free (new_name); | |
d9ad93bc | 2894 | |
24f13b03 | 2895 | free (internal_relocs); |
5874427f | 2896 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2897 | if (all_local_syms[i]) |
2898 | free (all_local_syms[i]); | |
2899 | free (all_local_syms); | |
24f13b03 ILT |
2900 | goto error_return; |
2901 | } | |
2902 | elf32_hppa_name_of_stub (caller_args, callee_args, | |
2903 | location, destination, stub_name); | |
2904 | strcat (stub_name + 22, sym_name); | |
2905 | ||
2906 | /* Because sym_name was malloced above for local symbols. */ | |
2907 | if (r_index < symtab_hdr->sh_info) | |
2908 | free (new_name); | |
2909 | ||
2910 | stub_hash | |
2911 | = elf32_hppa_stub_hash_lookup (stub_hash_table, stub_name, | |
2912 | false, false); | |
2913 | if (stub_hash != NULL) | |
2914 | { | |
2915 | /* The proper stub has already been created, nothing | |
2916 | else to do. */ | |
2917 | free (stub_name); | |
2918 | } | |
2919 | else | |
2920 | { | |
2921 | bfd_set_section_size (stub_bfd, stub_sec, | |
2922 | (bfd_section_size (stub_bfd, | |
2923 | stub_sec) | |
2924 | + size_of_stub)); | |
2925 | ||
2926 | /* Enter this entry into the linker stub hash table. */ | |
2927 | stub_hash | |
2928 | = elf32_hppa_stub_hash_lookup (stub_hash_table, | |
2929 | stub_name, true, true); | |
2930 | if (stub_hash == NULL) | |
2931 | { | |
24f13b03 ILT |
2932 | free (stub_name); |
2933 | free (internal_relocs); | |
5874427f | 2934 | for (i = 0; i < bfd_count; i++) |
77712cf0 JL |
2935 | if (all_local_syms[i]) |
2936 | free (all_local_syms[i]); | |
2937 | free (all_local_syms); | |
24f13b03 ILT |
2938 | goto error_return; |
2939 | } | |
d9ad93bc | 2940 | |
24f13b03 ILT |
2941 | /* We'll need these to determine the address that the |
2942 | stub will branch to. */ | |
2943 | stub_hash->target_value = sym_value; | |
2944 | stub_hash->target_section = sym_sec; | |
2945 | } | |
2946 | free (stub_name); | |
2947 | } | |
2948 | } | |
2949 | /* We're done with the internal relocs, free them. */ | |
2950 | free (internal_relocs); | |
2951 | } | |
7218bb04 | 2952 | } |
77712cf0 JL |
2953 | /* We're done with the local symbols, free them. */ |
2954 | for (i = 0; i < bfd_count; i++) | |
2955 | if (all_local_syms[i]) | |
2956 | free (all_local_syms[i]); | |
2957 | free (all_local_syms); | |
24f13b03 | 2958 | return true; |
7218bb04 | 2959 | |
24f13b03 ILT |
2960 | error_return: |
2961 | /* Return gracefully, avoiding dangling references to the hash tables. */ | |
2962 | if (stub_hash_table) | |
d9ad93bc | 2963 | { |
24f13b03 ILT |
2964 | elf32_hppa_hash_table(link_info)->stub_hash_table = NULL; |
2965 | free (stub_hash_table); | |
d9ad93bc | 2966 | } |
24f13b03 | 2967 | if (args_hash_table) |
7218bb04 | 2968 | { |
24f13b03 ILT |
2969 | elf32_hppa_hash_table(link_info)->args_hash_table = NULL; |
2970 | free (args_hash_table); | |
7218bb04 | 2971 | } |
9fe4fade JL |
2972 | /* Set the size of the stub section to zero since we're never going |
2973 | to create them. Avoids losing when we try to get its contents | |
2974 | too. */ | |
2975 | bfd_set_section_size (stub_bfd, stub_sec, 0); | |
d9ad93bc | 2976 | return false; |
8ddd7ab3 | 2977 | } |
4c85cbfa | 2978 | |
24f13b03 ILT |
2979 | /* Misc BFD support code. */ |
2980 | #define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup | |
25057836 | 2981 | #define bfd_elf32_bfd_is_local_label hppa_elf_is_local_label |
d9ad93bc | 2982 | |
24f13b03 ILT |
2983 | /* Symbol extension stuff. */ |
2984 | #define bfd_elf32_set_section_contents elf32_hppa_set_section_contents | |
2985 | #define elf_backend_symbol_table_processing \ | |
2986 | elf32_hppa_backend_symbol_table_processing | |
459ae909 JL |
2987 | #define elf_backend_begin_write_processing \ |
2988 | elf32_hppa_backend_begin_write_processing | |
2989 | #define elf_backend_final_write_processing \ | |
2990 | elf32_hppa_backend_final_write_processing | |
e08b9ad7 | 2991 | |
24f13b03 ILT |
2992 | /* Stuff for the BFD linker. */ |
2993 | #define elf_backend_relocate_section elf32_hppa_relocate_section | |
2994 | #define elf_backend_add_symbol_hook elf32_hppa_add_symbol_hook | |
2995 | #define elf_backend_link_output_symbol_hook \ | |
2996 | elf32_hppa_link_output_symbol_hook | |
2997 | #define bfd_elf32_bfd_link_hash_table_create \ | |
2998 | elf32_hppa_link_hash_table_create | |
2999 | ||
e8f2240a | 3000 | #define TARGET_BIG_SYM bfd_elf32_hppa_vec |
8ddd7ab3 KR |
3001 | #define TARGET_BIG_NAME "elf32-hppa" |
3002 | #define ELF_ARCH bfd_arch_hppa | |
459ae909 | 3003 | #define ELF_MACHINE_CODE EM_PARISC |
3a70b01d | 3004 | #define ELF_MAXPAGESIZE 0x1000 |
8ddd7ab3 KR |
3005 | |
3006 | #include "elf32-target.h" |