15635b845846facd1c0c5b5cd4ef92a0009b3e42
[deliverable/binutils-gdb.git] / bfd / som.c
1 /* bfd back-end for HP PA-RISC SOM objects.
2 Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3
4 Contributed by the Center for Software Science at the
5 University of Utah (pa-gdb-bugs@cs.utah.edu).
6
7 This file is part of BFD, the Binary File Descriptor library.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22
23 #include "bfd.h"
24 #include "sysdep.h"
25
26 #if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD)
27
28 #include "libbfd.h"
29 #include "som.h"
30 #include "libhppa.h"
31
32 #include <stdio.h>
33 #include <sys/types.h>
34 #include <sys/param.h>
35 #include <sys/dir.h>
36 #include <signal.h>
37 #include <machine/reg.h>
38 #include <sys/user.h> /* After a.out.h */
39 #include <sys/file.h>
40 #include <errno.h>
41
42 /* Magic not defined in standard HP-UX header files until 8.0 */
43
44 #ifndef CPU_PA_RISC1_0
45 #define CPU_PA_RISC1_0 0x20B
46 #endif /* CPU_PA_RISC1_0 */
47
48 #ifndef CPU_PA_RISC1_1
49 #define CPU_PA_RISC1_1 0x210
50 #endif /* CPU_PA_RISC1_1 */
51
52 #ifndef _PA_RISC1_0_ID
53 #define _PA_RISC1_0_ID CPU_PA_RISC1_0
54 #endif /* _PA_RISC1_0_ID */
55
56 #ifndef _PA_RISC1_1_ID
57 #define _PA_RISC1_1_ID CPU_PA_RISC1_1
58 #endif /* _PA_RISC1_1_ID */
59
60 #ifndef _PA_RISC_MAXID
61 #define _PA_RISC_MAXID 0x2FF
62 #endif /* _PA_RISC_MAXID */
63
64 #ifndef _PA_RISC_ID
65 #define _PA_RISC_ID(__m_num) \
66 (((__m_num) == _PA_RISC1_0_ID) || \
67 ((__m_num) >= _PA_RISC1_1_ID && (__m_num) <= _PA_RISC_MAXID))
68 #endif /* _PA_RISC_ID */
69
70 /* SOM allows any one of the four previous relocations to be reused
71 with a "R_PREV_FIXUP" relocation entry. Since R_PREV_FIXUP
72 relocations are always a single byte, using a R_PREV_FIXUP instead
73 of some multi-byte relocation makes object files smaller.
74
75 Note one side effect of using a R_PREV_FIXUP is the relocation that
76 is being repeated moves to the front of the queue. */
77 struct reloc_queue
78 {
79 unsigned char *reloc;
80 unsigned int size;
81 } reloc_queue[4];
82
83 /* This fully describes the symbol types which may be attached to
84 an EXPORT or IMPORT directive. Only SOM uses this formation
85 (ELF has no need for it). */
86 typedef enum
87 {
88 SYMBOL_TYPE_UNKNOWN,
89 SYMBOL_TYPE_ABSOLUTE,
90 SYMBOL_TYPE_CODE,
91 SYMBOL_TYPE_DATA,
92 SYMBOL_TYPE_ENTRY,
93 SYMBOL_TYPE_MILLICODE,
94 SYMBOL_TYPE_PLABEL,
95 SYMBOL_TYPE_PRI_PROG,
96 SYMBOL_TYPE_SEC_PROG,
97 } pa_symbol_type;
98
99 /* Forward declarations */
100
101 static boolean som_mkobject PARAMS ((bfd *));
102 static bfd_target * som_object_setup PARAMS ((bfd *,
103 struct header *,
104 struct som_exec_auxhdr *));
105 static asection * make_unique_section PARAMS ((bfd *, CONST char *, int));
106 static boolean setup_sections PARAMS ((bfd *, struct header *));
107 static bfd_target * som_object_p PARAMS ((bfd *));
108 static boolean som_write_object_contents PARAMS ((bfd *));
109 static boolean som_slurp_string_table PARAMS ((bfd *));
110 static unsigned int som_slurp_symbol_table PARAMS ((bfd *));
111 static unsigned int som_get_symtab_upper_bound PARAMS ((bfd *));
112 static unsigned int som_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
113 arelent **, asymbol **));
114 static unsigned int som_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
115 static unsigned int som_get_symtab PARAMS ((bfd *, asymbol **));
116 static asymbol * som_make_empty_symbol PARAMS ((bfd *));
117 static void som_print_symbol PARAMS ((bfd *, PTR,
118 asymbol *, bfd_print_symbol_type));
119 static boolean som_new_section_hook PARAMS ((bfd *, asection *));
120 static boolean som_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
121 file_ptr, bfd_size_type));
122 static boolean som_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
123 unsigned long));
124 static boolean som_find_nearest_line PARAMS ((bfd *, asection *,
125 asymbol **, bfd_vma,
126 CONST char **,
127 CONST char **,
128 unsigned int *));
129 static void som_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
130 static asection * som_section_from_subspace_index PARAMS ((bfd *,
131 unsigned int));
132 static int log2 PARAMS ((unsigned int));
133 static bfd_reloc_status_type hppa_som_reloc PARAMS ((bfd *, arelent *,
134 asymbol *, PTR,
135 asection *, bfd *));
136 static void som_initialize_reloc_queue PARAMS ((struct reloc_queue *));
137 static void som_reloc_queue_insert PARAMS ((unsigned char *, unsigned int,
138 struct reloc_queue *));
139 static void som_reloc_queue_fix PARAMS ((struct reloc_queue *, unsigned int));
140 static int som_reloc_queue_find PARAMS ((unsigned char *, unsigned int,
141 struct reloc_queue *));
142
143
144 static reloc_howto_type som_hppa_howto_table[] =
145 {
146 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
147 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
148 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
149 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
150 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
151 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
152 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
153 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
154 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
155 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
156 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
157 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
158 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
159 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
160 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
161 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
162 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
163 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
164 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
165 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
166 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
167 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
168 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
169 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
170 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
171 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
172 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
173 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
174 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
175 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
176 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
177 {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
178 {R_ZEROES, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ZEROES"},
179 {R_ZEROES, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ZEROES"},
180 {R_UNINIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_UNINIT"},
181 {R_UNINIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_UNINIT"},
182 {R_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RELOCATION"},
183 {R_DATA_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_ONE_SYMBOL"},
184 {R_DATA_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_ONE_SYMBOL"},
185 {R_DATA_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_PLABEL"},
186 {R_DATA_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_PLABEL"},
187 {R_SPACE_REF, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_SPACE_REF"},
188 {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
189 {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
190 {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
191 {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
192 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
193 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
194 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
195 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
196 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
197 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
198 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
199 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
200 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
201 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
202 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
203 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
204 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
205 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
206 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
207 {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
208 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
209 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
210 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
211 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
212 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
213 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
214 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
215 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
216 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
217 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
218 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
219 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
220 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
221 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
222 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
223 {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
224 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
225 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
226 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
227 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
228 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
229 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
230 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
231 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
232 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
233 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
234 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
235 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
236 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
237 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
238 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
239 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
240 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
241 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
242 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
243 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
244 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
245 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
246 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
247 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
248 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
249 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
250 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
251 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
252 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
253 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
254 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
255 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
256 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
257 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
258 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
259 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
260 {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
261 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
262 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
263 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
264 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
265 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
266 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
267 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
268 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
269 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
270 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
271 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
272 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
273 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
274 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
275 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
276 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
277 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
278 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
279 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
280 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
281 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
282 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
283 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
284 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
285 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
286 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
287 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
288 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
289 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
290 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
291 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
292 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
293 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
294 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
295 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
296 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
297 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
298 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
299 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
300 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
301 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
302 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
303 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
304 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
305 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
306 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
307 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
308 {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
309 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
310 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
311 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
312 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
313 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
314 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
315 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
316 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
317 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
318 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
319 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
320 {R_MILLI_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_MILLI_REL"},
321 {R_MILLI_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_MILLI_REL"},
322 {R_CODE_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_PLABEL"},
323 {R_CODE_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_PLABEL"},
324 {R_BREAKPOINT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BREAKPOINT"},
325 {R_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ENTRY"},
326 {R_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ENTRY"},
327 {R_ALT_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ALT_ENTRY"},
328 {R_EXIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_EXIT"},
329 {R_BEGIN_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BEGIN_TRY"},
330 {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"},
331 {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"},
332 {R_BEGIN_BRTAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BEGIN_BRTAB"},
333 {R_END_BRTAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_BRTAB"},
334 {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
335 {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
336 {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
337 {R_DATA_EXPR, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_EXPR"},
338 {R_CODE_EXPR, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_EXPR"},
339 {R_FSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_FSEL"},
340 {R_LSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LSEL"},
341 {R_RSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RSEL"},
342 {R_N_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_N_MODE"},
343 {R_S_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_S_MODE"},
344 {R_D_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_D_MODE"},
345 {R_R_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_R_MODE"},
346 {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
347 {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
348 {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
349 {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
350 {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
351 {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
352 {R_TRANSLATED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_TRANSLATED"},
353 {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
354 {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
355 {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
356 {R_COMP1, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP1"},
357 {R_COMP2, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP2"},
358 {R_COMP3, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP3"},
359 {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
360 {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
361 {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
362 {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
363 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
364 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
365 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
366 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
367 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
368 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
369 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
370 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
371 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
372 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
373 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
374 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
375 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
376 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
377 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
378 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
379 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
380 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
381 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
382 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
383 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
384 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
385 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
386 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
387 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
388 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
389 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
390 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
391 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
392 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
393 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
394 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
395 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
396 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
397 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
398 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
399 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
400 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
401 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
402 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
403 {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}};
404
405
406 /* Initialize the SOM relocation queue. By definition the queue holds
407 the last four multibyte fixups. */
408
409 static void
410 som_initialize_reloc_queue (queue)
411 struct reloc_queue *queue;
412 {
413 queue[0].reloc = NULL;
414 queue[0].size = 0;
415 queue[1].reloc = NULL;
416 queue[1].size = 0;
417 queue[2].reloc = NULL;
418 queue[2].size = 0;
419 queue[3].reloc = NULL;
420 queue[3].size = 0;
421 }
422
423 /* Insert a new relocation into the relocation queue. */
424
425 static void
426 som_reloc_queue_insert (p, size, queue)
427 unsigned char *p;
428 unsigned int size;
429 struct reloc_queue *queue;
430 {
431 queue[3].reloc = queue[2].reloc;
432 queue[3].size = queue[2].size;
433 queue[2].reloc = queue[1].reloc;
434 queue[2].size = queue[1].size;
435 queue[1].reloc = queue[0].reloc;
436 queue[1].size = queue[0].size;
437 queue[0].reloc = p;
438 queue[0].size = size;
439 }
440
441 /* When an entry in the relocation queue is reused, the entry moves
442 to the front of the queue. */
443
444 static void
445 som_reloc_queue_fix (queue, index)
446 struct reloc_queue *queue;
447 unsigned int index;
448 {
449 if (index == 0)
450 return;
451
452 if (index == 1)
453 {
454 unsigned char *tmp1 = queue[0].reloc;
455 unsigned int tmp2 = queue[0].size;
456 queue[0].reloc = queue[1].reloc;
457 queue[0].size = queue[1].size;
458 queue[1].reloc = tmp1;
459 queue[1].size = tmp2;
460 return;
461 }
462
463 if (index == 2)
464 {
465 unsigned char *tmp1 = queue[0].reloc;
466 unsigned int tmp2 = queue[0].size;
467 queue[0].reloc = queue[2].reloc;
468 queue[0].size = queue[2].size;
469 queue[2].reloc = queue[1].reloc;
470 queue[2].size = queue[1].size;
471 queue[1].reloc = tmp1;
472 queue[1].size = tmp2;
473 return;
474 }
475
476 if (index == 3)
477 {
478 unsigned char *tmp1 = queue[0].reloc;
479 unsigned int tmp2 = queue[0].size;
480 queue[0].reloc = queue[3].reloc;
481 queue[0].size = queue[3].size;
482 queue[3].reloc = queue[2].reloc;
483 queue[3].size = queue[2].size;
484 queue[2].reloc = queue[1].reloc;
485 queue[2].size = queue[1].size;
486 queue[1].reloc = tmp1;
487 queue[1].size = tmp2;
488 return;
489 }
490 abort();
491 }
492
493 /* Search for a particular relocation in the relocation queue. */
494
495 static int
496 som_reloc_queue_find (p, size, queue)
497 unsigned char *p;
498 unsigned int size;
499 struct reloc_queue *queue;
500 {
501 if (!bcmp (p, queue[0].reloc, size)
502 && size == queue[0].size)
503 return 0;
504 if (!bcmp (p, queue[1].reloc, size)
505 && size == queue[1].size)
506 return 1;
507 if (!bcmp (p, queue[2].reloc, size)
508 && size == queue[2].size)
509 return 2;
510 if (!bcmp (p, queue[3].reloc, size)
511 && size == queue[3].size)
512 return 3;
513 return -1;
514 }
515 /* Return the logarithm of X, base 2, considering X unsigned.
516 Abort if X is not a power of two -- this should never happen (FIXME:
517 It will happen on corrupt executables. GDB should give an error, not
518 a coredump, in that case). */
519
520 static int
521 log2 (x)
522 unsigned int x;
523 {
524 int log = 0;
525
526 /* Test for 0 or a power of 2. */
527 if (x == 0 || x != (x & -x))
528 abort();
529
530 while ((x >>= 1) != 0)
531 log++;
532 return log;
533 }
534
535 static bfd_reloc_status_type
536 hppa_som_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd)
537 bfd *abfd;
538 arelent *reloc_entry;
539 asymbol *symbol_in;
540 PTR data;
541 asection *input_section;
542 bfd *output_bfd;
543 {
544 if (output_bfd)
545 {
546 reloc_entry->address += input_section->output_offset;
547 return bfd_reloc_ok;
548 }
549 return bfd_reloc_ok;
550 }
551
552 /* Perform some initialization for an object. Save results of this
553 initialization in the BFD. */
554
555 static bfd_target *
556 som_object_setup (abfd, file_hdrp, aux_hdrp)
557 bfd *abfd;
558 struct header *file_hdrp;
559 struct som_exec_auxhdr *aux_hdrp;
560 {
561 asection *text, *data, *bss;
562
563 /* som_mkobject will set bfd_error if som_mkobject fails. */
564 if (som_mkobject (abfd) != true)
565 return 0;
566
567 /* Make the standard .text, .data, and .bss sections so that tools
568 which assume those names work (size for example). They will have
569 no contents, but the sizes and such will reflect those of the
570 $CODE$, $DATA$, and $BSS$ subspaces respectively.
571
572 FIXME: Should check return status from bfd_make_section calls below. */
573
574 text = bfd_make_section (abfd, ".text");
575 data = bfd_make_section (abfd, ".data");
576 bss = bfd_make_section (abfd, ".bss");
577
578 text->_raw_size = aux_hdrp->exec_tsize;
579 data->_raw_size = aux_hdrp->exec_dsize;
580 bss->_raw_size = aux_hdrp->exec_bsize;
581
582 text->flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_CODE);
583 data->flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS);
584 bss->flags = (SEC_ALLOC | SEC_IS_COMMON);
585
586 /* The virtual memory addresses of the sections */
587 text->vma = aux_hdrp->exec_tmem;
588 data->vma = aux_hdrp->exec_dmem;
589 bss->vma = aux_hdrp->exec_bfill;
590
591 /* The file offsets of the sections */
592 text->filepos = aux_hdrp->exec_tfile;
593 data->filepos = aux_hdrp->exec_dfile;
594
595 /* The file offsets of the relocation info */
596 text->rel_filepos = 0;
597 data->rel_filepos = 0;
598
599 /* Set BFD flags based on what information is available in the SOM. */
600 abfd->flags = NO_FLAGS;
601 if (! file_hdrp->entry_offset)
602 abfd->flags |= HAS_RELOC;
603 else
604 abfd->flags |= EXEC_P;
605 if (file_hdrp->symbol_total)
606 abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
607
608 bfd_get_start_address (abfd) = aux_hdrp->exec_entry;
609 bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 0);
610 bfd_get_symcount (abfd) = file_hdrp->symbol_total;
611
612 /* Initialize the saved symbol table and string table to NULL.
613 Save important offsets and sizes from the SOM header into
614 the BFD. */
615 obj_som_stringtab (abfd) = (char *) NULL;
616 obj_som_symtab (abfd) = (som_symbol_type *) NULL;
617 obj_som_stringtab_size (abfd) = file_hdrp->symbol_strings_size;
618 obj_som_sym_filepos (abfd) = file_hdrp->symbol_location;
619 obj_som_str_filepos (abfd) = file_hdrp->symbol_strings_location;
620 obj_som_reloc_filepos (abfd) = file_hdrp->fixup_request_location;
621
622 return abfd->xvec;
623 }
624
625 /* Create a new BFD section for NAME. If NAME already exists, then create a
626 new unique name, with NAME as the prefix. This exists because SOM .o files
627 may have more than one $CODE$ subspace. */
628
629 static asection *
630 make_unique_section (abfd, name, num)
631 bfd *abfd;
632 CONST char *name;
633 int num;
634 {
635 asection *sect;
636 char *newname;
637 char altname[100];
638
639 sect = bfd_make_section (abfd, name);
640 while (!sect)
641 {
642 sprintf (altname, "%s-%d", name, num++);
643 sect = bfd_make_section (abfd, altname);
644 }
645
646 newname = bfd_alloc (abfd, strlen (sect->name) + 1);
647 strcpy (newname, sect->name);
648
649 sect->name = newname;
650 return sect;
651 }
652
653 /* Convert all of the space and subspace info into BFD sections. Each space
654 contains a number of subspaces, which in turn describe the mapping between
655 regions of the exec file, and the address space that the program runs in.
656 BFD sections which correspond to spaces will overlap the sections for the
657 associated subspaces. */
658
659 static boolean
660 setup_sections (abfd, file_hdr)
661 bfd *abfd;
662 struct header *file_hdr;
663 {
664 char *space_strings;
665 int space_index;
666 unsigned int total_subspaces = 0;
667
668 /* First, read in space names */
669
670 space_strings = alloca (file_hdr->space_strings_size);
671 if (!space_strings)
672 return false;
673
674 if (bfd_seek (abfd, file_hdr->space_strings_location, SEEK_SET) < 0)
675 return false;
676 if (bfd_read (space_strings, 1, file_hdr->space_strings_size, abfd)
677 != file_hdr->space_strings_size)
678 return false;
679
680 /* Loop over all of the space dictionaries, building up sections */
681 for (space_index = 0; space_index < file_hdr->space_total; space_index++)
682 {
683 struct space_dictionary_record space;
684 struct subspace_dictionary_record subspace, save_subspace;
685 int subspace_index;
686 asection *space_asect;
687
688 /* Read the space dictionary element */
689 if (bfd_seek (abfd, file_hdr->space_location
690 + space_index * sizeof space, SEEK_SET) < 0)
691 return false;
692 if (bfd_read (&space, 1, sizeof space, abfd) != sizeof space)
693 return false;
694
695 /* Setup the space name string */
696 space.name.n_name = space.name.n_strx + space_strings;
697
698 /* Make a section out of it */
699 space_asect = make_unique_section (abfd, space.name.n_name, space_index);
700 if (!space_asect)
701 return false;
702
703 /* Now, read in the first subspace for this space */
704 if (bfd_seek (abfd, file_hdr->subspace_location
705 + space.subspace_index * sizeof subspace,
706 SEEK_SET) < 0)
707 return false;
708 if (bfd_read (&subspace, 1, sizeof subspace, abfd) != sizeof subspace)
709 return false;
710 /* Seek back to the start of the subspaces for loop below */
711 if (bfd_seek (abfd, file_hdr->subspace_location
712 + space.subspace_index * sizeof subspace,
713 SEEK_SET) < 0)
714 return false;
715
716 /* Setup the start address and file loc from the first subspace record */
717 space_asect->vma = subspace.subspace_start;
718 space_asect->filepos = subspace.file_loc_init_value;
719 space_asect->alignment_power = log2 (subspace.alignment);
720
721 /* Initialize save_subspace so we can reliably determine if this
722 loop placed any useful values into it. */
723 bzero (&save_subspace, sizeof (struct subspace_dictionary_record));
724
725 /* Loop over the rest of the subspaces, building up more sections */
726 for (subspace_index = 0; subspace_index < space.subspace_quantity;
727 subspace_index++)
728 {
729 asection *subspace_asect;
730
731 /* Read in the next subspace */
732 if (bfd_read (&subspace, 1, sizeof subspace, abfd)
733 != sizeof subspace)
734 return false;
735
736 /* Setup the subspace name string */
737 subspace.name.n_name = subspace.name.n_strx + space_strings;
738
739 /* Make a section out of this subspace */
740 subspace_asect = make_unique_section (abfd, subspace.name.n_name,
741 space.subspace_index + subspace_index);
742
743 if (!subspace_asect)
744 return false;
745
746 /* Keep an easy mapping between subspaces and sections. */
747 som_section_data (subspace_asect)->subspace_index
748 = total_subspaces++;
749
750 /* Set SEC_READONLY and SEC_CODE/SEC_DATA as specified
751 by the access_control_bits in the subspace header. */
752 switch (subspace.access_control_bits >> 4)
753 {
754 /* Readonly data. */
755 case 0x0:
756 subspace_asect->flags |= SEC_DATA | SEC_READONLY;
757 break;
758
759 /* Normal data. */
760 case 0x1:
761 subspace_asect->flags |= SEC_DATA;
762 break;
763
764 /* Readonly code and the gateways.
765 Gateways have other attributes which do not map
766 into anything BFD knows about. */
767 case 0x2:
768 case 0x4:
769 case 0x5:
770 case 0x6:
771 case 0x7:
772 subspace_asect->flags |= SEC_CODE | SEC_READONLY;
773 break;
774
775 /* dynamic (writable) code. */
776 case 0x3:
777 subspace_asect->flags |= SEC_CODE;
778 break;
779 }
780
781 if (subspace.dup_common || subspace.is_common)
782 subspace_asect->flags |= SEC_IS_COMMON;
783 else
784 subspace_asect->flags |= SEC_HAS_CONTENTS;
785 if (subspace.is_loadable)
786 subspace_asect->flags |= SEC_ALLOC | SEC_LOAD;
787 if (subspace.code_only)
788 subspace_asect->flags |= SEC_CODE;
789
790 /* This subspace has relocations.
791 The fixup_request_quantity is a byte count for the number of
792 entries in the relocation stream; it is not the actual number
793 of relocations in the subspace. */
794 if (subspace.fixup_request_quantity != 0)
795 {
796 subspace_asect->flags |= SEC_RELOC;
797 subspace_asect->rel_filepos = subspace.fixup_request_index;
798 som_section_data (subspace_asect)->reloc_size
799 = subspace.fixup_request_quantity;
800 /* We can not determine this yet. When we read in the
801 relocation table the correct value will be filled in. */
802 subspace_asect->reloc_count = -1;
803 }
804
805 /* Update save_subspace if appropriate. */
806 if (subspace.file_loc_init_value > save_subspace.file_loc_init_value)
807 save_subspace = subspace;
808
809 subspace_asect->vma = subspace.subspace_start;
810 subspace_asect->_cooked_size = subspace.subspace_length;
811 subspace_asect->_raw_size = subspace.initialization_length;
812 subspace_asect->alignment_power = log2 (subspace.alignment);
813 subspace_asect->filepos = subspace.file_loc_init_value;
814 }
815
816 /* Yow! there is no subspace within the space which actually
817 has initialized information in it; this should never happen
818 as far as I know. */
819 if (!save_subspace.file_loc_init_value)
820 abort ();
821
822 /* Setup the sizes for the space section based upon the info in the
823 last subspace of the space. */
824 space_asect->_cooked_size = save_subspace.subspace_start
825 - space_asect->vma + save_subspace.subspace_length;
826 space_asect->_raw_size = save_subspace.file_loc_init_value
827 - space_asect->filepos + save_subspace.initialization_length;
828 }
829 return true;
830 }
831
832 /* Read in a SOM object and make it into a BFD. */
833
834 static bfd_target *
835 som_object_p (abfd)
836 bfd *abfd;
837 {
838 struct header file_hdr;
839 struct som_exec_auxhdr aux_hdr;
840
841 if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
842 {
843 bfd_error = system_call_error;
844 return 0;
845 }
846
847 if (!_PA_RISC_ID (file_hdr.system_id))
848 {
849 bfd_error = wrong_format;
850 return 0;
851 }
852
853 switch (file_hdr.a_magic)
854 {
855 case RELOC_MAGIC:
856 case EXEC_MAGIC:
857 case SHARE_MAGIC:
858 case DEMAND_MAGIC:
859 #ifdef DL_MAGIC
860 case DL_MAGIC:
861 #endif
862 #ifdef SHL_MAGIC
863 case SHL_MAGIC:
864 #endif
865 #ifdef EXECLIBMAGIC
866 case EXECLIBMAGIC:
867 #endif
868 break;
869 default:
870 bfd_error = wrong_format;
871 return 0;
872 }
873
874 if (file_hdr.version_id != VERSION_ID
875 && file_hdr.version_id != NEW_VERSION_ID)
876 {
877 bfd_error = wrong_format;
878 return 0;
879 }
880
881 /* If the aux_header_size field in the file header is zero, then this
882 object is an incomplete executable (a .o file). Do not try to read
883 a non-existant auxiliary header. */
884 bzero (&aux_hdr, sizeof (struct som_exec_auxhdr));
885 if (file_hdr.aux_header_size != 0)
886 {
887 if (bfd_read ((PTR) & aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE)
888 {
889 bfd_error = wrong_format;
890 return 0;
891 }
892 }
893
894 if (!setup_sections (abfd, &file_hdr))
895 {
896 /* setup_sections does not bubble up a bfd error code. */
897 bfd_error = bad_value;
898 return 0;
899 }
900
901 /* This appears to be a valid SOM object. Do some initialization. */
902 return som_object_setup (abfd, &file_hdr, &aux_hdr);
903 }
904
905 /* Create a SOM object. */
906
907 static boolean
908 som_mkobject (abfd)
909 bfd *abfd;
910 {
911 /* Allocate memory to hold backend information. */
912 abfd->tdata.som_data = (struct som_data_struct *)
913 bfd_zalloc (abfd, sizeof (struct som_data_struct));
914 if (abfd->tdata.som_data == NULL)
915 {
916 bfd_error = no_memory;
917 return false;
918 }
919 obj_som_file_hdr (abfd) = bfd_zalloc (abfd, sizeof (struct header));
920 if (obj_som_file_hdr (abfd) == NULL)
921
922 {
923 bfd_error = no_memory;
924 return false;
925 }
926 return true;
927 }
928
929 boolean
930 som_write_object_contents (abfd)
931 bfd *abfd;
932 {
933 fprintf (stderr, "som_write_object_contents unimplemented\n");
934 fflush (stderr);
935 abort ();
936 return (false);
937 }
938 /* Read and save the string table associated with the given BFD. */
939
940 static boolean
941 som_slurp_string_table (abfd)
942 bfd *abfd;
943 {
944 char *stringtab;
945
946 /* Use the saved version if its available. */
947 if (obj_som_stringtab (abfd) != NULL)
948 return true;
949
950 /* Allocate and read in the string table. */
951 stringtab = bfd_zalloc (abfd, obj_som_stringtab_size (abfd));
952 if (stringtab == NULL)
953 {
954 bfd_error = no_memory;
955 return false;
956 }
957
958 if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0)
959 {
960 bfd_error = system_call_error;
961 return false;
962 }
963
964 if (bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd)
965 != obj_som_stringtab_size (abfd))
966 {
967 bfd_error = system_call_error;
968 return false;
969 }
970
971 /* Save our results and return success. */
972 obj_som_stringtab (abfd) = stringtab;
973 return true;
974 }
975
976 /* Return the amount of data (in bytes) required to hold the symbol
977 table for this object. */
978
979 static unsigned int
980 som_get_symtab_upper_bound (abfd)
981 bfd *abfd;
982 {
983 if (!som_slurp_symbol_table (abfd))
984 return 0;
985
986 return (bfd_get_symcount (abfd) + 1) * (sizeof (som_symbol_type *));
987 }
988
989 /* Convert from a SOM subspace index to a BFD section. */
990
991 static asection *
992 som_section_from_subspace_index (abfd, index)
993 bfd *abfd;
994 unsigned int index;
995 {
996 asection *section;
997
998 for (section = abfd->sections; section != NULL; section = section->next)
999 if (som_section_data (section)->subspace_index == index)
1000 return section;
1001
1002 /* Should never happen. */
1003 abort();
1004 }
1005
1006 /* Read and save the symbol table associated with the given BFD. */
1007
1008 static unsigned int
1009 som_slurp_symbol_table (abfd)
1010 bfd *abfd;
1011 {
1012 int symbol_count = bfd_get_symcount (abfd);
1013 int symsize = sizeof (struct symbol_dictionary_record);
1014 char *stringtab;
1015 struct symbol_dictionary_record *buf, *bufp, *endbufp;
1016 som_symbol_type *sym, *symbase;
1017
1018 /* Return saved value if it exists. */
1019 if (obj_som_symtab (abfd) != NULL)
1020 return true;
1021
1022 /* Sanity checking. Make sure there are some symbols and that
1023 we can read the string table too. */
1024 if (symbol_count == 0)
1025 {
1026 bfd_error = no_symbols;
1027 return false;
1028 }
1029
1030 if (!som_slurp_string_table (abfd))
1031 return false;
1032
1033 stringtab = obj_som_stringtab (abfd);
1034
1035 symbase = (som_symbol_type *)
1036 bfd_zalloc (abfd, symbol_count * sizeof (som_symbol_type));
1037 if (symbase == NULL)
1038 {
1039 bfd_error = no_memory;
1040 return false;
1041 }
1042
1043 /* Read in the external SOM representation. */
1044 buf = alloca (symbol_count * symsize);
1045 if (buf == NULL)
1046 {
1047 bfd_error = no_memory;
1048 return false;
1049 }
1050 if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) < 0)
1051 {
1052 bfd_error = system_call_error;
1053 return false;
1054 }
1055 if (bfd_read (buf, symbol_count * symsize, 1, abfd)
1056 != symbol_count * symsize)
1057 {
1058 bfd_error = no_symbols;
1059 return (false);
1060 }
1061
1062 /* Iterate over all the symbols and internalize them. */
1063 endbufp = buf + symbol_count;
1064 for (bufp = buf, sym = symbase; bufp < endbufp; ++bufp)
1065 {
1066
1067 /* I don't think we care about these. */
1068 if (bufp->symbol_type == ST_SYM_EXT
1069 || bufp->symbol_type == ST_ARG_EXT)
1070 continue;
1071
1072 /* Some reasonable defaults. */
1073 sym->symbol.the_bfd = abfd;
1074 sym->symbol.name = bufp->name.n_strx + stringtab;
1075 sym->symbol.value = bufp->symbol_value;
1076 sym->symbol.section = 0;
1077 sym->symbol.flags = 0;
1078
1079 switch (bufp->symbol_type)
1080 {
1081 case ST_ENTRY:
1082 sym->symbol.flags |= BSF_FUNCTION;
1083 sym->symbol.value &= ~0x3;
1084 break;
1085
1086 case ST_PRI_PROG:
1087 case ST_SEC_PROG:
1088 case ST_STUB:
1089 case ST_MILLICODE:
1090 case ST_CODE:
1091 sym->symbol.value &= ~0x3;
1092
1093 default:
1094 break;
1095 }
1096
1097 /* Handle scoping and section information. */
1098 switch (bufp->symbol_scope)
1099 {
1100 /* symbol_info field is undefined for SS_EXTERNAL and SS_UNSAT symbols,
1101 so the section associated with this symbol can't be known. */
1102 case SS_EXTERNAL:
1103 case SS_UNSAT:
1104 sym->symbol.flags |= (BSF_EXPORT | BSF_GLOBAL);
1105 break;
1106
1107 case SS_UNIVERSAL:
1108 sym->symbol.flags |= (BSF_EXPORT | BSF_GLOBAL);
1109 sym->symbol.section
1110 = som_section_from_subspace_index (abfd, bufp->symbol_info);
1111 sym->symbol.value -= sym->symbol.section->vma;
1112 break;
1113
1114 #if 0
1115 /* SS_GLOBAL and SS_LOCAL are two names for the same thing.
1116 Sound dumb? It is. */
1117 case SS_GLOBAL:
1118 #endif
1119 case SS_LOCAL:
1120 sym->symbol.flags |= BSF_LOCAL;
1121 sym->symbol.section
1122 = som_section_from_subspace_index (abfd, bufp->symbol_info);
1123 sym->symbol.value -= sym->symbol.section->vma;
1124 break;
1125 }
1126
1127 /* Mark symbols left around by the debugger. */
1128 if (strlen (sym->symbol.name) >= 3
1129 && sym->symbol.name[0] == 'L'
1130 && (sym->symbol.name[2] == '$' || sym->symbol.name[3] == '$'))
1131 sym->symbol.flags |= BSF_DEBUGGING;
1132
1133 /* Note increment at bottom of loop, since we skip some symbols
1134 we can not include it as part of the for statement. */
1135 sym++;
1136 }
1137
1138 /* Save our results and return success. */
1139 obj_som_symtab (abfd) = symbase;
1140 return (true);
1141 }
1142
1143 /* Canonicalize a SOM symbol table. Return the number of entries
1144 in the symbol table. */
1145
1146 static unsigned int
1147 som_get_symtab (abfd, location)
1148 bfd *abfd;
1149 asymbol **location;
1150 {
1151 int i;
1152 som_symbol_type *symbase;
1153
1154 if (!som_slurp_symbol_table (abfd))
1155 return 0;
1156
1157 i = bfd_get_symcount (abfd);
1158 symbase = obj_som_symtab (abfd);
1159
1160 for (; i > 0; i--, location++, symbase++)
1161 *location = &symbase->symbol;
1162
1163 /* Final null pointer. */
1164 *location = 0;
1165 return (bfd_get_symcount (abfd));
1166 }
1167
1168 /* Make a SOM symbol. There is nothing special to do here. */
1169
1170 static asymbol *
1171 som_make_empty_symbol (abfd)
1172 bfd *abfd;
1173 {
1174 som_symbol_type *new =
1175 (som_symbol_type *) bfd_zalloc (abfd, sizeof (som_symbol_type));
1176 if (new == NULL)
1177 {
1178 bfd_error = no_memory;
1179 return 0;
1180 }
1181 new->symbol.the_bfd = abfd;
1182
1183 return &new->symbol;
1184 }
1185
1186 /* Print symbol information. */
1187
1188 static void
1189 som_print_symbol (ignore_abfd, afile, symbol, how)
1190 bfd *ignore_abfd;
1191 PTR afile;
1192 asymbol *symbol;
1193 bfd_print_symbol_type how;
1194 {
1195 FILE *file = (FILE *) afile;
1196 switch (how)
1197 {
1198 case bfd_print_symbol_name:
1199 fprintf (file, "%s", symbol->name);
1200 break;
1201 case bfd_print_symbol_more:
1202 fprintf (file, "som ");
1203 fprintf_vma (file, symbol->value);
1204 fprintf (file, " %lx", (long) symbol->flags);
1205 break;
1206 case bfd_print_symbol_all:
1207 {
1208 CONST char *section_name;
1209 section_name = symbol->section ? symbol->section->name : "(*none*)";
1210 bfd_print_symbol_vandf ((PTR) file, symbol);
1211 fprintf (file, " %s\t%s", section_name, symbol->name);
1212 break;
1213 }
1214 }
1215 }
1216
1217 static unsigned int
1218 som_get_reloc_upper_bound (abfd, asect)
1219 bfd *abfd;
1220 sec_ptr asect;
1221 {
1222 fprintf (stderr, "som_get_reloc_upper_bound unimplemented\n");
1223 fflush (stderr);
1224 abort ();
1225 return (0);
1226 }
1227
1228 static unsigned int
1229 som_canonicalize_reloc (abfd, section, relptr, symbols)
1230 bfd *abfd;
1231 sec_ptr section;
1232 arelent **relptr;
1233 asymbol **symbols;
1234 {
1235 fprintf (stderr, "som_canonicalize_reloc unimplemented\n");
1236 fflush (stderr);
1237 abort ();
1238 }
1239
1240 extern bfd_target som_vec;
1241
1242 /* A hook to set up object file dependent section information. */
1243
1244 static boolean
1245 som_new_section_hook (abfd, newsect)
1246 bfd *abfd;
1247 asection *newsect;
1248 {
1249 newsect->used_by_bfd = (struct som_section_data_struct *)
1250 bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
1251 newsect->alignment_power = 3;
1252
1253 /* Initialize the subspace_index field to -1 so that it does
1254 not match a subspace with an index of 0. */
1255 som_section_data (newsect)->subspace_index = -1;
1256
1257 /* We allow more than three sections internally */
1258 return true;
1259 }
1260
1261 /* Set backend info for sections which can not be described
1262 in the BFD data structures. */
1263
1264 void
1265 bfd_som_set_section_attributes (section, defined, private, sort_key, spnum)
1266 asection *section;
1267 char defined;
1268 char private;
1269 unsigned char sort_key;
1270 int spnum;
1271 {
1272 struct space_dictionary_record *space_dict;
1273
1274 som_section_data (section)->is_space = 1;
1275 space_dict = &som_section_data (section)->space_dict;
1276 space_dict->is_defined = defined;
1277 space_dict->is_private = private;
1278 space_dict->sort_key = sort_key;
1279 space_dict->space_number = spnum;
1280 }
1281
1282 /* Set backend info for subsections which can not be described
1283 in the BFD data structures. */
1284
1285 void
1286 bfd_som_set_subsection_attributes (section, container, access,
1287 sort_key, quadrant)
1288 asection *section;
1289 asection *container;
1290 int access;
1291 unsigned char sort_key;
1292 int quadrant;
1293 {
1294 struct subspace_dictionary_record *subspace_dict;
1295 som_section_data (section)->is_subspace = 1;
1296 subspace_dict = &som_section_data (section)->subspace_dict;
1297 subspace_dict->access_control_bits = access;
1298 subspace_dict->sort_key = sort_key;
1299 subspace_dict->quadrant = quadrant;
1300 som_section_data (section)->containing_space = container;
1301 }
1302
1303 /* Set the full SOM symbol type. SOM needs far more symbol information
1304 than any other object file format I'm aware of. It is mandatory
1305 to be able to know if a symbol is an entry point, millicode, data,
1306 code, absolute, storage request, or procedure label. If you get
1307 the symbol type wrong your program will not link. */
1308
1309 void
1310 bfd_som_set_symbol_type (symbol, type)
1311 asymbol *symbol;
1312 unsigned int type;
1313 {
1314 (*som_symbol_data (symbol))->som_type = type;
1315 }
1316
1317 /* Attach 64bits of unwind information to a symbol (which hopefully
1318 is a function of some kind!). It would be better to keep this
1319 in the R_ENTRY relocation, but there is not enough space. */
1320
1321 void
1322 bfd_som_attach_unwind_info (symbol, unwind_desc)
1323 asymbol *symbol;
1324 char *unwind_desc;
1325 {
1326 (*som_symbol_data (symbol))->unwind = unwind_desc;
1327 }
1328
1329 static boolean
1330 som_set_section_contents (abfd, section, location, offset, count)
1331 bfd *abfd;
1332 sec_ptr section;
1333 PTR location;
1334 file_ptr offset;
1335 bfd_size_type count;
1336 {
1337 fprintf (stderr, "som_set_section_contents unimplimented\n");
1338 fflush (stderr);
1339 abort ();
1340 return false;
1341 }
1342
1343 static boolean
1344 som_set_arch_mach (abfd, arch, machine)
1345 bfd *abfd;
1346 enum bfd_architecture arch;
1347 unsigned long machine;
1348 {
1349 fprintf (stderr, "som_set_arch_mach unimplemented\n");
1350 fflush (stderr);
1351 /* Allow any architecture to be supported by the som backend */
1352 return bfd_default_set_arch_mach (abfd, arch, machine);
1353 }
1354
1355 static boolean
1356 som_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
1357 functionname_ptr, line_ptr)
1358 bfd *abfd;
1359 asection *section;
1360 asymbol **symbols;
1361 bfd_vma offset;
1362 CONST char **filename_ptr;
1363 CONST char **functionname_ptr;
1364 unsigned int *line_ptr;
1365 {
1366 fprintf (stderr, "som_find_nearest_line unimplemented\n");
1367 fflush (stderr);
1368 abort ();
1369 return (false);
1370 }
1371
1372 static int
1373 som_sizeof_headers (abfd, reloc)
1374 bfd *abfd;
1375 boolean reloc;
1376 {
1377 fprintf (stderr, "som_sizeof_headers unimplemented\n");
1378 fflush (stderr);
1379 abort ();
1380 return (0);
1381 }
1382
1383 /* Return information about SOM symbol SYMBOL in RET. */
1384
1385 static void
1386 som_get_symbol_info (ignore_abfd, symbol, ret)
1387 bfd *ignore_abfd; /* Ignored. */
1388 asymbol *symbol;
1389 symbol_info *ret;
1390 {
1391 bfd_symbol_info (symbol, ret);
1392 }
1393
1394 /* End of miscellaneous support functions. */
1395
1396 #define som_bfd_debug_info_start bfd_void
1397 #define som_bfd_debug_info_end bfd_void
1398 #define som_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
1399
1400 #define som_openr_next_archived_file bfd_generic_openr_next_archived_file
1401 #define som_generic_stat_arch_elt bfd_generic_stat_arch_elt
1402 #define som_slurp_armap bfd_false
1403 #define som_slurp_extended_name_table _bfd_slurp_extended_name_table
1404 #define som_truncate_arname (void (*)())bfd_nullvoidptr
1405 #define som_write_armap 0
1406
1407 #define som_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
1408 #define som_close_and_cleanup bfd_generic_close_and_cleanup
1409 #define som_get_section_contents bfd_generic_get_section_contents
1410
1411 #define som_bfd_get_relocated_section_contents \
1412 bfd_generic_get_relocated_section_contents
1413 #define som_bfd_relax_section bfd_generic_relax_section
1414 #define som_bfd_seclet_link bfd_generic_seclet_link
1415 #define som_bfd_reloc_type_lookup \
1416 ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
1417 #define som_bfd_make_debug_symbol \
1418 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
1419
1420 /* Core file support is in the hpux-core backend. */
1421 #define som_core_file_failing_command _bfd_dummy_core_file_failing_command
1422 #define som_core_file_failing_signal _bfd_dummy_core_file_failing_signal
1423 #define som_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p
1424
1425 bfd_target som_vec =
1426 {
1427 "som", /* name */
1428 bfd_target_som_flavour,
1429 true, /* target byte order */
1430 true, /* target headers byte order */
1431 (HAS_RELOC | EXEC_P | /* object flags */
1432 HAS_LINENO | HAS_DEBUG |
1433 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
1434 (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
1435 | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1436
1437 /* leading_symbol_char: is the first char of a user symbol
1438 predictable, and if so what is it */
1439 0,
1440 ' ', /* ar_pad_char */
1441 16, /* ar_max_namelen */
1442 3, /* minimum alignment */
1443 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1444 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1445 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
1446 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1447 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1448 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
1449 {_bfd_dummy_target,
1450 som_object_p, /* bfd_check_format */
1451 bfd_generic_archive_p,
1452 _bfd_dummy_target
1453 },
1454 {
1455 bfd_false,
1456 som_mkobject,
1457 _bfd_generic_mkarchive,
1458 bfd_false
1459 },
1460 {
1461 bfd_false,
1462 som_write_object_contents,
1463 _bfd_write_archive_contents,
1464 bfd_false,
1465 },
1466 #undef som
1467 JUMP_TABLE (som),
1468 (PTR) 0
1469 };
1470
1471 #endif /* HOST_HPPAHPUX || HOST_HPPABSD */
This page took 0.075005 seconds and 4 git commands to generate.