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 /* ELF/PA relocation howto entries. */
74 static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
76 {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"},
78 /* The values in DIR32 are to placate the check in
79 _bfd_stab_section_find_nearest_line. */
80 {R_PARISC_DIR32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR32", false, 0, 0xffffffff, false},
81 {R_PARISC_DIR21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR21L"},
82 {R_PARISC_DIR17R, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR17R"},
83 {R_PARISC_DIR17F, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR17F"},
84 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
85 {R_PARISC_DIR14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14R"},
86 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
87 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
88 {R_PARISC_PCREL32, 0, 0, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL32"},
90 {R_PARISC_PCREL21L, 0, 0, 21, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL21L"},
91 {R_PARISC_PCREL17R, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17R"},
92 {R_PARISC_PCREL17F, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17F"},
93 {R_PARISC_PCREL17C, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17C"},
94 {R_PARISC_PCREL14R, 0, 0, 14, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14R"},
95 {R_PARISC_PCREL14F, 0, 0, 14, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14F"},
96 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
97 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
98 {R_PARISC_DPREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL21L"},
99 {R_PARISC_DPREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14WR"},
101 {R_PARISC_DPREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14DR"},
102 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
103 {R_PARISC_DPREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14R"},
104 {R_PARISC_DPREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14F"},
105 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
106 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
107 {R_PARISC_DLTREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL21L"},
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_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
112 {R_PARISC_DLTREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14R"},
113 {R_PARISC_DLTREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14F"},
114 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
115 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
116 {R_PARISC_DLTIND21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND21L"},
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_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
120 {R_PARISC_DLTIND14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14R"},
121 {R_PARISC_DLTIND14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14F"},
123 {R_PARISC_SETBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SETBASE"},
124 {R_PARISC_SECREL32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SECREL32"},
125 {R_PARISC_BASEREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL21L"},
126 {R_PARISC_BASEREL17R, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL17R"},
127 {R_PARISC_BASEREL17F, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL17F"},
128 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
129 {R_PARISC_BASEREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14R"},
130 {R_PARISC_BASEREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14F"},
131 {R_PARISC_SEGBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGBASE"},
132 {R_PARISC_SEGREL32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGREL32"},
134 {R_PARISC_PLTOFF21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF21L"},
135 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
136 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
137 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
138 {R_PARISC_PLTOFF14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14R"},
139 {R_PARISC_PLTOFF14F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14F"},
140 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
141 {R_PARISC_LTOFF_FPTR32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR32"},
142 {R_PARISC_LTOFF_FPTR21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR21L"},
143 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
145 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
146 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
147 {R_PARISC_LTOFF_FPTR14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14R"},
148 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
149 {R_PARISC_FPTR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_FPTR64"},
150 {R_PARISC_PLABEL32, 0, 0, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL32"},
151 {R_PARISC_PLABEL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL21L"},
152 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
153 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
154 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
156 {R_PARISC_PLABEL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL14R"},
157 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
158 {R_PARISC_PCREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL64"},
159 {R_PARISC_PCREL22C, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL22C"},
160 {R_PARISC_PCREL22F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL22F"},
161 {R_PARISC_PCREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14WR"},
162 {R_PARISC_PCREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14DR"},
163 {R_PARISC_PCREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16F"},
164 {R_PARISC_PCREL16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16WF"},
165 {R_PARISC_PCREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16DF"},
167 {R_PARISC_DIR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR64"},
168 {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"},
169 {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"},
170 {R_PARISC_DIR14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14WR"},
171 {R_PARISC_DIR14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14DR"},
172 {R_PARISC_DIR16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16F"},
173 {R_PARISC_DIR16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16WF"},
174 {R_PARISC_DIR16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16DF"},
175 {R_PARISC_GPREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL64"},
176 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
178 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
179 {R_PARISC_DLTREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14WR"},
180 {R_PARISC_DLTREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14DR"},
181 {R_PARISC_GPREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16F"},
182 {R_PARISC_GPREL16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16WF"},
183 {R_PARISC_GPREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16DF"},
184 {R_PARISC_LTOFF64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF64"},
185 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
186 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
187 {R_PARISC_DLTIND14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14WR"},
189 {R_PARISC_DLTIND14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14DR"},
190 {R_PARISC_LTOFF16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16F"},
191 {R_PARISC_LTOFF16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF"},
192 {R_PARISC_LTOFF16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF"},
193 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
194 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
195 {R_PARISC_BASEREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BSEREL14WR"},
196 {R_PARISC_BASEREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14DR"},
197 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
198 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
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"},
202 {R_PARISC_SEGREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGREL64"},
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_PLTOFF14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14WR"},
206 {R_PARISC_PLTOFF14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14DR"},
207 {R_PARISC_PLTOFF16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16F"},
208 {R_PARISC_PLTOFF16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16WF"},
209 {R_PARISC_PLTOFF16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16DF"},
211 {R_PARISC_LTOFF_FPTR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
212 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
213 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
214 {R_PARISC_LTOFF_FPTR14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14WR"},
215 {R_PARISC_LTOFF_FPTR14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14DR"},
216 {R_PARISC_LTOFF_FPTR16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16F"},
217 {R_PARISC_LTOFF_FPTR16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16WF"},
218 {R_PARISC_LTOFF_FPTR16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
219 {R_PARISC_COPY, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_COPY"},
220 {R_PARISC_IPLT, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_IPLT"},
222 {R_PARISC_EPLT, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_EPLT"},
223 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
224 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
225 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
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_dont, NULL, "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"},
233 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
234 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
235 {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_bitfield, bfd_elf_generic_reloc, "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_dont, NULL, "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"},
244 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
245 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
246 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
247 {R_PARISC_TPREL32, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL32"},
248 {R_PARISC_TPREL21L, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL21L"},
249 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
250 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
251 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
252 {R_PARISC_TPREL14R, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL14R"},
253 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
255 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
256 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
257 {R_PARISC_LTOFF_TP21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP21L"},
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_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
260 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
261 {R_PARISC_LTOFF_TP14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
262 {R_PARISC_LTOFF_TP14F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14F"},
263 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
264 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
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_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
268 {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_bitfield, bfd_elf_generic_reloc, "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_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
275 {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_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
278 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
279 {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_bitfield, bfd_elf_generic_reloc, "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_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
286 {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_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
289 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
290 {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_bitfield, bfd_elf_generic_reloc, "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_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
297 {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_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
300 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
301 {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_bitfield, bfd_elf_generic_reloc, "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_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
308 {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_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
311 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
312 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "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_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
316 {R_PARISC_TPREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL64"},
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_TPREL14WR, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL14WR"},
321 {R_PARISC_TPREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL14DR"},
322 {R_PARISC_TPREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL16F"},
323 {R_PARISC_TPREL16WF, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL16WF"},
324 {R_PARISC_TPREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL16DF"},
325 {R_PARISC_LTOFF_TP64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP64"},
326 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
327 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
328 {R_PARISC_LTOFF_TP14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14WR"},
329 {R_PARISC_LTOFF_TP14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14DR"},
330 {R_PARISC_LTOFF_TP16F, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_LTOFF_TP16F"},
332 {R_PARISC_LTOFF_TP16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16WF"},
333 {R_PARISC_LTOFF_TP16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16DF"},
336 #define OFFSET_14R_FROM_21L 4
337 #define OFFSET_14F_FROM_21L 5
339 /* Return one (or more) BFD relocations which implement the base
340 relocation with modifications based on format and field. */
342 elf_hppa_reloc_type **
343 _bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
345 elf_hppa_reloc_type base_type;
351 elf_hppa_reloc_type *finaltype;
352 elf_hppa_reloc_type **final_types;
354 /* Allocate slots for the BFD relocation. */
355 final_types = ((elf_hppa_reloc_type **)
356 bfd_alloc (abfd, sizeof (elf_hppa_reloc_type *) * 2));
357 if (final_types == NULL)
360 /* Allocate space for the relocation itself. */
361 finaltype = ((elf_hppa_reloc_type *)
362 bfd_alloc (abfd, sizeof (elf_hppa_reloc_type)));
363 if (finaltype == NULL)
366 /* Some reasonable defaults. */
367 final_types[0] = finaltype;
368 final_types[1] = NULL;
370 #define final_type finaltype[0]
372 final_type = base_type;
374 /* Just a tangle of nested switch statements to deal with the braindamage
375 that a different field selector means a completely different relocation
379 /* We have been using generic relocation types. However, that may not
380 really make sense. Anyway, we need to support both R_PARISC_DIR64
381 and R_PARISC_DIR32 here. */
384 case R_HPPA_ABS_CALL:
392 final_type = R_PARISC_DIR14R;
395 final_type = R_PARISC_DLTIND14R;
398 final_type = R_PARISC_LTOFF_FPTR14DR;
401 final_type = R_PARISC_DLTIND14F;
404 final_type = R_PARISC_PLABEL14R;
415 final_type = R_PARISC_DIR17F;
419 final_type = R_PARISC_DIR17R;
431 final_type = R_PARISC_DIR21L;
434 final_type = R_PARISC_DLTIND21L;
437 final_type = R_PARISC_LTOFF_FPTR21L;
440 final_type = R_PARISC_PLABEL21L;
451 final_type = R_PARISC_DIR32;
452 /* When in 64bit mode, a 32bit relocation is supposed to
453 be a section relative relocation. Dwarf2 (for example)
454 uses 32bit section relative relocations. */
455 if (bfd_get_arch_info (abfd)->bits_per_address != 32)
456 final_type = R_PARISC_SECREL32;
459 final_type = R_PARISC_PLABEL32;
470 final_type = R_PARISC_DIR64;
473 final_type = R_PARISC_FPTR64;
494 final_type = base_type + OFFSET_14R_FROM_21L;
497 final_type = base_type + OFFSET_14F_FROM_21L;
509 final_type = base_type;
522 case R_HPPA_PCREL_CALL:
530 final_type = R_PARISC_PCREL14R;
533 final_type = R_PARISC_PCREL14F;
545 final_type = R_PARISC_PCREL17R;
548 final_type = R_PARISC_PCREL17F;
559 final_type = R_PARISC_PCREL22F;
571 final_type = R_PARISC_PCREL21L;
583 case R_PARISC_SEGREL32:
584 case R_PARISC_SEGBASE:
585 /* The defaults are fine for these cases. */
595 /* Translate from an elf into field into a howto relocation pointer. */
598 elf_hppa_info_to_howto (abfd, bfd_reloc, elf_reloc)
601 Elf_Internal_Rela *elf_reloc;
603 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
604 < (unsigned int) R_PARISC_UNIMPLEMENTED);
605 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
608 /* Translate from an elf into field into a howto relocation pointer. */
611 elf_hppa_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
614 Elf_Internal_Rel *elf_reloc;
616 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
617 < (unsigned int) R_PARISC_UNIMPLEMENTED);
618 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
621 /* Return the address of the howto table entry to perform the CODE
622 relocation for an ARCH machine. */
624 static reloc_howto_type *
625 elf_hppa_reloc_type_lookup (abfd, code)
627 bfd_reloc_code_real_type code;
629 if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
631 BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
632 return &elf_hppa_howto_table[(int) code];
638 elf_hppa_final_write_processing (abfd, linker)
642 int mach = bfd_get_mach (abfd);
644 elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL
645 | EF_PARISC_EXT | EF_PARISC_LSB
646 | EF_PARISC_WIDE | EF_PARISC_NO_KABP
647 | EF_PARISC_LAZYSWAP);
650 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0;
652 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1;
654 elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0;
656 elf_elfheader (abfd)->e_flags |= EF_PARISC_WIDE | EFA_PARISC_2_0;
659 /* Return true if SYM represents a local label symbol. */
662 elf_hppa_is_local_label_name (abfd, name)
663 bfd *abfd ATTRIBUTE_UNUSED;
666 return (name[0] == 'L' && name[1] == '$');
669 /* Set the correct type for an ELF section. We do this by the
670 section name, which is a hack, but ought to work. */
673 elf_hppa_fake_sections (abfd, hdr, sec)
675 Elf64_Internal_Shdr *hdr;
678 register const char *name;
680 name = bfd_get_section_name (abfd, sec);
682 if (strcmp (name, ".PARISC.unwind") == 0)
686 hdr->sh_type = SHT_LOPROC + 1;
687 /* ?!? How are unwinds supposed to work for symbols in arbitrary
688 sections? Or what if we have multiple .text sections in a single
689 .o file? HP really messed up on this one.
691 Ugh. We can not use elf_section_data (sec)->this_idx at this
692 point because it is not initialized yet.
694 So we (gasp) recompute it here. Hopefully nobody ever changes the
695 way sections are numbered in elf.c! */
696 for (sec = abfd->sections, indx = 1; sec; sec = sec->next, indx++)
698 if (sec->name && strcmp (sec->name, ".text") == 0)
705 /* I have no idea if this is really necessary or what it means. */
711 /* Hook called by the linker routine which adds symbols from an object
712 file. HP's libraries define symbols with HP specific section
713 indices, which we have to handle. */
716 elf_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
718 struct bfd_link_info *info ATTRIBUTE_UNUSED;
719 const Elf_Internal_Sym *sym;
720 const char **namep ATTRIBUTE_UNUSED;
721 flagword *flagsp ATTRIBUTE_UNUSED;
725 int index = sym->st_shndx;
729 case SHN_PARISC_ANSI_COMMON:
730 *secp = bfd_make_section_old_way (abfd, ".PARISC.ansi.common");
731 (*secp)->flags |= SEC_IS_COMMON;
732 *valp = sym->st_size;
735 case SHN_PARISC_HUGE_COMMON:
736 *secp = bfd_make_section_old_way (abfd, ".PARISC.huge.common");
737 (*secp)->flags |= SEC_IS_COMMON;
738 *valp = sym->st_size;
746 elf_hppa_unmark_useless_dynamic_symbols (h, data)
747 struct elf_link_hash_entry *h;
750 struct bfd_link_info *info = (struct bfd_link_info *)data;
752 /* If we are not creating a shared library, and this symbol is
753 referenced by a shared library but is not defined anywhere, then
754 the generic code will warn that it is undefined.
756 This behavior is undesirable on HPs since the standard shared
757 libraries contain reerences to undefined symbols.
759 So we twiddle the flags associated with such symbols so that they
760 will not trigger the warning. ?!? FIXME. This is horribly fraglie.
762 Ultimately we should have better controls over the generic ELF BFD
764 if (! info->relocateable
766 && !info->no_undefined)
767 && h->root.type == bfd_link_hash_undefined
768 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
769 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
771 h->elf_link_hash_flags &= ~ELF_LINK_HASH_REF_DYNAMIC;
772 h->elf_link_hash_flags |= 0x8000;
780 elf_hppa_remark_useless_dynamic_symbols (h, data)
781 struct elf_link_hash_entry *h;
784 struct bfd_link_info *info = (struct bfd_link_info *)data;
786 /* If we are not creating a shared library, and this symbol is
787 referenced by a shared library but is not defined anywhere, then
788 the generic code will warn that it is undefined.
790 This behavior is undesirable on HPs since the standard shared
791 libraries contain reerences to undefined symbols.
793 So we twiddle the flags associated with such symbols so that they
794 will not trigger the warning. ?!? FIXME. This is horribly fraglie.
796 Ultimately we should have better controls over the generic ELF BFD
798 if (! info->relocateable
800 && !info->no_undefined)
801 && h->root.type == bfd_link_hash_undefined
802 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
803 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
804 && (h->elf_link_hash_flags & 0x8000) != 0)
806 h->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC;
807 h->elf_link_hash_flags &= ~0x8000;
813 /* Called after we have seen all the input files/sections, but before
814 final symbol resolution and section placement has been determined.
816 We use this hook to (possibly) provide a value for __gp, then we
817 fall back to the generic ELF final link routine. */
820 elf_hppa_final_link (abfd, info)
822 struct bfd_link_info *info;
826 /* Make sure we've got ourselves a suitable __gp value. */
827 if (!info->relocateable)
829 bfd_vma min_short_vma = (bfd_vma) -1, max_short_vma = 0;
830 struct elf_link_hash_entry *gp;
834 /* Find the .opd section. __gp's value should be the same as
835 the start of .PARISC.global section. */
836 for (os = abfd->sections; os ; os = os->next)
840 /* This would be cleaner if we marked sections with an attribute
841 indicating they are short sections. */
842 if (strcmp (os->name, ".PARISC.global") == 0)
846 BFD_ASSERT (os != NULL)
848 gp_val = (os->output_section->vma + os->output_offset);
850 gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", true,
852 gp->root.type = bfd_link_hash_defined;
853 gp->root.u.def.section = os;
854 gp->root.u.def.value = 0;
855 _bfd_set_gp_value (abfd, gp_val);
858 /* HP's shared libraries have references to symbols that are not
859 defined anywhere. The generic ELF BFD linker code will complaim
862 So we detect the losing case and arrange for the flags on the symbol
863 to indicate that it was never referenced. This keeps the generic
864 ELF BFD link code happy and appears to not create any secondary
865 problems. Ultimately we need a way to control the behavior of the
866 generic ELF BFD link code better. */
867 elf_link_hash_traverse (elf_hash_table (info),
868 elf_hppa_unmark_useless_dynamic_symbols,
871 /* Invoke the regular ELF backend linker to do all the work. */
872 retval = bfd_elf_bfd_final_link (abfd, info);
874 elf_link_hash_traverse (elf_hash_table (info),
875 elf_hppa_remark_useless_dynamic_symbols,
881 /* Relocate an HPPA ELF section. */
884 elf_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
885 contents, relocs, local_syms, local_sections)
887 struct bfd_link_info *info;
889 asection *input_section;
891 Elf_Internal_Rela *relocs;
892 Elf_Internal_Sym *local_syms;
893 asection **local_sections;
895 Elf_Internal_Shdr *symtab_hdr;
896 Elf_Internal_Rela *rel;
897 Elf_Internal_Rela *relend;
898 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
900 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
903 relend = relocs + input_section->reloc_count;
904 for (; rel < relend; rel++)
907 reloc_howto_type *howto;
908 unsigned long r_symndx;
909 struct elf_link_hash_entry *h;
910 Elf_Internal_Sym *sym;
913 bfd_reloc_status_type r;
914 const char *sym_name;
916 char *dynh_buf = NULL;
917 size_t dynh_buflen = 0;
918 struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
920 r_type = ELF_R_TYPE (rel->r_info);
921 if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
923 bfd_set_error (bfd_error_bad_value);
927 r_symndx = ELF_R_SYM (rel->r_info);
929 if (info->relocateable)
931 /* This is a relocateable link. We don't have to change
932 anything, unless the reloc is against a section symbol,
933 in which case we have to adjust according to where the
934 section symbol winds up in the output section. */
935 if (r_symndx < symtab_hdr->sh_info)
937 sym = local_syms + r_symndx;
938 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
940 sym_sec = local_sections[r_symndx];
941 rel->r_addend += sym_sec->output_offset;
948 /* This is a final link. */
952 if (r_symndx < symtab_hdr->sh_info)
954 /* This is a local symbol. */
955 sym = local_syms + r_symndx;
956 sym_sec = local_sections[r_symndx];
957 relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION
959 + sym_sec->output_offset
960 + sym_sec->output_section->vma);
962 /* If this symbol has an entry in the PA64 dynamic hash
963 table, then get it. */
964 dyn_name = get_dyn_name (input_bfd, h, rel,
965 &dynh_buf, &dynh_buflen);
966 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
967 dyn_name, false, false);
972 /* This is not a local symbol. */
975 indx = r_symndx - symtab_hdr->sh_info;
976 h = elf_sym_hashes (input_bfd)[indx];
977 while (h->root.type == bfd_link_hash_indirect
978 || h->root.type == bfd_link_hash_warning)
979 h = (struct elf_link_hash_entry *) h->root.u.i.link;
980 if (h->root.type == bfd_link_hash_defined
981 || h->root.type == bfd_link_hash_defweak)
983 sym_sec = h->root.u.def.section;
986 /* If this symbol has an entry in the PA64 dynamic hash
987 table, then get it. */
988 dyn_name = get_dyn_name (input_bfd, h, rel,
989 &dynh_buf, &dynh_buflen);
990 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
991 dyn_name, false, false);
993 /* If we have a relocation against a symbol defined in a
994 shared library and we have not created an entry in the
995 PA64 dynamic symbol hash table for it, then we lose. */
996 if (sym_sec->output_section == NULL && dyn_h == NULL)
998 (*_bfd_error_handler)
999 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
1000 bfd_get_filename (input_bfd), h->root.root.string,
1001 bfd_get_section_name (input_bfd, input_section));
1004 else if (sym_sec->output_section)
1005 relocation = (h->root.u.def.value
1006 + sym_sec->output_offset
1007 + sym_sec->output_section->vma);
1008 /* Value will be provided via one of the offsets in the
1009 dyn_h hash table entry. */
1013 else if (h->root.type == bfd_link_hash_undefweak)
1017 if (!((*info->callbacks->undefined_symbol)
1018 (info, h->root.root.string, input_bfd,
1019 input_section, rel->r_offset)))
1026 sym_name = h->root.root.string;
1029 sym_name = bfd_elf_string_from_elf_section (input_bfd,
1030 symtab_hdr->sh_link,
1032 if (sym_name == NULL)
1034 if (*sym_name == '\0')
1035 sym_name = bfd_section_name (input_bfd, sym_sec);
1038 r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1039 input_section, contents,
1040 relocation, info, sym_sec,
1043 if (r != bfd_reloc_ok)
1049 case bfd_reloc_overflow:
1051 if (!((*info->callbacks->reloc_overflow)
1052 (info, sym_name, howto->name, (bfd_vma) 0,
1053 input_bfd, input_section, rel->r_offset)))
1064 /* Compute the value for a relocation (REL) during a final link stage,
1065 then insert the value into the proper location in CONTENTS.
1067 VALUE is a tentative value for the relocation and may be overridden
1068 and modified here based on the specific relocation to be performed.
1070 For example we do conversions for PC-relative branches in this routine
1071 or redirection of calls to external routines to stubs.
1073 The work of actually applying the relocation is left to a helper
1074 routine in an attempt to reduce the complexity and size of this
1077 static bfd_reloc_status_type
1078 elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1079 input_section, contents, value,
1080 info, sym_sec, h, dyn_h)
1081 Elf_Internal_Rela *rel;
1084 asection *input_section;
1087 struct bfd_link_info *info;
1089 struct elf_link_hash_entry *h;
1090 struct elf64_hppa_dyn_hash_entry *dyn_h;
1093 bfd_vma offset = rel->r_offset;
1094 bfd_vma addend = rel->r_addend;
1095 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
1096 unsigned long r_type = howto->type;
1097 unsigned long r_format = howto->bitsize;
1098 unsigned long r_field = e_fsel;
1099 bfd_byte *hit_data = contents + offset;
1100 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
1102 insn = bfd_get_32 (input_bfd, hit_data);
1104 /* For reference here a quick summary of the relocations found in the
1105 HPUX 11.00 PA64 .o and .a files, but not yet implemented. This is mostly
1106 a guide to help prioritize what relocation support is worked on first.
1107 The list will be deleted eventually.
1109 27210 R_PARISC_SEGREL32 */
1116 /* Random PC relative relocs. */
1117 case R_PARISC_PCREL21L:
1118 case R_PARISC_PCREL14R:
1119 case R_PARISC_PCREL14F:
1120 case R_PARISC_PCREL14WR:
1121 case R_PARISC_PCREL14DR:
1122 case R_PARISC_PCREL16F:
1123 case R_PARISC_PCREL16WF:
1124 case R_PARISC_PCREL16DF:
1126 if (r_type == R_PARISC_PCREL21L)
1128 else if (r_type == R_PARISC_PCREL14F
1129 || r_type == R_PARISC_PCREL16F
1130 || r_type == R_PARISC_PCREL16WF
1131 || r_type == R_PARISC_PCREL16DF)
1136 /* If this is a call to a function defined in another dynamic
1137 library, then redirect the call to the local stub for this
1139 if (sym_sec->output_section == NULL)
1140 value = dyn_h->stub_offset;
1142 /* Turn VALUE into a proper PC relative address. */
1143 value -= (offset + input_section->output_offset
1144 + input_section->output_section->vma);
1146 /* Adjust for any field selectors. */
1147 value = hppa_field_adjust (value, -8 + addend, r_field);
1149 /* Apply the relocation to the given instruction. */
1150 insn = elf_hppa_relocate_insn (insn, value, r_type);
1154 /* Basic function call support. I'm not entirely sure if PCREL14F is
1155 actually needed or even handled correctly.
1157 Note for a call to a function defined in another dynamic library
1158 we want to redirect the call to a stub. */
1159 case R_PARISC_PCREL22F:
1160 case R_PARISC_PCREL17F:
1161 case R_PARISC_PCREL22C:
1162 case R_PARISC_PCREL17C:
1163 case R_PARISC_PCREL17R:
1165 if (r_type == R_PARISC_PCREL17R)
1170 /* If this is a call to a function defined in another dynamic
1171 library, then redirect the call to the local stub for this
1173 if (sym_sec->output_section == NULL)
1174 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1175 + hppa_info->stub_sec->output_section->vma);
1177 /* Turn VALUE into a proper PC relative address. */
1178 value -= (offset + input_section->output_offset
1179 + input_section->output_section->vma);
1181 /* Adjust for any field selectors. */
1182 value = hppa_field_adjust (value, -8 + addend, e_fsel);
1184 /* All branches are implicitly shifted by 2 places. */
1187 /* Apply the relocation to the given instruction. */
1188 insn = elf_hppa_relocate_insn (insn, value, r_type);
1192 /* Indirect references to data through the DLT. */
1193 case R_PARISC_DLTIND14R:
1194 case R_PARISC_DLTIND14F:
1195 case R_PARISC_DLTIND14DR:
1196 case R_PARISC_DLTIND14WR:
1197 case R_PARISC_DLTIND21L:
1198 case R_PARISC_LTOFF_FPTR14R:
1199 case R_PARISC_LTOFF_FPTR14DR:
1200 case R_PARISC_LTOFF_FPTR14WR:
1201 case R_PARISC_LTOFF_FPTR21L:
1202 case R_PARISC_LTOFF_FPTR16F:
1203 case R_PARISC_LTOFF_FPTR16WF:
1204 case R_PARISC_LTOFF_FPTR16DF:
1205 case R_PARISC_LTOFF_TP21L:
1206 case R_PARISC_LTOFF_TP14R:
1207 case R_PARISC_LTOFF_TP14F:
1208 case R_PARISC_LTOFF_TP14WR:
1209 case R_PARISC_LTOFF_TP14DR:
1210 case R_PARISC_LTOFF_TP16F:
1211 case R_PARISC_LTOFF_TP16WF:
1212 case R_PARISC_LTOFF_TP16DF:
1213 case R_PARISC_LTOFF16F:
1214 case R_PARISC_LTOFF16WF:
1215 case R_PARISC_LTOFF16DF:
1217 /* If this relocation was against a local symbol, then we still
1218 have not set up the DLT entry (it's not convienent to do so
1219 in the "finalize_dlt" routine because it is difficult to get
1220 to the local symbol's value).
1222 So, if this is a local symbol (h == NULL), then we need to
1223 fill in its DLT entry. */
1224 if (dyn_h->h == NULL)
1226 bfd_put_64 (hppa_info->dlt_sec->owner,
1228 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
1231 /* We want the value of the DLT offset for this symbol, not
1232 the symbol's actual address. */
1233 value = dyn_h->dlt_offset + hppa_info->dlt_sec->output_offset;
1235 /* All DLTIND relocations are basically the same at this point,
1236 except that we need different field selectors for the 21bit
1237 version vs the 14bit versions. */
1238 if (r_type == R_PARISC_DLTIND21L
1239 || r_type == R_PARISC_LTOFF_FPTR21L
1240 || r_type == R_PARISC_LTOFF_TP21L)
1241 value = hppa_field_adjust (value, addend, e_lrsel);
1242 else if (r_type == R_PARISC_DLTIND14F
1243 || r_type == R_PARISC_LTOFF_FPTR16F
1244 || r_type == R_PARISC_LTOFF_FPTR16WF
1245 || r_type == R_PARISC_LTOFF_FPTR16DF
1246 || r_type == R_PARISC_LTOFF16F
1247 || r_type == R_PARISC_LTOFF16DF
1248 || r_type == R_PARISC_LTOFF16WF
1249 || r_type == R_PARISC_LTOFF_TP16F
1250 || r_type == R_PARISC_LTOFF_TP16WF
1251 || r_type == R_PARISC_LTOFF_TP16DF)
1252 value = hppa_field_adjust (value, addend, e_fsel);
1254 value = hppa_field_adjust (value, addend, e_rrsel);
1256 insn = elf_hppa_relocate_insn (insn, value, r_type);
1260 case R_PARISC_DLTREL14R:
1261 case R_PARISC_DLTREL14F:
1262 case R_PARISC_DLTREL14DR:
1263 case R_PARISC_DLTREL14WR:
1264 case R_PARISC_DLTREL21L:
1265 case R_PARISC_DPREL21L:
1266 case R_PARISC_DPREL14WR:
1267 case R_PARISC_DPREL14DR:
1268 case R_PARISC_DPREL14R:
1269 case R_PARISC_DPREL14F:
1270 case R_PARISC_GPREL16F:
1271 case R_PARISC_GPREL16WF:
1272 case R_PARISC_GPREL16DF:
1274 /* Subtract out the global pointer value to make value a DLT
1275 relative address. */
1276 value -= _bfd_get_gp_value (output_bfd);
1278 /* All DLTREL relocations are basically the same at this point,
1279 except that we need different field selectors for the 21bit
1280 version vs the 14bit versions. */
1281 if (r_type == R_PARISC_DLTREL21L
1282 || r_type == R_PARISC_DPREL21L)
1283 value = hppa_field_adjust (value, addend, e_lrsel);
1284 else if (r_type == R_PARISC_DLTREL14F
1285 || r_type == R_PARISC_DPREL14F
1286 || r_type == R_PARISC_GPREL16F
1287 || r_type == R_PARISC_GPREL16WF
1288 || r_type == R_PARISC_GPREL16DF)
1289 value = hppa_field_adjust (value, addend, e_fsel);
1291 value = hppa_field_adjust (value, addend, e_rrsel);
1293 insn = elf_hppa_relocate_insn (insn, value, r_type);
1297 case R_PARISC_DIR21L:
1298 case R_PARISC_DIR17R:
1299 case R_PARISC_DIR17F:
1300 case R_PARISC_DIR14R:
1301 case R_PARISC_DIR14WR:
1302 case R_PARISC_DIR14DR:
1303 case R_PARISC_DIR16F:
1304 case R_PARISC_DIR16WF:
1305 case R_PARISC_DIR16DF:
1307 /* All DIR relocations are basically the same at this point,
1308 except that we need different field selectors for the 21bit
1309 version vs the 14bit versions. */
1310 if (r_type == R_PARISC_DIR21L)
1311 value = hppa_field_adjust (value, addend, e_lrsel);
1312 else if (r_type == R_PARISC_DIR17F
1313 || r_type == R_PARISC_DIR16F
1314 || r_type == R_PARISC_DIR16WF
1315 || r_type == R_PARISC_DIR16DF)
1316 value = hppa_field_adjust (value, addend, e_fsel);
1318 value = hppa_field_adjust (value, addend, e_rrsel);
1320 insn = elf_hppa_relocate_insn (insn, value, r_type);
1324 case R_PARISC_PLTOFF21L:
1325 case R_PARISC_PLTOFF14R:
1326 case R_PARISC_PLTOFF14F:
1327 case R_PARISC_PLTOFF14WR:
1328 case R_PARISC_PLTOFF14DR:
1329 case R_PARISC_PLTOFF16F:
1330 case R_PARISC_PLTOFF16WF:
1331 case R_PARISC_PLTOFF16DF:
1333 /* We want the value of the PLT offset for this symbol, not
1334 the symbol's actual address. */
1335 value = dyn_h->plt_offset + hppa_info->plt_sec->output_offset;
1337 /* All PLTOFF relocations are basically the same at this point,
1338 except that we need different field selectors for the 21bit
1339 version vs the 14bit versions. */
1340 if (r_type == R_PARISC_PLTOFF21L)
1341 value = hppa_field_adjust (value, addend, e_lrsel);
1342 else if (r_type == R_PARISC_PLTOFF14F
1343 || r_type == R_PARISC_PLTOFF16F
1344 || r_type == R_PARISC_PLTOFF16WF
1345 || r_type == R_PARISC_PLTOFF16DF)
1346 value = hppa_field_adjust (value, addend, e_fsel);
1348 value = hppa_field_adjust (value, addend, e_rrsel);
1350 insn = elf_hppa_relocate_insn (insn, value, r_type);
1354 case R_PARISC_LTOFF_FPTR32:
1356 /* We want the value of the DLT offset for this symbol, not
1357 the symbol's actual address. */
1358 value = dyn_h->dlt_offset + hppa_info->dlt_sec->output_offset;
1359 bfd_put_32 (input_bfd, value, hit_data);
1360 return bfd_reloc_ok;
1363 case R_PARISC_LTOFF_FPTR64:
1364 case R_PARISC_LTOFF_TP64:
1366 /* We want the value of the DLT offset for this symbol, not
1367 the symbol's actual address. */
1368 value = dyn_h->dlt_offset + hppa_info->dlt_sec->output_offset;
1369 bfd_put_64 (input_bfd, value, hit_data);
1370 return bfd_reloc_ok;
1373 case R_PARISC_DIR32:
1374 bfd_put_32 (input_bfd, value + addend, hit_data);
1375 return bfd_reloc_ok;
1377 case R_PARISC_DIR64:
1378 bfd_put_64 (input_bfd, value + addend, hit_data);
1379 return bfd_reloc_ok;
1381 case R_PARISC_GPREL64:
1382 /* Subtract out the global pointer value to make value a DLT
1383 relative address. */
1384 value -= _bfd_get_gp_value (output_bfd);
1387 bfd_put_64 (input_bfd, value + addend, hit_data);
1388 return bfd_reloc_ok;
1390 case R_PARISC_LTOFF64:
1391 /* We want the value of the DLT offset for this symbol, not
1392 the symbol's actual address. */
1393 value = dyn_h->dlt_offset + hppa_info->dlt_sec->output_offset;
1395 bfd_put_64 (input_bfd, value + addend, hit_data);
1396 return bfd_reloc_ok;
1398 case R_PARISC_PCREL32:
1400 /* If this is a call to a function defined in another dynamic
1401 library, then redirect the call to the local stub for this
1403 if (sym_sec->output_section == NULL)
1404 value = dyn_h->stub_offset;
1406 /* Turn VALUE into a proper PC relative address. */
1407 value -= (offset + input_section->output_offset
1408 + input_section->output_section->vma);
1412 bfd_put_64 (input_bfd, value, hit_data);
1413 return bfd_reloc_ok;
1416 case R_PARISC_PCREL64:
1418 /* If this is a call to a function defined in another dynamic
1419 library, then redirect the call to the local stub for this
1421 if (sym_sec->output_section == NULL)
1422 value = dyn_h->stub_offset;
1424 /* Turn VALUE into a proper PC relative address. */
1425 value -= (offset + input_section->output_offset
1426 + input_section->output_section->vma);
1430 bfd_put_64 (input_bfd, value, hit_data);
1431 return bfd_reloc_ok;
1435 case R_PARISC_FPTR64:
1436 /* We want the value of the OPD offset for this symbol, not
1437 the symbol's actual address. */
1438 value = (dyn_h->opd_offset
1439 + hppa_info->opd_sec->output_offset
1440 + hppa_info->opd_sec->output_section->vma);
1442 bfd_put_64 (input_bfd, value + addend, hit_data);
1443 return bfd_reloc_ok;
1445 /* Something we don't know how to handle. */
1447 /* ?!? This is temporary as we flesh out basic linker support, once
1448 the basic support is functional we will return the not_supported
1449 error conditional appropriately. */
1451 return bfd_reloc_not_supported;
1453 return bfd_reloc_ok;
1457 /* Update the instruction word. */
1458 bfd_put_32 (input_bfd, insn, hit_data);
1459 return (bfd_reloc_ok);
1462 /* Relocate the given INSN. VALUE should be the actual value we want
1463 to insert into the instruction, ie by this point we should not be
1464 concerned with computing an offset relative to the DLT, PC, etc.
1465 Instead this routine is meant to handle the bit manipulations needed
1466 to insert the relocation into the given instruction. */
1468 static unsigned long
1469 elf_hppa_relocate_insn (insn, sym_value, r_type)
1472 unsigned long r_type;
1474 long constant_value;
1478 /* This is any 22bit branch. In PA2.0 syntax it corresponds to
1479 the "B" instruction. */
1480 case R_PARISC_PCREL22F:
1481 case R_PARISC_PCREL22C:
1483 unsigned int w3, w2, w1, w;
1485 /* These are 22 bit branches. Mask off bits we do not care
1487 sym_value &= 0x3fffff;
1489 /* Now extract the W1, W2, W3 and W fields from the value. */
1490 dis_assemble_22 (sym_value, &w3, &w1, &w2, &w);
1492 /* Mask out bits for the value in the instruction. */
1495 /* Insert the bits for the W1, W2 and W fields into the
1497 insn |= (w3 << 21) | (w2 << 2) | (w1 << 16) | w;
1501 /* This is any 17bit branch. In PA2.0 syntax it also corresponds to
1502 the "B" instruction as well as BE. */
1503 case R_PARISC_PCREL17F:
1504 case R_PARISC_DIR17F:
1505 case R_PARISC_DIR17R:
1506 case R_PARISC_PCREL17C:
1507 case R_PARISC_PCREL17R:
1509 unsigned int w2, w1, w;
1511 /* These are 17 bit branches. Mask off bits we do not care
1513 sym_value &= 0x1ffff;
1515 /* Now extract the W1, W2 and W fields from the value. */
1516 dis_assemble_17 (sym_value, &w1, &w2, &w);
1518 /* Mask out bits for the value in the instruction. */
1521 /* Insert the bits for the W1, W2 and W fields into the
1523 insn |= (w2 << 2) | (w1 << 16) | w;
1527 /* ADDIL or LDIL instructions. */
1528 case R_PARISC_DLTREL21L:
1529 case R_PARISC_DLTIND21L:
1530 case R_PARISC_LTOFF_FPTR21L:
1531 case R_PARISC_PCREL21L:
1532 case R_PARISC_LTOFF_TP21L:
1533 case R_PARISC_DPREL21L:
1534 case R_PARISC_PLTOFF21L:
1535 case R_PARISC_DIR21L:
1539 /* Mask off bits in INSN we do not want. */
1542 /* Turn the 21bit value into the proper format. */
1543 dis_assemble_21 (sym_value, &w);
1545 /* And insert the proper bits into INSN. */
1549 /* LDO and integer loads/stores with 14bit displacements. */
1550 case R_PARISC_DLTREL14R:
1551 case R_PARISC_DLTREL14F:
1552 case R_PARISC_DLTIND14R:
1553 case R_PARISC_DLTIND14F:
1554 case R_PARISC_LTOFF_FPTR14R:
1555 case R_PARISC_LTOFF_FPTR16F:
1556 case R_PARISC_PCREL14R:
1557 case R_PARISC_PCREL14F:
1558 case R_PARISC_PCREL16F:
1559 case R_PARISC_LTOFF_TP14R:
1560 case R_PARISC_LTOFF_TP14F:
1561 case R_PARISC_LTOFF_TP16F:
1562 case R_PARISC_DPREL14R:
1563 case R_PARISC_DPREL14F:
1564 case R_PARISC_GPREL16F:
1565 case R_PARISC_PLTOFF14R:
1566 case R_PARISC_PLTOFF14F:
1567 case R_PARISC_PLTOFF16F:
1568 case R_PARISC_DIR14R:
1569 case R_PARISC_DIR16F:
1570 case R_PARISC_LTOFF16F:
1574 /* Mask off bits in INSN we do not want. */
1577 /* Turn the 14bit value into the proper format. */
1578 low_sign_unext (sym_value, 14, &w);
1580 /* And insert the proper bits into INSN. */
1584 /* Doubleword loads and stores with a 14bit displacement. */
1585 case R_PARISC_DLTREL14DR:
1586 case R_PARISC_DLTIND14DR:
1587 case R_PARISC_LTOFF_FPTR14DR:
1588 case R_PARISC_LTOFF_FPTR16DF:
1589 case R_PARISC_PCREL14DR:
1590 case R_PARISC_PCREL16DF:
1591 case R_PARISC_LTOFF_TP14DR:
1592 case R_PARISC_LTOFF_TP16DF:
1593 case R_PARISC_DPREL14DR:
1594 case R_PARISC_GPREL16DF:
1595 case R_PARISC_PLTOFF14DR:
1596 case R_PARISC_PLTOFF16DF:
1597 case R_PARISC_DIR14DR:
1598 case R_PARISC_DIR16DF:
1599 case R_PARISC_LTOFF16DF:
1603 /* Mask off bits in INSN we do not want. */
1606 /* The sign bit at 14 moves into bit zero in the destination. */
1607 insn |= ((sym_value & 0x2000) >> 13);
1609 /* Turn off the bits in sym_value we do not care about. */
1610 sym_value &= 0x1ff8;
1612 /* Now shift it one bit position left so that it lines up with the
1613 destination field in INSN. */
1616 return insn | sym_value;
1619 /* Floating point single word load/store instructions. */
1620 case R_PARISC_DLTREL14WR:
1621 case R_PARISC_DLTIND14WR:
1622 case R_PARISC_LTOFF_FPTR14WR:
1623 case R_PARISC_LTOFF_FPTR16WF:
1624 case R_PARISC_PCREL14WR:
1625 case R_PARISC_PCREL16WF:
1626 case R_PARISC_LTOFF_TP14WR:
1627 case R_PARISC_LTOFF_TP16WF:
1628 case R_PARISC_DPREL14WR:
1629 case R_PARISC_GPREL16WF:
1630 case R_PARISC_PLTOFF14WR:
1631 case R_PARISC_PLTOFF16WF:
1632 case R_PARISC_DIR16WF:
1633 case R_PARISC_DIR14WR:
1634 case R_PARISC_LTOFF16WF:
1638 /* Mask off bits in INSN we do not want. */
1641 /* The sign bit at 14 moves into bit zero in the destination. */
1642 insn |= ((sym_value & 0x2000) >> 13);
1644 /* Turn off the bits in sym_value we do not care about. */
1645 sym_value &= 0x1ffc;
1647 /* Now shift it one bit position left so that it lines up with the
1648 destination field in INSN. */
1651 return insn | sym_value;