1 /* BFD back-end for HP PA-RISC ELF files.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001
3 Free Software Foundation, Inc.
6 Center for Software Science
7 Department of Computer Science
9 Largely rewritten by Alan Modra <alan@linuxcare.com.au>
11 This file is part of BFD, the Binary File Descriptor library.
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
33 #include "elf32-hppa.h"
36 #include "elf32-hppa.h"
38 /* In order to gain some understanding of code in this file without
39 knowing all the intricate details of the linker, note the
42 Functions named elf32_hppa_* are called by external routines, other
43 functions are only called locally. elf32_hppa_* functions appear
44 in this file more or less in the order in which they are called
45 from external routines. eg. elf32_hppa_check_relocs is called
46 early in the link process, elf32_hppa_finish_dynamic_sections is
47 one of the last functions. */
49 /* We use two hash tables to hold information for linking PA ELF objects.
51 The first is the elf32_hppa_link_hash_table which is derived
52 from the standard ELF linker hash table. We use this as a place to
53 attach other hash tables and static information.
55 The second is the stub hash table which is derived from the
56 base BFD hash table. The stub hash table holds the information
57 necessary to build the linker stubs during a link.
59 There are a number of different stubs generated by the linker.
67 : addil LR'X - ($PIC_pcrel$0 - 4),%r1
68 : be,n RR'X - ($PIC_pcrel$0 - 8)(%sr4,%r1)
70 Import stub to call shared library routine from normal object file
71 (single sub-space version)
72 : addil LR'lt_ptr+ltoff,%dp ; get procedure entry point
73 : ldw RR'lt_ptr+ltoff(%r1),%r21
75 : ldw RR'lt_ptr+ltoff+4(%r1),%r19 ; get new dlt value.
77 Import stub to call shared library routine from shared library
78 (single sub-space version)
79 : addil LR'ltoff,%r19 ; get procedure entry point
80 : ldw RR'ltoff(%r1),%r21
82 : ldw RR'ltoff+4(%r1),%r19 ; get new dlt value.
84 Import stub to call shared library routine from normal object file
85 (multiple sub-space support)
86 : addil LR'lt_ptr+ltoff,%dp ; get procedure entry point
87 : ldw RR'lt_ptr+ltoff(%r1),%r21
88 : ldw RR'lt_ptr+ltoff+4(%r1),%r19 ; get new dlt value.
91 : be 0(%sr0,%r21) ; branch to target
92 : stw %rp,-24(%sp) ; save rp
94 Import stub to call shared library routine from shared library
95 (multiple sub-space support)
96 : addil LR'ltoff,%r19 ; get procedure entry point
97 : ldw RR'ltoff(%r1),%r21
98 : ldw RR'ltoff+4(%r1),%r19 ; get new dlt value.
101 : be 0(%sr0,%r21) ; branch to target
102 : stw %rp,-24(%sp) ; save rp
104 Export stub to return from shared lib routine (multiple sub-space support)
105 One of these is created for each exported procedure in a shared
106 library (and stored in the shared lib). Shared lib routines are
107 called via the first instruction in the export stub so that we can
108 do an inter-space return. Not required for single sub-space.
109 : bl,n X,%rp ; trap the return
111 : ldw -24(%sp),%rp ; restore the original rp
114 : be,n 0(%sr0,%rp) ; inter-space return */
116 #define PLT_ENTRY_SIZE 8
117 #define PLABEL_PLT_ENTRY_SIZE PLT_ENTRY_SIZE
118 #define GOT_ENTRY_SIZE 4
119 #define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1"
121 static const bfd_byte plt_stub
[] =
123 0x0e, 0x80, 0x10, 0x96, /* 1: ldw 0(%r20),%r22 */
124 0xea, 0xc0, 0xc0, 0x00, /* bv %r0(%r22) */
125 0x0e, 0x88, 0x10, 0x95, /* ldw 4(%r20),%r21 */
126 #define PLT_STUB_ENTRY (3*4)
127 0xea, 0x9f, 0x1f, 0xdd, /* b,l 1b,%r20 */
128 0xd6, 0x80, 0x1c, 0x1e, /* depi 0,31,2,%r20 */
129 0x00, 0xc0, 0xff, 0xee, /* 9: .word fixup_func */
130 0xde, 0xad, 0xbe, 0xef /* .word fixup_ltp */
133 /* Section name for stubs is the associated section name plus this
135 #define STUB_SUFFIX ".stub"
137 /* We don't need to copy certain PC- or GP-relative dynamic relocs
138 into a shared object's dynamic section. All the relocs of the
139 limited class we are interested in, are absolute. */
140 #ifndef RELATIVE_DYNRELOCS
141 #define RELATIVE_DYNRELOCS 0
142 #define IS_ABSOLUTE_RELOC(r_type) 1
145 enum elf32_hppa_stub_type
{
146 hppa_stub_long_branch
,
147 hppa_stub_long_branch_shared
,
149 hppa_stub_import_shared
,
154 struct elf32_hppa_stub_hash_entry
{
156 /* Base hash table entry structure. */
157 struct bfd_hash_entry root
;
159 /* The stub section. */
162 /* Offset within stub_sec of the beginning of this stub. */
165 /* Given the symbol's value and its section we can determine its final
166 value when building the stubs (so the stub knows where to jump. */
167 bfd_vma target_value
;
168 asection
*target_section
;
170 enum elf32_hppa_stub_type stub_type
;
172 /* The symbol table entry, if any, that this was derived from. */
173 struct elf32_hppa_link_hash_entry
*h
;
175 /* Where this stub is being called from, or, in the case of combined
176 stub sections, the first input section in the group. */
180 struct elf32_hppa_link_hash_entry
{
182 struct elf_link_hash_entry elf
;
184 /* A pointer to the most recently used stub hash entry against this
186 struct elf32_hppa_stub_hash_entry
*stub_cache
;
188 /* Used to count relocations for delayed sizing of relocation
190 struct elf32_hppa_dyn_reloc_entry
{
192 /* Next relocation in the chain. */
193 struct elf32_hppa_dyn_reloc_entry
*next
;
195 /* The input section of the reloc. */
198 /* Number of relocs copied in this section. */
201 #if RELATIVE_DYNRELOCS
202 /* Number of relative relocs copied for the input section. */
203 bfd_size_type relative_count
;
207 /* Set during a static link if we detect a function is PIC. */
208 unsigned int maybe_pic_call
:1;
210 /* Set if the only reason we need a .plt entry is for a non-PIC to
211 PIC function call. */
212 unsigned int pic_call
:1;
214 /* Set if this symbol is used by a plabel reloc. */
215 unsigned int plabel
:1;
217 /* Set if this symbol is an init or fini function and thus should
218 use an absolute reloc. */
219 unsigned int plt_abs
:1;
222 struct elf32_hppa_link_hash_table
{
224 /* The main hash table. */
225 struct elf_link_hash_table root
;
227 /* The stub hash table. */
228 struct bfd_hash_table stub_hash_table
;
230 /* Linker stub bfd. */
233 /* Linker call-backs. */
234 asection
* (*add_stub_section
) PARAMS ((const char *, asection
*));
235 void (*layout_sections_again
) PARAMS ((void));
237 /* Array to keep track of which stub sections have been created, and
238 information on stub grouping. */
240 /* This is the section to which stubs in the group will be
243 /* The stub section. */
247 /* Short-cuts to get to dynamic linker sections. */
255 /* Used during a final link to store the base of the text and data
256 segments so that we can perform SEGREL relocations. */
257 bfd_vma text_segment_base
;
258 bfd_vma data_segment_base
;
260 /* Whether we support multiple sub-spaces for shared libs. */
261 unsigned int multi_subspace
:1;
263 /* Flags set when PCREL12F and PCREL17F branches detected. Used to
264 select suitable defaults for the stub group size. */
265 unsigned int has_12bit_branch
:1;
266 unsigned int has_17bit_branch
:1;
268 /* Set if we need a .plt stub to support lazy dynamic linking. */
269 unsigned int need_plt_stub
:1;
272 /* Various hash macros and functions. */
273 #define hppa_link_hash_table(p) \
274 ((struct elf32_hppa_link_hash_table *) ((p)->hash))
276 #define hppa_stub_hash_lookup(table, string, create, copy) \
277 ((struct elf32_hppa_stub_hash_entry *) \
278 bfd_hash_lookup ((table), (string), (create), (copy)))
280 static struct bfd_hash_entry
*stub_hash_newfunc
281 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
283 static struct bfd_hash_entry
*hppa_link_hash_newfunc
284 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
286 static struct bfd_link_hash_table
*elf32_hppa_link_hash_table_create
289 /* Stub handling functions. */
290 static char *hppa_stub_name
291 PARAMS ((const asection
*, const asection
*,
292 const struct elf32_hppa_link_hash_entry
*,
293 const Elf_Internal_Rela
*));
295 static struct elf32_hppa_stub_hash_entry
*hppa_get_stub_entry
296 PARAMS ((const asection
*, const asection
*,
297 struct elf32_hppa_link_hash_entry
*,
298 const Elf_Internal_Rela
*,
299 struct elf32_hppa_link_hash_table
*));
301 static struct elf32_hppa_stub_hash_entry
*hppa_add_stub
302 PARAMS ((const char *, asection
*, struct elf32_hppa_link_hash_table
*));
304 static enum elf32_hppa_stub_type hppa_type_of_stub
305 PARAMS ((asection
*, const Elf_Internal_Rela
*,
306 struct elf32_hppa_link_hash_entry
*, bfd_vma
));
308 static boolean hppa_build_one_stub
309 PARAMS ((struct bfd_hash_entry
*, PTR
));
311 static boolean hppa_size_one_stub
312 PARAMS ((struct bfd_hash_entry
*, PTR
));
314 /* BFD and elf backend functions. */
315 static boolean elf32_hppa_object_p
PARAMS ((bfd
*));
317 static boolean elf32_hppa_add_symbol_hook
318 PARAMS ((bfd
*, struct bfd_link_info
*, const Elf_Internal_Sym
*,
319 const char **, flagword
*, asection
**, bfd_vma
*));
321 static boolean elf32_hppa_create_dynamic_sections
322 PARAMS ((bfd
*, struct bfd_link_info
*));
324 static boolean elf32_hppa_check_relocs
325 PARAMS ((bfd
*, struct bfd_link_info
*,
326 asection
*, const Elf_Internal_Rela
*));
328 static asection
*elf32_hppa_gc_mark_hook
329 PARAMS ((bfd
*, struct bfd_link_info
*, Elf_Internal_Rela
*,
330 struct elf_link_hash_entry
*, Elf_Internal_Sym
*));
332 static boolean elf32_hppa_gc_sweep_hook
333 PARAMS ((bfd
*, struct bfd_link_info
*,
334 asection
*, const Elf_Internal_Rela
*));
336 static void elf32_hppa_hide_symbol
337 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
339 static boolean elf32_hppa_adjust_dynamic_symbol
340 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
342 static boolean hppa_handle_PIC_calls
343 PARAMS ((struct elf_link_hash_entry
*, PTR
));
345 static boolean allocate_dynrelocs
346 PARAMS ((struct elf_link_hash_entry
*, PTR
));
348 static boolean readonly_dynrelocs
349 PARAMS ((struct elf_link_hash_entry
*, PTR
));
351 static boolean clobber_millicode_symbols
352 PARAMS ((struct elf_link_hash_entry
*, struct bfd_link_info
*));
354 static boolean elf32_hppa_size_dynamic_sections
355 PARAMS ((bfd
*, struct bfd_link_info
*));
357 static boolean elf32_hppa_final_link
358 PARAMS ((bfd
*, struct bfd_link_info
*));
360 static void hppa_record_segment_addr
361 PARAMS ((bfd
*, asection
*, PTR
));
363 static bfd_reloc_status_type final_link_relocate
364 PARAMS ((asection
*, bfd_byte
*, const Elf_Internal_Rela
*,
365 bfd_vma
, struct elf32_hppa_link_hash_table
*, asection
*,
366 struct elf32_hppa_link_hash_entry
*));
368 static boolean elf32_hppa_relocate_section
369 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*,
370 bfd_byte
*, Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**));
372 static int hppa_unwind_entry_compare
373 PARAMS ((const PTR
, const PTR
));
375 static boolean elf32_hppa_finish_dynamic_symbol
376 PARAMS ((bfd
*, struct bfd_link_info
*,
377 struct elf_link_hash_entry
*, Elf_Internal_Sym
*));
379 static enum elf_reloc_type_class elf32_hppa_reloc_type_class
380 PARAMS ((const Elf_Internal_Rela
*));
382 static boolean elf32_hppa_finish_dynamic_sections
383 PARAMS ((bfd
*, struct bfd_link_info
*));
385 static void elf32_hppa_post_process_headers
386 PARAMS ((bfd
*, struct bfd_link_info
*));
388 static int elf32_hppa_elf_get_symbol_type
389 PARAMS ((Elf_Internal_Sym
*, int));
391 /* Assorted hash table functions. */
393 /* Initialize an entry in the stub hash table. */
395 static struct bfd_hash_entry
*
396 stub_hash_newfunc (entry
, table
, string
)
397 struct bfd_hash_entry
*entry
;
398 struct bfd_hash_table
*table
;
401 struct elf32_hppa_stub_hash_entry
*ret
;
403 ret
= (struct elf32_hppa_stub_hash_entry
*) entry
;
405 /* Allocate the structure if it has not already been allocated by a
409 ret
= ((struct elf32_hppa_stub_hash_entry
*)
410 bfd_hash_allocate (table
,
411 sizeof (struct elf32_hppa_stub_hash_entry
)));
416 /* Call the allocation method of the superclass. */
417 ret
= ((struct elf32_hppa_stub_hash_entry
*)
418 bfd_hash_newfunc ((struct bfd_hash_entry
*) ret
, table
, string
));
422 /* Initialize the local fields. */
423 ret
->stub_sec
= NULL
;
424 ret
->stub_offset
= 0;
425 ret
->target_value
= 0;
426 ret
->target_section
= NULL
;
427 ret
->stub_type
= hppa_stub_long_branch
;
432 return (struct bfd_hash_entry
*) ret
;
435 /* Initialize an entry in the link hash table. */
437 static struct bfd_hash_entry
*
438 hppa_link_hash_newfunc (entry
, table
, string
)
439 struct bfd_hash_entry
*entry
;
440 struct bfd_hash_table
*table
;
443 struct elf32_hppa_link_hash_entry
*ret
;
445 ret
= (struct elf32_hppa_link_hash_entry
*) entry
;
447 /* Allocate the structure if it has not already been allocated by a
451 ret
= ((struct elf32_hppa_link_hash_entry
*)
452 bfd_hash_allocate (table
,
453 sizeof (struct elf32_hppa_link_hash_entry
)));
458 /* Call the allocation method of the superclass. */
459 ret
= ((struct elf32_hppa_link_hash_entry
*)
460 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
465 /* Initialize the local fields. */
466 ret
->stub_cache
= NULL
;
467 ret
->dyn_relocs
= NULL
;
468 ret
->maybe_pic_call
= 0;
474 return (struct bfd_hash_entry
*) ret
;
477 /* Create the derived linker hash table. The PA ELF port uses the derived
478 hash table to keep information specific to the PA ELF linker (without
479 using static variables). */
481 static struct bfd_link_hash_table
*
482 elf32_hppa_link_hash_table_create (abfd
)
485 struct elf32_hppa_link_hash_table
*ret
;
486 bfd_size_type amt
= sizeof (*ret
);
488 ret
= (struct elf32_hppa_link_hash_table
*) bfd_alloc (abfd
, amt
);
492 if (!_bfd_elf_link_hash_table_init (&ret
->root
, abfd
, hppa_link_hash_newfunc
))
494 bfd_release (abfd
, ret
);
498 /* Init the stub hash table too. */
499 if (!bfd_hash_table_init (&ret
->stub_hash_table
, stub_hash_newfunc
))
502 ret
->stub_bfd
= NULL
;
503 ret
->add_stub_section
= NULL
;
504 ret
->layout_sections_again
= NULL
;
505 ret
->stub_group
= NULL
;
512 ret
->text_segment_base
= (bfd_vma
) -1;
513 ret
->data_segment_base
= (bfd_vma
) -1;
514 ret
->multi_subspace
= 0;
515 ret
->has_12bit_branch
= 0;
516 ret
->has_17bit_branch
= 0;
517 ret
->need_plt_stub
= 0;
519 return &ret
->root
.root
;
522 /* Build a name for an entry in the stub hash table. */
525 hppa_stub_name (input_section
, sym_sec
, hash
, rel
)
526 const asection
*input_section
;
527 const asection
*sym_sec
;
528 const struct elf32_hppa_link_hash_entry
*hash
;
529 const Elf_Internal_Rela
*rel
;
536 len
= 8 + 1 + strlen (hash
->elf
.root
.root
.string
) + 1 + 8 + 1;
537 stub_name
= bfd_malloc (len
);
538 if (stub_name
!= NULL
)
540 sprintf (stub_name
, "%08x_%s+%x",
541 input_section
->id
& 0xffffffff,
542 hash
->elf
.root
.root
.string
,
543 (int) rel
->r_addend
& 0xffffffff);
548 len
= 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1;
549 stub_name
= bfd_malloc (len
);
550 if (stub_name
!= NULL
)
552 sprintf (stub_name
, "%08x_%x:%x+%x",
553 input_section
->id
& 0xffffffff,
554 sym_sec
->id
& 0xffffffff,
555 (int) ELF32_R_SYM (rel
->r_info
) & 0xffffffff,
556 (int) rel
->r_addend
& 0xffffffff);
562 /* Look up an entry in the stub hash. Stub entries are cached because
563 creating the stub name takes a bit of time. */
565 static struct elf32_hppa_stub_hash_entry
*
566 hppa_get_stub_entry (input_section
, sym_sec
, hash
, rel
, hplink
)
567 const asection
*input_section
;
568 const asection
*sym_sec
;
569 struct elf32_hppa_link_hash_entry
*hash
;
570 const Elf_Internal_Rela
*rel
;
571 struct elf32_hppa_link_hash_table
*hplink
;
573 struct elf32_hppa_stub_hash_entry
*stub_entry
;
574 const asection
*id_sec
;
576 /* If this input section is part of a group of sections sharing one
577 stub section, then use the id of the first section in the group.
578 Stub names need to include a section id, as there may well be
579 more than one stub used to reach say, printf, and we need to
580 distinguish between them. */
581 id_sec
= hplink
->stub_group
[input_section
->id
].link_sec
;
583 if (hash
!= NULL
&& hash
->stub_cache
!= NULL
584 && hash
->stub_cache
->h
== hash
585 && hash
->stub_cache
->id_sec
== id_sec
)
587 stub_entry
= hash
->stub_cache
;
593 stub_name
= hppa_stub_name (id_sec
, sym_sec
, hash
, rel
);
594 if (stub_name
== NULL
)
597 stub_entry
= hppa_stub_hash_lookup (&hplink
->stub_hash_table
,
598 stub_name
, false, false);
599 if (stub_entry
== NULL
)
601 if (hash
== NULL
|| hash
->elf
.root
.type
!= bfd_link_hash_undefweak
)
602 (*_bfd_error_handler
) (_("%s(%s+0x%lx): cannot find stub entry %s"),
603 bfd_archive_filename (input_section
->owner
),
605 (long) rel
->r_offset
,
611 hash
->stub_cache
= stub_entry
;
620 /* Add a new stub entry to the stub hash. Not all fields of the new
621 stub entry are initialised. */
623 static struct elf32_hppa_stub_hash_entry
*
624 hppa_add_stub (stub_name
, section
, hplink
)
625 const char *stub_name
;
627 struct elf32_hppa_link_hash_table
*hplink
;
631 struct elf32_hppa_stub_hash_entry
*stub_entry
;
633 link_sec
= hplink
->stub_group
[section
->id
].link_sec
;
634 stub_sec
= hplink
->stub_group
[section
->id
].stub_sec
;
635 if (stub_sec
== NULL
)
637 stub_sec
= hplink
->stub_group
[link_sec
->id
].stub_sec
;
638 if (stub_sec
== NULL
)
643 len
= strlen (link_sec
->name
) + sizeof (STUB_SUFFIX
);
644 s_name
= bfd_alloc (hplink
->stub_bfd
, len
);
648 strcpy (s_name
, link_sec
->name
);
649 strcpy (s_name
+ len
- sizeof (STUB_SUFFIX
), STUB_SUFFIX
);
650 stub_sec
= (*hplink
->add_stub_section
) (s_name
, link_sec
);
651 if (stub_sec
== NULL
)
653 hplink
->stub_group
[link_sec
->id
].stub_sec
= stub_sec
;
655 hplink
->stub_group
[section
->id
].stub_sec
= stub_sec
;
658 /* Enter this entry into the linker stub hash table. */
659 stub_entry
= hppa_stub_hash_lookup (&hplink
->stub_hash_table
, stub_name
,
661 if (stub_entry
== NULL
)
663 (*_bfd_error_handler
) (_("%s: cannot create stub entry %s"),
664 bfd_archive_filename (section
->owner
),
669 stub_entry
->stub_sec
= stub_sec
;
670 stub_entry
->stub_offset
= 0;
671 stub_entry
->id_sec
= link_sec
;
675 /* Determine the type of stub needed, if any, for a call. */
677 static enum elf32_hppa_stub_type
678 hppa_type_of_stub (input_sec
, rel
, hash
, destination
)
680 const Elf_Internal_Rela
*rel
;
681 struct elf32_hppa_link_hash_entry
*hash
;
685 bfd_vma branch_offset
;
686 bfd_vma max_branch_offset
;
690 && (((hash
->elf
.root
.type
== bfd_link_hash_defined
691 || hash
->elf
.root
.type
== bfd_link_hash_defweak
)
692 && hash
->elf
.root
.u
.def
.section
->output_section
== NULL
)
693 || (hash
->elf
.root
.type
== bfd_link_hash_defweak
694 && hash
->elf
.dynindx
!= -1
695 && hash
->elf
.plt
.offset
!= (bfd_vma
) -1)
696 || hash
->elf
.root
.type
== bfd_link_hash_undefweak
697 || hash
->elf
.root
.type
== bfd_link_hash_undefined
698 || (hash
->maybe_pic_call
&& !(input_sec
->flags
& SEC_HAS_GOT_REF
))))
700 /* If output_section is NULL, then it's a symbol defined in a
701 shared library. We will need an import stub. Decide between
702 hppa_stub_import and hppa_stub_import_shared later. For
703 shared links we need stubs for undefined or weak syms too;
704 They will presumably be resolved by the dynamic linker. */
705 return hppa_stub_import
;
708 /* Determine where the call point is. */
709 location
= (input_sec
->output_offset
710 + input_sec
->output_section
->vma
713 branch_offset
= destination
- location
- 8;
714 r_type
= ELF32_R_TYPE (rel
->r_info
);
716 /* Determine if a long branch stub is needed. parisc branch offsets
717 are relative to the second instruction past the branch, ie. +8
718 bytes on from the branch instruction location. The offset is
719 signed and counts in units of 4 bytes. */
720 if (r_type
== (unsigned int) R_PARISC_PCREL17F
)
722 max_branch_offset
= (1 << (17-1)) << 2;
724 else if (r_type
== (unsigned int) R_PARISC_PCREL12F
)
726 max_branch_offset
= (1 << (12-1)) << 2;
728 else /* R_PARISC_PCREL22F. */
730 max_branch_offset
= (1 << (22-1)) << 2;
733 if (branch_offset
+ max_branch_offset
>= 2*max_branch_offset
)
734 return hppa_stub_long_branch
;
736 return hppa_stub_none
;
739 /* Build one linker stub as defined by the stub hash table entry GEN_ENTRY.
740 IN_ARG contains the link info pointer. */
742 #define LDIL_R1 0x20200000 /* ldil LR'XXX,%r1 */
743 #define BE_SR4_R1 0xe0202002 /* be,n RR'XXX(%sr4,%r1) */
745 #define BL_R1 0xe8200000 /* b,l .+8,%r1 */
746 #define ADDIL_R1 0x28200000 /* addil LR'XXX,%r1,%r1 */
747 #define DEPI_R1 0xd4201c1e /* depi 0,31,2,%r1 */
749 #define ADDIL_DP 0x2b600000 /* addil LR'XXX,%dp,%r1 */
750 #define LDW_R1_R21 0x48350000 /* ldw RR'XXX(%sr0,%r1),%r21 */
751 #define BV_R0_R21 0xeaa0c000 /* bv %r0(%r21) */
752 #define LDW_R1_R19 0x48330000 /* ldw RR'XXX(%sr0,%r1),%r19 */
754 #define ADDIL_R19 0x2a600000 /* addil LR'XXX,%r19,%r1 */
755 #define LDW_R1_DP 0x483b0000 /* ldw RR'XXX(%sr0,%r1),%dp */
757 #define LDSID_R21_R1 0x02a010a1 /* ldsid (%sr0,%r21),%r1 */
758 #define MTSP_R1 0x00011820 /* mtsp %r1,%sr0 */
759 #define BE_SR0_R21 0xe2a00000 /* be 0(%sr0,%r21) */
760 #define STW_RP 0x6bc23fd1 /* stw %rp,-24(%sr0,%sp) */
762 #define BL_RP 0xe8400002 /* b,l,n XXX,%rp */
763 #define NOP 0x08000240 /* nop */
764 #define LDW_RP 0x4bc23fd1 /* ldw -24(%sr0,%sp),%rp */
765 #define LDSID_RP_R1 0x004010a1 /* ldsid (%sr0,%rp),%r1 */
766 #define BE_SR0_RP 0xe0400002 /* be,n 0(%sr0,%rp) */
773 #define LDW_R1_DLT LDW_R1_R19
775 #define LDW_R1_DLT LDW_R1_DP
779 hppa_build_one_stub (gen_entry
, in_arg
)
780 struct bfd_hash_entry
*gen_entry
;
783 struct elf32_hppa_stub_hash_entry
*stub_entry
;
784 struct bfd_link_info
*info
;
785 struct elf32_hppa_link_hash_table
*hplink
;
795 /* Massage our args to the form they really have. */
796 stub_entry
= (struct elf32_hppa_stub_hash_entry
*) gen_entry
;
797 info
= (struct bfd_link_info
*) in_arg
;
799 hplink
= hppa_link_hash_table (info
);
800 stub_sec
= stub_entry
->stub_sec
;
802 /* Make a note of the offset within the stubs for this entry. */
803 stub_entry
->stub_offset
= stub_sec
->_raw_size
;
804 loc
= stub_sec
->contents
+ stub_entry
->stub_offset
;
806 stub_bfd
= stub_sec
->owner
;
808 switch (stub_entry
->stub_type
)
810 case hppa_stub_long_branch
:
811 /* Create the long branch. A long branch is formed with "ldil"
812 loading the upper bits of the target address into a register,
813 then branching with "be" which adds in the lower bits.
814 The "be" has its delay slot nullified. */
815 sym_value
= (stub_entry
->target_value
816 + stub_entry
->target_section
->output_offset
817 + stub_entry
->target_section
->output_section
->vma
);
819 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_lrsel
);
820 insn
= hppa_rebuild_insn ((int) LDIL_R1
, val
, 21);
821 bfd_put_32 (stub_bfd
, insn
, loc
);
823 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_rrsel
) >> 2;
824 insn
= hppa_rebuild_insn ((int) BE_SR4_R1
, val
, 17);
825 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
830 case hppa_stub_long_branch_shared
:
831 /* Branches are relative. This is where we are going to. */
832 sym_value
= (stub_entry
->target_value
833 + stub_entry
->target_section
->output_offset
834 + stub_entry
->target_section
->output_section
->vma
);
836 /* And this is where we are coming from, more or less. */
837 sym_value
-= (stub_entry
->stub_offset
838 + stub_sec
->output_offset
839 + stub_sec
->output_section
->vma
);
841 bfd_put_32 (stub_bfd
, (bfd_vma
) BL_R1
, loc
);
842 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_lrsel
);
843 insn
= hppa_rebuild_insn ((int) ADDIL_R1
, val
, 21);
844 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
846 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_rrsel
) >> 2;
847 insn
= hppa_rebuild_insn ((int) BE_SR4_R1
, val
, 17);
848 bfd_put_32 (stub_bfd
, insn
, loc
+ 8);
852 case hppa_stub_import
:
853 case hppa_stub_import_shared
:
854 off
= stub_entry
->h
->elf
.plt
.offset
;
855 if (off
>= (bfd_vma
) -2)
858 off
&= ~ (bfd_vma
) 1;
860 + hplink
->splt
->output_offset
861 + hplink
->splt
->output_section
->vma
862 - elf_gp (hplink
->splt
->output_section
->owner
));
866 if (stub_entry
->stub_type
== hppa_stub_import_shared
)
869 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_lrsel
),
870 insn
= hppa_rebuild_insn ((int) insn
, val
, 21);
871 bfd_put_32 (stub_bfd
, insn
, loc
);
873 /* It is critical to use lrsel/rrsel here because we are using
874 two different offsets (+0 and +4) from sym_value. If we use
875 lsel/rsel then with unfortunate sym_values we will round
876 sym_value+4 up to the next 2k block leading to a mis-match
877 between the lsel and rsel value. */
878 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_rrsel
);
879 insn
= hppa_rebuild_insn ((int) LDW_R1_R21
, val
, 14);
880 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
882 if (hplink
->multi_subspace
)
884 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 4, e_rrsel
);
885 insn
= hppa_rebuild_insn ((int) LDW_R1_DLT
, val
, 14);
886 bfd_put_32 (stub_bfd
, insn
, loc
+ 8);
888 bfd_put_32 (stub_bfd
, (bfd_vma
) LDSID_R21_R1
, loc
+ 12);
889 bfd_put_32 (stub_bfd
, (bfd_vma
) MTSP_R1
, loc
+ 16);
890 bfd_put_32 (stub_bfd
, (bfd_vma
) BE_SR0_R21
, loc
+ 20);
891 bfd_put_32 (stub_bfd
, (bfd_vma
) STW_RP
, loc
+ 24);
897 bfd_put_32 (stub_bfd
, (bfd_vma
) BV_R0_R21
, loc
+ 8);
898 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 4, e_rrsel
);
899 insn
= hppa_rebuild_insn ((int) LDW_R1_DLT
, val
, 14);
900 bfd_put_32 (stub_bfd
, insn
, loc
+ 12);
906 && stub_entry
->h
!= NULL
907 && stub_entry
->h
->pic_call
)
909 /* Build the .plt entry needed to call a PIC function from
910 statically linked code. We don't need any relocs. */
912 struct elf32_hppa_link_hash_entry
*eh
;
915 dynobj
= hplink
->root
.dynobj
;
916 eh
= (struct elf32_hppa_link_hash_entry
*) stub_entry
->h
;
918 if (eh
->elf
.root
.type
!= bfd_link_hash_defined
919 && eh
->elf
.root
.type
!= bfd_link_hash_defweak
)
922 value
= (eh
->elf
.root
.u
.def
.value
923 + eh
->elf
.root
.u
.def
.section
->output_offset
924 + eh
->elf
.root
.u
.def
.section
->output_section
->vma
);
926 /* Fill in the entry in the procedure linkage table.
928 The format of a plt entry is
932 bfd_put_32 (hplink
->splt
->owner
, value
,
933 hplink
->splt
->contents
+ off
);
934 value
= elf_gp (hplink
->splt
->output_section
->owner
);
935 bfd_put_32 (hplink
->splt
->owner
, value
,
936 hplink
->splt
->contents
+ off
+ 4);
940 case hppa_stub_export
:
941 /* Branches are relative. This is where we are going to. */
942 sym_value
= (stub_entry
->target_value
943 + stub_entry
->target_section
->output_offset
944 + stub_entry
->target_section
->output_section
->vma
);
946 /* And this is where we are coming from. */
947 sym_value
-= (stub_entry
->stub_offset
948 + stub_sec
->output_offset
949 + stub_sec
->output_section
->vma
);
951 if (sym_value
- 8 + 0x40000 >= 0x80000)
953 (*_bfd_error_handler
)
954 (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
955 bfd_archive_filename (stub_entry
->target_section
->owner
),
957 (long) stub_entry
->stub_offset
,
958 stub_entry
->root
.string
);
959 bfd_set_error (bfd_error_bad_value
);
963 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_fsel
) >> 2;
964 insn
= hppa_rebuild_insn ((int) BL_RP
, val
, 17);
965 bfd_put_32 (stub_bfd
, insn
, loc
);
967 bfd_put_32 (stub_bfd
, (bfd_vma
) NOP
, loc
+ 4);
968 bfd_put_32 (stub_bfd
, (bfd_vma
) LDW_RP
, loc
+ 8);
969 bfd_put_32 (stub_bfd
, (bfd_vma
) LDSID_RP_R1
, loc
+ 12);
970 bfd_put_32 (stub_bfd
, (bfd_vma
) MTSP_R1
, loc
+ 16);
971 bfd_put_32 (stub_bfd
, (bfd_vma
) BE_SR0_RP
, loc
+ 20);
973 /* Point the function symbol at the stub. */
974 stub_entry
->h
->elf
.root
.u
.def
.section
= stub_sec
;
975 stub_entry
->h
->elf
.root
.u
.def
.value
= stub_sec
->_raw_size
;
985 stub_sec
->_raw_size
+= size
;
1011 /* As above, but don't actually build the stub. Just bump offset so
1012 we know stub section sizes. */
1015 hppa_size_one_stub (gen_entry
, in_arg
)
1016 struct bfd_hash_entry
*gen_entry
;
1019 struct elf32_hppa_stub_hash_entry
*stub_entry
;
1020 struct elf32_hppa_link_hash_table
*hplink
;
1023 /* Massage our args to the form they really have. */
1024 stub_entry
= (struct elf32_hppa_stub_hash_entry
*) gen_entry
;
1025 hplink
= (struct elf32_hppa_link_hash_table
*) in_arg
;
1027 if (stub_entry
->stub_type
== hppa_stub_long_branch
)
1029 else if (stub_entry
->stub_type
== hppa_stub_long_branch_shared
)
1031 else if (stub_entry
->stub_type
== hppa_stub_export
)
1033 else /* hppa_stub_import or hppa_stub_import_shared. */
1035 if (hplink
->multi_subspace
)
1041 stub_entry
->stub_sec
->_raw_size
+= size
;
1045 /* Return nonzero if ABFD represents an HPPA ELF32 file.
1046 Additionally we set the default architecture and machine. */
1049 elf32_hppa_object_p (abfd
)
1052 Elf_Internal_Ehdr
* i_ehdrp
;
1055 i_ehdrp
= elf_elfheader (abfd
);
1056 if (strcmp (bfd_get_target (abfd
), "elf32-hppa-linux") == 0)
1058 if (i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_LINUX
)
1063 if (i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_HPUX
)
1067 flags
= i_ehdrp
->e_flags
;
1068 switch (flags
& (EF_PARISC_ARCH
| EF_PARISC_WIDE
))
1070 case EFA_PARISC_1_0
:
1071 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 10);
1072 case EFA_PARISC_1_1
:
1073 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 11);
1074 case EFA_PARISC_2_0
:
1075 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 20);
1076 case EFA_PARISC_2_0
| EF_PARISC_WIDE
:
1077 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 25);
1082 /* Undo the generic ELF code's subtraction of section->vma from the
1083 value of each external symbol. */
1086 elf32_hppa_add_symbol_hook (abfd
, info
, sym
, namep
, flagsp
, secp
, valp
)
1087 bfd
*abfd ATTRIBUTE_UNUSED
;
1088 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1089 const Elf_Internal_Sym
*sym ATTRIBUTE_UNUSED
;
1090 const char **namep ATTRIBUTE_UNUSED
;
1091 flagword
*flagsp ATTRIBUTE_UNUSED
;
1095 *valp
+= (*secp
)->vma
;
1099 /* Create the .plt and .got sections, and set up our hash table
1100 short-cuts to various dynamic sections. */
1103 elf32_hppa_create_dynamic_sections (abfd
, info
)
1105 struct bfd_link_info
*info
;
1107 struct elf32_hppa_link_hash_table
*hplink
;
1109 /* Don't try to create the .plt and .got twice. */
1110 hplink
= hppa_link_hash_table (info
);
1111 if (hplink
->splt
!= NULL
)
1114 /* Call the generic code to do most of the work. */
1115 if (! _bfd_elf_create_dynamic_sections (abfd
, info
))
1118 hplink
->splt
= bfd_get_section_by_name (abfd
, ".plt");
1119 hplink
->srelplt
= bfd_get_section_by_name (abfd
, ".rela.plt");
1121 hplink
->sgot
= bfd_get_section_by_name (abfd
, ".got");
1122 hplink
->srelgot
= bfd_make_section (abfd
, ".rela.got");
1123 if (hplink
->srelgot
== NULL
1124 || ! bfd_set_section_flags (abfd
, hplink
->srelgot
,
1129 | SEC_LINKER_CREATED
1131 || ! bfd_set_section_alignment (abfd
, hplink
->srelgot
, 2))
1134 hplink
->sdynbss
= bfd_get_section_by_name (abfd
, ".dynbss");
1135 hplink
->srelbss
= bfd_get_section_by_name (abfd
, ".rela.bss");
1140 /* Look through the relocs for a section during the first phase, and
1141 allocate space in the global offset table or procedure linkage
1142 table. At this point we haven't necessarily read all the input
1146 elf32_hppa_check_relocs (abfd
, info
, sec
, relocs
)
1148 struct bfd_link_info
*info
;
1150 const Elf_Internal_Rela
*relocs
;
1153 Elf_Internal_Shdr
*symtab_hdr
;
1154 struct elf_link_hash_entry
**sym_hashes
;
1155 bfd_signed_vma
*local_got_refcounts
;
1156 const Elf_Internal_Rela
*rel
;
1157 const Elf_Internal_Rela
*rel_end
;
1158 struct elf32_hppa_link_hash_table
*hplink
;
1160 asection
*stubreloc
;
1162 if (info
->relocateable
)
1165 hplink
= hppa_link_hash_table (info
);
1166 dynobj
= hplink
->root
.dynobj
;
1167 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1168 sym_hashes
= elf_sym_hashes (abfd
);
1169 local_got_refcounts
= elf_local_got_refcounts (abfd
);
1173 rel_end
= relocs
+ sec
->reloc_count
;
1174 for (rel
= relocs
; rel
< rel_end
; rel
++)
1183 unsigned int r_symndx
, r_type
;
1184 struct elf32_hppa_link_hash_entry
*h
;
1187 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1189 if (r_symndx
< symtab_hdr
->sh_info
)
1192 h
= ((struct elf32_hppa_link_hash_entry
*)
1193 sym_hashes
[r_symndx
- symtab_hdr
->sh_info
]);
1195 r_type
= ELF32_R_TYPE (rel
->r_info
);
1199 case R_PARISC_DLTIND14F
:
1200 case R_PARISC_DLTIND14R
:
1201 case R_PARISC_DLTIND21L
:
1202 /* This symbol requires a global offset table entry. */
1203 need_entry
= NEED_GOT
;
1205 /* Mark this section as containing PIC code. */
1206 sec
->flags
|= SEC_HAS_GOT_REF
;
1209 case R_PARISC_PLABEL14R
: /* "Official" procedure labels. */
1210 case R_PARISC_PLABEL21L
:
1211 case R_PARISC_PLABEL32
:
1212 /* If the addend is non-zero, we break badly. */
1213 if (rel
->r_addend
!= 0)
1216 /* If we are creating a shared library, then we need to
1217 create a PLT entry for all PLABELs, because PLABELs with
1218 local symbols may be passed via a pointer to another
1219 object. Additionally, output a dynamic relocation
1220 pointing to the PLT entry.
1221 For executables, the original 32-bit ABI allowed two
1222 different styles of PLABELs (function pointers): For
1223 global functions, the PLABEL word points into the .plt
1224 two bytes past a (function address, gp) pair, and for
1225 local functions the PLABEL points directly at the
1226 function. The magic +2 for the first type allows us to
1227 differentiate between the two. As you can imagine, this
1228 is a real pain when it comes to generating code to call
1229 functions indirectly or to compare function pointers.
1230 We avoid the mess by always pointing a PLABEL into the
1231 .plt, even for local functions. */
1232 need_entry
= PLT_PLABEL
| NEED_PLT
| NEED_DYNREL
;
1235 case R_PARISC_PCREL12F
:
1236 hplink
->has_12bit_branch
= 1;
1238 case R_PARISC_PCREL17C
:
1239 case R_PARISC_PCREL17F
:
1240 hplink
->has_17bit_branch
= 1;
1242 case R_PARISC_PCREL22F
:
1243 /* Function calls might need to go through the .plt, and
1244 might require long branch stubs. */
1247 /* We know local syms won't need a .plt entry, and if
1248 they need a long branch stub we can't guarantee that
1249 we can reach the stub. So just flag an error later
1250 if we're doing a shared link and find we need a long
1256 /* Global symbols will need a .plt entry if they remain
1257 global, and in most cases won't need a long branch
1258 stub. Unfortunately, we have to cater for the case
1259 where a symbol is forced local by versioning, or due
1260 to symbolic linking, and we lose the .plt entry. */
1261 need_entry
= NEED_PLT
;
1262 if (h
->elf
.type
== STT_PARISC_MILLI
)
1267 case R_PARISC_SEGBASE
: /* Used to set segment base. */
1268 case R_PARISC_SEGREL32
: /* Relative reloc, used for unwind. */
1269 case R_PARISC_PCREL14F
: /* PC relative load/store. */
1270 case R_PARISC_PCREL14R
:
1271 case R_PARISC_PCREL17R
: /* External branches. */
1272 case R_PARISC_PCREL21L
: /* As above, and for load/store too. */
1273 /* We don't need to propagate the relocation if linking a
1274 shared object since these are section relative. */
1277 case R_PARISC_DPREL14F
: /* Used for gp rel data load/store. */
1278 case R_PARISC_DPREL14R
:
1279 case R_PARISC_DPREL21L
:
1282 (*_bfd_error_handler
)
1283 (_("%s: relocation %s can not be used when making a shared object; recompile with -fPIC"),
1284 bfd_archive_filename (abfd
),
1285 elf_hppa_howto_table
[r_type
].name
);
1286 bfd_set_error (bfd_error_bad_value
);
1291 case R_PARISC_DIR17F
: /* Used for external branches. */
1292 case R_PARISC_DIR17R
:
1293 case R_PARISC_DIR14F
: /* Used for load/store from absolute locn. */
1294 case R_PARISC_DIR14R
:
1295 case R_PARISC_DIR21L
: /* As above, and for ext branches too. */
1297 /* Help debug shared library creation. Any of the above
1298 relocs can be used in shared libs, but they may cause
1299 pages to become unshared. */
1302 (*_bfd_error_handler
)
1303 (_("%s: relocation %s should not be used when making a shared object; recompile with -fPIC"),
1304 bfd_archive_filename (abfd
),
1305 elf_hppa_howto_table
[r_type
].name
);
1310 case R_PARISC_DIR32
: /* .word relocs. */
1311 /* We may want to output a dynamic relocation later. */
1312 need_entry
= NEED_DYNREL
;
1315 /* This relocation describes the C++ object vtable hierarchy.
1316 Reconstruct it for later use during GC. */
1317 case R_PARISC_GNU_VTINHERIT
:
1318 if (!_bfd_elf32_gc_record_vtinherit (abfd
, sec
,
1319 &h
->elf
, rel
->r_offset
))
1323 /* This relocation describes which C++ vtable entries are actually
1324 used. Record for later use during GC. */
1325 case R_PARISC_GNU_VTENTRY
:
1326 if (!_bfd_elf32_gc_record_vtentry (abfd
, sec
,
1327 &h
->elf
, rel
->r_addend
))
1335 /* Now carry out our orders. */
1336 if (need_entry
& NEED_GOT
)
1338 /* Allocate space for a GOT entry, as well as a dynamic
1339 relocation for this entry. */
1341 hplink
->root
.dynobj
= dynobj
= abfd
;
1343 if (hplink
->sgot
== NULL
)
1345 if (! elf32_hppa_create_dynamic_sections (dynobj
, info
))
1351 if (h
->elf
.got
.refcount
== -1)
1352 h
->elf
.got
.refcount
= 1;
1354 h
->elf
.got
.refcount
+= 1;
1358 /* This is a global offset table entry for a local symbol. */
1359 if (local_got_refcounts
== NULL
)
1363 /* Allocate space for local got offsets and local
1364 plt offsets. Done this way to save polluting
1365 elf_obj_tdata with another target specific
1367 size
= symtab_hdr
->sh_info
;
1368 size
*= 2 * sizeof (bfd_signed_vma
);
1369 local_got_refcounts
= ((bfd_signed_vma
*)
1370 bfd_alloc (abfd
, size
));
1371 if (local_got_refcounts
== NULL
)
1373 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
1374 memset (local_got_refcounts
, -1, (size_t) size
);
1376 if (local_got_refcounts
[r_symndx
] == -1)
1377 local_got_refcounts
[r_symndx
] = 1;
1379 local_got_refcounts
[r_symndx
] += 1;
1383 if (need_entry
& NEED_PLT
)
1385 /* If we are creating a shared library, and this is a reloc
1386 against a weak symbol or a global symbol in a dynamic
1387 object, then we will be creating an import stub and a
1388 .plt entry for the symbol. Similarly, on a normal link
1389 to symbols defined in a dynamic object we'll need the
1390 import stub and a .plt entry. We don't know yet whether
1391 the symbol is defined or not, so make an entry anyway and
1392 clean up later in adjust_dynamic_symbol. */
1393 if ((sec
->flags
& SEC_ALLOC
) != 0)
1397 if (h
->elf
.plt
.refcount
== -1)
1399 h
->elf
.plt
.refcount
= 1;
1400 h
->elf
.elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
1403 h
->elf
.plt
.refcount
+= 1;
1405 /* If this .plt entry is for a plabel, mark it so
1406 that adjust_dynamic_symbol will keep the entry
1407 even if it appears to be local. */
1408 if (need_entry
& PLT_PLABEL
)
1411 else if (need_entry
& PLT_PLABEL
)
1413 bfd_signed_vma
*local_plt_refcounts
;
1415 if (local_got_refcounts
== NULL
)
1419 /* Allocate space for local got offsets and local
1421 size
= symtab_hdr
->sh_info
;
1422 size
*= 2 * sizeof (bfd_signed_vma
);
1423 local_got_refcounts
= ((bfd_signed_vma
*)
1424 bfd_alloc (abfd
, size
));
1425 if (local_got_refcounts
== NULL
)
1427 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
1428 memset (local_got_refcounts
, -1, (size_t) size
);
1430 local_plt_refcounts
= (local_got_refcounts
1431 + symtab_hdr
->sh_info
);
1432 if (local_plt_refcounts
[r_symndx
] == -1)
1433 local_plt_refcounts
[r_symndx
] = 1;
1435 local_plt_refcounts
[r_symndx
] += 1;
1440 if (need_entry
& NEED_DYNREL
)
1442 /* Flag this symbol as having a non-got, non-plt reference
1443 so that we generate copy relocs if it turns out to be
1445 if (need_entry
== NEED_DYNREL
1448 && (sec
->flags
& SEC_READONLY
) != 0)
1449 h
->elf
.elf_link_hash_flags
|= ELF_LINK_NON_GOT_REF
;
1451 /* If we are creating a shared library then we need to copy
1452 the reloc into the shared library. However, if we are
1453 linking with -Bsymbolic, we need only copy absolute
1454 relocs or relocs against symbols that are not defined in
1455 an object we are including in the link. PC- or DP- or
1456 DLT-relative relocs against any local sym or global sym
1457 with DEF_REGULAR set, can be discarded. At this point we
1458 have not seen all the input files, so it is possible that
1459 DEF_REGULAR is not set now but will be set later (it is
1460 never cleared). We account for that possibility below by
1461 storing information in the dyn_relocs field of the
1464 A similar situation to the -Bsymbolic case occurs when
1465 creating shared libraries and symbol visibility changes
1466 render the symbol local.
1468 As it turns out, all the relocs we will be creating here
1469 are absolute, so we cannot remove them on -Bsymbolic
1470 links or visibility changes anyway. A STUB_REL reloc
1471 is absolute too, as in that case it is the reloc in the
1472 stub we will be creating, rather than copying the PCREL
1473 reloc in the branch.
1475 If on the other hand, we are creating an executable, we
1476 may need to keep relocations for symbols satisfied by a
1477 dynamic library if we manage to avoid copy relocs for the
1480 && (sec
->flags
& SEC_ALLOC
) != 0
1481 && (IS_ABSOLUTE_RELOC (r_type
)
1484 || h
->elf
.root
.type
== bfd_link_hash_defweak
1485 || (h
->elf
.elf_link_hash_flags
1486 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
1488 && (sec
->flags
& SEC_ALLOC
) != 0
1490 && (h
->elf
.elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0
1491 && (h
->elf
.root
.type
== bfd_link_hash_defweak
1492 || (h
->elf
.elf_link_hash_flags
1493 & ELF_LINK_HASH_DEF_REGULAR
) == 0)))
1495 /* Create a reloc section in dynobj and make room for
1502 hplink
->root
.dynobj
= dynobj
= abfd
;
1504 name
= (bfd_elf_string_from_elf_section
1506 elf_elfheader (abfd
)->e_shstrndx
,
1507 elf_section_data (sec
)->rel_hdr
.sh_name
));
1510 (*_bfd_error_handler
)
1511 (_("Could not find relocation section for %s"),
1513 bfd_set_error (bfd_error_bad_value
);
1517 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1522 sreloc
= bfd_make_section (dynobj
, name
);
1523 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
1524 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
1525 if ((sec
->flags
& SEC_ALLOC
) != 0)
1526 flags
|= SEC_ALLOC
| SEC_LOAD
;
1528 || !bfd_set_section_flags (dynobj
, sreloc
, flags
)
1529 || !bfd_set_section_alignment (dynobj
, sreloc
, 2))
1533 elf_section_data (sec
)->sreloc
= sreloc
;
1536 /* If this is a global symbol, we count the number of
1537 relocations we need for this symbol. */
1540 struct elf32_hppa_dyn_reloc_entry
*p
;
1543 if (p
== NULL
|| p
->sec
!= sec
)
1545 p
= ((struct elf32_hppa_dyn_reloc_entry
*)
1546 bfd_alloc (dynobj
, (bfd_size_type
) sizeof *p
));
1549 p
->next
= h
->dyn_relocs
;
1553 #if RELATIVE_DYNRELOCS
1554 p
->relative_count
= 0;
1559 #if RELATIVE_DYNRELOCS
1560 if (!IS_ABSOLUTE_RELOC (rtype
))
1561 p
->relative_count
+= 1;
1566 /* Track dynamic relocs needed for local syms too. */
1567 elf_section_data (sec
)->local_dynrel
+= 1;
1576 /* Return the section that should be marked against garbage collection
1577 for a given relocation. */
1580 elf32_hppa_gc_mark_hook (abfd
, info
, rel
, h
, sym
)
1582 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1583 Elf_Internal_Rela
*rel
;
1584 struct elf_link_hash_entry
*h
;
1585 Elf_Internal_Sym
*sym
;
1589 switch ((unsigned int) ELF32_R_TYPE (rel
->r_info
))
1591 case R_PARISC_GNU_VTINHERIT
:
1592 case R_PARISC_GNU_VTENTRY
:
1596 switch (h
->root
.type
)
1598 case bfd_link_hash_defined
:
1599 case bfd_link_hash_defweak
:
1600 return h
->root
.u
.def
.section
;
1602 case bfd_link_hash_common
:
1603 return h
->root
.u
.c
.p
->section
;
1612 if (!(elf_bad_symtab (abfd
)
1613 && ELF_ST_BIND (sym
->st_info
) != STB_LOCAL
)
1614 && ! ((sym
->st_shndx
<= 0 || sym
->st_shndx
>= SHN_LORESERVE
)
1615 && sym
->st_shndx
!= SHN_COMMON
))
1617 return bfd_section_from_elf_index (abfd
, sym
->st_shndx
);
1624 /* Update the got and plt entry reference counts for the section being
1628 elf32_hppa_gc_sweep_hook (abfd
, info
, sec
, relocs
)
1630 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1632 const Elf_Internal_Rela
*relocs
;
1634 Elf_Internal_Shdr
*symtab_hdr
;
1635 struct elf_link_hash_entry
**sym_hashes
;
1636 bfd_signed_vma
*local_got_refcounts
;
1637 bfd_signed_vma
*local_plt_refcounts
;
1638 const Elf_Internal_Rela
*rel
, *relend
;
1639 unsigned long r_symndx
;
1640 struct elf_link_hash_entry
*h
;
1641 struct elf32_hppa_link_hash_table
*hplink
;
1644 elf_section_data (sec
)->local_dynrel
= 0;
1646 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1647 sym_hashes
= elf_sym_hashes (abfd
);
1648 local_got_refcounts
= elf_local_got_refcounts (abfd
);
1649 local_plt_refcounts
= local_got_refcounts
;
1650 if (local_plt_refcounts
!= NULL
)
1651 local_plt_refcounts
+= symtab_hdr
->sh_info
;
1652 hplink
= hppa_link_hash_table (info
);
1653 dynobj
= hplink
->root
.dynobj
;
1657 relend
= relocs
+ sec
->reloc_count
;
1658 for (rel
= relocs
; rel
< relend
; rel
++)
1659 switch ((unsigned int) ELF32_R_TYPE (rel
->r_info
))
1661 case R_PARISC_DLTIND14F
:
1662 case R_PARISC_DLTIND14R
:
1663 case R_PARISC_DLTIND21L
:
1664 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1665 if (r_symndx
>= symtab_hdr
->sh_info
)
1667 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1668 if (h
->got
.refcount
> 0)
1669 h
->got
.refcount
-= 1;
1671 else if (local_got_refcounts
!= NULL
)
1673 if (local_got_refcounts
[r_symndx
] > 0)
1674 local_got_refcounts
[r_symndx
] -= 1;
1678 case R_PARISC_PCREL12F
:
1679 case R_PARISC_PCREL17C
:
1680 case R_PARISC_PCREL17F
:
1681 case R_PARISC_PCREL22F
:
1682 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1683 if (r_symndx
>= symtab_hdr
->sh_info
)
1685 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1686 if (h
->plt
.refcount
> 0)
1687 h
->plt
.refcount
-= 1;
1691 case R_PARISC_PLABEL14R
:
1692 case R_PARISC_PLABEL21L
:
1693 case R_PARISC_PLABEL32
:
1694 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1695 if (r_symndx
>= symtab_hdr
->sh_info
)
1697 struct elf32_hppa_link_hash_entry
*eh
;
1698 struct elf32_hppa_dyn_reloc_entry
**pp
;
1699 struct elf32_hppa_dyn_reloc_entry
*p
;
1701 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1703 if (h
->plt
.refcount
> 0)
1704 h
->plt
.refcount
-= 1;
1706 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
1708 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; pp
= &p
->next
)
1711 #if RELATIVE_DYNRELOCS
1712 if (!IS_ABSOLUTE_RELOC (rtype
))
1713 p
->relative_count
-= 1;
1721 else if (local_plt_refcounts
!= NULL
)
1723 if (local_plt_refcounts
[r_symndx
] > 0)
1724 local_plt_refcounts
[r_symndx
] -= 1;
1728 case R_PARISC_DIR32
:
1729 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1730 if (r_symndx
>= symtab_hdr
->sh_info
)
1732 struct elf32_hppa_link_hash_entry
*eh
;
1733 struct elf32_hppa_dyn_reloc_entry
**pp
;
1734 struct elf32_hppa_dyn_reloc_entry
*p
;
1736 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1738 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
1740 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; pp
= &p
->next
)
1743 #if RELATIVE_DYNRELOCS
1744 if (!IS_ABSOLUTE_RELOC (R_PARISC_DIR32
))
1745 p
->relative_count
-= 1;
1762 /* Our own version of hide_symbol, so that we can keep plt entries for
1766 elf32_hppa_hide_symbol (info
, h
)
1767 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1768 struct elf_link_hash_entry
*h
;
1770 if ((h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) != 0)
1772 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
)
1774 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1775 h
->plt
.offset
= (bfd_vma
) -1;
1779 /* This is the condition under which elf32_hppa_finish_dynamic_symbol
1780 will be called from elflink.h. If elflink.h doesn't call our
1781 finish_dynamic_symbol routine, we'll need to do something about
1782 initializing any .plt and .got entries in elf32_hppa_relocate_section. */
1783 #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
1785 && ((INFO)->shared \
1786 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
1787 && ((H)->dynindx != -1 \
1788 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
1790 /* Adjust a symbol defined by a dynamic object and referenced by a
1791 regular object. The current definition is in some section of the
1792 dynamic object, but we're not including those sections. We have to
1793 change the definition to something the rest of the link can
1797 elf32_hppa_adjust_dynamic_symbol (info
, h
)
1798 struct bfd_link_info
*info
;
1799 struct elf_link_hash_entry
*h
;
1802 struct elf32_hppa_link_hash_table
*hplink
;
1805 hplink
= hppa_link_hash_table (info
);
1806 dynobj
= hplink
->root
.dynobj
;
1808 /* If this is a function, put it in the procedure linkage table. We
1809 will fill in the contents of the procedure linkage table later,
1810 when we know the address of the .got section. */
1811 if (h
->type
== STT_FUNC
1812 || (h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0)
1815 && h
->plt
.refcount
> 0
1816 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
1817 && (h
->root
.u
.def
.section
->flags
& SEC_HAS_GOT_REF
) != 0)
1819 ((struct elf32_hppa_link_hash_entry
*) h
)->maybe_pic_call
= 1;
1822 if (h
->plt
.refcount
<= 0
1823 || ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
1824 && h
->root
.type
!= bfd_link_hash_defweak
1825 && ! ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
1826 && (!info
->shared
|| info
->symbolic
)))
1828 /* The .plt entry is not needed when:
1829 a) Garbage collection has removed all references to the
1831 b) We know for certain the symbol is defined in this
1832 object, and it's not a weak definition, nor is the symbol
1833 used by a plabel relocation. Either this object is the
1834 application or we are doing a shared symbolic link. */
1836 /* As a special sop to the hppa ABI, we keep a .plt entry
1837 for functions in sections containing PIC code. */
1838 if (((struct elf32_hppa_link_hash_entry
*) h
)->maybe_pic_call
)
1839 ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
= 1;
1842 h
->plt
.offset
= (bfd_vma
) -1;
1843 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1850 /* If this is a weak symbol, and there is a real definition, the
1851 processor independent code will have arranged for us to see the
1852 real definition first, and we can just use the same value. */
1853 if (h
->weakdef
!= NULL
)
1855 if (h
->weakdef
->root
.type
!= bfd_link_hash_defined
1856 && h
->weakdef
->root
.type
!= bfd_link_hash_defweak
)
1858 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
1859 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
1863 /* This is a reference to a symbol defined by a dynamic object which
1864 is not a function. */
1866 /* If we are creating a shared library, we must presume that the
1867 only references to the symbol are via the global offset table.
1868 For such cases we need not do anything here; the relocations will
1869 be handled correctly by relocate_section. */
1873 /* If there are no references to this symbol that do not use the
1874 GOT, we don't need to generate a copy reloc. */
1875 if ((h
->elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0)
1878 /* We must allocate the symbol in our .dynbss section, which will
1879 become part of the .bss section of the executable. There will be
1880 an entry for this symbol in the .dynsym section. The dynamic
1881 object will contain position independent code, so all references
1882 from the dynamic object to this symbol will go through the global
1883 offset table. The dynamic linker will use the .dynsym entry to
1884 determine the address it must put in the global offset table, so
1885 both the dynamic object and the regular object will refer to the
1886 same memory location for the variable. */
1888 s
= hplink
->sdynbss
;
1890 /* We must generate a COPY reloc to tell the dynamic linker to
1891 copy the initial value out of the dynamic object and into the
1892 runtime process image. We need to remember the offset into the
1893 .rela.bss section we are going to use. */
1894 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
1898 srel
= hplink
->srelbss
;
1899 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
1900 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
1904 /* We need to figure out the alignment required for this symbol. I
1905 have no idea how other ELF linkers handle this. */
1906 unsigned int power_of_two
;
1908 power_of_two
= bfd_log2 (h
->size
);
1909 if (power_of_two
> 3)
1912 /* Apply the required alignment. */
1913 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
1914 (bfd_size_type
) (1 << power_of_two
));
1915 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
1917 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
1921 /* Define the symbol as being at this point in the section. */
1922 h
->root
.u
.def
.section
= s
;
1923 h
->root
.u
.def
.value
= s
->_raw_size
;
1925 /* Increment the section size to make room for the symbol. */
1926 s
->_raw_size
+= h
->size
;
1931 /* Called via elf_link_hash_traverse to create .plt entries for an
1932 application that uses statically linked PIC functions. Similar to
1933 the first part of elf32_hppa_adjust_dynamic_symbol. */
1936 hppa_handle_PIC_calls (h
, inf
)
1937 struct elf_link_hash_entry
*h
;
1938 PTR inf ATTRIBUTE_UNUSED
;
1940 if (! (h
->plt
.refcount
> 0
1941 && (h
->root
.type
== bfd_link_hash_defined
1942 || h
->root
.type
== bfd_link_hash_defweak
)
1943 && (h
->root
.u
.def
.section
->flags
& SEC_HAS_GOT_REF
) != 0))
1945 h
->plt
.offset
= (bfd_vma
) -1;
1946 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1950 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
1951 ((struct elf32_hppa_link_hash_entry
*) h
)->maybe_pic_call
= 1;
1952 ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
= 1;
1957 /* Allocate space in .plt, .got and associated reloc sections for
1961 allocate_dynrelocs (h
, inf
)
1962 struct elf_link_hash_entry
*h
;
1965 struct bfd_link_info
*info
;
1966 struct elf32_hppa_link_hash_table
*hplink
;
1968 struct elf32_hppa_link_hash_entry
*eh
;
1969 struct elf32_hppa_dyn_reloc_entry
*p
;
1971 if (h
->root
.type
== bfd_link_hash_indirect
1972 || h
->root
.type
== bfd_link_hash_warning
)
1975 info
= (struct bfd_link_info
*) inf
;
1976 hplink
= hppa_link_hash_table (info
);
1977 if ((hplink
->root
.dynamic_sections_created
1978 && h
->plt
.refcount
> 0)
1979 || ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
1981 /* Make sure this symbol is output as a dynamic symbol.
1982 Undefined weak syms won't yet be marked as dynamic. */
1983 if (h
->dynindx
== -1
1984 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0
1985 && h
->type
!= STT_PARISC_MILLI
1986 && !((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
1988 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
1992 /* Make an entry in the .plt section. */
1994 h
->plt
.offset
= s
->_raw_size
;
1995 if (PLABEL_PLT_ENTRY_SIZE
!= PLT_ENTRY_SIZE
1996 && ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
1997 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0)
1999 /* Add some extra space for the dynamic linker to use. */
2000 s
->_raw_size
+= PLABEL_PLT_ENTRY_SIZE
;
2003 s
->_raw_size
+= PLT_ENTRY_SIZE
;
2005 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
2006 && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info
, h
))
2008 /* We also need to make an entry in the .rela.plt section. */
2009 hplink
->srelplt
->_raw_size
+= sizeof (Elf32_External_Rela
);
2010 hplink
->need_plt_stub
= 1;
2015 h
->plt
.offset
= (bfd_vma
) -1;
2016 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
2019 if (h
->got
.refcount
> 0)
2023 /* Make sure this symbol is output as a dynamic symbol.
2024 Undefined weak syms won't yet be marked as dynamic. */
2025 if (h
->dynindx
== -1
2026 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0
2027 && h
->type
!= STT_PARISC_MILLI
)
2029 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
2034 h
->got
.offset
= s
->_raw_size
;
2035 s
->_raw_size
+= GOT_ENTRY_SIZE
;
2036 dyn
= hplink
->root
.dynamic_sections_created
;
2037 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
, h
))
2038 hplink
->srelgot
->_raw_size
+= sizeof (Elf32_External_Rela
);
2041 h
->got
.offset
= (bfd_vma
) -1;
2043 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
2044 if (eh
->dyn_relocs
== NULL
)
2047 /* If this is a -Bsymbolic shared link, then we need to discard all
2048 space allocated for dynamic pc-relative relocs against symbols
2049 defined in a regular object. For the normal shared case, discard
2050 space for relocs that have become local due to symbol visibility
2054 #if RELATIVE_DYNRELOCS
2055 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
2056 && ((h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) != 0
2059 struct elf32_hppa_dyn_reloc_entry
**pp
;
2061 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; )
2063 p
->count
-= p
->relative_count
;
2064 p
->relative_count
= 0;
2075 /* For the non-shared case, discard space for relocs against
2076 symbols which turn out to need copy relocs or are not
2078 if ((h
->elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0
2079 && (((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_DYNAMIC
) != 0
2080 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
2081 || (hplink
->root
.dynamic_sections_created
2082 && (h
->root
.type
== bfd_link_hash_undefweak
2083 || h
->root
.type
== bfd_link_hash_undefined
))))
2085 /* Make sure this symbol is output as a dynamic symbol.
2086 Undefined weak syms won't yet be marked as dynamic. */
2087 if (h
->dynindx
== -1
2088 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0
2089 && h
->type
!= STT_PARISC_MILLI
)
2091 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
2095 /* If that succeeded, we know we'll be keeping all the
2097 if (h
->dynindx
!= -1)
2101 eh
->dyn_relocs
= NULL
;
2107 /* Finally, allocate space. */
2108 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
2110 asection
*sreloc
= elf_section_data (p
->sec
)->sreloc
;
2111 sreloc
->_raw_size
+= p
->count
* sizeof (Elf32_External_Rela
);
2117 /* This function is called via elf_link_hash_traverse to force
2118 millicode symbols local so they do not end up as globals in the
2119 dynamic symbol table. We ought to be able to do this in
2120 adjust_dynamic_symbol, but our adjust_dynamic_symbol is not called
2121 for all dynamic symbols. Arguably, this is a bug in
2122 elf_adjust_dynamic_symbol. */
2125 clobber_millicode_symbols (h
, info
)
2126 struct elf_link_hash_entry
*h
;
2127 struct bfd_link_info
*info
;
2129 /* We only want to remove these from the dynamic symbol table.
2130 Therefore we do not leave ELF_LINK_FORCED_LOCAL set. */
2131 if (h
->type
== STT_PARISC_MILLI
)
2133 unsigned short oldflags
= h
->elf_link_hash_flags
;
2134 h
->elf_link_hash_flags
|= ELF_LINK_FORCED_LOCAL
;
2135 elf32_hppa_hide_symbol (info
, h
);
2136 h
->elf_link_hash_flags
&= ~ELF_LINK_FORCED_LOCAL
;
2137 h
->elf_link_hash_flags
|= oldflags
& ELF_LINK_FORCED_LOCAL
;
2142 /* Find any dynamic relocs that apply to read-only sections. */
2145 readonly_dynrelocs (h
, inf
)
2146 struct elf_link_hash_entry
*h
;
2149 struct elf32_hppa_link_hash_entry
*eh
;
2150 struct elf32_hppa_dyn_reloc_entry
*p
;
2152 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
2153 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
2155 asection
*s
= p
->sec
->output_section
;
2157 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
2159 struct bfd_link_info
*info
= (struct bfd_link_info
*) inf
;
2161 info
->flags
|= DF_TEXTREL
;
2163 /* Not an error, just cut short the traversal. */
2170 /* Set the sizes of the dynamic sections. */
2173 elf32_hppa_size_dynamic_sections (output_bfd
, info
)
2174 bfd
*output_bfd ATTRIBUTE_UNUSED
;
2175 struct bfd_link_info
*info
;
2177 struct elf32_hppa_link_hash_table
*hplink
;
2183 hplink
= hppa_link_hash_table (info
);
2184 dynobj
= hplink
->root
.dynobj
;
2188 if (hplink
->root
.dynamic_sections_created
)
2190 /* Set the contents of the .interp section to the interpreter. */
2193 s
= bfd_get_section_by_name (dynobj
, ".interp");
2196 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
2197 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
2200 /* Force millicode symbols local. */
2201 elf_link_hash_traverse (&hplink
->root
,
2202 clobber_millicode_symbols
,
2207 /* Run through the function symbols, looking for any that are
2208 PIC, and allocate space for the necessary .plt entries so
2209 that %r19 will be set up. */
2211 elf_link_hash_traverse (&hplink
->root
,
2212 hppa_handle_PIC_calls
,
2216 /* Set up .got and .plt offsets for local syms, and space for local
2218 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link_next
)
2220 bfd_signed_vma
*local_got
;
2221 bfd_signed_vma
*end_local_got
;
2222 bfd_signed_vma
*local_plt
;
2223 bfd_signed_vma
*end_local_plt
;
2224 bfd_size_type locsymcount
;
2225 Elf_Internal_Shdr
*symtab_hdr
;
2228 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
)
2231 for (s
= ibfd
->sections
; s
!= NULL
; s
= s
->next
)
2233 bfd_size_type count
= elf_section_data (s
)->local_dynrel
;
2237 srel
= elf_section_data (s
)->sreloc
;
2238 srel
->_raw_size
+= count
* sizeof (Elf32_External_Rela
);
2242 local_got
= elf_local_got_refcounts (ibfd
);
2246 symtab_hdr
= &elf_tdata (ibfd
)->symtab_hdr
;
2247 locsymcount
= symtab_hdr
->sh_info
;
2248 end_local_got
= local_got
+ locsymcount
;
2250 srel
= hplink
->srelgot
;
2251 for (; local_got
< end_local_got
; ++local_got
)
2255 *local_got
= s
->_raw_size
;
2256 s
->_raw_size
+= GOT_ENTRY_SIZE
;
2258 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
2261 *local_got
= (bfd_vma
) -1;
2264 local_plt
= end_local_got
;
2265 end_local_plt
= local_plt
+ locsymcount
;
2266 if (! hplink
->root
.dynamic_sections_created
)
2268 /* Won't be used, but be safe. */
2269 for (; local_plt
< end_local_plt
; ++local_plt
)
2270 *local_plt
= (bfd_vma
) -1;
2275 srel
= hplink
->srelplt
;
2276 for (; local_plt
< end_local_plt
; ++local_plt
)
2280 *local_plt
= s
->_raw_size
;
2281 s
->_raw_size
+= PLT_ENTRY_SIZE
;
2283 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
2286 *local_plt
= (bfd_vma
) -1;
2291 /* Allocate global sym .plt and .got entries, and space for global
2292 sym dynamic relocs. */
2293 elf_link_hash_traverse (&hplink
->root
, allocate_dynrelocs
, (PTR
) info
);
2295 /* The check_relocs and adjust_dynamic_symbol entry points have
2296 determined the sizes of the various dynamic sections. Allocate
2299 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
2301 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
2304 if (s
== hplink
->splt
)
2306 if (hplink
->need_plt_stub
)
2308 /* Make space for the plt stub at the end of the .plt
2309 section. We want this stub right at the end, up
2310 against the .got section. */
2311 int gotalign
= bfd_section_alignment (dynobj
, hplink
->sgot
);
2312 int pltalign
= bfd_section_alignment (dynobj
, s
);
2315 if (gotalign
> pltalign
)
2316 bfd_set_section_alignment (dynobj
, s
, gotalign
);
2317 mask
= ((bfd_size_type
) 1 << gotalign
) - 1;
2318 s
->_raw_size
= (s
->_raw_size
+ sizeof (plt_stub
) + mask
) & ~mask
;
2321 else if (s
== hplink
->sgot
)
2323 else if (strncmp (bfd_get_section_name (dynobj
, s
), ".rela", 5) == 0)
2325 if (s
->_raw_size
!= 0)
2327 /* Remember whether there are any reloc sections other
2329 if (s
!= hplink
->srelplt
)
2332 /* We use the reloc_count field as a counter if we need
2333 to copy relocs into the output file. */
2339 /* It's not one of our sections, so don't allocate space. */
2343 if (s
->_raw_size
== 0)
2345 /* If we don't need this section, strip it from the
2346 output file. This is mostly to handle .rela.bss and
2347 .rela.plt. We must create both sections in
2348 create_dynamic_sections, because they must be created
2349 before the linker maps input sections to output
2350 sections. The linker does that before
2351 adjust_dynamic_symbol is called, and it is that
2352 function which decides whether anything needs to go
2353 into these sections. */
2354 _bfd_strip_section_from_output (info
, s
);
2358 /* Allocate memory for the section contents. Zero it, because
2359 we may not fill in all the reloc sections. */
2360 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->_raw_size
);
2361 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
2365 if (hplink
->root
.dynamic_sections_created
)
2367 /* Like IA-64 and HPPA64, always create a DT_PLTGOT. It
2368 actually has nothing to do with the PLT, it is how we
2369 communicate the LTP value of a load module to the dynamic
2371 #define add_dynamic_entry(TAG, VAL) \
2372 bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
2374 if (!add_dynamic_entry (DT_PLTGOT
, 0))
2377 /* Add some entries to the .dynamic section. We fill in the
2378 values later, in elf32_hppa_finish_dynamic_sections, but we
2379 must add the entries now so that we get the correct size for
2380 the .dynamic section. The DT_DEBUG entry is filled in by the
2381 dynamic linker and used by the debugger. */
2384 if (!add_dynamic_entry (DT_DEBUG
, 0))
2388 if (hplink
->srelplt
->_raw_size
!= 0)
2390 if (!add_dynamic_entry (DT_PLTRELSZ
, 0)
2391 || !add_dynamic_entry (DT_PLTREL
, DT_RELA
)
2392 || !add_dynamic_entry (DT_JMPREL
, 0))
2398 if (!add_dynamic_entry (DT_RELA
, 0)
2399 || !add_dynamic_entry (DT_RELASZ
, 0)
2400 || !add_dynamic_entry (DT_RELAENT
, sizeof (Elf32_External_Rela
)))
2403 /* If any dynamic relocs apply to a read-only section,
2404 then we need a DT_TEXTREL entry. */
2405 elf_link_hash_traverse (&hplink
->root
, readonly_dynrelocs
, (PTR
) info
);
2407 if ((info
->flags
& DF_TEXTREL
) != 0)
2409 if (!add_dynamic_entry (DT_TEXTREL
, 0))
2414 #undef add_dynamic_entry
2419 /* External entry points for sizing and building linker stubs. */
2421 /* Determine and set the size of the stub section for a final link.
2423 The basic idea here is to examine all the relocations looking for
2424 PC-relative calls to a target that is unreachable with a "bl"
2428 elf32_hppa_size_stubs (output_bfd
, stub_bfd
, info
, multi_subspace
, group_size
,
2429 add_stub_section
, layout_sections_again
)
2432 struct bfd_link_info
*info
;
2433 boolean multi_subspace
;
2434 bfd_signed_vma group_size
;
2435 asection
* (*add_stub_section
) PARAMS ((const char *, asection
*));
2436 void (*layout_sections_again
) PARAMS ((void));
2440 asection
**input_list
, **list
;
2441 Elf_Internal_Sym
*local_syms
, **all_local_syms
;
2442 unsigned int bfd_indx
, bfd_count
;
2443 int top_id
, top_index
;
2444 struct elf32_hppa_link_hash_table
*hplink
;
2445 bfd_size_type stub_group_size
;
2446 boolean stubs_always_before_branch
;
2447 boolean stub_changed
= 0;
2451 hplink
= hppa_link_hash_table (info
);
2453 /* Stash our params away. */
2454 hplink
->stub_bfd
= stub_bfd
;
2455 hplink
->multi_subspace
= multi_subspace
;
2456 hplink
->add_stub_section
= add_stub_section
;
2457 hplink
->layout_sections_again
= layout_sections_again
;
2458 stubs_always_before_branch
= group_size
< 0;
2460 stub_group_size
= -group_size
;
2462 stub_group_size
= group_size
;
2463 if (stub_group_size
== 1)
2465 /* Default values. */
2466 stub_group_size
= 8000000;
2467 if (hplink
->has_17bit_branch
|| hplink
->multi_subspace
)
2468 stub_group_size
= 250000;
2469 if (hplink
->has_12bit_branch
)
2470 stub_group_size
= 7812;
2473 /* Count the number of input BFDs and find the top input section id. */
2474 for (input_bfd
= info
->input_bfds
, bfd_count
= 0, top_id
= 0;
2476 input_bfd
= input_bfd
->link_next
)
2479 for (section
= input_bfd
->sections
;
2481 section
= section
->next
)
2483 if (top_id
< section
->id
)
2484 top_id
= section
->id
;
2488 amt
= sizeof (struct map_stub
) * (top_id
+ 1);
2489 hplink
->stub_group
= (struct map_stub
*) bfd_zmalloc (amt
);
2490 if (hplink
->stub_group
== NULL
)
2493 /* Make a list of input sections for each output section included in
2496 We can't use output_bfd->section_count here to find the top output
2497 section index as some sections may have been removed, and
2498 _bfd_strip_section_from_output doesn't renumber the indices. */
2499 for (section
= output_bfd
->sections
, top_index
= 0;
2501 section
= section
->next
)
2503 if (top_index
< section
->index
)
2504 top_index
= section
->index
;
2507 amt
= sizeof (asection
*) * (top_index
+ 1);
2508 input_list
= (asection
**) bfd_malloc (amt
);
2509 if (input_list
== NULL
)
2512 /* For sections we aren't interested in, mark their entries with a
2513 value we can check later. */
2514 list
= input_list
+ top_index
;
2516 *list
= bfd_abs_section_ptr
;
2517 while (list
-- != input_list
);
2519 for (section
= output_bfd
->sections
;
2521 section
= section
->next
)
2523 if ((section
->flags
& SEC_CODE
) != 0)
2524 input_list
[section
->index
] = NULL
;
2527 /* Now actually build the lists. */
2528 for (input_bfd
= info
->input_bfds
;
2530 input_bfd
= input_bfd
->link_next
)
2532 for (section
= input_bfd
->sections
;
2534 section
= section
->next
)
2536 if (section
->output_section
!= NULL
2537 && section
->output_section
->owner
== output_bfd
2538 && section
->output_section
->index
<= top_index
)
2540 list
= input_list
+ section
->output_section
->index
;
2541 if (*list
!= bfd_abs_section_ptr
)
2543 /* Steal the link_sec pointer for our list. */
2544 #define PREV_SEC(sec) (hplink->stub_group[(sec)->id].link_sec)
2545 /* This happens to make the list in reverse order,
2546 which is what we want. */
2547 PREV_SEC (section
) = *list
;
2554 /* See whether we can group stub sections together. Grouping stub
2555 sections may result in fewer stubs. More importantly, we need to
2556 put all .init* and .fini* stubs at the beginning of the .init or
2557 .fini output sections respectively, because glibc splits the
2558 _init and _fini functions into multiple parts. Putting a stub in
2559 the middle of a function is not a good idea. */
2560 list
= input_list
+ top_index
;
2563 asection
*tail
= *list
;
2564 if (tail
== bfd_abs_section_ptr
)
2566 while (tail
!= NULL
)
2570 bfd_size_type total
;
2573 if (tail
->_cooked_size
)
2574 total
= tail
->_cooked_size
;
2576 total
= tail
->_raw_size
;
2577 while ((prev
= PREV_SEC (curr
)) != NULL
2578 && ((total
+= curr
->output_offset
- prev
->output_offset
)
2582 /* OK, the size from the start of CURR to the end is less
2583 than 250000 bytes and thus can be handled by one stub
2584 section. (or the tail section is itself larger than
2585 250000 bytes, in which case we may be toast.)
2586 We should really be keeping track of the total size of
2587 stubs added here, as stubs contribute to the final output
2588 section size. That's a little tricky, and this way will
2589 only break if stubs added total more than 12144 bytes, or
2590 1518 long branch stubs. It seems unlikely for more than
2591 1518 different functions to be called, especially from
2592 code only 250000 bytes long. */
2595 prev
= PREV_SEC (tail
);
2596 /* Set up this stub group. */
2597 hplink
->stub_group
[tail
->id
].link_sec
= curr
;
2599 while (tail
!= curr
&& (tail
= prev
) != NULL
);
2601 /* But wait, there's more! Input sections up to 250000
2602 bytes before the stub section can be handled by it too. */
2603 if (!stubs_always_before_branch
)
2607 && ((total
+= tail
->output_offset
- prev
->output_offset
)
2611 prev
= PREV_SEC (tail
);
2612 hplink
->stub_group
[tail
->id
].link_sec
= curr
;
2618 while (list
-- != input_list
);
2622 /* We want to read in symbol extension records only once. To do this
2623 we need to read in the local symbols in parallel and save them for
2624 later use; so hold pointers to the local symbols in an array. */
2625 amt
= sizeof (Elf_Internal_Sym
*) * bfd_count
;
2626 all_local_syms
= (Elf_Internal_Sym
**) bfd_zmalloc (amt
);
2627 if (all_local_syms
== NULL
)
2630 /* Walk over all the input BFDs, swapping in local symbols.
2631 If we are creating a shared library, create hash entries for the
2633 for (input_bfd
= info
->input_bfds
, bfd_indx
= 0;
2635 input_bfd
= input_bfd
->link_next
, bfd_indx
++)
2637 Elf_Internal_Shdr
*symtab_hdr
;
2638 Elf_Internal_Sym
*isym
;
2639 Elf32_External_Sym
*ext_syms
, *esym
, *end_sy
;
2640 bfd_size_type sec_size
;
2642 /* We'll need the symbol table in a second. */
2643 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2644 if (symtab_hdr
->sh_info
== 0)
2647 /* We need an array of the local symbols attached to the input bfd.
2648 Unfortunately, we're going to have to read & swap them in. */
2649 sec_size
= symtab_hdr
->sh_info
;
2650 sec_size
*= sizeof (Elf_Internal_Sym
);
2651 local_syms
= (Elf_Internal_Sym
*) bfd_malloc (sec_size
);
2652 if (local_syms
== NULL
)
2654 goto error_ret_free_local
;
2656 all_local_syms
[bfd_indx
] = local_syms
;
2657 sec_size
= symtab_hdr
->sh_info
;
2658 sec_size
*= sizeof (Elf32_External_Sym
);
2659 ext_syms
= (Elf32_External_Sym
*) bfd_malloc (sec_size
);
2660 if (ext_syms
== NULL
)
2662 goto error_ret_free_local
;
2665 if (bfd_seek (input_bfd
, symtab_hdr
->sh_offset
, SEEK_SET
) != 0
2666 || (bfd_bread (ext_syms
, sec_size
, input_bfd
) != sec_size
))
2669 goto error_ret_free_local
;
2672 /* Swap the local symbols in. */
2675 for (end_sy
= esym
+ symtab_hdr
->sh_info
; esym
< end_sy
; esym
++, isym
++)
2676 bfd_elf32_swap_symbol_in (input_bfd
, esym
, isym
);
2678 /* Now we can free the external symbols. */
2681 if (info
->shared
&& hplink
->multi_subspace
)
2683 struct elf_link_hash_entry
**sym_hashes
;
2684 struct elf_link_hash_entry
**end_hashes
;
2685 unsigned int symcount
;
2687 symcount
= (symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
)
2688 - symtab_hdr
->sh_info
);
2689 sym_hashes
= elf_sym_hashes (input_bfd
);
2690 end_hashes
= sym_hashes
+ symcount
;
2692 /* Look through the global syms for functions; We need to
2693 build export stubs for all globally visible functions. */
2694 for (; sym_hashes
< end_hashes
; sym_hashes
++)
2696 struct elf32_hppa_link_hash_entry
*hash
;
2698 hash
= (struct elf32_hppa_link_hash_entry
*) *sym_hashes
;
2700 while (hash
->elf
.root
.type
== bfd_link_hash_indirect
2701 || hash
->elf
.root
.type
== bfd_link_hash_warning
)
2702 hash
= ((struct elf32_hppa_link_hash_entry
*)
2703 hash
->elf
.root
.u
.i
.link
);
2705 /* At this point in the link, undefined syms have been
2706 resolved, so we need to check that the symbol was
2707 defined in this BFD. */
2708 if ((hash
->elf
.root
.type
== bfd_link_hash_defined
2709 || hash
->elf
.root
.type
== bfd_link_hash_defweak
)
2710 && hash
->elf
.type
== STT_FUNC
2711 && hash
->elf
.root
.u
.def
.section
->output_section
!= NULL
2712 && (hash
->elf
.root
.u
.def
.section
->output_section
->owner
2714 && hash
->elf
.root
.u
.def
.section
->owner
== input_bfd
2715 && (hash
->elf
.elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)
2716 && !(hash
->elf
.elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
)
2717 && ELF_ST_VISIBILITY (hash
->elf
.other
) == STV_DEFAULT
)
2720 const char *stub_name
;
2721 struct elf32_hppa_stub_hash_entry
*stub_entry
;
2723 sec
= hash
->elf
.root
.u
.def
.section
;
2724 stub_name
= hash
->elf
.root
.root
.string
;
2725 stub_entry
= hppa_stub_hash_lookup (&hplink
->stub_hash_table
,
2728 if (stub_entry
== NULL
)
2730 stub_entry
= hppa_add_stub (stub_name
, sec
, hplink
);
2732 goto error_ret_free_local
;
2734 stub_entry
->target_value
= hash
->elf
.root
.u
.def
.value
;
2735 stub_entry
->target_section
= hash
->elf
.root
.u
.def
.section
;
2736 stub_entry
->stub_type
= hppa_stub_export
;
2737 stub_entry
->h
= hash
;
2742 (*_bfd_error_handler
) (_("%s: duplicate export stub %s"),
2743 bfd_archive_filename (input_bfd
),
2755 for (input_bfd
= info
->input_bfds
, bfd_indx
= 0;
2757 input_bfd
= input_bfd
->link_next
, bfd_indx
++)
2759 Elf_Internal_Shdr
*symtab_hdr
;
2761 /* We'll need the symbol table in a second. */
2762 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2763 if (symtab_hdr
->sh_info
== 0)
2766 local_syms
= all_local_syms
[bfd_indx
];
2768 /* Walk over each section attached to the input bfd. */
2769 for (section
= input_bfd
->sections
;
2771 section
= section
->next
)
2773 Elf_Internal_Shdr
*input_rel_hdr
;
2774 Elf32_External_Rela
*external_relocs
, *erelaend
, *erela
;
2775 Elf_Internal_Rela
*internal_relocs
, *irelaend
, *irela
;
2777 /* If there aren't any relocs, then there's nothing more
2779 if ((section
->flags
& SEC_RELOC
) == 0
2780 || section
->reloc_count
== 0)
2783 /* If this section is a link-once section that will be
2784 discarded, then don't create any stubs. */
2785 if (section
->output_section
== NULL
2786 || section
->output_section
->owner
!= output_bfd
)
2789 /* Allocate space for the external relocations. */
2790 amt
= section
->reloc_count
;
2791 amt
*= sizeof (Elf32_External_Rela
);
2792 external_relocs
= (Elf32_External_Rela
*) bfd_malloc (amt
);
2793 if (external_relocs
== NULL
)
2795 goto error_ret_free_local
;
2798 /* Likewise for the internal relocations. */
2799 amt
= section
->reloc_count
;
2800 amt
*= sizeof (Elf_Internal_Rela
);
2801 internal_relocs
= (Elf_Internal_Rela
*) bfd_malloc (amt
);
2802 if (internal_relocs
== NULL
)
2804 free (external_relocs
);
2805 goto error_ret_free_local
;
2808 /* Read in the external relocs. */
2809 input_rel_hdr
= &elf_section_data (section
)->rel_hdr
;
2810 if (bfd_seek (input_bfd
, input_rel_hdr
->sh_offset
, SEEK_SET
) != 0
2811 || bfd_bread (external_relocs
,
2812 input_rel_hdr
->sh_size
,
2813 input_bfd
) != input_rel_hdr
->sh_size
)
2815 free (external_relocs
);
2816 error_ret_free_internal
:
2817 free (internal_relocs
);
2818 goto error_ret_free_local
;
2821 /* Swap in the relocs. */
2822 erela
= external_relocs
;
2823 erelaend
= erela
+ section
->reloc_count
;
2824 irela
= internal_relocs
;
2825 for (; erela
< erelaend
; erela
++, irela
++)
2826 bfd_elf32_swap_reloca_in (input_bfd
, erela
, irela
);
2828 /* We're done with the external relocs, free them. */
2829 free (external_relocs
);
2831 /* Now examine each relocation. */
2832 irela
= internal_relocs
;
2833 irelaend
= irela
+ section
->reloc_count
;
2834 for (; irela
< irelaend
; irela
++)
2836 unsigned int r_type
, r_indx
;
2837 enum elf32_hppa_stub_type stub_type
;
2838 struct elf32_hppa_stub_hash_entry
*stub_entry
;
2841 bfd_vma destination
;
2842 struct elf32_hppa_link_hash_entry
*hash
;
2844 const asection
*id_sec
;
2846 r_type
= ELF32_R_TYPE (irela
->r_info
);
2847 r_indx
= ELF32_R_SYM (irela
->r_info
);
2849 if (r_type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
2851 bfd_set_error (bfd_error_bad_value
);
2852 goto error_ret_free_internal
;
2855 /* Only look for stubs on call instructions. */
2856 if (r_type
!= (unsigned int) R_PARISC_PCREL12F
2857 && r_type
!= (unsigned int) R_PARISC_PCREL17F
2858 && r_type
!= (unsigned int) R_PARISC_PCREL22F
)
2861 /* Now determine the call target, its name, value,
2867 if (r_indx
< symtab_hdr
->sh_info
)
2869 /* It's a local symbol. */
2870 Elf_Internal_Sym
*sym
;
2871 Elf_Internal_Shdr
*hdr
;
2873 sym
= local_syms
+ r_indx
;
2874 hdr
= elf_elfsections (input_bfd
)[sym
->st_shndx
];
2875 sym_sec
= hdr
->bfd_section
;
2876 if (ELF_ST_TYPE (sym
->st_info
) != STT_SECTION
)
2877 sym_value
= sym
->st_value
;
2878 destination
= (sym_value
+ irela
->r_addend
2879 + sym_sec
->output_offset
2880 + sym_sec
->output_section
->vma
);
2884 /* It's an external symbol. */
2887 e_indx
= r_indx
- symtab_hdr
->sh_info
;
2888 hash
= ((struct elf32_hppa_link_hash_entry
*)
2889 elf_sym_hashes (input_bfd
)[e_indx
]);
2891 while (hash
->elf
.root
.type
== bfd_link_hash_indirect
2892 || hash
->elf
.root
.type
== bfd_link_hash_warning
)
2893 hash
= ((struct elf32_hppa_link_hash_entry
*)
2894 hash
->elf
.root
.u
.i
.link
);
2896 if (hash
->elf
.root
.type
== bfd_link_hash_defined
2897 || hash
->elf
.root
.type
== bfd_link_hash_defweak
)
2899 sym_sec
= hash
->elf
.root
.u
.def
.section
;
2900 sym_value
= hash
->elf
.root
.u
.def
.value
;
2901 if (sym_sec
->output_section
!= NULL
)
2902 destination
= (sym_value
+ irela
->r_addend
2903 + sym_sec
->output_offset
2904 + sym_sec
->output_section
->vma
);
2906 else if (hash
->elf
.root
.type
== bfd_link_hash_undefweak
)
2911 else if (hash
->elf
.root
.type
== bfd_link_hash_undefined
)
2914 && !info
->no_undefined
2915 && (ELF_ST_VISIBILITY (hash
->elf
.other
)
2921 bfd_set_error (bfd_error_bad_value
);
2922 goto error_ret_free_internal
;
2926 /* Determine what (if any) linker stub is needed. */
2927 stub_type
= hppa_type_of_stub (section
, irela
, hash
,
2929 if (stub_type
== hppa_stub_none
)
2932 /* Support for grouping stub sections. */
2933 id_sec
= hplink
->stub_group
[section
->id
].link_sec
;
2935 /* Get the name of this stub. */
2936 stub_name
= hppa_stub_name (id_sec
, sym_sec
, hash
, irela
);
2938 goto error_ret_free_internal
;
2940 stub_entry
= hppa_stub_hash_lookup (&hplink
->stub_hash_table
,
2943 if (stub_entry
!= NULL
)
2945 /* The proper stub has already been created. */
2950 stub_entry
= hppa_add_stub (stub_name
, section
, hplink
);
2951 if (stub_entry
== NULL
)
2954 goto error_ret_free_local
;
2957 stub_entry
->target_value
= sym_value
;
2958 stub_entry
->target_section
= sym_sec
;
2959 stub_entry
->stub_type
= stub_type
;
2962 if (stub_type
== hppa_stub_import
)
2963 stub_entry
->stub_type
= hppa_stub_import_shared
;
2964 else if (stub_type
== hppa_stub_long_branch
)
2965 stub_entry
->stub_type
= hppa_stub_long_branch_shared
;
2967 stub_entry
->h
= hash
;
2971 /* We're done with the internal relocs, free them. */
2972 free (internal_relocs
);
2979 /* OK, we've added some stubs. Find out the new size of the
2981 for (stub_sec
= hplink
->stub_bfd
->sections
;
2983 stub_sec
= stub_sec
->next
)
2985 stub_sec
->_raw_size
= 0;
2986 stub_sec
->_cooked_size
= 0;
2989 bfd_hash_traverse (&hplink
->stub_hash_table
,
2993 /* Ask the linker to do its stuff. */
2994 (*hplink
->layout_sections_again
) ();
3000 error_ret_free_local
:
3001 while (bfd_count
-- > 0)
3002 if (all_local_syms
[bfd_count
])
3003 free (all_local_syms
[bfd_count
]);
3004 free (all_local_syms
);
3009 /* For a final link, this function is called after we have sized the
3010 stubs to provide a value for __gp. */
3013 elf32_hppa_set_gp (abfd
, info
)
3015 struct bfd_link_info
*info
;
3017 struct elf32_hppa_link_hash_table
*hplink
;
3018 struct elf_link_hash_entry
*h
;
3022 hplink
= hppa_link_hash_table (info
);
3023 h
= elf_link_hash_lookup (&hplink
->root
, "$global$",
3024 false, false, false);
3027 && (h
->root
.type
== bfd_link_hash_defined
3028 || h
->root
.type
== bfd_link_hash_defweak
))
3030 gp_val
= h
->root
.u
.def
.value
;
3031 sec
= h
->root
.u
.def
.section
;
3035 /* Choose to point our LTP at, in this order, one of .plt, .got,
3036 or .data, if these sections exist. In the case of choosing
3037 .plt try to make the LTP ideal for addressing anywhere in the
3038 .plt or .got with a 14 bit signed offset. Typically, the end
3039 of the .plt is the start of the .got, so choose .plt + 0x2000
3040 if either the .plt or .got is larger than 0x2000. If both
3041 the .plt and .got are smaller than 0x2000, choose the end of
3042 the .plt section. */
3047 gp_val
= sec
->_raw_size
;
3049 || (hplink
->sgot
&& hplink
->sgot
->_raw_size
> 0x2000))
3060 /* We know we don't have a .plt. If .got is large,
3062 if (sec
->_raw_size
> 0x2000)
3067 /* No .plt or .got. Who cares what the LTP is? */
3068 sec
= bfd_get_section_by_name (abfd
, ".data");
3074 h
->root
.type
= bfd_link_hash_defined
;
3075 h
->root
.u
.def
.value
= gp_val
;
3077 h
->root
.u
.def
.section
= sec
;
3079 h
->root
.u
.def
.section
= bfd_abs_section_ptr
;
3083 if (sec
!= NULL
&& sec
->output_section
!= NULL
)
3084 gp_val
+= sec
->output_section
->vma
+ sec
->output_offset
;
3086 elf_gp (abfd
) = gp_val
;
3090 /* Build all the stubs associated with the current output file. The
3091 stubs are kept in a hash table attached to the main linker hash
3092 table. We also set up the .plt entries for statically linked PIC
3093 functions here. This function is called via hppaelf_finish in the
3097 elf32_hppa_build_stubs (info
)
3098 struct bfd_link_info
*info
;
3101 struct bfd_hash_table
*table
;
3102 struct elf32_hppa_link_hash_table
*hplink
;
3104 hplink
= hppa_link_hash_table (info
);
3106 for (stub_sec
= hplink
->stub_bfd
->sections
;
3108 stub_sec
= stub_sec
->next
)
3112 /* Allocate memory to hold the linker stubs. */
3113 size
= stub_sec
->_raw_size
;
3114 stub_sec
->contents
= (unsigned char *) bfd_zalloc (hplink
->stub_bfd
,
3116 if (stub_sec
->contents
== NULL
&& size
!= 0)
3118 stub_sec
->_raw_size
= 0;
3121 /* Build the stubs as directed by the stub hash table. */
3122 table
= &hplink
->stub_hash_table
;
3123 bfd_hash_traverse (table
, hppa_build_one_stub
, info
);
3128 /* Perform a final link. */
3131 elf32_hppa_final_link (abfd
, info
)
3133 struct bfd_link_info
*info
;
3137 /* Invoke the regular ELF linker to do all the work. */
3138 if (!bfd_elf32_bfd_final_link (abfd
, info
))
3141 /* If we're producing a final executable, sort the contents of the
3142 unwind section. Magic section names, but this is much safer than
3143 having elf32_hppa_relocate_section remember where SEGREL32 relocs
3144 occurred. Consider what happens if someone inept creates a
3145 linker script that puts unwind information in .text. */
3146 s
= bfd_get_section_by_name (abfd
, ".PARISC.unwind");
3152 size
= s
->_raw_size
;
3153 contents
= bfd_malloc (size
);
3154 if (contents
== NULL
)
3157 if (! bfd_get_section_contents (abfd
, s
, contents
, (file_ptr
) 0, size
))
3160 qsort (contents
, (size_t) (size
/ 16), 16, hppa_unwind_entry_compare
);
3162 if (! bfd_set_section_contents (abfd
, s
, contents
, (file_ptr
) 0, size
))
3168 /* Record the lowest address for the data and text segments. */
3171 hppa_record_segment_addr (abfd
, section
, data
)
3172 bfd
*abfd ATTRIBUTE_UNUSED
;
3176 struct elf32_hppa_link_hash_table
*hplink
;
3178 hplink
= (struct elf32_hppa_link_hash_table
*) data
;
3180 if ((section
->flags
& (SEC_ALLOC
| SEC_LOAD
)) == (SEC_ALLOC
| SEC_LOAD
))
3182 bfd_vma value
= section
->vma
- section
->filepos
;
3184 if ((section
->flags
& SEC_READONLY
) != 0)
3186 if (value
< hplink
->text_segment_base
)
3187 hplink
->text_segment_base
= value
;
3191 if (value
< hplink
->data_segment_base
)
3192 hplink
->data_segment_base
= value
;
3197 /* Perform a relocation as part of a final link. */
3199 static bfd_reloc_status_type
3200 final_link_relocate (input_section
, contents
, rel
, value
, hplink
, sym_sec
, h
)
3201 asection
*input_section
;
3203 const Elf_Internal_Rela
*rel
;
3205 struct elf32_hppa_link_hash_table
*hplink
;
3207 struct elf32_hppa_link_hash_entry
*h
;
3210 unsigned int r_type
= ELF32_R_TYPE (rel
->r_info
);
3211 reloc_howto_type
*howto
= elf_hppa_howto_table
+ r_type
;
3212 int r_format
= howto
->bitsize
;
3213 enum hppa_reloc_field_selector_type_alt r_field
;
3214 bfd
*input_bfd
= input_section
->owner
;
3215 bfd_vma offset
= rel
->r_offset
;
3216 bfd_vma max_branch_offset
= 0;
3217 bfd_byte
*hit_data
= contents
+ offset
;
3218 bfd_signed_vma addend
= rel
->r_addend
;
3220 struct elf32_hppa_stub_hash_entry
*stub_entry
= NULL
;
3223 if (r_type
== R_PARISC_NONE
)
3224 return bfd_reloc_ok
;
3226 insn
= bfd_get_32 (input_bfd
, hit_data
);
3228 /* Find out where we are and where we're going. */
3229 location
= (offset
+
3230 input_section
->output_offset
+
3231 input_section
->output_section
->vma
);
3235 case R_PARISC_PCREL12F
:
3236 case R_PARISC_PCREL17F
:
3237 case R_PARISC_PCREL22F
:
3238 /* If this is a call to a function defined in another dynamic
3239 library, or if it is a call to a PIC function in the same
3240 object, or if this is a shared link and it is a call to a
3241 weak symbol which may or may not be in the same object, then
3242 find the import stub in the stub hash. */
3244 || sym_sec
->output_section
== NULL
3246 && ((h
->maybe_pic_call
3247 && !(input_section
->flags
& SEC_HAS_GOT_REF
))
3248 || (h
->elf
.root
.type
== bfd_link_hash_defweak
3249 && h
->elf
.dynindx
!= -1
3250 && h
->elf
.plt
.offset
!= (bfd_vma
) -1))))
3252 stub_entry
= hppa_get_stub_entry (input_section
, sym_sec
,
3254 if (stub_entry
!= NULL
)
3256 value
= (stub_entry
->stub_offset
3257 + stub_entry
->stub_sec
->output_offset
3258 + stub_entry
->stub_sec
->output_section
->vma
);
3261 else if (sym_sec
== NULL
&& h
!= NULL
3262 && h
->elf
.root
.type
== bfd_link_hash_undefweak
)
3264 /* It's OK if undefined weak. Calls to undefined weak
3265 symbols behave as if the "called" function
3266 immediately returns. We can thus call to a weak
3267 function without first checking whether the function
3273 return bfd_reloc_notsupported
;
3277 case R_PARISC_PCREL21L
:
3278 case R_PARISC_PCREL17C
:
3279 case R_PARISC_PCREL17R
:
3280 case R_PARISC_PCREL14R
:
3281 case R_PARISC_PCREL14F
:
3282 /* Make it a pc relative offset. */
3287 case R_PARISC_DPREL21L
:
3288 case R_PARISC_DPREL14R
:
3289 case R_PARISC_DPREL14F
:
3290 /* For all the DP relative relocations, we need to examine the symbol's
3291 section. If it's a code section, then "data pointer relative" makes
3292 no sense. In that case we don't adjust the "value", and for 21 bit
3293 addil instructions, we change the source addend register from %dp to
3294 %r0. This situation commonly arises when a variable's "constness"
3295 is declared differently from the way the variable is defined. For
3296 instance: "extern int foo" with foo defined as "const int foo". */
3297 if (sym_sec
== NULL
)
3299 if ((sym_sec
->flags
& SEC_CODE
) != 0)
3301 if ((insn
& ((0x3f << 26) | (0x1f << 21)))
3302 == (((int) OP_ADDIL
<< 26) | (27 << 21)))
3304 insn
&= ~ (0x1f << 21);
3305 #if 1 /* debug them. */
3306 (*_bfd_error_handler
)
3307 (_("%s(%s+0x%lx): fixing %s"),
3308 bfd_archive_filename (input_bfd
),
3309 input_section
->name
,
3310 (long) rel
->r_offset
,
3314 /* Now try to make things easy for the dynamic linker. */
3320 case R_PARISC_DLTIND21L
:
3321 case R_PARISC_DLTIND14R
:
3322 case R_PARISC_DLTIND14F
:
3323 value
-= elf_gp (input_section
->output_section
->owner
);
3326 case R_PARISC_SEGREL32
:
3327 if ((sym_sec
->flags
& SEC_CODE
) != 0)
3328 value
-= hplink
->text_segment_base
;
3330 value
-= hplink
->data_segment_base
;
3339 case R_PARISC_DIR32
:
3340 case R_PARISC_DIR14F
:
3341 case R_PARISC_DIR17F
:
3342 case R_PARISC_PCREL17C
:
3343 case R_PARISC_PCREL14F
:
3344 case R_PARISC_DPREL14F
:
3345 case R_PARISC_PLABEL32
:
3346 case R_PARISC_DLTIND14F
:
3347 case R_PARISC_SEGBASE
:
3348 case R_PARISC_SEGREL32
:
3352 case R_PARISC_DIR21L
:
3353 case R_PARISC_PCREL21L
:
3354 case R_PARISC_DPREL21L
:
3355 case R_PARISC_PLABEL21L
:
3356 case R_PARISC_DLTIND21L
:
3360 case R_PARISC_DIR17R
:
3361 case R_PARISC_PCREL17R
:
3362 case R_PARISC_DIR14R
:
3363 case R_PARISC_PCREL14R
:
3364 case R_PARISC_DPREL14R
:
3365 case R_PARISC_PLABEL14R
:
3366 case R_PARISC_DLTIND14R
:
3370 case R_PARISC_PCREL12F
:
3371 case R_PARISC_PCREL17F
:
3372 case R_PARISC_PCREL22F
:
3375 if (r_type
== (unsigned int) R_PARISC_PCREL17F
)
3377 max_branch_offset
= (1 << (17-1)) << 2;
3379 else if (r_type
== (unsigned int) R_PARISC_PCREL12F
)
3381 max_branch_offset
= (1 << (12-1)) << 2;
3385 max_branch_offset
= (1 << (22-1)) << 2;
3388 /* sym_sec is NULL on undefined weak syms or when shared on
3389 undefined syms. We've already checked for a stub for the
3390 shared undefined case. */
3391 if (sym_sec
== NULL
)
3394 /* If the branch is out of reach, then redirect the
3395 call to the local stub for this function. */
3396 if (value
+ addend
+ max_branch_offset
>= 2*max_branch_offset
)
3398 stub_entry
= hppa_get_stub_entry (input_section
, sym_sec
,
3400 if (stub_entry
== NULL
)
3401 return bfd_reloc_notsupported
;
3403 /* Munge up the value and addend so that we call the stub
3404 rather than the procedure directly. */
3405 value
= (stub_entry
->stub_offset
3406 + stub_entry
->stub_sec
->output_offset
3407 + stub_entry
->stub_sec
->output_section
->vma
3413 /* Something we don't know how to handle. */
3415 return bfd_reloc_notsupported
;
3418 /* Make sure we can reach the stub. */
3419 if (max_branch_offset
!= 0
3420 && value
+ addend
+ max_branch_offset
>= 2*max_branch_offset
)
3422 (*_bfd_error_handler
)
3423 (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
3424 bfd_archive_filename (input_bfd
),
3425 input_section
->name
,
3426 (long) rel
->r_offset
,
3427 stub_entry
->root
.string
);
3428 return bfd_reloc_notsupported
;
3431 val
= hppa_field_adjust (value
, addend
, r_field
);
3435 case R_PARISC_PCREL12F
:
3436 case R_PARISC_PCREL17C
:
3437 case R_PARISC_PCREL17F
:
3438 case R_PARISC_PCREL17R
:
3439 case R_PARISC_PCREL22F
:
3440 case R_PARISC_DIR17F
:
3441 case R_PARISC_DIR17R
:
3442 /* This is a branch. Divide the offset by four.
3443 Note that we need to decide whether it's a branch or
3444 otherwise by inspecting the reloc. Inspecting insn won't
3445 work as insn might be from a .word directive. */
3453 insn
= hppa_rebuild_insn (insn
, val
, r_format
);
3455 /* Update the instruction word. */
3456 bfd_put_32 (input_bfd
, (bfd_vma
) insn
, hit_data
);
3457 return bfd_reloc_ok
;
3460 /* Relocate an HPPA ELF section. */
3463 elf32_hppa_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
3464 contents
, relocs
, local_syms
, local_sections
)
3466 struct bfd_link_info
*info
;
3468 asection
*input_section
;
3470 Elf_Internal_Rela
*relocs
;
3471 Elf_Internal_Sym
*local_syms
;
3472 asection
**local_sections
;
3475 bfd_vma
*local_got_offsets
;
3476 struct elf32_hppa_link_hash_table
*hplink
;
3477 Elf_Internal_Shdr
*symtab_hdr
;
3478 Elf_Internal_Rela
*rel
;
3479 Elf_Internal_Rela
*relend
;
3481 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
3483 hplink
= hppa_link_hash_table (info
);
3484 dynobj
= hplink
->root
.dynobj
;
3485 local_got_offsets
= elf_local_got_offsets (input_bfd
);
3488 relend
= relocs
+ input_section
->reloc_count
;
3489 for (; rel
< relend
; rel
++)
3491 unsigned int r_type
;
3492 reloc_howto_type
*howto
;
3493 unsigned int r_symndx
;
3494 struct elf32_hppa_link_hash_entry
*h
;
3495 Elf_Internal_Sym
*sym
;
3498 bfd_reloc_status_type r
;
3499 const char *sym_name
;
3503 r_type
= ELF32_R_TYPE (rel
->r_info
);
3504 if (r_type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
3506 bfd_set_error (bfd_error_bad_value
);
3509 if (r_type
== (unsigned int) R_PARISC_GNU_VTENTRY
3510 || r_type
== (unsigned int) R_PARISC_GNU_VTINHERIT
)
3513 r_symndx
= ELF32_R_SYM (rel
->r_info
);
3515 if (info
->relocateable
)
3517 /* This is a relocateable link. We don't have to change
3518 anything, unless the reloc is against a section symbol,
3519 in which case we have to adjust according to where the
3520 section symbol winds up in the output section. */
3521 if (r_symndx
< symtab_hdr
->sh_info
)
3523 sym
= local_syms
+ r_symndx
;
3524 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
3526 sym_sec
= local_sections
[r_symndx
];
3527 rel
->r_addend
+= sym_sec
->output_offset
;
3533 /* This is a final link. */
3537 if (r_symndx
< symtab_hdr
->sh_info
)
3539 /* This is a local symbol, h defaults to NULL. */
3540 sym
= local_syms
+ r_symndx
;
3541 sym_sec
= local_sections
[r_symndx
];
3542 relocation
= ((ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
3543 ? 0 : sym
->st_value
)
3544 + sym_sec
->output_offset
3545 + sym_sec
->output_section
->vma
);
3551 /* It's a global; Find its entry in the link hash. */
3552 indx
= r_symndx
- symtab_hdr
->sh_info
;
3553 h
= ((struct elf32_hppa_link_hash_entry
*)
3554 elf_sym_hashes (input_bfd
)[indx
]);
3555 while (h
->elf
.root
.type
== bfd_link_hash_indirect
3556 || h
->elf
.root
.type
== bfd_link_hash_warning
)
3557 h
= (struct elf32_hppa_link_hash_entry
*) h
->elf
.root
.u
.i
.link
;
3560 if (h
->elf
.root
.type
== bfd_link_hash_defined
3561 || h
->elf
.root
.type
== bfd_link_hash_defweak
)
3563 sym_sec
= h
->elf
.root
.u
.def
.section
;
3564 /* If sym_sec->output_section is NULL, then it's a
3565 symbol defined in a shared library. */
3566 if (sym_sec
->output_section
!= NULL
)
3567 relocation
= (h
->elf
.root
.u
.def
.value
3568 + sym_sec
->output_offset
3569 + sym_sec
->output_section
->vma
);
3571 else if (h
->elf
.root
.type
== bfd_link_hash_undefweak
)
3573 else if (info
->shared
&& !info
->no_undefined
3574 && ELF_ST_VISIBILITY (h
->elf
.other
) == STV_DEFAULT
3575 && h
->elf
.type
!= STT_PARISC_MILLI
)
3577 if (info
->symbolic
&& !info
->allow_shlib_undefined
)
3578 if (!((*info
->callbacks
->undefined_symbol
)
3579 (info
, h
->elf
.root
.root
.string
, input_bfd
,
3580 input_section
, rel
->r_offset
, false)))
3585 if (!((*info
->callbacks
->undefined_symbol
)
3586 (info
, h
->elf
.root
.root
.string
, input_bfd
,
3587 input_section
, rel
->r_offset
, true)))
3592 /* Do any required modifications to the relocation value, and
3593 determine what types of dynamic info we need to output, if
3598 case R_PARISC_DLTIND14F
:
3599 case R_PARISC_DLTIND14R
:
3600 case R_PARISC_DLTIND21L
:
3601 /* Relocation is to the entry for this symbol in the global
3607 off
= h
->elf
.got
.offset
;
3608 dyn
= hplink
->root
.dynamic_sections_created
;
3609 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
, &h
->elf
))
3611 /* This is actually a static link, or it is a
3612 -Bsymbolic link and the symbol is defined
3613 locally, or the symbol was forced to be local
3614 because of a version file. We must initialize
3615 this entry in the global offset table. Since the
3616 offset must always be a multiple of 4, we use the
3617 least significant bit to record whether we have
3618 initialized it already.
3620 When doing a dynamic link, we create a .rela.got
3621 relocation entry to initialize the value. This
3622 is done in the finish_dynamic_symbol routine. */
3627 bfd_put_32 (output_bfd
, relocation
,
3628 hplink
->sgot
->contents
+ off
);
3629 h
->elf
.got
.offset
|= 1;
3635 /* Local symbol case. */
3636 if (local_got_offsets
== NULL
)
3639 off
= local_got_offsets
[r_symndx
];
3641 /* The offset must always be a multiple of 4. We use
3642 the least significant bit to record whether we have
3643 already generated the necessary reloc. */
3648 bfd_put_32 (output_bfd
, relocation
,
3649 hplink
->sgot
->contents
+ off
);
3653 /* Output a dynamic relocation for this GOT
3654 entry. In this case it is relative to the
3655 base of the object because the symbol index
3657 Elf_Internal_Rela outrel
;
3658 asection
*srelgot
= hplink
->srelgot
;
3660 outrel
.r_offset
= (off
3661 + hplink
->sgot
->output_offset
3662 + hplink
->sgot
->output_section
->vma
);
3663 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_DIR32
);
3664 outrel
.r_addend
= relocation
;
3665 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
3666 ((Elf32_External_Rela
*)
3668 + srelgot
->reloc_count
));
3669 ++srelgot
->reloc_count
;
3672 local_got_offsets
[r_symndx
] |= 1;
3676 if (off
>= (bfd_vma
) -2)
3679 /* Add the base of the GOT to the relocation value. */
3681 + hplink
->sgot
->output_offset
3682 + hplink
->sgot
->output_section
->vma
);
3685 case R_PARISC_SEGREL32
:
3686 /* If this is the first SEGREL relocation, then initialize
3687 the segment base values. */
3688 if (hplink
->text_segment_base
== (bfd_vma
) -1)
3689 bfd_map_over_sections (output_bfd
,
3690 hppa_record_segment_addr
,
3694 case R_PARISC_PLABEL14R
:
3695 case R_PARISC_PLABEL21L
:
3696 case R_PARISC_PLABEL32
:
3697 if (hplink
->root
.dynamic_sections_created
)
3699 /* If we have a global symbol with a PLT slot, then
3700 redirect this relocation to it. */
3703 off
= h
->elf
.plt
.offset
;
3704 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info
, &h
->elf
))
3706 /* In a non-shared link, adjust_dynamic_symbols
3707 isn't called for symbols forced local. We
3708 need to write out the plt entry here. */
3713 bfd_put_32 (output_bfd
,
3715 hplink
->splt
->contents
+ off
);
3716 bfd_put_32 (output_bfd
,
3717 elf_gp (hplink
->splt
->output_section
->owner
),
3718 hplink
->splt
->contents
+ off
+ 4);
3719 h
->elf
.plt
.offset
|= 1;
3725 bfd_vma
*local_plt_offsets
;
3727 if (local_got_offsets
== NULL
)
3730 local_plt_offsets
= local_got_offsets
+ symtab_hdr
->sh_info
;
3731 off
= local_plt_offsets
[r_symndx
];
3733 /* As for the local .got entry case, we use the last
3734 bit to record whether we've already initialised
3735 this local .plt entry. */
3740 bfd_put_32 (output_bfd
,
3742 hplink
->splt
->contents
+ off
);
3743 bfd_put_32 (output_bfd
,
3744 elf_gp (hplink
->splt
->output_section
->owner
),
3745 hplink
->splt
->contents
+ off
+ 4);
3749 /* Output a dynamic IPLT relocation for this
3751 Elf_Internal_Rela outrel
;
3752 asection
*srelplt
= hplink
->srelplt
;
3754 outrel
.r_offset
= (off
3755 + hplink
->splt
->output_offset
3756 + hplink
->splt
->output_section
->vma
);
3757 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_IPLT
);
3758 outrel
.r_addend
= relocation
;
3759 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
3760 ((Elf32_External_Rela
*)
3762 + srelplt
->reloc_count
));
3763 ++srelplt
->reloc_count
;
3766 local_plt_offsets
[r_symndx
] |= 1;
3770 if (off
>= (bfd_vma
) -2)
3773 /* PLABELs contain function pointers. Relocation is to
3774 the entry for the function in the .plt. The magic +2
3775 offset signals to $$dyncall that the function pointer
3776 is in the .plt and thus has a gp pointer too.
3777 Exception: Undefined PLABELs should have a value of
3780 || (h
->elf
.root
.type
!= bfd_link_hash_undefweak
3781 && h
->elf
.root
.type
!= bfd_link_hash_undefined
))
3784 + hplink
->splt
->output_offset
3785 + hplink
->splt
->output_section
->vma
3790 /* Fall through and possibly emit a dynamic relocation. */
3792 case R_PARISC_DIR17F
:
3793 case R_PARISC_DIR17R
:
3794 case R_PARISC_DIR14F
:
3795 case R_PARISC_DIR14R
:
3796 case R_PARISC_DIR21L
:
3797 case R_PARISC_DPREL14F
:
3798 case R_PARISC_DPREL14R
:
3799 case R_PARISC_DPREL21L
:
3800 case R_PARISC_DIR32
:
3801 /* The reloc types handled here and this conditional
3802 expression must match the code in ..check_relocs and
3803 ..discard_relocs. ie. We need exactly the same condition
3804 as in ..check_relocs, with some extra conditions (dynindx
3805 test in this case) to cater for relocs removed by
3806 ..discard_relocs. If you squint, the non-shared test
3807 here does indeed match the one in ..check_relocs, the
3808 difference being that here we test DEF_DYNAMIC as well as
3809 !DEF_REGULAR. All common syms end up with !DEF_REGULAR,
3810 which is why we can't use just that test here.
3811 Conversely, DEF_DYNAMIC can't be used in check_relocs as
3812 there all files have not been loaded. */
3814 && (input_section
->flags
& SEC_ALLOC
) != 0
3815 && (IS_ABSOLUTE_RELOC (r_type
)
3817 && h
->elf
.dynindx
!= -1
3819 || (h
->elf
.elf_link_hash_flags
3820 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
3822 && (input_section
->flags
& SEC_ALLOC
) != 0
3824 && h
->elf
.dynindx
!= -1
3825 && (h
->elf
.elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0
3826 && (((h
->elf
.elf_link_hash_flags
3827 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0
3828 && (h
->elf
.elf_link_hash_flags
3829 & ELF_LINK_HASH_DEF_REGULAR
) == 0)
3830 || h
->elf
.root
.type
== bfd_link_hash_undefweak
3831 || h
->elf
.root
.type
== bfd_link_hash_undefined
)))
3833 Elf_Internal_Rela outrel
;
3836 Elf32_External_Rela
*loc
;
3838 /* When generating a shared object, these relocations
3839 are copied into the output file to be resolved at run
3842 outrel
.r_offset
= rel
->r_offset
;
3843 outrel
.r_addend
= rel
->r_addend
;
3845 if (elf_section_data (input_section
)->stab_info
!= NULL
)
3847 off
= (_bfd_stab_section_offset
3848 (output_bfd
, &hplink
->root
.stab_info
,
3850 &elf_section_data (input_section
)->stab_info
,
3852 if (off
== (bfd_vma
) -1)
3854 outrel
.r_offset
= off
;
3857 outrel
.r_offset
+= (input_section
->output_offset
3858 + input_section
->output_section
->vma
);
3862 memset (&outrel
, 0, sizeof (outrel
));
3865 && h
->elf
.dynindx
!= -1
3867 || !IS_ABSOLUTE_RELOC (r_type
)
3870 || (h
->elf
.elf_link_hash_flags
3871 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
3873 outrel
.r_info
= ELF32_R_INFO (h
->elf
.dynindx
, r_type
);
3875 else /* It's a local symbol, or one marked to become local. */
3879 /* Add the absolute offset of the symbol. */
3880 outrel
.r_addend
+= relocation
;
3882 /* Global plabels need to be processed by the
3883 dynamic linker so that functions have at most one
3884 fptr. For this reason, we need to differentiate
3885 between global and local plabels, which we do by
3886 providing the function symbol for a global plabel
3887 reloc, and no symbol for local plabels. */
3890 && sym_sec
->output_section
!= NULL
3891 && ! bfd_is_abs_section (sym_sec
))
3893 indx
= elf_section_data (sym_sec
->output_section
)->dynindx
;
3894 /* We are turning this relocation into one
3895 against a section symbol, so subtract out the
3896 output section's address but not the offset
3897 of the input section in the output section. */
3898 outrel
.r_addend
-= sym_sec
->output_section
->vma
;
3901 outrel
.r_info
= ELF32_R_INFO (indx
, r_type
);
3904 /* EH info can cause unaligned DIR32 relocs.
3905 Tweak the reloc type for the dynamic linker. */
3906 if (r_type
== R_PARISC_DIR32
&& (outrel
.r_offset
& 3) != 0)
3907 outrel
.r_info
= ELF32_R_INFO (ELF32_R_SYM (outrel
.r_info
),
3910 sreloc
= elf_section_data (input_section
)->sreloc
;
3914 loc
= ((Elf32_External_Rela
*) sreloc
->contents
3915 + sreloc
->reloc_count
);
3916 sreloc
->reloc_count
+= 1;
3917 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
3925 r
= final_link_relocate (input_section
, contents
, rel
, relocation
,
3926 hplink
, sym_sec
, h
);
3928 if (r
== bfd_reloc_ok
)
3932 sym_name
= h
->elf
.root
.root
.string
;
3935 sym_name
= bfd_elf_string_from_elf_section (input_bfd
,
3936 symtab_hdr
->sh_link
,
3938 if (sym_name
== NULL
)
3940 if (*sym_name
== '\0')
3941 sym_name
= bfd_section_name (input_bfd
, sym_sec
);
3944 howto
= elf_hppa_howto_table
+ r_type
;
3946 if (r
== bfd_reloc_undefined
|| r
== bfd_reloc_notsupported
)
3948 (*_bfd_error_handler
)
3949 (_("%s(%s+0x%lx): cannot handle %s for %s"),
3950 bfd_archive_filename (input_bfd
),
3951 input_section
->name
,
3952 (long) rel
->r_offset
,
3955 bfd_set_error (bfd_error_bad_value
);
3960 if (!((*info
->callbacks
->reloc_overflow
)
3961 (info
, sym_name
, howto
->name
, (bfd_vma
) 0,
3962 input_bfd
, input_section
, rel
->r_offset
)))
3970 /* Comparison function for qsort to sort unwind section during a
3974 hppa_unwind_entry_compare (a
, b
)
3978 const bfd_byte
*ap
, *bp
;
3979 unsigned long av
, bv
;
3981 ap
= (const bfd_byte
*) a
;
3982 av
= (unsigned long) ap
[0] << 24;
3983 av
|= (unsigned long) ap
[1] << 16;
3984 av
|= (unsigned long) ap
[2] << 8;
3985 av
|= (unsigned long) ap
[3];
3987 bp
= (const bfd_byte
*) b
;
3988 bv
= (unsigned long) bp
[0] << 24;
3989 bv
|= (unsigned long) bp
[1] << 16;
3990 bv
|= (unsigned long) bp
[2] << 8;
3991 bv
|= (unsigned long) bp
[3];
3993 return av
< bv
? -1 : av
> bv
? 1 : 0;
3996 /* Finish up dynamic symbol handling. We set the contents of various
3997 dynamic sections here. */
4000 elf32_hppa_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
4002 struct bfd_link_info
*info
;
4003 struct elf_link_hash_entry
*h
;
4004 Elf_Internal_Sym
*sym
;
4006 struct elf32_hppa_link_hash_table
*hplink
;
4009 hplink
= hppa_link_hash_table (info
);
4010 dynobj
= hplink
->root
.dynobj
;
4012 if (h
->plt
.offset
!= (bfd_vma
) -1)
4016 if (h
->plt
.offset
& 1)
4019 /* This symbol has an entry in the procedure linkage table. Set
4022 The format of a plt entry is
4027 if (h
->root
.type
== bfd_link_hash_defined
4028 || h
->root
.type
== bfd_link_hash_defweak
)
4030 value
= h
->root
.u
.def
.value
;
4031 if (h
->root
.u
.def
.section
->output_section
!= NULL
)
4032 value
+= (h
->root
.u
.def
.section
->output_offset
4033 + h
->root
.u
.def
.section
->output_section
->vma
);
4036 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
4038 Elf_Internal_Rela rel
;
4040 /* Create a dynamic IPLT relocation for this entry. */
4041 rel
.r_offset
= (h
->plt
.offset
4042 + hplink
->splt
->output_offset
4043 + hplink
->splt
->output_section
->vma
);
4044 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->plt_abs
4045 && h
->dynindx
!= -1)
4047 /* To support lazy linking, the function pointer is
4048 initialised to point to a special stub stored at the
4049 end of the .plt. This is not done for plt entries
4050 with a base-relative dynamic relocation. */
4051 value
= (hplink
->splt
->output_offset
4052 + hplink
->splt
->output_section
->vma
4053 + hplink
->splt
->_raw_size
4056 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_PARISC_IPLT
);
4061 /* This symbol has been marked to become local, and is
4062 used by a plabel so must be kept in the .plt. */
4063 rel
.r_info
= ELF32_R_INFO (0, R_PARISC_IPLT
);
4064 rel
.r_addend
= value
;
4067 bfd_elf32_swap_reloca_out (hplink
->splt
->output_section
->owner
,
4069 ((Elf32_External_Rela
*)
4070 hplink
->srelplt
->contents
4071 + hplink
->srelplt
->reloc_count
));
4072 hplink
->srelplt
->reloc_count
++;
4075 bfd_put_32 (hplink
->splt
->owner
,
4077 hplink
->splt
->contents
+ h
->plt
.offset
);
4078 bfd_put_32 (hplink
->splt
->owner
,
4079 elf_gp (hplink
->splt
->output_section
->owner
),
4080 hplink
->splt
->contents
+ h
->plt
.offset
+ 4);
4081 if (PLABEL_PLT_ENTRY_SIZE
!= PLT_ENTRY_SIZE
4082 && ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
4083 && h
->dynindx
!= -1)
4085 memset (hplink
->splt
->contents
+ h
->plt
.offset
+ 8,
4086 0, PLABEL_PLT_ENTRY_SIZE
- PLT_ENTRY_SIZE
);
4089 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
4091 /* Mark the symbol as undefined, rather than as defined in
4092 the .plt section. Leave the value alone. */
4093 sym
->st_shndx
= SHN_UNDEF
;
4097 if (h
->got
.offset
!= (bfd_vma
) -1)
4099 Elf_Internal_Rela rel
;
4101 /* This symbol has an entry in the global offset table. Set it
4104 rel
.r_offset
= ((h
->got
.offset
&~ (bfd_vma
) 1)
4105 + hplink
->sgot
->output_offset
4106 + hplink
->sgot
->output_section
->vma
);
4108 /* If this is a -Bsymbolic link and the symbol is defined
4109 locally or was forced to be local because of a version file,
4110 we just want to emit a RELATIVE reloc. The entry in the
4111 global offset table will already have been initialized in the
4112 relocate_section function. */
4114 && (info
->symbolic
|| h
->dynindx
== -1)
4115 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
))
4117 rel
.r_info
= ELF32_R_INFO (0, R_PARISC_DIR32
);
4118 rel
.r_addend
= (h
->root
.u
.def
.value
4119 + h
->root
.u
.def
.section
->output_offset
4120 + h
->root
.u
.def
.section
->output_section
->vma
);
4124 if ((h
->got
.offset
& 1) != 0)
4126 bfd_put_32 (output_bfd
, (bfd_vma
) 0,
4127 hplink
->sgot
->contents
+ h
->got
.offset
);
4128 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_PARISC_DIR32
);
4132 bfd_elf32_swap_reloca_out (output_bfd
, &rel
,
4133 ((Elf32_External_Rela
*)
4134 hplink
->srelgot
->contents
4135 + hplink
->srelgot
->reloc_count
));
4136 ++hplink
->srelgot
->reloc_count
;
4139 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
4142 Elf_Internal_Rela rel
;
4144 /* This symbol needs a copy reloc. Set it up. */
4146 if (! (h
->dynindx
!= -1
4147 && (h
->root
.type
== bfd_link_hash_defined
4148 || h
->root
.type
== bfd_link_hash_defweak
)))
4151 s
= hplink
->srelbss
;
4153 rel
.r_offset
= (h
->root
.u
.def
.value
4154 + h
->root
.u
.def
.section
->output_offset
4155 + h
->root
.u
.def
.section
->output_section
->vma
);
4157 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_PARISC_COPY
);
4158 bfd_elf32_swap_reloca_out (output_bfd
, &rel
,
4159 ((Elf32_External_Rela
*) s
->contents
4164 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
4165 if (h
->root
.root
.string
[0] == '_'
4166 && (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
4167 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0))
4169 sym
->st_shndx
= SHN_ABS
;
4175 /* Used to decide how to sort relocs in an optimal manner for the
4176 dynamic linker, before writing them out. */
4178 static enum elf_reloc_type_class
4179 elf32_hppa_reloc_type_class (rela
)
4180 const Elf_Internal_Rela
*rela
;
4182 if (ELF32_R_SYM (rela
->r_info
) == 0)
4183 return reloc_class_relative
;
4185 switch ((int) ELF32_R_TYPE (rela
->r_info
))
4188 return reloc_class_plt
;
4190 return reloc_class_copy
;
4192 return reloc_class_normal
;
4196 /* Finish up the dynamic sections. */
4199 elf32_hppa_finish_dynamic_sections (output_bfd
, info
)
4201 struct bfd_link_info
*info
;
4204 struct elf32_hppa_link_hash_table
*hplink
;
4207 hplink
= hppa_link_hash_table (info
);
4208 dynobj
= hplink
->root
.dynobj
;
4210 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
4212 if (hplink
->root
.dynamic_sections_created
)
4214 Elf32_External_Dyn
*dyncon
, *dynconend
;
4219 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
4220 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
4221 for (; dyncon
< dynconend
; dyncon
++)
4223 Elf_Internal_Dyn dyn
;
4226 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
4234 /* Use PLTGOT to set the GOT register. */
4235 dyn
.d_un
.d_ptr
= elf_gp (output_bfd
);
4236 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4240 s
= hplink
->srelplt
;
4241 dyn
.d_un
.d_ptr
= s
->output_section
->vma
+ s
->output_offset
;
4242 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4246 s
= hplink
->srelplt
;
4247 if (s
->_cooked_size
!= 0)
4248 dyn
.d_un
.d_val
= s
->_cooked_size
;
4250 dyn
.d_un
.d_val
= s
->_raw_size
;
4251 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4257 if (hplink
->sgot
!= NULL
&& hplink
->sgot
->_raw_size
!= 0)
4259 /* Fill in the first entry in the global offset table.
4260 We use it to point to our dynamic section, if we have one. */
4261 bfd_put_32 (output_bfd
,
4263 ? sdyn
->output_section
->vma
+ sdyn
->output_offset
4265 hplink
->sgot
->contents
);
4267 /* The second entry is reserved for use by the dynamic linker. */
4268 memset (hplink
->sgot
->contents
+ GOT_ENTRY_SIZE
, 0, GOT_ENTRY_SIZE
);
4270 /* Set .got entry size. */
4271 elf_section_data (hplink
->sgot
->output_section
)
4272 ->this_hdr
.sh_entsize
= GOT_ENTRY_SIZE
;
4275 if (hplink
->splt
!= NULL
&& hplink
->splt
->_raw_size
!= 0)
4277 /* Set plt entry size. */
4278 elf_section_data (hplink
->splt
->output_section
)
4279 ->this_hdr
.sh_entsize
= PLT_ENTRY_SIZE
;
4281 if (hplink
->need_plt_stub
)
4283 /* Set up the .plt stub. */
4284 memcpy (hplink
->splt
->contents
4285 + hplink
->splt
->_raw_size
- sizeof (plt_stub
),
4286 plt_stub
, sizeof (plt_stub
));
4288 if ((hplink
->splt
->output_offset
4289 + hplink
->splt
->output_section
->vma
4290 + hplink
->splt
->_raw_size
)
4291 != (hplink
->sgot
->output_offset
4292 + hplink
->sgot
->output_section
->vma
))
4294 (*_bfd_error_handler
)
4295 (_(".got section not immediately after .plt section"));
4304 /* Tweak the OSABI field of the elf header. */
4307 elf32_hppa_post_process_headers (abfd
, link_info
)
4309 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
4311 Elf_Internal_Ehdr
* i_ehdrp
;
4313 i_ehdrp
= elf_elfheader (abfd
);
4315 if (strcmp (bfd_get_target (abfd
), "elf32-hppa-linux") == 0)
4317 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_LINUX
;
4321 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_HPUX
;
4325 /* Called when writing out an object file to decide the type of a
4328 elf32_hppa_elf_get_symbol_type (elf_sym
, type
)
4329 Elf_Internal_Sym
*elf_sym
;
4332 if (ELF_ST_TYPE (elf_sym
->st_info
) == STT_PARISC_MILLI
)
4333 return STT_PARISC_MILLI
;
4338 /* Misc BFD support code. */
4339 #define bfd_elf32_bfd_is_local_label_name elf_hppa_is_local_label_name
4340 #define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup
4341 #define elf_info_to_howto elf_hppa_info_to_howto
4342 #define elf_info_to_howto_rel elf_hppa_info_to_howto_rel
4344 /* Stuff for the BFD linker. */
4345 #define bfd_elf32_bfd_final_link elf32_hppa_final_link
4346 #define bfd_elf32_bfd_link_hash_table_create elf32_hppa_link_hash_table_create
4347 #define elf_backend_add_symbol_hook elf32_hppa_add_symbol_hook
4348 #define elf_backend_adjust_dynamic_symbol elf32_hppa_adjust_dynamic_symbol
4349 #define elf_backend_check_relocs elf32_hppa_check_relocs
4350 #define elf_backend_create_dynamic_sections elf32_hppa_create_dynamic_sections
4351 #define elf_backend_fake_sections elf_hppa_fake_sections
4352 #define elf_backend_relocate_section elf32_hppa_relocate_section
4353 #define elf_backend_hide_symbol elf32_hppa_hide_symbol
4354 #define elf_backend_finish_dynamic_symbol elf32_hppa_finish_dynamic_symbol
4355 #define elf_backend_finish_dynamic_sections elf32_hppa_finish_dynamic_sections
4356 #define elf_backend_size_dynamic_sections elf32_hppa_size_dynamic_sections
4357 #define elf_backend_gc_mark_hook elf32_hppa_gc_mark_hook
4358 #define elf_backend_gc_sweep_hook elf32_hppa_gc_sweep_hook
4359 #define elf_backend_object_p elf32_hppa_object_p
4360 #define elf_backend_final_write_processing elf_hppa_final_write_processing
4361 #define elf_backend_post_process_headers elf32_hppa_post_process_headers
4362 #define elf_backend_get_symbol_type elf32_hppa_elf_get_symbol_type
4363 #define elf_backend_reloc_type_class elf32_hppa_reloc_type_class
4365 #define elf_backend_can_gc_sections 1
4366 #define elf_backend_plt_alignment 2
4367 #define elf_backend_want_got_plt 0
4368 #define elf_backend_plt_readonly 0
4369 #define elf_backend_want_plt_sym 0
4370 #define elf_backend_got_header_size 8
4372 #define TARGET_BIG_SYM bfd_elf32_hppa_vec
4373 #define TARGET_BIG_NAME "elf32-hppa"
4374 #define ELF_ARCH bfd_arch_hppa
4375 #define ELF_MACHINE_CODE EM_PARISC
4376 #define ELF_MAXPAGESIZE 0x1000
4378 #include "elf32-target.h"
4380 #undef TARGET_BIG_SYM
4381 #define TARGET_BIG_SYM bfd_elf32_hppa_linux_vec
4382 #undef TARGET_BIG_NAME
4383 #define TARGET_BIG_NAME "elf32-hppa-linux"
4385 #define INCLUDED_TARGET_FILE 1
4386 #include "elf32-target.h"