]>
Commit | Line | Data |
---|---|---|
d9ad93bc KR |
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 ([email protected]). | |
6 | ||
9e16fcf1 | 7 | This file is part of BFD, the Binary File Descriptor library. |
d9ad93bc | 8 | |
9e16fcf1 SG |
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. | |
d9ad93bc | 13 | |
9e16fcf1 SG |
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. | |
d9ad93bc | 18 | |
9e16fcf1 SG |
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. */ | |
d9ad93bc KR |
22 | |
23 | #include "bfd.h" | |
24 | #include "sysdep.h" | |
25 | ||
d9ad93bc KR |
26 | #if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) |
27 | ||
28 | #include "libbfd.h" | |
29 | #include "som.h" | |
70f1d738 | 30 | #include "libhppa.h" |
d9ad93bc KR |
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 | ||
9d0dea6f JL |
70 | /* Size (in chars) of the temporary buffers used during fixup and string |
71 | table writes. */ | |
72 | ||
73 | #define SOM_TMP_BUFSIZE 8192 | |
74 | ||
75 | ||
4fdb66cd JL |
76 | /* SOM allows any one of the four previous relocations to be reused |
77 | with a "R_PREV_FIXUP" relocation entry. Since R_PREV_FIXUP | |
78 | relocations are always a single byte, using a R_PREV_FIXUP instead | |
79 | of some multi-byte relocation makes object files smaller. | |
80 | ||
81 | Note one side effect of using a R_PREV_FIXUP is the relocation that | |
82 | is being repeated moves to the front of the queue. */ | |
83 | struct reloc_queue | |
84 | { | |
85 | unsigned char *reloc; | |
86 | unsigned int size; | |
87 | } reloc_queue[4]; | |
88 | ||
89 | /* This fully describes the symbol types which may be attached to | |
90 | an EXPORT or IMPORT directive. Only SOM uses this formation | |
91 | (ELF has no need for it). */ | |
92 | typedef enum | |
93 | { | |
94 | SYMBOL_TYPE_UNKNOWN, | |
95 | SYMBOL_TYPE_ABSOLUTE, | |
96 | SYMBOL_TYPE_CODE, | |
97 | SYMBOL_TYPE_DATA, | |
98 | SYMBOL_TYPE_ENTRY, | |
99 | SYMBOL_TYPE_MILLICODE, | |
100 | SYMBOL_TYPE_PLABEL, | |
101 | SYMBOL_TYPE_PRI_PROG, | |
102 | SYMBOL_TYPE_SEC_PROG, | |
103 | } pa_symbol_type; | |
104 | ||
017a52d7 JL |
105 | struct section_to_type |
106 | { | |
107 | char *section; | |
108 | char type; | |
109 | }; | |
110 | ||
9e16fcf1 SG |
111 | /* Forward declarations */ |
112 | ||
113 | static boolean som_mkobject PARAMS ((bfd *)); | |
114 | static bfd_target * som_object_setup PARAMS ((bfd *, | |
115 | struct header *, | |
116 | struct som_exec_auxhdr *)); | |
117 | static asection * make_unique_section PARAMS ((bfd *, CONST char *, int)); | |
118 | static boolean setup_sections PARAMS ((bfd *, struct header *)); | |
119 | static bfd_target * som_object_p PARAMS ((bfd *)); | |
120 | static boolean som_write_object_contents PARAMS ((bfd *)); | |
121 | static boolean som_slurp_string_table PARAMS ((bfd *)); | |
122 | static unsigned int som_slurp_symbol_table PARAMS ((bfd *)); | |
123 | static unsigned int som_get_symtab_upper_bound PARAMS ((bfd *)); | |
124 | static unsigned int som_canonicalize_reloc PARAMS ((bfd *, sec_ptr, | |
125 | arelent **, asymbol **)); | |
126 | static unsigned int som_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); | |
36456a67 JL |
127 | static unsigned int som_set_reloc_info PARAMS ((unsigned char *, unsigned int, |
128 | arelent *, asection *, | |
129 | asymbol **, boolean)); | |
130 | static boolean som_slurp_reloc_table PARAMS ((bfd *, asection *, | |
131 | asymbol **, boolean)); | |
9e16fcf1 SG |
132 | static unsigned int som_get_symtab PARAMS ((bfd *, asymbol **)); |
133 | static asymbol * som_make_empty_symbol PARAMS ((bfd *)); | |
134 | static void som_print_symbol PARAMS ((bfd *, PTR, | |
135 | asymbol *, bfd_print_symbol_type)); | |
136 | static boolean som_new_section_hook PARAMS ((bfd *, asection *)); | |
137 | static boolean som_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, | |
138 | file_ptr, bfd_size_type)); | |
139 | static boolean som_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, | |
140 | unsigned long)); | |
141 | static boolean som_find_nearest_line PARAMS ((bfd *, asection *, | |
142 | asymbol **, bfd_vma, | |
143 | CONST char **, | |
144 | CONST char **, | |
145 | unsigned int *)); | |
146 | static void som_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); | |
147 | static asection * som_section_from_subspace_index PARAMS ((bfd *, | |
148 | unsigned int)); | |
149 | static int log2 PARAMS ((unsigned int)); | |
fcb0c846 JL |
150 | static bfd_reloc_status_type hppa_som_reloc PARAMS ((bfd *, arelent *, |
151 | asymbol *, PTR, | |
152 | asection *, bfd *)); | |
d125665c JL |
153 | static void som_initialize_reloc_queue PARAMS ((struct reloc_queue *)); |
154 | static void som_reloc_queue_insert PARAMS ((unsigned char *, unsigned int, | |
155 | struct reloc_queue *)); | |
156 | static void som_reloc_queue_fix PARAMS ((struct reloc_queue *, unsigned int)); | |
157 | static int som_reloc_queue_find PARAMS ((unsigned char *, unsigned int, | |
158 | struct reloc_queue *)); | |
54bbfd37 JL |
159 | static unsigned char * try_prev_fixup PARAMS ((bfd *, int *, unsigned char *, |
160 | unsigned int, | |
161 | struct reloc_queue *)); | |
162 | ||
163 | static unsigned char * som_reloc_skip PARAMS ((bfd *, unsigned int, | |
164 | unsigned char *, unsigned int *, | |
165 | struct reloc_queue *)); | |
166 | static unsigned char * som_reloc_addend PARAMS ((bfd *, int, unsigned char *, | |
167 | unsigned int *, | |
168 | struct reloc_queue *)); | |
7057b78f JL |
169 | static unsigned char * som_reloc_call PARAMS ((bfd *, unsigned char *, |
170 | unsigned int *, | |
171 | arelent *, int, | |
172 | struct reloc_queue *)); | |
5532fc5a JL |
173 | static unsigned long som_count_spaces PARAMS ((bfd *)); |
174 | static unsigned long som_count_subspaces PARAMS ((bfd *)); | |
175 | static int compare_syms PARAMS ((asymbol **, asymbol **)); | |
176 | static unsigned long som_compute_checksum PARAMS ((bfd *)); | |
0ffa24b9 | 177 | static boolean som_prep_headers PARAMS ((bfd *)); |
2212ff92 | 178 | static int som_sizeof_headers PARAMS ((bfd *, boolean)); |
efc0df7c | 179 | static boolean som_write_headers PARAMS ((bfd *)); |
713de7ec | 180 | static boolean som_build_and_write_symbol_table PARAMS ((bfd *)); |
aff97790 | 181 | static void som_prep_for_fixups PARAMS ((bfd *, asymbol **, unsigned long)); |
9d0dea6f | 182 | static boolean som_write_fixups PARAMS ((bfd *, unsigned long, unsigned int *)); |
0b35f7ec JL |
183 | static boolean som_write_space_strings PARAMS ((bfd *, unsigned long, |
184 | unsigned int *)); | |
185 | static boolean som_write_symbol_strings PARAMS ((bfd *, unsigned long, | |
186 | asymbol **, unsigned int, | |
187 | unsigned *)); | |
6eb64408 | 188 | static boolean som_begin_writing PARAMS ((bfd *)); |
91c0bcbb JL |
189 | static const reloc_howto_type * som_bfd_reloc_type_lookup |
190 | PARAMS ((bfd_arch_info_type *, bfd_reloc_code_real_type)); | |
017a52d7 JL |
191 | static char som_section_type PARAMS ((const char *)); |
192 | static int som_decode_symclass PARAMS ((asymbol *)); | |
193 | ||
194 | ||
195 | /* Map SOM section names to POSIX/BSD single-character symbol types. | |
196 | ||
197 | This table includes all the standard subspaces as defined in the | |
198 | current "PRO ABI for PA-RISC Systems", $UNWIND$ which for | |
199 | some reason was left out, and sections specific to embedded stabs. */ | |
200 | ||
201 | static const struct section_to_type stt[] = { | |
202 | {"$TEXT$", 't'}, | |
203 | {"$SHLIB_INFO$", 't'}, | |
204 | {"$MILLICODE$", 't'}, | |
205 | {"$LIT$", 't'}, | |
206 | {"$CODE$", 't'}, | |
207 | {"$UNWIND_START$", 't'}, | |
208 | {"$UNWIND$", 't'}, | |
209 | {"$PRIVATE$", 'd'}, | |
210 | {"$PLT$", 'd'}, | |
211 | {"$SHLIB_DATA$", 'd'}, | |
212 | {"$DATA$", 'd'}, | |
213 | {"$SHORTDATA$", 'g'}, | |
214 | {"$DLT$", 'd'}, | |
215 | {"$GLOBAL$", 'g'}, | |
216 | {"$SHORTBSS$", 's'}, | |
217 | {"$BSS$", 'b'}, | |
218 | {"$GDB_STRINGS$", 'N'}, | |
219 | {"$GDB_SYMBOLS$", 'N'}, | |
220 | {0, 0} | |
221 | }; | |
2212ff92 | 222 | |
36456a67 JL |
223 | /* About the relocation formatting table... |
224 | ||
225 | There are 256 entries in the table, one for each possible | |
226 | relocation opcode available in SOM. We index the table by | |
227 | the relocation opcode. The names and operations are those | |
228 | defined by a.out_800 (4). | |
229 | ||
230 | Right now this table is only used to count and perform minimal | |
231 | processing on relocation streams so that they can be internalized | |
232 | into BFD and symbolically printed by utilities. To make actual use | |
233 | of them would be much more difficult, BFD's concept of relocations | |
234 | is far too simple to handle SOM relocations. The basic assumption | |
235 | that a relocation can be completely processed independent of other | |
236 | relocations before an object file is written is invalid for SOM. | |
237 | ||
238 | The SOM relocations are meant to be processed as a stream, they | |
239 | specify copying of data from the input section to the output section | |
240 | while possibly modifying the data in some manner. They also can | |
241 | specify that a variable number of zeros or uninitialized data be | |
242 | inserted on in the output segment at the current offset. Some | |
243 | relocations specify that some previous relocation be re-applied at | |
244 | the current location in the input/output sections. And finally a number | |
245 | of relocations have effects on other sections (R_ENTRY, R_EXIT, | |
246 | R_UNWIND_AUX and a variety of others). There isn't even enough room | |
247 | in the BFD relocation data structure to store enough information to | |
248 | perform all the relocations. | |
249 | ||
250 | Each entry in the table has three fields. | |
251 | ||
252 | The first entry is an index into this "class" of relocations. This | |
253 | index can then be used as a variable within the relocation itself. | |
254 | ||
255 | The second field is a format string which actually controls processing | |
256 | of the relocation. It uses a simple postfix machine to do calculations | |
257 | based on variables/constants found in the string and the relocation | |
258 | stream. | |
259 | ||
260 | The third field specifys whether or not this relocation may use | |
261 | a constant (V) from the previous R_DATA_OVERRIDE rather than a constant | |
262 | stored in the instruction. | |
263 | ||
264 | Variables: | |
265 | ||
266 | L = input space byte count | |
267 | D = index into class of relocations | |
268 | M = output space byte count | |
269 | N = statement number (unused?) | |
270 | O = stack operation | |
271 | R = parameter relocation bits | |
272 | S = symbol index | |
273 | U = 64 bits of stack unwind and frame size info (we only keep 32 bits) | |
274 | V = a literal constant (usually used in the next relocation) | |
275 | P = a previous relocation | |
276 | ||
277 | Lower case letters (starting with 'b') refer to following | |
278 | bytes in the relocation stream. 'b' is the next 1 byte, | |
279 | c is the next 2 bytes, d is the next 3 bytes, etc... | |
280 | This is the variable part of the relocation entries that | |
281 | makes our life a living hell. | |
282 | ||
283 | numerical constants are also used in the format string. Note | |
284 | the constants are represented in decimal. | |
285 | ||
286 | '+', "*" and "=" represents the obvious postfix operators. | |
287 | '<' represents a left shift. | |
288 | ||
289 | Stack Operations: | |
290 | ||
291 | Parameter Relocation Bits: | |
292 | ||
293 | Unwind Entries: | |
294 | ||
295 | Previous Relocations: The index field represents which in the queue | |
296 | of 4 previous fixups should be re-applied. | |
297 | ||
298 | Literal Constants: These are generally used to represent addend | |
299 | parts of relocations when these constants are not stored in the | |
300 | fields of the instructions themselves. For example the instruction | |
301 | addil foo-$global$-0x1234 would use an override for "0x1234" rather | |
302 | than storing it into the addil itself. */ | |
303 | ||
304 | struct fixup_format | |
305 | { | |
306 | int D; | |
307 | char *format; | |
308 | }; | |
309 | ||
310 | static const struct fixup_format som_fixup_formats[256] = | |
311 | { | |
312 | /* R_NO_RELOCATION */ | |
313 | 0, "LD1+4*=", /* 0x00 */ | |
314 | 1, "LD1+4*=", /* 0x01 */ | |
315 | 2, "LD1+4*=", /* 0x02 */ | |
316 | 3, "LD1+4*=", /* 0x03 */ | |
317 | 4, "LD1+4*=", /* 0x04 */ | |
318 | 5, "LD1+4*=", /* 0x05 */ | |
319 | 6, "LD1+4*=", /* 0x06 */ | |
320 | 7, "LD1+4*=", /* 0x07 */ | |
321 | 8, "LD1+4*=", /* 0x08 */ | |
322 | 9, "LD1+4*=", /* 0x09 */ | |
323 | 10, "LD1+4*=", /* 0x0a */ | |
324 | 11, "LD1+4*=", /* 0x0b */ | |
325 | 12, "LD1+4*=", /* 0x0c */ | |
326 | 13, "LD1+4*=", /* 0x0d */ | |
327 | 14, "LD1+4*=", /* 0x0e */ | |
328 | 15, "LD1+4*=", /* 0x0f */ | |
329 | 16, "LD1+4*=", /* 0x10 */ | |
330 | 17, "LD1+4*=", /* 0x11 */ | |
331 | 18, "LD1+4*=", /* 0x12 */ | |
332 | 19, "LD1+4*=", /* 0x13 */ | |
333 | 20, "LD1+4*=", /* 0x14 */ | |
334 | 21, "LD1+4*=", /* 0x15 */ | |
335 | 22, "LD1+4*=", /* 0x16 */ | |
336 | 23, "LD1+4*=", /* 0x17 */ | |
337 | 0, "LD8<b+1+4*=", /* 0x18 */ | |
338 | 1, "LD8<b+1+4*=", /* 0x19 */ | |
339 | 2, "LD8<b+1+4*=", /* 0x1a */ | |
340 | 3, "LD8<b+1+4*=", /* 0x1b */ | |
341 | 0, "LD16<c+1+4*=", /* 0x1c */ | |
342 | 1, "LD16<c+1+4*=", /* 0x1d */ | |
343 | 2, "LD16<c+1+4*=", /* 0x1e */ | |
344 | 0, "Ld1+=", /* 0x1f */ | |
345 | /* R_ZEROES */ | |
346 | 0, "Lb1+4*=", /* 0x20 */ | |
347 | 1, "Ld1+=", /* 0x21 */ | |
348 | /* R_UNINIT */ | |
349 | 0, "Lb1+4*=", /* 0x22 */ | |
350 | 1, "Ld1+=", /* 0x23 */ | |
351 | /* R_RELOCATION */ | |
352 | 0, "L4=", /* 0x24 */ | |
353 | /* R_DATA_ONE_SYMBOL */ | |
354 | 0, "L4=Sb=", /* 0x25 */ | |
355 | 1, "L4=Sd=", /* 0x26 */ | |
356 | /* R_DATA_PLEBEL */ | |
357 | 0, "L4=Sb=", /* 0x27 */ | |
358 | 1, "L4=Sd=", /* 0x28 */ | |
359 | /* R_SPACE_REF */ | |
360 | 0, "L4=", /* 0x29 */ | |
361 | /* R_REPEATED_INIT */ | |
362 | 0, "L4=Mb1+4*=", /* 0x2a */ | |
363 | 1, "Lb4*=Mb1+L*=", /* 0x2b */ | |
364 | 2, "Lb4*=Md1+4*=", /* 0x2c */ | |
365 | 3, "Ld1+=Me1+=", /* 0x2d */ | |
366 | /* R_RESERVED */ | |
367 | 0, "", /* 0x2e */ | |
368 | 0, "", /* 0x2f */ | |
369 | /* R_PCREL_CALL */ | |
370 | 0, "L4=RD=Sb=", /* 0x30 */ | |
371 | 1, "L4=RD=Sb=", /* 0x31 */ | |
372 | 2, "L4=RD=Sb=", /* 0x32 */ | |
373 | 3, "L4=RD=Sb=", /* 0x33 */ | |
374 | 4, "L4=RD=Sb=", /* 0x34 */ | |
375 | 5, "L4=RD=Sb=", /* 0x35 */ | |
376 | 6, "L4=RD=Sb=", /* 0x36 */ | |
377 | 7, "L4=RD=Sb=", /* 0x37 */ | |
378 | 8, "L4=RD=Sb=", /* 0x38 */ | |
379 | 9, "L4=RD=Sb=", /* 0x39 */ | |
380 | 0, "L4=RD8<b+=Sb=",/* 0x3a */ | |
381 | 1, "L4=RD8<b+=Sb=",/* 0x3b */ | |
382 | 0, "L4=RD8<b+=Sd=",/* 0x3c */ | |
383 | 1, "L4=RD8<b+=Sd=",/* 0x3d */ | |
384 | /* R_RESERVED */ | |
385 | 0, "", /* 0x3e */ | |
386 | 0, "", /* 0x3f */ | |
387 | /* R_ABS_CALL */ | |
388 | 0, "L4=RD=Sb=", /* 0x40 */ | |
389 | 1, "L4=RD=Sb=", /* 0x41 */ | |
390 | 2, "L4=RD=Sb=", /* 0x42 */ | |
391 | 3, "L4=RD=Sb=", /* 0x43 */ | |
392 | 4, "L4=RD=Sb=", /* 0x44 */ | |
393 | 5, "L4=RD=Sb=", /* 0x45 */ | |
394 | 6, "L4=RD=Sb=", /* 0x46 */ | |
395 | 7, "L4=RD=Sb=", /* 0x47 */ | |
396 | 8, "L4=RD=Sb=", /* 0x48 */ | |
397 | 9, "L4=RD=Sb=", /* 0x49 */ | |
398 | 0, "L4=RD8<b+=Sb=",/* 0x4a */ | |
399 | 1, "L4=RD8<b+=Sb=",/* 0x4b */ | |
400 | 0, "L4=RD8<b+=Sd=",/* 0x4c */ | |
401 | 1, "L4=RD8<b+=Sd=",/* 0x4d */ | |
402 | /* R_RESERVED */ | |
403 | 0, "", /* 0x4e */ | |
404 | 0, "", /* 0x4f */ | |
405 | /* R_DP_RELATIVE */ | |
406 | 0, "L4=SD=", /* 0x50 */ | |
407 | 1, "L4=SD=", /* 0x51 */ | |
408 | 2, "L4=SD=", /* 0x52 */ | |
409 | 3, "L4=SD=", /* 0x53 */ | |
410 | 4, "L4=SD=", /* 0x54 */ | |
411 | 5, "L4=SD=", /* 0x55 */ | |
412 | 6, "L4=SD=", /* 0x56 */ | |
413 | 7, "L4=SD=", /* 0x57 */ | |
414 | 8, "L4=SD=", /* 0x58 */ | |
415 | 9, "L4=SD=", /* 0x59 */ | |
416 | 10, "L4=SD=", /* 0x5a */ | |
417 | 11, "L4=SD=", /* 0x5b */ | |
418 | 12, "L4=SD=", /* 0x5c */ | |
419 | 13, "L4=SD=", /* 0x5d */ | |
420 | 14, "L4=SD=", /* 0x5e */ | |
421 | 15, "L4=SD=", /* 0x5f */ | |
422 | 16, "L4=SD=", /* 0x60 */ | |
423 | 17, "L4=SD=", /* 0x61 */ | |
424 | 18, "L4=SD=", /* 0x62 */ | |
425 | 19, "L4=SD=", /* 0x63 */ | |
426 | 20, "L4=SD=", /* 0x64 */ | |
427 | 21, "L4=SD=", /* 0x65 */ | |
428 | 22, "L4=SD=", /* 0x66 */ | |
429 | 23, "L4=SD=", /* 0x67 */ | |
430 | 24, "L4=SD=", /* 0x68 */ | |
431 | 25, "L4=SD=", /* 0x69 */ | |
432 | 26, "L4=SD=", /* 0x6a */ | |
433 | 27, "L4=SD=", /* 0x6b */ | |
434 | 28, "L4=SD=", /* 0x6c */ | |
435 | 29, "L4=SD=", /* 0x6d */ | |
436 | 30, "L4=SD=", /* 0x6e */ | |
437 | 31, "L4=SD=", /* 0x6f */ | |
438 | 32, "L4=Sb=", /* 0x70 */ | |
439 | 33, "L4=Sd=", /* 0x71 */ | |
440 | /* R_RESERVED */ | |
441 | 0, "", /* 0x72 */ | |
442 | 0, "", /* 0x73 */ | |
443 | 0, "", /* 0x74 */ | |
444 | 0, "", /* 0x75 */ | |
445 | 0, "", /* 0x76 */ | |
446 | 0, "", /* 0x77 */ | |
447 | /* R_DLT_REL */ | |
448 | 0, "L4=Sb=", /* 0x78 */ | |
449 | 1, "L4=Sd=", /* 0x79 */ | |
450 | /* R_RESERVED */ | |
451 | 0, "", /* 0x7a */ | |
452 | 0, "", /* 0x7b */ | |
453 | 0, "", /* 0x7c */ | |
454 | 0, "", /* 0x7d */ | |
455 | 0, "", /* 0x7e */ | |
456 | 0, "", /* 0x7f */ | |
457 | /* R_CODE_ONE_SYMBOL */ | |
458 | 0, "L4=SD=", /* 0x80 */ | |
459 | 1, "L4=SD=", /* 0x81 */ | |
460 | 2, "L4=SD=", /* 0x82 */ | |
461 | 3, "L4=SD=", /* 0x83 */ | |
462 | 4, "L4=SD=", /* 0x84 */ | |
463 | 5, "L4=SD=", /* 0x85 */ | |
464 | 6, "L4=SD=", /* 0x86 */ | |
465 | 7, "L4=SD=", /* 0x87 */ | |
466 | 8, "L4=SD=", /* 0x88 */ | |
467 | 9, "L4=SD=", /* 0x89 */ | |
468 | 10, "L4=SD=", /* 0x8q */ | |
469 | 11, "L4=SD=", /* 0x8b */ | |
470 | 12, "L4=SD=", /* 0x8c */ | |
471 | 13, "L4=SD=", /* 0x8d */ | |
472 | 14, "L4=SD=", /* 0x8e */ | |
473 | 15, "L4=SD=", /* 0x8f */ | |
474 | 16, "L4=SD=", /* 0x90 */ | |
475 | 17, "L4=SD=", /* 0x91 */ | |
476 | 18, "L4=SD=", /* 0x92 */ | |
477 | 19, "L4=SD=", /* 0x93 */ | |
478 | 20, "L4=SD=", /* 0x94 */ | |
479 | 21, "L4=SD=", /* 0x95 */ | |
480 | 22, "L4=SD=", /* 0x96 */ | |
481 | 23, "L4=SD=", /* 0x97 */ | |
482 | 24, "L4=SD=", /* 0x98 */ | |
483 | 25, "L4=SD=", /* 0x99 */ | |
484 | 26, "L4=SD=", /* 0x9a */ | |
485 | 27, "L4=SD=", /* 0x9b */ | |
486 | 28, "L4=SD=", /* 0x9c */ | |
487 | 29, "L4=SD=", /* 0x9d */ | |
488 | 30, "L4=SD=", /* 0x9e */ | |
489 | 31, "L4=SD=", /* 0x9f */ | |
490 | 32, "L4=Sb=", /* 0xa0 */ | |
491 | 33, "L4=Sd=", /* 0xa1 */ | |
492 | /* R_RESERVED */ | |
493 | 0, "", /* 0xa2 */ | |
494 | 0, "", /* 0xa3 */ | |
495 | 0, "", /* 0xa4 */ | |
496 | 0, "", /* 0xa5 */ | |
497 | 0, "", /* 0xa6 */ | |
498 | 0, "", /* 0xa7 */ | |
499 | 0, "", /* 0xa8 */ | |
500 | 0, "", /* 0xa9 */ | |
501 | 0, "", /* 0xaa */ | |
502 | 0, "", /* 0xab */ | |
503 | 0, "", /* 0xac */ | |
504 | 0, "", /* 0xad */ | |
505 | /* R_MILLI_REL */ | |
506 | 0, "L4=Sb=", /* 0xae */ | |
507 | 1, "L4=Sd=", /* 0xaf */ | |
508 | /* R_CODE_PLABEL */ | |
509 | 0, "L4=Sb=", /* 0xb0 */ | |
510 | 1, "L4=Sd=", /* 0xb1 */ | |
511 | /* R_BREAKPOINT */ | |
512 | 0, "L4=", /* 0xb2 */ | |
513 | /* R_ENTRY */ | |
514 | 0, "Ui=", /* 0xb3 */ | |
515 | 1, "Uf=", /* 0xb4 */ | |
516 | /* R_ALT_ENTRY */ | |
517 | 0, "", /* 0xb5 */ | |
518 | /* R_EXIT */ | |
519 | 0, "", /* 0xb6 */ | |
520 | /* R_BEGIN_TRY */ | |
521 | 0, "", /* 0xb7 */ | |
522 | /* R_END_TRY */ | |
523 | 0, "R0=", /* 0xb8 */ | |
524 | 1, "Rb4*=", /* 0xb9 */ | |
525 | 2, "Rd4*=", /* 0xba */ | |
526 | /* R_BEGIN_BRTAB */ | |
527 | 0, "", /* 0xbb */ | |
528 | /* R_END_BRTAB */ | |
529 | 0, "", /* 0xbc */ | |
530 | /* R_STATEMENT */ | |
531 | 0, "Nb=", /* 0xbd */ | |
532 | 1, "Nc=", /* 0xbe */ | |
533 | 2, "Nd=", /* 0xbf */ | |
534 | /* R_DATA_EXPR */ | |
535 | 0, "L4=", /* 0xc0 */ | |
536 | /* R_CODE_EXPR */ | |
537 | 0, "L4=", /* 0xc1 */ | |
538 | /* R_FSEL */ | |
539 | 0, "", /* 0xc2 */ | |
540 | /* R_LSEL */ | |
541 | 0, "", /* 0xc3 */ | |
542 | /* R_RSEL */ | |
543 | 0, "", /* 0xc4 */ | |
544 | /* R_N_MODE */ | |
545 | 0, "", /* 0xc5 */ | |
546 | /* R_S_MODE */ | |
547 | 0, "", /* 0xc6 */ | |
548 | /* R_D_MODE */ | |
549 | 0, "", /* 0xc7 */ | |
550 | /* R_R_MODE */ | |
551 | 0, "", /* 0xc8 */ | |
552 | /* R_DATA_OVERRIDE */ | |
553 | 0, "V0=", /* 0xc9 */ | |
554 | 1, "Vb=", /* 0xca */ | |
555 | 2, "Vc=", /* 0xcb */ | |
556 | 3, "Vd=", /* 0xcc */ | |
557 | 4, "Ve=", /* 0xcd */ | |
558 | /* R_TRANSLATED */ | |
559 | 0, "", /* 0xce */ | |
560 | /* R_RESERVED */ | |
561 | 0, "", /* 0xcf */ | |
562 | /* R_COMP1 */ | |
563 | 0, "Ob=", /* 0xd0 */ | |
564 | /* R_COMP2 */ | |
565 | 0, "Ob=Sd=", /* 0xd1 */ | |
566 | /* R_COMP3 */ | |
567 | 0, "Ob=Ve=", /* 0xd2 */ | |
568 | /* R_PREV_FIXUP */ | |
569 | 0, "P", /* 0xd3 */ | |
570 | 1, "P", /* 0xd4 */ | |
571 | 2, "P", /* 0xd5 */ | |
572 | 3, "P", /* 0xd6 */ | |
573 | /* R_RESERVED */ | |
574 | 0, "", /* 0xd7 */ | |
575 | 0, "", /* 0xd8 */ | |
576 | 0, "", /* 0xd9 */ | |
577 | 0, "", /* 0xda */ | |
578 | 0, "", /* 0xdb */ | |
579 | 0, "", /* 0xdc */ | |
580 | 0, "", /* 0xdd */ | |
581 | 0, "", /* 0xde */ | |
582 | 0, "", /* 0xdf */ | |
583 | 0, "", /* 0xe0 */ | |
584 | 0, "", /* 0xe1 */ | |
585 | 0, "", /* 0xe2 */ | |
586 | 0, "", /* 0xe3 */ | |
587 | 0, "", /* 0xe4 */ | |
588 | 0, "", /* 0xe5 */ | |
589 | 0, "", /* 0xe6 */ | |
590 | 0, "", /* 0xe7 */ | |
591 | 0, "", /* 0xe8 */ | |
592 | 0, "", /* 0xe9 */ | |
593 | 0, "", /* 0xea */ | |
594 | 0, "", /* 0xeb */ | |
595 | 0, "", /* 0xec */ | |
596 | 0, "", /* 0xed */ | |
597 | 0, "", /* 0xee */ | |
598 | 0, "", /* 0xef */ | |
599 | 0, "", /* 0xf0 */ | |
600 | 0, "", /* 0xf1 */ | |
601 | 0, "", /* 0xf2 */ | |
602 | 0, "", /* 0xf3 */ | |
603 | 0, "", /* 0xf4 */ | |
604 | 0, "", /* 0xf5 */ | |
605 | 0, "", /* 0xf6 */ | |
606 | 0, "", /* 0xf7 */ | |
607 | 0, "", /* 0xf8 */ | |
608 | 0, "", /* 0xf9 */ | |
609 | 0, "", /* 0xfa */ | |
610 | 0, "", /* 0xfb */ | |
611 | 0, "", /* 0xfc */ | |
612 | 0, "", /* 0xfd */ | |
613 | 0, "", /* 0xfe */ | |
614 | 0, "", /* 0xff */ | |
615 | }; | |
616 | ||
617 | static const int comp1_opcodes[] = | |
618 | { | |
619 | 0x00, | |
620 | 0x40, | |
621 | 0x41, | |
622 | 0x42, | |
623 | 0x43, | |
624 | 0x44, | |
625 | 0x45, | |
626 | 0x46, | |
627 | 0x47, | |
628 | 0x48, | |
629 | 0x49, | |
630 | 0x4a, | |
631 | 0x4b, | |
632 | 0x60, | |
633 | 0x80, | |
634 | 0xa0, | |
635 | 0xc0, | |
636 | -1 | |
637 | }; | |
638 | ||
639 | static const int comp2_opcodes[] = | |
640 | { | |
641 | 0x00, | |
642 | 0x80, | |
643 | 0x82, | |
644 | 0xc0, | |
645 | -1 | |
646 | }; | |
647 | ||
648 | static const int comp3_opcodes[] = | |
649 | { | |
650 | 0x00, | |
651 | 0x02, | |
652 | -1 | |
653 | }; | |
654 | ||
744069b8 JL |
655 | /* These apparently are not in older versions of hpux reloc.h. */ |
656 | #ifndef R_DLT_REL | |
657 | #define R_DLT_REL 0x78 | |
658 | #endif | |
659 | ||
660 | #ifndef R_AUX_UNWIND | |
661 | #define R_AUX_UNWIND 0xcf | |
662 | #endif | |
663 | ||
664 | #ifndef R_SEC_STMT | |
665 | #define R_SEC_STMT 0xd7 | |
666 | #endif | |
667 | ||
fcb0c846 JL |
668 | static reloc_howto_type som_hppa_howto_table[] = |
669 | { | |
670 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
671 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
672 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
673 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
674 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
675 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
676 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
677 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
678 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
679 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
680 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
681 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
682 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
683 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
684 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
685 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
686 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
687 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
688 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
689 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
690 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
691 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
692 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
693 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
694 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
695 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
696 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
697 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
698 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
699 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
700 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
701 | {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"}, | |
702 | {R_ZEROES, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ZEROES"}, | |
703 | {R_ZEROES, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ZEROES"}, | |
704 | {R_UNINIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_UNINIT"}, | |
705 | {R_UNINIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_UNINIT"}, | |
706 | {R_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RELOCATION"}, | |
707 | {R_DATA_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_ONE_SYMBOL"}, | |
708 | {R_DATA_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_ONE_SYMBOL"}, | |
709 | {R_DATA_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_PLABEL"}, | |
710 | {R_DATA_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_PLABEL"}, | |
711 | {R_SPACE_REF, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_SPACE_REF"}, | |
712 | {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"}, | |
713 | {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"}, | |
714 | {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"}, | |
715 | {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"}, | |
716 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
717 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
718 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
719 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
720 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
721 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
722 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
723 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
724 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
725 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
726 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
727 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
728 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
729 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
730 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
731 | {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"}, | |
732 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
733 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
734 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
735 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
736 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
737 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
738 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
739 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
740 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
741 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
742 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
743 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
744 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
745 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
746 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
747 | {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"}, | |
748 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
749 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
750 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
751 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
752 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
753 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
754 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
755 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
756 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
757 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
758 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
759 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
760 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
761 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
762 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
763 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
764 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
765 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
766 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
767 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
768 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
769 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
770 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
771 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
772 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
773 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
774 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
775 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
776 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
777 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
778 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
779 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
780 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
781 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
782 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
783 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
784 | {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"}, | |
785 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
786 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
787 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
788 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
789 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
744069b8 JL |
790 | {R_DLT_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DLT_REL"}, |
791 | {R_DLT_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DLT_REL"}, | |
fcb0c846 JL |
792 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, |
793 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
794 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
795 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
796 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
797 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
798 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
799 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
800 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
801 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
802 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
803 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
804 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
805 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
806 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
807 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
808 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
809 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
810 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
811 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
812 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
813 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
814 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
815 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
816 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
817 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
818 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
819 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
820 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
821 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
822 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
823 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
824 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
825 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
826 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
827 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
828 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
829 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
830 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
831 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
832 | {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"}, | |
833 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
834 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
835 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
836 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
837 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
838 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
839 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
840 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
841 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
842 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
843 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
844 | {R_MILLI_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_MILLI_REL"}, | |
845 | {R_MILLI_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_MILLI_REL"}, | |
846 | {R_CODE_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_PLABEL"}, | |
847 | {R_CODE_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_PLABEL"}, | |
848 | {R_BREAKPOINT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BREAKPOINT"}, | |
849 | {R_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ENTRY"}, | |
850 | {R_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ENTRY"}, | |
851 | {R_ALT_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ALT_ENTRY"}, | |
852 | {R_EXIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_EXIT"}, | |
853 | {R_BEGIN_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BEGIN_TRY"}, | |
854 | {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"}, | |
855 | {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"}, | |
017a52d7 | 856 | {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"}, |
fcb0c846 JL |
857 | {R_BEGIN_BRTAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BEGIN_BRTAB"}, |
858 | {R_END_BRTAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_BRTAB"}, | |
859 | {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"}, | |
860 | {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"}, | |
861 | {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"}, | |
862 | {R_DATA_EXPR, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_EXPR"}, | |
863 | {R_CODE_EXPR, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_EXPR"}, | |
864 | {R_FSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_FSEL"}, | |
865 | {R_LSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LSEL"}, | |
866 | {R_RSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RSEL"}, | |
867 | {R_N_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_N_MODE"}, | |
868 | {R_S_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_S_MODE"}, | |
869 | {R_D_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_D_MODE"}, | |
870 | {R_R_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_R_MODE"}, | |
871 | {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"}, | |
872 | {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"}, | |
873 | {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"}, | |
874 | {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"}, | |
875 | {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"}, | |
fcb0c846 | 876 | {R_TRANSLATED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_TRANSLATED"}, |
744069b8 | 877 | {R_AUX_UNWIND, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_AUX_UNWIND"}, |
fcb0c846 JL |
878 | {R_COMP1, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP1"}, |
879 | {R_COMP2, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP2"}, | |
880 | {R_COMP3, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP3"}, | |
881 | {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"}, | |
882 | {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"}, | |
883 | {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"}, | |
884 | {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"}, | |
744069b8 | 885 | {R_SEC_STMT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_SEC_STMT"}, |
fcb0c846 JL |
886 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, |
887 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
888 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
889 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
890 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
891 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
892 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
893 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
894 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
895 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
896 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
897 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
898 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
899 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
900 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
901 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
902 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
903 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
904 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
905 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
906 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
907 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
908 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
909 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
910 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
911 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
912 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
913 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
914 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
915 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
916 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
917 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
918 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
919 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
920 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
921 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
922 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
923 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
924 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}, | |
925 | {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}}; | |
926 | ||
d125665c JL |
927 | |
928 | /* Initialize the SOM relocation queue. By definition the queue holds | |
929 | the last four multibyte fixups. */ | |
930 | ||
931 | static void | |
932 | som_initialize_reloc_queue (queue) | |
933 | struct reloc_queue *queue; | |
934 | { | |
935 | queue[0].reloc = NULL; | |
936 | queue[0].size = 0; | |
937 | queue[1].reloc = NULL; | |
938 | queue[1].size = 0; | |
939 | queue[2].reloc = NULL; | |
940 | queue[2].size = 0; | |
941 | queue[3].reloc = NULL; | |
942 | queue[3].size = 0; | |
943 | } | |
944 | ||
945 | /* Insert a new relocation into the relocation queue. */ | |
946 | ||
947 | static void | |
948 | som_reloc_queue_insert (p, size, queue) | |
949 | unsigned char *p; | |
950 | unsigned int size; | |
951 | struct reloc_queue *queue; | |
952 | { | |
953 | queue[3].reloc = queue[2].reloc; | |
954 | queue[3].size = queue[2].size; | |
955 | queue[2].reloc = queue[1].reloc; | |
956 | queue[2].size = queue[1].size; | |
957 | queue[1].reloc = queue[0].reloc; | |
958 | queue[1].size = queue[0].size; | |
959 | queue[0].reloc = p; | |
960 | queue[0].size = size; | |
961 | } | |
962 | ||
963 | /* When an entry in the relocation queue is reused, the entry moves | |
964 | to the front of the queue. */ | |
965 | ||
966 | static void | |
967 | som_reloc_queue_fix (queue, index) | |
968 | struct reloc_queue *queue; | |
969 | unsigned int index; | |
970 | { | |
971 | if (index == 0) | |
972 | return; | |
973 | ||
974 | if (index == 1) | |
975 | { | |
976 | unsigned char *tmp1 = queue[0].reloc; | |
977 | unsigned int tmp2 = queue[0].size; | |
978 | queue[0].reloc = queue[1].reloc; | |
979 | queue[0].size = queue[1].size; | |
980 | queue[1].reloc = tmp1; | |
981 | queue[1].size = tmp2; | |
982 | return; | |
983 | } | |
984 | ||
985 | if (index == 2) | |
986 | { | |
987 | unsigned char *tmp1 = queue[0].reloc; | |
988 | unsigned int tmp2 = queue[0].size; | |
989 | queue[0].reloc = queue[2].reloc; | |
990 | queue[0].size = queue[2].size; | |
991 | queue[2].reloc = queue[1].reloc; | |
992 | queue[2].size = queue[1].size; | |
993 | queue[1].reloc = tmp1; | |
994 | queue[1].size = tmp2; | |
995 | return; | |
996 | } | |
997 | ||
998 | if (index == 3) | |
999 | { | |
1000 | unsigned char *tmp1 = queue[0].reloc; | |
1001 | unsigned int tmp2 = queue[0].size; | |
1002 | queue[0].reloc = queue[3].reloc; | |
1003 | queue[0].size = queue[3].size; | |
1004 | queue[3].reloc = queue[2].reloc; | |
1005 | queue[3].size = queue[2].size; | |
1006 | queue[2].reloc = queue[1].reloc; | |
1007 | queue[2].size = queue[1].size; | |
1008 | queue[1].reloc = tmp1; | |
1009 | queue[1].size = tmp2; | |
1010 | return; | |
1011 | } | |
1012 | abort(); | |
1013 | } | |
1014 | ||
1015 | /* Search for a particular relocation in the relocation queue. */ | |
1016 | ||
1017 | static int | |
1018 | som_reloc_queue_find (p, size, queue) | |
1019 | unsigned char *p; | |
1020 | unsigned int size; | |
1021 | struct reloc_queue *queue; | |
1022 | { | |
1023 | if (!bcmp (p, queue[0].reloc, size) | |
1024 | && size == queue[0].size) | |
1025 | return 0; | |
1026 | if (!bcmp (p, queue[1].reloc, size) | |
1027 | && size == queue[1].size) | |
1028 | return 1; | |
1029 | if (!bcmp (p, queue[2].reloc, size) | |
1030 | && size == queue[2].size) | |
1031 | return 2; | |
1032 | if (!bcmp (p, queue[3].reloc, size) | |
1033 | && size == queue[3].size) | |
1034 | return 3; | |
1035 | return -1; | |
1036 | } | |
54bbfd37 JL |
1037 | |
1038 | static unsigned char * | |
1039 | try_prev_fixup (abfd, subspace_reloc_sizep, p, size, queue) | |
1040 | bfd *abfd; | |
1041 | int *subspace_reloc_sizep; | |
1042 | unsigned char *p; | |
1043 | unsigned int size; | |
1044 | struct reloc_queue *queue; | |
1045 | { | |
1046 | int queue_index = som_reloc_queue_find (p, size, queue); | |
1047 | ||
1048 | if (queue_index != -1) | |
1049 | { | |
1050 | /* Found this in a previous fixup. Undo the fixup we | |
1051 | just built and use R_PREV_FIXUP instead. We saved | |
1052 | a total of size - 1 bytes in the fixup stream. */ | |
1053 | bfd_put_8 (abfd, R_PREV_FIXUP + queue_index, p); | |
1054 | p += 1; | |
1055 | *subspace_reloc_sizep += 1; | |
1056 | som_reloc_queue_fix (queue, queue_index); | |
1057 | } | |
1058 | else | |
1059 | { | |
1060 | som_reloc_queue_insert (p, size, queue); | |
1061 | *subspace_reloc_sizep += size; | |
1062 | p += size; | |
1063 | } | |
1064 | return p; | |
1065 | } | |
1066 | ||
1067 | /* Emit the proper R_NO_RELOCATION fixups to map the next SKIP | |
1068 | bytes without any relocation. Update the size of the subspace | |
1069 | relocation stream via SUBSPACE_RELOC_SIZE_P; also return the | |
1070 | current pointer into the relocation stream. */ | |
1071 | ||
1072 | static unsigned char * | |
1073 | som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, queue) | |
1074 | bfd *abfd; | |
1075 | unsigned int skip; | |
1076 | unsigned char *p; | |
1077 | unsigned int *subspace_reloc_sizep; | |
1078 | struct reloc_queue *queue; | |
1079 | { | |
1080 | /* Use a 4 byte R_NO_RELOCATION entry with a maximal value | |
1081 | then R_PREV_FIXUPs to get the difference down to a | |
1082 | reasonable size. */ | |
1083 | if (skip >= 0x1000000) | |
1084 | { | |
1085 | skip -= 0x1000000; | |
1086 | bfd_put_8 (abfd, R_NO_RELOCATION + 31, p); | |
1087 | bfd_put_8 (abfd, 0xff, p + 1); | |
1088 | bfd_put_16 (abfd, 0xffff, p + 2); | |
1089 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue); | |
1090 | while (skip >= 0x1000000) | |
1091 | { | |
1092 | skip -= 0x1000000; | |
1093 | bfd_put_8 (abfd, R_PREV_FIXUP, p); | |
1094 | p++; | |
1095 | *subspace_reloc_sizep += 1; | |
1096 | /* No need to adjust queue here since we are repeating the | |
1097 | most recent fixup. */ | |
1098 | } | |
1099 | } | |
1100 | ||
1101 | /* The difference must be less than 0x1000000. Use one | |
1102 | more R_NO_RELOCATION entry to get to the right difference. */ | |
1103 | if ((skip & 3) == 0 && skip <= 0xc0000 && skip > 0) | |
1104 | { | |
1105 | /* Difference can be handled in a simple single-byte | |
1106 | R_NO_RELOCATION entry. */ | |
1107 | if (skip <= 0x60) | |
1108 | { | |
1109 | bfd_put_8 (abfd, R_NO_RELOCATION + (skip >> 2) - 1, p); | |
1110 | *subspace_reloc_sizep += 1; | |
1111 | p++; | |
1112 | } | |
1113 | /* Handle it with a two byte R_NO_RELOCATION entry. */ | |
1114 | else if (skip <= 0x1000) | |
1115 | { | |
1116 | bfd_put_8 (abfd, R_NO_RELOCATION + 24 + (((skip >> 2) - 1) >> 8), p); | |
1117 | bfd_put_8 (abfd, (skip >> 2) - 1, p + 1); | |
1118 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue); | |
1119 | } | |
1120 | /* Handle it with a three byte R_NO_RELOCATION entry. */ | |
1121 | else | |
1122 | { | |
1123 | bfd_put_8 (abfd, R_NO_RELOCATION + 28 + (((skip >> 2) - 1) >> 16), p); | |
1124 | bfd_put_16 (abfd, (skip >> 2) - 1, p + 1); | |
1125 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue); | |
1126 | } | |
1127 | } | |
1128 | /* Ugh. Punt and use a 4 byte entry. */ | |
1129 | else if (skip > 0) | |
1130 | { | |
1131 | bfd_put_8 (abfd, R_NO_RELOCATION + 31, p); | |
1132 | bfd_put_8 (abfd, skip >> 16, p + 1); | |
1133 | bfd_put_16 (abfd, skip, p + 2); | |
1134 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue); | |
1135 | } | |
1136 | return p; | |
1137 | } | |
1138 | ||
1139 | /* Emit the proper R_DATA_OVERRIDE fixups to handle a nonzero addend | |
1140 | from a BFD relocation. Update the size of the subspace relocation | |
1141 | stream via SUBSPACE_RELOC_SIZE_P; also return the current pointer | |
1142 | into the relocation stream. */ | |
1143 | ||
1144 | static unsigned char * | |
1145 | som_reloc_addend (abfd, addend, p, subspace_reloc_sizep, queue) | |
1146 | bfd *abfd; | |
1147 | int addend; | |
1148 | unsigned char *p; | |
1149 | unsigned int *subspace_reloc_sizep; | |
1150 | struct reloc_queue *queue; | |
1151 | { | |
1152 | if ((unsigned)(addend) + 0x80 < 0x100) | |
1153 | { | |
1154 | bfd_put_8 (abfd, R_DATA_OVERRIDE + 1, p); | |
1155 | bfd_put_8 (abfd, addend, p + 1); | |
1156 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue); | |
1157 | } | |
1158 | else if ((unsigned) (addend) + 0x8000 < 0x10000) | |
1159 | { | |
1160 | bfd_put_8 (abfd, R_DATA_OVERRIDE + 2, p); | |
1161 | bfd_put_16 (abfd, addend, p + 1); | |
1162 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue); | |
1163 | } | |
1164 | else if ((unsigned) (addend) + 0x800000 < 0x1000000) | |
1165 | { | |
1166 | bfd_put_8 (abfd, R_DATA_OVERRIDE + 3, p); | |
1167 | bfd_put_8 (abfd, addend >> 16, p + 1); | |
1168 | bfd_put_16 (abfd, addend, p + 2); | |
1169 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue); | |
1170 | } | |
1171 | else | |
1172 | { | |
1173 | bfd_put_8 (abfd, R_DATA_OVERRIDE + 4, p); | |
1174 | bfd_put_32 (abfd, addend, p + 1); | |
1175 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 5, queue); | |
1176 | } | |
1177 | return p; | |
1178 | } | |
1179 | ||
7057b78f JL |
1180 | /* Handle a single function call relocation. */ |
1181 | ||
1182 | static unsigned char * | |
1183 | som_reloc_call (abfd, p, subspace_reloc_sizep, bfd_reloc, sym_num, queue) | |
1184 | bfd *abfd; | |
1185 | unsigned char *p; | |
1186 | unsigned int *subspace_reloc_sizep; | |
1187 | arelent *bfd_reloc; | |
1188 | int sym_num; | |
1189 | struct reloc_queue *queue; | |
1190 | { | |
1191 | int arg_bits = HPPA_R_ARG_RELOC (bfd_reloc->addend); | |
1192 | int rtn_bits = arg_bits & 0x3; | |
1193 | int type, done = 0; | |
1194 | ||
1195 | /* You'll never believe all this is necessary to handle relocations | |
1196 | for function calls. Having to compute and pack the argument | |
1197 | relocation bits is the real nightmare. | |
1198 | ||
1199 | If you're interested in how this works, just forget it. You really | |
1200 | do not want to know about this braindamage. */ | |
1201 | ||
1202 | /* First see if this can be done with a "simple" relocation. Simple | |
1203 | relocations have a symbol number < 0x100 and have simple encodings | |
1204 | of argument relocations. */ | |
1205 | ||
1206 | if (sym_num < 0x100) | |
1207 | { | |
1208 | switch (arg_bits) | |
1209 | { | |
1210 | case 0: | |
1211 | case 1: | |
1212 | type = 0; | |
1213 | break; | |
1214 | case 1 << 8: | |
1215 | case 1 << 8 | 1: | |
1216 | type = 1; | |
1217 | break; | |
1218 | case 1 << 8 | 1 << 6: | |
1219 | case 1 << 8 | 1 << 6 | 1: | |
1220 | type = 2; | |
1221 | break; | |
1222 | case 1 << 8 | 1 << 6 | 1 << 4: | |
1223 | case 1 << 8 | 1 << 6 | 1 << 4 | 1: | |
1224 | type = 3; | |
1225 | break; | |
1226 | case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2: | |
1227 | case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2 | 1: | |
1228 | type = 4; | |
1229 | break; | |
1230 | default: | |
1231 | /* Not one of the easy encodings. This will have to be | |
1232 | handled by the more complex code below. */ | |
1233 | type = -1; | |
1234 | break; | |
1235 | } | |
1236 | if (type != -1) | |
1237 | { | |
1238 | /* Account for the return value too. */ | |
1239 | if (rtn_bits) | |
1240 | type += 5; | |
1241 | ||
1242 | /* Emit a 2 byte relocation. Then see if it can be handled | |
1243 | with a relocation which is already in the relocation queue. */ | |
1244 | bfd_put_8 (abfd, bfd_reloc->howto->type + type, p); | |
1245 | bfd_put_8 (abfd, sym_num, p + 1); | |
1246 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue); | |
1247 | done = 1; | |
1248 | } | |
1249 | } | |
1250 | ||
1251 | /* If this could not be handled with a simple relocation, then do a hard | |
1252 | one. Hard relocations occur if the symbol number was too high or if | |
1253 | the encoding of argument relocation bits is too complex. */ | |
1254 | if (! done) | |
1255 | { | |
1256 | /* Don't ask about these magic sequences. I took them straight | |
1257 | from gas-1.36 which took them from the a.out man page. */ | |
1258 | type = rtn_bits; | |
1259 | if ((arg_bits >> 6 & 0xf) == 0xe) | |
1260 | type += 9 * 40; | |
1261 | else | |
1262 | type += (3 * (arg_bits >> 8 & 3) + (arg_bits >> 6 & 3)) * 40; | |
1263 | if ((arg_bits >> 2 & 0xf) == 0xe) | |
1264 | type += 9 * 4; | |
1265 | else | |
1266 | type += (3 * (arg_bits >> 4 & 3) + (arg_bits >> 2 & 3)) * 4; | |
1267 | ||
1268 | /* Output the first two bytes of the relocation. These describe | |
1269 | the length of the relocation and encoding style. */ | |
1270 | bfd_put_8 (abfd, bfd_reloc->howto->type + 10 | |
1271 | + 2 * (sym_num >= 0x100) + (type >= 0x100), | |
1272 | p); | |
1273 | bfd_put_8 (abfd, type, p + 1); | |
1274 | ||
1275 | /* Now output the symbol index and see if this bizarre relocation | |
1276 | just happened to be in the relocation queue. */ | |
1277 | if (sym_num < 0x100) | |
1278 | { | |
1279 | bfd_put_8 (abfd, sym_num, p + 2); | |
1280 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue); | |
1281 | } | |
1282 | else | |
1283 | { | |
1284 | bfd_put_8 (abfd, sym_num >> 16, p + 2); | |
1285 | bfd_put_16 (abfd, sym_num, p + 3); | |
1286 | p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 5, queue); | |
1287 | } | |
1288 | } | |
1289 | return p; | |
1290 | } | |
1291 | ||
1292 | ||
9e16fcf1 | 1293 | /* Return the logarithm of X, base 2, considering X unsigned. |
40249bfb JL |
1294 | Abort if X is not a power of two -- this should never happen (FIXME: |
1295 | It will happen on corrupt executables. GDB should give an error, not | |
1296 | a coredump, in that case). */ | |
9e16fcf1 SG |
1297 | |
1298 | static int | |
1299 | log2 (x) | |
1300 | unsigned int x; | |
1301 | { | |
1302 | int log = 0; | |
1303 | ||
1304 | /* Test for 0 or a power of 2. */ | |
1305 | if (x == 0 || x != (x & -x)) | |
1306 | abort(); | |
1307 | ||
1308 | while ((x >>= 1) != 0) | |
1309 | log++; | |
1310 | return log; | |
1311 | } | |
1312 | ||
fcb0c846 JL |
1313 | static bfd_reloc_status_type |
1314 | hppa_som_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd) | |
1315 | bfd *abfd; | |
1316 | arelent *reloc_entry; | |
1317 | asymbol *symbol_in; | |
1318 | PTR data; | |
1319 | asection *input_section; | |
1320 | bfd *output_bfd; | |
1321 | { | |
1322 | if (output_bfd) | |
1323 | { | |
1324 | reloc_entry->address += input_section->output_offset; | |
1325 | return bfd_reloc_ok; | |
1326 | } | |
1327 | return bfd_reloc_ok; | |
1328 | } | |
32619c58 JL |
1329 | |
1330 | /* Given a generic HPPA relocation type, the instruction format, | |
1331 | and a field selector, return an appropriate SOM reloation. | |
1332 | ||
1333 | FIXME. Need to handle %RR, %LR and the like as field selectors. | |
1334 | These will need to generate multiple SOM relocations. */ | |
1335 | ||
1336 | int ** | |
1337 | hppa_som_gen_reloc_type (abfd, base_type, format, field) | |
1338 | bfd *abfd; | |
1339 | int base_type; | |
1340 | int format; | |
017a52d7 | 1341 | enum hppa_reloc_field_selector_type field; |
32619c58 JL |
1342 | { |
1343 | int *final_type, **final_types; | |
1344 | ||
017a52d7 | 1345 | final_types = (int **) bfd_alloc_by_size_t (abfd, sizeof (int *) * 3); |
32619c58 JL |
1346 | final_type = (int *) bfd_alloc_by_size_t (abfd, sizeof (int)); |
1347 | ||
017a52d7 JL |
1348 | /* The field selector may require additional relocations to be |
1349 | generated. It's impossible to know at this moment if additional | |
1350 | relocations will be needed, so we make them. The code to actually | |
1351 | write the relocation/fixup stream is responsible for removing | |
1352 | any redundant relocations. */ | |
1353 | switch (field) | |
1354 | { | |
1355 | case e_fsel: | |
1356 | case e_psel: | |
1357 | case e_lpsel: | |
1358 | case e_rpsel: | |
a36b6f1d JL |
1359 | final_types[0] = final_type; |
1360 | final_types[1] = NULL; | |
1361 | final_types[2] = NULL; | |
1362 | *final_type = base_type; | |
1363 | break; | |
1364 | ||
017a52d7 JL |
1365 | case e_tsel: |
1366 | case e_ltsel: | |
1367 | case e_rtsel: | |
a36b6f1d JL |
1368 | final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int)); |
1369 | *final_types[0] = R_FSEL; | |
1370 | final_types[1] = final_type; | |
017a52d7 JL |
1371 | final_types[2] = NULL; |
1372 | *final_type = base_type; | |
1373 | break; | |
1374 | ||
1375 | case e_lssel: | |
1376 | case e_rssel: | |
1377 | final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int)); | |
1378 | *final_types[0] = R_S_MODE; | |
1379 | final_types[1] = final_type; | |
1380 | final_types[2] = NULL; | |
1381 | *final_type = base_type; | |
1382 | break; | |
32619c58 | 1383 | |
017a52d7 JL |
1384 | case e_lsel: |
1385 | case e_rsel: | |
1386 | final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int)); | |
1387 | *final_types[0] = R_N_MODE; | |
1388 | final_types[1] = final_type; | |
1389 | final_types[2] = NULL; | |
1390 | *final_type = base_type; | |
1391 | break; | |
32619c58 | 1392 | |
017a52d7 JL |
1393 | case e_ldsel: |
1394 | case e_rdsel: | |
1395 | final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int)); | |
1396 | *final_types[0] = R_D_MODE; | |
1397 | final_types[1] = final_type; | |
1398 | final_types[2] = NULL; | |
1399 | *final_type = base_type; | |
1400 | break; | |
32619c58 | 1401 | |
017a52d7 JL |
1402 | case e_lrsel: |
1403 | case e_rrsel: | |
1404 | final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int)); | |
1405 | *final_types[0] = R_R_MODE; | |
1406 | final_types[1] = final_type; | |
1407 | final_types[2] = NULL; | |
1408 | *final_type = base_type; | |
1409 | break; | |
1410 | } | |
1411 | ||
32619c58 JL |
1412 | switch (base_type) |
1413 | { | |
1414 | case R_HPPA: | |
1415 | /* PLABELs get their own relocation type. */ | |
1416 | if (field == e_psel | |
1417 | || field == e_lpsel | |
1418 | || field == e_rpsel) | |
a36b6f1d JL |
1419 | { |
1420 | /* A PLABEL relocation that has a size of 32 bits must | |
1421 | be a R_DATA_PLABEL. All others are R_CODE_PLABELs. */ | |
1422 | if (format == 32) | |
1423 | *final_type = R_DATA_PLABEL; | |
1424 | else | |
1425 | *final_type = R_CODE_PLABEL; | |
1426 | } | |
1427 | /* PIC stuff. */ | |
1428 | else if (field == e_tsel | |
1429 | || field == e_ltsel | |
1430 | || field == e_rtsel) | |
1431 | *final_type = R_DLT_REL; | |
1432 | /* A relocation in the data space is always a full 32bits. */ | |
32619c58 JL |
1433 | else if (format == 32) |
1434 | *final_type = R_DATA_ONE_SYMBOL; | |
1435 | ||
1436 | break; | |
1437 | ||
1438 | case R_HPPA_GOTOFF: | |
1439 | /* More PLABEL special cases. */ | |
1440 | if (field == e_psel | |
1441 | || field == e_lpsel | |
1442 | || field == e_rpsel) | |
1443 | *final_type = R_DATA_PLABEL; | |
1444 | break; | |
1445 | ||
1446 | case R_HPPA_NONE: | |
1447 | case R_HPPA_ABS_CALL: | |
1448 | case R_HPPA_PCREL_CALL: | |
1449 | case R_HPPA_COMPLEX: | |
1450 | case R_HPPA_COMPLEX_PCREL_CALL: | |
1451 | case R_HPPA_COMPLEX_ABS_CALL: | |
1452 | /* Right now we can default all these. */ | |
1453 | break; | |
1454 | } | |
1455 | return final_types; | |
1456 | } | |
1457 | ||
1458 | /* Return the address of the correct entry in the PA SOM relocation | |
1459 | howto table. */ | |
1460 | ||
91c0bcbb | 1461 | static const reloc_howto_type * |
32619c58 JL |
1462 | som_bfd_reloc_type_lookup (arch, code) |
1463 | bfd_arch_info_type *arch; | |
1464 | bfd_reloc_code_real_type code; | |
1465 | { | |
1466 | if ((int) code < (int) R_NO_RELOCATION + 255) | |
1467 | { | |
1468 | BFD_ASSERT ((int) som_hppa_howto_table[(int) code].type == (int) code); | |
1469 | return &som_hppa_howto_table[(int) code]; | |
1470 | } | |
1471 | ||
1472 | return (reloc_howto_type *) 0; | |
1473 | } | |
1474 | ||
9e16fcf1 SG |
1475 | /* Perform some initialization for an object. Save results of this |
1476 | initialization in the BFD. */ | |
d9ad93bc KR |
1477 | |
1478 | static bfd_target * | |
9e16fcf1 | 1479 | som_object_setup (abfd, file_hdrp, aux_hdrp) |
d9ad93bc KR |
1480 | bfd *abfd; |
1481 | struct header *file_hdrp; | |
1482 | struct som_exec_auxhdr *aux_hdrp; | |
1483 | { | |
9e16fcf1 SG |
1484 | /* som_mkobject will set bfd_error if som_mkobject fails. */ |
1485 | if (som_mkobject (abfd) != true) | |
1486 | return 0; | |
d9ad93bc | 1487 | |
9e16fcf1 SG |
1488 | /* Set BFD flags based on what information is available in the SOM. */ |
1489 | abfd->flags = NO_FLAGS; | |
1490 | if (! file_hdrp->entry_offset) | |
1491 | abfd->flags |= HAS_RELOC; | |
1492 | else | |
1493 | abfd->flags |= EXEC_P; | |
1494 | if (file_hdrp->symbol_total) | |
1495 | abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS; | |
1496 | ||
1497 | bfd_get_start_address (abfd) = aux_hdrp->exec_entry; | |
1498 | bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 0); | |
d9ad93bc | 1499 | bfd_get_symcount (abfd) = file_hdrp->symbol_total; |
9e16fcf1 SG |
1500 | |
1501 | /* Initialize the saved symbol table and string table to NULL. | |
1502 | Save important offsets and sizes from the SOM header into | |
1503 | the BFD. */ | |
1504 | obj_som_stringtab (abfd) = (char *) NULL; | |
1505 | obj_som_symtab (abfd) = (som_symbol_type *) NULL; | |
1506 | obj_som_stringtab_size (abfd) = file_hdrp->symbol_strings_size; | |
1507 | obj_som_sym_filepos (abfd) = file_hdrp->symbol_location; | |
1508 | obj_som_str_filepos (abfd) = file_hdrp->symbol_strings_location; | |
1509 | obj_som_reloc_filepos (abfd) = file_hdrp->fixup_request_location; | |
d9ad93bc KR |
1510 | |
1511 | return abfd->xvec; | |
1512 | } | |
1513 | ||
1514 | /* Create a new BFD section for NAME. If NAME already exists, then create a | |
1515 | new unique name, with NAME as the prefix. This exists because SOM .o files | |
9e16fcf1 | 1516 | may have more than one $CODE$ subspace. */ |
d9ad93bc KR |
1517 | |
1518 | static asection * | |
1519 | make_unique_section (abfd, name, num) | |
1520 | bfd *abfd; | |
1521 | CONST char *name; | |
1522 | int num; | |
1523 | { | |
1524 | asection *sect; | |
1525 | char *newname; | |
1526 | char altname[100]; | |
1527 | ||
1528 | sect = bfd_make_section (abfd, name); | |
1529 | while (!sect) | |
1530 | { | |
1531 | sprintf (altname, "%s-%d", name, num++); | |
1532 | sect = bfd_make_section (abfd, altname); | |
1533 | } | |
1534 | ||
1535 | newname = bfd_alloc (abfd, strlen (sect->name) + 1); | |
1536 | strcpy (newname, sect->name); | |
1537 | ||
1538 | sect->name = newname; | |
1539 | return sect; | |
1540 | } | |
1541 | ||
1542 | /* Convert all of the space and subspace info into BFD sections. Each space | |
1543 | contains a number of subspaces, which in turn describe the mapping between | |
1544 | regions of the exec file, and the address space that the program runs in. | |
1545 | BFD sections which correspond to spaces will overlap the sections for the | |
1546 | associated subspaces. */ | |
1547 | ||
9e16fcf1 | 1548 | static boolean |
d9ad93bc KR |
1549 | setup_sections (abfd, file_hdr) |
1550 | bfd *abfd; | |
1551 | struct header *file_hdr; | |
1552 | { | |
1553 | char *space_strings; | |
1554 | int space_index; | |
9e16fcf1 | 1555 | unsigned int total_subspaces = 0; |
d9ad93bc KR |
1556 | |
1557 | /* First, read in space names */ | |
1558 | ||
1559 | space_strings = alloca (file_hdr->space_strings_size); | |
1560 | if (!space_strings) | |
9e16fcf1 | 1561 | return false; |
d9ad93bc KR |
1562 | |
1563 | if (bfd_seek (abfd, file_hdr->space_strings_location, SEEK_SET) < 0) | |
9e16fcf1 | 1564 | return false; |
d9ad93bc KR |
1565 | if (bfd_read (space_strings, 1, file_hdr->space_strings_size, abfd) |
1566 | != file_hdr->space_strings_size) | |
9e16fcf1 | 1567 | return false; |
d9ad93bc KR |
1568 | |
1569 | /* Loop over all of the space dictionaries, building up sections */ | |
d9ad93bc KR |
1570 | for (space_index = 0; space_index < file_hdr->space_total; space_index++) |
1571 | { | |
1572 | struct space_dictionary_record space; | |
9e16fcf1 SG |
1573 | struct subspace_dictionary_record subspace, save_subspace; |
1574 | int subspace_index; | |
d9ad93bc KR |
1575 | asection *space_asect; |
1576 | ||
1577 | /* Read the space dictionary element */ | |
1578 | if (bfd_seek (abfd, file_hdr->space_location | |
1579 | + space_index * sizeof space, SEEK_SET) < 0) | |
9e16fcf1 | 1580 | return false; |
d9ad93bc | 1581 | if (bfd_read (&space, 1, sizeof space, abfd) != sizeof space) |
9e16fcf1 | 1582 | return false; |
d9ad93bc KR |
1583 | |
1584 | /* Setup the space name string */ | |
1585 | space.name.n_name = space.name.n_strx + space_strings; | |
1586 | ||
1587 | /* Make a section out of it */ | |
1588 | space_asect = make_unique_section (abfd, space.name.n_name, space_index); | |
1589 | if (!space_asect) | |
9e16fcf1 | 1590 | return false; |
d9ad93bc KR |
1591 | |
1592 | /* Now, read in the first subspace for this space */ | |
1593 | if (bfd_seek (abfd, file_hdr->subspace_location | |
1594 | + space.subspace_index * sizeof subspace, | |
1595 | SEEK_SET) < 0) | |
9e16fcf1 | 1596 | return false; |
d9ad93bc | 1597 | if (bfd_read (&subspace, 1, sizeof subspace, abfd) != sizeof subspace) |
9e16fcf1 | 1598 | return false; |
d9ad93bc KR |
1599 | /* Seek back to the start of the subspaces for loop below */ |
1600 | if (bfd_seek (abfd, file_hdr->subspace_location | |
1601 | + space.subspace_index * sizeof subspace, | |
1602 | SEEK_SET) < 0) | |
9e16fcf1 | 1603 | return false; |
d9ad93bc KR |
1604 | |
1605 | /* Setup the start address and file loc from the first subspace record */ | |
1606 | space_asect->vma = subspace.subspace_start; | |
1607 | space_asect->filepos = subspace.file_loc_init_value; | |
9e16fcf1 SG |
1608 | space_asect->alignment_power = log2 (subspace.alignment); |
1609 | ||
1610 | /* Initialize save_subspace so we can reliably determine if this | |
1611 | loop placed any useful values into it. */ | |
1612 | bzero (&save_subspace, sizeof (struct subspace_dictionary_record)); | |
d9ad93bc KR |
1613 | |
1614 | /* Loop over the rest of the subspaces, building up more sections */ | |
1615 | for (subspace_index = 0; subspace_index < space.subspace_quantity; | |
1616 | subspace_index++) | |
1617 | { | |
1618 | asection *subspace_asect; | |
1619 | ||
1620 | /* Read in the next subspace */ | |
1621 | if (bfd_read (&subspace, 1, sizeof subspace, abfd) | |
1622 | != sizeof subspace) | |
9e16fcf1 | 1623 | return false; |
d9ad93bc KR |
1624 | |
1625 | /* Setup the subspace name string */ | |
1626 | subspace.name.n_name = subspace.name.n_strx + space_strings; | |
1627 | ||
1628 | /* Make a section out of this subspace */ | |
1629 | subspace_asect = make_unique_section (abfd, subspace.name.n_name, | |
1630 | space.subspace_index + subspace_index); | |
1631 | ||
1632 | if (!subspace_asect) | |
9e16fcf1 SG |
1633 | return false; |
1634 | ||
1635 | /* Keep an easy mapping between subspaces and sections. */ | |
1636 | som_section_data (subspace_asect)->subspace_index | |
1637 | = total_subspaces++; | |
1638 | ||
1639 | /* Set SEC_READONLY and SEC_CODE/SEC_DATA as specified | |
1640 | by the access_control_bits in the subspace header. */ | |
1641 | switch (subspace.access_control_bits >> 4) | |
1642 | { | |
1643 | /* Readonly data. */ | |
1644 | case 0x0: | |
1645 | subspace_asect->flags |= SEC_DATA | SEC_READONLY; | |
1646 | break; | |
1647 | ||
1648 | /* Normal data. */ | |
1649 | case 0x1: | |
1650 | subspace_asect->flags |= SEC_DATA; | |
1651 | break; | |
1652 | ||
1653 | /* Readonly code and the gateways. | |
1654 | Gateways have other attributes which do not map | |
1655 | into anything BFD knows about. */ | |
1656 | case 0x2: | |
1657 | case 0x4: | |
1658 | case 0x5: | |
1659 | case 0x6: | |
1660 | case 0x7: | |
1661 | subspace_asect->flags |= SEC_CODE | SEC_READONLY; | |
1662 | break; | |
1663 | ||
1664 | /* dynamic (writable) code. */ | |
1665 | case 0x3: | |
1666 | subspace_asect->flags |= SEC_CODE; | |
1667 | break; | |
1668 | } | |
1669 | ||
1670 | if (subspace.dup_common || subspace.is_common) | |
1671 | subspace_asect->flags |= SEC_IS_COMMON; | |
36456a67 | 1672 | else if (subspace.subspace_length > 0) |
9e16fcf1 | 1673 | subspace_asect->flags |= SEC_HAS_CONTENTS; |
d9ad93bc KR |
1674 | if (subspace.is_loadable) |
1675 | subspace_asect->flags |= SEC_ALLOC | SEC_LOAD; | |
1676 | if (subspace.code_only) | |
1677 | subspace_asect->flags |= SEC_CODE; | |
1678 | ||
36456a67 JL |
1679 | /* Both file_loc_init_value and initialization_length will |
1680 | be zero for a BSS like subspace. */ | |
1681 | if (subspace.file_loc_init_value == 0 | |
1682 | && subspace.initialization_length == 0) | |
1683 | subspace_asect->flags &= ~(SEC_DATA | SEC_LOAD); | |
1684 | ||
9e16fcf1 SG |
1685 | /* This subspace has relocations. |
1686 | The fixup_request_quantity is a byte count for the number of | |
1687 | entries in the relocation stream; it is not the actual number | |
1688 | of relocations in the subspace. */ | |
1689 | if (subspace.fixup_request_quantity != 0) | |
1690 | { | |
1691 | subspace_asect->flags |= SEC_RELOC; | |
1692 | subspace_asect->rel_filepos = subspace.fixup_request_index; | |
1693 | som_section_data (subspace_asect)->reloc_size | |
1694 | = subspace.fixup_request_quantity; | |
1695 | /* We can not determine this yet. When we read in the | |
1696 | relocation table the correct value will be filled in. */ | |
1697 | subspace_asect->reloc_count = -1; | |
1698 | } | |
1699 | ||
1700 | /* Update save_subspace if appropriate. */ | |
1701 | if (subspace.file_loc_init_value > save_subspace.file_loc_init_value) | |
1702 | save_subspace = subspace; | |
1703 | ||
d9ad93bc KR |
1704 | subspace_asect->vma = subspace.subspace_start; |
1705 | subspace_asect->_cooked_size = subspace.subspace_length; | |
36456a67 | 1706 | subspace_asect->_raw_size = subspace.subspace_length; |
9e16fcf1 | 1707 | subspace_asect->alignment_power = log2 (subspace.alignment); |
d9ad93bc | 1708 | subspace_asect->filepos = subspace.file_loc_init_value; |
d9ad93bc | 1709 | } |
9e16fcf1 SG |
1710 | |
1711 | /* Yow! there is no subspace within the space which actually | |
1712 | has initialized information in it; this should never happen | |
1713 | as far as I know. */ | |
1714 | if (!save_subspace.file_loc_init_value) | |
1715 | abort (); | |
1716 | ||
d9ad93bc | 1717 | /* Setup the sizes for the space section based upon the info in the |
9e16fcf1 SG |
1718 | last subspace of the space. */ |
1719 | space_asect->_cooked_size = save_subspace.subspace_start | |
1720 | - space_asect->vma + save_subspace.subspace_length; | |
1721 | space_asect->_raw_size = save_subspace.file_loc_init_value | |
1722 | - space_asect->filepos + save_subspace.initialization_length; | |
d9ad93bc | 1723 | } |
9e16fcf1 | 1724 | return true; |
d9ad93bc KR |
1725 | } |
1726 | ||
9e16fcf1 SG |
1727 | /* Read in a SOM object and make it into a BFD. */ |
1728 | ||
d9ad93bc | 1729 | static bfd_target * |
9e16fcf1 | 1730 | som_object_p (abfd) |
d9ad93bc KR |
1731 | bfd *abfd; |
1732 | { | |
1733 | struct header file_hdr; | |
1734 | struct som_exec_auxhdr aux_hdr; | |
1735 | ||
1736 | if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE) | |
9e16fcf1 SG |
1737 | { |
1738 | bfd_error = system_call_error; | |
1739 | return 0; | |
1740 | } | |
d9ad93bc KR |
1741 | |
1742 | if (!_PA_RISC_ID (file_hdr.system_id)) | |
1743 | { | |
1744 | bfd_error = wrong_format; | |
1745 | return 0; | |
1746 | } | |
1747 | ||
1748 | switch (file_hdr.a_magic) | |
1749 | { | |
9e16fcf1 | 1750 | case RELOC_MAGIC: |
d9ad93bc KR |
1751 | case EXEC_MAGIC: |
1752 | case SHARE_MAGIC: | |
1753 | case DEMAND_MAGIC: | |
1754 | #ifdef DL_MAGIC | |
1755 | case DL_MAGIC: | |
1756 | #endif | |
1757 | #ifdef SHL_MAGIC | |
1758 | case SHL_MAGIC: | |
9e16fcf1 SG |
1759 | #endif |
1760 | #ifdef EXECLIBMAGIC | |
1761 | case EXECLIBMAGIC: | |
017a52d7 JL |
1762 | #endif |
1763 | #ifdef SHARED_MAGIC_CNX | |
1764 | case SHARED_MAGIC_CNX: | |
d9ad93bc KR |
1765 | #endif |
1766 | break; | |
1767 | default: | |
1768 | bfd_error = wrong_format; | |
1769 | return 0; | |
1770 | } | |
1771 | ||
1772 | if (file_hdr.version_id != VERSION_ID | |
1773 | && file_hdr.version_id != NEW_VERSION_ID) | |
1774 | { | |
1775 | bfd_error = wrong_format; | |
1776 | return 0; | |
1777 | } | |
1778 | ||
9e16fcf1 SG |
1779 | /* If the aux_header_size field in the file header is zero, then this |
1780 | object is an incomplete executable (a .o file). Do not try to read | |
1781 | a non-existant auxiliary header. */ | |
1782 | bzero (&aux_hdr, sizeof (struct som_exec_auxhdr)); | |
1783 | if (file_hdr.aux_header_size != 0) | |
1784 | { | |
1785 | if (bfd_read ((PTR) & aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE) | |
1786 | { | |
1787 | bfd_error = wrong_format; | |
1788 | return 0; | |
1789 | } | |
1790 | } | |
d9ad93bc KR |
1791 | |
1792 | if (!setup_sections (abfd, &file_hdr)) | |
9e16fcf1 SG |
1793 | { |
1794 | /* setup_sections does not bubble up a bfd error code. */ | |
1795 | bfd_error = bad_value; | |
1796 | return 0; | |
1797 | } | |
d9ad93bc | 1798 | |
9e16fcf1 SG |
1799 | /* This appears to be a valid SOM object. Do some initialization. */ |
1800 | return som_object_setup (abfd, &file_hdr, &aux_hdr); | |
d9ad93bc KR |
1801 | } |
1802 | ||
9e16fcf1 SG |
1803 | /* Create a SOM object. */ |
1804 | ||
d9ad93bc | 1805 | static boolean |
9e16fcf1 | 1806 | som_mkobject (abfd) |
d9ad93bc KR |
1807 | bfd *abfd; |
1808 | { | |
9e16fcf1 SG |
1809 | /* Allocate memory to hold backend information. */ |
1810 | abfd->tdata.som_data = (struct som_data_struct *) | |
1811 | bfd_zalloc (abfd, sizeof (struct som_data_struct)); | |
1812 | if (abfd->tdata.som_data == NULL) | |
1813 | { | |
1814 | bfd_error = no_memory; | |
1815 | return false; | |
1816 | } | |
1817 | obj_som_file_hdr (abfd) = bfd_zalloc (abfd, sizeof (struct header)); | |
1818 | if (obj_som_file_hdr (abfd) == NULL) | |
1819 | ||
1820 | { | |
1821 | bfd_error = no_memory; | |
1822 | return false; | |
1823 | } | |
1824 | return true; | |
d9ad93bc KR |
1825 | } |
1826 | ||
0ffa24b9 JL |
1827 | /* Initialize some information in the file header. This routine makes |
1828 | not attempt at doing the right thing for a full executable; it | |
1829 | is only meant to handle relocatable objects. */ | |
1830 | ||
1831 | static boolean | |
1832 | som_prep_headers (abfd) | |
1833 | bfd *abfd; | |
1834 | { | |
1835 | struct header *file_hdr = obj_som_file_hdr (abfd); | |
1836 | asection *section; | |
1837 | ||
1838 | /* FIXME. This should really be conditional based on whether or not | |
1839 | PA1.1 instructions/registers have been used. */ | |
1840 | file_hdr->system_id = HP9000S800_ID; | |
1841 | ||
1842 | /* FIXME. Only correct for building relocatable objects. */ | |
1843 | if (abfd->flags & EXEC_P) | |
1844 | abort (); | |
1845 | else | |
1846 | file_hdr->a_magic = RELOC_MAGIC; | |
1847 | ||
1848 | /* Only new format SOM is supported. */ | |
1849 | file_hdr->version_id = NEW_VERSION_ID; | |
1850 | ||
1851 | /* These fields are optional, and embedding timestamps is not always | |
1852 | a wise thing to do, it makes comparing objects during a multi-stage | |
1853 | bootstrap difficult. */ | |
1854 | file_hdr->file_time.secs = 0; | |
1855 | file_hdr->file_time.nanosecs = 0; | |
1856 | ||
1857 | if (abfd->flags & EXEC_P) | |
1858 | abort (); | |
1859 | else | |
1860 | { | |
1861 | file_hdr->entry_space = 0; | |
1862 | file_hdr->entry_subspace = 0; | |
1863 | file_hdr->entry_offset = 0; | |
1864 | } | |
1865 | ||
1866 | /* FIXME. I do not know if we ever need to put anything other | |
1867 | than zero in this field. */ | |
1868 | file_hdr->presumed_dp = 0; | |
1869 | ||
1870 | /* Now iterate over the sections translating information from | |
1871 | BFD sections to SOM spaces/subspaces. */ | |
1872 | ||
1873 | for (section = abfd->sections; section != NULL; section = section->next) | |
1874 | { | |
1875 | /* Ignore anything which has not been marked as a space or | |
1876 | subspace. */ | |
1877 | if (som_section_data (section)->is_space == 0 | |
1878 | ||
1879 | && som_section_data (section)->is_subspace == 0) | |
1880 | continue; | |
1881 | ||
1882 | if (som_section_data (section)->is_space) | |
1883 | { | |
1884 | /* Set space attributes. Note most attributes of SOM spaces | |
1885 | are set based on the subspaces it contains. */ | |
1886 | som_section_data (section)->space_dict.loader_fix_index = -1; | |
1887 | som_section_data (section)->space_dict.init_pointer_index = -1; | |
1888 | } | |
1889 | else | |
1890 | { | |
1891 | /* Set subspace attributes. Basic stuff is done here, additional | |
1892 | attributes are filled in later as more information becomes | |
1893 | available. */ | |
1894 | if (section->flags & SEC_IS_COMMON) | |
1895 | { | |
1896 | som_section_data (section)->subspace_dict.dup_common = 1; | |
1897 | som_section_data (section)->subspace_dict.is_common = 1; | |
1898 | } | |
1899 | ||
1900 | if (section->flags & SEC_ALLOC) | |
1901 | som_section_data (section)->subspace_dict.is_loadable = 1; | |
1902 | ||
1903 | if (section->flags & SEC_CODE) | |
1904 | som_section_data (section)->subspace_dict.code_only = 1; | |
1905 | ||
1906 | som_section_data (section)->subspace_dict.subspace_start = | |
1907 | section->vma; | |
1908 | som_section_data (section)->subspace_dict.subspace_length = | |
1909 | bfd_section_size (abfd, section); | |
1910 | som_section_data (section)->subspace_dict.initialization_length = | |
1911 | bfd_section_size (abfd, section); | |
1912 | som_section_data (section)->subspace_dict.alignment = | |
1913 | 1 << section->alignment_power; | |
1914 | } | |
1915 | } | |
1916 | return true; | |
1917 | } | |
1918 | ||
5532fc5a JL |
1919 | /* Count and return the number of spaces attached to the given BFD. */ |
1920 | ||
1921 | static unsigned long | |
1922 | som_count_spaces (abfd) | |
1923 | bfd *abfd; | |
1924 | { | |
1925 | int count = 0; | |
1926 | asection *section; | |
1927 | ||
1928 | for (section = abfd->sections; section != NULL; section = section->next) | |
1929 | count += som_section_data (section)->is_space; | |
1930 | ||
1931 | return count; | |
1932 | } | |
1933 | ||
1934 | /* Count the number of subspaces attached to the given BFD. */ | |
1935 | ||
1936 | static unsigned long | |
1937 | som_count_subspaces (abfd) | |
1938 | bfd *abfd; | |
1939 | { | |
1940 | int count = 0; | |
1941 | asection *section; | |
1942 | ||
1943 | for (section = abfd->sections; section != NULL; section = section->next) | |
1944 | count += som_section_data (section)->is_subspace; | |
1945 | ||
1946 | return count; | |
1947 | } | |
1948 | ||
1949 | /* Return -1, 0, 1 indicating the relative ordering of sym1 and sym2. | |
1950 | ||
1951 | We desire symbols to be ordered starting with the symbol with the | |
1952 | highest relocation count down to the symbol with the lowest relocation | |
1953 | count. Doing so compacts the relocation stream. */ | |
1954 | ||
1955 | static int | |
1956 | compare_syms (sym1, sym2) | |
1957 | asymbol **sym1; | |
1958 | asymbol **sym2; | |
1959 | ||
1960 | { | |
1961 | unsigned int count1, count2; | |
1962 | ||
1963 | /* Get relocation count for each symbol. Note that the count | |
1964 | is stored in the udata pointer for section symbols! */ | |
1965 | if ((*sym1)->flags & BSF_SECTION_SYM) | |
1966 | count1 = (int)(*sym1)->udata; | |
1967 | else | |
1968 | count1 = (*som_symbol_data ((*sym1)))->reloc_count; | |
1969 | ||
1970 | if ((*sym2)->flags & BSF_SECTION_SYM) | |
1971 | count2 = (int)(*sym2)->udata; | |
1972 | else | |
1973 | count2 = (*som_symbol_data ((*sym2)))->reloc_count; | |
1974 | ||
1975 | /* Return the appropriate value. */ | |
1976 | if (count1 < count2) | |
1977 | return 1; | |
1978 | else if (count1 > count2) | |
1979 | return -1; | |
1980 | return 0; | |
1981 | } | |
1982 | ||
aff97790 JL |
1983 | /* Perform various work in preparation for emitting the fixup stream. */ |
1984 | ||
1985 | static void | |
1986 | som_prep_for_fixups (abfd, syms, num_syms) | |
1987 | bfd *abfd; | |
1988 | asymbol **syms; | |
1989 | unsigned long num_syms; | |
1990 | { | |
1991 | int i; | |
1992 | asection *section; | |
1993 | ||
1994 | /* Most SOM relocations involving a symbol have a length which is | |
1995 | dependent on the index of the symbol. So symbols which are | |
1996 | used often in relocations should have a small index. */ | |
1997 | ||
1998 | /* First initialize the counters for each symbol. */ | |
1999 | for (i = 0; i < num_syms; i++) | |
2000 | { | |
2001 | /* Handle a section symbol; these have no pointers back to the | |
2002 | SOM symbol info. So we just use the pointer field (udata) | |
2003 | to hold the relocation count. | |
2004 | ||
2005 | FIXME. While we're here set the name of any section symbol | |
2006 | to something which will not screw GDB. How do other formats | |
2007 | deal with this?!? */ | |
2008 | if (som_symbol_data (syms[i]) == NULL) | |
2009 | { | |
2010 | syms[i]->flags |= BSF_SECTION_SYM; | |
2011 | syms[i]->name = "L$0\002"; | |
2012 | syms[i]->udata = (PTR) 0; | |
2013 | } | |
2014 | else | |
2015 | (*som_symbol_data (syms[i]))->reloc_count = 0; | |
2016 | } | |
2017 | ||
2018 | /* Now that the counters are initialized, make a weighted count | |
2019 | of how often a given symbol is used in a relocation. */ | |
2020 | for (section = abfd->sections; section != NULL; section = section->next) | |
2021 | { | |
2022 | int i; | |
2023 | ||
2024 | /* Does this section have any relocations? */ | |
2025 | if (section->reloc_count <= 0) | |
2026 | continue; | |
2027 | ||
2028 | /* Walk through each relocation for this section. */ | |
2029 | for (i = 1; i < section->reloc_count; i++) | |
2030 | { | |
2031 | arelent *reloc = section->orelocation[i]; | |
2032 | int scale; | |
2033 | ||
2034 | /* If no symbol, then there is no counter to increase. */ | |
2035 | if (reloc->sym_ptr_ptr == NULL) | |
2036 | continue; | |
2037 | ||
2038 | /* Scaling to encourage symbols involved in R_DP_RELATIVE | |
2039 | and R_CODE_ONE_SYMBOL relocations to come first. These | |
2040 | two relocations have single byte versions if the symbol | |
2041 | index is very small. */ | |
2042 | if (reloc->howto->type == R_DP_RELATIVE | |
2043 | || reloc->howto->type == R_CODE_ONE_SYMBOL) | |
2044 | scale = 2; | |
2045 | else | |
2046 | scale = 1; | |
2047 | ||
2048 | /* Handle section symbols by ramming the count in the udata | |
2049 | field. It will not be used and the count is very important | |
2050 | for these symbols. */ | |
2051 | if ((*reloc->sym_ptr_ptr)->flags & BSF_SECTION_SYM) | |
2052 | { | |
2053 | (*reloc->sym_ptr_ptr)->udata = | |
2054 | (PTR) ((int) (*reloc->sym_ptr_ptr)->udata + scale); | |
2055 | continue; | |
2056 | } | |
2057 | ||
2058 | /* A normal symbol. Increment the count. */ | |
2059 | (*som_symbol_data ((*reloc->sym_ptr_ptr)))->reloc_count += scale; | |
2060 | } | |
2061 | } | |
2062 | ||
2063 | /* Now sort the symbols. */ | |
2064 | qsort (syms, num_syms, sizeof (asymbol *), compare_syms); | |
2065 | ||
2066 | /* Compute the symbol indexes, they will be needed by the relocation | |
2067 | code. */ | |
2068 | for (i = 0; i < num_syms; i++) | |
2069 | { | |
2070 | /* A section symbol. Again, there is no pointer to backend symbol | |
2071 | information, so we reuse (abuse) the udata field again. */ | |
2072 | if (syms[i]->flags & BSF_SECTION_SYM) | |
2073 | syms[i]->udata = (PTR) i; | |
2074 | else | |
2075 | (*som_symbol_data (syms[i]))->index = i; | |
2076 | } | |
2077 | } | |
2078 | ||
9d0dea6f JL |
2079 | static boolean |
2080 | som_write_fixups (abfd, current_offset, total_reloc_sizep) | |
2081 | bfd *abfd; | |
2082 | unsigned long current_offset; | |
2083 | unsigned int *total_reloc_sizep; | |
2084 | { | |
2085 | unsigned int i, j; | |
2086 | unsigned char *tmp_space, *p; | |
2087 | unsigned int total_reloc_size = 0; | |
2088 | unsigned int subspace_reloc_size = 0; | |
2089 | unsigned int num_spaces = obj_som_file_hdr (abfd)->space_total; | |
2090 | asection *section = abfd->sections; | |
2091 | ||
2092 | /* Get a chunk of memory that we can use as buffer space, then throw | |
2093 | away. */ | |
2094 | tmp_space = alloca (SOM_TMP_BUFSIZE); | |
2095 | bzero (tmp_space, SOM_TMP_BUFSIZE); | |
2096 | p = tmp_space; | |
2097 | ||
2098 | /* All the fixups for a particular subspace are emitted in a single | |
2099 | stream. All the subspaces for a particular space are emitted | |
2100 | as a single stream. | |
2101 | ||
2102 | So, to get all the locations correct one must iterate through all the | |
2103 | spaces, for each space iterate through its subspaces and output a | |
2104 | fixups stream. */ | |
2105 | for (i = 0; i < num_spaces; i++) | |
2106 | { | |
2107 | asection *subsection; | |
2108 | ||
2109 | /* Find a space. */ | |
2110 | while (som_section_data (section)->is_space == 0) | |
2111 | section = section->next; | |
2112 | ||
2113 | /* Now iterate through each of its subspaces. */ | |
2114 | for (subsection = abfd->sections; | |
2115 | subsection != NULL; | |
2116 | subsection = subsection->next) | |
2117 | { | |
017a52d7 | 2118 | int reloc_offset, current_rounding_mode; |
9d0dea6f JL |
2119 | |
2120 | /* Find a subspace of this space. */ | |
2121 | if (som_section_data (subsection)->is_subspace == 0 | |
2122 | || som_section_data (subsection)->containing_space != section) | |
2123 | continue; | |
2124 | ||
2125 | /* If this subspace had no relocations, then we're finished | |
2126 | with it. */ | |
2127 | if (subsection->reloc_count <= 0) | |
2128 | { | |
2129 | som_section_data (subsection)->subspace_dict.fixup_request_index | |
2130 | = -1; | |
2131 | continue; | |
2132 | } | |
2133 | ||
2134 | /* This subspace has some relocations. Put the relocation stream | |
2135 | index into the subspace record. */ | |
2136 | som_section_data (subsection)->subspace_dict.fixup_request_index | |
2137 | = total_reloc_size; | |
2138 | ||
2139 | /* To make life easier start over with a clean slate for | |
2140 | each subspace. Seek to the start of the relocation stream | |
2141 | for this subspace in preparation for writing out its fixup | |
2142 | stream. */ | |
2143 | if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) != 0) | |
2144 | { | |
2145 | bfd_error = system_call_error; | |
2146 | return false; | |
2147 | } | |
2148 | ||
2149 | /* Buffer space has already been allocated. Just perform some | |
2150 | initialization here. */ | |
2151 | p = tmp_space; | |
2152 | subspace_reloc_size = 0; | |
2153 | reloc_offset = 0; | |
2154 | som_initialize_reloc_queue (reloc_queue); | |
017a52d7 | 2155 | current_rounding_mode = R_N_MODE; |
9d0dea6f JL |
2156 | |
2157 | /* Translate each BFD relocation into one or more SOM | |
2158 | relocations. */ | |
2159 | for (j = 0; j < subsection->reloc_count; j++) | |
2160 | { | |
2161 | arelent *bfd_reloc = subsection->orelocation[j]; | |
2162 | unsigned int skip; | |
2163 | int sym_num; | |
2164 | ||
2165 | /* Get the symbol number. Remember it's stored in a | |
2166 | special place for section symbols. */ | |
2167 | if ((*bfd_reloc->sym_ptr_ptr)->flags & BSF_SECTION_SYM) | |
2168 | sym_num = (int) (*bfd_reloc->sym_ptr_ptr)->udata; | |
2169 | else | |
91c0bcbb | 2170 | sym_num = (*som_symbol_data ((*bfd_reloc->sym_ptr_ptr)))->index; |
9d0dea6f JL |
2171 | |
2172 | /* If there is not enough room for the next couple relocations, | |
2173 | then dump the current buffer contents now. Also reinitialize | |
2174 | the relocation queue. | |
2175 | ||
2176 | FIXME. We assume here that no BFD relocation will expand | |
2177 | to more than 100 bytes of SOM relocations. This should (?!?) | |
2178 | be quite safe. */ | |
2179 | if (p - tmp_space + 100 > SOM_TMP_BUFSIZE) | |
2180 | { | |
2181 | if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd) | |
2182 | != p - tmp_space) | |
2183 | { | |
2184 | bfd_error = system_call_error; | |
2185 | return false; | |
2186 | } | |
2187 | p = tmp_space; | |
2188 | som_initialize_reloc_queue (reloc_queue); | |
2189 | } | |
2190 | ||
2191 | /* Emit R_NO_RELOCATION fixups to map any bytes which were | |
2192 | skipped. */ | |
2193 | skip = bfd_reloc->address - reloc_offset; | |
2194 | p = som_reloc_skip (abfd, skip, p, | |
2195 | &subspace_reloc_size, reloc_queue); | |
2196 | ||
2197 | /* Update reloc_offset for the next iteration. | |
2198 | ||
017a52d7 JL |
2199 | Many relocations do not consume input bytes. They |
2200 | are markers, or set state necessary to perform some | |
2201 | later relocation. */ | |
2202 | switch (bfd_reloc->howto->type) | |
2203 | { | |
2204 | /* This only needs to handle relocations that may be | |
2205 | made by hppa_som_gen_reloc. */ | |
2206 | case R_ENTRY: | |
2207 | case R_EXIT: | |
2208 | case R_N_MODE: | |
2209 | case R_S_MODE: | |
2210 | case R_D_MODE: | |
2211 | case R_R_MODE: | |
a36b6f1d JL |
2212 | case R_FSEL: |
2213 | case R_LSEL: | |
2214 | case R_RSEL: | |
017a52d7 JL |
2215 | reloc_offset = bfd_reloc->address; |
2216 | break; | |
9d0dea6f | 2217 | |
017a52d7 JL |
2218 | default: |
2219 | reloc_offset = bfd_reloc->address + 4; | |
2220 | break; | |
2221 | } | |
9d0dea6f JL |
2222 | |
2223 | /* Now the actual relocation we care about. */ | |
2224 | switch (bfd_reloc->howto->type) | |
2225 | { | |
2226 | case R_PCREL_CALL: | |
2227 | case R_ABS_CALL: | |
2228 | p = som_reloc_call (abfd, p, &subspace_reloc_size, | |
2229 | bfd_reloc, sym_num, reloc_queue); | |
2230 | break; | |
2231 | ||
2232 | case R_CODE_ONE_SYMBOL: | |
2233 | case R_DP_RELATIVE: | |
2234 | /* Account for any addend. */ | |
2235 | if (bfd_reloc->addend) | |
2236 | p = som_reloc_addend (abfd, bfd_reloc->addend, p, | |
2237 | &subspace_reloc_size, reloc_queue); | |
2238 | ||
2239 | if (sym_num < 0x20) | |
2240 | { | |
2241 | bfd_put_8 (abfd, bfd_reloc->howto->type + sym_num, p); | |
2242 | subspace_reloc_size += 1; | |
2243 | p += 1; | |
2244 | } | |
2245 | else if (sym_num < 0x100) | |
2246 | { | |
2247 | bfd_put_8 (abfd, bfd_reloc->howto->type + 32, p); | |
2248 | bfd_put_8 (abfd, sym_num, p + 1); | |
2249 | p = try_prev_fixup (abfd, &subspace_reloc_size, p, | |
2250 | 2, reloc_queue); | |
2251 | } | |
2252 | else if (sym_num < 0x10000000) | |
2253 | { | |
2254 | bfd_put_8 (abfd, bfd_reloc->howto->type + 33, p); | |
2255 | bfd_put_8 (abfd, sym_num >> 16, p + 1); | |
2256 | bfd_put_16 (abfd, sym_num, p + 2); | |
2257 | p = try_prev_fixup (abfd, &subspace_reloc_size, | |
2258 | p, 4, reloc_queue); | |
2259 | } | |
2260 | else | |
2261 | abort (); | |
2262 | break; | |
2263 | ||
2264 | case R_DATA_ONE_SYMBOL: | |
2265 | case R_DATA_PLABEL: | |
2266 | case R_CODE_PLABEL: | |
a36b6f1d | 2267 | case R_DLT_REL: |
9d0dea6f JL |
2268 | /* Account for any addend. */ |
2269 | if (bfd_reloc->addend) | |
2270 | p = som_reloc_addend (abfd, bfd_reloc->addend, p, | |
2271 | &subspace_reloc_size, reloc_queue); | |
2272 | ||
2273 | if (sym_num < 0x100) | |
2274 | { | |
2275 | bfd_put_8 (abfd, bfd_reloc->howto->type, p); | |
2276 | bfd_put_8 (abfd, sym_num, p + 1); | |
2277 | p = try_prev_fixup (abfd, &subspace_reloc_size, p, | |
2278 | 2, reloc_queue); | |
2279 | } | |
2280 | else if (sym_num < 0x10000000) | |
2281 | { | |
2282 | bfd_put_8 (abfd, bfd_reloc->howto->type + 1, p); | |
2283 | bfd_put_8 (abfd, sym_num >> 16, p + 1); | |
2284 | bfd_put_16 (abfd, sym_num, p + 2); | |
2285 | p = try_prev_fixup (abfd, &subspace_reloc_size, | |
2286 | p, 4, reloc_queue); | |
2287 | } | |
2288 | else | |
2289 | abort (); | |
2290 | break; | |
2291 | ||
2292 | case R_ENTRY: | |
2293 | { | |
2294 | int *descp | |
2295 | = (int *) (*som_symbol_data ((*bfd_reloc->sym_ptr_ptr)))->unwind; | |
2296 | bfd_put_8 (abfd, R_ENTRY, p); | |
2297 | bfd_put_32 (abfd, descp[0], p + 1); | |
2298 | bfd_put_32 (abfd, descp[1], p + 5); | |
2299 | p = try_prev_fixup (abfd, &subspace_reloc_size, | |
2300 | p, 9, reloc_queue); | |
2301 | break; | |
2302 | } | |
2303 | ||
2304 | case R_EXIT: | |
2305 | bfd_put_8 (abfd, R_EXIT, p); | |
2306 | subspace_reloc_size += 1; | |
2307 | p += 1; | |
2308 | break; | |
2309 | ||
017a52d7 JL |
2310 | case R_N_MODE: |
2311 | case R_S_MODE: | |
2312 | case R_D_MODE: | |
2313 | case R_R_MODE: | |
2314 | /* If this relocation requests the current rounding | |
2315 | mode, then it is redundant. */ | |
2316 | if (bfd_reloc->howto->type != current_rounding_mode) | |
2317 | { | |
2318 | bfd_put_8 (abfd, bfd_reloc->howto->type, p); | |
2319 | subspace_reloc_size += 1; | |
2320 | p += 1; | |
2321 | current_rounding_mode = bfd_reloc->howto->type; | |
2322 | } | |
2323 | break; | |
2324 | ||
a36b6f1d JL |
2325 | case R_FSEL: |
2326 | case R_LSEL: | |
2327 | case R_RSEL: | |
2328 | bfd_put_8 (abfd, bfd_reloc->howto->type, p); | |
2329 | subspace_reloc_size += 1; | |
2330 | p += 1; | |
2331 | break; | |
2332 | ||
9d0dea6f JL |
2333 | /* Put a "R_RESERVED" relocation in the stream if |
2334 | we hit something we do not understand. The linker | |
2335 | will complain loudly if this ever happens. */ | |
2336 | default: | |
2337 | bfd_put_8 (abfd, 0xff, p); | |
2338 | subspace_reloc_size += 1; | |
2339 | p += 1; | |
017a52d7 | 2340 | break; |
9d0dea6f JL |
2341 | } |
2342 | } | |
2343 | ||
2344 | /* Last BFD relocation for a subspace has been processed. | |
2345 | Map the rest of the subspace with R_NO_RELOCATION fixups. */ | |
2346 | p = som_reloc_skip (abfd, bfd_section_size (abfd, subsection) | |
2347 | - reloc_offset, | |
2348 | p, &subspace_reloc_size, reloc_queue); | |
2349 | ||
2350 | /* Scribble out the relocations. */ | |
2351 | if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd) | |
2352 | != p - tmp_space) | |
2353 | { | |
2354 | bfd_error = system_call_error; | |
2355 | return false; | |
2356 | } | |
2357 | p = tmp_space; | |
2358 | ||
2359 | total_reloc_size += subspace_reloc_size; | |
2360 | som_section_data (subsection)->subspace_dict.fixup_request_quantity | |
2361 | = subspace_reloc_size; | |
2362 | } | |
2363 | section = section->next; | |
2364 | } | |
2365 | *total_reloc_sizep = total_reloc_size; | |
2366 | return true; | |
2367 | } | |
2368 | ||
0b35f7ec JL |
2369 | /* Write out the space/subspace string table. */ |
2370 | ||
2371 | static boolean | |
2372 | som_write_space_strings (abfd, current_offset, string_sizep) | |
2373 | bfd *abfd; | |
2374 | unsigned long current_offset; | |
2375 | unsigned int *string_sizep; | |
2376 | { | |
2377 | unsigned char *tmp_space, *p; | |
2378 | unsigned int strings_size = 0; | |
2379 | asection *section; | |
2380 | ||
2381 | /* Get a chunk of memory that we can use as buffer space, then throw | |
2382 | away. */ | |
2383 | tmp_space = alloca (SOM_TMP_BUFSIZE); | |
2384 | bzero (tmp_space, SOM_TMP_BUFSIZE); | |
2385 | p = tmp_space; | |
2386 | ||
2387 | /* Seek to the start of the space strings in preparation for writing | |
2388 | them out. */ | |
2389 | if (bfd_seek (abfd, current_offset, SEEK_SET) != 0) | |
2390 | { | |
2391 | bfd_error = system_call_error; | |
2392 | return false; | |
2393 | } | |
2394 | ||
2395 | /* Walk through all the spaces and subspaces (order is not important) | |
2396 | building up and writing string table entries for their names. */ | |
2397 | for (section = abfd->sections; section != NULL; section = section->next) | |
2398 | { | |
2399 | int length; | |
2400 | ||
2401 | /* Only work with space/subspaces; avoid any other sections | |
2402 | which might have been made (.text for example). */ | |
2403 | if (som_section_data (section)->is_space == 0 | |
2404 | && som_section_data (section)->is_subspace == 0) | |
2405 | continue; | |
2406 | ||
2407 | /* Get the length of the space/subspace name. */ | |
2408 | length = strlen (section->name); | |
2409 | ||
2410 | /* If there is not enough room for the next entry, then dump the | |
2411 | current buffer contents now. Each entry will take 4 bytes to | |
2412 | hold the string length + the string itself + null terminator. */ | |
2413 | if (p - tmp_space + 5 + length > SOM_TMP_BUFSIZE) | |
2414 | { | |
2415 | if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd) | |
2416 | != p - tmp_space) | |
2417 | { | |
2418 | bfd_error = system_call_error; | |
2419 | return false; | |
2420 | } | |
2421 | /* Reset to beginning of the buffer space. */ | |
2422 | p = tmp_space; | |
2423 | } | |
2424 | ||
2425 | /* First element in a string table entry is the length of the | |
2426 | string. Alignment issues are already handled. */ | |
2427 | bfd_put_32 (abfd, length, p); | |
2428 | p += 4; | |
2429 | strings_size += 4; | |
2430 | ||
2431 | /* Record the index in the space/subspace records. */ | |
2432 | if (som_section_data (section)->is_space) | |
2433 | som_section_data (section)->space_dict.name.n_strx = strings_size; | |
2434 | else | |
2435 | som_section_data (section)->subspace_dict.name.n_strx = strings_size; | |
2436 | ||
2437 | /* Next comes the string itself + a null terminator. */ | |
2438 | strcpy (p, section->name); | |
2439 | p += length + 1; | |
2440 | strings_size += length + 1; | |
2441 | ||
2442 | /* Always align up to the next word boundary. */ | |
2443 | while (strings_size % 4) | |
2444 | { | |
2445 | bfd_put_8 (abfd, 0, p); | |
2446 | p++; | |
2447 | strings_size++; | |
2448 | } | |
2449 | } | |
2450 | ||
2451 | /* Done with the space/subspace strings. Write out any information | |
2452 | contained in a partial block. */ | |
2453 | if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd) != p - tmp_space) | |
2454 | { | |
2455 | bfd_error = system_call_error; | |
2456 | return false; | |
2457 | } | |
2458 | *string_sizep = strings_size; | |
2459 | return true; | |
2460 | } | |
2461 | ||
2462 | /* Write out the symbol string table. */ | |
2463 | ||
2464 | static boolean | |
2465 | som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep) | |
2466 | bfd *abfd; | |
2467 | unsigned long current_offset; | |
2468 | asymbol **syms; | |
2469 | unsigned int num_syms; | |
2470 | unsigned int *string_sizep; | |
2471 | { | |
2472 | unsigned int i; | |
2473 | unsigned char *tmp_space, *p; | |
2474 | unsigned int strings_size = 0; | |
2475 | ||
2476 | /* Get a chunk of memory that we can use as buffer space, then throw | |
2477 | away. */ | |
2478 | tmp_space = alloca (SOM_TMP_BUFSIZE); | |
2479 | bzero (tmp_space, SOM_TMP_BUFSIZE); | |
2480 | p = tmp_space; | |
2481 | ||
2482 | /* Seek to the start of the space strings in preparation for writing | |
2483 | them out. */ | |
2484 | if (bfd_seek (abfd, current_offset, SEEK_SET) != 0) | |
2485 | { | |
2486 | bfd_error = system_call_error; | |
2487 | return false; | |
2488 | } | |
2489 | ||
2490 | for (i = 0; i < num_syms; i++) | |
2491 | { | |
2492 | int length = strlen (syms[i]->name); | |
2493 | ||
2494 | /* If there is not enough room for the next entry, then dump the | |
2495 | current buffer contents now. */ | |
2496 | if (p - tmp_space + 5 + length > SOM_TMP_BUFSIZE) | |
2497 | { | |
2498 | if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd) | |
2499 | != p - tmp_space) | |
2500 | { | |
2501 | bfd_error = system_call_error; | |
2502 | return false; | |
2503 | } | |
2504 | /* Reset to beginning of the buffer space. */ | |
2505 | p = tmp_space; | |
2506 | } | |
2507 | ||
2508 | /* First element in a string table entry is the length of the | |
2509 | string. This must always be 4 byte aligned. This is also | |
2510 | an appropriate time to fill in the string index field in the | |
2511 | symbol table entry. */ | |
2512 | bfd_put_32 (abfd, length, p); | |
2513 | strings_size += 4; | |
2514 | p += 4; | |
2515 | ||
2516 | /* Next comes the string itself + a null terminator. */ | |
2517 | strcpy (p, syms[i]->name); | |
2518 | ||
2519 | /* ACK. FIXME. */ | |
2520 | syms[i]->name = (char *)strings_size; | |
2521 | p += length + 1; | |
2522 | strings_size += length + 1; | |
2523 | ||
2524 | /* Always align up to the next word boundary. */ | |
2525 | while (strings_size % 4) | |
2526 | { | |
2527 | bfd_put_8 (abfd, 0, p); | |
2528 | strings_size++; | |
2529 | p++; | |
2530 | } | |
2531 | } | |
2532 | ||
2533 | /* Scribble out any partial block. */ | |
2534 | if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd) != p - tmp_space) | |
2535 | { | |
2536 | bfd_error = system_call_error; | |
2537 | return false; | |
2538 | } | |
2539 | ||
2540 | *string_sizep = strings_size; | |
2541 | return true; | |
2542 | } | |
2543 | ||
6eb64408 JL |
2544 | /* Compute variable information to be placed in the SOM headers, |
2545 | space/subspace dictionaries, relocation streams, etc. Begin | |
2546 | writing parts of the object file. */ | |
2547 | ||
2548 | static boolean | |
2549 | som_begin_writing (abfd) | |
2550 | bfd *abfd; | |
2551 | { | |
2552 | unsigned long current_offset = 0; | |
2553 | int strings_size = 0; | |
2554 | unsigned int total_reloc_size = 0; | |
2555 | unsigned long num_spaces, num_subspaces, num_syms, i; | |
2556 | asection *section; | |
2557 | asymbol **syms = bfd_get_outsymbols (abfd); | |
2558 | unsigned int total_subspaces = 0; | |
2559 | ||
2560 | /* The file header will always be first in an object file, | |
2561 | everything else can be in random locations. To keep things | |
2562 | "simple" BFD will lay out the object file in the manner suggested | |
2563 | by the PRO ABI for PA-RISC Systems. */ | |
2564 | ||
2565 | /* Before any output can really begin offsets for all the major | |
2566 | portions of the object file must be computed. So, starting | |
2567 | with the initial file header compute (and sometimes write) | |
2568 | each portion of the object file. */ | |
2569 | ||
2570 | /* Make room for the file header, it's contents are not complete | |
2571 | yet, so it can not be written at this time. */ | |
2572 | current_offset += sizeof (struct header); | |
2573 | ||
2574 | /* Any auxiliary headers will follow the file header. Right now | |
f6c2300b | 2575 | we support only the copyright and version headers. */ |
6eb64408 JL |
2576 | obj_som_file_hdr (abfd)->aux_header_location = current_offset; |
2577 | obj_som_file_hdr (abfd)->aux_header_size = 0; | |
f6c2300b JL |
2578 | if (obj_som_version_hdr (abfd) != NULL) |
2579 | { | |
2580 | unsigned int len; | |
2581 | ||
2582 | bfd_seek (abfd, current_offset, SEEK_SET); | |
2583 | ||
2584 | /* Write the aux_id structure and the string length. */ | |
2585 | len = sizeof (struct aux_id) + sizeof (unsigned int); | |
2586 | obj_som_file_hdr (abfd)->aux_header_size += len; | |
2587 | current_offset += len; | |
2588 | if (bfd_write ((PTR) obj_som_version_hdr (abfd), len, 1, abfd) != len) | |
2589 | { | |
2590 | bfd_error = system_call_error; | |
2591 | return false; | |
2592 | } | |
2593 | ||
2594 | /* Write the version string. */ | |
2595 | len = obj_som_version_hdr (abfd)->string_length; | |
2596 | obj_som_file_hdr (abfd)->aux_header_size += len; | |
2597 | current_offset += len; | |
2598 | if (bfd_write ((PTR) obj_som_version_hdr (abfd)->user_string, | |
2599 | len, 1, abfd) != len) | |
2600 | { | |
2601 | bfd_error = system_call_error; | |
2602 | return false; | |
2603 | } | |
2604 | } | |
6eb64408 | 2605 | |
f6c2300b JL |
2606 | if (obj_som_copyright_hdr (abfd) != NULL) |
2607 | { | |
2608 | unsigned int len; | |
2609 | ||
2610 | bfd_seek (abfd, current_offset, SEEK_SET); | |
2611 | ||
2612 | /* Write the aux_id structure and the string length. */ | |
2613 | len = sizeof (struct aux_id) + sizeof (unsigned int); | |
2614 | obj_som_file_hdr (abfd)->aux_header_size += len; | |
2615 | current_offset += len; | |
2616 | if (bfd_write ((PTR) obj_som_copyright_hdr (abfd), len, 1, abfd) != len) | |
2617 | { | |
2618 | bfd_error = system_call_error; | |
2619 | return false; | |
2620 | } | |
2621 | ||
2622 | /* Write the copyright string. */ | |
2623 | len = obj_som_copyright_hdr (abfd)->string_length; | |
2624 | obj_som_file_hdr (abfd)->aux_header_size += len; | |
2625 | current_offset += len; | |
2626 | if (bfd_write ((PTR) obj_som_copyright_hdr (abfd)->copyright, | |
2627 | len, 1, abfd) != len) | |
2628 | { | |
2629 | bfd_error = system_call_error; | |
2630 | return false; | |
2631 | } | |
2632 | } | |
2633 | ||
2634 | /* Next comes the initialization pointers; we have no initialization | |
2635 | pointers, so current offset does not change. */ | |
6eb64408 JL |
2636 | obj_som_file_hdr (abfd)->init_array_location = current_offset; |
2637 | obj_som_file_hdr (abfd)->init_array_total = 0; | |
2638 | ||
2639 | /* Next are the space records. These are fixed length records. | |
2640 | ||
2641 | Count the number of spaces to determine how much room is needed | |
2642 | in the object file for the space records. | |
2643 | ||
2644 | The names of the spaces are stored in a separate string table, | |
2645 | and the index for each space into the string table is computed | |
2646 | below. Therefore, it is not possible to write the space headers | |
2647 | at this time. */ | |
2648 | num_spaces = som_count_spaces (abfd); | |
2649 | obj_som_file_hdr (abfd)->space_location = current_offset; | |
2650 | obj_som_file_hdr (abfd)->space_total = num_spaces; | |
2651 | current_offset += num_spaces * sizeof (struct space_dictionary_record); | |
2652 | ||
2653 | /* Next are the subspace records. These are fixed length records. | |
2654 | ||
2655 | Count the number of subspaes to determine how much room is needed | |
2656 | in the object file for the subspace records. | |
2657 | ||
2658 | A variety if fields in the subspace record are still unknown at | |
2659 | this time (index into string table, fixup stream location/size, etc). */ | |
2660 | num_subspaces = som_count_subspaces (abfd); | |
2661 | obj_som_file_hdr (abfd)->subspace_location = current_offset; | |
2662 | obj_som_file_hdr (abfd)->subspace_total = num_subspaces; | |
2663 | current_offset += num_subspaces * sizeof (struct subspace_dictionary_record); | |
2664 | ||
2665 | /* Next is the string table for the space/subspace names. We will | |
2666 | build and write the string table on the fly. At the same time | |
2667 | we will fill in the space/subspace name index fields. */ | |
2668 | ||
2669 | /* The string table needs to be aligned on a word boundary. */ | |
2670 | if (current_offset % 4) | |
2671 | current_offset += (4 - (current_offset % 4)); | |
2672 | ||
2673 | /* Mark the offset of the space/subspace string table in the | |
2674 | file header. */ | |
2675 | obj_som_file_hdr (abfd)->space_strings_location = current_offset; | |
2676 | ||
2677 | /* Scribble out the space strings. */ | |
2678 | if (som_write_space_strings (abfd, current_offset, &strings_size) == false) | |
2679 | return false; | |
2680 | ||
2681 | /* Record total string table size in the header and update the | |
2682 | current offset. */ | |
2683 | obj_som_file_hdr (abfd)->space_strings_size = strings_size; | |
2684 | current_offset += strings_size; | |
2685 | ||
2686 | /* Next is the symbol table. These are fixed length records. | |
2687 | ||
2688 | Count the number of symbols to determine how much room is needed | |
2689 | in the object file for the symbol table. | |
2690 | ||
2691 | The names of the symbols are stored in a separate string table, | |
2692 | and the index for each symbol name into the string table is computed | |
2693 | below. Therefore, it is not possible to write the symobl table | |
2694 | at this time. */ | |
2695 | num_syms = bfd_get_symcount (abfd); | |
2696 | obj_som_file_hdr (abfd)->symbol_location = current_offset; | |
2697 | obj_som_file_hdr (abfd)->symbol_total = num_syms; | |
2698 | current_offset += num_syms * sizeof (struct symbol_dictionary_record); | |
2699 | ||
2700 | /* Do prep work before handling fixups. */ | |
2701 | som_prep_for_fixups (abfd, syms, num_syms); | |
2702 | ||
2703 | /* Next comes the fixup stream which starts on a word boundary. */ | |
2704 | if (current_offset % 4) | |
2705 | current_offset += (4 - (current_offset % 4)); | |
2706 | obj_som_file_hdr (abfd)->fixup_request_location = current_offset; | |
2707 | ||
2708 | /* Write the fixups and update fields in subspace headers which | |
2709 | relate to the fixup stream. */ | |
2710 | if (som_write_fixups (abfd, current_offset, &total_reloc_size) == false) | |
2711 | return false; | |
2712 | ||
2713 | /* Record the total size of the fixup stream in the file header. */ | |
2714 | obj_som_file_hdr (abfd)->fixup_request_total = total_reloc_size; | |
2715 | current_offset += total_reloc_size; | |
2716 | ||
2717 | /* Next are the symbol strings. | |
2718 | Align them to a word boundary. */ | |
2719 | if (current_offset % 4) | |
2720 | current_offset += (4 - (current_offset % 4)); | |
2721 | obj_som_file_hdr (abfd)->symbol_strings_location = current_offset; | |
2722 | ||
2723 | /* Scribble out the symbol strings. */ | |
2724 | if (som_write_symbol_strings (abfd, current_offset, syms, | |
2725 | num_syms, &strings_size) | |
2726 | == false) | |
2727 | return false; | |
2728 | ||
2729 | /* Record total string table size in header and update the | |
2730 | current offset. */ | |
2731 | obj_som_file_hdr (abfd)->symbol_strings_size = strings_size; | |
2732 | current_offset += strings_size; | |
2733 | ||
2734 | /* Next is the compiler records. We do not use these. */ | |
2735 | obj_som_file_hdr (abfd)->compiler_location = current_offset; | |
2736 | obj_som_file_hdr (abfd)->compiler_total = 0; | |
2737 | ||
2738 | /* Now compute the file positions for the loadable subspaces. */ | |
2739 | ||
2740 | section = abfd->sections; | |
2741 | for (i = 0; i < num_spaces; i++) | |
2742 | { | |
2743 | asection *subsection; | |
2744 | ||
2745 | /* Find a space. */ | |
2746 | while (som_section_data (section)->is_space == 0) | |
2747 | section = section->next; | |
2748 | ||
2749 | /* Now look for all its subspaces. */ | |
2750 | for (subsection = abfd->sections; | |
2751 | subsection != NULL; | |
2752 | subsection = subsection->next) | |
2753 | { | |
2754 | ||
2755 | if (som_section_data (subsection)->is_subspace == 0 | |
2756 | || som_section_data (subsection)->containing_space != section | |
2757 | || (subsection->flags & SEC_ALLOC) == 0) | |
2758 | continue; | |
2759 | ||
2760 | som_section_data (subsection)->subspace_index = total_subspaces++; | |
2761 | /* This is real data to be loaded from the file. */ | |
2762 | if (subsection->flags & SEC_LOAD) | |
2763 | { | |
2764 | som_section_data (subsection)->subspace_dict.file_loc_init_value | |
2765 | = current_offset; | |
2766 | section->filepos = current_offset; | |
2767 | current_offset += bfd_section_size (abfd, subsection); | |
2768 | } | |
2769 | /* Looks like uninitialized data. */ | |
2770 | else | |
2771 | { | |
2772 | som_section_data (subsection)->subspace_dict.file_loc_init_value | |
2773 | = 0; | |
2774 | som_section_data (subsection)->subspace_dict. | |
2775 | initialization_length = 0; | |
2776 | } | |
2777 | } | |
2778 | /* Goto the next section. */ | |
2779 | section = section->next; | |
2780 | } | |
2781 | ||
2782 | /* Finally compute the file positions for unloadable subspaces. */ | |
2783 | ||
2784 | obj_som_file_hdr (abfd)->unloadable_sp_location = current_offset; | |
2785 | section = abfd->sections; | |
2786 | for (i = 0; i < num_spaces; i++) | |
2787 | { | |
2788 | asection *subsection; | |
2789 | ||
2790 | /* Find a space. */ | |
2791 | while (som_section_data (section)->is_space == 0) | |
2792 | section = section->next; | |
2793 | ||
2794 | /* Now look for all its subspaces. */ | |
2795 | for (subsection = abfd->sections; | |
2796 | subsection != NULL; | |
2797 | subsection = subsection->next) | |
2798 | { | |
2799 | ||
2800 | if (som_section_data (subsection)->is_subspace == 0 | |
2801 | || som_section_data (subsection)->containing_space != section | |
2802 | || (subsection->flags & SEC_ALLOC) != 0) | |
2803 | continue; | |
2804 | ||
2805 | som_section_data (subsection)->subspace_index = total_subspaces++; | |
2806 | /* This is real data to be loaded from the file. */ | |
2807 | if ((subsection->flags & SEC_LOAD) == 0) | |
2808 | { | |
2809 | som_section_data (subsection)->subspace_dict.file_loc_init_value | |
2810 | = current_offset; | |
2811 | section->filepos = current_offset; | |
2812 | current_offset += bfd_section_size (abfd, subsection); | |
2813 | } | |
2814 | /* Looks like uninitialized data. */ | |
2815 | else | |
2816 | { | |
2817 | som_section_data (subsection)->subspace_dict.file_loc_init_value | |
2818 | = 0; | |
2819 | som_section_data (subsection)->subspace_dict. | |
2820 | initialization_length = bfd_section_size (abfd, subsection); | |
2821 | } | |
2822 | } | |
2823 | /* Goto the next section. */ | |
2824 | section = section->next; | |
2825 | } | |
2826 | ||
2827 | obj_som_file_hdr (abfd)->unloadable_sp_size | |
2828 | = current_offset - obj_som_file_hdr (abfd)->unloadable_sp_location; | |
2829 | ||
2830 | /* Loader fixups are not supported in any way shape or form. */ | |
2831 | obj_som_file_hdr (abfd)->loader_fixup_location = 0; | |
2832 | obj_som_file_hdr (abfd)->loader_fixup_total = 0; | |
2833 | ||
2834 | /* Done. Store the total size of the SOM. */ | |
2835 | obj_som_file_hdr (abfd)->som_length = current_offset; | |
2836 | return true; | |
2837 | } | |
2838 | ||
efc0df7c JL |
2839 | /* Finally, scribble out the various headers to the disk. */ |
2840 | ||
2841 | static boolean | |
2842 | som_write_headers (abfd) | |
2843 | bfd *abfd; | |
2844 | { | |
2845 | int num_spaces = som_count_spaces (abfd); | |
2846 | int i; | |
2847 | int subspace_index = 0; | |
2848 | file_ptr location; | |
2849 | asection *section; | |
2850 | ||
2851 | /* Subspaces are written first so that we can set up information | |
2852 | about them in their containing spaces as the subspace is written. */ | |
2853 | ||
2854 | /* Seek to the start of the subspace dictionary records. */ | |
2855 | location = obj_som_file_hdr (abfd)->subspace_location; | |
2856 | bfd_seek (abfd, location, SEEK_SET); | |
2857 | section = abfd->sections; | |
2858 | /* Now for each loadable space write out records for its subspaces. */ | |
2859 | for (i = 0; i < num_spaces; i++) | |
2860 | { | |
2861 | asection *subsection; | |
2862 | ||
2863 | /* Find a space. */ | |
2864 | while (som_section_data (section)->is_space == 0) | |
2865 | section = section->next; | |
2866 | ||
2867 | /* Now look for all its subspaces. */ | |
2868 | for (subsection = abfd->sections; | |
2869 | subsection != NULL; | |
2870 | subsection = subsection->next) | |
2871 | { | |
2872 | ||
2873 | /* Skip any section which does not correspond to a space | |
2874 | or subspace. Or does not have SEC_ALLOC set (and therefore | |
2875 | has no real bits on the disk). */ | |
2876 | if (som_section_data (subsection)->is_subspace == 0 | |
2877 | || som_section_data (subsection)->containing_space != section | |
2878 | || (subsection->flags & SEC_ALLOC) == 0) | |
2879 | continue; | |
2880 | ||
2881 | /* If this is the first subspace for this space, then save | |
2882 | the index of the subspace in its containing space. Also | |
2883 | set "is_loadable" in the containing space. */ | |
2884 | ||
2885 | if (som_section_data (section)->space_dict.subspace_quantity == 0) | |
2886 | { | |
2887 | som_section_data (section)->space_dict.is_loadable = 1; | |
2888 | som_section_data (section)->space_dict.subspace_index | |
2889 | = subspace_index; | |
2890 | } | |
2891 | ||
2892 | /* Increment the number of subspaces seen and the number of | |
2893 | subspaces contained within the current space. */ | |
2894 | subspace_index++; | |
2895 | som_section_data (section)->space_dict.subspace_quantity++; | |
2896 | ||
2897 | /* Mark the index of the current space within the subspace's | |
2898 | dictionary record. */ | |
2899 | som_section_data (subsection)->subspace_dict.space_index = i; | |
2900 | ||
2901 | /* Dump the current subspace header. */ | |
2902 | if (bfd_write ((PTR) &som_section_data (subsection)->subspace_dict, | |
2903 | sizeof (struct subspace_dictionary_record), 1, abfd) | |
2904 | != sizeof (struct subspace_dictionary_record)) | |
2905 | { | |
2906 | bfd_error = system_call_error; | |
2907 | return false; | |
2908 | } | |
2909 | } | |
2910 | /* Goto the next section. */ | |
2911 | section = section->next; | |
2912 | } | |
2913 | ||
2914 | /* Now repeat the process for unloadable subspaces. */ | |
2915 | section = abfd->sections; | |
2916 | /* Now for each space write out records for its subspaces. */ | |
2917 | for (i = 0; i < num_spaces; i++) | |
2918 | { | |
2919 | asection *subsection; | |
2920 | ||
2921 | /* Find a space. */ | |
2922 | while (som_section_data (section)->is_space == 0) | |
2923 | section = section->next; | |
2924 | ||
2925 | /* Now look for all its subspaces. */ | |
2926 | for (subsection = abfd->sections; | |
2927 | subsection != NULL; | |
2928 | subsection = subsection->next) | |
2929 | { | |
2930 | ||
2931 | /* Skip any section which does not correspond to a space or | |
2932 | subspace, or which SEC_ALLOC set (and therefore handled | |
2933 | in the loadable spaces/subspaces code above. */ | |
2934 | ||
2935 | if (som_section_data (subsection)->is_subspace == 0 | |
2936 | || som_section_data (subsection)->containing_space != section | |
2937 | || (subsection->flags & SEC_ALLOC) != 0) | |
2938 | continue; | |
2939 | ||
2940 | /* If this is the first subspace for this space, then save | |
2941 | the index of the subspace in its containing space. Clear | |
2942 | "is_loadable". */ | |
2943 | ||
2944 | if (som_section_data (section)->space_dict.subspace_quantity == 0) | |
2945 | { | |
2946 | som_section_data (section)->space_dict.is_loadable = 0; | |
2947 | som_section_data (section)->space_dict.subspace_index | |
2948 | = subspace_index; | |
2949 | } | |
2950 | ||
2951 | /* Increment the number of subspaces seen and the number of | |
2952 | subspaces contained within the current space. */ | |
2953 | som_section_data (section)->space_dict.subspace_quantity++; | |
2954 | subspace_index++; | |
2955 | ||
2956 | /* Mark the index of the current space within the subspace's | |
2957 | dictionary record. */ | |
2958 | som_section_data (subsection)->subspace_dict.space_index = i; | |
2959 | ||
2960 | /* Dump this subspace header. */ | |
2961 | if (bfd_write ((PTR) &som_section_data (subsection)->subspace_dict, | |
2962 | sizeof (struct subspace_dictionary_record), 1, abfd) | |
2963 | != sizeof (struct subspace_dictionary_record)) | |
2964 | { | |
2965 | bfd_error = system_call_error; | |
2966 | return false; | |
2967 | } | |
2968 | } | |
2969 | /* Goto the next section. */ | |
2970 | section = section->next; | |
2971 | } | |
2972 | ||
2973 | /* All the subspace dictiondary records are written, and all the | |
2974 | fields are set up in the space dictionary records. | |
2975 | ||
2976 | Seek to the right location and start writing the space | |
2977 | dictionary records. */ | |
2978 | location = obj_som_file_hdr (abfd)->space_location; | |
2979 | bfd_seek (abfd, location, SEEK_SET); | |
2980 | ||
2981 | section = abfd->sections; | |
2982 | for (i = 0; i < num_spaces; i++) | |
2983 | { | |
2984 | ||
2985 | /* Find a space. */ | |
2986 | while (som_section_data (section)->is_space == 0) | |
2987 | section = section->next; | |
2988 | ||
2989 | /* Dump its header */ | |
2990 | if (bfd_write ((PTR) &som_section_data (section)->space_dict, | |
2991 | sizeof (struct space_dictionary_record), 1, abfd) | |
2992 | != sizeof (struct space_dictionary_record)) | |
2993 | { | |
2994 | bfd_error = system_call_error; | |
2995 | return false; | |
2996 | } | |
2997 | ||
2998 | /* Goto the next section. */ | |
2999 | section = section->next; | |
3000 | } | |
3001 | ||
3002 | /* Only thing left to do is write out the file header. It is always | |
3003 | at location zero. Seek there and write it. */ | |
3004 | bfd_seek (abfd, (file_ptr) 0, SEEK_SET); | |
3005 | if (bfd_write ((PTR) obj_som_file_hdr (abfd), | |
3006 | sizeof (struct header), 1, abfd) | |
3007 | != sizeof (struct header)) | |
3008 | { | |
3009 | bfd_error = system_call_error; | |
3010 | return false; | |
3011 | } | |
3012 | return true; | |
3013 | } | |
3014 | ||
980bac64 JL |
3015 | /* Compute and return the checksum for a SOM file header. */ |
3016 | ||
5532fc5a JL |
3017 | static unsigned long |
3018 | som_compute_checksum (abfd) | |
3019 | bfd *abfd; | |
3020 | { | |
3021 | unsigned long checksum, count, i; | |
3022 | unsigned long *buffer = (unsigned long *) obj_som_file_hdr (abfd); | |
3023 | ||
3024 | checksum = 0; | |
3025 | count = sizeof (struct header) / sizeof (unsigned long); | |
3026 | for (i = 0; i < count; i++) | |
3027 | checksum ^= *(buffer + i); | |
3028 | ||
3029 | return checksum; | |
3030 | } | |
3031 | ||
713de7ec JL |
3032 | /* Build and write, in one big chunk, the entire symbol table for |
3033 | this BFD. */ | |
3034 | ||
3035 | static boolean | |
3036 | som_build_and_write_symbol_table (abfd) | |
3037 | bfd *abfd; | |
3038 | { | |
3039 | unsigned int num_syms = bfd_get_symcount (abfd); | |
3040 | file_ptr symtab_location = obj_som_file_hdr (abfd)->symbol_location; | |
3041 | asymbol **bfd_syms = bfd_get_outsymbols (abfd); | |
3042 | struct symbol_dictionary_record *som_symtab; | |
3043 | int i, symtab_size; | |
3044 | ||
3045 | /* Compute total symbol table size and allocate a chunk of memory | |
3046 | to hold the symbol table as we build it. */ | |
3047 | symtab_size = num_syms * sizeof (struct symbol_dictionary_record); | |
3048 | som_symtab = (struct symbol_dictionary_record *) alloca (symtab_size); | |
3049 | bzero (som_symtab, symtab_size); | |
3050 | ||
3051 | /* Walk over each symbol. */ | |
3052 | for (i = 0; i < num_syms; i++) | |
3053 | { | |
3054 | /* This is really an index into the symbol strings table. | |
3055 | By the time we get here, the index has already been | |
3056 | computed and stored into the name field in the BFD symbol. */ | |
3057 | som_symtab[i].name.n_strx = (int) bfd_syms[i]->name; | |
3058 | ||
3059 | /* The HP SOM linker requires detailed type information about | |
3060 | all symbols (including undefined symbols!). Unfortunately, | |
3061 | the type specified in an import/export statement does not | |
3062 | always match what the linker wants. Severe braindamage. */ | |
3063 | ||
3064 | /* Section symbols will not have a SOM symbol type assigned to | |
3065 | them yet. Assign all section symbols type ST_DATA. */ | |
3066 | if (bfd_syms[i]->flags & BSF_SECTION_SYM) | |
3067 | som_symtab[i].symbol_type = ST_DATA; | |
3068 | else | |
3069 | { | |
3070 | /* Common symbols must have scope SS_UNSAT and type | |
3071 | ST_STORAGE or the linker will choke. */ | |
3072 | if (bfd_syms[i]->section == &bfd_com_section) | |
3073 | { | |
3074 | som_symtab[i].symbol_scope = SS_UNSAT; | |
3075 | som_symtab[i].symbol_type = ST_STORAGE; | |
3076 | } | |
3077 | ||
3078 | /* It is possible to have a symbol without an associated | |
3079 | type. This happens if the user imported the symbol | |
3080 | without a type and the symbol was never defined | |
3081 | locally. If BSF_FUNCTION is set for this symbol, then | |
3082 | assign it type ST_CODE (the HP linker requires undefined | |
3083 | external functions to have type ST_CODE rather than ST_ENTRY. */ | |
3084 | else if (((*som_symbol_data (bfd_syms[i]))->som_type | |
3085 | == SYMBOL_TYPE_UNKNOWN) | |
3086 | && (bfd_syms[i]->section == &bfd_und_section) | |
3087 | && (bfd_syms[i]->flags & BSF_FUNCTION)) | |
3088 | som_symtab[i].symbol_type = ST_CODE; | |
3089 | ||
3090 | /* Handle function symbols which were defined in this file. | |
3091 | They should have type ST_ENTRY. Also retrieve the argument | |
3092 | relocation bits from the SOM backend information. */ | |
3093 | else if (((*som_symbol_data (bfd_syms[i]))->som_type | |
3094 | == SYMBOL_TYPE_ENTRY) | |
3095 | || (((*som_symbol_data (bfd_syms[i]))->som_type | |
3096 | == SYMBOL_TYPE_CODE) | |
3097 | && (bfd_syms[i]->flags & BSF_FUNCTION)) | |
3098 | || (((*som_symbol_data (bfd_syms[i]))->som_type | |
3099 | == SYMBOL_TYPE_UNKNOWN) | |
3100 | && (bfd_syms[i]->flags & BSF_FUNCTION))) | |
3101 | { | |
3102 | som_symtab[i].symbol_type = ST_ENTRY; | |
3103 | som_symtab[i].arg_reloc | |
3104 | = (*som_symbol_data (bfd_syms[i]))->tc_data.hppa_arg_reloc; | |
3105 | } | |
3106 | ||
3107 | /* If the type is unknown at this point, it should be | |
3108 | ST_DATA (functions were handled as special cases above). */ | |
3109 | else if ((*som_symbol_data (bfd_syms[i]))->som_type | |
3110 | == SYMBOL_TYPE_UNKNOWN) | |
3111 | som_symtab[i].symbol_type = ST_DATA; | |
3112 | ||
3113 | /* From now on it's a very simple mapping. */ | |
3114 | else if ((*som_symbol_data (bfd_syms[i]))->som_type | |
3115 | == SYMBOL_TYPE_ABSOLUTE) | |
3116 | som_symtab[i].symbol_type = ST_ABSOLUTE; | |
3117 | else if ((*som_symbol_data (bfd_syms[i]))->som_type | |
3118 | == SYMBOL_TYPE_CODE) | |
3119 | som_symtab[i].symbol_type = ST_CODE; | |
3120 | else if ((*som_symbol_data (bfd_syms[i]))->som_type | |
3121 | == SYMBOL_TYPE_DATA) | |
3122 | som_symtab[i].symbol_type = ST_DATA; | |
3123 | else if ((*som_symbol_data (bfd_syms[i]))->som_type | |
3124 | == SYMBOL_TYPE_MILLICODE) | |
3125 | som_symtab[i].symbol_type = ST_MILLICODE; | |
3126 | else if ((*som_symbol_data (bfd_syms[i]))->som_type | |
3127 | == SYMBOL_TYPE_PLABEL) | |
3128 | som_symtab[i].symbol_type = ST_PLABEL; | |
3129 | else if ((*som_symbol_data (bfd_syms[i]))->som_type | |
3130 | == SYMBOL_TYPE_PRI_PROG) | |
3131 | som_symtab[i].symbol_type = ST_PRI_PROG; | |
3132 | else if ((*som_symbol_data (bfd_syms[i]))->som_type | |
3133 | == SYMBOL_TYPE_SEC_PROG) | |
3134 | som_symtab[i].symbol_type = ST_SEC_PROG; | |
3135 | } | |
3136 | ||
3137 | /* Now handle the symbol's scope. Exported data which is not | |
3138 | in the common section has scope SS_UNIVERSAL. Note scope | |
980bac64 | 3139 | of common symbols was handled earlier! */ |
713de7ec JL |
3140 | if (bfd_syms[i]->flags & BSF_EXPORT |
3141 | && bfd_syms[i]->section != &bfd_com_section) | |
3142 | som_symtab[i].symbol_scope = SS_UNIVERSAL; | |
3143 | /* Any undefined symbol at this point has a scope SS_UNSAT. */ | |
3144 | else if (bfd_syms[i]->section == &bfd_und_section) | |
3145 | som_symtab[i].symbol_scope = SS_UNSAT; | |
3146 | /* Anything else which is not in the common section has scope | |
3147 | SS_LOCAL. */ | |
3148 | else if (bfd_syms[i]->section != &bfd_com_section) | |
3149 | som_symtab[i].symbol_scope = SS_LOCAL; | |
3150 | ||
3151 | /* Now set the symbol_info field. It has no real meaning | |
3152 | for undefined or common symbols, but the HP linker will | |
3153 | choke if it's not set to some "reasonable" value. We | |
3154 | use zero as a reasonable value. */ | |
3155 | if (bfd_syms[i]->section == &bfd_com_section | |
3156 | || bfd_syms[i]->section == &bfd_und_section) | |
3157 | som_symtab[i].symbol_info = 0; | |
3158 | /* For all other symbols, the symbol_info field contains the | |
3159 | subspace index of the space this symbol is contained in. */ | |
3160 | else | |
3161 | som_symtab[i].symbol_info | |
3162 | = som_section_data (bfd_syms[i]->section)->subspace_index; | |
3163 | ||
3164 | /* Set the symbol's value. */ | |
3165 | som_symtab[i].symbol_value | |
3166 | = bfd_syms[i]->value + bfd_syms[i]->section->vma; | |
3167 | } | |
3168 | ||
3169 | /* Egad. Everything is ready, seek to the right location and | |
3170 | scribble out the symbol table. */ | |
3171 | if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0) | |
3172 | { | |
3173 | bfd_error = system_call_error; | |
3174 | return false; | |
3175 | } | |
3176 | ||
3177 | if (bfd_write ((PTR) som_symtab, symtab_size, 1, abfd) != symtab_size) | |
3178 | { | |
3179 | bfd_error = system_call_error; | |
3180 | return false; | |
3181 | } | |
3182 | return true; | |
3183 | } | |
3184 | ||
980bac64 JL |
3185 | /* Write an object in SOM format. */ |
3186 | ||
3187 | static boolean | |
9e16fcf1 | 3188 | som_write_object_contents (abfd) |
d9ad93bc KR |
3189 | bfd *abfd; |
3190 | { | |
980bac64 JL |
3191 | if (abfd->output_has_begun == false) |
3192 | { | |
3193 | /* Set up fixed parts of the file, space, and subspace headers. | |
3194 | Notify the world that output has begun. */ | |
3195 | som_prep_headers (abfd); | |
3196 | abfd->output_has_begun = true; | |
980bac64 JL |
3197 | /* Start writing the object file. This include all the string |
3198 | tables, fixup streams, and other portions of the object file. */ | |
3199 | som_begin_writing (abfd); | |
980bac64 JL |
3200 | } |
3201 | ||
3202 | /* Now that the symbol table information is complete, build and | |
3203 | write the symbol table. */ | |
3204 | if (som_build_and_write_symbol_table (abfd) == false) | |
3205 | return false; | |
3206 | ||
3207 | /* Compute the checksum for the file header just before writing | |
3208 | the header to disk. */ | |
3209 | obj_som_file_hdr (abfd)->checksum = som_compute_checksum (abfd); | |
3210 | return (som_write_headers (abfd)); | |
d9ad93bc | 3211 | } |
980bac64 JL |
3212 | |
3213 | \f | |
9e16fcf1 | 3214 | /* Read and save the string table associated with the given BFD. */ |
d9ad93bc | 3215 | |
9e16fcf1 SG |
3216 | static boolean |
3217 | som_slurp_string_table (abfd) | |
d9ad93bc KR |
3218 | bfd *abfd; |
3219 | { | |
9e16fcf1 SG |
3220 | char *stringtab; |
3221 | ||
3222 | /* Use the saved version if its available. */ | |
3223 | if (obj_som_stringtab (abfd) != NULL) | |
3224 | return true; | |
3225 | ||
3226 | /* Allocate and read in the string table. */ | |
3227 | stringtab = bfd_zalloc (abfd, obj_som_stringtab_size (abfd)); | |
3228 | if (stringtab == NULL) | |
3229 | { | |
3230 | bfd_error = no_memory; | |
3231 | return false; | |
3232 | } | |
3233 | ||
3234 | if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0) | |
3235 | { | |
3236 | bfd_error = system_call_error; | |
3237 | return false; | |
3238 | } | |
3239 | ||
3240 | if (bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd) | |
3241 | != obj_som_stringtab_size (abfd)) | |
3242 | { | |
3243 | bfd_error = system_call_error; | |
3244 | return false; | |
3245 | } | |
3246 | ||
3247 | /* Save our results and return success. */ | |
3248 | obj_som_stringtab (abfd) = stringtab; | |
3249 | return true; | |
d9ad93bc KR |
3250 | } |
3251 | ||
9e16fcf1 SG |
3252 | /* Return the amount of data (in bytes) required to hold the symbol |
3253 | table for this object. */ | |
3254 | ||
d9ad93bc | 3255 | static unsigned int |
9e16fcf1 | 3256 | som_get_symtab_upper_bound (abfd) |
d9ad93bc | 3257 | bfd *abfd; |
d9ad93bc | 3258 | { |
9e16fcf1 SG |
3259 | if (!som_slurp_symbol_table (abfd)) |
3260 | return 0; | |
3261 | ||
3262 | return (bfd_get_symcount (abfd) + 1) * (sizeof (som_symbol_type *)); | |
d9ad93bc KR |
3263 | } |
3264 | ||
9e16fcf1 SG |
3265 | /* Convert from a SOM subspace index to a BFD section. */ |
3266 | ||
3267 | static asection * | |
3268 | som_section_from_subspace_index (abfd, index) | |
3269 | bfd *abfd; | |
3270 | unsigned int index; | |
3271 | { | |
3272 | asection *section; | |
3273 | ||
3274 | for (section = abfd->sections; section != NULL; section = section->next) | |
3275 | if (som_section_data (section)->subspace_index == index) | |
3276 | return section; | |
3277 | ||
3278 | /* Should never happen. */ | |
3279 | abort(); | |
3280 | } | |
3281 | ||
3282 | /* Read and save the symbol table associated with the given BFD. */ | |
3283 | ||
d9ad93bc | 3284 | static unsigned int |
9e16fcf1 | 3285 | som_slurp_symbol_table (abfd) |
d9ad93bc | 3286 | bfd *abfd; |
d9ad93bc | 3287 | { |
9e16fcf1 SG |
3288 | int symbol_count = bfd_get_symcount (abfd); |
3289 | int symsize = sizeof (struct symbol_dictionary_record); | |
3290 | char *stringtab; | |
3291 | struct symbol_dictionary_record *buf, *bufp, *endbufp; | |
3292 | som_symbol_type *sym, *symbase; | |
3293 | ||
3294 | /* Return saved value if it exists. */ | |
3295 | if (obj_som_symtab (abfd) != NULL) | |
3296 | return true; | |
3297 | ||
3298 | /* Sanity checking. Make sure there are some symbols and that | |
3299 | we can read the string table too. */ | |
3300 | if (symbol_count == 0) | |
3301 | { | |
3302 | bfd_error = no_symbols; | |
3303 | return false; | |
3304 | } | |
3305 | ||
3306 | if (!som_slurp_string_table (abfd)) | |
3307 | return false; | |
3308 | ||
3309 | stringtab = obj_som_stringtab (abfd); | |
3310 | ||
3311 | symbase = (som_symbol_type *) | |
3312 | bfd_zalloc (abfd, symbol_count * sizeof (som_symbol_type)); | |
3313 | if (symbase == NULL) | |
3314 | { | |
3315 | bfd_error = no_memory; | |
3316 | return false; | |
3317 | } | |
3318 | ||
3319 | /* Read in the external SOM representation. */ | |
3320 | buf = alloca (symbol_count * symsize); | |
3321 | if (buf == NULL) | |
3322 | { | |
3323 | bfd_error = no_memory; | |
3324 | return false; | |
3325 | } | |
3326 | if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) < 0) | |
3327 | { | |
3328 | bfd_error = system_call_error; | |
3329 | return false; | |
3330 | } | |
3331 | if (bfd_read (buf, symbol_count * symsize, 1, abfd) | |
3332 | != symbol_count * symsize) | |
3333 | { | |
3334 | bfd_error = no_symbols; | |
3335 | return (false); | |
3336 | } | |
3337 | ||
3338 | /* Iterate over all the symbols and internalize them. */ | |
3339 | endbufp = buf + symbol_count; | |
3340 | for (bufp = buf, sym = symbase; bufp < endbufp; ++bufp) | |
3341 | { | |
3342 | ||
3343 | /* I don't think we care about these. */ | |
3344 | if (bufp->symbol_type == ST_SYM_EXT | |
3345 | || bufp->symbol_type == ST_ARG_EXT) | |
3346 | continue; | |
3347 | ||
3348 | /* Some reasonable defaults. */ | |
3349 | sym->symbol.the_bfd = abfd; | |
3350 | sym->symbol.name = bufp->name.n_strx + stringtab; | |
3351 | sym->symbol.value = bufp->symbol_value; | |
3352 | sym->symbol.section = 0; | |
3353 | sym->symbol.flags = 0; | |
3354 | ||
3355 | switch (bufp->symbol_type) | |
3356 | { | |
3357 | case ST_ENTRY: | |
36456a67 JL |
3358 | case ST_PRI_PROG: |
3359 | case ST_SEC_PROG: | |
3360 | case ST_MILLICODE: | |
9e16fcf1 SG |
3361 | sym->symbol.flags |= BSF_FUNCTION; |
3362 | sym->symbol.value &= ~0x3; | |
3363 | break; | |
3364 | ||
9e16fcf1 | 3365 | case ST_STUB: |
9e16fcf1 SG |
3366 | case ST_CODE: |
3367 | sym->symbol.value &= ~0x3; | |
3368 | ||
3369 | default: | |
3370 | break; | |
3371 | } | |
3372 | ||
3373 | /* Handle scoping and section information. */ | |
3374 | switch (bufp->symbol_scope) | |
3375 | { | |
3376 | /* symbol_info field is undefined for SS_EXTERNAL and SS_UNSAT symbols, | |
3377 | so the section associated with this symbol can't be known. */ | |
3378 | case SS_EXTERNAL: | |
3379 | case SS_UNSAT: | |
017a52d7 JL |
3380 | if (bufp->symbol_type != ST_STORAGE) |
3381 | sym->symbol.section = &bfd_und_section; | |
3382 | else | |
3383 | sym->symbol.section = &bfd_com_section; | |
9e16fcf1 SG |
3384 | sym->symbol.flags |= (BSF_EXPORT | BSF_GLOBAL); |
3385 | break; | |
3386 | ||
3387 | case SS_UNIVERSAL: | |
3388 | sym->symbol.flags |= (BSF_EXPORT | BSF_GLOBAL); | |
3389 | sym->symbol.section | |
3390 | = som_section_from_subspace_index (abfd, bufp->symbol_info); | |
3391 | sym->symbol.value -= sym->symbol.section->vma; | |
3392 | break; | |
3393 | ||
3394 | #if 0 | |
3395 | /* SS_GLOBAL and SS_LOCAL are two names for the same thing. | |
3396 | Sound dumb? It is. */ | |
3397 | case SS_GLOBAL: | |
3398 | #endif | |
3399 | case SS_LOCAL: | |
3400 | sym->symbol.flags |= BSF_LOCAL; | |
3401 | sym->symbol.section | |
3402 | = som_section_from_subspace_index (abfd, bufp->symbol_info); | |
3403 | sym->symbol.value -= sym->symbol.section->vma; | |
3404 | break; | |
3405 | } | |
3406 | ||
3407 | /* Mark symbols left around by the debugger. */ | |
36456a67 | 3408 | if (strlen (sym->symbol.name) >= 2 |
9e16fcf1 | 3409 | && sym->symbol.name[0] == 'L' |
36456a67 JL |
3410 | && (sym->symbol.name[1] == '$' || sym->symbol.name[2] == '$' |
3411 | || sym->symbol.name[3] == '$')) | |
9e16fcf1 SG |
3412 | sym->symbol.flags |= BSF_DEBUGGING; |
3413 | ||
3414 | /* Note increment at bottom of loop, since we skip some symbols | |
3415 | we can not include it as part of the for statement. */ | |
3416 | sym++; | |
3417 | } | |
3418 | ||
3419 | /* Save our results and return success. */ | |
3420 | obj_som_symtab (abfd) = symbase; | |
3421 | return (true); | |
d9ad93bc KR |
3422 | } |
3423 | ||
9e16fcf1 SG |
3424 | /* Canonicalize a SOM symbol table. Return the number of entries |
3425 | in the symbol table. */ | |
d9ad93bc KR |
3426 | |
3427 | static unsigned int | |
9e16fcf1 | 3428 | som_get_symtab (abfd, location) |
d9ad93bc KR |
3429 | bfd *abfd; |
3430 | asymbol **location; | |
3431 | { | |
9e16fcf1 SG |
3432 | int i; |
3433 | som_symbol_type *symbase; | |
3434 | ||
3435 | if (!som_slurp_symbol_table (abfd)) | |
3436 | return 0; | |
3437 | ||
3438 | i = bfd_get_symcount (abfd); | |
3439 | symbase = obj_som_symtab (abfd); | |
3440 | ||
3441 | for (; i > 0; i--, location++, symbase++) | |
3442 | *location = &symbase->symbol; | |
3443 | ||
3444 | /* Final null pointer. */ | |
3445 | *location = 0; | |
3446 | return (bfd_get_symcount (abfd)); | |
d9ad93bc KR |
3447 | } |
3448 | ||
9e16fcf1 SG |
3449 | /* Make a SOM symbol. There is nothing special to do here. */ |
3450 | ||
d9ad93bc | 3451 | static asymbol * |
9e16fcf1 | 3452 | som_make_empty_symbol (abfd) |
d9ad93bc KR |
3453 | bfd *abfd; |
3454 | { | |
9e16fcf1 SG |
3455 | som_symbol_type *new = |
3456 | (som_symbol_type *) bfd_zalloc (abfd, sizeof (som_symbol_type)); | |
3457 | if (new == NULL) | |
3458 | { | |
3459 | bfd_error = no_memory; | |
3460 | return 0; | |
3461 | } | |
d9ad93bc KR |
3462 | new->symbol.the_bfd = abfd; |
3463 | ||
3464 | return &new->symbol; | |
3465 | } | |
3466 | ||
9e16fcf1 SG |
3467 | /* Print symbol information. */ |
3468 | ||
d9ad93bc | 3469 | static void |
9e16fcf1 | 3470 | som_print_symbol (ignore_abfd, afile, symbol, how) |
d9ad93bc KR |
3471 | bfd *ignore_abfd; |
3472 | PTR afile; | |
3473 | asymbol *symbol; | |
3474 | bfd_print_symbol_type how; | |
3475 | { | |
9e16fcf1 SG |
3476 | FILE *file = (FILE *) afile; |
3477 | switch (how) | |
3478 | { | |
3479 | case bfd_print_symbol_name: | |
3480 | fprintf (file, "%s", symbol->name); | |
3481 | break; | |
3482 | case bfd_print_symbol_more: | |
3483 | fprintf (file, "som "); | |
3484 | fprintf_vma (file, symbol->value); | |
3485 | fprintf (file, " %lx", (long) symbol->flags); | |
3486 | break; | |
3487 | case bfd_print_symbol_all: | |
3488 | { | |
3489 | CONST char *section_name; | |
3490 | section_name = symbol->section ? symbol->section->name : "(*none*)"; | |
3491 | bfd_print_symbol_vandf ((PTR) file, symbol); | |
3492 | fprintf (file, " %s\t%s", section_name, symbol->name); | |
3493 | break; | |
3494 | } | |
3495 | } | |
3496 | } | |
3497 | ||
36456a67 JL |
3498 | /* Count or process variable-length SOM fixup records. |
3499 | ||
3500 | To avoid code duplication we use this code both to compute the number | |
3501 | of relocations requested by a stream, and to internalize the stream. | |
3502 | ||
3503 | When computing the number of relocations requested by a stream the | |
3504 | variables rptr, section, and symbols have no meaning. | |
3505 | ||
3506 | Return the number of relocations requested by the fixup stream. When | |
3507 | not just counting | |
3508 | ||
3509 | This needs at least two or three more passes to get it cleaned up. */ | |
3510 | ||
3511 | static unsigned int | |
3512 | som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count) | |
3513 | unsigned char *fixup; | |
3514 | unsigned int end; | |
3515 | arelent *internal_relocs; | |
3516 | asection *section; | |
3517 | asymbol **symbols; | |
3518 | boolean just_count; | |
3519 | { | |
3520 | unsigned int op, varname; | |
3521 | unsigned char *end_fixups = &fixup[end]; | |
3522 | const struct fixup_format *fp; | |
3523 | char *cp; | |
3524 | unsigned char *save_fixup; | |
3525 | int variables[26], stack[20], c, v, count, prev_fixup, *sp; | |
3526 | const int *subop; | |
3527 | arelent *rptr= internal_relocs; | |
3528 | unsigned int offset = just_count ? 0 : section->vma; | |
3529 | ||
3530 | #define var(c) variables[(c) - 'A'] | |
3531 | #define push(v) (*sp++ = (v)) | |
3532 | #define pop() (*--sp) | |
3533 | #define emptystack() (sp == stack) | |
3534 | ||
3535 | som_initialize_reloc_queue (reloc_queue); | |
3536 | bzero (variables, sizeof (variables)); | |
3537 | bzero (stack, sizeof (stack)); | |
3538 | count = 0; | |
3539 | prev_fixup = 0; | |
3540 | sp = stack; | |
3541 | ||
3542 | while (fixup < end_fixups) | |
3543 | { | |
3544 | ||
3545 | /* Save pointer to the start of this fixup. We'll use | |
3546 | it later to determine if it is necessary to put this fixup | |
3547 | on the queue. */ | |
3548 | save_fixup = fixup; | |
3549 | ||
3550 | /* Get the fixup code and its associated format. */ | |
3551 | op = *fixup++; | |
3552 | fp = &som_fixup_formats[op]; | |
3553 | ||
3554 | /* Handle a request for a previous fixup. */ | |
3555 | if (*fp->format == 'P') | |
3556 | { | |
3557 | /* Get pointer to the beginning of the prev fixup, move | |
3558 | the repeated fixup to the head of the queue. */ | |
3559 | fixup = reloc_queue[fp->D].reloc; | |
3560 | som_reloc_queue_fix (reloc_queue, fp->D); | |
3561 | prev_fixup = 1; | |
3562 | ||
3563 | /* Get the fixup code and its associated format. */ | |
3564 | op = *fixup++; | |
3565 | fp = &som_fixup_formats[op]; | |
3566 | } | |
3567 | ||
3568 | /* If we are not just counting, set some reasonable defaults. */ | |
3569 | if (! just_count) | |
3570 | { | |
3571 | rptr->address = offset; | |
3572 | rptr->howto = &som_hppa_howto_table[op]; | |
3573 | rptr->addend = 0; | |
3574 | } | |
3575 | ||
3576 | /* Set default input length to 0. Get the opcode class index | |
3577 | into D. */ | |
3578 | var ('L') = 0; | |
3579 | var ('D') = fp->D; | |
3580 | ||
3581 | /* Get the opcode format. */ | |
3582 | cp = fp->format; | |
3583 | ||
3584 | /* Process the format string. Parsing happens in two phases, | |
3585 | parse RHS, then assign to LHS. Repeat until no more | |
3586 | characters in the format string. */ | |
3587 | while (*cp) | |
3588 | { | |
3589 | /* The variable this pass is going to compute a value for. */ | |
3590 | varname = *cp++; | |
3591 | ||
3592 | /* Start processing RHS. Continue until a NULL or '=' is found. */ | |
3593 | do | |
3594 | { | |
3595 | c = *cp++; | |
3596 | ||
3597 | /* If this is a variable, push it on the stack. */ | |
3598 | if (isupper (c)) | |
3599 | push (var (c)); | |
3600 | ||
3601 | /* If this is a lower case letter, then it represents | |
3602 | additional data from the fixup stream to be pushed onto | |
3603 | the stack. */ | |
3604 | else if (islower (c)) | |
3605 | { | |
3606 | for (v = 0; c > 'a'; --c) | |
3607 | v = (v << 8) | *fixup++; | |
3608 | push (v); | |
3609 | } | |
3610 | ||
3611 | /* A decimal constant. Push it on the stack. */ | |
3612 | else if (isdigit (c)) | |
3613 | { | |
3614 | v = c - '0'; | |
3615 | while (isdigit (*cp)) | |
3616 | v = (v * 10) + (*cp++ - '0'); | |
3617 | push (v); | |
3618 | } | |
3619 | else | |
3620 | ||
3621 | /* An operator. Pop two two values from the stack and | |
3622 | use them as operands to the given operation. Push | |
3623 | the result of the operation back on the stack. */ | |
3624 | switch (c) | |
3625 | { | |
3626 | case '+': | |
3627 | v = pop (); | |
3628 | v += pop (); | |
3629 | push (v); | |
3630 | break; | |
3631 | case '*': | |
3632 | v = pop (); | |
3633 | v *= pop (); | |
3634 | push (v); | |
3635 | break; | |
3636 | case '<': | |
3637 | v = pop (); | |
3638 | v = pop () << v; | |
3639 | push (v); | |
3640 | break; | |
3641 | default: | |
3642 | abort (); | |
3643 | } | |
3644 | } | |
3645 | while (*cp && *cp != '='); | |
3646 | ||
3647 | /* Move over the equal operator. */ | |
3648 | cp++; | |
3649 | ||
3650 | /* Pop the RHS off the stack. */ | |
3651 | c = pop (); | |
3652 | ||
3653 | /* Perform the assignment. */ | |
3654 | var (varname) = c; | |
3655 | ||
3656 | /* Handle side effects. and special 'O' stack cases. */ | |
3657 | switch (varname) | |
3658 | { | |
3659 | /* Consume some bytes from the input space. */ | |
3660 | case 'L': | |
3661 | offset += c; | |
3662 | break; | |
3663 | /* A symbol to use in the relocation. Make a note | |
3664 | of this if we are not just counting. */ | |
3665 | case 'S': | |
3666 | if (! just_count) | |
3667 | rptr->sym_ptr_ptr = &symbols[c]; | |
3668 | break; | |
3669 | /* Handle the linker expression stack. */ | |
3670 | case 'O': | |
3671 | switch (op) | |
3672 | { | |
3673 | case R_COMP1: | |
3674 | subop = comp1_opcodes; | |
3675 | break; | |
3676 | case R_COMP2: | |
3677 | subop = comp2_opcodes; | |
3678 | break; | |
3679 | case R_COMP3: | |
3680 | subop = comp3_opcodes; | |
3681 | break; | |
3682 | default: | |
3683 | abort (); | |
3684 | } | |
3685 | while (*subop <= (unsigned char) c) | |
3686 | ++subop; | |
3687 | --subop; | |
3688 | break; | |
3689 | default: | |
3690 | break; | |
3691 | } | |
3692 | } | |
3693 | ||
3694 | /* If we used a previous fixup, clean up after it. */ | |
3695 | if (prev_fixup) | |
3696 | { | |
3697 | fixup = save_fixup + 1; | |
3698 | prev_fixup = 0; | |
3699 | } | |
3700 | /* Queue it. */ | |
3701 | else if (fixup > save_fixup + 1) | |
3702 | som_reloc_queue_insert (save_fixup, fixup - save_fixup, reloc_queue); | |
3703 | ||
3704 | /* We do not pass R_DATA_OVERRIDE or R_NO_RELOCATION | |
3705 | fixups to BFD. */ | |
3706 | if (som_hppa_howto_table[op].type != R_DATA_OVERRIDE | |
3707 | && som_hppa_howto_table[op].type != R_NO_RELOCATION) | |
3708 | { | |
3709 | /* Done with a single reloction. Loop back to the top. */ | |
3710 | if (! just_count) | |
3711 | { | |
3712 | rptr->addend = var ('V'); | |
3713 | rptr++; | |
3714 | } | |
3715 | count++; | |
3716 | /* Now that we've handled a "full" relocation, reset | |
3717 | some state. */ | |
3718 | bzero (variables, sizeof (variables)); | |
3719 | bzero (stack, sizeof (stack)); | |
3720 | } | |
3721 | } | |
3722 | return count; | |
3723 | ||
3724 | #undef var | |
3725 | #undef push | |
3726 | #undef pop | |
3727 | #undef emptystack | |
3728 | } | |
3729 | ||
3730 | /* Read in the relocs (aka fixups in SOM terms) for a section. | |
3731 | ||
3732 | som_get_reloc_upper_bound calls this routine with JUST_COUNT | |
3733 | set to true to indicate it only needs a count of the number | |
3734 | of actual relocations. */ | |
3735 | ||
3736 | static boolean | |
3737 | som_slurp_reloc_table (abfd, section, symbols, just_count) | |
3738 | bfd *abfd; | |
3739 | asection *section; | |
3740 | asymbol **symbols; | |
3741 | boolean just_count; | |
3742 | { | |
3743 | char *external_relocs; | |
3744 | unsigned int fixup_stream_size; | |
3745 | arelent *internal_relocs; | |
3746 | unsigned int num_relocs; | |
3747 | ||
3748 | fixup_stream_size = som_section_data (section)->reloc_size; | |
3749 | /* If there were no relocations, then there is nothing to do. */ | |
3750 | if (section->reloc_count == 0) | |
3751 | return true; | |
3752 | ||
3753 | /* If reloc_count is -1, then the relocation stream has not been | |
3754 | parsed. We must do so now to know how many relocations exist. */ | |
3755 | if (section->reloc_count == -1) | |
3756 | { | |
3757 | external_relocs = (char *) bfd_zalloc (abfd, fixup_stream_size); | |
3758 | if (external_relocs == (char *) NULL) | |
3759 | { | |
3760 | bfd_error = no_memory; | |
3761 | return false; | |
3762 | } | |
3763 | /* Read in the external forms. */ | |
3764 | if (bfd_seek (abfd, | |
3765 | obj_som_reloc_filepos (abfd) + section->rel_filepos, | |
3766 | SEEK_SET) | |
3767 | != 0) | |
3768 | { | |
3769 | bfd_error = system_call_error; | |
3770 | return false; | |
3771 | } | |
3772 | if (bfd_read (external_relocs, 1, fixup_stream_size, abfd) | |
3773 | != fixup_stream_size) | |
3774 | { | |
3775 | bfd_error = system_call_error; | |
3776 | return false; | |
3777 | } | |
3778 | /* Let callers know how many relocations found. | |
3779 | also save the relocation stream as we will | |
3780 | need it again. */ | |
3781 | section->reloc_count = som_set_reloc_info (external_relocs, | |
3782 | fixup_stream_size, | |
3783 | NULL, NULL, NULL, true); | |
3784 | ||
3785 | som_section_data (section)->reloc_stream = external_relocs; | |
3786 | } | |
3787 | ||
3788 | /* If the caller only wanted a count, then return now. */ | |
3789 | if (just_count) | |
3790 | return true; | |
3791 | ||
3792 | num_relocs = section->reloc_count; | |
3793 | external_relocs = som_section_data (section)->reloc_stream; | |
3794 | /* Return saved information about the relocations if it is available. */ | |
3795 | if (section->relocation != (arelent *) NULL) | |
3796 | return true; | |
3797 | ||
3798 | internal_relocs = (arelent *) bfd_zalloc (abfd, | |
3799 | num_relocs * sizeof (arelent)); | |
3800 | if (internal_relocs == (arelent *) NULL) | |
3801 | { | |
3802 | bfd_error = no_memory; | |
3803 | return false; | |
3804 | } | |
3805 | ||
3806 | /* Process and internalize the relocations. */ | |
3807 | som_set_reloc_info (external_relocs, fixup_stream_size, | |
3808 | internal_relocs, section, symbols, false); | |
3809 | ||
3810 | /* Save our results and return success. */ | |
3811 | section->relocation = internal_relocs; | |
3812 | return (true); | |
3813 | } | |
3814 | ||
3815 | /* Return the number of bytes required to store the relocation | |
3816 | information associated with the given section. */ | |
3817 | ||
9e16fcf1 SG |
3818 | static unsigned int |
3819 | som_get_reloc_upper_bound (abfd, asect) | |
3820 | bfd *abfd; | |
3821 | sec_ptr asect; | |
3822 | { | |
36456a67 JL |
3823 | /* If section has relocations, then read in the relocation stream |
3824 | and parse it to determine how many relocations exist. */ | |
3825 | if (asect->flags & SEC_RELOC) | |
3826 | { | |
3827 | if (som_slurp_reloc_table (abfd, asect, NULL, true)) | |
3828 | return (asect->reloc_count + 1) * sizeof (arelent); | |
3829 | } | |
3830 | /* Either there are no relocations or an error occurred while | |
3831 | reading and parsing the relocation stream. */ | |
3832 | return 0; | |
d9ad93bc KR |
3833 | } |
3834 | ||
36456a67 JL |
3835 | /* Convert relocations from SOM (external) form into BFD internal |
3836 | form. Return the number of relocations. */ | |
3837 | ||
9e16fcf1 SG |
3838 | static unsigned int |
3839 | som_canonicalize_reloc (abfd, section, relptr, symbols) | |
3840 | bfd *abfd; | |
3841 | sec_ptr section; | |
3842 | arelent **relptr; | |
3843 | asymbol **symbols; | |
3844 | { | |
36456a67 JL |
3845 | arelent *tblptr; |
3846 | int count; | |
3847 | ||
3848 | if (som_slurp_reloc_table (abfd, section, symbols, false) == false) | |
3849 | return 0; | |
3850 | ||
3851 | count = section->reloc_count; | |
3852 | tblptr = section->relocation; | |
3853 | if (tblptr == (arelent *) NULL) | |
3854 | return 0; | |
3855 | ||
3856 | while (count--) | |
3857 | *relptr++ = tblptr++; | |
3858 | ||
3859 | *relptr = (arelent *) NULL; | |
3860 | return section->reloc_count; | |
9e16fcf1 SG |
3861 | } |
3862 | ||
3863 | extern bfd_target som_vec; | |
3864 | ||
3865 | /* A hook to set up object file dependent section information. */ | |
3866 | ||
d9ad93bc | 3867 | static boolean |
9e16fcf1 | 3868 | som_new_section_hook (abfd, newsect) |
d9ad93bc KR |
3869 | bfd *abfd; |
3870 | asection *newsect; | |
3871 | { | |
9e16fcf1 SG |
3872 | newsect->used_by_bfd = (struct som_section_data_struct *) |
3873 | bfd_zalloc (abfd, sizeof (struct som_section_data_struct)); | |
d9ad93bc KR |
3874 | newsect->alignment_power = 3; |
3875 | ||
9e16fcf1 SG |
3876 | /* Initialize the subspace_index field to -1 so that it does |
3877 | not match a subspace with an index of 0. */ | |
3878 | som_section_data (newsect)->subspace_index = -1; | |
3879 | ||
d9ad93bc KR |
3880 | /* We allow more than three sections internally */ |
3881 | return true; | |
3882 | } | |
3883 | ||
40249bfb JL |
3884 | /* Set backend info for sections which can not be described |
3885 | in the BFD data structures. */ | |
3886 | ||
3887 | void | |
3888 | bfd_som_set_section_attributes (section, defined, private, sort_key, spnum) | |
3889 | asection *section; | |
3890 | char defined; | |
3891 | char private; | |
3892 | unsigned char sort_key; | |
3893 | int spnum; | |
3894 | { | |
3895 | struct space_dictionary_record *space_dict; | |
3896 | ||
3897 | som_section_data (section)->is_space = 1; | |
3898 | space_dict = &som_section_data (section)->space_dict; | |
3899 | space_dict->is_defined = defined; | |
3900 | space_dict->is_private = private; | |
3901 | space_dict->sort_key = sort_key; | |
3902 | space_dict->space_number = spnum; | |
3903 | } | |
3904 | ||
3905 | /* Set backend info for subsections which can not be described | |
3906 | in the BFD data structures. */ | |
3907 | ||
3908 | void | |
3909 | bfd_som_set_subsection_attributes (section, container, access, | |
3910 | sort_key, quadrant) | |
3911 | asection *section; | |
3912 | asection *container; | |
3913 | int access; | |
3914 | unsigned char sort_key; | |
3915 | int quadrant; | |
3916 | { | |
3917 | struct subspace_dictionary_record *subspace_dict; | |
3918 | som_section_data (section)->is_subspace = 1; | |
3919 | subspace_dict = &som_section_data (section)->subspace_dict; | |
3920 | subspace_dict->access_control_bits = access; | |
3921 | subspace_dict->sort_key = sort_key; | |
3922 | subspace_dict->quadrant = quadrant; | |
3923 | som_section_data (section)->containing_space = container; | |
3924 | } | |
3925 | ||
3926 | /* Set the full SOM symbol type. SOM needs far more symbol information | |
3927 | than any other object file format I'm aware of. It is mandatory | |
3928 | to be able to know if a symbol is an entry point, millicode, data, | |
3929 | code, absolute, storage request, or procedure label. If you get | |
3930 | the symbol type wrong your program will not link. */ | |
3931 | ||
3932 | void | |
3933 | bfd_som_set_symbol_type (symbol, type) | |
3934 | asymbol *symbol; | |
3935 | unsigned int type; | |
3936 | { | |
3937 | (*som_symbol_data (symbol))->som_type = type; | |
3938 | } | |
3939 | ||
3940 | /* Attach 64bits of unwind information to a symbol (which hopefully | |
3941 | is a function of some kind!). It would be better to keep this | |
3942 | in the R_ENTRY relocation, but there is not enough space. */ | |
3943 | ||
3944 | void | |
3945 | bfd_som_attach_unwind_info (symbol, unwind_desc) | |
3946 | asymbol *symbol; | |
3947 | char *unwind_desc; | |
3948 | { | |
3949 | (*som_symbol_data (symbol))->unwind = unwind_desc; | |
3950 | } | |
3951 | ||
f6c2300b JL |
3952 | /* Attach an auxiliary header to the BFD backend so that it may be |
3953 | written into the object file. */ | |
3954 | void | |
3955 | bfd_som_attach_aux_hdr (abfd, type, string) | |
3956 | bfd *abfd; | |
3957 | int type; | |
3958 | char *string; | |
3959 | { | |
3960 | if (type == VERSION_AUX_ID) | |
3961 | { | |
3962 | int len = strlen (string); | |
3963 | ||
3964 | if (len % 4) | |
3965 | len += (4 - (len % 4)); | |
3966 | obj_som_version_hdr (abfd) | |
3967 | = bfd_zalloc (abfd, | |
3968 | sizeof (struct aux_id) + sizeof (unsigned int) + len); | |
3969 | obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID; | |
3970 | obj_som_version_hdr (abfd)->header_id.length | |
3971 | = sizeof (struct aux_id) + sizeof (unsigned int) + len; | |
3972 | obj_som_version_hdr (abfd)->string_length = len; | |
3973 | strcpy (obj_som_version_hdr (abfd)->user_string, string); | |
3974 | } | |
3975 | else if (type == COPYRIGHT_AUX_ID) | |
3976 | { | |
3977 | int len = strlen (string); | |
3978 | ||
3979 | if (len % 4) | |
3980 | len += (4 - (len % 4)); | |
3981 | obj_som_copyright_hdr (abfd) | |
3982 | = bfd_zalloc (abfd, | |
3983 | sizeof (struct aux_id) + sizeof (unsigned int) + len); | |
3984 | obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID; | |
3985 | obj_som_version_hdr (abfd)->header_id.length | |
3986 | = sizeof (struct aux_id) + sizeof (unsigned int) + len; | |
3987 | obj_som_copyright_hdr (abfd)->string_length = len; | |
3988 | strcpy (obj_som_copyright_hdr (abfd)->copyright, string); | |
3989 | } | |
3990 | else | |
3991 | abort (); | |
3992 | } | |
3993 | ||
d9ad93bc | 3994 | static boolean |
9e16fcf1 | 3995 | som_set_section_contents (abfd, section, location, offset, count) |
d9ad93bc KR |
3996 | bfd *abfd; |
3997 | sec_ptr section; | |
3998 | PTR location; | |
3999 | file_ptr offset; | |
4000 | bfd_size_type count; | |
4001 | { | |
980bac64 JL |
4002 | if (abfd->output_has_begun == false) |
4003 | { | |
4004 | /* Set up fixed parts of the file, space, and subspace headers. | |
4005 | Notify the world that output has begun. */ | |
4006 | som_prep_headers (abfd); | |
4007 | abfd->output_has_begun = true; | |
980bac64 JL |
4008 | /* Start writing the object file. This include all the string |
4009 | tables, fixup streams, and other portions of the object file. */ | |
4010 | som_begin_writing (abfd); | |
980bac64 JL |
4011 | } |
4012 | ||
4013 | /* Only write subspaces which have "real" contents (eg. the contents | |
4014 | are not generated at run time by the OS). */ | |
4015 | if (som_section_data (section)->is_subspace != 1 | |
4016 | || ((section->flags & (SEC_LOAD | SEC_DEBUGGING)) == 0)) | |
4017 | return true; | |
4018 | ||
4019 | /* Seek to the proper offset within the object file and write the | |
4020 | data. */ | |
4021 | offset += som_section_data (section)->subspace_dict.file_loc_init_value; | |
4022 | if (bfd_seek (abfd, offset, SEEK_SET) == -1) | |
4023 | { | |
4024 | bfd_error = system_call_error; | |
4025 | return false; | |
4026 | } | |
4027 | ||
4028 | if (bfd_write ((PTR) location, 1, count, abfd) != count) | |
4029 | { | |
4030 | bfd_error = system_call_error; | |
4031 | return false; | |
4032 | } | |
4033 | return true; | |
d9ad93bc KR |
4034 | } |
4035 | ||
4036 | static boolean | |
9e16fcf1 | 4037 | som_set_arch_mach (abfd, arch, machine) |
d9ad93bc KR |
4038 | bfd *abfd; |
4039 | enum bfd_architecture arch; | |
4040 | unsigned long machine; | |
4041 | { | |
2212ff92 | 4042 | /* Allow any architecture to be supported by the SOM backend */ |
d9ad93bc KR |
4043 | return bfd_default_set_arch_mach (abfd, arch, machine); |
4044 | } | |
4045 | ||
4046 | static boolean | |
9e16fcf1 | 4047 | som_find_nearest_line (abfd, section, symbols, offset, filename_ptr, |
d9ad93bc KR |
4048 | functionname_ptr, line_ptr) |
4049 | bfd *abfd; | |
4050 | asection *section; | |
4051 | asymbol **symbols; | |
4052 | bfd_vma offset; | |
4053 | CONST char **filename_ptr; | |
4054 | CONST char **functionname_ptr; | |
4055 | unsigned int *line_ptr; | |
4056 | { | |
9e16fcf1 | 4057 | fprintf (stderr, "som_find_nearest_line unimplemented\n"); |
d9ad93bc KR |
4058 | fflush (stderr); |
4059 | abort (); | |
4060 | return (false); | |
4061 | } | |
4062 | ||
4063 | static int | |
9e16fcf1 | 4064 | som_sizeof_headers (abfd, reloc) |
d9ad93bc KR |
4065 | bfd *abfd; |
4066 | boolean reloc; | |
4067 | { | |
9e16fcf1 | 4068 | fprintf (stderr, "som_sizeof_headers unimplemented\n"); |
d9ad93bc KR |
4069 | fflush (stderr); |
4070 | abort (); | |
4071 | return (0); | |
4072 | } | |
4073 | ||
017a52d7 JL |
4074 | /* Return the single-character symbol type corresponding to |
4075 | SOM section S, or '?' for an unknown SOM section. */ | |
4076 | ||
4077 | static char | |
4078 | som_section_type (s) | |
4079 | const char *s; | |
4080 | { | |
4081 | const struct section_to_type *t; | |
4082 | ||
4083 | for (t = &stt[0]; t->section; t++) | |
4084 | if (!strcmp (s, t->section)) | |
4085 | return t->type; | |
4086 | return '?'; | |
4087 | } | |
4088 | ||
4089 | static int | |
4090 | som_decode_symclass (symbol) | |
4091 | asymbol *symbol; | |
4092 | { | |
4093 | char c; | |
4094 | ||
4095 | if (bfd_is_com_section (symbol->section)) | |
4096 | return 'C'; | |
4097 | if (symbol->section == &bfd_und_section) | |
4098 | return 'U'; | |
4099 | if (symbol->section == &bfd_ind_section) | |
4100 | return 'I'; | |
4101 | if (!(symbol->flags & (BSF_GLOBAL|BSF_LOCAL))) | |
4102 | return '?'; | |
4103 | ||
4104 | if (symbol->section == &bfd_abs_section) | |
4105 | c = 'a'; | |
4106 | else if (symbol->section) | |
4107 | c = som_section_type (symbol->section->name); | |
4108 | else | |
4109 | return '?'; | |
4110 | if (symbol->flags & BSF_GLOBAL) | |
4111 | c = toupper (c); | |
4112 | return c; | |
4113 | } | |
4114 | ||
d9ad93bc KR |
4115 | /* Return information about SOM symbol SYMBOL in RET. */ |
4116 | ||
4117 | static void | |
9e16fcf1 | 4118 | som_get_symbol_info (ignore_abfd, symbol, ret) |
017a52d7 | 4119 | bfd *ignore_abfd; |
d9ad93bc KR |
4120 | asymbol *symbol; |
4121 | symbol_info *ret; | |
4122 | { | |
017a52d7 JL |
4123 | ret->type = som_decode_symclass (symbol); |
4124 | if (ret->type != 'U') | |
4125 | ret->value = symbol->value+symbol->section->vma; | |
4126 | else | |
4127 | ret->value = 0; | |
4128 | ret->name = symbol->name; | |
d9ad93bc KR |
4129 | } |
4130 | ||
4131 | /* End of miscellaneous support functions. */ | |
4132 | ||
9e16fcf1 SG |
4133 | #define som_bfd_debug_info_start bfd_void |
4134 | #define som_bfd_debug_info_end bfd_void | |
4135 | #define som_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void | |
d9ad93bc | 4136 | |
9e16fcf1 SG |
4137 | #define som_openr_next_archived_file bfd_generic_openr_next_archived_file |
4138 | #define som_generic_stat_arch_elt bfd_generic_stat_arch_elt | |
4139 | #define som_slurp_armap bfd_false | |
4140 | #define som_slurp_extended_name_table _bfd_slurp_extended_name_table | |
4141 | #define som_truncate_arname (void (*)())bfd_nullvoidptr | |
4142 | #define som_write_armap 0 | |
d9ad93bc | 4143 | |
9e16fcf1 SG |
4144 | #define som_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr |
4145 | #define som_close_and_cleanup bfd_generic_close_and_cleanup | |
4146 | #define som_get_section_contents bfd_generic_get_section_contents | |
d9ad93bc | 4147 | |
9e16fcf1 | 4148 | #define som_bfd_get_relocated_section_contents \ |
d9ad93bc | 4149 | bfd_generic_get_relocated_section_contents |
9e16fcf1 SG |
4150 | #define som_bfd_relax_section bfd_generic_relax_section |
4151 | #define som_bfd_seclet_link bfd_generic_seclet_link | |
9e16fcf1 | 4152 | #define som_bfd_make_debug_symbol \ |
d9ad93bc KR |
4153 | ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr) |
4154 | ||
4155 | /* Core file support is in the hpux-core backend. */ | |
9e16fcf1 SG |
4156 | #define som_core_file_failing_command _bfd_dummy_core_file_failing_command |
4157 | #define som_core_file_failing_signal _bfd_dummy_core_file_failing_signal | |
4158 | #define som_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p | |
d9ad93bc | 4159 | |
9e16fcf1 | 4160 | bfd_target som_vec = |
d9ad93bc | 4161 | { |
9e16fcf1 SG |
4162 | "som", /* name */ |
4163 | bfd_target_som_flavour, | |
d9ad93bc KR |
4164 | true, /* target byte order */ |
4165 | true, /* target headers byte order */ | |
4166 | (HAS_RELOC | EXEC_P | /* object flags */ | |
4167 | HAS_LINENO | HAS_DEBUG | | |
40249bfb | 4168 | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), |
d9ad93bc | 4169 | (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS |
9e16fcf1 | 4170 | | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ |
d9ad93bc KR |
4171 | |
4172 | /* leading_symbol_char: is the first char of a user symbol | |
9e16fcf1 | 4173 | predictable, and if so what is it */ |
d9ad93bc KR |
4174 | 0, |
4175 | ' ', /* ar_pad_char */ | |
4176 | 16, /* ar_max_namelen */ | |
4177 | 3, /* minimum alignment */ | |
9e16fcf1 SG |
4178 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, |
4179 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
4180 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ | |
4181 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
4182 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
4183 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ | |
d9ad93bc | 4184 | {_bfd_dummy_target, |
9e16fcf1 | 4185 | som_object_p, /* bfd_check_format */ |
d9ad93bc KR |
4186 | bfd_generic_archive_p, |
4187 | _bfd_dummy_target | |
4188 | }, | |
4189 | { | |
4190 | bfd_false, | |
9e16fcf1 | 4191 | som_mkobject, |
d9ad93bc KR |
4192 | _bfd_generic_mkarchive, |
4193 | bfd_false | |
4194 | }, | |
4195 | { | |
4196 | bfd_false, | |
9e16fcf1 | 4197 | som_write_object_contents, |
d9ad93bc KR |
4198 | _bfd_write_archive_contents, |
4199 | bfd_false, | |
4200 | }, | |
9e16fcf1 SG |
4201 | #undef som |
4202 | JUMP_TABLE (som), | |
d9ad93bc KR |
4203 | (PTR) 0 |
4204 | }; | |
4205 | ||
4206 | #endif /* HOST_HPPAHPUX || HOST_HPPABSD */ |