missed entry
[deliverable/binutils-gdb.git] / bfd / elf-hppa.h
CommitLineData
9e103c9c 1/* Common code for PA ELF implementations.
ab96bf03 2 Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
555cd476 3 Free Software Foundation, Inc.
9e103c9c 4
9b52905e 5 This file is part of BFD, the Binary File Descriptor library.
9e103c9c 6
9b52905e
NC
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
9e103c9c 11
9b52905e
NC
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
9e103c9c 16
9b52905e
NC
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
9e103c9c
JL
20
21#define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
22
2eb429af
JL
23/* This file is included by multiple PA ELF BFD backends with different
24 sizes.
25
26 Most of the routines are written to be size independent, but sometimes
27 external constraints require 32 or 64 bit specific code. We remap
28 the definitions/functions as necessary here. */
9e103c9c 29#if ARCH_SIZE == 64
9b52905e
NC
30#define ELF_R_TYPE(X) ELF64_R_TYPE(X)
31#define ELF_R_SYM(X) ELF64_R_SYM(X)
32#define elf_hppa_reloc_final_type elf64_hppa_reloc_final_type
33#define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
34#define elf_hppa_relocate_section elf64_hppa_relocate_section
35#define elf_hppa_final_link elf64_hppa_final_link
9e103c9c
JL
36#endif
37#if ARCH_SIZE == 32
9b52905e
NC
38#define ELF_R_TYPE(X) ELF32_R_TYPE(X)
39#define ELF_R_SYM(X) ELF32_R_SYM(X)
40#define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type
41#define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
42#define elf_hppa_relocate_section elf32_hppa_relocate_section
43#define elf_hppa_final_link elf32_hppa_final_link
3f9b03b5
AM
44#endif
45
9e103c9c
JL
46/* ELF/PA relocation howto entries. */
47
48static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
49{
b34976b6
AM
50 { R_PARISC_NONE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
51 bfd_elf_generic_reloc, "R_PARISC_NONE", FALSE, 0, 0, FALSE },
9e103c9c
JL
52
53 /* The values in DIR32 are to placate the check in
54 _bfd_stab_section_find_nearest_line. */
b34976b6
AM
55 { R_PARISC_DIR32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
56 bfd_elf_generic_reloc, "R_PARISC_DIR32", FALSE, 0, 0xffffffff, FALSE },
ab96bf03 57 { R_PARISC_DIR21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6 58 bfd_elf_generic_reloc, "R_PARISC_DIR21L", FALSE, 0, 0, FALSE },
ab96bf03 59 { R_PARISC_DIR17R, 0, 2, 17, FALSE, 0, complain_overflow_bitfield,
b34976b6 60 bfd_elf_generic_reloc, "R_PARISC_DIR17R", FALSE, 0, 0, FALSE },
ab96bf03 61 { R_PARISC_DIR17F, 0, 2, 17, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
62 bfd_elf_generic_reloc, "R_PARISC_DIR17F", FALSE, 0, 0, FALSE },
63 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
64 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 65 { R_PARISC_DIR14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 66 bfd_elf_generic_reloc, "R_PARISC_DIR14R", FALSE, 0, 0, FALSE },
ab96bf03 67 { R_PARISC_DIR14F, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 68 bfd_elf_generic_reloc, "R_PARISC_DIR14F", FALSE, 0, 0, FALSE },
49bd834c 69 /* 8 */
ab96bf03 70 { R_PARISC_PCREL12F, 0, 2, 12, TRUE, 0, complain_overflow_bitfield,
b34976b6 71 bfd_elf_generic_reloc, "R_PARISC_PCREL12F", FALSE, 0, 0, FALSE },
ab96bf03 72 { R_PARISC_PCREL32, 0, 2, 32, TRUE, 0, complain_overflow_bitfield,
b34976b6 73 bfd_elf_generic_reloc, "R_PARISC_PCREL32", FALSE, 0, 0, FALSE },
ab96bf03 74 { R_PARISC_PCREL21L, 0, 2, 21, TRUE, 0, complain_overflow_bitfield,
b34976b6 75 bfd_elf_generic_reloc, "R_PARISC_PCREL21L", FALSE, 0, 0, FALSE },
ab96bf03 76 { R_PARISC_PCREL17R, 0, 2, 17, TRUE, 0, complain_overflow_bitfield,
b34976b6 77 bfd_elf_generic_reloc, "R_PARISC_PCREL17R", FALSE, 0, 0, FALSE },
ab96bf03 78 { R_PARISC_PCREL17F, 0, 2, 17, TRUE, 0, complain_overflow_bitfield,
b34976b6 79 bfd_elf_generic_reloc, "R_PARISC_PCREL17F", FALSE, 0, 0, FALSE },
ab96bf03 80 { R_PARISC_PCREL17C, 0, 2, 17, TRUE, 0, complain_overflow_bitfield,
b34976b6 81 bfd_elf_generic_reloc, "R_PARISC_PCREL17C", FALSE, 0, 0, FALSE },
ab96bf03 82 { R_PARISC_PCREL14R, 0, 2, 14, TRUE, 0, complain_overflow_bitfield,
b34976b6 83 bfd_elf_generic_reloc, "R_PARISC_PCREL14R", FALSE, 0, 0, FALSE },
ab96bf03 84 { R_PARISC_PCREL14F, 0, 2, 14, TRUE, 0, complain_overflow_bitfield,
b34976b6 85 bfd_elf_generic_reloc, "R_PARISC_PCREL14F", FALSE, 0, 0, FALSE },
49bd834c 86 /* 16 */
b34976b6
AM
87 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
88 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
89 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
90 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 91 { R_PARISC_DPREL21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6 92 bfd_elf_generic_reloc, "R_PARISC_DPREL21L", FALSE, 0, 0, FALSE },
ab96bf03 93 { R_PARISC_DPREL14WR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 94 bfd_elf_generic_reloc, "R_PARISC_DPREL14WR", FALSE, 0, 0, FALSE },
ab96bf03 95 { R_PARISC_DPREL14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
96 bfd_elf_generic_reloc, "R_PARISC_DPREL14DR", FALSE, 0, 0, FALSE },
97 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
98 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 99 { R_PARISC_DPREL14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 100 bfd_elf_generic_reloc, "R_PARISC_DPREL14R", FALSE, 0, 0, FALSE },
ab96bf03 101 { R_PARISC_DPREL14F, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 102 bfd_elf_generic_reloc, "R_PARISC_DPREL14F", FALSE, 0, 0, FALSE },
49bd834c 103 /* 24 */
b34976b6
AM
104 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
105 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
106 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
107 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 108 { R_PARISC_DLTREL21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
109 bfd_elf_generic_reloc, "R_PARISC_DLTREL21L", FALSE, 0, 0, FALSE },
110 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
111 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
112 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
113 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
114 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
115 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 116 { R_PARISC_DLTREL14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 117 bfd_elf_generic_reloc, "R_PARISC_DLTREL14R", FALSE, 0, 0, FALSE },
ab96bf03 118 { R_PARISC_DLTREL14F, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 119 bfd_elf_generic_reloc, "R_PARISC_DLTREL14F", FALSE, 0, 0, FALSE },
49bd834c 120 /* 32 */
b34976b6
AM
121 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
122 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
123 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
124 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 125 { R_PARISC_DLTIND21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
126 bfd_elf_generic_reloc, "R_PARISC_DLTIND21L", FALSE, 0, 0, FALSE },
127 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
128 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
129 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
130 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
131 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
132 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 133 { R_PARISC_DLTIND14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 134 bfd_elf_generic_reloc, "R_PARISC_DLTIND14R", FALSE, 0, 0, FALSE },
ab96bf03 135 { R_PARISC_DLTIND14F, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 136 bfd_elf_generic_reloc, "R_PARISC_DLTIND14F", FALSE, 0, 0, FALSE },
49bd834c 137 /* 40 */
b34976b6
AM
138 { R_PARISC_SETBASE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
139 bfd_elf_generic_reloc, "R_PARISC_SETBASE", FALSE, 0, 0, FALSE },
ab96bf03
AM
140 { R_PARISC_SECREL32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
141 bfd_elf_generic_reloc, "R_PARISC_SECREL32", FALSE, 0, 0xffffffff, FALSE },
142 { R_PARISC_BASEREL21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6 143 bfd_elf_generic_reloc, "R_PARISC_BASEREL21L", FALSE, 0, 0, FALSE },
ab96bf03 144 { R_PARISC_BASEREL17R, 0, 2, 17, FALSE, 0, complain_overflow_bitfield,
b34976b6 145 bfd_elf_generic_reloc, "R_PARISC_BASEREL17R", FALSE, 0, 0, FALSE },
ab96bf03 146 { R_PARISC_BASEREL17F, 0, 2, 17, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
147 bfd_elf_generic_reloc, "R_PARISC_BASEREL17F", FALSE, 0, 0, FALSE },
148 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
149 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 150 { R_PARISC_BASEREL14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 151 bfd_elf_generic_reloc, "R_PARISC_BASEREL14R", FALSE, 0, 0, FALSE },
ab96bf03 152 { R_PARISC_BASEREL14F, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 153 bfd_elf_generic_reloc, "R_PARISC_BASEREL14F", FALSE, 0, 0, FALSE },
49bd834c 154 /* 48 */
b34976b6
AM
155 { R_PARISC_SEGBASE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
156 bfd_elf_generic_reloc, "R_PARISC_SEGBASE", FALSE, 0, 0, FALSE },
ab96bf03 157 { R_PARISC_SEGREL32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
b34976b6 158 bfd_elf_generic_reloc, "R_PARISC_SEGREL32", FALSE, 0, 0, FALSE },
ab96bf03 159 { R_PARISC_PLTOFF21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
160 bfd_elf_generic_reloc, "R_PARISC_PLTOFF21L", FALSE, 0, 0, FALSE },
161 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
162 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
163 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
164 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
165 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
166 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 167 { R_PARISC_PLTOFF14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 168 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14R", FALSE, 0, 0, FALSE },
ab96bf03 169 { R_PARISC_PLTOFF14F, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 170 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14F", FALSE, 0, 0, FALSE },
49bd834c 171 /* 56 */
b34976b6
AM
172 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
173 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 174 { R_PARISC_LTOFF_FPTR32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
b34976b6 175 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR32", FALSE, 0, 0, FALSE },
ab96bf03 176 { R_PARISC_LTOFF_FPTR21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
177 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR21L", FALSE, 0, 0, FALSE },
178 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
179 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
180 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
181 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
182 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
183 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 184 { R_PARISC_LTOFF_FPTR14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
185 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14R", FALSE, 0, 0, FALSE },
186 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
187 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 188 /* 64 */
ab96bf03 189 { R_PARISC_FPTR64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
b34976b6 190 bfd_elf_generic_reloc, "R_PARISC_FPTR64", FALSE, 0, 0, FALSE },
ab96bf03 191 { R_PARISC_PLABEL32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
b34976b6 192 bfd_elf_generic_reloc, "R_PARISC_PLABEL32", FALSE, 0, 0, FALSE },
ab96bf03 193 { R_PARISC_PLABEL21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
194 bfd_elf_generic_reloc, "R_PARISC_PLABEL21L", FALSE, 0, 0, FALSE },
195 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
196 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
197 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
198 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
199 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
200 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 201 { R_PARISC_PLABEL14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
202 bfd_elf_generic_reloc, "R_PARISC_PLABEL14R", FALSE, 0, 0, FALSE },
203 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
204 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 205 /* 72 */
ab96bf03 206 { R_PARISC_PCREL64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
b34976b6 207 bfd_elf_generic_reloc, "R_PARISC_PCREL64", FALSE, 0, 0, FALSE },
ab96bf03 208 { R_PARISC_PCREL22C, 0, 2, 22, FALSE, 0, complain_overflow_bitfield,
b34976b6 209 bfd_elf_generic_reloc, "R_PARISC_PCREL22C", FALSE, 0, 0, FALSE },
ab96bf03 210 { R_PARISC_PCREL22F, 0, 2, 22, FALSE, 0, complain_overflow_bitfield,
b34976b6 211 bfd_elf_generic_reloc, "R_PARISC_PCREL22F", FALSE, 0, 0, FALSE },
ab96bf03 212 { R_PARISC_PCREL14WR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 213 bfd_elf_generic_reloc, "R_PARISC_PCREL14WR", FALSE, 0, 0, FALSE },
ab96bf03 214 { R_PARISC_PCREL14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 215 bfd_elf_generic_reloc, "R_PARISC_PCREL14DR", FALSE, 0, 0, FALSE },
ab96bf03 216 { R_PARISC_PCREL16F, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 217 bfd_elf_generic_reloc, "R_PARISC_PCREL16F", FALSE, 0, 0, FALSE },
ab96bf03 218 { R_PARISC_PCREL16WF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 219 bfd_elf_generic_reloc, "R_PARISC_PCREL16WF", FALSE, 0, 0, FALSE },
ab96bf03 220 { R_PARISC_PCREL16DF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 221 bfd_elf_generic_reloc, "R_PARISC_PCREL16DF", FALSE, 0, 0, FALSE },
49bd834c 222 /* 80 */
ab96bf03 223 { R_PARISC_DIR64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
224 bfd_elf_generic_reloc, "R_PARISC_DIR64", FALSE, 0, 0, FALSE },
225 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
226 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
227 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
228 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 229 { R_PARISC_DIR14WR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 230 bfd_elf_generic_reloc, "R_PARISC_DIR14WR", FALSE, 0, 0, FALSE },
ab96bf03 231 { R_PARISC_DIR14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 232 bfd_elf_generic_reloc, "R_PARISC_DIR14DR", FALSE, 0, 0, FALSE },
ab96bf03 233 { R_PARISC_DIR16F, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 234 bfd_elf_generic_reloc, "R_PARISC_DIR16F", FALSE, 0, 0, FALSE },
ab96bf03 235 { R_PARISC_DIR16WF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 236 bfd_elf_generic_reloc, "R_PARISC_DIR16WF", FALSE, 0, 0, FALSE },
ab96bf03 237 { R_PARISC_DIR16DF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 238 bfd_elf_generic_reloc, "R_PARISC_DIR16DF", FALSE, 0, 0, FALSE },
49bd834c 239 /* 88 */
ab96bf03 240 { R_PARISC_GPREL64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
241 bfd_elf_generic_reloc, "R_PARISC_GPREL64", FALSE, 0, 0, FALSE },
242 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
243 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
244 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
245 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 246 { R_PARISC_DLTREL14WR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 247 bfd_elf_generic_reloc, "R_PARISC_DLTREL14WR", FALSE, 0, 0, FALSE },
ab96bf03 248 { R_PARISC_DLTREL14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 249 bfd_elf_generic_reloc, "R_PARISC_DLTREL14DR", FALSE, 0, 0, FALSE },
ab96bf03 250 { R_PARISC_GPREL16F, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 251 bfd_elf_generic_reloc, "R_PARISC_GPREL16F", FALSE, 0, 0, FALSE },
ab96bf03 252 { R_PARISC_GPREL16WF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 253 bfd_elf_generic_reloc, "R_PARISC_GPREL16WF", FALSE, 0, 0, FALSE },
ab96bf03 254 { R_PARISC_GPREL16DF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 255 bfd_elf_generic_reloc, "R_PARISC_GPREL16DF", FALSE, 0, 0, FALSE },
49bd834c 256 /* 96 */
ab96bf03 257 { R_PARISC_LTOFF64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
258 bfd_elf_generic_reloc, "R_PARISC_LTOFF64", FALSE, 0, 0, FALSE },
259 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
260 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
261 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
262 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 263 { R_PARISC_DLTIND14WR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 264 bfd_elf_generic_reloc, "R_PARISC_DLTIND14WR", FALSE, 0, 0, FALSE },
ab96bf03 265 { R_PARISC_DLTIND14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 266 bfd_elf_generic_reloc, "R_PARISC_DLTIND14DR", FALSE, 0, 0, FALSE },
ab96bf03 267 { R_PARISC_LTOFF16F, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 268 bfd_elf_generic_reloc, "R_PARISC_LTOFF16F", FALSE, 0, 0, FALSE },
ab96bf03 269 { R_PARISC_LTOFF16WF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 270 bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF", FALSE, 0, 0, FALSE },
ab96bf03 271 { R_PARISC_LTOFF16DF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 272 bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF", FALSE, 0, 0, FALSE },
49bd834c 273 /* 104 */
b34976b6
AM
274 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
275 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
276 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
277 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 278 { R_PARISC_BASEREL14WR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 279 bfd_elf_generic_reloc, "R_PARISC_BASEREL14WR", FALSE, 0, 0, FALSE },
ab96bf03 280 { R_PARISC_BASEREL14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
281 bfd_elf_generic_reloc, "R_PARISC_BASEREL14DR", FALSE, 0, 0, FALSE },
282 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
283 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
284 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
285 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
286 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
287 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
288 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
289 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 290 /* 112 */
ab96bf03 291 { R_PARISC_SEGREL64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
292 bfd_elf_generic_reloc, "R_PARISC_SEGREL64", FALSE, 0, 0, FALSE },
293 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
294 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
295 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
296 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 297 { R_PARISC_PLTOFF14WR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 298 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14WR", FALSE, 0, 0, FALSE },
ab96bf03 299 { R_PARISC_PLTOFF14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 300 bfd_elf_generic_reloc, "R_PARISC_PLTOFF14DR", FALSE, 0, 0, FALSE },
ab96bf03 301 { R_PARISC_PLTOFF16F, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 302 bfd_elf_generic_reloc, "R_PARISC_PLTOFF16F", FALSE, 0, 0, FALSE },
ab96bf03 303 { R_PARISC_PLTOFF16WF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 304 bfd_elf_generic_reloc, "R_PARISC_PLTOFF16WF", FALSE, 0, 0, FALSE },
ab96bf03 305 { R_PARISC_PLTOFF16DF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 306 bfd_elf_generic_reloc, "R_PARISC_PLTOFF16DF", FALSE, 0, 0, FALSE },
49bd834c 307 /* 120 */
ab96bf03 308 { R_PARISC_LTOFF_FPTR64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
309 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
310 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
311 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
312 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
313 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 314 { R_PARISC_LTOFF_FPTR14WR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 315 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14WR", FALSE, 0, 0, FALSE },
ab96bf03 316 { R_PARISC_LTOFF_FPTR14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 317 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14DR", FALSE, 0, 0, FALSE },
ab96bf03 318 { R_PARISC_LTOFF_FPTR16F, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 319 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16F", FALSE, 0, 0, FALSE },
ab96bf03 320 { R_PARISC_LTOFF_FPTR16WF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 321 bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16WF", FALSE, 0, 0, FALSE },
ab96bf03 322 { R_PARISC_LTOFF_FPTR16DF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 323 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 324 /* 128 */
b34976b6
AM
325 { R_PARISC_COPY, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
326 bfd_elf_generic_reloc, "R_PARISC_COPY", FALSE, 0, 0, FALSE },
327 { R_PARISC_IPLT, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
328 bfd_elf_generic_reloc, "R_PARISC_IPLT", FALSE, 0, 0, FALSE },
329 { R_PARISC_EPLT, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
330 bfd_elf_generic_reloc, "R_PARISC_EPLT", FALSE, 0, 0, FALSE },
331 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
332 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
333 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
334 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
335 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
336 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
337 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
338 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
339 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
340 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 341 /* 136 */
b34976b6
AM
342 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
343 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
344 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
345 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
346 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
347 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
348 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
349 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
350 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
351 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
352 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
353 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
354 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
355 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
356 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
357 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 358 /* 144 */
b34976b6
AM
359 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
360 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
361 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
362 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
363 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
364 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
365 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
366 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
367 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
368 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
369 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
370 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
371 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
372 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
373 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
374 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 375 /* 152 */
b34976b6
AM
376 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
377 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 378 { R_PARISC_TPREL32, 0, 2, 32, FALSE, 0, complain_overflow_dont,
b34976b6 379 bfd_elf_generic_reloc, "R_PARISC_TPREL32", FALSE, 0, 0, FALSE },
ab96bf03 380 { R_PARISC_TPREL21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
381 bfd_elf_generic_reloc, "R_PARISC_TPREL21L", FALSE, 0, 0, FALSE },
382 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
383 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
384 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
385 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
386 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
387 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 388 { R_PARISC_TPREL14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
389 bfd_elf_generic_reloc, "R_PARISC_TPREL14R", FALSE, 0, 0, FALSE },
390 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
391 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 392 /* 160 */
b34976b6
AM
393 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
394 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
395 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
396 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 397 { R_PARISC_LTOFF_TP21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
398 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP21L", FALSE, 0, 0, FALSE },
399 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
400 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
401 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
402 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
403 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
404 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 405 { R_PARISC_LTOFF_TP14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
9b52905e 406 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14R", FALSE, 0, 0, FALSE },
ab96bf03 407 { R_PARISC_LTOFF_TP14F, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 408 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14F", FALSE, 0, 0, FALSE },
49bd834c 409 /* 168 */
b34976b6
AM
410 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
411 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
412 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
413 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
414 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
415 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
416 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
417 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
418 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
419 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
420 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
421 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
422 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
423 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
424 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
425 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 426 /* 176 */
b34976b6
AM
427 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
428 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
429 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
430 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
431 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
432 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
433 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
434 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
435 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
436 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
437 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
438 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
439 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
440 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
441 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
442 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 443 /* 184 */
b34976b6
AM
444 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
445 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
446 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
447 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
448 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
449 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
450 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
451 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
452 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
453 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
454 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
455 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
456 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
457 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
458 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
459 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 460 /* 192 */
b34976b6
AM
461 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
462 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
463 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
464 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
465 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
466 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
467 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
468 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
469 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
470 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
471 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
472 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
473 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
474 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
475 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
476 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 477 /* 200 */
b34976b6
AM
478 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
479 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
480 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
481 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
482 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
483 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
484 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
485 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
486 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
487 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
488 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
489 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
490 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
491 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
492 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
493 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 494 /* 208 */
b34976b6
AM
495 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
496 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
497 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
498 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
499 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
500 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
501 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
502 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
503 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_dont,
504 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
505 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
506 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
507 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
508 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
509 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
510 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
49bd834c 511 /* 216 */
ab96bf03 512 { R_PARISC_TPREL64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
513 bfd_elf_generic_reloc, "R_PARISC_TPREL64", FALSE, 0, 0, FALSE },
514 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
515 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
516 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
517 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 518 { R_PARISC_TPREL14WR, 0, 2, 14, FALSE, 0, complain_overflow_dont,
b34976b6 519 bfd_elf_generic_reloc, "R_PARISC_TPREL14WR", FALSE, 0, 0, FALSE },
ab96bf03 520 { R_PARISC_TPREL14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 521 bfd_elf_generic_reloc, "R_PARISC_TPREL14DR", FALSE, 0, 0, FALSE },
ab96bf03 522 { R_PARISC_TPREL16F, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 523 bfd_elf_generic_reloc, "R_PARISC_TPREL16F", FALSE, 0, 0, FALSE },
ab96bf03 524 { R_PARISC_TPREL16WF, 0, 2, 16, FALSE, 0, complain_overflow_dont,
b34976b6 525 bfd_elf_generic_reloc, "R_PARISC_TPREL16WF", FALSE, 0, 0, FALSE },
ab96bf03 526 { R_PARISC_TPREL16DF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 527 bfd_elf_generic_reloc, "R_PARISC_TPREL16DF", FALSE, 0, 0, FALSE },
49bd834c 528 /* 224 */
ab96bf03 529 { R_PARISC_LTOFF_TP64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
b34976b6
AM
530 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP64", FALSE, 0, 0, FALSE },
531 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
532 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
533 { R_PARISC_UNIMPLEMENTED, 0, 0, 0, FALSE, 0, complain_overflow_bitfield,
534 bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED", FALSE, 0, 0, FALSE },
ab96bf03 535 { R_PARISC_LTOFF_TP14WR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 536 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14WR", FALSE, 0, 0, FALSE },
ab96bf03 537 { R_PARISC_LTOFF_TP14DR, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
b34976b6 538 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14DR", FALSE, 0, 0, FALSE },
ab96bf03 539 { R_PARISC_LTOFF_TP16F, 0, 2, 16, FALSE, 0, complain_overflow_dont,
b34976b6 540 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16F", FALSE, 0, 0, FALSE },
ab96bf03 541 { R_PARISC_LTOFF_TP16WF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 542 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16WF", FALSE, 0, 0, FALSE },
ab96bf03 543 { R_PARISC_LTOFF_TP16DF, 0, 2, 16, FALSE, 0, complain_overflow_bitfield,
b34976b6 544 bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16DF", FALSE, 0, 0, FALSE },
49bd834c 545 /* 232 */
b34976b6
AM
546 { R_PARISC_GNU_VTENTRY, 0, 0, 0, FALSE, 0, complain_overflow_dont,
547 bfd_elf_generic_reloc, "R_PARISC_GNU_VTENTRY", FALSE, 0, 0, FALSE },
548 { R_PARISC_GNU_VTINHERIT, 0, 0, 0, FALSE, 0, complain_overflow_dont,
549 bfd_elf_generic_reloc, "R_PARISC_GNU_VTINHERIT", FALSE, 0, 0, FALSE },
ab96bf03 550 { R_PARISC_TLS_GD21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
9b52905e 551 bfd_elf_generic_reloc, "R_PARISC_TLS_GD21L", FALSE, 0, 0, FALSE },
ab96bf03 552 { R_PARISC_TLS_GD14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
9b52905e
NC
553 bfd_elf_generic_reloc, "R_PARISC_TLS_GD14R", FALSE, 0, 0, FALSE },
554 { R_PARISC_TLS_GDCALL, 0, 0, 0, FALSE, 0, complain_overflow_dont,
555 bfd_elf_generic_reloc, "R_PARISC_TLS_GDCALL", FALSE, 0, 0, FALSE },
ab96bf03 556 { R_PARISC_TLS_LDM21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
9b52905e 557 bfd_elf_generic_reloc, "R_PARISC_TLS_LDM21L", FALSE, 0, 0, FALSE },
ab96bf03 558 { R_PARISC_TLS_LDM14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
9b52905e
NC
559 bfd_elf_generic_reloc, "R_PARISC_TLS_LDM14R", FALSE, 0, 0, FALSE },
560 { R_PARISC_TLS_LDMCALL, 0, 0, 0, FALSE, 0, complain_overflow_dont,
561 bfd_elf_generic_reloc, "R_PARISC_TLS_LDMCALL", FALSE, 0, 0, FALSE },
562 /* 240 */
ab96bf03 563 { R_PARISC_TLS_LDO21L, 0, 2, 21, FALSE, 0, complain_overflow_bitfield,
9b52905e 564 bfd_elf_generic_reloc, "R_PARISC_TLS_LDO21L", FALSE, 0, 0, FALSE },
ab96bf03 565 { R_PARISC_TLS_LDO14R, 0, 2, 14, FALSE, 0, complain_overflow_bitfield,
9b52905e 566 bfd_elf_generic_reloc, "R_PARISC_TLS_LDO14R", FALSE, 0, 0, FALSE },
ab96bf03 567 { R_PARISC_TLS_DTPMOD32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
9b52905e 568 bfd_elf_generic_reloc, "R_PARISC_TLS_DTPMOD32", FALSE, 0, 0, FALSE },
ab96bf03 569 { R_PARISC_TLS_DTPMOD64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
9b52905e 570 bfd_elf_generic_reloc, "R_PARISC_TLS_DTPMOD64", FALSE, 0, 0, FALSE },
ab96bf03 571 { R_PARISC_TLS_DTPOFF32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
9b52905e 572 bfd_elf_generic_reloc, "R_PARISC_TLS_DTPOFF32", FALSE, 0, 0, FALSE },
ab96bf03 573 { R_PARISC_TLS_DTPOFF64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
9b52905e 574 bfd_elf_generic_reloc, "R_PARISC_TLS_DTPOFF64", FALSE, 0, 0, FALSE },
9e103c9c
JL
575};
576
6e2bf930
JL
577#define OFFSET_14R_FROM_21L 4
578#define OFFSET_14F_FROM_21L 5
579
189c6563
AM
580/* Return the final relocation type for the given base type, instruction
581 format, and field selector. */
9e103c9c 582
189c6563 583elf_hppa_reloc_type
c39a58e6
AM
584elf_hppa_reloc_final_type (bfd *abfd,
585 elf_hppa_reloc_type base_type,
586 int format,
587 unsigned int field)
9e103c9c 588{
189c6563 589 elf_hppa_reloc_type final_type = base_type;
9e103c9c
JL
590
591 /* Just a tangle of nested switch statements to deal with the braindamage
592 that a different field selector means a completely different relocation
593 for PA ELF. */
594 switch (base_type)
595 {
9b52905e
NC
596 /* We have been using generic relocation types. However, that may not
597 really make sense. Anyway, we need to support both R_PARISC_DIR64
598 and R_PARISC_DIR32 here. */
0d571602
JL
599 case R_PARISC_DIR32:
600 case R_PARISC_DIR64:
9e103c9c
JL
601 case R_HPPA_ABS_CALL:
602 switch (format)
603 {
604 case 14:
605 switch (field)
606 {
47d89dba
AM
607 case e_fsel:
608 final_type = R_PARISC_DIR14F;
609 break;
9e103c9c
JL
610 case e_rsel:
611 case e_rrsel:
47d89dba 612 case e_rdsel:
9e103c9c
JL
613 final_type = R_PARISC_DIR14R;
614 break;
615 case e_rtsel:
f31cedf7 616 final_type = R_PARISC_DLTIND14R;
9e103c9c 617 break;
36860900
JL
618 case e_rtpsel:
619 final_type = R_PARISC_LTOFF_FPTR14DR;
620 break;
9e103c9c 621 case e_tsel:
f31cedf7 622 final_type = R_PARISC_DLTIND14F;
9e103c9c
JL
623 break;
624 case e_rpsel:
625 final_type = R_PARISC_PLABEL14R;
626 break;
627 default:
189c6563 628 return R_PARISC_NONE;
9e103c9c
JL
629 }
630 break;
631
632 case 17:
633 switch (field)
634 {
635 case e_fsel:
636 final_type = R_PARISC_DIR17F;
637 break;
638 case e_rsel:
639 case e_rrsel:
47d89dba 640 case e_rdsel:
9e103c9c
JL
641 final_type = R_PARISC_DIR17R;
642 break;
643 default:
189c6563 644 return R_PARISC_NONE;
9e103c9c
JL
645 }
646 break;
647
648 case 21:
649 switch (field)
650 {
651 case e_lsel:
652 case e_lrsel:
47d89dba 653 case e_ldsel:
edd21aca
AM
654 case e_nlsel:
655 case e_nlrsel:
9e103c9c
JL
656 final_type = R_PARISC_DIR21L;
657 break;
658 case e_ltsel:
f31cedf7 659 final_type = R_PARISC_DLTIND21L;
9e103c9c 660 break;
36860900
JL
661 case e_ltpsel:
662 final_type = R_PARISC_LTOFF_FPTR21L;
663 break;
9e103c9c
JL
664 case e_lpsel:
665 final_type = R_PARISC_PLABEL21L;
666 break;
667 default:
189c6563 668 return R_PARISC_NONE;
9e103c9c
JL
669 }
670 break;
671
672 case 32:
673 switch (field)
674 {
675 case e_fsel:
676 final_type = R_PARISC_DIR32;
432bdd91
JL
677 /* When in 64bit mode, a 32bit relocation is supposed to
678 be a section relative relocation. Dwarf2 (for example)
679 uses 32bit section relative relocations. */
680 if (bfd_get_arch_info (abfd)->bits_per_address != 32)
46fe4e66 681 final_type = R_PARISC_SECREL32;
9e103c9c
JL
682 break;
683 case e_psel:
684 final_type = R_PARISC_PLABEL32;
685 break;
686 default:
189c6563 687 return R_PARISC_NONE;
9e103c9c
JL
688 }
689 break;
690
6e2bf930
JL
691 case 64:
692 switch (field)
693 {
694 case e_fsel:
695 final_type = R_PARISC_DIR64;
696 break;
697 case e_psel:
36860900
JL
698 final_type = R_PARISC_FPTR64;
699 break;
6e2bf930 700 default:
189c6563 701 return R_PARISC_NONE;
6e2bf930
JL
702 }
703 break;
704
9e103c9c 705 default:
189c6563 706 return R_PARISC_NONE;
9e103c9c
JL
707 }
708 break;
709
9e103c9c
JL
710 case R_HPPA_GOTOFF:
711 switch (format)
712 {
713 case 14:
714 switch (field)
715 {
716 case e_rsel:
717 case e_rrsel:
47d89dba 718 case e_rdsel:
9b52905e 719 /* R_PARISC_DLTREL14R for elf64, R_PARISC_DPREL14R for elf32. */
6e2bf930 720 final_type = base_type + OFFSET_14R_FROM_21L;
9e103c9c
JL
721 break;
722 case e_fsel:
9b52905e 723 /* R_PARISC_DLTREL14F for elf64, R_PARISC_DPREL14F for elf32. */
6e2bf930 724 final_type = base_type + OFFSET_14F_FROM_21L;
9e103c9c
JL
725 break;
726 default:
189c6563 727 return R_PARISC_NONE;
9e103c9c
JL
728 }
729 break;
730
731 case 21:
732 switch (field)
733 {
9e103c9c 734 case e_lsel:
edd21aca 735 case e_lrsel:
47d89dba 736 case e_ldsel:
edd21aca
AM
737 case e_nlsel:
738 case e_nlrsel:
9b52905e 739 /* R_PARISC_DLTREL21L for elf64, R_PARISC_DPREL21L for elf32. */
6e2bf930 740 final_type = base_type;
9e103c9c
JL
741 break;
742 default:
189c6563 743 return R_PARISC_NONE;
9e103c9c
JL
744 }
745 break;
746
747 default:
189c6563 748 return R_PARISC_NONE;
9e103c9c
JL
749 }
750 break;
751
9e103c9c
JL
752 case R_HPPA_PCREL_CALL:
753 switch (format)
754 {
49bd834c
AM
755 case 12:
756 switch (field)
757 {
758 case e_fsel:
759 final_type = R_PARISC_PCREL12F;
760 break;
761 default:
189c6563 762 return R_PARISC_NONE;
49bd834c
AM
763 }
764 break;
765
9e103c9c 766 case 14:
49bd834c
AM
767 /* Contrary to appearances, these are not calls of any sort.
768 Rather, they are loads/stores with a pcrel reloc. */
9e103c9c
JL
769 switch (field)
770 {
771 case e_rsel:
772 case e_rrsel:
47d89dba 773 case e_rdsel:
9e103c9c
JL
774 final_type = R_PARISC_PCREL14R;
775 break;
776 case e_fsel:
ba94744e
AM
777 if (bfd_get_mach (abfd) < 25)
778 final_type = R_PARISC_PCREL14F;
779 else
780 final_type = R_PARISC_PCREL16F;
9e103c9c
JL
781 break;
782 default:
189c6563 783 return R_PARISC_NONE;
9e103c9c
JL
784 }
785 break;
786
787 case 17:
788 switch (field)
789 {
790 case e_rsel:
791 case e_rrsel:
47d89dba 792 case e_rdsel:
9e103c9c
JL
793 final_type = R_PARISC_PCREL17R;
794 break;
795 case e_fsel:
796 final_type = R_PARISC_PCREL17F;
797 break;
798 default:
189c6563 799 return R_PARISC_NONE;
9e103c9c
JL
800 }
801 break;
802
edd21aca 803 case 21:
341362b5
JL
804 switch (field)
805 {
edd21aca
AM
806 case e_lsel:
807 case e_lrsel:
47d89dba 808 case e_ldsel:
edd21aca
AM
809 case e_nlsel:
810 case e_nlrsel:
811 final_type = R_PARISC_PCREL21L;
341362b5
JL
812 break;
813 default:
189c6563 814 return R_PARISC_NONE;
341362b5
JL
815 }
816 break;
817
edd21aca 818 case 22:
9e103c9c
JL
819 switch (field)
820 {
edd21aca
AM
821 case e_fsel:
822 final_type = R_PARISC_PCREL22F;
9e103c9c
JL
823 break;
824 default:
189c6563 825 return R_PARISC_NONE;
9e103c9c
JL
826 }
827 break;
828
9992270f
DA
829 case 32:
830 switch (field)
831 {
832 case e_fsel:
833 final_type = R_PARISC_PCREL32;
834 break;
835 default:
836 return R_PARISC_NONE;
837 }
838 break;
839
840 case 64:
841 switch (field)
842 {
843 case e_fsel:
844 final_type = R_PARISC_PCREL64;
845 break;
846 default:
847 return R_PARISC_NONE;
848 }
849 break;
850
9e103c9c 851 default:
189c6563 852 return R_PARISC_NONE;
9e103c9c
JL
853 }
854 break;
855
9b52905e
NC
856 case R_PARISC_TLS_GD21L:
857 switch (field)
858 {
859 case e_ltsel:
860 case e_lrsel:
861 final_type = R_PARISC_TLS_GD21L;
862 break;
863 case e_rtsel:
864 case e_rrsel:
865 final_type = R_PARISC_TLS_GD14R;
866 break;
867 default:
868 return R_PARISC_NONE;
869 }
870 break;
871
872 case R_PARISC_TLS_LDM21L:
873 switch (field)
874 {
875 case e_ltsel:
876 case e_lrsel:
877 final_type = R_PARISC_TLS_LDM21L;
878 break;
879 case e_rtsel:
880 case e_rrsel:
881 final_type = R_PARISC_TLS_LDM14R;
882 break;
883 default:
884 return R_PARISC_NONE;
885 }
886 break;
887
888 case R_PARISC_TLS_LDO21L:
889 switch (field)
890 {
891 case e_lrsel:
892 final_type = R_PARISC_TLS_LDO21L;
893 break;
894 case e_rrsel:
895 final_type = R_PARISC_TLS_LDO14R;
896 break;
897 default:
898 return R_PARISC_NONE;
899 }
900 break;
901
902 case R_PARISC_TLS_IE21L:
903 switch (field)
904 {
905 case e_ltsel:
906 case e_lrsel:
907 final_type = R_PARISC_TLS_IE21L;
908 break;
909 case e_rtsel:
910 case e_rrsel:
911 final_type = R_PARISC_TLS_IE14R;
912 break;
913 default:
914 return R_PARISC_NONE;
915 }
916 break;
917
918 case R_PARISC_TLS_LE21L:
919 switch (field)
920 {
921 case e_lrsel:
922 final_type = R_PARISC_TLS_LE21L;
923 break;
924 case e_rrsel:
925 final_type = R_PARISC_TLS_LE14R;
926 break;
927 default:
928 return R_PARISC_NONE;
929 }
930 break;
931
49bd834c
AM
932 case R_PARISC_GNU_VTENTRY:
933 case R_PARISC_GNU_VTINHERIT:
fc91f658
JL
934 case R_PARISC_SEGREL32:
935 case R_PARISC_SEGBASE:
936 /* The defaults are fine for these cases. */
937 break;
938
9e103c9c 939 default:
189c6563 940 return R_PARISC_NONE;
9e103c9c
JL
941 }
942
189c6563
AM
943 return final_type;
944}
945
946/* Return one (or more) BFD relocations which implement the base
947 relocation with modifications based on format and field. */
948
949elf_hppa_reloc_type **
c39a58e6
AM
950_bfd_elf_hppa_gen_reloc_type (bfd *abfd,
951 elf_hppa_reloc_type base_type,
952 int format,
953 unsigned int field,
954 int ignore ATTRIBUTE_UNUSED,
955 asymbol *sym ATTRIBUTE_UNUSED)
189c6563
AM
956{
957 elf_hppa_reloc_type *finaltype;
958 elf_hppa_reloc_type **final_types;
959 bfd_size_type amt = sizeof (elf_hppa_reloc_type *) * 2;
960
961 /* Allocate slots for the BFD relocation. */
c39a58e6 962 final_types = bfd_alloc (abfd, amt);
189c6563
AM
963 if (final_types == NULL)
964 return NULL;
965
966 /* Allocate space for the relocation itself. */
967 amt = sizeof (elf_hppa_reloc_type);
c39a58e6 968 finaltype = bfd_alloc (abfd, amt);
189c6563
AM
969 if (finaltype == NULL)
970 return NULL;
971
972 /* Some reasonable defaults. */
973 final_types[0] = finaltype;
974 final_types[1] = NULL;
975
976 *finaltype = elf_hppa_reloc_final_type (abfd, base_type, format, field);
977
9e103c9c
JL
978 return final_types;
979}
980
981/* Translate from an elf into field into a howto relocation pointer. */
982
983static void
c39a58e6
AM
984elf_hppa_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
985 arelent *bfd_reloc,
986 Elf_Internal_Rela *elf_reloc)
9e103c9c 987{
c39a58e6 988 BFD_ASSERT (ELF_R_TYPE (elf_reloc->r_info)
9e103c9c
JL
989 < (unsigned int) R_PARISC_UNIMPLEMENTED);
990 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
991}
992
993/* Translate from an elf into field into a howto relocation pointer. */
994
995static void
c39a58e6
AM
996elf_hppa_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
997 arelent *bfd_reloc,
998 Elf_Internal_Rela *elf_reloc)
9e103c9c 999{
9b52905e 1000 BFD_ASSERT (ELF_R_TYPE (elf_reloc->r_info)
9e103c9c
JL
1001 < (unsigned int) R_PARISC_UNIMPLEMENTED);
1002 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
1003}
1004
1005/* Return the address of the howto table entry to perform the CODE
1006 relocation for an ARCH machine. */
1007
1008static reloc_howto_type *
c39a58e6
AM
1009elf_hppa_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
1010 bfd_reloc_code_real_type code)
9e103c9c
JL
1011{
1012 if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
1013 {
1014 BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
1015 return &elf_hppa_howto_table[(int) code];
1016 }
1017 return NULL;
1018}
95cbae0b 1019
b34976b6 1020/* Return TRUE if SYM represents a local label symbol. */
432bdd91 1021
b34976b6 1022static bfd_boolean
c39a58e6 1023elf_hppa_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
432bdd91 1024{
49bd834c 1025 if (name[0] == 'L' && name[1] == '$')
9b52905e 1026 return TRUE;
49bd834c 1027 return _bfd_elf_is_local_label_name (abfd, name);
432bdd91
JL
1028}
1029
052e120f
JL
1030/* Set the correct type for an ELF section. We do this by the
1031 section name, which is a hack, but ought to work. */
1032
b34976b6 1033static bfd_boolean
c39a58e6 1034elf_hppa_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec)
052e120f 1035{
c39a58e6 1036 const char *name;
052e120f
JL
1037
1038 name = bfd_get_section_name (abfd, sec);
1039
1040 if (strcmp (name, ".PARISC.unwind") == 0)
1041 {
1ca74062 1042 int indx;
edd21aca 1043 asection *asec;
9b52905e 1044
3f9b03b5 1045#if ARCH_SIZE == 64
052e120f 1046 hdr->sh_type = SHT_LOPROC + 1;
3f9b03b5
AM
1047#else
1048 hdr->sh_type = 1;
1049#endif
052e120f
JL
1050 /* ?!? How are unwinds supposed to work for symbols in arbitrary
1051 sections? Or what if we have multiple .text sections in a single
be7582f3 1052 .o file? HP really messed up on this one.
052e120f 1053
1ca74062
JL
1054 Ugh. We can not use elf_section_data (sec)->this_idx at this
1055 point because it is not initialized yet.
1056
1057 So we (gasp) recompute it here. Hopefully nobody ever changes the
1058 way sections are numbered in elf.c! */
edd21aca 1059 for (asec = abfd->sections, indx = 1; asec; asec = asec->next, indx++)
1ca74062 1060 {
edd21aca 1061 if (asec->name && strcmp (asec->name, ".text") == 0)
1ca74062
JL
1062 {
1063 hdr->sh_info = indx;
1064 break;
1065 }
1066 }
be7582f3 1067
052e120f
JL
1068 /* I have no idea if this is really necessary or what it means. */
1069 hdr->sh_entsize = 4;
1070 }
b34976b6 1071 return TRUE;
052e120f
JL
1072}
1073
3f9b03b5 1074static void
c39a58e6
AM
1075elf_hppa_final_write_processing (bfd *abfd,
1076 bfd_boolean linker ATTRIBUTE_UNUSED)
3f9b03b5
AM
1077{
1078 int mach = bfd_get_mach (abfd);
1079
1080 elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL
1081 | EF_PARISC_EXT | EF_PARISC_LSB
1082 | EF_PARISC_WIDE | EF_PARISC_NO_KABP
1083 | EF_PARISC_LAZYSWAP);
1084
1085 if (mach == 10)
1086 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0;
1087 else if (mach == 11)
1088 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1;
1089 else if (mach == 20)
1090 elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0;
1091 else if (mach == 25)
1092 elf_elfheader (abfd)->e_flags |= (EF_PARISC_WIDE
1093 | EFA_PARISC_2_0
1094 /* The GNU tools have trapped without
1095 option since 1993, so need to take
1096 a step backwards with the ELF
1097 based toolchains. */
1098 | EF_PARISC_TRAPNIL);
1099}
1100
46fe4e66
AM
1101/* Comparison function for qsort to sort unwind section during a
1102 final link. */
1103
1104static int
c39a58e6 1105hppa_unwind_entry_compare (const void *a, const void *b)
46fe4e66
AM
1106{
1107 const bfd_byte *ap, *bp;
1108 unsigned long av, bv;
1109
c39a58e6 1110 ap = a;
46fe4e66
AM
1111 av = (unsigned long) ap[0] << 24;
1112 av |= (unsigned long) ap[1] << 16;
1113 av |= (unsigned long) ap[2] << 8;
1114 av |= (unsigned long) ap[3];
1115
c39a58e6 1116 bp = b;
46fe4e66
AM
1117 bv = (unsigned long) bp[0] << 24;
1118 bv |= (unsigned long) bp[1] << 16;
1119 bv |= (unsigned long) bp[2] << 8;
1120 bv |= (unsigned long) bp[3];
1121
1122 return av < bv ? -1 : av > bv ? 1 : 0;
1123}
1124
9b52905e
NC
1125static bfd_boolean
1126elf_hppa_sort_unwind (bfd *abfd)
46fe4e66
AM
1127{
1128 asection *s;
1129
1130 /* Magic section names, but this is much safer than having
1131 relocate_section remember where SEGREL32 relocs occurred.
1132 Consider what happens if someone inept creates a linker script
1133 that puts unwind information in .text. */
1134 s = bfd_get_section_by_name (abfd, ".PARISC.unwind");
1135 if (s != NULL)
1136 {
1137 bfd_size_type size;
eea6121a 1138 bfd_byte *contents;
46fe4e66 1139
eea6121a 1140 if (!bfd_malloc_and_get_section (abfd, s, &contents))
b34976b6 1141 return FALSE;
46fe4e66 1142
eea6121a 1143 size = s->size;
46fe4e66
AM
1144 qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare);
1145
1146 if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size))
b34976b6 1147 return FALSE;
46fe4e66
AM
1148 }
1149
b34976b6 1150 return TRUE;
46fe4e66
AM
1151}
1152
8a696751
AM
1153/* What to do when ld finds relocations against symbols defined in
1154 discarded sections. */
1155
1156static unsigned int
1157elf_hppa_action_discarded (asection *sec)
1158{
1159 if (strcmp (".PARISC.unwind", sec->name) == 0)
1160 return 0;
1161
1162 return _bfd_elf_default_action_discarded (sec);
1163}
1164
49bd834c 1165#if ARCH_SIZE == 64
2eb429af
JL
1166/* Hook called by the linker routine which adds symbols from an object
1167 file. HP's libraries define symbols with HP specific section
1168 indices, which we have to handle. */
1169
b34976b6 1170static bfd_boolean
c39a58e6
AM
1171elf_hppa_add_symbol_hook (bfd *abfd,
1172 struct bfd_link_info *info ATTRIBUTE_UNUSED,
555cd476 1173 Elf_Internal_Sym *sym,
c39a58e6
AM
1174 const char **namep ATTRIBUTE_UNUSED,
1175 flagword *flagsp ATTRIBUTE_UNUSED,
1176 asection **secp,
1177 bfd_vma *valp)
2eb429af
JL
1178{
1179 int index = sym->st_shndx;
be7582f3 1180
2eb429af
JL
1181 switch (index)
1182 {
1183 case SHN_PARISC_ANSI_COMMON:
1184 *secp = bfd_make_section_old_way (abfd, ".PARISC.ansi.common");
1185 (*secp)->flags |= SEC_IS_COMMON;
1186 *valp = sym->st_size;
1187 break;
be7582f3 1188
2eb429af
JL
1189 case SHN_PARISC_HUGE_COMMON:
1190 *secp = bfd_make_section_old_way (abfd, ".PARISC.huge.common");
1191 (*secp)->flags |= SEC_IS_COMMON;
1192 *valp = sym->st_size;
1193 break;
1194 }
1195
b34976b6 1196 return TRUE;
2eb429af
JL
1197}
1198
b34976b6 1199static bfd_boolean
c39a58e6
AM
1200elf_hppa_unmark_useless_dynamic_symbols (struct elf_link_hash_entry *h,
1201 void *data)
af7dc644 1202{
c39a58e6 1203 struct bfd_link_info *info = data;
af7dc644 1204
e92d460e
AM
1205 if (h->root.type == bfd_link_hash_warning)
1206 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1207
af7dc644
JL
1208 /* If we are not creating a shared library, and this symbol is
1209 referenced by a shared library but is not defined anywhere, then
1210 the generic code will warn that it is undefined.
1211
1212 This behavior is undesirable on HPs since the standard shared
3f9b03b5 1213 libraries contain references to undefined symbols.
af7dc644
JL
1214
1215 So we twiddle the flags associated with such symbols so that they
3f9b03b5 1216 will not trigger the warning. ?!? FIXME. This is horribly fragile.
af7dc644
JL
1217
1218 Ultimately we should have better controls over the generic ELF BFD
1219 linker code. */
1049f94e 1220 if (! info->relocatable
59c2e50f 1221 && info->unresolved_syms_in_shared_libs != RM_IGNORE
af7dc644 1222 && h->root.type == bfd_link_hash_undefined
f5385ebf
AM
1223 && h->ref_dynamic
1224 && !h->ref_regular)
af7dc644 1225 {
f5385ebf
AM
1226 h->ref_dynamic = 0;
1227 h->pointer_equality_needed = 1;
af7dc644
JL
1228 }
1229
b34976b6 1230 return TRUE;
af7dc644
JL
1231}
1232
b34976b6 1233static bfd_boolean
c39a58e6
AM
1234elf_hppa_remark_useless_dynamic_symbols (struct elf_link_hash_entry *h,
1235 void *data)
af7dc644 1236{
c39a58e6 1237 struct bfd_link_info *info = data;
af7dc644 1238
e92d460e
AM
1239 if (h->root.type == bfd_link_hash_warning)
1240 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1241
af7dc644
JL
1242 /* If we are not creating a shared library, and this symbol is
1243 referenced by a shared library but is not defined anywhere, then
1244 the generic code will warn that it is undefined.
1245
1246 This behavior is undesirable on HPs since the standard shared
4cc11e76 1247 libraries contain references to undefined symbols.
af7dc644
JL
1248
1249 So we twiddle the flags associated with such symbols so that they
228d307f 1250 will not trigger the warning. ?!? FIXME. This is horribly fragile.
af7dc644
JL
1251
1252 Ultimately we should have better controls over the generic ELF BFD
1253 linker code. */
1049f94e 1254 if (! info->relocatable
59c2e50f 1255 && info->unresolved_syms_in_shared_libs != RM_IGNORE
af7dc644 1256 && h->root.type == bfd_link_hash_undefined
f5385ebf
AM
1257 && !h->ref_dynamic
1258 && !h->ref_regular
1259 && h->pointer_equality_needed)
af7dc644 1260 {
f5385ebf
AM
1261 h->ref_dynamic = 1;
1262 h->pointer_equality_needed = 0;
af7dc644
JL
1263 }
1264
b34976b6 1265 return TRUE;
af7dc644
JL
1266}
1267
b34976b6 1268static bfd_boolean
c39a58e6 1269elf_hppa_is_dynamic_loader_symbol (const char *name)
1bf42538
JL
1270{
1271 return (! strcmp (name, "__CPU_REVISION")
1272 || ! strcmp (name, "__CPU_KEYBITS_1")
1273 || ! strcmp (name, "__SYSTEM_ID_D")
1274 || ! strcmp (name, "__FPU_MODEL")
1275 || ! strcmp (name, "__FPU_REVISION")
1276 || ! strcmp (name, "__ARGC")
1277 || ! strcmp (name, "__ARGV")
1278 || ! strcmp (name, "__ENVP")
1279 || ! strcmp (name, "__TLS_SIZE_D")
1280 || ! strcmp (name, "__LOAD_INFO")
1281 || ! strcmp (name, "__systab"));
1282}
1283
2ec0dd12
JL
1284/* Record the lowest address for the data and text segments. */
1285static void
c39a58e6
AM
1286elf_hppa_record_segment_addrs (bfd *abfd ATTRIBUTE_UNUSED,
1287 asection *section,
1288 void *data)
2ec0dd12
JL
1289{
1290 struct elf64_hppa_link_hash_table *hppa_info;
1291 bfd_vma value;
a7c10850 1292
c39a58e6 1293 hppa_info = data;
2ec0dd12
JL
1294
1295 value = section->vma - section->filepos;
1296
edd21aca 1297 if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
2ec0dd12
JL
1298 == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1299 && value < hppa_info->text_segment_base)
1300 hppa_info->text_segment_base = value;
edd21aca
AM
1301 else if (((section->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
1302 == (SEC_ALLOC | SEC_LOAD))
1303 && value < hppa_info->data_segment_base)
2ec0dd12
JL
1304 hppa_info->data_segment_base = value;
1305}
1306
2eb429af
JL
1307/* Called after we have seen all the input files/sections, but before
1308 final symbol resolution and section placement has been determined.
1309
1310 We use this hook to (possibly) provide a value for __gp, then we
1311 fall back to the generic ELF final link routine. */
1312
b34976b6 1313static bfd_boolean
c39a58e6 1314elf_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
2eb429af 1315{
b34976b6 1316 bfd_boolean retval;
edd21aca 1317 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
af7dc644 1318
1049f94e 1319 if (! info->relocatable)
2eb429af 1320 {
2eb429af 1321 struct elf_link_hash_entry *gp;
19ef5465 1322 bfd_vma gp_val;
1209c612
JL
1323
1324 /* The linker script defines a value for __gp iff it was referenced
1325 by one of the objects being linked. First try to find the symbol
1326 in the hash table. If that fails, just compute the value __gp
1327 should have had. */
b34976b6
AM
1328 gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
1329 FALSE, FALSE);
2eb429af 1330
1209c612
JL
1331 if (gp)
1332 {
1333
1334 /* Adjust the value of __gp as we may want to slide it into the
1335 .plt section so that the stubs can access PLT entries without
1336 using an addil sequence. */
edd21aca 1337 gp->root.u.def.value += hppa_info->gp_offset;
1209c612
JL
1338
1339 gp_val = (gp->root.u.def.section->output_section->vma
1340 + gp->root.u.def.section->output_offset
1341 + gp->root.u.def.value);
1342 }
1343 else
1344 {
1345 asection *sec;
1209c612
JL
1346
1347 /* First look for a .plt section. If found, then __gp is the
1348 address of the .plt + gp_offset.
1349
1350 If no .plt is found, then look for .dlt, .opd and .data (in
d663e1cd
JL
1351 that order) and set __gp to the base address of whichever
1352 section is found first. */
1209c612
JL
1353
1354 sec = hppa_info->plt_sec;
d663e1cd 1355 if (sec && ! (sec->flags & SEC_EXCLUDE))
1209c612
JL
1356 gp_val = (sec->output_offset
1357 + sec->output_section->vma
1358 + hppa_info->gp_offset);
1359 else
1360 {
1361 sec = hppa_info->dlt_sec;
d663e1cd 1362 if (!sec || (sec->flags & SEC_EXCLUDE))
1209c612 1363 sec = hppa_info->opd_sec;
d663e1cd 1364 if (!sec || (sec->flags & SEC_EXCLUDE))
1209c612 1365 sec = bfd_get_section_by_name (abfd, ".data");
d663e1cd 1366 if (!sec || (sec->flags & SEC_EXCLUDE))
c456f082
AM
1367 gp_val = 0;
1368 else
1369 gp_val = sec->output_offset + sec->output_section->vma;
1209c612
JL
1370 }
1371 }
2eb429af 1372
1209c612 1373 /* Install whatever value we found/computed for __gp. */
2eb429af
JL
1374 _bfd_set_gp_value (abfd, gp_val);
1375 }
1376
2ec0dd12 1377 /* We need to know the base of the text and data segments so that we
edd21aca 1378 can perform SEGREL relocations. We will record the base addresses
2ec0dd12 1379 when we encounter the first SEGREL relocation. */
edd21aca
AM
1380 hppa_info->text_segment_base = (bfd_vma)-1;
1381 hppa_info->data_segment_base = (bfd_vma)-1;
2ec0dd12 1382
af7dc644 1383 /* HP's shared libraries have references to symbols that are not
4cc11e76 1384 defined anywhere. The generic ELF BFD linker code will complain
af7dc644
JL
1385 about such symbols.
1386
1387 So we detect the losing case and arrange for the flags on the symbol
1388 to indicate that it was never referenced. This keeps the generic
1389 ELF BFD link code happy and appears to not create any secondary
1390 problems. Ultimately we need a way to control the behavior of the
1391 generic ELF BFD link code better. */
1392 elf_link_hash_traverse (elf_hash_table (info),
1393 elf_hppa_unmark_useless_dynamic_symbols,
1394 info);
1395
2eb429af 1396 /* Invoke the regular ELF backend linker to do all the work. */
c152c796 1397 retval = bfd_elf_final_link (abfd, info);
af7dc644
JL
1398
1399 elf_link_hash_traverse (elf_hash_table (info),
1400 elf_hppa_remark_useless_dynamic_symbols,
1401 info);
1402
46fe4e66
AM
1403 /* If we're producing a final executable, sort the contents of the
1404 unwind section. */
1405 if (retval)
1406 retval = elf_hppa_sort_unwind (abfd);
1407
af7dc644 1408 return retval;
2eb429af
JL
1409}
1410
9b52905e
NC
1411/* Relocate the given INSN. VALUE should be the actual value we want
1412 to insert into the instruction, ie by this point we should not be
1413 concerned with computing an offset relative to the DLT, PC, etc.
1414 Instead this routine is meant to handle the bit manipulations needed
1415 to insert the relocation into the given instruction. */
2eb429af 1416
9b52905e
NC
1417static int
1418elf_hppa_relocate_insn (int insn, int sym_value, unsigned int r_type)
2eb429af 1419{
9b52905e
NC
1420 switch (r_type)
1421 {
1422 /* This is any 22 bit branch. In PA2.0 syntax it corresponds to
1423 the "B" instruction. */
1424 case R_PARISC_PCREL22F:
1425 case R_PARISC_PCREL22C:
1426 return (insn & ~0x3ff1ffd) | re_assemble_22 (sym_value);
f0fe0e16 1427
9b52905e
NC
1428 /* This is any 12 bit branch. */
1429 case R_PARISC_PCREL12F:
1430 return (insn & ~0x1ffd) | re_assemble_12 (sym_value);
2eb429af 1431
9b52905e
NC
1432 /* This is any 17 bit branch. In PA2.0 syntax it also corresponds
1433 to the "B" instruction as well as BE. */
1434 case R_PARISC_PCREL17F:
1435 case R_PARISC_DIR17F:
1436 case R_PARISC_DIR17R:
1437 case R_PARISC_PCREL17C:
1438 case R_PARISC_PCREL17R:
1439 return (insn & ~0x1f1ffd) | re_assemble_17 (sym_value);
2eb429af 1440
9b52905e
NC
1441 /* ADDIL or LDIL instructions. */
1442 case R_PARISC_DLTREL21L:
1443 case R_PARISC_DLTIND21L:
1444 case R_PARISC_LTOFF_FPTR21L:
1445 case R_PARISC_PCREL21L:
1446 case R_PARISC_LTOFF_TP21L:
1447 case R_PARISC_DPREL21L:
1448 case R_PARISC_PLTOFF21L:
1449 case R_PARISC_DIR21L:
1450 return (insn & ~0x1fffff) | re_assemble_21 (sym_value);
2eb429af 1451
9b52905e
NC
1452 /* LDO and integer loads/stores with 14 bit displacements. */
1453 case R_PARISC_DLTREL14R:
1454 case R_PARISC_DLTREL14F:
1455 case R_PARISC_DLTIND14R:
1456 case R_PARISC_DLTIND14F:
1457 case R_PARISC_LTOFF_FPTR14R:
1458 case R_PARISC_PCREL14R:
1459 case R_PARISC_PCREL14F:
1460 case R_PARISC_LTOFF_TP14R:
1461 case R_PARISC_LTOFF_TP14F:
1462 case R_PARISC_DPREL14R:
1463 case R_PARISC_DPREL14F:
1464 case R_PARISC_PLTOFF14R:
1465 case R_PARISC_PLTOFF14F:
1466 case R_PARISC_DIR14R:
1467 case R_PARISC_DIR14F:
1468 return (insn & ~0x3fff) | low_sign_unext (sym_value, 14);
2eb429af 1469
9b52905e
NC
1470 /* PA2.0W LDO and integer loads/stores with 16 bit displacements. */
1471 case R_PARISC_LTOFF_FPTR16F:
1472 case R_PARISC_PCREL16F:
1473 case R_PARISC_LTOFF_TP16F:
1474 case R_PARISC_GPREL16F:
1475 case R_PARISC_PLTOFF16F:
1476 case R_PARISC_DIR16F:
1477 case R_PARISC_LTOFF16F:
1478 return (insn & ~0xffff) | re_assemble_16 (sym_value);
be7582f3 1479
9b52905e
NC
1480 /* Doubleword loads and stores with a 14 bit displacement. */
1481 case R_PARISC_DLTREL14DR:
1482 case R_PARISC_DLTIND14DR:
1483 case R_PARISC_LTOFF_FPTR14DR:
1484 case R_PARISC_LTOFF_FPTR16DF:
1485 case R_PARISC_PCREL14DR:
1486 case R_PARISC_PCREL16DF:
1487 case R_PARISC_LTOFF_TP14DR:
1488 case R_PARISC_LTOFF_TP16DF:
1489 case R_PARISC_DPREL14DR:
1490 case R_PARISC_GPREL16DF:
1491 case R_PARISC_PLTOFF14DR:
1492 case R_PARISC_PLTOFF16DF:
1493 case R_PARISC_DIR14DR:
1494 case R_PARISC_DIR16DF:
1495 case R_PARISC_LTOFF16DF:
1496 return (insn & ~0x3ff1) | (((sym_value & 0x2000) >> 13)
1497 | ((sym_value & 0x1ff8) << 1));
be7582f3 1498
9b52905e
NC
1499 /* Floating point single word load/store instructions. */
1500 case R_PARISC_DLTREL14WR:
1501 case R_PARISC_DLTIND14WR:
1502 case R_PARISC_LTOFF_FPTR14WR:
1503 case R_PARISC_LTOFF_FPTR16WF:
1504 case R_PARISC_PCREL14WR:
1505 case R_PARISC_PCREL16WF:
1506 case R_PARISC_LTOFF_TP14WR:
1507 case R_PARISC_LTOFF_TP16WF:
1508 case R_PARISC_DPREL14WR:
1509 case R_PARISC_GPREL16WF:
1510 case R_PARISC_PLTOFF14WR:
1511 case R_PARISC_PLTOFF16WF:
1512 case R_PARISC_DIR16WF:
1513 case R_PARISC_DIR14WR:
1514 case R_PARISC_LTOFF16WF:
1515 return (insn & ~0x3ff9) | (((sym_value & 0x2000) >> 13)
1516 | ((sym_value & 0x1ffc) << 1));
2eb429af 1517
9b52905e
NC
1518 default:
1519 return insn;
1520 }
1521}
be7582f3 1522
9b52905e
NC
1523/* Compute the value for a relocation (REL) during a final link stage,
1524 then insert the value into the proper location in CONTENTS.
be7582f3 1525
9b52905e
NC
1526 VALUE is a tentative value for the relocation and may be overridden
1527 and modified here based on the specific relocation to be performed.
be7582f3
JL
1528
1529 For example we do conversions for PC-relative branches in this routine
a7c10850 1530 or redirection of calls to external routines to stubs.
be7582f3
JL
1531
1532 The work of actually applying the relocation is left to a helper
1533 routine in an attempt to reduce the complexity and size of this
1534 function. */
2eb429af
JL
1535
1536static bfd_reloc_status_type
c39a58e6
AM
1537elf_hppa_final_link_relocate (Elf_Internal_Rela *rel,
1538 bfd *input_bfd,
1539 bfd *output_bfd,
1540 asection *input_section,
1541 bfd_byte *contents,
1542 bfd_vma value,
1543 struct bfd_link_info *info,
1544 asection *sym_sec,
1545 struct elf_link_hash_entry *h ATTRIBUTE_UNUSED,
1546 struct elf64_hppa_dyn_hash_entry *dyn_h)
2eb429af 1547{
dc810e39 1548 int insn;
be7582f3 1549 bfd_vma offset = rel->r_offset;
dc810e39 1550 bfd_signed_vma addend = rel->r_addend;
be7582f3 1551 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
3f9b03b5 1552 unsigned int r_type = howto->type;
2eb429af 1553 bfd_byte *hit_data = contents + offset;
be7582f3 1554 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
2eb429af
JL
1555
1556 insn = bfd_get_32 (input_bfd, hit_data);
1557
2eb429af
JL
1558 switch (r_type)
1559 {
1560 case R_PARISC_NONE:
1561 break;
1562
ba94744e 1563 /* Basic function call support.
3f9b03b5
AM
1564
1565 Note for a call to a function defined in another dynamic library
1566 we want to redirect the call to a stub. */
1567
571047ad 1568 /* Random PC relative relocs. */
b233eaab
JL
1569 case R_PARISC_PCREL21L:
1570 case R_PARISC_PCREL14R:
1571 case R_PARISC_PCREL14F:
571047ad
JL
1572 case R_PARISC_PCREL14WR:
1573 case R_PARISC_PCREL14DR:
1574 case R_PARISC_PCREL16F:
1575 case R_PARISC_PCREL16WF:
1576 case R_PARISC_PCREL16DF:
1577 {
571047ad
JL
1578 /* If this is a call to a function defined in another dynamic
1579 library, then redirect the call to the local stub for this
1580 function. */
dfec422f
JL
1581 if (sym_sec == NULL || sym_sec->output_section == NULL)
1582 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1583 + hppa_info->stub_sec->output_section->vma);
a7c10850 1584
571047ad
JL
1585 /* Turn VALUE into a proper PC relative address. */
1586 value -= (offset + input_section->output_offset
1587 + input_section->output_section->vma);
1588
1589 /* Adjust for any field selectors. */
3f9b03b5
AM
1590 if (r_type == R_PARISC_PCREL21L)
1591 value = hppa_field_adjust (value, -8 + addend, e_lsel);
1592 else if (r_type == R_PARISC_PCREL14F
1593 || r_type == R_PARISC_PCREL16F
1594 || r_type == R_PARISC_PCREL16WF
1595 || r_type == R_PARISC_PCREL16DF)
1596 value = hppa_field_adjust (value, -8 + addend, e_fsel);
1597 else
1598 value = hppa_field_adjust (value, -8 + addend, e_rsel);
571047ad
JL
1599
1600 /* Apply the relocation to the given instruction. */
dc810e39 1601 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
571047ad
JL
1602 break;
1603 }
1604
49bd834c 1605 case R_PARISC_PCREL12F:
2eb429af
JL
1606 case R_PARISC_PCREL22F:
1607 case R_PARISC_PCREL17F:
571047ad
JL
1608 case R_PARISC_PCREL22C:
1609 case R_PARISC_PCREL17C:
1610 case R_PARISC_PCREL17R:
2eb429af 1611 {
be7582f3
JL
1612 /* If this is a call to a function defined in another dynamic
1613 library, then redirect the call to the local stub for this
1614 function. */
dfec422f 1615 if (sym_sec == NULL || sym_sec->output_section == NULL)
6a0b9871
JL
1616 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1617 + hppa_info->stub_sec->output_section->vma);
a7c10850 1618
be7582f3
JL
1619 /* Turn VALUE into a proper PC relative address. */
1620 value -= (offset + input_section->output_offset
1621 + input_section->output_section->vma);
1622
1623 /* Adjust for any field selectors. */
70d72e0e
AM
1624 if (r_type == R_PARISC_PCREL17R)
1625 value = hppa_field_adjust (value, -8 + addend, e_rsel);
1626 else
1627 value = hppa_field_adjust (value, -8 + addend, e_fsel);
2eb429af 1628
be7582f3
JL
1629 /* All branches are implicitly shifted by 2 places. */
1630 value >>= 2;
2eb429af 1631
be7582f3 1632 /* Apply the relocation to the given instruction. */
dc810e39 1633 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
2eb429af
JL
1634 break;
1635 }
1636
be7582f3
JL
1637 /* Indirect references to data through the DLT. */
1638 case R_PARISC_DLTIND14R:
571047ad 1639 case R_PARISC_DLTIND14F:
be7582f3
JL
1640 case R_PARISC_DLTIND14DR:
1641 case R_PARISC_DLTIND14WR:
1642 case R_PARISC_DLTIND21L:
e5bb3efc
JL
1643 case R_PARISC_LTOFF_FPTR14R:
1644 case R_PARISC_LTOFF_FPTR14DR:
1645 case R_PARISC_LTOFF_FPTR14WR:
1646 case R_PARISC_LTOFF_FPTR21L:
1647 case R_PARISC_LTOFF_FPTR16F:
1648 case R_PARISC_LTOFF_FPTR16WF:
1649 case R_PARISC_LTOFF_FPTR16DF:
b233eaab
JL
1650 case R_PARISC_LTOFF_TP21L:
1651 case R_PARISC_LTOFF_TP14R:
1652 case R_PARISC_LTOFF_TP14F:
1653 case R_PARISC_LTOFF_TP14WR:
1654 case R_PARISC_LTOFF_TP14DR:
1655 case R_PARISC_LTOFF_TP16F:
1656 case R_PARISC_LTOFF_TP16WF:
1657 case R_PARISC_LTOFF_TP16DF:
b7263961
JL
1658 case R_PARISC_LTOFF16F:
1659 case R_PARISC_LTOFF16WF:
1660 case R_PARISC_LTOFF16DF:
c8933571 1661 {
6a0b9871 1662 /* If this relocation was against a local symbol, then we still
edd21aca 1663 have not set up the DLT entry (it's not convenient to do so
6a0b9871
JL
1664 in the "finalize_dlt" routine because it is difficult to get
1665 to the local symbol's value).
1666
1667 So, if this is a local symbol (h == NULL), then we need to
a7c10850 1668 fill in its DLT entry.
e48c661e
JL
1669
1670 Similarly we may still need to set up an entry in .opd for
1671 a local function which had its address taken. */
6a0b9871
JL
1672 if (dyn_h->h == NULL)
1673 {
1bf42538 1674 /* Now do .opd creation if needed. */
e48c661e
JL
1675 if (r_type == R_PARISC_LTOFF_FPTR14R
1676 || r_type == R_PARISC_LTOFF_FPTR14DR
1677 || r_type == R_PARISC_LTOFF_FPTR14WR
1678 || r_type == R_PARISC_LTOFF_FPTR21L
1679 || r_type == R_PARISC_LTOFF_FPTR16F
1680 || r_type == R_PARISC_LTOFF_FPTR16WF
1681 || r_type == R_PARISC_LTOFF_FPTR16DF)
1682 {
1683 /* The first two words of an .opd entry are zero. */
1684 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset,
1685 0, 16);
1686
1687 /* The next word is the address of the function. */
1bf42538 1688 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
e48c661e
JL
1689 (hppa_info->opd_sec->contents
1690 + dyn_h->opd_offset + 16));
1691
1692 /* The last word is our local __gp value. */
1693 value = _bfd_get_gp_value
1694 (hppa_info->opd_sec->output_section->owner);
1695 bfd_put_64 (hppa_info->opd_sec->owner, value,
1696 (hppa_info->opd_sec->contents
1697 + dyn_h->opd_offset + 24));
1bf42538
JL
1698
1699 /* The DLT value is the address of the .opd entry. */
1700 value = (dyn_h->opd_offset
1701 + hppa_info->opd_sec->output_offset
1702 + hppa_info->opd_sec->output_section->vma);
1703 addend = 0;
e48c661e 1704 }
1bf42538
JL
1705
1706 bfd_put_64 (hppa_info->dlt_sec->owner,
1707 value + addend,
1708 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
6a0b9871
JL
1709 }
1710
be7582f3 1711 /* We want the value of the DLT offset for this symbol, not
19ef5465
JL
1712 the symbol's actual address. Note that __gp may not point
1713 to the start of the DLT, so we have to compute the absolute
1714 address, then subtract out the value of __gp. */
1715 value = (dyn_h->dlt_offset
1716 + hppa_info->dlt_sec->output_offset
1717 + hppa_info->dlt_sec->output_section->vma);
1718 value -= _bfd_get_gp_value (output_bfd);
1719
be7582f3
JL
1720 /* All DLTIND relocations are basically the same at this point,
1721 except that we need different field selectors for the 21bit
1722 version vs the 14bit versions. */
e5bb3efc 1723 if (r_type == R_PARISC_DLTIND21L
b233eaab
JL
1724 || r_type == R_PARISC_LTOFF_FPTR21L
1725 || r_type == R_PARISC_LTOFF_TP21L)
1bf42538 1726 value = hppa_field_adjust (value, 0, e_lsel);
571047ad
JL
1727 else if (r_type == R_PARISC_DLTIND14F
1728 || r_type == R_PARISC_LTOFF_FPTR16F
1729 || r_type == R_PARISC_LTOFF_FPTR16WF
b233eaab 1730 || r_type == R_PARISC_LTOFF_FPTR16DF
b7263961
JL
1731 || r_type == R_PARISC_LTOFF16F
1732 || r_type == R_PARISC_LTOFF16DF
1733 || r_type == R_PARISC_LTOFF16WF
b233eaab
JL
1734 || r_type == R_PARISC_LTOFF_TP16F
1735 || r_type == R_PARISC_LTOFF_TP16WF
1736 || r_type == R_PARISC_LTOFF_TP16DF)
1bf42538 1737 value = hppa_field_adjust (value, 0, e_fsel);
be7582f3 1738 else
1bf42538 1739 value = hppa_field_adjust (value, 0, e_rsel);
be7582f3 1740
dc810e39 1741 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
c8933571
JL
1742 break;
1743 }
1744
be7582f3 1745 case R_PARISC_DLTREL14R:
571047ad 1746 case R_PARISC_DLTREL14F:
be7582f3
JL
1747 case R_PARISC_DLTREL14DR:
1748 case R_PARISC_DLTREL14WR:
c8933571 1749 case R_PARISC_DLTREL21L:
6849fb4d
JL
1750 case R_PARISC_DPREL21L:
1751 case R_PARISC_DPREL14WR:
1752 case R_PARISC_DPREL14DR:
1753 case R_PARISC_DPREL14R:
1754 case R_PARISC_DPREL14F:
1755 case R_PARISC_GPREL16F:
1756 case R_PARISC_GPREL16WF:
1757 case R_PARISC_GPREL16DF:
c8933571 1758 {
be7582f3
JL
1759 /* Subtract out the global pointer value to make value a DLT
1760 relative address. */
1761 value -= _bfd_get_gp_value (output_bfd);
1762
1763 /* All DLTREL relocations are basically the same at this point,
1764 except that we need different field selectors for the 21bit
1765 version vs the 14bit versions. */
6849fb4d
JL
1766 if (r_type == R_PARISC_DLTREL21L
1767 || r_type == R_PARISC_DPREL21L)
be7582f3 1768 value = hppa_field_adjust (value, addend, e_lrsel);
6849fb4d
JL
1769 else if (r_type == R_PARISC_DLTREL14F
1770 || r_type == R_PARISC_DPREL14F
1771 || r_type == R_PARISC_GPREL16F
1772 || r_type == R_PARISC_GPREL16WF
1773 || r_type == R_PARISC_GPREL16DF)
571047ad 1774 value = hppa_field_adjust (value, addend, e_fsel);
be7582f3
JL
1775 else
1776 value = hppa_field_adjust (value, addend, e_rrsel);
1777
dc810e39 1778 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
c8933571
JL
1779 break;
1780 }
1781
b7263961
JL
1782 case R_PARISC_DIR21L:
1783 case R_PARISC_DIR17R:
1784 case R_PARISC_DIR17F:
1785 case R_PARISC_DIR14R:
47d89dba 1786 case R_PARISC_DIR14F:
b7263961
JL
1787 case R_PARISC_DIR14WR:
1788 case R_PARISC_DIR14DR:
1789 case R_PARISC_DIR16F:
1790 case R_PARISC_DIR16WF:
1791 case R_PARISC_DIR16DF:
1792 {
1793 /* All DIR relocations are basically the same at this point,
70d72e0e
AM
1794 except that branch offsets need to be divided by four, and
1795 we need different field selectors. Note that we don't
1796 redirect absolute calls to local stubs. */
3f9b03b5 1797
b7263961
JL
1798 if (r_type == R_PARISC_DIR21L)
1799 value = hppa_field_adjust (value, addend, e_lrsel);
1800 else if (r_type == R_PARISC_DIR17F
1801 || r_type == R_PARISC_DIR16F
1802 || r_type == R_PARISC_DIR16WF
47d89dba
AM
1803 || r_type == R_PARISC_DIR16DF
1804 || r_type == R_PARISC_DIR14F)
b7263961
JL
1805 value = hppa_field_adjust (value, addend, e_fsel);
1806 else
1807 value = hppa_field_adjust (value, addend, e_rrsel);
1808
70d72e0e 1809 if (r_type == R_PARISC_DIR17R || r_type == R_PARISC_DIR17F)
9b52905e
NC
1810 /* All branches are implicitly shifted by 2 places. */
1811 value >>= 2;
70d72e0e 1812
dc810e39 1813 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
b7263961
JL
1814 break;
1815 }
1816
8267b155
JL
1817 case R_PARISC_PLTOFF21L:
1818 case R_PARISC_PLTOFF14R:
1819 case R_PARISC_PLTOFF14F:
1820 case R_PARISC_PLTOFF14WR:
1821 case R_PARISC_PLTOFF14DR:
1822 case R_PARISC_PLTOFF16F:
1823 case R_PARISC_PLTOFF16WF:
1824 case R_PARISC_PLTOFF16DF:
1825 {
1826 /* We want the value of the PLT offset for this symbol, not
19ef5465
JL
1827 the symbol's actual address. Note that __gp may not point
1828 to the start of the DLT, so we have to compute the absolute
1829 address, then subtract out the value of __gp. */
1830 value = (dyn_h->plt_offset
1831 + hppa_info->plt_sec->output_offset
1832 + hppa_info->plt_sec->output_section->vma);
1833 value -= _bfd_get_gp_value (output_bfd);
8267b155
JL
1834
1835 /* All PLTOFF relocations are basically the same at this point,
1836 except that we need different field selectors for the 21bit
1837 version vs the 14bit versions. */
1838 if (r_type == R_PARISC_PLTOFF21L)
1839 value = hppa_field_adjust (value, addend, e_lrsel);
1840 else if (r_type == R_PARISC_PLTOFF14F
1841 || r_type == R_PARISC_PLTOFF16F
1842 || r_type == R_PARISC_PLTOFF16WF
1843 || r_type == R_PARISC_PLTOFF16DF)
1844 value = hppa_field_adjust (value, addend, e_fsel);
1845 else
1846 value = hppa_field_adjust (value, addend, e_rrsel);
1847
dc810e39 1848 insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
8267b155
JL
1849 break;
1850 }
1851
e5bb3efc
JL
1852 case R_PARISC_LTOFF_FPTR32:
1853 {
e48c661e
JL
1854 /* We may still need to create the FPTR itself if it was for
1855 a local symbol. */
1856 if (dyn_h->h == NULL)
1857 {
1858 /* The first two words of an .opd entry are zero. */
1859 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1860
1861 /* The next word is the address of the function. */
1bf42538 1862 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
e48c661e
JL
1863 (hppa_info->opd_sec->contents
1864 + dyn_h->opd_offset + 16));
1865
1866 /* The last word is our local __gp value. */
1867 value = _bfd_get_gp_value
1868 (hppa_info->opd_sec->output_section->owner);
1869 bfd_put_64 (hppa_info->opd_sec->owner, value,
1870 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1bf42538
JL
1871
1872 /* The DLT value is the address of the .opd entry. */
1873 value = (dyn_h->opd_offset
1874 + hppa_info->opd_sec->output_offset
1875 + hppa_info->opd_sec->output_section->vma);
1876
1877 bfd_put_64 (hppa_info->dlt_sec->owner,
1878 value,
1879 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
e48c661e
JL
1880 }
1881
e5bb3efc 1882 /* We want the value of the DLT offset for this symbol, not
19ef5465
JL
1883 the symbol's actual address. Note that __gp may not point
1884 to the start of the DLT, so we have to compute the absolute
1885 address, then subtract out the value of __gp. */
1886 value = (dyn_h->dlt_offset
1887 + hppa_info->dlt_sec->output_offset
1888 + hppa_info->dlt_sec->output_section->vma);
1889 value -= _bfd_get_gp_value (output_bfd);
e5bb3efc
JL
1890 bfd_put_32 (input_bfd, value, hit_data);
1891 return bfd_reloc_ok;
1892 }
1893
e5bb3efc 1894 case R_PARISC_LTOFF_FPTR64:
b233eaab 1895 case R_PARISC_LTOFF_TP64:
e5bb3efc 1896 {
e48c661e
JL
1897 /* We may still need to create the FPTR itself if it was for
1898 a local symbol. */
1899 if (dyn_h->h == NULL && r_type == R_PARISC_LTOFF_FPTR64)
1900 {
1901 /* The first two words of an .opd entry are zero. */
1902 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1903
1904 /* The next word is the address of the function. */
1bf42538 1905 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
e48c661e
JL
1906 (hppa_info->opd_sec->contents
1907 + dyn_h->opd_offset + 16));
1908
1909 /* The last word is our local __gp value. */
1910 value = _bfd_get_gp_value
1911 (hppa_info->opd_sec->output_section->owner);
1912 bfd_put_64 (hppa_info->opd_sec->owner, value,
1913 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1bf42538
JL
1914
1915 /* The DLT value is the address of the .opd entry. */
1916 value = (dyn_h->opd_offset
1917 + hppa_info->opd_sec->output_offset
1918 + hppa_info->opd_sec->output_section->vma);
1919
1920 bfd_put_64 (hppa_info->dlt_sec->owner,
1921 value,
1922 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
e48c661e
JL
1923 }
1924
e5bb3efc 1925 /* We want the value of the DLT offset for this symbol, not
19ef5465
JL
1926 the symbol's actual address. Note that __gp may not point
1927 to the start of the DLT, so we have to compute the absolute
1928 address, then subtract out the value of __gp. */
1929 value = (dyn_h->dlt_offset
1930 + hppa_info->dlt_sec->output_offset
1931 + hppa_info->dlt_sec->output_section->vma);
1932 value -= _bfd_get_gp_value (output_bfd);
e5bb3efc
JL
1933 bfd_put_64 (input_bfd, value, hit_data);
1934 return bfd_reloc_ok;
1935 }
1936
1937 case R_PARISC_DIR32:
571047ad 1938 bfd_put_32 (input_bfd, value + addend, hit_data);
e5bb3efc
JL
1939 return bfd_reloc_ok;
1940
1941 case R_PARISC_DIR64:
571047ad 1942 bfd_put_64 (input_bfd, value + addend, hit_data);
e5bb3efc
JL
1943 return bfd_reloc_ok;
1944
6849fb4d
JL
1945 case R_PARISC_GPREL64:
1946 /* Subtract out the global pointer value to make value a DLT
1947 relative address. */
1948 value -= _bfd_get_gp_value (output_bfd);
6849fb4d
JL
1949
1950 bfd_put_64 (input_bfd, value + addend, hit_data);
1951 return bfd_reloc_ok;
1952
b7263961 1953 case R_PARISC_LTOFF64:
19ef5465
JL
1954 /* We want the value of the DLT offset for this symbol, not
1955 the symbol's actual address. Note that __gp may not point
1956 to the start of the DLT, so we have to compute the absolute
1957 address, then subtract out the value of __gp. */
1958 value = (dyn_h->dlt_offset
1959 + hppa_info->dlt_sec->output_offset
1960 + hppa_info->dlt_sec->output_section->vma);
1961 value -= _bfd_get_gp_value (output_bfd);
b7263961
JL
1962
1963 bfd_put_64 (input_bfd, value + addend, hit_data);
1964 return bfd_reloc_ok;
1965
571047ad
JL
1966 case R_PARISC_PCREL32:
1967 {
1968 /* If this is a call to a function defined in another dynamic
1969 library, then redirect the call to the local stub for this
1970 function. */
dfec422f
JL
1971 if (sym_sec == NULL || sym_sec->output_section == NULL)
1972 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1973 + hppa_info->stub_sec->output_section->vma);
a7c10850 1974
571047ad
JL
1975 /* Turn VALUE into a proper PC relative address. */
1976 value -= (offset + input_section->output_offset
1977 + input_section->output_section->vma);
1978
b233eaab 1979 value += addend;
571047ad 1980 value -= 8;
edd21aca 1981 bfd_put_32 (input_bfd, value, hit_data);
571047ad
JL
1982 return bfd_reloc_ok;
1983 }
1984
1985 case R_PARISC_PCREL64:
1986 {
1987 /* If this is a call to a function defined in another dynamic
1988 library, then redirect the call to the local stub for this
1989 function. */
dfec422f
JL
1990 if (sym_sec == NULL || sym_sec->output_section == NULL)
1991 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1992 + hppa_info->stub_sec->output_section->vma);
a7c10850 1993
571047ad
JL
1994 /* Turn VALUE into a proper PC relative address. */
1995 value -= (offset + input_section->output_offset
1996 + input_section->output_section->vma);
1997
b233eaab 1998 value += addend;
571047ad
JL
1999 value -= 8;
2000 bfd_put_64 (input_bfd, value, hit_data);
2001 return bfd_reloc_ok;
2002 }
2003
e5bb3efc 2004 case R_PARISC_FPTR64:
e48c661e
JL
2005 {
2006 /* We may still need to create the FPTR itself if it was for
2007 a local symbol. */
2008 if (dyn_h->h == NULL)
2009 {
2010 /* The first two words of an .opd entry are zero. */
2011 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
2012
2013 /* The next word is the address of the function. */
1bf42538 2014 bfd_put_64 (hppa_info->opd_sec->owner, value + addend,
e48c661e
JL
2015 (hppa_info->opd_sec->contents
2016 + dyn_h->opd_offset + 16));
2017
2018 /* The last word is our local __gp value. */
2019 value = _bfd_get_gp_value
2020 (hppa_info->opd_sec->output_section->owner);
2021 bfd_put_64 (hppa_info->opd_sec->owner, value,
2022 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
2023 }
2024
d663e1cd
JL
2025 if (dyn_h->want_opd)
2026 /* We want the value of the OPD offset for this symbol. */
2027 value = (dyn_h->opd_offset
2028 + hppa_info->opd_sec->output_offset
2029 + hppa_info->opd_sec->output_section->vma);
2030 else
2031 /* We want the address of the symbol. */
2032 value += addend;
a7c10850 2033
1bf42538 2034 bfd_put_64 (input_bfd, value, hit_data);
e48c661e
JL
2035 return bfd_reloc_ok;
2036 }
e5bb3efc 2037
228d307f
JL
2038 case R_PARISC_SECREL32:
2039 bfd_put_32 (input_bfd,
edd21aca 2040 value + addend - sym_sec->output_section->vma,
228d307f
JL
2041 hit_data);
2042 return bfd_reloc_ok;
2043
2044 case R_PARISC_SEGREL32:
2ec0dd12
JL
2045 case R_PARISC_SEGREL64:
2046 {
2047 /* If this is the first SEGREL relocation, then initialize
2048 the segment base values. */
2049 if (hppa_info->text_segment_base == (bfd_vma) -1)
2050 bfd_map_over_sections (output_bfd, elf_hppa_record_segment_addrs,
edd21aca 2051 hppa_info);
2ec0dd12
JL
2052
2053 /* VALUE holds the absolute address. We want to include the
2054 addend, then turn it into a segment relative address.
2055
2056 The segment is derived from SYM_SEC. We assume that there are
2057 only two segments of note in the resulting executable/shlib.
2058 A readonly segment (.text) and a readwrite segment (.data). */
2059 value += addend;
2060
2061 if (sym_sec->flags & SEC_CODE)
2062 value -= hppa_info->text_segment_base;
2063 else
2064 value -= hppa_info->data_segment_base;
2065
2066 if (r_type == R_PARISC_SEGREL32)
2067 bfd_put_32 (input_bfd, value, hit_data);
2068 else
2069 bfd_put_64 (input_bfd, value, hit_data);
46fe4e66 2070 return bfd_reloc_ok;
2ec0dd12 2071 }
228d307f 2072
2eb429af
JL
2073 /* Something we don't know how to handle. */
2074 default:
228d307f 2075 return bfd_reloc_notsupported;
2eb429af
JL
2076 }
2077
2078 /* Update the instruction word. */
dc810e39 2079 bfd_put_32 (input_bfd, (bfd_vma) insn, hit_data);
edd21aca 2080 return bfd_reloc_ok;
2eb429af
JL
2081}
2082
9b52905e 2083/* Relocate an HPPA ELF section. */
2eb429af 2084
9b52905e
NC
2085static bfd_boolean
2086elf_hppa_relocate_section (bfd *output_bfd,
2087 struct bfd_link_info *info,
2088 bfd *input_bfd,
2089 asection *input_section,
2090 bfd_byte *contents,
2091 Elf_Internal_Rela *relocs,
2092 Elf_Internal_Sym *local_syms,
2093 asection **local_sections)
2eb429af 2094{
9b52905e
NC
2095 Elf_Internal_Shdr *symtab_hdr;
2096 Elf_Internal_Rela *rel;
2097 Elf_Internal_Rela *relend;
2098 struct elf64_hppa_link_hash_table *hppa_info;
2099
9b52905e
NC
2100 hppa_info = elf64_hppa_hash_table (info);
2101 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
2102
2103 rel = relocs;
2104 relend = relocs + input_section->reloc_count;
2105 for (; rel < relend; rel++)
2eb429af 2106 {
9b52905e
NC
2107 int r_type;
2108 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
2109 unsigned long r_symndx;
2110 struct elf_link_hash_entry *h;
2111 Elf_Internal_Sym *sym;
2112 asection *sym_sec;
2113 bfd_vma relocation;
2114 bfd_reloc_status_type r;
2115 const char *dyn_name;
2116 char *dynh_buf = NULL;
2117 size_t dynh_buflen = 0;
2118 struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
2eb429af 2119
9b52905e
NC
2120 r_type = ELF_R_TYPE (rel->r_info);
2121 if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
2122 {
2123 bfd_set_error (bfd_error_bad_value);
2124 return FALSE;
2125 }
49bd834c 2126
9b52905e
NC
2127 /* This is a final link. */
2128 r_symndx = ELF_R_SYM (rel->r_info);
2129 h = NULL;
2130 sym = NULL;
2131 sym_sec = NULL;
2132 if (r_symndx < symtab_hdr->sh_info)
2133 {
2134 /* This is a local symbol. */
2135 sym = local_syms + r_symndx;
2136 sym_sec = local_sections[r_symndx];
2137 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sym_sec, rel);
2eb429af 2138
9b52905e
NC
2139 /* If this symbol has an entry in the PA64 dynamic hash
2140 table, then get it. */
2141 dyn_name = get_dyn_name (input_bfd, h, rel,
2142 &dynh_buf, &dynh_buflen);
2143 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
2144 dyn_name, FALSE, FALSE);
be7582f3 2145
9b52905e
NC
2146 }
2147 else
2148 {
2149 /* This is not a local symbol. */
2150 long indx;
ba94744e 2151
ab96bf03 2152 relocation = 0;
9b52905e
NC
2153 indx = r_symndx - symtab_hdr->sh_info;
2154 h = elf_sym_hashes (input_bfd)[indx];
2155 while (h->root.type == bfd_link_hash_indirect
2156 || h->root.type == bfd_link_hash_warning)
2157 h = (struct elf_link_hash_entry *) h->root.u.i.link;
2158 if (h->root.type == bfd_link_hash_defined
2159 || h->root.type == bfd_link_hash_defweak)
2160 {
2161 sym_sec = h->root.u.def.section;
be7582f3 2162
9b52905e
NC
2163 /* If this symbol has an entry in the PA64 dynamic hash
2164 table, then get it. */
2165 dyn_name = get_dyn_name (input_bfd, h, rel,
2166 &dynh_buf, &dynh_buflen);
2167 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
2168 dyn_name, FALSE, FALSE);
11c19a4e 2169
9b52905e
NC
2170 /* If we have a relocation against a symbol defined in a
2171 shared library and we have not created an entry in the
2172 PA64 dynamic symbol hash table for it, then we lose. */
ab96bf03
AM
2173 if (!info->relocatable
2174 && sym_sec->output_section == NULL && dyn_h == NULL)
9b52905e
NC
2175 {
2176 (*_bfd_error_handler)
2177 (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
2178 input_bfd,
2179 input_section,
2180 (long) rel->r_offset,
2181 howto->name,
2182 h->root.root.string);
9b52905e
NC
2183 }
2184 else if (sym_sec->output_section)
2185 relocation = (h->root.u.def.value
2186 + sym_sec->output_offset
2187 + sym_sec->output_section->vma);
9b52905e
NC
2188 }
2189 else if (info->unresolved_syms_in_objects == RM_IGNORE
2190 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
2191 {
2192 /* If this symbol has an entry in the PA64 dynamic hash
2193 table, then get it. */
2194 dyn_name = get_dyn_name (input_bfd, h, rel,
2195 &dynh_buf, &dynh_buflen);
2196 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
2197 dyn_name, FALSE, FALSE);
be7582f3 2198
ab96bf03 2199 if (!info->relocatable && dyn_h == NULL)
9b52905e
NC
2200 {
2201 (*_bfd_error_handler)
2202 (_("%B(%A): warning: unresolvable relocation against symbol `%s'"),
2203 input_bfd, input_section, h->root.root.string);
2204 }
9b52905e
NC
2205 }
2206 else if (h->root.type == bfd_link_hash_undefweak)
2207 {
2208 dyn_name = get_dyn_name (input_bfd, h, rel,
2209 &dynh_buf, &dynh_buflen);
2210 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
2211 dyn_name, FALSE, FALSE);
2212
ab96bf03 2213 if (!info->relocatable && dyn_h == NULL)
9b52905e
NC
2214 {
2215 (*_bfd_error_handler)
2216 (_("%B(%A): warning: unresolvable relocation against symbol `%s'"),
2217 input_bfd, input_section, h->root.root.string);
2218 }
9b52905e 2219 }
ab96bf03 2220 else if (!info->relocatable)
9b52905e
NC
2221 {
2222 /* Ignore dynamic loader defined symbols. */
ab96bf03 2223 if (!elf_hppa_is_dynamic_loader_symbol (h->root.root.string))
9b52905e
NC
2224 {
2225 if (!((*info->callbacks->undefined_symbol)
2226 (info, h->root.root.string, input_bfd,
2227 input_section, rel->r_offset,
2228 (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
2229 || ELF_ST_VISIBILITY (h->other)))))
2230 return FALSE;
2231 break;
2232 }
2233 }
2234 }
2235
ab96bf03
AM
2236 if (sym_sec != NULL && elf_discarded_section (sym_sec))
2237 {
2238 /* For relocs against symbols from removed linkonce sections,
2239 or sections discarded by a linker script, we just want the
2240 section contents zeroed. Avoid any special processing. */
2241 _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
2242 rel->r_info = 0;
2243 rel->r_addend = 0;
2244 continue;
2245 }
2246
2247 if (info->relocatable)
2248 continue;
2249
9b52905e
NC
2250 r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
2251 input_section, contents,
2252 relocation, info, sym_sec,
2253 h, dyn_h);
2254
2255 if (r != bfd_reloc_ok)
2256 {
2257 switch (r)
2258 {
2259 default:
2260 abort ();
2261 case bfd_reloc_overflow:
2262 {
2263 const char *sym_name;
2264
2265 if (h != NULL)
2266 sym_name = NULL;
2267 else
2268 {
2269 sym_name = bfd_elf_string_from_elf_section (input_bfd,
2270 symtab_hdr->sh_link,
2271 sym->st_name);
2272 if (sym_name == NULL)
2273 return FALSE;
2274 if (*sym_name == '\0')
2275 sym_name = bfd_section_name (input_bfd, sym_sec);
2276 }
2277
2278 if (!((*info->callbacks->reloc_overflow)
2279 (info, (h ? &h->root : NULL), sym_name,
2280 howto->name, (bfd_vma) 0, input_bfd,
2281 input_section, rel->r_offset)))
2282 return FALSE;
2283 }
2284 break;
2285 }
2286 }
2eb429af 2287 }
9b52905e 2288 return TRUE;
2eb429af 2289}
9b52905e
NC
2290
2291#endif /* ARCH_SIZE == 64 */
This page took 0.72189 seconds and 4 git commands to generate.