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