source: trunk/src/binutils/bfd/elf64-hppa.c@ 10

Last change on this file since 10 was 10, checked in by bird, 22 years ago

Initial revision

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