1 /* BFD back-end for HP PA-RISC ELF files.
2 Copyright (C) 1990-1991 Free Software Foundation, Inc.
6 Center for Software Science
7 Department of Computer Science
10 This file is part of BFD, the Binary File Descriptor library.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
32 /* ELF32/HPPA relocation support
34 This file contains ELF32/HPPA relocation support as specified
35 in the Stratus FTX/Golf Object File Format (SED-1762) dated
42 Center for Software Science
43 Department of Computer Science
47 #include "elf32-hppa.h"
49 #include "aout/aout64.h"
51 /* ELF/PA relocation howto entries */
53 static bfd_reloc_status_type hppa_elf_reloc ();
55 reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
57 /* 'bitpos' and 'abs' are obsolete */
58 /* type rs sz bsz pcrel bpos abs ovrf sf name */
59 /* 9.3.4. Address relocation types */
60 {R_HPPA_NONE, 0, 3, 19, false, 0, false, true, hppa_elf_reloc, "R_HPPA_NONE"},
61 {R_HPPA_32, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_32"},
62 {R_HPPA_11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_11"},
63 {R_HPPA_14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_14"},
64 {R_HPPA_17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_17"},
65 {R_HPPA_L21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_L21"},
66 {R_HPPA_R11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_R11"},
67 {R_HPPA_R14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_R14"},
68 {R_HPPA_R17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_R17"},
69 {R_HPPA_LS21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_LS21"},
70 {R_HPPA_RS11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_RS11"},
71 {R_HPPA_RS14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_RS14"},
72 {R_HPPA_RS17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_RS17"},
73 {R_HPPA_LD21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_LD21"},
74 {R_HPPA_RD11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_RD11"},
75 {R_HPPA_RD14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_RD14"},
76 {R_HPPA_RD17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_RD17"},
77 {R_HPPA_LR21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_LR21"},
78 {R_HPPA_RR14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_RR14"},
79 {R_HPPA_RR17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_RR17"},
80 /* 9.3.5. GOTOFF address relocation types */
81 {R_HPPA_GOTOFF_11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_11"},
82 {R_HPPA_GOTOFF_14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_14"},
83 {R_HPPA_GOTOFF_L21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_L21"},
84 {R_HPPA_GOTOFF_R11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_R11"},
85 {R_HPPA_GOTOFF_R14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_R14"},
86 {R_HPPA_GOTOFF_LS21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_LS21"},
87 {R_HPPA_GOTOFF_RS11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RS11"},
88 {R_HPPA_GOTOFF_RS14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RS14"},
89 {R_HPPA_GOTOFF_LD21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_LD21"},
90 {R_HPPA_GOTOFF_RD11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RD11"},
91 {R_HPPA_GOTOFF_RD14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RD14"},
92 {R_HPPA_GOTOFF_LR21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_LR21"},
93 {R_HPPA_GOTOFF_RR14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_GOTOFF_RR14"},
94 /* 9.3.6. Absolute call relocation types */
95 {R_HPPA_ABS_CALL_11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_11"},
96 {R_HPPA_ABS_CALL_14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_14"},
97 {R_HPPA_ABS_CALL_17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_17"},
98 {R_HPPA_ABS_CALL_L21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_L21"},
99 {R_HPPA_ABS_CALL_R11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_R11"},
100 {R_HPPA_ABS_CALL_R14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_R14"},
101 {R_HPPA_ABS_CALL_R17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_R17"},
102 {R_HPPA_ABS_CALL_LS21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_LS21"},
103 {R_HPPA_ABS_CALL_RS11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RS11"},
104 {R_HPPA_ABS_CALL_RS14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RS14"},
105 {R_HPPA_ABS_CALL_RS17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RS17"},
106 {R_HPPA_ABS_CALL_LD21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_LD21"},
107 {R_HPPA_ABS_CALL_RD11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RD11"},
108 {R_HPPA_ABS_CALL_RD14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RD14"},
109 {R_HPPA_ABS_CALL_RD17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RD17"},
110 {R_HPPA_ABS_CALL_LR21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_LR21"},
111 {R_HPPA_ABS_CALL_RR14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RR14"},
112 {R_HPPA_ABS_CALL_RR17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ABS_CALL_RR17"},
113 /* 9.3.7. PC-relative call relocation types */
114 {R_HPPA_PCREL_CALL_11, 0, 3, 11, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_11"},
115 {R_HPPA_PCREL_CALL_14, 0, 3, 14, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_14"},
116 {R_HPPA_PCREL_CALL_17, 0, 3, 17, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_17"},
117 {R_HPPA_PCREL_CALL_12, 0, 3, 12, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_12"},
118 {R_HPPA_PCREL_CALL_L21, 0, 3, 21, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_L21"},
119 {R_HPPA_PCREL_CALL_R11, 0, 3, 11, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_R11"},
120 {R_HPPA_PCREL_CALL_R14, 0, 3, 14, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_R14"},
121 {R_HPPA_PCREL_CALL_R17, 0, 3, 17, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_R17"},
122 {R_HPPA_PCREL_CALL_LS21, 0, 3, 21, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_LS21"},
123 {R_HPPA_PCREL_CALL_RS11, 0, 3, 11, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RS11"},
124 {R_HPPA_PCREL_CALL_RS14, 0, 3, 14, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RS14"},
125 {R_HPPA_PCREL_CALL_RS17, 0, 3, 17, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RS17"},
126 {R_HPPA_PCREL_CALL_LD21, 0, 3, 21, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_LD21"},
127 {R_HPPA_PCREL_CALL_RD11, 0, 3, 11, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RD11"},
128 {R_HPPA_PCREL_CALL_RD14, 0, 3, 14, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RD14"},
129 {R_HPPA_PCREL_CALL_RD17, 0, 3, 17, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RD17"},
130 {R_HPPA_PCREL_CALL_LR21, 0, 3, 21, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_LR21"},
131 {R_HPPA_PCREL_CALL_RR14, 0, 3, 14, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RR14"},
132 {R_HPPA_PCREL_CALL_RR17, 0, 3, 17, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PCREL_CALL_RR17"},
134 /* 9.3.8. Plabel relocation types */
135 {R_HPPA_PLABEL_32, 0, 3, 32, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PLABEL_32"},
136 {R_HPPA_PLABEL_11, 0, 3, 11, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PLABEL_11"},
137 {R_HPPA_PLABEL_14, 0, 3, 14, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PLABEL_14"},
138 {R_HPPA_PLABEL_L21, 0, 3, 21, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PLABEL_L21"},
139 {R_HPPA_PLABEL_R11, 0, 3, 11, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PLABEL_R11"},
140 {R_HPPA_PLABEL_R14, 0, 3, 14, true, 0, false, true, hppa_elf_reloc, "R_HPPA_PLABEL_R14"},
142 /* 9.3.9. Data linkage table (DLT) relocation types */
143 {R_HPPA_DLT_32, 0, 3, 32, true, 0, false, true, hppa_elf_reloc, "R_HPPA_DLT_32"},
144 {R_HPPA_DLT_11, 0, 3, 11, true, 0, false, true, hppa_elf_reloc, "R_HPPA_DLT_11"},
145 {R_HPPA_DLT_14, 0, 3, 14, true, 0, false, true, hppa_elf_reloc, "R_HPPA_DLT_14"},
146 {R_HPPA_DLT_L21, 0, 3, 21, true, 0, false, true, hppa_elf_reloc, "R_HPPA_DLT_L21"},
147 {R_HPPA_DLT_R11, 0, 3, 11, true, 0, false, true, hppa_elf_reloc, "R_HPPA_DLT_R11"},
148 {R_HPPA_DLT_R14, 0, 3, 14, true, 0, false, true, hppa_elf_reloc, "R_HPPA_DLT_R14"},
150 /* 9.3.10. Relocations for unwinder tables */
151 {R_HPPA_UNWIND_ENTRY, 0, 3, 32, true, 0, false, true, hppa_elf_reloc, "R_HPPA_UNWIND_ENTRY"},
152 {R_HPPA_UNWIND_ENTRIES, 0, 3, 32, true, 0, false, true, hppa_elf_reloc, "R_HPPA_UNWIND_ENTRIES"},
154 /* 9.3.11. Relocation types for complex expressions */
155 {R_HPPA_PUSH_CONST, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_PUSH_CONST"},
156 {R_HPPA_PUSH_PC, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_PUSH_PC"},
157 {R_HPPA_PUSH_SYM, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_PUSH_SYM"},
158 {R_HPPA_PUSH_GOTOFF, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_PUSH_GOTOFF"},
159 {R_HPPA_PUSH_ABS_CALL, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_PUSH_ABS_CALL"},
160 {R_HPPA_PUSH_PCREL_CALL, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_PUSH_PCREL_CALL"},
161 {R_HPPA_PUSH_PLABEL, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_PUSH_PLABEL"},
162 {R_HPPA_MAX, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_MAX"},
163 {R_HPPA_MIN, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_MIN"},
164 {R_HPPA_ADD, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ADD"},
165 {R_HPPA_SUB, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_SUB"},
166 {R_HPPA_MULT, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_MULT"},
167 {R_HPPA_DIV, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_DIV"},
168 {R_HPPA_MOD, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_MOD"},
169 {R_HPPA_AND, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_AND"},
170 {R_HPPA_OR, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_OR"},
171 {R_HPPA_XOR, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_XOR"},
172 {R_HPPA_NOT, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_NOT"},
173 {R_HPPA_LSHIFT, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_LSHIFT"},
174 {R_HPPA_ARITH_RSHIFT, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_ARITH_RSHIFT"},
175 {R_HPPA_LOGIC_RSHIFT, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_LOGIC_RSHIFT"},
176 {R_HPPA_EXPR_F, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_L"},
177 {R_HPPA_EXPR_L, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_L"},
178 {R_HPPA_EXPR_R, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_R"},
179 {R_HPPA_EXPR_LS, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_LS"},
180 {R_HPPA_EXPR_RS, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_RS"},
181 {R_HPPA_EXPR_LD, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_LD"},
182 {R_HPPA_EXPR_RD, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_RD"},
183 {R_HPPA_EXPR_LR, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_LR"},
184 {R_HPPA_EXPR_RR, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_RR"},
186 {R_HPPA_EXPR_32, 0, 3, 32, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_32"},
187 {R_HPPA_EXPR_21, 0, 3, 21, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_21"},
188 {R_HPPA_EXPR_11, 0, 3, 11, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_11"},
189 {R_HPPA_EXPR_14, 0, 3, 14, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_14"},
190 {R_HPPA_EXPR_17, 0, 3, 17, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_17"},
191 {R_HPPA_EXPR_12, 0, 3, 12, false, 0, false, true, hppa_elf_reloc, "R_HPPA_EXPR_12"},
192 {R_HPPA_UNIMPLEMENTED, 0, 0, 0, false, 0, false, false, NULL, "R_HPPA_UNIMPLEMENTED"},
195 static symext_chainS *symext_rootP = NULL;
196 static symext_chainS *symext_lastP = NULL;
199 DEFUN (hppa_elf_rebuild_insn, (abfd, insn, value, r_type, r_field, r_format),
201 unsigned long insn AND
202 unsigned long value AND
203 unsigned short r_type AND
204 unsigned short r_field AND
205 unsigned short r_format)
207 unsigned long const_part; /* part of the instruction that does not change */
208 unsigned long rebuilt_part;
216 const_part = insn & 0xffffe002;
217 dis_assemble_12 (value, &w1, &w);
218 rebuilt_part = (w1 << 2) | w;
219 return const_part | rebuilt_part;
226 const_part = insn & 0xffffe002;
227 dis_assemble_12 (value, &w1, &w);
228 rebuilt_part = (w1 << 2) | w;
229 return const_part | rebuilt_part;
233 const_part = insn & 0xffffc000;
234 low_sign_unext (value, 14, &rebuilt_part);
235 return const_part | rebuilt_part;
241 const_part = insn & 0xffe0e002;
242 dis_assemble_17 (value, &w1, &w2, &w);
243 rebuilt_part = (w2 << 2) | (w1 << 16) | w;
244 return const_part | rebuilt_part;
248 const_part = insn & 0xffe00000;
249 dis_assemble_21 (value, &rebuilt_part);
250 return const_part | rebuilt_part;
257 fprintf (stderr, "Relocation problem : ");
259 "Unrecognized reloc type %d (fmt=%d,fld=%d), in module %s\n",
260 r_type, r_format, r_field, abfd->filename);
266 DEFUN (hppa_elf_relocate_insn,
268 insn, address, symp, sym_value, r_addend,
269 r_type, r_format, r_field, pcrel),
271 asection * input_sect AND
272 unsigned long insn AND
273 unsigned long address AND
277 unsigned short r_type AND
278 unsigned short r_format AND
279 unsigned short r_field AND
282 unsigned char opcode = get_opcode (insn);
297 constant_value = ELF32_HPPA_R_CONSTANT (r_addend);
298 BFD_ASSERT (r_format == 14);
301 sym_value -= address;
302 sym_value = hppa_field_adjust (sym_value, constant_value, r_field);
303 return hppa_elf_rebuild_insn (abfd, insn, sym_value, r_type, r_format, r_format);
306 case SUBI: /* case SUBIO: */
307 case ADDIT: /* case ADDITO: */
308 case ADDI: /* case ADDIO: */
309 BFD_ASSERT (r_format == 11);
311 constant_value = ((insn & 0x1) << 10) | ((insn & 0xffe) >> 1);
312 sym_value = hppa_field_adjust (sym_value, constant_value, r_field);
313 return hppa_elf_rebuild_insn (abfd, insn, sym_value, r_type, r_field, r_format);
317 BFD_ASSERT (r_format == 21);
319 constant_value = assemble_21 (insn);
320 constant_value += ELF32_HPPA_R_CONSTANT (r_addend);
321 sym_value = hppa_field_adjust (sym_value, constant_value, r_field);
322 return hppa_elf_rebuild_insn (abfd, insn, sym_value, r_type, r_field, r_format);
327 arg_reloc = ELF32_HPPA_R_ARG_RELOC (r_addend);
329 BFD_ASSERT (r_format == 17);
331 /* XXX computing constant_value is not needed??? */
332 constant_value = assemble_17 ((insn & 0x001f0000) >> 16,
333 (insn & 0x00001ffc) >> 2,
335 /* @@ Assumes only 32 bits. */
336 constant_value = (constant_value << 15) >> 15;
340 address + input_sect->output_offset
341 + input_sect->output_section->vma;
342 sym_value = hppa_field_adjust (sym_value, -8, r_field);
345 sym_value = hppa_field_adjust (sym_value, constant_value, r_field);
347 return hppa_elf_rebuild_insn (abfd, insn, sym_value >> 2, r_type, r_field, r_format);
352 BFD_ASSERT (r_format == 32);
353 constant_value = insn;
354 constant_value += ELF32_HPPA_R_CONSTANT (r_addend);
356 return hppa_field_adjust (sym_value, constant_value, r_field);
361 "Unrecognized opcode 0x%02x (fmt=%x,field=%x)\n",
362 opcode, r_format, r_field);
369 DEFUN (hppa_elf_relocate_unwind_table,
371 data, address, symp, sym_value, r_addend,
372 r_type, r_format, r_field, pcrel),
374 asection * input_sect AND
376 unsigned long address AND
380 unsigned short r_type AND
381 unsigned short r_format AND
382 unsigned short r_field AND
385 bfd_byte *hit_data = address + (bfd_byte *) (data);
388 long relocated_value;
391 BFD_ASSERT (r_format == 32);
392 BFD_ASSERT (r_field == e_fsel);
395 case R_HPPA_UNWIND_ENTRY:
396 start_offset = bfd_get_32 (abfd, hit_data);
397 relocated_value = hppa_field_adjust (sym_value, start_offset, r_field);
398 bfd_put_32 (abfd, relocated_value, hit_data);
400 hit_data += sizeof (unsigned long);
401 end_offset = bfd_get_32 (abfd, hit_data);
402 relocated_value = hppa_field_adjust (sym_value, end_offset, r_field);
403 bfd_put_32 (abfd, relocated_value, hit_data);
406 case R_HPPA_UNWIND_ENTRIES:
407 for (i = 0; i < r_addend; i++, hit_data += 3 * sizeof (unsigned long))
410 start_offset = bfd_get_32 (abfd, hit_data);
411 /* Stuff the symbol value into the first word */
412 /* of the unwind descriptor */
413 bfd_put_32 (abfd, sym_value, hit_data);
415 hit_data += sizeof (unsigned long);
416 end_offset = bfd_get_32 (abfd, hit_data);
417 /* We could also compute the ending offset for */
418 /* the 2nd word of the unwind entry by */
419 /* retrieving the st_size field of the Elf_Sym */
420 /* structure stored with this symbol. We can */
422 /* e = (elf_symbol_type *)symp */
423 /* fsize = e->internal_elf_sym.st_size */
425 fsize = end_offset - start_offset;
426 relocated_value = hppa_field_adjust (sym_value, fsize, r_field);
427 bfd_put_32 (abfd, relocated_value, hit_data);
429 /* If this is not the last unwind entry, */
430 /* adjust the symbol value. */
431 if (i + 1 < r_addend)
433 start_offset = bfd_get_32 (abfd, hit_data + 3 * sizeof (unsigned long));
434 sym_value += fsize + start_offset - end_offset;
441 "Unrecognized relocation type 0x%02x (fmt=%x,field=%x)\n",
442 r_type, r_format, r_field);
446 /* Provided the symbol, returns the value reffed */
448 get_symbol_value (symbol)
453 if (symbol == (asymbol *) NULL)
455 else if (symbol->section == &bfd_com_section)
461 relocation = symbol->value +
462 symbol->section->output_section->vma +
463 symbol->section->output_offset;
469 /* This function provides a pretty straight-forward mapping between a */
470 /* base relocation type, format and field into the relocation type */
471 /* that will be emitted in an object file. The only wrinkle in the */
472 /* mapping is that when the T, TR, TL, P, PR, or PL expression */
473 /* prefixes are involved, the type gets promoted to a *_GOTOFF_* */
474 /* relocation (in the case of T, TR, and TL) or a PLABEL relocation */
475 /* (in the case of P, PR, and PL). */
477 /* NOTE: XXX the T, TR, TL, P, PR, and PL expression prefixes are not */
481 hppa_elf_gen_reloc_error (base_type, fmt, field)
482 elf32_hppa_reloc_type base_type;
486 fprintf (stderr, "undefined relocation: base=0x%x,fmt=0x%x,field=0x%x\n",
487 base_type, fmt, field);
490 elf32_hppa_reloc_type **
491 hppa_elf_gen_reloc_type (abfd, base_type, format, field)
493 elf32_hppa_reloc_type base_type;
497 #define UNDEFINED hppa_elf_gen_reloc_error(base_type,format,field);
499 elf32_hppa_reloc_type *finaltype;
500 elf32_hppa_reloc_type **final_types;
503 final_types = (elf32_hppa_reloc_type **) bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type *) * 2);
504 BFD_ASSERT (final_types != 0);
506 finaltype = (elf32_hppa_reloc_type *) bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type));
507 BFD_ASSERT (finaltype != 0);
509 final_types[0] = finaltype;
510 final_types[1] = NULL;
512 #define final_type finaltype[0]
514 final_type = base_type;
525 final_type = R_HPPA_11;
528 final_type = R_HPPA_R11;
531 final_type = R_HPPA_RS11;
534 final_type = R_HPPA_RD11;
538 final_type = R_HPPA_PLABEL_11;
541 final_type = R_HPPA_PLABEL_R11;
554 final_type = base_type;
565 final_type = R_HPPA_R14;
568 final_type = R_HPPA_RS14;
571 final_type = R_HPPA_RD14;
574 final_type = R_HPPA_RR14;
578 final_type = R_HPPA_PLABEL_14;
581 final_type = R_HPPA_PLABEL_R14;
595 final_type = base_type;
603 final_type = R_HPPA_17;
606 final_type = R_HPPA_R17;
609 final_type = R_HPPA_RS17;
612 final_type = R_HPPA_RD17;
615 final_type = R_HPPA_RR17;
623 final_type = base_type;
631 final_type = R_HPPA_L21;
634 final_type = R_HPPA_LS21;
637 final_type = R_HPPA_LD21;
640 final_type = R_HPPA_LR21;
643 final_type = R_HPPA_PLABEL_L21;
652 final_type = base_type;
660 final_type = R_HPPA_32;
663 final_type = R_HPPA_PLABEL_32;
667 final_type = base_type;
673 final_type = base_type;
684 final_type = R_HPPA_GOTOFF_R11;
687 final_type = R_HPPA_GOTOFF_RS11;
690 final_type = R_HPPA_GOTOFF_RD11;
693 final_type = R_HPPA_GOTOFF_11;
701 final_type = base_type;
707 final_type = base_type;
713 final_type = R_HPPA_GOTOFF_R14;
716 final_type = R_HPPA_GOTOFF_RS14;
719 final_type = R_HPPA_GOTOFF_RD14;
722 final_type = R_HPPA_GOTOFF_RR14;
725 final_type = R_HPPA_GOTOFF_14;
733 final_type = base_type;
739 final_type = base_type;
745 final_type = R_HPPA_GOTOFF_L21;
748 final_type = R_HPPA_GOTOFF_LS21;
751 final_type = R_HPPA_GOTOFF_LD21;
754 final_type = R_HPPA_GOTOFF_LR21;
763 final_type = base_type;
769 final_type = base_type;
773 final_type = base_type;
777 case R_HPPA_PCREL_CALL:
784 final_type = R_HPPA_PCREL_CALL_R11;
787 final_type = R_HPPA_PCREL_CALL_RS11;
790 final_type = R_HPPA_PCREL_CALL_RD11;
793 final_type = R_HPPA_PCREL_CALL_11;
801 final_type = base_type;
807 final_type = base_type;
813 final_type = R_HPPA_PCREL_CALL_R14;
816 final_type = R_HPPA_PCREL_CALL_RS14;
819 final_type = R_HPPA_PCREL_CALL_RD14;
822 final_type = R_HPPA_PCREL_CALL_RR14;
825 final_type = R_HPPA_PCREL_CALL_14;
833 final_type = base_type;
841 final_type = R_HPPA_PCREL_CALL_R17;
844 final_type = R_HPPA_PCREL_CALL_RS17;
847 final_type = R_HPPA_PCREL_CALL_RD17;
850 final_type = R_HPPA_PCREL_CALL_RR17;
853 final_type = R_HPPA_PCREL_CALL_17;
861 final_type = base_type;
869 final_type = R_HPPA_PCREL_CALL_L21;
872 final_type = R_HPPA_PCREL_CALL_LS21;
875 final_type = R_HPPA_PCREL_CALL_LD21;
878 final_type = R_HPPA_PCREL_CALL_LR21;
887 final_type = base_type;
893 final_type = base_type;
897 final_type = base_type;
908 final_type = R_HPPA_PLABEL_11;
911 final_type = R_HPPA_PLABEL_R11;
915 final_type = base_type;
923 final_type = R_HPPA_PLABEL_14;
926 final_type = R_HPPA_PLABEL_R14;
930 final_type = base_type;
938 final_type = R_HPPA_PLABEL_L21;
942 final_type = base_type;
950 final_type = R_HPPA_PLABEL_32;
954 final_type = base_type;
960 final_type = base_type;
963 case R_HPPA_ABS_CALL:
970 final_type = R_HPPA_ABS_CALL_R11;
973 final_type = R_HPPA_ABS_CALL_RS11;
976 final_type = R_HPPA_ABS_CALL_RD11;
979 final_type = R_HPPA_ABS_CALL_11;
987 final_type = base_type;
993 final_type = base_type;
999 final_type = R_HPPA_ABS_CALL_R14;
1002 final_type = R_HPPA_ABS_CALL_RS14;
1005 final_type = R_HPPA_ABS_CALL_RD14;
1008 final_type = R_HPPA_ABS_CALL_RR14;
1011 final_type = R_HPPA_ABS_CALL_14;
1019 final_type = base_type;
1027 final_type = R_HPPA_ABS_CALL_R17;
1030 final_type = R_HPPA_ABS_CALL_RS17;
1033 final_type = R_HPPA_ABS_CALL_RD17;
1036 final_type = R_HPPA_ABS_CALL_RR17;
1039 final_type = R_HPPA_ABS_CALL_17;
1047 final_type = base_type;
1055 final_type = R_HPPA_ABS_CALL_L21;
1058 final_type = R_HPPA_ABS_CALL_LS21;
1061 final_type = R_HPPA_ABS_CALL_LD21;
1064 final_type = R_HPPA_ABS_CALL_LR21;
1073 final_type = base_type;
1079 final_type = base_type;
1083 final_type = base_type;
1088 final_type = R_HPPA_UNWIND_ENTRY;
1090 case R_HPPA_COMPLEX:
1091 case R_HPPA_COMPLEX_PCREL_CALL:
1092 case R_HPPA_COMPLEX_ABS_CALL:
1093 final_types = (elf32_hppa_reloc_type **) bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type *) * 6);
1094 BFD_ASSERT (final_types != 0);
1096 finaltype = (elf32_hppa_reloc_type *) bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type) * 5);
1097 BFD_ASSERT (finaltype != 0);
1099 for (i = 0; i < 5; i++)
1100 final_types[i] = &finaltype[i];
1102 final_types[5] = NULL;
1104 finaltype[0] = R_HPPA_PUSH_SYM;
1106 if (base_type == R_HPPA_COMPLEX)
1107 finaltype[1] = R_HPPA_PUSH_SYM;
1108 else if (base_type == R_HPPA_COMPLEX_PCREL_CALL)
1109 finaltype[1] = R_HPPA_PUSH_PCREL_CALL;
1110 else /* base_type == R_HPPA_COMPLEX_ABS_CALL */
1111 finaltype[1] = R_HPPA_PUSH_ABS_CALL;
1113 finaltype[2] = R_HPPA_SUB;
1118 finaltype[3] = R_HPPA_EXPR_F;
1121 finaltype[3] = R_HPPA_EXPR_L;
1124 finaltype[3] = R_HPPA_EXPR_R;
1127 finaltype[3] = R_HPPA_EXPR_LS;
1130 finaltype[3] = R_HPPA_EXPR_RS;
1133 finaltype[3] = R_HPPA_EXPR_LD;
1136 finaltype[3] = R_HPPA_EXPR_RD;
1139 finaltype[3] = R_HPPA_EXPR_LR;
1142 finaltype[3] = R_HPPA_EXPR_RR;
1149 finaltype[4] = R_HPPA_EXPR_11;
1152 finaltype[4] = R_HPPA_EXPR_12;
1155 finaltype[4] = R_HPPA_EXPR_14;
1158 finaltype[4] = R_HPPA_EXPR_17;
1161 finaltype[4] = R_HPPA_EXPR_21;
1164 finaltype[4] = R_HPPA_EXPR_32;
1171 final_type = base_type;
1180 /* 12.4.4. Derive format from instruction */
1182 /* Given a machine instruction, this function determines its format. */
1183 /* The format can be determined solely from looking at the first six */
1184 /* bits (the major opcode) of the instruction. Several major opcodes */
1185 /* map to the same format. Opcodes which do not map to a known format */
1186 /* should probably be reported as an error. */
1189 hppa_elf_insn2fmt (type, insn)
1190 elf32_hppa_reloc_type type;
1193 unsigned char fmt = 0; /* XXX: is this a proper default? */
1194 unsigned char op = get_opcode (insn);
1196 if (type == R_HPPA_NONE)
1250 /* this function is in charge of performing all the HP PA relocations */
1251 static long global_value = 0;
1252 static long GOT_value = 0; /* XXX: need to calculate this! For HPUX, GOT == DP */
1253 static asymbol *global_symbol = (asymbol *) NULL;
1255 static bfd_reloc_status_type
1256 DEFUN (hppa_elf_reloc, (abfd, reloc_entry, symbol_in, data, input_section, output_bfd),
1258 arelent * reloc_entry AND
1259 asymbol * symbol_in AND
1261 asection * input_section AND
1267 unsigned long addr = reloc_entry->address; /*+ input_section->vma*/
1268 bfd_byte *hit_data = addr + (bfd_byte *) (data);
1269 unsigned short r_type = reloc_entry->howto->type & 0xFF;
1270 unsigned short r_field = e_fsel;
1271 boolean r_pcrel = reloc_entry->howto->pc_relative;
1273 /* howto->bitsize contains the format (11, 14, 21, etc) information */
1274 unsigned r_format = reloc_entry->howto->bitsize;
1275 long r_addend = reloc_entry->addend;
1280 /* Partial linking - do nothing */
1281 reloc_entry->address += input_section->output_offset;
1282 return bfd_reloc_ok;
1285 if (symbol_in && symbol_in->section == &bfd_und_section)
1286 return bfd_reloc_undefined;
1288 /* Check for stubs that might be required. */
1289 /* symbol_in = hppa_elf_stub_check (abfd, input_section->output_section->owner, reloc_entry); */
1291 sym_value = get_symbol_value (symbol_in);
1293 /* compute value of $global$ if it is there. */
1295 if (global_symbol == (asymbol *) NULL)
1297 struct elf32_backend_data *bed
1298 = (struct elf32_backend_data *) abfd->xvec->backend_data;
1300 if (bed && bed->global_sym)
1302 asymbol *gsym = &bed->global_sym->symbol;
1305 + gsym->section->output_section->vma
1306 + gsym->section->output_offset;
1307 GOT_value = global_value; /* XXX: For HP-UX, GOT==DP */
1308 global_symbol = gsym;
1312 /* get the instruction word */
1313 insn = bfd_get_32 (abfd, hit_data);
1315 /* relocate the value based on the relocation type */
1317 /* basic_type_1: relocation is relative to $global$ */
1318 /* basic_type_2: relocation is relative to the current GOT */
1319 /* basic_type_3: relocation is an absolute call */
1320 /* basic_type_4: relocation is an PC-relative call */
1321 /* basic_type_5: relocation is plabel reference */
1322 /* basic_type_6: relocation is an unwind table relocation */
1323 /* extended_type: unimplemented */
1329 case R_HPPA_32: /* Symbol + Addend 32 */
1331 goto do_basic_type_1;
1332 case R_HPPA_11: /* Symbol + Addend 11 */
1334 goto do_basic_type_1;
1335 case R_HPPA_14: /* Symbol + Addend 14 */
1337 goto do_basic_type_1;
1338 case R_HPPA_17: /* Symbol + Addend 17 */
1340 goto do_basic_type_1;
1341 case R_HPPA_L21: /* L (Symbol, Addend) 21 */
1343 goto do_basic_type_1;
1344 case R_HPPA_R11: /* R (Symbol, Addend) 11 */
1346 goto do_basic_type_1;
1347 case R_HPPA_R14: /* R (Symbol, Addend) 14 */
1349 goto do_basic_type_1;
1350 case R_HPPA_R17: /* R (Symbol, Addend) 17 */
1352 goto do_basic_type_1;
1353 case R_HPPA_LS21: /* LS(Symbol, Addend) 21 */
1355 goto do_basic_type_1;
1356 case R_HPPA_RS11: /* RS(Symbol, Addend) 11 */
1358 goto do_basic_type_1;
1359 case R_HPPA_RS14: /* RS(Symbol, Addend) 14 */
1361 goto do_basic_type_1;
1362 case R_HPPA_RS17: /* RS(Symbol, Addend) 17 */
1364 goto do_basic_type_1;
1365 case R_HPPA_LD21: /* LD(Symbol, Addend) 21 */
1367 goto do_basic_type_1;
1368 case R_HPPA_RD11: /* RD(Symbol, Addend) 11 */
1370 goto do_basic_type_1;
1371 case R_HPPA_RD14: /* RD(Symbol, Addend) 14 */
1373 goto do_basic_type_1;
1374 case R_HPPA_RD17: /* RD(Symbol, Addend) 17 */
1376 goto do_basic_type_1;
1377 case R_HPPA_LR21: /* LR(Symbol, Addend) 21 */
1379 goto do_basic_type_1;
1380 case R_HPPA_RR14: /* RR(Symbol, Addend) 14 */
1382 goto do_basic_type_1;
1383 case R_HPPA_RR17: /* RR(Symbol, Addend) 17 */
1387 insn = hppa_elf_relocate_insn (abfd, input_section, insn, addr,
1388 symbol_in, sym_value, r_addend,
1389 r_type, r_format, r_field, r_pcrel);
1392 case R_HPPA_GOTOFF_11: /* Symbol - GOT + Addend 11 */
1394 goto do_basic_type_2;
1395 case R_HPPA_GOTOFF_14: /* Symbol - GOT + Addend 14 */
1397 goto do_basic_type_2;
1398 case R_HPPA_GOTOFF_L21: /* L (Sym - GOT, Addend) 21 */
1400 goto do_basic_type_2;
1401 case R_HPPA_GOTOFF_R11: /* R (Sym - GOT, Addend) 11 */
1403 goto do_basic_type_2;
1404 case R_HPPA_GOTOFF_R14: /* R (Sym - GOT, Addend) 14 */
1406 goto do_basic_type_2;
1407 case R_HPPA_GOTOFF_LS21: /* LS(Sym - GOT, Addend) 21 */
1409 goto do_basic_type_2;
1410 case R_HPPA_GOTOFF_RS11: /* RS(Sym - GOT, Addend) 11 */
1412 goto do_basic_type_2;
1413 case R_HPPA_GOTOFF_RS14: /* RS(Sym - GOT, Addend) 14 */
1415 goto do_basic_type_2;
1416 case R_HPPA_GOTOFF_LD21: /* LD(Sym - GOT, Addend) 21 */
1418 goto do_basic_type_2;
1419 case R_HPPA_GOTOFF_RD11: /* RD(Sym - GOT, Addend) 11 */
1421 goto do_basic_type_2;
1422 case R_HPPA_GOTOFF_RD14: /* RD(Sym - GOT, Addend) 14 */
1424 goto do_basic_type_2;
1425 case R_HPPA_GOTOFF_LR21: /* LR(Sym - GOT, Addend) 21 */
1427 goto do_basic_type_2;
1428 case R_HPPA_GOTOFF_RR14: /* RR(Sym - GOT, Addend) 14 */
1431 sym_value -= GOT_value;
1432 insn = hppa_elf_relocate_insn (abfd, input_section, insn, addr,
1433 symbol_in, sym_value, r_addend,
1434 r_type, r_format, r_field, r_pcrel);
1437 case R_HPPA_ABS_CALL_11: /* Symbol + Addend 11 */
1439 goto do_basic_type_3;
1440 case R_HPPA_ABS_CALL_14: /* Symbol + Addend 14 */
1442 goto do_basic_type_3;
1443 case R_HPPA_ABS_CALL_17: /* Symbol + Addend 17 */
1445 goto do_basic_type_3;
1446 case R_HPPA_ABS_CALL_L21: /* L (Symbol, Addend) 21 */
1448 goto do_basic_type_3;
1449 case R_HPPA_ABS_CALL_R11: /* R (Symbol, Addend) 11 */
1451 goto do_basic_type_3;
1452 case R_HPPA_ABS_CALL_R14: /* R (Symbol, Addend) 14 */
1454 goto do_basic_type_3;
1455 case R_HPPA_ABS_CALL_R17: /* R (Symbol, Addend) 17 */
1457 goto do_basic_type_3;
1458 case R_HPPA_ABS_CALL_LS21: /* LS(Symbol, Addend) 21 */
1460 goto do_basic_type_3;
1461 case R_HPPA_ABS_CALL_RS11: /* RS(Symbol, Addend) 11 */
1463 goto do_basic_type_3;
1464 case R_HPPA_ABS_CALL_RS14: /* RS(Symbol, Addend) 14 */
1466 goto do_basic_type_3;
1467 case R_HPPA_ABS_CALL_RS17: /* RS(Symbol, Addend) 17 */
1469 goto do_basic_type_3;
1470 case R_HPPA_ABS_CALL_LD21: /* LD(Symbol, Addend) 21 */
1472 goto do_basic_type_3;
1473 case R_HPPA_ABS_CALL_RD11: /* RD(Symbol, Addend) 11 */
1475 goto do_basic_type_3;
1476 case R_HPPA_ABS_CALL_RD14: /* RD(Symbol, Addend) 14 */
1478 goto do_basic_type_3;
1479 case R_HPPA_ABS_CALL_RD17: /* RD(Symbol, Addend) 17 */
1481 goto do_basic_type_3;
1482 case R_HPPA_ABS_CALL_LR21: /* LR(Symbol, Addend) 21 */
1484 goto do_basic_type_3;
1485 case R_HPPA_ABS_CALL_RR14: /* RR(Symbol, Addend) 14 */
1487 goto do_basic_type_3;
1488 case R_HPPA_ABS_CALL_RR17: /* RR(Symbol, Addend) 17 */
1491 insn = hppa_elf_relocate_insn (abfd, input_section, insn, addr,
1492 symbol_in, sym_value, r_addend,
1493 r_type, r_format, r_field, r_pcrel);
1496 case R_HPPA_PCREL_CALL_11: /* Symbol - PC + Addend 11 */
1498 goto do_basic_type_4;
1499 case R_HPPA_PCREL_CALL_14: /* Symbol - PC + Addend 14 */
1501 goto do_basic_type_4;
1502 case R_HPPA_PCREL_CALL_17: /* Symbol - PC + Addend 17 */
1504 goto do_basic_type_4;
1505 case R_HPPA_PCREL_CALL_L21:/* L (Symbol - PC, Addend) 21 */
1507 goto do_basic_type_4;
1508 case R_HPPA_PCREL_CALL_R11:/* R (Symbol - PC, Addend) 11 */
1510 goto do_basic_type_4;
1511 case R_HPPA_PCREL_CALL_R14:/* R (Symbol - PC, Addend) 14 */
1513 goto do_basic_type_4;
1514 case R_HPPA_PCREL_CALL_R17:/* R (Symbol - PC, Addend) 17 */
1516 goto do_basic_type_4;
1517 case R_HPPA_PCREL_CALL_LS21: /* LS(Symbol - PC, Addend) 21 */
1519 goto do_basic_type_4;
1520 case R_HPPA_PCREL_CALL_RS11: /* RS(Symbol - PC, Addend) 11 */
1522 goto do_basic_type_4;
1523 case R_HPPA_PCREL_CALL_RS14: /* RS(Symbol - PC, Addend) 14 */
1525 goto do_basic_type_4;
1526 case R_HPPA_PCREL_CALL_RS17: /* RS(Symbol - PC, Addend) 17 */
1528 goto do_basic_type_4;
1529 case R_HPPA_PCREL_CALL_LD21: /* LD(Symbol - PC, Addend) 21 */
1531 goto do_basic_type_4;
1532 case R_HPPA_PCREL_CALL_RD11: /* RD(Symbol - PC, Addend) 11 */
1534 goto do_basic_type_4;
1535 case R_HPPA_PCREL_CALL_RD14: /* RD(Symbol - PC, Addend) 14 */
1537 goto do_basic_type_4;
1538 case R_HPPA_PCREL_CALL_RD17: /* RD(Symbol - PC, Addend) 17 */
1540 goto do_basic_type_4;
1541 case R_HPPA_PCREL_CALL_LR21: /* LR(Symbol - PC, Addend) 21 */
1543 goto do_basic_type_4;
1544 case R_HPPA_PCREL_CALL_RR14: /* RR(Symbol - PC, Addend) 14 */
1546 goto do_basic_type_4;
1547 case R_HPPA_PCREL_CALL_RR17: /* RR(Symbol - PC, Addend) 17 *//* #69 */
1550 insn = hppa_elf_relocate_insn (abfd, input_section, insn, addr,
1551 symbol_in, sym_value, r_addend,
1552 r_type, r_format, r_field, r_pcrel);
1555 case R_HPPA_PLABEL_32:
1556 case R_HPPA_PLABEL_11:
1557 case R_HPPA_PLABEL_14:
1559 goto do_basic_type_5;
1560 case R_HPPA_PLABEL_L21:
1562 goto do_basic_type_5;
1563 case R_HPPA_PLABEL_R11:
1564 case R_HPPA_PLABEL_R14:
1567 insn = hppa_elf_relocate_insn (abfd, input_section, insn, addr,
1568 symbol_in, sym_value, r_addend,
1569 r_type, r_format, r_field, r_pcrel);
1572 case R_HPPA_UNWIND_ENTRY:
1573 case R_HPPA_UNWIND_ENTRIES:
1574 hppa_elf_relocate_unwind_table (abfd, input_section, data, addr,
1575 symbol_in, sym_value, r_addend,
1576 r_type, r_format, r_field, r_pcrel);
1577 return (bfd_reloc_ok);
1579 case R_HPPA_PUSH_CONST: /* push Addend - - */
1580 case R_HPPA_PUSH_PC: /* push PC + Addend - - */
1581 case R_HPPA_PUSH_SYM: /* push Symbol + Addend - - */
1582 case R_HPPA_PUSH_GOTOFF: /* push Symbol - GOT + Addend - - */
1583 case R_HPPA_PUSH_ABS_CALL: /* push Symbol + Addend - - */
1584 case R_HPPA_PUSH_PCREL_CALL: /* push Symbol - PC + Addend - - */
1585 case R_HPPA_PUSH_PLABEL: /* [TBD] - - */
1586 case R_HPPA_MAX: /* pop A and B, push max(B,A) - - */
1587 case R_HPPA_MIN: /* pop A and B, push min(B,A) - - */
1588 case R_HPPA_ADD: /* pop A and B, push B + A - - */
1589 case R_HPPA_SUB: /* pop A and B, push B - A - - */
1590 case R_HPPA_MULT: /* pop A and B, push B * A - - */
1591 case R_HPPA_DIV: /* pop A and B, push B / A - - */
1592 case R_HPPA_MOD: /* pop A and B, push B % A - - */
1593 case R_HPPA_AND: /* pop A and B, push B & A - - */
1594 case R_HPPA_OR: /* pop A and B, push B | A - - */
1595 case R_HPPA_XOR: /* pop A and B, push B ^ A - - */
1596 case R_HPPA_NOT: /* pop A, push ~A - - */
1597 case R_HPPA_LSHIFT: /* pop A, push A << Addend - - */
1598 case R_HPPA_ARITH_RSHIFT: /* pop A, push A >> Addend - - */
1599 case R_HPPA_LOGIC_RSHIFT: /* pop A, push A >> Addend - - */
1600 case R_HPPA_EXPR_F: /* pop A, push A + Addend L - */
1601 case R_HPPA_EXPR_L: /* pop A, push L(A,Addend) L - */
1602 case R_HPPA_EXPR_R: /* pop A, push R(A,Addend) R - */
1603 case R_HPPA_EXPR_LS: /* pop A, push LS(A,Addend) LS - */
1604 case R_HPPA_EXPR_RS: /* pop A, push RS(A,Addend) RS - */
1605 case R_HPPA_EXPR_LD: /* pop A, push LD(A,Addend) LD - */
1606 case R_HPPA_EXPR_RD: /* pop A, push RD(A,Addend) RD - */
1607 case R_HPPA_EXPR_LR: /* pop A, push LR(A,Addend) LR - */
1608 case R_HPPA_EXPR_RR: /* pop A, push RR(A,Addend) RR - */
1610 case R_HPPA_EXPR_32: /* pop - 32 */
1611 case R_HPPA_EXPR_21: /* pop - 21 */
1612 case R_HPPA_EXPR_11: /* pop - 11 */
1613 case R_HPPA_EXPR_14: /* pop - 14 */
1614 case R_HPPA_EXPR_17: /* pop - 17 */
1615 case R_HPPA_EXPR_12: /* pop - 12 */
1616 fprintf (stderr, "Relocation problem: ");
1617 fprintf (stderr, "Unimplemented reloc type %d, in module %s\n",
1618 r_type, abfd->filename);
1619 return (bfd_reloc_notsupported);
1621 fprintf (stderr, "Relocation problem : ");
1622 fprintf (stderr, "Unrecognized reloc type %d, in module %s\n",
1623 r_type, abfd->filename);
1624 return (bfd_reloc_dangerous);
1627 /* update the instruction word */
1628 bfd_put_32 (abfd, insn, hit_data);
1630 return (bfd_reloc_ok);
1634 struct elf_reloc_map
1636 unsigned char bfd_reloc_val;
1637 unsigned char elf_reloc_val;
1640 static CONST struct elf_reloc_map elf_hppa_reloc_map[] =
1642 {BFD_RELOC_NONE, R_HPPA_NONE,},
1643 {BFD_RELOC_HPPA_32, R_HPPA_32,},
1644 {BFD_RELOC_HPPA_11, R_HPPA_11,},
1645 {BFD_RELOC_HPPA_14, R_HPPA_14,},
1646 {BFD_RELOC_HPPA_17, R_HPPA_17,},
1647 {BFD_RELOC_HPPA_L21, R_HPPA_L21,},
1648 {BFD_RELOC_HPPA_R11, R_HPPA_R11,},
1649 {BFD_RELOC_HPPA_R14, R_HPPA_R14,},
1650 {BFD_RELOC_HPPA_R17, R_HPPA_R17,},
1651 {BFD_RELOC_HPPA_LS21, R_HPPA_LS21,},
1652 {BFD_RELOC_HPPA_RS11, R_HPPA_RS11,},
1653 {BFD_RELOC_HPPA_RS14, R_HPPA_RS14,},
1654 {BFD_RELOC_HPPA_RS17, R_HPPA_RS17,},
1655 {BFD_RELOC_HPPA_LD21, R_HPPA_LD21,},
1656 {BFD_RELOC_HPPA_RD11, R_HPPA_RD11,},
1657 {BFD_RELOC_HPPA_RD14, R_HPPA_RD14,},
1658 {BFD_RELOC_HPPA_RD17, R_HPPA_RD17,},
1659 {BFD_RELOC_HPPA_LR21, R_HPPA_LR21,},
1660 {BFD_RELOC_HPPA_RR14, R_HPPA_RR14,},
1661 {BFD_RELOC_HPPA_RR17, R_HPPA_RR17,},
1662 {BFD_RELOC_HPPA_GOTOFF_11, R_HPPA_GOTOFF_11,},
1663 {BFD_RELOC_HPPA_GOTOFF_14, R_HPPA_GOTOFF_14,},
1664 {BFD_RELOC_HPPA_GOTOFF_L21, R_HPPA_GOTOFF_L21,},
1665 {BFD_RELOC_HPPA_GOTOFF_R11, R_HPPA_GOTOFF_R11,},
1666 {BFD_RELOC_HPPA_GOTOFF_R14, R_HPPA_GOTOFF_R14,},
1667 {BFD_RELOC_HPPA_GOTOFF_LS21, R_HPPA_GOTOFF_LS21,},
1668 {BFD_RELOC_HPPA_GOTOFF_RS11, R_HPPA_GOTOFF_RS11,},
1669 {BFD_RELOC_HPPA_GOTOFF_RS14, R_HPPA_GOTOFF_RS14,},
1670 {BFD_RELOC_HPPA_GOTOFF_LD21, R_HPPA_GOTOFF_LD21,},
1671 {BFD_RELOC_HPPA_GOTOFF_RD11, R_HPPA_GOTOFF_RD11,},
1672 {BFD_RELOC_HPPA_GOTOFF_RD14, R_HPPA_GOTOFF_RD14,},
1673 {BFD_RELOC_HPPA_GOTOFF_LR21, R_HPPA_GOTOFF_LR21,},
1674 {BFD_RELOC_HPPA_GOTOFF_RR14, R_HPPA_GOTOFF_RR14,},
1675 {BFD_RELOC_HPPA_ABS_CALL_11, R_HPPA_ABS_CALL_11,},
1676 {BFD_RELOC_HPPA_ABS_CALL_14, R_HPPA_ABS_CALL_14,},
1677 {BFD_RELOC_HPPA_ABS_CALL_17, R_HPPA_ABS_CALL_17,},
1678 {BFD_RELOC_HPPA_ABS_CALL_L21, R_HPPA_ABS_CALL_L21,},
1679 {BFD_RELOC_HPPA_ABS_CALL_R11, R_HPPA_ABS_CALL_R11,},
1680 {BFD_RELOC_HPPA_ABS_CALL_R14, R_HPPA_ABS_CALL_R14,},
1681 {BFD_RELOC_HPPA_ABS_CALL_R17, R_HPPA_ABS_CALL_R17,},
1682 {BFD_RELOC_HPPA_ABS_CALL_LS21, R_HPPA_ABS_CALL_LS21,},
1683 {BFD_RELOC_HPPA_ABS_CALL_RS11, R_HPPA_ABS_CALL_RS11,},
1684 {BFD_RELOC_HPPA_ABS_CALL_RS14, R_HPPA_ABS_CALL_RS14,},
1685 {BFD_RELOC_HPPA_ABS_CALL_RS17, R_HPPA_ABS_CALL_RS17,},
1686 {BFD_RELOC_HPPA_ABS_CALL_LD21, R_HPPA_ABS_CALL_LD21,},
1687 {BFD_RELOC_HPPA_ABS_CALL_RD11, R_HPPA_ABS_CALL_RD11,},
1688 {BFD_RELOC_HPPA_ABS_CALL_RD14, R_HPPA_ABS_CALL_RD14,},
1689 {BFD_RELOC_HPPA_ABS_CALL_RD17, R_HPPA_ABS_CALL_RD17,},
1690 {BFD_RELOC_HPPA_ABS_CALL_LR21, R_HPPA_ABS_CALL_LR21,},
1691 {BFD_RELOC_HPPA_ABS_CALL_RR14, R_HPPA_ABS_CALL_RR14,},
1692 {BFD_RELOC_HPPA_ABS_CALL_RR17, R_HPPA_ABS_CALL_RR17,},
1693 {BFD_RELOC_HPPA_PCREL_CALL_11, R_HPPA_PCREL_CALL_11,},
1694 {BFD_RELOC_HPPA_PCREL_CALL_14, R_HPPA_PCREL_CALL_14,},
1695 {BFD_RELOC_HPPA_PCREL_CALL_17, R_HPPA_PCREL_CALL_17,},
1696 {BFD_RELOC_HPPA_PCREL_CALL_12, R_HPPA_PCREL_CALL_12,},
1697 {BFD_RELOC_HPPA_PCREL_CALL_L21, R_HPPA_PCREL_CALL_L21,},
1698 {BFD_RELOC_HPPA_PCREL_CALL_R11, R_HPPA_PCREL_CALL_R11,},
1699 {BFD_RELOC_HPPA_PCREL_CALL_R14, R_HPPA_PCREL_CALL_R14,},
1700 {BFD_RELOC_HPPA_PCREL_CALL_R17, R_HPPA_PCREL_CALL_R17,},
1701 {BFD_RELOC_HPPA_PCREL_CALL_LS21, R_HPPA_PCREL_CALL_LS21,},
1702 {BFD_RELOC_HPPA_PCREL_CALL_RS11, R_HPPA_PCREL_CALL_RS11,},
1703 {BFD_RELOC_HPPA_PCREL_CALL_RS14, R_HPPA_PCREL_CALL_RS14,},
1704 {BFD_RELOC_HPPA_PCREL_CALL_RS17, R_HPPA_PCREL_CALL_RS17,},
1705 {BFD_RELOC_HPPA_PCREL_CALL_LD21, R_HPPA_PCREL_CALL_LD21,},
1706 {BFD_RELOC_HPPA_PCREL_CALL_RD11, R_HPPA_PCREL_CALL_RD11,},
1707 {BFD_RELOC_HPPA_PCREL_CALL_RD14, R_HPPA_PCREL_CALL_RD14,},
1708 {BFD_RELOC_HPPA_PCREL_CALL_RD17, R_HPPA_PCREL_CALL_RD17,},
1709 {BFD_RELOC_HPPA_PCREL_CALL_LR21, R_HPPA_PCREL_CALL_LR21,},
1710 {BFD_RELOC_HPPA_PCREL_CALL_RR14, R_HPPA_PCREL_CALL_RR14,},
1711 {BFD_RELOC_HPPA_PCREL_CALL_RR17, R_HPPA_PCREL_CALL_RR17,},
1712 {BFD_RELOC_HPPA_PLABEL_32, R_HPPA_PLABEL_32,},
1713 {BFD_RELOC_HPPA_PLABEL_11, R_HPPA_PLABEL_11,},
1714 {BFD_RELOC_HPPA_PLABEL_14, R_HPPA_PLABEL_14,},
1715 {BFD_RELOC_HPPA_PLABEL_L21, R_HPPA_PLABEL_L21,},
1716 {BFD_RELOC_HPPA_PLABEL_R11, R_HPPA_PLABEL_R11,},
1717 {BFD_RELOC_HPPA_PLABEL_R14, R_HPPA_PLABEL_R14,},
1718 {BFD_RELOC_HPPA_DLT_32, R_HPPA_DLT_32,},
1719 {BFD_RELOC_HPPA_DLT_11, R_HPPA_DLT_11,},
1720 {BFD_RELOC_HPPA_DLT_14, R_HPPA_DLT_14,},
1721 {BFD_RELOC_HPPA_DLT_L21, R_HPPA_DLT_L21,},
1722 {BFD_RELOC_HPPA_DLT_R11, R_HPPA_DLT_R11,},
1723 {BFD_RELOC_HPPA_DLT_R14, R_HPPA_DLT_R14,},
1724 {BFD_RELOC_HPPA_UNWIND_ENTRY, R_HPPA_UNWIND_ENTRY,},
1725 {BFD_RELOC_HPPA_UNWIND_ENTRIES, R_HPPA_UNWIND_ENTRIES,},
1728 static reloc_howto_type *
1729 elf_hppa_reloc_type_lookup (arch, code)
1730 bfd_arch_info_type *arch;
1731 bfd_reloc_code_real_type code;
1735 if ((int) code < (int) R_HPPA_UNIMPLEMENTED)
1737 BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
1738 return &elf_hppa_howto_table[(int) code];
1741 return (reloc_howto_type *) 0;
1744 #define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup
1748 DEFUN (elf_hppa_tc_symbol, (abfd, symbolP, sym_idx),
1750 elf32_symbol_type * symbolP AND
1753 symext_chainS *symextP;
1754 unsigned int arg_reloc;
1756 if (!(symbolP->symbol.flags & BSF_FUNCTION))
1759 if (!((symbolP->symbol.flags & BSF_EXPORT) ||
1760 (symbolP->symbol.flags & BSF_GLOBAL)))
1763 arg_reloc = symbolP->tc_data.hppa_arg_reloc;
1765 symextP = (symext_chainS *) bfd_alloc (abfd, sizeof (symext_chainS) * 2);
1767 symextP[0].entry = ELF32_HPPA_SX_WORD (HPPA_SXT_SYMNDX, sym_idx);
1768 symextP[0].next = &symextP[1];
1770 symextP[1].entry = ELF32_HPPA_SX_WORD (HPPA_SXT_ARG_RELOC, arg_reloc);
1771 symextP[1].next = NULL;
1773 if (symext_rootP == NULL)
1775 symext_rootP = &symextP[0];
1776 symext_lastP = &symextP[1];
1780 symext_lastP->next = &symextP[0];
1781 symext_lastP = &symextP[1];
1785 static symext_entryS *symextn_contents = NULL;
1786 static unsigned int symextn_contents_real_size = 0;
1789 DEFUN (elf_hppa_tc_make_sections, (abfd, ignored),
1793 symext_chainS *symextP;
1794 symext_entryS *outbound_symexts;
1798 extern char *stub_section_contents; /* forward declaration */
1799 void hppa_elf_stub_finish (); /* forward declaration */
1800 asection *symextn_sec;
1802 hppa_elf_stub_finish (abfd);
1804 if (symext_rootP == NULL)
1807 for (n = 0, symextP = symext_rootP; symextP; symextP = symextP->next, ++n)
1810 size = sizeof (symext_entryS) * n;
1811 symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME);
1812 if (symextn_sec == (asection *) 0)
1814 symextn_sec = bfd_make_section (abfd, SYMEXTN_SECTION_NAME);
1815 bfd_set_section_flags (abfd,
1817 SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE | SEC_READONLY);
1818 symextn_sec->output_section = symextn_sec;
1819 symextn_sec->output_offset = 0;
1820 bfd_set_section_alignment (abfd, symextn_sec, 2);
1822 symextn_contents = (symext_entryS *) bfd_alloc (abfd, size);
1824 for (i = 0, symextP = symext_rootP; symextP; symextP = symextP->next, ++i)
1825 symextn_contents[i] = symextP->entry;
1826 symextn_contents_real_size = size;
1827 bfd_set_section_size (abfd, symextn_sec, symextn_contents_real_size);
1832 /* Support for HP PA-RISC stub generation.
1836 Center for Software Science
1837 Department of Computer Science
1843 HP-PA calling conventions state:
1845 1. an argument relocation stub is required whenever the callee and
1846 caller argument relocation bits do not match exactly. The exception
1847 to this rule is if either the caller or callee argument relocation
1848 bit are 00 (do not relocate).
1850 2. The linker can optionally add a symbol record for the stub so that
1851 the stub can be reused. The symbol record will be the same as the
1852 original export symbol record, except that the relocation bits will
1853 reflect the input of the stub, the type would be STUB and the symbol
1854 value will be the location of the relocation stub.
1858 Stubs can be inserted *before* the section of the caller. The stubs
1859 can be treated as calls to code that manipulates the arguments.
1866 HPPA_STUB_ARG_RELOC,
1867 HPPA_STUB_LONG_BRANCH
1871 elf32_hppa_get_sym_extn (abfd, sym, type)
1876 /* This function finds the symbol extension record of the */
1877 /* specified type for the specified symbol. It returns the */
1878 /* value of the symbol extension record. */
1879 symext_entryS retval;
1884 retval = (symext_entryS) 0;
1886 case HPPA_SXT_SYMNDX:
1887 retval = (symext_entryS) 0; /* XXX: need to fix this */
1889 case HPPA_SXT_ARG_RELOC:
1891 elf32_symbol_type *esymP = (elf32_symbol_type *) sym;
1893 retval = (symext_entryS) esymP->tc_data.hppa_arg_reloc;
1901 typedef struct Elf32_hppa_Stub_description_struct
1903 bfd *this_bfd; /* bfd to which this stub */
1905 asection *stub_sec; /* stub section for this bfd */
1906 unsigned relocs_allocated_cnt; /* count of relocations for this stub section */
1908 unsigned allocated_size;
1909 int *stub_secp; /* pointer to the next available location in the buffer */
1910 char *stub_contents; /* contents of the stubs for this bfd */
1913 Elf32_hppa_Stub_description;
1915 typedef struct Elf32_hppa_Stub_list_struct
1917 Elf32_hppa_Stub_description *stub;
1918 struct Elf32_hppa_Stub_list_struct *next;
1919 } Elf32_hppa_Stub_list;
1921 static Elf32_hppa_Stub_list *elf_hppa_stub_rootP = NULL;
1923 /* Locate the stub section information for the given bfd. */
1924 static Elf32_hppa_Stub_description *
1925 find_stubs (abfd, stub_sec)
1929 Elf32_hppa_Stub_list *stubP;
1931 for (stubP = elf_hppa_stub_rootP; stubP; stubP = stubP->next)
1933 if (stubP->stub->this_bfd == abfd
1934 && stubP->stub->stub_sec == stub_sec)
1938 return (Elf32_hppa_Stub_description *) NULL;
1941 static Elf32_hppa_Stub_description *
1942 new_stub (abfd, stub_sec)
1946 Elf32_hppa_Stub_description *stub = find_stubs (abfd, stub_sec);
1951 stub = (Elf32_hppa_Stub_description *) bfd_zalloc (abfd, sizeof (Elf32_hppa_Stub_description));
1952 stub->this_bfd = abfd;
1953 stub->stub_sec = stub_sec;
1954 stub->real_size = 0;
1955 stub->allocated_size = 0;
1956 stub->stub_contents = NULL;
1957 stub->stub_secp = NULL;
1964 Elf32_hppa_Stub_description *stub;
1966 Elf32_hppa_Stub_list *new_entry;
1968 new_entry = (Elf32_hppa_Stub_list *) bfd_zalloc (stub->this_bfd, sizeof (Elf32_hppa_Stub_list));
1972 new_entry->stub = stub;
1974 if (elf_hppa_stub_rootP)
1976 new_entry->next = elf_hppa_stub_rootP;
1977 elf_hppa_stub_rootP = new_entry;
1981 new_entry->next = (Elf32_hppa_Stub_list *) NULL;
1982 elf_hppa_stub_rootP = new_entry;
1987 bfd_error = no_memory;
1988 bfd_perror ("add_stub");
1993 #define RETURN_VALUE 1
1995 #define NO_ARG_RELOC 0
1998 #define ARG_RELOC_ERR 3
2011 static CONST char *CONST reloc_type_strings[] =
2013 "NONE", "GR->FR", "FR->GR", "ERROR"
2016 static CONST char mismatches[4][4] =
2017 { /* CALLEE NONE CALLEE GR CALLEE FR CALLEE FU */
2019 {NO_ARG_RELOC, NO_ARG_RELOC, NO_ARG_RELOC, NO_ARG_RELOC},
2021 {NO_ARG_RELOC, NO_ARG_RELOC, R_TO_FR, R_TO_FR},
2023 {NO_ARG_RELOC, FR_TO_R, NO_ARG_RELOC, NO_ARG_RELOC},
2025 {NO_ARG_RELOC, FR_TO_R, NO_ARG_RELOC, NO_ARG_RELOC},
2028 static CONST char retval_mismatches[4][4] =
2029 { /* CALLEE NONE CALLEE GR CALLEE FR CALLEE FU */
2031 {NO_ARG_RELOC, NO_ARG_RELOC, NO_ARG_RELOC, NO_ARG_RELOC},
2033 {NO_ARG_RELOC, NO_ARG_RELOC, R_TO_FR, R_TO_FR},
2035 {NO_ARG_RELOC, FR_TO_R, NO_ARG_RELOC, NO_ARG_RELOC},
2037 {NO_ARG_RELOC, FR_TO_R, NO_ARG_RELOC, NO_ARG_RELOC},
2041 type_of_mismatch (caller_bits, callee_bits, type)
2049 return mismatches[caller_bits][callee_bits];
2051 return retval_mismatches[caller_bits][callee_bits];
2057 #define EXTRACT_ARBITS(ar,which) ((ar) >> (8-(which*2))) & 3
2059 #include "hppa_stubs.h"
2061 #define NEW_INSTRUCTION(desc,insn) \
2062 *((desc)->stub_secp)++ = (insn); \
2063 (desc)->real_size += sizeof(int); \
2064 bfd_set_section_size((desc)->this_bfd,(desc)->stub_sec,(desc)->real_size);
2067 hppa_elf_stub_finish (output_bfd)
2070 extern bfd_error_vector_type bfd_error_vector;
2071 Elf32_hppa_Stub_list *stub_list = elf_hppa_stub_rootP;
2072 /* All the stubs have been built. Finish up building */
2073 /* stub section. Apply relocations to the section. */
2075 for (; stub_list; stub_list = stub_list->next)
2077 if (stub_list->stub->real_size)
2079 bfd *stub_bfd = stub_list->stub->this_bfd;
2080 asection *stub_sec = bfd_get_section_by_name (stub_bfd, ".hppa_linker_stubs");
2081 bfd_size_type reloc_size;
2082 arelent **reloc_vector;
2084 BFD_ASSERT (stub_sec == stub_list->stub->stub_sec);
2085 reloc_size = bfd_get_reloc_upper_bound (stub_bfd, stub_sec);
2086 reloc_vector = (arelent **) alloca (reloc_size);
2088 BFD_ASSERT (stub_sec);
2090 /* We are not relaxing the section, so just copy the size info */
2091 stub_sec->_cooked_size = stub_sec->_raw_size;
2092 stub_sec->reloc_done = true;
2095 if (bfd_canonicalize_reloc (stub_bfd,
2098 output_bfd->outsymbols))
2101 for (parent = reloc_vector; *parent != (arelent *) NULL;
2104 bfd_reloc_status_type r =
2105 bfd_perform_relocation (stub_bfd,
2107 stub_list->stub->stub_contents,
2111 if (r != bfd_reloc_ok)
2115 case bfd_reloc_undefined:
2116 bfd_error_vector.undefined_symbol (*parent, NULL);
2118 case bfd_reloc_dangerous:
2119 bfd_error_vector.reloc_dangerous (*parent, NULL);
2121 case bfd_reloc_outofrange:
2122 case bfd_reloc_overflow:
2123 bfd_error_vector.reloc_value_truncated (*parent, NULL);
2133 bfd_set_section_contents (output_bfd,
2135 stub_list->stub->stub_contents,
2137 stub_list->stub->real_size);
2139 free (reloc_vector);
2145 hppa_elf_stub_branch_reloc (stub_desc, /* the bfd */
2146 output_bfd, /* the output bfd */
2147 stub_sym, /* the stub symbol */
2148 offset) /* the offset within the stub buffer (pre-calculated) */
2149 Elf32_hppa_Stub_description *stub_desc;
2154 /* Allocate a new relocation entry. */
2158 if (stub_desc->relocs_allocated_cnt == stub_desc->stub_sec->reloc_count)
2160 if (stub_desc->stub_sec->relocation == NULL)
2162 stub_desc->relocs_allocated_cnt = STUB_RELOC_INCR;
2163 size = sizeof (arelent) * stub_desc->relocs_allocated_cnt;
2164 stub_desc->stub_sec->relocation = (arelent *) zalloc (size);
2168 stub_desc->relocs_allocated_cnt += STUB_RELOC_INCR;
2169 size = sizeof (arelent) * stub_desc->relocs_allocated_cnt;
2170 stub_desc->stub_sec->relocation = (arelent *) realloc (stub_desc->stub_sec->relocation,
2175 /* Fill in the details. */
2176 relent.address = offset;
2178 relent.sym_ptr_ptr = (asymbol **) bfd_zalloc (stub_desc->this_bfd, sizeof (asymbol *));
2179 BFD_ASSERT (relent.sym_ptr_ptr);
2181 relent.sym_ptr_ptr[0] = stub_sym;
2182 relent.howto = bfd_reloc_type_lookup (stub_desc->this_bfd, R_HPPA_ABS_CALL_17);
2184 /* Save it in the array of relocations for the stub section. */
2186 memcpy (&stub_desc->stub_sec->relocation[stub_desc->stub_sec->reloc_count++],
2192 hppa_elf_build_arg_reloc_stub (abfd, output_bfd, reloc_entry, stub_types)
2195 arelent *reloc_entry;
2198 asection *stub_sec = bfd_get_section_by_name (abfd, ".hppa_linker_stubs");
2199 Elf32_hppa_Stub_description *stub_desc = find_stubs (abfd, stub_sec);
2200 asymbol *stub_sym = NULL;
2201 asection *output_text_section = bfd_get_section_by_name (output_bfd, ".text");
2203 char stub_sym_name[128];
2207 BFD_ASSERT (stub_desc == NULL);
2208 stub_sec = bfd_make_section (abfd, ".hppa_linker_stubs");
2209 bfd_set_section_flags (output_bfd,
2211 SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_READONLY);
2212 stub_sec->output_section = output_text_section->output_section;
2213 stub_sec->output_offset = 0;
2214 bfd_set_section_alignment (output_bfd, stub_sec, 2);
2215 stub_desc = new_stub (abfd, stub_sec);
2216 add_stub (stub_desc);
2219 /* make sure we have a stub descriptor structure */
2223 stub_desc = new_stub (abfd, stub_sec);
2224 add_stub (stub_desc);
2227 /* allocate some space to write the stub */
2229 if (!stub_desc->stub_contents)
2231 stub_desc->allocated_size = STUB_BUFFER_INCR;
2232 stub_desc->stub_contents = (char *) malloc (STUB_BUFFER_INCR);
2234 else if ((stub_desc->allocated_size - stub_desc->real_size) < STUB_MAX_SIZE)
2236 stub_desc->allocated_size = stub_desc->allocated_size + STUB_BUFFER_INCR;
2237 stub_desc->stub_contents = (char *) realloc (stub_desc->stub_contents,
2238 stub_desc->allocated_size);
2241 stub_desc->stub_secp = (int *) (stub_desc->stub_contents + stub_desc->real_size);
2243 /* create a symbol to point to this stub */
2244 stub_sym = bfd_make_empty_symbol (abfd);
2245 sprintf (stub_sym_name,
2246 "_stub_%s_%02d_%02d_%02d_%02d_%02d\000",
2247 reloc_entry->sym_ptr_ptr[0]->name,
2248 stub_types[0], stub_types[1], stub_types[2], stub_types[3], stub_types[4]);
2249 stub_sym->name = bfd_zalloc (output_bfd, strlen (stub_sym_name) + 1);
2250 strcpy ((char *) stub_sym->name, stub_sym_name);
2251 stub_sym->value = (int) stub_desc->stub_secp - (int) stub_desc->stub_contents;
2252 stub_sym->section = stub_sec;
2253 stub_sym->flags = BSF_LOCAL | BSF_FUNCTION;
2255 /* redirect the original relocation from the old symbol (a function) */
2256 /* to the stub (the stub calls the function). */
2257 /* XXX do we need to change the relocation type? */
2258 reloc_entry->sym_ptr_ptr = (asymbol **) bfd_zalloc (stub_desc->this_bfd, sizeof (asymbol *));
2259 reloc_entry->sym_ptr_ptr[0] = stub_sym;
2261 /* generate the beginning common section for all stubs */
2263 NEW_INSTRUCTION (stub_desc, ADDI_8_SP);
2265 /* generate the code to move the arguments around */
2266 for (i = ARG0; i < ARG3; i++)
2268 if (stub_types[i] != NO_ARG_RELOC)
2270 /* A stub is needed */
2271 switch (stub_types[i])
2277 NEW_INSTRUCTION (stub_desc, LDWS_M8SP_ARG0);
2278 NEW_INSTRUCTION (stub_desc, FSTWS_FARG0_M8SP);
2281 NEW_INSTRUCTION (stub_desc, LDWS_M8SP_ARG1);
2282 NEW_INSTRUCTION (stub_desc, FSTWS_FARG1_M8SP);
2285 NEW_INSTRUCTION (stub_desc, LDWS_M8SP_ARG1);
2286 NEW_INSTRUCTION (stub_desc, FSTWS_FARG1_M8SP);
2289 NEW_INSTRUCTION (stub_desc, LDWS_M8SP_ARG1);
2290 NEW_INSTRUCTION (stub_desc, FSTWS_FARG1_M8SP);
2299 NEW_INSTRUCTION (stub_desc, FLDWS_M8SP_FARG0);
2300 NEW_INSTRUCTION (stub_desc, STWS_ARG0_M8SP);
2303 NEW_INSTRUCTION (stub_desc, FLDWS_M8SP_FARG1);
2304 NEW_INSTRUCTION (stub_desc, STWS_ARG1_M8SP);
2307 NEW_INSTRUCTION (stub_desc, FLDWS_M8SP_FARG1);
2308 NEW_INSTRUCTION (stub_desc, STWS_ARG1_M8SP);
2311 NEW_INSTRUCTION (stub_desc, FLDWS_M8SP_FARG1);
2312 NEW_INSTRUCTION (stub_desc, STWS_ARG1_M8SP);
2321 /* generate the branch to the target routine */
2322 NEW_INSTRUCTION (stub_desc, STW_RP_M8SP); /* First, save the return address */
2323 NEW_INSTRUCTION (stub_desc, BL_XXX_RP); /* set up a branch to the function */
2325 /* Fix the branch to the function. We can do this with a relocation. */
2327 hppa_elf_stub_branch_reloc (stub_desc,
2328 output_bfd, /* the output bfd */
2329 stub_sym, /* the stub symbol */
2330 (int) stub_desc->stub_secp - (int) stub_desc->stub_contents - 4); /* the offset within the stub buffer */
2332 NEW_INSTRUCTION (stub_desc, NOP);
2334 /* generate the code to move the return value around */
2336 if (stub_types[i] != NO_ARG_RELOC)
2338 /* A stub is needed */
2339 switch (stub_types[i])
2342 NEW_INSTRUCTION (stub_desc, LDWS_M8SP_RET0);
2343 NEW_INSTRUCTION (stub_desc, FSTWS_FRET0_M8SP);
2347 NEW_INSTRUCTION (stub_desc, FLDWS_M8SP_FRET0);
2348 NEW_INSTRUCTION (stub_desc, STWS_RET0_M8SP);
2353 /* generate the ending common section for all stubs */
2355 NEW_INSTRUCTION (stub_desc, LDW_M8SP_RP); /* restore return address */
2356 NEW_INSTRUCTION (stub_desc, SUBI_8_SP);
2358 /* XXX: can we assume this is a save return? */
2359 NEW_INSTRUCTION (stub_desc, BV_N_0RP);
2365 hppa_elf_arg_reloc_needed_p (abfd, reloc_entry, stub_types)
2367 arelent *reloc_entry;
2371 /* If the symbol is still undefined, there is */
2372 /* no way to know if a stub is required. */
2374 if (reloc_entry->sym_ptr_ptr[0] && reloc_entry->sym_ptr_ptr[0]->section != &bfd_und_section)
2376 symext_entryS caller_ar = (symext_entryS) ELF32_HPPA_R_ARG_RELOC (reloc_entry->addend);
2377 symext_entryS callee_ar = elf32_hppa_get_sym_extn (abfd,
2378 reloc_entry->sym_ptr_ptr[0],
2379 HPPA_SXT_ARG_RELOC);
2381 /* Now, determine if a stub is */
2382 /* required. A stub is required if they the callee and caller */
2383 /* argument relocation bits are both nonzero and not equal. */
2385 if (caller_ar && callee_ar)
2387 /* Both are non-zero, we need to do further checking. */
2388 /* First, check if there is a return value relocation to be done */
2392 callee_loc[RETVAL] = EXTRACT_ARBITS (callee_ar, RETVAL);
2393 caller_loc[RETVAL] = EXTRACT_ARBITS (caller_ar, RETVAL);
2394 callee_loc[ARG0] = EXTRACT_ARBITS (callee_ar, ARG0);
2395 caller_loc[ARG0] = EXTRACT_ARBITS (caller_ar, ARG0);
2396 callee_loc[ARG1] = EXTRACT_ARBITS (callee_ar, ARG1);
2397 caller_loc[ARG1] = EXTRACT_ARBITS (caller_ar, ARG1);
2398 callee_loc[ARG2] = EXTRACT_ARBITS (callee_ar, ARG2);
2399 caller_loc[ARG2] = EXTRACT_ARBITS (caller_ar, ARG2);
2400 callee_loc[ARG3] = EXTRACT_ARBITS (callee_ar, ARG3);
2401 caller_loc[ARG3] = EXTRACT_ARBITS (caller_ar, ARG3);
2403 /* Check some special combinations. For */
2404 /* example, if FU appears in ARG1 or ARG3, we */
2405 /* can move it to ARG0 or ARG2, respectively. */
2407 if (caller_loc[ARG0] == AR_FU || caller_loc[ARG1] == AR_FU)
2409 caller_loc[ARG0] = AR_FU;
2410 caller_loc[ARG1] = AR_NO;
2412 if (caller_loc[ARG2] == AR_FU || caller_loc[ARG3] == AR_FU)
2414 caller_loc[ARG2] = AR_FU;
2415 caller_loc[ARG3] = AR_NO;
2417 if (callee_loc[ARG0] == AR_FU || callee_loc[ARG1] == AR_FU)
2419 callee_loc[ARG0] = AR_FU;
2420 callee_loc[ARG1] = AR_NO;
2422 if (callee_loc[ARG2] == AR_FU || callee_loc[ARG3] == AR_FU)
2424 callee_loc[ARG2] = AR_FU;
2425 callee_loc[ARG3] = AR_NO;
2428 stub_types[ARG0] = type_of_mismatch (caller_loc[ARG0], callee_loc[ARG0], ARGUMENTS);
2429 stub_types[ARG1] = type_of_mismatch (caller_loc[ARG1], callee_loc[ARG1], ARGUMENTS);
2430 stub_types[ARG2] = type_of_mismatch (caller_loc[ARG2], callee_loc[ARG2], ARGUMENTS);
2431 stub_types[ARG3] = type_of_mismatch (caller_loc[ARG3], callee_loc[ARG3], ARGUMENTS);
2432 stub_types[RETVAL] = type_of_mismatch (caller_loc[RETVAL], callee_loc[RETVAL], RETURN_VALUE);
2434 /* XXX for now, just report a */
2437 /* But, when we start building stubs, here are the steps involved: */
2438 /* 1. Determine what argument registers need to relocated. This */
2439 /* step is already done here. */
2440 /* 2. Build the appropriate stub in the .hppa_linker_stubs section. */
2441 /* This section should never appear in an object file. It is */
2442 /* only used internally. The output_section of the */
2443 /* .hppa_linker_stubs section is the .text section of the */
2445 /* 3. Build a symbol that is used (internally only) as the entry */
2446 /* point of the stub. */
2447 /* 4. Change the instruction of the original branch into a branch to */
2448 /* the stub routine. */
2449 /* 5. Build a relocation entry for the instruction of the original */
2450 /* branch to be R_HPPA_ABS_CALL to the stub routine. */
2460 fprintf (stderr, "Stub needed for %s @ %s+0x%x: callee/caller ar=0x%x/0x%x ",
2461 reloc_entry->sym_ptr_ptr[0]->name,
2462 abfd->filename, reloc_entry->address,
2463 callee_ar, caller_ar);
2464 for (i = ARG0; i < RETVAL; i++)
2466 if (stub_types[i] != NO_ARG_RELOC)
2468 fprintf (stderr, "%s%d: %s ",
2469 i == RETVAL ? "ret" : "arg",
2470 i == RETVAL ? 0 : i,
2471 reloc_type_strings[stub_types[i]]);
2474 fprintf (stderr, "\n");
2485 hppa_elf_stub_check (abfd, output_bfd, reloc_entry)
2488 arelent *reloc_entry;
2492 switch (reloc_entry->howto->type)
2494 case R_HPPA_ABS_CALL_11: /* Symbol + Addend 11 */
2495 case R_HPPA_ABS_CALL_14: /* Symbol + Addend 14 */
2496 case R_HPPA_ABS_CALL_17: /* Symbol + Addend 17 */
2497 case R_HPPA_ABS_CALL_L21: /* L (Symbol, Addend) 21 */
2498 case R_HPPA_ABS_CALL_R11: /* R (Symbol, Addend) 11 */
2499 case R_HPPA_ABS_CALL_R14: /* R (Symbol, Addend) 14 */
2500 case R_HPPA_ABS_CALL_R17: /* R (Symbol, Addend) 17 */
2501 case R_HPPA_ABS_CALL_LS21: /* LS(Symbol, Addend) 21 */
2502 case R_HPPA_ABS_CALL_RS11: /* RS(Symbol, Addend) 11 */
2503 case R_HPPA_ABS_CALL_RS14: /* RS(Symbol, Addend) 14 */
2504 case R_HPPA_ABS_CALL_RS17: /* RS(Symbol, Addend) 17 */
2505 case R_HPPA_ABS_CALL_LD21: /* LD(Symbol, Addend) 21 */
2506 case R_HPPA_ABS_CALL_RD11: /* RD(Symbol, Addend) 11 */
2507 case R_HPPA_ABS_CALL_RD14: /* RD(Symbol, Addend) 14 */
2508 case R_HPPA_ABS_CALL_RD17: /* RD(Symbol, Addend) 17 */
2509 case R_HPPA_ABS_CALL_LR21: /* LR(Symbol, Addend) 21 */
2510 case R_HPPA_ABS_CALL_RR14: /* RR(Symbol, Addend) 14 */
2511 case R_HPPA_ABS_CALL_RR17: /* RR(Symbol, Addend) 17 */
2513 case R_HPPA_PCREL_CALL_11: /* Symbol - PC + Addend 11 */
2514 case R_HPPA_PCREL_CALL_14: /* Symbol - PC + Addend 14 */
2515 case R_HPPA_PCREL_CALL_17: /* Symbol - PC + Addend 17 */
2516 case R_HPPA_PCREL_CALL_12: /* Symbol - PC + Addend 12 */
2517 case R_HPPA_PCREL_CALL_L21:/* L (Symbol - PC, Addend) 21 */
2518 case R_HPPA_PCREL_CALL_R11:/* R (Symbol - PC, Addend) 11 */
2519 case R_HPPA_PCREL_CALL_R14:/* R (Symbol - PC, Addend) 14 */
2520 case R_HPPA_PCREL_CALL_R17:/* R (Symbol - PC, Addend) 17 */
2521 case R_HPPA_PCREL_CALL_LS21: /* LS(Symbol - PC, Addend) 21 */
2522 case R_HPPA_PCREL_CALL_RS11: /* RS(Symbol - PC, Addend) 11 */
2523 case R_HPPA_PCREL_CALL_RS14: /* RS(Symbol - PC, Addend) 14 */
2524 case R_HPPA_PCREL_CALL_RS17: /* RS(Symbol - PC, Addend) 17 */
2525 case R_HPPA_PCREL_CALL_LD21: /* LD(Symbol - PC, Addend) 21 */
2526 case R_HPPA_PCREL_CALL_RD11: /* RD(Symbol - PC, Addend) 11 */
2527 case R_HPPA_PCREL_CALL_RD14: /* RD(Symbol - PC, Addend) 14 */
2528 case R_HPPA_PCREL_CALL_RD17: /* RD(Symbol - PC, Addend) 17 */
2529 case R_HPPA_PCREL_CALL_LR21: /* LR(Symbol - PC, Addend) 21 */
2530 case R_HPPA_PCREL_CALL_RR14: /* RR(Symbol - PC, Addend) 14 */
2531 case R_HPPA_PCREL_CALL_RR17: /* RR(Symbol - PC, Addend) 17 */
2532 if (hppa_elf_arg_reloc_needed_p (abfd, reloc_entry, stub_types))
2534 /* generate a stub */
2535 return hppa_elf_build_arg_reloc_stub (abfd, output_bfd, reloc_entry, stub_types);
2543 return reloc_entry->sym_ptr_ptr[0];
2546 #define STUB_SYM_BUFFER_INC 5
2549 hppa_look_for_stubs_in_section (abfd, output_bfd, asec, syms, new_sym_cnt)
2558 asymbol *new_syms = (asymbol *) NULL;
2562 /* Relocations are in different places depending on whether this is */
2563 /* an output section or an input section. Also, the relocations are */
2564 /* in different forms. Sigh. */
2565 /* Luckily, we have bfd_canonicalize_reloc() to straighten this out for us. */
2567 /* if ( asec->orelocation || asec->relocation ) { */
2568 if (asec->reloc_count > 0)
2570 arelent **reloc_vector = (arelent **) alloca (asec->reloc_count * (sizeof (arelent *) + 1));
2572 bfd_canonicalize_reloc (abfd, asec, reloc_vector, syms);
2573 for (i = 0; i < asec->reloc_count; i++)
2578 if ( asec->orelocation )
2579 rle = asec->orelocation[i];
2581 rle = asec->relocation+i;
2584 arelent *rle = reloc_vector[i];
2586 switch (rle->howto->type)
2588 case R_HPPA_ABS_CALL_11: /* Symbol + Addend 11 */
2589 case R_HPPA_ABS_CALL_14: /* Symbol + Addend 14 */
2590 case R_HPPA_ABS_CALL_17: /* Symbol + Addend 17 */
2591 case R_HPPA_ABS_CALL_L21: /* L (Symbol, Addend) 21 */
2592 case R_HPPA_ABS_CALL_R11: /* R (Symbol, Addend) 11 */
2593 case R_HPPA_ABS_CALL_R14: /* R (Symbol, Addend) 14 */
2594 case R_HPPA_ABS_CALL_R17: /* R (Symbol, Addend) 17 */
2595 case R_HPPA_ABS_CALL_LS21: /* LS(Symbol, Addend) 21 */
2596 case R_HPPA_ABS_CALL_RS11: /* RS(Symbol, Addend) 11 */
2597 case R_HPPA_ABS_CALL_RS14: /* RS(Symbol, Addend) 14 */
2598 case R_HPPA_ABS_CALL_RS17: /* RS(Symbol, Addend) 17 */
2599 case R_HPPA_ABS_CALL_LD21: /* LD(Symbol, Addend) 21 */
2600 case R_HPPA_ABS_CALL_RD11: /* RD(Symbol, Addend) 11 */
2601 case R_HPPA_ABS_CALL_RD14: /* RD(Symbol, Addend) 14 */
2602 case R_HPPA_ABS_CALL_RD17: /* RD(Symbol, Addend) 17 */
2603 case R_HPPA_ABS_CALL_LR21: /* LR(Symbol, Addend) 21 */
2604 case R_HPPA_ABS_CALL_RR14: /* RR(Symbol, Addend) 14 */
2605 case R_HPPA_ABS_CALL_RR17: /* RR(Symbol, Addend) 17 */
2607 case R_HPPA_PCREL_CALL_11: /* Symbol - PC + Addend 11 */
2608 case R_HPPA_PCREL_CALL_14: /* Symbol - PC + Addend 14 */
2609 case R_HPPA_PCREL_CALL_17: /* Symbol - PC + Addend 17 */
2610 case R_HPPA_PCREL_CALL_12: /* Symbol - PC + Addend 12 */
2611 case R_HPPA_PCREL_CALL_L21: /* L (Symbol - PC, Addend) 21 */
2612 case R_HPPA_PCREL_CALL_R11: /* R (Symbol - PC, Addend) 11 */
2613 case R_HPPA_PCREL_CALL_R14: /* R (Symbol - PC, Addend) 14 */
2614 case R_HPPA_PCREL_CALL_R17: /* R (Symbol - PC, Addend) 17 */
2615 case R_HPPA_PCREL_CALL_LS21: /* LS(Symbol - PC, Addend) 21 */
2616 case R_HPPA_PCREL_CALL_RS11: /* RS(Symbol - PC, Addend) 11 */
2617 case R_HPPA_PCREL_CALL_RS14: /* RS(Symbol - PC, Addend) 14 */
2618 case R_HPPA_PCREL_CALL_RS17: /* RS(Symbol - PC, Addend) 17 */
2619 case R_HPPA_PCREL_CALL_LD21: /* LD(Symbol - PC, Addend) 21 */
2620 case R_HPPA_PCREL_CALL_RD11: /* RD(Symbol - PC, Addend) 11 */
2621 case R_HPPA_PCREL_CALL_RD14: /* RD(Symbol - PC, Addend) 14 */
2622 case R_HPPA_PCREL_CALL_RD17: /* RD(Symbol - PC, Addend) 17 */
2623 case R_HPPA_PCREL_CALL_LR21: /* LR(Symbol - PC, Addend) 21 */
2624 case R_HPPA_PCREL_CALL_RR14: /* RR(Symbol - PC, Addend) 14 */
2625 case R_HPPA_PCREL_CALL_RR17: /* RR(Symbol - PC, Addend) 17 */
2626 if (hppa_elf_arg_reloc_needed_p (abfd, rle, stub_types))
2628 /* generate a stub */
2629 /* keep track of the new symbol */
2630 if (new_cnt == new_max)
2632 new_max += STUB_SYM_BUFFER_INC;
2633 new_syms = (asymbol *) realloc (new_syms, new_max * sizeof (asymbol));
2635 new_syms[new_cnt++] = *(hppa_elf_build_arg_reloc_stub (abfd, output_bfd, rle, stub_types));
2645 *new_sym_cnt = new_cnt;
2650 hppa_look_for_stubs (abfd, output_bfd)
2654 /* bfd_map_over_sections(abfd,hppa_look_for_stubs_in_section,(PTR)output_bfd,NULL); */
2658 DEFUN (hppa_elf_get_section_contents, (abfd, section, location, offset, count),
2663 bfd_size_type count)
2665 /* if this is the linker stub section, then we have the */
2666 /* section contents in memory rather than on disk. */
2667 if (strcmp (section->name, ".hppa_linker_stubs") == 0)
2669 Elf32_hppa_Stub_description *stub_desc = find_stubs (abfd, section);
2673 if ((bfd_size_type) (offset + count) > section->_raw_size)
2674 return (false); /* on error */
2675 if ((bfd_size_type) (offset + count) > stub_desc->real_size)
2676 return (false); /* on error */
2678 memcpy (location, stub_desc->stub_contents + offset, count);
2681 /* if this is the symbol extension section, then we have the */
2682 /* section contents in memory rather than on disk. */
2683 else if (strcmp (section->name, ".hppa_symextn") == 0)
2687 if ((bfd_size_type) (offset + count) > section->_raw_size)
2688 return (false); /* on error */
2689 if ((bfd_size_type) (offset + count) > symextn_contents_real_size)
2690 return (false); /* on error */
2692 memcpy (location, symextn_contents + offset, count);
2696 return bfd_generic_get_section_contents (abfd, section, location, offset, count);
2700 DEFUN (elf_info_to_howto, (abfd, cache_ptr, dst),
2702 arelent * cache_ptr AND
2703 Elf32_Internal_Rela * dst)
2708 #define TARGET_BIG_SYM bfd_elf32_hppa_vec
2709 #define TARGET_BIG_NAME "elf32-hppa"
2710 #define ELF_ARCH bfd_arch_hppa
2712 #include "elf32-target.h"