1 /* BFD back-end for HP PA-RISC ELF files.
2 Copyright (C) 1990-2020 Free Software Foundation, Inc.
5 Center for Software Science
6 Department of Computer Science
8 Largely rewritten by Alan Modra <alan@linuxcare.com.au>
9 Naming cleanup by Carlos O'Donell <carlos@systemhalted.org>
10 TLS support written by Randolph Chung <tausq@debian.org>
12 This file is part of BFD, the Binary File Descriptor library.
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
27 MA 02110-1301, USA. */
35 #include "elf32-hppa.h"
37 #include "elf32-hppa.h"
40 /* In order to gain some understanding of code in this file without
41 knowing all the intricate details of the linker, note the
44 Functions named elf32_hppa_* are called by external routines, other
45 functions are only called locally. elf32_hppa_* functions appear
46 in this file more or less in the order in which they are called
47 from external routines. eg. elf32_hppa_check_relocs is called
48 early in the link process, elf32_hppa_finish_dynamic_sections is
49 one of the last functions. */
51 /* We use two hash tables to hold information for linking PA ELF objects.
53 The first is the elf32_hppa_link_hash_table which is derived
54 from the standard ELF linker hash table. We use this as a place to
55 attach other hash tables and static information.
57 The second is the stub hash table which is derived from the
58 base BFD hash table. The stub hash table holds the information
59 necessary to build the linker stubs during a link.
61 There are a number of different stubs generated by the linker.
69 : addil LR'X - ($PIC_pcrel$0 - 4),%r1
70 : be,n RR'X - ($PIC_pcrel$0 - 8)(%sr4,%r1)
72 Import stub to call shared library routine from normal object file
73 (single sub-space version)
74 : addil LR'lt_ptr+ltoff,%dp ; get PLT address
75 : ldo RR'lt_ptr+ltoff(%r1),%r22 ;
76 : ldw 0(%r22),%r21 ; get procedure entry point
78 : ldw 4(%r22),%r19 ; get new dlt value.
80 Import stub to call shared library routine from shared library
81 (single sub-space version)
82 : addil LR'ltoff,%r19 ; get PLT address
83 : ldo RR'ltoff(%r1),%r22
84 : ldw 0(%r22),%r21 ; get procedure entry point
86 : ldw 4(%r22),%r19 ; get new dlt value.
88 Import stub to call shared library routine from normal object file
89 (multiple sub-space support)
90 : addil LR'lt_ptr+ltoff,%dp ; get PLT address
91 : ldo RR'lt_ptr+ltoff(%r1),%r22 ;
92 : ldw 0(%r22),%r21 ; get procedure entry point
93 : ldsid (%r21),%r1 ; get target sid
94 : ldw 4(%r22),%r19 ; get new dlt value.
96 : be 0(%sr0,%r21) ; branch to target
97 : stw %rp,-24(%sp) ; save rp
99 Import stub to call shared library routine from shared library
100 (multiple sub-space support)
101 : addil LR'ltoff,%r19 ; get PLT address
102 : ldo RR'ltoff(%r1),%r22
103 : ldw 0(%r22),%r21 ; get procedure entry point
104 : ldsid (%r21),%r1 ; get target sid
105 : ldw 4(%r22),%r19 ; get new dlt value.
107 : be 0(%sr0,%r21) ; branch to target
108 : stw %rp,-24(%sp) ; save rp
110 Export stub to return from shared lib routine (multiple sub-space support)
111 One of these is created for each exported procedure in a shared
112 library (and stored in the shared lib). Shared lib routines are
113 called via the first instruction in the export stub so that we can
114 do an inter-space return. Not required for single sub-space.
115 : bl,n X,%rp ; trap the return
117 : ldw -24(%sp),%rp ; restore the original rp
120 : be,n 0(%sr0,%rp) ; inter-space return. */
123 /* Variable names follow a coding style.
124 Please follow this (Apps Hungarian) style:
126 Structure/Variable Prefix
127 elf_link_hash_table "etab"
128 elf_link_hash_entry "eh"
130 elf32_hppa_link_hash_table "htab"
131 elf32_hppa_link_hash_entry "hh"
133 bfd_hash_table "btab"
136 bfd_hash_table containing stubs "bstab"
137 elf32_hppa_stub_hash_entry "hsh"
139 Always remember to use GNU Coding Style. */
141 #define PLT_ENTRY_SIZE 8
142 #define GOT_ENTRY_SIZE 4
143 #define LONG_BRANCH_STUB_SIZE 8
144 #define LONG_BRANCH_SHARED_STUB_SIZE 12
145 #define IMPORT_STUB_SIZE 20
146 #define IMPORT_SHARED_STUB_SIZE 32
147 #define EXPORT_STUB_SIZE 24
148 #define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1"
150 static const bfd_byte plt_stub
[] =
152 0x0e, 0x80, 0x10, 0x95, /* 1: ldw 0(%r20),%r21 */
153 0xea, 0xa0, 0xc0, 0x00, /* bv %r0(%r21) */
154 0x0e, 0x88, 0x10, 0x95, /* ldw 4(%r20),%r21 */
155 #define PLT_STUB_ENTRY (3*4)
156 0xea, 0x9f, 0x1f, 0xdd, /* b,l 1b,%r20 */
157 0xd6, 0x80, 0x1c, 0x1e, /* depi 0,31,2,%r20 */
158 0x00, 0xc0, 0xff, 0xee, /* 9: .word fixup_func */
159 0xde, 0xad, 0xbe, 0xef /* .word fixup_ltp */
162 /* Section name for stubs is the associated section name plus this
164 #define STUB_SUFFIX ".stub"
166 /* We don't need to copy certain PC- or GP-relative dynamic relocs
167 into a shared object's dynamic section. All the relocs of the
168 limited class we are interested in, are absolute. */
169 #ifndef RELATIVE_DYNRELOCS
170 #define RELATIVE_DYNRELOCS 0
171 #define IS_ABSOLUTE_RELOC(r_type) 1
172 #define pc_dynrelocs(hh) 0
175 /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
176 copying dynamic variables from a shared lib into an app's dynbss
177 section, and instead use a dynamic relocation to point into the
179 #define ELIMINATE_COPY_RELOCS 1
181 enum elf32_hppa_stub_type
183 hppa_stub_long_branch
,
184 hppa_stub_long_branch_shared
,
186 hppa_stub_import_shared
,
191 struct elf32_hppa_stub_hash_entry
193 /* Base hash table entry structure. */
194 struct bfd_hash_entry bh_root
;
196 /* The stub section. */
199 /* Offset within stub_sec of the beginning of this stub. */
202 /* Given the symbol's value and its section we can determine its final
203 value when building the stubs (so the stub knows where to jump. */
204 bfd_vma target_value
;
205 asection
*target_section
;
207 enum elf32_hppa_stub_type stub_type
;
209 /* The symbol table entry, if any, that this was derived from. */
210 struct elf32_hppa_link_hash_entry
*hh
;
212 /* Where this stub is being called from, or, in the case of combined
213 stub sections, the first input section in the group. */
226 struct elf32_hppa_link_hash_entry
228 struct elf_link_hash_entry eh
;
230 /* A pointer to the most recently used stub hash entry against this
232 struct elf32_hppa_stub_hash_entry
*hsh_cache
;
234 ENUM_BITFIELD (_tls_type
) tls_type
: 8;
236 /* Set if this symbol is used by a plabel reloc. */
237 unsigned int plabel
:1;
240 struct elf32_hppa_link_hash_table
242 /* The main hash table. */
243 struct elf_link_hash_table etab
;
245 /* The stub hash table. */
246 struct bfd_hash_table bstab
;
248 /* Linker stub bfd. */
251 /* Linker call-backs. */
252 asection
* (*add_stub_section
) (const char *, asection
*);
253 void (*layout_sections_again
) (void);
255 /* Array to keep track of which stub sections have been created, and
256 information on stub grouping. */
259 /* This is the section to which stubs in the group will be
262 /* The stub section. */
266 /* Assorted information used by elf32_hppa_size_stubs. */
267 unsigned int bfd_count
;
268 unsigned int top_index
;
269 asection
**input_list
;
270 Elf_Internal_Sym
**all_local_syms
;
272 /* Used during a final link to store the base of the text and data
273 segments so that we can perform SEGREL relocations. */
274 bfd_vma text_segment_base
;
275 bfd_vma data_segment_base
;
277 /* Whether we support multiple sub-spaces for shared libs. */
278 unsigned int multi_subspace
:1;
280 /* Flags set when various size branches are detected. Used to
281 select suitable defaults for the stub group size. */
282 unsigned int has_12bit_branch
:1;
283 unsigned int has_17bit_branch
:1;
284 unsigned int has_22bit_branch
:1;
286 /* Set if we need a .plt stub to support lazy dynamic linking. */
287 unsigned int need_plt_stub
:1;
289 /* Data for LDM relocations. */
292 bfd_signed_vma refcount
;
297 /* Various hash macros and functions. */
298 #define hppa_link_hash_table(p) \
299 ((is_elf_hash_table ((p)->hash) \
300 && elf_hash_table_id (elf_hash_table (p)) == HPPA32_ELF_DATA) \
301 ? (struct elf32_hppa_link_hash_table *) (p)->hash : NULL)
303 #define hppa_elf_hash_entry(ent) \
304 ((struct elf32_hppa_link_hash_entry *)(ent))
306 #define hppa_stub_hash_entry(ent) \
307 ((struct elf32_hppa_stub_hash_entry *)(ent))
309 #define hppa_stub_hash_lookup(table, string, create, copy) \
310 ((struct elf32_hppa_stub_hash_entry *) \
311 bfd_hash_lookup ((table), (string), (create), (copy)))
313 #define hppa_elf_local_got_tls_type(abfd) \
314 ((char *)(elf_local_got_offsets (abfd) + (elf_tdata (abfd)->symtab_hdr.sh_info * 2)))
316 #define hh_name(hh) \
317 (hh ? hh->eh.root.root.string : "<undef>")
319 #define eh_name(eh) \
320 (eh ? eh->root.root.string : "<undef>")
322 /* Assorted hash table functions. */
324 /* Initialize an entry in the stub hash table. */
326 static struct bfd_hash_entry
*
327 stub_hash_newfunc (struct bfd_hash_entry
*entry
,
328 struct bfd_hash_table
*table
,
331 /* Allocate the structure if it has not already been allocated by a
335 entry
= bfd_hash_allocate (table
,
336 sizeof (struct elf32_hppa_stub_hash_entry
));
341 /* Call the allocation method of the superclass. */
342 entry
= bfd_hash_newfunc (entry
, table
, string
);
345 struct elf32_hppa_stub_hash_entry
*hsh
;
347 /* Initialize the local fields. */
348 hsh
= hppa_stub_hash_entry (entry
);
349 hsh
->stub_sec
= NULL
;
350 hsh
->stub_offset
= 0;
351 hsh
->target_value
= 0;
352 hsh
->target_section
= NULL
;
353 hsh
->stub_type
= hppa_stub_long_branch
;
361 /* Initialize an entry in the link hash table. */
363 static struct bfd_hash_entry
*
364 hppa_link_hash_newfunc (struct bfd_hash_entry
*entry
,
365 struct bfd_hash_table
*table
,
368 /* Allocate the structure if it has not already been allocated by a
372 entry
= bfd_hash_allocate (table
,
373 sizeof (struct elf32_hppa_link_hash_entry
));
378 /* Call the allocation method of the superclass. */
379 entry
= _bfd_elf_link_hash_newfunc (entry
, table
, string
);
382 struct elf32_hppa_link_hash_entry
*hh
;
384 /* Initialize the local fields. */
385 hh
= hppa_elf_hash_entry (entry
);
386 hh
->hsh_cache
= NULL
;
388 hh
->tls_type
= GOT_UNKNOWN
;
394 /* Free the derived linker hash table. */
397 elf32_hppa_link_hash_table_free (bfd
*obfd
)
399 struct elf32_hppa_link_hash_table
*htab
400 = (struct elf32_hppa_link_hash_table
*) obfd
->link
.hash
;
402 bfd_hash_table_free (&htab
->bstab
);
403 _bfd_elf_link_hash_table_free (obfd
);
406 /* Create the derived linker hash table. The PA ELF port uses the derived
407 hash table to keep information specific to the PA ELF linker (without
408 using static variables). */
410 static struct bfd_link_hash_table
*
411 elf32_hppa_link_hash_table_create (bfd
*abfd
)
413 struct elf32_hppa_link_hash_table
*htab
;
414 size_t amt
= sizeof (*htab
);
416 htab
= bfd_zmalloc (amt
);
420 if (!_bfd_elf_link_hash_table_init (&htab
->etab
, abfd
, hppa_link_hash_newfunc
,
421 sizeof (struct elf32_hppa_link_hash_entry
),
428 /* Init the stub hash table too. */
429 if (!bfd_hash_table_init (&htab
->bstab
, stub_hash_newfunc
,
430 sizeof (struct elf32_hppa_stub_hash_entry
)))
432 _bfd_elf_link_hash_table_free (abfd
);
435 htab
->etab
.root
.hash_table_free
= elf32_hppa_link_hash_table_free
;
436 htab
->etab
.dt_pltgot_required
= TRUE
;
438 htab
->text_segment_base
= (bfd_vma
) -1;
439 htab
->data_segment_base
= (bfd_vma
) -1;
440 return &htab
->etab
.root
;
443 /* Initialize the linker stubs BFD so that we can use it for linker
444 created dynamic sections. */
447 elf32_hppa_init_stub_bfd (bfd
*abfd
, struct bfd_link_info
*info
)
449 struct elf32_hppa_link_hash_table
*htab
= hppa_link_hash_table (info
);
451 elf_elfheader (abfd
)->e_ident
[EI_CLASS
] = ELFCLASS32
;
452 htab
->etab
.dynobj
= abfd
;
455 /* Build a name for an entry in the stub hash table. */
458 hppa_stub_name (const asection
*input_section
,
459 const asection
*sym_sec
,
460 const struct elf32_hppa_link_hash_entry
*hh
,
461 const Elf_Internal_Rela
*rela
)
468 len
= 8 + 1 + strlen (hh_name (hh
)) + 1 + 8 + 1;
469 stub_name
= bfd_malloc (len
);
470 if (stub_name
!= NULL
)
471 sprintf (stub_name
, "%08x_%s+%x",
472 input_section
->id
& 0xffffffff,
474 (int) rela
->r_addend
& 0xffffffff);
478 len
= 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1;
479 stub_name
= bfd_malloc (len
);
480 if (stub_name
!= NULL
)
481 sprintf (stub_name
, "%08x_%x:%x+%x",
482 input_section
->id
& 0xffffffff,
483 sym_sec
->id
& 0xffffffff,
484 (int) ELF32_R_SYM (rela
->r_info
) & 0xffffffff,
485 (int) rela
->r_addend
& 0xffffffff);
490 /* Look up an entry in the stub hash. Stub entries are cached because
491 creating the stub name takes a bit of time. */
493 static struct elf32_hppa_stub_hash_entry
*
494 hppa_get_stub_entry (const asection
*input_section
,
495 const asection
*sym_sec
,
496 struct elf32_hppa_link_hash_entry
*hh
,
497 const Elf_Internal_Rela
*rela
,
498 struct elf32_hppa_link_hash_table
*htab
)
500 struct elf32_hppa_stub_hash_entry
*hsh_entry
;
501 const asection
*id_sec
;
503 /* If this input section is part of a group of sections sharing one
504 stub section, then use the id of the first section in the group.
505 Stub names need to include a section id, as there may well be
506 more than one stub used to reach say, printf, and we need to
507 distinguish between them. */
508 id_sec
= htab
->stub_group
[input_section
->id
].link_sec
;
512 if (hh
!= NULL
&& hh
->hsh_cache
!= NULL
513 && hh
->hsh_cache
->hh
== hh
514 && hh
->hsh_cache
->id_sec
== id_sec
)
516 hsh_entry
= hh
->hsh_cache
;
522 stub_name
= hppa_stub_name (id_sec
, sym_sec
, hh
, rela
);
523 if (stub_name
== NULL
)
526 hsh_entry
= hppa_stub_hash_lookup (&htab
->bstab
,
527 stub_name
, FALSE
, FALSE
);
529 hh
->hsh_cache
= hsh_entry
;
537 /* Add a new stub entry to the stub hash. Not all fields of the new
538 stub entry are initialised. */
540 static struct elf32_hppa_stub_hash_entry
*
541 hppa_add_stub (const char *stub_name
,
543 struct elf32_hppa_link_hash_table
*htab
)
547 struct elf32_hppa_stub_hash_entry
*hsh
;
549 link_sec
= htab
->stub_group
[section
->id
].link_sec
;
550 stub_sec
= htab
->stub_group
[section
->id
].stub_sec
;
551 if (stub_sec
== NULL
)
553 stub_sec
= htab
->stub_group
[link_sec
->id
].stub_sec
;
554 if (stub_sec
== NULL
)
560 namelen
= strlen (link_sec
->name
);
561 len
= namelen
+ sizeof (STUB_SUFFIX
);
562 s_name
= bfd_alloc (htab
->stub_bfd
, len
);
566 memcpy (s_name
, link_sec
->name
, namelen
);
567 memcpy (s_name
+ namelen
, STUB_SUFFIX
, sizeof (STUB_SUFFIX
));
568 stub_sec
= (*htab
->add_stub_section
) (s_name
, link_sec
);
569 if (stub_sec
== NULL
)
571 htab
->stub_group
[link_sec
->id
].stub_sec
= stub_sec
;
573 htab
->stub_group
[section
->id
].stub_sec
= stub_sec
;
576 /* Enter this entry into the linker stub hash table. */
577 hsh
= hppa_stub_hash_lookup (&htab
->bstab
, stub_name
,
581 /* xgettext:c-format */
582 _bfd_error_handler (_("%pB: cannot create stub entry %s"),
583 section
->owner
, stub_name
);
587 hsh
->stub_sec
= stub_sec
;
588 hsh
->stub_offset
= 0;
589 hsh
->id_sec
= link_sec
;
593 /* Determine the type of stub needed, if any, for a call. */
595 static enum elf32_hppa_stub_type
596 hppa_type_of_stub (asection
*input_sec
,
597 const Elf_Internal_Rela
*rela
,
598 struct elf32_hppa_link_hash_entry
*hh
,
600 struct bfd_link_info
*info
)
603 bfd_vma branch_offset
;
604 bfd_vma max_branch_offset
;
608 && hh
->eh
.plt
.offset
!= (bfd_vma
) -1
609 && hh
->eh
.dynindx
!= -1
611 && (bfd_link_pic (info
)
612 || !hh
->eh
.def_regular
613 || hh
->eh
.root
.type
== bfd_link_hash_defweak
))
615 /* We need an import stub. Decide between hppa_stub_import
616 and hppa_stub_import_shared later. */
617 return hppa_stub_import
;
620 if (destination
== (bfd_vma
) -1)
621 return hppa_stub_none
;
623 /* Determine where the call point is. */
624 location
= (input_sec
->output_offset
625 + input_sec
->output_section
->vma
628 branch_offset
= destination
- location
- 8;
629 r_type
= ELF32_R_TYPE (rela
->r_info
);
631 /* Determine if a long branch stub is needed. parisc branch offsets
632 are relative to the second instruction past the branch, ie. +8
633 bytes on from the branch instruction location. The offset is
634 signed and counts in units of 4 bytes. */
635 if (r_type
== (unsigned int) R_PARISC_PCREL17F
)
636 max_branch_offset
= (1 << (17 - 1)) << 2;
638 else if (r_type
== (unsigned int) R_PARISC_PCREL12F
)
639 max_branch_offset
= (1 << (12 - 1)) << 2;
641 else /* R_PARISC_PCREL22F. */
642 max_branch_offset
= (1 << (22 - 1)) << 2;
644 if (branch_offset
+ max_branch_offset
>= 2*max_branch_offset
)
645 return hppa_stub_long_branch
;
647 return hppa_stub_none
;
650 /* Build one linker stub as defined by the stub hash table entry GEN_ENTRY.
651 IN_ARG contains the link info pointer. */
653 #define LDIL_R1 0x20200000 /* ldil LR'XXX,%r1 */
654 #define BE_SR4_R1 0xe0202002 /* be,n RR'XXX(%sr4,%r1) */
656 #define BL_R1 0xe8200000 /* b,l .+8,%r1 */
657 #define ADDIL_R1 0x28200000 /* addil LR'XXX,%r1,%r1 */
658 #define DEPI_R1 0xd4201c1e /* depi 0,31,2,%r1 */
660 #define ADDIL_DP 0x2b600000 /* addil LR'XXX,%dp,%r1 */
661 #define LDW_R1_R21 0x48350000 /* ldw RR'XXX(%sr0,%r1),%r21 */
662 #define BV_R0_R21 0xeaa0c000 /* bv %r0(%r21) */
663 #define LDW_R1_R19 0x48330000 /* ldw RR'XXX(%sr0,%r1),%r19 */
665 #define ADDIL_R19 0x2a600000 /* addil LR'XXX,%r19,%r1 */
666 #define LDW_R1_DP 0x483b0000 /* ldw RR'XXX(%sr0,%r1),%dp */
668 #define LDO_R1_R22 0x34360000 /* ldo RR'XXX(%r1),%r22 */
669 #define LDW_R22_R21 0x0ec01095 /* ldw 0(%r22),%r21 */
670 #define LDW_R22_R19 0x0ec81093 /* ldw 4(%r22),%r19 */
672 #define LDSID_R21_R1 0x02a010a1 /* ldsid (%sr0,%r21),%r1 */
673 #define MTSP_R1 0x00011820 /* mtsp %r1,%sr0 */
674 #define BE_SR0_R21 0xe2a00000 /* be 0(%sr0,%r21) */
675 #define STW_RP 0x6bc23fd1 /* stw %rp,-24(%sr0,%sp) */
677 #define BL22_RP 0xe800a002 /* b,l,n XXX,%rp */
678 #define BL_RP 0xe8400002 /* b,l,n XXX,%rp */
679 #define NOP 0x08000240 /* nop */
680 #define LDW_RP 0x4bc23fd1 /* ldw -24(%sr0,%sp),%rp */
681 #define LDSID_RP_R1 0x004010a1 /* ldsid (%sr0,%rp),%r1 */
682 #define BE_SR0_RP 0xe0400002 /* be,n 0(%sr0,%rp) */
689 #define LDW_R1_DLT LDW_R1_R19
691 #define LDW_R1_DLT LDW_R1_DP
695 hppa_build_one_stub (struct bfd_hash_entry
*bh
, void *in_arg
)
697 struct elf32_hppa_stub_hash_entry
*hsh
;
698 struct bfd_link_info
*info
;
699 struct elf32_hppa_link_hash_table
*htab
;
709 /* Massage our args to the form they really have. */
710 hsh
= hppa_stub_hash_entry (bh
);
711 info
= (struct bfd_link_info
*)in_arg
;
713 htab
= hppa_link_hash_table (info
);
717 stub_sec
= hsh
->stub_sec
;
719 /* Make a note of the offset within the stubs for this entry. */
720 hsh
->stub_offset
= stub_sec
->size
;
721 loc
= stub_sec
->contents
+ hsh
->stub_offset
;
723 stub_bfd
= stub_sec
->owner
;
725 switch (hsh
->stub_type
)
727 case hppa_stub_long_branch
:
728 /* Fail if the target section could not be assigned to an output
729 section. The user should fix his linker script. */
730 if (hsh
->target_section
->output_section
== NULL
731 && info
->non_contiguous_regions
)
732 info
->callbacks
->einfo (_("%F%P: Could not assign '%pA' to an output "
733 "section. Retry without "
734 "--enable-non-contiguous-regions.\n"),
735 hsh
->target_section
);
737 /* Create the long branch. A long branch is formed with "ldil"
738 loading the upper bits of the target address into a register,
739 then branching with "be" which adds in the lower bits.
740 The "be" has its delay slot nullified. */
741 sym_value
= (hsh
->target_value
742 + hsh
->target_section
->output_offset
743 + hsh
->target_section
->output_section
->vma
);
745 val
= hppa_field_adjust (sym_value
, 0, e_lrsel
);
746 insn
= hppa_rebuild_insn ((int) LDIL_R1
, val
, 21);
747 bfd_put_32 (stub_bfd
, insn
, loc
);
749 val
= hppa_field_adjust (sym_value
, 0, e_rrsel
) >> 2;
750 insn
= hppa_rebuild_insn ((int) BE_SR4_R1
, val
, 17);
751 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
753 size
= LONG_BRANCH_STUB_SIZE
;
756 case hppa_stub_long_branch_shared
:
757 /* Fail if the target section could not be assigned to an output
758 section. The user should fix his linker script. */
759 if (hsh
->target_section
->output_section
== NULL
760 && info
->non_contiguous_regions
)
761 info
->callbacks
->einfo (_("%F%P: Could not assign %pA to an output "
762 "section. Retry without "
763 "--enable-non-contiguous-regions.\n"),
764 hsh
->target_section
);
766 /* Branches are relative. This is where we are going to. */
767 sym_value
= (hsh
->target_value
768 + hsh
->target_section
->output_offset
769 + hsh
->target_section
->output_section
->vma
);
771 /* And this is where we are coming from, more or less. */
772 sym_value
-= (hsh
->stub_offset
773 + stub_sec
->output_offset
774 + stub_sec
->output_section
->vma
);
776 bfd_put_32 (stub_bfd
, (bfd_vma
) BL_R1
, loc
);
777 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_lrsel
);
778 insn
= hppa_rebuild_insn ((int) ADDIL_R1
, val
, 21);
779 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
781 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_rrsel
) >> 2;
782 insn
= hppa_rebuild_insn ((int) BE_SR4_R1
, val
, 17);
783 bfd_put_32 (stub_bfd
, insn
, loc
+ 8);
784 size
= LONG_BRANCH_SHARED_STUB_SIZE
;
787 case hppa_stub_import
:
788 case hppa_stub_import_shared
:
789 off
= hsh
->hh
->eh
.plt
.offset
;
790 if (off
>= (bfd_vma
) -2)
793 off
&= ~ (bfd_vma
) 1;
795 + htab
->etab
.splt
->output_offset
796 + htab
->etab
.splt
->output_section
->vma
797 - elf_gp (htab
->etab
.splt
->output_section
->owner
));
801 if (hsh
->stub_type
== hppa_stub_import_shared
)
805 /* Load function descriptor address into register %r22. It is
806 sometimes needed for lazy binding. */
807 val
= hppa_field_adjust (sym_value
, 0, e_lrsel
),
808 insn
= hppa_rebuild_insn ((int) insn
, val
, 21);
809 bfd_put_32 (stub_bfd
, insn
, loc
);
811 val
= hppa_field_adjust (sym_value
, 0, e_rrsel
);
812 insn
= hppa_rebuild_insn ((int) LDO_R1_R22
, val
, 14);
813 bfd_put_32 (stub_bfd
, insn
, loc
+ 4);
815 bfd_put_32 (stub_bfd
, (bfd_vma
) LDW_R22_R21
, loc
+ 8);
817 if (htab
->multi_subspace
)
819 bfd_put_32 (stub_bfd
, (bfd_vma
) LDSID_R21_R1
, loc
+ 12);
820 bfd_put_32 (stub_bfd
, (bfd_vma
) LDW_R22_R19
, loc
+ 16);
821 bfd_put_32 (stub_bfd
, (bfd_vma
) MTSP_R1
, loc
+ 20);
822 bfd_put_32 (stub_bfd
, (bfd_vma
) BE_SR0_R21
, loc
+ 24);
823 bfd_put_32 (stub_bfd
, (bfd_vma
) STW_RP
, loc
+ 28);
825 size
= IMPORT_SHARED_STUB_SIZE
;
829 bfd_put_32 (stub_bfd
, (bfd_vma
) BV_R0_R21
, loc
+ 12);
830 bfd_put_32 (stub_bfd
, (bfd_vma
) LDW_R22_R19
, loc
+ 16);
832 size
= IMPORT_STUB_SIZE
;
837 case hppa_stub_export
:
838 /* Fail if the target section could not be assigned to an output
839 section. The user should fix his linker script. */
840 if (hsh
->target_section
->output_section
== NULL
841 && info
->non_contiguous_regions
)
842 info
->callbacks
->einfo (_("%F%P: Could not assign %pA to an output "
843 "section. Retry without "
844 "--enable-non-contiguous-regions.\n"),
845 hsh
->target_section
);
847 /* Branches are relative. This is where we are going to. */
848 sym_value
= (hsh
->target_value
849 + hsh
->target_section
->output_offset
850 + hsh
->target_section
->output_section
->vma
);
852 /* And this is where we are coming from. */
853 sym_value
-= (hsh
->stub_offset
854 + stub_sec
->output_offset
855 + stub_sec
->output_section
->vma
);
857 if (sym_value
- 8 + (1 << (17 + 1)) >= (1 << (17 + 2))
858 && (!htab
->has_22bit_branch
859 || sym_value
- 8 + (1 << (22 + 1)) >= (1 << (22 + 2))))
862 /* xgettext:c-format */
863 (_("%pB(%pA+%#" PRIx64
"): "
864 "cannot reach %s, recompile with -ffunction-sections"),
865 hsh
->target_section
->owner
,
867 (uint64_t) hsh
->stub_offset
,
868 hsh
->bh_root
.string
);
869 bfd_set_error (bfd_error_bad_value
);
873 val
= hppa_field_adjust (sym_value
, (bfd_signed_vma
) -8, e_fsel
) >> 2;
874 if (!htab
->has_22bit_branch
)
875 insn
= hppa_rebuild_insn ((int) BL_RP
, val
, 17);
877 insn
= hppa_rebuild_insn ((int) BL22_RP
, val
, 22);
878 bfd_put_32 (stub_bfd
, insn
, loc
);
880 bfd_put_32 (stub_bfd
, (bfd_vma
) NOP
, loc
+ 4);
881 bfd_put_32 (stub_bfd
, (bfd_vma
) LDW_RP
, loc
+ 8);
882 bfd_put_32 (stub_bfd
, (bfd_vma
) LDSID_RP_R1
, loc
+ 12);
883 bfd_put_32 (stub_bfd
, (bfd_vma
) MTSP_R1
, loc
+ 16);
884 bfd_put_32 (stub_bfd
, (bfd_vma
) BE_SR0_RP
, loc
+ 20);
886 /* Point the function symbol at the stub. */
887 hsh
->hh
->eh
.root
.u
.def
.section
= stub_sec
;
888 hsh
->hh
->eh
.root
.u
.def
.value
= stub_sec
->size
;
890 size
= EXPORT_STUB_SIZE
;
898 stub_sec
->size
+= size
;
923 /* As above, but don't actually build the stub. Just bump offset so
924 we know stub section sizes. */
927 hppa_size_one_stub (struct bfd_hash_entry
*bh
, void *in_arg
)
929 struct elf32_hppa_stub_hash_entry
*hsh
;
930 struct elf32_hppa_link_hash_table
*htab
;
933 /* Massage our args to the form they really have. */
934 hsh
= hppa_stub_hash_entry (bh
);
937 if (hsh
->stub_type
== hppa_stub_long_branch
)
938 size
= LONG_BRANCH_STUB_SIZE
;
939 else if (hsh
->stub_type
== hppa_stub_long_branch_shared
)
940 size
= LONG_BRANCH_SHARED_STUB_SIZE
;
941 else if (hsh
->stub_type
== hppa_stub_export
)
942 size
= EXPORT_STUB_SIZE
;
943 else /* hppa_stub_import or hppa_stub_import_shared. */
945 if (htab
->multi_subspace
)
946 size
= IMPORT_SHARED_STUB_SIZE
;
948 size
= IMPORT_STUB_SIZE
;
951 hsh
->stub_sec
->size
+= size
;
955 /* Return nonzero if ABFD represents an HPPA ELF32 file.
956 Additionally we set the default architecture and machine. */
959 elf32_hppa_object_p (bfd
*abfd
)
961 Elf_Internal_Ehdr
* i_ehdrp
;
964 i_ehdrp
= elf_elfheader (abfd
);
965 if (strcmp (bfd_get_target (abfd
), "elf32-hppa-linux") == 0)
967 /* GCC on hppa-linux produces binaries with OSABI=GNU,
968 but the kernel produces corefiles with OSABI=SysV. */
969 if (i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_GNU
&&
970 i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_NONE
) /* aka SYSV */
973 else if (strcmp (bfd_get_target (abfd
), "elf32-hppa-netbsd") == 0)
975 /* GCC on hppa-netbsd produces binaries with OSABI=NetBSD,
976 but the kernel produces corefiles with OSABI=SysV. */
977 if (i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_NETBSD
&&
978 i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_NONE
) /* aka SYSV */
983 if (i_ehdrp
->e_ident
[EI_OSABI
] != ELFOSABI_HPUX
)
987 flags
= i_ehdrp
->e_flags
;
988 switch (flags
& (EF_PARISC_ARCH
| EF_PARISC_WIDE
))
991 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 10);
993 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 11);
995 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 20);
996 case EFA_PARISC_2_0
| EF_PARISC_WIDE
:
997 return bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 25);
1002 /* Create the .plt and .got sections, and set up our hash table
1003 short-cuts to various dynamic sections. */
1006 elf32_hppa_create_dynamic_sections (bfd
*abfd
, struct bfd_link_info
*info
)
1008 struct elf32_hppa_link_hash_table
*htab
;
1009 struct elf_link_hash_entry
*eh
;
1011 /* Don't try to create the .plt and .got twice. */
1012 htab
= hppa_link_hash_table (info
);
1015 if (htab
->etab
.splt
!= NULL
)
1018 /* Call the generic code to do most of the work. */
1019 if (! _bfd_elf_create_dynamic_sections (abfd
, info
))
1022 /* hppa-linux needs _GLOBAL_OFFSET_TABLE_ to be visible from the main
1023 application, because __canonicalize_funcptr_for_compare needs it. */
1024 eh
= elf_hash_table (info
)->hgot
;
1025 eh
->forced_local
= 0;
1026 eh
->other
= STV_DEFAULT
;
1027 return bfd_elf_link_record_dynamic_symbol (info
, eh
);
1030 /* Copy the extra info we tack onto an elf_link_hash_entry. */
1033 elf32_hppa_copy_indirect_symbol (struct bfd_link_info
*info
,
1034 struct elf_link_hash_entry
*eh_dir
,
1035 struct elf_link_hash_entry
*eh_ind
)
1037 struct elf32_hppa_link_hash_entry
*hh_dir
, *hh_ind
;
1039 hh_dir
= hppa_elf_hash_entry (eh_dir
);
1040 hh_ind
= hppa_elf_hash_entry (eh_ind
);
1042 if (eh_ind
->root
.type
== bfd_link_hash_indirect
)
1044 hh_dir
->plabel
|= hh_ind
->plabel
;
1045 hh_dir
->tls_type
|= hh_ind
->tls_type
;
1046 hh_ind
->tls_type
= GOT_UNKNOWN
;
1049 _bfd_elf_link_hash_copy_indirect (info
, eh_dir
, eh_ind
);
1053 elf32_hppa_optimized_tls_reloc (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
1054 int r_type
, int is_local ATTRIBUTE_UNUSED
)
1056 /* For now we don't support linker optimizations. */
1060 /* Return a pointer to the local GOT, PLT and TLS reference counts
1061 for ABFD. Returns NULL if the storage allocation fails. */
1063 static bfd_signed_vma
*
1064 hppa32_elf_local_refcounts (bfd
*abfd
)
1066 Elf_Internal_Shdr
*symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1067 bfd_signed_vma
*local_refcounts
;
1069 local_refcounts
= elf_local_got_refcounts (abfd
);
1070 if (local_refcounts
== NULL
)
1074 /* Allocate space for local GOT and PLT reference
1075 counts. Done this way to save polluting elf_obj_tdata
1076 with another target specific pointer. */
1077 size
= symtab_hdr
->sh_info
;
1078 size
*= 2 * sizeof (bfd_signed_vma
);
1079 /* Add in space to store the local GOT TLS types. */
1080 size
+= symtab_hdr
->sh_info
;
1081 local_refcounts
= bfd_zalloc (abfd
, size
);
1082 if (local_refcounts
== NULL
)
1084 elf_local_got_refcounts (abfd
) = local_refcounts
;
1085 memset (hppa_elf_local_got_tls_type (abfd
), GOT_UNKNOWN
,
1086 symtab_hdr
->sh_info
);
1088 return local_refcounts
;
1092 /* Look through the relocs for a section during the first phase, and
1093 calculate needed space in the global offset table, procedure linkage
1094 table, and dynamic reloc sections. At this point we haven't
1095 necessarily read all the input files. */
1098 elf32_hppa_check_relocs (bfd
*abfd
,
1099 struct bfd_link_info
*info
,
1101 const Elf_Internal_Rela
*relocs
)
1103 Elf_Internal_Shdr
*symtab_hdr
;
1104 struct elf_link_hash_entry
**eh_syms
;
1105 const Elf_Internal_Rela
*rela
;
1106 const Elf_Internal_Rela
*rela_end
;
1107 struct elf32_hppa_link_hash_table
*htab
;
1110 if (bfd_link_relocatable (info
))
1113 htab
= hppa_link_hash_table (info
);
1116 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1117 eh_syms
= elf_sym_hashes (abfd
);
1120 rela_end
= relocs
+ sec
->reloc_count
;
1121 for (rela
= relocs
; rela
< rela_end
; rela
++)
1130 unsigned int r_symndx
, r_type
;
1131 struct elf32_hppa_link_hash_entry
*hh
;
1134 r_symndx
= ELF32_R_SYM (rela
->r_info
);
1136 if (r_symndx
< symtab_hdr
->sh_info
)
1140 hh
= hppa_elf_hash_entry (eh_syms
[r_symndx
- symtab_hdr
->sh_info
]);
1141 while (hh
->eh
.root
.type
== bfd_link_hash_indirect
1142 || hh
->eh
.root
.type
== bfd_link_hash_warning
)
1143 hh
= hppa_elf_hash_entry (hh
->eh
.root
.u
.i
.link
);
1146 r_type
= ELF32_R_TYPE (rela
->r_info
);
1147 r_type
= elf32_hppa_optimized_tls_reloc (info
, r_type
, hh
== NULL
);
1151 case R_PARISC_DLTIND14F
:
1152 case R_PARISC_DLTIND14R
:
1153 case R_PARISC_DLTIND21L
:
1154 /* This symbol requires a global offset table entry. */
1155 need_entry
= NEED_GOT
;
1158 case R_PARISC_PLABEL14R
: /* "Official" procedure labels. */
1159 case R_PARISC_PLABEL21L
:
1160 case R_PARISC_PLABEL32
:
1161 /* If the addend is non-zero, we break badly. */
1162 if (rela
->r_addend
!= 0)
1165 /* If we are creating a shared library, then we need to
1166 create a PLT entry for all PLABELs, because PLABELs with
1167 local symbols may be passed via a pointer to another
1168 object. Additionally, output a dynamic relocation
1169 pointing to the PLT entry.
1171 For executables, the original 32-bit ABI allowed two
1172 different styles of PLABELs (function pointers): For
1173 global functions, the PLABEL word points into the .plt
1174 two bytes past a (function address, gp) pair, and for
1175 local functions the PLABEL points directly at the
1176 function. The magic +2 for the first type allows us to
1177 differentiate between the two. As you can imagine, this
1178 is a real pain when it comes to generating code to call
1179 functions indirectly or to compare function pointers.
1180 We avoid the mess by always pointing a PLABEL into the
1181 .plt, even for local functions. */
1182 need_entry
= PLT_PLABEL
| NEED_PLT
;
1183 if (bfd_link_pic (info
))
1184 need_entry
|= NEED_DYNREL
;
1187 case R_PARISC_PCREL12F
:
1188 htab
->has_12bit_branch
= 1;
1191 case R_PARISC_PCREL17C
:
1192 case R_PARISC_PCREL17F
:
1193 htab
->has_17bit_branch
= 1;
1196 case R_PARISC_PCREL22F
:
1197 htab
->has_22bit_branch
= 1;
1199 /* Function calls might need to go through the .plt, and
1200 might require long branch stubs. */
1203 /* We know local syms won't need a .plt entry, and if
1204 they need a long branch stub we can't guarantee that
1205 we can reach the stub. So just flag an error later
1206 if we're doing a shared link and find we need a long
1212 /* Global symbols will need a .plt entry if they remain
1213 global, and in most cases won't need a long branch
1214 stub. Unfortunately, we have to cater for the case
1215 where a symbol is forced local by versioning, or due
1216 to symbolic linking, and we lose the .plt entry. */
1217 need_entry
= NEED_PLT
;
1218 if (hh
->eh
.type
== STT_PARISC_MILLI
)
1223 case R_PARISC_SEGBASE
: /* Used to set segment base. */
1224 case R_PARISC_SEGREL32
: /* Relative reloc, used for unwind. */
1225 case R_PARISC_PCREL14F
: /* PC relative load/store. */
1226 case R_PARISC_PCREL14R
:
1227 case R_PARISC_PCREL17R
: /* External branches. */
1228 case R_PARISC_PCREL21L
: /* As above, and for load/store too. */
1229 case R_PARISC_PCREL32
:
1230 /* We don't need to propagate the relocation if linking a
1231 shared object since these are section relative. */
1234 case R_PARISC_DPREL14F
: /* Used for gp rel data load/store. */
1235 case R_PARISC_DPREL14R
:
1236 case R_PARISC_DPREL21L
:
1237 if (bfd_link_pic (info
))
1240 /* xgettext:c-format */
1241 (_("%pB: relocation %s can not be used when making a shared object; recompile with -fPIC"),
1243 elf_hppa_howto_table
[r_type
].name
);
1244 bfd_set_error (bfd_error_bad_value
);
1249 case R_PARISC_DIR17F
: /* Used for external branches. */
1250 case R_PARISC_DIR17R
:
1251 case R_PARISC_DIR14F
: /* Used for load/store from absolute locn. */
1252 case R_PARISC_DIR14R
:
1253 case R_PARISC_DIR21L
: /* As above, and for ext branches too. */
1254 case R_PARISC_DIR32
: /* .word relocs. */
1255 /* We may want to output a dynamic relocation later. */
1256 need_entry
= NEED_DYNREL
;
1259 /* This relocation describes the C++ object vtable hierarchy.
1260 Reconstruct it for later use during GC. */
1261 case R_PARISC_GNU_VTINHERIT
:
1262 if (!bfd_elf_gc_record_vtinherit (abfd
, sec
, &hh
->eh
, rela
->r_offset
))
1266 /* This relocation describes which C++ vtable entries are actually
1267 used. Record for later use during GC. */
1268 case R_PARISC_GNU_VTENTRY
:
1269 if (!bfd_elf_gc_record_vtentry (abfd
, sec
, &hh
->eh
, rela
->r_addend
))
1273 case R_PARISC_TLS_GD21L
:
1274 case R_PARISC_TLS_GD14R
:
1275 case R_PARISC_TLS_LDM21L
:
1276 case R_PARISC_TLS_LDM14R
:
1277 need_entry
= NEED_GOT
;
1280 case R_PARISC_TLS_IE21L
:
1281 case R_PARISC_TLS_IE14R
:
1282 if (bfd_link_dll (info
))
1283 info
->flags
|= DF_STATIC_TLS
;
1284 need_entry
= NEED_GOT
;
1291 /* Now carry out our orders. */
1292 if (need_entry
& NEED_GOT
)
1294 int tls_type
= GOT_NORMAL
;
1300 case R_PARISC_TLS_GD21L
:
1301 case R_PARISC_TLS_GD14R
:
1302 tls_type
= GOT_TLS_GD
;
1304 case R_PARISC_TLS_LDM21L
:
1305 case R_PARISC_TLS_LDM14R
:
1306 tls_type
= GOT_TLS_LDM
;
1308 case R_PARISC_TLS_IE21L
:
1309 case R_PARISC_TLS_IE14R
:
1310 tls_type
= GOT_TLS_IE
;
1314 /* Allocate space for a GOT entry, as well as a dynamic
1315 relocation for this entry. */
1316 if (htab
->etab
.sgot
== NULL
)
1318 if (!elf32_hppa_create_dynamic_sections (htab
->etab
.dynobj
, info
))
1324 if (tls_type
== GOT_TLS_LDM
)
1325 htab
->tls_ldm_got
.refcount
+= 1;
1327 hh
->eh
.got
.refcount
+= 1;
1328 hh
->tls_type
|= tls_type
;
1332 bfd_signed_vma
*local_got_refcounts
;
1334 /* This is a global offset table entry for a local symbol. */
1335 local_got_refcounts
= hppa32_elf_local_refcounts (abfd
);
1336 if (local_got_refcounts
== NULL
)
1338 if (tls_type
== GOT_TLS_LDM
)
1339 htab
->tls_ldm_got
.refcount
+= 1;
1341 local_got_refcounts
[r_symndx
] += 1;
1343 hppa_elf_local_got_tls_type (abfd
) [r_symndx
] |= tls_type
;
1347 if (need_entry
& NEED_PLT
)
1349 /* If we are creating a shared library, and this is a reloc
1350 against a weak symbol or a global symbol in a dynamic
1351 object, then we will be creating an import stub and a
1352 .plt entry for the symbol. Similarly, on a normal link
1353 to symbols defined in a dynamic object we'll need the
1354 import stub and a .plt entry. We don't know yet whether
1355 the symbol is defined or not, so make an entry anyway and
1356 clean up later in adjust_dynamic_symbol. */
1357 if ((sec
->flags
& SEC_ALLOC
) != 0)
1361 hh
->eh
.needs_plt
= 1;
1362 hh
->eh
.plt
.refcount
+= 1;
1364 /* If this .plt entry is for a plabel, mark it so
1365 that adjust_dynamic_symbol will keep the entry
1366 even if it appears to be local. */
1367 if (need_entry
& PLT_PLABEL
)
1370 else if (need_entry
& PLT_PLABEL
)
1372 bfd_signed_vma
*local_got_refcounts
;
1373 bfd_signed_vma
*local_plt_refcounts
;
1375 local_got_refcounts
= hppa32_elf_local_refcounts (abfd
);
1376 if (local_got_refcounts
== NULL
)
1378 local_plt_refcounts
= (local_got_refcounts
1379 + symtab_hdr
->sh_info
);
1380 local_plt_refcounts
[r_symndx
] += 1;
1385 if ((need_entry
& NEED_DYNREL
) != 0
1386 && (sec
->flags
& SEC_ALLOC
) != 0)
1388 /* Flag this symbol as having a non-got, non-plt reference
1389 so that we generate copy relocs if it turns out to be
1392 hh
->eh
.non_got_ref
= 1;
1394 /* If we are creating a shared library then we need to copy
1395 the reloc into the shared library. However, if we are
1396 linking with -Bsymbolic, we need only copy absolute
1397 relocs or relocs against symbols that are not defined in
1398 an object we are including in the link. PC- or DP- or
1399 DLT-relative relocs against any local sym or global sym
1400 with DEF_REGULAR set, can be discarded. At this point we
1401 have not seen all the input files, so it is possible that
1402 DEF_REGULAR is not set now but will be set later (it is
1403 never cleared). We account for that possibility below by
1404 storing information in the dyn_relocs field of the
1407 A similar situation to the -Bsymbolic case occurs when
1408 creating shared libraries and symbol visibility changes
1409 render the symbol local.
1411 As it turns out, all the relocs we will be creating here
1412 are absolute, so we cannot remove them on -Bsymbolic
1413 links or visibility changes anyway. A STUB_REL reloc
1414 is absolute too, as in that case it is the reloc in the
1415 stub we will be creating, rather than copying the PCREL
1416 reloc in the branch.
1418 If on the other hand, we are creating an executable, we
1419 may need to keep relocations for symbols satisfied by a
1420 dynamic library if we manage to avoid copy relocs for the
1422 if ((bfd_link_pic (info
)
1423 && (IS_ABSOLUTE_RELOC (r_type
)
1425 && (!SYMBOLIC_BIND (info
, &hh
->eh
)
1426 || hh
->eh
.root
.type
== bfd_link_hash_defweak
1427 || !hh
->eh
.def_regular
))))
1428 || (ELIMINATE_COPY_RELOCS
1429 && !bfd_link_pic (info
)
1431 && (hh
->eh
.root
.type
== bfd_link_hash_defweak
1432 || !hh
->eh
.def_regular
)))
1434 struct elf_dyn_relocs
*hdh_p
;
1435 struct elf_dyn_relocs
**hdh_head
;
1437 /* Create a reloc section in dynobj and make room for
1441 sreloc
= _bfd_elf_make_dynamic_reloc_section
1442 (sec
, htab
->etab
.dynobj
, 2, abfd
, /*rela?*/ TRUE
);
1446 bfd_set_error (bfd_error_bad_value
);
1451 /* If this is a global symbol, we count the number of
1452 relocations we need for this symbol. */
1455 hdh_head
= &hh
->eh
.dyn_relocs
;
1459 /* Track dynamic relocs needed for local syms too.
1460 We really need local syms available to do this
1464 Elf_Internal_Sym
*isym
;
1466 isym
= bfd_sym_from_r_symndx (&htab
->etab
.sym_cache
,
1471 sr
= bfd_section_from_elf_index (abfd
, isym
->st_shndx
);
1475 vpp
= &elf_section_data (sr
)->local_dynrel
;
1476 hdh_head
= (struct elf_dyn_relocs
**) vpp
;
1480 if (hdh_p
== NULL
|| hdh_p
->sec
!= sec
)
1482 hdh_p
= bfd_alloc (htab
->etab
.dynobj
, sizeof *hdh_p
);
1485 hdh_p
->next
= *hdh_head
;
1489 #if RELATIVE_DYNRELOCS
1490 hdh_p
->pc_count
= 0;
1495 #if RELATIVE_DYNRELOCS
1496 if (!IS_ABSOLUTE_RELOC (rtype
))
1497 hdh_p
->pc_count
+= 1;
1506 /* Return the section that should be marked against garbage collection
1507 for a given relocation. */
1510 elf32_hppa_gc_mark_hook (asection
*sec
,
1511 struct bfd_link_info
*info
,
1512 Elf_Internal_Rela
*rela
,
1513 struct elf_link_hash_entry
*hh
,
1514 Elf_Internal_Sym
*sym
)
1517 switch ((unsigned int) ELF32_R_TYPE (rela
->r_info
))
1519 case R_PARISC_GNU_VTINHERIT
:
1520 case R_PARISC_GNU_VTENTRY
:
1524 return _bfd_elf_gc_mark_hook (sec
, info
, rela
, hh
, sym
);
1527 /* Support for core dump NOTE sections. */
1530 elf32_hppa_grok_prstatus (bfd
*abfd
, Elf_Internal_Note
*note
)
1535 switch (note
->descsz
)
1540 case 396: /* Linux/hppa */
1542 elf_tdata (abfd
)->core
->signal
= bfd_get_16 (abfd
, note
->descdata
+ 12);
1545 elf_tdata (abfd
)->core
->lwpid
= bfd_get_32 (abfd
, note
->descdata
+ 24);
1554 /* Make a ".reg/999" section. */
1555 return _bfd_elfcore_make_pseudosection (abfd
, ".reg",
1556 size
, note
->descpos
+ offset
);
1560 elf32_hppa_grok_psinfo (bfd
*abfd
, Elf_Internal_Note
*note
)
1562 switch (note
->descsz
)
1567 case 124: /* Linux/hppa elf_prpsinfo. */
1568 elf_tdata (abfd
)->core
->program
1569 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 28, 16);
1570 elf_tdata (abfd
)->core
->command
1571 = _bfd_elfcore_strndup (abfd
, note
->descdata
+ 44, 80);
1574 /* Note that for some reason, a spurious space is tacked
1575 onto the end of the args in some (at least one anyway)
1576 implementations, so strip it off if it exists. */
1578 char *command
= elf_tdata (abfd
)->core
->command
;
1579 int n
= strlen (command
);
1581 if (0 < n
&& command
[n
- 1] == ' ')
1582 command
[n
- 1] = '\0';
1588 /* Our own version of hide_symbol, so that we can keep plt entries for
1592 elf32_hppa_hide_symbol (struct bfd_link_info
*info
,
1593 struct elf_link_hash_entry
*eh
,
1594 bfd_boolean force_local
)
1598 eh
->forced_local
= 1;
1599 if (eh
->dynindx
!= -1)
1602 _bfd_elf_strtab_delref (elf_hash_table (info
)->dynstr
,
1606 /* PR 16082: Remove version information from hidden symbol. */
1607 eh
->verinfo
.verdef
= NULL
;
1608 eh
->verinfo
.vertree
= NULL
;
1611 /* STT_GNU_IFUNC symbol must go through PLT. */
1612 if (! hppa_elf_hash_entry (eh
)->plabel
1613 && eh
->type
!= STT_GNU_IFUNC
)
1616 eh
->plt
= elf_hash_table (info
)->init_plt_offset
;
1620 /* Return true if we have dynamic relocs against H or any of its weak
1621 aliases, that apply to read-only sections. Cannot be used after
1622 size_dynamic_sections. */
1625 alias_readonly_dynrelocs (struct elf_link_hash_entry
*eh
)
1627 struct elf32_hppa_link_hash_entry
*hh
= hppa_elf_hash_entry (eh
);
1630 if (_bfd_elf_readonly_dynrelocs (&hh
->eh
))
1632 hh
= hppa_elf_hash_entry (hh
->eh
.u
.alias
);
1633 } while (hh
!= NULL
&& &hh
->eh
!= eh
);
1638 /* Adjust a symbol defined by a dynamic object and referenced by a
1639 regular object. The current definition is in some section of the
1640 dynamic object, but we're not including those sections. We have to
1641 change the definition to something the rest of the link can
1645 elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info
*info
,
1646 struct elf_link_hash_entry
*eh
)
1648 struct elf32_hppa_link_hash_table
*htab
;
1649 asection
*sec
, *srel
;
1651 /* If this is a function, put it in the procedure linkage table. We
1652 will fill in the contents of the procedure linkage table later. */
1653 if (eh
->type
== STT_FUNC
1656 bfd_boolean local
= (SYMBOL_CALLS_LOCAL (info
, eh
)
1657 || UNDEFWEAK_NO_DYNAMIC_RELOC (info
, eh
));
1658 /* Discard dyn_relocs when non-pic if we've decided that a
1659 function symbol is local. */
1660 if (!bfd_link_pic (info
) && local
)
1661 eh
->dyn_relocs
= NULL
;
1663 /* If the symbol is used by a plabel, we must allocate a PLT slot.
1664 The refcounts are not reliable when it has been hidden since
1665 hide_symbol can be called before the plabel flag is set. */
1666 if (hppa_elf_hash_entry (eh
)->plabel
)
1667 eh
->plt
.refcount
= 1;
1669 /* Note that unlike some other backends, the refcount is not
1670 incremented for a non-call (and non-plabel) function reference. */
1671 else if (eh
->plt
.refcount
<= 0
1674 /* The .plt entry is not needed when:
1675 a) Garbage collection has removed all references to the
1677 b) We know for certain the symbol is defined in this
1678 object, and it's not a weak definition, nor is the symbol
1679 used by a plabel relocation. Either this object is the
1680 application or we are doing a shared symbolic link. */
1681 eh
->plt
.offset
= (bfd_vma
) -1;
1685 /* Unlike other targets, elf32-hppa.c does not define a function
1686 symbol in a non-pic executable on PLT stub code, so we don't
1687 have a local definition in that case. ie. dyn_relocs can't
1690 /* Function symbols can't have copy relocs. */
1694 eh
->plt
.offset
= (bfd_vma
) -1;
1696 htab
= hppa_link_hash_table (info
);
1700 /* If this is a weak symbol, and there is a real definition, the
1701 processor independent code will have arranged for us to see the
1702 real definition first, and we can just use the same value. */
1703 if (eh
->is_weakalias
)
1705 struct elf_link_hash_entry
*def
= weakdef (eh
);
1706 BFD_ASSERT (def
->root
.type
== bfd_link_hash_defined
);
1707 eh
->root
.u
.def
.section
= def
->root
.u
.def
.section
;
1708 eh
->root
.u
.def
.value
= def
->root
.u
.def
.value
;
1709 if (def
->root
.u
.def
.section
== htab
->etab
.sdynbss
1710 || def
->root
.u
.def
.section
== htab
->etab
.sdynrelro
)
1711 eh
->dyn_relocs
= NULL
;
1715 /* This is a reference to a symbol defined by a dynamic object which
1716 is not a function. */
1718 /* If we are creating a shared library, we must presume that the
1719 only references to the symbol are via the global offset table.
1720 For such cases we need not do anything here; the relocations will
1721 be handled correctly by relocate_section. */
1722 if (bfd_link_pic (info
))
1725 /* If there are no references to this symbol that do not use the
1726 GOT, we don't need to generate a copy reloc. */
1727 if (!eh
->non_got_ref
)
1730 /* If -z nocopyreloc was given, we won't generate them either. */
1731 if (info
->nocopyreloc
)
1734 /* If we don't find any dynamic relocs in read-only sections, then
1735 we'll be keeping the dynamic relocs and avoiding the copy reloc. */
1736 if (ELIMINATE_COPY_RELOCS
1737 && !alias_readonly_dynrelocs (eh
))
1740 /* We must allocate the symbol in our .dynbss section, which will
1741 become part of the .bss section of the executable. There will be
1742 an entry for this symbol in the .dynsym section. The dynamic
1743 object will contain position independent code, so all references
1744 from the dynamic object to this symbol will go through the global
1745 offset table. The dynamic linker will use the .dynsym entry to
1746 determine the address it must put in the global offset table, so
1747 both the dynamic object and the regular object will refer to the
1748 same memory location for the variable. */
1749 if ((eh
->root
.u
.def
.section
->flags
& SEC_READONLY
) != 0)
1751 sec
= htab
->etab
.sdynrelro
;
1752 srel
= htab
->etab
.sreldynrelro
;
1756 sec
= htab
->etab
.sdynbss
;
1757 srel
= htab
->etab
.srelbss
;
1759 if ((eh
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0 && eh
->size
!= 0)
1761 /* We must generate a COPY reloc to tell the dynamic linker to
1762 copy the initial value out of the dynamic object and into the
1763 runtime process image. */
1764 srel
->size
+= sizeof (Elf32_External_Rela
);
1768 /* We no longer want dyn_relocs. */
1769 eh
->dyn_relocs
= NULL
;
1770 return _bfd_elf_adjust_dynamic_copy (info
, eh
, sec
);
1773 /* If EH is undefined, make it dynamic if that makes sense. */
1776 ensure_undef_dynamic (struct bfd_link_info
*info
,
1777 struct elf_link_hash_entry
*eh
)
1779 struct elf_link_hash_table
*htab
= elf_hash_table (info
);
1781 if (htab
->dynamic_sections_created
1782 && (eh
->root
.type
== bfd_link_hash_undefweak
1783 || eh
->root
.type
== bfd_link_hash_undefined
)
1784 && eh
->dynindx
== -1
1785 && !eh
->forced_local
1786 && eh
->type
!= STT_PARISC_MILLI
1787 && !UNDEFWEAK_NO_DYNAMIC_RELOC (info
, eh
)
1788 && ELF_ST_VISIBILITY (eh
->other
) == STV_DEFAULT
)
1789 return bfd_elf_link_record_dynamic_symbol (info
, eh
);
1793 /* Allocate space in the .plt for entries that won't have relocations.
1794 ie. plabel entries. */
1797 allocate_plt_static (struct elf_link_hash_entry
*eh
, void *inf
)
1799 struct bfd_link_info
*info
;
1800 struct elf32_hppa_link_hash_table
*htab
;
1801 struct elf32_hppa_link_hash_entry
*hh
;
1804 if (eh
->root
.type
== bfd_link_hash_indirect
)
1807 info
= (struct bfd_link_info
*) inf
;
1808 hh
= hppa_elf_hash_entry (eh
);
1809 htab
= hppa_link_hash_table (info
);
1813 if (htab
->etab
.dynamic_sections_created
1814 && eh
->plt
.refcount
> 0)
1816 if (!ensure_undef_dynamic (info
, eh
))
1819 if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info
), eh
))
1821 /* Allocate these later. From this point on, h->plabel
1822 means that the plt entry is only used by a plabel.
1823 We'll be using a normal plt entry for this symbol, so
1824 clear the plabel indicator. */
1828 else if (hh
->plabel
)
1830 /* Make an entry in the .plt section for plabel references
1831 that won't have a .plt entry for other reasons. */
1832 sec
= htab
->etab
.splt
;
1833 eh
->plt
.offset
= sec
->size
;
1834 sec
->size
+= PLT_ENTRY_SIZE
;
1835 if (bfd_link_pic (info
))
1836 htab
->etab
.srelplt
->size
+= sizeof (Elf32_External_Rela
);
1840 /* No .plt entry needed. */
1841 eh
->plt
.offset
= (bfd_vma
) -1;
1847 eh
->plt
.offset
= (bfd_vma
) -1;
1854 /* Calculate size of GOT entries for symbol given its TLS_TYPE. */
1856 static inline unsigned int
1857 got_entries_needed (int tls_type
)
1859 unsigned int need
= 0;
1861 if ((tls_type
& GOT_NORMAL
) != 0)
1862 need
+= GOT_ENTRY_SIZE
;
1863 if ((tls_type
& GOT_TLS_GD
) != 0)
1864 need
+= GOT_ENTRY_SIZE
* 2;
1865 if ((tls_type
& GOT_TLS_IE
) != 0)
1866 need
+= GOT_ENTRY_SIZE
;
1870 /* Calculate size of relocs needed for symbol given its TLS_TYPE and
1871 NEEDed GOT entries. TPREL_KNOWN says a TPREL offset can be
1872 calculated at link time. DTPREL_KNOWN says the same for a DTPREL
1875 static inline unsigned int
1876 got_relocs_needed (int tls_type
, unsigned int need
,
1877 bfd_boolean dtprel_known
, bfd_boolean tprel_known
)
1879 /* All the entries we allocated need relocs.
1880 Except for GD and IE with local symbols. */
1881 if ((tls_type
& GOT_TLS_GD
) != 0 && dtprel_known
)
1882 need
-= GOT_ENTRY_SIZE
;
1883 if ((tls_type
& GOT_TLS_IE
) != 0 && tprel_known
)
1884 need
-= GOT_ENTRY_SIZE
;
1885 return need
* sizeof (Elf32_External_Rela
) / GOT_ENTRY_SIZE
;
1888 /* Allocate space in .plt, .got and associated reloc sections for
1892 allocate_dynrelocs (struct elf_link_hash_entry
*eh
, void *inf
)
1894 struct bfd_link_info
*info
;
1895 struct elf32_hppa_link_hash_table
*htab
;
1897 struct elf32_hppa_link_hash_entry
*hh
;
1898 struct elf_dyn_relocs
*hdh_p
;
1900 if (eh
->root
.type
== bfd_link_hash_indirect
)
1904 htab
= hppa_link_hash_table (info
);
1908 hh
= hppa_elf_hash_entry (eh
);
1910 if (htab
->etab
.dynamic_sections_created
1911 && eh
->plt
.offset
!= (bfd_vma
) -1
1913 && eh
->plt
.refcount
> 0)
1915 /* Make an entry in the .plt section. */
1916 sec
= htab
->etab
.splt
;
1917 eh
->plt
.offset
= sec
->size
;
1918 sec
->size
+= PLT_ENTRY_SIZE
;
1920 /* We also need to make an entry in the .rela.plt section. */
1921 htab
->etab
.srelplt
->size
+= sizeof (Elf32_External_Rela
);
1922 htab
->need_plt_stub
= 1;
1925 if (eh
->got
.refcount
> 0)
1929 if (!ensure_undef_dynamic (info
, eh
))
1932 sec
= htab
->etab
.sgot
;
1933 eh
->got
.offset
= sec
->size
;
1934 need
= got_entries_needed (hh
->tls_type
);
1936 if (htab
->etab
.dynamic_sections_created
1937 && (bfd_link_dll (info
)
1938 || (bfd_link_pic (info
) && (hh
->tls_type
& GOT_NORMAL
) != 0)
1939 || (eh
->dynindx
!= -1
1940 && !SYMBOL_REFERENCES_LOCAL (info
, eh
)))
1941 && !UNDEFWEAK_NO_DYNAMIC_RELOC (info
, eh
))
1943 bfd_boolean local
= SYMBOL_REFERENCES_LOCAL (info
, eh
);
1944 htab
->etab
.srelgot
->size
1945 += got_relocs_needed (hh
->tls_type
, need
, local
,
1946 local
&& bfd_link_executable (info
));
1950 eh
->got
.offset
= (bfd_vma
) -1;
1952 /* If no dynamic sections we can't have dynamic relocs. */
1953 if (!htab
->etab
.dynamic_sections_created
)
1954 eh
->dyn_relocs
= NULL
;
1956 /* Discard relocs on undefined syms with non-default visibility. */
1957 else if ((eh
->root
.type
== bfd_link_hash_undefined
1958 && ELF_ST_VISIBILITY (eh
->other
) != STV_DEFAULT
)
1959 || UNDEFWEAK_NO_DYNAMIC_RELOC (info
, eh
))
1960 eh
->dyn_relocs
= NULL
;
1962 if (eh
->dyn_relocs
== NULL
)
1965 /* If this is a -Bsymbolic shared link, then we need to discard all
1966 space allocated for dynamic pc-relative relocs against symbols
1967 defined in a regular object. For the normal shared case, discard
1968 space for relocs that have become local due to symbol visibility
1970 if (bfd_link_pic (info
))
1972 #if RELATIVE_DYNRELOCS
1973 if (SYMBOL_CALLS_LOCAL (info
, eh
))
1975 struct elf_dyn_relocs
**hdh_pp
;
1977 for (hdh_pp
= &eh
->dyn_relocs
; (hdh_p
= *hdh_pp
) != NULL
; )
1979 hdh_p
->count
-= hdh_p
->pc_count
;
1980 hdh_p
->pc_count
= 0;
1981 if (hdh_p
->count
== 0)
1982 *hdh_pp
= hdh_p
->next
;
1984 hdh_pp
= &hdh_p
->next
;
1989 if (eh
->dyn_relocs
!= NULL
)
1991 if (!ensure_undef_dynamic (info
, eh
))
1995 else if (ELIMINATE_COPY_RELOCS
)
1997 /* For the non-shared case, discard space for relocs against
1998 symbols which turn out to need copy relocs or are not
2001 if (eh
->dynamic_adjusted
2003 && !ELF_COMMON_DEF_P (eh
))
2005 if (!ensure_undef_dynamic (info
, eh
))
2008 if (eh
->dynindx
== -1)
2009 eh
->dyn_relocs
= NULL
;
2012 eh
->dyn_relocs
= NULL
;
2015 /* Finally, allocate space. */
2016 for (hdh_p
= eh
->dyn_relocs
; hdh_p
!= NULL
; hdh_p
= hdh_p
->next
)
2018 asection
*sreloc
= elf_section_data (hdh_p
->sec
)->sreloc
;
2019 sreloc
->size
+= hdh_p
->count
* sizeof (Elf32_External_Rela
);
2025 /* This function is called via elf_link_hash_traverse to force
2026 millicode symbols local so they do not end up as globals in the
2027 dynamic symbol table. We ought to be able to do this in
2028 adjust_dynamic_symbol, but our adjust_dynamic_symbol is not called
2029 for all dynamic symbols. Arguably, this is a bug in
2030 elf_adjust_dynamic_symbol. */
2033 clobber_millicode_symbols (struct elf_link_hash_entry
*eh
,
2034 struct bfd_link_info
*info
)
2036 if (eh
->type
== STT_PARISC_MILLI
2037 && !eh
->forced_local
)
2039 elf32_hppa_hide_symbol (info
, eh
, TRUE
);
2044 /* Set the sizes of the dynamic sections. */
2047 elf32_hppa_size_dynamic_sections (bfd
*output_bfd ATTRIBUTE_UNUSED
,
2048 struct bfd_link_info
*info
)
2050 struct elf32_hppa_link_hash_table
*htab
;
2056 htab
= hppa_link_hash_table (info
);
2060 dynobj
= htab
->etab
.dynobj
;
2064 if (htab
->etab
.dynamic_sections_created
)
2066 /* Set the contents of the .interp section to the interpreter. */
2067 if (bfd_link_executable (info
) && !info
->nointerp
)
2069 sec
= bfd_get_linker_section (dynobj
, ".interp");
2072 sec
->size
= sizeof ELF_DYNAMIC_INTERPRETER
;
2073 sec
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
2076 /* Force millicode symbols local. */
2077 elf_link_hash_traverse (&htab
->etab
,
2078 clobber_millicode_symbols
,
2082 /* Set up .got and .plt offsets for local syms, and space for local
2084 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link
.next
)
2086 bfd_signed_vma
*local_got
;
2087 bfd_signed_vma
*end_local_got
;
2088 bfd_signed_vma
*local_plt
;
2089 bfd_signed_vma
*end_local_plt
;
2090 bfd_size_type locsymcount
;
2091 Elf_Internal_Shdr
*symtab_hdr
;
2093 char *local_tls_type
;
2095 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
)
2098 for (sec
= ibfd
->sections
; sec
!= NULL
; sec
= sec
->next
)
2100 struct elf_dyn_relocs
*hdh_p
;
2102 for (hdh_p
= ((struct elf_dyn_relocs
*)
2103 elf_section_data (sec
)->local_dynrel
);
2105 hdh_p
= hdh_p
->next
)
2107 if (!bfd_is_abs_section (hdh_p
->sec
)
2108 && bfd_is_abs_section (hdh_p
->sec
->output_section
))
2110 /* Input section has been discarded, either because
2111 it is a copy of a linkonce section or due to
2112 linker script /DISCARD/, so we'll be discarding
2115 else if (hdh_p
->count
!= 0)
2117 srel
= elf_section_data (hdh_p
->sec
)->sreloc
;
2118 srel
->size
+= hdh_p
->count
* sizeof (Elf32_External_Rela
);
2119 if ((hdh_p
->sec
->output_section
->flags
& SEC_READONLY
) != 0)
2120 info
->flags
|= DF_TEXTREL
;
2125 local_got
= elf_local_got_refcounts (ibfd
);
2129 symtab_hdr
= &elf_tdata (ibfd
)->symtab_hdr
;
2130 locsymcount
= symtab_hdr
->sh_info
;
2131 end_local_got
= local_got
+ locsymcount
;
2132 local_tls_type
= hppa_elf_local_got_tls_type (ibfd
);
2133 sec
= htab
->etab
.sgot
;
2134 srel
= htab
->etab
.srelgot
;
2135 for (; local_got
< end_local_got
; ++local_got
)
2141 *local_got
= sec
->size
;
2142 need
= got_entries_needed (*local_tls_type
);
2144 if (bfd_link_dll (info
)
2145 || (bfd_link_pic (info
)
2146 && (*local_tls_type
& GOT_NORMAL
) != 0))
2147 htab
->etab
.srelgot
->size
2148 += got_relocs_needed (*local_tls_type
, need
, TRUE
,
2149 bfd_link_executable (info
));
2152 *local_got
= (bfd_vma
) -1;
2157 local_plt
= end_local_got
;
2158 end_local_plt
= local_plt
+ locsymcount
;
2159 if (! htab
->etab
.dynamic_sections_created
)
2161 /* Won't be used, but be safe. */
2162 for (; local_plt
< end_local_plt
; ++local_plt
)
2163 *local_plt
= (bfd_vma
) -1;
2167 sec
= htab
->etab
.splt
;
2168 srel
= htab
->etab
.srelplt
;
2169 for (; local_plt
< end_local_plt
; ++local_plt
)
2173 *local_plt
= sec
->size
;
2174 sec
->size
+= PLT_ENTRY_SIZE
;
2175 if (bfd_link_pic (info
))
2176 srel
->size
+= sizeof (Elf32_External_Rela
);
2179 *local_plt
= (bfd_vma
) -1;
2184 if (htab
->tls_ldm_got
.refcount
> 0)
2186 /* Allocate 2 got entries and 1 dynamic reloc for
2187 R_PARISC_TLS_DTPMOD32 relocs. */
2188 htab
->tls_ldm_got
.offset
= htab
->etab
.sgot
->size
;
2189 htab
->etab
.sgot
->size
+= (GOT_ENTRY_SIZE
* 2);
2190 htab
->etab
.srelgot
->size
+= sizeof (Elf32_External_Rela
);
2193 htab
->tls_ldm_got
.offset
= -1;
2195 /* Do all the .plt entries without relocs first. The dynamic linker
2196 uses the last .plt reloc to find the end of the .plt (and hence
2197 the start of the .got) for lazy linking. */
2198 elf_link_hash_traverse (&htab
->etab
, allocate_plt_static
, info
);
2200 /* Allocate global sym .plt and .got entries, and space for global
2201 sym dynamic relocs. */
2202 elf_link_hash_traverse (&htab
->etab
, allocate_dynrelocs
, info
);
2204 /* The check_relocs and adjust_dynamic_symbol entry points have
2205 determined the sizes of the various dynamic sections. Allocate
2208 for (sec
= dynobj
->sections
; sec
!= NULL
; sec
= sec
->next
)
2210 if ((sec
->flags
& SEC_LINKER_CREATED
) == 0)
2213 if (sec
== htab
->etab
.splt
)
2215 if (htab
->need_plt_stub
)
2217 /* Make space for the plt stub at the end of the .plt
2218 section. We want this stub right at the end, up
2219 against the .got section. */
2220 int gotalign
= bfd_section_alignment (htab
->etab
.sgot
);
2221 int pltalign
= bfd_section_alignment (sec
);
2222 int align
= gotalign
> 3 ? gotalign
: 3;
2225 if (align
> pltalign
)
2226 bfd_set_section_alignment (sec
, align
);
2227 mask
= ((bfd_size_type
) 1 << gotalign
) - 1;
2228 sec
->size
= (sec
->size
+ sizeof (plt_stub
) + mask
) & ~mask
;
2231 else if (sec
== htab
->etab
.sgot
2232 || sec
== htab
->etab
.sdynbss
2233 || sec
== htab
->etab
.sdynrelro
)
2235 else if (CONST_STRNEQ (bfd_section_name (sec
), ".rela"))
2239 /* Remember whether there are any reloc sections other
2241 if (sec
!= htab
->etab
.srelplt
)
2244 /* We use the reloc_count field as a counter if we need
2245 to copy relocs into the output file. */
2246 sec
->reloc_count
= 0;
2251 /* It's not one of our sections, so don't allocate space. */
2257 /* If we don't need this section, strip it from the
2258 output file. This is mostly to handle .rela.bss and
2259 .rela.plt. We must create both sections in
2260 create_dynamic_sections, because they must be created
2261 before the linker maps input sections to output
2262 sections. The linker does that before
2263 adjust_dynamic_symbol is called, and it is that
2264 function which decides whether anything needs to go
2265 into these sections. */
2266 sec
->flags
|= SEC_EXCLUDE
;
2270 if ((sec
->flags
& SEC_HAS_CONTENTS
) == 0)
2273 /* Allocate memory for the section contents. Zero it, because
2274 we may not fill in all the reloc sections. */
2275 sec
->contents
= bfd_zalloc (dynobj
, sec
->size
);
2276 if (sec
->contents
== NULL
)
2280 return _bfd_elf_add_dynamic_tags (output_bfd
, info
, relocs
);
2283 /* External entry points for sizing and building linker stubs. */
2285 /* Set up various things so that we can make a list of input sections
2286 for each output section included in the link. Returns -1 on error,
2287 0 when no stubs will be needed, and 1 on success. */
2290 elf32_hppa_setup_section_lists (bfd
*output_bfd
, struct bfd_link_info
*info
)
2293 unsigned int bfd_count
;
2294 unsigned int top_id
, top_index
;
2296 asection
**input_list
, **list
;
2298 struct elf32_hppa_link_hash_table
*htab
= hppa_link_hash_table (info
);
2303 /* Count the number of input BFDs and find the top input section id. */
2304 for (input_bfd
= info
->input_bfds
, bfd_count
= 0, top_id
= 0;
2306 input_bfd
= input_bfd
->link
.next
)
2309 for (section
= input_bfd
->sections
;
2311 section
= section
->next
)
2313 if (top_id
< section
->id
)
2314 top_id
= section
->id
;
2317 htab
->bfd_count
= bfd_count
;
2319 amt
= sizeof (struct map_stub
) * (top_id
+ 1);
2320 htab
->stub_group
= bfd_zmalloc (amt
);
2321 if (htab
->stub_group
== NULL
)
2324 /* We can't use output_bfd->section_count here to find the top output
2325 section index as some sections may have been removed, and
2326 strip_excluded_output_sections doesn't renumber the indices. */
2327 for (section
= output_bfd
->sections
, top_index
= 0;
2329 section
= section
->next
)
2331 if (top_index
< section
->index
)
2332 top_index
= section
->index
;
2335 htab
->top_index
= top_index
;
2336 amt
= sizeof (asection
*) * (top_index
+ 1);
2337 input_list
= bfd_malloc (amt
);
2338 htab
->input_list
= input_list
;
2339 if (input_list
== NULL
)
2342 /* For sections we aren't interested in, mark their entries with a
2343 value we can check later. */
2344 list
= input_list
+ top_index
;
2346 *list
= bfd_abs_section_ptr
;
2347 while (list
-- != input_list
);
2349 for (section
= output_bfd
->sections
;
2351 section
= section
->next
)
2353 if ((section
->flags
& SEC_CODE
) != 0)
2354 input_list
[section
->index
] = NULL
;
2360 /* The linker repeatedly calls this function for each input section,
2361 in the order that input sections are linked into output sections.
2362 Build lists of input sections to determine groupings between which
2363 we may insert linker stubs. */
2366 elf32_hppa_next_input_section (struct bfd_link_info
*info
, asection
*isec
)
2368 struct elf32_hppa_link_hash_table
*htab
= hppa_link_hash_table (info
);
2373 if (isec
->output_section
->index
<= htab
->top_index
)
2375 asection
**list
= htab
->input_list
+ isec
->output_section
->index
;
2376 if (*list
!= bfd_abs_section_ptr
)
2378 /* Steal the link_sec pointer for our list. */
2379 #define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
2380 /* This happens to make the list in reverse order,
2381 which is what we want. */
2382 PREV_SEC (isec
) = *list
;
2388 /* See whether we can group stub sections together. Grouping stub
2389 sections may result in fewer stubs. More importantly, we need to
2390 put all .init* and .fini* stubs at the beginning of the .init or
2391 .fini output sections respectively, because glibc splits the
2392 _init and _fini functions into multiple parts. Putting a stub in
2393 the middle of a function is not a good idea. */
2396 group_sections (struct elf32_hppa_link_hash_table
*htab
,
2397 bfd_size_type stub_group_size
,
2398 bfd_boolean stubs_always_before_branch
)
2400 asection
**list
= htab
->input_list
+ htab
->top_index
;
2403 asection
*tail
= *list
;
2404 if (tail
== bfd_abs_section_ptr
)
2406 while (tail
!= NULL
)
2410 bfd_size_type total
;
2411 bfd_boolean big_sec
;
2415 big_sec
= total
>= stub_group_size
;
2417 while ((prev
= PREV_SEC (curr
)) != NULL
2418 && ((total
+= curr
->output_offset
- prev
->output_offset
)
2422 /* OK, the size from the start of CURR to the end is less
2423 than 240000 bytes and thus can be handled by one stub
2424 section. (or the tail section is itself larger than
2425 240000 bytes, in which case we may be toast.)
2426 We should really be keeping track of the total size of
2427 stubs added here, as stubs contribute to the final output
2428 section size. That's a little tricky, and this way will
2429 only break if stubs added total more than 22144 bytes, or
2430 2768 long branch stubs. It seems unlikely for more than
2431 2768 different functions to be called, especially from
2432 code only 240000 bytes long. This limit used to be
2433 250000, but c++ code tends to generate lots of little
2434 functions, and sometimes violated the assumption. */
2437 prev
= PREV_SEC (tail
);
2438 /* Set up this stub group. */
2439 htab
->stub_group
[tail
->id
].link_sec
= curr
;
2441 while (tail
!= curr
&& (tail
= prev
) != NULL
);
2443 /* But wait, there's more! Input sections up to 240000
2444 bytes before the stub section can be handled by it too.
2445 Don't do this if we have a really large section after the
2446 stubs, as adding more stubs increases the chance that
2447 branches may not reach into the stub section. */
2448 if (!stubs_always_before_branch
&& !big_sec
)
2452 && ((total
+= tail
->output_offset
- prev
->output_offset
)
2456 prev
= PREV_SEC (tail
);
2457 htab
->stub_group
[tail
->id
].link_sec
= curr
;
2463 while (list
-- != htab
->input_list
);
2464 free (htab
->input_list
);
2468 /* Read in all local syms for all input bfds, and create hash entries
2469 for export stubs if we are building a multi-subspace shared lib.
2470 Returns -1 on error, 1 if export stubs created, 0 otherwise. */
2473 get_local_syms (bfd
*output_bfd
, bfd
*input_bfd
, struct bfd_link_info
*info
)
2475 unsigned int bfd_indx
;
2476 Elf_Internal_Sym
*local_syms
, **all_local_syms
;
2477 int stub_changed
= 0;
2478 struct elf32_hppa_link_hash_table
*htab
= hppa_link_hash_table (info
);
2483 /* We want to read in symbol extension records only once. To do this
2484 we need to read in the local symbols in parallel and save them for
2485 later use; so hold pointers to the local symbols in an array. */
2486 size_t amt
= sizeof (Elf_Internal_Sym
*) * htab
->bfd_count
;
2487 all_local_syms
= bfd_zmalloc (amt
);
2488 htab
->all_local_syms
= all_local_syms
;
2489 if (all_local_syms
== NULL
)
2492 /* Walk over all the input BFDs, swapping in local symbols.
2493 If we are creating a shared library, create hash entries for the
2497 input_bfd
= input_bfd
->link
.next
, bfd_indx
++)
2499 Elf_Internal_Shdr
*symtab_hdr
;
2501 /* We'll need the symbol table in a second. */
2502 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2503 if (symtab_hdr
->sh_info
== 0)
2506 /* We need an array of the local symbols attached to the input bfd. */
2507 local_syms
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
2508 if (local_syms
== NULL
)
2510 local_syms
= bfd_elf_get_elf_syms (input_bfd
, symtab_hdr
,
2511 symtab_hdr
->sh_info
, 0,
2513 /* Cache them for elf_link_input_bfd. */
2514 symtab_hdr
->contents
= (unsigned char *) local_syms
;
2516 if (local_syms
== NULL
)
2519 all_local_syms
[bfd_indx
] = local_syms
;
2521 if (bfd_link_pic (info
) && htab
->multi_subspace
)
2523 struct elf_link_hash_entry
**eh_syms
;
2524 struct elf_link_hash_entry
**eh_symend
;
2525 unsigned int symcount
;
2527 symcount
= (symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
)
2528 - symtab_hdr
->sh_info
);
2529 eh_syms
= (struct elf_link_hash_entry
**) elf_sym_hashes (input_bfd
);
2530 eh_symend
= (struct elf_link_hash_entry
**) (eh_syms
+ symcount
);
2532 /* Look through the global syms for functions; We need to
2533 build export stubs for all globally visible functions. */
2534 for (; eh_syms
< eh_symend
; eh_syms
++)
2536 struct elf32_hppa_link_hash_entry
*hh
;
2538 hh
= hppa_elf_hash_entry (*eh_syms
);
2540 while (hh
->eh
.root
.type
== bfd_link_hash_indirect
2541 || hh
->eh
.root
.type
== bfd_link_hash_warning
)
2542 hh
= hppa_elf_hash_entry (hh
->eh
.root
.u
.i
.link
);
2544 /* At this point in the link, undefined syms have been
2545 resolved, so we need to check that the symbol was
2546 defined in this BFD. */
2547 if ((hh
->eh
.root
.type
== bfd_link_hash_defined
2548 || hh
->eh
.root
.type
== bfd_link_hash_defweak
)
2549 && hh
->eh
.type
== STT_FUNC
2550 && hh
->eh
.root
.u
.def
.section
->output_section
!= NULL
2551 && (hh
->eh
.root
.u
.def
.section
->output_section
->owner
2553 && hh
->eh
.root
.u
.def
.section
->owner
== input_bfd
2554 && hh
->eh
.def_regular
2555 && !hh
->eh
.forced_local
2556 && ELF_ST_VISIBILITY (hh
->eh
.other
) == STV_DEFAULT
)
2559 const char *stub_name
;
2560 struct elf32_hppa_stub_hash_entry
*hsh
;
2562 sec
= hh
->eh
.root
.u
.def
.section
;
2563 stub_name
= hh_name (hh
);
2564 hsh
= hppa_stub_hash_lookup (&htab
->bstab
,
2569 hsh
= hppa_add_stub (stub_name
, sec
, htab
);
2573 hsh
->target_value
= hh
->eh
.root
.u
.def
.value
;
2574 hsh
->target_section
= hh
->eh
.root
.u
.def
.section
;
2575 hsh
->stub_type
= hppa_stub_export
;
2581 /* xgettext:c-format */
2582 _bfd_error_handler (_("%pB: duplicate export stub %s"),
2583 input_bfd
, stub_name
);
2590 return stub_changed
;
2593 /* Determine and set the size of the stub section for a final link.
2595 The basic idea here is to examine all the relocations looking for
2596 PC-relative calls to a target that is unreachable with a "bl"
2600 elf32_hppa_size_stubs
2601 (bfd
*output_bfd
, bfd
*stub_bfd
, struct bfd_link_info
*info
,
2602 bfd_boolean multi_subspace
, bfd_signed_vma group_size
,
2603 asection
* (*add_stub_section
) (const char *, asection
*),
2604 void (*layout_sections_again
) (void))
2606 bfd_size_type stub_group_size
;
2607 bfd_boolean stubs_always_before_branch
;
2608 bfd_boolean stub_changed
;
2609 struct elf32_hppa_link_hash_table
*htab
= hppa_link_hash_table (info
);
2614 /* Stash our params away. */
2615 htab
->stub_bfd
= stub_bfd
;
2616 htab
->multi_subspace
= multi_subspace
;
2617 htab
->add_stub_section
= add_stub_section
;
2618 htab
->layout_sections_again
= layout_sections_again
;
2619 stubs_always_before_branch
= group_size
< 0;
2621 stub_group_size
= -group_size
;
2623 stub_group_size
= group_size
;
2624 if (stub_group_size
== 1)
2626 /* Default values. */
2627 if (stubs_always_before_branch
)
2629 stub_group_size
= 7680000;
2630 if (htab
->has_17bit_branch
|| htab
->multi_subspace
)
2631 stub_group_size
= 240000;
2632 if (htab
->has_12bit_branch
)
2633 stub_group_size
= 7500;
2637 stub_group_size
= 6971392;
2638 if (htab
->has_17bit_branch
|| htab
->multi_subspace
)
2639 stub_group_size
= 217856;
2640 if (htab
->has_12bit_branch
)
2641 stub_group_size
= 6808;
2645 group_sections (htab
, stub_group_size
, stubs_always_before_branch
);
2647 switch (get_local_syms (output_bfd
, info
->input_bfds
, info
))
2650 if (htab
->all_local_syms
)
2651 goto error_ret_free_local
;
2655 stub_changed
= FALSE
;
2659 stub_changed
= TRUE
;
2666 unsigned int bfd_indx
;
2669 for (input_bfd
= info
->input_bfds
, bfd_indx
= 0;
2671 input_bfd
= input_bfd
->link
.next
, bfd_indx
++)
2673 Elf_Internal_Shdr
*symtab_hdr
;
2675 Elf_Internal_Sym
*local_syms
;
2677 /* We'll need the symbol table in a second. */
2678 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
2679 if (symtab_hdr
->sh_info
== 0)
2682 local_syms
= htab
->all_local_syms
[bfd_indx
];
2684 /* Walk over each section attached to the input bfd. */
2685 for (section
= input_bfd
->sections
;
2687 section
= section
->next
)
2689 Elf_Internal_Rela
*internal_relocs
, *irelaend
, *irela
;
2691 /* If there aren't any relocs, then there's nothing more
2693 if ((section
->flags
& SEC_RELOC
) == 0
2694 || (section
->flags
& SEC_ALLOC
) == 0
2695 || (section
->flags
& SEC_LOAD
) == 0
2696 || (section
->flags
& SEC_CODE
) == 0
2697 || section
->reloc_count
== 0)
2700 /* If this section is a link-once section that will be
2701 discarded, then don't create any stubs. */
2702 if (section
->output_section
== NULL
2703 || section
->output_section
->owner
!= output_bfd
)
2706 /* Get the relocs. */
2708 = _bfd_elf_link_read_relocs (input_bfd
, section
, NULL
, NULL
,
2710 if (internal_relocs
== NULL
)
2711 goto error_ret_free_local
;
2713 /* Now examine each relocation. */
2714 irela
= internal_relocs
;
2715 irelaend
= irela
+ section
->reloc_count
;
2716 for (; irela
< irelaend
; irela
++)
2718 unsigned int r_type
, r_indx
;
2719 enum elf32_hppa_stub_type stub_type
;
2720 struct elf32_hppa_stub_hash_entry
*hsh
;
2723 bfd_vma destination
;
2724 struct elf32_hppa_link_hash_entry
*hh
;
2726 const asection
*id_sec
;
2728 r_type
= ELF32_R_TYPE (irela
->r_info
);
2729 r_indx
= ELF32_R_SYM (irela
->r_info
);
2731 if (r_type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
2733 bfd_set_error (bfd_error_bad_value
);
2734 error_ret_free_internal
:
2735 if (elf_section_data (section
)->relocs
== NULL
)
2736 free (internal_relocs
);
2737 goto error_ret_free_local
;
2740 /* Only look for stubs on call instructions. */
2741 if (r_type
!= (unsigned int) R_PARISC_PCREL12F
2742 && r_type
!= (unsigned int) R_PARISC_PCREL17F
2743 && r_type
!= (unsigned int) R_PARISC_PCREL22F
)
2746 /* Now determine the call target, its name, value,
2752 if (r_indx
< symtab_hdr
->sh_info
)
2754 /* It's a local symbol. */
2755 Elf_Internal_Sym
*sym
;
2756 Elf_Internal_Shdr
*hdr
;
2759 sym
= local_syms
+ r_indx
;
2760 if (ELF_ST_TYPE (sym
->st_info
) != STT_SECTION
)
2761 sym_value
= sym
->st_value
;
2762 shndx
= sym
->st_shndx
;
2763 if (shndx
< elf_numsections (input_bfd
))
2765 hdr
= elf_elfsections (input_bfd
)[shndx
];
2766 sym_sec
= hdr
->bfd_section
;
2767 destination
= (sym_value
+ irela
->r_addend
2768 + sym_sec
->output_offset
2769 + sym_sec
->output_section
->vma
);
2774 /* It's an external symbol. */
2777 e_indx
= r_indx
- symtab_hdr
->sh_info
;
2778 hh
= hppa_elf_hash_entry (elf_sym_hashes (input_bfd
)[e_indx
]);
2780 while (hh
->eh
.root
.type
== bfd_link_hash_indirect
2781 || hh
->eh
.root
.type
== bfd_link_hash_warning
)
2782 hh
= hppa_elf_hash_entry (hh
->eh
.root
.u
.i
.link
);
2784 if (hh
->eh
.root
.type
== bfd_link_hash_defined
2785 || hh
->eh
.root
.type
== bfd_link_hash_defweak
)
2787 sym_sec
= hh
->eh
.root
.u
.def
.section
;
2788 sym_value
= hh
->eh
.root
.u
.def
.value
;
2789 if (sym_sec
->output_section
!= NULL
)
2790 destination
= (sym_value
+ irela
->r_addend
2791 + sym_sec
->output_offset
2792 + sym_sec
->output_section
->vma
);
2794 else if (hh
->eh
.root
.type
== bfd_link_hash_undefweak
)
2796 if (! bfd_link_pic (info
))
2799 else if (hh
->eh
.root
.type
== bfd_link_hash_undefined
)
2801 if (! (info
->unresolved_syms_in_objects
== RM_IGNORE
2802 && (ELF_ST_VISIBILITY (hh
->eh
.other
)
2804 && hh
->eh
.type
!= STT_PARISC_MILLI
))
2809 bfd_set_error (bfd_error_bad_value
);
2810 goto error_ret_free_internal
;
2814 /* Determine what (if any) linker stub is needed. */
2815 stub_type
= hppa_type_of_stub (section
, irela
, hh
,
2817 if (stub_type
== hppa_stub_none
)
2820 /* Support for grouping stub sections. */
2821 id_sec
= htab
->stub_group
[section
->id
].link_sec
;
2823 /* Get the name of this stub. */
2824 stub_name
= hppa_stub_name (id_sec
, sym_sec
, hh
, irela
);
2826 goto error_ret_free_internal
;
2828 hsh
= hppa_stub_hash_lookup (&htab
->bstab
,
2833 /* The proper stub has already been created. */
2838 hsh
= hppa_add_stub (stub_name
, section
, htab
);
2842 goto error_ret_free_internal
;
2845 hsh
->target_value
= sym_value
;
2846 hsh
->target_section
= sym_sec
;
2847 hsh
->stub_type
= stub_type
;
2848 if (bfd_link_pic (info
))
2850 if (stub_type
== hppa_stub_import
)
2851 hsh
->stub_type
= hppa_stub_import_shared
;
2852 else if (stub_type
== hppa_stub_long_branch
)
2853 hsh
->stub_type
= hppa_stub_long_branch_shared
;
2856 stub_changed
= TRUE
;
2859 /* We're done with the internal relocs, free them. */
2860 if (elf_section_data (section
)->relocs
== NULL
)
2861 free (internal_relocs
);
2868 /* OK, we've added some stubs. Find out the new size of the
2870 for (stub_sec
= htab
->stub_bfd
->sections
;
2872 stub_sec
= stub_sec
->next
)
2873 if ((stub_sec
->flags
& SEC_LINKER_CREATED
) == 0)
2876 bfd_hash_traverse (&htab
->bstab
, hppa_size_one_stub
, htab
);
2878 /* Ask the linker to do its stuff. */
2879 (*htab
->layout_sections_again
) ();
2880 stub_changed
= FALSE
;
2883 free (htab
->all_local_syms
);
2886 error_ret_free_local
:
2887 free (htab
->all_local_syms
);
2891 /* For a final link, this function is called after we have sized the
2892 stubs to provide a value for __gp. */
2895 elf32_hppa_set_gp (bfd
*abfd
, struct bfd_link_info
*info
)
2897 struct bfd_link_hash_entry
*h
;
2898 asection
*sec
= NULL
;
2901 h
= bfd_link_hash_lookup (info
->hash
, "$global$", FALSE
, FALSE
, FALSE
);
2904 && (h
->type
== bfd_link_hash_defined
2905 || h
->type
== bfd_link_hash_defweak
))
2907 gp_val
= h
->u
.def
.value
;
2908 sec
= h
->u
.def
.section
;
2912 asection
*splt
= bfd_get_section_by_name (abfd
, ".plt");
2913 asection
*sgot
= bfd_get_section_by_name (abfd
, ".got");
2915 /* Choose to point our LTP at, in this order, one of .plt, .got,
2916 or .data, if these sections exist. In the case of choosing
2917 .plt try to make the LTP ideal for addressing anywhere in the
2918 .plt or .got with a 14 bit signed offset. Typically, the end
2919 of the .plt is the start of the .got, so choose .plt + 0x2000
2920 if either the .plt or .got is larger than 0x2000. If both
2921 the .plt and .got are smaller than 0x2000, choose the end of
2922 the .plt section. */
2923 sec
= strcmp (bfd_get_target (abfd
), "elf32-hppa-netbsd") == 0
2928 if (gp_val
> 0x2000 || (sgot
&& sgot
->size
> 0x2000))
2938 if (strcmp (bfd_get_target (abfd
), "elf32-hppa-netbsd") != 0)
2940 /* We know we don't have a .plt. If .got is large,
2942 if (sec
->size
> 0x2000)
2948 /* No .plt or .got. Who cares what the LTP is? */
2949 sec
= bfd_get_section_by_name (abfd
, ".data");
2955 h
->type
= bfd_link_hash_defined
;
2956 h
->u
.def
.value
= gp_val
;
2958 h
->u
.def
.section
= sec
;
2960 h
->u
.def
.section
= bfd_abs_section_ptr
;
2964 if (bfd_get_flavour (abfd
) == bfd_target_elf_flavour
)
2966 if (sec
!= NULL
&& sec
->output_section
!= NULL
)
2967 gp_val
+= sec
->output_section
->vma
+ sec
->output_offset
;
2969 elf_gp (abfd
) = gp_val
;
2974 /* Build all the stubs associated with the current output file. The
2975 stubs are kept in a hash table attached to the main linker hash
2976 table. We also set up the .plt entries for statically linked PIC
2977 functions here. This function is called via hppaelf_finish in the
2981 elf32_hppa_build_stubs (struct bfd_link_info
*info
)
2984 struct bfd_hash_table
*table
;
2985 struct elf32_hppa_link_hash_table
*htab
;
2987 htab
= hppa_link_hash_table (info
);
2991 for (stub_sec
= htab
->stub_bfd
->sections
;
2993 stub_sec
= stub_sec
->next
)
2994 if ((stub_sec
->flags
& SEC_LINKER_CREATED
) == 0
2995 && stub_sec
->size
!= 0)
2997 /* Allocate memory to hold the linker stubs. */
2998 stub_sec
->contents
= bfd_zalloc (htab
->stub_bfd
, stub_sec
->size
);
2999 if (stub_sec
->contents
== NULL
)
3004 /* Build the stubs as directed by the stub hash table. */
3005 table
= &htab
->bstab
;
3006 bfd_hash_traverse (table
, hppa_build_one_stub
, info
);
3011 /* Return the base vma address which should be subtracted from the real
3012 address when resolving a dtpoff relocation.
3013 This is PT_TLS segment p_vaddr. */
3016 dtpoff_base (struct bfd_link_info
*info
)
3018 /* If tls_sec is NULL, we should have signalled an error already. */
3019 if (elf_hash_table (info
)->tls_sec
== NULL
)
3021 return elf_hash_table (info
)->tls_sec
->vma
;
3024 /* Return the relocation value for R_PARISC_TLS_TPOFF*.. */
3027 tpoff (struct bfd_link_info
*info
, bfd_vma address
)
3029 struct elf_link_hash_table
*htab
= elf_hash_table (info
);
3031 /* If tls_sec is NULL, we should have signalled an error already. */
3032 if (htab
->tls_sec
== NULL
)
3034 /* hppa TLS ABI is variant I and static TLS block start just after
3035 tcbhead structure which has 2 pointer fields. */
3036 return (address
- htab
->tls_sec
->vma
3037 + align_power ((bfd_vma
) 8, htab
->tls_sec
->alignment_power
));
3040 /* Perform a final link. */
3043 elf32_hppa_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
3047 /* Invoke the regular ELF linker to do all the work. */
3048 if (!bfd_elf_final_link (abfd
, info
))
3051 /* If we're producing a final executable, sort the contents of the
3053 if (bfd_link_relocatable (info
))
3056 /* Do not attempt to sort non-regular files. This is here
3057 especially for configure scripts and kernel builds which run
3058 tests with "ld [...] -o /dev/null". */
3059 if (stat (bfd_get_filename (abfd
), &buf
) != 0
3060 || !S_ISREG(buf
.st_mode
))
3063 return elf_hppa_sort_unwind (abfd
);
3066 /* Record the lowest address for the data and text segments. */
3069 hppa_record_segment_addr (bfd
*abfd
, asection
*section
, void *data
)
3071 struct elf32_hppa_link_hash_table
*htab
;
3073 htab
= (struct elf32_hppa_link_hash_table
*) data
;
3077 if ((section
->flags
& (SEC_ALLOC
| SEC_LOAD
)) == (SEC_ALLOC
| SEC_LOAD
))
3080 Elf_Internal_Phdr
*p
;
3082 p
= _bfd_elf_find_segment_containing_section (abfd
, section
->output_section
);
3083 BFD_ASSERT (p
!= NULL
);
3086 if ((section
->flags
& SEC_READONLY
) != 0)
3088 if (value
< htab
->text_segment_base
)
3089 htab
->text_segment_base
= value
;
3093 if (value
< htab
->data_segment_base
)
3094 htab
->data_segment_base
= value
;
3099 /* Perform a relocation as part of a final link. */
3101 static bfd_reloc_status_type
3102 final_link_relocate (asection
*input_section
,
3104 const Elf_Internal_Rela
*rela
,
3106 struct elf32_hppa_link_hash_table
*htab
,
3108 struct elf32_hppa_link_hash_entry
*hh
,
3109 struct bfd_link_info
*info
)
3112 unsigned int r_type
= ELF32_R_TYPE (rela
->r_info
);
3113 unsigned int orig_r_type
= r_type
;
3114 reloc_howto_type
*howto
= elf_hppa_howto_table
+ r_type
;
3115 int r_format
= howto
->bitsize
;
3116 enum hppa_reloc_field_selector_type_alt r_field
;
3117 bfd
*input_bfd
= input_section
->owner
;
3118 bfd_vma offset
= rela
->r_offset
;
3119 bfd_vma max_branch_offset
= 0;
3120 bfd_byte
*hit_data
= contents
+ offset
;
3121 bfd_signed_vma addend
= rela
->r_addend
;
3123 struct elf32_hppa_stub_hash_entry
*hsh
= NULL
;
3126 if (r_type
== R_PARISC_NONE
)
3127 return bfd_reloc_ok
;
3129 insn
= bfd_get_32 (input_bfd
, hit_data
);
3131 /* Find out where we are and where we're going. */
3132 location
= (offset
+
3133 input_section
->output_offset
+
3134 input_section
->output_section
->vma
);
3136 /* If we are not building a shared library, convert DLTIND relocs to
3138 if (!bfd_link_pic (info
))
3142 case R_PARISC_DLTIND21L
:
3143 case R_PARISC_TLS_GD21L
:
3144 case R_PARISC_TLS_LDM21L
:
3145 case R_PARISC_TLS_IE21L
:
3146 r_type
= R_PARISC_DPREL21L
;
3149 case R_PARISC_DLTIND14R
:
3150 case R_PARISC_TLS_GD14R
:
3151 case R_PARISC_TLS_LDM14R
:
3152 case R_PARISC_TLS_IE14R
:
3153 r_type
= R_PARISC_DPREL14R
;
3156 case R_PARISC_DLTIND14F
:
3157 r_type
= R_PARISC_DPREL14F
;
3164 case R_PARISC_PCREL12F
:
3165 case R_PARISC_PCREL17F
:
3166 case R_PARISC_PCREL22F
:
3167 /* If this call should go via the plt, find the import stub in
3170 || sym_sec
->output_section
== NULL
3172 && hh
->eh
.plt
.offset
!= (bfd_vma
) -1
3173 && hh
->eh
.dynindx
!= -1
3175 && (bfd_link_pic (info
)
3176 || !hh
->eh
.def_regular
3177 || hh
->eh
.root
.type
== bfd_link_hash_defweak
)))
3179 hsh
= hppa_get_stub_entry (input_section
, sym_sec
,
3183 value
= (hsh
->stub_offset
3184 + hsh
->stub_sec
->output_offset
3185 + hsh
->stub_sec
->output_section
->vma
);
3188 else if (sym_sec
== NULL
&& hh
!= NULL
3189 && hh
->eh
.root
.type
== bfd_link_hash_undefweak
)
3191 /* It's OK if undefined weak. Calls to undefined weak
3192 symbols behave as if the "called" function
3193 immediately returns. We can thus call to a weak
3194 function without first checking whether the function
3200 return bfd_reloc_undefined
;
3204 case R_PARISC_PCREL21L
:
3205 case R_PARISC_PCREL17C
:
3206 case R_PARISC_PCREL17R
:
3207 case R_PARISC_PCREL14R
:
3208 case R_PARISC_PCREL14F
:
3209 case R_PARISC_PCREL32
:
3210 /* Make it a pc relative offset. */
3215 case R_PARISC_DPREL21L
:
3216 case R_PARISC_DPREL14R
:
3217 case R_PARISC_DPREL14F
:
3218 /* Convert instructions that use the linkage table pointer (r19) to
3219 instructions that use the global data pointer (dp). This is the
3220 most efficient way of using PIC code in an incomplete executable,
3221 but the user must follow the standard runtime conventions for
3222 accessing data for this to work. */
3223 if (orig_r_type
!= r_type
)
3225 if (r_type
== R_PARISC_DPREL21L
)
3227 /* GCC sometimes uses a register other than r19 for the
3228 operation, so we must convert any addil instruction
3229 that uses this relocation. */
3230 if ((insn
& 0xfc000000) == OP_ADDIL
<< 26)
3233 /* We must have a ldil instruction. It's too hard to find
3234 and convert the associated add instruction, so issue an
3237 /* xgettext:c-format */
3238 (_("%pB(%pA+%#" PRIx64
"): %s fixup for insn %#x "
3239 "is not supported in a non-shared link"),
3246 else if (r_type
== R_PARISC_DPREL14F
)
3248 /* This must be a format 1 load/store. Change the base
3250 insn
= (insn
& 0xfc1ffff) | (27 << 21);
3254 /* For all the DP relative relocations, we need to examine the symbol's
3255 section. If it has no section or if it's a code section, then
3256 "data pointer relative" makes no sense. In that case we don't
3257 adjust the "value", and for 21 bit addil instructions, we change the
3258 source addend register from %dp to %r0. This situation commonly
3259 arises for undefined weak symbols and when a variable's "constness"
3260 is declared differently from the way the variable is defined. For
3261 instance: "extern int foo" with foo defined as "const int foo". */
3262 if (sym_sec
== NULL
|| (sym_sec
->flags
& SEC_CODE
) != 0)
3264 if ((insn
& ((0x3fu
<< 26) | (0x1f << 21)))
3265 == ((OP_ADDIL
<< 26) | (27 << 21)))
3267 insn
&= ~ (0x1f << 21);
3269 /* Now try to make things easy for the dynamic linker. */
3275 case R_PARISC_DLTIND21L
:
3276 case R_PARISC_DLTIND14R
:
3277 case R_PARISC_DLTIND14F
:
3278 case R_PARISC_TLS_GD21L
:
3279 case R_PARISC_TLS_LDM21L
:
3280 case R_PARISC_TLS_IE21L
:
3281 case R_PARISC_TLS_GD14R
:
3282 case R_PARISC_TLS_LDM14R
:
3283 case R_PARISC_TLS_IE14R
:
3284 value
-= elf_gp (input_section
->output_section
->owner
);
3287 case R_PARISC_SEGREL32
:
3288 if ((sym_sec
->flags
& SEC_CODE
) != 0)
3289 value
-= htab
->text_segment_base
;
3291 value
-= htab
->data_segment_base
;
3300 case R_PARISC_DIR32
:
3301 case R_PARISC_DIR14F
:
3302 case R_PARISC_DIR17F
:
3303 case R_PARISC_PCREL17C
:
3304 case R_PARISC_PCREL14F
:
3305 case R_PARISC_PCREL32
:
3306 case R_PARISC_DPREL14F
:
3307 case R_PARISC_PLABEL32
:
3308 case R_PARISC_DLTIND14F
:
3309 case R_PARISC_SEGBASE
:
3310 case R_PARISC_SEGREL32
:
3311 case R_PARISC_TLS_DTPMOD32
:
3312 case R_PARISC_TLS_DTPOFF32
:
3313 case R_PARISC_TLS_TPREL32
:
3317 case R_PARISC_DLTIND21L
:
3318 case R_PARISC_PCREL21L
:
3319 case R_PARISC_PLABEL21L
:
3323 case R_PARISC_DIR21L
:
3324 case R_PARISC_DPREL21L
:
3325 case R_PARISC_TLS_GD21L
:
3326 case R_PARISC_TLS_LDM21L
:
3327 case R_PARISC_TLS_LDO21L
:
3328 case R_PARISC_TLS_IE21L
:
3329 case R_PARISC_TLS_LE21L
:
3333 case R_PARISC_PCREL17R
:
3334 case R_PARISC_PCREL14R
:
3335 case R_PARISC_PLABEL14R
:
3336 case R_PARISC_DLTIND14R
:
3340 case R_PARISC_DIR17R
:
3341 case R_PARISC_DIR14R
:
3342 case R_PARISC_DPREL14R
:
3343 case R_PARISC_TLS_GD14R
:
3344 case R_PARISC_TLS_LDM14R
:
3345 case R_PARISC_TLS_LDO14R
:
3346 case R_PARISC_TLS_IE14R
:
3347 case R_PARISC_TLS_LE14R
:
3351 case R_PARISC_PCREL12F
:
3352 case R_PARISC_PCREL17F
:
3353 case R_PARISC_PCREL22F
:
3356 if (r_type
== (unsigned int) R_PARISC_PCREL17F
)
3358 max_branch_offset
= (1 << (17-1)) << 2;
3360 else if (r_type
== (unsigned int) R_PARISC_PCREL12F
)
3362 max_branch_offset
= (1 << (12-1)) << 2;
3366 max_branch_offset
= (1 << (22-1)) << 2;
3369 /* sym_sec is NULL on undefined weak syms or when shared on
3370 undefined syms. We've already checked for a stub for the
3371 shared undefined case. */
3372 if (sym_sec
== NULL
)
3375 /* If the branch is out of reach, then redirect the
3376 call to the local stub for this function. */
3377 if (value
+ addend
+ max_branch_offset
>= 2*max_branch_offset
)
3379 hsh
= hppa_get_stub_entry (input_section
, sym_sec
,
3382 return bfd_reloc_undefined
;
3384 /* Munge up the value and addend so that we call the stub
3385 rather than the procedure directly. */
3386 value
= (hsh
->stub_offset
3387 + hsh
->stub_sec
->output_offset
3388 + hsh
->stub_sec
->output_section
->vma
3394 /* Something we don't know how to handle. */
3396 return bfd_reloc_notsupported
;
3399 /* Make sure we can reach the stub. */
3400 if (max_branch_offset
!= 0
3401 && value
+ addend
+ max_branch_offset
>= 2*max_branch_offset
)
3404 /* xgettext:c-format */
3405 (_("%pB(%pA+%#" PRIx64
"): cannot reach %s, "
3406 "recompile with -ffunction-sections"),
3410 hsh
->bh_root
.string
);
3411 bfd_set_error (bfd_error_bad_value
);
3412 return bfd_reloc_notsupported
;
3415 val
= hppa_field_adjust (value
, addend
, r_field
);
3419 case R_PARISC_PCREL12F
:
3420 case R_PARISC_PCREL17C
:
3421 case R_PARISC_PCREL17F
:
3422 case R_PARISC_PCREL17R
:
3423 case R_PARISC_PCREL22F
:
3424 case R_PARISC_DIR17F
:
3425 case R_PARISC_DIR17R
:
3426 /* This is a branch. Divide the offset by four.
3427 Note that we need to decide whether it's a branch or
3428 otherwise by inspecting the reloc. Inspecting insn won't
3429 work as insn might be from a .word directive. */
3437 insn
= hppa_rebuild_insn (insn
, val
, r_format
);
3439 /* Update the instruction word. */
3440 bfd_put_32 (input_bfd
, (bfd_vma
) insn
, hit_data
);
3441 return bfd_reloc_ok
;
3444 /* Relocate an HPPA ELF section. */
3447 elf32_hppa_relocate_section (bfd
*output_bfd
,
3448 struct bfd_link_info
*info
,
3450 asection
*input_section
,
3452 Elf_Internal_Rela
*relocs
,
3453 Elf_Internal_Sym
*local_syms
,
3454 asection
**local_sections
)
3456 bfd_vma
*local_got_offsets
;
3457 struct elf32_hppa_link_hash_table
*htab
;
3458 Elf_Internal_Shdr
*symtab_hdr
;
3459 Elf_Internal_Rela
*rela
;
3460 Elf_Internal_Rela
*relend
;
3462 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
3464 htab
= hppa_link_hash_table (info
);
3468 local_got_offsets
= elf_local_got_offsets (input_bfd
);
3471 relend
= relocs
+ input_section
->reloc_count
;
3472 for (; rela
< relend
; rela
++)
3474 unsigned int r_type
;
3475 reloc_howto_type
*howto
;
3476 unsigned int r_symndx
;
3477 struct elf32_hppa_link_hash_entry
*hh
;
3478 Elf_Internal_Sym
*sym
;
3481 bfd_reloc_status_type rstatus
;
3482 const char *sym_name
;
3484 bfd_boolean warned_undef
;
3486 r_type
= ELF32_R_TYPE (rela
->r_info
);
3487 if (r_type
>= (unsigned int) R_PARISC_UNIMPLEMENTED
)
3489 bfd_set_error (bfd_error_bad_value
);
3492 if (r_type
== (unsigned int) R_PARISC_GNU_VTENTRY
3493 || r_type
== (unsigned int) R_PARISC_GNU_VTINHERIT
)
3496 r_symndx
= ELF32_R_SYM (rela
->r_info
);
3500 warned_undef
= FALSE
;
3501 if (r_symndx
< symtab_hdr
->sh_info
)
3503 /* This is a local symbol, h defaults to NULL. */
3504 sym
= local_syms
+ r_symndx
;
3505 sym_sec
= local_sections
[r_symndx
];
3506 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, &sym_sec
, rela
);
3510 struct elf_link_hash_entry
*eh
;
3511 bfd_boolean unresolved_reloc
, ignored
;
3512 struct elf_link_hash_entry
**sym_hashes
= elf_sym_hashes (input_bfd
);
3514 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rela
,
3515 r_symndx
, symtab_hdr
, sym_hashes
,
3516 eh
, sym_sec
, relocation
,
3517 unresolved_reloc
, warned_undef
,
3520 if (!bfd_link_relocatable (info
)
3522 && eh
->root
.type
!= bfd_link_hash_defined
3523 && eh
->root
.type
!= bfd_link_hash_defweak
3524 && eh
->root
.type
!= bfd_link_hash_undefweak
)
3526 if (info
->unresolved_syms_in_objects
== RM_IGNORE
3527 && ELF_ST_VISIBILITY (eh
->other
) == STV_DEFAULT
3528 && eh
->type
== STT_PARISC_MILLI
)
3530 (*info
->callbacks
->undefined_symbol
)
3531 (info
, eh_name (eh
), input_bfd
,
3532 input_section
, rela
->r_offset
, FALSE
);
3533 warned_undef
= TRUE
;
3536 hh
= hppa_elf_hash_entry (eh
);
3539 if (sym_sec
!= NULL
&& discarded_section (sym_sec
))
3540 RELOC_AGAINST_DISCARDED_SECTION (info
, input_bfd
, input_section
,
3542 elf_hppa_howto_table
+ r_type
, 0,
3545 if (bfd_link_relocatable (info
))
3548 /* Do any required modifications to the relocation value, and
3549 determine what types of dynamic info we need to output, if
3554 case R_PARISC_DLTIND14F
:
3555 case R_PARISC_DLTIND14R
:
3556 case R_PARISC_DLTIND21L
:
3559 bfd_boolean do_got
= FALSE
;
3560 bfd_boolean reloc
= bfd_link_pic (info
);
3562 /* Relocation is to the entry for this symbol in the
3563 global offset table. */
3568 off
= hh
->eh
.got
.offset
;
3569 dyn
= htab
->etab
.dynamic_sections_created
;
3570 reloc
= (!UNDEFWEAK_NO_DYNAMIC_RELOC (info
, &hh
->eh
)
3572 || (hh
->eh
.dynindx
!= -1
3573 && !SYMBOL_REFERENCES_LOCAL (info
, &hh
->eh
))));
3575 || !WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
,
3576 bfd_link_pic (info
),
3579 /* If we aren't going to call finish_dynamic_symbol,
3580 then we need to handle initialisation of the .got
3581 entry and create needed relocs here. Since the
3582 offset must always be a multiple of 4, we use the
3583 least significant bit to record whether we have
3584 initialised it already. */
3589 hh
->eh
.got
.offset
|= 1;
3596 /* Local symbol case. */
3597 if (local_got_offsets
== NULL
)
3600 off
= local_got_offsets
[r_symndx
];
3602 /* The offset must always be a multiple of 4. We use
3603 the least significant bit to record whether we have
3604 already generated the necessary reloc. */
3609 local_got_offsets
[r_symndx
] |= 1;
3618 /* Output a dynamic relocation for this GOT entry.
3619 In this case it is relative to the base of the
3620 object because the symbol index is zero. */
3621 Elf_Internal_Rela outrel
;
3623 asection
*sec
= htab
->etab
.srelgot
;
3625 outrel
.r_offset
= (off
3626 + htab
->etab
.sgot
->output_offset
3627 + htab
->etab
.sgot
->output_section
->vma
);
3628 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_DIR32
);
3629 outrel
.r_addend
= relocation
;
3630 loc
= sec
->contents
;
3631 loc
+= sec
->reloc_count
++ * sizeof (Elf32_External_Rela
);
3632 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
3635 bfd_put_32 (output_bfd
, relocation
,
3636 htab
->etab
.sgot
->contents
+ off
);
3639 if (off
>= (bfd_vma
) -2)
3642 /* Add the base of the GOT to the relocation value. */
3644 + htab
->etab
.sgot
->output_offset
3645 + htab
->etab
.sgot
->output_section
->vma
);
3649 case R_PARISC_SEGREL32
:
3650 /* If this is the first SEGREL relocation, then initialize
3651 the segment base values. */
3652 if (htab
->text_segment_base
== (bfd_vma
) -1)
3653 bfd_map_over_sections (output_bfd
, hppa_record_segment_addr
, htab
);
3656 case R_PARISC_PLABEL14R
:
3657 case R_PARISC_PLABEL21L
:
3658 case R_PARISC_PLABEL32
:
3659 if (htab
->etab
.dynamic_sections_created
)
3662 bfd_boolean do_plt
= 0;
3663 /* If we have a global symbol with a PLT slot, then
3664 redirect this relocation to it. */
3667 off
= hh
->eh
.plt
.offset
;
3668 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (1,
3669 bfd_link_pic (info
),
3672 /* In a non-shared link, adjust_dynamic_symbol
3673 isn't called for symbols forced local. We
3674 need to write out the plt entry here. */
3679 hh
->eh
.plt
.offset
|= 1;
3686 bfd_vma
*local_plt_offsets
;
3688 if (local_got_offsets
== NULL
)
3691 local_plt_offsets
= local_got_offsets
+ symtab_hdr
->sh_info
;
3692 off
= local_plt_offsets
[r_symndx
];
3694 /* As for the local .got entry case, we use the last
3695 bit to record whether we've already initialised
3696 this local .plt entry. */
3701 local_plt_offsets
[r_symndx
] |= 1;
3708 if (bfd_link_pic (info
))
3710 /* Output a dynamic IPLT relocation for this
3712 Elf_Internal_Rela outrel
;
3714 asection
*s
= htab
->etab
.srelplt
;
3716 outrel
.r_offset
= (off
3717 + htab
->etab
.splt
->output_offset
3718 + htab
->etab
.splt
->output_section
->vma
);
3719 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_IPLT
);
3720 outrel
.r_addend
= relocation
;
3722 loc
+= s
->reloc_count
++ * sizeof (Elf32_External_Rela
);
3723 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
3727 bfd_put_32 (output_bfd
,
3729 htab
->etab
.splt
->contents
+ off
);
3730 bfd_put_32 (output_bfd
,
3731 elf_gp (htab
->etab
.splt
->output_section
->owner
),
3732 htab
->etab
.splt
->contents
+ off
+ 4);
3736 if (off
>= (bfd_vma
) -2)
3739 /* PLABELs contain function pointers. Relocation is to
3740 the entry for the function in the .plt. The magic +2
3741 offset signals to $$dyncall that the function pointer
3742 is in the .plt and thus has a gp pointer too.
3743 Exception: Undefined PLABELs should have a value of
3746 || (hh
->eh
.root
.type
!= bfd_link_hash_undefweak
3747 && hh
->eh
.root
.type
!= bfd_link_hash_undefined
))
3750 + htab
->etab
.splt
->output_offset
3751 + htab
->etab
.splt
->output_section
->vma
3758 case R_PARISC_DIR17F
:
3759 case R_PARISC_DIR17R
:
3760 case R_PARISC_DIR14F
:
3761 case R_PARISC_DIR14R
:
3762 case R_PARISC_DIR21L
:
3763 case R_PARISC_DPREL14F
:
3764 case R_PARISC_DPREL14R
:
3765 case R_PARISC_DPREL21L
:
3766 case R_PARISC_DIR32
:
3767 if ((input_section
->flags
& SEC_ALLOC
) == 0)
3770 if (bfd_link_pic (info
)
3772 || hh
->eh
.dyn_relocs
!= NULL
)
3773 && ((hh
!= NULL
&& pc_dynrelocs (hh
))
3774 || IS_ABSOLUTE_RELOC (r_type
)))
3776 && hh
->eh
.dyn_relocs
!= NULL
))
3778 Elf_Internal_Rela outrel
;
3783 /* When generating a shared object, these relocations
3784 are copied into the output file to be resolved at run
3787 outrel
.r_addend
= rela
->r_addend
;
3789 _bfd_elf_section_offset (output_bfd
, info
, input_section
,
3791 skip
= (outrel
.r_offset
== (bfd_vma
) -1
3792 || outrel
.r_offset
== (bfd_vma
) -2);
3793 outrel
.r_offset
+= (input_section
->output_offset
3794 + input_section
->output_section
->vma
);
3798 memset (&outrel
, 0, sizeof (outrel
));
3801 && hh
->eh
.dynindx
!= -1
3803 || !IS_ABSOLUTE_RELOC (r_type
)
3804 || !bfd_link_pic (info
)
3805 || !SYMBOLIC_BIND (info
, &hh
->eh
)
3806 || !hh
->eh
.def_regular
))
3808 outrel
.r_info
= ELF32_R_INFO (hh
->eh
.dynindx
, r_type
);
3810 else /* It's a local symbol, or one marked to become local. */
3814 /* Add the absolute offset of the symbol. */
3815 outrel
.r_addend
+= relocation
;
3817 /* Global plabels need to be processed by the
3818 dynamic linker so that functions have at most one
3819 fptr. For this reason, we need to differentiate
3820 between global and local plabels, which we do by
3821 providing the function symbol for a global plabel
3822 reloc, and no symbol for local plabels. */
3825 && sym_sec
->output_section
!= NULL
3826 && ! bfd_is_abs_section (sym_sec
))
3830 osec
= sym_sec
->output_section
;
3831 indx
= elf_section_data (osec
)->dynindx
;
3834 osec
= htab
->etab
.text_index_section
;
3835 indx
= elf_section_data (osec
)->dynindx
;
3837 BFD_ASSERT (indx
!= 0);
3839 /* We are turning this relocation into one
3840 against a section symbol, so subtract out the
3841 output section's address but not the offset
3842 of the input section in the output section. */
3843 outrel
.r_addend
-= osec
->vma
;
3846 outrel
.r_info
= ELF32_R_INFO (indx
, r_type
);
3848 sreloc
= elf_section_data (input_section
)->sreloc
;
3852 loc
= sreloc
->contents
;
3853 loc
+= sreloc
->reloc_count
++ * sizeof (Elf32_External_Rela
);
3854 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
3858 case R_PARISC_TLS_LDM21L
:
3859 case R_PARISC_TLS_LDM14R
:
3863 off
= htab
->tls_ldm_got
.offset
;
3868 Elf_Internal_Rela outrel
;
3871 outrel
.r_offset
= (off
3872 + htab
->etab
.sgot
->output_section
->vma
3873 + htab
->etab
.sgot
->output_offset
);
3874 outrel
.r_addend
= 0;
3875 outrel
.r_info
= ELF32_R_INFO (0, R_PARISC_TLS_DTPMOD32
);
3876 loc
= htab
->etab
.srelgot
->contents
;
3877 loc
+= htab
->etab
.srelgot
->reloc_count
++ * sizeof (Elf32_External_Rela
);
3879 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
3880 htab
->tls_ldm_got
.offset
|= 1;
3883 /* Add the base of the GOT to the relocation value. */
3885 + htab
->etab
.sgot
->output_offset
3886 + htab
->etab
.sgot
->output_section
->vma
);
3891 case R_PARISC_TLS_LDO21L
:
3892 case R_PARISC_TLS_LDO14R
:
3893 relocation
-= dtpoff_base (info
);
3896 case R_PARISC_TLS_GD21L
:
3897 case R_PARISC_TLS_GD14R
:
3898 case R_PARISC_TLS_IE21L
:
3899 case R_PARISC_TLS_IE14R
:
3908 if (!htab
->etab
.dynamic_sections_created
3909 || hh
->eh
.dynindx
== -1
3910 || SYMBOL_REFERENCES_LOCAL (info
, &hh
->eh
)
3911 || UNDEFWEAK_NO_DYNAMIC_RELOC (info
, &hh
->eh
))
3912 /* This is actually a static link, or it is a
3913 -Bsymbolic link and the symbol is defined
3914 locally, or the symbol was forced to be local
3915 because of a version file. */
3918 indx
= hh
->eh
.dynindx
;
3919 off
= hh
->eh
.got
.offset
;
3920 tls_type
= hh
->tls_type
;
3924 off
= local_got_offsets
[r_symndx
];
3925 tls_type
= hppa_elf_local_got_tls_type (input_bfd
)[r_symndx
];
3928 if (tls_type
== GOT_UNKNOWN
)
3935 bfd_boolean need_relocs
= FALSE
;
3936 Elf_Internal_Rela outrel
;
3937 bfd_byte
*loc
= NULL
;
3940 /* The GOT entries have not been initialized yet. Do it
3941 now, and emit any relocations. If both an IE GOT and a
3942 GD GOT are necessary, we emit the GD first. */
3945 || (bfd_link_dll (info
)
3947 || !UNDEFWEAK_NO_DYNAMIC_RELOC (info
, &hh
->eh
))))
3950 loc
= htab
->etab
.srelgot
->contents
;
3951 loc
+= (htab
->etab
.srelgot
->reloc_count
3952 * sizeof (Elf32_External_Rela
));
3955 if (tls_type
& GOT_TLS_GD
)
3961 + htab
->etab
.sgot
->output_section
->vma
3962 + htab
->etab
.sgot
->output_offset
);
3964 = ELF32_R_INFO (indx
, R_PARISC_TLS_DTPMOD32
);
3965 outrel
.r_addend
= 0;
3966 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
3967 htab
->etab
.srelgot
->reloc_count
++;
3968 loc
+= sizeof (Elf32_External_Rela
);
3969 bfd_put_32 (output_bfd
, 0,
3970 htab
->etab
.sgot
->contents
+ cur_off
);
3973 /* If we are not emitting relocations for a
3974 general dynamic reference, then we must be in a
3975 static link or an executable link with the
3976 symbol binding locally. Mark it as belonging
3977 to module 1, the executable. */
3978 bfd_put_32 (output_bfd
, 1,
3979 htab
->etab
.sgot
->contents
+ cur_off
);
3984 = ELF32_R_INFO (indx
, R_PARISC_TLS_DTPOFF32
);
3985 outrel
.r_offset
+= 4;
3986 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
3987 htab
->etab
.srelgot
->reloc_count
++;
3988 loc
+= sizeof (Elf32_External_Rela
);
3989 bfd_put_32 (output_bfd
, 0,
3990 htab
->etab
.sgot
->contents
+ cur_off
+ 4);
3993 bfd_put_32 (output_bfd
, relocation
- dtpoff_base (info
),
3994 htab
->etab
.sgot
->contents
+ cur_off
+ 4);
3998 if (tls_type
& GOT_TLS_IE
)
4001 && !(bfd_link_executable (info
)
4002 && SYMBOL_REFERENCES_LOCAL (info
, &hh
->eh
)))
4006 + htab
->etab
.sgot
->output_section
->vma
4007 + htab
->etab
.sgot
->output_offset
);
4008 outrel
.r_info
= ELF32_R_INFO (indx
,
4009 R_PARISC_TLS_TPREL32
);
4011 outrel
.r_addend
= relocation
- dtpoff_base (info
);
4013 outrel
.r_addend
= 0;
4014 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
, loc
);
4015 htab
->etab
.srelgot
->reloc_count
++;
4016 loc
+= sizeof (Elf32_External_Rela
);
4019 bfd_put_32 (output_bfd
, tpoff (info
, relocation
),
4020 htab
->etab
.sgot
->contents
+ cur_off
);
4025 hh
->eh
.got
.offset
|= 1;
4027 local_got_offsets
[r_symndx
] |= 1;
4030 if ((tls_type
& GOT_NORMAL
) != 0
4031 && (tls_type
& (GOT_TLS_GD
| GOT_TLS_LDM
| GOT_TLS_IE
)) != 0)
4034 _bfd_error_handler (_("%s has both normal and TLS relocs"),
4038 Elf_Internal_Sym
*isym
4039 = bfd_sym_from_r_symndx (&htab
->etab
.sym_cache
,
4040 input_bfd
, r_symndx
);
4044 = bfd_elf_string_from_elf_section (input_bfd
,
4045 symtab_hdr
->sh_link
,
4047 if (sym_name
== NULL
)
4049 if (*sym_name
== '\0')
4050 sym_name
= bfd_section_name (sym_sec
);
4052 (_("%pB:%s has both normal and TLS relocs"),
4053 input_bfd
, sym_name
);
4055 bfd_set_error (bfd_error_bad_value
);
4059 if ((tls_type
& GOT_TLS_GD
)
4060 && r_type
!= R_PARISC_TLS_GD21L
4061 && r_type
!= R_PARISC_TLS_GD14R
)
4062 off
+= 2 * GOT_ENTRY_SIZE
;
4064 /* Add the base of the GOT to the relocation value. */
4066 + htab
->etab
.sgot
->output_offset
4067 + htab
->etab
.sgot
->output_section
->vma
);
4072 case R_PARISC_TLS_LE21L
:
4073 case R_PARISC_TLS_LE14R
:
4075 relocation
= tpoff (info
, relocation
);
4084 rstatus
= final_link_relocate (input_section
, contents
, rela
, relocation
,
4085 htab
, sym_sec
, hh
, info
);
4087 if (rstatus
== bfd_reloc_ok
)
4091 sym_name
= hh_name (hh
);
4094 sym_name
= bfd_elf_string_from_elf_section (input_bfd
,
4095 symtab_hdr
->sh_link
,
4097 if (sym_name
== NULL
)
4099 if (*sym_name
== '\0')
4100 sym_name
= bfd_section_name (sym_sec
);
4103 howto
= elf_hppa_howto_table
+ r_type
;
4105 if (rstatus
== bfd_reloc_undefined
|| rstatus
== bfd_reloc_notsupported
)
4107 if (rstatus
== bfd_reloc_notsupported
|| !warned_undef
)
4110 /* xgettext:c-format */
4111 (_("%pB(%pA+%#" PRIx64
"): cannot handle %s for %s"),
4114 (uint64_t) rela
->r_offset
,
4117 bfd_set_error (bfd_error_bad_value
);
4122 (*info
->callbacks
->reloc_overflow
)
4123 (info
, (hh
? &hh
->eh
.root
: NULL
), sym_name
, howto
->name
,
4124 (bfd_vma
) 0, input_bfd
, input_section
, rela
->r_offset
);
4130 /* Finish up dynamic symbol handling. We set the contents of various
4131 dynamic sections here. */
4134 elf32_hppa_finish_dynamic_symbol (bfd
*output_bfd
,
4135 struct bfd_link_info
*info
,
4136 struct elf_link_hash_entry
*eh
,
4137 Elf_Internal_Sym
*sym
)
4139 struct elf32_hppa_link_hash_table
*htab
;
4140 Elf_Internal_Rela rela
;
4143 htab
= hppa_link_hash_table (info
);
4147 if (eh
->plt
.offset
!= (bfd_vma
) -1)
4151 if (eh
->plt
.offset
& 1)
4154 /* This symbol has an entry in the procedure linkage table. Set
4157 The format of a plt entry is
4162 if (eh
->root
.type
== bfd_link_hash_defined
4163 || eh
->root
.type
== bfd_link_hash_defweak
)
4165 value
= eh
->root
.u
.def
.value
;
4166 if (eh
->root
.u
.def
.section
->output_section
!= NULL
)
4167 value
+= (eh
->root
.u
.def
.section
->output_offset
4168 + eh
->root
.u
.def
.section
->output_section
->vma
);
4171 /* Create a dynamic IPLT relocation for this entry. */
4172 rela
.r_offset
= (eh
->plt
.offset
4173 + htab
->etab
.splt
->output_offset
4174 + htab
->etab
.splt
->output_section
->vma
);
4175 if (eh
->dynindx
!= -1)
4177 rela
.r_info
= ELF32_R_INFO (eh
->dynindx
, R_PARISC_IPLT
);
4182 /* This symbol has been marked to become local, and is
4183 used by a plabel so must be kept in the .plt. */
4184 rela
.r_info
= ELF32_R_INFO (0, R_PARISC_IPLT
);
4185 rela
.r_addend
= value
;
4188 loc
= htab
->etab
.srelplt
->contents
;
4189 loc
+= htab
->etab
.srelplt
->reloc_count
++ * sizeof (Elf32_External_Rela
);
4190 bfd_elf32_swap_reloca_out (htab
->etab
.splt
->output_section
->owner
, &rela
, loc
);
4192 if (!eh
->def_regular
)
4194 /* Mark the symbol as undefined, rather than as defined in
4195 the .plt section. Leave the value alone. */
4196 sym
->st_shndx
= SHN_UNDEF
;
4200 if (eh
->got
.offset
!= (bfd_vma
) -1
4201 && (hppa_elf_hash_entry (eh
)->tls_type
& GOT_NORMAL
) != 0
4202 && !UNDEFWEAK_NO_DYNAMIC_RELOC (info
, eh
))
4204 bfd_boolean is_dyn
= (eh
->dynindx
!= -1
4205 && !SYMBOL_REFERENCES_LOCAL (info
, eh
));
4207 if (is_dyn
|| bfd_link_pic (info
))
4209 /* This symbol has an entry in the global offset table. Set
4212 rela
.r_offset
= ((eh
->got
.offset
&~ (bfd_vma
) 1)
4213 + htab
->etab
.sgot
->output_offset
4214 + htab
->etab
.sgot
->output_section
->vma
);
4216 /* If this is a -Bsymbolic link and the symbol is defined
4217 locally or was forced to be local because of a version
4218 file, we just want to emit a RELATIVE reloc. The entry
4219 in the global offset table will already have been
4220 initialized in the relocate_section function. */
4223 rela
.r_info
= ELF32_R_INFO (0, R_PARISC_DIR32
);
4224 rela
.r_addend
= (eh
->root
.u
.def
.value
4225 + eh
->root
.u
.def
.section
->output_offset
4226 + eh
->root
.u
.def
.section
->output_section
->vma
);
4230 if ((eh
->got
.offset
& 1) != 0)
4233 bfd_put_32 (output_bfd
, 0,
4234 htab
->etab
.sgot
->contents
+ (eh
->got
.offset
& ~1));
4235 rela
.r_info
= ELF32_R_INFO (eh
->dynindx
, R_PARISC_DIR32
);
4239 loc
= htab
->etab
.srelgot
->contents
;
4240 loc
+= (htab
->etab
.srelgot
->reloc_count
++
4241 * sizeof (Elf32_External_Rela
));
4242 bfd_elf32_swap_reloca_out (output_bfd
, &rela
, loc
);
4250 /* This symbol needs a copy reloc. Set it up. */
4252 if (! (eh
->dynindx
!= -1
4253 && (eh
->root
.type
== bfd_link_hash_defined
4254 || eh
->root
.type
== bfd_link_hash_defweak
)))
4257 rela
.r_offset
= (eh
->root
.u
.def
.value
4258 + eh
->root
.u
.def
.section
->output_offset
4259 + eh
->root
.u
.def
.section
->output_section
->vma
);
4261 rela
.r_info
= ELF32_R_INFO (eh
->dynindx
, R_PARISC_COPY
);
4262 if (eh
->root
.u
.def
.section
== htab
->etab
.sdynrelro
)
4263 sec
= htab
->etab
.sreldynrelro
;
4265 sec
= htab
->etab
.srelbss
;
4266 loc
= sec
->contents
+ sec
->reloc_count
++ * sizeof (Elf32_External_Rela
);
4267 bfd_elf32_swap_reloca_out (output_bfd
, &rela
, loc
);
4270 /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
4271 if (eh
== htab
->etab
.hdynamic
|| eh
== htab
->etab
.hgot
)
4273 sym
->st_shndx
= SHN_ABS
;
4279 /* Used to decide how to sort relocs in an optimal manner for the
4280 dynamic linker, before writing them out. */
4282 static enum elf_reloc_type_class
4283 elf32_hppa_reloc_type_class (const struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
4284 const asection
*rel_sec ATTRIBUTE_UNUSED
,
4285 const Elf_Internal_Rela
*rela
)
4287 /* Handle TLS relocs first; we don't want them to be marked
4288 relative by the "if (ELF32_R_SYM (rela->r_info) == STN_UNDEF)"
4290 switch ((int) ELF32_R_TYPE (rela
->r_info
))
4292 case R_PARISC_TLS_DTPMOD32
:
4293 case R_PARISC_TLS_DTPOFF32
:
4294 case R_PARISC_TLS_TPREL32
:
4295 return reloc_class_normal
;
4298 if (ELF32_R_SYM (rela
->r_info
) == STN_UNDEF
)
4299 return reloc_class_relative
;
4301 switch ((int) ELF32_R_TYPE (rela
->r_info
))
4304 return reloc_class_plt
;
4306 return reloc_class_copy
;
4308 return reloc_class_normal
;
4312 /* Finish up the dynamic sections. */
4315 elf32_hppa_finish_dynamic_sections (bfd
*output_bfd
,
4316 struct bfd_link_info
*info
)
4319 struct elf32_hppa_link_hash_table
*htab
;
4323 htab
= hppa_link_hash_table (info
);
4327 dynobj
= htab
->etab
.dynobj
;
4329 sgot
= htab
->etab
.sgot
;
4330 /* A broken linker script might have discarded the dynamic sections.
4331 Catch this here so that we do not seg-fault later on. */
4332 if (sgot
!= NULL
&& bfd_is_abs_section (sgot
->output_section
))
4335 sdyn
= bfd_get_linker_section (dynobj
, ".dynamic");
4337 if (htab
->etab
.dynamic_sections_created
)
4339 Elf32_External_Dyn
*dyncon
, *dynconend
;
4344 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
4345 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->size
);
4346 for (; dyncon
< dynconend
; dyncon
++)
4348 Elf_Internal_Dyn dyn
;
4351 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
4359 /* Use PLTGOT to set the GOT register. */
4360 dyn
.d_un
.d_ptr
= elf_gp (output_bfd
);
4364 s
= htab
->etab
.srelplt
;
4365 dyn
.d_un
.d_ptr
= s
->output_section
->vma
+ s
->output_offset
;
4369 s
= htab
->etab
.srelplt
;
4370 dyn
.d_un
.d_val
= s
->size
;
4374 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
4378 if (sgot
!= NULL
&& sgot
->size
!= 0)
4380 /* Fill in the first entry in the global offset table.
4381 We use it to point to our dynamic section, if we have one. */
4382 bfd_put_32 (output_bfd
,
4383 sdyn
? sdyn
->output_section
->vma
+ sdyn
->output_offset
: 0,
4386 /* The second entry is reserved for use by the dynamic linker. */
4387 memset (sgot
->contents
+ GOT_ENTRY_SIZE
, 0, GOT_ENTRY_SIZE
);
4389 /* Set .got entry size. */
4390 elf_section_data (sgot
->output_section
)
4391 ->this_hdr
.sh_entsize
= GOT_ENTRY_SIZE
;
4394 if (htab
->etab
.splt
!= NULL
&& htab
->etab
.splt
->size
!= 0)
4396 /* Set plt entry size to 0 instead of PLT_ENTRY_SIZE, since we add the
4397 plt stubs and as such the section does not hold a table of fixed-size
4399 elf_section_data (htab
->etab
.splt
->output_section
)->this_hdr
.sh_entsize
= 0;
4401 if (htab
->need_plt_stub
)
4403 /* Set up the .plt stub. */
4404 memcpy (htab
->etab
.splt
->contents
4405 + htab
->etab
.splt
->size
- sizeof (plt_stub
),
4406 plt_stub
, sizeof (plt_stub
));
4408 if ((htab
->etab
.splt
->output_offset
4409 + htab
->etab
.splt
->output_section
->vma
4410 + htab
->etab
.splt
->size
)
4411 != (sgot
->output_offset
4412 + sgot
->output_section
->vma
))
4415 (_(".got section not immediately after .plt section"));
4424 /* Called when writing out an object file to decide the type of a
4427 elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym
*elf_sym
, int type
)
4429 if (ELF_ST_TYPE (elf_sym
->st_info
) == STT_PARISC_MILLI
)
4430 return STT_PARISC_MILLI
;
4435 /* Misc BFD support code. */
4436 #define bfd_elf32_bfd_is_local_label_name elf_hppa_is_local_label_name
4437 #define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup
4438 #define bfd_elf32_bfd_reloc_name_lookup elf_hppa_reloc_name_lookup
4439 #define elf_info_to_howto elf_hppa_info_to_howto
4440 #define elf_info_to_howto_rel elf_hppa_info_to_howto_rel
4442 /* Stuff for the BFD linker. */
4443 #define bfd_elf32_bfd_final_link elf32_hppa_final_link
4444 #define bfd_elf32_bfd_link_hash_table_create elf32_hppa_link_hash_table_create
4445 #define elf_backend_adjust_dynamic_symbol elf32_hppa_adjust_dynamic_symbol
4446 #define elf_backend_copy_indirect_symbol elf32_hppa_copy_indirect_symbol
4447 #define elf_backend_check_relocs elf32_hppa_check_relocs
4448 #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible
4449 #define elf_backend_create_dynamic_sections elf32_hppa_create_dynamic_sections
4450 #define elf_backend_fake_sections elf_hppa_fake_sections
4451 #define elf_backend_relocate_section elf32_hppa_relocate_section
4452 #define elf_backend_hide_symbol elf32_hppa_hide_symbol
4453 #define elf_backend_finish_dynamic_symbol elf32_hppa_finish_dynamic_symbol
4454 #define elf_backend_finish_dynamic_sections elf32_hppa_finish_dynamic_sections
4455 #define elf_backend_size_dynamic_sections elf32_hppa_size_dynamic_sections
4456 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
4457 #define elf_backend_gc_mark_hook elf32_hppa_gc_mark_hook
4458 #define elf_backend_grok_prstatus elf32_hppa_grok_prstatus
4459 #define elf_backend_grok_psinfo elf32_hppa_grok_psinfo
4460 #define elf_backend_object_p elf32_hppa_object_p
4461 #define elf_backend_final_write_processing elf_hppa_final_write_processing
4462 #define elf_backend_get_symbol_type elf32_hppa_elf_get_symbol_type
4463 #define elf_backend_reloc_type_class elf32_hppa_reloc_type_class
4464 #define elf_backend_action_discarded elf_hppa_action_discarded
4466 #define elf_backend_can_gc_sections 1
4467 #define elf_backend_can_refcount 1
4468 #define elf_backend_plt_alignment 2
4469 #define elf_backend_want_got_plt 0
4470 #define elf_backend_plt_readonly 0
4471 #define elf_backend_want_plt_sym 0
4472 #define elf_backend_got_header_size 8
4473 #define elf_backend_want_dynrelro 1
4474 #define elf_backend_rela_normal 1
4475 #define elf_backend_dtrel_excludes_plt 1
4476 #define elf_backend_no_page_alias 1
4478 #define TARGET_BIG_SYM hppa_elf32_vec
4479 #define TARGET_BIG_NAME "elf32-hppa"
4480 #define ELF_ARCH bfd_arch_hppa
4481 #define ELF_TARGET_ID HPPA32_ELF_DATA
4482 #define ELF_MACHINE_CODE EM_PARISC
4483 #define ELF_MAXPAGESIZE 0x1000
4484 #define ELF_OSABI ELFOSABI_HPUX
4485 #define elf32_bed elf32_hppa_hpux_bed
4487 #include "elf32-target.h"
4489 #undef TARGET_BIG_SYM
4490 #define TARGET_BIG_SYM hppa_elf32_linux_vec
4491 #undef TARGET_BIG_NAME
4492 #define TARGET_BIG_NAME "elf32-hppa-linux"
4494 #define ELF_OSABI ELFOSABI_GNU
4496 #define elf32_bed elf32_hppa_linux_bed
4498 #include "elf32-target.h"
4500 #undef TARGET_BIG_SYM
4501 #define TARGET_BIG_SYM hppa_elf32_nbsd_vec
4502 #undef TARGET_BIG_NAME
4503 #define TARGET_BIG_NAME "elf32-hppa-netbsd"
4505 #define ELF_OSABI ELFOSABI_NETBSD
4507 #define elf32_bed elf32_hppa_netbsd_bed
4509 #include "elf32-target.h"