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 /* Setting the following non-zero makes all long branch stubs
138 generated during a shared link of the PIC variety. This saves on
139 relocs, but costs one extra instruction per stub. */
140 #ifndef LONG_BRANCH_PIC_IN_SHLIB
141 #define LONG_BRANCH_PIC_IN_SHLIB 1
144 /* Set this non-zero to use import stubs instead of long branch stubs
145 where a .plt entry exists for the symbol. This is a fairly useless
146 option as import stubs are bigger than PIC long branch stubs. */
147 #ifndef LONG_BRANCH_VIA_PLT
148 #define LONG_BRANCH_VIA_PLT 0
151 /* We don't need to copy any PC- or GP-relative dynamic relocs into a
152 shared object's dynamic section. */
153 #ifndef RELATIVE_DYNAMIC_RELOCS
154 #define RELATIVE_DYNAMIC_RELOCS 0
157 enum elf32_hppa_stub_type
{
158 hppa_stub_long_branch
,
159 hppa_stub_long_branch_shared
,
161 hppa_stub_import_shared
,
166 struct elf32_hppa_stub_hash_entry
{
168 /* Base hash table entry structure. */
169 struct bfd_hash_entry root
;
171 /* The stub section. */
174 #if ! LONG_BRANCH_PIC_IN_SHLIB
175 /* It's associated reloc section. */
179 /* Offset within stub_sec of the beginning of this stub. */
182 /* Given the symbol's value and its section we can determine its final
183 value when building the stubs (so the stub knows where to jump. */
184 bfd_vma target_value
;
185 asection
*target_section
;
187 enum elf32_hppa_stub_type stub_type
;
189 /* The symbol table entry, if any, that this was derived from. */
190 struct elf32_hppa_link_hash_entry
*h
;
192 /* Where this stub is being called from, or, in the case of combined
193 stub sections, the first input section in the group. */
197 struct elf32_hppa_link_hash_entry
{
199 struct elf_link_hash_entry elf
;
201 /* A pointer to the most recently used stub hash entry against this
203 struct elf32_hppa_stub_hash_entry
*stub_cache
;
205 #if ! LONG_BRANCH_PIC_IN_SHLIB
206 /* Used to track whether we have allocated space for a long branch
207 stub relocation for this symbol in the given section. */
208 asection
*stub_reloc_sec
;
211 #if ! LONG_BRANCH_PIC_IN_SHLIB || RELATIVE_DYNAMIC_RELOCS
212 /* Used to count relocations for delayed sizing of relocation
214 struct elf32_hppa_dyn_reloc_entry
{
216 /* Next relocation in the chain. */
217 struct elf32_hppa_dyn_reloc_entry
*next
;
219 /* The section in dynobj. */
222 /* Number of relocs copied in this section. */
227 /* Set during a static link if we detect a function is PIC. */
228 unsigned int maybe_pic_call
:1;
230 /* Set if the only reason we need a .plt entry is for a non-PIC to
231 PIC function call. */
232 unsigned int pic_call
:1;
234 /* Set if this symbol is used by a plabel reloc. */
235 unsigned int plabel
:1;
237 /* Set if this symbol is an init or fini function and thus should
238 use an absolute reloc. */
239 unsigned int plt_abs
:1;
242 struct elf32_hppa_link_hash_table
{
244 /* The main hash table. */
245 struct elf_link_hash_table root
;
247 /* The stub hash table. */
248 struct bfd_hash_table stub_hash_table
;
250 /* Linker stub bfd. */
253 /* Linker call-backs. */
254 asection
* (*add_stub_section
) PARAMS ((const char *, asection
*));
255 void (*layout_sections_again
) PARAMS ((void));
257 /* Array to keep track of which stub sections have been created, and
258 information on stub grouping. */
260 /* This is the section to which stubs in the group will be
263 /* The stub section. */
265 #if ! LONG_BRANCH_PIC_IN_SHLIB
266 /* The stub section's reloc section. */
271 /* Short-cuts to get to dynamic linker sections. */
279 /* Used during a final link to store the base of the text and data
280 segments so that we can perform SEGREL relocations. */
281 bfd_vma text_segment_base
;
282 bfd_vma data_segment_base
;
284 /* Whether we support multiple sub-spaces for shared libs. */
285 unsigned int multi_subspace
:1;
287 /* Flags set when PCREL12F and PCREL17F branches detected. Used to
288 select suitable defaults for the stub group size. */
289 unsigned int has_12bit_branch
:1;
290 unsigned int has_17bit_branch
:1;
292 /* Set if we need a .plt stub to support lazy dynamic linking. */
293 unsigned int need_plt_stub
:1;
296 /* Various hash macros and functions. */
297 #define hppa_link_hash_table(p) \
298 ((struct elf32_hppa_link_hash_table *) ((p)->hash))
300 #define hppa_stub_hash_lookup(table, string, create, copy) \
301 ((struct elf32_hppa_stub_hash_entry *) \
302 bfd_hash_lookup ((table), (string), (create), (copy)))
304 static struct bfd_hash_entry
*stub_hash_newfunc
305 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
307 static struct bfd_hash_entry
*hppa_link_hash_newfunc
308 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
310 static struct bfd_link_hash_table
*elf32_hppa_link_hash_table_create
313 /* Stub handling functions. */
314 static char *hppa_stub_name
315 PARAMS ((const asection
*, const asection
*,
316 const struct elf32_hppa_link_hash_entry
*,
317 const Elf_Internal_Rela
*));
319 static struct elf32_hppa_stub_hash_entry
*hppa_get_stub_entry
320 PARAMS ((const asection
*, const asection
*,
321 struct elf32_hppa_link_hash_entry
*,
322 const Elf_Internal_Rela
*,
323 struct elf32_hppa_link_hash_table
*));
325 static struct elf32_hppa_stub_hash_entry
*hppa_add_stub
326 PARAMS ((const char *, asection
*, struct elf32_hppa_link_hash_table
*));
328 static enum elf32_hppa_stub_type hppa_type_of_stub
329 PARAMS ((asection
*, const Elf_Internal_Rela
*,
330 struct elf32_hppa_link_hash_entry
*, bfd_vma
));
332 static boolean hppa_build_one_stub
333 PARAMS ((struct bfd_hash_entry
*, PTR
));
335 static boolean hppa_size_one_stub
336 PARAMS ((struct bfd_hash_entry
*, PTR
));
338 /* BFD and elf backend functions. */
339 static boolean elf32_hppa_object_p
PARAMS ((bfd
*));
341 static boolean elf32_hppa_add_symbol_hook
342 PARAMS ((bfd
*, struct bfd_link_info
*, const Elf_Internal_Sym
*,
343 const char **, flagword
*, asection
**, bfd_vma
*));
345 static boolean elf32_hppa_create_dynamic_sections
346 PARAMS ((bfd
*, struct bfd_link_info
*));
348 static boolean elf32_hppa_check_relocs
349 PARAMS ((bfd
*, struct bfd_link_info
*,
350 asection
*, const Elf_Internal_Rela
*));
352 static asection
*elf32_hppa_gc_mark_hook
353 PARAMS ((bfd
*, struct bfd_link_info
*, Elf_Internal_Rela
*,
354 struct elf_link_hash_entry
*, Elf_Internal_Sym
*));
356 static boolean elf32_hppa_gc_sweep_hook
357 PARAMS ((bfd
*, struct bfd_link_info
*,
358 asection
*, const Elf_Internal_Rela
*));
360 static void elf32_hppa_hide_symbol
361 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
363 static boolean elf32_hppa_adjust_dynamic_symbol
364 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
366 static boolean hppa_handle_PIC_calls
367 PARAMS ((struct elf_link_hash_entry
*, PTR
));
369 static boolean allocate_plt_and_got
370 PARAMS ((struct elf_link_hash_entry
*, PTR
));
372 #if ((! LONG_BRANCH_PIC_IN_SHLIB && LONG_BRANCH_VIA_PLT) \
373 || RELATIVE_DYNAMIC_RELOCS)
374 static boolean hppa_discard_copies
375 PARAMS ((struct elf_link_hash_entry
*, PTR
));
378 static boolean clobber_millicode_symbols
379 PARAMS ((struct elf_link_hash_entry
*, struct bfd_link_info
*));
381 static boolean elf32_hppa_size_dynamic_sections
382 PARAMS ((bfd
*, struct bfd_link_info
*));
384 static boolean elf32_hppa_final_link
385 PARAMS ((bfd
*, struct bfd_link_info
*));
387 static void hppa_record_segment_addr
388 PARAMS ((bfd
*, asection
*, PTR
));
390 static bfd_reloc_status_type final_link_relocate
391 PARAMS ((asection
*, bfd_byte
*, const Elf_Internal_Rela
*,
392 bfd_vma
, struct elf32_hppa_link_hash_table
*, asection
*,
393 struct elf32_hppa_link_hash_entry
*));
395 static boolean elf32_hppa_relocate_section
396 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*,
397 bfd_byte
*, Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**));
399 static int hppa_unwind_entry_compare
400 PARAMS ((const PTR
, const PTR
));
402 static boolean elf32_hppa_finish_dynamic_symbol
403 PARAMS ((bfd
*, struct bfd_link_info
*,
404 struct elf_link_hash_entry
*, Elf_Internal_Sym
*));
406 static boolean elf32_hppa_finish_dynamic_sections
407 PARAMS ((bfd
*, struct bfd_link_info
*));
409 static void elf32_hppa_post_process_headers
410 PARAMS ((bfd
*, struct bfd_link_info
*));
412 static int elf32_hppa_elf_get_symbol_type
413 PARAMS ((Elf_Internal_Sym
*, int));
415 /* Assorted hash table functions. */
417 /* Initialize an entry in the stub hash table. */
419 static struct bfd_hash_entry
*
420 stub_hash_newfunc (entry
, table
, string
)
421 struct bfd_hash_entry
*entry
;
422 struct bfd_hash_table
*table
;
425 struct elf32_hppa_stub_hash_entry
*ret
;
427 ret
= (struct elf32_hppa_stub_hash_entry
*) entry
;
429 /* Allocate the structure if it has not already been allocated by a
433 ret
= ((struct elf32_hppa_stub_hash_entry
*)
434 bfd_hash_allocate (table
,
435 sizeof (struct elf32_hppa_stub_hash_entry
)));
440 /* Call the allocation method of the superclass. */
441 ret
= ((struct elf32_hppa_stub_hash_entry
*)
442 bfd_hash_newfunc ((struct bfd_hash_entry
*) ret
, table
, string
));
446 /* Initialize the local fields. */
447 ret
->stub_sec
= NULL
;
448 #if ! LONG_BRANCH_PIC_IN_SHLIB
449 ret
->reloc_sec
= NULL
;
451 ret
->stub_offset
= 0;
452 ret
->target_value
= 0;
453 ret
->target_section
= NULL
;
454 ret
->stub_type
= hppa_stub_long_branch
;
459 return (struct bfd_hash_entry
*) ret
;
462 /* Initialize an entry in the link hash table. */
464 static struct bfd_hash_entry
*
465 hppa_link_hash_newfunc (entry
, table
, string
)
466 struct bfd_hash_entry
*entry
;
467 struct bfd_hash_table
*table
;
470 struct elf32_hppa_link_hash_entry
*ret
;
472 ret
= (struct elf32_hppa_link_hash_entry
*) entry
;
474 /* Allocate the structure if it has not already been allocated by a
478 ret
= ((struct elf32_hppa_link_hash_entry
*)
479 bfd_hash_allocate (table
,
480 sizeof (struct elf32_hppa_link_hash_entry
)));
485 /* Call the allocation method of the superclass. */
486 ret
= ((struct elf32_hppa_link_hash_entry
*)
487 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
492 /* Initialize the local fields. */
493 #if ! LONG_BRANCH_PIC_IN_SHLIB
494 ret
->stub_reloc_sec
= NULL
;
496 ret
->stub_cache
= NULL
;
497 #if ! LONG_BRANCH_PIC_IN_SHLIB || RELATIVE_DYNAMIC_RELOCS
498 ret
->reloc_entries
= NULL
;
500 ret
->maybe_pic_call
= 0;
506 return (struct bfd_hash_entry
*) ret
;
509 /* Create the derived linker hash table. The PA ELF port uses the derived
510 hash table to keep information specific to the PA ELF linker (without
511 using static variables). */
513 static struct bfd_link_hash_table
*
514 elf32_hppa_link_hash_table_create (abfd
)
517 struct elf32_hppa_link_hash_table
*ret
;
519 ret
= ((struct elf32_hppa_link_hash_table
*) bfd_alloc (abfd
, sizeof (*ret
)));
523 if (!_bfd_elf_link_hash_table_init (&ret
->root
, abfd
, hppa_link_hash_newfunc
))
525 bfd_release (abfd
, ret
);
529 /* Init the stub hash table too. */
530 if (!bfd_hash_table_init (&ret
->stub_hash_table
, stub_hash_newfunc
))
533 ret
->stub_bfd
= NULL
;
534 ret
->add_stub_section
= NULL
;
535 ret
->layout_sections_again
= NULL
;
536 ret
->stub_group
= NULL
;
543 ret
->text_segment_base
= (bfd_vma
) -1;
544 ret
->data_segment_base
= (bfd_vma
) -1;
545 ret
->multi_subspace
= 0;
546 ret
->has_12bit_branch
= 0;
547 ret
->has_17bit_branch
= 0;
548 ret
->need_plt_stub
= 0;
550 return &ret
->root
.root
;
553 /* Build a name for an entry in the stub hash table. */
556 hppa_stub_name (input_section
, sym_sec
, hash
, rel
)
557 const asection
*input_section
;
558 const asection
*sym_sec
;
559 const struct elf32_hppa_link_hash_entry
*hash
;
560 const Elf_Internal_Rela
*rel
;
567 len
= 8 + 1 + strlen (hash
->elf
.root
.root
.string
) + 1 + 8 + 1;
568 stub_name
= bfd_malloc (len
);
569 if (stub_name
!= NULL
)
571 sprintf (stub_name
, "%08x_%s+%x",
572 input_section
->id
& 0xffffffff,
573 hash
->elf
.root
.root
.string
,
574 (int) rel
->r_addend
& 0xffffffff);
579 len
= 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1;
580 stub_name
= bfd_malloc (len
);
581 if (stub_name
!= NULL
)
583 sprintf (stub_name
, "%08x_%x:%x+%x",
584 input_section
->id
& 0xffffffff,
585 sym_sec
->id
& 0xffffffff,
586 (int) ELF32_R_SYM (rel
->r_info
) & 0xffffffff,
587 (int) rel
->r_addend
& 0xffffffff);
593 /* Look up an entry in the stub hash. Stub entries are cached because
594 creating the stub name takes a bit of time. */
596 static struct elf32_hppa_stub_hash_entry
*
597 hppa_get_stub_entry (input_section
, sym_sec
, hash
, rel
, hplink
)
598 const asection
*input_section
;
599 const asection
*sym_sec
;
600 struct elf32_hppa_link_hash_entry
*hash
;
601 const Elf_Internal_Rela
*rel
;
602 struct elf32_hppa_link_hash_table
*hplink
;
604 struct elf32_hppa_stub_hash_entry
*stub_entry
;
605 const asection
*id_sec
;
607 /* If this input section is part of a group of sections sharing one
608 stub section, then use the id of the first section in the group.
609 Stub names need to include a section id, as there may well be
610 more than one stub used to reach say, printf, and we need to
611 distinguish between them. */
612 id_sec
= hplink
->stub_group
[input_section
->id
].link_sec
;
614 if (hash
!= NULL
&& hash
->stub_cache
!= NULL
615 && hash
->stub_cache
->h
== hash
616 && hash
->stub_cache
->id_sec
== id_sec
)
618 stub_entry
= hash
->stub_cache
;
624 stub_name
= hppa_stub_name (id_sec
, sym_sec
, hash
, rel
);
625 if (stub_name
== NULL
)
628 stub_entry
= hppa_stub_hash_lookup (&hplink
->stub_hash_table
,
629 stub_name
, false, false);
630 if (stub_entry
== NULL
)
632 if (hash
== NULL
|| hash
->elf
.root
.type
!= bfd_link_hash_undefweak
)
633 (*_bfd_error_handler
) (_("%s(%s+0x%lx): cannot find stub entry %s"),
634 bfd_get_filename (input_section
->owner
),
636 (long) rel
->r_offset
,
642 hash
->stub_cache
= stub_entry
;
651 /* Add a new stub entry to the stub hash. Not all fields of the new
652 stub entry are initialised. */
654 static struct elf32_hppa_stub_hash_entry
*
655 hppa_add_stub (stub_name
, section
, hplink
)
656 const char *stub_name
;
658 struct elf32_hppa_link_hash_table
*hplink
;
662 struct elf32_hppa_stub_hash_entry
*stub_entry
;
664 link_sec
= hplink
->stub_group
[section
->id
].link_sec
;
665 stub_sec
= hplink
->stub_group
[section
->id
].stub_sec
;
666 if (stub_sec
== NULL
)
668 stub_sec
= hplink
->stub_group
[link_sec
->id
].stub_sec
;
669 if (stub_sec
== NULL
)
674 len
= strlen (link_sec
->name
) + sizeof (STUB_SUFFIX
);
675 s_name
= bfd_alloc (hplink
->stub_bfd
, len
);
679 strcpy (s_name
, link_sec
->name
);
680 strcpy (s_name
+ len
- sizeof (STUB_SUFFIX
), STUB_SUFFIX
);
681 stub_sec
= (*hplink
->add_stub_section
) (s_name
, link_sec
);
682 if (stub_sec
== NULL
)
684 hplink
->stub_group
[link_sec
->id
].stub_sec
= stub_sec
;
686 hplink
->stub_group
[section
->id
].stub_sec
= stub_sec
;
689 /* Enter this entry into the linker stub hash table. */
690 stub_entry
= hppa_stub_hash_lookup (&hplink
->stub_hash_table
, stub_name
,
692 if (stub_entry
== NULL
)
694 (*_bfd_error_handler
) (_("%s: cannot create stub entry %s"),
695 bfd_get_filename (section
->owner
),
700 stub_entry
->stub_sec
= stub_sec
;
701 #if ! LONG_BRANCH_PIC_IN_SHLIB
702 stub_entry
->reloc_sec
= hplink
->stub_group
[section
->id
].reloc_sec
;
704 stub_entry
->stub_offset
= 0;
705 stub_entry
->id_sec
= link_sec
;
709 /* Determine the type of stub needed, if any, for a call. */
711 static enum elf32_hppa_stub_type
712 hppa_type_of_stub (input_sec
, rel
, hash
, destination
)
714 const Elf_Internal_Rela
*rel
;
715 struct elf32_hppa_link_hash_entry
*hash
;
719 bfd_vma branch_offset
;
720 bfd_vma max_branch_offset
;
724 && (((hash
->elf
.root
.type
== bfd_link_hash_defined
725 || hash
->elf
.root
.type
== bfd_link_hash_defweak
)
726 && hash
->elf
.root
.u
.def
.section
->output_section
== NULL
)
727 || (hash
->elf
.root
.type
== bfd_link_hash_defweak
728 && hash
->elf
.dynindx
!= -1
729 && hash
->elf
.plt
.offset
!= (bfd_vma
) -1)
730 || hash
->elf
.root
.type
== bfd_link_hash_undefweak
731 || hash
->elf
.root
.type
== bfd_link_hash_undefined
732 || (hash
->maybe_pic_call
&& !(input_sec
->flags
& SEC_HAS_GOT_REF
))))
734 /* If output_section is NULL, then it's a symbol defined in a
735 shared library. We will need an import stub. Decide between
736 hppa_stub_import and hppa_stub_import_shared later. For
737 shared links we need stubs for undefined or weak syms too;
738 They will presumably be resolved by the dynamic linker. */
739 return hppa_stub_import
;
742 /* Determine where the call point is. */
743 location
= (input_sec
->output_offset
744 + input_sec
->output_section
->vma
747 branch_offset
= destination
- location
- 8;
748 r_type
= ELF32_R_TYPE (rel
->r_info
);
750 /* Determine if a long branch stub is needed. parisc branch offsets
751 are relative to the second instruction past the branch, ie. +8
752 bytes on from the branch instruction location. The offset is
753 signed and counts in units of 4 bytes. */
754 if (r_type
== (unsigned int) R_PARISC_PCREL17F
)
756 max_branch_offset
= (1 << (17-1)) << 2;
758 else if (r_type
== (unsigned int) R_PARISC_PCREL12F
)
760 max_branch_offset
= (1 << (12-1)) << 2;
762 else /* R_PARISC_PCREL22F. */
764 max_branch_offset
= (1 << (22-1)) << 2;
767 if (branch_offset
+ max_branch_offset
>= 2*max_branch_offset
)
769 #if LONG_BRANCH_VIA_PLT
771 && hash
->elf
.dynindx
!= -1
772 && hash
->elf
.plt
.offset
!= (bfd_vma
) -1
773 && hash
->elf
.type
!= STT_PARISC_MILLI
)
775 /* If we are doing a shared link and find we need a long
776 branch stub, then go via the .plt if possible. */
777 return hppa_stub_import
;
781 return hppa_stub_long_branch
;
783 return hppa_stub_none
;
786 /* Build one linker stub as defined by the stub hash table entry GEN_ENTRY.
787 IN_ARG contains the link info pointer. */
789 #define LDIL_R1 0x20200000 /* ldil LR'XXX,%r1 */
790 #define BE_SR4_R1 0xe0202002 /* be,n RR'XXX(%sr4,%r1) */
792 #define BL_R1 0xe8200000 /* b,l .+8,%r1 */
793 #define ADDIL_R1 0x28200000 /* addil LR'XXX,%r1,%r1 */
794 #define DEPI_R1 0xd4201c1e /* depi 0,31,2,%r1 */
796 #define ADDIL_DP 0x2b600000 /* addil LR'XXX,%dp,%r1 */
797 #define LDW_R1_R21 0x48350000 /* ldw RR'XXX(%sr0,%r1),%r21 */
798 #define BV_R0_R21 0xeaa0c000 /* bv %r0(%r21) */
799 #define LDW_R1_R19 0x48330000 /* ldw RR'XXX(%sr0,%r1),%r19 */
801 #define ADDIL_R19 0x2a600000 /* addil LR'XXX,%r19,%r1 */
802 #define LDW_R1_DP 0x483b0000 /* ldw RR'XXX(%sr0,%r1),%dp */
804 #define LDSID_R21_R1 0x02a010a1 /* ldsid (%sr0,%r21),%r1 */
805 #define MTSP_R1 0x00011820 /* mtsp %r1,%sr0 */
806 #define BE_SR0_R21 0xe2a00000 /* be 0(%sr0,%r21) */
807 #define STW_RP 0x6bc23fd1 /* stw %rp,-24(%sr0,%sp) */
809 #define BL_RP 0xe8400002 /* b,l,n XXX,%rp */
810 #define NOP 0x08000240 /* nop */
811 #define LDW_RP 0x4bc23fd1 /* ldw -24(%sr0,%sp),%rp */
812 #define LDSID_RP_R1 0x004010a1 /* ldsid (%sr0,%rp),%r1 */
813 #define BE_SR0_RP 0xe0400002 /* be,n 0(%sr0,%rp) */
820 #define LDW_R1_DLT LDW_R1_R19
822 #define LDW_R1_DLT LDW_R1_DP
826 hppa_build_one_stub (gen_entry
, in_arg
)
827 struct bfd_hash_entry
*gen_entry
;
830 struct elf32_hppa_stub_hash_entry
*stub_entry
;
831 struct bfd_link_info
*info
;
832 struct elf32_hppa_link_hash_table
*hplink
;
842 /* Massage our args to the form they really have. */
843 stub_entry
= (struct elf32_hppa_stub_hash_entry
*) gen_entry
;
844 info
= (struct bfd_link_info
*) in_arg
;
846 hplink
= hppa_link_hash_table (info
);
847 stub_sec
= stub_entry
->stub_sec
;
849 /* Make a note of the offset within the stubs for this entry. */
850 stub_entry
->stub_offset
= stub_sec
->_raw_size
;
851 loc
= stub_sec
->contents
+ stub_entry
->stub_offset
;
853 stub_bfd
= stub_sec
->owner
;
855 switch (stub_entry
->stub_type
)
857 case hppa_stub_long_branch
:
858 /* Create the long branch. A long branch is formed with "ldil"
859 loading the upper bits of the target address into a register,
860 then branching with "be" which adds in the lower bits.
861 The "be" has its delay slot nullified. */
862 sym_value
= (stub_entry
->target_value
863 + stub_entry
->target_section
->output_offset
864 + stub_entry
->target_section
->output_section
->vma
);
866 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_lrsel
);
867 insn
= hppa_rebuild_insn ((int) LDIL_R1
, val
, 21);
868 bfd_put_32 (stub_bfd
, insn
, loc
);
870 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_rrsel
) >> 2;
871 insn
= hppa_rebuild_insn ((int) BE_SR4_R1
, val
, 17);
872 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
874 #if ! LONG_BRANCH_PIC_IN_SHLIB
877 /* Output a dynamic relocation for this stub. We only
878 output one PCREL21L reloc per stub, trusting that the
879 dynamic linker will also fix the implied PCREL17R for the
880 second instruction. PCREL21L dynamic relocs had better
881 never be emitted for some other purpose... */
883 Elf_Internal_Rela outrel
;
885 if (stub_entry
->h
== NULL
)
887 (*_bfd_error_handler
)
888 (_("%s(%s+0x%lx): cannot relocate %s, recompile with -ffunction-sections"),
889 bfd_get_filename (stub_entry
->target_section
->owner
),
891 (long) stub_entry
->stub_offset
,
892 stub_entry
->root
.string
);
893 bfd_set_error (bfd_error_bad_value
);
897 srel
= stub_entry
->reloc_sec
;
900 (*_bfd_error_handler
)
901 (_("Could not find relocation section for %s"),
903 bfd_set_error (bfd_error_bad_value
);
907 outrel
.r_offset
= (stub_entry
->stub_offset
908 + stub_sec
->output_offset
909 + stub_sec
->output_section
->vma
);
910 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_PCREL21L
);
911 outrel
.r_addend
= sym_value
;
912 bfd_elf32_swap_reloca_out (stub_sec
->output_section
->owner
,
914 ((Elf32_External_Rela
*)
915 srel
->contents
+ srel
->reloc_count
));
922 case hppa_stub_long_branch_shared
:
923 /* Branches are relative. This is where we are going to. */
924 sym_value
= (stub_entry
->target_value
925 + stub_entry
->target_section
->output_offset
926 + stub_entry
->target_section
->output_section
->vma
);
928 /* And this is where we are coming from, more or less. */
929 sym_value
-= (stub_entry
->stub_offset
930 + stub_sec
->output_offset
931 + stub_sec
->output_section
->vma
);
933 bfd_put_32 (stub_bfd
, (bfd_vma
) BL_R1
, loc
);
934 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_lrsel
);
935 insn
= hppa_rebuild_insn ((int) ADDIL_R1
, val
, 21);
936 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
938 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_rrsel
) >> 2;
939 insn
= hppa_rebuild_insn ((int) BE_SR4_R1
, val
, 17);
940 bfd_put_32 (stub_bfd
, insn
, loc
+ 8);
944 case hppa_stub_import
:
945 case hppa_stub_import_shared
:
946 off
= stub_entry
->h
->elf
.plt
.offset
;
947 if (off
>= (bfd_vma
) -2)
950 off
&= ~ (bfd_vma
) 1;
952 + hplink
->splt
->output_offset
953 + hplink
->splt
->output_section
->vma
954 - elf_gp (hplink
->splt
->output_section
->owner
));
958 if (stub_entry
->stub_type
== hppa_stub_import_shared
)
961 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_lrsel
),
962 insn
= hppa_rebuild_insn ((int) insn
, val
, 21);
963 bfd_put_32 (stub_bfd
, insn
, loc
);
965 /* It is critical to use lrsel/rrsel here because we are using
966 two different offsets (+0 and +4) from sym_value. If we use
967 lsel/rsel then with unfortunate sym_values we will round
968 sym_value+4 up to the next 2k block leading to a mis-match
969 between the lsel and rsel value. */
970 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 0, e_rrsel
);
971 insn
= hppa_rebuild_insn ((int) LDW_R1_R21
, val
, 14);
972 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
974 if (hplink
->multi_subspace
)
976 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 4, e_rrsel
);
977 insn
= hppa_rebuild_insn ((int) LDW_R1_DLT
, val
, 14);
978 bfd_put_32 (stub_bfd
, insn
, loc
+ 8);
980 bfd_put_32 (stub_bfd
, (bfd_vma
) LDSID_R21_R1
, loc
+ 12);
981 bfd_put_32 (stub_bfd
, (bfd_vma
) MTSP_R1
, loc
+ 16);
982 bfd_put_32 (stub_bfd
, (bfd_vma
) BE_SR0_R21
, loc
+ 20);
983 bfd_put_32 (stub_bfd
, (bfd_vma
) STW_RP
, loc
+ 24);
989 bfd_put_32 (stub_bfd
, (bfd_vma
) BV_R0_R21
, loc
+ 8);
990 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) 4, e_rrsel
);
991 insn
= hppa_rebuild_insn ((int) LDW_R1_DLT
, val
, 14);
992 bfd_put_32 (stub_bfd
, insn
, loc
+ 12);
998 && stub_entry
->h
!= NULL
999 && stub_entry
->h
->pic_call
)
1001 /* Build the .plt entry needed to call a PIC function from
1002 statically linked code. We don't need any relocs. */
1004 struct elf32_hppa_link_hash_entry
*eh
;
1007 dynobj
= hplink
->root
.dynobj
;
1008 eh
= (struct elf32_hppa_link_hash_entry
*) stub_entry
->h
;
1010 if (eh
->elf
.root
.type
!= bfd_link_hash_defined
1011 && eh
->elf
.root
.type
!= bfd_link_hash_defweak
)
1014 value
= (eh
->elf
.root
.u
.def
.value
1015 + eh
->elf
.root
.u
.def
.section
->output_offset
1016 + eh
->elf
.root
.u
.def
.section
->output_section
->vma
);
1018 /* Fill in the entry in the procedure linkage table.
1020 The format of a plt entry is
1024 bfd_put_32 (hplink
->splt
->owner
, value
,
1025 hplink
->splt
->contents
+ off
);
1026 value
= elf_gp (hplink
->splt
->output_section
->owner
);
1027 bfd_put_32 (hplink
->splt
->owner
, value
,
1028 hplink
->splt
->contents
+ off
+ 4);
1032 case hppa_stub_export
:
1033 /* Branches are relative. This is where we are going to. */
1034 sym_value
= (stub_entry
->target_value
1035 + stub_entry
->target_section
->output_offset
1036 + stub_entry
->target_section
->output_section
->vma
);
1038 /* And this is where we are coming from. */
1039 sym_value
-= (stub_entry
->stub_offset
1040 + stub_sec
->output_offset
1041 + stub_sec
->output_section
->vma
);
1043 if (sym_value
- 8 + 0x40000 >= 0x80000)
1045 (*_bfd_error_handler
)
1046 (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
1047 bfd_get_filename (stub_entry
->target_section
->owner
),
1049 (long) stub_entry
->stub_offset
,
1050 stub_entry
->root
.string
);
1051 bfd_set_error (bfd_error_bad_value
);
1055 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_fsel
) >> 2;
1056 insn
= hppa_rebuild_insn ((int) BL_RP
, val
, 17);
1057 bfd_put_32 (stub_bfd
, insn
, loc
);
1059 bfd_put_32 (stub_bfd
, (bfd_vma
) NOP
, loc
+ 4);
1060 bfd_put_32 (stub_bfd
, (bfd_vma
) LDW_RP
, loc
+ 8);
1061 bfd_put_32 (stub_bfd
, (bfd_vma
) LDSID_RP_R1
, loc
+ 12);
1062 bfd_put_32 (stub_bfd
, (bfd_vma
) MTSP_R1
, loc
+ 16);
1063 bfd_put_32 (stub_bfd
, (bfd_vma
) BE_SR0_RP
, loc
+ 20);
1065 /* Point the function symbol at the stub. */
1066 stub_entry
->h
->elf
.root
.u
.def
.section
= stub_sec
;
1067 stub_entry
->h
->elf
.root
.u
.def
.value
= stub_sec
->_raw_size
;
1077 stub_sec
->_raw_size
+= size
;
1103 /* As above, but don't actually build the stub. Just bump offset so
1104 we know stub section sizes. */
1107 hppa_size_one_stub (gen_entry
, in_arg
)
1108 struct bfd_hash_entry
*gen_entry
;
1111 struct elf32_hppa_stub_hash_entry
*stub_entry
;
1112 struct elf32_hppa_link_hash_table
*hplink
;
1115 /* Massage our args to the form they really have. */
1116 stub_entry
= (struct elf32_hppa_stub_hash_entry
*) gen_entry
;
1117 hplink
= (struct elf32_hppa_link_hash_table
*) in_arg
;
1119 if (stub_entry
->stub_type
== hppa_stub_long_branch
)
1121 #if ! LONG_BRANCH_PIC_IN_SHLIB
1122 if (stub_entry
->reloc_sec
!= NULL
)
1123 stub_entry
->reloc_sec
->_raw_size
+= sizeof (Elf32_External_Rela
);
1127 else if (stub_entry
->stub_type
== hppa_stub_long_branch_shared
)
1129 else if (stub_entry
->stub_type
== hppa_stub_export
)
1131 else /* hppa_stub_import or hppa_stub_import_shared. */
1133 if (hplink
->multi_subspace
)
1139 stub_entry
->stub_sec
->_raw_size
+= size
;
1143 /* Return nonzero if ABFD represents an HPPA ELF32 file.
1144 Additionally we set the default architecture and machine. */
1147 elf32_hppa_object_p (abfd
)
1150 Elf_Internal_Ehdr
* i_ehdrp
;
1153 i_ehdrp
= elf_elfheader (abfd
);
1154 if (strcmp (bfd_get_target (abfd
), "elf32-hppa-linux") == 0)
1156 if (i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_LINUX
)
1161 if (i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_HPUX
)
1165 flags
= i_ehdrp
->e_flags
;
1166 switch (flags
& (EF_PARISC_ARCH
| EF_PARISC_WIDE
))
1168 case EFA_PARISC_1_0
:
1169 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 10);
1170 case EFA_PARISC_1_1
:
1171 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 11);
1172 case EFA_PARISC_2_0
:
1173 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 20);
1174 case EFA_PARISC_2_0
| EF_PARISC_WIDE
:
1175 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 25);
1180 /* Undo the generic ELF code's subtraction of section->vma from the
1181 value of each external symbol. */
1184 elf32_hppa_add_symbol_hook (abfd
, info
, sym
, namep
, flagsp
, secp
, valp
)
1185 bfd
*abfd ATTRIBUTE_UNUSED
;
1186 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1187 const Elf_Internal_Sym
*sym ATTRIBUTE_UNUSED
;
1188 const char **namep ATTRIBUTE_UNUSED
;
1189 flagword
*flagsp ATTRIBUTE_UNUSED
;
1193 *valp
+= (*secp
)->vma
;
1197 /* Create the .plt and .got sections, and set up our hash table
1198 short-cuts to various dynamic sections. */
1201 elf32_hppa_create_dynamic_sections (abfd
, info
)
1203 struct bfd_link_info
*info
;
1205 struct elf32_hppa_link_hash_table
*hplink
;
1207 /* Don't try to create the .plt and .got twice. */
1208 hplink
= hppa_link_hash_table (info
);
1209 if (hplink
->splt
!= NULL
)
1212 /* Call the generic code to do most of the work. */
1213 if (! _bfd_elf_create_dynamic_sections (abfd
, info
))
1216 hplink
->splt
= bfd_get_section_by_name (abfd
, ".plt");
1217 hplink
->srelplt
= bfd_get_section_by_name (abfd
, ".rela.plt");
1219 hplink
->sgot
= bfd_get_section_by_name (abfd
, ".got");
1220 hplink
->srelgot
= bfd_make_section (abfd
, ".rela.got");
1221 if (hplink
->srelgot
== NULL
1222 || ! bfd_set_section_flags (abfd
, hplink
->srelgot
,
1227 | SEC_LINKER_CREATED
1229 || ! bfd_set_section_alignment (abfd
, hplink
->srelgot
, 2))
1232 hplink
->sdynbss
= bfd_get_section_by_name (abfd
, ".dynbss");
1233 hplink
->srelbss
= bfd_get_section_by_name (abfd
, ".rela.bss");
1238 /* Look through the relocs for a section during the first phase, and
1239 allocate space in the global offset table or procedure linkage
1240 table. At this point we haven't necessarily read all the input
1244 elf32_hppa_check_relocs (abfd
, info
, sec
, relocs
)
1246 struct bfd_link_info
*info
;
1248 const Elf_Internal_Rela
*relocs
;
1251 Elf_Internal_Shdr
*symtab_hdr
;
1252 struct elf_link_hash_entry
**sym_hashes
;
1253 bfd_signed_vma
*local_got_refcounts
;
1254 const Elf_Internal_Rela
*rel
;
1255 const Elf_Internal_Rela
*rel_end
;
1256 struct elf32_hppa_link_hash_table
*hplink
;
1258 asection
*stubreloc
;
1260 if (info
->relocateable
)
1263 hplink
= hppa_link_hash_table (info
);
1264 dynobj
= hplink
->root
.dynobj
;
1265 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1266 sym_hashes
= elf_sym_hashes (abfd
);
1267 local_got_refcounts
= elf_local_got_refcounts (abfd
);
1271 rel_end
= relocs
+ sec
->reloc_count
;
1272 for (rel
= relocs
; rel
< rel_end
; rel
++)
1278 #if LONG_BRANCH_PIC_IN_SHLIB
1279 NEED_STUBREL
= 0, /* We won't be needing them in this case. */
1286 unsigned int r_symndx
, r_type
;
1287 struct elf32_hppa_link_hash_entry
*h
;
1290 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1292 if (r_symndx
< symtab_hdr
->sh_info
)
1295 h
= ((struct elf32_hppa_link_hash_entry
*)
1296 sym_hashes
[r_symndx
- symtab_hdr
->sh_info
]);
1298 r_type
= ELF32_R_TYPE (rel
->r_info
);
1302 case R_PARISC_DLTIND14F
:
1303 case R_PARISC_DLTIND14R
:
1304 case R_PARISC_DLTIND21L
:
1305 /* This symbol requires a global offset table entry. */
1306 need_entry
= NEED_GOT
;
1308 /* Mark this section as containing PIC code. */
1309 sec
->flags
|= SEC_HAS_GOT_REF
;
1312 case R_PARISC_PLABEL14R
: /* "Official" procedure labels. */
1313 case R_PARISC_PLABEL21L
:
1314 case R_PARISC_PLABEL32
:
1315 /* If the addend is non-zero, we break badly. */
1316 if (rel
->r_addend
!= 0)
1319 /* If we are creating a shared library, then we need to
1320 create a PLT entry for all PLABELs, because PLABELs with
1321 local symbols may be passed via a pointer to another
1322 object. Additionally, output a dynamic relocation
1323 pointing to the PLT entry.
1324 For executables, the original 32-bit ABI allowed two
1325 different styles of PLABELs (function pointers): For
1326 global functions, the PLABEL word points into the .plt
1327 two bytes past a (function address, gp) pair, and for
1328 local functions the PLABEL points directly at the
1329 function. The magic +2 for the first type allows us to
1330 differentiate between the two. As you can imagine, this
1331 is a real pain when it comes to generating code to call
1332 functions indirectly or to compare function pointers.
1333 We avoid the mess by always pointing a PLABEL into the
1334 .plt, even for local functions. */
1335 need_entry
= PLT_PLABEL
| NEED_PLT
| NEED_DYNREL
;
1338 case R_PARISC_PCREL12F
:
1339 hplink
->has_12bit_branch
= 1;
1341 case R_PARISC_PCREL17C
:
1342 case R_PARISC_PCREL17F
:
1343 hplink
->has_17bit_branch
= 1;
1345 case R_PARISC_PCREL22F
:
1346 /* Function calls might need to go through the .plt, and
1347 might require long branch stubs. */
1350 /* We know local syms won't need a .plt entry, and if
1351 they need a long branch stub we can't guarantee that
1352 we can reach the stub. So just flag an error later
1353 if we're doing a shared link and find we need a long
1359 /* Global symbols will need a .plt entry if they remain
1360 global, and in most cases won't need a long branch
1361 stub. Unfortunately, we have to cater for the case
1362 where a symbol is forced local by versioning, or due
1363 to symbolic linking, and we lose the .plt entry. */
1364 need_entry
= NEED_PLT
| NEED_STUBREL
;
1365 if (h
->elf
.type
== STT_PARISC_MILLI
)
1366 need_entry
= NEED_STUBREL
;
1370 case R_PARISC_SEGBASE
: /* Used to set segment base. */
1371 case R_PARISC_SEGREL32
: /* Relative reloc, used for unwind. */
1372 case R_PARISC_PCREL14F
: /* PC relative load/store. */
1373 case R_PARISC_PCREL14R
:
1374 case R_PARISC_PCREL17R
: /* External branches. */
1375 case R_PARISC_PCREL21L
: /* As above, and for load/store too. */
1376 /* We don't need to propagate the relocation if linking a
1377 shared object since these are section relative. */
1380 case R_PARISC_DPREL14F
: /* Used for gp rel data load/store. */
1381 case R_PARISC_DPREL14R
:
1382 case R_PARISC_DPREL21L
:
1385 (*_bfd_error_handler
)
1386 (_("%s: relocation %s can not be used when making a shared object; recompile with -fPIC"),
1387 bfd_get_filename (abfd
),
1388 elf_hppa_howto_table
[r_type
].name
);
1389 bfd_set_error (bfd_error_bad_value
);
1394 case R_PARISC_DIR17F
: /* Used for external branches. */
1395 case R_PARISC_DIR17R
:
1396 case R_PARISC_DIR14F
: /* Used for load/store from absolute locn. */
1397 case R_PARISC_DIR14R
:
1398 case R_PARISC_DIR21L
: /* As above, and for ext branches too. */
1400 /* Help debug shared library creation. Any of the above
1401 relocs can be used in shared libs, but they may cause
1402 pages to become unshared. */
1405 (*_bfd_error_handler
)
1406 (_("%s: relocation %s should not be used when making a shared object; recompile with -fPIC"),
1407 bfd_get_filename (abfd
),
1408 elf_hppa_howto_table
[r_type
].name
);
1413 case R_PARISC_DIR32
: /* .word relocs. */
1414 /* We may want to output a dynamic relocation later. */
1415 need_entry
= NEED_DYNREL
;
1418 /* This relocation describes the C++ object vtable hierarchy.
1419 Reconstruct it for later use during GC. */
1420 case R_PARISC_GNU_VTINHERIT
:
1421 if (!_bfd_elf32_gc_record_vtinherit (abfd
, sec
,
1422 &h
->elf
, rel
->r_offset
))
1426 /* This relocation describes which C++ vtable entries are actually
1427 used. Record for later use during GC. */
1428 case R_PARISC_GNU_VTENTRY
:
1429 if (!_bfd_elf32_gc_record_vtentry (abfd
, sec
,
1430 &h
->elf
, rel
->r_addend
))
1438 /* Now carry out our orders. */
1439 if (need_entry
& NEED_GOT
)
1441 /* Allocate space for a GOT entry, as well as a dynamic
1442 relocation for this entry. */
1444 hplink
->root
.dynobj
= dynobj
= abfd
;
1446 if (hplink
->sgot
== NULL
)
1448 if (! elf32_hppa_create_dynamic_sections (dynobj
, info
))
1454 if (h
->elf
.got
.refcount
== -1)
1456 h
->elf
.got
.refcount
= 1;
1458 /* Make sure this symbol is output as a dynamic symbol. */
1459 if (h
->elf
.dynindx
== -1)
1461 if (! bfd_elf32_link_record_dynamic_symbol (info
,
1467 h
->elf
.got
.refcount
+= 1;
1471 /* This is a global offset table entry for a local symbol. */
1472 if (local_got_refcounts
== NULL
)
1476 /* Allocate space for local got offsets and local
1477 plt offsets. Done this way to save polluting
1478 elf_obj_tdata with another target specific
1480 size
= symtab_hdr
->sh_info
* 2 * sizeof (bfd_signed_vma
);
1481 local_got_refcounts
= ((bfd_signed_vma
*)
1482 bfd_alloc (abfd
, size
));
1483 if (local_got_refcounts
== NULL
)
1485 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
1486 memset (local_got_refcounts
, -1, size
);
1488 if (local_got_refcounts
[r_symndx
] == -1)
1489 local_got_refcounts
[r_symndx
] = 1;
1491 local_got_refcounts
[r_symndx
] += 1;
1495 if (need_entry
& NEED_PLT
)
1497 /* If we are creating a shared library, and this is a reloc
1498 against a weak symbol or a global symbol in a dynamic
1499 object, then we will be creating an import stub and a
1500 .plt entry for the symbol. Similarly, on a normal link
1501 to symbols defined in a dynamic object we'll need the
1502 import stub and a .plt entry. We don't know yet whether
1503 the symbol is defined or not, so make an entry anyway and
1504 clean up later in adjust_dynamic_symbol. */
1505 if ((sec
->flags
& SEC_ALLOC
) != 0)
1509 if (h
->elf
.plt
.refcount
== -1)
1511 h
->elf
.plt
.refcount
= 1;
1512 h
->elf
.elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
1515 h
->elf
.plt
.refcount
+= 1;
1517 /* If this .plt entry is for a plabel, mark it so
1518 that adjust_dynamic_symbol will keep the entry
1519 even if it appears to be local. */
1520 if (need_entry
& PLT_PLABEL
)
1523 else if (need_entry
& PLT_PLABEL
)
1527 if (local_got_refcounts
== NULL
)
1531 /* Allocate space for local got offsets and local
1533 size
= symtab_hdr
->sh_info
* 2 * sizeof (bfd_signed_vma
);
1534 local_got_refcounts
= ((bfd_signed_vma
*)
1535 bfd_alloc (abfd
, size
));
1536 if (local_got_refcounts
== NULL
)
1538 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
1539 memset (local_got_refcounts
, -1, size
);
1541 indx
= r_symndx
+ symtab_hdr
->sh_info
;
1542 if (local_got_refcounts
[indx
] == -1)
1543 local_got_refcounts
[indx
] = 1;
1545 local_got_refcounts
[indx
] += 1;
1550 if (need_entry
& (NEED_DYNREL
| NEED_STUBREL
))
1552 /* Flag this symbol as having a non-got, non-plt reference
1553 so that we generate copy relocs if it turns out to be
1556 h
->elf
.elf_link_hash_flags
|= ELF_LINK_NON_GOT_REF
;
1558 /* If we are creating a shared library then we need to copy
1559 the reloc into the shared library. However, if we are
1560 linking with -Bsymbolic, we need only copy absolute
1561 relocs or relocs against symbols that are not defined in
1562 an object we are including in the link. PC- or DP- or
1563 DLT-relative relocs against any local sym or global sym
1564 with DEF_REGULAR set, can be discarded. At this point we
1565 have not seen all the input files, so it is possible that
1566 DEF_REGULAR is not set now but will be set later (it is
1567 never cleared). We account for that possibility below by
1568 storing information in the reloc_entries field of the
1571 A similar situation to the -Bsymbolic case occurs when
1572 creating shared libraries and symbol visibility changes
1573 render the symbol local.
1575 As it turns out, all the relocs we will be creating here
1576 are absolute, so we cannot remove them on -Bsymbolic
1577 links or visibility changes anyway. A STUB_REL reloc
1578 is absolute too, as in that case it is the reloc in the
1579 stub we will be creating, rather than copying the PCREL
1580 reloc in the branch. */
1581 if ((sec
->flags
& SEC_ALLOC
) != 0
1583 #if RELATIVE_DYNAMIC_RELOCS
1585 || is_absolute_reloc (r_type
)
1587 && ((h
->elf
.elf_link_hash_flags
1588 & ELF_LINK_HASH_DEF_REGULAR
) == 0)))
1596 if ((need_entry
& NEED_STUBREL
))
1599 /* Create a reloc section in dynobj and make room for
1606 hplink
->root
.dynobj
= dynobj
= abfd
;
1608 name
= bfd_elf_string_from_elf_section
1610 elf_elfheader (abfd
)->e_shstrndx
,
1611 elf_section_data (sec
)->rel_hdr
.sh_name
);
1614 (*_bfd_error_handler
)
1615 (_("Could not find relocation section for %s"),
1617 bfd_set_error (bfd_error_bad_value
);
1621 if ((need_entry
& NEED_STUBREL
))
1623 size_t len
= strlen (name
) + sizeof (STUB_SUFFIX
);
1624 char *newname
= bfd_malloc (len
);
1626 if (newname
== NULL
)
1628 strcpy (newname
, name
);
1629 strcpy (newname
+ len
- sizeof (STUB_SUFFIX
),
1634 srel
= bfd_get_section_by_name (dynobj
, name
);
1639 srel
= bfd_make_section (dynobj
, name
);
1640 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
1641 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
1642 if ((sec
->flags
& SEC_ALLOC
) != 0)
1643 flags
|= SEC_ALLOC
| SEC_LOAD
;
1645 || !bfd_set_section_flags (dynobj
, srel
, flags
)
1646 || !bfd_set_section_alignment (dynobj
, srel
, 2))
1649 else if ((need_entry
& NEED_STUBREL
))
1652 if ((need_entry
& NEED_STUBREL
))
1658 #if ! LONG_BRANCH_PIC_IN_SHLIB
1659 /* If this is a function call, we only need one dynamic
1660 reloc for the stub as all calls to a particular
1661 function will go through the same stub. Actually, a
1662 long branch stub needs two relocations, but we count
1663 on some intelligence on the part of the dynamic
1665 if ((need_entry
& NEED_STUBREL
))
1667 doit
= h
->stub_reloc_sec
!= stubreloc
;
1668 h
->stub_reloc_sec
= stubreloc
;
1676 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
1678 #if ! LONG_BRANCH_PIC_IN_SHLIB || RELATIVE_DYNAMIC_RELOCS
1679 /* Keep track of relocations we have entered for
1680 this global symbol, so that we can discard them
1681 later if necessary. */
1684 #if RELATIVE_DYNAMIC_RELOCS
1685 || ! is_absolute_reloc (rtype
)
1687 || (need_entry
& NEED_STUBREL
)))
1689 struct elf32_hppa_dyn_reloc_entry
*p
;
1691 for (p
= h
->reloc_entries
; p
!= NULL
; p
= p
->next
)
1692 if (p
->section
== srel
)
1697 p
= ((struct elf32_hppa_dyn_reloc_entry
*)
1698 bfd_alloc (dynobj
, sizeof *p
));
1701 p
->next
= h
->reloc_entries
;
1702 h
->reloc_entries
= p
;
1707 /* NEED_STUBREL and NEED_DYNREL are never both
1708 set. Leave the count at zero for the
1709 NEED_STUBREL case as we only ever have one
1710 stub reloc per section per symbol, and this
1711 simplifies code in hppa_discard_copies. */
1712 if (! (need_entry
& NEED_STUBREL
))
1724 /* Return the section that should be marked against garbage collection
1725 for a given relocation. */
1728 elf32_hppa_gc_mark_hook (abfd
, info
, rel
, h
, sym
)
1730 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1731 Elf_Internal_Rela
*rel
;
1732 struct elf_link_hash_entry
*h
;
1733 Elf_Internal_Sym
*sym
;
1737 switch ((unsigned int) ELF32_R_TYPE (rel
->r_info
))
1739 case R_PARISC_GNU_VTINHERIT
:
1740 case R_PARISC_GNU_VTENTRY
:
1744 switch (h
->root
.type
)
1746 case bfd_link_hash_defined
:
1747 case bfd_link_hash_defweak
:
1748 return h
->root
.u
.def
.section
;
1750 case bfd_link_hash_common
:
1751 return h
->root
.u
.c
.p
->section
;
1760 if (!(elf_bad_symtab (abfd
)
1761 && ELF_ST_BIND (sym
->st_info
) != STB_LOCAL
)
1762 && ! ((sym
->st_shndx
<= 0 || sym
->st_shndx
>= SHN_LORESERVE
)
1763 && sym
->st_shndx
!= SHN_COMMON
))
1765 return bfd_section_from_elf_index (abfd
, sym
->st_shndx
);
1772 /* Update the got and plt entry reference counts for the section being
1776 elf32_hppa_gc_sweep_hook (abfd
, info
, sec
, relocs
)
1778 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1780 const Elf_Internal_Rela
*relocs
;
1782 Elf_Internal_Shdr
*symtab_hdr
;
1783 struct elf_link_hash_entry
**sym_hashes
;
1784 bfd_signed_vma
*local_got_refcounts
;
1785 bfd_signed_vma
*local_plt_refcounts
;
1786 const Elf_Internal_Rela
*rel
, *relend
;
1787 unsigned long r_symndx
;
1788 struct elf_link_hash_entry
*h
;
1789 struct elf32_hppa_link_hash_table
*hplink
;
1792 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1793 sym_hashes
= elf_sym_hashes (abfd
);
1794 local_got_refcounts
= elf_local_got_refcounts (abfd
);
1795 local_plt_refcounts
= local_got_refcounts
;
1796 if (local_plt_refcounts
!= NULL
)
1797 local_plt_refcounts
+= symtab_hdr
->sh_info
;
1798 hplink
= hppa_link_hash_table (info
);
1799 dynobj
= hplink
->root
.dynobj
;
1803 relend
= relocs
+ sec
->reloc_count
;
1804 for (rel
= relocs
; rel
< relend
; rel
++)
1805 switch ((unsigned int) ELF32_R_TYPE (rel
->r_info
))
1807 case R_PARISC_DLTIND14F
:
1808 case R_PARISC_DLTIND14R
:
1809 case R_PARISC_DLTIND21L
:
1810 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1811 if (r_symndx
>= symtab_hdr
->sh_info
)
1813 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1814 if (h
->got
.refcount
> 0)
1815 h
->got
.refcount
-= 1;
1817 else if (local_got_refcounts
!= NULL
)
1819 if (local_got_refcounts
[r_symndx
] > 0)
1820 local_got_refcounts
[r_symndx
] -= 1;
1824 case R_PARISC_PCREL12F
:
1825 case R_PARISC_PCREL17C
:
1826 case R_PARISC_PCREL17F
:
1827 case R_PARISC_PCREL22F
:
1828 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1829 if (r_symndx
>= symtab_hdr
->sh_info
)
1831 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1832 if (h
->plt
.refcount
> 0)
1833 h
->plt
.refcount
-= 1;
1837 case R_PARISC_PLABEL14R
:
1838 case R_PARISC_PLABEL21L
:
1839 case R_PARISC_PLABEL32
:
1840 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1841 if (r_symndx
>= symtab_hdr
->sh_info
)
1843 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1844 if (h
->plt
.refcount
> 0)
1845 h
->plt
.refcount
-= 1;
1847 else if (local_plt_refcounts
!= NULL
)
1849 if (local_plt_refcounts
[r_symndx
] > 0)
1850 local_plt_refcounts
[r_symndx
] -= 1;
1861 /* Our own version of hide_symbol, so that we can keep plt entries for
1865 elf32_hppa_hide_symbol (info
, h
)
1866 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1867 struct elf_link_hash_entry
*h
;
1869 if ((h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) != 0)
1871 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
)
1873 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1874 h
->plt
.offset
= (bfd_vma
) -1;
1878 /* This is the condition under which elf32_hppa_finish_dynamic_symbol
1879 will be called from elflink.h. If elflink.h doesn't call our
1880 finish_dynamic_symbol routine, we'll need to do something about
1881 initializing any .plt and .got entries in elf32_hppa_relocate_section. */
1882 #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
1884 && ((INFO)->shared \
1885 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
1886 && ((H)->dynindx != -1 \
1887 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
1889 /* Adjust a symbol defined by a dynamic object and referenced by a
1890 regular object. The current definition is in some section of the
1891 dynamic object, but we're not including those sections. We have to
1892 change the definition to something the rest of the link can
1896 elf32_hppa_adjust_dynamic_symbol (info
, h
)
1897 struct bfd_link_info
*info
;
1898 struct elf_link_hash_entry
*h
;
1901 struct elf32_hppa_link_hash_table
*hplink
;
1904 hplink
= hppa_link_hash_table (info
);
1905 dynobj
= hplink
->root
.dynobj
;
1907 /* If this is a function, put it in the procedure linkage table. We
1908 will fill in the contents of the procedure linkage table later,
1909 when we know the address of the .got section. */
1910 if (h
->type
== STT_FUNC
1911 || (h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0)
1914 && h
->plt
.refcount
> 0
1915 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
1916 && (h
->root
.u
.def
.section
->flags
& SEC_HAS_GOT_REF
) != 0)
1918 ((struct elf32_hppa_link_hash_entry
*) h
)->maybe_pic_call
= 1;
1921 if (h
->plt
.refcount
<= 0
1922 || ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
1923 && h
->root
.type
!= bfd_link_hash_defweak
1924 && ! ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
1925 && (!info
->shared
|| info
->symbolic
)))
1927 /* The .plt entry is not needed when:
1928 a) Garbage collection has removed all references to the
1930 b) We know for certain the symbol is defined in this
1931 object, and it's not a weak definition, nor is the symbol
1932 used by a plabel relocation. Either this object is the
1933 application or we are doing a shared symbolic link. */
1935 /* As a special sop to the hppa ABI, we keep a .plt entry
1936 for functions in sections containing PIC code. */
1937 if (((struct elf32_hppa_link_hash_entry
*) h
)->maybe_pic_call
)
1938 ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
= 1;
1941 h
->plt
.offset
= (bfd_vma
) -1;
1942 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1947 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
1949 /* Make sure this symbol is output as a dynamic symbol. */
1950 if (h
->dynindx
== -1
1951 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0)
1953 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
1961 /* If this is a weak symbol, and there is a real definition, the
1962 processor independent code will have arranged for us to see the
1963 real definition first, and we can just use the same value. */
1964 if (h
->weakdef
!= NULL
)
1966 if (h
->weakdef
->root
.type
!= bfd_link_hash_defined
1967 && h
->weakdef
->root
.type
!= bfd_link_hash_defweak
)
1969 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
1970 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
1974 /* This is a reference to a symbol defined by a dynamic object which
1975 is not a function. */
1977 /* If we are creating a shared library, we must presume that the
1978 only references to the symbol are via the global offset table.
1979 For such cases we need not do anything here; the relocations will
1980 be handled correctly by relocate_section. */
1984 /* If there are no references to this symbol that do not use the
1985 GOT, we don't need to generate a copy reloc. */
1986 if ((h
->elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0)
1989 /* We must allocate the symbol in our .dynbss section, which will
1990 become part of the .bss section of the executable. There will be
1991 an entry for this symbol in the .dynsym section. The dynamic
1992 object will contain position independent code, so all references
1993 from the dynamic object to this symbol will go through the global
1994 offset table. The dynamic linker will use the .dynsym entry to
1995 determine the address it must put in the global offset table, so
1996 both the dynamic object and the regular object will refer to the
1997 same memory location for the variable. */
1999 s
= hplink
->sdynbss
;
2001 /* We must generate a COPY reloc to tell the dynamic linker to
2002 copy the initial value out of the dynamic object and into the
2003 runtime process image. We need to remember the offset into the
2004 .rela.bss section we are going to use. */
2005 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
2009 srel
= hplink
->srelbss
;
2010 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
2011 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
2015 /* We need to figure out the alignment required for this symbol. I
2016 have no idea how other ELF linkers handle this. */
2017 unsigned int power_of_two
;
2019 power_of_two
= bfd_log2 (h
->size
);
2020 if (power_of_two
> 3)
2023 /* Apply the required alignment. */
2024 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
2025 (bfd_size_type
) (1 << power_of_two
));
2026 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
2028 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
2032 /* Define the symbol as being at this point in the section. */
2033 h
->root
.u
.def
.section
= s
;
2034 h
->root
.u
.def
.value
= s
->_raw_size
;
2036 /* Increment the section size to make room for the symbol. */
2037 s
->_raw_size
+= h
->size
;
2042 /* Called via elf_link_hash_traverse to create .plt entries for an
2043 application that uses statically linked PIC functions. Similar to
2044 the first part of elf32_hppa_adjust_dynamic_symbol. */
2047 hppa_handle_PIC_calls (h
, inf
)
2048 struct elf_link_hash_entry
*h
;
2049 PTR inf ATTRIBUTE_UNUSED
;
2051 if (! (h
->plt
.refcount
> 0
2052 && (h
->root
.type
== bfd_link_hash_defined
2053 || h
->root
.type
== bfd_link_hash_defweak
)
2054 && (h
->root
.u
.def
.section
->flags
& SEC_HAS_GOT_REF
) != 0))
2056 h
->plt
.offset
= (bfd_vma
) -1;
2057 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
2061 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
2062 ((struct elf32_hppa_link_hash_entry
*) h
)->maybe_pic_call
= 1;
2063 ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
= 1;
2068 /* Allocate space in .plt, .got and associated reloc sections for
2072 allocate_plt_and_got (h
, inf
)
2073 struct elf_link_hash_entry
*h
;
2076 struct bfd_link_info
*info
;
2077 struct elf32_hppa_link_hash_table
*hplink
;
2080 if (h
->root
.type
== bfd_link_hash_indirect
2081 || h
->root
.type
== bfd_link_hash_warning
)
2084 info
= (struct bfd_link_info
*) inf
;
2085 hplink
= hppa_link_hash_table (info
);
2086 if ((hplink
->root
.dynamic_sections_created
2087 && h
->plt
.refcount
> 0)
2088 || ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
2090 /* Make an entry in the .plt section. */
2092 h
->plt
.offset
= s
->_raw_size
;
2093 if (PLABEL_PLT_ENTRY_SIZE
!= PLT_ENTRY_SIZE
2094 && ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
2095 && (h
->elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
) == 0)
2097 /* Add some extra space for the dynamic linker to use. */
2098 s
->_raw_size
+= PLABEL_PLT_ENTRY_SIZE
;
2101 s
->_raw_size
+= PLT_ENTRY_SIZE
;
2103 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
2104 && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info
, h
))
2106 /* We also need to make an entry in the .rela.plt section. */
2107 hplink
->srelplt
->_raw_size
+= sizeof (Elf32_External_Rela
);
2108 hplink
->need_plt_stub
= 1;
2113 h
->plt
.offset
= (bfd_vma
) -1;
2114 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
2117 if (h
->got
.refcount
> 0)
2122 h
->got
.offset
= s
->_raw_size
;
2123 s
->_raw_size
+= GOT_ENTRY_SIZE
;
2124 dyn
= hplink
->root
.dynamic_sections_created
;
2125 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
, h
))
2126 hplink
->srelgot
->_raw_size
+= sizeof (Elf32_External_Rela
);
2129 h
->got
.offset
= (bfd_vma
) -1;
2134 #if ((! LONG_BRANCH_PIC_IN_SHLIB && LONG_BRANCH_VIA_PLT) \
2135 || RELATIVE_DYNAMIC_RELOCS)
2136 /* This function is called via elf_link_hash_traverse to discard space
2137 we allocated for relocs that it turned out we didn't need. */
2140 hppa_discard_copies (h
, inf
)
2141 struct elf_link_hash_entry
*h
;
2144 struct elf32_hppa_dyn_reloc_entry
*s
;
2145 struct elf32_hppa_link_hash_entry
*eh
;
2146 struct bfd_link_info
*info
;
2148 eh
= (struct elf32_hppa_link_hash_entry
*) h
;
2149 info
= (struct bfd_link_info
*) inf
;
2151 #if ! LONG_BRANCH_PIC_IN_SHLIB && LONG_BRANCH_VIA_PLT
2152 /* Handle the stub reloc case. If we have a plt entry for the
2153 function, we won't be needing long branch stubs. s->count will
2154 only be zero for stub relocs, which provides a handy way of
2155 flagging these relocs, and means we need do nothing special for
2156 the forced local and symbolic link case. */
2157 if (eh
->stub_reloc_sec
!= NULL
2158 && eh
->elf
.plt
.offset
!= (bfd_vma
) -1)
2160 for (s
= eh
->reloc_entries
; s
!= NULL
; s
= s
->next
)
2162 s
->section
->_raw_size
-= sizeof (Elf32_External_Rela
);
2166 #if RELATIVE_DYNAMIC_RELOCS
2167 /* If a symbol has been forced local or we have found a regular
2168 definition for the symbolic link case, then we won't be needing
2170 if (eh
->elf
.dynindx
== -1
2171 || ((eh
->elf
.elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) != 0
2172 && !is_absolute_reloc (r_type
)
2175 for (s
= eh
->reloc_entries
; s
!= NULL
; s
= s
->next
)
2176 s
->section
->_raw_size
-= s
->count
* sizeof (Elf32_External_Rela
);
2184 /* This function is called via elf_link_hash_traverse to force
2185 millicode symbols local so they do not end up as globals in the
2186 dynamic symbol table. We ought to be able to do this in
2187 adjust_dynamic_symbol, but our adjust_dynamic_symbol is not called
2188 for all dynamic symbols. Arguably, this is a bug in
2189 elf_adjust_dynamic_symbol. */
2192 clobber_millicode_symbols (h
, info
)
2193 struct elf_link_hash_entry
*h
;
2194 struct bfd_link_info
*info
;
2196 /* We only want to remove these from the dynamic symbol table.
2197 Therefore we do not leave ELF_LINK_FORCED_LOCAL set. */
2198 if (h
->type
== STT_PARISC_MILLI
)
2200 unsigned short oldflags
= h
->elf_link_hash_flags
;
2201 h
->elf_link_hash_flags
|= ELF_LINK_FORCED_LOCAL
;
2202 elf32_hppa_hide_symbol (info
, h
);
2203 h
->elf_link_hash_flags
&= ~ELF_LINK_FORCED_LOCAL
;
2204 h
->elf_link_hash_flags
|= oldflags
& ELF_LINK_FORCED_LOCAL
;
2209 /* Set the sizes of the dynamic sections. */
2212 elf32_hppa_size_dynamic_sections (output_bfd
, info
)
2214 struct bfd_link_info
*info
;
2216 struct elf32_hppa_link_hash_table
*hplink
;
2222 hplink
= hppa_link_hash_table (info
);
2223 dynobj
= hplink
->root
.dynobj
;
2227 if (hplink
->root
.dynamic_sections_created
)
2231 /* Set the contents of the .interp section to the interpreter. */
2234 s
= bfd_get_section_by_name (dynobj
, ".interp");
2237 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
2238 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
2241 /* Force millicode symbols local. */
2242 elf_link_hash_traverse (&hplink
->root
,
2243 clobber_millicode_symbols
,
2246 /* Set up .got and .plt offsets for local syms. */
2247 for (i
= info
->input_bfds
; i
; i
= i
->link_next
)
2249 bfd_signed_vma
*local_got
;
2250 bfd_signed_vma
*end_local_got
;
2251 bfd_signed_vma
*local_plt
;
2252 bfd_signed_vma
*end_local_plt
;
2253 bfd_size_type locsymcount
;
2254 Elf_Internal_Shdr
*symtab_hdr
;
2257 if (bfd_get_flavour (i
) != bfd_target_elf_flavour
)
2260 local_got
= elf_local_got_refcounts (i
);
2264 symtab_hdr
= &elf_tdata (i
)->symtab_hdr
;
2265 locsymcount
= symtab_hdr
->sh_info
;
2266 end_local_got
= local_got
+ locsymcount
;
2268 srel
= hplink
->srelgot
;
2269 for (; local_got
< end_local_got
; ++local_got
)
2273 *local_got
= s
->_raw_size
;
2274 s
->_raw_size
+= GOT_ENTRY_SIZE
;
2276 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
2279 *local_got
= (bfd_vma
) -1;
2282 local_plt
= end_local_got
;
2283 end_local_plt
= local_plt
+ locsymcount
;
2285 srel
= hplink
->srelplt
;
2286 for (; local_plt
< end_local_plt
; ++local_plt
)
2290 *local_plt
= s
->_raw_size
;
2291 s
->_raw_size
+= PLT_ENTRY_SIZE
;
2293 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
2296 *local_plt
= (bfd_vma
) -1;
2302 /* Run through the function symbols, looking for any that are
2303 PIC, and allocate space for the necessary .plt entries so
2304 that %r19 will be set up. */
2306 elf_link_hash_traverse (&hplink
->root
,
2307 hppa_handle_PIC_calls
,
2311 /* Allocate global sym .plt and .got entries. */
2312 elf_link_hash_traverse (&hplink
->root
,
2313 allocate_plt_and_got
,
2316 #if ((! LONG_BRANCH_PIC_IN_SHLIB && LONG_BRANCH_VIA_PLT) \
2317 || RELATIVE_DYNAMIC_RELOCS)
2318 /* If this is a -Bsymbolic shared link, then we need to discard all
2319 relocs against symbols defined in a regular object. We also need
2320 to lose relocs we've allocated for long branch stubs if we know
2321 we won't be generating a stub. */
2323 elf_link_hash_traverse (&hplink
->root
,
2324 hppa_discard_copies
,
2328 /* The check_relocs and adjust_dynamic_symbol entry points have
2329 determined the sizes of the various dynamic sections. Allocate
2333 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
2337 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
2340 /* It's OK to base decisions on the section name, because none
2341 of the dynobj section names depend upon the input files. */
2342 name
= bfd_get_section_name (dynobj
, s
);
2344 if (strncmp (name
, ".rela", 5) == 0)
2346 if (s
->_raw_size
!= 0)
2349 const char *outname
;
2351 /* Remember whether there are any reloc sections other
2353 if (strcmp (name
+5, ".plt") != 0)
2356 /* If this relocation section applies to a read only
2357 section, then we probably need a DT_TEXTREL entry. */
2358 outname
= bfd_get_section_name (output_bfd
,
2360 target
= bfd_get_section_by_name (output_bfd
, outname
+ 5);
2362 && (target
->flags
& SEC_READONLY
) != 0
2363 && (target
->flags
& SEC_ALLOC
) != 0)
2366 /* We use the reloc_count field as a counter if we need
2367 to copy relocs into the output file. */
2371 else if (strcmp (name
, ".plt") == 0)
2373 if (hplink
->need_plt_stub
)
2375 /* Make space for the plt stub at the end of the .plt
2376 section. We want this stub right at the end, up
2377 against the .got section. */
2378 int gotalign
= bfd_section_alignment (dynobj
, hplink
->sgot
);
2379 int pltalign
= bfd_section_alignment (dynobj
, s
);
2382 if (gotalign
> pltalign
)
2383 bfd_set_section_alignment (dynobj
, s
, gotalign
);
2384 mask
= ((bfd_size_type
) 1 << gotalign
) - 1;
2385 s
->_raw_size
= (s
->_raw_size
+ sizeof (plt_stub
) + mask
) & ~mask
;
2388 else if (strcmp (name
, ".got") == 0)
2392 /* It's not one of our sections, so don't allocate space. */
2396 if (s
->_raw_size
== 0)
2398 /* If we don't need this section, strip it from the
2399 output file. This is mostly to handle .rela.bss and
2400 .rela.plt. We must create both sections in
2401 create_dynamic_sections, because they must be created
2402 before the linker maps input sections to output
2403 sections. The linker does that before
2404 adjust_dynamic_symbol is called, and it is that
2405 function which decides whether anything needs to go
2406 into these sections. */
2407 _bfd_strip_section_from_output (info
, s
);
2411 /* Allocate memory for the section contents. Zero it, because
2412 we may not fill in all the reloc sections. */
2413 s
->contents
= (bfd_byte
*) bfd_zalloc (dynobj
, s
->_raw_size
);
2414 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
2418 if (hplink
->root
.dynamic_sections_created
)
2420 /* Like IA-64 and HPPA64, always create a DT_PLTGOT. It
2421 actually has nothing to do with the PLT, it is how we
2422 communicate the LTP value of a load module to the dynamic
2424 if (! bfd_elf32_add_dynamic_entry (info
, DT_PLTGOT
, 0))
2427 /* Add some entries to the .dynamic section. We fill in the
2428 values later, in elf32_hppa_finish_dynamic_sections, but we
2429 must add the entries now so that we get the correct size for
2430 the .dynamic section. The DT_DEBUG entry is filled in by the
2431 dynamic linker and used by the debugger. */
2434 if (! bfd_elf32_add_dynamic_entry (info
, DT_DEBUG
, 0))
2438 if (hplink
->srelplt
->_raw_size
!= 0)
2440 if (! bfd_elf32_add_dynamic_entry (info
, DT_PLTRELSZ
, 0)
2441 || ! bfd_elf32_add_dynamic_entry (info
, DT_PLTREL
, DT_RELA
)
2442 || ! bfd_elf32_add_dynamic_entry (info
, DT_JMPREL
, 0))
2448 if (! bfd_elf32_add_dynamic_entry (info
, DT_RELA
, 0)
2449 || ! bfd_elf32_add_dynamic_entry (info
, DT_RELASZ
, 0)
2450 || ! bfd_elf32_add_dynamic_entry (info
, DT_RELAENT
,
2451 sizeof (Elf32_External_Rela
)))
2457 if (! bfd_elf32_add_dynamic_entry (info
, DT_TEXTREL
, 0))
2459 info
->flags
|= DF_TEXTREL
;
2466 /* External entry points for sizing and building linker stubs. */
2468 /* Determine and set the size of the stub section for a final link.
2470 The basic idea here is to examine all the relocations looking for
2471 PC-relative calls to a target that is unreachable with a "bl"
2475 elf32_hppa_size_stubs (output_bfd
, stub_bfd
, info
, multi_subspace
, group_size
,
2476 add_stub_section
, layout_sections_again
)
2479 struct bfd_link_info
*info
;
2480 boolean multi_subspace
;
2481 bfd_signed_vma group_size
;
2482 asection
* (*add_stub_section
) PARAMS ((const char *, asection
*));
2483 void (*layout_sections_again
) PARAMS ((void));
2487 asection
**input_list
, **list
;
2488 Elf_Internal_Sym
*local_syms
, **all_local_syms
;
2489 unsigned int bfd_indx
, bfd_count
;
2490 int top_id
, top_index
;
2491 struct elf32_hppa_link_hash_table
*hplink
;
2492 bfd_size_type stub_group_size
;
2493 boolean stubs_always_before_branch
;
2494 boolean stub_changed
= 0;
2497 hplink
= hppa_link_hash_table (info
);
2499 /* Stash our params away. */
2500 hplink
->stub_bfd
= stub_bfd
;
2501 hplink
->multi_subspace
= multi_subspace
;
2502 hplink
->add_stub_section
= add_stub_section
;
2503 hplink
->layout_sections_again
= layout_sections_again
;
2504 stubs_always_before_branch
= group_size
< 0;
2506 stub_group_size
= -group_size
;
2508 stub_group_size
= group_size
;
2509 if (stub_group_size
== 1)
2511 /* Default values. */
2512 stub_group_size
= 8000000;
2513 if (hplink
->has_17bit_branch
|| hplink
->multi_subspace
)
2514 stub_group_size
= 250000;
2515 if (hplink
->has_12bit_branch
)
2516 stub_group_size
= 7812;
2519 /* Count the number of input BFDs and find the top input section id. */
2520 for (input_bfd
= info
->input_bfds
, bfd_count
= 0, top_id
= 0;
2522 input_bfd
= input_bfd
->link_next
)
2525 for (section
= input_bfd
->sections
;
2527 section
= section
->next
)
2529 if (top_id
< section
->id
)
2530 top_id
= section
->id
;
2535 = (struct map_stub
*) bfd_zmalloc (sizeof (struct map_stub
) * (top_id
+ 1));
2536 if (hplink
->stub_group
== NULL
)
2539 /* Make a list of input sections for each output section included in
2542 We can't use output_bfd->section_count here to find the top output
2543 section index as some sections may have been removed, and
2544 _bfd_strip_section_from_output doesn't renumber the indices. */
2545 for (section
= output_bfd
->sections
, top_index
= 0;
2547 section
= section
->next
)
2549 if (top_index
< section
->index
)
2550 top_index
= section
->index
;
2554 = (asection
**) bfd_malloc (sizeof (asection
*) * (top_index
+ 1));
2555 if (input_list
== NULL
)
2558 /* For sections we aren't interested in, mark their entries with a
2559 value we can check later. */
2560 list
= input_list
+ top_index
;
2562 *list
= bfd_abs_section_ptr
;
2563 while (list
-- != input_list
);
2565 for (section
= output_bfd
->sections
;
2567 section
= section
->next
)
2569 if ((section
->flags
& SEC_CODE
) != 0)
2570 input_list
[section
->index
] = NULL
;
2573 /* Now actually build the lists. */
2574 for (input_bfd
= info
->input_bfds
;
2576 input_bfd
= input_bfd
->link_next
)
2578 for (section
= input_bfd
->sections
;
2580 section
= section
->next
)
2582 if (section
->output_section
!= NULL
2583 && section
->output_section
->owner
== output_bfd
2584 && section
->output_section
->index
<= top_index
)
2586 list
= input_list
+ section
->output_section
->index
;
2587 if (*list
!= bfd_abs_section_ptr
)
2589 /* Steal the link_sec pointer for our list. */
2590 #define PREV_SEC(sec) (hplink->stub_group[(sec)->id].link_sec)
2591 /* This happens to make the list in reverse order,
2592 which is what we want. */
2593 PREV_SEC (section
) = *list
;
2600 /* See whether we can group stub sections together. Grouping stub
2601 sections may result in fewer stubs. More importantly, we need to
2602 put all .init* and .fini* stubs at the beginning of the .init or
2603 .fini output sections respectively, because glibc splits the
2604 _init and _fini functions into multiple parts. Putting a stub in
2605 the middle of a function is not a good idea. */
2606 list
= input_list
+ top_index
;
2609 asection
*tail
= *list
;
2610 if (tail
== bfd_abs_section_ptr
)
2612 while (tail
!= NULL
)
2616 bfd_size_type total
;
2619 if (tail
->_cooked_size
)
2620 total
= tail
->_cooked_size
;
2622 total
= tail
->_raw_size
;
2623 while ((prev
= PREV_SEC (curr
)) != NULL
2624 && ((total
+= curr
->output_offset
- prev
->output_offset
)
2628 /* OK, the size from the start of CURR to the end is less
2629 than 250000 bytes and thus can be handled by one stub
2630 section. (or the tail section is itself larger than
2631 250000 bytes, in which case we may be toast.)
2632 We should really be keeping track of the total size of
2633 stubs added here, as stubs contribute to the final output
2634 section size. That's a little tricky, and this way will
2635 only break if stubs added total more than 12144 bytes, or
2636 1518 long branch stubs. It seems unlikely for more than
2637 1518 different functions to be called, especially from
2638 code only 250000 bytes long. */
2641 prev
= PREV_SEC (tail
);
2642 /* Set up this stub group. */
2643 hplink
->stub_group
[tail
->id
].link_sec
= curr
;
2645 while (tail
!= curr
&& (tail
= prev
) != NULL
);
2647 /* But wait, there's more! Input sections up to 250000
2648 bytes before the stub section can be handled by it too. */
2649 if (!stubs_always_before_branch
)
2653 && ((total
+= tail
->output_offset
- prev
->output_offset
)
2657 prev
= PREV_SEC (tail
);
2658 hplink
->stub_group
[tail
->id
].link_sec
= curr
;
2664 while (list
-- != input_list
);
2668 /* We want to read in symbol extension records only once. To do this
2669 we need to read in the local symbols in parallel and save them for
2670 later use; so hold pointers to the local symbols in an array. */
2672 = (Elf_Internal_Sym
**) bfd_zmalloc (sizeof (Elf_Internal_Sym
*)
2674 if (all_local_syms
== NULL
)
2677 /* Walk over all the input BFDs, swapping in local symbols.
2678 If we are creating a shared library, create hash entries for the
2680 for (input_bfd
= info
->input_bfds
, bfd_indx
= 0;
2682 input_bfd
= input_bfd
->link_next
, bfd_indx
++)
2684 Elf_Internal_Shdr
*symtab_hdr
;
2685 Elf_Internal_Sym
*isym
;
2686 Elf32_External_Sym
*ext_syms
, *esym
, *end_sy
;
2688 /* We'll need the symbol table in a second. */
2689 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2690 if (symtab_hdr
->sh_info
== 0)
2693 /* We need an array of the local symbols attached to the input bfd.
2694 Unfortunately, we're going to have to read & swap them in. */
2695 local_syms
= (Elf_Internal_Sym
*)
2696 bfd_malloc (symtab_hdr
->sh_info
* sizeof (Elf_Internal_Sym
));
2697 if (local_syms
== NULL
)
2699 goto error_ret_free_local
;
2701 all_local_syms
[bfd_indx
] = local_syms
;
2702 ext_syms
= (Elf32_External_Sym
*)
2703 bfd_malloc (symtab_hdr
->sh_info
* sizeof (Elf32_External_Sym
));
2704 if (ext_syms
== NULL
)
2706 goto error_ret_free_local
;
2709 if (bfd_seek (input_bfd
, symtab_hdr
->sh_offset
, SEEK_SET
) != 0
2710 || (bfd_read (ext_syms
, 1,
2711 (symtab_hdr
->sh_info
* sizeof (Elf32_External_Sym
)),
2713 != (symtab_hdr
->sh_info
* sizeof (Elf32_External_Sym
))))
2716 goto error_ret_free_local
;
2719 /* Swap the local symbols in. */
2722 for (end_sy
= esym
+ symtab_hdr
->sh_info
; esym
< end_sy
; esym
++, isym
++)
2723 bfd_elf32_swap_symbol_in (input_bfd
, esym
, isym
);
2725 /* Now we can free the external symbols. */
2728 #if ! LONG_BRANCH_PIC_IN_SHLIB
2729 /* If this is a shared link, find all the stub reloc sections. */
2731 for (section
= input_bfd
->sections
;
2733 section
= section
->next
)
2736 asection
*reloc_sec
;
2738 name
= bfd_malloc (strlen (section
->name
)
2739 + sizeof STUB_SUFFIX
2743 sprintf (name
, ".rela%s%s", section
->name
, STUB_SUFFIX
);
2744 reloc_sec
= bfd_get_section_by_name (hplink
->root
.dynobj
, name
);
2745 hplink
->stub_group
[section
->id
].reloc_sec
= reloc_sec
;
2750 if (info
->shared
&& hplink
->multi_subspace
)
2752 struct elf_link_hash_entry
**sym_hashes
;
2753 struct elf_link_hash_entry
**end_hashes
;
2754 unsigned int symcount
;
2756 symcount
= (symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
)
2757 - symtab_hdr
->sh_info
);
2758 sym_hashes
= elf_sym_hashes (input_bfd
);
2759 end_hashes
= sym_hashes
+ symcount
;
2761 /* Look through the global syms for functions; We need to
2762 build export stubs for all globally visible functions. */
2763 for (; sym_hashes
< end_hashes
; sym_hashes
++)
2765 struct elf32_hppa_link_hash_entry
*hash
;
2767 hash
= (struct elf32_hppa_link_hash_entry
*) *sym_hashes
;
2769 while (hash
->elf
.root
.type
== bfd_link_hash_indirect
2770 || hash
->elf
.root
.type
== bfd_link_hash_warning
)
2771 hash
= ((struct elf32_hppa_link_hash_entry
*)
2772 hash
->elf
.root
.u
.i
.link
);
2774 /* At this point in the link, undefined syms have been
2775 resolved, so we need to check that the symbol was
2776 defined in this BFD. */
2777 if ((hash
->elf
.root
.type
== bfd_link_hash_defined
2778 || hash
->elf
.root
.type
== bfd_link_hash_defweak
)
2779 && hash
->elf
.type
== STT_FUNC
2780 && hash
->elf
.root
.u
.def
.section
->output_section
!= NULL
2781 && (hash
->elf
.root
.u
.def
.section
->output_section
->owner
2783 && hash
->elf
.root
.u
.def
.section
->owner
== input_bfd
2784 && (hash
->elf
.elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)
2785 && !(hash
->elf
.elf_link_hash_flags
& ELF_LINK_FORCED_LOCAL
)
2786 && ELF_ST_VISIBILITY (hash
->elf
.other
) == STV_DEFAULT
)
2789 const char *stub_name
;
2790 struct elf32_hppa_stub_hash_entry
*stub_entry
;
2792 sec
= hash
->elf
.root
.u
.def
.section
;
2793 stub_name
= hash
->elf
.root
.root
.string
;
2794 stub_entry
= hppa_stub_hash_lookup (&hplink
->stub_hash_table
,
2797 if (stub_entry
== NULL
)
2799 stub_entry
= hppa_add_stub (stub_name
, sec
, hplink
);
2801 goto error_ret_free_local
;
2803 stub_entry
->target_value
= hash
->elf
.root
.u
.def
.value
;
2804 stub_entry
->target_section
= hash
->elf
.root
.u
.def
.section
;
2805 stub_entry
->stub_type
= hppa_stub_export
;
2806 stub_entry
->h
= hash
;
2811 (*_bfd_error_handler
) (_("%s: duplicate export stub %s"),
2812 bfd_get_filename (input_bfd
),
2824 for (input_bfd
= info
->input_bfds
, bfd_indx
= 0;
2826 input_bfd
= input_bfd
->link_next
, bfd_indx
++)
2828 Elf_Internal_Shdr
*symtab_hdr
;
2830 /* We'll need the symbol table in a second. */
2831 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2832 if (symtab_hdr
->sh_info
== 0)
2835 local_syms
= all_local_syms
[bfd_indx
];
2837 /* Walk over each section attached to the input bfd. */
2838 for (section
= input_bfd
->sections
;
2840 section
= section
->next
)
2842 Elf_Internal_Shdr
*input_rel_hdr
;
2843 Elf32_External_Rela
*external_relocs
, *erelaend
, *erela
;
2844 Elf_Internal_Rela
*internal_relocs
, *irelaend
, *irela
;
2846 /* If there aren't any relocs, then there's nothing more
2848 if ((section
->flags
& SEC_RELOC
) == 0
2849 || section
->reloc_count
== 0)
2852 /* If this section is a link-once section that will be
2853 discarded, then don't create any stubs. */
2854 if (section
->output_section
== NULL
2855 || section
->output_section
->owner
!= output_bfd
)
2858 /* Allocate space for the external relocations. */
2860 = ((Elf32_External_Rela
*)
2861 bfd_malloc (section
->reloc_count
2862 * sizeof (Elf32_External_Rela
)));
2863 if (external_relocs
== NULL
)
2865 goto error_ret_free_local
;
2868 /* Likewise for the internal relocations. */
2869 internal_relocs
= ((Elf_Internal_Rela
*)
2870 bfd_malloc (section
->reloc_count
2871 * sizeof (Elf_Internal_Rela
)));
2872 if (internal_relocs
== NULL
)
2874 free (external_relocs
);
2875 goto error_ret_free_local
;
2878 /* Read in the external relocs. */
2879 input_rel_hdr
= &elf_section_data (section
)->rel_hdr
;
2880 if (bfd_seek (input_bfd
, input_rel_hdr
->sh_offset
, SEEK_SET
) != 0
2881 || bfd_read (external_relocs
, 1,
2882 input_rel_hdr
->sh_size
,
2883 input_bfd
) != input_rel_hdr
->sh_size
)
2885 free (external_relocs
);
2886 error_ret_free_internal
:
2887 free (internal_relocs
);
2888 goto error_ret_free_local
;
2891 /* Swap in the relocs. */
2892 erela
= external_relocs
;
2893 erelaend
= erela
+ section
->reloc_count
;
2894 irela
= internal_relocs
;
2895 for (; erela
< erelaend
; erela
++, irela
++)
2896 bfd_elf32_swap_reloca_in (input_bfd
, erela
, irela
);
2898 /* We're done with the external relocs, free them. */
2899 free (external_relocs
);
2901 /* Now examine each relocation. */
2902 irela
= internal_relocs
;
2903 irelaend
= irela
+ section
->reloc_count
;
2904 for (; irela
< irelaend
; irela
++)
2906 unsigned int r_type
, r_indx
;
2907 enum elf32_hppa_stub_type stub_type
;
2908 struct elf32_hppa_stub_hash_entry
*stub_entry
;
2911 bfd_vma destination
;
2912 struct elf32_hppa_link_hash_entry
*hash
;
2914 const asection
*id_sec
;
2916 r_type
= ELF32_R_TYPE (irela
->r_info
);
2917 r_indx
= ELF32_R_SYM (irela
->r_info
);
2919 if (r_type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
2921 bfd_set_error (bfd_error_bad_value
);
2922 goto error_ret_free_internal
;
2925 /* Only look for stubs on call instructions. */
2926 if (r_type
!= (unsigned int) R_PARISC_PCREL12F
2927 && r_type
!= (unsigned int) R_PARISC_PCREL17F
2928 && r_type
!= (unsigned int) R_PARISC_PCREL22F
)
2931 /* Now determine the call target, its name, value,
2937 if (r_indx
< symtab_hdr
->sh_info
)
2939 /* It's a local symbol. */
2940 Elf_Internal_Sym
*sym
;
2941 Elf_Internal_Shdr
*hdr
;
2943 sym
= local_syms
+ r_indx
;
2944 hdr
= elf_elfsections (input_bfd
)[sym
->st_shndx
];
2945 sym_sec
= hdr
->bfd_section
;
2946 if (ELF_ST_TYPE (sym
->st_info
) != STT_SECTION
)
2947 sym_value
= sym
->st_value
;
2948 destination
= (sym_value
+ irela
->r_addend
2949 + sym_sec
->output_offset
2950 + sym_sec
->output_section
->vma
);
2954 /* It's an external symbol. */
2957 e_indx
= r_indx
- symtab_hdr
->sh_info
;
2958 hash
= ((struct elf32_hppa_link_hash_entry
*)
2959 elf_sym_hashes (input_bfd
)[e_indx
]);
2961 while (hash
->elf
.root
.type
== bfd_link_hash_indirect
2962 || hash
->elf
.root
.type
== bfd_link_hash_warning
)
2963 hash
= ((struct elf32_hppa_link_hash_entry
*)
2964 hash
->elf
.root
.u
.i
.link
);
2966 if (hash
->elf
.root
.type
== bfd_link_hash_defined
2967 || hash
->elf
.root
.type
== bfd_link_hash_defweak
)
2969 sym_sec
= hash
->elf
.root
.u
.def
.section
;
2970 sym_value
= hash
->elf
.root
.u
.def
.value
;
2971 if (sym_sec
->output_section
!= NULL
)
2972 destination
= (sym_value
+ irela
->r_addend
2973 + sym_sec
->output_offset
2974 + sym_sec
->output_section
->vma
);
2976 else if (hash
->elf
.root
.type
== bfd_link_hash_undefweak
)
2981 else if (hash
->elf
.root
.type
== bfd_link_hash_undefined
)
2984 && !info
->no_undefined
2985 && (ELF_ST_VISIBILITY (hash
->elf
.other
)
2991 bfd_set_error (bfd_error_bad_value
);
2992 goto error_ret_free_internal
;
2996 /* Determine what (if any) linker stub is needed. */
2997 stub_type
= hppa_type_of_stub (section
, irela
, hash
,
2999 if (stub_type
== hppa_stub_none
)
3002 /* Support for grouping stub sections. */
3003 id_sec
= hplink
->stub_group
[section
->id
].link_sec
;
3005 /* Get the name of this stub. */
3006 stub_name
= hppa_stub_name (id_sec
, sym_sec
, hash
, irela
);
3008 goto error_ret_free_internal
;
3010 stub_entry
= hppa_stub_hash_lookup (&hplink
->stub_hash_table
,
3013 if (stub_entry
!= NULL
)
3015 /* The proper stub has already been created. */
3020 stub_entry
= hppa_add_stub (stub_name
, section
, hplink
);
3021 if (stub_entry
== NULL
)
3024 goto error_ret_free_local
;
3027 stub_entry
->target_value
= sym_value
;
3028 stub_entry
->target_section
= sym_sec
;
3029 stub_entry
->stub_type
= stub_type
;
3032 if (stub_type
== hppa_stub_import
)
3033 stub_entry
->stub_type
= hppa_stub_import_shared
;
3034 else if (stub_type
== hppa_stub_long_branch
3035 && (LONG_BRANCH_PIC_IN_SHLIB
|| hash
== NULL
))
3036 stub_entry
->stub_type
= hppa_stub_long_branch_shared
;
3038 stub_entry
->h
= hash
;
3042 /* We're done with the internal relocs, free them. */
3043 free (internal_relocs
);
3050 /* OK, we've added some stubs. Find out the new size of the
3052 for (stub_sec
= hplink
->stub_bfd
->sections
;
3054 stub_sec
= stub_sec
->next
)
3056 stub_sec
->_raw_size
= 0;
3057 stub_sec
->_cooked_size
= 0;
3059 #if ! LONG_BRANCH_PIC_IN_SHLIB
3063 for (i
= top_id
; i
>= 0; --i
)
3065 /* This will probably hit the same section many times.. */
3066 stub_sec
= hplink
->stub_group
[i
].reloc_sec
;
3067 if (stub_sec
!= NULL
)
3069 stub_sec
->_raw_size
= 0;
3070 stub_sec
->_cooked_size
= 0;
3076 bfd_hash_traverse (&hplink
->stub_hash_table
,
3080 /* Ask the linker to do its stuff. */
3081 (*hplink
->layout_sections_again
) ();
3087 error_ret_free_local
:
3088 while (bfd_count
-- > 0)
3089 if (all_local_syms
[bfd_count
])
3090 free (all_local_syms
[bfd_count
]);
3091 free (all_local_syms
);
3096 /* For a final link, this function is called after we have sized the
3097 stubs to provide a value for __gp. */
3100 elf32_hppa_set_gp (abfd
, info
)
3102 struct bfd_link_info
*info
;
3104 struct elf32_hppa_link_hash_table
*hplink
;
3105 struct elf_link_hash_entry
*h
;
3109 hplink
= hppa_link_hash_table (info
);
3110 h
= elf_link_hash_lookup (&hplink
->root
, "$global$",
3111 false, false, false);
3114 && (h
->root
.type
== bfd_link_hash_defined
3115 || h
->root
.type
== bfd_link_hash_defweak
))
3117 gp_val
= h
->root
.u
.def
.value
;
3118 sec
= h
->root
.u
.def
.section
;
3122 /* Choose to point our LTP at, in this order, one of .plt, .got,
3123 or .data, if these sections exist. In the case of choosing
3124 .plt try to make the LTP ideal for addressing anywhere in the
3125 .plt or .got with a 14 bit signed offset. Typically, the end
3126 of the .plt is the start of the .got, so choose .plt + 0x2000
3127 if either the .plt or .got is larger than 0x2000. If both
3128 the .plt and .got are smaller than 0x2000, choose the end of
3129 the .plt section. */
3134 gp_val
= sec
->_raw_size
;
3136 || (hplink
->sgot
&& hplink
->sgot
->_raw_size
> 0x2000))
3147 /* We know we don't have a .plt. If .got is large,
3149 if (sec
->_raw_size
> 0x2000)
3154 /* No .plt or .got. Who cares what the LTP is? */
3155 sec
= bfd_get_section_by_name (abfd
, ".data");
3161 h
->root
.type
= bfd_link_hash_defined
;
3162 h
->root
.u
.def
.value
= gp_val
;
3164 h
->root
.u
.def
.section
= sec
;
3166 h
->root
.u
.def
.section
= bfd_abs_section_ptr
;
3170 if (sec
!= NULL
&& sec
->output_section
!= NULL
)
3171 gp_val
+= sec
->output_section
->vma
+ sec
->output_offset
;
3173 elf_gp (abfd
) = gp_val
;
3177 /* Build all the stubs associated with the current output file. The
3178 stubs are kept in a hash table attached to the main linker hash
3179 table. We also set up the .plt entries for statically linked PIC
3180 functions here. This function is called via hppaelf_finish in the
3184 elf32_hppa_build_stubs (info
)
3185 struct bfd_link_info
*info
;
3188 struct bfd_hash_table
*table
;
3189 struct elf32_hppa_link_hash_table
*hplink
;
3191 hplink
= hppa_link_hash_table (info
);
3193 for (stub_sec
= hplink
->stub_bfd
->sections
;
3195 stub_sec
= stub_sec
->next
)
3199 /* Allocate memory to hold the linker stubs. */
3200 size
= stub_sec
->_raw_size
;
3201 stub_sec
->contents
= (unsigned char *) bfd_zalloc (hplink
->stub_bfd
,
3203 if (stub_sec
->contents
== NULL
&& size
!= 0)
3205 stub_sec
->_raw_size
= 0;
3208 /* Build the stubs as directed by the stub hash table. */
3209 table
= &hplink
->stub_hash_table
;
3210 bfd_hash_traverse (table
, hppa_build_one_stub
, info
);
3215 /* Perform a final link. */
3218 elf32_hppa_final_link (abfd
, info
)
3220 struct bfd_link_info
*info
;
3224 /* Invoke the regular ELF linker to do all the work. */
3225 if (!bfd_elf32_bfd_final_link (abfd
, info
))
3228 /* If we're producing a final executable, sort the contents of the
3229 unwind section. Magic section names, but this is much safer than
3230 having elf32_hppa_relocate_section remember where SEGREL32 relocs
3231 occurred. Consider what happens if someone inept creates a
3232 linker script that puts unwind information in .text. */
3233 s
= bfd_get_section_by_name (abfd
, ".PARISC.unwind");
3239 size
= s
->_raw_size
;
3240 contents
= bfd_malloc (size
);
3241 if (contents
== NULL
)
3244 if (! bfd_get_section_contents (abfd
, s
, contents
, (file_ptr
) 0, size
))
3247 qsort (contents
, size
/ 16, 16, hppa_unwind_entry_compare
);
3249 if (! bfd_set_section_contents (abfd
, s
, contents
, (file_ptr
) 0, size
))
3255 /* Record the lowest address for the data and text segments. */
3258 hppa_record_segment_addr (abfd
, section
, data
)
3259 bfd
*abfd ATTRIBUTE_UNUSED
;
3263 struct elf32_hppa_link_hash_table
*hplink
;
3265 hplink
= (struct elf32_hppa_link_hash_table
*) data
;
3267 if ((section
->flags
& (SEC_ALLOC
| SEC_LOAD
)) == (SEC_ALLOC
| SEC_LOAD
))
3269 bfd_vma value
= section
->vma
- section
->filepos
;
3271 if ((section
->flags
& SEC_READONLY
) != 0)
3273 if (value
< hplink
->text_segment_base
)
3274 hplink
->text_segment_base
= value
;
3278 if (value
< hplink
->data_segment_base
)
3279 hplink
->data_segment_base
= value
;
3284 /* Perform a relocation as part of a final link. */
3286 static bfd_reloc_status_type
3287 final_link_relocate (input_section
, contents
, rel
, value
, hplink
, sym_sec
, h
)
3288 asection
*input_section
;
3290 const Elf_Internal_Rela
*rel
;
3292 struct elf32_hppa_link_hash_table
*hplink
;
3294 struct elf32_hppa_link_hash_entry
*h
;
3297 unsigned int r_type
= ELF32_R_TYPE (rel
->r_info
);
3298 reloc_howto_type
*howto
= elf_hppa_howto_table
+ r_type
;
3299 int r_format
= howto
->bitsize
;
3300 enum hppa_reloc_field_selector_type_alt r_field
;
3301 bfd
*input_bfd
= input_section
->owner
;
3302 bfd_vma offset
= rel
->r_offset
;
3303 bfd_vma max_branch_offset
= 0;
3304 bfd_byte
*hit_data
= contents
+ offset
;
3305 bfd_signed_vma addend
= rel
->r_addend
;
3307 struct elf32_hppa_stub_hash_entry
*stub_entry
= NULL
;
3310 if (r_type
== R_PARISC_NONE
)
3311 return bfd_reloc_ok
;
3313 insn
= bfd_get_32 (input_bfd
, hit_data
);
3315 /* Find out where we are and where we're going. */
3316 location
= (offset
+
3317 input_section
->output_offset
+
3318 input_section
->output_section
->vma
);
3322 case R_PARISC_PCREL12F
:
3323 case R_PARISC_PCREL17F
:
3324 case R_PARISC_PCREL22F
:
3325 /* If this is a call to a function defined in another dynamic
3326 library, or if it is a call to a PIC function in the same
3327 object, or if this is a shared link and it is a call to a
3328 weak symbol which may or may not be in the same object, then
3329 find the import stub in the stub hash. */
3331 || sym_sec
->output_section
== NULL
3333 && ((h
->maybe_pic_call
3334 && !(input_section
->flags
& SEC_HAS_GOT_REF
))
3335 || (h
->elf
.root
.type
== bfd_link_hash_defweak
3336 && h
->elf
.dynindx
!= -1
3337 && h
->elf
.plt
.offset
!= (bfd_vma
) -1))))
3339 stub_entry
= hppa_get_stub_entry (input_section
, sym_sec
,
3341 if (stub_entry
!= NULL
)
3343 value
= (stub_entry
->stub_offset
3344 + stub_entry
->stub_sec
->output_offset
3345 + stub_entry
->stub_sec
->output_section
->vma
);
3348 else if (sym_sec
== NULL
&& h
!= NULL
3349 && h
->elf
.root
.type
== bfd_link_hash_undefweak
)
3351 /* It's OK if undefined weak. Calls to undefined weak
3352 symbols behave as if the "called" function
3353 immediately returns. We can thus call to a weak
3354 function without first checking whether the function
3360 return bfd_reloc_notsupported
;
3364 case R_PARISC_PCREL21L
:
3365 case R_PARISC_PCREL17C
:
3366 case R_PARISC_PCREL17R
:
3367 case R_PARISC_PCREL14R
:
3368 case R_PARISC_PCREL14F
:
3369 /* Make it a pc relative offset. */
3374 case R_PARISC_DPREL21L
:
3375 case R_PARISC_DPREL14R
:
3376 case R_PARISC_DPREL14F
:
3377 /* For all the DP relative relocations, we need to examine the symbol's
3378 section. If it's a code section, then "data pointer relative" makes
3379 no sense. In that case we don't adjust the "value", and for 21 bit
3380 addil instructions, we change the source addend register from %dp to
3381 %r0. This situation commonly arises when a variable's "constness"
3382 is declared differently from the way the variable is defined. For
3383 instance: "extern int foo" with foo defined as "const int foo". */
3384 if (sym_sec
== NULL
)
3386 if ((sym_sec
->flags
& SEC_CODE
) != 0)
3388 if ((insn
& ((0x3f << 26) | (0x1f << 21)))
3389 == (((int) OP_ADDIL
<< 26) | (27 << 21)))
3391 insn
&= ~ (0x1f << 21);
3392 #if 1 /* debug them. */
3393 (*_bfd_error_handler
)
3394 (_("%s(%s+0x%lx): fixing %s"),
3395 bfd_get_filename (input_bfd
),
3396 input_section
->name
,
3397 (long) rel
->r_offset
,
3401 /* Now try to make things easy for the dynamic linker. */
3407 case R_PARISC_DLTIND21L
:
3408 case R_PARISC_DLTIND14R
:
3409 case R_PARISC_DLTIND14F
:
3410 value
-= elf_gp (input_section
->output_section
->owner
);
3413 case R_PARISC_SEGREL32
:
3414 if ((sym_sec
->flags
& SEC_CODE
) != 0)
3415 value
-= hplink
->text_segment_base
;
3417 value
-= hplink
->data_segment_base
;
3426 case R_PARISC_DIR32
:
3427 case R_PARISC_DIR14F
:
3428 case R_PARISC_DIR17F
:
3429 case R_PARISC_PCREL17C
:
3430 case R_PARISC_PCREL14F
:
3431 case R_PARISC_DPREL14F
:
3432 case R_PARISC_PLABEL32
:
3433 case R_PARISC_DLTIND14F
:
3434 case R_PARISC_SEGBASE
:
3435 case R_PARISC_SEGREL32
:
3439 case R_PARISC_DIR21L
:
3440 case R_PARISC_PCREL21L
:
3441 case R_PARISC_DPREL21L
:
3442 case R_PARISC_PLABEL21L
:
3443 case R_PARISC_DLTIND21L
:
3447 case R_PARISC_DIR17R
:
3448 case R_PARISC_PCREL17R
:
3449 case R_PARISC_DIR14R
:
3450 case R_PARISC_PCREL14R
:
3451 case R_PARISC_DPREL14R
:
3452 case R_PARISC_PLABEL14R
:
3453 case R_PARISC_DLTIND14R
:
3457 case R_PARISC_PCREL12F
:
3458 case R_PARISC_PCREL17F
:
3459 case R_PARISC_PCREL22F
:
3462 if (r_type
== (unsigned int) R_PARISC_PCREL17F
)
3464 max_branch_offset
= (1 << (17-1)) << 2;
3466 else if (r_type
== (unsigned int) R_PARISC_PCREL12F
)
3468 max_branch_offset
= (1 << (12-1)) << 2;
3472 max_branch_offset
= (1 << (22-1)) << 2;
3475 /* sym_sec is NULL on undefined weak syms or when shared on
3476 undefined syms. We've already checked for a stub for the
3477 shared undefined case. */
3478 if (sym_sec
== NULL
)
3481 /* If the branch is out of reach, then redirect the
3482 call to the local stub for this function. */
3483 if (value
+ addend
+ max_branch_offset
>= 2*max_branch_offset
)
3485 stub_entry
= hppa_get_stub_entry (input_section
, sym_sec
,
3487 if (stub_entry
== NULL
)
3488 return bfd_reloc_notsupported
;
3490 /* Munge up the value and addend so that we call the stub
3491 rather than the procedure directly. */
3492 value
= (stub_entry
->stub_offset
3493 + stub_entry
->stub_sec
->output_offset
3494 + stub_entry
->stub_sec
->output_section
->vma
3500 /* Something we don't know how to handle. */
3502 return bfd_reloc_notsupported
;
3505 /* Make sure we can reach the stub. */
3506 if (max_branch_offset
!= 0
3507 && value
+ addend
+ max_branch_offset
>= 2*max_branch_offset
)
3509 (*_bfd_error_handler
)
3510 (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
3511 bfd_get_filename (input_bfd
),
3512 input_section
->name
,
3513 (long) rel
->r_offset
,
3514 stub_entry
->root
.string
);
3515 return bfd_reloc_notsupported
;
3518 val
= hppa_field_adjust (value
, addend
, r_field
);
3522 case R_PARISC_PCREL12F
:
3523 case R_PARISC_PCREL17C
:
3524 case R_PARISC_PCREL17F
:
3525 case R_PARISC_PCREL17R
:
3526 case R_PARISC_PCREL22F
:
3527 case R_PARISC_DIR17F
:
3528 case R_PARISC_DIR17R
:
3529 /* This is a branch. Divide the offset by four.
3530 Note that we need to decide whether it's a branch or
3531 otherwise by inspecting the reloc. Inspecting insn won't
3532 work as insn might be from a .word directive. */
3540 insn
= hppa_rebuild_insn (insn
, val
, r_format
);
3542 /* Update the instruction word. */
3543 bfd_put_32 (input_bfd
, (bfd_vma
) insn
, hit_data
);
3544 return bfd_reloc_ok
;
3547 /* Relocate an HPPA ELF section. */
3550 elf32_hppa_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
3551 contents
, relocs
, local_syms
, local_sections
)
3553 struct bfd_link_info
*info
;
3555 asection
*input_section
;
3557 Elf_Internal_Rela
*relocs
;
3558 Elf_Internal_Sym
*local_syms
;
3559 asection
**local_sections
;
3562 bfd_vma
*local_got_offsets
;
3563 struct elf32_hppa_link_hash_table
*hplink
;
3564 Elf_Internal_Shdr
*symtab_hdr
;
3565 Elf_Internal_Rela
*rel
;
3566 Elf_Internal_Rela
*relend
;
3569 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
3571 hplink
= hppa_link_hash_table (info
);
3572 dynobj
= hplink
->root
.dynobj
;
3573 local_got_offsets
= elf_local_got_offsets (input_bfd
);
3577 relend
= relocs
+ input_section
->reloc_count
;
3578 for (; rel
< relend
; rel
++)
3580 unsigned int r_type
;
3581 reloc_howto_type
*howto
;
3582 unsigned int r_symndx
;
3583 struct elf32_hppa_link_hash_entry
*h
;
3584 Elf_Internal_Sym
*sym
;
3587 bfd_reloc_status_type r
;
3588 const char *sym_name
;
3591 r_type
= ELF32_R_TYPE (rel
->r_info
);
3592 if (r_type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
3594 bfd_set_error (bfd_error_bad_value
);
3597 if (r_type
== (unsigned int) R_PARISC_GNU_VTENTRY
3598 || r_type
== (unsigned int) R_PARISC_GNU_VTINHERIT
)
3601 r_symndx
= ELF32_R_SYM (rel
->r_info
);
3603 if (info
->relocateable
)
3605 /* This is a relocateable link. We don't have to change
3606 anything, unless the reloc is against a section symbol,
3607 in which case we have to adjust according to where the
3608 section symbol winds up in the output section. */
3609 if (r_symndx
< symtab_hdr
->sh_info
)
3611 sym
= local_syms
+ r_symndx
;
3612 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
3614 sym_sec
= local_sections
[r_symndx
];
3615 rel
->r_addend
+= sym_sec
->output_offset
;
3621 /* This is a final link. */
3625 if (r_symndx
< symtab_hdr
->sh_info
)
3627 /* This is a local symbol, h defaults to NULL. */
3628 sym
= local_syms
+ r_symndx
;
3629 sym_sec
= local_sections
[r_symndx
];
3630 relocation
= ((ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
3631 ? 0 : sym
->st_value
)
3632 + sym_sec
->output_offset
3633 + sym_sec
->output_section
->vma
);
3639 /* It's a global; Find its entry in the link hash. */
3640 indx
= r_symndx
- symtab_hdr
->sh_info
;
3641 h
= ((struct elf32_hppa_link_hash_entry
*)
3642 elf_sym_hashes (input_bfd
)[indx
]);
3643 while (h
->elf
.root
.type
== bfd_link_hash_indirect
3644 || h
->elf
.root
.type
== bfd_link_hash_warning
)
3645 h
= (struct elf32_hppa_link_hash_entry
*) h
->elf
.root
.u
.i
.link
;
3648 if (h
->elf
.root
.type
== bfd_link_hash_defined
3649 || h
->elf
.root
.type
== bfd_link_hash_defweak
)
3651 sym_sec
= h
->elf
.root
.u
.def
.section
;
3652 /* If sym_sec->output_section is NULL, then it's a
3653 symbol defined in a shared library. */
3654 if (sym_sec
->output_section
!= NULL
)
3655 relocation
= (h
->elf
.root
.u
.def
.value
3656 + sym_sec
->output_offset
3657 + sym_sec
->output_section
->vma
);
3659 else if (h
->elf
.root
.type
== bfd_link_hash_undefweak
)
3661 else if (info
->shared
&& !info
->no_undefined
3662 && ELF_ST_VISIBILITY (h
->elf
.other
) == STV_DEFAULT
3663 && h
->elf
.type
!= STT_PARISC_MILLI
)
3666 if (!((*info
->callbacks
->undefined_symbol
)
3667 (info
, h
->elf
.root
.root
.string
, input_bfd
,
3668 input_section
, rel
->r_offset
, false)))
3673 if (!((*info
->callbacks
->undefined_symbol
)
3674 (info
, h
->elf
.root
.root
.string
, input_bfd
,
3675 input_section
, rel
->r_offset
, true)))
3680 /* Do any required modifications to the relocation value, and
3681 determine what types of dynamic info we need to output, if
3686 case R_PARISC_DLTIND14F
:
3687 case R_PARISC_DLTIND14R
:
3688 case R_PARISC_DLTIND21L
:
3689 /* Relocation is to the entry for this symbol in the global
3696 off
= h
->elf
.got
.offset
;
3697 if (off
== (bfd_vma
) -1)
3700 dyn
= hplink
->root
.dynamic_sections_created
;
3701 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
, info
, &h
->elf
))
3703 /* This is actually a static link, or it is a
3704 -Bsymbolic link and the symbol is defined
3705 locally, or the symbol was forced to be local
3706 because of a version file. We must initialize
3707 this entry in the global offset table. Since the
3708 offset must always be a multiple of 4, we use the
3709 least significant bit to record whether we have
3710 initialized it already.
3712 When doing a dynamic link, we create a .rela.got
3713 relocation entry to initialize the value. This
3714 is done in the finish_dynamic_symbol routine. */
3719 bfd_put_32 (output_bfd
, relocation
,
3720 hplink
->sgot
->contents
+ off
);
3721 h
->elf
.got
.offset
|= 1;
3729 /* Local symbol case. */
3732 if (local_got_offsets
== NULL
3733 || (off
= local_got_offsets
[r_symndx
]) == (bfd_vma
) -1)
3736 /* The offset must always be a multiple of 4. We use
3737 the least significant bit to record whether we have
3738 already generated the necessary reloc. */
3743 bfd_put_32 (output_bfd
, relocation
,
3744 hplink
->sgot
->contents
+ off
);
3748 /* Output a dynamic relocation for this GOT
3749 entry. In this case it is relative to the
3750 base of the object because the symbol index
3752 Elf_Internal_Rela outrel
;
3753 asection
*srelgot
= hplink
->srelgot
;
3755 outrel
.r_offset
= (off
3756 + hplink
->sgot
->output_offset
3757 + hplink
->sgot
->output_section
->vma
);
3758 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_DIR32
);
3759 outrel
.r_addend
= relocation
;
3760 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
3761 ((Elf32_External_Rela
*)
3763 + srelgot
->reloc_count
));
3764 ++srelgot
->reloc_count
;
3767 local_got_offsets
[r_symndx
] |= 1;
3773 /* Add the base of the GOT to the relocation value. */
3774 relocation
+= (hplink
->sgot
->output_offset
3775 + hplink
->sgot
->output_section
->vma
);
3778 case R_PARISC_SEGREL32
:
3779 /* If this is the first SEGREL relocation, then initialize
3780 the segment base values. */
3781 if (hplink
->text_segment_base
== (bfd_vma
) -1)
3782 bfd_map_over_sections (output_bfd
,
3783 hppa_record_segment_addr
,
3787 case R_PARISC_PLABEL14R
:
3788 case R_PARISC_PLABEL21L
:
3789 case R_PARISC_PLABEL32
:
3790 if (hplink
->root
.dynamic_sections_created
)
3794 /* If we have a global symbol with a PLT slot, then
3795 redirect this relocation to it. */
3798 off
= h
->elf
.plt
.offset
;
3799 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info
, &h
->elf
))
3801 /* In a non-shared link, adjust_dynamic_symbols
3802 isn't called for symbols forced local. We
3803 need to write out the plt entry here. */
3808 bfd_put_32 (output_bfd
,
3810 hplink
->splt
->contents
+ off
);
3811 bfd_put_32 (output_bfd
,
3812 elf_gp (hplink
->splt
->output_section
->owner
),
3813 hplink
->splt
->contents
+ off
+ 4);
3814 h
->elf
.plt
.offset
|= 1;
3822 indx
= r_symndx
+ symtab_hdr
->sh_info
;
3823 off
= local_got_offsets
[indx
];
3825 /* As for the local .got entry case, we use the last
3826 bit to record whether we've already initialised
3827 this local .plt entry. */
3832 bfd_put_32 (output_bfd
,
3834 hplink
->splt
->contents
+ off
);
3835 bfd_put_32 (output_bfd
,
3836 elf_gp (hplink
->splt
->output_section
->owner
),
3837 hplink
->splt
->contents
+ off
+ 4);
3841 /* Output a dynamic IPLT relocation for this
3843 Elf_Internal_Rela outrel
;
3844 asection
*srelplt
= hplink
->srelplt
;
3846 outrel
.r_offset
= (off
3847 + hplink
->splt
->output_offset
3848 + hplink
->splt
->output_section
->vma
);
3849 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_IPLT
);
3850 outrel
.r_addend
= relocation
;
3851 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
3852 ((Elf32_External_Rela
*)
3854 + srelplt
->reloc_count
));
3855 ++srelplt
->reloc_count
;
3858 local_got_offsets
[indx
] |= 1;
3862 if (off
>= (bfd_vma
) -2 || (off
& 1) != 0)
3865 /* PLABELs contain function pointers. Relocation is to
3866 the entry for the function in the .plt. The magic +2
3867 offset signals to $$dyncall that the function pointer
3868 is in the .plt and thus has a gp pointer too.
3869 Exception: Undefined PLABELs should have a value of
3872 || (h
->elf
.root
.type
!= bfd_link_hash_undefweak
3873 && h
->elf
.root
.type
!= bfd_link_hash_undefined
))
3876 + hplink
->splt
->output_offset
3877 + hplink
->splt
->output_section
->vma
3882 /* Fall through and possibly emit a dynamic relocation. */
3884 case R_PARISC_DIR17F
:
3885 case R_PARISC_DIR17R
:
3886 case R_PARISC_DIR14F
:
3887 case R_PARISC_DIR14R
:
3888 case R_PARISC_DIR21L
:
3889 case R_PARISC_DPREL14F
:
3890 case R_PARISC_DPREL14R
:
3891 case R_PARISC_DPREL21L
:
3892 case R_PARISC_DIR32
:
3893 /* The reloc types handled here and this conditional
3894 expression must match the code in check_relocs and
3895 hppa_discard_copies. ie. We need exactly the same
3896 condition as in check_relocs, with some extra conditions
3897 (dynindx test in this case) to cater for relocs removed
3898 by hppa_discard_copies. */
3899 if ((input_section
->flags
& SEC_ALLOC
) != 0
3901 #if RELATIVE_DYNAMIC_RELOCS
3902 && (is_absolute_reloc (r_type
)
3903 || ((!info
->symbolic
3905 && ((h
->elf
.elf_link_hash_flags
3906 & ELF_LINK_HASH_DEF_REGULAR
) == 0
3907 || h
->elf
.root
.type
== bfd_link_hash_defweak
)))
3908 && (h
== NULL
|| h
->elf
.dynindx
!= -1)))
3912 Elf_Internal_Rela outrel
;
3915 /* When generating a shared object, these relocations
3916 are copied into the output file to be resolved at run
3923 name
= (bfd_elf_string_from_elf_section
3925 elf_elfheader (input_bfd
)->e_shstrndx
,
3926 elf_section_data (input_section
)->rel_hdr
.sh_name
));
3929 sreloc
= bfd_get_section_by_name (dynobj
, name
);
3934 outrel
.r_offset
= rel
->r_offset
;
3935 outrel
.r_addend
= rel
->r_addend
;
3937 if (elf_section_data (input_section
)->stab_info
!= NULL
)
3941 off
= (_bfd_stab_section_offset
3942 (output_bfd
, &hplink
->root
.stab_info
,
3944 &elf_section_data (input_section
)->stab_info
,
3946 if (off
== (bfd_vma
) -1)
3948 outrel
.r_offset
= off
;
3951 outrel
.r_offset
+= (input_section
->output_offset
3952 + input_section
->output_section
->vma
);
3956 memset (&outrel
, 0, sizeof (outrel
));
3959 && h
->elf
.dynindx
!= -1
3962 || (h
->elf
.elf_link_hash_flags
3963 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
3965 outrel
.r_info
= ELF32_R_INFO (h
->elf
.dynindx
, r_type
);
3967 else /* It's a local symbol, or one marked to become local. */
3971 /* Add the absolute offset of the symbol. */
3972 outrel
.r_addend
+= relocation
;
3974 /* Global plabels need to be processed by the
3975 dynamic linker so that functions have at most one
3976 fptr. For this reason, we need to differentiate
3977 between global and local plabels, which we do by
3978 providing the function symbol for a global plabel
3979 reloc, and no symbol for local plabels. */
3982 && sym_sec
->output_section
!= NULL
3983 && ! bfd_is_abs_section (sym_sec
))
3985 indx
= elf_section_data (sym_sec
->output_section
)->dynindx
;
3986 /* We are turning this relocation into one
3987 against a section symbol, so subtract out the
3988 output section's address but not the offset
3989 of the input section in the output section. */
3990 outrel
.r_addend
-= sym_sec
->output_section
->vma
;
3993 outrel
.r_info
= ELF32_R_INFO (indx
, r_type
);
3996 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
3997 ((Elf32_External_Rela
*)
3999 + sreloc
->reloc_count
));
4000 ++sreloc
->reloc_count
;
4008 r
= final_link_relocate (input_section
, contents
, rel
, relocation
,
4009 hplink
, sym_sec
, h
);
4011 if (r
== bfd_reloc_ok
)
4015 sym_name
= h
->elf
.root
.root
.string
;
4018 sym_name
= bfd_elf_string_from_elf_section (input_bfd
,
4019 symtab_hdr
->sh_link
,
4021 if (sym_name
== NULL
)
4023 if (*sym_name
== '\0')
4024 sym_name
= bfd_section_name (input_bfd
, sym_sec
);
4027 howto
= elf_hppa_howto_table
+ r_type
;
4029 if (r
== bfd_reloc_undefined
|| r
== bfd_reloc_notsupported
)
4031 (*_bfd_error_handler
)
4032 (_("%s(%s+0x%lx): cannot handle %s for %s"),
4033 bfd_get_filename (input_bfd
),
4034 input_section
->name
,
4035 (long) rel
->r_offset
,
4041 if (!((*info
->callbacks
->reloc_overflow
)
4042 (info
, sym_name
, howto
->name
, (bfd_vma
) 0,
4043 input_bfd
, input_section
, rel
->r_offset
)))
4051 /* Comparison function for qsort to sort unwind section during a
4055 hppa_unwind_entry_compare (a
, b
)
4059 const bfd_byte
*ap
, *bp
;
4060 unsigned long av
, bv
;
4062 ap
= (const bfd_byte
*) a
;
4063 av
= (unsigned long) ap
[0] << 24;
4064 av
|= (unsigned long) ap
[1] << 16;
4065 av
|= (unsigned long) ap
[2] << 8;
4066 av
|= (unsigned long) ap
[3];
4068 bp
= (const bfd_byte
*) b
;
4069 bv
= (unsigned long) bp
[0] << 24;
4070 bv
|= (unsigned long) bp
[1] << 16;
4071 bv
|= (unsigned long) bp
[2] << 8;
4072 bv
|= (unsigned long) bp
[3];
4074 return av
< bv
? -1 : av
> bv
? 1 : 0;
4077 /* Finish up dynamic symbol handling. We set the contents of various
4078 dynamic sections here. */
4081 elf32_hppa_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
4083 struct bfd_link_info
*info
;
4084 struct elf_link_hash_entry
*h
;
4085 Elf_Internal_Sym
*sym
;
4087 struct elf32_hppa_link_hash_table
*hplink
;
4090 hplink
= hppa_link_hash_table (info
);
4091 dynobj
= hplink
->root
.dynobj
;
4093 if (h
->plt
.offset
!= (bfd_vma
) -1)
4097 if (h
->plt
.offset
& 1)
4100 /* This symbol has an entry in the procedure linkage table. Set
4103 The format of a plt entry is
4108 if (h
->root
.type
== bfd_link_hash_defined
4109 || h
->root
.type
== bfd_link_hash_defweak
)
4111 value
= h
->root
.u
.def
.value
;
4112 if (h
->root
.u
.def
.section
->output_section
!= NULL
)
4113 value
+= (h
->root
.u
.def
.section
->output_offset
4114 + h
->root
.u
.def
.section
->output_section
->vma
);
4117 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->pic_call
)
4119 Elf_Internal_Rela rel
;
4121 /* Create a dynamic IPLT relocation for this entry. */
4122 rel
.r_offset
= (h
->plt
.offset
4123 + hplink
->splt
->output_offset
4124 + hplink
->splt
->output_section
->vma
);
4125 if (! ((struct elf32_hppa_link_hash_entry
*) h
)->plt_abs
4126 && h
->dynindx
!= -1)
4128 /* To support lazy linking, the function pointer is
4129 initialised to point to a special stub stored at the
4130 end of the .plt. This is not done for plt entries
4131 with a base-relative dynamic relocation. */
4132 value
= (hplink
->splt
->output_offset
4133 + hplink
->splt
->output_section
->vma
4134 + hplink
->splt
->_raw_size
4137 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_PARISC_IPLT
);
4142 /* This symbol has been marked to become local, and is
4143 used by a plabel so must be kept in the .plt. */
4144 rel
.r_info
= ELF32_R_INFO (0, R_PARISC_IPLT
);
4145 rel
.r_addend
= value
;
4148 bfd_elf32_swap_reloca_out (hplink
->splt
->output_section
->owner
,
4150 ((Elf32_External_Rela
*)
4151 hplink
->srelplt
->contents
4152 + hplink
->srelplt
->reloc_count
));
4153 hplink
->srelplt
->reloc_count
++;
4156 bfd_put_32 (hplink
->splt
->owner
,
4158 hplink
->splt
->contents
+ h
->plt
.offset
);
4159 bfd_put_32 (hplink
->splt
->owner
,
4160 elf_gp (hplink
->splt
->output_section
->owner
),
4161 hplink
->splt
->contents
+ h
->plt
.offset
+ 4);
4162 if (PLABEL_PLT_ENTRY_SIZE
!= PLT_ENTRY_SIZE
4163 && ((struct elf32_hppa_link_hash_entry
*) h
)->plabel
4164 && h
->dynindx
!= -1)
4166 memset (hplink
->splt
->contents
+ h
->plt
.offset
+ 8,
4167 0, PLABEL_PLT_ENTRY_SIZE
- PLT_ENTRY_SIZE
);
4170 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
4172 /* Mark the symbol as undefined, rather than as defined in
4173 the .plt section. Leave the value alone. */
4174 sym
->st_shndx
= SHN_UNDEF
;
4178 if (h
->got
.offset
!= (bfd_vma
) -1)
4180 Elf_Internal_Rela rel
;
4182 /* This symbol has an entry in the global offset table. Set it
4185 rel
.r_offset
= ((h
->got
.offset
&~ (bfd_vma
) 1)
4186 + hplink
->sgot
->output_offset
4187 + hplink
->sgot
->output_section
->vma
);
4189 /* If this is a -Bsymbolic link and the symbol is defined
4190 locally or was forced to be local because of a version file,
4191 we just want to emit a RELATIVE reloc. The entry in the
4192 global offset table will already have been initialized in the
4193 relocate_section function. */
4195 && (info
->symbolic
|| h
->dynindx
== -1)
4196 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
))
4198 rel
.r_info
= ELF32_R_INFO (0, R_PARISC_DIR32
);
4199 rel
.r_addend
= (h
->root
.u
.def
.value
4200 + h
->root
.u
.def
.section
->output_offset
4201 + h
->root
.u
.def
.section
->output_section
->vma
);
4205 if ((h
->got
.offset
& 1) != 0)
4207 bfd_put_32 (output_bfd
, (bfd_vma
) 0,
4208 hplink
->sgot
->contents
+ h
->got
.offset
);
4209 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_PARISC_DIR32
);
4213 bfd_elf32_swap_reloca_out (output_bfd
, &rel
,
4214 ((Elf32_External_Rela
*)
4215 hplink
->srelgot
->contents
4216 + hplink
->srelgot
->reloc_count
));
4217 ++hplink
->srelgot
->reloc_count
;
4220 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
4223 Elf_Internal_Rela rel
;
4225 /* This symbol needs a copy reloc. Set it up. */
4227 if (! (h
->dynindx
!= -1
4228 && (h
->root
.type
== bfd_link_hash_defined
4229 || h
->root
.type
== bfd_link_hash_defweak
)))
4232 s
= hplink
->srelbss
;
4234 rel
.r_offset
= (h
->root
.u
.def
.value
4235 + h
->root
.u
.def
.section
->output_offset
4236 + h
->root
.u
.def
.section
->output_section
->vma
);
4238 rel
.r_info
= ELF32_R_INFO (h
->dynindx
, R_PARISC_COPY
);
4239 bfd_elf32_swap_reloca_out (output_bfd
, &rel
,
4240 ((Elf32_External_Rela
*) s
->contents
4245 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
4246 if (h
->root
.root
.string
[0] == '_'
4247 && (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
4248 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0))
4250 sym
->st_shndx
= SHN_ABS
;
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
*hplink
;
4267 hplink
= hppa_link_hash_table (info
);
4268 dynobj
= hplink
->root
.dynobj
;
4270 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
4272 if (hplink
->root
.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
);
4296 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4300 s
= hplink
->srelplt
;
4301 dyn
.d_un
.d_ptr
= s
->output_section
->vma
+ s
->output_offset
;
4302 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4306 s
= hplink
->srelplt
;
4307 if (s
->_cooked_size
!= 0)
4308 dyn
.d_un
.d_val
= s
->_cooked_size
;
4310 dyn
.d_un
.d_val
= s
->_raw_size
;
4311 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4317 if (hplink
->sgot
->_raw_size
!= 0)
4319 /* Fill in the first entry in the global offset table.
4320 We use it to point to our dynamic section, if we have one. */
4321 bfd_put_32 (output_bfd
,
4323 ? sdyn
->output_section
->vma
+ sdyn
->output_offset
4325 hplink
->sgot
->contents
);
4327 /* The second entry is reserved for use by the dynamic linker. */
4328 memset (hplink
->sgot
->contents
+ GOT_ENTRY_SIZE
, 0, GOT_ENTRY_SIZE
);
4330 /* Set .got entry size. */
4331 elf_section_data (hplink
->sgot
->output_section
)
4332 ->this_hdr
.sh_entsize
= GOT_ENTRY_SIZE
;
4335 if (hplink
->splt
->_raw_size
!= 0)
4337 /* Set plt entry size. */
4338 elf_section_data (hplink
->splt
->output_section
)
4339 ->this_hdr
.sh_entsize
= PLT_ENTRY_SIZE
;
4341 if (hplink
->need_plt_stub
)
4343 /* Set up the .plt stub. */
4344 memcpy (hplink
->splt
->contents
4345 + hplink
->splt
->_raw_size
- sizeof (plt_stub
),
4346 plt_stub
, sizeof (plt_stub
));
4348 if ((hplink
->splt
->output_offset
4349 + hplink
->splt
->output_section
->vma
4350 + hplink
->splt
->_raw_size
)
4351 != (hplink
->sgot
->output_offset
4352 + hplink
->sgot
->output_section
->vma
))
4354 (*_bfd_error_handler
)
4355 (_(".got section not immediately after .plt section"));
4364 /* Tweak the OSABI field of the elf header. */
4367 elf32_hppa_post_process_headers (abfd
, link_info
)
4369 struct bfd_link_info
*link_info ATTRIBUTE_UNUSED
;
4371 Elf_Internal_Ehdr
* i_ehdrp
;
4373 i_ehdrp
= elf_elfheader (abfd
);
4375 if (strcmp (bfd_get_target (abfd
), "elf32-hppa-linux") == 0)
4377 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_LINUX
;
4381 i_ehdrp
->e_ident
[EI_OSABI
] = ELFOSABI_HPUX
;
4385 /* Called when writing out an object file to decide the type of a
4388 elf32_hppa_elf_get_symbol_type (elf_sym
, type
)
4389 Elf_Internal_Sym
*elf_sym
;
4392 if (ELF_ST_TYPE (elf_sym
->st_info
) == STT_PARISC_MILLI
)
4393 return STT_PARISC_MILLI
;
4398 /* Misc BFD support code. */
4399 #define bfd_elf32_bfd_is_local_label_name elf_hppa_is_local_label_name
4400 #define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup
4401 #define elf_info_to_howto elf_hppa_info_to_howto
4402 #define elf_info_to_howto_rel elf_hppa_info_to_howto_rel
4404 /* Stuff for the BFD linker. */
4405 #define bfd_elf32_bfd_final_link elf32_hppa_final_link
4406 #define bfd_elf32_bfd_link_hash_table_create elf32_hppa_link_hash_table_create
4407 #define elf_backend_add_symbol_hook elf32_hppa_add_symbol_hook
4408 #define elf_backend_adjust_dynamic_symbol elf32_hppa_adjust_dynamic_symbol
4409 #define elf_backend_check_relocs elf32_hppa_check_relocs
4410 #define elf_backend_create_dynamic_sections elf32_hppa_create_dynamic_sections
4411 #define elf_backend_fake_sections elf_hppa_fake_sections
4412 #define elf_backend_relocate_section elf32_hppa_relocate_section
4413 #define elf_backend_hide_symbol elf32_hppa_hide_symbol
4414 #define elf_backend_finish_dynamic_symbol elf32_hppa_finish_dynamic_symbol
4415 #define elf_backend_finish_dynamic_sections elf32_hppa_finish_dynamic_sections
4416 #define elf_backend_size_dynamic_sections elf32_hppa_size_dynamic_sections
4417 #define elf_backend_gc_mark_hook elf32_hppa_gc_mark_hook
4418 #define elf_backend_gc_sweep_hook elf32_hppa_gc_sweep_hook
4419 #define elf_backend_object_p elf32_hppa_object_p
4420 #define elf_backend_final_write_processing elf_hppa_final_write_processing
4421 #define elf_backend_post_process_headers elf32_hppa_post_process_headers
4422 #define elf_backend_get_symbol_type elf32_hppa_elf_get_symbol_type
4424 #define elf_backend_can_gc_sections 1
4425 #define elf_backend_plt_alignment 2
4426 #define elf_backend_want_got_plt 0
4427 #define elf_backend_plt_readonly 0
4428 #define elf_backend_want_plt_sym 0
4429 #define elf_backend_got_header_size 8
4431 #define TARGET_BIG_SYM bfd_elf32_hppa_vec
4432 #define TARGET_BIG_NAME "elf32-hppa"
4433 #define ELF_ARCH bfd_arch_hppa
4434 #define ELF_MACHINE_CODE EM_PARISC
4435 #define ELF_MAXPAGESIZE 0x1000
4437 #include "elf32-target.h"
4439 #undef TARGET_BIG_SYM
4440 #define TARGET_BIG_SYM bfd_elf32_hppa_linux_vec
4441 #undef TARGET_BIG_NAME
4442 #define TARGET_BIG_NAME "elf32-hppa-linux"
4444 #define INCLUDED_TARGET_FILE 1
4445 #include "elf32-target.h"