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;
218 struct elf32_hppa_link_hash_table
{
220 /* The main hash table. */
221 struct elf_link_hash_table elf
;
223 /* The stub hash table. */
224 struct bfd_hash_table stub_hash_table
;
226 /* Linker stub bfd. */
229 /* Linker call-backs. */
230 asection
* (*add_stub_section
) PARAMS ((const char *, asection
*));
231 void (*layout_sections_again
) PARAMS ((void));
233 /* Array to keep track of which stub sections have been created, and
234 information on stub grouping. */
236 /* This is the section to which stubs in the group will be
239 /* The stub section. */
243 /* Short-cuts to get to dynamic linker sections. */
251 /* Used during a final link to store the base of the text and data
252 segments so that we can perform SEGREL relocations. */
253 bfd_vma text_segment_base
;
254 bfd_vma data_segment_base
;
256 /* Whether we support multiple sub-spaces for shared libs. */
257 unsigned int multi_subspace
:1;
259 /* Flags set when PCREL12F and PCREL17F branches detected. Used to
260 select suitable defaults for the stub group size. */
261 unsigned int has_12bit_branch
:1;
262 unsigned int has_17bit_branch
:1;
264 /* Set if we need a .plt stub to support lazy dynamic linking. */
265 unsigned int need_plt_stub
:1;
268 /* Various hash macros and functions. */
269 #define hppa_link_hash_table(p) \
270 ((struct elf32_hppa_link_hash_table *) ((p)->hash))
272 #define hppa_stub_hash_lookup(table, string, create, copy) \
273 ((struct elf32_hppa_stub_hash_entry *) \
274 bfd_hash_lookup ((table), (string), (create), (copy)))
276 static struct bfd_hash_entry
*stub_hash_newfunc
277 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
279 static struct bfd_hash_entry
*hppa_link_hash_newfunc
280 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
282 static struct bfd_link_hash_table
*elf32_hppa_link_hash_table_create
285 /* Stub handling functions. */
286 static char *hppa_stub_name
287 PARAMS ((const asection
*, const asection
*,
288 const struct elf32_hppa_link_hash_entry
*,
289 const Elf_Internal_Rela
*));
291 static struct elf32_hppa_stub_hash_entry
*hppa_get_stub_entry
292 PARAMS ((const asection
*, const asection
*,
293 struct elf32_hppa_link_hash_entry
*,
294 const Elf_Internal_Rela
*,
295 struct elf32_hppa_link_hash_table
*));
297 static struct elf32_hppa_stub_hash_entry
*hppa_add_stub
298 PARAMS ((const char *, asection
*, struct elf32_hppa_link_hash_table
*));
300 static enum elf32_hppa_stub_type hppa_type_of_stub
301 PARAMS ((asection
*, const Elf_Internal_Rela
*,
302 struct elf32_hppa_link_hash_entry
*, bfd_vma
));
304 static boolean hppa_build_one_stub
305 PARAMS ((struct bfd_hash_entry
*, PTR
));
307 static boolean hppa_size_one_stub
308 PARAMS ((struct bfd_hash_entry
*, PTR
));
310 /* BFD and elf backend functions. */
311 static boolean elf32_hppa_object_p
PARAMS ((bfd
*));
313 static boolean elf32_hppa_add_symbol_hook
314 PARAMS ((bfd
*, struct bfd_link_info
*, const Elf_Internal_Sym
*,
315 const char **, flagword
*, asection
**, bfd_vma
*));
317 static boolean elf32_hppa_create_dynamic_sections
318 PARAMS ((bfd
*, struct bfd_link_info
*));
320 static void elf32_hppa_copy_indirect_symbol
321 PARAMS ((struct elf_link_hash_entry
*, struct elf_link_hash_entry
*));
323 static boolean elf32_hppa_check_relocs
324 PARAMS ((bfd
*, struct bfd_link_info
*,
325 asection
*, const Elf_Internal_Rela
*));
327 static asection
*elf32_hppa_gc_mark_hook
328 PARAMS ((bfd
*, struct bfd_link_info
*, Elf_Internal_Rela
*,
329 struct elf_link_hash_entry
*, Elf_Internal_Sym
*));
331 static boolean elf32_hppa_gc_sweep_hook
332 PARAMS ((bfd
*, struct bfd_link_info
*,
333 asection
*, const Elf_Internal_Rela
*));
335 static void elf32_hppa_hide_symbol
336 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
338 static boolean elf32_hppa_adjust_dynamic_symbol
339 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
341 static boolean mark_PIC_calls
342 PARAMS ((struct elf_link_hash_entry
*, PTR
));
344 static boolean allocate_PIC_calls
345 PARAMS ((struct elf_link_hash_entry
*, PTR
));
347 static boolean allocate_dynrelocs
348 PARAMS ((struct elf_link_hash_entry
*, PTR
));
350 static boolean readonly_dynrelocs
351 PARAMS ((struct elf_link_hash_entry
*, PTR
));
353 static boolean clobber_millicode_symbols
354 PARAMS ((struct elf_link_hash_entry
*, struct bfd_link_info
*));
356 static boolean elf32_hppa_size_dynamic_sections
357 PARAMS ((bfd
*, struct bfd_link_info
*));
359 static boolean elf32_hppa_final_link
360 PARAMS ((bfd
*, struct bfd_link_info
*));
362 static void hppa_record_segment_addr
363 PARAMS ((bfd
*, asection
*, PTR
));
365 static bfd_reloc_status_type final_link_relocate
366 PARAMS ((asection
*, bfd_byte
*, const Elf_Internal_Rela
*,
367 bfd_vma
, struct elf32_hppa_link_hash_table
*, asection
*,
368 struct elf32_hppa_link_hash_entry
*));
370 static boolean elf32_hppa_relocate_section
371 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*,
372 bfd_byte
*, Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**));
374 static int hppa_unwind_entry_compare
375 PARAMS ((const PTR
, const PTR
));
377 static boolean elf32_hppa_finish_dynamic_symbol
378 PARAMS ((bfd
*, struct bfd_link_info
*,
379 struct elf_link_hash_entry
*, Elf_Internal_Sym
*));
381 static enum elf_reloc_type_class elf32_hppa_reloc_type_class
382 PARAMS ((const Elf_Internal_Rela
*));
384 static boolean elf32_hppa_finish_dynamic_sections
385 PARAMS ((bfd
*, struct bfd_link_info
*));
387 static void elf32_hppa_post_process_headers
388 PARAMS ((bfd
*, struct bfd_link_info
*));
390 static int elf32_hppa_elf_get_symbol_type
391 PARAMS ((Elf_Internal_Sym
*, int));
393 /* Assorted hash table functions. */
395 /* Initialize an entry in the stub hash table. */
397 static struct bfd_hash_entry
*
398 stub_hash_newfunc (entry
, table
, string
)
399 struct bfd_hash_entry
*entry
;
400 struct bfd_hash_table
*table
;
403 /* Allocate the structure if it has not already been allocated by a
407 entry
= bfd_hash_allocate (table
,
408 sizeof (struct elf32_hppa_stub_hash_entry
));
413 /* Call the allocation method of the superclass. */
414 entry
= bfd_hash_newfunc (entry
, table
, string
);
417 struct elf32_hppa_stub_hash_entry
*eh
;
419 /* Initialize the local fields. */
420 eh
= (struct elf32_hppa_stub_hash_entry
*) entry
;
423 eh
->target_value
= 0;
424 eh
->target_section
= NULL
;
425 eh
->stub_type
= hppa_stub_long_branch
;
433 /* Initialize an entry in the link hash table. */
435 static struct bfd_hash_entry
*
436 hppa_link_hash_newfunc (entry
, table
, string
)
437 struct bfd_hash_entry
*entry
;
438 struct bfd_hash_table
*table
;
441 /* Allocate the structure if it has not already been allocated by a
445 entry
= bfd_hash_allocate (table
,
446 sizeof (struct elf32_hppa_link_hash_entry
));
451 /* Call the allocation method of the superclass. */
452 entry
= _bfd_elf_link_hash_newfunc (entry
, table
, string
);
455 struct elf32_hppa_link_hash_entry
*eh
;
457 /* Initialize the local fields. */
458 eh
= (struct elf32_hppa_link_hash_entry
*) entry
;
459 eh
->stub_cache
= NULL
;
460 eh
->dyn_relocs
= NULL
;
461 eh
->maybe_pic_call
= 0;
469 /* Create the derived linker hash table. The PA ELF port uses the derived
470 hash table to keep information specific to the PA ELF linker (without
471 using static variables). */
473 static struct bfd_link_hash_table
*
474 elf32_hppa_link_hash_table_create (abfd
)
477 struct elf32_hppa_link_hash_table
*ret
;
478 bfd_size_type amt
= sizeof (*ret
);
480 ret
= (struct elf32_hppa_link_hash_table
*) bfd_alloc (abfd
, amt
);
484 if (!_bfd_elf_link_hash_table_init (&ret
->elf
, abfd
, hppa_link_hash_newfunc
))
486 bfd_release (abfd
, ret
);
490 /* Init the stub hash table too. */
491 if (!bfd_hash_table_init (&ret
->stub_hash_table
, stub_hash_newfunc
))
494 ret
->stub_bfd
= NULL
;
495 ret
->add_stub_section
= NULL
;
496 ret
->layout_sections_again
= NULL
;
497 ret
->stub_group
= NULL
;
504 ret
->text_segment_base
= (bfd_vma
) -1;
505 ret
->data_segment_base
= (bfd_vma
) -1;
506 ret
->multi_subspace
= 0;
507 ret
->has_12bit_branch
= 0;
508 ret
->has_17bit_branch
= 0;
509 ret
->need_plt_stub
= 0;
511 return &ret
->elf
.root
;
514 /* Build a name for an entry in the stub hash table. */
517 hppa_stub_name (input_section
, sym_sec
, hash
, rel
)
518 const asection
*input_section
;
519 const asection
*sym_sec
;
520 const struct elf32_hppa_link_hash_entry
*hash
;
521 const Elf_Internal_Rela
*rel
;
528 len
= 8 + 1 + strlen (hash
->elf
.root
.root
.string
) + 1 + 8 + 1;
529 stub_name
= bfd_malloc (len
);
530 if (stub_name
!= NULL
)
532 sprintf (stub_name
, "%08x_%s+%x",
533 input_section
->id
& 0xffffffff,
534 hash
->elf
.root
.root
.string
,
535 (int) rel
->r_addend
& 0xffffffff);
540 len
= 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1;
541 stub_name
= bfd_malloc (len
);
542 if (stub_name
!= NULL
)
544 sprintf (stub_name
, "%08x_%x:%x+%x",
545 input_section
->id
& 0xffffffff,
546 sym_sec
->id
& 0xffffffff,
547 (int) ELF32_R_SYM (rel
->r_info
) & 0xffffffff,
548 (int) rel
->r_addend
& 0xffffffff);
554 /* Look up an entry in the stub hash. Stub entries are cached because
555 creating the stub name takes a bit of time. */
557 static struct elf32_hppa_stub_hash_entry
*
558 hppa_get_stub_entry (input_section
, sym_sec
, hash
, rel
, htab
)
559 const asection
*input_section
;
560 const asection
*sym_sec
;
561 struct elf32_hppa_link_hash_entry
*hash
;
562 const Elf_Internal_Rela
*rel
;
563 struct elf32_hppa_link_hash_table
*htab
;
565 struct elf32_hppa_stub_hash_entry
*stub_entry
;
566 const asection
*id_sec
;
568 /* If this input section is part of a group of sections sharing one
569 stub section, then use the id of the first section in the group.
570 Stub names need to include a section id, as there may well be
571 more than one stub used to reach say, printf, and we need to
572 distinguish between them. */
573 id_sec
= htab
->stub_group
[input_section
->id
].link_sec
;
575 if (hash
!= NULL
&& hash
->stub_cache
!= NULL
576 && hash
->stub_cache
->h
== hash
577 && hash
->stub_cache
->id_sec
== id_sec
)
579 stub_entry
= hash
->stub_cache
;
585 stub_name
= hppa_stub_name (id_sec
, sym_sec
, hash
, rel
);
586 if (stub_name
== NULL
)
589 stub_entry
= hppa_stub_hash_lookup (&htab
->stub_hash_table
,
590 stub_name
, false, false);
591 if (stub_entry
== NULL
)
593 if (hash
== NULL
|| hash
->elf
.root
.type
!= bfd_link_hash_undefweak
)
594 (*_bfd_error_handler
) (_("%s(%s+0x%lx): cannot find stub entry %s"),
595 bfd_archive_filename (input_section
->owner
),
597 (long) rel
->r_offset
,
603 hash
->stub_cache
= stub_entry
;
612 /* Add a new stub entry to the stub hash. Not all fields of the new
613 stub entry are initialised. */
615 static struct elf32_hppa_stub_hash_entry
*
616 hppa_add_stub (stub_name
, section
, htab
)
617 const char *stub_name
;
619 struct elf32_hppa_link_hash_table
*htab
;
623 struct elf32_hppa_stub_hash_entry
*stub_entry
;
625 link_sec
= htab
->stub_group
[section
->id
].link_sec
;
626 stub_sec
= htab
->stub_group
[section
->id
].stub_sec
;
627 if (stub_sec
== NULL
)
629 stub_sec
= htab
->stub_group
[link_sec
->id
].stub_sec
;
630 if (stub_sec
== NULL
)
635 len
= strlen (link_sec
->name
) + sizeof (STUB_SUFFIX
);
636 s_name
= bfd_alloc (htab
->stub_bfd
, len
);
640 strcpy (s_name
, link_sec
->name
);
641 strcpy (s_name
+ len
- sizeof (STUB_SUFFIX
), STUB_SUFFIX
);
642 stub_sec
= (*htab
->add_stub_section
) (s_name
, link_sec
);
643 if (stub_sec
== NULL
)
645 htab
->stub_group
[link_sec
->id
].stub_sec
= stub_sec
;
647 htab
->stub_group
[section
->id
].stub_sec
= stub_sec
;
650 /* Enter this entry into the linker stub hash table. */
651 stub_entry
= hppa_stub_hash_lookup (&htab
->stub_hash_table
, stub_name
,
653 if (stub_entry
== NULL
)
655 (*_bfd_error_handler
) (_("%s: cannot create stub entry %s"),
656 bfd_archive_filename (section
->owner
),
661 stub_entry
->stub_sec
= stub_sec
;
662 stub_entry
->stub_offset
= 0;
663 stub_entry
->id_sec
= link_sec
;
667 /* Determine the type of stub needed, if any, for a call. */
669 static enum elf32_hppa_stub_type
670 hppa_type_of_stub (input_sec
, rel
, hash
, destination
)
672 const Elf_Internal_Rela
*rel
;
673 struct elf32_hppa_link_hash_entry
*hash
;
677 bfd_vma branch_offset
;
678 bfd_vma max_branch_offset
;
682 && (((hash
->elf
.root
.type
== bfd_link_hash_defined
683 || hash
->elf
.root
.type
== bfd_link_hash_defweak
)
684 && hash
->elf
.root
.u
.def
.section
->output_section
== NULL
)
685 || (hash
->elf
.root
.type
== bfd_link_hash_defweak
686 && hash
->elf
.dynindx
!= -1
687 && hash
->elf
.plt
.offset
!= (bfd_vma
) -1)
688 || hash
->elf
.root
.type
== bfd_link_hash_undefweak
689 || hash
->elf
.root
.type
== bfd_link_hash_undefined
690 || (hash
->maybe_pic_call
&& !(input_sec
->flags
& SEC_HAS_GOT_REF
))))
692 /* If output_section is NULL, then it's a symbol defined in a
693 shared library. We will need an import stub. Decide between
694 hppa_stub_import and hppa_stub_import_shared later. For
695 shared links we need stubs for undefined or weak syms too;
696 They will presumably be resolved by the dynamic linker. */
697 return hppa_stub_import
;
700 /* Determine where the call point is. */
701 location
= (input_sec
->output_offset
702 + input_sec
->output_section
->vma
705 branch_offset
= destination
- location
- 8;
706 r_type
= ELF32_R_TYPE (rel
->r_info
);
708 /* Determine if a long branch stub is needed. parisc branch offsets
709 are relative to the second instruction past the branch, ie. +8
710 bytes on from the branch instruction location. The offset is
711 signed and counts in units of 4 bytes. */
712 if (r_type
== (unsigned int) R_PARISC_PCREL17F
)
714 max_branch_offset
= (1 << (17-1)) << 2;
716 else if (r_type
== (unsigned int) R_PARISC_PCREL12F
)
718 max_branch_offset
= (1 << (12-1)) << 2;
720 else /* R_PARISC_PCREL22F. */
722 max_branch_offset
= (1 << (22-1)) << 2;
725 if (branch_offset
+ max_branch_offset
>= 2*max_branch_offset
)
726 return hppa_stub_long_branch
;
728 return hppa_stub_none
;
731 /* Build one linker stub as defined by the stub hash table entry GEN_ENTRY.
732 IN_ARG contains the link info pointer. */
734 #define LDIL_R1 0x20200000 /* ldil LR'XXX,%r1 */
735 #define BE_SR4_R1 0xe0202002 /* be,n RR'XXX(%sr4,%r1) */
737 #define BL_R1 0xe8200000 /* b,l .+8,%r1 */
738 #define ADDIL_R1 0x28200000 /* addil LR'XXX,%r1,%r1 */
739 #define DEPI_R1 0xd4201c1e /* depi 0,31,2,%r1 */
741 #define ADDIL_DP 0x2b600000 /* addil LR'XXX,%dp,%r1 */
742 #define LDW_R1_R21 0x48350000 /* ldw RR'XXX(%sr0,%r1),%r21 */
743 #define BV_R0_R21 0xeaa0c000 /* bv %r0(%r21) */
744 #define LDW_R1_R19 0x48330000 /* ldw RR'XXX(%sr0,%r1),%r19 */
746 #define ADDIL_R19 0x2a600000 /* addil LR'XXX,%r19,%r1 */
747 #define LDW_R1_DP 0x483b0000 /* ldw RR'XXX(%sr0,%r1),%dp */
749 #define LDSID_R21_R1 0x02a010a1 /* ldsid (%sr0,%r21),%r1 */
750 #define MTSP_R1 0x00011820 /* mtsp %r1,%sr0 */
751 #define BE_SR0_R21 0xe2a00000 /* be 0(%sr0,%r21) */
752 #define STW_RP 0x6bc23fd1 /* stw %rp,-24(%sr0,%sp) */
754 #define BL_RP 0xe8400002 /* b,l,n XXX,%rp */
755 #define NOP 0x08000240 /* nop */
756 #define LDW_RP 0x4bc23fd1 /* ldw -24(%sr0,%sp),%rp */
757 #define LDSID_RP_R1 0x004010a1 /* ldsid (%sr0,%rp),%r1 */
758 #define BE_SR0_RP 0xe0400002 /* be,n 0(%sr0,%rp) */
765 #define LDW_R1_DLT LDW_R1_R19
767 #define LDW_R1_DLT LDW_R1_DP
771 hppa_build_one_stub (gen_entry
, in_arg
)
772 struct bfd_hash_entry
*gen_entry
;
775 struct elf32_hppa_stub_hash_entry
*stub_entry
;
776 struct bfd_link_info
*info
;
777 struct elf32_hppa_link_hash_table
*htab
;
787 /* Massage our args to the form they really have. */
788 stub_entry
= (struct elf32_hppa_stub_hash_entry
*) gen_entry
;
789 info
= (struct bfd_link_info
*) in_arg
;
791 htab
= hppa_link_hash_table (info
);
792 stub_sec
= stub_entry
->stub_sec
;
794 /* Make a note of the offset within the stubs for this entry. */
795 stub_entry
->stub_offset
= stub_sec
->_raw_size
;
796 loc
= stub_sec
->contents
+ stub_entry
->stub_offset
;
798 stub_bfd
= stub_sec
->owner
;
800 switch (stub_entry
->stub_type
)
802 case hppa_stub_long_branch
:
803 /* Create the long branch. A long branch is formed with "ldil"
804 loading the upper bits of the target address into a register,
805 then branching with "be" which adds in the lower bits.
806 The "be" has its delay slot nullified. */
807 sym_value
= (stub_entry
->target_value
808 + stub_entry
->target_section
->output_offset
809 + stub_entry
->target_section
->output_section
->vma
);
811 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_lrsel
);
812 insn
= hppa_rebuild_insn ((int) LDIL_R1
, val
, 21);
813 bfd_put_32 (stub_bfd
, insn
, loc
);
815 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_rrsel
) >> 2;
816 insn
= hppa_rebuild_insn ((int) BE_SR4_R1
, val
, 17);
817 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
822 case hppa_stub_long_branch_shared
:
823 /* Branches are relative. This is where we are going to. */
824 sym_value
= (stub_entry
->target_value
825 + stub_entry
->target_section
->output_offset
826 + stub_entry
->target_section
->output_section
->vma
);
828 /* And this is where we are coming from, more or less. */
829 sym_value
-= (stub_entry
->stub_offset
830 + stub_sec
->output_offset
831 + stub_sec
->output_section
->vma
);
833 bfd_put_32 (stub_bfd
, (bfd_vma
) BL_R1
, loc
);
834 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_lrsel
);
835 insn
= hppa_rebuild_insn ((int) ADDIL_R1
, val
, 21);
836 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
838 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_rrsel
) >> 2;
839 insn
= hppa_rebuild_insn ((int) BE_SR4_R1
, val
, 17);
840 bfd_put_32 (stub_bfd
, insn
, loc
+ 8);
844 case hppa_stub_import
:
845 case hppa_stub_import_shared
:
846 off
= stub_entry
->h
->elf
.plt
.offset
;
847 if (off
>= (bfd_vma
) -2)
850 off
&= ~ (bfd_vma
) 1;
852 + htab
->splt
->output_offset
853 + htab
->splt
->output_section
->vma
854 - elf_gp (htab
->splt
->output_section
->owner
));
858 if (stub_entry
->stub_type
== hppa_stub_import_shared
)
861 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_lrsel
),
862 insn
= hppa_rebuild_insn ((int) insn
, val
, 21);
863 bfd_put_32 (stub_bfd
, insn
, loc
);
865 /* It is critical to use lrsel/rrsel here because we are using
866 two different offsets (+0 and +4) from sym_value. If we use
867 lsel/rsel then with unfortunate sym_values we will round
868 sym_value+4 up to the next 2k block leading to a mis-match
869 between the lsel and rsel value. */
870 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_rrsel
);
871 insn
= hppa_rebuild_insn ((int) LDW_R1_R21
, val
, 14);
872 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
874 if (htab
->multi_subspace
)
876 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 4, e_rrsel
);
877 insn
= hppa_rebuild_insn ((int) LDW_R1_DLT
, val
, 14);
878 bfd_put_32 (stub_bfd
, insn
, loc
+ 8);
880 bfd_put_32 (stub_bfd
, (bfd_vma
) LDSID_R21_R1
, loc
+ 12);
881 bfd_put_32 (stub_bfd
, (bfd_vma
) MTSP_R1
, loc
+ 16);
882 bfd_put_32 (stub_bfd
, (bfd_vma
) BE_SR0_R21
, loc
+ 20);
883 bfd_put_32 (stub_bfd
, (bfd_vma
) STW_RP
, loc
+ 24);
889 bfd_put_32 (stub_bfd
, (bfd_vma
) BV_R0_R21
, loc
+ 8);
890 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 4, e_rrsel
);
891 insn
= hppa_rebuild_insn ((int) LDW_R1_DLT
, val
, 14);
892 bfd_put_32 (stub_bfd
, insn
, loc
+ 12);
898 && stub_entry
->h
!= NULL
899 && stub_entry
->h
->pic_call
)
901 /* Build the .plt entry needed to call a PIC function from
902 statically linked code. We don't need any relocs. */
904 struct elf32_hppa_link_hash_entry
*eh
;
907 dynobj
= htab
->elf
.dynobj
;
908 eh
= (struct elf32_hppa_link_hash_entry
*) stub_entry
->h
;
910 if (eh
->elf
.root
.type
!= bfd_link_hash_defined
911 && eh
->elf
.root
.type
!= bfd_link_hash_defweak
)
914 value
= (eh
->elf
.root
.u
.def
.value
915 + eh
->elf
.root
.u
.def
.section
->output_offset
916 + eh
->elf
.root
.u
.def
.section
->output_section
->vma
);
918 /* Fill in the entry in the procedure linkage table.
920 The format of a plt entry is
924 bfd_put_32 (htab
->splt
->owner
, value
,
925 htab
->splt
->contents
+ off
);
926 value
= elf_gp (htab
->splt
->output_section
->owner
);
927 bfd_put_32 (htab
->splt
->owner
, value
,
928 htab
->splt
->contents
+ off
+ 4);
932 case hppa_stub_export
:
933 /* Branches are relative. This is where we are going to. */
934 sym_value
= (stub_entry
->target_value
935 + stub_entry
->target_section
->output_offset
936 + stub_entry
->target_section
->output_section
->vma
);
938 /* And this is where we are coming from. */
939 sym_value
-= (stub_entry
->stub_offset
940 + stub_sec
->output_offset
941 + stub_sec
->output_section
->vma
);
943 if (sym_value
- 8 + 0x40000 >= 0x80000)
945 (*_bfd_error_handler
)
946 (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
947 bfd_archive_filename (stub_entry
->target_section
->owner
),
949 (long) stub_entry
->stub_offset
,
950 stub_entry
->root
.string
);
951 bfd_set_error (bfd_error_bad_value
);
955 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_fsel
) >> 2;
956 insn
= hppa_rebuild_insn ((int) BL_RP
, val
, 17);
957 bfd_put_32 (stub_bfd
, insn
, loc
);
959 bfd_put_32 (stub_bfd
, (bfd_vma
) NOP
, loc
+ 4);
960 bfd_put_32 (stub_bfd
, (bfd_vma
) LDW_RP
, loc
+ 8);
961 bfd_put_32 (stub_bfd
, (bfd_vma
) LDSID_RP_R1
, loc
+ 12);
962 bfd_put_32 (stub_bfd
, (bfd_vma
) MTSP_R1
, loc
+ 16);
963 bfd_put_32 (stub_bfd
, (bfd_vma
) BE_SR0_RP
, loc
+ 20);
965 /* Point the function symbol at the stub. */
966 stub_entry
->h
->elf
.root
.u
.def
.section
= stub_sec
;
967 stub_entry
->h
->elf
.root
.u
.def
.value
= stub_sec
->_raw_size
;
977 stub_sec
->_raw_size
+= size
;
1003 /* As above, but don't actually build the stub. Just bump offset so
1004 we know stub section sizes. */
1007 hppa_size_one_stub (gen_entry
, in_arg
)
1008 struct bfd_hash_entry
*gen_entry
;
1011 struct elf32_hppa_stub_hash_entry
*stub_entry
;
1012 struct elf32_hppa_link_hash_table
*htab
;
1015 /* Massage our args to the form they really have. */
1016 stub_entry
= (struct elf32_hppa_stub_hash_entry
*) gen_entry
;
1017 htab
= (struct elf32_hppa_link_hash_table
*) in_arg
;
1019 if (stub_entry
->stub_type
== hppa_stub_long_branch
)
1021 else if (stub_entry
->stub_type
== hppa_stub_long_branch_shared
)
1023 else if (stub_entry
->stub_type
== hppa_stub_export
)
1025 else /* hppa_stub_import or hppa_stub_import_shared. */
1027 if (htab
->multi_subspace
)
1033 stub_entry
->stub_sec
->_raw_size
+= size
;
1037 /* Return nonzero if ABFD represents an HPPA ELF32 file.
1038 Additionally we set the default architecture and machine. */
1041 elf32_hppa_object_p (abfd
)
1044 Elf_Internal_Ehdr
* i_ehdrp
;
1047 i_ehdrp
= elf_elfheader (abfd
);
1048 if (strcmp (bfd_get_target (abfd
), "elf32-hppa-linux") == 0)
1050 if (i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_LINUX
)
1055 if (i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_HPUX
)
1059 flags
= i_ehdrp
->e_flags
;
1060 switch (flags
& (EF_PARISC_ARCH
| EF_PARISC_WIDE
))
1062 case EFA_PARISC_1_0
:
1063 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 10);
1064 case EFA_PARISC_1_1
:
1065 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 11);
1066 case EFA_PARISC_2_0
:
1067 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 20);
1068 case EFA_PARISC_2_0
| EF_PARISC_WIDE
:
1069 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 25);
1074 /* Undo the generic ELF code's subtraction of section->vma from the
1075 value of each external symbol. */
1078 elf32_hppa_add_symbol_hook (abfd
, info
, sym
, namep
, flagsp
, secp
, valp
)
1079 bfd
*abfd ATTRIBUTE_UNUSED
;
1080 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1081 const Elf_Internal_Sym
*sym ATTRIBUTE_UNUSED
;
1082 const char **namep ATTRIBUTE_UNUSED
;
1083 flagword
*flagsp ATTRIBUTE_UNUSED
;
1087 *valp
+= (*secp
)->vma
;
1091 /* Create the .plt and .got sections, and set up our hash table
1092 short-cuts to various dynamic sections. */
1095 elf32_hppa_create_dynamic_sections (abfd
, info
)
1097 struct bfd_link_info
*info
;
1099 struct elf32_hppa_link_hash_table
*htab
;
1101 /* Don't try to create the .plt and .got twice. */
1102 htab
= hppa_link_hash_table (info
);
1103 if (htab
->splt
!= NULL
)
1106 /* Call the generic code to do most of the work. */
1107 if (! _bfd_elf_create_dynamic_sections (abfd
, info
))
1110 htab
->splt
= bfd_get_section_by_name (abfd
, ".plt");
1111 htab
->srelplt
= bfd_get_section_by_name (abfd
, ".rela.plt");
1113 htab
->sgot
= bfd_get_section_by_name (abfd
, ".got");
1114 htab
->srelgot
= bfd_make_section (abfd
, ".rela.got");
1115 if (htab
->srelgot
== NULL
1116 || ! bfd_set_section_flags (abfd
, htab
->srelgot
,
1121 | SEC_LINKER_CREATED
1123 || ! bfd_set_section_alignment (abfd
, htab
->srelgot
, 2))
1126 htab
->sdynbss
= bfd_get_section_by_name (abfd
, ".dynbss");
1127 htab
->srelbss
= bfd_get_section_by_name (abfd
, ".rela.bss");
1132 /* Copy the extra info we tack onto an elf_link_hash_entry. */
1135 elf32_hppa_copy_indirect_symbol (dir
, ind
)
1136 struct elf_link_hash_entry
*dir
, *ind
;
1138 struct elf32_hppa_link_hash_entry
*edir
, *eind
;
1140 edir
= (struct elf32_hppa_link_hash_entry
*) dir
;
1141 eind
= (struct elf32_hppa_link_hash_entry
*) ind
;
1143 if (eind
->dyn_relocs
!= NULL
)
1145 if (edir
->dyn_relocs
!= NULL
)
1147 struct elf32_hppa_dyn_reloc_entry
**pp
;
1148 struct elf32_hppa_dyn_reloc_entry
*p
;
1150 if (ind
->root
.type
== bfd_link_hash_indirect
)
1153 /* Add reloc counts against the weak sym to the strong sym
1154 list. Merge any entries against the same section. */
1155 for (pp
= &eind
->dyn_relocs
; (p
= *pp
) != NULL
; )
1157 struct elf32_hppa_dyn_reloc_entry
*q
;
1159 for (q
= edir
->dyn_relocs
; q
!= NULL
; q
= q
->next
)
1160 if (q
->sec
== p
->sec
)
1162 #if RELATIVE_DYNRELOCS
1163 q
->relative_count
+= p
->relative_count
;
1165 q
->count
+= p
->count
;
1172 *pp
= edir
->dyn_relocs
;
1175 edir
->dyn_relocs
= eind
->dyn_relocs
;
1176 eind
->dyn_relocs
= NULL
;
1179 _bfd_elf_link_hash_copy_indirect (dir
, ind
);
1182 /* Look through the relocs for a section during the first phase, and
1183 calculate needed space in the global offset table, procedure linkage
1184 table, and dynamic reloc sections. At this point we haven't
1185 necessarily read all the input files. */
1188 elf32_hppa_check_relocs (abfd
, info
, sec
, relocs
)
1190 struct bfd_link_info
*info
;
1192 const Elf_Internal_Rela
*relocs
;
1194 Elf_Internal_Shdr
*symtab_hdr
;
1195 struct elf_link_hash_entry
**sym_hashes
;
1196 const Elf_Internal_Rela
*rel
;
1197 const Elf_Internal_Rela
*rel_end
;
1198 struct elf32_hppa_link_hash_table
*htab
;
1200 asection
*stubreloc
;
1202 if (info
->relocateable
)
1205 htab
= hppa_link_hash_table (info
);
1206 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1207 sym_hashes
= elf_sym_hashes (abfd
);
1211 rel_end
= relocs
+ sec
->reloc_count
;
1212 for (rel
= relocs
; rel
< rel_end
; rel
++)
1221 unsigned int r_symndx
, r_type
;
1222 struct elf32_hppa_link_hash_entry
*h
;
1225 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1227 if (r_symndx
< symtab_hdr
->sh_info
)
1230 h
= ((struct elf32_hppa_link_hash_entry
*)
1231 sym_hashes
[r_symndx
- symtab_hdr
->sh_info
]);
1233 r_type
= ELF32_R_TYPE (rel
->r_info
);
1237 case R_PARISC_DLTIND14F
:
1238 case R_PARISC_DLTIND14R
:
1239 case R_PARISC_DLTIND21L
:
1240 /* This symbol requires a global offset table entry. */
1241 need_entry
= NEED_GOT
;
1243 /* Mark this section as containing PIC code. */
1244 sec
->flags
|= SEC_HAS_GOT_REF
;
1247 case R_PARISC_PLABEL14R
: /* "Official" procedure labels. */
1248 case R_PARISC_PLABEL21L
:
1249 case R_PARISC_PLABEL32
:
1250 /* If the addend is non-zero, we break badly. */
1251 if (rel
->r_addend
!= 0)
1254 /* If we are creating a shared library, then we need to
1255 create a PLT entry for all PLABELs, because PLABELs with
1256 local symbols may be passed via a pointer to another
1257 object. Additionally, output a dynamic relocation
1258 pointing to the PLT entry.
1259 For executables, the original 32-bit ABI allowed two
1260 different styles of PLABELs (function pointers): For
1261 global functions, the PLABEL word points into the .plt
1262 two bytes past a (function address, gp) pair, and for
1263 local functions the PLABEL points directly at the
1264 function. The magic +2 for the first type allows us to
1265 differentiate between the two. As you can imagine, this
1266 is a real pain when it comes to generating code to call
1267 functions indirectly or to compare function pointers.
1268 We avoid the mess by always pointing a PLABEL into the
1269 .plt, even for local functions. */
1270 need_entry
= PLT_PLABEL
| NEED_PLT
| NEED_DYNREL
;
1273 case R_PARISC_PCREL12F
:
1274 htab
->has_12bit_branch
= 1;
1276 case R_PARISC_PCREL17C
:
1277 case R_PARISC_PCREL17F
:
1278 htab
->has_17bit_branch
= 1;
1280 case R_PARISC_PCREL22F
:
1281 /* Function calls might need to go through the .plt, and
1282 might require long branch stubs. */
1285 /* We know local syms won't need a .plt entry, and if
1286 they need a long branch stub we can't guarantee that
1287 we can reach the stub. So just flag an error later
1288 if we're doing a shared link and find we need a long
1294 /* Global symbols will need a .plt entry if they remain
1295 global, and in most cases won't need a long branch
1296 stub. Unfortunately, we have to cater for the case
1297 where a symbol is forced local by versioning, or due
1298 to symbolic linking, and we lose the .plt entry. */
1299 need_entry
= NEED_PLT
;
1300 if (h
->elf
.type
== STT_PARISC_MILLI
)
1305 case R_PARISC_SEGBASE
: /* Used to set segment base. */
1306 case R_PARISC_SEGREL32
: /* Relative reloc, used for unwind. */
1307 case R_PARISC_PCREL14F
: /* PC relative load/store. */
1308 case R_PARISC_PCREL14R
:
1309 case R_PARISC_PCREL17R
: /* External branches. */
1310 case R_PARISC_PCREL21L
: /* As above, and for load/store too. */
1311 /* We don't need to propagate the relocation if linking a
1312 shared object since these are section relative. */
1315 case R_PARISC_DPREL14F
: /* Used for gp rel data load/store. */
1316 case R_PARISC_DPREL14R
:
1317 case R_PARISC_DPREL21L
:
1320 (*_bfd_error_handler
)
1321 (_("%s: relocation %s can not be used when making a shared object; recompile with -fPIC"),
1322 bfd_archive_filename (abfd
),
1323 elf_hppa_howto_table
[r_type
].name
);
1324 bfd_set_error (bfd_error_bad_value
);
1329 case R_PARISC_DIR17F
: /* Used for external branches. */
1330 case R_PARISC_DIR17R
:
1331 case R_PARISC_DIR14F
: /* Used for load/store from absolute locn. */
1332 case R_PARISC_DIR14R
:
1333 case R_PARISC_DIR21L
: /* As above, and for ext branches too. */
1335 /* Help debug shared library creation. Any of the above
1336 relocs can be used in shared libs, but they may cause
1337 pages to become unshared. */
1340 (*_bfd_error_handler
)
1341 (_("%s: relocation %s should not be used when making a shared object; recompile with -fPIC"),
1342 bfd_archive_filename (abfd
),
1343 elf_hppa_howto_table
[r_type
].name
);
1348 case R_PARISC_DIR32
: /* .word relocs. */
1349 /* We may want to output a dynamic relocation later. */
1350 need_entry
= NEED_DYNREL
;
1353 /* This relocation describes the C++ object vtable hierarchy.
1354 Reconstruct it for later use during GC. */
1355 case R_PARISC_GNU_VTINHERIT
:
1356 if (!_bfd_elf32_gc_record_vtinherit (abfd
, sec
,
1357 &h
->elf
, rel
->r_offset
))
1361 /* This relocation describes which C++ vtable entries are actually
1362 used. Record for later use during GC. */
1363 case R_PARISC_GNU_VTENTRY
:
1364 if (!_bfd_elf32_gc_record_vtentry (abfd
, sec
,
1365 &h
->elf
, rel
->r_addend
))
1373 /* Now carry out our orders. */
1374 if (need_entry
& NEED_GOT
)
1376 /* Allocate space for a GOT entry, as well as a dynamic
1377 relocation for this entry. */
1378 if (htab
->sgot
== NULL
)
1380 if (htab
->elf
.dynobj
== NULL
)
1381 htab
->elf
.dynobj
= abfd
;
1382 if (!elf32_hppa_create_dynamic_sections (htab
->elf
.dynobj
, info
))
1388 h
->elf
.got
.refcount
+= 1;
1392 bfd_signed_vma
*local_got_refcounts
;
1394 /* This is a global offset table entry for a local symbol. */
1395 local_got_refcounts
= elf_local_got_refcounts (abfd
);
1396 if (local_got_refcounts
== NULL
)
1400 /* Allocate space for local got offsets and local
1401 plt offsets. Done this way to save polluting
1402 elf_obj_tdata with another target specific
1404 size
= symtab_hdr
->sh_info
;
1405 size
*= 2 * sizeof (bfd_signed_vma
);
1406 local_got_refcounts
= ((bfd_signed_vma
*)
1407 bfd_zalloc (abfd
, size
));
1408 if (local_got_refcounts
== NULL
)
1410 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
1412 local_got_refcounts
[r_symndx
] += 1;
1416 if (need_entry
& NEED_PLT
)
1418 /* If we are creating a shared library, and this is a reloc
1419 against a weak symbol or a global symbol in a dynamic
1420 object, then we will be creating an import stub and a
1421 .plt entry for the symbol. Similarly, on a normal link
1422 to symbols defined in a dynamic object we'll need the
1423 import stub and a .plt entry. We don't know yet whether
1424 the symbol is defined or not, so make an entry anyway and
1425 clean up later in adjust_dynamic_symbol. */
1426 if ((sec
->flags
& SEC_ALLOC
) != 0)
1430 h
->elf
.elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
1431 h
->elf
.plt
.refcount
+= 1;
1433 /* If this .plt entry is for a plabel, mark it so
1434 that adjust_dynamic_symbol will keep the entry
1435 even if it appears to be local. */
1436 if (need_entry
& PLT_PLABEL
)
1439 else if (need_entry
& PLT_PLABEL
)
1441 bfd_signed_vma
*local_got_refcounts
;
1442 bfd_signed_vma
*local_plt_refcounts
;
1444 local_got_refcounts
= elf_local_got_refcounts (abfd
);
1445 if (local_got_refcounts
== NULL
)
1449 /* Allocate space for local got offsets and local
1451 size
= symtab_hdr
->sh_info
;
1452 size
*= 2 * sizeof (bfd_signed_vma
);
1453 local_got_refcounts
= ((bfd_signed_vma
*)
1454 bfd_zalloc (abfd
, size
));
1455 if (local_got_refcounts
== NULL
)
1457 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
1459 local_plt_refcounts
= (local_got_refcounts
1460 + symtab_hdr
->sh_info
);
1461 local_plt_refcounts
[r_symndx
] += 1;
1466 if (need_entry
& NEED_DYNREL
)
1468 /* Flag this symbol as having a non-got, non-plt reference
1469 so that we generate copy relocs if it turns out to be
1471 if (h
!= NULL
&& !info
->shared
)
1472 h
->elf
.elf_link_hash_flags
|= ELF_LINK_NON_GOT_REF
;
1474 /* If we are creating a shared library then we need to copy
1475 the reloc into the shared library. However, if we are
1476 linking with -Bsymbolic, we need only copy absolute
1477 relocs or relocs against symbols that are not defined in
1478 an object we are including in the link. PC- or DP- or
1479 DLT-relative relocs against any local sym or global sym
1480 with DEF_REGULAR set, can be discarded. At this point we
1481 have not seen all the input files, so it is possible that
1482 DEF_REGULAR is not set now but will be set later (it is
1483 never cleared). We account for that possibility below by
1484 storing information in the dyn_relocs field of the
1487 A similar situation to the -Bsymbolic case occurs when
1488 creating shared libraries and symbol visibility changes
1489 render the symbol local.
1491 As it turns out, all the relocs we will be creating here
1492 are absolute, so we cannot remove them on -Bsymbolic
1493 links or visibility changes anyway. A STUB_REL reloc
1494 is absolute too, as in that case it is the reloc in the
1495 stub we will be creating, rather than copying the PCREL
1496 reloc in the branch.
1498 If on the other hand, we are creating an executable, we
1499 may need to keep relocations for symbols satisfied by a
1500 dynamic library if we manage to avoid copy relocs for the
1503 && (sec
->flags
& SEC_ALLOC
) != 0
1504 && (IS_ABSOLUTE_RELOC (r_type
)
1507 || h
->elf
.root
.type
== bfd_link_hash_defweak
1508 || (h
->elf
.elf_link_hash_flags
1509 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
1511 && (sec
->flags
& SEC_ALLOC
) != 0
1513 && (h
->elf
.root
.type
== bfd_link_hash_defweak
1514 || (h
->elf
.elf_link_hash_flags
1515 & ELF_LINK_HASH_DEF_REGULAR
) == 0)))
1517 /* Create a reloc section in dynobj and make room for
1524 name
= (bfd_elf_string_from_elf_section
1526 elf_elfheader (abfd
)->e_shstrndx
,
1527 elf_section_data (sec
)->rel_hdr
.sh_name
));
1530 (*_bfd_error_handler
)
1531 (_("Could not find relocation section for %s"),
1533 bfd_set_error (bfd_error_bad_value
);
1537 if (htab
->elf
.dynobj
== NULL
)
1538 htab
->elf
.dynobj
= abfd
;
1540 dynobj
= htab
->elf
.dynobj
;
1541 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1546 sreloc
= bfd_make_section (dynobj
, name
);
1547 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
1548 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
1549 if ((sec
->flags
& SEC_ALLOC
) != 0)
1550 flags
|= SEC_ALLOC
| SEC_LOAD
;
1552 || !bfd_set_section_flags (dynobj
, sreloc
, flags
)
1553 || !bfd_set_section_alignment (dynobj
, sreloc
, 2))
1557 elf_section_data (sec
)->sreloc
= sreloc
;
1560 /* If this is a global symbol, we count the number of
1561 relocations we need for this symbol. */
1564 struct elf32_hppa_dyn_reloc_entry
*p
;
1567 if (p
== NULL
|| p
->sec
!= sec
)
1569 p
= ((struct elf32_hppa_dyn_reloc_entry
*)
1570 bfd_alloc (htab
->elf
.dynobj
,
1571 (bfd_size_type
) sizeof *p
));
1574 p
->next
= h
->dyn_relocs
;
1578 #if RELATIVE_DYNRELOCS
1579 p
->relative_count
= 0;
1584 #if RELATIVE_DYNRELOCS
1585 if (!IS_ABSOLUTE_RELOC (rtype
))
1586 p
->relative_count
+= 1;
1591 /* Track dynamic relocs needed for local syms too. */
1592 elf_section_data (sec
)->local_dynrel
+= 1;
1601 /* Return the section that should be marked against garbage collection
1602 for a given relocation. */
1605 elf32_hppa_gc_mark_hook (abfd
, info
, rel
, h
, sym
)
1607 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1608 Elf_Internal_Rela
*rel
;
1609 struct elf_link_hash_entry
*h
;
1610 Elf_Internal_Sym
*sym
;
1614 switch ((unsigned int) ELF32_R_TYPE (rel
->r_info
))
1616 case R_PARISC_GNU_VTINHERIT
:
1617 case R_PARISC_GNU_VTENTRY
:
1621 switch (h
->root
.type
)
1623 case bfd_link_hash_defined
:
1624 case bfd_link_hash_defweak
:
1625 return h
->root
.u
.def
.section
;
1627 case bfd_link_hash_common
:
1628 return h
->root
.u
.c
.p
->section
;
1637 if (!(elf_bad_symtab (abfd
)
1638 && ELF_ST_BIND (sym
->st_info
) != STB_LOCAL
)
1639 && ! ((sym
->st_shndx
<= 0 || sym
->st_shndx
>= SHN_LORESERVE
)
1640 && sym
->st_shndx
!= SHN_COMMON
))
1642 return bfd_section_from_elf_index (abfd
, sym
->st_shndx
);
1649 /* Update the got and plt entry reference counts for the section being
1653 elf32_hppa_gc_sweep_hook (abfd
, info
, sec
, relocs
)
1655 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1657 const Elf_Internal_Rela
*relocs
;
1659 Elf_Internal_Shdr
*symtab_hdr
;
1660 struct elf_link_hash_entry
**sym_hashes
;
1661 bfd_signed_vma
*local_got_refcounts
;
1662 bfd_signed_vma
*local_plt_refcounts
;
1663 const Elf_Internal_Rela
*rel
, *relend
;
1664 unsigned long r_symndx
;
1665 struct elf_link_hash_entry
*h
;
1666 struct elf32_hppa_link_hash_table
*htab
;
1669 elf_section_data (sec
)->local_dynrel
= 0;
1671 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1672 sym_hashes
= elf_sym_hashes (abfd
);
1673 local_got_refcounts
= elf_local_got_refcounts (abfd
);
1674 local_plt_refcounts
= local_got_refcounts
;
1675 if (local_plt_refcounts
!= NULL
)
1676 local_plt_refcounts
+= symtab_hdr
->sh_info
;
1677 htab
= hppa_link_hash_table (info
);
1678 dynobj
= htab
->elf
.dynobj
;
1682 relend
= relocs
+ sec
->reloc_count
;
1683 for (rel
= relocs
; rel
< relend
; rel
++)
1684 switch ((unsigned int) ELF32_R_TYPE (rel
->r_info
))
1686 case R_PARISC_DLTIND14F
:
1687 case R_PARISC_DLTIND14R
:
1688 case R_PARISC_DLTIND21L
:
1689 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1690 if (r_symndx
>= symtab_hdr
->sh_info
)
1692 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1693 if (h
->got
.refcount
> 0)
1694 h
->got
.refcount
-= 1;
1696 else if (local_got_refcounts
!= NULL
)
1698 if (local_got_refcounts
[r_symndx
] > 0)
1699 local_got_refcounts
[r_symndx
] -= 1;
1703 case R_PARISC_PCREL12F
:
1704 case R_PARISC_PCREL17C
:
1705 case R_PARISC_PCREL17F
:
1706 case R_PARISC_PCREL22F
:
1707 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1708 if (r_symndx
>= symtab_hdr
->sh_info
)
1710 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1711 if (h
->plt
.refcount
> 0)
1712 h
->plt
.refcount
-= 1;
1716 case R_PARISC_PLABEL14R
:
1717 case R_PARISC_PLABEL21L
:
1718 case R_PARISC_PLABEL32
:
1719 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1720 if (r_symndx
>= symtab_hdr
->sh_info
)
1722 struct elf32_hppa_link_hash_entry
*eh
;
1723 struct elf32_hppa_dyn_reloc_entry
**pp
;
1724 struct elf32_hppa_dyn_reloc_entry
*p
;
1726 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1728 if (h
->plt
.refcount
> 0)
1729 h
->plt
.refcount
-= 1;
1731 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
1733 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; pp
= &p
->next
)
1736 #if RELATIVE_DYNRELOCS
1737 if (!IS_ABSOLUTE_RELOC (rtype
))
1738 p
->relative_count
-= 1;
1746 else if (local_plt_refcounts
!= NULL
)
1748 if (local_plt_refcounts
[r_symndx
] > 0)
1749 local_plt_refcounts
[r_symndx
] -= 1;
1753 case R_PARISC_DIR32
:
1754 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1755 if (r_symndx
>= symtab_hdr
->sh_info
)
1757 struct elf32_hppa_link_hash_entry
*eh
;
1758 struct elf32_hppa_dyn_reloc_entry
**pp
;
1759 struct elf32_hppa_dyn_reloc_entry
*p
;
1761 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1763 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
1765 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; pp
= &p
->next
)
1768 #if RELATIVE_DYNRELOCS
1769 if (!IS_ABSOLUTE_RELOC (R_PARISC_DIR32
))
1770 p
->relative_count
-= 1;
1787 /* Our own version of hide_symbol, so that we can keep plt entries for
1791 elf32_hppa_hide_symbol (info
, h
)
1792 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1793 struct elf_link_hash_entry
*h
;
1795 if ((h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) != 0)
1797 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
)
1799 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1800 h
->plt
.offset
= (bfd_vma
) -1;
1804 /* This is the condition under which elf32_hppa_finish_dynamic_symbol
1805 will be called from elflink.h. If elflink.h doesn't call our
1806 finish_dynamic_symbol routine, we'll need to do something about
1807 initializing any .plt and .got entries in elf32_hppa_relocate_section. */
1808 #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
1810 && ((INFO)->shared \
1811 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
1812 && ((H)->dynindx != -1 \
1813 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
1815 /* Adjust a symbol defined by a dynamic object and referenced by a
1816 regular object. The current definition is in some section of the
1817 dynamic object, but we're not including those sections. We have to
1818 change the definition to something the rest of the link can
1822 elf32_hppa_adjust_dynamic_symbol (info
, h
)
1823 struct bfd_link_info
*info
;
1824 struct elf_link_hash_entry
*h
;
1826 struct elf32_hppa_link_hash_table
*htab
;
1827 struct elf32_hppa_link_hash_entry
*eh
;
1828 struct elf32_hppa_dyn_reloc_entry
*p
;
1830 unsigned int power_of_two
;
1832 /* If this is a function, put it in the procedure linkage table. We
1833 will fill in the contents of the procedure linkage table later,
1834 when we know the address of the .got section. */
1835 if (h
->type
== STT_FUNC
1836 || (h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0)
1839 && h
->plt
.refcount
> 0
1840 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
1841 && (h
->root
.u
.def
.section
->flags
& SEC_HAS_GOT_REF
) != 0)
1843 ((struct elf32_hppa_link_hash_entry
*) h
)->maybe_pic_call
= 1;
1846 if (h
->plt
.refcount
<= 0
1847 || ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
1848 && h
->root
.type
!= bfd_link_hash_defweak
1849 && ! ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
1850 && (!info
->shared
|| info
->symbolic
)))
1852 /* The .plt entry is not needed when:
1853 a) Garbage collection has removed all references to the
1855 b) We know for certain the symbol is defined in this
1856 object, and it's not a weak definition, nor is the symbol
1857 used by a plabel relocation. Either this object is the
1858 application or we are doing a shared symbolic link. */
1860 /* As a special sop to the hppa ABI, we keep a .plt entry
1861 for functions in sections containing PIC code. */
1862 if (((struct elf32_hppa_link_hash_entry
*) h
)->maybe_pic_call
)
1863 ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
= 1;
1866 h
->plt
.offset
= (bfd_vma
) -1;
1867 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1874 h
->plt
.offset
= (bfd_vma
) -1;
1876 /* If this is a weak symbol, and there is a real definition, the
1877 processor independent code will have arranged for us to see the
1878 real definition first, and we can just use the same value. */
1879 if (h
->weakdef
!= NULL
)
1881 if (h
->weakdef
->root
.type
!= bfd_link_hash_defined
1882 && h
->weakdef
->root
.type
!= bfd_link_hash_defweak
)
1884 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
1885 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
1889 /* This is a reference to a symbol defined by a dynamic object which
1890 is not a function. */
1892 /* If we are creating a shared library, we must presume that the
1893 only references to the symbol are via the global offset table.
1894 For such cases we need not do anything here; the relocations will
1895 be handled correctly by relocate_section. */
1899 /* If there are no references to this symbol that do not use the
1900 GOT, we don't need to generate a copy reloc. */
1901 if ((h
->elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0)
1904 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
1905 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
1907 s
= p
->sec
->output_section
;
1908 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
1912 /* If we didn't find any dynamic relocs in read-only sections, then
1913 we'll be keeping the dynamic relocs and avoiding the copy reloc. */
1916 h
->elf_link_hash_flags
&= ~ELF_LINK_NON_GOT_REF
;
1920 /* We must allocate the symbol in our .dynbss section, which will
1921 become part of the .bss section of the executable. There will be
1922 an entry for this symbol in the .dynsym section. The dynamic
1923 object will contain position independent code, so all references
1924 from the dynamic object to this symbol will go through the global
1925 offset table. The dynamic linker will use the .dynsym entry to
1926 determine the address it must put in the global offset table, so
1927 both the dynamic object and the regular object will refer to the
1928 same memory location for the variable. */
1930 htab
= hppa_link_hash_table (info
);
1932 /* We must generate a COPY reloc to tell the dynamic linker to
1933 copy the initial value out of the dynamic object and into the
1934 runtime process image. */
1935 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
1937 htab
->srelbss
->_raw_size
+= sizeof (Elf32_External_Rela
);
1938 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
1941 /* We need to figure out the alignment required for this symbol. I
1942 have no idea how other ELF linkers handle this. */
1944 power_of_two
= bfd_log2 (h
->size
);
1945 if (power_of_two
> 3)
1948 /* Apply the required alignment. */
1950 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
1951 (bfd_size_type
) (1 << power_of_two
));
1952 if (power_of_two
> bfd_get_section_alignment (htab
->elf
.dynobj
, s
))
1954 if (! bfd_set_section_alignment (htab
->elf
.dynobj
, s
, power_of_two
))
1958 /* Define the symbol as being at this point in the section. */
1959 h
->root
.u
.def
.section
= s
;
1960 h
->root
.u
.def
.value
= s
->_raw_size
;
1962 /* Increment the section size to make room for the symbol. */
1963 s
->_raw_size
+= h
->size
;
1968 /* Called via elf_link_hash_traverse to create .plt entries for an
1969 application that uses statically linked PIC functions. Similar to
1970 the first part of elf32_hppa_adjust_dynamic_symbol. */
1973 mark_PIC_calls (h
, inf
)
1974 struct elf_link_hash_entry
*h
;
1975 PTR inf ATTRIBUTE_UNUSED
;
1977 if (! (h
->plt
.refcount
> 0
1978 && (h
->root
.type
== bfd_link_hash_defined
1979 || h
->root
.type
== bfd_link_hash_defweak
)
1980 && (h
->root
.u
.def
.section
->flags
& SEC_HAS_GOT_REF
) != 0))
1982 h
->plt
.offset
= (bfd_vma
) -1;
1983 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1987 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
1988 ((struct elf32_hppa_link_hash_entry
*) h
)->maybe_pic_call
= 1;
1989 ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
= 1;
1994 /* Allocate space in the .plt for pic_call entries. */
1997 allocate_PIC_calls (h
, inf
)
1998 struct elf_link_hash_entry
*h
;
2001 struct bfd_link_info
*info
;
2002 struct elf32_hppa_link_hash_table
*htab
;
2005 if (h
->root
.type
== bfd_link_hash_indirect
2006 || h
->root
.type
== bfd_link_hash_warning
)
2009 info
= (struct bfd_link_info
*) inf
;
2010 htab
= hppa_link_hash_table (info
);
2011 if (((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
2013 /* Make an entry in the .plt section. */
2015 h
->plt
.offset
= s
->_raw_size
;
2016 if (PLABEL_PLT_ENTRY_SIZE
!= PLT_ENTRY_SIZE
2017 && ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
2018 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0)
2020 /* Add some extra space for the dynamic linker to use. */
2021 s
->_raw_size
+= PLABEL_PLT_ENTRY_SIZE
;
2024 s
->_raw_size
+= PLT_ENTRY_SIZE
;
2030 /* Allocate space in .plt, .got and associated reloc sections for
2034 allocate_dynrelocs (h
, inf
)
2035 struct elf_link_hash_entry
*h
;
2038 struct bfd_link_info
*info
;
2039 struct elf32_hppa_link_hash_table
*htab
;
2041 struct elf32_hppa_link_hash_entry
*eh
;
2042 struct elf32_hppa_dyn_reloc_entry
*p
;
2044 if (h
->root
.type
== bfd_link_hash_indirect
2045 || h
->root
.type
== bfd_link_hash_warning
)
2048 info
= (struct bfd_link_info
*) inf
;
2049 htab
= hppa_link_hash_table (info
);
2050 if ((htab
->elf
.dynamic_sections_created
2051 && h
->plt
.refcount
> 0)
2052 || ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
2054 /* Make sure this symbol is output as a dynamic symbol.
2055 Undefined weak syms won't yet be marked as dynamic. */
2056 if (h
->dynindx
== -1
2057 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0
2058 && h
->type
!= STT_PARISC_MILLI
2059 && !((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
2061 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
2065 if (((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
2067 /* Already handled by allocate_PIC_calls. */
2069 else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info
, h
))
2071 /* Make an entry in the .plt section. */
2073 h
->plt
.offset
= s
->_raw_size
;
2074 if (PLABEL_PLT_ENTRY_SIZE
!= PLT_ENTRY_SIZE
2075 && ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
2076 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0)
2078 /* Add some extra space for the dynamic linker to use. */
2079 s
->_raw_size
+= PLABEL_PLT_ENTRY_SIZE
;
2082 s
->_raw_size
+= PLT_ENTRY_SIZE
;
2084 /* We also need to make an entry in the .rela.plt section. */
2085 htab
->srelplt
->_raw_size
+= sizeof (Elf32_External_Rela
);
2086 htab
->need_plt_stub
= 1;
2090 h
->plt
.offset
= (bfd_vma
) -1;
2091 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
2096 h
->plt
.offset
= (bfd_vma
) -1;
2097 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
2100 if (h
->got
.refcount
> 0)
2102 /* Make sure this symbol is output as a dynamic symbol.
2103 Undefined weak syms won't yet be marked as dynamic. */
2104 if (h
->dynindx
== -1
2105 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0
2106 && h
->type
!= STT_PARISC_MILLI
)
2108 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
2113 h
->got
.offset
= s
->_raw_size
;
2114 s
->_raw_size
+= GOT_ENTRY_SIZE
;
2115 if (htab
->elf
.dynamic_sections_created
2117 || (h
->dynindx
!= -1
2118 && h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0))
2120 htab
->srelgot
->_raw_size
+= sizeof (Elf32_External_Rela
);
2124 h
->got
.offset
= (bfd_vma
) -1;
2126 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
2127 if (eh
->dyn_relocs
== NULL
)
2130 /* If this is a -Bsymbolic shared link, then we need to discard all
2131 space allocated for dynamic pc-relative relocs against symbols
2132 defined in a regular object. For the normal shared case, discard
2133 space for relocs that have become local due to symbol visibility
2137 #if RELATIVE_DYNRELOCS
2138 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
2139 && ((h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) != 0
2142 struct elf32_hppa_dyn_reloc_entry
**pp
;
2144 for (pp
= &eh
->dyn_relocs
; (p
= *pp
) != NULL
; )
2146 p
->count
-= p
->relative_count
;
2147 p
->relative_count
= 0;
2158 /* For the non-shared case, discard space for relocs against
2159 symbols which turn out to need copy relocs or are not
2161 if ((h
->elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0
2162 && (((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_DYNAMIC
) != 0
2163 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
2164 || (htab
->elf
.dynamic_sections_created
2165 && (h
->root
.type
== bfd_link_hash_undefweak
2166 || h
->root
.type
== bfd_link_hash_undefined
))))
2168 /* Make sure this symbol is output as a dynamic symbol.
2169 Undefined weak syms won't yet be marked as dynamic. */
2170 if (h
->dynindx
== -1
2171 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0
2172 && h
->type
!= STT_PARISC_MILLI
)
2174 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
2178 /* If that succeeded, we know we'll be keeping all the
2180 if (h
->dynindx
!= -1)
2184 eh
->dyn_relocs
= NULL
;
2190 /* Finally, allocate space. */
2191 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
2193 asection
*sreloc
= elf_section_data (p
->sec
)->sreloc
;
2194 sreloc
->_raw_size
+= p
->count
* sizeof (Elf32_External_Rela
);
2200 /* This function is called via elf_link_hash_traverse to force
2201 millicode symbols local so they do not end up as globals in the
2202 dynamic symbol table. We ought to be able to do this in
2203 adjust_dynamic_symbol, but our adjust_dynamic_symbol is not called
2204 for all dynamic symbols. Arguably, this is a bug in
2205 elf_adjust_dynamic_symbol. */
2208 clobber_millicode_symbols (h
, info
)
2209 struct elf_link_hash_entry
*h
;
2210 struct bfd_link_info
*info
;
2212 /* We only want to remove these from the dynamic symbol table.
2213 Therefore we do not leave ELF_LINK_FORCED_LOCAL set. */
2214 if (h
->type
== STT_PARISC_MILLI
)
2216 unsigned short oldflags
= h
->elf_link_hash_flags
;
2217 h
->elf_link_hash_flags
|= ELF_LINK_FORCED_LOCAL
;
2218 elf32_hppa_hide_symbol (info
, h
);
2219 h
->elf_link_hash_flags
&= ~ELF_LINK_FORCED_LOCAL
;
2220 h
->elf_link_hash_flags
|= oldflags
& ELF_LINK_FORCED_LOCAL
;
2225 /* Find any dynamic relocs that apply to read-only sections. */
2228 readonly_dynrelocs (h
, inf
)
2229 struct elf_link_hash_entry
*h
;
2232 struct elf32_hppa_link_hash_entry
*eh
;
2233 struct elf32_hppa_dyn_reloc_entry
*p
;
2235 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
2236 for (p
= eh
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
2238 asection
*s
= p
->sec
->output_section
;
2240 if (s
!= NULL
&& (s
->flags
& SEC_READONLY
) != 0)
2242 struct bfd_link_info
*info
= (struct bfd_link_info
*) inf
;
2244 info
->flags
|= DF_TEXTREL
;
2246 /* Not an error, just cut short the traversal. */
2253 /* Set the sizes of the dynamic sections. */
2256 elf32_hppa_size_dynamic_sections (output_bfd
, info
)
2257 bfd
*output_bfd ATTRIBUTE_UNUSED
;
2258 struct bfd_link_info
*info
;
2260 struct elf32_hppa_link_hash_table
*htab
;
2266 htab
= hppa_link_hash_table (info
);
2267 dynobj
= htab
->elf
.dynobj
;
2271 if (htab
->elf
.dynamic_sections_created
)
2273 /* Set the contents of the .interp section to the interpreter. */
2276 s
= bfd_get_section_by_name (dynobj
, ".interp");
2279 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
2280 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
2283 /* Force millicode symbols local. */
2284 elf_link_hash_traverse (&htab
->elf
,
2285 clobber_millicode_symbols
,
2290 /* Run through the function symbols, looking for any that are
2291 PIC, and mark them as needing .plt entries so that %r19 will
2294 elf_link_hash_traverse (&htab
->elf
, mark_PIC_calls
, (PTR
) info
);
2297 /* Set up .got and .plt offsets for local syms, and space for local
2299 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link_next
)
2301 bfd_signed_vma
*local_got
;
2302 bfd_signed_vma
*end_local_got
;
2303 bfd_signed_vma
*local_plt
;
2304 bfd_signed_vma
*end_local_plt
;
2305 bfd_size_type locsymcount
;
2306 Elf_Internal_Shdr
*symtab_hdr
;
2309 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
)
2312 for (s
= ibfd
->sections
; s
!= NULL
; s
= s
->next
)
2314 bfd_size_type count
= elf_section_data (s
)->local_dynrel
;
2318 srel
= elf_section_data (s
)->sreloc
;
2319 srel
->_raw_size
+= count
* sizeof (Elf32_External_Rela
);
2323 local_got
= elf_local_got_refcounts (ibfd
);
2327 symtab_hdr
= &elf_tdata (ibfd
)->symtab_hdr
;
2328 locsymcount
= symtab_hdr
->sh_info
;
2329 end_local_got
= local_got
+ locsymcount
;
2331 srel
= htab
->srelgot
;
2332 for (; local_got
< end_local_got
; ++local_got
)
2336 *local_got
= s
->_raw_size
;
2337 s
->_raw_size
+= GOT_ENTRY_SIZE
;
2339 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
2342 *local_got
= (bfd_vma
) -1;
2345 local_plt
= end_local_got
;
2346 end_local_plt
= local_plt
+ locsymcount
;
2347 if (! htab
->elf
.dynamic_sections_created
)
2349 /* Won't be used, but be safe. */
2350 for (; local_plt
< end_local_plt
; ++local_plt
)
2351 *local_plt
= (bfd_vma
) -1;
2356 srel
= htab
->srelplt
;
2357 for (; local_plt
< end_local_plt
; ++local_plt
)
2361 *local_plt
= s
->_raw_size
;
2362 s
->_raw_size
+= PLT_ENTRY_SIZE
;
2364 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
2367 *local_plt
= (bfd_vma
) -1;
2373 elf_link_hash_traverse (&htab
->elf
, allocate_PIC_calls
, (PTR
) info
);
2375 /* Allocate global sym .plt and .got entries, and space for global
2376 sym dynamic relocs. */
2377 elf_link_hash_traverse (&htab
->elf
, allocate_dynrelocs
, (PTR
) info
);
2379 /* The check_relocs and adjust_dynamic_symbol entry points have
2380 determined the sizes of the various dynamic sections. Allocate
2383 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
2385 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
2388 if (s
== htab
->splt
)
2390 if (htab
->need_plt_stub
)
2392 /* Make space for the plt stub at the end of the .plt
2393 section. We want this stub right at the end, up
2394 against the .got section. */
2395 int gotalign
= bfd_section_alignment (dynobj
, htab
->sgot
);
2396 int pltalign
= bfd_section_alignment (dynobj
, s
);
2399 if (gotalign
> pltalign
)
2400 bfd_set_section_alignment (dynobj
, s
, gotalign
);
2401 mask
= ((bfd_size_type
) 1 << gotalign
) - 1;
2402 s
->_raw_size
= (s
->_raw_size
+ sizeof (plt_stub
) + mask
) & ~mask
;
2405 else if (s
== htab
->sgot
)
2407 else if (strncmp (bfd_get_section_name (dynobj
, s
), ".rela", 5) == 0)
2409 if (s
->_raw_size
!= 0)
2411 /* Remember whether there are any reloc sections other
2413 if (s
!= htab
->srelplt
)
2416 /* We use the reloc_count field as a counter if we need
2417 to copy relocs into the output file. */
2423 /* It's not one of our sections, so don't allocate space. */
2427 if (s
->_raw_size
== 0)
2429 /* If we don't need this section, strip it from the
2430 output file. This is mostly to handle .rela.bss and
2431 .rela.plt. We must create both sections in
2432 create_dynamic_sections, because they must be created
2433 before the linker maps input sections to output
2434 sections. The linker does that before
2435 adjust_dynamic_symbol is called, and it is that
2436 function which decides whether anything needs to go
2437 into these sections. */
2438 _bfd_strip_section_from_output (info
, s
);
2442 /* Allocate memory for the section contents. Zero it, because
2443 we may not fill in all the reloc sections. */
2444 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->_raw_size
);
2445 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
2449 if (htab
->elf
.dynamic_sections_created
)
2451 /* Like IA-64 and HPPA64, always create a DT_PLTGOT. It
2452 actually has nothing to do with the PLT, it is how we
2453 communicate the LTP value of a load module to the dynamic
2455 #define add_dynamic_entry(TAG, VAL) \
2456 bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
2458 if (!add_dynamic_entry (DT_PLTGOT
, 0))
2461 /* Add some entries to the .dynamic section. We fill in the
2462 values later, in elf32_hppa_finish_dynamic_sections, but we
2463 must add the entries now so that we get the correct size for
2464 the .dynamic section. The DT_DEBUG entry is filled in by the
2465 dynamic linker and used by the debugger. */
2468 if (!add_dynamic_entry (DT_DEBUG
, 0))
2472 if (htab
->srelplt
->_raw_size
!= 0)
2474 if (!add_dynamic_entry (DT_PLTRELSZ
, 0)
2475 || !add_dynamic_entry (DT_PLTREL
, DT_RELA
)
2476 || !add_dynamic_entry (DT_JMPREL
, 0))
2482 if (!add_dynamic_entry (DT_RELA
, 0)
2483 || !add_dynamic_entry (DT_RELASZ
, 0)
2484 || !add_dynamic_entry (DT_RELAENT
, sizeof (Elf32_External_Rela
)))
2487 /* If any dynamic relocs apply to a read-only section,
2488 then we need a DT_TEXTREL entry. */
2489 elf_link_hash_traverse (&htab
->elf
, readonly_dynrelocs
, (PTR
) info
);
2491 if ((info
->flags
& DF_TEXTREL
) != 0)
2493 if (!add_dynamic_entry (DT_TEXTREL
, 0))
2498 #undef add_dynamic_entry
2503 /* External entry points for sizing and building linker stubs. */
2505 /* Determine and set the size of the stub section for a final link.
2507 The basic idea here is to examine all the relocations looking for
2508 PC-relative calls to a target that is unreachable with a "bl"
2512 elf32_hppa_size_stubs (output_bfd
, stub_bfd
, info
, multi_subspace
, group_size
,
2513 add_stub_section
, layout_sections_again
)
2516 struct bfd_link_info
*info
;
2517 boolean multi_subspace
;
2518 bfd_signed_vma group_size
;
2519 asection
* (*add_stub_section
) PARAMS ((const char *, asection
*));
2520 void (*layout_sections_again
) PARAMS ((void));
2524 asection
**input_list
, **list
;
2525 Elf_Internal_Sym
*local_syms
, **all_local_syms
;
2526 unsigned int bfd_indx
, bfd_count
;
2527 int top_id
, top_index
;
2528 struct elf32_hppa_link_hash_table
*htab
;
2529 bfd_size_type stub_group_size
;
2530 boolean stubs_always_before_branch
;
2531 boolean stub_changed
= 0;
2535 htab
= hppa_link_hash_table (info
);
2537 /* Stash our params away. */
2538 htab
->stub_bfd
= stub_bfd
;
2539 htab
->multi_subspace
= multi_subspace
;
2540 htab
->add_stub_section
= add_stub_section
;
2541 htab
->layout_sections_again
= layout_sections_again
;
2542 stubs_always_before_branch
= group_size
< 0;
2544 stub_group_size
= -group_size
;
2546 stub_group_size
= group_size
;
2547 if (stub_group_size
== 1)
2549 /* Default values. */
2550 stub_group_size
= 8000000;
2551 if (htab
->has_17bit_branch
|| htab
->multi_subspace
)
2552 stub_group_size
= 250000;
2553 if (htab
->has_12bit_branch
)
2554 stub_group_size
= 7812;
2557 /* Count the number of input BFDs and find the top input section id. */
2558 for (input_bfd
= info
->input_bfds
, bfd_count
= 0, top_id
= 0;
2560 input_bfd
= input_bfd
->link_next
)
2563 for (section
= input_bfd
->sections
;
2565 section
= section
->next
)
2567 if (top_id
< section
->id
)
2568 top_id
= section
->id
;
2572 amt
= sizeof (struct map_stub
) * (top_id
+ 1);
2573 htab
->stub_group
= (struct map_stub
*) bfd_zmalloc (amt
);
2574 if (htab
->stub_group
== NULL
)
2577 /* Make a list of input sections for each output section included in
2580 We can't use output_bfd->section_count here to find the top output
2581 section index as some sections may have been removed, and
2582 _bfd_strip_section_from_output doesn't renumber the indices. */
2583 for (section
= output_bfd
->sections
, top_index
= 0;
2585 section
= section
->next
)
2587 if (top_index
< section
->index
)
2588 top_index
= section
->index
;
2591 amt
= sizeof (asection
*) * (top_index
+ 1);
2592 input_list
= (asection
**) bfd_malloc (amt
);
2593 if (input_list
== NULL
)
2596 /* For sections we aren't interested in, mark their entries with a
2597 value we can check later. */
2598 list
= input_list
+ top_index
;
2600 *list
= bfd_abs_section_ptr
;
2601 while (list
-- != input_list
);
2603 for (section
= output_bfd
->sections
;
2605 section
= section
->next
)
2607 if ((section
->flags
& SEC_CODE
) != 0)
2608 input_list
[section
->index
] = NULL
;
2611 /* Now actually build the lists. */
2612 for (input_bfd
= info
->input_bfds
;
2614 input_bfd
= input_bfd
->link_next
)
2616 for (section
= input_bfd
->sections
;
2618 section
= section
->next
)
2620 if (section
->output_section
!= NULL
2621 && section
->output_section
->owner
== output_bfd
2622 && section
->output_section
->index
<= top_index
)
2624 list
= input_list
+ section
->output_section
->index
;
2625 if (*list
!= bfd_abs_section_ptr
)
2627 /* Steal the link_sec pointer for our list. */
2628 #define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
2629 /* This happens to make the list in reverse order,
2630 which is what we want. */
2631 PREV_SEC (section
) = *list
;
2638 /* See whether we can group stub sections together. Grouping stub
2639 sections may result in fewer stubs. More importantly, we need to
2640 put all .init* and .fini* stubs at the beginning of the .init or
2641 .fini output sections respectively, because glibc splits the
2642 _init and _fini functions into multiple parts. Putting a stub in
2643 the middle of a function is not a good idea. */
2644 list
= input_list
+ top_index
;
2647 asection
*tail
= *list
;
2648 if (tail
== bfd_abs_section_ptr
)
2650 while (tail
!= NULL
)
2654 bfd_size_type total
;
2657 if (tail
->_cooked_size
)
2658 total
= tail
->_cooked_size
;
2660 total
= tail
->_raw_size
;
2661 while ((prev
= PREV_SEC (curr
)) != NULL
2662 && ((total
+= curr
->output_offset
- prev
->output_offset
)
2666 /* OK, the size from the start of CURR to the end is less
2667 than 250000 bytes and thus can be handled by one stub
2668 section. (or the tail section is itself larger than
2669 250000 bytes, in which case we may be toast.)
2670 We should really be keeping track of the total size of
2671 stubs added here, as stubs contribute to the final output
2672 section size. That's a little tricky, and this way will
2673 only break if stubs added total more than 12144 bytes, or
2674 1518 long branch stubs. It seems unlikely for more than
2675 1518 different functions to be called, especially from
2676 code only 250000 bytes long. */
2679 prev
= PREV_SEC (tail
);
2680 /* Set up this stub group. */
2681 htab
->stub_group
[tail
->id
].link_sec
= curr
;
2683 while (tail
!= curr
&& (tail
= prev
) != NULL
);
2685 /* But wait, there's more! Input sections up to 250000
2686 bytes before the stub section can be handled by it too. */
2687 if (!stubs_always_before_branch
)
2691 && ((total
+= tail
->output_offset
- prev
->output_offset
)
2695 prev
= PREV_SEC (tail
);
2696 htab
->stub_group
[tail
->id
].link_sec
= curr
;
2702 while (list
-- != input_list
);
2706 /* We want to read in symbol extension records only once. To do this
2707 we need to read in the local symbols in parallel and save them for
2708 later use; so hold pointers to the local symbols in an array. */
2709 amt
= sizeof (Elf_Internal_Sym
*) * bfd_count
;
2710 all_local_syms
= (Elf_Internal_Sym
**) bfd_zmalloc (amt
);
2711 if (all_local_syms
== NULL
)
2714 /* Walk over all the input BFDs, swapping in local symbols.
2715 If we are creating a shared library, create hash entries for the
2717 for (input_bfd
= info
->input_bfds
, bfd_indx
= 0;
2719 input_bfd
= input_bfd
->link_next
, bfd_indx
++)
2721 Elf_Internal_Shdr
*symtab_hdr
;
2722 Elf_Internal_Sym
*isym
;
2723 Elf32_External_Sym
*ext_syms
, *esym
, *end_sy
;
2724 bfd_size_type sec_size
;
2726 /* We'll need the symbol table in a second. */
2727 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2728 if (symtab_hdr
->sh_info
== 0)
2731 /* We need an array of the local symbols attached to the input bfd.
2732 Unfortunately, we're going to have to read & swap them in. */
2733 sec_size
= symtab_hdr
->sh_info
;
2734 sec_size
*= sizeof (Elf_Internal_Sym
);
2735 local_syms
= (Elf_Internal_Sym
*) bfd_malloc (sec_size
);
2736 if (local_syms
== NULL
)
2738 goto error_ret_free_local
;
2740 all_local_syms
[bfd_indx
] = local_syms
;
2741 sec_size
= symtab_hdr
->sh_info
;
2742 sec_size
*= sizeof (Elf32_External_Sym
);
2743 ext_syms
= (Elf32_External_Sym
*) bfd_malloc (sec_size
);
2744 if (ext_syms
== NULL
)
2746 goto error_ret_free_local
;
2749 if (bfd_seek (input_bfd
, symtab_hdr
->sh_offset
, SEEK_SET
) != 0
2750 || (bfd_bread (ext_syms
, sec_size
, input_bfd
) != sec_size
))
2753 goto error_ret_free_local
;
2756 /* Swap the local symbols in. */
2759 for (end_sy
= esym
+ symtab_hdr
->sh_info
; esym
< end_sy
; esym
++, isym
++)
2760 bfd_elf32_swap_symbol_in (input_bfd
, esym
, isym
);
2762 /* Now we can free the external symbols. */
2765 if (info
->shared
&& htab
->multi_subspace
)
2767 struct elf_link_hash_entry
**sym_hashes
;
2768 struct elf_link_hash_entry
**end_hashes
;
2769 unsigned int symcount
;
2771 symcount
= (symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
)
2772 - symtab_hdr
->sh_info
);
2773 sym_hashes
= elf_sym_hashes (input_bfd
);
2774 end_hashes
= sym_hashes
+ symcount
;
2776 /* Look through the global syms for functions; We need to
2777 build export stubs for all globally visible functions. */
2778 for (; sym_hashes
< end_hashes
; sym_hashes
++)
2780 struct elf32_hppa_link_hash_entry
*hash
;
2782 hash
= (struct elf32_hppa_link_hash_entry
*) *sym_hashes
;
2784 while (hash
->elf
.root
.type
== bfd_link_hash_indirect
2785 || hash
->elf
.root
.type
== bfd_link_hash_warning
)
2786 hash
= ((struct elf32_hppa_link_hash_entry
*)
2787 hash
->elf
.root
.u
.i
.link
);
2789 /* At this point in the link, undefined syms have been
2790 resolved, so we need to check that the symbol was
2791 defined in this BFD. */
2792 if ((hash
->elf
.root
.type
== bfd_link_hash_defined
2793 || hash
->elf
.root
.type
== bfd_link_hash_defweak
)
2794 && hash
->elf
.type
== STT_FUNC
2795 && hash
->elf
.root
.u
.def
.section
->output_section
!= NULL
2796 && (hash
->elf
.root
.u
.def
.section
->output_section
->owner
2798 && hash
->elf
.root
.u
.def
.section
->owner
== input_bfd
2799 && (hash
->elf
.elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)
2800 && !(hash
->elf
.elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
)
2801 && ELF_ST_VISIBILITY (hash
->elf
.other
) == STV_DEFAULT
)
2804 const char *stub_name
;
2805 struct elf32_hppa_stub_hash_entry
*stub_entry
;
2807 sec
= hash
->elf
.root
.u
.def
.section
;
2808 stub_name
= hash
->elf
.root
.root
.string
;
2809 stub_entry
= hppa_stub_hash_lookup (&htab
->stub_hash_table
,
2812 if (stub_entry
== NULL
)
2814 stub_entry
= hppa_add_stub (stub_name
, sec
, htab
);
2816 goto error_ret_free_local
;
2818 stub_entry
->target_value
= hash
->elf
.root
.u
.def
.value
;
2819 stub_entry
->target_section
= hash
->elf
.root
.u
.def
.section
;
2820 stub_entry
->stub_type
= hppa_stub_export
;
2821 stub_entry
->h
= hash
;
2826 (*_bfd_error_handler
) (_("%s: duplicate export stub %s"),
2827 bfd_archive_filename (input_bfd
),
2839 for (input_bfd
= info
->input_bfds
, bfd_indx
= 0;
2841 input_bfd
= input_bfd
->link_next
, bfd_indx
++)
2843 Elf_Internal_Shdr
*symtab_hdr
;
2845 /* We'll need the symbol table in a second. */
2846 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2847 if (symtab_hdr
->sh_info
== 0)
2850 local_syms
= all_local_syms
[bfd_indx
];
2852 /* Walk over each section attached to the input bfd. */
2853 for (section
= input_bfd
->sections
;
2855 section
= section
->next
)
2857 Elf_Internal_Shdr
*input_rel_hdr
;
2858 Elf32_External_Rela
*external_relocs
, *erelaend
, *erela
;
2859 Elf_Internal_Rela
*internal_relocs
, *irelaend
, *irela
;
2861 /* If there aren't any relocs, then there's nothing more
2863 if ((section
->flags
& SEC_RELOC
) == 0
2864 || section
->reloc_count
== 0)
2867 /* If this section is a link-once section that will be
2868 discarded, then don't create any stubs. */
2869 if (section
->output_section
== NULL
2870 || section
->output_section
->owner
!= output_bfd
)
2873 /* Allocate space for the external relocations. */
2874 amt
= section
->reloc_count
;
2875 amt
*= sizeof (Elf32_External_Rela
);
2876 external_relocs
= (Elf32_External_Rela
*) bfd_malloc (amt
);
2877 if (external_relocs
== NULL
)
2879 goto error_ret_free_local
;
2882 /* Likewise for the internal relocations. */
2883 amt
= section
->reloc_count
;
2884 amt
*= sizeof (Elf_Internal_Rela
);
2885 internal_relocs
= (Elf_Internal_Rela
*) bfd_malloc (amt
);
2886 if (internal_relocs
== NULL
)
2888 free (external_relocs
);
2889 goto error_ret_free_local
;
2892 /* Read in the external relocs. */
2893 input_rel_hdr
= &elf_section_data (section
)->rel_hdr
;
2894 if (bfd_seek (input_bfd
, input_rel_hdr
->sh_offset
, SEEK_SET
) != 0
2895 || bfd_bread (external_relocs
,
2896 input_rel_hdr
->sh_size
,
2897 input_bfd
) != input_rel_hdr
->sh_size
)
2899 free (external_relocs
);
2900 error_ret_free_internal
:
2901 free (internal_relocs
);
2902 goto error_ret_free_local
;
2905 /* Swap in the relocs. */
2906 erela
= external_relocs
;
2907 erelaend
= erela
+ section
->reloc_count
;
2908 irela
= internal_relocs
;
2909 for (; erela
< erelaend
; erela
++, irela
++)
2910 bfd_elf32_swap_reloca_in (input_bfd
, erela
, irela
);
2912 /* We're done with the external relocs, free them. */
2913 free (external_relocs
);
2915 /* Now examine each relocation. */
2916 irela
= internal_relocs
;
2917 irelaend
= irela
+ section
->reloc_count
;
2918 for (; irela
< irelaend
; irela
++)
2920 unsigned int r_type
, r_indx
;
2921 enum elf32_hppa_stub_type stub_type
;
2922 struct elf32_hppa_stub_hash_entry
*stub_entry
;
2925 bfd_vma destination
;
2926 struct elf32_hppa_link_hash_entry
*hash
;
2928 const asection
*id_sec
;
2930 r_type
= ELF32_R_TYPE (irela
->r_info
);
2931 r_indx
= ELF32_R_SYM (irela
->r_info
);
2933 if (r_type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
2935 bfd_set_error (bfd_error_bad_value
);
2936 goto error_ret_free_internal
;
2939 /* Only look for stubs on call instructions. */
2940 if (r_type
!= (unsigned int) R_PARISC_PCREL12F
2941 && r_type
!= (unsigned int) R_PARISC_PCREL17F
2942 && r_type
!= (unsigned int) R_PARISC_PCREL22F
)
2945 /* Now determine the call target, its name, value,
2951 if (r_indx
< symtab_hdr
->sh_info
)
2953 /* It's a local symbol. */
2954 Elf_Internal_Sym
*sym
;
2955 Elf_Internal_Shdr
*hdr
;
2957 sym
= local_syms
+ r_indx
;
2958 hdr
= elf_elfsections (input_bfd
)[sym
->st_shndx
];
2959 sym_sec
= hdr
->bfd_section
;
2960 if (ELF_ST_TYPE (sym
->st_info
) != STT_SECTION
)
2961 sym_value
= sym
->st_value
;
2962 destination
= (sym_value
+ irela
->r_addend
2963 + sym_sec
->output_offset
2964 + sym_sec
->output_section
->vma
);
2968 /* It's an external symbol. */
2971 e_indx
= r_indx
- symtab_hdr
->sh_info
;
2972 hash
= ((struct elf32_hppa_link_hash_entry
*)
2973 elf_sym_hashes (input_bfd
)[e_indx
]);
2975 while (hash
->elf
.root
.type
== bfd_link_hash_indirect
2976 || hash
->elf
.root
.type
== bfd_link_hash_warning
)
2977 hash
= ((struct elf32_hppa_link_hash_entry
*)
2978 hash
->elf
.root
.u
.i
.link
);
2980 if (hash
->elf
.root
.type
== bfd_link_hash_defined
2981 || hash
->elf
.root
.type
== bfd_link_hash_defweak
)
2983 sym_sec
= hash
->elf
.root
.u
.def
.section
;
2984 sym_value
= hash
->elf
.root
.u
.def
.value
;
2985 if (sym_sec
->output_section
!= NULL
)
2986 destination
= (sym_value
+ irela
->r_addend
2987 + sym_sec
->output_offset
2988 + sym_sec
->output_section
->vma
);
2990 else if (hash
->elf
.root
.type
== bfd_link_hash_undefweak
)
2995 else if (hash
->elf
.root
.type
== bfd_link_hash_undefined
)
2998 && !info
->no_undefined
2999 && (ELF_ST_VISIBILITY (hash
->elf
.other
)
3005 bfd_set_error (bfd_error_bad_value
);
3006 goto error_ret_free_internal
;
3010 /* Determine what (if any) linker stub is needed. */
3011 stub_type
= hppa_type_of_stub (section
, irela
, hash
,
3013 if (stub_type
== hppa_stub_none
)
3016 /* Support for grouping stub sections. */
3017 id_sec
= htab
->stub_group
[section
->id
].link_sec
;
3019 /* Get the name of this stub. */
3020 stub_name
= hppa_stub_name (id_sec
, sym_sec
, hash
, irela
);
3022 goto error_ret_free_internal
;
3024 stub_entry
= hppa_stub_hash_lookup (&htab
->stub_hash_table
,
3027 if (stub_entry
!= NULL
)
3029 /* The proper stub has already been created. */
3034 stub_entry
= hppa_add_stub (stub_name
, section
, htab
);
3035 if (stub_entry
== NULL
)
3038 goto error_ret_free_local
;
3041 stub_entry
->target_value
= sym_value
;
3042 stub_entry
->target_section
= sym_sec
;
3043 stub_entry
->stub_type
= stub_type
;
3046 if (stub_type
== hppa_stub_import
)
3047 stub_entry
->stub_type
= hppa_stub_import_shared
;
3048 else if (stub_type
== hppa_stub_long_branch
)
3049 stub_entry
->stub_type
= hppa_stub_long_branch_shared
;
3051 stub_entry
->h
= hash
;
3055 /* We're done with the internal relocs, free them. */
3056 free (internal_relocs
);
3063 /* OK, we've added some stubs. Find out the new size of the
3065 for (stub_sec
= htab
->stub_bfd
->sections
;
3067 stub_sec
= stub_sec
->next
)
3069 stub_sec
->_raw_size
= 0;
3070 stub_sec
->_cooked_size
= 0;
3073 bfd_hash_traverse (&htab
->stub_hash_table
, hppa_size_one_stub
, htab
);
3075 /* Ask the linker to do its stuff. */
3076 (*htab
->layout_sections_again
) ();
3082 error_ret_free_local
:
3083 while (bfd_count
-- > 0)
3084 if (all_local_syms
[bfd_count
])
3085 free (all_local_syms
[bfd_count
]);
3086 free (all_local_syms
);
3091 /* For a final link, this function is called after we have sized the
3092 stubs to provide a value for __gp. */
3095 elf32_hppa_set_gp (abfd
, info
)
3097 struct bfd_link_info
*info
;
3099 struct elf32_hppa_link_hash_table
*htab
;
3100 struct elf_link_hash_entry
*h
;
3104 htab
= hppa_link_hash_table (info
);
3105 h
= elf_link_hash_lookup (&htab
->elf
, "$global$", false, false, false);
3108 && (h
->root
.type
== bfd_link_hash_defined
3109 || h
->root
.type
== bfd_link_hash_defweak
))
3111 gp_val
= h
->root
.u
.def
.value
;
3112 sec
= h
->root
.u
.def
.section
;
3116 /* Choose to point our LTP at, in this order, one of .plt, .got,
3117 or .data, if these sections exist. In the case of choosing
3118 .plt try to make the LTP ideal for addressing anywhere in the
3119 .plt or .got with a 14 bit signed offset. Typically, the end
3120 of the .plt is the start of the .got, so choose .plt + 0x2000
3121 if either the .plt or .got is larger than 0x2000. If both
3122 the .plt and .got are smaller than 0x2000, choose the end of
3123 the .plt section. */
3128 gp_val
= sec
->_raw_size
;
3130 || (htab
->sgot
&& htab
->sgot
->_raw_size
> 0x2000))
3141 /* We know we don't have a .plt. If .got is large,
3143 if (sec
->_raw_size
> 0x2000)
3148 /* No .plt or .got. Who cares what the LTP is? */
3149 sec
= bfd_get_section_by_name (abfd
, ".data");
3155 h
->root
.type
= bfd_link_hash_defined
;
3156 h
->root
.u
.def
.value
= gp_val
;
3158 h
->root
.u
.def
.section
= sec
;
3160 h
->root
.u
.def
.section
= bfd_abs_section_ptr
;
3164 if (sec
!= NULL
&& sec
->output_section
!= NULL
)
3165 gp_val
+= sec
->output_section
->vma
+ sec
->output_offset
;
3167 elf_gp (abfd
) = gp_val
;
3171 /* Build all the stubs associated with the current output file. The
3172 stubs are kept in a hash table attached to the main linker hash
3173 table. We also set up the .plt entries for statically linked PIC
3174 functions here. This function is called via hppaelf_finish in the
3178 elf32_hppa_build_stubs (info
)
3179 struct bfd_link_info
*info
;
3182 struct bfd_hash_table
*table
;
3183 struct elf32_hppa_link_hash_table
*htab
;
3185 htab
= hppa_link_hash_table (info
);
3187 for (stub_sec
= htab
->stub_bfd
->sections
;
3189 stub_sec
= stub_sec
->next
)
3193 /* Allocate memory to hold the linker stubs. */
3194 size
= stub_sec
->_raw_size
;
3195 stub_sec
->contents
= (unsigned char *) bfd_zalloc (htab
->stub_bfd
, size
);
3196 if (stub_sec
->contents
== NULL
&& size
!= 0)
3198 stub_sec
->_raw_size
= 0;
3201 /* Build the stubs as directed by the stub hash table. */
3202 table
= &htab
->stub_hash_table
;
3203 bfd_hash_traverse (table
, hppa_build_one_stub
, info
);
3208 /* Perform a final link. */
3211 elf32_hppa_final_link (abfd
, info
)
3213 struct bfd_link_info
*info
;
3217 /* Invoke the regular ELF linker to do all the work. */
3218 if (!bfd_elf32_bfd_final_link (abfd
, info
))
3221 /* If we're producing a final executable, sort the contents of the
3222 unwind section. Magic section names, but this is much safer than
3223 having elf32_hppa_relocate_section remember where SEGREL32 relocs
3224 occurred. Consider what happens if someone inept creates a
3225 linker script that puts unwind information in .text. */
3226 s
= bfd_get_section_by_name (abfd
, ".PARISC.unwind");
3232 size
= s
->_raw_size
;
3233 contents
= bfd_malloc (size
);
3234 if (contents
== NULL
)
3237 if (! bfd_get_section_contents (abfd
, s
, contents
, (file_ptr
) 0, size
))
3240 qsort (contents
, (size_t) (size
/ 16), 16, hppa_unwind_entry_compare
);
3242 if (! bfd_set_section_contents (abfd
, s
, contents
, (file_ptr
) 0, size
))
3248 /* Record the lowest address for the data and text segments. */
3251 hppa_record_segment_addr (abfd
, section
, data
)
3252 bfd
*abfd ATTRIBUTE_UNUSED
;
3256 struct elf32_hppa_link_hash_table
*htab
;
3258 htab
= (struct elf32_hppa_link_hash_table
*) data
;
3260 if ((section
->flags
& (SEC_ALLOC
| SEC_LOAD
)) == (SEC_ALLOC
| SEC_LOAD
))
3262 bfd_vma value
= section
->vma
- section
->filepos
;
3264 if ((section
->flags
& SEC_READONLY
) != 0)
3266 if (value
< htab
->text_segment_base
)
3267 htab
->text_segment_base
= value
;
3271 if (value
< htab
->data_segment_base
)
3272 htab
->data_segment_base
= value
;
3277 /* Perform a relocation as part of a final link. */
3279 static bfd_reloc_status_type
3280 final_link_relocate (input_section
, contents
, rel
, value
, htab
, sym_sec
, h
)
3281 asection
*input_section
;
3283 const Elf_Internal_Rela
*rel
;
3285 struct elf32_hppa_link_hash_table
*htab
;
3287 struct elf32_hppa_link_hash_entry
*h
;
3290 unsigned int r_type
= ELF32_R_TYPE (rel
->r_info
);
3291 reloc_howto_type
*howto
= elf_hppa_howto_table
+ r_type
;
3292 int r_format
= howto
->bitsize
;
3293 enum hppa_reloc_field_selector_type_alt r_field
;
3294 bfd
*input_bfd
= input_section
->owner
;
3295 bfd_vma offset
= rel
->r_offset
;
3296 bfd_vma max_branch_offset
= 0;
3297 bfd_byte
*hit_data
= contents
+ offset
;
3298 bfd_signed_vma addend
= rel
->r_addend
;
3300 struct elf32_hppa_stub_hash_entry
*stub_entry
= NULL
;
3303 if (r_type
== R_PARISC_NONE
)
3304 return bfd_reloc_ok
;
3306 insn
= bfd_get_32 (input_bfd
, hit_data
);
3308 /* Find out where we are and where we're going. */
3309 location
= (offset
+
3310 input_section
->output_offset
+
3311 input_section
->output_section
->vma
);
3315 case R_PARISC_PCREL12F
:
3316 case R_PARISC_PCREL17F
:
3317 case R_PARISC_PCREL22F
:
3318 /* If this is a call to a function defined in another dynamic
3319 library, or if it is a call to a PIC function in the same
3320 object, or if this is a shared link and it is a call to a
3321 weak symbol which may or may not be in the same object, then
3322 find the import stub in the stub hash. */
3324 || sym_sec
->output_section
== NULL
3326 && ((h
->maybe_pic_call
3327 && !(input_section
->flags
& SEC_HAS_GOT_REF
))
3328 || (h
->elf
.root
.type
== bfd_link_hash_defweak
3329 && h
->elf
.dynindx
!= -1
3330 && h
->elf
.plt
.offset
!= (bfd_vma
) -1))))
3332 stub_entry
= hppa_get_stub_entry (input_section
, sym_sec
,
3334 if (stub_entry
!= NULL
)
3336 value
= (stub_entry
->stub_offset
3337 + stub_entry
->stub_sec
->output_offset
3338 + stub_entry
->stub_sec
->output_section
->vma
);
3341 else if (sym_sec
== NULL
&& h
!= NULL
3342 && h
->elf
.root
.type
== bfd_link_hash_undefweak
)
3344 /* It's OK if undefined weak. Calls to undefined weak
3345 symbols behave as if the "called" function
3346 immediately returns. We can thus call to a weak
3347 function without first checking whether the function
3353 return bfd_reloc_notsupported
;
3357 case R_PARISC_PCREL21L
:
3358 case R_PARISC_PCREL17C
:
3359 case R_PARISC_PCREL17R
:
3360 case R_PARISC_PCREL14R
:
3361 case R_PARISC_PCREL14F
:
3362 /* Make it a pc relative offset. */
3367 case R_PARISC_DPREL21L
:
3368 case R_PARISC_DPREL14R
:
3369 case R_PARISC_DPREL14F
:
3370 /* For all the DP relative relocations, we need to examine the symbol's
3371 section. If it's a code section, then "data pointer relative" makes
3372 no sense. In that case we don't adjust the "value", and for 21 bit
3373 addil instructions, we change the source addend register from %dp to
3374 %r0. This situation commonly arises when a variable's "constness"
3375 is declared differently from the way the variable is defined. For
3376 instance: "extern int foo" with foo defined as "const int foo". */
3377 if (sym_sec
== NULL
)
3379 if ((sym_sec
->flags
& SEC_CODE
) != 0)
3381 if ((insn
& ((0x3f << 26) | (0x1f << 21)))
3382 == (((int) OP_ADDIL
<< 26) | (27 << 21)))
3384 insn
&= ~ (0x1f << 21);
3385 #if 1 /* debug them. */
3386 (*_bfd_error_handler
)
3387 (_("%s(%s+0x%lx): fixing %s"),
3388 bfd_archive_filename (input_bfd
),
3389 input_section
->name
,
3390 (long) rel
->r_offset
,
3394 /* Now try to make things easy for the dynamic linker. */
3400 case R_PARISC_DLTIND21L
:
3401 case R_PARISC_DLTIND14R
:
3402 case R_PARISC_DLTIND14F
:
3403 value
-= elf_gp (input_section
->output_section
->owner
);
3406 case R_PARISC_SEGREL32
:
3407 if ((sym_sec
->flags
& SEC_CODE
) != 0)
3408 value
-= htab
->text_segment_base
;
3410 value
-= htab
->data_segment_base
;
3419 case R_PARISC_DIR32
:
3420 case R_PARISC_DIR14F
:
3421 case R_PARISC_DIR17F
:
3422 case R_PARISC_PCREL17C
:
3423 case R_PARISC_PCREL14F
:
3424 case R_PARISC_DPREL14F
:
3425 case R_PARISC_PLABEL32
:
3426 case R_PARISC_DLTIND14F
:
3427 case R_PARISC_SEGBASE
:
3428 case R_PARISC_SEGREL32
:
3432 case R_PARISC_DIR21L
:
3433 case R_PARISC_PCREL21L
:
3434 case R_PARISC_DPREL21L
:
3435 case R_PARISC_PLABEL21L
:
3436 case R_PARISC_DLTIND21L
:
3440 case R_PARISC_DIR17R
:
3441 case R_PARISC_PCREL17R
:
3442 case R_PARISC_DIR14R
:
3443 case R_PARISC_PCREL14R
:
3444 case R_PARISC_DPREL14R
:
3445 case R_PARISC_PLABEL14R
:
3446 case R_PARISC_DLTIND14R
:
3450 case R_PARISC_PCREL12F
:
3451 case R_PARISC_PCREL17F
:
3452 case R_PARISC_PCREL22F
:
3455 if (r_type
== (unsigned int) R_PARISC_PCREL17F
)
3457 max_branch_offset
= (1 << (17-1)) << 2;
3459 else if (r_type
== (unsigned int) R_PARISC_PCREL12F
)
3461 max_branch_offset
= (1 << (12-1)) << 2;
3465 max_branch_offset
= (1 << (22-1)) << 2;
3468 /* sym_sec is NULL on undefined weak syms or when shared on
3469 undefined syms. We've already checked for a stub for the
3470 shared undefined case. */
3471 if (sym_sec
== NULL
)
3474 /* If the branch is out of reach, then redirect the
3475 call to the local stub for this function. */
3476 if (value
+ addend
+ max_branch_offset
>= 2*max_branch_offset
)
3478 stub_entry
= hppa_get_stub_entry (input_section
, sym_sec
,
3480 if (stub_entry
== NULL
)
3481 return bfd_reloc_notsupported
;
3483 /* Munge up the value and addend so that we call the stub
3484 rather than the procedure directly. */
3485 value
= (stub_entry
->stub_offset
3486 + stub_entry
->stub_sec
->output_offset
3487 + stub_entry
->stub_sec
->output_section
->vma
3493 /* Something we don't know how to handle. */
3495 return bfd_reloc_notsupported
;
3498 /* Make sure we can reach the stub. */
3499 if (max_branch_offset
!= 0
3500 && value
+ addend
+ max_branch_offset
>= 2*max_branch_offset
)
3502 (*_bfd_error_handler
)
3503 (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
3504 bfd_archive_filename (input_bfd
),
3505 input_section
->name
,
3506 (long) rel
->r_offset
,
3507 stub_entry
->root
.string
);
3508 bfd_set_error (bfd_error_bad_value
);
3509 return bfd_reloc_notsupported
;
3512 val
= hppa_field_adjust (value
, addend
, r_field
);
3516 case R_PARISC_PCREL12F
:
3517 case R_PARISC_PCREL17C
:
3518 case R_PARISC_PCREL17F
:
3519 case R_PARISC_PCREL17R
:
3520 case R_PARISC_PCREL22F
:
3521 case R_PARISC_DIR17F
:
3522 case R_PARISC_DIR17R
:
3523 /* This is a branch. Divide the offset by four.
3524 Note that we need to decide whether it's a branch or
3525 otherwise by inspecting the reloc. Inspecting insn won't
3526 work as insn might be from a .word directive. */
3534 insn
= hppa_rebuild_insn (insn
, val
, r_format
);
3536 /* Update the instruction word. */
3537 bfd_put_32 (input_bfd
, (bfd_vma
) insn
, hit_data
);
3538 return bfd_reloc_ok
;
3541 /* Relocate an HPPA ELF section. */
3544 elf32_hppa_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
3545 contents
, relocs
, local_syms
, local_sections
)
3547 struct bfd_link_info
*info
;
3549 asection
*input_section
;
3551 Elf_Internal_Rela
*relocs
;
3552 Elf_Internal_Sym
*local_syms
;
3553 asection
**local_sections
;
3555 bfd_vma
*local_got_offsets
;
3556 struct elf32_hppa_link_hash_table
*htab
;
3557 Elf_Internal_Shdr
*symtab_hdr
;
3558 Elf_Internal_Rela
*rel
;
3559 Elf_Internal_Rela
*relend
;
3561 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
3563 htab
= hppa_link_hash_table (info
);
3564 local_got_offsets
= elf_local_got_offsets (input_bfd
);
3567 relend
= relocs
+ input_section
->reloc_count
;
3568 for (; rel
< relend
; rel
++)
3570 unsigned int r_type
;
3571 reloc_howto_type
*howto
;
3572 unsigned int r_symndx
;
3573 struct elf32_hppa_link_hash_entry
*h
;
3574 Elf_Internal_Sym
*sym
;
3577 bfd_reloc_status_type r
;
3578 const char *sym_name
;
3581 r_type
= ELF32_R_TYPE (rel
->r_info
);
3582 if (r_type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
3584 bfd_set_error (bfd_error_bad_value
);
3587 if (r_type
== (unsigned int) R_PARISC_GNU_VTENTRY
3588 || r_type
== (unsigned int) R_PARISC_GNU_VTINHERIT
)
3591 r_symndx
= ELF32_R_SYM (rel
->r_info
);
3593 if (info
->relocateable
)
3595 /* This is a relocatable link. We don't have to change
3596 anything, unless the reloc is against a section symbol,
3597 in which case we have to adjust according to where the
3598 section symbol winds up in the output section. */
3599 if (r_symndx
< symtab_hdr
->sh_info
)
3601 sym
= local_syms
+ r_symndx
;
3602 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
3604 sym_sec
= local_sections
[r_symndx
];
3605 rel
->r_addend
+= sym_sec
->output_offset
;
3611 /* This is a final link. */
3615 if (r_symndx
< symtab_hdr
->sh_info
)
3617 /* This is a local symbol, h defaults to NULL. */
3618 sym
= local_syms
+ r_symndx
;
3619 sym_sec
= local_sections
[r_symndx
];
3620 relocation
= ((ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
3621 ? 0 : sym
->st_value
)
3622 + sym_sec
->output_offset
3623 + sym_sec
->output_section
->vma
);
3629 /* It's a global; Find its entry in the link hash. */
3630 indx
= r_symndx
- symtab_hdr
->sh_info
;
3631 h
= ((struct elf32_hppa_link_hash_entry
*)
3632 elf_sym_hashes (input_bfd
)[indx
]);
3633 while (h
->elf
.root
.type
== bfd_link_hash_indirect
3634 || h
->elf
.root
.type
== bfd_link_hash_warning
)
3635 h
= (struct elf32_hppa_link_hash_entry
*) h
->elf
.root
.u
.i
.link
;
3638 if (h
->elf
.root
.type
== bfd_link_hash_defined
3639 || h
->elf
.root
.type
== bfd_link_hash_defweak
)
3641 sym_sec
= h
->elf
.root
.u
.def
.section
;
3642 /* If sym_sec->output_section is NULL, then it's a
3643 symbol defined in a shared library. */
3644 if (sym_sec
->output_section
!= NULL
)
3645 relocation
= (h
->elf
.root
.u
.def
.value
3646 + sym_sec
->output_offset
3647 + sym_sec
->output_section
->vma
);
3649 else if (h
->elf
.root
.type
== bfd_link_hash_undefweak
)
3651 else if (info
->shared
&& !info
->no_undefined
3652 && ELF_ST_VISIBILITY (h
->elf
.other
) == STV_DEFAULT
3653 && h
->elf
.type
!= STT_PARISC_MILLI
)
3655 if (info
->symbolic
&& !info
->allow_shlib_undefined
)
3656 if (!((*info
->callbacks
->undefined_symbol
)
3657 (info
, h
->elf
.root
.root
.string
, input_bfd
,
3658 input_section
, rel
->r_offset
, false)))
3663 if (!((*info
->callbacks
->undefined_symbol
)
3664 (info
, h
->elf
.root
.root
.string
, input_bfd
,
3665 input_section
, rel
->r_offset
, true)))
3670 /* Do any required modifications to the relocation value, and
3671 determine what types of dynamic info we need to output, if
3676 case R_PARISC_DLTIND14F
:
3677 case R_PARISC_DLTIND14R
:
3678 case R_PARISC_DLTIND21L
:
3683 /* Relocation is to the entry for this symbol in the
3684 global offset table. */
3689 off
= h
->elf
.got
.offset
;
3690 dyn
= htab
->elf
.dynamic_sections_created
;
3691 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
, &h
->elf
))
3693 /* If we aren't going to call finish_dynamic_symbol,
3694 then we need to handle initialisation of the .got
3695 entry and create needed relocs here. Since the
3696 offset must always be a multiple of 4, we use the
3697 least significant bit to record whether we have
3698 initialised it already. */
3703 h
->elf
.got
.offset
|= 1;
3710 /* Local symbol case. */
3711 if (local_got_offsets
== NULL
)
3714 off
= local_got_offsets
[r_symndx
];
3716 /* The offset must always be a multiple of 4. We use
3717 the least significant bit to record whether we have
3718 already generated the necessary reloc. */
3723 local_got_offsets
[r_symndx
] |= 1;
3732 /* Output a dynamic relocation for this GOT entry.
3733 In this case it is relative to the base of the
3734 object because the symbol index is zero. */
3735 Elf_Internal_Rela outrel
;
3736 asection
*srelgot
= htab
->srelgot
;
3737 Elf32_External_Rela
*loc
;
3739 outrel
.r_offset
= (off
3740 + htab
->sgot
->output_offset
3741 + htab
->sgot
->output_section
->vma
);
3742 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_DIR32
);
3743 outrel
.r_addend
= relocation
;
3744 loc
= (Elf32_External_Rela
*) srelgot
->contents
;
3745 loc
+= srelgot
->reloc_count
++;
3746 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
3749 bfd_put_32 (output_bfd
, relocation
,
3750 htab
->sgot
->contents
+ off
);
3753 if (off
>= (bfd_vma
) -2)
3756 /* Add the base of the GOT to the relocation value. */
3758 + htab
->sgot
->output_offset
3759 + htab
->sgot
->output_section
->vma
);
3763 case R_PARISC_SEGREL32
:
3764 /* If this is the first SEGREL relocation, then initialize
3765 the segment base values. */
3766 if (htab
->text_segment_base
== (bfd_vma
) -1)
3767 bfd_map_over_sections (output_bfd
, hppa_record_segment_addr
, htab
);
3770 case R_PARISC_PLABEL14R
:
3771 case R_PARISC_PLABEL21L
:
3772 case R_PARISC_PLABEL32
:
3773 if (htab
->elf
.dynamic_sections_created
)
3778 /* If we have a global symbol with a PLT slot, then
3779 redirect this relocation to it. */
3782 off
= h
->elf
.plt
.offset
;
3783 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info
, &h
->elf
))
3785 /* In a non-shared link, adjust_dynamic_symbols
3786 isn't called for symbols forced local. We
3787 need to write out the plt entry here. */
3792 h
->elf
.plt
.offset
|= 1;
3799 bfd_vma
*local_plt_offsets
;
3801 if (local_got_offsets
== NULL
)
3804 local_plt_offsets
= local_got_offsets
+ symtab_hdr
->sh_info
;
3805 off
= local_plt_offsets
[r_symndx
];
3807 /* As for the local .got entry case, we use the last
3808 bit to record whether we've already initialised
3809 this local .plt entry. */
3814 local_plt_offsets
[r_symndx
] |= 1;
3823 /* Output a dynamic IPLT relocation for this
3825 Elf_Internal_Rela outrel
;
3826 asection
*srelplt
= htab
->srelplt
;
3827 Elf32_External_Rela
*loc
;
3829 outrel
.r_offset
= (off
3830 + htab
->splt
->output_offset
3831 + htab
->splt
->output_section
->vma
);
3832 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_IPLT
);
3833 outrel
.r_addend
= relocation
;
3834 loc
= (Elf32_External_Rela
*) srelplt
->contents
;
3835 loc
+= srelplt
->reloc_count
++;
3836 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
3840 bfd_put_32 (output_bfd
,
3842 htab
->splt
->contents
+ off
);
3843 bfd_put_32 (output_bfd
,
3844 elf_gp (htab
->splt
->output_section
->owner
),
3845 htab
->splt
->contents
+ off
+ 4);
3849 if (off
>= (bfd_vma
) -2)
3852 /* PLABELs contain function pointers. Relocation is to
3853 the entry for the function in the .plt. The magic +2
3854 offset signals to $$dyncall that the function pointer
3855 is in the .plt and thus has a gp pointer too.
3856 Exception: Undefined PLABELs should have a value of
3859 || (h
->elf
.root
.type
!= bfd_link_hash_undefweak
3860 && h
->elf
.root
.type
!= bfd_link_hash_undefined
))
3863 + htab
->splt
->output_offset
3864 + htab
->splt
->output_section
->vma
3869 /* Fall through and possibly emit a dynamic relocation. */
3871 case R_PARISC_DIR17F
:
3872 case R_PARISC_DIR17R
:
3873 case R_PARISC_DIR14F
:
3874 case R_PARISC_DIR14R
:
3875 case R_PARISC_DIR21L
:
3876 case R_PARISC_DPREL14F
:
3877 case R_PARISC_DPREL14R
:
3878 case R_PARISC_DPREL21L
:
3879 case R_PARISC_DIR32
:
3880 /* The reloc types handled here and this conditional
3881 expression must match the code in ..check_relocs and
3882 ..discard_relocs. ie. We need exactly the same condition
3883 as in ..check_relocs, with some extra conditions (dynindx
3884 test in this case) to cater for relocs removed by
3885 ..discard_relocs. If you squint, the non-shared test
3886 here does indeed match the one in ..check_relocs, the
3887 difference being that here we test DEF_DYNAMIC as well as
3888 !DEF_REGULAR. All common syms end up with !DEF_REGULAR,
3889 which is why we can't use just that test here.
3890 Conversely, DEF_DYNAMIC can't be used in check_relocs as
3891 there all files have not been loaded. */
3893 && (input_section
->flags
& SEC_ALLOC
) != 0
3894 && (IS_ABSOLUTE_RELOC (r_type
)
3896 && h
->elf
.dynindx
!= -1
3898 || (h
->elf
.elf_link_hash_flags
3899 & ELF_LINK_HASH_DEF_REGULAR
) == 0))))
3901 && (input_section
->flags
& SEC_ALLOC
) != 0
3903 && h
->elf
.dynindx
!= -1
3904 && (h
->elf
.elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0
3905 && (((h
->elf
.elf_link_hash_flags
3906 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0
3907 && (h
->elf
.elf_link_hash_flags
3908 & ELF_LINK_HASH_DEF_REGULAR
) == 0)
3909 || h
->elf
.root
.type
== bfd_link_hash_undefweak
3910 || h
->elf
.root
.type
== bfd_link_hash_undefined
)))
3912 Elf_Internal_Rela outrel
;
3915 Elf32_External_Rela
*loc
;
3917 /* When generating a shared object, these relocations
3918 are copied into the output file to be resolved at run
3921 outrel
.r_offset
= rel
->r_offset
;
3922 outrel
.r_addend
= rel
->r_addend
;
3924 if (elf_section_data (input_section
)->stab_info
!= NULL
)
3928 off
= (_bfd_stab_section_offset
3929 (output_bfd
, &htab
->elf
.stab_info
,
3931 &elf_section_data (input_section
)->stab_info
,
3933 if (off
== (bfd_vma
) -1)
3935 outrel
.r_offset
= off
;
3938 outrel
.r_offset
+= (input_section
->output_offset
3939 + input_section
->output_section
->vma
);
3943 memset (&outrel
, 0, sizeof (outrel
));
3946 && h
->elf
.dynindx
!= -1
3948 || !IS_ABSOLUTE_RELOC (r_type
)
3951 || (h
->elf
.elf_link_hash_flags
3952 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
3954 outrel
.r_info
= ELF32_R_INFO (h
->elf
.dynindx
, r_type
);
3956 else /* It's a local symbol, or one marked to become local. */
3960 /* Add the absolute offset of the symbol. */
3961 outrel
.r_addend
+= relocation
;
3963 /* Global plabels need to be processed by the
3964 dynamic linker so that functions have at most one
3965 fptr. For this reason, we need to differentiate
3966 between global and local plabels, which we do by
3967 providing the function symbol for a global plabel
3968 reloc, and no symbol for local plabels. */
3971 && sym_sec
->output_section
!= NULL
3972 && ! bfd_is_abs_section (sym_sec
))
3974 indx
= elf_section_data (sym_sec
->output_section
)->dynindx
;
3975 /* We are turning this relocation into one
3976 against a section symbol, so subtract out the
3977 output section's address but not the offset
3978 of the input section in the output section. */
3979 outrel
.r_addend
-= sym_sec
->output_section
->vma
;
3982 outrel
.r_info
= ELF32_R_INFO (indx
, r_type
);
3985 /* EH info can cause unaligned DIR32 relocs.
3986 Tweak the reloc type for the dynamic linker. */
3987 if (r_type
== R_PARISC_DIR32
&& (outrel
.r_offset
& 3) != 0)
3988 outrel
.r_info
= ELF32_R_INFO (ELF32_R_SYM (outrel
.r_info
),
3991 sreloc
= elf_section_data (input_section
)->sreloc
;
3995 loc
= (Elf32_External_Rela
*) sreloc
->contents
;
3996 loc
+= sreloc
->reloc_count
++;
3997 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
4005 r
= final_link_relocate (input_section
, contents
, rel
, relocation
,
4008 if (r
== bfd_reloc_ok
)
4012 sym_name
= h
->elf
.root
.root
.string
;
4015 sym_name
= bfd_elf_string_from_elf_section (input_bfd
,
4016 symtab_hdr
->sh_link
,
4018 if (sym_name
== NULL
)
4020 if (*sym_name
== '\0')
4021 sym_name
= bfd_section_name (input_bfd
, sym_sec
);
4024 howto
= elf_hppa_howto_table
+ r_type
;
4026 if (r
== bfd_reloc_undefined
|| r
== bfd_reloc_notsupported
)
4028 (*_bfd_error_handler
)
4029 (_("%s(%s+0x%lx): cannot handle %s for %s"),
4030 bfd_archive_filename (input_bfd
),
4031 input_section
->name
,
4032 (long) rel
->r_offset
,
4035 bfd_set_error (bfd_error_bad_value
);
4040 if (!((*info
->callbacks
->reloc_overflow
)
4041 (info
, sym_name
, howto
->name
, (bfd_vma
) 0,
4042 input_bfd
, input_section
, rel
->r_offset
)))
4050 /* Comparison function for qsort to sort unwind section during a
4054 hppa_unwind_entry_compare (a
, b
)
4058 const bfd_byte
*ap
, *bp
;
4059 unsigned long av
, bv
;
4061 ap
= (const bfd_byte
*) a
;
4062 av
= (unsigned long) ap
[0] << 24;
4063 av
|= (unsigned long) ap
[1] << 16;
4064 av
|= (unsigned long) ap
[2] << 8;
4065 av
|= (unsigned long) ap
[3];
4067 bp
= (const bfd_byte
*) b
;
4068 bv
= (unsigned long) bp
[0] << 24;
4069 bv
|= (unsigned long) bp
[1] << 16;
4070 bv
|= (unsigned long) bp
[2] << 8;
4071 bv
|= (unsigned long) bp
[3];
4073 return av
< bv
? -1 : av
> bv
? 1 : 0;
4076 /* Finish up dynamic symbol handling. We set the contents of various
4077 dynamic sections here. */
4080 elf32_hppa_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
4082 struct bfd_link_info
*info
;
4083 struct elf_link_hash_entry
*h
;
4084 Elf_Internal_Sym
*sym
;
4086 struct elf32_hppa_link_hash_table
*htab
;
4088 htab
= hppa_link_hash_table (info
);
4090 if (h
->plt
.offset
!= (bfd_vma
) -1)
4094 if (h
->plt
.offset
& 1)
4097 /* This symbol has an entry in the procedure linkage table. Set
4100 The format of a plt entry is
4105 if (h
->root
.type
== bfd_link_hash_defined
4106 || h
->root
.type
== bfd_link_hash_defweak
)
4108 value
= h
->root
.u
.def
.value
;
4109 if (h
->root
.u
.def
.section
->output_section
!= NULL
)
4110 value
+= (h
->root
.u
.def
.section
->output_offset
4111 + h
->root
.u
.def
.section
->output_section
->vma
);
4114 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
4116 Elf_Internal_Rela rel
;
4117 Elf32_External_Rela
*loc
;
4119 /* Create a dynamic IPLT relocation for this entry. */
4120 rel
.r_offset
= (h
->plt
.offset
4121 + htab
->splt
->output_offset
4122 + htab
->splt
->output_section
->vma
);
4123 if (h
->dynindx
!= -1)
4125 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_PARISC_IPLT
);
4130 /* This symbol has been marked to become local, and is
4131 used by a plabel so must be kept in the .plt. */
4132 rel
.r_info
= ELF32_R_INFO (0, R_PARISC_IPLT
);
4133 rel
.r_addend
= value
;
4136 loc
= (Elf32_External_Rela
*) htab
->srelplt
->contents
;
4137 loc
+= htab
->srelplt
->reloc_count
++;
4138 bfd_elf32_swap_reloca_out (htab
->splt
->output_section
->owner
,
4143 bfd_put_32 (htab
->splt
->owner
,
4145 htab
->splt
->contents
+ h
->plt
.offset
);
4146 bfd_put_32 (htab
->splt
->owner
,
4147 elf_gp (htab
->splt
->output_section
->owner
),
4148 htab
->splt
->contents
+ h
->plt
.offset
+ 4);
4151 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
4153 /* Mark the symbol as undefined, rather than as defined in
4154 the .plt section. Leave the value alone. */
4155 sym
->st_shndx
= SHN_UNDEF
;
4159 if (h
->got
.offset
!= (bfd_vma
) -1)
4161 Elf_Internal_Rela rel
;
4162 Elf32_External_Rela
*loc
;
4164 /* This symbol has an entry in the global offset table. Set it
4167 rel
.r_offset
= ((h
->got
.offset
&~ (bfd_vma
) 1)
4168 + htab
->sgot
->output_offset
4169 + htab
->sgot
->output_section
->vma
);
4171 /* If this is a -Bsymbolic link and the symbol is defined
4172 locally or was forced to be local because of a version file,
4173 we just want to emit a RELATIVE reloc. The entry in the
4174 global offset table will already have been initialized in the
4175 relocate_section function. */
4177 && (info
->symbolic
|| h
->dynindx
== -1)
4178 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
))
4180 rel
.r_info
= ELF32_R_INFO (0, R_PARISC_DIR32
);
4181 rel
.r_addend
= (h
->root
.u
.def
.value
4182 + h
->root
.u
.def
.section
->output_offset
4183 + h
->root
.u
.def
.section
->output_section
->vma
);
4187 if ((h
->got
.offset
& 1) != 0)
4189 bfd_put_32 (output_bfd
, (bfd_vma
) 0,
4190 htab
->sgot
->contents
+ h
->got
.offset
);
4191 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_PARISC_DIR32
);
4195 loc
= (Elf32_External_Rela
*) htab
->srelgot
->contents
;
4196 loc
+= htab
->srelgot
->reloc_count
++;
4197 bfd_elf32_swap_reloca_out (output_bfd
, &rel
, loc
);
4200 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
4203 Elf_Internal_Rela rel
;
4204 Elf32_External_Rela
*loc
;
4206 /* This symbol needs a copy reloc. Set it up. */
4208 if (! (h
->dynindx
!= -1
4209 && (h
->root
.type
== bfd_link_hash_defined
4210 || h
->root
.type
== bfd_link_hash_defweak
)))
4215 rel
.r_offset
= (h
->root
.u
.def
.value
4216 + h
->root
.u
.def
.section
->output_offset
4217 + h
->root
.u
.def
.section
->output_section
->vma
);
4219 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_PARISC_COPY
);
4220 loc
= (Elf32_External_Rela
*) s
->contents
+ s
->reloc_count
++;
4221 bfd_elf32_swap_reloca_out (output_bfd
, &rel
, loc
);
4224 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
4225 if (h
->root
.root
.string
[0] == '_'
4226 && (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
4227 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0))
4229 sym
->st_shndx
= SHN_ABS
;
4235 /* Used to decide how to sort relocs in an optimal manner for the
4236 dynamic linker, before writing them out. */
4238 static enum elf_reloc_type_class
4239 elf32_hppa_reloc_type_class (rela
)
4240 const Elf_Internal_Rela
*rela
;
4242 if (ELF32_R_SYM (rela
->r_info
) == 0)
4243 return reloc_class_relative
;
4245 switch ((int) ELF32_R_TYPE (rela
->r_info
))
4248 return reloc_class_plt
;
4250 return reloc_class_copy
;
4252 return reloc_class_normal
;
4256 /* Finish up the dynamic sections. */
4259 elf32_hppa_finish_dynamic_sections (output_bfd
, info
)
4261 struct bfd_link_info
*info
;
4264 struct elf32_hppa_link_hash_table
*htab
;
4267 htab
= hppa_link_hash_table (info
);
4268 dynobj
= htab
->elf
.dynobj
;
4270 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
4272 if (htab
->elf
.dynamic_sections_created
)
4274 Elf32_External_Dyn
*dyncon
, *dynconend
;
4279 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
4280 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
4281 for (; dyncon
< dynconend
; dyncon
++)
4283 Elf_Internal_Dyn dyn
;
4286 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
4294 /* Use PLTGOT to set the GOT register. */
4295 dyn
.d_un
.d_ptr
= elf_gp (output_bfd
);
4300 dyn
.d_un
.d_ptr
= s
->output_section
->vma
+ s
->output_offset
;
4305 if (s
->_cooked_size
!= 0)
4306 dyn
.d_un
.d_val
= s
->_cooked_size
;
4308 dyn
.d_un
.d_val
= s
->_raw_size
;
4312 /* Don't count procedure linkage table relocs in the
4313 overall reloc count. */
4314 if (htab
->srelplt
!= NULL
)
4316 s
= htab
->srelplt
->output_section
;
4317 if (s
->_cooked_size
!= 0)
4318 dyn
.d_un
.d_val
-= s
->_cooked_size
;
4320 dyn
.d_un
.d_val
-= s
->_raw_size
;
4325 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4329 if (htab
->sgot
!= NULL
&& htab
->sgot
->_raw_size
!= 0)
4331 /* Fill in the first entry in the global offset table.
4332 We use it to point to our dynamic section, if we have one. */
4333 bfd_put_32 (output_bfd
,
4335 ? sdyn
->output_section
->vma
+ sdyn
->output_offset
4337 htab
->sgot
->contents
);
4339 /* The second entry is reserved for use by the dynamic linker. */
4340 memset (htab
->sgot
->contents
+ GOT_ENTRY_SIZE
, 0, GOT_ENTRY_SIZE
);
4342 /* Set .got entry size. */
4343 elf_section_data (htab
->sgot
->output_section
)
4344 ->this_hdr
.sh_entsize
= GOT_ENTRY_SIZE
;
4347 if (htab
->splt
!= NULL
&& htab
->splt
->_raw_size
!= 0)
4349 /* Set plt entry size. */
4350 elf_section_data (htab
->splt
->output_section
)
4351 ->this_hdr
.sh_entsize
= PLT_ENTRY_SIZE
;
4353 if (htab
->need_plt_stub
)
4355 /* Set up the .plt stub. */
4356 memcpy (htab
->splt
->contents
4357 + htab
->splt
->_raw_size
- sizeof (plt_stub
),
4358 plt_stub
, sizeof (plt_stub
));
4360 if ((htab
->splt
->output_offset
4361 + htab
->splt
->output_section
->vma
4362 + htab
->splt
->_raw_size
)
4363 != (htab
->sgot
->output_offset
4364 + htab
->sgot
->output_section
->vma
))
4366 (*_bfd_error_handler
)
4367 (_(".got section not immediately after .plt section"));
4376 /* Tweak the OSABI field of the elf header. */
4379 elf32_hppa_post_process_headers (abfd
, link_info
)
4381 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
4383 Elf_Internal_Ehdr
* i_ehdrp
;
4385 i_ehdrp
= elf_elfheader (abfd
);
4387 if (strcmp (bfd_get_target (abfd
), "elf32-hppa-linux") == 0)
4389 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_LINUX
;
4393 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_HPUX
;
4397 /* Called when writing out an object file to decide the type of a
4400 elf32_hppa_elf_get_symbol_type (elf_sym
, type
)
4401 Elf_Internal_Sym
*elf_sym
;
4404 if (ELF_ST_TYPE (elf_sym
->st_info
) == STT_PARISC_MILLI
)
4405 return STT_PARISC_MILLI
;
4410 /* Misc BFD support code. */
4411 #define bfd_elf32_bfd_is_local_label_name elf_hppa_is_local_label_name
4412 #define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup
4413 #define elf_info_to_howto elf_hppa_info_to_howto
4414 #define elf_info_to_howto_rel elf_hppa_info_to_howto_rel
4416 /* Stuff for the BFD linker. */
4417 #define bfd_elf32_bfd_final_link elf32_hppa_final_link
4418 #define bfd_elf32_bfd_link_hash_table_create elf32_hppa_link_hash_table_create
4419 #define elf_backend_add_symbol_hook elf32_hppa_add_symbol_hook
4420 #define elf_backend_adjust_dynamic_symbol elf32_hppa_adjust_dynamic_symbol
4421 #define elf_backend_copy_indirect_symbol elf32_hppa_copy_indirect_symbol
4422 #define elf_backend_check_relocs elf32_hppa_check_relocs
4423 #define elf_backend_create_dynamic_sections elf32_hppa_create_dynamic_sections
4424 #define elf_backend_fake_sections elf_hppa_fake_sections
4425 #define elf_backend_relocate_section elf32_hppa_relocate_section
4426 #define elf_backend_hide_symbol elf32_hppa_hide_symbol
4427 #define elf_backend_finish_dynamic_symbol elf32_hppa_finish_dynamic_symbol
4428 #define elf_backend_finish_dynamic_sections elf32_hppa_finish_dynamic_sections
4429 #define elf_backend_size_dynamic_sections elf32_hppa_size_dynamic_sections
4430 #define elf_backend_gc_mark_hook elf32_hppa_gc_mark_hook
4431 #define elf_backend_gc_sweep_hook elf32_hppa_gc_sweep_hook
4432 #define elf_backend_object_p elf32_hppa_object_p
4433 #define elf_backend_final_write_processing elf_hppa_final_write_processing
4434 #define elf_backend_post_process_headers elf32_hppa_post_process_headers
4435 #define elf_backend_get_symbol_type elf32_hppa_elf_get_symbol_type
4436 #define elf_backend_reloc_type_class elf32_hppa_reloc_type_class
4438 #define elf_backend_can_gc_sections 1
4439 #define elf_backend_can_refcount 1
4440 #define elf_backend_plt_alignment 2
4441 #define elf_backend_want_got_plt 0
4442 #define elf_backend_plt_readonly 0
4443 #define elf_backend_want_plt_sym 0
4444 #define elf_backend_got_header_size 8
4446 #define TARGET_BIG_SYM bfd_elf32_hppa_vec
4447 #define TARGET_BIG_NAME "elf32-hppa"
4448 #define ELF_ARCH bfd_arch_hppa
4449 #define ELF_MACHINE_CODE EM_PARISC
4450 #define ELF_MAXPAGESIZE 0x1000
4452 #include "elf32-target.h"
4454 #undef TARGET_BIG_SYM
4455 #define TARGET_BIG_SYM bfd_elf32_hppa_linux_vec
4456 #undef TARGET_BIG_NAME
4457 #define TARGET_BIG_NAME "elf32-hppa-linux"
4459 #define INCLUDED_TARGET_FILE 1
4460 #include "elf32-target.h"