1 /* Common code for PA ELF implementations.
2 Copyright (C) 1999 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
22 /* This file is included by multiple PA ELF BFD backends with different
25 Most of the routines are written to be size independent, but sometimes
26 external constraints require 32 or 64 bit specific code. We remap
27 the definitions/functions as necessary here. */
29 #define ELF_R_TYPE(X) ELF64_R_TYPE(X)
30 #define ELF_R_SYM(X) ELF64_R_SYM(X)
31 #define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
32 #define elf_hppa_relocate_section elf64_hppa_relocate_section
33 #define bfd_elf_bfd_final_link bfd_elf64_bfd_final_link
34 #define elf_hppa_final_link elf64_hppa_final_link
37 #define ELF_R_TYPE(X) ELF32_R_TYPE(X)
38 #define ELF_R_SYM(X) ELF32_R_SYM(X)
39 #define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
40 #define elf_hppa_relocate_section elf32_hppa_relocate_section
41 #define bfd_elf_bfd_final_link bfd_elf32_bfd_final_link
42 #define elf_hppa_final_link elf32_hppa_final_link
46 elf_hppa_relocate_section
47 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
48 bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
50 static bfd_reloc_status_type elf_hppa_final_link_relocate
51 PARAMS ((Elf_Internal_Rela *, bfd *, bfd *, asection *,
52 bfd_byte *, bfd_vma, struct bfd_link_info *,
53 asection *, struct elf_link_hash_entry *,
54 struct elf64_hppa_dyn_hash_entry *));
56 static unsigned long elf_hppa_relocate_insn
57 PARAMS ((unsigned long, long, unsigned long));
59 static boolean elf_hppa_add_symbol_hook
60 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
61 const char **, flagword *, asection **, bfd_vma *));
63 static boolean elf_hppa_final_link
64 PARAMS ((bfd *, struct bfd_link_info *));
66 static boolean elf_hppa_unmark_useless_dynamic_symbols
67 PARAMS ((struct elf_link_hash_entry *, PTR));
69 static boolean elf_hppa_remark_useless_dynamic_symbols
70 PARAMS ((struct elf_link_hash_entry *, PTR));
72 static void elf_hppa_record_segment_addrs
73 PARAMS ((bfd *, asection *, PTR));
75 /* ELF/PA relocation howto entries. */
77 static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
79 {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"},
81 /* The values in DIR32 are to placate the check in
82 _bfd_stab_section_find_nearest_line. */
83 {R_PARISC_DIR32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR32", false, 0, 0xffffffff, false},
84 {R_PARISC_DIR21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR21L"},
85 {R_PARISC_DIR17R, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR17R"},
86 {R_PARISC_DIR17F, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR17F"},
87 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
88 {R_PARISC_DIR14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14R"},
89 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
90 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
91 {R_PARISC_PCREL32, 0, 0, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL32"},
93 {R_PARISC_PCREL21L, 0, 0, 21, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL21L"},
94 {R_PARISC_PCREL17R, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17R"},
95 {R_PARISC_PCREL17F, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17F"},
96 {R_PARISC_PCREL17C, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17C"},
97 {R_PARISC_PCREL14R, 0, 0, 14, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14R"},
98 {R_PARISC_PCREL14F, 0, 0, 14, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14F"},
99 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
100 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
101 {R_PARISC_DPREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL21L"},
102 {R_PARISC_DPREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14WR"},
104 {R_PARISC_DPREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14DR"},
105 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
106 {R_PARISC_DPREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14R"},
107 {R_PARISC_DPREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14F"},
108 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
109 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
110 {R_PARISC_DLTREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL21L"},
111 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
112 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
113 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
115 {R_PARISC_DLTREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14R"},
116 {R_PARISC_DLTREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14F"},
117 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
118 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
119 {R_PARISC_DLTIND21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND21L"},
120 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
121 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
122 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
123 {R_PARISC_DLTIND14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14R"},
124 {R_PARISC_DLTIND14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14F"},
126 {R_PARISC_SETBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SETBASE"},
127 {R_PARISC_SECREL32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SECREL32"},
128 {R_PARISC_BASEREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL21L"},
129 {R_PARISC_BASEREL17R, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL17R"},
130 {R_PARISC_BASEREL17F, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL17F"},
131 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
132 {R_PARISC_BASEREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14R"},
133 {R_PARISC_BASEREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14F"},
134 {R_PARISC_SEGBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGBASE"},
135 {R_PARISC_SEGREL32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGREL32"},
137 {R_PARISC_PLTOFF21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF21L"},
138 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
139 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
140 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
141 {R_PARISC_PLTOFF14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14R"},
142 {R_PARISC_PLTOFF14F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14F"},
143 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
144 {R_PARISC_LTOFF_FPTR32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR32"},
145 {R_PARISC_LTOFF_FPTR21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR21L"},
146 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
148 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
149 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
150 {R_PARISC_LTOFF_FPTR14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14R"},
151 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
152 {R_PARISC_FPTR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_FPTR64"},
153 {R_PARISC_PLABEL32, 0, 0, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL32"},
154 {R_PARISC_PLABEL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL21L"},
155 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
156 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
157 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
159 {R_PARISC_PLABEL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL14R"},
160 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
161 {R_PARISC_PCREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL64"},
162 {R_PARISC_PCREL22C, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL22C"},
163 {R_PARISC_PCREL22F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL22F"},
164 {R_PARISC_PCREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14WR"},
165 {R_PARISC_PCREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14DR"},
166 {R_PARISC_PCREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16F"},
167 {R_PARISC_PCREL16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16WF"},
168 {R_PARISC_PCREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16DF"},
170 {R_PARISC_DIR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR64"},
171 {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"},
172 {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"},
173 {R_PARISC_DIR14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14WR"},
174 {R_PARISC_DIR14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14DR"},
175 {R_PARISC_DIR16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16F"},
176 {R_PARISC_DIR16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16WF"},
177 {R_PARISC_DIR16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16DF"},
178 {R_PARISC_GPREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL64"},
179 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
181 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
182 {R_PARISC_DLTREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14WR"},
183 {R_PARISC_DLTREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14DR"},
184 {R_PARISC_GPREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16F"},
185 {R_PARISC_GPREL16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16WF"},
186 {R_PARISC_GPREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16DF"},
187 {R_PARISC_LTOFF64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF64"},
188 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
189 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
190 {R_PARISC_DLTIND14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14WR"},
192 {R_PARISC_DLTIND14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14DR"},
193 {R_PARISC_LTOFF16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16F"},
194 {R_PARISC_LTOFF16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF"},
195 {R_PARISC_LTOFF16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF"},
196 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
197 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
198 {R_PARISC_BASEREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BSEREL14WR"},
199 {R_PARISC_BASEREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14DR"},
200 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
201 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
203 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
204 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
205 {R_PARISC_SEGREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGREL64"},
206 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
207 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
208 {R_PARISC_PLTOFF14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14WR"},
209 {R_PARISC_PLTOFF14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14DR"},
210 {R_PARISC_PLTOFF16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16F"},
211 {R_PARISC_PLTOFF16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16WF"},
212 {R_PARISC_PLTOFF16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16DF"},
214 {R_PARISC_LTOFF_FPTR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
215 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
216 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
217 {R_PARISC_LTOFF_FPTR14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14WR"},
218 {R_PARISC_LTOFF_FPTR14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14DR"},
219 {R_PARISC_LTOFF_FPTR16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16F"},
220 {R_PARISC_LTOFF_FPTR16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16WF"},
221 {R_PARISC_LTOFF_FPTR16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
222 {R_PARISC_COPY, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_COPY"},
223 {R_PARISC_IPLT, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_IPLT"},
225 {R_PARISC_EPLT, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_EPLT"},
226 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
227 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
228 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
229 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
230 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
231 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
232 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
233 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
234 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
236 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
237 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
238 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
239 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
240 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
241 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
242 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
243 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
244 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
245 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
247 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
248 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
249 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
250 {R_PARISC_TPREL32, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL32"},
251 {R_PARISC_TPREL21L, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL21L"},
252 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
253 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
254 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
255 {R_PARISC_TPREL14R, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL14R"},
256 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
258 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
259 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
260 {R_PARISC_LTOFF_TP21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP21L"},
261 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
262 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
263 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
264 {R_PARISC_LTOFF_TP14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
265 {R_PARISC_LTOFF_TP14F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14F"},
266 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
267 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
269 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
270 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
271 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
272 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
273 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
274 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
275 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
276 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
277 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
278 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
280 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
281 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
282 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
283 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
284 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
285 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
286 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
287 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
288 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
289 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
291 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
292 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
293 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
294 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
295 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
296 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
297 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
298 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
299 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
300 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
302 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
303 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
304 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
305 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
306 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
307 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
308 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
309 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
310 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
311 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
313 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
314 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
315 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
316 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
317 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
318 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
319 {R_PARISC_TPREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL64"},
320 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
321 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
322 {R_PARISC_TPREL14WR, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL14WR"},
324 {R_PARISC_TPREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL14DR"},
325 {R_PARISC_TPREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL16F"},
326 {R_PARISC_TPREL16WF, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL16WF"},
327 {R_PARISC_TPREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL16DF"},
328 {R_PARISC_LTOFF_TP64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP64"},
329 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
330 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
331 {R_PARISC_LTOFF_TP14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14WR"},
332 {R_PARISC_LTOFF_TP14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14DR"},
333 {R_PARISC_LTOFF_TP16F, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_LTOFF_TP16F"},
335 {R_PARISC_LTOFF_TP16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16WF"},
336 {R_PARISC_LTOFF_TP16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16DF"},
339 #define OFFSET_14R_FROM_21L 4
340 #define OFFSET_14F_FROM_21L 5
342 /* Return one (or more) BFD relocations which implement the base
343 relocation with modifications based on format and field. */
345 elf_hppa_reloc_type **
346 _bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
348 elf_hppa_reloc_type base_type;
354 elf_hppa_reloc_type *finaltype;
355 elf_hppa_reloc_type **final_types;
357 /* Allocate slots for the BFD relocation. */
358 final_types = ((elf_hppa_reloc_type **)
359 bfd_alloc (abfd, sizeof (elf_hppa_reloc_type *) * 2));
360 if (final_types == NULL)
363 /* Allocate space for the relocation itself. */
364 finaltype = ((elf_hppa_reloc_type *)
365 bfd_alloc (abfd, sizeof (elf_hppa_reloc_type)));
366 if (finaltype == NULL)
369 /* Some reasonable defaults. */
370 final_types[0] = finaltype;
371 final_types[1] = NULL;
373 #define final_type finaltype[0]
375 final_type = base_type;
377 /* Just a tangle of nested switch statements to deal with the braindamage
378 that a different field selector means a completely different relocation
382 /* We have been using generic relocation types. However, that may not
383 really make sense. Anyway, we need to support both R_PARISC_DIR64
384 and R_PARISC_DIR32 here. */
387 case R_HPPA_ABS_CALL:
395 final_type = R_PARISC_DIR14R;
398 final_type = R_PARISC_DLTIND14R;
401 final_type = R_PARISC_LTOFF_FPTR14DR;
404 final_type = R_PARISC_DLTIND14F;
407 final_type = R_PARISC_PLABEL14R;
418 final_type = R_PARISC_DIR17F;
422 final_type = R_PARISC_DIR17R;
434 final_type = R_PARISC_DIR21L;
437 final_type = R_PARISC_DLTIND21L;
440 final_type = R_PARISC_LTOFF_FPTR21L;
443 final_type = R_PARISC_PLABEL21L;
454 final_type = R_PARISC_DIR32;
455 /* When in 64bit mode, a 32bit relocation is supposed to
456 be a section relative relocation. Dwarf2 (for example)
457 uses 32bit section relative relocations. */
458 if (bfd_get_arch_info (abfd)->bits_per_address != 32)
459 final_type = R_PARISC_SECREL32;
462 final_type = R_PARISC_PLABEL32;
473 final_type = R_PARISC_DIR64;
476 final_type = R_PARISC_FPTR64;
497 final_type = base_type + OFFSET_14R_FROM_21L;
500 final_type = base_type + OFFSET_14F_FROM_21L;
512 final_type = base_type;
525 case R_HPPA_PCREL_CALL:
533 final_type = R_PARISC_PCREL14R;
536 final_type = R_PARISC_PCREL14F;
548 final_type = R_PARISC_PCREL17R;
551 final_type = R_PARISC_PCREL17F;
562 final_type = R_PARISC_PCREL22F;
574 final_type = R_PARISC_PCREL21L;
586 case R_PARISC_SEGREL32:
587 case R_PARISC_SEGBASE:
588 /* The defaults are fine for these cases. */
598 /* Translate from an elf into field into a howto relocation pointer. */
601 elf_hppa_info_to_howto (abfd, bfd_reloc, elf_reloc)
604 Elf_Internal_Rela *elf_reloc;
606 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
607 < (unsigned int) R_PARISC_UNIMPLEMENTED);
608 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
611 /* Translate from an elf into field into a howto relocation pointer. */
614 elf_hppa_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
617 Elf_Internal_Rel *elf_reloc;
619 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
620 < (unsigned int) R_PARISC_UNIMPLEMENTED);
621 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
624 /* Return the address of the howto table entry to perform the CODE
625 relocation for an ARCH machine. */
627 static reloc_howto_type *
628 elf_hppa_reloc_type_lookup (abfd, code)
630 bfd_reloc_code_real_type code;
632 if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
634 BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
635 return &elf_hppa_howto_table[(int) code];
641 elf_hppa_final_write_processing (abfd, linker)
645 int mach = bfd_get_mach (abfd);
647 elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL
648 | EF_PARISC_EXT | EF_PARISC_LSB
649 | EF_PARISC_WIDE | EF_PARISC_NO_KABP
650 | EF_PARISC_LAZYSWAP);
653 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0;
655 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1;
657 elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0;
659 elf_elfheader (abfd)->e_flags |= (EF_PARISC_WIDE
661 /* The GNU tools have trapped without
662 option since 1993, so need to take
663 a step backwards with the ELF
665 | EF_PARISC_TRAPNIL);
668 /* Return true if SYM represents a local label symbol. */
671 elf_hppa_is_local_label_name (abfd, name)
672 bfd *abfd ATTRIBUTE_UNUSED;
675 return (name[0] == 'L' && name[1] == '$');
678 /* Set the correct type for an ELF section. We do this by the
679 section name, which is a hack, but ought to work. */
682 elf_hppa_fake_sections (abfd, hdr, sec)
684 Elf64_Internal_Shdr *hdr;
687 register const char *name;
689 name = bfd_get_section_name (abfd, sec);
691 if (strcmp (name, ".PARISC.unwind") == 0)
695 hdr->sh_type = SHT_LOPROC + 1;
696 /* ?!? How are unwinds supposed to work for symbols in arbitrary
697 sections? Or what if we have multiple .text sections in a single
698 .o file? HP really messed up on this one.
700 Ugh. We can not use elf_section_data (sec)->this_idx at this
701 point because it is not initialized yet.
703 So we (gasp) recompute it here. Hopefully nobody ever changes the
704 way sections are numbered in elf.c! */
705 for (sec = abfd->sections, indx = 1; sec; sec = sec->next, indx++)
707 if (sec->name && strcmp (sec->name, ".text") == 0)
714 /* I have no idea if this is really necessary or what it means. */
720 /* Hook called by the linker routine which adds symbols from an object
721 file. HP's libraries define symbols with HP specific section
722 indices, which we have to handle. */
725 elf_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
727 struct bfd_link_info *info ATTRIBUTE_UNUSED;
728 const Elf_Internal_Sym *sym;
729 const char **namep ATTRIBUTE_UNUSED;
730 flagword *flagsp ATTRIBUTE_UNUSED;
734 int index = sym->st_shndx;
738 case SHN_PARISC_ANSI_COMMON:
739 *secp = bfd_make_section_old_way (abfd, ".PARISC.ansi.common");
740 (*secp)->flags |= SEC_IS_COMMON;
741 *valp = sym->st_size;
744 case SHN_PARISC_HUGE_COMMON:
745 *secp = bfd_make_section_old_way (abfd, ".PARISC.huge.common");
746 (*secp)->flags |= SEC_IS_COMMON;
747 *valp = sym->st_size;
755 elf_hppa_unmark_useless_dynamic_symbols (h, data)
756 struct elf_link_hash_entry *h;
759 struct bfd_link_info *info = (struct bfd_link_info *)data;
761 /* If we are not creating a shared library, and this symbol is
762 referenced by a shared library but is not defined anywhere, then
763 the generic code will warn that it is undefined.
765 This behavior is undesirable on HPs since the standard shared
766 libraries contain reerences to undefined symbols.
768 So we twiddle the flags associated with such symbols so that they
769 will not trigger the warning. ?!? FIXME. This is horribly fraglie.
771 Ultimately we should have better controls over the generic ELF BFD
773 if (! info->relocateable
775 && !info->no_undefined)
776 && h->root.type == bfd_link_hash_undefined
777 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
778 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
780 h->elf_link_hash_flags &= ~ELF_LINK_HASH_REF_DYNAMIC;
781 h->elf_link_hash_flags |= 0x8000;
789 elf_hppa_remark_useless_dynamic_symbols (h, data)
790 struct elf_link_hash_entry *h;
793 struct bfd_link_info *info = (struct bfd_link_info *)data;
795 /* If we are not creating a shared library, and this symbol is
796 referenced by a shared library but is not defined anywhere, then
797 the generic code will warn that it is undefined.
799 This behavior is undesirable on HPs since the standard shared
800 libraries contain reerences to undefined symbols.
802 So we twiddle the flags associated with such symbols so that they
803 will not trigger the warning. ?!? FIXME. This is horribly fragile.
805 Ultimately we should have better controls over the generic ELF BFD
807 if (! info->relocateable
809 && !info->no_undefined)
810 && h->root.type == bfd_link_hash_undefined
811 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
812 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
813 && (h->elf_link_hash_flags & 0x8000) != 0)
815 h->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC;
816 h->elf_link_hash_flags &= ~0x8000;
822 /* Record the lowest address for the data and text segments. */
824 elf_hppa_record_segment_addrs (abfd, section, data)
825 bfd *abfd ATTRIBUTE_UNUSED;
829 struct elf64_hppa_link_hash_table *hppa_info;
832 hppa_info = (struct elf64_hppa_link_hash_table *)data;
834 value = section->vma - section->filepos;
836 if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
837 == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
838 && value < hppa_info->text_segment_base)
839 hppa_info->text_segment_base = value;
840 else if ((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
841 == (SEC_ALLOC | SEC_LOAD))
842 && value < hppa_info->data_segment_base)
843 hppa_info->data_segment_base = value;
846 /* Called after we have seen all the input files/sections, but before
847 final symbol resolution and section placement has been determined.
849 We use this hook to (possibly) provide a value for __gp, then we
850 fall back to the generic ELF final link routine. */
853 elf_hppa_final_link (abfd, info)
855 struct bfd_link_info *info;
859 if (! info->relocateable)
861 struct elf_link_hash_entry *gp;
863 struct elf64_hppa_link_hash_table *hppa_info;
865 hppa_info = elf64_hppa_hash_table (info);
867 /* The linker script defines a value for __gp iff it was referenced
868 by one of the objects being linked. First try to find the symbol
869 in the hash table. If that fails, just compute the value __gp
871 gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", false,
877 /* Adjust the value of __gp as we may want to slide it into the
878 .plt section so that the stubs can access PLT entries without
879 using an addil sequence. */
880 gp->root.u.def.value += elf64_hppa_hash_table (info)->gp_offset;
882 gp_val = (gp->root.u.def.section->output_section->vma
883 + gp->root.u.def.section->output_offset
884 + gp->root.u.def.value);
891 /* First look for a .plt section. If found, then __gp is the
892 address of the .plt + gp_offset.
894 If no .plt is found, then look for .dlt, .opd and .data (in
895 that order) and set __gp to the base address of whichever section
898 sec = hppa_info->plt_sec;
900 gp_val = (sec->output_offset
901 + sec->output_section->vma
902 + hppa_info->gp_offset);
905 sec = hppa_info->dlt_sec;
907 sec = hppa_info->opd_sec;
909 sec = bfd_get_section_by_name (abfd, ".data");
913 gp_val = sec->output_offset + sec->output_section->vma;
917 /* Install whatever value we found/computed for __gp. */
918 _bfd_set_gp_value (abfd, gp_val);
921 /* We need to know the base of the text and data segments so that we
922 can perform SEGREL relocations. We will recore the base addresses
923 when we encounter the first SEGREL relocation. */
924 elf64_hppa_hash_table (info)->text_segment_base = (bfd_vma)-1;
925 elf64_hppa_hash_table (info)->data_segment_base = (bfd_vma)-1;
927 /* HP's shared libraries have references to symbols that are not
928 defined anywhere. The generic ELF BFD linker code will complaim
931 So we detect the losing case and arrange for the flags on the symbol
932 to indicate that it was never referenced. This keeps the generic
933 ELF BFD link code happy and appears to not create any secondary
934 problems. Ultimately we need a way to control the behavior of the
935 generic ELF BFD link code better. */
936 elf_link_hash_traverse (elf_hash_table (info),
937 elf_hppa_unmark_useless_dynamic_symbols,
940 /* Invoke the regular ELF backend linker to do all the work. */
941 retval = bfd_elf_bfd_final_link (abfd, info);
943 elf_link_hash_traverse (elf_hash_table (info),
944 elf_hppa_remark_useless_dynamic_symbols,
950 /* Relocate an HPPA ELF section. */
953 elf_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
954 contents, relocs, local_syms, local_sections)
956 struct bfd_link_info *info;
958 asection *input_section;
960 Elf_Internal_Rela *relocs;
961 Elf_Internal_Sym *local_syms;
962 asection **local_sections;
964 Elf_Internal_Shdr *symtab_hdr;
965 Elf_Internal_Rela *rel;
966 Elf_Internal_Rela *relend;
967 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
969 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
972 relend = relocs + input_section->reloc_count;
973 for (; rel < relend; rel++)
976 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
977 unsigned long r_symndx;
978 struct elf_link_hash_entry *h;
979 Elf_Internal_Sym *sym;
982 bfd_reloc_status_type r;
983 const char *sym_name;
985 char *dynh_buf = NULL;
986 size_t dynh_buflen = 0;
987 struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
989 r_type = ELF_R_TYPE (rel->r_info);
990 if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
992 bfd_set_error (bfd_error_bad_value);
996 r_symndx = ELF_R_SYM (rel->r_info);
998 if (info->relocateable)
1000 /* This is a relocateable link. We don't have to change
1001 anything, unless the reloc is against a section symbol,
1002 in which case we have to adjust according to where the
1003 section symbol winds up in the output section. */
1004 if (r_symndx < symtab_hdr->sh_info)
1006 sym = local_syms + r_symndx;
1007 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
1009 sym_sec = local_sections[r_symndx];
1010 rel->r_addend += sym_sec->output_offset;
1017 /* This is a final link. */
1021 if (r_symndx < symtab_hdr->sh_info)
1023 /* This is a local symbol. */
1024 sym = local_syms + r_symndx;
1025 sym_sec = local_sections[r_symndx];
1026 relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION
1027 ? 0 : sym->st_value)
1028 + sym_sec->output_offset
1029 + sym_sec->output_section->vma);
1031 /* If this symbol has an entry in the PA64 dynamic hash
1032 table, then get it. */
1033 dyn_name = get_dyn_name (input_bfd, h, rel,
1034 &dynh_buf, &dynh_buflen);
1035 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1036 dyn_name, false, false);
1041 /* This is not a local symbol. */
1044 indx = r_symndx - symtab_hdr->sh_info;
1045 h = elf_sym_hashes (input_bfd)[indx];
1046 while (h->root.type == bfd_link_hash_indirect
1047 || h->root.type == bfd_link_hash_warning)
1048 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1049 if (h->root.type == bfd_link_hash_defined
1050 || h->root.type == bfd_link_hash_defweak)
1052 sym_sec = h->root.u.def.section;
1054 /* If this symbol has an entry in the PA64 dynamic hash
1055 table, then get it. */
1056 dyn_name = get_dyn_name (input_bfd, h, rel,
1057 &dynh_buf, &dynh_buflen);
1058 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1059 dyn_name, false, false);
1061 /* If we have a relocation against a symbol defined in a
1062 shared library and we have not created an entry in the
1063 PA64 dynamic symbol hash table for it, then we lose. */
1064 if (sym_sec->output_section == NULL && dyn_h == NULL)
1066 (*_bfd_error_handler)
1067 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1068 bfd_get_filename (input_bfd), h->root.root.string,
1069 bfd_get_section_name (input_bfd, input_section));
1072 else if (sym_sec->output_section)
1073 relocation = (h->root.u.def.value
1074 + sym_sec->output_offset
1075 + sym_sec->output_section->vma);
1076 /* Value will be provided via one of the offsets in the
1077 dyn_h hash table entry. */
1081 /* Allow undefined symbols in shared libraries. */
1082 else if (info->shared && !info->no_undefined)
1085 (*info->callbacks->undefined_symbol)
1086 (info, h->root.root.string, input_bfd,
1087 input_section, rel->r_offset, false);
1089 /* If this symbol has an entry in the PA64 dynamic hash
1090 table, then get it. */
1091 dyn_name = get_dyn_name (input_bfd, h, rel,
1092 &dynh_buf, &dynh_buflen);
1093 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
1094 dyn_name, false, false);
1098 (*_bfd_error_handler)
1099 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1100 bfd_get_filename (input_bfd), h->root.root.string,
1101 bfd_get_section_name (input_bfd, input_section));
1106 else if (h->root.type == bfd_link_hash_undefweak)
1110 if (!((*info->callbacks->undefined_symbol)
1111 (info, h->root.root.string, input_bfd,
1112 input_section, rel->r_offset, true)))
1119 sym_name = h->root.root.string;
1122 sym_name = bfd_elf_string_from_elf_section (input_bfd,
1123 symtab_hdr->sh_link,
1125 if (sym_name == NULL)
1127 if (*sym_name == '\0')
1128 sym_name = bfd_section_name (input_bfd, sym_sec);
1131 r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1132 input_section, contents,
1133 relocation, info, sym_sec,
1136 if (r != bfd_reloc_ok)
1142 case bfd_reloc_overflow:
1144 if (!((*info->callbacks->reloc_overflow)
1145 (info, sym_name, howto->name, (bfd_vma) 0,
1146 input_bfd, input_section, rel->r_offset)))
1157 /* Compute the value for a relocation (REL) during a final link stage,
1158 then insert the value into the proper location in CONTENTS.
1160 VALUE is a tentative value for the relocation and may be overridden
1161 and modified here based on the specific relocation to be performed.
1163 For example we do conversions for PC-relative branches in this routine
1164 or redirection of calls to external routines to stubs.
1166 The work of actually applying the relocation is left to a helper
1167 routine in an attempt to reduce the complexity and size of this
1170 static bfd_reloc_status_type
1171 elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1172 input_section, contents, value,
1173 info, sym_sec, h, dyn_h)
1174 Elf_Internal_Rela *rel;
1177 asection *input_section;
1180 struct bfd_link_info *info;
1182 struct elf_link_hash_entry *h;
1183 struct elf64_hppa_dyn_hash_entry *dyn_h;
1186 bfd_vma offset = rel->r_offset;
1187 bfd_vma addend = rel->r_addend;
1188 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
1189 unsigned long r_type = howto->type;
1190 unsigned long r_field = e_fsel;
1191 bfd_byte *hit_data = contents + offset;
1192 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
1194 insn = bfd_get_32 (input_bfd, hit_data);
1201 /* Random PC relative relocs. */
1202 case R_PARISC_PCREL21L:
1203 case R_PARISC_PCREL14R:
1204 case R_PARISC_PCREL14F:
1205 case R_PARISC_PCREL14WR:
1206 case R_PARISC_PCREL14DR:
1207 case R_PARISC_PCREL16F:
1208 case R_PARISC_PCREL16WF:
1209 case R_PARISC_PCREL16DF:
1211 if (r_type == R_PARISC_PCREL21L)
1213 else if (r_type == R_PARISC_PCREL14F
1214 || r_type == R_PARISC_PCREL16F
1215 || r_type == R_PARISC_PCREL16WF
1216 || r_type == R_PARISC_PCREL16DF)
1221 /* If this is a call to a function defined in another dynamic
1222 library, then redirect the call to the local stub for this
1224 if (sym_sec == NULL || sym_sec->output_section == NULL)
1225 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1226 + hppa_info->stub_sec->output_section->vma);
1228 /* Turn VALUE into a proper PC relative address. */
1229 value -= (offset + input_section->output_offset
1230 + input_section->output_section->vma);
1232 /* Adjust for any field selectors. */
1233 value = hppa_field_adjust (value, -8 + addend, r_field);
1235 /* Apply the relocation to the given instruction. */
1236 insn = elf_hppa_relocate_insn (insn, value, r_type);
1240 /* Basic function call support. I'm not entirely sure if PCREL14F is
1241 actually needed or even handled correctly.
1243 Note for a call to a function defined in another dynamic library
1244 we want to redirect the call to a stub. */
1245 case R_PARISC_PCREL22F:
1246 case R_PARISC_PCREL17F:
1247 case R_PARISC_PCREL22C:
1248 case R_PARISC_PCREL17C:
1249 case R_PARISC_PCREL17R:
1251 if (r_type == R_PARISC_PCREL17R)
1256 /* If this is a call to a function defined in another dynamic
1257 library, then redirect the call to the local stub for this
1259 if (sym_sec == NULL || sym_sec->output_section == NULL)
1260 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1261 + hppa_info->stub_sec->output_section->vma);
1263 /* Turn VALUE into a proper PC relative address. */
1264 value -= (offset + input_section->output_offset
1265 + input_section->output_section->vma);
1267 /* Adjust for any field selectors. */
1268 value = hppa_field_adjust (value, -8 + addend, e_fsel);
1270 /* All branches are implicitly shifted by 2 places. */
1273 /* Apply the relocation to the given instruction. */
1274 insn = elf_hppa_relocate_insn (insn, value, r_type);
1278 /* Indirect references to data through the DLT. */
1279 case R_PARISC_DLTIND14R:
1280 case R_PARISC_DLTIND14F:
1281 case R_PARISC_DLTIND14DR:
1282 case R_PARISC_DLTIND14WR:
1283 case R_PARISC_DLTIND21L:
1284 case R_PARISC_LTOFF_FPTR14R:
1285 case R_PARISC_LTOFF_FPTR14DR:
1286 case R_PARISC_LTOFF_FPTR14WR:
1287 case R_PARISC_LTOFF_FPTR21L:
1288 case R_PARISC_LTOFF_FPTR16F:
1289 case R_PARISC_LTOFF_FPTR16WF:
1290 case R_PARISC_LTOFF_FPTR16DF:
1291 case R_PARISC_LTOFF_TP21L:
1292 case R_PARISC_LTOFF_TP14R:
1293 case R_PARISC_LTOFF_TP14F:
1294 case R_PARISC_LTOFF_TP14WR:
1295 case R_PARISC_LTOFF_TP14DR:
1296 case R_PARISC_LTOFF_TP16F:
1297 case R_PARISC_LTOFF_TP16WF:
1298 case R_PARISC_LTOFF_TP16DF:
1299 case R_PARISC_LTOFF16F:
1300 case R_PARISC_LTOFF16WF:
1301 case R_PARISC_LTOFF16DF:
1303 /* If this relocation was against a local symbol, then we still
1304 have not set up the DLT entry (it's not convienent to do so
1305 in the "finalize_dlt" routine because it is difficult to get
1306 to the local symbol's value).
1308 So, if this is a local symbol (h == NULL), then we need to
1309 fill in its DLT entry.
1311 Similarly we may still need to set up an entry in .opd for
1312 a local function which had its address taken. */
1313 if (dyn_h->h == NULL)
1315 bfd_put_64 (hppa_info->dlt_sec->owner,
1317 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1319 /* Now handle .opd creation if needed. */
1320 if (r_type == R_PARISC_LTOFF_FPTR14R
1321 || r_type == R_PARISC_LTOFF_FPTR14DR
1322 || r_type == R_PARISC_LTOFF_FPTR14WR
1323 || r_type == R_PARISC_LTOFF_FPTR21L
1324 || r_type == R_PARISC_LTOFF_FPTR16F
1325 || r_type == R_PARISC_LTOFF_FPTR16WF
1326 || r_type == R_PARISC_LTOFF_FPTR16DF)
1328 /* The first two words of an .opd entry are zero. */
1329 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset,
1332 /* The next word is the address of the function. */
1333 bfd_put_64 (hppa_info->opd_sec->owner, value,
1334 (hppa_info->opd_sec->contents
1335 + dyn_h->opd_offset + 16));
1337 /* The last word is our local __gp value. */
1338 value = _bfd_get_gp_value
1339 (hppa_info->opd_sec->output_section->owner);
1340 bfd_put_64 (hppa_info->opd_sec->owner, value,
1341 (hppa_info->opd_sec->contents
1342 + dyn_h->opd_offset + 24));
1346 /* We want the value of the DLT offset for this symbol, not
1347 the symbol's actual address. Note that __gp may not point
1348 to the start of the DLT, so we have to compute the absolute
1349 address, then subtract out the value of __gp. */
1350 value = (dyn_h->dlt_offset
1351 + hppa_info->dlt_sec->output_offset
1352 + hppa_info->dlt_sec->output_section->vma);
1353 value -= _bfd_get_gp_value (output_bfd);
1356 /* All DLTIND relocations are basically the same at this point,
1357 except that we need different field selectors for the 21bit
1358 version vs the 14bit versions. */
1359 if (r_type == R_PARISC_DLTIND21L
1360 || r_type == R_PARISC_LTOFF_FPTR21L
1361 || r_type == R_PARISC_LTOFF_TP21L)
1362 value = hppa_field_adjust (value, addend, e_lrsel);
1363 else if (r_type == R_PARISC_DLTIND14F
1364 || r_type == R_PARISC_LTOFF_FPTR16F
1365 || r_type == R_PARISC_LTOFF_FPTR16WF
1366 || r_type == R_PARISC_LTOFF_FPTR16DF
1367 || r_type == R_PARISC_LTOFF16F
1368 || r_type == R_PARISC_LTOFF16DF
1369 || r_type == R_PARISC_LTOFF16WF
1370 || r_type == R_PARISC_LTOFF_TP16F
1371 || r_type == R_PARISC_LTOFF_TP16WF
1372 || r_type == R_PARISC_LTOFF_TP16DF)
1373 value = hppa_field_adjust (value, addend, e_fsel);
1375 value = hppa_field_adjust (value, addend, e_rrsel);
1377 insn = elf_hppa_relocate_insn (insn, value, r_type);
1381 case R_PARISC_DLTREL14R:
1382 case R_PARISC_DLTREL14F:
1383 case R_PARISC_DLTREL14DR:
1384 case R_PARISC_DLTREL14WR:
1385 case R_PARISC_DLTREL21L:
1386 case R_PARISC_DPREL21L:
1387 case R_PARISC_DPREL14WR:
1388 case R_PARISC_DPREL14DR:
1389 case R_PARISC_DPREL14R:
1390 case R_PARISC_DPREL14F:
1391 case R_PARISC_GPREL16F:
1392 case R_PARISC_GPREL16WF:
1393 case R_PARISC_GPREL16DF:
1395 /* Subtract out the global pointer value to make value a DLT
1396 relative address. */
1397 value -= _bfd_get_gp_value (output_bfd);
1399 /* All DLTREL relocations are basically the same at this point,
1400 except that we need different field selectors for the 21bit
1401 version vs the 14bit versions. */
1402 if (r_type == R_PARISC_DLTREL21L
1403 || r_type == R_PARISC_DPREL21L)
1404 value = hppa_field_adjust (value, addend, e_lrsel);
1405 else if (r_type == R_PARISC_DLTREL14F
1406 || r_type == R_PARISC_DPREL14F
1407 || r_type == R_PARISC_GPREL16F
1408 || r_type == R_PARISC_GPREL16WF
1409 || r_type == R_PARISC_GPREL16DF)
1410 value = hppa_field_adjust (value, addend, e_fsel);
1412 value = hppa_field_adjust (value, addend, e_rrsel);
1414 insn = elf_hppa_relocate_insn (insn, value, r_type);
1418 case R_PARISC_DIR21L:
1419 case R_PARISC_DIR17R:
1420 case R_PARISC_DIR17F:
1421 case R_PARISC_DIR14R:
1422 case R_PARISC_DIR14WR:
1423 case R_PARISC_DIR14DR:
1424 case R_PARISC_DIR16F:
1425 case R_PARISC_DIR16WF:
1426 case R_PARISC_DIR16DF:
1428 /* All DIR relocations are basically the same at this point,
1429 except that we need different field selectors for the 21bit
1430 version vs the 14bit versions. */
1431 if (r_type == R_PARISC_DIR21L)
1432 value = hppa_field_adjust (value, addend, e_lrsel);
1433 else if (r_type == R_PARISC_DIR17F
1434 || r_type == R_PARISC_DIR16F
1435 || r_type == R_PARISC_DIR16WF
1436 || r_type == R_PARISC_DIR16DF)
1437 value = hppa_field_adjust (value, addend, e_fsel);
1439 value = hppa_field_adjust (value, addend, e_rrsel);
1441 insn = elf_hppa_relocate_insn (insn, value, r_type);
1445 case R_PARISC_PLTOFF21L:
1446 case R_PARISC_PLTOFF14R:
1447 case R_PARISC_PLTOFF14F:
1448 case R_PARISC_PLTOFF14WR:
1449 case R_PARISC_PLTOFF14DR:
1450 case R_PARISC_PLTOFF16F:
1451 case R_PARISC_PLTOFF16WF:
1452 case R_PARISC_PLTOFF16DF:
1454 /* We want the value of the PLT offset for this symbol, not
1455 the symbol's actual address. Note that __gp may not point
1456 to the start of the DLT, so we have to compute the absolute
1457 address, then subtract out the value of __gp. */
1458 value = (dyn_h->plt_offset
1459 + hppa_info->plt_sec->output_offset
1460 + hppa_info->plt_sec->output_section->vma);
1461 value -= _bfd_get_gp_value (output_bfd);
1463 /* All PLTOFF relocations are basically the same at this point,
1464 except that we need different field selectors for the 21bit
1465 version vs the 14bit versions. */
1466 if (r_type == R_PARISC_PLTOFF21L)
1467 value = hppa_field_adjust (value, addend, e_lrsel);
1468 else if (r_type == R_PARISC_PLTOFF14F
1469 || r_type == R_PARISC_PLTOFF16F
1470 || r_type == R_PARISC_PLTOFF16WF
1471 || r_type == R_PARISC_PLTOFF16DF)
1472 value = hppa_field_adjust (value, addend, e_fsel);
1474 value = hppa_field_adjust (value, addend, e_rrsel);
1476 insn = elf_hppa_relocate_insn (insn, value, r_type);
1480 case R_PARISC_LTOFF_FPTR32:
1482 /* We may still need to create the FPTR itself if it was for
1484 if (dyn_h->h == NULL)
1486 /* The first two words of an .opd entry are zero. */
1487 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1489 /* The next word is the address of the function. */
1490 bfd_put_64 (hppa_info->opd_sec->owner, value,
1491 (hppa_info->opd_sec->contents
1492 + dyn_h->opd_offset + 16));
1494 /* The last word is our local __gp value. */
1495 value = _bfd_get_gp_value
1496 (hppa_info->opd_sec->output_section->owner);
1497 bfd_put_64 (hppa_info->opd_sec->owner, value,
1498 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1501 /* We want the value of the DLT offset for this symbol, not
1502 the symbol's actual address. Note that __gp may not point
1503 to the start of the DLT, so we have to compute the absolute
1504 address, then subtract out the value of __gp. */
1505 value = (dyn_h->dlt_offset
1506 + hppa_info->dlt_sec->output_offset
1507 + hppa_info->dlt_sec->output_section->vma);
1508 value -= _bfd_get_gp_value (output_bfd);
1509 bfd_put_32 (input_bfd, value, hit_data);
1510 return bfd_reloc_ok;
1513 case R_PARISC_LTOFF_FPTR64:
1514 case R_PARISC_LTOFF_TP64:
1516 /* We may still need to create the FPTR itself if it was for
1518 if (dyn_h->h == NULL && r_type == R_PARISC_LTOFF_FPTR64)
1520 /* The first two words of an .opd entry are zero. */
1521 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1523 /* The next word is the address of the function. */
1524 bfd_put_64 (hppa_info->opd_sec->owner, value,
1525 (hppa_info->opd_sec->contents
1526 + dyn_h->opd_offset + 16));
1528 /* The last word is our local __gp value. */
1529 value = _bfd_get_gp_value
1530 (hppa_info->opd_sec->output_section->owner);
1531 bfd_put_64 (hppa_info->opd_sec->owner, value,
1532 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1535 /* We want the value of the DLT offset for this symbol, not
1536 the symbol's actual address. Note that __gp may not point
1537 to the start of the DLT, so we have to compute the absolute
1538 address, then subtract out the value of __gp. */
1539 value = (dyn_h->dlt_offset
1540 + hppa_info->dlt_sec->output_offset
1541 + hppa_info->dlt_sec->output_section->vma);
1542 value -= _bfd_get_gp_value (output_bfd);
1543 bfd_put_64 (input_bfd, value, hit_data);
1544 return bfd_reloc_ok;
1547 case R_PARISC_DIR32:
1548 bfd_put_32 (input_bfd, value + addend, hit_data);
1549 return bfd_reloc_ok;
1551 case R_PARISC_DIR64:
1552 bfd_put_64 (input_bfd, value + addend, hit_data);
1553 return bfd_reloc_ok;
1555 case R_PARISC_GPREL64:
1556 /* Subtract out the global pointer value to make value a DLT
1557 relative address. */
1558 value -= _bfd_get_gp_value (output_bfd);
1561 bfd_put_64 (input_bfd, value + addend, hit_data);
1562 return bfd_reloc_ok;
1564 case R_PARISC_LTOFF64:
1565 /* We want the value of the DLT offset for this symbol, not
1566 the symbol's actual address. Note that __gp may not point
1567 to the start of the DLT, so we have to compute the absolute
1568 address, then subtract out the value of __gp. */
1569 value = (dyn_h->dlt_offset
1570 + hppa_info->dlt_sec->output_offset
1571 + hppa_info->dlt_sec->output_section->vma);
1572 value -= _bfd_get_gp_value (output_bfd);
1574 bfd_put_64 (input_bfd, value + addend, hit_data);
1575 return bfd_reloc_ok;
1577 case R_PARISC_PCREL32:
1579 /* If this is a call to a function defined in another dynamic
1580 library, then redirect the call to the local stub for this
1582 if (sym_sec == NULL || sym_sec->output_section == NULL)
1583 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1584 + hppa_info->stub_sec->output_section->vma);
1586 /* Turn VALUE into a proper PC relative address. */
1587 value -= (offset + input_section->output_offset
1588 + input_section->output_section->vma);
1592 bfd_put_64 (input_bfd, value, hit_data);
1593 return bfd_reloc_ok;
1596 case R_PARISC_PCREL64:
1598 /* If this is a call to a function defined in another dynamic
1599 library, then redirect the call to the local stub for this
1601 if (sym_sec == NULL || sym_sec->output_section == NULL)
1602 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1603 + hppa_info->stub_sec->output_section->vma);
1606 /* Turn VALUE into a proper PC relative address. */
1607 value -= (offset + input_section->output_offset
1608 + input_section->output_section->vma);
1612 bfd_put_64 (input_bfd, value, hit_data);
1613 return bfd_reloc_ok;
1617 case R_PARISC_FPTR64:
1619 /* We may still need to create the FPTR itself if it was for
1621 if (dyn_h->h == NULL)
1623 /* The first two words of an .opd entry are zero. */
1624 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1626 /* The next word is the address of the function. */
1627 bfd_put_64 (hppa_info->opd_sec->owner, value,
1628 (hppa_info->opd_sec->contents
1629 + dyn_h->opd_offset + 16));
1631 /* The last word is our local __gp value. */
1632 value = _bfd_get_gp_value
1633 (hppa_info->opd_sec->output_section->owner);
1634 bfd_put_64 (hppa_info->opd_sec->owner, value,
1635 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1638 /* We want the value of the OPD offset for this symbol, not
1639 the symbol's actual address. */
1640 value = (dyn_h->opd_offset
1641 + hppa_info->opd_sec->output_offset
1642 + hppa_info->opd_sec->output_section->vma);
1644 bfd_put_64 (input_bfd, value + addend, hit_data);
1645 return bfd_reloc_ok;
1648 case R_PARISC_SECREL32:
1649 bfd_put_32 (input_bfd,
1651 - sym_sec->output_section->vma),
1653 return bfd_reloc_ok;
1655 case R_PARISC_SEGREL32:
1656 case R_PARISC_SEGREL64:
1658 /* If this is the first SEGREL relocation, then initialize
1659 the segment base values. */
1660 if (hppa_info->text_segment_base == (bfd_vma) -1)
1661 bfd_map_over_sections (output_bfd, elf_hppa_record_segment_addrs,
1662 elf64_hppa_hash_table (info));
1664 /* VALUE holds the absolute address. We want to include the
1665 addend, then turn it into a segment relative address.
1667 The segment is derived from SYM_SEC. We assume that there are
1668 only two segments of note in the resulting executable/shlib.
1669 A readonly segment (.text) and a readwrite segment (.data). */
1672 if (sym_sec->flags & SEC_CODE)
1673 value -= hppa_info->text_segment_base;
1675 value -= hppa_info->data_segment_base;
1677 if (r_type == R_PARISC_SEGREL32)
1678 bfd_put_32 (input_bfd, value, hit_data);
1680 bfd_put_64 (input_bfd, value, hit_data);
1681 return bfd_reloc_ok;
1685 /* Something we don't know how to handle. */
1687 return bfd_reloc_notsupported;
1690 /* Update the instruction word. */
1691 bfd_put_32 (input_bfd, insn, hit_data);
1692 return (bfd_reloc_ok);
1695 /* Relocate the given INSN. VALUE should be the actual value we want
1696 to insert into the instruction, ie by this point we should not be
1697 concerned with computing an offset relative to the DLT, PC, etc.
1698 Instead this routine is meant to handle the bit manipulations needed
1699 to insert the relocation into the given instruction. */
1701 static unsigned long
1702 elf_hppa_relocate_insn (insn, sym_value, r_type)
1705 unsigned long r_type;
1709 /* This is any 22bit branch. In PA2.0 syntax it corresponds to
1710 the "B" instruction. */
1711 case R_PARISC_PCREL22F:
1712 case R_PARISC_PCREL22C:
1714 unsigned int w3, w2, w1, w;
1716 /* These are 22 bit branches. Mask off bits we do not care
1718 sym_value &= 0x3fffff;
1720 /* Now extract the W1, W2, W3 and W fields from the value. */
1721 dis_assemble_22 (sym_value, &w3, &w1, &w2, &w);
1723 /* Mask out bits for the value in the instruction. */
1726 /* Insert the bits for the W1, W2 and W fields into the
1728 insn |= (w3 << 21) | (w2 << 2) | (w1 << 16) | w;
1732 /* This is any 17bit branch. In PA2.0 syntax it also corresponds to
1733 the "B" instruction as well as BE. */
1734 case R_PARISC_PCREL17F:
1735 case R_PARISC_DIR17F:
1736 case R_PARISC_DIR17R:
1737 case R_PARISC_PCREL17C:
1738 case R_PARISC_PCREL17R:
1740 unsigned int w2, w1, w;
1742 /* These are 17 bit branches. Mask off bits we do not care
1744 sym_value &= 0x1ffff;
1746 /* Now extract the W1, W2 and W fields from the value. */
1747 dis_assemble_17 (sym_value, &w1, &w2, &w);
1749 /* Mask out bits for the value in the instruction. */
1752 /* Insert the bits for the W1, W2 and W fields into the
1754 insn |= (w2 << 2) | (w1 << 16) | w;
1758 /* ADDIL or LDIL instructions. */
1759 case R_PARISC_DLTREL21L:
1760 case R_PARISC_DLTIND21L:
1761 case R_PARISC_LTOFF_FPTR21L:
1762 case R_PARISC_PCREL21L:
1763 case R_PARISC_LTOFF_TP21L:
1764 case R_PARISC_DPREL21L:
1765 case R_PARISC_PLTOFF21L:
1766 case R_PARISC_DIR21L:
1770 /* Mask off bits in INSN we do not want. */
1773 /* Turn the 21bit value into the proper format. */
1774 dis_assemble_21 (sym_value, &w);
1776 /* And insert the proper bits into INSN. */
1780 /* LDO and integer loads/stores with 14bit displacements. */
1781 case R_PARISC_DLTREL14R:
1782 case R_PARISC_DLTREL14F:
1783 case R_PARISC_DLTIND14R:
1784 case R_PARISC_DLTIND14F:
1785 case R_PARISC_LTOFF_FPTR14R:
1786 case R_PARISC_LTOFF_FPTR16F:
1787 case R_PARISC_PCREL14R:
1788 case R_PARISC_PCREL14F:
1789 case R_PARISC_PCREL16F:
1790 case R_PARISC_LTOFF_TP14R:
1791 case R_PARISC_LTOFF_TP14F:
1792 case R_PARISC_LTOFF_TP16F:
1793 case R_PARISC_DPREL14R:
1794 case R_PARISC_DPREL14F:
1795 case R_PARISC_GPREL16F:
1796 case R_PARISC_PLTOFF14R:
1797 case R_PARISC_PLTOFF14F:
1798 case R_PARISC_PLTOFF16F:
1799 case R_PARISC_DIR14R:
1800 case R_PARISC_DIR16F:
1801 case R_PARISC_LTOFF16F:
1805 /* Mask off bits in INSN we do not want. */
1808 /* Turn the 14bit value into the proper format. */
1809 low_sign_unext (sym_value, 14, &w);
1811 /* And insert the proper bits into INSN. */
1815 /* Doubleword loads and stores with a 14bit displacement. */
1816 case R_PARISC_DLTREL14DR:
1817 case R_PARISC_DLTIND14DR:
1818 case R_PARISC_LTOFF_FPTR14DR:
1819 case R_PARISC_LTOFF_FPTR16DF:
1820 case R_PARISC_PCREL14DR:
1821 case R_PARISC_PCREL16DF:
1822 case R_PARISC_LTOFF_TP14DR:
1823 case R_PARISC_LTOFF_TP16DF:
1824 case R_PARISC_DPREL14DR:
1825 case R_PARISC_GPREL16DF:
1826 case R_PARISC_PLTOFF14DR:
1827 case R_PARISC_PLTOFF16DF:
1828 case R_PARISC_DIR14DR:
1829 case R_PARISC_DIR16DF:
1830 case R_PARISC_LTOFF16DF:
1832 /* Mask off bits in INSN we do not want. */
1835 /* The sign bit at 14 moves into bit zero in the destination. */
1836 insn |= ((sym_value & 0x2000) >> 13);
1838 /* Turn off the bits in sym_value we do not care about. */
1839 sym_value &= 0x1ff8;
1841 /* Now shift it one bit position left so that it lines up with the
1842 destination field in INSN. */
1845 return insn | sym_value;
1848 /* Floating point single word load/store instructions. */
1849 case R_PARISC_DLTREL14WR:
1850 case R_PARISC_DLTIND14WR:
1851 case R_PARISC_LTOFF_FPTR14WR:
1852 case R_PARISC_LTOFF_FPTR16WF:
1853 case R_PARISC_PCREL14WR:
1854 case R_PARISC_PCREL16WF:
1855 case R_PARISC_LTOFF_TP14WR:
1856 case R_PARISC_LTOFF_TP16WF:
1857 case R_PARISC_DPREL14WR:
1858 case R_PARISC_GPREL16WF:
1859 case R_PARISC_PLTOFF14WR:
1860 case R_PARISC_PLTOFF16WF:
1861 case R_PARISC_DIR16WF:
1862 case R_PARISC_DIR14WR:
1863 case R_PARISC_LTOFF16WF:
1865 /* Mask off bits in INSN we do not want. */
1868 /* The sign bit at 14 moves into bit zero in the destination. */
1869 insn |= ((sym_value & 0x2000) >> 13);
1871 /* Turn off the bits in sym_value we do not care about. */
1872 sym_value &= 0x1ffc;
1874 /* Now shift it one bit position left so that it lines up with the
1875 destination field in INSN. */
1878 return insn | sym_value;