]>
Commit | Line | Data |
---|---|---|
b352eebf | 1 | /* Support for HPPA 64-bit ELF |
4fbb74a6 | 2 | Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
5a580b3a | 3 | Free Software Foundation, Inc. |
15bda425 | 4 | |
ae9a127f | 5 | This file is part of BFD, the Binary File Descriptor library. |
15bda425 | 6 | |
ae9a127f NC |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
cd123cb7 | 9 | the Free Software Foundation; either version 3 of the License, or |
ae9a127f | 10 | (at your option) any later version. |
15bda425 | 11 | |
ae9a127f NC |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
15bda425 | 16 | |
ae9a127f NC |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
cd123cb7 NC |
19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | MA 02110-1301, USA. */ | |
15bda425 | 21 | |
15bda425 | 22 | #include "sysdep.h" |
3db64b00 | 23 | #include "bfd.h" |
15bda425 JL |
24 | #include "libbfd.h" |
25 | #include "elf-bfd.h" | |
26 | #include "elf/hppa.h" | |
27 | #include "libhppa.h" | |
28 | #include "elf64-hppa.h" | |
8bc9c892 NC |
29 | |
30 | /* This is the code recommended in the autoconf documentation, almost | |
31 | verbatim. */ | |
32 | #ifndef __GNUC__ | |
33 | # if HAVE_ALLOCA_H | |
34 | # include <alloca.h> | |
35 | # else | |
36 | # ifdef _AIX | |
37 | /* Indented so that pre-ansi C compilers will ignore it, rather than | |
38 | choke on it. Some versions of AIX require this to be the first | |
39 | thing in the file. */ | |
40 | #pragma alloca | |
41 | # else | |
42 | # ifndef alloca /* predefined by HP cc +Olibcalls */ | |
43 | # if !defined (__STDC__) && !defined (__hpux) | |
44 | extern char *alloca (); | |
45 | # else | |
46 | extern void *alloca (); | |
47 | # endif /* __STDC__, __hpux */ | |
48 | # endif /* alloca */ | |
49 | # endif /* _AIX */ | |
50 | # endif /* HAVE_ALLOCA_H */ | |
d68aa3e6 DA |
51 | #else |
52 | extern void *alloca (size_t); | |
8bc9c892 NC |
53 | #endif /* __GNUC__ */ |
54 | ||
55 | ||
15bda425 JL |
56 | #define ARCH_SIZE 64 |
57 | ||
58 | #define PLT_ENTRY_SIZE 0x10 | |
59 | #define DLT_ENTRY_SIZE 0x8 | |
60 | #define OPD_ENTRY_SIZE 0x20 | |
fe8bc63d | 61 | |
15bda425 JL |
62 | #define ELF_DYNAMIC_INTERPRETER "/usr/lib/pa20_64/dld.sl" |
63 | ||
64 | /* The stub is supposed to load the target address and target's DP | |
65 | value out of the PLT, then do an external branch to the target | |
66 | address. | |
67 | ||
68 | LDD PLTOFF(%r27),%r1 | |
69 | BVE (%r1) | |
70 | LDD PLTOFF+8(%r27),%r27 | |
71 | ||
72 | Note that we must use the LDD with a 14 bit displacement, not the one | |
73 | with a 5 bit displacement. */ | |
74 | static char plt_stub[] = {0x53, 0x61, 0x00, 0x00, 0xe8, 0x20, 0xd0, 0x00, | |
75 | 0x53, 0x7b, 0x00, 0x00 }; | |
76 | ||
77 | struct elf64_hppa_dyn_hash_entry | |
78 | { | |
79 | struct bfd_hash_entry root; | |
80 | ||
81 | /* Offsets for this symbol in various linker sections. */ | |
82 | bfd_vma dlt_offset; | |
83 | bfd_vma plt_offset; | |
84 | bfd_vma opd_offset; | |
85 | bfd_vma stub_offset; | |
86 | ||
edd21aca | 87 | /* The symbol table entry, if any, that this was derived from. */ |
15bda425 JL |
88 | struct elf_link_hash_entry *h; |
89 | ||
90 | /* The index of the (possibly local) symbol in the input bfd and its | |
91 | associated BFD. Needed so that we can have relocs against local | |
92 | symbols in shared libraries. */ | |
dc810e39 | 93 | long sym_indx; |
15bda425 JL |
94 | bfd *owner; |
95 | ||
96 | /* Dynamic symbols may need to have two different values. One for | |
97 | the dynamic symbol table, one for the normal symbol table. | |
98 | ||
99 | In such cases we store the symbol's real value and section | |
100 | index here so we can restore the real value before we write | |
101 | the normal symbol table. */ | |
102 | bfd_vma st_value; | |
103 | int st_shndx; | |
104 | ||
105 | /* Used to count non-got, non-plt relocations for delayed sizing | |
106 | of relocation sections. */ | |
107 | struct elf64_hppa_dyn_reloc_entry | |
108 | { | |
109 | /* Next relocation in the chain. */ | |
110 | struct elf64_hppa_dyn_reloc_entry *next; | |
111 | ||
112 | /* The type of the relocation. */ | |
113 | int type; | |
114 | ||
115 | /* The input section of the relocation. */ | |
116 | asection *sec; | |
117 | ||
118 | /* The index of the section symbol for the input section of | |
119 | the relocation. Only needed when building shared libraries. */ | |
120 | int sec_symndx; | |
121 | ||
122 | /* The offset within the input section of the relocation. */ | |
123 | bfd_vma offset; | |
124 | ||
125 | /* The addend for the relocation. */ | |
126 | bfd_vma addend; | |
127 | ||
128 | } *reloc_entries; | |
129 | ||
130 | /* Nonzero if this symbol needs an entry in one of the linker | |
131 | sections. */ | |
132 | unsigned want_dlt; | |
133 | unsigned want_plt; | |
134 | unsigned want_opd; | |
135 | unsigned want_stub; | |
136 | }; | |
137 | ||
138 | struct elf64_hppa_dyn_hash_table | |
139 | { | |
140 | struct bfd_hash_table root; | |
141 | }; | |
142 | ||
143 | struct elf64_hppa_link_hash_table | |
144 | { | |
145 | struct elf_link_hash_table root; | |
146 | ||
147 | /* Shortcuts to get to the various linker defined sections. */ | |
148 | asection *dlt_sec; | |
149 | asection *dlt_rel_sec; | |
150 | asection *plt_sec; | |
151 | asection *plt_rel_sec; | |
152 | asection *opd_sec; | |
153 | asection *opd_rel_sec; | |
154 | asection *other_rel_sec; | |
155 | ||
156 | /* Offset of __gp within .plt section. When the PLT gets large we want | |
157 | to slide __gp into the PLT section so that we can continue to use | |
158 | single DP relative instructions to load values out of the PLT. */ | |
159 | bfd_vma gp_offset; | |
160 | ||
161 | /* Note this is not strictly correct. We should create a stub section for | |
162 | each input section with calls. The stub section should be placed before | |
163 | the section with the call. */ | |
164 | asection *stub_sec; | |
165 | ||
166 | bfd_vma text_segment_base; | |
167 | bfd_vma data_segment_base; | |
168 | ||
169 | struct elf64_hppa_dyn_hash_table dyn_hash_table; | |
170 | ||
171 | /* We build tables to map from an input section back to its | |
172 | symbol index. This is the BFD for which we currently have | |
173 | a map. */ | |
174 | bfd *section_syms_bfd; | |
175 | ||
176 | /* Array of symbol numbers for each input section attached to the | |
177 | current BFD. */ | |
178 | int *section_syms; | |
179 | }; | |
180 | ||
181 | #define elf64_hppa_hash_table(p) \ | |
182 | ((struct elf64_hppa_link_hash_table *) ((p)->hash)) | |
183 | ||
184 | typedef struct bfd_hash_entry *(*new_hash_entry_func) | |
185 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); | |
186 | ||
15bda425 JL |
187 | static struct bfd_hash_entry *elf64_hppa_new_dyn_hash_entry |
188 | PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table, | |
189 | const char *string)); | |
190 | static struct bfd_link_hash_table *elf64_hppa_hash_table_create | |
191 | PARAMS ((bfd *abfd)); | |
192 | static struct elf64_hppa_dyn_hash_entry *elf64_hppa_dyn_hash_lookup | |
193 | PARAMS ((struct elf64_hppa_dyn_hash_table *table, const char *string, | |
b34976b6 | 194 | bfd_boolean create, bfd_boolean copy)); |
15bda425 JL |
195 | static void elf64_hppa_dyn_hash_traverse |
196 | PARAMS ((struct elf64_hppa_dyn_hash_table *table, | |
b34976b6 | 197 | bfd_boolean (*func) (struct elf64_hppa_dyn_hash_entry *, PTR), |
15bda425 JL |
198 | PTR info)); |
199 | ||
200 | static const char *get_dyn_name | |
d63b5ed9 | 201 | PARAMS ((bfd *, struct elf_link_hash_entry *, |
0ba2a60e | 202 | const Elf_Internal_Rela *, char **, size_t *)); |
15bda425 | 203 | |
15bda425 JL |
204 | /* This must follow the definitions of the various derived linker |
205 | hash tables and shared functions. */ | |
206 | #include "elf-hppa.h" | |
207 | ||
b34976b6 | 208 | static bfd_boolean elf64_hppa_object_p |
15bda425 JL |
209 | PARAMS ((bfd *)); |
210 | ||
15bda425 JL |
211 | static void elf64_hppa_post_process_headers |
212 | PARAMS ((bfd *, struct bfd_link_info *)); | |
213 | ||
b34976b6 | 214 | static bfd_boolean elf64_hppa_create_dynamic_sections |
15bda425 JL |
215 | PARAMS ((bfd *, struct bfd_link_info *)); |
216 | ||
b34976b6 | 217 | static bfd_boolean elf64_hppa_adjust_dynamic_symbol |
15bda425 JL |
218 | PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); |
219 | ||
b34976b6 | 220 | static bfd_boolean elf64_hppa_mark_milli_and_exported_functions |
47b7c2db AM |
221 | PARAMS ((struct elf_link_hash_entry *, PTR)); |
222 | ||
b34976b6 | 223 | static bfd_boolean elf64_hppa_size_dynamic_sections |
15bda425 JL |
224 | PARAMS ((bfd *, struct bfd_link_info *)); |
225 | ||
b34976b6 | 226 | static bfd_boolean elf64_hppa_link_output_symbol_hook |
754021d0 AM |
227 | PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *, |
228 | asection *, struct elf_link_hash_entry *)); | |
99c79b2e | 229 | |
b34976b6 | 230 | static bfd_boolean elf64_hppa_finish_dynamic_symbol |
15bda425 JL |
231 | PARAMS ((bfd *, struct bfd_link_info *, |
232 | struct elf_link_hash_entry *, Elf_Internal_Sym *)); | |
fe8bc63d | 233 | |
5ac81c74 JL |
234 | static enum elf_reloc_type_class elf64_hppa_reloc_type_class |
235 | PARAMS ((const Elf_Internal_Rela *)); | |
236 | ||
b34976b6 | 237 | static bfd_boolean elf64_hppa_finish_dynamic_sections |
15bda425 JL |
238 | PARAMS ((bfd *, struct bfd_link_info *)); |
239 | ||
b34976b6 | 240 | static bfd_boolean elf64_hppa_check_relocs |
15bda425 JL |
241 | PARAMS ((bfd *, struct bfd_link_info *, |
242 | asection *, const Elf_Internal_Rela *)); | |
243 | ||
b34976b6 | 244 | static bfd_boolean elf64_hppa_dynamic_symbol_p |
15bda425 JL |
245 | PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *)); |
246 | ||
b34976b6 | 247 | static bfd_boolean elf64_hppa_mark_exported_functions |
15bda425 JL |
248 | PARAMS ((struct elf_link_hash_entry *, PTR)); |
249 | ||
b34976b6 | 250 | static bfd_boolean elf64_hppa_finalize_opd |
15bda425 JL |
251 | PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); |
252 | ||
b34976b6 | 253 | static bfd_boolean elf64_hppa_finalize_dlt |
15bda425 JL |
254 | PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); |
255 | ||
b34976b6 | 256 | static bfd_boolean allocate_global_data_dlt |
15bda425 JL |
257 | PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); |
258 | ||
b34976b6 | 259 | static bfd_boolean allocate_global_data_plt |
15bda425 JL |
260 | PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); |
261 | ||
b34976b6 | 262 | static bfd_boolean allocate_global_data_stub |
15bda425 JL |
263 | PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); |
264 | ||
b34976b6 | 265 | static bfd_boolean allocate_global_data_opd |
15bda425 JL |
266 | PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); |
267 | ||
b34976b6 | 268 | static bfd_boolean get_reloc_section |
15bda425 JL |
269 | PARAMS ((bfd *, struct elf64_hppa_link_hash_table *, asection *)); |
270 | ||
b34976b6 | 271 | static bfd_boolean count_dyn_reloc |
15bda425 JL |
272 | PARAMS ((bfd *, struct elf64_hppa_dyn_hash_entry *, |
273 | int, asection *, int, bfd_vma, bfd_vma)); | |
274 | ||
b34976b6 | 275 | static bfd_boolean allocate_dynrel_entries |
15bda425 JL |
276 | PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); |
277 | ||
b34976b6 | 278 | static bfd_boolean elf64_hppa_finalize_dynreloc |
15bda425 JL |
279 | PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); |
280 | ||
b34976b6 | 281 | static bfd_boolean get_opd |
15bda425 JL |
282 | PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *)); |
283 | ||
b34976b6 | 284 | static bfd_boolean get_plt |
15bda425 JL |
285 | PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *)); |
286 | ||
b34976b6 | 287 | static bfd_boolean get_dlt |
15bda425 JL |
288 | PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *)); |
289 | ||
b34976b6 | 290 | static bfd_boolean get_stub |
15bda425 JL |
291 | PARAMS ((bfd *, struct bfd_link_info *, struct elf64_hppa_link_hash_table *)); |
292 | ||
3fab46d0 AM |
293 | static int elf64_hppa_elf_get_symbol_type |
294 | PARAMS ((Elf_Internal_Sym *, int)); | |
295 | ||
b34976b6 | 296 | static bfd_boolean |
66eb6687 AM |
297 | elf64_hppa_dyn_hash_table_init (struct elf64_hppa_dyn_hash_table *ht, |
298 | bfd *abfd ATTRIBUTE_UNUSED, | |
299 | new_hash_entry_func new, | |
300 | unsigned int entsize) | |
15bda425 | 301 | { |
fe8bc63d | 302 | memset (ht, 0, sizeof (*ht)); |
66eb6687 | 303 | return bfd_hash_table_init (&ht->root, new, entsize); |
15bda425 JL |
304 | } |
305 | ||
306 | static struct bfd_hash_entry* | |
307 | elf64_hppa_new_dyn_hash_entry (entry, table, string) | |
308 | struct bfd_hash_entry *entry; | |
309 | struct bfd_hash_table *table; | |
310 | const char *string; | |
311 | { | |
312 | struct elf64_hppa_dyn_hash_entry *ret; | |
313 | ret = (struct elf64_hppa_dyn_hash_entry *) entry; | |
314 | ||
315 | /* Allocate the structure if it has not already been allocated by a | |
316 | subclass. */ | |
317 | if (!ret) | |
318 | ret = bfd_hash_allocate (table, sizeof (*ret)); | |
319 | ||
320 | if (!ret) | |
321 | return 0; | |
322 | ||
15bda425 JL |
323 | /* Call the allocation method of the superclass. */ |
324 | ret = ((struct elf64_hppa_dyn_hash_entry *) | |
325 | bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); | |
326 | ||
336549c1 AM |
327 | /* Initialize our local data. All zeros. */ |
328 | memset (&ret->dlt_offset, 0, | |
329 | (sizeof (struct elf64_hppa_dyn_hash_entry) | |
330 | - offsetof (struct elf64_hppa_dyn_hash_entry, dlt_offset))); | |
331 | ||
15bda425 JL |
332 | return &ret->root; |
333 | } | |
334 | ||
335 | /* Create the derived linker hash table. The PA64 ELF port uses this | |
336 | derived hash table to keep information specific to the PA ElF | |
337 | linker (without using static variables). */ | |
338 | ||
339 | static struct bfd_link_hash_table* | |
340 | elf64_hppa_hash_table_create (abfd) | |
341 | bfd *abfd; | |
342 | { | |
343 | struct elf64_hppa_link_hash_table *ret; | |
344 | ||
dc810e39 | 345 | ret = bfd_zalloc (abfd, (bfd_size_type) sizeof (*ret)); |
15bda425 JL |
346 | if (!ret) |
347 | return 0; | |
348 | if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, | |
66eb6687 AM |
349 | _bfd_elf_link_hash_newfunc, |
350 | sizeof (struct elf_link_hash_entry))) | |
15bda425 JL |
351 | { |
352 | bfd_release (abfd, ret); | |
353 | return 0; | |
354 | } | |
355 | ||
356 | if (!elf64_hppa_dyn_hash_table_init (&ret->dyn_hash_table, abfd, | |
66eb6687 AM |
357 | elf64_hppa_new_dyn_hash_entry, |
358 | sizeof (struct elf64_hppa_dyn_hash_entry))) | |
15bda425 JL |
359 | return 0; |
360 | return &ret->root.root; | |
361 | } | |
362 | ||
363 | /* Look up an entry in a PA64 ELF linker hash table. */ | |
364 | ||
365 | static struct elf64_hppa_dyn_hash_entry * | |
366 | elf64_hppa_dyn_hash_lookup(table, string, create, copy) | |
367 | struct elf64_hppa_dyn_hash_table *table; | |
368 | const char *string; | |
b34976b6 | 369 | bfd_boolean create, copy; |
15bda425 JL |
370 | { |
371 | return ((struct elf64_hppa_dyn_hash_entry *) | |
372 | bfd_hash_lookup (&table->root, string, create, copy)); | |
373 | } | |
374 | ||
375 | /* Traverse a PA64 ELF linker hash table. */ | |
376 | ||
377 | static void | |
378 | elf64_hppa_dyn_hash_traverse (table, func, info) | |
379 | struct elf64_hppa_dyn_hash_table *table; | |
b34976b6 | 380 | bfd_boolean (*func) PARAMS ((struct elf64_hppa_dyn_hash_entry *, PTR)); |
15bda425 JL |
381 | PTR info; |
382 | { | |
383 | (bfd_hash_traverse | |
384 | (&table->root, | |
b34976b6 | 385 | (bfd_boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) func, |
15bda425 JL |
386 | info)); |
387 | } | |
388 | \f | |
389 | /* Return nonzero if ABFD represents a PA2.0 ELF64 file. | |
390 | ||
391 | Additionally we set the default architecture and machine. */ | |
b34976b6 | 392 | static bfd_boolean |
15bda425 JL |
393 | elf64_hppa_object_p (abfd) |
394 | bfd *abfd; | |
395 | { | |
24a5e751 L |
396 | Elf_Internal_Ehdr * i_ehdrp; |
397 | unsigned int flags; | |
d9634ba1 | 398 | |
24a5e751 L |
399 | i_ehdrp = elf_elfheader (abfd); |
400 | if (strcmp (bfd_get_target (abfd), "elf64-hppa-linux") == 0) | |
401 | { | |
6c21aa76 NC |
402 | /* GCC on hppa-linux produces binaries with OSABI=Linux, |
403 | but the kernel produces corefiles with OSABI=SysV. */ | |
d97a8924 DA |
404 | if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX |
405 | && i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */ | |
b34976b6 | 406 | return FALSE; |
24a5e751 L |
407 | } |
408 | else | |
409 | { | |
d97a8924 DA |
410 | /* HPUX produces binaries with OSABI=HPUX, |
411 | but the kernel produces corefiles with OSABI=SysV. */ | |
412 | if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX | |
413 | && i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */ | |
b34976b6 | 414 | return FALSE; |
24a5e751 L |
415 | } |
416 | ||
417 | flags = i_ehdrp->e_flags; | |
d9634ba1 AM |
418 | switch (flags & (EF_PARISC_ARCH | EF_PARISC_WIDE)) |
419 | { | |
420 | case EFA_PARISC_1_0: | |
421 | return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 10); | |
422 | case EFA_PARISC_1_1: | |
423 | return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 11); | |
424 | case EFA_PARISC_2_0: | |
d97a8924 DA |
425 | if (i_ehdrp->e_ident[EI_CLASS] == ELFCLASS64) |
426 | return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 25); | |
427 | else | |
428 | return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 20); | |
d9634ba1 AM |
429 | case EFA_PARISC_2_0 | EF_PARISC_WIDE: |
430 | return bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 25); | |
431 | } | |
432 | /* Don't be fussy. */ | |
b34976b6 | 433 | return TRUE; |
15bda425 JL |
434 | } |
435 | ||
436 | /* Given section type (hdr->sh_type), return a boolean indicating | |
437 | whether or not the section is an elf64-hppa specific section. */ | |
b34976b6 | 438 | static bfd_boolean |
6dc132d9 L |
439 | elf64_hppa_section_from_shdr (bfd *abfd, |
440 | Elf_Internal_Shdr *hdr, | |
441 | const char *name, | |
442 | int shindex) | |
15bda425 JL |
443 | { |
444 | asection *newsect; | |
445 | ||
446 | switch (hdr->sh_type) | |
447 | { | |
448 | case SHT_PARISC_EXT: | |
449 | if (strcmp (name, ".PARISC.archext") != 0) | |
b34976b6 | 450 | return FALSE; |
15bda425 JL |
451 | break; |
452 | case SHT_PARISC_UNWIND: | |
453 | if (strcmp (name, ".PARISC.unwind") != 0) | |
b34976b6 | 454 | return FALSE; |
15bda425 JL |
455 | break; |
456 | case SHT_PARISC_DOC: | |
457 | case SHT_PARISC_ANNOT: | |
458 | default: | |
b34976b6 | 459 | return FALSE; |
15bda425 JL |
460 | } |
461 | ||
6dc132d9 | 462 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) |
b34976b6 | 463 | return FALSE; |
15bda425 JL |
464 | newsect = hdr->bfd_section; |
465 | ||
b34976b6 | 466 | return TRUE; |
15bda425 JL |
467 | } |
468 | ||
15bda425 | 469 | /* Construct a string for use in the elf64_hppa_dyn_hash_table. The |
fe8bc63d | 470 | name describes what was once potentially anonymous memory. We |
15bda425 JL |
471 | allocate memory as necessary, possibly reusing PBUF/PLEN. */ |
472 | ||
473 | static const char * | |
d63b5ed9 DA |
474 | get_dyn_name (abfd, h, rel, pbuf, plen) |
475 | bfd *abfd; | |
15bda425 JL |
476 | struct elf_link_hash_entry *h; |
477 | const Elf_Internal_Rela *rel; | |
478 | char **pbuf; | |
479 | size_t *plen; | |
480 | { | |
d63b5ed9 | 481 | asection *sec = abfd->sections; |
15bda425 JL |
482 | size_t nlen, tlen; |
483 | char *buf; | |
484 | size_t len; | |
485 | ||
486 | if (h && rel->r_addend == 0) | |
487 | return h->root.root.string; | |
488 | ||
489 | if (h) | |
490 | nlen = strlen (h->root.root.string); | |
491 | else | |
0ba2a60e AM |
492 | nlen = 8 + 1 + sizeof (rel->r_info) * 2 - 8; |
493 | tlen = nlen + 1 + sizeof (rel->r_addend) * 2 + 1; | |
15bda425 JL |
494 | |
495 | len = *plen; | |
496 | buf = *pbuf; | |
497 | if (len < tlen) | |
498 | { | |
499 | if (buf) | |
500 | free (buf); | |
501 | *pbuf = buf = malloc (tlen); | |
502 | *plen = len = tlen; | |
503 | if (!buf) | |
504 | return NULL; | |
505 | } | |
506 | ||
507 | if (h) | |
508 | { | |
509 | memcpy (buf, h->root.root.string, nlen); | |
0ba2a60e | 510 | buf[nlen++] = '+'; |
15bda425 JL |
511 | sprintf_vma (buf + nlen, rel->r_addend); |
512 | } | |
513 | else | |
514 | { | |
0ba2a60e AM |
515 | nlen = sprintf (buf, "%x:%lx", |
516 | sec->id & 0xffffffff, | |
517 | (long) ELF64_R_SYM (rel->r_info)); | |
15bda425 JL |
518 | if (rel->r_addend) |
519 | { | |
520 | buf[nlen++] = '+'; | |
521 | sprintf_vma (buf + nlen, rel->r_addend); | |
522 | } | |
523 | } | |
524 | ||
525 | return buf; | |
526 | } | |
527 | ||
528 | /* SEC is a section containing relocs for an input BFD when linking; return | |
529 | a suitable section for holding relocs in the output BFD for a link. */ | |
530 | ||
b34976b6 | 531 | static bfd_boolean |
15bda425 JL |
532 | get_reloc_section (abfd, hppa_info, sec) |
533 | bfd *abfd; | |
534 | struct elf64_hppa_link_hash_table *hppa_info; | |
535 | asection *sec; | |
536 | { | |
537 | const char *srel_name; | |
538 | asection *srel; | |
539 | bfd *dynobj; | |
540 | ||
541 | srel_name = (bfd_elf_string_from_elf_section | |
542 | (abfd, elf_elfheader(abfd)->e_shstrndx, | |
543 | elf_section_data(sec)->rel_hdr.sh_name)); | |
544 | if (srel_name == NULL) | |
b34976b6 | 545 | return FALSE; |
15bda425 | 546 | |
0112cd26 | 547 | BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela") |
15bda425 | 548 | && strcmp (bfd_get_section_name (abfd, sec), |
0112cd26 NC |
549 | srel_name + 5) == 0) |
550 | || (CONST_STRNEQ (srel_name, ".rel") | |
15bda425 | 551 | && strcmp (bfd_get_section_name (abfd, sec), |
0112cd26 | 552 | srel_name + 4) == 0)); |
15bda425 JL |
553 | |
554 | dynobj = hppa_info->root.dynobj; | |
555 | if (!dynobj) | |
556 | hppa_info->root.dynobj = dynobj = abfd; | |
557 | ||
558 | srel = bfd_get_section_by_name (dynobj, srel_name); | |
559 | if (srel == NULL) | |
560 | { | |
3496cb2a L |
561 | srel = bfd_make_section_with_flags (dynobj, srel_name, |
562 | (SEC_ALLOC | |
563 | | SEC_LOAD | |
564 | | SEC_HAS_CONTENTS | |
565 | | SEC_IN_MEMORY | |
566 | | SEC_LINKER_CREATED | |
567 | | SEC_READONLY)); | |
15bda425 | 568 | if (srel == NULL |
15bda425 | 569 | || !bfd_set_section_alignment (dynobj, srel, 3)) |
b34976b6 | 570 | return FALSE; |
15bda425 JL |
571 | } |
572 | ||
573 | hppa_info->other_rel_sec = srel; | |
b34976b6 | 574 | return TRUE; |
15bda425 JL |
575 | } |
576 | ||
fe8bc63d | 577 | /* Add a new entry to the list of dynamic relocations against DYN_H. |
15bda425 JL |
578 | |
579 | We use this to keep a record of all the FPTR relocations against a | |
580 | particular symbol so that we can create FPTR relocations in the | |
581 | output file. */ | |
582 | ||
b34976b6 | 583 | static bfd_boolean |
15bda425 JL |
584 | count_dyn_reloc (abfd, dyn_h, type, sec, sec_symndx, offset, addend) |
585 | bfd *abfd; | |
586 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
587 | int type; | |
588 | asection *sec; | |
589 | int sec_symndx; | |
590 | bfd_vma offset; | |
591 | bfd_vma addend; | |
592 | { | |
593 | struct elf64_hppa_dyn_reloc_entry *rent; | |
594 | ||
595 | rent = (struct elf64_hppa_dyn_reloc_entry *) | |
dc810e39 | 596 | bfd_alloc (abfd, (bfd_size_type) sizeof (*rent)); |
15bda425 | 597 | if (!rent) |
b34976b6 | 598 | return FALSE; |
15bda425 JL |
599 | |
600 | rent->next = dyn_h->reloc_entries; | |
601 | rent->type = type; | |
602 | rent->sec = sec; | |
603 | rent->sec_symndx = sec_symndx; | |
604 | rent->offset = offset; | |
605 | rent->addend = addend; | |
606 | dyn_h->reloc_entries = rent; | |
607 | ||
b34976b6 | 608 | return TRUE; |
15bda425 JL |
609 | } |
610 | ||
611 | /* Scan the RELOCS and record the type of dynamic entries that each | |
612 | referenced symbol needs. */ | |
613 | ||
b34976b6 | 614 | static bfd_boolean |
15bda425 JL |
615 | elf64_hppa_check_relocs (abfd, info, sec, relocs) |
616 | bfd *abfd; | |
617 | struct bfd_link_info *info; | |
618 | asection *sec; | |
619 | const Elf_Internal_Rela *relocs; | |
620 | { | |
621 | struct elf64_hppa_link_hash_table *hppa_info; | |
622 | const Elf_Internal_Rela *relend; | |
623 | Elf_Internal_Shdr *symtab_hdr; | |
624 | const Elf_Internal_Rela *rel; | |
625 | asection *dlt, *plt, *stubs; | |
626 | char *buf; | |
627 | size_t buf_len; | |
4fbb74a6 | 628 | unsigned int sec_symndx; |
15bda425 | 629 | |
1049f94e | 630 | if (info->relocatable) |
b34976b6 | 631 | return TRUE; |
15bda425 JL |
632 | |
633 | /* If this is the first dynamic object found in the link, create | |
634 | the special sections required for dynamic linking. */ | |
635 | if (! elf_hash_table (info)->dynamic_sections_created) | |
636 | { | |
45d6a902 | 637 | if (! _bfd_elf_link_create_dynamic_sections (abfd, info)) |
b34976b6 | 638 | return FALSE; |
15bda425 JL |
639 | } |
640 | ||
641 | hppa_info = elf64_hppa_hash_table (info); | |
642 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; | |
643 | ||
644 | /* If necessary, build a new table holding section symbols indices | |
6cdc0ccc | 645 | for this BFD. */ |
fe8bc63d | 646 | |
15bda425 JL |
647 | if (info->shared && hppa_info->section_syms_bfd != abfd) |
648 | { | |
832d951b | 649 | unsigned long i; |
9ad5cbcf | 650 | unsigned int highest_shndx; |
6cdc0ccc AM |
651 | Elf_Internal_Sym *local_syms = NULL; |
652 | Elf_Internal_Sym *isym, *isymend; | |
dc810e39 | 653 | bfd_size_type amt; |
15bda425 JL |
654 | |
655 | /* We're done with the old cache of section index to section symbol | |
656 | index information. Free it. | |
657 | ||
658 | ?!? Note we leak the last section_syms array. Presumably we | |
659 | could free it in one of the later routines in this file. */ | |
660 | if (hppa_info->section_syms) | |
661 | free (hppa_info->section_syms); | |
662 | ||
6cdc0ccc AM |
663 | /* Read this BFD's local symbols. */ |
664 | if (symtab_hdr->sh_info != 0) | |
47b7c2db | 665 | { |
6cdc0ccc AM |
666 | local_syms = (Elf_Internal_Sym *) symtab_hdr->contents; |
667 | if (local_syms == NULL) | |
668 | local_syms = bfd_elf_get_elf_syms (abfd, symtab_hdr, | |
669 | symtab_hdr->sh_info, 0, | |
670 | NULL, NULL, NULL); | |
671 | if (local_syms == NULL) | |
b34976b6 | 672 | return FALSE; |
9ad5cbcf AM |
673 | } |
674 | ||
6cdc0ccc | 675 | /* Record the highest section index referenced by the local symbols. */ |
15bda425 | 676 | highest_shndx = 0; |
6cdc0ccc AM |
677 | isymend = local_syms + symtab_hdr->sh_info; |
678 | for (isym = local_syms; isym < isymend; isym++) | |
15bda425 | 679 | { |
4fbb74a6 AM |
680 | if (isym->st_shndx > highest_shndx |
681 | && isym->st_shndx < SHN_LORESERVE) | |
15bda425 JL |
682 | highest_shndx = isym->st_shndx; |
683 | } | |
684 | ||
15bda425 JL |
685 | /* Allocate an array to hold the section index to section symbol index |
686 | mapping. Bump by one since we start counting at zero. */ | |
687 | highest_shndx++; | |
dc810e39 AM |
688 | amt = highest_shndx; |
689 | amt *= sizeof (int); | |
690 | hppa_info->section_syms = (int *) bfd_malloc (amt); | |
15bda425 JL |
691 | |
692 | /* Now walk the local symbols again. If we find a section symbol, | |
693 | record the index of the symbol into the section_syms array. */ | |
6cdc0ccc | 694 | for (i = 0, isym = local_syms; isym < isymend; i++, isym++) |
15bda425 JL |
695 | { |
696 | if (ELF_ST_TYPE (isym->st_info) == STT_SECTION) | |
697 | hppa_info->section_syms[isym->st_shndx] = i; | |
698 | } | |
699 | ||
6cdc0ccc AM |
700 | /* We are finished with the local symbols. */ |
701 | if (local_syms != NULL | |
702 | && symtab_hdr->contents != (unsigned char *) local_syms) | |
703 | { | |
704 | if (! info->keep_memory) | |
705 | free (local_syms); | |
706 | else | |
707 | { | |
708 | /* Cache the symbols for elf_link_input_bfd. */ | |
709 | symtab_hdr->contents = (unsigned char *) local_syms; | |
710 | } | |
711 | } | |
15bda425 JL |
712 | |
713 | /* Record which BFD we built the section_syms mapping for. */ | |
714 | hppa_info->section_syms_bfd = abfd; | |
715 | } | |
716 | ||
717 | /* Record the symbol index for this input section. We may need it for | |
718 | relocations when building shared libraries. When not building shared | |
719 | libraries this value is never really used, but assign it to zero to | |
720 | prevent out of bounds memory accesses in other routines. */ | |
721 | if (info->shared) | |
722 | { | |
723 | sec_symndx = _bfd_elf_section_from_bfd_section (abfd, sec); | |
724 | ||
725 | /* If we did not find a section symbol for this section, then | |
726 | something went terribly wrong above. */ | |
4fbb74a6 | 727 | if (sec_symndx == SHN_BAD) |
b34976b6 | 728 | return FALSE; |
15bda425 | 729 | |
4fbb74a6 AM |
730 | if (sec_symndx < SHN_LORESERVE) |
731 | sec_symndx = hppa_info->section_syms[sec_symndx]; | |
732 | else | |
733 | sec_symndx = 0; | |
15bda425 JL |
734 | } |
735 | else | |
736 | sec_symndx = 0; | |
fe8bc63d | 737 | |
15bda425 JL |
738 | dlt = plt = stubs = NULL; |
739 | buf = NULL; | |
740 | buf_len = 0; | |
741 | ||
742 | relend = relocs + sec->reloc_count; | |
743 | for (rel = relocs; rel < relend; ++rel) | |
744 | { | |
560e09e9 NC |
745 | enum |
746 | { | |
747 | NEED_DLT = 1, | |
748 | NEED_PLT = 2, | |
749 | NEED_STUB = 4, | |
750 | NEED_OPD = 8, | |
751 | NEED_DYNREL = 16, | |
752 | }; | |
15bda425 JL |
753 | |
754 | struct elf_link_hash_entry *h = NULL; | |
755 | unsigned long r_symndx = ELF64_R_SYM (rel->r_info); | |
756 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
757 | int need_entry; | |
758 | const char *addr_name; | |
b34976b6 | 759 | bfd_boolean maybe_dynamic; |
15bda425 JL |
760 | int dynrel_type = R_PARISC_NONE; |
761 | static reloc_howto_type *howto; | |
762 | ||
763 | if (r_symndx >= symtab_hdr->sh_info) | |
764 | { | |
765 | /* We're dealing with a global symbol -- find its hash entry | |
766 | and mark it as being referenced. */ | |
767 | long indx = r_symndx - symtab_hdr->sh_info; | |
768 | h = elf_sym_hashes (abfd)[indx]; | |
769 | while (h->root.type == bfd_link_hash_indirect | |
770 | || h->root.type == bfd_link_hash_warning) | |
771 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
772 | ||
f5385ebf | 773 | h->ref_regular = 1; |
15bda425 JL |
774 | } |
775 | ||
776 | /* We can only get preliminary data on whether a symbol is | |
777 | locally or externally defined, as not all of the input files | |
778 | have yet been processed. Do something with what we know, as | |
779 | this may help reduce memory usage and processing time later. */ | |
b34976b6 | 780 | maybe_dynamic = FALSE; |
671bae9c | 781 | if (h && ((info->shared |
f5385ebf AM |
782 | && (!info->symbolic |
783 | || info->unresolved_syms_in_shared_libs == RM_IGNORE)) | |
784 | || !h->def_regular | |
15bda425 | 785 | || h->root.type == bfd_link_hash_defweak)) |
b34976b6 | 786 | maybe_dynamic = TRUE; |
15bda425 JL |
787 | |
788 | howto = elf_hppa_howto_table + ELF64_R_TYPE (rel->r_info); | |
789 | need_entry = 0; | |
790 | switch (howto->type) | |
791 | { | |
792 | /* These are simple indirect references to symbols through the | |
793 | DLT. We need to create a DLT entry for any symbols which | |
794 | appears in a DLTIND relocation. */ | |
795 | case R_PARISC_DLTIND21L: | |
796 | case R_PARISC_DLTIND14R: | |
797 | case R_PARISC_DLTIND14F: | |
798 | case R_PARISC_DLTIND14WR: | |
799 | case R_PARISC_DLTIND14DR: | |
800 | need_entry = NEED_DLT; | |
801 | break; | |
802 | ||
803 | /* ?!? These need a DLT entry. But I have no idea what to do with | |
804 | the "link time TP value. */ | |
805 | case R_PARISC_LTOFF_TP21L: | |
806 | case R_PARISC_LTOFF_TP14R: | |
807 | case R_PARISC_LTOFF_TP14F: | |
808 | case R_PARISC_LTOFF_TP64: | |
809 | case R_PARISC_LTOFF_TP14WR: | |
810 | case R_PARISC_LTOFF_TP14DR: | |
811 | case R_PARISC_LTOFF_TP16F: | |
812 | case R_PARISC_LTOFF_TP16WF: | |
813 | case R_PARISC_LTOFF_TP16DF: | |
814 | need_entry = NEED_DLT; | |
815 | break; | |
816 | ||
817 | /* These are function calls. Depending on their precise target we | |
818 | may need to make a stub for them. The stub uses the PLT, so we | |
819 | need to create PLT entries for these symbols too. */ | |
832d951b | 820 | case R_PARISC_PCREL12F: |
15bda425 JL |
821 | case R_PARISC_PCREL17F: |
822 | case R_PARISC_PCREL22F: | |
823 | case R_PARISC_PCREL32: | |
824 | case R_PARISC_PCREL64: | |
825 | case R_PARISC_PCREL21L: | |
826 | case R_PARISC_PCREL17R: | |
827 | case R_PARISC_PCREL17C: | |
828 | case R_PARISC_PCREL14R: | |
829 | case R_PARISC_PCREL14F: | |
830 | case R_PARISC_PCREL22C: | |
831 | case R_PARISC_PCREL14WR: | |
832 | case R_PARISC_PCREL14DR: | |
833 | case R_PARISC_PCREL16F: | |
834 | case R_PARISC_PCREL16WF: | |
835 | case R_PARISC_PCREL16DF: | |
836 | need_entry = (NEED_PLT | NEED_STUB); | |
837 | break; | |
838 | ||
839 | case R_PARISC_PLTOFF21L: | |
840 | case R_PARISC_PLTOFF14R: | |
841 | case R_PARISC_PLTOFF14F: | |
842 | case R_PARISC_PLTOFF14WR: | |
843 | case R_PARISC_PLTOFF14DR: | |
844 | case R_PARISC_PLTOFF16F: | |
845 | case R_PARISC_PLTOFF16WF: | |
846 | case R_PARISC_PLTOFF16DF: | |
847 | need_entry = (NEED_PLT); | |
848 | break; | |
849 | ||
850 | case R_PARISC_DIR64: | |
851 | if (info->shared || maybe_dynamic) | |
852 | need_entry = (NEED_DYNREL); | |
853 | dynrel_type = R_PARISC_DIR64; | |
854 | break; | |
855 | ||
856 | /* This is an indirect reference through the DLT to get the address | |
857 | of a OPD descriptor. Thus we need to make a DLT entry that points | |
858 | to an OPD entry. */ | |
859 | case R_PARISC_LTOFF_FPTR21L: | |
860 | case R_PARISC_LTOFF_FPTR14R: | |
861 | case R_PARISC_LTOFF_FPTR14WR: | |
862 | case R_PARISC_LTOFF_FPTR14DR: | |
863 | case R_PARISC_LTOFF_FPTR32: | |
864 | case R_PARISC_LTOFF_FPTR64: | |
865 | case R_PARISC_LTOFF_FPTR16F: | |
866 | case R_PARISC_LTOFF_FPTR16WF: | |
867 | case R_PARISC_LTOFF_FPTR16DF: | |
868 | if (info->shared || maybe_dynamic) | |
869 | need_entry = (NEED_DLT | NEED_OPD); | |
870 | else | |
871 | need_entry = (NEED_DLT | NEED_OPD); | |
872 | dynrel_type = R_PARISC_FPTR64; | |
873 | break; | |
874 | ||
875 | /* This is a simple OPD entry. */ | |
876 | case R_PARISC_FPTR64: | |
877 | if (info->shared || maybe_dynamic) | |
878 | need_entry = (NEED_OPD | NEED_DYNREL); | |
879 | else | |
880 | need_entry = (NEED_OPD); | |
881 | dynrel_type = R_PARISC_FPTR64; | |
882 | break; | |
883 | ||
884 | /* Add more cases as needed. */ | |
885 | } | |
886 | ||
887 | if (!need_entry) | |
888 | continue; | |
889 | ||
890 | /* Collect a canonical name for this address. */ | |
d63b5ed9 | 891 | addr_name = get_dyn_name (abfd, h, rel, &buf, &buf_len); |
15bda425 JL |
892 | |
893 | /* Collect the canonical entry data for this address. */ | |
894 | dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, | |
b34976b6 | 895 | addr_name, TRUE, TRUE); |
15bda425 JL |
896 | BFD_ASSERT (dyn_h); |
897 | ||
898 | /* Stash away enough information to be able to find this symbol | |
899 | regardless of whether or not it is local or global. */ | |
900 | dyn_h->h = h; | |
901 | dyn_h->owner = abfd; | |
902 | dyn_h->sym_indx = r_symndx; | |
903 | ||
904 | /* ?!? We may need to do some error checking in here. */ | |
905 | /* Create what's needed. */ | |
906 | if (need_entry & NEED_DLT) | |
907 | { | |
908 | if (! hppa_info->dlt_sec | |
909 | && ! get_dlt (abfd, info, hppa_info)) | |
910 | goto err_out; | |
911 | dyn_h->want_dlt = 1; | |
912 | } | |
913 | ||
914 | if (need_entry & NEED_PLT) | |
915 | { | |
916 | if (! hppa_info->plt_sec | |
917 | && ! get_plt (abfd, info, hppa_info)) | |
918 | goto err_out; | |
919 | dyn_h->want_plt = 1; | |
920 | } | |
921 | ||
922 | if (need_entry & NEED_STUB) | |
923 | { | |
924 | if (! hppa_info->stub_sec | |
925 | && ! get_stub (abfd, info, hppa_info)) | |
926 | goto err_out; | |
927 | dyn_h->want_stub = 1; | |
928 | } | |
929 | ||
930 | if (need_entry & NEED_OPD) | |
931 | { | |
932 | if (! hppa_info->opd_sec | |
933 | && ! get_opd (abfd, info, hppa_info)) | |
934 | goto err_out; | |
935 | ||
936 | dyn_h->want_opd = 1; | |
937 | ||
938 | /* FPTRs are not allocated by the dynamic linker for PA64, though | |
939 | it is possible that will change in the future. */ | |
fe8bc63d | 940 | |
15bda425 JL |
941 | /* This could be a local function that had its address taken, in |
942 | which case H will be NULL. */ | |
943 | if (h) | |
f5385ebf | 944 | h->needs_plt = 1; |
15bda425 JL |
945 | } |
946 | ||
947 | /* Add a new dynamic relocation to the chain of dynamic | |
948 | relocations for this symbol. */ | |
949 | if ((need_entry & NEED_DYNREL) && (sec->flags & SEC_ALLOC)) | |
950 | { | |
951 | if (! hppa_info->other_rel_sec | |
952 | && ! get_reloc_section (abfd, hppa_info, sec)) | |
953 | goto err_out; | |
954 | ||
955 | if (!count_dyn_reloc (abfd, dyn_h, dynrel_type, sec, | |
956 | sec_symndx, rel->r_offset, rel->r_addend)) | |
957 | goto err_out; | |
958 | ||
959 | /* If we are building a shared library and we just recorded | |
960 | a dynamic R_PARISC_FPTR64 relocation, then make sure the | |
961 | section symbol for this section ends up in the dynamic | |
962 | symbol table. */ | |
963 | if (info->shared && dynrel_type == R_PARISC_FPTR64 | |
c152c796 | 964 | && ! (bfd_elf_link_record_local_dynamic_symbol |
15bda425 | 965 | (info, abfd, sec_symndx))) |
b34976b6 | 966 | return FALSE; |
15bda425 JL |
967 | } |
968 | } | |
969 | ||
970 | if (buf) | |
971 | free (buf); | |
b34976b6 | 972 | return TRUE; |
15bda425 JL |
973 | |
974 | err_out: | |
975 | if (buf) | |
976 | free (buf); | |
b34976b6 | 977 | return FALSE; |
15bda425 JL |
978 | } |
979 | ||
980 | struct elf64_hppa_allocate_data | |
981 | { | |
982 | struct bfd_link_info *info; | |
983 | bfd_size_type ofs; | |
984 | }; | |
985 | ||
986 | /* Should we do dynamic things to this symbol? */ | |
987 | ||
b34976b6 | 988 | static bfd_boolean |
15bda425 JL |
989 | elf64_hppa_dynamic_symbol_p (h, info) |
990 | struct elf_link_hash_entry *h; | |
991 | struct bfd_link_info *info; | |
992 | { | |
986a241f RH |
993 | /* ??? What, if anything, needs to happen wrt STV_PROTECTED symbols |
994 | and relocations that retrieve a function descriptor? Assume the | |
995 | worst for now. */ | |
996 | if (_bfd_elf_dynamic_symbol_p (h, info, 1)) | |
997 | { | |
998 | /* ??? Why is this here and not elsewhere is_local_label_name. */ | |
999 | if (h->root.root.string[0] == '$' && h->root.root.string[1] == '$') | |
1000 | return FALSE; | |
15bda425 | 1001 | |
986a241f RH |
1002 | return TRUE; |
1003 | } | |
1004 | else | |
b34976b6 | 1005 | return FALSE; |
15bda425 JL |
1006 | } |
1007 | ||
4cc11e76 | 1008 | /* Mark all functions exported by this file so that we can later allocate |
15bda425 JL |
1009 | entries in .opd for them. */ |
1010 | ||
b34976b6 | 1011 | static bfd_boolean |
15bda425 JL |
1012 | elf64_hppa_mark_exported_functions (h, data) |
1013 | struct elf_link_hash_entry *h; | |
1014 | PTR data; | |
1015 | { | |
1016 | struct bfd_link_info *info = (struct bfd_link_info *)data; | |
1017 | struct elf64_hppa_link_hash_table *hppa_info; | |
1018 | ||
1019 | hppa_info = elf64_hppa_hash_table (info); | |
1020 | ||
e92d460e AM |
1021 | if (h->root.type == bfd_link_hash_warning) |
1022 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
1023 | ||
15bda425 JL |
1024 | if (h |
1025 | && (h->root.type == bfd_link_hash_defined | |
1026 | || h->root.type == bfd_link_hash_defweak) | |
1027 | && h->root.u.def.section->output_section != NULL | |
1028 | && h->type == STT_FUNC) | |
1029 | { | |
1030 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
1031 | ||
1032 | /* Add this symbol to the PA64 linker hash table. */ | |
1033 | dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, | |
b34976b6 | 1034 | h->root.root.string, TRUE, TRUE); |
15bda425 JL |
1035 | BFD_ASSERT (dyn_h); |
1036 | dyn_h->h = h; | |
1037 | ||
1038 | if (! hppa_info->opd_sec | |
1039 | && ! get_opd (hppa_info->root.dynobj, info, hppa_info)) | |
b34976b6 | 1040 | return FALSE; |
15bda425 JL |
1041 | |
1042 | dyn_h->want_opd = 1; | |
832d951b AM |
1043 | /* Put a flag here for output_symbol_hook. */ |
1044 | dyn_h->st_shndx = -1; | |
f5385ebf | 1045 | h->needs_plt = 1; |
15bda425 JL |
1046 | } |
1047 | ||
b34976b6 | 1048 | return TRUE; |
15bda425 JL |
1049 | } |
1050 | ||
1051 | /* Allocate space for a DLT entry. */ | |
1052 | ||
b34976b6 | 1053 | static bfd_boolean |
15bda425 JL |
1054 | allocate_global_data_dlt (dyn_h, data) |
1055 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
1056 | PTR data; | |
1057 | { | |
1058 | struct elf64_hppa_allocate_data *x = (struct elf64_hppa_allocate_data *)data; | |
1059 | ||
1060 | if (dyn_h->want_dlt) | |
1061 | { | |
1062 | struct elf_link_hash_entry *h = dyn_h->h; | |
1063 | ||
1064 | if (x->info->shared) | |
1065 | { | |
1066 | /* Possibly add the symbol to the local dynamic symbol | |
1067 | table since we might need to create a dynamic relocation | |
1068 | against it. */ | |
1069 | if (! h | |
47b7c2db | 1070 | || (h->dynindx == -1 && h->type != STT_PARISC_MILLI)) |
15bda425 JL |
1071 | { |
1072 | bfd *owner; | |
1073 | owner = (h ? h->root.u.def.section->owner : dyn_h->owner); | |
1074 | ||
c152c796 | 1075 | if (! (bfd_elf_link_record_local_dynamic_symbol |
dc810e39 | 1076 | (x->info, owner, dyn_h->sym_indx))) |
b34976b6 | 1077 | return FALSE; |
15bda425 JL |
1078 | } |
1079 | } | |
1080 | ||
1081 | dyn_h->dlt_offset = x->ofs; | |
1082 | x->ofs += DLT_ENTRY_SIZE; | |
1083 | } | |
b34976b6 | 1084 | return TRUE; |
15bda425 JL |
1085 | } |
1086 | ||
1087 | /* Allocate space for a DLT.PLT entry. */ | |
1088 | ||
b34976b6 | 1089 | static bfd_boolean |
15bda425 JL |
1090 | allocate_global_data_plt (dyn_h, data) |
1091 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
1092 | PTR data; | |
1093 | { | |
1094 | struct elf64_hppa_allocate_data *x = (struct elf64_hppa_allocate_data *)data; | |
1095 | ||
1096 | if (dyn_h->want_plt | |
1097 | && elf64_hppa_dynamic_symbol_p (dyn_h->h, x->info) | |
1098 | && !((dyn_h->h->root.type == bfd_link_hash_defined | |
1099 | || dyn_h->h->root.type == bfd_link_hash_defweak) | |
1100 | && dyn_h->h->root.u.def.section->output_section != NULL)) | |
1101 | { | |
1102 | dyn_h->plt_offset = x->ofs; | |
1103 | x->ofs += PLT_ENTRY_SIZE; | |
1104 | if (dyn_h->plt_offset < 0x2000) | |
1105 | elf64_hppa_hash_table (x->info)->gp_offset = dyn_h->plt_offset; | |
1106 | } | |
1107 | else | |
1108 | dyn_h->want_plt = 0; | |
1109 | ||
b34976b6 | 1110 | return TRUE; |
15bda425 JL |
1111 | } |
1112 | ||
1113 | /* Allocate space for a STUB entry. */ | |
1114 | ||
b34976b6 | 1115 | static bfd_boolean |
15bda425 JL |
1116 | allocate_global_data_stub (dyn_h, data) |
1117 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
1118 | PTR data; | |
1119 | { | |
1120 | struct elf64_hppa_allocate_data *x = (struct elf64_hppa_allocate_data *)data; | |
1121 | ||
1122 | if (dyn_h->want_stub | |
1123 | && elf64_hppa_dynamic_symbol_p (dyn_h->h, x->info) | |
1124 | && !((dyn_h->h->root.type == bfd_link_hash_defined | |
1125 | || dyn_h->h->root.type == bfd_link_hash_defweak) | |
1126 | && dyn_h->h->root.u.def.section->output_section != NULL)) | |
1127 | { | |
1128 | dyn_h->stub_offset = x->ofs; | |
1129 | x->ofs += sizeof (plt_stub); | |
1130 | } | |
1131 | else | |
1132 | dyn_h->want_stub = 0; | |
b34976b6 | 1133 | return TRUE; |
15bda425 JL |
1134 | } |
1135 | ||
1136 | /* Allocate space for a FPTR entry. */ | |
1137 | ||
b34976b6 | 1138 | static bfd_boolean |
15bda425 JL |
1139 | allocate_global_data_opd (dyn_h, data) |
1140 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
1141 | PTR data; | |
1142 | { | |
1143 | struct elf64_hppa_allocate_data *x = (struct elf64_hppa_allocate_data *)data; | |
1144 | ||
1145 | if (dyn_h->want_opd) | |
1146 | { | |
1147 | struct elf_link_hash_entry *h = dyn_h->h; | |
fe8bc63d | 1148 | |
15bda425 JL |
1149 | if (h) |
1150 | while (h->root.type == bfd_link_hash_indirect | |
1151 | || h->root.type == bfd_link_hash_warning) | |
1152 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
1153 | ||
1154 | /* We never need an opd entry for a symbol which is not | |
1155 | defined by this output file. */ | |
3db4b612 | 1156 | if (h && (h->root.type == bfd_link_hash_undefined |
af7cfa33 | 1157 | || h->root.type == bfd_link_hash_undefweak |
3db4b612 | 1158 | || h->root.u.def.section->output_section == NULL)) |
15bda425 JL |
1159 | dyn_h->want_opd = 0; |
1160 | ||
1161 | /* If we are creating a shared library, took the address of a local | |
1162 | function or might export this function from this object file, then | |
1163 | we have to create an opd descriptor. */ | |
1164 | else if (x->info->shared | |
1165 | || h == NULL | |
47b7c2db | 1166 | || (h->dynindx == -1 && h->type != STT_PARISC_MILLI) |
3db4b612 JL |
1167 | || (h->root.type == bfd_link_hash_defined |
1168 | || h->root.type == bfd_link_hash_defweak)) | |
15bda425 JL |
1169 | { |
1170 | /* If we are creating a shared library, then we will have to | |
1171 | create a runtime relocation for the symbol to properly | |
1172 | initialize the .opd entry. Make sure the symbol gets | |
1173 | added to the dynamic symbol table. */ | |
1174 | if (x->info->shared | |
1175 | && (h == NULL || (h->dynindx == -1))) | |
1176 | { | |
1177 | bfd *owner; | |
1178 | owner = (h ? h->root.u.def.section->owner : dyn_h->owner); | |
1179 | ||
c152c796 | 1180 | if (!bfd_elf_link_record_local_dynamic_symbol |
15bda425 | 1181 | (x->info, owner, dyn_h->sym_indx)) |
b34976b6 | 1182 | return FALSE; |
15bda425 JL |
1183 | } |
1184 | ||
1185 | /* This may not be necessary or desirable anymore now that | |
1186 | we have some support for dealing with section symbols | |
1187 | in dynamic relocs. But name munging does make the result | |
1188 | much easier to debug. ie, the EPLT reloc will reference | |
1189 | a symbol like .foobar, instead of .text + offset. */ | |
1190 | if (x->info->shared && h) | |
1191 | { | |
1192 | char *new_name; | |
1193 | struct elf_link_hash_entry *nh; | |
1194 | ||
1195 | new_name = alloca (strlen (h->root.root.string) + 2); | |
1196 | new_name[0] = '.'; | |
1197 | strcpy (new_name + 1, h->root.root.string); | |
1198 | ||
1199 | nh = elf_link_hash_lookup (elf_hash_table (x->info), | |
b34976b6 | 1200 | new_name, TRUE, TRUE, TRUE); |
15bda425 JL |
1201 | |
1202 | nh->root.type = h->root.type; | |
1203 | nh->root.u.def.value = h->root.u.def.value; | |
1204 | nh->root.u.def.section = h->root.u.def.section; | |
1205 | ||
c152c796 | 1206 | if (! bfd_elf_link_record_dynamic_symbol (x->info, nh)) |
b34976b6 | 1207 | return FALSE; |
15bda425 JL |
1208 | |
1209 | } | |
1210 | dyn_h->opd_offset = x->ofs; | |
1211 | x->ofs += OPD_ENTRY_SIZE; | |
1212 | } | |
1213 | ||
1214 | /* Otherwise we do not need an opd entry. */ | |
1215 | else | |
1216 | dyn_h->want_opd = 0; | |
1217 | } | |
b34976b6 | 1218 | return TRUE; |
15bda425 JL |
1219 | } |
1220 | ||
1221 | /* HP requires the EI_OSABI field to be filled in. The assignment to | |
1222 | EI_ABIVERSION may not be strictly necessary. */ | |
1223 | ||
1224 | static void | |
1225 | elf64_hppa_post_process_headers (abfd, link_info) | |
1226 | bfd * abfd; | |
1227 | struct bfd_link_info * link_info ATTRIBUTE_UNUSED; | |
1228 | { | |
1229 | Elf_Internal_Ehdr * i_ehdrp; | |
1230 | ||
1231 | i_ehdrp = elf_elfheader (abfd); | |
d1036acb L |
1232 | |
1233 | i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi; | |
1234 | i_ehdrp->e_ident[EI_ABIVERSION] = 1; | |
15bda425 JL |
1235 | } |
1236 | ||
1237 | /* Create function descriptor section (.opd). This section is called .opd | |
4cc11e76 | 1238 | because it contains "official procedure descriptors". The "official" |
15bda425 JL |
1239 | refers to the fact that these descriptors are used when taking the address |
1240 | of a procedure, thus ensuring a unique address for each procedure. */ | |
1241 | ||
b34976b6 | 1242 | static bfd_boolean |
15bda425 JL |
1243 | get_opd (abfd, info, hppa_info) |
1244 | bfd *abfd; | |
edd21aca | 1245 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
15bda425 JL |
1246 | struct elf64_hppa_link_hash_table *hppa_info; |
1247 | { | |
1248 | asection *opd; | |
1249 | bfd *dynobj; | |
1250 | ||
1251 | opd = hppa_info->opd_sec; | |
1252 | if (!opd) | |
1253 | { | |
1254 | dynobj = hppa_info->root.dynobj; | |
1255 | if (!dynobj) | |
1256 | hppa_info->root.dynobj = dynobj = abfd; | |
1257 | ||
3496cb2a L |
1258 | opd = bfd_make_section_with_flags (dynobj, ".opd", |
1259 | (SEC_ALLOC | |
1260 | | SEC_LOAD | |
1261 | | SEC_HAS_CONTENTS | |
1262 | | SEC_IN_MEMORY | |
1263 | | SEC_LINKER_CREATED)); | |
15bda425 | 1264 | if (!opd |
15bda425 JL |
1265 | || !bfd_set_section_alignment (abfd, opd, 3)) |
1266 | { | |
1267 | BFD_ASSERT (0); | |
b34976b6 | 1268 | return FALSE; |
15bda425 JL |
1269 | } |
1270 | ||
1271 | hppa_info->opd_sec = opd; | |
1272 | } | |
1273 | ||
b34976b6 | 1274 | return TRUE; |
15bda425 JL |
1275 | } |
1276 | ||
1277 | /* Create the PLT section. */ | |
1278 | ||
b34976b6 | 1279 | static bfd_boolean |
15bda425 JL |
1280 | get_plt (abfd, info, hppa_info) |
1281 | bfd *abfd; | |
edd21aca | 1282 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
15bda425 JL |
1283 | struct elf64_hppa_link_hash_table *hppa_info; |
1284 | { | |
1285 | asection *plt; | |
1286 | bfd *dynobj; | |
1287 | ||
1288 | plt = hppa_info->plt_sec; | |
1289 | if (!plt) | |
1290 | { | |
1291 | dynobj = hppa_info->root.dynobj; | |
1292 | if (!dynobj) | |
1293 | hppa_info->root.dynobj = dynobj = abfd; | |
1294 | ||
3496cb2a L |
1295 | plt = bfd_make_section_with_flags (dynobj, ".plt", |
1296 | (SEC_ALLOC | |
1297 | | SEC_LOAD | |
1298 | | SEC_HAS_CONTENTS | |
1299 | | SEC_IN_MEMORY | |
1300 | | SEC_LINKER_CREATED)); | |
15bda425 | 1301 | if (!plt |
15bda425 JL |
1302 | || !bfd_set_section_alignment (abfd, plt, 3)) |
1303 | { | |
1304 | BFD_ASSERT (0); | |
b34976b6 | 1305 | return FALSE; |
15bda425 JL |
1306 | } |
1307 | ||
1308 | hppa_info->plt_sec = plt; | |
1309 | } | |
1310 | ||
b34976b6 | 1311 | return TRUE; |
15bda425 JL |
1312 | } |
1313 | ||
1314 | /* Create the DLT section. */ | |
1315 | ||
b34976b6 | 1316 | static bfd_boolean |
15bda425 JL |
1317 | get_dlt (abfd, info, hppa_info) |
1318 | bfd *abfd; | |
edd21aca | 1319 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
15bda425 JL |
1320 | struct elf64_hppa_link_hash_table *hppa_info; |
1321 | { | |
1322 | asection *dlt; | |
1323 | bfd *dynobj; | |
1324 | ||
1325 | dlt = hppa_info->dlt_sec; | |
1326 | if (!dlt) | |
1327 | { | |
1328 | dynobj = hppa_info->root.dynobj; | |
1329 | if (!dynobj) | |
1330 | hppa_info->root.dynobj = dynobj = abfd; | |
1331 | ||
3496cb2a L |
1332 | dlt = bfd_make_section_with_flags (dynobj, ".dlt", |
1333 | (SEC_ALLOC | |
1334 | | SEC_LOAD | |
1335 | | SEC_HAS_CONTENTS | |
1336 | | SEC_IN_MEMORY | |
1337 | | SEC_LINKER_CREATED)); | |
15bda425 | 1338 | if (!dlt |
15bda425 JL |
1339 | || !bfd_set_section_alignment (abfd, dlt, 3)) |
1340 | { | |
1341 | BFD_ASSERT (0); | |
b34976b6 | 1342 | return FALSE; |
15bda425 JL |
1343 | } |
1344 | ||
1345 | hppa_info->dlt_sec = dlt; | |
1346 | } | |
1347 | ||
b34976b6 | 1348 | return TRUE; |
15bda425 JL |
1349 | } |
1350 | ||
1351 | /* Create the stubs section. */ | |
1352 | ||
b34976b6 | 1353 | static bfd_boolean |
15bda425 JL |
1354 | get_stub (abfd, info, hppa_info) |
1355 | bfd *abfd; | |
edd21aca | 1356 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
15bda425 JL |
1357 | struct elf64_hppa_link_hash_table *hppa_info; |
1358 | { | |
1359 | asection *stub; | |
1360 | bfd *dynobj; | |
1361 | ||
1362 | stub = hppa_info->stub_sec; | |
1363 | if (!stub) | |
1364 | { | |
1365 | dynobj = hppa_info->root.dynobj; | |
1366 | if (!dynobj) | |
1367 | hppa_info->root.dynobj = dynobj = abfd; | |
1368 | ||
3496cb2a L |
1369 | stub = bfd_make_section_with_flags (dynobj, ".stub", |
1370 | (SEC_ALLOC | SEC_LOAD | |
1371 | | SEC_HAS_CONTENTS | |
1372 | | SEC_IN_MEMORY | |
1373 | | SEC_READONLY | |
1374 | | SEC_LINKER_CREATED)); | |
15bda425 | 1375 | if (!stub |
15bda425 JL |
1376 | || !bfd_set_section_alignment (abfd, stub, 3)) |
1377 | { | |
1378 | BFD_ASSERT (0); | |
b34976b6 | 1379 | return FALSE; |
15bda425 JL |
1380 | } |
1381 | ||
1382 | hppa_info->stub_sec = stub; | |
1383 | } | |
1384 | ||
b34976b6 | 1385 | return TRUE; |
15bda425 JL |
1386 | } |
1387 | ||
1388 | /* Create sections necessary for dynamic linking. This is only a rough | |
1389 | cut and will likely change as we learn more about the somewhat | |
1390 | unusual dynamic linking scheme HP uses. | |
1391 | ||
1392 | .stub: | |
1393 | Contains code to implement cross-space calls. The first time one | |
1394 | of the stubs is used it will call into the dynamic linker, later | |
1395 | calls will go straight to the target. | |
1396 | ||
1397 | The only stub we support right now looks like | |
1398 | ||
1399 | ldd OFFSET(%dp),%r1 | |
1400 | bve %r0(%r1) | |
1401 | ldd OFFSET+8(%dp),%dp | |
1402 | ||
1403 | Other stubs may be needed in the future. We may want the remove | |
1404 | the break/nop instruction. It is only used right now to keep the | |
1405 | offset of a .plt entry and a .stub entry in sync. | |
1406 | ||
1407 | .dlt: | |
1408 | This is what most people call the .got. HP used a different name. | |
1409 | Losers. | |
1410 | ||
1411 | .rela.dlt: | |
1412 | Relocations for the DLT. | |
1413 | ||
1414 | .plt: | |
1415 | Function pointers as address,gp pairs. | |
1416 | ||
1417 | .rela.plt: | |
1418 | Should contain dynamic IPLT (and EPLT?) relocations. | |
1419 | ||
1420 | .opd: | |
fe8bc63d | 1421 | FPTRS |
15bda425 JL |
1422 | |
1423 | .rela.opd: | |
1424 | EPLT relocations for symbols exported from shared libraries. */ | |
1425 | ||
b34976b6 | 1426 | static bfd_boolean |
15bda425 JL |
1427 | elf64_hppa_create_dynamic_sections (abfd, info) |
1428 | bfd *abfd; | |
1429 | struct bfd_link_info *info; | |
1430 | { | |
1431 | asection *s; | |
1432 | ||
1433 | if (! get_stub (abfd, info, elf64_hppa_hash_table (info))) | |
b34976b6 | 1434 | return FALSE; |
15bda425 JL |
1435 | |
1436 | if (! get_dlt (abfd, info, elf64_hppa_hash_table (info))) | |
b34976b6 | 1437 | return FALSE; |
15bda425 JL |
1438 | |
1439 | if (! get_plt (abfd, info, elf64_hppa_hash_table (info))) | |
b34976b6 | 1440 | return FALSE; |
15bda425 JL |
1441 | |
1442 | if (! get_opd (abfd, info, elf64_hppa_hash_table (info))) | |
b34976b6 | 1443 | return FALSE; |
15bda425 | 1444 | |
3496cb2a L |
1445 | s = bfd_make_section_with_flags (abfd, ".rela.dlt", |
1446 | (SEC_ALLOC | SEC_LOAD | |
1447 | | SEC_HAS_CONTENTS | |
1448 | | SEC_IN_MEMORY | |
1449 | | SEC_READONLY | |
1450 | | SEC_LINKER_CREATED)); | |
15bda425 | 1451 | if (s == NULL |
15bda425 | 1452 | || !bfd_set_section_alignment (abfd, s, 3)) |
b34976b6 | 1453 | return FALSE; |
15bda425 JL |
1454 | elf64_hppa_hash_table (info)->dlt_rel_sec = s; |
1455 | ||
3496cb2a L |
1456 | s = bfd_make_section_with_flags (abfd, ".rela.plt", |
1457 | (SEC_ALLOC | SEC_LOAD | |
1458 | | SEC_HAS_CONTENTS | |
1459 | | SEC_IN_MEMORY | |
1460 | | SEC_READONLY | |
1461 | | SEC_LINKER_CREATED)); | |
15bda425 | 1462 | if (s == NULL |
15bda425 | 1463 | || !bfd_set_section_alignment (abfd, s, 3)) |
b34976b6 | 1464 | return FALSE; |
15bda425 JL |
1465 | elf64_hppa_hash_table (info)->plt_rel_sec = s; |
1466 | ||
3496cb2a L |
1467 | s = bfd_make_section_with_flags (abfd, ".rela.data", |
1468 | (SEC_ALLOC | SEC_LOAD | |
1469 | | SEC_HAS_CONTENTS | |
1470 | | SEC_IN_MEMORY | |
1471 | | SEC_READONLY | |
1472 | | SEC_LINKER_CREATED)); | |
15bda425 | 1473 | if (s == NULL |
15bda425 | 1474 | || !bfd_set_section_alignment (abfd, s, 3)) |
b34976b6 | 1475 | return FALSE; |
15bda425 JL |
1476 | elf64_hppa_hash_table (info)->other_rel_sec = s; |
1477 | ||
3496cb2a L |
1478 | s = bfd_make_section_with_flags (abfd, ".rela.opd", |
1479 | (SEC_ALLOC | SEC_LOAD | |
1480 | | SEC_HAS_CONTENTS | |
1481 | | SEC_IN_MEMORY | |
1482 | | SEC_READONLY | |
1483 | | SEC_LINKER_CREATED)); | |
15bda425 | 1484 | if (s == NULL |
15bda425 | 1485 | || !bfd_set_section_alignment (abfd, s, 3)) |
b34976b6 | 1486 | return FALSE; |
15bda425 JL |
1487 | elf64_hppa_hash_table (info)->opd_rel_sec = s; |
1488 | ||
b34976b6 | 1489 | return TRUE; |
15bda425 JL |
1490 | } |
1491 | ||
1492 | /* Allocate dynamic relocations for those symbols that turned out | |
1493 | to be dynamic. */ | |
1494 | ||
b34976b6 | 1495 | static bfd_boolean |
15bda425 JL |
1496 | allocate_dynrel_entries (dyn_h, data) |
1497 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
1498 | PTR data; | |
1499 | { | |
1500 | struct elf64_hppa_allocate_data *x = (struct elf64_hppa_allocate_data *)data; | |
1501 | struct elf64_hppa_link_hash_table *hppa_info; | |
1502 | struct elf64_hppa_dyn_reloc_entry *rent; | |
b34976b6 | 1503 | bfd_boolean dynamic_symbol, shared; |
15bda425 JL |
1504 | |
1505 | hppa_info = elf64_hppa_hash_table (x->info); | |
1506 | dynamic_symbol = elf64_hppa_dynamic_symbol_p (dyn_h->h, x->info); | |
1507 | shared = x->info->shared; | |
1508 | ||
1509 | /* We may need to allocate relocations for a non-dynamic symbol | |
1510 | when creating a shared library. */ | |
1511 | if (!dynamic_symbol && !shared) | |
b34976b6 | 1512 | return TRUE; |
15bda425 JL |
1513 | |
1514 | /* Take care of the normal data relocations. */ | |
1515 | ||
1516 | for (rent = dyn_h->reloc_entries; rent; rent = rent->next) | |
1517 | { | |
d663e1cd JL |
1518 | /* Allocate one iff we are building a shared library, the relocation |
1519 | isn't a R_PARISC_FPTR64, or we don't want an opd entry. */ | |
1520 | if (!shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd) | |
1521 | continue; | |
1522 | ||
eea6121a | 1523 | hppa_info->other_rel_sec->size += sizeof (Elf64_External_Rela); |
15bda425 JL |
1524 | |
1525 | /* Make sure this symbol gets into the dynamic symbol table if it is | |
1526 | not already recorded. ?!? This should not be in the loop since | |
1527 | the symbol need only be added once. */ | |
47b7c2db AM |
1528 | if (dyn_h->h == 0 |
1529 | || (dyn_h->h->dynindx == -1 && dyn_h->h->type != STT_PARISC_MILLI)) | |
c152c796 | 1530 | if (!bfd_elf_link_record_local_dynamic_symbol |
15bda425 | 1531 | (x->info, rent->sec->owner, dyn_h->sym_indx)) |
b34976b6 | 1532 | return FALSE; |
15bda425 JL |
1533 | } |
1534 | ||
1535 | /* Take care of the GOT and PLT relocations. */ | |
1536 | ||
1537 | if ((dynamic_symbol || shared) && dyn_h->want_dlt) | |
eea6121a | 1538 | hppa_info->dlt_rel_sec->size += sizeof (Elf64_External_Rela); |
15bda425 JL |
1539 | |
1540 | /* If we are building a shared library, then every symbol that has an | |
1541 | opd entry will need an EPLT relocation to relocate the symbol's address | |
1542 | and __gp value based on the runtime load address. */ | |
1543 | if (shared && dyn_h->want_opd) | |
eea6121a | 1544 | hppa_info->opd_rel_sec->size += sizeof (Elf64_External_Rela); |
15bda425 JL |
1545 | |
1546 | if (dyn_h->want_plt && dynamic_symbol) | |
1547 | { | |
1548 | bfd_size_type t = 0; | |
1549 | ||
1550 | /* Dynamic symbols get one IPLT relocation. Local symbols in | |
1551 | shared libraries get two REL relocations. Local symbols in | |
1552 | main applications get nothing. */ | |
1553 | if (dynamic_symbol) | |
1554 | t = sizeof (Elf64_External_Rela); | |
1555 | else if (shared) | |
1556 | t = 2 * sizeof (Elf64_External_Rela); | |
1557 | ||
eea6121a | 1558 | hppa_info->plt_rel_sec->size += t; |
15bda425 JL |
1559 | } |
1560 | ||
b34976b6 | 1561 | return TRUE; |
15bda425 JL |
1562 | } |
1563 | ||
1564 | /* Adjust a symbol defined by a dynamic object and referenced by a | |
1565 | regular object. */ | |
1566 | ||
b34976b6 | 1567 | static bfd_boolean |
15bda425 | 1568 | elf64_hppa_adjust_dynamic_symbol (info, h) |
edd21aca | 1569 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
15bda425 JL |
1570 | struct elf_link_hash_entry *h; |
1571 | { | |
1572 | /* ??? Undefined symbols with PLT entries should be re-defined | |
1573 | to be the PLT entry. */ | |
1574 | ||
1575 | /* If this is a weak symbol, and there is a real definition, the | |
1576 | processor independent code will have arranged for us to see the | |
1577 | real definition first, and we can just use the same value. */ | |
f6e332e6 | 1578 | if (h->u.weakdef != NULL) |
15bda425 | 1579 | { |
f6e332e6 AM |
1580 | BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined |
1581 | || h->u.weakdef->root.type == bfd_link_hash_defweak); | |
1582 | h->root.u.def.section = h->u.weakdef->root.u.def.section; | |
1583 | h->root.u.def.value = h->u.weakdef->root.u.def.value; | |
b34976b6 | 1584 | return TRUE; |
15bda425 JL |
1585 | } |
1586 | ||
1587 | /* If this is a reference to a symbol defined by a dynamic object which | |
1588 | is not a function, we might allocate the symbol in our .dynbss section | |
1589 | and allocate a COPY dynamic relocation. | |
1590 | ||
1591 | But PA64 code is canonically PIC, so as a rule we can avoid this sort | |
1592 | of hackery. */ | |
1593 | ||
b34976b6 | 1594 | return TRUE; |
15bda425 JL |
1595 | } |
1596 | ||
47b7c2db AM |
1597 | /* This function is called via elf_link_hash_traverse to mark millicode |
1598 | symbols with a dynindx of -1 and to remove the string table reference | |
1599 | from the dynamic symbol table. If the symbol is not a millicode symbol, | |
1600 | elf64_hppa_mark_exported_functions is called. */ | |
1601 | ||
b34976b6 | 1602 | static bfd_boolean |
47b7c2db AM |
1603 | elf64_hppa_mark_milli_and_exported_functions (h, data) |
1604 | struct elf_link_hash_entry *h; | |
1605 | PTR data; | |
1606 | { | |
1607 | struct bfd_link_info *info = (struct bfd_link_info *)data; | |
1608 | struct elf_link_hash_entry *elf = h; | |
1609 | ||
1610 | if (elf->root.type == bfd_link_hash_warning) | |
1611 | elf = (struct elf_link_hash_entry *) elf->root.u.i.link; | |
1612 | ||
1613 | if (elf->type == STT_PARISC_MILLI) | |
1614 | { | |
1615 | if (elf->dynindx != -1) | |
1616 | { | |
1617 | elf->dynindx = -1; | |
1618 | _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr, | |
1619 | elf->dynstr_index); | |
1620 | } | |
b34976b6 | 1621 | return TRUE; |
47b7c2db AM |
1622 | } |
1623 | ||
1624 | return elf64_hppa_mark_exported_functions (h, data); | |
1625 | } | |
1626 | ||
15bda425 JL |
1627 | /* Set the final sizes of the dynamic sections and allocate memory for |
1628 | the contents of our special sections. */ | |
1629 | ||
b34976b6 | 1630 | static bfd_boolean |
15bda425 JL |
1631 | elf64_hppa_size_dynamic_sections (output_bfd, info) |
1632 | bfd *output_bfd; | |
1633 | struct bfd_link_info *info; | |
1634 | { | |
1635 | bfd *dynobj; | |
1636 | asection *s; | |
b34976b6 AM |
1637 | bfd_boolean plt; |
1638 | bfd_boolean relocs; | |
1639 | bfd_boolean reltext; | |
15bda425 JL |
1640 | struct elf64_hppa_allocate_data data; |
1641 | struct elf64_hppa_link_hash_table *hppa_info; | |
1642 | ||
1643 | hppa_info = elf64_hppa_hash_table (info); | |
1644 | ||
1645 | dynobj = elf_hash_table (info)->dynobj; | |
1646 | BFD_ASSERT (dynobj != NULL); | |
1647 | ||
47b7c2db AM |
1648 | /* Mark each function this program exports so that we will allocate |
1649 | space in the .opd section for each function's FPTR. If we are | |
1650 | creating dynamic sections, change the dynamic index of millicode | |
1651 | symbols to -1 and remove them from the string table for .dynstr. | |
1652 | ||
1653 | We have to traverse the main linker hash table since we have to | |
1654 | find functions which may not have been mentioned in any relocs. */ | |
1655 | elf_link_hash_traverse (elf_hash_table (info), | |
1656 | (elf_hash_table (info)->dynamic_sections_created | |
1657 | ? elf64_hppa_mark_milli_and_exported_functions | |
1658 | : elf64_hppa_mark_exported_functions), | |
1659 | info); | |
1660 | ||
15bda425 JL |
1661 | if (elf_hash_table (info)->dynamic_sections_created) |
1662 | { | |
1663 | /* Set the contents of the .interp section to the interpreter. */ | |
893c4fe2 | 1664 | if (info->executable) |
15bda425 JL |
1665 | { |
1666 | s = bfd_get_section_by_name (dynobj, ".interp"); | |
1667 | BFD_ASSERT (s != NULL); | |
eea6121a | 1668 | s->size = sizeof ELF_DYNAMIC_INTERPRETER; |
15bda425 JL |
1669 | s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; |
1670 | } | |
1671 | } | |
1672 | else | |
1673 | { | |
1674 | /* We may have created entries in the .rela.got section. | |
1675 | However, if we are not creating the dynamic sections, we will | |
1676 | not actually use these entries. Reset the size of .rela.dlt, | |
1677 | which will cause it to get stripped from the output file | |
1678 | below. */ | |
1679 | s = bfd_get_section_by_name (dynobj, ".rela.dlt"); | |
1680 | if (s != NULL) | |
eea6121a | 1681 | s->size = 0; |
15bda425 JL |
1682 | } |
1683 | ||
1684 | /* Allocate the GOT entries. */ | |
1685 | ||
1686 | data.info = info; | |
1687 | if (elf64_hppa_hash_table (info)->dlt_sec) | |
1688 | { | |
1689 | data.ofs = 0x0; | |
1690 | elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, | |
1691 | allocate_global_data_dlt, &data); | |
eea6121a | 1692 | hppa_info->dlt_sec->size = data.ofs; |
15bda425 JL |
1693 | |
1694 | data.ofs = 0x0; | |
1695 | elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, | |
1696 | allocate_global_data_plt, &data); | |
eea6121a | 1697 | hppa_info->plt_sec->size = data.ofs; |
15bda425 JL |
1698 | |
1699 | data.ofs = 0x0; | |
1700 | elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, | |
1701 | allocate_global_data_stub, &data); | |
eea6121a | 1702 | hppa_info->stub_sec->size = data.ofs; |
15bda425 JL |
1703 | } |
1704 | ||
15bda425 JL |
1705 | /* Allocate space for entries in the .opd section. */ |
1706 | if (elf64_hppa_hash_table (info)->opd_sec) | |
1707 | { | |
1708 | data.ofs = 0; | |
1709 | elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, | |
1710 | allocate_global_data_opd, &data); | |
eea6121a | 1711 | hppa_info->opd_sec->size = data.ofs; |
15bda425 JL |
1712 | } |
1713 | ||
1714 | /* Now allocate space for dynamic relocations, if necessary. */ | |
1715 | if (hppa_info->root.dynamic_sections_created) | |
1716 | elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, | |
1717 | allocate_dynrel_entries, &data); | |
1718 | ||
1719 | /* The sizes of all the sections are set. Allocate memory for them. */ | |
b34976b6 AM |
1720 | plt = FALSE; |
1721 | relocs = FALSE; | |
1722 | reltext = FALSE; | |
15bda425 JL |
1723 | for (s = dynobj->sections; s != NULL; s = s->next) |
1724 | { | |
1725 | const char *name; | |
15bda425 JL |
1726 | |
1727 | if ((s->flags & SEC_LINKER_CREATED) == 0) | |
1728 | continue; | |
1729 | ||
1730 | /* It's OK to base decisions on the section name, because none | |
1731 | of the dynobj section names depend upon the input files. */ | |
1732 | name = bfd_get_section_name (dynobj, s); | |
1733 | ||
15bda425 JL |
1734 | if (strcmp (name, ".plt") == 0) |
1735 | { | |
c456f082 AM |
1736 | /* Remember whether there is a PLT. */ |
1737 | plt = s->size != 0; | |
15bda425 | 1738 | } |
c456f082 | 1739 | else if (strcmp (name, ".opd") == 0 |
0112cd26 | 1740 | || CONST_STRNEQ (name, ".dlt") |
c456f082 AM |
1741 | || strcmp (name, ".stub") == 0 |
1742 | || strcmp (name, ".got") == 0) | |
15bda425 | 1743 | { |
d663e1cd | 1744 | /* Strip this section if we don't need it; see the comment below. */ |
15bda425 | 1745 | } |
0112cd26 | 1746 | else if (CONST_STRNEQ (name, ".rela")) |
15bda425 | 1747 | { |
c456f082 | 1748 | if (s->size != 0) |
15bda425 JL |
1749 | { |
1750 | asection *target; | |
1751 | ||
1752 | /* Remember whether there are any reloc sections other | |
1753 | than .rela.plt. */ | |
1754 | if (strcmp (name, ".rela.plt") != 0) | |
1755 | { | |
1756 | const char *outname; | |
1757 | ||
b34976b6 | 1758 | relocs = TRUE; |
15bda425 JL |
1759 | |
1760 | /* If this relocation section applies to a read only | |
1761 | section, then we probably need a DT_TEXTREL | |
1762 | entry. The entries in the .rela.plt section | |
1763 | really apply to the .got section, which we | |
1764 | created ourselves and so know is not readonly. */ | |
1765 | outname = bfd_get_section_name (output_bfd, | |
1766 | s->output_section); | |
1767 | target = bfd_get_section_by_name (output_bfd, outname + 4); | |
1768 | if (target != NULL | |
1769 | && (target->flags & SEC_READONLY) != 0 | |
1770 | && (target->flags & SEC_ALLOC) != 0) | |
b34976b6 | 1771 | reltext = TRUE; |
15bda425 JL |
1772 | } |
1773 | ||
1774 | /* We use the reloc_count field as a counter if we need | |
1775 | to copy relocs into the output file. */ | |
1776 | s->reloc_count = 0; | |
1777 | } | |
1778 | } | |
c456f082 | 1779 | else |
15bda425 JL |
1780 | { |
1781 | /* It's not one of our sections, so don't allocate space. */ | |
1782 | continue; | |
1783 | } | |
1784 | ||
c456f082 | 1785 | if (s->size == 0) |
15bda425 | 1786 | { |
c456f082 AM |
1787 | /* If we don't need this section, strip it from the |
1788 | output file. This is mostly to handle .rela.bss and | |
1789 | .rela.plt. We must create both sections in | |
1790 | create_dynamic_sections, because they must be created | |
1791 | before the linker maps input sections to output | |
1792 | sections. The linker does that before | |
1793 | adjust_dynamic_symbol is called, and it is that | |
1794 | function which decides whether anything needs to go | |
1795 | into these sections. */ | |
8423293d | 1796 | s->flags |= SEC_EXCLUDE; |
15bda425 JL |
1797 | continue; |
1798 | } | |
1799 | ||
c456f082 AM |
1800 | if ((s->flags & SEC_HAS_CONTENTS) == 0) |
1801 | continue; | |
1802 | ||
15bda425 | 1803 | /* Allocate memory for the section contents if it has not |
832d951b AM |
1804 | been allocated already. We use bfd_zalloc here in case |
1805 | unused entries are not reclaimed before the section's | |
1806 | contents are written out. This should not happen, but this | |
1807 | way if it does, we get a R_PARISC_NONE reloc instead of | |
1808 | garbage. */ | |
15bda425 JL |
1809 | if (s->contents == NULL) |
1810 | { | |
eea6121a | 1811 | s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); |
c456f082 | 1812 | if (s->contents == NULL) |
b34976b6 | 1813 | return FALSE; |
15bda425 JL |
1814 | } |
1815 | } | |
1816 | ||
1817 | if (elf_hash_table (info)->dynamic_sections_created) | |
1818 | { | |
1819 | /* Always create a DT_PLTGOT. It actually has nothing to do with | |
1820 | the PLT, it is how we communicate the __gp value of a load | |
1821 | module to the dynamic linker. */ | |
dc810e39 | 1822 | #define add_dynamic_entry(TAG, VAL) \ |
5a580b3a | 1823 | _bfd_elf_add_dynamic_entry (info, TAG, VAL) |
dc810e39 AM |
1824 | |
1825 | if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0) | |
1826 | || !add_dynamic_entry (DT_PLTGOT, 0)) | |
b34976b6 | 1827 | return FALSE; |
15bda425 JL |
1828 | |
1829 | /* Add some entries to the .dynamic section. We fill in the | |
1830 | values later, in elf64_hppa_finish_dynamic_sections, but we | |
1831 | must add the entries now so that we get the correct size for | |
1832 | the .dynamic section. The DT_DEBUG entry is filled in by the | |
1833 | dynamic linker and used by the debugger. */ | |
1834 | if (! info->shared) | |
1835 | { | |
dc810e39 AM |
1836 | if (!add_dynamic_entry (DT_DEBUG, 0) |
1837 | || !add_dynamic_entry (DT_HP_DLD_HOOK, 0) | |
1838 | || !add_dynamic_entry (DT_HP_LOAD_MAP, 0)) | |
b34976b6 | 1839 | return FALSE; |
15bda425 JL |
1840 | } |
1841 | ||
f2482cb2 NC |
1842 | /* Force DT_FLAGS to always be set. |
1843 | Required by HPUX 11.00 patch PHSS_26559. */ | |
1844 | if (!add_dynamic_entry (DT_FLAGS, (info)->flags)) | |
b34976b6 | 1845 | return FALSE; |
f2482cb2 | 1846 | |
15bda425 JL |
1847 | if (plt) |
1848 | { | |
dc810e39 AM |
1849 | if (!add_dynamic_entry (DT_PLTRELSZ, 0) |
1850 | || !add_dynamic_entry (DT_PLTREL, DT_RELA) | |
1851 | || !add_dynamic_entry (DT_JMPREL, 0)) | |
b34976b6 | 1852 | return FALSE; |
15bda425 JL |
1853 | } |
1854 | ||
1855 | if (relocs) | |
1856 | { | |
dc810e39 AM |
1857 | if (!add_dynamic_entry (DT_RELA, 0) |
1858 | || !add_dynamic_entry (DT_RELASZ, 0) | |
1859 | || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela))) | |
b34976b6 | 1860 | return FALSE; |
15bda425 JL |
1861 | } |
1862 | ||
1863 | if (reltext) | |
1864 | { | |
dc810e39 | 1865 | if (!add_dynamic_entry (DT_TEXTREL, 0)) |
b34976b6 | 1866 | return FALSE; |
d6cf2879 | 1867 | info->flags |= DF_TEXTREL; |
15bda425 JL |
1868 | } |
1869 | } | |
dc810e39 | 1870 | #undef add_dynamic_entry |
15bda425 | 1871 | |
b34976b6 | 1872 | return TRUE; |
15bda425 JL |
1873 | } |
1874 | ||
1875 | /* Called after we have output the symbol into the dynamic symbol | |
1876 | table, but before we output the symbol into the normal symbol | |
1877 | table. | |
1878 | ||
1879 | For some symbols we had to change their address when outputting | |
1880 | the dynamic symbol table. We undo that change here so that | |
1881 | the symbols have their expected value in the normal symbol | |
1882 | table. Ick. */ | |
1883 | ||
b34976b6 | 1884 | static bfd_boolean |
754021d0 | 1885 | elf64_hppa_link_output_symbol_hook (info, name, sym, input_sec, h) |
15bda425 JL |
1886 | struct bfd_link_info *info; |
1887 | const char *name; | |
1888 | Elf_Internal_Sym *sym; | |
edd21aca | 1889 | asection *input_sec ATTRIBUTE_UNUSED; |
754021d0 | 1890 | struct elf_link_hash_entry *h; |
15bda425 JL |
1891 | { |
1892 | struct elf64_hppa_link_hash_table *hppa_info; | |
1893 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
1894 | ||
1895 | /* We may be called with the file symbol or section symbols. | |
1896 | They never need munging, so it is safe to ignore them. */ | |
1897 | if (!name) | |
b34976b6 | 1898 | return TRUE; |
15bda425 JL |
1899 | |
1900 | /* Get the PA dyn_symbol (if any) associated with NAME. */ | |
1901 | hppa_info = elf64_hppa_hash_table (info); | |
1902 | dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, | |
b34976b6 | 1903 | name, FALSE, FALSE); |
ac7bbf74 | 1904 | if (!dyn_h || dyn_h->h != h) |
754021d0 | 1905 | return TRUE; |
15bda425 | 1906 | |
832d951b AM |
1907 | /* Function symbols for which we created .opd entries *may* have been |
1908 | munged by finish_dynamic_symbol and have to be un-munged here. | |
1909 | ||
1910 | Note that finish_dynamic_symbol sometimes turns dynamic symbols | |
1911 | into non-dynamic ones, so we initialize st_shndx to -1 in | |
1912 | mark_exported_functions and check to see if it was overwritten | |
1913 | here instead of just checking dyn_h->h->dynindx. */ | |
ac7bbf74 | 1914 | if (dyn_h->want_opd && dyn_h->st_shndx != -1) |
15bda425 JL |
1915 | { |
1916 | /* Restore the saved value and section index. */ | |
1917 | sym->st_value = dyn_h->st_value; | |
fe8bc63d | 1918 | sym->st_shndx = dyn_h->st_shndx; |
15bda425 JL |
1919 | } |
1920 | ||
b34976b6 | 1921 | return TRUE; |
15bda425 JL |
1922 | } |
1923 | ||
1924 | /* Finish up dynamic symbol handling. We set the contents of various | |
1925 | dynamic sections here. */ | |
1926 | ||
b34976b6 | 1927 | static bfd_boolean |
15bda425 JL |
1928 | elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym) |
1929 | bfd *output_bfd; | |
1930 | struct bfd_link_info *info; | |
1931 | struct elf_link_hash_entry *h; | |
1932 | Elf_Internal_Sym *sym; | |
1933 | { | |
1934 | asection *stub, *splt, *sdlt, *sopd, *spltrel, *sdltrel; | |
1935 | struct elf64_hppa_link_hash_table *hppa_info; | |
1936 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
1937 | ||
1938 | hppa_info = elf64_hppa_hash_table (info); | |
1939 | dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table, | |
b34976b6 | 1940 | h->root.root.string, FALSE, FALSE); |
15bda425 JL |
1941 | |
1942 | stub = hppa_info->stub_sec; | |
1943 | splt = hppa_info->plt_sec; | |
1944 | sdlt = hppa_info->dlt_sec; | |
1945 | sopd = hppa_info->opd_sec; | |
1946 | spltrel = hppa_info->plt_rel_sec; | |
1947 | sdltrel = hppa_info->dlt_rel_sec; | |
1948 | ||
15bda425 JL |
1949 | /* Incredible. It is actually necessary to NOT use the symbol's real |
1950 | value when building the dynamic symbol table for a shared library. | |
1951 | At least for symbols that refer to functions. | |
1952 | ||
1953 | We will store a new value and section index into the symbol long | |
1954 | enough to output it into the dynamic symbol table, then we restore | |
1955 | the original values (in elf64_hppa_link_output_symbol_hook). */ | |
1956 | if (dyn_h && dyn_h->want_opd) | |
1957 | { | |
f12123c0 | 1958 | BFD_ASSERT (sopd != NULL); |
d663e1cd | 1959 | |
15bda425 JL |
1960 | /* Save away the original value and section index so that we |
1961 | can restore them later. */ | |
1962 | dyn_h->st_value = sym->st_value; | |
1963 | dyn_h->st_shndx = sym->st_shndx; | |
1964 | ||
1965 | /* For the dynamic symbol table entry, we want the value to be | |
1966 | address of this symbol's entry within the .opd section. */ | |
1967 | sym->st_value = (dyn_h->opd_offset | |
1968 | + sopd->output_offset | |
1969 | + sopd->output_section->vma); | |
1970 | sym->st_shndx = _bfd_elf_section_from_bfd_section (output_bfd, | |
1971 | sopd->output_section); | |
1972 | } | |
1973 | ||
1974 | /* Initialize a .plt entry if requested. */ | |
1975 | if (dyn_h && dyn_h->want_plt | |
1976 | && elf64_hppa_dynamic_symbol_p (dyn_h->h, info)) | |
1977 | { | |
1978 | bfd_vma value; | |
1979 | Elf_Internal_Rela rel; | |
947216bf | 1980 | bfd_byte *loc; |
15bda425 | 1981 | |
f12123c0 | 1982 | BFD_ASSERT (splt != NULL && spltrel != NULL); |
d663e1cd | 1983 | |
15bda425 JL |
1984 | /* We do not actually care about the value in the PLT entry |
1985 | if we are creating a shared library and the symbol is | |
1986 | still undefined, we create a dynamic relocation to fill | |
1987 | in the correct value. */ | |
1988 | if (info->shared && h->root.type == bfd_link_hash_undefined) | |
1989 | value = 0; | |
1990 | else | |
1991 | value = (h->root.u.def.value + h->root.u.def.section->vma); | |
1992 | ||
fe8bc63d | 1993 | /* Fill in the entry in the procedure linkage table. |
15bda425 JL |
1994 | |
1995 | The format of a plt entry is | |
fe8bc63d | 1996 | <funcaddr> <__gp>. |
15bda425 JL |
1997 | |
1998 | plt_offset is the offset within the PLT section at which to | |
fe8bc63d | 1999 | install the PLT entry. |
15bda425 JL |
2000 | |
2001 | We are modifying the in-memory PLT contents here, so we do not add | |
2002 | in the output_offset of the PLT section. */ | |
2003 | ||
2004 | bfd_put_64 (splt->owner, value, splt->contents + dyn_h->plt_offset); | |
2005 | value = _bfd_get_gp_value (splt->output_section->owner); | |
2006 | bfd_put_64 (splt->owner, value, splt->contents + dyn_h->plt_offset + 0x8); | |
2007 | ||
2008 | /* Create a dynamic IPLT relocation for this entry. | |
2009 | ||
2010 | We are creating a relocation in the output file's PLT section, | |
2011 | which is included within the DLT secton. So we do need to include | |
2012 | the PLT's output_offset in the computation of the relocation's | |
2013 | address. */ | |
2014 | rel.r_offset = (dyn_h->plt_offset + splt->output_offset | |
2015 | + splt->output_section->vma); | |
2016 | rel.r_info = ELF64_R_INFO (h->dynindx, R_PARISC_IPLT); | |
2017 | rel.r_addend = 0; | |
2018 | ||
947216bf AM |
2019 | loc = spltrel->contents; |
2020 | loc += spltrel->reloc_count++ * sizeof (Elf64_External_Rela); | |
2021 | bfd_elf64_swap_reloca_out (splt->output_section->owner, &rel, loc); | |
15bda425 JL |
2022 | } |
2023 | ||
2024 | /* Initialize an external call stub entry if requested. */ | |
2025 | if (dyn_h && dyn_h->want_stub | |
2026 | && elf64_hppa_dynamic_symbol_p (dyn_h->h, info)) | |
2027 | { | |
2028 | bfd_vma value; | |
2029 | int insn; | |
b352eebf | 2030 | unsigned int max_offset; |
15bda425 | 2031 | |
f12123c0 | 2032 | BFD_ASSERT (stub != NULL); |
d663e1cd | 2033 | |
15bda425 JL |
2034 | /* Install the generic stub template. |
2035 | ||
2036 | We are modifying the contents of the stub section, so we do not | |
2037 | need to include the stub section's output_offset here. */ | |
2038 | memcpy (stub->contents + dyn_h->stub_offset, plt_stub, sizeof (plt_stub)); | |
2039 | ||
2040 | /* Fix up the first ldd instruction. | |
2041 | ||
2042 | We are modifying the contents of the STUB section in memory, | |
fe8bc63d | 2043 | so we do not need to include its output offset in this computation. |
15bda425 JL |
2044 | |
2045 | Note the plt_offset value is the value of the PLT entry relative to | |
2046 | the start of the PLT section. These instructions will reference | |
2047 | data relative to the value of __gp, which may not necessarily have | |
2048 | the same address as the start of the PLT section. | |
2049 | ||
2050 | gp_offset contains the offset of __gp within the PLT section. */ | |
2051 | value = dyn_h->plt_offset - hppa_info->gp_offset; | |
fe8bc63d | 2052 | |
15bda425 | 2053 | insn = bfd_get_32 (stub->owner, stub->contents + dyn_h->stub_offset); |
b352eebf AM |
2054 | if (output_bfd->arch_info->mach >= 25) |
2055 | { | |
2056 | /* Wide mode allows 16 bit offsets. */ | |
2057 | max_offset = 32768; | |
2058 | insn &= ~ 0xfff1; | |
dc810e39 | 2059 | insn |= re_assemble_16 ((int) value); |
b352eebf AM |
2060 | } |
2061 | else | |
2062 | { | |
2063 | max_offset = 8192; | |
2064 | insn &= ~ 0x3ff1; | |
dc810e39 | 2065 | insn |= re_assemble_14 ((int) value); |
b352eebf AM |
2066 | } |
2067 | ||
2068 | if ((value & 7) || value + max_offset >= 2*max_offset - 8) | |
2069 | { | |
2070 | (*_bfd_error_handler) (_("stub entry for %s cannot load .plt, dp offset = %ld"), | |
2071 | dyn_h->root.string, | |
2072 | (long) value); | |
b34976b6 | 2073 | return FALSE; |
b352eebf AM |
2074 | } |
2075 | ||
dc810e39 | 2076 | bfd_put_32 (stub->owner, (bfd_vma) insn, |
15bda425 JL |
2077 | stub->contents + dyn_h->stub_offset); |
2078 | ||
2079 | /* Fix up the second ldd instruction. */ | |
b352eebf | 2080 | value += 8; |
15bda425 | 2081 | insn = bfd_get_32 (stub->owner, stub->contents + dyn_h->stub_offset + 8); |
b352eebf AM |
2082 | if (output_bfd->arch_info->mach >= 25) |
2083 | { | |
2084 | insn &= ~ 0xfff1; | |
dc810e39 | 2085 | insn |= re_assemble_16 ((int) value); |
b352eebf AM |
2086 | } |
2087 | else | |
2088 | { | |
2089 | insn &= ~ 0x3ff1; | |
dc810e39 | 2090 | insn |= re_assemble_14 ((int) value); |
b352eebf | 2091 | } |
dc810e39 | 2092 | bfd_put_32 (stub->owner, (bfd_vma) insn, |
15bda425 JL |
2093 | stub->contents + dyn_h->stub_offset + 8); |
2094 | } | |
2095 | ||
b34976b6 | 2096 | return TRUE; |
15bda425 JL |
2097 | } |
2098 | ||
2099 | /* The .opd section contains FPTRs for each function this file | |
2100 | exports. Initialize the FPTR entries. */ | |
2101 | ||
b34976b6 | 2102 | static bfd_boolean |
15bda425 JL |
2103 | elf64_hppa_finalize_opd (dyn_h, data) |
2104 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
2105 | PTR data; | |
2106 | { | |
2107 | struct bfd_link_info *info = (struct bfd_link_info *)data; | |
2108 | struct elf64_hppa_link_hash_table *hppa_info; | |
3db4b612 | 2109 | struct elf_link_hash_entry *h = dyn_h ? dyn_h->h : NULL; |
15bda425 JL |
2110 | asection *sopd; |
2111 | asection *sopdrel; | |
2112 | ||
2113 | hppa_info = elf64_hppa_hash_table (info); | |
2114 | sopd = hppa_info->opd_sec; | |
2115 | sopdrel = hppa_info->opd_rel_sec; | |
2116 | ||
3db4b612 | 2117 | if (h && dyn_h->want_opd) |
15bda425 JL |
2118 | { |
2119 | bfd_vma value; | |
2120 | ||
fe8bc63d | 2121 | /* The first two words of an .opd entry are zero. |
15bda425 JL |
2122 | |
2123 | We are modifying the contents of the OPD section in memory, so we | |
2124 | do not need to include its output offset in this computation. */ | |
2125 | memset (sopd->contents + dyn_h->opd_offset, 0, 16); | |
2126 | ||
2127 | value = (h->root.u.def.value | |
2128 | + h->root.u.def.section->output_section->vma | |
2129 | + h->root.u.def.section->output_offset); | |
2130 | ||
2131 | /* The next word is the address of the function. */ | |
2132 | bfd_put_64 (sopd->owner, value, sopd->contents + dyn_h->opd_offset + 16); | |
2133 | ||
2134 | /* The last word is our local __gp value. */ | |
2135 | value = _bfd_get_gp_value (sopd->output_section->owner); | |
2136 | bfd_put_64 (sopd->owner, value, sopd->contents + dyn_h->opd_offset + 24); | |
2137 | } | |
2138 | ||
2139 | /* If we are generating a shared library, we must generate EPLT relocations | |
2140 | for each entry in the .opd, even for static functions (they may have | |
2141 | had their address taken). */ | |
2142 | if (info->shared && dyn_h && dyn_h->want_opd) | |
2143 | { | |
947216bf AM |
2144 | Elf_Internal_Rela rel; |
2145 | bfd_byte *loc; | |
15bda425 JL |
2146 | int dynindx; |
2147 | ||
2148 | /* We may need to do a relocation against a local symbol, in | |
2149 | which case we have to look up it's dynamic symbol index off | |
2150 | the local symbol hash table. */ | |
2151 | if (h && h->dynindx != -1) | |
2152 | dynindx = h->dynindx; | |
2153 | else | |
2154 | dynindx | |
2155 | = _bfd_elf_link_lookup_local_dynindx (info, dyn_h->owner, | |
2156 | dyn_h->sym_indx); | |
2157 | ||
2158 | /* The offset of this relocation is the absolute address of the | |
2159 | .opd entry for this symbol. */ | |
2160 | rel.r_offset = (dyn_h->opd_offset + sopd->output_offset | |
2161 | + sopd->output_section->vma); | |
2162 | ||
2163 | /* If H is non-null, then we have an external symbol. | |
2164 | ||
2165 | It is imperative that we use a different dynamic symbol for the | |
2166 | EPLT relocation if the symbol has global scope. | |
2167 | ||
2168 | In the dynamic symbol table, the function symbol will have a value | |
2169 | which is address of the function's .opd entry. | |
2170 | ||
2171 | Thus, we can not use that dynamic symbol for the EPLT relocation | |
2172 | (if we did, the data in the .opd would reference itself rather | |
2173 | than the actual address of the function). Instead we have to use | |
2174 | a new dynamic symbol which has the same value as the original global | |
fe8bc63d | 2175 | function symbol. |
15bda425 JL |
2176 | |
2177 | We prefix the original symbol with a "." and use the new symbol in | |
2178 | the EPLT relocation. This new symbol has already been recorded in | |
2179 | the symbol table, we just have to look it up and use it. | |
2180 | ||
2181 | We do not have such problems with static functions because we do | |
2182 | not make their addresses in the dynamic symbol table point to | |
2183 | the .opd entry. Ultimately this should be safe since a static | |
2184 | function can not be directly referenced outside of its shared | |
2185 | library. | |
2186 | ||
2187 | We do have to play similar games for FPTR relocations in shared | |
2188 | libraries, including those for static symbols. See the FPTR | |
2189 | handling in elf64_hppa_finalize_dynreloc. */ | |
2190 | if (h) | |
2191 | { | |
2192 | char *new_name; | |
2193 | struct elf_link_hash_entry *nh; | |
2194 | ||
2195 | new_name = alloca (strlen (h->root.root.string) + 2); | |
2196 | new_name[0] = '.'; | |
2197 | strcpy (new_name + 1, h->root.root.string); | |
2198 | ||
2199 | nh = elf_link_hash_lookup (elf_hash_table (info), | |
b34976b6 | 2200 | new_name, FALSE, FALSE, FALSE); |
15bda425 JL |
2201 | |
2202 | /* All we really want from the new symbol is its dynamic | |
2203 | symbol index. */ | |
2204 | dynindx = nh->dynindx; | |
2205 | } | |
2206 | ||
2207 | rel.r_addend = 0; | |
2208 | rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_EPLT); | |
2209 | ||
947216bf AM |
2210 | loc = sopdrel->contents; |
2211 | loc += sopdrel->reloc_count++ * sizeof (Elf64_External_Rela); | |
2212 | bfd_elf64_swap_reloca_out (sopd->output_section->owner, &rel, loc); | |
15bda425 | 2213 | } |
b34976b6 | 2214 | return TRUE; |
15bda425 JL |
2215 | } |
2216 | ||
2217 | /* The .dlt section contains addresses for items referenced through the | |
2218 | dlt. Note that we can have a DLTIND relocation for a local symbol, thus | |
2219 | we can not depend on finish_dynamic_symbol to initialize the .dlt. */ | |
2220 | ||
b34976b6 | 2221 | static bfd_boolean |
15bda425 JL |
2222 | elf64_hppa_finalize_dlt (dyn_h, data) |
2223 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
2224 | PTR data; | |
2225 | { | |
2226 | struct bfd_link_info *info = (struct bfd_link_info *)data; | |
2227 | struct elf64_hppa_link_hash_table *hppa_info; | |
2228 | asection *sdlt, *sdltrel; | |
3db4b612 | 2229 | struct elf_link_hash_entry *h = dyn_h ? dyn_h->h : NULL; |
15bda425 JL |
2230 | |
2231 | hppa_info = elf64_hppa_hash_table (info); | |
2232 | ||
2233 | sdlt = hppa_info->dlt_sec; | |
2234 | sdltrel = hppa_info->dlt_rel_sec; | |
2235 | ||
2236 | /* H/DYN_H may refer to a local variable and we know it's | |
2237 | address, so there is no need to create a relocation. Just install | |
2238 | the proper value into the DLT, note this shortcut can not be | |
2239 | skipped when building a shared library. */ | |
3db4b612 | 2240 | if (! info->shared && h && dyn_h->want_dlt) |
15bda425 JL |
2241 | { |
2242 | bfd_vma value; | |
2243 | ||
2244 | /* If we had an LTOFF_FPTR style relocation we want the DLT entry | |
fe8bc63d | 2245 | to point to the FPTR entry in the .opd section. |
15bda425 JL |
2246 | |
2247 | We include the OPD's output offset in this computation as | |
2248 | we are referring to an absolute address in the resulting | |
2249 | object file. */ | |
2250 | if (dyn_h->want_opd) | |
2251 | { | |
2252 | value = (dyn_h->opd_offset | |
2253 | + hppa_info->opd_sec->output_offset | |
2254 | + hppa_info->opd_sec->output_section->vma); | |
2255 | } | |
37f4508b AM |
2256 | else if ((h->root.type == bfd_link_hash_defined |
2257 | || h->root.type == bfd_link_hash_defweak) | |
2258 | && h->root.u.def.section) | |
15bda425 | 2259 | { |
3db4b612 | 2260 | value = h->root.u.def.value + h->root.u.def.section->output_offset; |
15bda425 JL |
2261 | if (h->root.u.def.section->output_section) |
2262 | value += h->root.u.def.section->output_section->vma; | |
2263 | else | |
2264 | value += h->root.u.def.section->vma; | |
2265 | } | |
3db4b612 JL |
2266 | else |
2267 | /* We have an undefined function reference. */ | |
2268 | value = 0; | |
15bda425 JL |
2269 | |
2270 | /* We do not need to include the output offset of the DLT section | |
2271 | here because we are modifying the in-memory contents. */ | |
2272 | bfd_put_64 (sdlt->owner, value, sdlt->contents + dyn_h->dlt_offset); | |
2273 | } | |
2274 | ||
4cc11e76 | 2275 | /* Create a relocation for the DLT entry associated with this symbol. |
15bda425 JL |
2276 | When building a shared library the symbol does not have to be dynamic. */ |
2277 | if (dyn_h->want_dlt | |
2278 | && (elf64_hppa_dynamic_symbol_p (dyn_h->h, info) || info->shared)) | |
2279 | { | |
947216bf AM |
2280 | Elf_Internal_Rela rel; |
2281 | bfd_byte *loc; | |
15bda425 JL |
2282 | int dynindx; |
2283 | ||
2284 | /* We may need to do a relocation against a local symbol, in | |
2285 | which case we have to look up it's dynamic symbol index off | |
2286 | the local symbol hash table. */ | |
2287 | if (h && h->dynindx != -1) | |
2288 | dynindx = h->dynindx; | |
2289 | else | |
2290 | dynindx | |
2291 | = _bfd_elf_link_lookup_local_dynindx (info, dyn_h->owner, | |
2292 | dyn_h->sym_indx); | |
2293 | ||
15bda425 JL |
2294 | /* Create a dynamic relocation for this entry. Do include the output |
2295 | offset of the DLT entry since we need an absolute address in the | |
2296 | resulting object file. */ | |
2297 | rel.r_offset = (dyn_h->dlt_offset + sdlt->output_offset | |
2298 | + sdlt->output_section->vma); | |
2299 | if (h && h->type == STT_FUNC) | |
2300 | rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_FPTR64); | |
2301 | else | |
2302 | rel.r_info = ELF64_R_INFO (dynindx, R_PARISC_DIR64); | |
2303 | rel.r_addend = 0; | |
2304 | ||
947216bf AM |
2305 | loc = sdltrel->contents; |
2306 | loc += sdltrel->reloc_count++ * sizeof (Elf64_External_Rela); | |
2307 | bfd_elf64_swap_reloca_out (sdlt->output_section->owner, &rel, loc); | |
15bda425 | 2308 | } |
b34976b6 | 2309 | return TRUE; |
15bda425 JL |
2310 | } |
2311 | ||
2312 | /* Finalize the dynamic relocations. Specifically the FPTR relocations | |
2313 | for dynamic functions used to initialize static data. */ | |
2314 | ||
b34976b6 | 2315 | static bfd_boolean |
15bda425 JL |
2316 | elf64_hppa_finalize_dynreloc (dyn_h, data) |
2317 | struct elf64_hppa_dyn_hash_entry *dyn_h; | |
2318 | PTR data; | |
2319 | { | |
2320 | struct bfd_link_info *info = (struct bfd_link_info *)data; | |
2321 | struct elf64_hppa_link_hash_table *hppa_info; | |
2322 | struct elf_link_hash_entry *h; | |
2323 | int dynamic_symbol; | |
2324 | ||
2325 | dynamic_symbol = elf64_hppa_dynamic_symbol_p (dyn_h->h, info); | |
2326 | ||
2327 | if (!dynamic_symbol && !info->shared) | |
b34976b6 | 2328 | return TRUE; |
15bda425 JL |
2329 | |
2330 | if (dyn_h->reloc_entries) | |
2331 | { | |
2332 | struct elf64_hppa_dyn_reloc_entry *rent; | |
2333 | int dynindx; | |
2334 | ||
2335 | hppa_info = elf64_hppa_hash_table (info); | |
2336 | h = dyn_h->h; | |
2337 | ||
2338 | /* We may need to do a relocation against a local symbol, in | |
2339 | which case we have to look up it's dynamic symbol index off | |
2340 | the local symbol hash table. */ | |
2341 | if (h && h->dynindx != -1) | |
2342 | dynindx = h->dynindx; | |
2343 | else | |
2344 | dynindx | |
2345 | = _bfd_elf_link_lookup_local_dynindx (info, dyn_h->owner, | |
2346 | dyn_h->sym_indx); | |
2347 | ||
2348 | for (rent = dyn_h->reloc_entries; rent; rent = rent->next) | |
2349 | { | |
947216bf AM |
2350 | Elf_Internal_Rela rel; |
2351 | bfd_byte *loc; | |
15bda425 | 2352 | |
d663e1cd JL |
2353 | /* Allocate one iff we are building a shared library, the relocation |
2354 | isn't a R_PARISC_FPTR64, or we don't want an opd entry. */ | |
2355 | if (!info->shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd) | |
2356 | continue; | |
15bda425 | 2357 | |
fe8bc63d | 2358 | /* Create a dynamic relocation for this entry. |
15bda425 JL |
2359 | |
2360 | We need the output offset for the reloc's section because | |
2361 | we are creating an absolute address in the resulting object | |
2362 | file. */ | |
2363 | rel.r_offset = (rent->offset + rent->sec->output_offset | |
2364 | + rent->sec->output_section->vma); | |
2365 | ||
2366 | /* An FPTR64 relocation implies that we took the address of | |
2367 | a function and that the function has an entry in the .opd | |
2368 | section. We want the FPTR64 relocation to reference the | |
2369 | entry in .opd. | |
2370 | ||
2371 | We could munge the symbol value in the dynamic symbol table | |
2372 | (in fact we already do for functions with global scope) to point | |
2373 | to the .opd entry. Then we could use that dynamic symbol in | |
2374 | this relocation. | |
2375 | ||
2376 | Or we could do something sensible, not munge the symbol's | |
2377 | address and instead just use a different symbol to reference | |
2378 | the .opd entry. At least that seems sensible until you | |
2379 | realize there's no local dynamic symbols we can use for that | |
2380 | purpose. Thus the hair in the check_relocs routine. | |
fe8bc63d | 2381 | |
15bda425 JL |
2382 | We use a section symbol recorded by check_relocs as the |
2383 | base symbol for the relocation. The addend is the difference | |
2384 | between the section symbol and the address of the .opd entry. */ | |
3db4b612 | 2385 | if (info->shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd) |
15bda425 JL |
2386 | { |
2387 | bfd_vma value, value2; | |
15bda425 JL |
2388 | |
2389 | /* First compute the address of the opd entry for this symbol. */ | |
2390 | value = (dyn_h->opd_offset | |
2391 | + hppa_info->opd_sec->output_section->vma | |
2392 | + hppa_info->opd_sec->output_offset); | |
2393 | ||
2394 | /* Compute the value of the start of the section with | |
2395 | the relocation. */ | |
2396 | value2 = (rent->sec->output_section->vma | |
2397 | + rent->sec->output_offset); | |
2398 | ||
2399 | /* Compute the difference between the start of the section | |
2400 | with the relocation and the opd entry. */ | |
2401 | value -= value2; | |
fe8bc63d | 2402 | |
15bda425 JL |
2403 | /* The result becomes the addend of the relocation. */ |
2404 | rel.r_addend = value; | |
2405 | ||
2406 | /* The section symbol becomes the symbol for the dynamic | |
2407 | relocation. */ | |
2408 | dynindx | |
2409 | = _bfd_elf_link_lookup_local_dynindx (info, | |
2410 | rent->sec->owner, | |
2411 | rent->sec_symndx); | |
2412 | } | |
2413 | else | |
2414 | rel.r_addend = rent->addend; | |
2415 | ||
2416 | rel.r_info = ELF64_R_INFO (dynindx, rent->type); | |
2417 | ||
947216bf AM |
2418 | loc = hppa_info->other_rel_sec->contents; |
2419 | loc += (hppa_info->other_rel_sec->reloc_count++ | |
2420 | * sizeof (Elf64_External_Rela)); | |
15bda425 | 2421 | bfd_elf64_swap_reloca_out (hppa_info->other_rel_sec->output_section->owner, |
947216bf | 2422 | &rel, loc); |
15bda425 JL |
2423 | } |
2424 | } | |
2425 | ||
b34976b6 | 2426 | return TRUE; |
15bda425 JL |
2427 | } |
2428 | ||
5ac81c74 JL |
2429 | /* Used to decide how to sort relocs in an optimal manner for the |
2430 | dynamic linker, before writing them out. */ | |
2431 | ||
2432 | static enum elf_reloc_type_class | |
2433 | elf64_hppa_reloc_type_class (rela) | |
2434 | const Elf_Internal_Rela *rela; | |
2435 | { | |
2436 | if (ELF64_R_SYM (rela->r_info) == 0) | |
2437 | return reloc_class_relative; | |
2438 | ||
2439 | switch ((int) ELF64_R_TYPE (rela->r_info)) | |
2440 | { | |
2441 | case R_PARISC_IPLT: | |
2442 | return reloc_class_plt; | |
2443 | case R_PARISC_COPY: | |
2444 | return reloc_class_copy; | |
2445 | default: | |
2446 | return reloc_class_normal; | |
2447 | } | |
2448 | } | |
2449 | ||
15bda425 JL |
2450 | /* Finish up the dynamic sections. */ |
2451 | ||
b34976b6 | 2452 | static bfd_boolean |
15bda425 JL |
2453 | elf64_hppa_finish_dynamic_sections (output_bfd, info) |
2454 | bfd *output_bfd; | |
2455 | struct bfd_link_info *info; | |
2456 | { | |
2457 | bfd *dynobj; | |
2458 | asection *sdyn; | |
2459 | struct elf64_hppa_link_hash_table *hppa_info; | |
2460 | ||
2461 | hppa_info = elf64_hppa_hash_table (info); | |
2462 | ||
2463 | /* Finalize the contents of the .opd section. */ | |
2464 | elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, | |
2465 | elf64_hppa_finalize_opd, | |
2466 | info); | |
2467 | ||
2468 | elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, | |
2469 | elf64_hppa_finalize_dynreloc, | |
2470 | info); | |
2471 | ||
2472 | /* Finalize the contents of the .dlt section. */ | |
2473 | dynobj = elf_hash_table (info)->dynobj; | |
2474 | /* Finalize the contents of the .dlt section. */ | |
2475 | elf64_hppa_dyn_hash_traverse (&hppa_info->dyn_hash_table, | |
2476 | elf64_hppa_finalize_dlt, | |
2477 | info); | |
2478 | ||
15bda425 JL |
2479 | sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); |
2480 | ||
2481 | if (elf_hash_table (info)->dynamic_sections_created) | |
2482 | { | |
2483 | Elf64_External_Dyn *dyncon, *dynconend; | |
15bda425 JL |
2484 | |
2485 | BFD_ASSERT (sdyn != NULL); | |
2486 | ||
2487 | dyncon = (Elf64_External_Dyn *) sdyn->contents; | |
eea6121a | 2488 | dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); |
15bda425 JL |
2489 | for (; dyncon < dynconend; dyncon++) |
2490 | { | |
2491 | Elf_Internal_Dyn dyn; | |
2492 | asection *s; | |
2493 | ||
2494 | bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn); | |
2495 | ||
2496 | switch (dyn.d_tag) | |
2497 | { | |
2498 | default: | |
2499 | break; | |
2500 | ||
2501 | case DT_HP_LOAD_MAP: | |
2502 | /* Compute the absolute address of 16byte scratchpad area | |
2503 | for the dynamic linker. | |
2504 | ||
2505 | By convention the linker script will allocate the scratchpad | |
2506 | area at the start of the .data section. So all we have to | |
2507 | to is find the start of the .data section. */ | |
2508 | s = bfd_get_section_by_name (output_bfd, ".data"); | |
2509 | dyn.d_un.d_ptr = s->vma; | |
2510 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); | |
2511 | break; | |
2512 | ||
2513 | case DT_PLTGOT: | |
2514 | /* HP's use PLTGOT to set the GOT register. */ | |
2515 | dyn.d_un.d_ptr = _bfd_get_gp_value (output_bfd); | |
2516 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); | |
2517 | break; | |
2518 | ||
2519 | case DT_JMPREL: | |
2520 | s = hppa_info->plt_rel_sec; | |
2521 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; | |
2522 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); | |
2523 | break; | |
2524 | ||
2525 | case DT_PLTRELSZ: | |
2526 | s = hppa_info->plt_rel_sec; | |
eea6121a | 2527 | dyn.d_un.d_val = s->size; |
15bda425 JL |
2528 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); |
2529 | break; | |
2530 | ||
2531 | case DT_RELA: | |
2532 | s = hppa_info->other_rel_sec; | |
eea6121a | 2533 | if (! s || ! s->size) |
15bda425 | 2534 | s = hppa_info->dlt_rel_sec; |
eea6121a | 2535 | if (! s || ! s->size) |
5ac81c74 | 2536 | s = hppa_info->opd_rel_sec; |
15bda425 JL |
2537 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; |
2538 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); | |
2539 | break; | |
2540 | ||
2541 | case DT_RELASZ: | |
2542 | s = hppa_info->other_rel_sec; | |
eea6121a | 2543 | dyn.d_un.d_val = s->size; |
15bda425 | 2544 | s = hppa_info->dlt_rel_sec; |
eea6121a | 2545 | dyn.d_un.d_val += s->size; |
15bda425 | 2546 | s = hppa_info->opd_rel_sec; |
eea6121a | 2547 | dyn.d_un.d_val += s->size; |
15bda425 JL |
2548 | /* There is some question about whether or not the size of |
2549 | the PLT relocs should be included here. HP's tools do | |
2550 | it, so we'll emulate them. */ | |
2551 | s = hppa_info->plt_rel_sec; | |
eea6121a | 2552 | dyn.d_un.d_val += s->size; |
15bda425 JL |
2553 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); |
2554 | break; | |
2555 | ||
2556 | } | |
2557 | } | |
2558 | } | |
2559 | ||
b34976b6 | 2560 | return TRUE; |
15bda425 JL |
2561 | } |
2562 | ||
235ecfbc NC |
2563 | /* Support for core dump NOTE sections. */ |
2564 | ||
2565 | static bfd_boolean | |
2566 | elf64_hppa_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) | |
2567 | { | |
2568 | int offset; | |
2569 | size_t size; | |
2570 | ||
2571 | switch (note->descsz) | |
2572 | { | |
2573 | default: | |
2574 | return FALSE; | |
2575 | ||
2576 | case 760: /* Linux/hppa */ | |
2577 | /* pr_cursig */ | |
2578 | elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); | |
2579 | ||
2580 | /* pr_pid */ | |
2581 | elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32); | |
2582 | ||
2583 | /* pr_reg */ | |
2584 | offset = 112; | |
2585 | size = 640; | |
2586 | ||
2587 | break; | |
2588 | } | |
2589 | ||
2590 | /* Make a ".reg/999" section. */ | |
2591 | return _bfd_elfcore_make_pseudosection (abfd, ".reg", | |
2592 | size, note->descpos + offset); | |
2593 | } | |
2594 | ||
2595 | static bfd_boolean | |
2596 | elf64_hppa_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) | |
2597 | { | |
2598 | char * command; | |
2599 | int n; | |
2600 | ||
2601 | switch (note->descsz) | |
2602 | { | |
2603 | default: | |
2604 | return FALSE; | |
2605 | ||
2606 | case 136: /* Linux/hppa elf_prpsinfo. */ | |
2607 | elf_tdata (abfd)->core_program | |
2608 | = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16); | |
2609 | elf_tdata (abfd)->core_command | |
2610 | = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80); | |
2611 | } | |
2612 | ||
2613 | /* Note that for some reason, a spurious space is tacked | |
2614 | onto the end of the args in some (at least one anyway) | |
2615 | implementations, so strip it off if it exists. */ | |
2616 | command = elf_tdata (abfd)->core_command; | |
2617 | n = strlen (command); | |
2618 | ||
2619 | if (0 < n && command[n - 1] == ' ') | |
2620 | command[n - 1] = '\0'; | |
2621 | ||
2622 | return TRUE; | |
2623 | } | |
2624 | ||
15bda425 JL |
2625 | /* Return the number of additional phdrs we will need. |
2626 | ||
2627 | The generic ELF code only creates PT_PHDRs for executables. The HP | |
fe8bc63d | 2628 | dynamic linker requires PT_PHDRs for dynamic libraries too. |
15bda425 JL |
2629 | |
2630 | This routine indicates that the backend needs one additional program | |
2631 | header for that case. | |
2632 | ||
2633 | Note we do not have access to the link info structure here, so we have | |
2634 | to guess whether or not we are building a shared library based on the | |
2635 | existence of a .interp section. */ | |
2636 | ||
2637 | static int | |
a6b96beb AM |
2638 | elf64_hppa_additional_program_headers (bfd *abfd, |
2639 | struct bfd_link_info *info ATTRIBUTE_UNUSED) | |
15bda425 JL |
2640 | { |
2641 | asection *s; | |
2642 | ||
2643 | /* If we are creating a shared library, then we have to create a | |
2644 | PT_PHDR segment. HP's dynamic linker chokes without it. */ | |
2645 | s = bfd_get_section_by_name (abfd, ".interp"); | |
2646 | if (! s) | |
2647 | return 1; | |
2648 | return 0; | |
2649 | } | |
2650 | ||
2651 | /* Allocate and initialize any program headers required by this | |
2652 | specific backend. | |
2653 | ||
2654 | The generic ELF code only creates PT_PHDRs for executables. The HP | |
fe8bc63d | 2655 | dynamic linker requires PT_PHDRs for dynamic libraries too. |
15bda425 JL |
2656 | |
2657 | This allocates the PT_PHDR and initializes it in a manner suitable | |
fe8bc63d | 2658 | for the HP linker. |
15bda425 JL |
2659 | |
2660 | Note we do not have access to the link info structure here, so we have | |
2661 | to guess whether or not we are building a shared library based on the | |
2662 | existence of a .interp section. */ | |
2663 | ||
b34976b6 | 2664 | static bfd_boolean |
8ded5a0f AM |
2665 | elf64_hppa_modify_segment_map (bfd *abfd, |
2666 | struct bfd_link_info *info ATTRIBUTE_UNUSED) | |
15bda425 | 2667 | { |
edd21aca | 2668 | struct elf_segment_map *m; |
15bda425 JL |
2669 | asection *s; |
2670 | ||
2671 | s = bfd_get_section_by_name (abfd, ".interp"); | |
2672 | if (! s) | |
2673 | { | |
2674 | for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) | |
2675 | if (m->p_type == PT_PHDR) | |
2676 | break; | |
2677 | if (m == NULL) | |
2678 | { | |
dc810e39 AM |
2679 | m = ((struct elf_segment_map *) |
2680 | bfd_zalloc (abfd, (bfd_size_type) sizeof *m)); | |
15bda425 | 2681 | if (m == NULL) |
b34976b6 | 2682 | return FALSE; |
15bda425 JL |
2683 | |
2684 | m->p_type = PT_PHDR; | |
2685 | m->p_flags = PF_R | PF_X; | |
2686 | m->p_flags_valid = 1; | |
2687 | m->p_paddr_valid = 1; | |
2688 | m->includes_phdrs = 1; | |
2689 | ||
2690 | m->next = elf_tdata (abfd)->segment_map; | |
2691 | elf_tdata (abfd)->segment_map = m; | |
2692 | } | |
2693 | } | |
2694 | ||
2695 | for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) | |
2696 | if (m->p_type == PT_LOAD) | |
2697 | { | |
0ba2a60e | 2698 | unsigned int i; |
15bda425 JL |
2699 | |
2700 | for (i = 0; i < m->count; i++) | |
2701 | { | |
2702 | /* The code "hint" is not really a hint. It is a requirement | |
2703 | for certain versions of the HP dynamic linker. Worse yet, | |
2704 | it must be set even if the shared library does not have | |
2705 | any code in its "text" segment (thus the check for .hash | |
2706 | to catch this situation). */ | |
2707 | if (m->sections[i]->flags & SEC_CODE | |
2708 | || (strcmp (m->sections[i]->name, ".hash") == 0)) | |
2709 | m->p_flags |= (PF_X | PF_HP_CODE); | |
2710 | } | |
2711 | } | |
2712 | ||
b34976b6 | 2713 | return TRUE; |
15bda425 JL |
2714 | } |
2715 | ||
3fab46d0 AM |
2716 | /* Called when writing out an object file to decide the type of a |
2717 | symbol. */ | |
2718 | static int | |
2719 | elf64_hppa_elf_get_symbol_type (elf_sym, type) | |
2720 | Elf_Internal_Sym *elf_sym; | |
2721 | int type; | |
2722 | { | |
2723 | if (ELF_ST_TYPE (elf_sym->st_info) == STT_PARISC_MILLI) | |
2724 | return STT_PARISC_MILLI; | |
2725 | else | |
2726 | return type; | |
2727 | } | |
2728 | ||
d97a8924 DA |
2729 | /* Support HP specific sections for core files. */ |
2730 | static bfd_boolean | |
2731 | elf64_hppa_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int index, | |
2732 | const char *typename) | |
2733 | { | |
927e625f MK |
2734 | if (hdr->p_type == PT_HP_CORE_KERNEL) |
2735 | { | |
2736 | asection *sect; | |
2737 | ||
2738 | if (!_bfd_elf_make_section_from_phdr (abfd, hdr, index, typename)) | |
2739 | return FALSE; | |
2740 | ||
2741 | sect = bfd_make_section_anyway (abfd, ".kernel"); | |
2742 | if (sect == NULL) | |
2743 | return FALSE; | |
2744 | sect->size = hdr->p_filesz; | |
2745 | sect->filepos = hdr->p_offset; | |
2746 | sect->flags = SEC_HAS_CONTENTS | SEC_READONLY; | |
2747 | return TRUE; | |
2748 | } | |
2749 | ||
d97a8924 DA |
2750 | if (hdr->p_type == PT_HP_CORE_PROC) |
2751 | { | |
2752 | int sig; | |
2753 | ||
2754 | if (bfd_seek (abfd, hdr->p_offset, SEEK_SET) != 0) | |
2755 | return FALSE; | |
2756 | if (bfd_bread (&sig, 4, abfd) != 4) | |
2757 | return FALSE; | |
2758 | ||
2759 | elf_tdata (abfd)->core_signal = sig; | |
2760 | ||
927e625f | 2761 | if (!_bfd_elf_make_section_from_phdr (abfd, hdr, index, typename)) |
d97a8924 | 2762 | return FALSE; |
927e625f MK |
2763 | |
2764 | /* GDB uses the ".reg" section to read register contents. */ | |
2765 | return _bfd_elfcore_make_pseudosection (abfd, ".reg", hdr->p_filesz, | |
2766 | hdr->p_offset); | |
d97a8924 DA |
2767 | } |
2768 | ||
2769 | if (hdr->p_type == PT_HP_CORE_LOADABLE | |
2770 | || hdr->p_type == PT_HP_CORE_STACK | |
2771 | || hdr->p_type == PT_HP_CORE_MMF) | |
2772 | hdr->p_type = PT_LOAD; | |
2773 | ||
2774 | return _bfd_elf_make_section_from_phdr (abfd, hdr, index, typename); | |
2775 | } | |
2776 | ||
b35d266b | 2777 | static const struct bfd_elf_special_section elf64_hppa_special_sections[] = |
2f89ff8d | 2778 | { |
0112cd26 NC |
2779 | { STRING_COMMA_LEN (".fini"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, |
2780 | { STRING_COMMA_LEN (".init"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, | |
2781 | { STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, | |
2782 | { STRING_COMMA_LEN (".dlt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, | |
2783 | { STRING_COMMA_LEN (".sdata"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, | |
2784 | { STRING_COMMA_LEN (".sbss"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, | |
2785 | { STRING_COMMA_LEN (".tbss"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_HP_TLS }, | |
2786 | { NULL, 0, 0, 0, 0 } | |
2f89ff8d L |
2787 | }; |
2788 | ||
15bda425 JL |
2789 | /* The hash bucket size is the standard one, namely 4. */ |
2790 | ||
2791 | const struct elf_size_info hppa64_elf_size_info = | |
2792 | { | |
2793 | sizeof (Elf64_External_Ehdr), | |
2794 | sizeof (Elf64_External_Phdr), | |
2795 | sizeof (Elf64_External_Shdr), | |
2796 | sizeof (Elf64_External_Rel), | |
2797 | sizeof (Elf64_External_Rela), | |
2798 | sizeof (Elf64_External_Sym), | |
2799 | sizeof (Elf64_External_Dyn), | |
2800 | sizeof (Elf_External_Note), | |
2801 | 4, | |
2802 | 1, | |
45d6a902 | 2803 | 64, 3, |
15bda425 JL |
2804 | ELFCLASS64, EV_CURRENT, |
2805 | bfd_elf64_write_out_phdrs, | |
2806 | bfd_elf64_write_shdrs_and_ehdr, | |
1489a3a0 | 2807 | bfd_elf64_checksum_contents, |
15bda425 | 2808 | bfd_elf64_write_relocs, |
73ff0d56 | 2809 | bfd_elf64_swap_symbol_in, |
15bda425 JL |
2810 | bfd_elf64_swap_symbol_out, |
2811 | bfd_elf64_slurp_reloc_table, | |
2812 | bfd_elf64_slurp_symbol_table, | |
2813 | bfd_elf64_swap_dyn_in, | |
2814 | bfd_elf64_swap_dyn_out, | |
947216bf AM |
2815 | bfd_elf64_swap_reloc_in, |
2816 | bfd_elf64_swap_reloc_out, | |
2817 | bfd_elf64_swap_reloca_in, | |
2818 | bfd_elf64_swap_reloca_out | |
15bda425 JL |
2819 | }; |
2820 | ||
2821 | #define TARGET_BIG_SYM bfd_elf64_hppa_vec | |
2822 | #define TARGET_BIG_NAME "elf64-hppa" | |
2823 | #define ELF_ARCH bfd_arch_hppa | |
2824 | #define ELF_MACHINE_CODE EM_PARISC | |
2825 | /* This is not strictly correct. The maximum page size for PA2.0 is | |
2826 | 64M. But everything still uses 4k. */ | |
2827 | #define ELF_MAXPAGESIZE 0x1000 | |
d1036acb L |
2828 | #define ELF_OSABI ELFOSABI_HPUX |
2829 | ||
15bda425 | 2830 | #define bfd_elf64_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup |
157090f7 | 2831 | #define bfd_elf64_bfd_reloc_name_lookup elf_hppa_reloc_name_lookup |
15bda425 JL |
2832 | #define bfd_elf64_bfd_is_local_label_name elf_hppa_is_local_label_name |
2833 | #define elf_info_to_howto elf_hppa_info_to_howto | |
2834 | #define elf_info_to_howto_rel elf_hppa_info_to_howto_rel | |
2835 | ||
2836 | #define elf_backend_section_from_shdr elf64_hppa_section_from_shdr | |
2837 | #define elf_backend_object_p elf64_hppa_object_p | |
2838 | #define elf_backend_final_write_processing \ | |
2839 | elf_hppa_final_write_processing | |
99c79b2e | 2840 | #define elf_backend_fake_sections elf_hppa_fake_sections |
15bda425 JL |
2841 | #define elf_backend_add_symbol_hook elf_hppa_add_symbol_hook |
2842 | ||
f0fe0e16 | 2843 | #define elf_backend_relocate_section elf_hppa_relocate_section |
15bda425 JL |
2844 | |
2845 | #define bfd_elf64_bfd_final_link elf_hppa_final_link | |
2846 | ||
2847 | #define elf_backend_create_dynamic_sections \ | |
2848 | elf64_hppa_create_dynamic_sections | |
2849 | #define elf_backend_post_process_headers elf64_hppa_post_process_headers | |
2850 | ||
74541ad4 AM |
2851 | #define elf_backend_omit_section_dynsym \ |
2852 | ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) | |
15bda425 JL |
2853 | #define elf_backend_adjust_dynamic_symbol \ |
2854 | elf64_hppa_adjust_dynamic_symbol | |
2855 | ||
2856 | #define elf_backend_size_dynamic_sections \ | |
2857 | elf64_hppa_size_dynamic_sections | |
2858 | ||
2859 | #define elf_backend_finish_dynamic_symbol \ | |
2860 | elf64_hppa_finish_dynamic_symbol | |
2861 | #define elf_backend_finish_dynamic_sections \ | |
2862 | elf64_hppa_finish_dynamic_sections | |
235ecfbc NC |
2863 | #define elf_backend_grok_prstatus elf64_hppa_grok_prstatus |
2864 | #define elf_backend_grok_psinfo elf64_hppa_grok_psinfo | |
2865 | ||
15bda425 JL |
2866 | /* Stuff for the BFD linker: */ |
2867 | #define bfd_elf64_bfd_link_hash_table_create \ | |
2868 | elf64_hppa_hash_table_create | |
2869 | ||
2870 | #define elf_backend_check_relocs \ | |
2871 | elf64_hppa_check_relocs | |
2872 | ||
2873 | #define elf_backend_size_info \ | |
2874 | hppa64_elf_size_info | |
2875 | ||
2876 | #define elf_backend_additional_program_headers \ | |
2877 | elf64_hppa_additional_program_headers | |
2878 | ||
2879 | #define elf_backend_modify_segment_map \ | |
2880 | elf64_hppa_modify_segment_map | |
2881 | ||
2882 | #define elf_backend_link_output_symbol_hook \ | |
2883 | elf64_hppa_link_output_symbol_hook | |
2884 | ||
15bda425 JL |
2885 | #define elf_backend_want_got_plt 0 |
2886 | #define elf_backend_plt_readonly 0 | |
2887 | #define elf_backend_want_plt_sym 0 | |
2888 | #define elf_backend_got_header_size 0 | |
b34976b6 AM |
2889 | #define elf_backend_type_change_ok TRUE |
2890 | #define elf_backend_get_symbol_type elf64_hppa_elf_get_symbol_type | |
2891 | #define elf_backend_reloc_type_class elf64_hppa_reloc_type_class | |
2892 | #define elf_backend_rela_normal 1 | |
29ef7005 | 2893 | #define elf_backend_special_sections elf64_hppa_special_sections |
8a696751 | 2894 | #define elf_backend_action_discarded elf_hppa_action_discarded |
d97a8924 | 2895 | #define elf_backend_section_from_phdr elf64_hppa_section_from_phdr |
15bda425 | 2896 | |
83d1651b L |
2897 | #define elf64_bed elf64_hppa_hpux_bed |
2898 | ||
15bda425 | 2899 | #include "elf64-target.h" |
d952f17a AM |
2900 | |
2901 | #undef TARGET_BIG_SYM | |
2902 | #define TARGET_BIG_SYM bfd_elf64_hppa_linux_vec | |
2903 | #undef TARGET_BIG_NAME | |
2904 | #define TARGET_BIG_NAME "elf64-hppa-linux" | |
d1036acb L |
2905 | #undef ELF_OSABI |
2906 | #define ELF_OSABI ELFOSABI_LINUX | |
2907 | #undef elf_backend_post_process_headers | |
2908 | #define elf_backend_post_process_headers _bfd_elf_set_osabi | |
83d1651b L |
2909 | #undef elf64_bed |
2910 | #define elf64_bed elf64_hppa_linux_bed | |
d952f17a | 2911 | |
d952f17a | 2912 | #include "elf64-target.h" |