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