* emultempl/elf32.em (gld${EMULATION_NAME}_open_dynamic_archive):
[deliverable/binutils-gdb.git] / bfd / elf-hppa.h
CommitLineData
9e103c9c 1/* Common code for PA ELF implementations.
5f771d47 2 Copyright (C) 1999 Free Software Foundation, Inc.
9e103c9c
JL
3
4This file is part of BFD, the Binary File Descriptor library.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20#define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
21
2eb429af
JL
22/* This file is included by multiple PA ELF BFD backends with different
23 sizes.
24
25 Most of the routines are written to be size independent, but sometimes
26 external constraints require 32 or 64 bit specific code. We remap
27 the definitions/functions as necessary here. */
9e103c9c
JL
28#if ARCH_SIZE == 64
29#define ELF_R_TYPE(X) ELF64_R_TYPE(X)
2eb429af 30#define ELF_R_SYM(X) ELF64_R_SYM(X)
9e103c9c 31#define _bfd_elf_hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
2eb429af
JL
32#define elf_hppa_relocate_section elf64_hppa_relocate_section
33#define bfd_elf_bfd_final_link bfd_elf64_bfd_final_link
34#define elf_hppa_final_link elf64_hppa_final_link
9e103c9c
JL
35#endif
36#if ARCH_SIZE == 32
37#define ELF_R_TYPE(X) ELF32_R_TYPE(X)
2eb429af 38#define ELF_R_SYM(X) ELF32_R_SYM(X)
9e103c9c 39#define _bfd_elf_hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
2eb429af
JL
40#define elf_hppa_relocate_section elf32_hppa_relocate_section
41#define bfd_elf_bfd_final_link bfd_elf32_bfd_final_link
42#define elf_hppa_final_link elf32_hppa_final_link
9e103c9c
JL
43#endif
44
2eb429af
JL
45static boolean
46elf_hppa_relocate_section
47 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
48 bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
49
50static bfd_reloc_status_type elf_hppa_final_link_relocate
be7582f3
JL
51 PARAMS ((Elf_Internal_Rela *, bfd *, bfd *, asection *,
52 bfd_byte *, bfd_vma, struct bfd_link_info *,
53 asection *, struct elf_link_hash_entry *,
54 struct elf64_hppa_dyn_hash_entry *));
2eb429af
JL
55
56static unsigned long elf_hppa_relocate_insn
be7582f3 57 PARAMS ((unsigned long, long, unsigned long));
2eb429af
JL
58
59static boolean elf_hppa_add_symbol_hook
f273939b 60 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
2eb429af
JL
61 const char **, flagword *, asection **, bfd_vma *));
62
63static boolean elf_hppa_final_link
64 PARAMS ((bfd *, struct bfd_link_info *));
65
af7dc644
JL
66static boolean elf_hppa_unmark_useless_dynamic_symbols
67 PARAMS ((struct elf_link_hash_entry *, PTR));
68
69static boolean elf_hppa_remark_useless_dynamic_symbols
70 PARAMS ((struct elf_link_hash_entry *, PTR));
71
9e103c9c
JL
72/* ELF/PA relocation howto entries. */
73
74static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
75{
be7582f3 76 {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"},
9e103c9c
JL
77
78 /* The values in DIR32 are to placate the check in
79 _bfd_stab_section_find_nearest_line. */
caf3d37c 80 {R_PARISC_DIR32, 0, 2, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR32", false, 0, 0xffffffff, false},
be7582f3
JL
81 {R_PARISC_DIR21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR21L"},
82 {R_PARISC_DIR17R, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR17R"},
83 {R_PARISC_DIR17F, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR17F"},
84 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
85 {R_PARISC_DIR14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14R"},
86 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
87 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
88 {R_PARISC_PCREL32, 0, 0, 32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL32"},
89
90 {R_PARISC_PCREL21L, 0, 0, 21, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL21L"},
91 {R_PARISC_PCREL17R, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17R"},
92 {R_PARISC_PCREL17F, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17F"},
93 {R_PARISC_PCREL17C, 0, 0, 17, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL17C"},
94 {R_PARISC_PCREL14R, 0, 0, 14, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14R"},
95 {R_PARISC_PCREL14F, 0, 0, 14, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14F"},
96 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
97 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
98 {R_PARISC_DPREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL21L"},
99 {R_PARISC_DPREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14WR"},
100
101 {R_PARISC_DPREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14DR"},
102 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
103 {R_PARISC_DPREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14R"},
104 {R_PARISC_DPREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DPREL14F"},
105 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
106 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
107 {R_PARISC_DLTREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL21L"},
108 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
109 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
110 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
111
112 {R_PARISC_DLTREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14R"},
113 {R_PARISC_DLTREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14F"},
114 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
115 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
116 {R_PARISC_DLTIND21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND21L"},
117 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
118 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
119 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
120 {R_PARISC_DLTIND14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14R"},
121 {R_PARISC_DLTIND14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14F"},
122
123 {R_PARISC_SETBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SETBASE"},
124 {R_PARISC_SECREL32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SECREL32"},
125 {R_PARISC_BASEREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL21L"},
126 {R_PARISC_BASEREL17R, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL17R"},
127 {R_PARISC_BASEREL17F, 0, 0, 17, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL17F"},
128 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
129 {R_PARISC_BASEREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14R"},
130 {R_PARISC_BASEREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14F"},
131 {R_PARISC_SEGBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGBASE"},
132 {R_PARISC_SEGREL32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGREL32"},
133
134 {R_PARISC_PLTOFF21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF21L"},
135 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
136 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
137 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
138 {R_PARISC_PLTOFF14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14R"},
139 {R_PARISC_PLTOFF14F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14F"},
140 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
141 {R_PARISC_LTOFF_FPTR32, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR32"},
142 {R_PARISC_LTOFF_FPTR21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR21L"},
143 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
144
145 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
146 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
147 {R_PARISC_LTOFF_FPTR14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14R"},
148 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
149 {R_PARISC_FPTR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_FPTR64"},
150 {R_PARISC_PLABEL32, 0, 0, 32, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL32"},
151 {R_PARISC_PLABEL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL21L"},
152 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
153 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
154 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
155
156 {R_PARISC_PLABEL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLABEL14R"},
157 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
158 {R_PARISC_PCREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL64"},
159 {R_PARISC_PCREL22C, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL22C"},
160 {R_PARISC_PCREL22F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL22F"},
161 {R_PARISC_PCREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14WR"},
162 {R_PARISC_PCREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL14DR"},
163 {R_PARISC_PCREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16F"},
164 {R_PARISC_PCREL16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16WF"},
165 {R_PARISC_PCREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PCREL16DF"},
166
167 {R_PARISC_DIR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR64"},
b7263961
JL
168 {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"},
169 {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_NONE"},
be7582f3
JL
170 {R_PARISC_DIR14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14WR"},
171 {R_PARISC_DIR14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR14DR"},
172 {R_PARISC_DIR16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16F"},
173 {R_PARISC_DIR16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16WF"},
174 {R_PARISC_DIR16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DIR16DF"},
175 {R_PARISC_GPREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL64"},
176 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
177
178 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
179 {R_PARISC_DLTREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14WR"},
180 {R_PARISC_DLTREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTREL14DR"},
181 {R_PARISC_GPREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16F"},
182 {R_PARISC_GPREL16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16WF"},
183 {R_PARISC_GPREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_GPREL16DF"},
184 {R_PARISC_LTOFF64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF64"},
185 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
186 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
187 {R_PARISC_DLTIND14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14WR"},
188
189 {R_PARISC_DLTIND14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_DLTIND14DR"},
190 {R_PARISC_LTOFF16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16F"},
b7263961 191 {R_PARISC_LTOFF16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF"},
be7582f3 192 {R_PARISC_LTOFF16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF16DF"},
be7582f3
JL
193 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
194 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
195 {R_PARISC_BASEREL14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BSEREL14WR"},
196 {R_PARISC_BASEREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_BASEREL14DR"},
197 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
198 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
199
200 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
201 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
202 {R_PARISC_SEGREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_SEGREL64"},
203 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
204 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
205 {R_PARISC_PLTOFF14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14WR"},
206 {R_PARISC_PLTOFF14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF14DR"},
207 {R_PARISC_PLTOFF16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16F"},
208 {R_PARISC_PLTOFF16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16WF"},
209 {R_PARISC_PLTOFF16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_PLTOFF16DF"},
210
211 {R_PARISC_LTOFF_FPTR64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
212 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
213 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
214 {R_PARISC_LTOFF_FPTR14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14WR"},
215 {R_PARISC_LTOFF_FPTR14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR14DR"},
216 {R_PARISC_LTOFF_FPTR16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16F"},
217 {R_PARISC_LTOFF_FPTR16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_FPTR16WF"},
218 {R_PARISC_LTOFF_FPTR16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
219 {R_PARISC_COPY, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_COPY"},
220 {R_PARISC_IPLT, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_IPLT"},
221
222 {R_PARISC_EPLT, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_EPLT"},
223 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
224 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
225 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
226 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
227 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
228 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
229 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
230 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
231 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
232
233 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
234 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
235 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
236 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
237 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
238 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
239 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
240 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
241 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
242 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
243
244 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
245 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
246 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
247 {R_PARISC_TPREL32, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL32"},
248 {R_PARISC_TPREL21L, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL21L"},
249 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
250 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
251 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
252 {R_PARISC_TPREL14R, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL14R"},
253 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
254
255 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
256 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
257 {R_PARISC_LTOFF_TP21L, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP21L"},
258 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
259 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
260 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
261 {R_PARISC_LTOFF_TP14R, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
262 {R_PARISC_LTOFF_TP14F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14F"},
263 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
264 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
265
266 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
267 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
268 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
269 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
270 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
271 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
272 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
273 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
274 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
275 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
276
277 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
278 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
279 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
280 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
281 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
282 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
283 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
284 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
285 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
286 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
287
288 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
289 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
290 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
291 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
292 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
293 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
294 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
295 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
296 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
297 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
298
299 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
300 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
301 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
302 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
303 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
304 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
305 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
306 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
307 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
308 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
309
310 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
311 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
312 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
313 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
314 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
315 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
316 {R_PARISC_TPREL64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL64"},
317 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
318 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
319 {R_PARISC_TPREL14WR, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL14WR"},
320
321 {R_PARISC_TPREL14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL14DR"},
322 {R_PARISC_TPREL16F, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL16F"},
323 {R_PARISC_TPREL16WF, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_TPREL16WF"},
324 {R_PARISC_TPREL16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_TPREL16DF"},
325 {R_PARISC_LTOFF_TP64, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP64"},
326 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
327 {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_UNIMPLEMENTED"},
328 {R_PARISC_LTOFF_TP14WR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14WR"},
329 {R_PARISC_LTOFF_TP14DR, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP14DR"},
330 {R_PARISC_LTOFF_TP16F, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_LTOFF_TP16F"},
331
332 {R_PARISC_LTOFF_TP16WF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16WF"},
333 {R_PARISC_LTOFF_TP16DF, 0, 0, 0, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_PARISC_LTOFF_TP16DF"},
9e103c9c
JL
334};
335
6e2bf930
JL
336#define OFFSET_14R_FROM_21L 4
337#define OFFSET_14F_FROM_21L 5
338
9e103c9c
JL
339/* Return one (or more) BFD relocations which implement the base
340 relocation with modifications based on format and field. */
341
342elf_hppa_reloc_type **
343_bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym)
344 bfd *abfd;
345 elf_hppa_reloc_type base_type;
346 int format;
347 int field;
be7582f3
JL
348 int ignore;
349 asymbol *sym;
9e103c9c
JL
350{
351 elf_hppa_reloc_type *finaltype;
352 elf_hppa_reloc_type **final_types;
353
354 /* Allocate slots for the BFD relocation. */
355 final_types = ((elf_hppa_reloc_type **)
356 bfd_alloc (abfd, sizeof (elf_hppa_reloc_type *) * 2));
357 if (final_types == NULL)
358 return NULL;
359
360 /* Allocate space for the relocation itself. */
361 finaltype = ((elf_hppa_reloc_type *)
362 bfd_alloc (abfd, sizeof (elf_hppa_reloc_type)));
363 if (finaltype == NULL)
364 return NULL;
365
366 /* Some reasonable defaults. */
367 final_types[0] = finaltype;
368 final_types[1] = NULL;
369
370#define final_type finaltype[0]
371
372 final_type = base_type;
373
374 /* Just a tangle of nested switch statements to deal with the braindamage
375 that a different field selector means a completely different relocation
376 for PA ELF. */
377 switch (base_type)
378 {
0d571602
JL
379 /* We have been using generic relocation types. However, that may not
380 really make sense. Anyway, we need to support both R_PARISC_DIR64
381 and R_PARISC_DIR32 here. */
382 case R_PARISC_DIR32:
383 case R_PARISC_DIR64:
9e103c9c
JL
384 case R_HPPA_ABS_CALL:
385 switch (format)
386 {
387 case 14:
388 switch (field)
389 {
390 case e_rsel:
391 case e_rrsel:
392 final_type = R_PARISC_DIR14R;
393 break;
394 case e_rtsel:
f31cedf7 395 final_type = R_PARISC_DLTIND14R;
9e103c9c 396 break;
36860900
JL
397 case e_rtpsel:
398 final_type = R_PARISC_LTOFF_FPTR14DR;
399 break;
9e103c9c 400 case e_tsel:
f31cedf7 401 final_type = R_PARISC_DLTIND14F;
9e103c9c
JL
402 break;
403 case e_rpsel:
404 final_type = R_PARISC_PLABEL14R;
405 break;
406 default:
407 return NULL;
408 }
409 break;
410
411 case 17:
412 switch (field)
413 {
414 case e_fsel:
415 final_type = R_PARISC_DIR17F;
416 break;
417 case e_rsel:
418 case e_rrsel:
419 final_type = R_PARISC_DIR17R;
420 break;
421 default:
422 return NULL;
423 }
424 break;
425
426 case 21:
427 switch (field)
428 {
429 case e_lsel:
430 case e_lrsel:
431 final_type = R_PARISC_DIR21L;
432 break;
433 case e_ltsel:
f31cedf7 434 final_type = R_PARISC_DLTIND21L;
9e103c9c 435 break;
36860900
JL
436 case e_ltpsel:
437 final_type = R_PARISC_LTOFF_FPTR21L;
438 break;
9e103c9c
JL
439 case e_lpsel:
440 final_type = R_PARISC_PLABEL21L;
441 break;
442 default:
443 return NULL;
444 }
445 break;
446
447 case 32:
448 switch (field)
449 {
450 case e_fsel:
451 final_type = R_PARISC_DIR32;
432bdd91
JL
452 /* When in 64bit mode, a 32bit relocation is supposed to
453 be a section relative relocation. Dwarf2 (for example)
454 uses 32bit section relative relocations. */
455 if (bfd_get_arch_info (abfd)->bits_per_address != 32)
456 final_type = R_PARISC_SECREL32;
9e103c9c
JL
457 break;
458 case e_psel:
459 final_type = R_PARISC_PLABEL32;
460 break;
461 default:
462 return NULL;
463 }
464 break;
465
6e2bf930
JL
466 case 64:
467 switch (field)
468 {
469 case e_fsel:
470 final_type = R_PARISC_DIR64;
471 break;
472 case e_psel:
36860900
JL
473 final_type = R_PARISC_FPTR64;
474 break;
6e2bf930
JL
475 default:
476 return NULL;
477 }
478 break;
479
9e103c9c
JL
480 default:
481 return NULL;
482 }
483 break;
484
485
486 case R_HPPA_GOTOFF:
487 switch (format)
488 {
489 case 14:
490 switch (field)
491 {
492 case e_rsel:
493 case e_rrsel:
6e2bf930 494 final_type = base_type + OFFSET_14R_FROM_21L;
9e103c9c
JL
495 break;
496 case e_fsel:
6e2bf930 497 final_type = base_type + OFFSET_14F_FROM_21L;
9e103c9c
JL
498 break;
499 default:
500 return NULL;
501 }
502 break;
503
504 case 21:
505 switch (field)
506 {
507 case e_lrsel:
508 case e_lsel:
6e2bf930 509 final_type = base_type;
9e103c9c
JL
510 break;
511 default:
512 return NULL;
513 }
514 break;
515
516 default:
517 return NULL;
518 }
519 break;
520
521
522 case R_HPPA_PCREL_CALL:
523 switch (format)
524 {
525 case 14:
526 switch (field)
527 {
528 case e_rsel:
529 case e_rrsel:
530 final_type = R_PARISC_PCREL14R;
531 break;
532 case e_fsel:
533 final_type = R_PARISC_PCREL14F;
534 break;
535 default:
536 return NULL;
537 }
538 break;
539
540 case 17:
541 switch (field)
542 {
543 case e_rsel:
544 case e_rrsel:
545 final_type = R_PARISC_PCREL17R;
546 break;
547 case e_fsel:
548 final_type = R_PARISC_PCREL17F;
549 break;
550 default:
551 return NULL;
552 }
553 break;
554
341362b5
JL
555 case 22:
556 switch (field)
557 {
558 case e_fsel:
559 final_type = R_PARISC_PCREL22F;
560 break;
561 default:
562 return NULL;
563 }
564 break;
565
9e103c9c
JL
566 case 21:
567 switch (field)
568 {
569 case e_lsel:
570 case e_lrsel:
571 final_type = R_PARISC_PCREL21L;
572 break;
573 default:
574 return NULL;
575 }
576 break;
577
578 default:
579 return NULL;
580 }
581 break;
582
fc91f658
JL
583 case R_PARISC_SEGREL32:
584 case R_PARISC_SEGBASE:
585 /* The defaults are fine for these cases. */
586 break;
587
9e103c9c
JL
588 default:
589 return NULL;
590 }
591
592 return final_types;
593}
594
595/* Translate from an elf into field into a howto relocation pointer. */
596
597static void
598elf_hppa_info_to_howto (abfd, bfd_reloc, elf_reloc)
be7582f3 599 bfd *abfd;
9e103c9c
JL
600 arelent *bfd_reloc;
601 Elf_Internal_Rela *elf_reloc;
602{
603 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
604 < (unsigned int) R_PARISC_UNIMPLEMENTED);
605 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
606}
607
608/* Translate from an elf into field into a howto relocation pointer. */
609
610static void
611elf_hppa_info_to_howto_rel (abfd, bfd_reloc, elf_reloc)
be7582f3 612 bfd *abfd;
9e103c9c
JL
613 arelent *bfd_reloc;
614 Elf_Internal_Rel *elf_reloc;
615{
616 BFD_ASSERT (ELF_R_TYPE(elf_reloc->r_info)
617 < (unsigned int) R_PARISC_UNIMPLEMENTED);
618 bfd_reloc->howto = &elf_hppa_howto_table[ELF_R_TYPE (elf_reloc->r_info)];
619}
620
621/* Return the address of the howto table entry to perform the CODE
622 relocation for an ARCH machine. */
623
624static reloc_howto_type *
625elf_hppa_reloc_type_lookup (abfd, code)
be7582f3 626 bfd *abfd;
9e103c9c
JL
627 bfd_reloc_code_real_type code;
628{
629 if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
630 {
631 BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
632 return &elf_hppa_howto_table[(int) code];
633 }
634 return NULL;
635}
95cbae0b
JL
636
637static void
638elf_hppa_final_write_processing (abfd, linker)
639 bfd *abfd;
be7582f3 640 boolean linker;
95cbae0b
JL
641{
642 int mach = bfd_get_mach (abfd);
643
644 elf_elfheader (abfd)->e_flags &= ~(EF_PARISC_ARCH | EF_PARISC_TRAPNIL
645 | EF_PARISC_EXT | EF_PARISC_LSB
646 | EF_PARISC_WIDE | EF_PARISC_NO_KABP
647 | EF_PARISC_LAZYSWAP);
648
649 if (mach == 10)
650 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_0;
651 else if (mach == 11)
652 elf_elfheader (abfd)->e_flags |= EFA_PARISC_1_1;
653 else if (mach == 20)
3a9acac8
JL
654 elf_elfheader (abfd)->e_flags |= EFA_PARISC_2_0;
655 else if (mach == 25)
656 elf_elfheader (abfd)->e_flags |= EF_PARISC_WIDE | EFA_PARISC_2_0;
95cbae0b 657}
432bdd91
JL
658
659/* Return true if SYM represents a local label symbol. */
660
661static boolean
662elf_hppa_is_local_label_name (abfd, name)
663 bfd *abfd ATTRIBUTE_UNUSED;
664 const char *name;
665{
666 return (name[0] == 'L' && name[1] == '$');
667}
668
052e120f
JL
669/* Set the correct type for an ELF section. We do this by the
670 section name, which is a hack, but ought to work. */
671
672static boolean
673elf_hppa_fake_sections (abfd, hdr, sec)
674 bfd *abfd;
675 Elf64_Internal_Shdr *hdr;
676 asection *sec;
677{
678 register const char *name;
679
680 name = bfd_get_section_name (abfd, sec);
681
682 if (strcmp (name, ".PARISC.unwind") == 0)
683 {
1ca74062 684 int indx;
183df869 685 asection *sec;
052e120f
JL
686 hdr->sh_type = SHT_LOPROC + 1;
687 /* ?!? How are unwinds supposed to work for symbols in arbitrary
688 sections? Or what if we have multiple .text sections in a single
be7582f3 689 .o file? HP really messed up on this one.
052e120f 690
1ca74062
JL
691 Ugh. We can not use elf_section_data (sec)->this_idx at this
692 point because it is not initialized yet.
693
694 So we (gasp) recompute it here. Hopefully nobody ever changes the
695 way sections are numbered in elf.c! */
696 for (sec = abfd->sections, indx = 1; sec; sec = sec->next, indx++)
697 {
698 if (sec->name && strcmp (sec->name, ".text") == 0)
699 {
700 hdr->sh_info = indx;
701 break;
702 }
703 }
be7582f3 704
052e120f
JL
705 /* I have no idea if this is really necessary or what it means. */
706 hdr->sh_entsize = 4;
707 }
708 return true;
709}
710
2eb429af
JL
711/* Hook called by the linker routine which adds symbols from an object
712 file. HP's libraries define symbols with HP specific section
713 indices, which we have to handle. */
714
715static boolean
716elf_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
717 bfd *abfd;
718 struct bfd_link_info *info ATTRIBUTE_UNUSED;
719 const Elf_Internal_Sym *sym;
720 const char **namep ATTRIBUTE_UNUSED;
721 flagword *flagsp ATTRIBUTE_UNUSED;
722 asection **secp;
723 bfd_vma *valp;
724{
725 int index = sym->st_shndx;
be7582f3 726
2eb429af
JL
727 switch (index)
728 {
729 case SHN_PARISC_ANSI_COMMON:
730 *secp = bfd_make_section_old_way (abfd, ".PARISC.ansi.common");
731 (*secp)->flags |= SEC_IS_COMMON;
732 *valp = sym->st_size;
733 break;
be7582f3 734
2eb429af
JL
735 case SHN_PARISC_HUGE_COMMON:
736 *secp = bfd_make_section_old_way (abfd, ".PARISC.huge.common");
737 (*secp)->flags |= SEC_IS_COMMON;
738 *valp = sym->st_size;
739 break;
740 }
741
742 return true;
743}
744
af7dc644
JL
745static boolean
746elf_hppa_unmark_useless_dynamic_symbols (h, data)
747 struct elf_link_hash_entry *h;
748 PTR data;
749{
750 struct bfd_link_info *info = (struct bfd_link_info *)data;
751
752 /* If we are not creating a shared library, and this symbol is
753 referenced by a shared library but is not defined anywhere, then
754 the generic code will warn that it is undefined.
755
756 This behavior is undesirable on HPs since the standard shared
757 libraries contain reerences to undefined symbols.
758
759 So we twiddle the flags associated with such symbols so that they
760 will not trigger the warning. ?!? FIXME. This is horribly fraglie.
761
762 Ultimately we should have better controls over the generic ELF BFD
763 linker code. */
764 if (! info->relocateable
765 && ! (info->shared
766 && !info->no_undefined)
767 && h->root.type == bfd_link_hash_undefined
768 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
769 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
770 {
771 h->elf_link_hash_flags &= ~ELF_LINK_HASH_REF_DYNAMIC;
772 h->elf_link_hash_flags |= 0x8000;
773 }
774
775 return true;
776}
777
778
779static boolean
780elf_hppa_remark_useless_dynamic_symbols (h, data)
781 struct elf_link_hash_entry *h;
782 PTR data;
783{
784 struct bfd_link_info *info = (struct bfd_link_info *)data;
785
786 /* If we are not creating a shared library, and this symbol is
787 referenced by a shared library but is not defined anywhere, then
788 the generic code will warn that it is undefined.
789
790 This behavior is undesirable on HPs since the standard shared
791 libraries contain reerences to undefined symbols.
792
793 So we twiddle the flags associated with such symbols so that they
228d307f 794 will not trigger the warning. ?!? FIXME. This is horribly fragile.
af7dc644
JL
795
796 Ultimately we should have better controls over the generic ELF BFD
797 linker code. */
798 if (! info->relocateable
799 && ! (info->shared
800 && !info->no_undefined)
801 && h->root.type == bfd_link_hash_undefined
802 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
803 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
804 && (h->elf_link_hash_flags & 0x8000) != 0)
805 {
806 h->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC;
807 h->elf_link_hash_flags &= ~0x8000;
808 }
809
810 return true;
811}
812
2eb429af
JL
813/* Called after we have seen all the input files/sections, but before
814 final symbol resolution and section placement has been determined.
815
816 We use this hook to (possibly) provide a value for __gp, then we
817 fall back to the generic ELF final link routine. */
818
819static boolean
820elf_hppa_final_link (abfd, info)
821 bfd *abfd;
822 struct bfd_link_info *info;
823{
af7dc644
JL
824 boolean retval;
825
2eb429af
JL
826 /* Make sure we've got ourselves a suitable __gp value. */
827 if (!info->relocateable)
828 {
2eb429af
JL
829 struct elf_link_hash_entry *gp;
830 bfd_vma gp_val = 0;
831 asection *os;
832
be7582f3
JL
833 /* Find the .opd section. __gp's value should be the same as
834 the start of .PARISC.global section. */
2eb429af
JL
835 for (os = abfd->sections; os ; os = os->next)
836 {
2eb429af
JL
837 /* This would be cleaner if we marked sections with an attribute
838 indicating they are short sections. */
be7582f3
JL
839 if (strcmp (os->name, ".PARISC.global") == 0)
840 break;
2eb429af
JL
841 }
842
be7582f3 843 BFD_ASSERT (os != NULL)
2eb429af 844
be7582f3
JL
845 gp_val = (os->output_section->vma + os->output_offset);
846
847 gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", true,
848 true, false);
849 gp->root.type = bfd_link_hash_defined;
850 gp->root.u.def.section = os;
851 gp->root.u.def.value = 0;
2eb429af
JL
852 _bfd_set_gp_value (abfd, gp_val);
853 }
854
af7dc644
JL
855 /* HP's shared libraries have references to symbols that are not
856 defined anywhere. The generic ELF BFD linker code will complaim
857 about such symbols.
858
859 So we detect the losing case and arrange for the flags on the symbol
860 to indicate that it was never referenced. This keeps the generic
861 ELF BFD link code happy and appears to not create any secondary
862 problems. Ultimately we need a way to control the behavior of the
863 generic ELF BFD link code better. */
864 elf_link_hash_traverse (elf_hash_table (info),
865 elf_hppa_unmark_useless_dynamic_symbols,
866 info);
867
2eb429af 868 /* Invoke the regular ELF backend linker to do all the work. */
af7dc644
JL
869 retval = bfd_elf_bfd_final_link (abfd, info);
870
871 elf_link_hash_traverse (elf_hash_table (info),
872 elf_hppa_remark_useless_dynamic_symbols,
873 info);
874
875 return retval;
2eb429af
JL
876}
877
878/* Relocate an HPPA ELF section. */
879
880static boolean
881elf_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
882 contents, relocs, local_syms, local_sections)
883 bfd *output_bfd;
884 struct bfd_link_info *info;
885 bfd *input_bfd;
886 asection *input_section;
887 bfd_byte *contents;
888 Elf_Internal_Rela *relocs;
889 Elf_Internal_Sym *local_syms;
890 asection **local_sections;
891{
892 Elf_Internal_Shdr *symtab_hdr;
893 Elf_Internal_Rela *rel;
894 Elf_Internal_Rela *relend;
be7582f3 895 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
2eb429af
JL
896
897 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
898
899 rel = relocs;
900 relend = relocs + input_section->reloc_count;
901 for (; rel < relend; rel++)
902 {
903 int r_type;
b2e311df 904 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
2eb429af
JL
905 unsigned long r_symndx;
906 struct elf_link_hash_entry *h;
907 Elf_Internal_Sym *sym;
908 asection *sym_sec;
909 bfd_vma relocation;
910 bfd_reloc_status_type r;
911 const char *sym_name;
be7582f3
JL
912 char *dyn_name;
913 char *dynh_buf = NULL;
914 size_t dynh_buflen = 0;
915 struct elf64_hppa_dyn_hash_entry *dyn_h = NULL;
2eb429af
JL
916
917 r_type = ELF_R_TYPE (rel->r_info);
918 if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
919 {
920 bfd_set_error (bfd_error_bad_value);
921 return false;
922 }
2eb429af
JL
923
924 r_symndx = ELF_R_SYM (rel->r_info);
925
926 if (info->relocateable)
927 {
928 /* This is a relocateable link. We don't have to change
929 anything, unless the reloc is against a section symbol,
930 in which case we have to adjust according to where the
931 section symbol winds up in the output section. */
932 if (r_symndx < symtab_hdr->sh_info)
933 {
934 sym = local_syms + r_symndx;
935 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
936 {
937 sym_sec = local_sections[r_symndx];
938 rel->r_addend += sym_sec->output_offset;
939 }
940 }
941
942 continue;
943 }
944
945 /* This is a final link. */
946 h = NULL;
947 sym = NULL;
948 sym_sec = NULL;
949 if (r_symndx < symtab_hdr->sh_info)
950 {
be7582f3 951 /* This is a local symbol. */
2eb429af
JL
952 sym = local_syms + r_symndx;
953 sym_sec = local_sections[r_symndx];
954 relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION
955 ? 0 : sym->st_value)
956 + sym_sec->output_offset
957 + sym_sec->output_section->vma);
be7582f3
JL
958
959 /* If this symbol has an entry in the PA64 dynamic hash
960 table, then get it. */
961 dyn_name = get_dyn_name (input_bfd, h, rel,
962 &dynh_buf, &dynh_buflen);
963 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
964 dyn_name, false, false);
965
2eb429af
JL
966 }
967 else
968 {
be7582f3 969 /* This is not a local symbol. */
2eb429af
JL
970 long indx;
971
972 indx = r_symndx - symtab_hdr->sh_info;
973 h = elf_sym_hashes (input_bfd)[indx];
974 while (h->root.type == bfd_link_hash_indirect
975 || h->root.type == bfd_link_hash_warning)
976 h = (struct elf_link_hash_entry *) h->root.u.i.link;
977 if (h->root.type == bfd_link_hash_defined
978 || h->root.type == bfd_link_hash_defweak)
979 {
980 sym_sec = h->root.u.def.section;
be7582f3
JL
981
982
983 /* If this symbol has an entry in the PA64 dynamic hash
984 table, then get it. */
985 dyn_name = get_dyn_name (input_bfd, h, rel,
986 &dynh_buf, &dynh_buflen);
987 dyn_h = elf64_hppa_dyn_hash_lookup (&hppa_info->dyn_hash_table,
988 dyn_name, false, false);
989
990 /* If we have a relocation against a symbol defined in a
991 shared library and we have not created an entry in the
992 PA64 dynamic symbol hash table for it, then we lose. */
993 if (sym_sec->output_section == NULL && dyn_h == NULL)
994 {
995 (*_bfd_error_handler)
996 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
997 bfd_get_filename (input_bfd), h->root.root.string,
998 bfd_get_section_name (input_bfd, input_section));
999 relocation = 0;
1000 }
1001 else if (sym_sec->output_section)
1002 relocation = (h->root.u.def.value
1003 + sym_sec->output_offset
1004 + sym_sec->output_section->vma);
1005 /* Value will be provided via one of the offsets in the
1006 dyn_h hash table entry. */
1007 else
1008 relocation = 0;
2eb429af
JL
1009 }
1010 else if (h->root.type == bfd_link_hash_undefweak)
1011 relocation = 0;
1012 else
1013 {
1014 if (!((*info->callbacks->undefined_symbol)
1015 (info, h->root.root.string, input_bfd,
1016 input_section, rel->r_offset)))
1017 return false;
1018 break;
1019 }
1020 }
1021
1022 if (h != NULL)
1023 sym_name = h->root.root.string;
1024 else
1025 {
1026 sym_name = bfd_elf_string_from_elf_section (input_bfd,
1027 symtab_hdr->sh_link,
1028 sym->st_name);
1029 if (sym_name == NULL)
1030 return false;
1031 if (*sym_name == '\0')
1032 sym_name = bfd_section_name (input_bfd, sym_sec);
1033 }
1034
be7582f3 1035 r = elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
2eb429af 1036 input_section, contents,
be7582f3
JL
1037 relocation, info, sym_sec,
1038 h, dyn_h);
2eb429af
JL
1039
1040 if (r != bfd_reloc_ok)
1041 {
1042 switch (r)
1043 {
1044 default:
1045 abort ();
1046 case bfd_reloc_overflow:
1047 {
1048 if (!((*info->callbacks->reloc_overflow)
1049 (info, sym_name, howto->name, (bfd_vma) 0,
1050 input_bfd, input_section, rel->r_offset)))
1051 return false;
1052 }
1053 break;
1054 }
1055 }
1056 }
1057 return true;
1058}
1059
1060
be7582f3
JL
1061/* Compute the value for a relocation (REL) during a final link stage,
1062 then insert the value into the proper location in CONTENTS.
1063
1064 VALUE is a tentative value for the relocation and may be overridden
1065 and modified here based on the specific relocation to be performed.
1066
1067 For example we do conversions for PC-relative branches in this routine
1068 or redirection of calls to external routines to stubs.
1069
1070 The work of actually applying the relocation is left to a helper
1071 routine in an attempt to reduce the complexity and size of this
1072 function. */
2eb429af
JL
1073
1074static bfd_reloc_status_type
be7582f3
JL
1075elf_hppa_final_link_relocate (rel, input_bfd, output_bfd,
1076 input_section, contents, value,
1077 info, sym_sec, h, dyn_h)
1078 Elf_Internal_Rela *rel;
2eb429af 1079 bfd *input_bfd;
be7582f3 1080 bfd *output_bfd;
2eb429af
JL
1081 asection *input_section;
1082 bfd_byte *contents;
2eb429af 1083 bfd_vma value;
2eb429af
JL
1084 struct bfd_link_info *info;
1085 asection *sym_sec;
be7582f3
JL
1086 struct elf_link_hash_entry *h;
1087 struct elf64_hppa_dyn_hash_entry *dyn_h;
2eb429af
JL
1088{
1089 unsigned long insn;
be7582f3
JL
1090 bfd_vma offset = rel->r_offset;
1091 bfd_vma addend = rel->r_addend;
1092 reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
2eb429af 1093 unsigned long r_type = howto->type;
2eb429af
JL
1094 unsigned long r_field = e_fsel;
1095 bfd_byte *hit_data = contents + offset;
be7582f3 1096 struct elf64_hppa_link_hash_table *hppa_info = elf64_hppa_hash_table (info);
2eb429af
JL
1097
1098 insn = bfd_get_32 (input_bfd, hit_data);
1099
1100/* For reference here a quick summary of the relocations found in the
1101 HPUX 11.00 PA64 .o and .a files, but not yet implemented. This is mostly
1102 a guide to help prioritize what relocation support is worked on first.
1103 The list will be deleted eventually.
1104
b1d55905 1105 27210 R_PARISC_SEGREL32 */
2eb429af
JL
1106
1107 switch (r_type)
1108 {
1109 case R_PARISC_NONE:
1110 break;
1111
571047ad 1112 /* Random PC relative relocs. */
b233eaab
JL
1113 case R_PARISC_PCREL21L:
1114 case R_PARISC_PCREL14R:
1115 case R_PARISC_PCREL14F:
571047ad
JL
1116 case R_PARISC_PCREL14WR:
1117 case R_PARISC_PCREL14DR:
1118 case R_PARISC_PCREL16F:
1119 case R_PARISC_PCREL16WF:
1120 case R_PARISC_PCREL16DF:
1121 {
1122 if (r_type == R_PARISC_PCREL21L)
1123 r_field = e_lsel;
1124 else if (r_type == R_PARISC_PCREL14F
1125 || r_type == R_PARISC_PCREL16F
1126 || r_type == R_PARISC_PCREL16WF
1127 || r_type == R_PARISC_PCREL16DF)
1128 r_field = e_fsel;
1129 else
1130 r_field = e_rsel;
1131
1132 /* If this is a call to a function defined in another dynamic
1133 library, then redirect the call to the local stub for this
1134 function. */
1135 if (sym_sec->output_section == NULL)
1136 value = dyn_h->stub_offset;
1137
1138 /* Turn VALUE into a proper PC relative address. */
1139 value -= (offset + input_section->output_offset
1140 + input_section->output_section->vma);
1141
1142 /* Adjust for any field selectors. */
1143 value = hppa_field_adjust (value, -8 + addend, r_field);
1144
1145 /* Apply the relocation to the given instruction. */
1146 insn = elf_hppa_relocate_insn (insn, value, r_type);
1147 break;
1148 }
1149
be7582f3
JL
1150 /* Basic function call support. I'm not entirely sure if PCREL14F is
1151 actually needed or even handled correctly.
1152
1153 Note for a call to a function defined in another dynamic library
1154 we want to redirect the call to a stub. */
2eb429af
JL
1155 case R_PARISC_PCREL22F:
1156 case R_PARISC_PCREL17F:
571047ad
JL
1157 case R_PARISC_PCREL22C:
1158 case R_PARISC_PCREL17C:
1159 case R_PARISC_PCREL17R:
2eb429af 1160 {
571047ad
JL
1161 if (r_type == R_PARISC_PCREL17R)
1162 r_field = e_rsel;
1163 else
1164 r_field = e_fsel;
1165
be7582f3
JL
1166 /* If this is a call to a function defined in another dynamic
1167 library, then redirect the call to the local stub for this
1168 function. */
1169 if (sym_sec->output_section == NULL)
6a0b9871
JL
1170 value = (dyn_h->stub_offset + hppa_info->stub_sec->output_offset
1171 + hppa_info->stub_sec->output_section->vma);
be7582f3
JL
1172
1173 /* Turn VALUE into a proper PC relative address. */
1174 value -= (offset + input_section->output_offset
1175 + input_section->output_section->vma);
1176
1177 /* Adjust for any field selectors. */
571047ad 1178 value = hppa_field_adjust (value, -8 + addend, e_fsel);
2eb429af 1179
be7582f3
JL
1180 /* All branches are implicitly shifted by 2 places. */
1181 value >>= 2;
2eb429af 1182
be7582f3
JL
1183 /* Apply the relocation to the given instruction. */
1184 insn = elf_hppa_relocate_insn (insn, value, r_type);
2eb429af
JL
1185 break;
1186 }
1187
be7582f3
JL
1188 /* Indirect references to data through the DLT. */
1189 case R_PARISC_DLTIND14R:
571047ad 1190 case R_PARISC_DLTIND14F:
be7582f3
JL
1191 case R_PARISC_DLTIND14DR:
1192 case R_PARISC_DLTIND14WR:
1193 case R_PARISC_DLTIND21L:
e5bb3efc
JL
1194 case R_PARISC_LTOFF_FPTR14R:
1195 case R_PARISC_LTOFF_FPTR14DR:
1196 case R_PARISC_LTOFF_FPTR14WR:
1197 case R_PARISC_LTOFF_FPTR21L:
1198 case R_PARISC_LTOFF_FPTR16F:
1199 case R_PARISC_LTOFF_FPTR16WF:
1200 case R_PARISC_LTOFF_FPTR16DF:
b233eaab
JL
1201 case R_PARISC_LTOFF_TP21L:
1202 case R_PARISC_LTOFF_TP14R:
1203 case R_PARISC_LTOFF_TP14F:
1204 case R_PARISC_LTOFF_TP14WR:
1205 case R_PARISC_LTOFF_TP14DR:
1206 case R_PARISC_LTOFF_TP16F:
1207 case R_PARISC_LTOFF_TP16WF:
1208 case R_PARISC_LTOFF_TP16DF:
b7263961
JL
1209 case R_PARISC_LTOFF16F:
1210 case R_PARISC_LTOFF16WF:
1211 case R_PARISC_LTOFF16DF:
c8933571 1212 {
6a0b9871
JL
1213 /* If this relocation was against a local symbol, then we still
1214 have not set up the DLT entry (it's not convienent to do so
1215 in the "finalize_dlt" routine because it is difficult to get
1216 to the local symbol's value).
1217
1218 So, if this is a local symbol (h == NULL), then we need to
e48c661e
JL
1219 fill in its DLT entry.
1220
1221 Similarly we may still need to set up an entry in .opd for
1222 a local function which had its address taken. */
6a0b9871
JL
1223 if (dyn_h->h == NULL)
1224 {
1225 bfd_put_64 (hppa_info->dlt_sec->owner,
1226 value,
1227 hppa_info->dlt_sec->contents + dyn_h->dlt_offset);
e48c661e
JL
1228
1229 /* Now handle .opd creation if needed. */
1230 if (r_type == R_PARISC_LTOFF_FPTR14R
1231 || r_type == R_PARISC_LTOFF_FPTR14DR
1232 || r_type == R_PARISC_LTOFF_FPTR14WR
1233 || r_type == R_PARISC_LTOFF_FPTR21L
1234 || r_type == R_PARISC_LTOFF_FPTR16F
1235 || r_type == R_PARISC_LTOFF_FPTR16WF
1236 || r_type == R_PARISC_LTOFF_FPTR16DF)
1237 {
1238 /* The first two words of an .opd entry are zero. */
1239 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset,
1240 0, 16);
1241
1242 /* The next word is the address of the function. */
1243 bfd_put_64 (hppa_info->opd_sec->owner, value,
1244 (hppa_info->opd_sec->contents
1245 + dyn_h->opd_offset + 16));
1246
1247 /* The last word is our local __gp value. */
1248 value = _bfd_get_gp_value
1249 (hppa_info->opd_sec->output_section->owner);
1250 bfd_put_64 (hppa_info->opd_sec->owner, value,
1251 (hppa_info->opd_sec->contents
1252 + dyn_h->opd_offset + 24));
1253 }
6a0b9871
JL
1254 }
1255
be7582f3
JL
1256 /* We want the value of the DLT offset for this symbol, not
1257 the symbol's actual address. */
1258 value = dyn_h->dlt_offset + hppa_info->dlt_sec->output_offset;
1259
1260 /* All DLTIND relocations are basically the same at this point,
1261 except that we need different field selectors for the 21bit
1262 version vs the 14bit versions. */
e5bb3efc 1263 if (r_type == R_PARISC_DLTIND21L
b233eaab
JL
1264 || r_type == R_PARISC_LTOFF_FPTR21L
1265 || r_type == R_PARISC_LTOFF_TP21L)
be7582f3 1266 value = hppa_field_adjust (value, addend, e_lrsel);
571047ad
JL
1267 else if (r_type == R_PARISC_DLTIND14F
1268 || r_type == R_PARISC_LTOFF_FPTR16F
1269 || r_type == R_PARISC_LTOFF_FPTR16WF
b233eaab 1270 || r_type == R_PARISC_LTOFF_FPTR16DF
b7263961
JL
1271 || r_type == R_PARISC_LTOFF16F
1272 || r_type == R_PARISC_LTOFF16DF
1273 || r_type == R_PARISC_LTOFF16WF
b233eaab
JL
1274 || r_type == R_PARISC_LTOFF_TP16F
1275 || r_type == R_PARISC_LTOFF_TP16WF
1276 || r_type == R_PARISC_LTOFF_TP16DF)
e5bb3efc 1277 value = hppa_field_adjust (value, addend, e_fsel);
be7582f3
JL
1278 else
1279 value = hppa_field_adjust (value, addend, e_rrsel);
1280
1281 insn = elf_hppa_relocate_insn (insn, value, r_type);
c8933571
JL
1282 break;
1283 }
1284
be7582f3 1285 case R_PARISC_DLTREL14R:
571047ad 1286 case R_PARISC_DLTREL14F:
be7582f3
JL
1287 case R_PARISC_DLTREL14DR:
1288 case R_PARISC_DLTREL14WR:
c8933571 1289 case R_PARISC_DLTREL21L:
6849fb4d
JL
1290 case R_PARISC_DPREL21L:
1291 case R_PARISC_DPREL14WR:
1292 case R_PARISC_DPREL14DR:
1293 case R_PARISC_DPREL14R:
1294 case R_PARISC_DPREL14F:
1295 case R_PARISC_GPREL16F:
1296 case R_PARISC_GPREL16WF:
1297 case R_PARISC_GPREL16DF:
c8933571 1298 {
be7582f3
JL
1299 /* Subtract out the global pointer value to make value a DLT
1300 relative address. */
1301 value -= _bfd_get_gp_value (output_bfd);
1302
1303 /* All DLTREL relocations are basically the same at this point,
1304 except that we need different field selectors for the 21bit
1305 version vs the 14bit versions. */
6849fb4d
JL
1306 if (r_type == R_PARISC_DLTREL21L
1307 || r_type == R_PARISC_DPREL21L)
be7582f3 1308 value = hppa_field_adjust (value, addend, e_lrsel);
6849fb4d
JL
1309 else if (r_type == R_PARISC_DLTREL14F
1310 || r_type == R_PARISC_DPREL14F
1311 || r_type == R_PARISC_GPREL16F
1312 || r_type == R_PARISC_GPREL16WF
1313 || r_type == R_PARISC_GPREL16DF)
571047ad 1314 value = hppa_field_adjust (value, addend, e_fsel);
be7582f3
JL
1315 else
1316 value = hppa_field_adjust (value, addend, e_rrsel);
1317
1318 insn = elf_hppa_relocate_insn (insn, value, r_type);
c8933571
JL
1319 break;
1320 }
1321
b7263961
JL
1322 case R_PARISC_DIR21L:
1323 case R_PARISC_DIR17R:
1324 case R_PARISC_DIR17F:
1325 case R_PARISC_DIR14R:
1326 case R_PARISC_DIR14WR:
1327 case R_PARISC_DIR14DR:
1328 case R_PARISC_DIR16F:
1329 case R_PARISC_DIR16WF:
1330 case R_PARISC_DIR16DF:
1331 {
1332 /* All DIR relocations are basically the same at this point,
1333 except that we need different field selectors for the 21bit
1334 version vs the 14bit versions. */
1335 if (r_type == R_PARISC_DIR21L)
1336 value = hppa_field_adjust (value, addend, e_lrsel);
1337 else if (r_type == R_PARISC_DIR17F
1338 || r_type == R_PARISC_DIR16F
1339 || r_type == R_PARISC_DIR16WF
1340 || r_type == R_PARISC_DIR16DF)
1341 value = hppa_field_adjust (value, addend, e_fsel);
1342 else
1343 value = hppa_field_adjust (value, addend, e_rrsel);
1344
1345 insn = elf_hppa_relocate_insn (insn, value, r_type);
1346 break;
1347 }
1348
8267b155
JL
1349 case R_PARISC_PLTOFF21L:
1350 case R_PARISC_PLTOFF14R:
1351 case R_PARISC_PLTOFF14F:
1352 case R_PARISC_PLTOFF14WR:
1353 case R_PARISC_PLTOFF14DR:
1354 case R_PARISC_PLTOFF16F:
1355 case R_PARISC_PLTOFF16WF:
1356 case R_PARISC_PLTOFF16DF:
1357 {
1358 /* We want the value of the PLT offset for this symbol, not
1359 the symbol's actual address. */
1360 value = dyn_h->plt_offset + hppa_info->plt_sec->output_offset;
1361
1362 /* All PLTOFF relocations are basically the same at this point,
1363 except that we need different field selectors for the 21bit
1364 version vs the 14bit versions. */
1365 if (r_type == R_PARISC_PLTOFF21L)
1366 value = hppa_field_adjust (value, addend, e_lrsel);
1367 else if (r_type == R_PARISC_PLTOFF14F
1368 || r_type == R_PARISC_PLTOFF16F
1369 || r_type == R_PARISC_PLTOFF16WF
1370 || r_type == R_PARISC_PLTOFF16DF)
1371 value = hppa_field_adjust (value, addend, e_fsel);
1372 else
1373 value = hppa_field_adjust (value, addend, e_rrsel);
1374
1375 insn = elf_hppa_relocate_insn (insn, value, r_type);
1376 break;
1377 }
1378
e5bb3efc
JL
1379 case R_PARISC_LTOFF_FPTR32:
1380 {
e48c661e
JL
1381 /* We may still need to create the FPTR itself if it was for
1382 a local symbol. */
1383 if (dyn_h->h == NULL)
1384 {
1385 /* The first two words of an .opd entry are zero. */
1386 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1387
1388 /* The next word is the address of the function. */
1389 bfd_put_64 (hppa_info->opd_sec->owner, value,
1390 (hppa_info->opd_sec->contents
1391 + dyn_h->opd_offset + 16));
1392
1393 /* The last word is our local __gp value. */
1394 value = _bfd_get_gp_value
1395 (hppa_info->opd_sec->output_section->owner);
1396 bfd_put_64 (hppa_info->opd_sec->owner, value,
1397 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1398 }
1399
e5bb3efc
JL
1400 /* We want the value of the DLT offset for this symbol, not
1401 the symbol's actual address. */
1402 value = dyn_h->dlt_offset + hppa_info->dlt_sec->output_offset;
1403 bfd_put_32 (input_bfd, value, hit_data);
1404 return bfd_reloc_ok;
1405 }
1406
e5bb3efc 1407 case R_PARISC_LTOFF_FPTR64:
b233eaab 1408 case R_PARISC_LTOFF_TP64:
e5bb3efc 1409 {
e48c661e
JL
1410 /* We may still need to create the FPTR itself if it was for
1411 a local symbol. */
1412 if (dyn_h->h == NULL && r_type == R_PARISC_LTOFF_FPTR64)
1413 {
1414 /* The first two words of an .opd entry are zero. */
1415 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1416
1417 /* The next word is the address of the function. */
1418 bfd_put_64 (hppa_info->opd_sec->owner, value,
1419 (hppa_info->opd_sec->contents
1420 + dyn_h->opd_offset + 16));
1421
1422 /* The last word is our local __gp value. */
1423 value = _bfd_get_gp_value
1424 (hppa_info->opd_sec->output_section->owner);
1425 bfd_put_64 (hppa_info->opd_sec->owner, value,
1426 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1427 }
1428
e5bb3efc
JL
1429 /* We want the value of the DLT offset for this symbol, not
1430 the symbol's actual address. */
1431 value = dyn_h->dlt_offset + hppa_info->dlt_sec->output_offset;
1432 bfd_put_64 (input_bfd, value, hit_data);
1433 return bfd_reloc_ok;
1434 }
1435
1436 case R_PARISC_DIR32:
571047ad 1437 bfd_put_32 (input_bfd, value + addend, hit_data);
e5bb3efc
JL
1438 return bfd_reloc_ok;
1439
1440 case R_PARISC_DIR64:
571047ad 1441 bfd_put_64 (input_bfd, value + addend, hit_data);
e5bb3efc
JL
1442 return bfd_reloc_ok;
1443
6849fb4d
JL
1444 case R_PARISC_GPREL64:
1445 /* Subtract out the global pointer value to make value a DLT
1446 relative address. */
1447 value -= _bfd_get_gp_value (output_bfd);
1448 value += addend;
1449
1450 bfd_put_64 (input_bfd, value + addend, hit_data);
1451 return bfd_reloc_ok;
1452
b7263961
JL
1453 case R_PARISC_LTOFF64:
1454 /* We want the value of the DLT offset for this symbol, not
1455 the symbol's actual address. */
1456 value = dyn_h->dlt_offset + hppa_info->dlt_sec->output_offset;
1457
1458 bfd_put_64 (input_bfd, value + addend, hit_data);
1459 return bfd_reloc_ok;
1460
571047ad
JL
1461 case R_PARISC_PCREL32:
1462 {
1463 /* If this is a call to a function defined in another dynamic
1464 library, then redirect the call to the local stub for this
1465 function. */
1466 if (sym_sec->output_section == NULL)
1467 value = dyn_h->stub_offset;
1468
1469 /* Turn VALUE into a proper PC relative address. */
1470 value -= (offset + input_section->output_offset
1471 + input_section->output_section->vma);
1472
b233eaab 1473 value += addend;
571047ad
JL
1474 value -= 8;
1475 bfd_put_64 (input_bfd, value, hit_data);
1476 return bfd_reloc_ok;
1477 }
1478
1479 case R_PARISC_PCREL64:
1480 {
1481 /* If this is a call to a function defined in another dynamic
1482 library, then redirect the call to the local stub for this
1483 function. */
1484 if (sym_sec->output_section == NULL)
1485 value = dyn_h->stub_offset;
1486
1487 /* Turn VALUE into a proper PC relative address. */
1488 value -= (offset + input_section->output_offset
1489 + input_section->output_section->vma);
1490
b233eaab 1491 value += addend;
571047ad
JL
1492 value -= 8;
1493 bfd_put_64 (input_bfd, value, hit_data);
1494 return bfd_reloc_ok;
1495 }
1496
1497
e5bb3efc 1498 case R_PARISC_FPTR64:
e48c661e
JL
1499 {
1500 /* We may still need to create the FPTR itself if it was for
1501 a local symbol. */
1502 if (dyn_h->h == NULL)
1503 {
1504 /* The first two words of an .opd entry are zero. */
1505 memset (hppa_info->opd_sec->contents + dyn_h->opd_offset, 0, 16);
1506
1507 /* The next word is the address of the function. */
1508 bfd_put_64 (hppa_info->opd_sec->owner, value,
1509 (hppa_info->opd_sec->contents
1510 + dyn_h->opd_offset + 16));
1511
1512 /* The last word is our local __gp value. */
1513 value = _bfd_get_gp_value
1514 (hppa_info->opd_sec->output_section->owner);
1515 bfd_put_64 (hppa_info->opd_sec->owner, value,
1516 hppa_info->opd_sec->contents + dyn_h->opd_offset + 24);
1517 }
1518
1519 /* We want the value of the OPD offset for this symbol, not
1520 the symbol's actual address. */
1521 value = (dyn_h->opd_offset
1522 + hppa_info->opd_sec->output_offset
1523 + hppa_info->opd_sec->output_section->vma);
6a0b9871 1524
e48c661e
JL
1525 bfd_put_64 (input_bfd, value + addend, hit_data);
1526 return bfd_reloc_ok;
1527 }
e5bb3efc 1528
228d307f
JL
1529 case R_PARISC_SECREL32:
1530 bfd_put_32 (input_bfd,
1531 (value + addend
1532 - sym_sec->output_section->vma),
1533 hit_data);
1534 return bfd_reloc_ok;
1535
1536 case R_PARISC_SEGREL32:
1537 return bfd_reloc_ok;
1538
2eb429af
JL
1539 /* Something we don't know how to handle. */
1540 default:
228d307f 1541 return bfd_reloc_notsupported;
2eb429af
JL
1542 }
1543
1544 /* Update the instruction word. */
1545 bfd_put_32 (input_bfd, insn, hit_data);
1546 return (bfd_reloc_ok);
1547}
1548
be7582f3
JL
1549/* Relocate the given INSN. VALUE should be the actual value we want
1550 to insert into the instruction, ie by this point we should not be
1551 concerned with computing an offset relative to the DLT, PC, etc.
1552 Instead this routine is meant to handle the bit manipulations needed
1553 to insert the relocation into the given instruction. */
2eb429af
JL
1554
1555static unsigned long
be7582f3 1556elf_hppa_relocate_insn (insn, sym_value, r_type)
2eb429af 1557 unsigned long insn;
2eb429af 1558 long sym_value;
c8933571 1559 unsigned long r_type;
2eb429af 1560{
c8933571 1561 switch (r_type)
2eb429af 1562 {
be7582f3
JL
1563 /* This is any 22bit branch. In PA2.0 syntax it corresponds to
1564 the "B" instruction. */
c8933571 1565 case R_PARISC_PCREL22F:
571047ad 1566 case R_PARISC_PCREL22C:
be7582f3
JL
1567 {
1568 unsigned int w3, w2, w1, w;
2eb429af 1569
be7582f3
JL
1570 /* These are 22 bit branches. Mask off bits we do not care
1571 about. */
1572 sym_value &= 0x3fffff;
2eb429af 1573
be7582f3
JL
1574 /* Now extract the W1, W2, W3 and W fields from the value. */
1575 dis_assemble_22 (sym_value, &w3, &w1, &w2, &w);
2eb429af 1576
be7582f3
JL
1577 /* Mask out bits for the value in the instruction. */
1578 insn &= 0xfc00e002;
2eb429af 1579
be7582f3
JL
1580 /* Insert the bits for the W1, W2 and W fields into the
1581 instruction. */
1582 insn |= (w3 << 21) | (w2 << 2) | (w1 << 16) | w;
1583 return insn;
1584 }
2eb429af 1585
be7582f3
JL
1586 /* This is any 17bit branch. In PA2.0 syntax it also corresponds to
1587 the "B" instruction as well as BE. */
1588 case R_PARISC_PCREL17F:
c8933571 1589 case R_PARISC_DIR17F:
b7263961 1590 case R_PARISC_DIR17R:
571047ad
JL
1591 case R_PARISC_PCREL17C:
1592 case R_PARISC_PCREL17R:
2eb429af
JL
1593 {
1594 unsigned int w2, w1, w;
1595
2eb429af
JL
1596 /* These are 17 bit branches. Mask off bits we do not care
1597 about. */
1598 sym_value &= 0x1ffff;
1599
1600 /* Now extract the W1, W2 and W fields from the value. */
1601 dis_assemble_17 (sym_value, &w1, &w2, &w);
1602
1603 /* Mask out bits for the value in the instruction. */
1604 insn &= 0xffe0e002;
1605
1606 /* Insert the bits for the W1, W2 and W fields into the
1607 instruction. */
1608 insn |= (w2 << 2) | (w1 << 16) | w;
1609 return insn;
1610 }
1611
be7582f3 1612 /* ADDIL or LDIL instructions. */
c8933571 1613 case R_PARISC_DLTREL21L:
be7582f3 1614 case R_PARISC_DLTIND21L:
e5bb3efc 1615 case R_PARISC_LTOFF_FPTR21L:
b233eaab
JL
1616 case R_PARISC_PCREL21L:
1617 case R_PARISC_LTOFF_TP21L:
6849fb4d 1618 case R_PARISC_DPREL21L:
8267b155 1619 case R_PARISC_PLTOFF21L:
b7263961 1620 case R_PARISC_DIR21L:
c8933571
JL
1621 {
1622 int w;
1623
c8933571
JL
1624 /* Mask off bits in INSN we do not want. */
1625 insn &= 0xffe00000;
1626
1627 /* Turn the 21bit value into the proper format. */
1628 dis_assemble_21 (sym_value, &w);
1629
1630 /* And insert the proper bits into INSN. */
1631 return insn | w;
1632 }
be7582f3
JL
1633
1634 /* LDO and integer loads/stores with 14bit displacements. */
c8933571 1635 case R_PARISC_DLTREL14R:
084d930b 1636 case R_PARISC_DLTREL14F:
be7582f3
JL
1637 case R_PARISC_DLTIND14R:
1638 case R_PARISC_DLTIND14F:
e5bb3efc
JL
1639 case R_PARISC_LTOFF_FPTR14R:
1640 case R_PARISC_LTOFF_FPTR16F:
b233eaab 1641 case R_PARISC_PCREL14R:
571047ad
JL
1642 case R_PARISC_PCREL14F:
1643 case R_PARISC_PCREL16F:
b233eaab
JL
1644 case R_PARISC_LTOFF_TP14R:
1645 case R_PARISC_LTOFF_TP14F:
1646 case R_PARISC_LTOFF_TP16F:
6849fb4d
JL
1647 case R_PARISC_DPREL14R:
1648 case R_PARISC_DPREL14F:
1649 case R_PARISC_GPREL16F:
8267b155
JL
1650 case R_PARISC_PLTOFF14R:
1651 case R_PARISC_PLTOFF14F:
1652 case R_PARISC_PLTOFF16F:
b7263961
JL
1653 case R_PARISC_DIR14R:
1654 case R_PARISC_DIR16F:
1655 case R_PARISC_LTOFF16F:
c8933571
JL
1656 {
1657 int w;
1658
c8933571
JL
1659 /* Mask off bits in INSN we do not want. */
1660 insn &= 0xffffc000;
1661
1662 /* Turn the 14bit value into the proper format. */
1663 low_sign_unext (sym_value, 14, &w);
1664
1665 /* And insert the proper bits into INSN. */
1666 return insn | w;
1667 }
be7582f3
JL
1668
1669 /* Doubleword loads and stores with a 14bit displacement. */
11c19a4e 1670 case R_PARISC_DLTREL14DR:
be7582f3 1671 case R_PARISC_DLTIND14DR:
e5bb3efc
JL
1672 case R_PARISC_LTOFF_FPTR14DR:
1673 case R_PARISC_LTOFF_FPTR16DF:
571047ad
JL
1674 case R_PARISC_PCREL14DR:
1675 case R_PARISC_PCREL16DF:
b233eaab
JL
1676 case R_PARISC_LTOFF_TP14DR:
1677 case R_PARISC_LTOFF_TP16DF:
6849fb4d
JL
1678 case R_PARISC_DPREL14DR:
1679 case R_PARISC_GPREL16DF:
8267b155
JL
1680 case R_PARISC_PLTOFF14DR:
1681 case R_PARISC_PLTOFF16DF:
b7263961
JL
1682 case R_PARISC_DIR14DR:
1683 case R_PARISC_DIR16DF:
1684 case R_PARISC_LTOFF16DF:
11c19a4e 1685 {
11c19a4e
JL
1686 /* Mask off bits in INSN we do not want. */
1687 insn &= 0xffffc00e;
1688
1689 /* The sign bit at 14 moves into bit zero in the destination. */
1690 insn |= ((sym_value & 0x2000) >> 13);
1691
1692 /* Turn off the bits in sym_value we do not care about. */
1693 sym_value &= 0x1ff8;
1694
1695 /* Now shift it one bit position left so that it lines up with the
1696 destination field in INSN. */
1697 sym_value <<= 1;
1698
1699 return insn | sym_value;
1700 }
1701
be7582f3 1702 /* Floating point single word load/store instructions. */
11c19a4e 1703 case R_PARISC_DLTREL14WR:
be7582f3 1704 case R_PARISC_DLTIND14WR:
e5bb3efc
JL
1705 case R_PARISC_LTOFF_FPTR14WR:
1706 case R_PARISC_LTOFF_FPTR16WF:
571047ad
JL
1707 case R_PARISC_PCREL14WR:
1708 case R_PARISC_PCREL16WF:
b233eaab
JL
1709 case R_PARISC_LTOFF_TP14WR:
1710 case R_PARISC_LTOFF_TP16WF:
6849fb4d
JL
1711 case R_PARISC_DPREL14WR:
1712 case R_PARISC_GPREL16WF:
8267b155
JL
1713 case R_PARISC_PLTOFF14WR:
1714 case R_PARISC_PLTOFF16WF:
b7263961
JL
1715 case R_PARISC_DIR16WF:
1716 case R_PARISC_DIR14WR:
1717 case R_PARISC_LTOFF16WF:
11c19a4e 1718 {
11c19a4e
JL
1719 /* Mask off bits in INSN we do not want. */
1720 insn &= 0xffffc006;
1721
1722 /* The sign bit at 14 moves into bit zero in the destination. */
1723 insn |= ((sym_value & 0x2000) >> 13);
1724
1725 /* Turn off the bits in sym_value we do not care about. */
1726 sym_value &= 0x1ffc;
1727
1728 /* Now shift it one bit position left so that it lines up with the
1729 destination field in INSN. */
1730 sym_value <<= 1;
1731
1732 return insn | sym_value;
1733 }
be7582f3 1734
2eb429af
JL
1735 default:
1736 return insn;
1737 }
1738}
This page took 0.162599 seconds and 4 git commands to generate.