1 /* bfd back-end for HP PA-RISC SOM objects.
2 Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998, 2000
3 Free Software Foundation, Inc.
5 Contributed by the Center for Software Science at the
8 This file is part of BFD, the Binary File Descriptor library.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 #include "alloca-conf.h"
29 #if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) || defined(HOST_HPPAMPEIX)
34 #include <sys/param.h>
36 #include <machine/reg.h>
40 /* Magic not defined in standard HP-UX header files until 8.0 */
42 #ifndef CPU_PA_RISC1_0
43 #define CPU_PA_RISC1_0 0x20B
44 #endif /* CPU_PA_RISC1_0 */
46 #ifndef CPU_PA_RISC1_1
47 #define CPU_PA_RISC1_1 0x210
48 #endif /* CPU_PA_RISC1_1 */
50 #ifndef CPU_PA_RISC2_0
51 #define CPU_PA_RISC2_0 0x214
52 #endif /* CPU_PA_RISC2_0 */
54 #ifndef _PA_RISC1_0_ID
55 #define _PA_RISC1_0_ID CPU_PA_RISC1_0
56 #endif /* _PA_RISC1_0_ID */
58 #ifndef _PA_RISC1_1_ID
59 #define _PA_RISC1_1_ID CPU_PA_RISC1_1
60 #endif /* _PA_RISC1_1_ID */
62 #ifndef _PA_RISC2_0_ID
63 #define _PA_RISC2_0_ID CPU_PA_RISC2_0
64 #endif /* _PA_RISC2_0_ID */
66 #ifndef _PA_RISC_MAXID
67 #define _PA_RISC_MAXID 0x2FF
68 #endif /* _PA_RISC_MAXID */
71 #define _PA_RISC_ID(__m_num) \
72 (((__m_num) == _PA_RISC1_0_ID) || \
73 ((__m_num) >= _PA_RISC1_1_ID && (__m_num) <= _PA_RISC_MAXID))
74 #endif /* _PA_RISC_ID */
76 /* HIUX in it's infinite stupidity changed the names for several "well
77 known" constants. Work around such braindamage. Try the HPUX version
78 first, then the HIUX version, and finally provide a default. */
80 #define EXEC_AUX_ID HPUX_AUX_ID
83 #if !defined (EXEC_AUX_ID) && defined (HIUX_AUX_ID)
84 #define EXEC_AUX_ID HIUX_AUX_ID
91 /* Size (in chars) of the temporary buffers used during fixup and string
94 #define SOM_TMP_BUFSIZE 8192
96 /* Size of the hash table in archives. */
97 #define SOM_LST_HASH_SIZE 31
99 /* Max number of SOMs to be found in an archive. */
100 #define SOM_LST_MODULE_LIMIT 1024
102 /* Generic alignment macro. */
103 #define SOM_ALIGN(val, alignment) \
104 (((val) + (alignment) - 1) & ~((alignment) - 1))
106 /* SOM allows any one of the four previous relocations to be reused
107 with a "R_PREV_FIXUP" relocation entry. Since R_PREV_FIXUP
108 relocations are always a single byte, using a R_PREV_FIXUP instead
109 of some multi-byte relocation makes object files smaller.
111 Note one side effect of using a R_PREV_FIXUP is the relocation that
112 is being repeated moves to the front of the queue. */
114 unsigned char *reloc
;
118 /* This fully describes the symbol types which may be attached to
119 an EXPORT or IMPORT directive. Only SOM uses this formation
120 (ELF has no need for it). */
123 SYMBOL_TYPE_ABSOLUTE
,
127 SYMBOL_TYPE_MILLICODE
,
129 SYMBOL_TYPE_PRI_PROG
,
130 SYMBOL_TYPE_SEC_PROG
,
133 struct section_to_type
{
138 /* Assorted symbol information that needs to be derived from the BFD symbol
139 and/or the BFD backend private symbol data. */
140 struct som_misc_symbol_info
{
141 unsigned int symbol_type
;
142 unsigned int symbol_scope
;
143 unsigned int arg_reloc
;
144 unsigned int symbol_info
;
145 unsigned int symbol_value
;
146 unsigned int priv_level
;
147 unsigned int secondary_def
;
150 /* Forward declarations */
152 static boolean som_mkobject
PARAMS ((bfd
*));
153 static const bfd_target
* som_object_setup
PARAMS ((bfd
*,
155 struct som_exec_auxhdr
*,
157 static boolean setup_sections
PARAMS ((bfd
*, struct header
*, unsigned long));
158 static const bfd_target
* som_object_p
PARAMS ((bfd
*));
159 static boolean som_write_object_contents
PARAMS ((bfd
*));
160 static boolean som_slurp_string_table
PARAMS ((bfd
*));
161 static unsigned int som_slurp_symbol_table
PARAMS ((bfd
*));
162 static long som_get_symtab_upper_bound
PARAMS ((bfd
*));
163 static long som_canonicalize_reloc
PARAMS ((bfd
*, sec_ptr
,
164 arelent
**, asymbol
**));
165 static long som_get_reloc_upper_bound
PARAMS ((bfd
*, sec_ptr
));
166 static unsigned int som_set_reloc_info
PARAMS ((unsigned char *, unsigned int,
167 arelent
*, asection
*,
168 asymbol
**, boolean
));
169 static boolean som_slurp_reloc_table
PARAMS ((bfd
*, asection
*,
170 asymbol
**, boolean
));
171 static long som_get_symtab
PARAMS ((bfd
*, asymbol
**));
172 static asymbol
* som_make_empty_symbol
PARAMS ((bfd
*));
173 static void som_print_symbol
PARAMS ((bfd
*, PTR
,
174 asymbol
*, bfd_print_symbol_type
));
175 static boolean som_new_section_hook
PARAMS ((bfd
*, asection
*));
176 static boolean som_bfd_copy_private_symbol_data
PARAMS ((bfd
*, asymbol
*,
178 static boolean som_bfd_copy_private_section_data
PARAMS ((bfd
*, asection
*,
180 static boolean som_bfd_copy_private_bfd_data
PARAMS ((bfd
*, bfd
*));
181 #define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
182 #define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
183 static boolean som_bfd_is_local_label_name
PARAMS ((bfd
*, const char *));
184 static boolean som_set_section_contents
PARAMS ((bfd
*, sec_ptr
, PTR
,
185 file_ptr
, bfd_size_type
));
186 static boolean som_get_section_contents
PARAMS ((bfd
*, sec_ptr
, PTR
,
187 file_ptr
, bfd_size_type
));
188 static boolean som_set_arch_mach
PARAMS ((bfd
*, enum bfd_architecture
,
190 static boolean som_find_nearest_line
PARAMS ((bfd
*, asection
*,
195 static void som_get_symbol_info
PARAMS ((bfd
*, asymbol
*, symbol_info
*));
196 static asection
* bfd_section_from_som_symbol
PARAMS ((bfd
*,
197 struct symbol_dictionary_record
*));
198 static int log2
PARAMS ((unsigned int));
199 static bfd_reloc_status_type hppa_som_reloc
PARAMS ((bfd
*, arelent
*,
203 static void som_initialize_reloc_queue
PARAMS ((struct reloc_queue
*));
204 static void som_reloc_queue_insert
PARAMS ((unsigned char *, unsigned int,
205 struct reloc_queue
*));
206 static void som_reloc_queue_fix
PARAMS ((struct reloc_queue
*, unsigned int));
207 static int som_reloc_queue_find
PARAMS ((unsigned char *, unsigned int,
208 struct reloc_queue
*));
209 static unsigned char * try_prev_fixup
PARAMS ((bfd
*, int *, unsigned char *,
211 struct reloc_queue
*));
213 static unsigned char * som_reloc_skip
PARAMS ((bfd
*, unsigned int,
214 unsigned char *, unsigned int *,
215 struct reloc_queue
*));
216 static unsigned char * som_reloc_addend
PARAMS ((bfd
*, int, unsigned char *,
218 struct reloc_queue
*));
219 static unsigned char * som_reloc_call
PARAMS ((bfd
*, unsigned char *,
222 struct reloc_queue
*));
223 static unsigned long som_count_spaces
PARAMS ((bfd
*));
224 static unsigned long som_count_subspaces
PARAMS ((bfd
*));
225 static int compare_syms
PARAMS ((const void *, const void *));
226 static int compare_subspaces
PARAMS ((const void *, const void *));
227 static unsigned long som_compute_checksum
PARAMS ((bfd
*));
228 static boolean som_prep_headers
PARAMS ((bfd
*));
229 static int som_sizeof_headers
PARAMS ((bfd
*, boolean
));
230 static boolean som_finish_writing
PARAMS ((bfd
*));
231 static boolean som_build_and_write_symbol_table
PARAMS ((bfd
*));
232 static void som_prep_for_fixups
PARAMS ((bfd
*, asymbol
**, unsigned long));
233 static boolean som_write_fixups
PARAMS ((bfd
*, unsigned long, unsigned int *));
234 static boolean som_write_space_strings
PARAMS ((bfd
*, unsigned long,
236 static boolean som_write_symbol_strings
PARAMS ((bfd
*, unsigned long,
237 asymbol
**, unsigned int,
240 static boolean som_begin_writing
PARAMS ((bfd
*));
241 static reloc_howto_type
* som_bfd_reloc_type_lookup
242 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
243 static char som_section_type
PARAMS ((const char *));
244 static int som_decode_symclass
PARAMS ((asymbol
*));
245 static boolean som_bfd_count_ar_symbols
PARAMS ((bfd
*, struct lst_header
*,
248 static boolean som_bfd_fill_in_ar_symbols
PARAMS ((bfd
*, struct lst_header
*,
250 static boolean som_slurp_armap
PARAMS ((bfd
*));
251 static boolean som_write_armap
PARAMS ((bfd
*, unsigned int, struct orl
*,
253 static void som_bfd_derive_misc_symbol_info
PARAMS ((bfd
*, asymbol
*,
254 struct som_misc_symbol_info
*));
255 static boolean som_bfd_prep_for_ar_write
PARAMS ((bfd
*, unsigned int *,
257 static unsigned int som_bfd_ar_symbol_hash
PARAMS ((asymbol
*));
258 static boolean som_bfd_ar_write_symbol_stuff
PARAMS ((bfd
*, unsigned int,
262 static boolean som_is_space
PARAMS ((asection
*));
263 static boolean som_is_subspace
PARAMS ((asection
*));
264 static boolean som_is_container
PARAMS ((asection
*, asection
*));
265 static boolean som_bfd_free_cached_info
PARAMS ((bfd
*));
266 static boolean som_bfd_link_split_section
PARAMS ((bfd
*, asection
*));
268 /* Map SOM section names to POSIX/BSD single-character symbol types.
270 This table includes all the standard subspaces as defined in the
271 current "PRO ABI for PA-RISC Systems", $UNWIND$ which for
272 some reason was left out, and sections specific to embedded stabs. */
274 static const struct section_to_type stt
[] = {
276 {"$SHLIB_INFO$", 't'},
277 {"$MILLICODE$", 't'},
280 {"$UNWIND_START$", 't'},
284 {"$SHLIB_DATA$", 'd'},
286 {"$SHORTDATA$", 'g'},
291 {"$GDB_STRINGS$", 'N'},
292 {"$GDB_SYMBOLS$", 'N'},
296 /* About the relocation formatting table...
298 There are 256 entries in the table, one for each possible
299 relocation opcode available in SOM. We index the table by
300 the relocation opcode. The names and operations are those
301 defined by a.out_800 (4).
303 Right now this table is only used to count and perform minimal
304 processing on relocation streams so that they can be internalized
305 into BFD and symbolically printed by utilities. To make actual use
306 of them would be much more difficult, BFD's concept of relocations
307 is far too simple to handle SOM relocations. The basic assumption
308 that a relocation can be completely processed independent of other
309 relocations before an object file is written is invalid for SOM.
311 The SOM relocations are meant to be processed as a stream, they
312 specify copying of data from the input section to the output section
313 while possibly modifying the data in some manner. They also can
314 specify that a variable number of zeros or uninitialized data be
315 inserted on in the output segment at the current offset. Some
316 relocations specify that some previous relocation be re-applied at
317 the current location in the input/output sections. And finally a number
318 of relocations have effects on other sections (R_ENTRY, R_EXIT,
319 R_UNWIND_AUX and a variety of others). There isn't even enough room
320 in the BFD relocation data structure to store enough information to
321 perform all the relocations.
323 Each entry in the table has three fields.
325 The first entry is an index into this "class" of relocations. This
326 index can then be used as a variable within the relocation itself.
328 The second field is a format string which actually controls processing
329 of the relocation. It uses a simple postfix machine to do calculations
330 based on variables/constants found in the string and the relocation
333 The third field specifys whether or not this relocation may use
334 a constant (V) from the previous R_DATA_OVERRIDE rather than a constant
335 stored in the instruction.
339 L = input space byte count
340 D = index into class of relocations
341 M = output space byte count
342 N = statement number (unused?)
344 R = parameter relocation bits
346 T = first 32 bits of stack unwind information
347 U = second 32 bits of stack unwind information
348 V = a literal constant (usually used in the next relocation)
349 P = a previous relocation
351 Lower case letters (starting with 'b') refer to following
352 bytes in the relocation stream. 'b' is the next 1 byte,
353 c is the next 2 bytes, d is the next 3 bytes, etc...
354 This is the variable part of the relocation entries that
355 makes our life a living hell.
357 numerical constants are also used in the format string. Note
358 the constants are represented in decimal.
360 '+', "*" and "=" represents the obvious postfix operators.
361 '<' represents a left shift.
365 Parameter Relocation Bits:
369 Previous Relocations: The index field represents which in the queue
370 of 4 previous fixups should be re-applied.
372 Literal Constants: These are generally used to represent addend
373 parts of relocations when these constants are not stored in the
374 fields of the instructions themselves. For example the instruction
375 addil foo-$global$-0x1234 would use an override for "0x1234" rather
376 than storing it into the addil itself. */
378 struct fixup_format
{
383 static const struct fixup_format som_fixup_formats
[256] = {
384 /* R_NO_RELOCATION */
385 0, "LD1+4*=", /* 0x00 */
386 1, "LD1+4*=", /* 0x01 */
387 2, "LD1+4*=", /* 0x02 */
388 3, "LD1+4*=", /* 0x03 */
389 4, "LD1+4*=", /* 0x04 */
390 5, "LD1+4*=", /* 0x05 */
391 6, "LD1+4*=", /* 0x06 */
392 7, "LD1+4*=", /* 0x07 */
393 8, "LD1+4*=", /* 0x08 */
394 9, "LD1+4*=", /* 0x09 */
395 10, "LD1+4*=", /* 0x0a */
396 11, "LD1+4*=", /* 0x0b */
397 12, "LD1+4*=", /* 0x0c */
398 13, "LD1+4*=", /* 0x0d */
399 14, "LD1+4*=", /* 0x0e */
400 15, "LD1+4*=", /* 0x0f */
401 16, "LD1+4*=", /* 0x10 */
402 17, "LD1+4*=", /* 0x11 */
403 18, "LD1+4*=", /* 0x12 */
404 19, "LD1+4*=", /* 0x13 */
405 20, "LD1+4*=", /* 0x14 */
406 21, "LD1+4*=", /* 0x15 */
407 22, "LD1+4*=", /* 0x16 */
408 23, "LD1+4*=", /* 0x17 */
409 0, "LD8<b+1+4*=", /* 0x18 */
410 1, "LD8<b+1+4*=", /* 0x19 */
411 2, "LD8<b+1+4*=", /* 0x1a */
412 3, "LD8<b+1+4*=", /* 0x1b */
413 0, "LD16<c+1+4*=", /* 0x1c */
414 1, "LD16<c+1+4*=", /* 0x1d */
415 2, "LD16<c+1+4*=", /* 0x1e */
416 0, "Ld1+=", /* 0x1f */
418 0, "Lb1+4*=", /* 0x20 */
419 1, "Ld1+=", /* 0x21 */
421 0, "Lb1+4*=", /* 0x22 */
422 1, "Ld1+=", /* 0x23 */
425 /* R_DATA_ONE_SYMBOL */
426 0, "L4=Sb=", /* 0x25 */
427 1, "L4=Sd=", /* 0x26 */
429 0, "L4=Sb=", /* 0x27 */
430 1, "L4=Sd=", /* 0x28 */
433 /* R_REPEATED_INIT */
434 0, "L4=Mb1+4*=", /* 0x2a */
435 1, "Lb4*=Mb1+L*=", /* 0x2b */
436 2, "Lb4*=Md1+4*=", /* 0x2c */
437 3, "Ld1+=Me1+=", /* 0x2d */
441 0, "L4=RD=Sb=", /* 0x30 */
442 1, "L4=RD=Sb=", /* 0x31 */
443 2, "L4=RD=Sb=", /* 0x32 */
444 3, "L4=RD=Sb=", /* 0x33 */
445 4, "L4=RD=Sb=", /* 0x34 */
446 5, "L4=RD=Sb=", /* 0x35 */
447 6, "L4=RD=Sb=", /* 0x36 */
448 7, "L4=RD=Sb=", /* 0x37 */
449 8, "L4=RD=Sb=", /* 0x38 */
450 9, "L4=RD=Sb=", /* 0x39 */
451 0, "L4=RD8<b+=Sb=",/* 0x3a */
452 1, "L4=RD8<b+=Sb=",/* 0x3b */
453 0, "L4=RD8<b+=Sd=",/* 0x3c */
454 1, "L4=RD8<b+=Sd=",/* 0x3d */
455 /* R_SHORT_PCREL_MODE */
457 /* R_LONG_PCREL_MODE */
460 0, "L4=RD=Sb=", /* 0x40 */
461 1, "L4=RD=Sb=", /* 0x41 */
462 2, "L4=RD=Sb=", /* 0x42 */
463 3, "L4=RD=Sb=", /* 0x43 */
464 4, "L4=RD=Sb=", /* 0x44 */
465 5, "L4=RD=Sb=", /* 0x45 */
466 6, "L4=RD=Sb=", /* 0x46 */
467 7, "L4=RD=Sb=", /* 0x47 */
468 8, "L4=RD=Sb=", /* 0x48 */
469 9, "L4=RD=Sb=", /* 0x49 */
470 0, "L4=RD8<b+=Sb=",/* 0x4a */
471 1, "L4=RD8<b+=Sb=",/* 0x4b */
472 0, "L4=RD8<b+=Sd=",/* 0x4c */
473 1, "L4=RD8<b+=Sd=",/* 0x4d */
478 0, "L4=SD=", /* 0x50 */
479 1, "L4=SD=", /* 0x51 */
480 2, "L4=SD=", /* 0x52 */
481 3, "L4=SD=", /* 0x53 */
482 4, "L4=SD=", /* 0x54 */
483 5, "L4=SD=", /* 0x55 */
484 6, "L4=SD=", /* 0x56 */
485 7, "L4=SD=", /* 0x57 */
486 8, "L4=SD=", /* 0x58 */
487 9, "L4=SD=", /* 0x59 */
488 10, "L4=SD=", /* 0x5a */
489 11, "L4=SD=", /* 0x5b */
490 12, "L4=SD=", /* 0x5c */
491 13, "L4=SD=", /* 0x5d */
492 14, "L4=SD=", /* 0x5e */
493 15, "L4=SD=", /* 0x5f */
494 16, "L4=SD=", /* 0x60 */
495 17, "L4=SD=", /* 0x61 */
496 18, "L4=SD=", /* 0x62 */
497 19, "L4=SD=", /* 0x63 */
498 20, "L4=SD=", /* 0x64 */
499 21, "L4=SD=", /* 0x65 */
500 22, "L4=SD=", /* 0x66 */
501 23, "L4=SD=", /* 0x67 */
502 24, "L4=SD=", /* 0x68 */
503 25, "L4=SD=", /* 0x69 */
504 26, "L4=SD=", /* 0x6a */
505 27, "L4=SD=", /* 0x6b */
506 28, "L4=SD=", /* 0x6c */
507 29, "L4=SD=", /* 0x6d */
508 30, "L4=SD=", /* 0x6e */
509 31, "L4=SD=", /* 0x6f */
510 32, "L4=Sb=", /* 0x70 */
511 33, "L4=Sd=", /* 0x71 */
520 0, "L4=Sb=", /* 0x78 */
521 1, "L4=Sd=", /* 0x79 */
529 /* R_CODE_ONE_SYMBOL */
530 0, "L4=SD=", /* 0x80 */
531 1, "L4=SD=", /* 0x81 */
532 2, "L4=SD=", /* 0x82 */
533 3, "L4=SD=", /* 0x83 */
534 4, "L4=SD=", /* 0x84 */
535 5, "L4=SD=", /* 0x85 */
536 6, "L4=SD=", /* 0x86 */
537 7, "L4=SD=", /* 0x87 */
538 8, "L4=SD=", /* 0x88 */
539 9, "L4=SD=", /* 0x89 */
540 10, "L4=SD=", /* 0x8q */
541 11, "L4=SD=", /* 0x8b */
542 12, "L4=SD=", /* 0x8c */
543 13, "L4=SD=", /* 0x8d */
544 14, "L4=SD=", /* 0x8e */
545 15, "L4=SD=", /* 0x8f */
546 16, "L4=SD=", /* 0x90 */
547 17, "L4=SD=", /* 0x91 */
548 18, "L4=SD=", /* 0x92 */
549 19, "L4=SD=", /* 0x93 */
550 20, "L4=SD=", /* 0x94 */
551 21, "L4=SD=", /* 0x95 */
552 22, "L4=SD=", /* 0x96 */
553 23, "L4=SD=", /* 0x97 */
554 24, "L4=SD=", /* 0x98 */
555 25, "L4=SD=", /* 0x99 */
556 26, "L4=SD=", /* 0x9a */
557 27, "L4=SD=", /* 0x9b */
558 28, "L4=SD=", /* 0x9c */
559 29, "L4=SD=", /* 0x9d */
560 30, "L4=SD=", /* 0x9e */
561 31, "L4=SD=", /* 0x9f */
562 32, "L4=Sb=", /* 0xa0 */
563 33, "L4=Sd=", /* 0xa1 */
578 0, "L4=Sb=", /* 0xae */
579 1, "L4=Sd=", /* 0xaf */
581 0, "L4=Sb=", /* 0xb0 */
582 1, "L4=Sd=", /* 0xb1 */
586 0, "Te=Ue=", /* 0xb3 */
596 1, "Rb4*=", /* 0xb9 */
597 2, "Rd4*=", /* 0xba */
624 /* R_DATA_OVERRIDE */
633 0, "Sd=Vf=Ef=", /* 0xcf */
637 0, "Ob=Sd=", /* 0xd1 */
639 0, "Ob=Ve=", /* 0xd2 */
652 0, "Eb=Sd=Ve=", /* 0xda */
654 0, "Eb=Mb=", /* 0xdb */
658 0, "Ob=Ve=", /* 0xdd */
696 static const int comp1_opcodes
[] = {
717 static const int comp2_opcodes
[] = {
725 static const int comp3_opcodes
[] = {
731 /* These apparently are not in older versions of hpux reloc.h (hpux7). */
733 #define R_DLT_REL 0x78
737 #define R_AUX_UNWIND 0xcf
741 #define R_SEC_STMT 0xd7
744 /* And these first appeared in hpux10. */
745 #ifndef R_SHORT_PCREL_MODE
746 #define NO_PCREL_MODES
747 #define R_SHORT_PCREL_MODE 0x3e
750 #ifndef R_LONG_PCREL_MODE
751 #define R_LONG_PCREL_MODE 0x3f
763 #define R_LINETAB 0xda
766 #ifndef R_LINETAB_ESC
767 #define R_LINETAB_ESC 0xdb
770 #ifndef R_LTP_OVERRIDE
771 #define R_LTP_OVERRIDE 0xdc
775 #define R_COMMENT 0xdd
778 #define SOM_HOWTO(TYPE, NAME) \
779 HOWTO(TYPE, 0, 0, 32, false, 0, 0, hppa_som_reloc, NAME, false, 0, 0, false)
781 static reloc_howto_type som_hppa_howto_table
[] = {
782 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
783 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
784 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
785 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
786 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
787 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
788 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
789 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
790 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
791 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
792 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
793 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
794 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
795 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
796 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
797 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
798 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
799 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
800 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
801 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
802 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
803 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
804 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
805 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
806 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
807 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
808 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
809 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
810 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
811 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
812 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
813 SOM_HOWTO (R_NO_RELOCATION
, "R_NO_RELOCATION"),
814 SOM_HOWTO (R_ZEROES
, "R_ZEROES"),
815 SOM_HOWTO (R_ZEROES
, "R_ZEROES"),
816 SOM_HOWTO (R_UNINIT
, "R_UNINIT"),
817 SOM_HOWTO (R_UNINIT
, "R_UNINIT"),
818 SOM_HOWTO (R_RELOCATION
, "R_RELOCATION"),
819 SOM_HOWTO (R_DATA_ONE_SYMBOL
, "R_DATA_ONE_SYMBOL"),
820 SOM_HOWTO (R_DATA_ONE_SYMBOL
, "R_DATA_ONE_SYMBOL"),
821 SOM_HOWTO (R_DATA_PLABEL
, "R_DATA_PLABEL"),
822 SOM_HOWTO (R_DATA_PLABEL
, "R_DATA_PLABEL"),
823 SOM_HOWTO (R_SPACE_REF
, "R_SPACE_REF"),
824 SOM_HOWTO (R_REPEATED_INIT
, "REPEATED_INIT"),
825 SOM_HOWTO (R_REPEATED_INIT
, "REPEATED_INIT"),
826 SOM_HOWTO (R_REPEATED_INIT
, "REPEATED_INIT"),
827 SOM_HOWTO (R_REPEATED_INIT
, "REPEATED_INIT"),
828 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
829 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
830 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
831 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
832 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
833 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
834 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
835 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
836 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
837 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
838 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
839 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
840 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
841 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
842 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
843 SOM_HOWTO (R_PCREL_CALL
, "R_PCREL_CALL"),
844 SOM_HOWTO (R_SHORT_PCREL_MODE
, "R_SHORT_PCREL_MODE"),
845 SOM_HOWTO (R_LONG_PCREL_MODE
, "R_LONG_PCREL_MODE"),
846 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
847 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
848 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
849 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
850 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
851 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
852 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
853 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
854 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
855 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
856 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
857 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
858 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
859 SOM_HOWTO (R_ABS_CALL
, "R_ABS_CALL"),
860 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
861 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
862 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
863 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
864 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
865 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
866 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
867 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
868 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
869 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
870 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
871 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
872 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
873 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
874 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
875 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
876 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
877 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
878 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
879 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
880 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
881 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
882 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
883 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
884 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
885 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
886 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
887 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
888 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
889 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
890 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
891 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
892 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
893 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
894 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
895 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
896 SOM_HOWTO (R_DP_RELATIVE
, "R_DP_RELATIVE"),
897 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
898 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
899 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
900 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
901 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
902 SOM_HOWTO (R_DLT_REL
, "R_DLT_REL"),
903 SOM_HOWTO (R_DLT_REL
, "R_DLT_REL"),
904 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
905 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
906 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
907 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
908 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
909 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
910 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
911 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
912 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
913 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
914 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
915 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
916 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
917 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
918 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
919 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
920 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
921 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
922 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
923 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
924 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
925 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
926 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
927 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
928 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
929 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
930 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
931 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
932 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
933 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
934 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
935 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
936 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
937 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
938 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
939 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
940 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
941 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
942 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
943 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
944 SOM_HOWTO (R_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
945 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
946 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
947 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
948 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
949 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
950 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
951 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
952 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
953 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
954 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
955 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
956 SOM_HOWTO (R_MILLI_REL
, "R_MILLI_REL"),
957 SOM_HOWTO (R_MILLI_REL
, "R_MILLI_REL"),
958 SOM_HOWTO (R_CODE_PLABEL
, "R_CODE_PLABEL"),
959 SOM_HOWTO (R_CODE_PLABEL
, "R_CODE_PLABEL"),
960 SOM_HOWTO (R_BREAKPOINT
, "R_BREAKPOINT"),
961 SOM_HOWTO (R_ENTRY
, "R_ENTRY"),
962 SOM_HOWTO (R_ENTRY
, "R_ENTRY"),
963 SOM_HOWTO (R_ALT_ENTRY
, "R_ALT_ENTRY"),
964 SOM_HOWTO (R_EXIT
, "R_EXIT"),
965 SOM_HOWTO (R_BEGIN_TRY
, "R_BEGIN_TRY"),
966 SOM_HOWTO (R_END_TRY
, "R_END_TRY"),
967 SOM_HOWTO (R_END_TRY
, "R_END_TRY"),
968 SOM_HOWTO (R_END_TRY
, "R_END_TRY"),
969 SOM_HOWTO (R_BEGIN_BRTAB
, "R_BEGIN_BRTAB"),
970 SOM_HOWTO (R_END_BRTAB
, "R_END_BRTAB"),
971 SOM_HOWTO (R_STATEMENT
, "R_STATEMENT"),
972 SOM_HOWTO (R_STATEMENT
, "R_STATEMENT"),
973 SOM_HOWTO (R_STATEMENT
, "R_STATEMENT"),
974 SOM_HOWTO (R_DATA_EXPR
, "R_DATA_EXPR"),
975 SOM_HOWTO (R_CODE_EXPR
, "R_CODE_EXPR"),
976 SOM_HOWTO (R_FSEL
, "R_FSEL"),
977 SOM_HOWTO (R_LSEL
, "R_LSEL"),
978 SOM_HOWTO (R_RSEL
, "R_RSEL"),
979 SOM_HOWTO (R_N_MODE
, "R_N_MODE"),
980 SOM_HOWTO (R_S_MODE
, "R_S_MODE"),
981 SOM_HOWTO (R_D_MODE
, "R_D_MODE"),
982 SOM_HOWTO (R_R_MODE
, "R_R_MODE"),
983 SOM_HOWTO (R_DATA_OVERRIDE
, "R_DATA_OVERRIDE"),
984 SOM_HOWTO (R_DATA_OVERRIDE
, "R_DATA_OVERRIDE"),
985 SOM_HOWTO (R_DATA_OVERRIDE
, "R_DATA_OVERRIDE"),
986 SOM_HOWTO (R_DATA_OVERRIDE
, "R_DATA_OVERRIDE"),
987 SOM_HOWTO (R_DATA_OVERRIDE
, "R_DATA_OVERRIDE"),
988 SOM_HOWTO (R_TRANSLATED
, "R_TRANSLATED"),
989 SOM_HOWTO (R_AUX_UNWIND
, "R_AUX_UNWIND"),
990 SOM_HOWTO (R_COMP1
, "R_COMP1"),
991 SOM_HOWTO (R_COMP2
, "R_COMP2"),
992 SOM_HOWTO (R_COMP3
, "R_COMP3"),
993 SOM_HOWTO (R_PREV_FIXUP
, "R_PREV_FIXUP"),
994 SOM_HOWTO (R_PREV_FIXUP
, "R_PREV_FIXUP"),
995 SOM_HOWTO (R_PREV_FIXUP
, "R_PREV_FIXUP"),
996 SOM_HOWTO (R_PREV_FIXUP
, "R_PREV_FIXUP"),
997 SOM_HOWTO (R_SEC_STMT
, "R_SEC_STMT"),
998 SOM_HOWTO (R_N0SEL
, "R_N0SEL"),
999 SOM_HOWTO (R_N1SEL
, "R_N1SEL"),
1000 SOM_HOWTO (R_LINETAB
, "R_LINETAB"),
1001 SOM_HOWTO (R_LINETAB_ESC
, "R_LINETAB_ESC"),
1002 SOM_HOWTO (R_LTP_OVERRIDE
, "R_LTP_OVERRIDE"),
1003 SOM_HOWTO (R_COMMENT
, "R_COMMENT"),
1004 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1005 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1006 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1007 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1008 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1009 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1010 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1011 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1012 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1013 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1014 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1015 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1016 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1017 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1018 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1019 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1020 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1021 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1022 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1023 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1024 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1025 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1026 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1027 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1028 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1029 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1030 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1031 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1032 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1033 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1034 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1035 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1036 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
1037 SOM_HOWTO (R_RESERVED
, "R_RESERVED")
1040 /* Initialize the SOM relocation queue. By definition the queue holds
1041 the last four multibyte fixups. */
1044 som_initialize_reloc_queue (queue
)
1045 struct reloc_queue
*queue
;
1047 queue
[0].reloc
= NULL
;
1049 queue
[1].reloc
= NULL
;
1051 queue
[2].reloc
= NULL
;
1053 queue
[3].reloc
= NULL
;
1057 /* Insert a new relocation into the relocation queue. */
1060 som_reloc_queue_insert (p
, size
, queue
)
1063 struct reloc_queue
*queue
;
1065 queue
[3].reloc
= queue
[2].reloc
;
1066 queue
[3].size
= queue
[2].size
;
1067 queue
[2].reloc
= queue
[1].reloc
;
1068 queue
[2].size
= queue
[1].size
;
1069 queue
[1].reloc
= queue
[0].reloc
;
1070 queue
[1].size
= queue
[0].size
;
1072 queue
[0].size
= size
;
1075 /* When an entry in the relocation queue is reused, the entry moves
1076 to the front of the queue. */
1079 som_reloc_queue_fix (queue
, index
)
1080 struct reloc_queue
*queue
;
1088 unsigned char *tmp1
= queue
[0].reloc
;
1089 unsigned int tmp2
= queue
[0].size
;
1090 queue
[0].reloc
= queue
[1].reloc
;
1091 queue
[0].size
= queue
[1].size
;
1092 queue
[1].reloc
= tmp1
;
1093 queue
[1].size
= tmp2
;
1099 unsigned char *tmp1
= queue
[0].reloc
;
1100 unsigned int tmp2
= queue
[0].size
;
1101 queue
[0].reloc
= queue
[2].reloc
;
1102 queue
[0].size
= queue
[2].size
;
1103 queue
[2].reloc
= queue
[1].reloc
;
1104 queue
[2].size
= queue
[1].size
;
1105 queue
[1].reloc
= tmp1
;
1106 queue
[1].size
= tmp2
;
1112 unsigned char *tmp1
= queue
[0].reloc
;
1113 unsigned int tmp2
= queue
[0].size
;
1114 queue
[0].reloc
= queue
[3].reloc
;
1115 queue
[0].size
= queue
[3].size
;
1116 queue
[3].reloc
= queue
[2].reloc
;
1117 queue
[3].size
= queue
[2].size
;
1118 queue
[2].reloc
= queue
[1].reloc
;
1119 queue
[2].size
= queue
[1].size
;
1120 queue
[1].reloc
= tmp1
;
1121 queue
[1].size
= tmp2
;
1127 /* Search for a particular relocation in the relocation queue. */
1130 som_reloc_queue_find (p
, size
, queue
)
1133 struct reloc_queue
*queue
;
1135 if (queue
[0].reloc
&& !memcmp (p
, queue
[0].reloc
, size
)
1136 && size
== queue
[0].size
)
1138 if (queue
[1].reloc
&& !memcmp (p
, queue
[1].reloc
, size
)
1139 && size
== queue
[1].size
)
1141 if (queue
[2].reloc
&& !memcmp (p
, queue
[2].reloc
, size
)
1142 && size
== queue
[2].size
)
1144 if (queue
[3].reloc
&& !memcmp (p
, queue
[3].reloc
, size
)
1145 && size
== queue
[3].size
)
1150 static unsigned char *
1151 try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, size
, queue
)
1152 bfd
*abfd ATTRIBUTE_UNUSED
;
1153 int *subspace_reloc_sizep
;
1156 struct reloc_queue
*queue
;
1158 int queue_index
= som_reloc_queue_find (p
, size
, queue
);
1160 if (queue_index
!= -1)
1162 /* Found this in a previous fixup. Undo the fixup we
1163 just built and use R_PREV_FIXUP instead. We saved
1164 a total of size - 1 bytes in the fixup stream. */
1165 bfd_put_8 (abfd
, R_PREV_FIXUP
+ queue_index
, p
);
1167 *subspace_reloc_sizep
+= 1;
1168 som_reloc_queue_fix (queue
, queue_index
);
1172 som_reloc_queue_insert (p
, size
, queue
);
1173 *subspace_reloc_sizep
+= size
;
1179 /* Emit the proper R_NO_RELOCATION fixups to map the next SKIP
1180 bytes without any relocation. Update the size of the subspace
1181 relocation stream via SUBSPACE_RELOC_SIZE_P; also return the
1182 current pointer into the relocation stream. */
1184 static unsigned char *
1185 som_reloc_skip (abfd
, skip
, p
, subspace_reloc_sizep
, queue
)
1189 unsigned int *subspace_reloc_sizep
;
1190 struct reloc_queue
*queue
;
1192 /* Use a 4 byte R_NO_RELOCATION entry with a maximal value
1193 then R_PREV_FIXUPs to get the difference down to a
1195 if (skip
>= 0x1000000)
1198 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 31, p
);
1199 bfd_put_8 (abfd
, 0xff, p
+ 1);
1200 bfd_put_16 (abfd
, 0xffff, p
+ 2);
1201 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 4, queue
);
1202 while (skip
>= 0x1000000)
1205 bfd_put_8 (abfd
, R_PREV_FIXUP
, p
);
1207 *subspace_reloc_sizep
+= 1;
1208 /* No need to adjust queue here since we are repeating the
1209 most recent fixup. */
1213 /* The difference must be less than 0x1000000. Use one
1214 more R_NO_RELOCATION entry to get to the right difference. */
1215 if ((skip
& 3) == 0 && skip
<= 0xc0000 && skip
> 0)
1217 /* Difference can be handled in a simple single-byte
1218 R_NO_RELOCATION entry. */
1221 bfd_put_8 (abfd
, R_NO_RELOCATION
+ (skip
>> 2) - 1, p
);
1222 *subspace_reloc_sizep
+= 1;
1225 /* Handle it with a two byte R_NO_RELOCATION entry. */
1226 else if (skip
<= 0x1000)
1228 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 24 + (((skip
>> 2) - 1) >> 8), p
);
1229 bfd_put_8 (abfd
, (skip
>> 2) - 1, p
+ 1);
1230 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 2, queue
);
1232 /* Handle it with a three byte R_NO_RELOCATION entry. */
1235 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 28 + (((skip
>> 2) - 1) >> 16), p
);
1236 bfd_put_16 (abfd
, (skip
>> 2) - 1, p
+ 1);
1237 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 3, queue
);
1240 /* Ugh. Punt and use a 4 byte entry. */
1243 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 31, p
);
1244 bfd_put_8 (abfd
, (skip
- 1) >> 16, p
+ 1);
1245 bfd_put_16 (abfd
, skip
- 1, p
+ 2);
1246 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 4, queue
);
1251 /* Emit the proper R_DATA_OVERRIDE fixups to handle a nonzero addend
1252 from a BFD relocation. Update the size of the subspace relocation
1253 stream via SUBSPACE_RELOC_SIZE_P; also return the current pointer
1254 into the relocation stream. */
1256 static unsigned char *
1257 som_reloc_addend (abfd
, addend
, p
, subspace_reloc_sizep
, queue
)
1261 unsigned int *subspace_reloc_sizep
;
1262 struct reloc_queue
*queue
;
1264 if ((unsigned) (addend
) + 0x80 < 0x100)
1266 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 1, p
);
1267 bfd_put_8 (abfd
, addend
, p
+ 1);
1268 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 2, queue
);
1270 else if ((unsigned) (addend
) + 0x8000 < 0x10000)
1272 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 2, p
);
1273 bfd_put_16 (abfd
, addend
, p
+ 1);
1274 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 3, queue
);
1276 else if ((unsigned) (addend
) + 0x800000 < 0x1000000)
1278 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 3, p
);
1279 bfd_put_8 (abfd
, addend
>> 16, p
+ 1);
1280 bfd_put_16 (abfd
, addend
, p
+ 2);
1281 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 4, queue
);
1285 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 4, p
);
1286 bfd_put_32 (abfd
, addend
, p
+ 1);
1287 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 5, queue
);
1292 /* Handle a single function call relocation. */
1294 static unsigned char *
1295 som_reloc_call (abfd
, p
, subspace_reloc_sizep
, bfd_reloc
, sym_num
, queue
)
1298 unsigned int *subspace_reloc_sizep
;
1301 struct reloc_queue
*queue
;
1303 int arg_bits
= HPPA_R_ARG_RELOC (bfd_reloc
->addend
);
1304 int rtn_bits
= arg_bits
& 0x3;
1307 /* You'll never believe all this is necessary to handle relocations
1308 for function calls. Having to compute and pack the argument
1309 relocation bits is the real nightmare.
1311 If you're interested in how this works, just forget it. You really
1312 do not want to know about this braindamage. */
1314 /* First see if this can be done with a "simple" relocation. Simple
1315 relocations have a symbol number < 0x100 and have simple encodings
1316 of argument relocations. */
1318 if (sym_num
< 0x100)
1330 case 1 << 8 | 1 << 6:
1331 case 1 << 8 | 1 << 6 | 1:
1334 case 1 << 8 | 1 << 6 | 1 << 4:
1335 case 1 << 8 | 1 << 6 | 1 << 4 | 1:
1338 case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2:
1339 case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2 | 1:
1343 /* Not one of the easy encodings. This will have to be
1344 handled by the more complex code below. */
1350 /* Account for the return value too. */
1354 /* Emit a 2 byte relocation. Then see if it can be handled
1355 with a relocation which is already in the relocation queue. */
1356 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ type
, p
);
1357 bfd_put_8 (abfd
, sym_num
, p
+ 1);
1358 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 2, queue
);
1363 /* If this could not be handled with a simple relocation, then do a hard
1364 one. Hard relocations occur if the symbol number was too high or if
1365 the encoding of argument relocation bits is too complex. */
1368 /* Don't ask about these magic sequences. I took them straight
1369 from gas-1.36 which took them from the a.out man page. */
1371 if ((arg_bits
>> 6 & 0xf) == 0xe)
1374 type
+= (3 * (arg_bits
>> 8 & 3) + (arg_bits
>> 6 & 3)) * 40;
1375 if ((arg_bits
>> 2 & 0xf) == 0xe)
1378 type
+= (3 * (arg_bits
>> 4 & 3) + (arg_bits
>> 2 & 3)) * 4;
1380 /* Output the first two bytes of the relocation. These describe
1381 the length of the relocation and encoding style. */
1382 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 10
1383 + 2 * (sym_num
>= 0x100) + (type
>= 0x100),
1385 bfd_put_8 (abfd
, type
, p
+ 1);
1387 /* Now output the symbol index and see if this bizarre relocation
1388 just happened to be in the relocation queue. */
1389 if (sym_num
< 0x100)
1391 bfd_put_8 (abfd
, sym_num
, p
+ 2);
1392 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 3, queue
);
1396 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 2);
1397 bfd_put_16 (abfd
, sym_num
, p
+ 3);
1398 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 5, queue
);
1404 /* Return the logarithm of X, base 2, considering X unsigned.
1405 Abort -1 if X is not a power or two or is zero. */
1413 /* Test for 0 or a power of 2. */
1414 if (x
== 0 || x
!= (x
& -x
))
1417 while ((x
>>= 1) != 0)
1422 static bfd_reloc_status_type
1423 hppa_som_reloc (abfd
, reloc_entry
, symbol_in
, data
,
1424 input_section
, output_bfd
, error_message
)
1425 bfd
*abfd ATTRIBUTE_UNUSED
;
1426 arelent
*reloc_entry
;
1427 asymbol
*symbol_in ATTRIBUTE_UNUSED
;
1428 PTR data ATTRIBUTE_UNUSED
;
1429 asection
*input_section
;
1431 char **error_message ATTRIBUTE_UNUSED
;
1435 reloc_entry
->address
+= input_section
->output_offset
;
1436 return bfd_reloc_ok
;
1438 return bfd_reloc_ok
;
1441 /* Given a generic HPPA relocation type, the instruction format,
1442 and a field selector, return one or more appropriate SOM relocations. */
1445 hppa_som_gen_reloc_type (abfd
, base_type
, format
, field
, sym_diff
, sym
)
1449 enum hppa_reloc_field_selector_type_alt field
;
1453 int *final_type
, **final_types
;
1455 final_types
= (int **) bfd_alloc (abfd
, sizeof (int *) * 6);
1456 final_type
= (int *) bfd_alloc (abfd
, sizeof (int));
1457 if (!final_types
|| !final_type
)
1460 /* The field selector may require additional relocations to be
1461 generated. It's impossible to know at this moment if additional
1462 relocations will be needed, so we make them. The code to actually
1463 write the relocation/fixup stream is responsible for removing
1464 any redundant relocations. */
1471 final_types
[0] = final_type
;
1472 final_types
[1] = NULL
;
1473 final_types
[2] = NULL
;
1474 *final_type
= base_type
;
1480 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1481 if (!final_types
[0])
1483 if (field
== e_tsel
)
1484 *final_types
[0] = R_FSEL
;
1485 else if (field
== e_ltsel
)
1486 *final_types
[0] = R_LSEL
;
1488 *final_types
[0] = R_RSEL
;
1489 final_types
[1] = final_type
;
1490 final_types
[2] = NULL
;
1491 *final_type
= base_type
;
1496 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1497 if (!final_types
[0])
1499 *final_types
[0] = R_S_MODE
;
1500 final_types
[1] = final_type
;
1501 final_types
[2] = NULL
;
1502 *final_type
= base_type
;
1507 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1508 if (!final_types
[0])
1510 *final_types
[0] = R_N_MODE
;
1511 final_types
[1] = final_type
;
1512 final_types
[2] = NULL
;
1513 *final_type
= base_type
;
1518 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1519 if (!final_types
[0])
1521 *final_types
[0] = R_D_MODE
;
1522 final_types
[1] = final_type
;
1523 final_types
[2] = NULL
;
1524 *final_type
= base_type
;
1529 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1530 if (!final_types
[0])
1532 *final_types
[0] = R_R_MODE
;
1533 final_types
[1] = final_type
;
1534 final_types
[2] = NULL
;
1535 *final_type
= base_type
;
1539 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1540 if (!final_types
[0])
1542 *final_types
[0] = R_N1SEL
;
1543 final_types
[1] = final_type
;
1544 final_types
[2] = NULL
;
1545 *final_type
= base_type
;
1550 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1551 if (!final_types
[0])
1553 *final_types
[0] = R_N0SEL
;
1554 final_types
[1] = (int *) bfd_alloc (abfd
, sizeof (int));
1555 if (!final_types
[1])
1557 if (field
== e_nlsel
)
1558 *final_types
[1] = R_N_MODE
;
1560 *final_types
[1] = R_R_MODE
;
1561 final_types
[2] = final_type
;
1562 final_types
[3] = NULL
;
1563 *final_type
= base_type
;
1570 /* The difference of two symbols needs *very* special handling. */
1573 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1574 final_types
[1] = (int *) bfd_alloc (abfd
, sizeof (int));
1575 final_types
[2] = (int *) bfd_alloc (abfd
, sizeof (int));
1576 final_types
[3] = (int *) bfd_alloc (abfd
, sizeof (int));
1577 if (!final_types
[0] || !final_types
[1] || !final_types
[2])
1579 if (field
== e_fsel
)
1580 *final_types
[0] = R_FSEL
;
1581 else if (field
== e_rsel
)
1582 *final_types
[0] = R_RSEL
;
1583 else if (field
== e_lsel
)
1584 *final_types
[0] = R_LSEL
;
1585 *final_types
[1] = R_COMP2
;
1586 *final_types
[2] = R_COMP2
;
1587 *final_types
[3] = R_COMP1
;
1588 final_types
[4] = final_type
;
1590 *final_types
[4] = R_DATA_EXPR
;
1592 *final_types
[4] = R_CODE_EXPR
;
1593 final_types
[5] = NULL
;
1596 /* PLABELs get their own relocation type. */
1597 else if (field
== e_psel
1599 || field
== e_rpsel
)
1601 /* A PLABEL relocation that has a size of 32 bits must
1602 be a R_DATA_PLABEL. All others are R_CODE_PLABELs. */
1604 *final_type
= R_DATA_PLABEL
;
1606 *final_type
= R_CODE_PLABEL
;
1609 else if (field
== e_tsel
1611 || field
== e_rtsel
)
1612 *final_type
= R_DLT_REL
;
1613 /* A relocation in the data space is always a full 32bits. */
1614 else if (format
== 32)
1616 *final_type
= R_DATA_ONE_SYMBOL
;
1618 /* If there's no SOM symbol type associated with this BFD
1619 symbol, then set the symbol type to ST_DATA.
1621 Only do this if the type is going to default later when
1622 we write the object file.
1624 This is done so that the linker never encounters an
1625 R_DATA_ONE_SYMBOL reloc involving an ST_CODE symbol.
1627 This allows the compiler to generate exception handling
1630 Note that one day we may need to also emit BEGIN_BRTAB and
1631 END_BRTAB to prevent the linker from optimizing away insns
1632 in exception handling regions. */
1633 if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
1634 && (sym
->flags
& BSF_SECTION_SYM
) == 0
1635 && (sym
->flags
& BSF_FUNCTION
) == 0
1636 && ! bfd_is_com_section (sym
->section
))
1637 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_DATA
;
1642 /* More PLABEL special cases. */
1645 || field
== e_rpsel
)
1646 *final_type
= R_DATA_PLABEL
;
1649 case R_HPPA_COMPLEX
:
1650 /* The difference of two symbols needs *very* special handling. */
1653 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1654 final_types
[1] = (int *) bfd_alloc (abfd
, sizeof (int));
1655 final_types
[2] = (int *) bfd_alloc (abfd
, sizeof (int));
1656 final_types
[3] = (int *) bfd_alloc (abfd
, sizeof (int));
1657 if (!final_types
[0] || !final_types
[1] || !final_types
[2])
1659 if (field
== e_fsel
)
1660 *final_types
[0] = R_FSEL
;
1661 else if (field
== e_rsel
)
1662 *final_types
[0] = R_RSEL
;
1663 else if (field
== e_lsel
)
1664 *final_types
[0] = R_LSEL
;
1665 *final_types
[1] = R_COMP2
;
1666 *final_types
[2] = R_COMP2
;
1667 *final_types
[3] = R_COMP1
;
1668 final_types
[4] = final_type
;
1670 *final_types
[4] = R_DATA_EXPR
;
1672 *final_types
[4] = R_CODE_EXPR
;
1673 final_types
[5] = NULL
;
1680 case R_HPPA_ABS_CALL
:
1681 /* Right now we can default all these. */
1684 case R_HPPA_PCREL_CALL
:
1686 #ifndef NO_PCREL_MODES
1687 /* If we have short and long pcrel modes, then generate the proper
1688 mode selector, then the pcrel relocation. Redundant selectors
1689 will be eliminted as the relocs are sized and emitted. */
1690 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1691 if (!final_types
[0])
1694 *final_types
[0] = R_SHORT_PCREL_MODE
;
1696 *final_types
[0] = R_LONG_PCREL_MODE
;
1697 final_types
[1] = final_type
;
1698 final_types
[2] = NULL
;
1699 *final_type
= base_type
;
1707 /* Return the address of the correct entry in the PA SOM relocation
1710 static reloc_howto_type
*
1711 som_bfd_reloc_type_lookup (abfd
, code
)
1712 bfd
*abfd ATTRIBUTE_UNUSED
;
1713 bfd_reloc_code_real_type code
;
1715 if ((int) code
< (int) R_NO_RELOCATION
+ 255)
1717 BFD_ASSERT ((int) som_hppa_howto_table
[(int) code
].type
== (int) code
);
1718 return &som_hppa_howto_table
[(int) code
];
1721 return (reloc_howto_type
*) 0;
1724 /* Perform some initialization for an object. Save results of this
1725 initialization in the BFD. */
1727 static const bfd_target
*
1728 som_object_setup (abfd
, file_hdrp
, aux_hdrp
, current_offset
)
1730 struct header
*file_hdrp
;
1731 struct som_exec_auxhdr
*aux_hdrp
;
1732 unsigned long current_offset
;
1737 /* som_mkobject will set bfd_error if som_mkobject fails. */
1738 if (som_mkobject (abfd
) != true)
1741 /* Set BFD flags based on what information is available in the SOM. */
1742 abfd
->flags
= BFD_NO_FLAGS
;
1743 if (file_hdrp
->symbol_total
)
1744 abfd
->flags
|= HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
;
1746 switch (file_hdrp
->a_magic
)
1749 abfd
->flags
|= (D_PAGED
| WP_TEXT
| EXEC_P
);
1752 abfd
->flags
|= (WP_TEXT
| EXEC_P
);
1755 abfd
->flags
|= (EXEC_P
);
1758 abfd
->flags
|= HAS_RELOC
;
1766 abfd
->flags
|= DYNAMIC
;
1773 /* Allocate space to hold the saved exec header information. */
1774 obj_som_exec_data (abfd
) = (struct som_exec_data
*)
1775 bfd_zalloc (abfd
, sizeof (struct som_exec_data
));
1776 if (obj_som_exec_data (abfd
) == NULL
)
1779 /* The braindamaged OSF1 linker switched exec_flags and exec_entry!
1781 We used to identify OSF1 binaries based on NEW_VERSION_ID, but
1782 apparently the latest HPUX linker is using NEW_VERSION_ID now.
1784 It's about time, OSF has used the new id since at least 1992;
1785 HPUX didn't start till nearly 1995!.
1787 The new approach examines the entry field. If it's zero or not 4
1788 byte aligned then it's not a proper code address and we guess it's
1789 really the executable flags. */
1791 for (section
= abfd
->sections
; section
; section
= section
->next
)
1793 if ((section
->flags
& SEC_CODE
) == 0)
1795 if (aux_hdrp
->exec_entry
>= section
->vma
1796 && aux_hdrp
->exec_entry
< section
->vma
+ section
->_cooked_size
)
1799 if (aux_hdrp
->exec_entry
== 0
1800 || (aux_hdrp
->exec_entry
& 0x3) != 0
1803 bfd_get_start_address (abfd
) = aux_hdrp
->exec_flags
;
1804 obj_som_exec_data (abfd
)->exec_flags
= aux_hdrp
->exec_entry
;
1808 bfd_get_start_address (abfd
) = aux_hdrp
->exec_entry
+ current_offset
;
1809 obj_som_exec_data (abfd
)->exec_flags
= aux_hdrp
->exec_flags
;
1812 bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, pa10
);
1813 bfd_get_symcount (abfd
) = file_hdrp
->symbol_total
;
1815 /* Initialize the saved symbol table and string table to NULL.
1816 Save important offsets and sizes from the SOM header into
1818 obj_som_stringtab (abfd
) = (char *) NULL
;
1819 obj_som_symtab (abfd
) = (som_symbol_type
*) NULL
;
1820 obj_som_sorted_syms (abfd
) = NULL
;
1821 obj_som_stringtab_size (abfd
) = file_hdrp
->symbol_strings_size
;
1822 obj_som_sym_filepos (abfd
) = file_hdrp
->symbol_location
+ current_offset
;
1823 obj_som_str_filepos (abfd
) = (file_hdrp
->symbol_strings_location
1825 obj_som_reloc_filepos (abfd
) = (file_hdrp
->fixup_request_location
1827 obj_som_exec_data (abfd
)->system_id
= file_hdrp
->system_id
;
1832 /* Convert all of the space and subspace info into BFD sections. Each space
1833 contains a number of subspaces, which in turn describe the mapping between
1834 regions of the exec file, and the address space that the program runs in.
1835 BFD sections which correspond to spaces will overlap the sections for the
1836 associated subspaces. */
1839 setup_sections (abfd
, file_hdr
, current_offset
)
1841 struct header
*file_hdr
;
1842 unsigned long current_offset
;
1844 char *space_strings
;
1845 unsigned int space_index
, i
;
1846 unsigned int total_subspaces
= 0;
1847 asection
**subspace_sections
, *section
;
1849 /* First, read in space names. */
1851 space_strings
= bfd_malloc (file_hdr
->space_strings_size
);
1852 if (!space_strings
&& file_hdr
->space_strings_size
!= 0)
1855 if (bfd_seek (abfd
, current_offset
+ file_hdr
->space_strings_location
,
1858 if (bfd_read (space_strings
, 1, file_hdr
->space_strings_size
, abfd
)
1859 != file_hdr
->space_strings_size
)
1862 /* Loop over all of the space dictionaries, building up sections. */
1863 for (space_index
= 0; space_index
< file_hdr
->space_total
; space_index
++)
1865 struct space_dictionary_record space
;
1866 struct subspace_dictionary_record subspace
, save_subspace
;
1868 asection
*space_asect
;
1871 /* Read the space dictionary element. */
1873 (current_offset
+ file_hdr
->space_location
1874 + space_index
* sizeof space
),
1877 if (bfd_read (&space
, 1, sizeof space
, abfd
) != sizeof space
)
1880 /* Setup the space name string. */
1881 space
.name
.n_name
= space
.name
.n_strx
+ space_strings
;
1883 /* Make a section out of it. */
1884 newname
= bfd_alloc (abfd
, strlen (space
.name
.n_name
) + 1);
1887 strcpy (newname
, space
.name
.n_name
);
1889 space_asect
= bfd_make_section_anyway (abfd
, newname
);
1893 if (space
.is_loadable
== 0)
1894 space_asect
->flags
|= SEC_DEBUGGING
;
1896 /* Set up all the attributes for the space. */
1897 if (bfd_som_set_section_attributes (space_asect
, space
.is_defined
,
1898 space
.is_private
, space
.sort_key
,
1899 space
.space_number
) == false)
1902 /* If the space has no subspaces, then we're done. */
1903 if (space
.subspace_quantity
== 0)
1906 /* Now, read in the first subspace for this space. */
1908 (current_offset
+ file_hdr
->subspace_location
1909 + space
.subspace_index
* sizeof subspace
),
1912 if (bfd_read (&subspace
, 1, sizeof subspace
, abfd
) != sizeof subspace
)
1914 /* Seek back to the start of the subspaces for loop below. */
1916 (current_offset
+ file_hdr
->subspace_location
1917 + space
.subspace_index
* sizeof subspace
),
1921 /* Setup the start address and file loc from the first subspace
1923 space_asect
->vma
= subspace
.subspace_start
;
1924 space_asect
->filepos
= subspace
.file_loc_init_value
+ current_offset
;
1925 space_asect
->alignment_power
= log2 (subspace
.alignment
);
1926 if (space_asect
->alignment_power
== -1)
1929 /* Initialize save_subspace so we can reliably determine if this
1930 loop placed any useful values into it. */
1931 memset (&save_subspace
, 0, sizeof (struct subspace_dictionary_record
));
1933 /* Loop over the rest of the subspaces, building up more sections. */
1934 for (subspace_index
= 0; subspace_index
< space
.subspace_quantity
;
1937 asection
*subspace_asect
;
1939 /* Read in the next subspace. */
1940 if (bfd_read (&subspace
, 1, sizeof subspace
, abfd
)
1944 /* Setup the subspace name string. */
1945 subspace
.name
.n_name
= subspace
.name
.n_strx
+ space_strings
;
1947 newname
= bfd_alloc (abfd
, strlen (subspace
.name
.n_name
) + 1);
1950 strcpy (newname
, subspace
.name
.n_name
);
1952 /* Make a section out of this subspace. */
1953 subspace_asect
= bfd_make_section_anyway (abfd
, newname
);
1954 if (!subspace_asect
)
1957 /* Store private information about the section. */
1958 if (bfd_som_set_subsection_attributes (subspace_asect
, space_asect
,
1959 subspace
.access_control_bits
,
1961 subspace
.quadrant
) == false)
1964 /* Keep an easy mapping between subspaces and sections.
1965 Note we do not necessarily read the subspaces in the
1966 same order in which they appear in the object file.
1968 So to make the target index come out correctly, we
1969 store the location of the subspace header in target
1970 index, then sort using the location of the subspace
1971 header as the key. Then we can assign correct
1972 subspace indices. */
1974 subspace_asect
->target_index
= bfd_tell (abfd
) - sizeof (subspace
);
1976 /* Set SEC_READONLY and SEC_CODE/SEC_DATA as specified
1977 by the access_control_bits in the subspace header. */
1978 switch (subspace
.access_control_bits
>> 4)
1980 /* Readonly data. */
1982 subspace_asect
->flags
|= SEC_DATA
| SEC_READONLY
;
1987 subspace_asect
->flags
|= SEC_DATA
;
1990 /* Readonly code and the gateways.
1991 Gateways have other attributes which do not map
1992 into anything BFD knows about. */
1998 subspace_asect
->flags
|= SEC_CODE
| SEC_READONLY
;
2001 /* dynamic (writable) code. */
2003 subspace_asect
->flags
|= SEC_CODE
;
2007 if (subspace
.dup_common
|| subspace
.is_common
)
2008 subspace_asect
->flags
|= SEC_IS_COMMON
;
2009 else if (subspace
.subspace_length
> 0)
2010 subspace_asect
->flags
|= SEC_HAS_CONTENTS
;
2012 if (subspace
.is_loadable
)
2013 subspace_asect
->flags
|= SEC_ALLOC
| SEC_LOAD
;
2015 subspace_asect
->flags
|= SEC_DEBUGGING
;
2017 if (subspace
.code_only
)
2018 subspace_asect
->flags
|= SEC_CODE
;
2020 /* Both file_loc_init_value and initialization_length will
2021 be zero for a BSS like subspace. */
2022 if (subspace
.file_loc_init_value
== 0
2023 && subspace
.initialization_length
== 0)
2024 subspace_asect
->flags
&= ~(SEC_DATA
| SEC_LOAD
| SEC_HAS_CONTENTS
);
2026 /* This subspace has relocations.
2027 The fixup_request_quantity is a byte count for the number of
2028 entries in the relocation stream; it is not the actual number
2029 of relocations in the subspace. */
2030 if (subspace
.fixup_request_quantity
!= 0)
2032 subspace_asect
->flags
|= SEC_RELOC
;
2033 subspace_asect
->rel_filepos
= subspace
.fixup_request_index
;
2034 som_section_data (subspace_asect
)->reloc_size
2035 = subspace
.fixup_request_quantity
;
2036 /* We can not determine this yet. When we read in the
2037 relocation table the correct value will be filled in. */
2038 subspace_asect
->reloc_count
= -1;
2041 /* Update save_subspace if appropriate. */
2042 if (subspace
.file_loc_init_value
> save_subspace
.file_loc_init_value
)
2043 save_subspace
= subspace
;
2045 subspace_asect
->vma
= subspace
.subspace_start
;
2046 subspace_asect
->_cooked_size
= subspace
.subspace_length
;
2047 subspace_asect
->_raw_size
= subspace
.subspace_length
;
2048 subspace_asect
->filepos
= (subspace
.file_loc_init_value
2050 subspace_asect
->alignment_power
= log2 (subspace
.alignment
);
2051 if (subspace_asect
->alignment_power
== -1)
2055 /* This can happen for a .o which defines symbols in otherwise
2057 if (!save_subspace
.file_loc_init_value
)
2059 space_asect
->_cooked_size
= 0;
2060 space_asect
->_raw_size
= 0;
2064 /* Setup the sizes for the space section based upon the info in the
2065 last subspace of the space. */
2066 space_asect
->_cooked_size
= (save_subspace
.subspace_start
2068 + save_subspace
.subspace_length
);
2069 space_asect
->_raw_size
= (save_subspace
.file_loc_init_value
2070 - space_asect
->filepos
2071 + save_subspace
.initialization_length
);
2074 /* Now that we've read in all the subspace records, we need to assign
2075 a target index to each subspace. */
2076 subspace_sections
= (asection
**) bfd_malloc (total_subspaces
2077 * sizeof (asection
*));
2078 if (subspace_sections
== NULL
)
2081 for (i
= 0, section
= abfd
->sections
; section
; section
= section
->next
)
2083 if (!som_is_subspace (section
))
2086 subspace_sections
[i
] = section
;
2089 qsort (subspace_sections
, total_subspaces
,
2090 sizeof (asection
*), compare_subspaces
);
2092 /* subspace_sections is now sorted in the order in which the subspaces
2093 appear in the object file. Assign an index to each one now. */
2094 for (i
= 0; i
< total_subspaces
; i
++)
2095 subspace_sections
[i
]->target_index
= i
;
2097 if (space_strings
!= NULL
)
2098 free (space_strings
);
2100 if (subspace_sections
!= NULL
)
2101 free (subspace_sections
);
2106 if (space_strings
!= NULL
)
2107 free (space_strings
);
2109 if (subspace_sections
!= NULL
)
2110 free (subspace_sections
);
2114 /* Read in a SOM object and make it into a BFD. */
2116 static const bfd_target
*
2120 struct header file_hdr
;
2121 struct som_exec_auxhdr aux_hdr
;
2122 unsigned long current_offset
= 0;
2123 struct lst_header lst_header
;
2124 struct som_entry som_entry
;
2125 #define ENTRY_SIZE sizeof (struct som_entry)
2127 if (bfd_read ((PTR
) & file_hdr
, 1, FILE_HDR_SIZE
, abfd
) != FILE_HDR_SIZE
)
2129 if (bfd_get_error () != bfd_error_system_call
)
2130 bfd_set_error (bfd_error_wrong_format
);
2134 if (!_PA_RISC_ID (file_hdr
.system_id
))
2136 bfd_set_error (bfd_error_wrong_format
);
2140 switch (file_hdr
.a_magic
)
2152 #ifdef SHARED_MAGIC_CNX
2153 case SHARED_MAGIC_CNX
:
2159 /* Read the lst header and determine where the SOM directory begins. */
2161 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) < 0)
2163 if (bfd_get_error () != bfd_error_system_call
)
2164 bfd_set_error (bfd_error_wrong_format
);
2168 if (bfd_read ((PTR
) & lst_header
, 1, SLSTHDR
, abfd
) != SLSTHDR
)
2170 if (bfd_get_error () != bfd_error_system_call
)
2171 bfd_set_error (bfd_error_wrong_format
);
2175 /* Position to and read the first directory entry. */
2177 if (bfd_seek (abfd
, lst_header
.dir_loc
, SEEK_SET
) < 0)
2179 if (bfd_get_error () != bfd_error_system_call
)
2180 bfd_set_error (bfd_error_wrong_format
);
2184 if (bfd_read ((PTR
) & som_entry
, 1, ENTRY_SIZE
, abfd
) != ENTRY_SIZE
)
2186 if (bfd_get_error () != bfd_error_system_call
)
2187 bfd_set_error (bfd_error_wrong_format
);
2191 /* Now position to the first SOM. */
2193 if (bfd_seek (abfd
, som_entry
.location
, SEEK_SET
) < 0)
2195 if (bfd_get_error () != bfd_error_system_call
)
2196 bfd_set_error (bfd_error_wrong_format
);
2200 current_offset
= som_entry
.location
;
2202 /* And finally, re-read the som header. */
2204 if (bfd_read ((PTR
) & file_hdr
, 1, FILE_HDR_SIZE
, abfd
) != FILE_HDR_SIZE
)
2206 if (bfd_get_error () != bfd_error_system_call
)
2207 bfd_set_error (bfd_error_wrong_format
);
2215 bfd_set_error (bfd_error_wrong_format
);
2219 if (file_hdr
.version_id
!= VERSION_ID
2220 && file_hdr
.version_id
!= NEW_VERSION_ID
)
2222 bfd_set_error (bfd_error_wrong_format
);
2226 /* If the aux_header_size field in the file header is zero, then this
2227 object is an incomplete executable (a .o file). Do not try to read
2228 a non-existant auxiliary header. */
2229 memset (&aux_hdr
, 0, sizeof (struct som_exec_auxhdr
));
2230 if (file_hdr
.aux_header_size
!= 0)
2232 if (bfd_read ((PTR
) & aux_hdr
, 1, AUX_HDR_SIZE
, abfd
) != AUX_HDR_SIZE
)
2234 if (bfd_get_error () != bfd_error_system_call
)
2235 bfd_set_error (bfd_error_wrong_format
);
2240 if (!setup_sections (abfd
, &file_hdr
, current_offset
))
2242 /* setup_sections does not bubble up a bfd error code. */
2243 bfd_set_error (bfd_error_bad_value
);
2247 /* This appears to be a valid SOM object. Do some initialization. */
2248 return som_object_setup (abfd
, &file_hdr
, &aux_hdr
, current_offset
);
2251 /* Create a SOM object. */
2257 /* Allocate memory to hold backend information. */
2258 abfd
->tdata
.som_data
= (struct som_data_struct
*)
2259 bfd_zalloc (abfd
, sizeof (struct som_data_struct
));
2260 if (abfd
->tdata
.som_data
== NULL
)
2265 /* Initialize some information in the file header. This routine makes
2266 not attempt at doing the right thing for a full executable; it
2267 is only meant to handle relocatable objects. */
2270 som_prep_headers (abfd
)
2273 struct header
*file_hdr
;
2276 /* Make and attach a file header to the BFD. */
2277 file_hdr
= (struct header
*) bfd_zalloc (abfd
, sizeof (struct header
));
2278 if (file_hdr
== NULL
)
2280 obj_som_file_hdr (abfd
) = file_hdr
;
2282 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
2285 /* Make and attach an exec header to the BFD. */
2286 obj_som_exec_hdr (abfd
) = (struct som_exec_auxhdr
*)
2287 bfd_zalloc (abfd
, sizeof (struct som_exec_auxhdr
));
2288 if (obj_som_exec_hdr (abfd
) == NULL
)
2291 if (abfd
->flags
& D_PAGED
)
2292 file_hdr
->a_magic
= DEMAND_MAGIC
;
2293 else if (abfd
->flags
& WP_TEXT
)
2294 file_hdr
->a_magic
= SHARE_MAGIC
;
2296 else if (abfd
->flags
& DYNAMIC
)
2297 file_hdr
->a_magic
= SHL_MAGIC
;
2300 file_hdr
->a_magic
= EXEC_MAGIC
;
2303 file_hdr
->a_magic
= RELOC_MAGIC
;
2305 /* Only new format SOM is supported. */
2306 file_hdr
->version_id
= NEW_VERSION_ID
;
2308 /* These fields are optional, and embedding timestamps is not always
2309 a wise thing to do, it makes comparing objects during a multi-stage
2310 bootstrap difficult. */
2311 file_hdr
->file_time
.secs
= 0;
2312 file_hdr
->file_time
.nanosecs
= 0;
2314 file_hdr
->entry_space
= 0;
2315 file_hdr
->entry_subspace
= 0;
2316 file_hdr
->entry_offset
= 0;
2317 file_hdr
->presumed_dp
= 0;
2319 /* Now iterate over the sections translating information from
2320 BFD sections to SOM spaces/subspaces. */
2322 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2324 /* Ignore anything which has not been marked as a space or
2326 if (!som_is_space (section
) && !som_is_subspace (section
))
2329 if (som_is_space (section
))
2331 /* Allocate space for the space dictionary. */
2332 som_section_data (section
)->space_dict
=
2333 (struct space_dictionary_record
*)
2334 bfd_zalloc (abfd
, sizeof (struct space_dictionary_record
));
2335 if (som_section_data (section
)->space_dict
== NULL
)
2337 /* Set space attributes. Note most attributes of SOM spaces
2338 are set based on the subspaces it contains. */
2339 som_section_data (section
)->space_dict
->loader_fix_index
= -1;
2340 som_section_data (section
)->space_dict
->init_pointer_index
= -1;
2342 /* Set more attributes that were stuffed away in private data. */
2343 som_section_data (section
)->space_dict
->sort_key
=
2344 som_section_data (section
)->copy_data
->sort_key
;
2345 som_section_data (section
)->space_dict
->is_defined
=
2346 som_section_data (section
)->copy_data
->is_defined
;
2347 som_section_data (section
)->space_dict
->is_private
=
2348 som_section_data (section
)->copy_data
->is_private
;
2349 som_section_data (section
)->space_dict
->space_number
=
2350 som_section_data (section
)->copy_data
->space_number
;
2354 /* Allocate space for the subspace dictionary. */
2355 som_section_data (section
)->subspace_dict
2356 = (struct subspace_dictionary_record
*)
2357 bfd_zalloc (abfd
, sizeof (struct subspace_dictionary_record
));
2358 if (som_section_data (section
)->subspace_dict
== NULL
)
2361 /* Set subspace attributes. Basic stuff is done here, additional
2362 attributes are filled in later as more information becomes
2364 if (section
->flags
& SEC_IS_COMMON
)
2366 som_section_data (section
)->subspace_dict
->dup_common
= 1;
2367 som_section_data (section
)->subspace_dict
->is_common
= 1;
2370 if (section
->flags
& SEC_ALLOC
)
2371 som_section_data (section
)->subspace_dict
->is_loadable
= 1;
2373 if (section
->flags
& SEC_CODE
)
2374 som_section_data (section
)->subspace_dict
->code_only
= 1;
2376 som_section_data (section
)->subspace_dict
->subspace_start
=
2378 som_section_data (section
)->subspace_dict
->subspace_length
=
2379 bfd_section_size (abfd
, section
);
2380 som_section_data (section
)->subspace_dict
->initialization_length
=
2381 bfd_section_size (abfd
, section
);
2382 som_section_data (section
)->subspace_dict
->alignment
=
2383 1 << section
->alignment_power
;
2385 /* Set more attributes that were stuffed away in private data. */
2386 som_section_data (section
)->subspace_dict
->sort_key
=
2387 som_section_data (section
)->copy_data
->sort_key
;
2388 som_section_data (section
)->subspace_dict
->access_control_bits
=
2389 som_section_data (section
)->copy_data
->access_control_bits
;
2390 som_section_data (section
)->subspace_dict
->quadrant
=
2391 som_section_data (section
)->copy_data
->quadrant
;
2397 /* Return true if the given section is a SOM space, false otherwise. */
2400 som_is_space (section
)
2403 /* If no copy data is available, then it's neither a space nor a
2405 if (som_section_data (section
)->copy_data
== NULL
)
2408 /* If the containing space isn't the same as the given section,
2409 then this isn't a space. */
2410 if (som_section_data (section
)->copy_data
->container
!= section
2411 && (som_section_data (section
)->copy_data
->container
->output_section
2415 /* OK. Must be a space. */
2419 /* Return true if the given section is a SOM subspace, false otherwise. */
2422 som_is_subspace (section
)
2425 /* If no copy data is available, then it's neither a space nor a
2427 if (som_section_data (section
)->copy_data
== NULL
)
2430 /* If the containing space is the same as the given section,
2431 then this isn't a subspace. */
2432 if (som_section_data (section
)->copy_data
->container
== section
2433 || (som_section_data (section
)->copy_data
->container
->output_section
2437 /* OK. Must be a subspace. */
2441 /* Return true if the given space containins the given subspace. It
2442 is safe to assume space really is a space, and subspace really
2446 som_is_container (space
, subspace
)
2447 asection
*space
, *subspace
;
2449 return (som_section_data (subspace
)->copy_data
->container
== space
2450 || (som_section_data (subspace
)->copy_data
->container
->output_section
2454 /* Count and return the number of spaces attached to the given BFD. */
2456 static unsigned long
2457 som_count_spaces (abfd
)
2463 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2464 count
+= som_is_space (section
);
2469 /* Count the number of subspaces attached to the given BFD. */
2471 static unsigned long
2472 som_count_subspaces (abfd
)
2478 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2479 count
+= som_is_subspace (section
);
2484 /* Return -1, 0, 1 indicating the relative ordering of sym1 and sym2.
2486 We desire symbols to be ordered starting with the symbol with the
2487 highest relocation count down to the symbol with the lowest relocation
2488 count. Doing so compacts the relocation stream. */
2491 compare_syms (arg1
, arg2
)
2496 asymbol
**sym1
= (asymbol
**) arg1
;
2497 asymbol
**sym2
= (asymbol
**) arg2
;
2498 unsigned int count1
, count2
;
2500 /* Get relocation count for each symbol. Note that the count
2501 is stored in the udata pointer for section symbols! */
2502 if ((*sym1
)->flags
& BSF_SECTION_SYM
)
2503 count1
= (*sym1
)->udata
.i
;
2505 count1
= som_symbol_data (*sym1
)->reloc_count
;
2507 if ((*sym2
)->flags
& BSF_SECTION_SYM
)
2508 count2
= (*sym2
)->udata
.i
;
2510 count2
= som_symbol_data (*sym2
)->reloc_count
;
2512 /* Return the appropriate value. */
2513 if (count1
< count2
)
2515 else if (count1
> count2
)
2520 /* Return -1, 0, 1 indicating the relative ordering of subspace1
2524 compare_subspaces (arg1
, arg2
)
2529 asection
**subspace1
= (asection
**) arg1
;
2530 asection
**subspace2
= (asection
**) arg2
;
2532 if ((*subspace1
)->target_index
< (*subspace2
)->target_index
)
2534 else if ((*subspace2
)->target_index
< (*subspace1
)->target_index
)
2540 /* Perform various work in preparation for emitting the fixup stream. */
2543 som_prep_for_fixups (abfd
, syms
, num_syms
)
2546 unsigned long num_syms
;
2550 asymbol
**sorted_syms
;
2552 /* Most SOM relocations involving a symbol have a length which is
2553 dependent on the index of the symbol. So symbols which are
2554 used often in relocations should have a small index. */
2556 /* First initialize the counters for each symbol. */
2557 for (i
= 0; i
< num_syms
; i
++)
2559 /* Handle a section symbol; these have no pointers back to the
2560 SOM symbol info. So we just use the udata field to hold the
2561 relocation count. */
2562 if (som_symbol_data (syms
[i
]) == NULL
2563 || syms
[i
]->flags
& BSF_SECTION_SYM
)
2565 syms
[i
]->flags
|= BSF_SECTION_SYM
;
2566 syms
[i
]->udata
.i
= 0;
2569 som_symbol_data (syms
[i
])->reloc_count
= 0;
2572 /* Now that the counters are initialized, make a weighted count
2573 of how often a given symbol is used in a relocation. */
2574 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2578 /* Does this section have any relocations? */
2579 if (section
->reloc_count
<= 0)
2582 /* Walk through each relocation for this section. */
2583 for (i
= 1; i
< section
->reloc_count
; i
++)
2585 arelent
*reloc
= section
->orelocation
[i
];
2588 /* A relocation against a symbol in the *ABS* section really
2589 does not have a symbol. Likewise if the symbol isn't associated
2590 with any section. */
2591 if (reloc
->sym_ptr_ptr
== NULL
2592 || bfd_is_abs_section ((*reloc
->sym_ptr_ptr
)->section
))
2595 /* Scaling to encourage symbols involved in R_DP_RELATIVE
2596 and R_CODE_ONE_SYMBOL relocations to come first. These
2597 two relocations have single byte versions if the symbol
2598 index is very small. */
2599 if (reloc
->howto
->type
== R_DP_RELATIVE
2600 || reloc
->howto
->type
== R_CODE_ONE_SYMBOL
)
2605 /* Handle section symbols by storing the count in the udata
2606 field. It will not be used and the count is very important
2607 for these symbols. */
2608 if ((*reloc
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
)
2610 (*reloc
->sym_ptr_ptr
)->udata
.i
=
2611 (*reloc
->sym_ptr_ptr
)->udata
.i
+ scale
;
2615 /* A normal symbol. Increment the count. */
2616 som_symbol_data (*reloc
->sym_ptr_ptr
)->reloc_count
+= scale
;
2620 /* Sort a copy of the symbol table, rather than the canonical
2621 output symbol table. */
2622 sorted_syms
= (asymbol
**) bfd_zalloc (abfd
, num_syms
* sizeof (asymbol
*));
2623 memcpy (sorted_syms
, syms
, num_syms
* sizeof (asymbol
*));
2624 qsort (sorted_syms
, num_syms
, sizeof (asymbol
*), compare_syms
);
2625 obj_som_sorted_syms (abfd
) = sorted_syms
;
2627 /* Compute the symbol indexes, they will be needed by the relocation
2629 for (i
= 0; i
< num_syms
; i
++)
2631 /* A section symbol. Again, there is no pointer to backend symbol
2632 information, so we reuse the udata field again. */
2633 if (sorted_syms
[i
]->flags
& BSF_SECTION_SYM
)
2634 sorted_syms
[i
]->udata
.i
= i
;
2636 som_symbol_data (sorted_syms
[i
])->index
= i
;
2641 som_write_fixups (abfd
, current_offset
, total_reloc_sizep
)
2643 unsigned long current_offset
;
2644 unsigned int *total_reloc_sizep
;
2647 /* Chunk of memory that we can use as buffer space, then throw
2649 unsigned char tmp_space
[SOM_TMP_BUFSIZE
];
2651 unsigned int total_reloc_size
= 0;
2652 unsigned int subspace_reloc_size
= 0;
2653 unsigned int num_spaces
= obj_som_file_hdr (abfd
)->space_total
;
2654 asection
*section
= abfd
->sections
;
2656 memset (tmp_space
, 0, SOM_TMP_BUFSIZE
);
2659 /* All the fixups for a particular subspace are emitted in a single
2660 stream. All the subspaces for a particular space are emitted
2663 So, to get all the locations correct one must iterate through all the
2664 spaces, for each space iterate through its subspaces and output a
2666 for (i
= 0; i
< num_spaces
; i
++)
2668 asection
*subsection
;
2671 while (!som_is_space (section
))
2672 section
= section
->next
;
2674 /* Now iterate through each of its subspaces. */
2675 for (subsection
= abfd
->sections
;
2677 subsection
= subsection
->next
)
2679 int reloc_offset
, current_rounding_mode
;
2680 #ifndef NO_PCREL_MODES
2681 int current_call_mode
;
2684 /* Find a subspace of this space. */
2685 if (!som_is_subspace (subsection
)
2686 || !som_is_container (section
, subsection
))
2689 /* If this subspace does not have real data, then we are
2691 if ((subsection
->flags
& SEC_HAS_CONTENTS
) == 0)
2693 som_section_data (subsection
)->subspace_dict
->fixup_request_index
2698 /* This subspace has some relocations. Put the relocation stream
2699 index into the subspace record. */
2700 som_section_data (subsection
)->subspace_dict
->fixup_request_index
2703 /* To make life easier start over with a clean slate for
2704 each subspace. Seek to the start of the relocation stream
2705 for this subspace in preparation for writing out its fixup
2707 if (bfd_seek (abfd
, current_offset
+ total_reloc_size
, SEEK_SET
) < 0)
2710 /* Buffer space has already been allocated. Just perform some
2711 initialization here. */
2713 subspace_reloc_size
= 0;
2715 som_initialize_reloc_queue (reloc_queue
);
2716 current_rounding_mode
= R_N_MODE
;
2717 #ifndef NO_PCREL_MODES
2718 current_call_mode
= R_SHORT_PCREL_MODE
;
2721 /* Translate each BFD relocation into one or more SOM
2723 for (j
= 0; j
< subsection
->reloc_count
; j
++)
2725 arelent
*bfd_reloc
= subsection
->orelocation
[j
];
2729 /* Get the symbol number. Remember it's stored in a
2730 special place for section symbols. */
2731 if ((*bfd_reloc
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
)
2732 sym_num
= (*bfd_reloc
->sym_ptr_ptr
)->udata
.i
;
2734 sym_num
= som_symbol_data (*bfd_reloc
->sym_ptr_ptr
)->index
;
2736 /* If there is not enough room for the next couple relocations,
2737 then dump the current buffer contents now. Also reinitialize
2738 the relocation queue.
2740 No single BFD relocation could ever translate into more
2741 than 100 bytes of SOM relocations (20bytes is probably the
2742 upper limit, but leave lots of space for growth). */
2743 if (p
- tmp_space
+ 100 > SOM_TMP_BUFSIZE
)
2745 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
)
2750 som_initialize_reloc_queue (reloc_queue
);
2753 /* Emit R_NO_RELOCATION fixups to map any bytes which were
2755 skip
= bfd_reloc
->address
- reloc_offset
;
2756 p
= som_reloc_skip (abfd
, skip
, p
,
2757 &subspace_reloc_size
, reloc_queue
);
2759 /* Update reloc_offset for the next iteration.
2761 Many relocations do not consume input bytes. They
2762 are markers, or set state necessary to perform some
2763 later relocation. */
2764 switch (bfd_reloc
->howto
->type
)
2784 #ifndef NO_PCREL_MODES
2785 case R_SHORT_PCREL_MODE
:
2786 case R_LONG_PCREL_MODE
:
2788 reloc_offset
= bfd_reloc
->address
;
2792 reloc_offset
= bfd_reloc
->address
+ 4;
2796 /* Now the actual relocation we care about. */
2797 switch (bfd_reloc
->howto
->type
)
2801 p
= som_reloc_call (abfd
, p
, &subspace_reloc_size
,
2802 bfd_reloc
, sym_num
, reloc_queue
);
2805 case R_CODE_ONE_SYMBOL
:
2807 /* Account for any addend. */
2808 if (bfd_reloc
->addend
)
2809 p
= som_reloc_addend (abfd
, bfd_reloc
->addend
, p
,
2810 &subspace_reloc_size
, reloc_queue
);
2814 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ sym_num
, p
);
2815 subspace_reloc_size
+= 1;
2818 else if (sym_num
< 0x100)
2820 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 32, p
);
2821 bfd_put_8 (abfd
, sym_num
, p
+ 1);
2822 p
= try_prev_fixup (abfd
, &subspace_reloc_size
, p
,
2825 else if (sym_num
< 0x10000000)
2827 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 33, p
);
2828 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 1);
2829 bfd_put_16 (abfd
, sym_num
, p
+ 2);
2830 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2837 case R_DATA_ONE_SYMBOL
:
2841 /* Account for any addend using R_DATA_OVERRIDE. */
2842 if (bfd_reloc
->howto
->type
!= R_DATA_ONE_SYMBOL
2843 && bfd_reloc
->addend
)
2844 p
= som_reloc_addend (abfd
, bfd_reloc
->addend
, p
,
2845 &subspace_reloc_size
, reloc_queue
);
2847 if (sym_num
< 0x100)
2849 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2850 bfd_put_8 (abfd
, sym_num
, p
+ 1);
2851 p
= try_prev_fixup (abfd
, &subspace_reloc_size
, p
,
2854 else if (sym_num
< 0x10000000)
2856 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 1, p
);
2857 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 1);
2858 bfd_put_16 (abfd
, sym_num
, p
+ 2);
2859 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2869 arelent
*tmp_reloc
= NULL
;
2870 bfd_put_8 (abfd
, R_ENTRY
, p
);
2872 /* R_ENTRY relocations have 64 bits of associated
2873 data. Unfortunately the addend field of a bfd
2874 relocation is only 32 bits. So, we split up
2875 the 64bit unwind information and store part in
2876 the R_ENTRY relocation, and the rest in the R_EXIT
2878 bfd_put_32 (abfd
, bfd_reloc
->addend
, p
+ 1);
2880 /* Find the next R_EXIT relocation. */
2881 for (tmp
= j
; tmp
< subsection
->reloc_count
; tmp
++)
2883 tmp_reloc
= subsection
->orelocation
[tmp
];
2884 if (tmp_reloc
->howto
->type
== R_EXIT
)
2888 if (tmp
== subsection
->reloc_count
)
2891 bfd_put_32 (abfd
, tmp_reloc
->addend
, p
+ 5);
2892 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2901 /* If this relocation requests the current rounding
2902 mode, then it is redundant. */
2903 if (bfd_reloc
->howto
->type
!= current_rounding_mode
)
2905 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2906 subspace_reloc_size
+= 1;
2908 current_rounding_mode
= bfd_reloc
->howto
->type
;
2912 #ifndef NO_PCREL_MODES
2913 case R_LONG_PCREL_MODE
:
2914 case R_SHORT_PCREL_MODE
:
2915 if (bfd_reloc
->howto
->type
!= current_call_mode
)
2917 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2918 subspace_reloc_size
+= 1;
2920 current_call_mode
= bfd_reloc
->howto
->type
;
2935 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2936 subspace_reloc_size
+= 1;
2941 /* The end of a exception handling region. The reloc's
2942 addend contains the offset of the exception handling
2944 if (bfd_reloc
->addend
== 0)
2945 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2946 else if (bfd_reloc
->addend
< 1024)
2948 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 1, p
);
2949 bfd_put_8 (abfd
, bfd_reloc
->addend
/ 4, p
+ 1);
2950 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2955 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 2, p
);
2956 bfd_put_8 (abfd
, (bfd_reloc
->addend
/ 4) >> 16, p
+ 1);
2957 bfd_put_16 (abfd
, bfd_reloc
->addend
/ 4, p
+ 2);
2958 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2964 /* The only time we generate R_COMP1, R_COMP2 and
2965 R_CODE_EXPR relocs is for the difference of two
2966 symbols. Hence we can cheat here. */
2967 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2968 bfd_put_8 (abfd
, 0x44, p
+ 1);
2969 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2974 /* The only time we generate R_COMP1, R_COMP2 and
2975 R_CODE_EXPR relocs is for the difference of two
2976 symbols. Hence we can cheat here. */
2977 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2978 bfd_put_8 (abfd
, 0x80, p
+ 1);
2979 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 2);
2980 bfd_put_16 (abfd
, sym_num
, p
+ 3);
2981 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2987 /* The only time we generate R_COMP1, R_COMP2 and
2988 R_CODE_EXPR relocs is for the difference of two
2989 symbols. Hence we can cheat here. */
2990 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2991 subspace_reloc_size
+= 1;
2995 /* Put a "R_RESERVED" relocation in the stream if
2996 we hit something we do not understand. The linker
2997 will complain loudly if this ever happens. */
2999 bfd_put_8 (abfd
, 0xff, p
);
3000 subspace_reloc_size
+= 1;
3006 /* Last BFD relocation for a subspace has been processed.
3007 Map the rest of the subspace with R_NO_RELOCATION fixups. */
3008 p
= som_reloc_skip (abfd
, bfd_section_size (abfd
, subsection
)
3010 p
, &subspace_reloc_size
, reloc_queue
);
3012 /* Scribble out the relocations. */
3013 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
)
3018 total_reloc_size
+= subspace_reloc_size
;
3019 som_section_data (subsection
)->subspace_dict
->fixup_request_quantity
3020 = subspace_reloc_size
;
3022 section
= section
->next
;
3024 *total_reloc_sizep
= total_reloc_size
;
3028 /* Write out the space/subspace string table. */
3031 som_write_space_strings (abfd
, current_offset
, string_sizep
)
3033 unsigned long current_offset
;
3034 unsigned int *string_sizep
;
3036 /* Chunk of memory that we can use as buffer space, then throw
3038 size_t tmp_space_size
= SOM_TMP_BUFSIZE
;
3039 unsigned char *tmp_space
= alloca (tmp_space_size
);
3040 unsigned char *p
= tmp_space
;
3041 unsigned int strings_size
= 0;
3044 /* Seek to the start of the space strings in preparation for writing
3046 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) < 0)
3049 /* Walk through all the spaces and subspaces (order is not important)
3050 building up and writing string table entries for their names. */
3051 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3055 /* Only work with space/subspaces; avoid any other sections
3056 which might have been made (.text for example). */
3057 if (!som_is_space (section
) && !som_is_subspace (section
))
3060 /* Get the length of the space/subspace name. */
3061 length
= strlen (section
->name
);
3063 /* If there is not enough room for the next entry, then dump the
3064 current buffer contents now and maybe allocate a larger
3065 buffer. Each entry will take 4 bytes to hold the string
3066 length + the string itself + null terminator. */
3067 if (p
- tmp_space
+ 5 + length
> tmp_space_size
)
3069 /* Flush buffer before refilling or reallocating. */
3070 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
)
3074 /* Reallocate if now empty buffer still too small. */
3075 if (5 + length
> tmp_space_size
)
3077 /* Ensure a minimum growth factor to avoid O(n**2) space
3078 consumption for n strings. The optimal minimum
3079 factor seems to be 2, as no other value can guarantee
3080 wasting less then 50% space. (Note that we cannot
3081 deallocate space allocated by `alloca' without
3082 returning from this function.) The same technique is
3083 used a few more times below when a buffer is
3085 tmp_space_size
= MAX (2 * tmp_space_size
, 5 + length
);
3086 tmp_space
= alloca (tmp_space_size
);
3089 /* Reset to beginning of the (possibly new) buffer space. */
3093 /* First element in a string table entry is the length of the
3094 string. Alignment issues are already handled. */
3095 bfd_put_32 (abfd
, length
, p
);
3099 /* Record the index in the space/subspace records. */
3100 if (som_is_space (section
))
3101 som_section_data (section
)->space_dict
->name
.n_strx
= strings_size
;
3103 som_section_data (section
)->subspace_dict
->name
.n_strx
= strings_size
;
3105 /* Next comes the string itself + a null terminator. */
3106 strcpy (p
, section
->name
);
3108 strings_size
+= length
+ 1;
3110 /* Always align up to the next word boundary. */
3111 while (strings_size
% 4)
3113 bfd_put_8 (abfd
, 0, p
);
3119 /* Done with the space/subspace strings. Write out any information
3120 contained in a partial block. */
3121 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
) != p
- tmp_space
)
3123 *string_sizep
= strings_size
;
3127 /* Write out the symbol string table. */
3130 som_write_symbol_strings (abfd
, current_offset
, syms
, num_syms
, string_sizep
,
3133 unsigned long current_offset
;
3135 unsigned int num_syms
;
3136 unsigned int *string_sizep
;
3137 COMPUNIT
*compilation_unit
;
3141 /* Chunk of memory that we can use as buffer space, then throw
3143 size_t tmp_space_size
= SOM_TMP_BUFSIZE
;
3144 unsigned char *tmp_space
= alloca (tmp_space_size
);
3145 unsigned char *p
= tmp_space
;
3147 unsigned int strings_size
= 0;
3148 unsigned char *comp
[4];
3150 /* This gets a bit gruesome because of the compilation unit. The
3151 strings within the compilation unit are part of the symbol
3152 strings, but don't have symbol_dictionary entries. So, manually
3153 write them and update the compliation unit header. On input, the
3154 compilation unit header contains local copies of the strings.
3156 if (compilation_unit
)
3158 comp
[0] = compilation_unit
->name
.n_name
;
3159 comp
[1] = compilation_unit
->language_name
.n_name
;
3160 comp
[2] = compilation_unit
->product_id
.n_name
;
3161 comp
[3] = compilation_unit
->version_id
.n_name
;
3164 /* Seek to the start of the space strings in preparation for writing
3166 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) < 0)
3169 if (compilation_unit
)
3171 for (i
= 0; i
< 4; i
++)
3173 size_t length
= strlen (comp
[i
]);
3175 /* If there is not enough room for the next entry, then dump
3176 the current buffer contents now and maybe allocate a
3178 if (p
- tmp_space
+ 5 + length
> tmp_space_size
)
3180 /* Flush buffer before refilling or reallocating. */
3181 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
)
3185 /* Reallocate if now empty buffer still too small. */
3186 if (5 + length
> tmp_space_size
)
3188 /* See alloca above for discussion of new size. */
3189 tmp_space_size
= MAX (2 * tmp_space_size
, 5 + length
);
3190 tmp_space
= alloca (tmp_space_size
);
3193 /* Reset to beginning of the (possibly new) buffer
3198 /* First element in a string table entry is the length of
3199 the string. This must always be 4 byte aligned. This is
3200 also an appropriate time to fill in the string index
3201 field in the symbol table entry. */
3202 bfd_put_32 (abfd
, length
, p
);
3206 /* Next comes the string itself + a null terminator. */
3207 strcpy (p
, comp
[i
]);
3212 obj_som_compilation_unit (abfd
)->name
.n_strx
= strings_size
;
3215 obj_som_compilation_unit (abfd
)->language_name
.n_strx
=
3219 obj_som_compilation_unit (abfd
)->product_id
.n_strx
=
3223 obj_som_compilation_unit (abfd
)->version_id
.n_strx
=
3229 strings_size
+= length
+ 1;
3231 /* Always align up to the next word boundary. */
3232 while (strings_size
% 4)
3234 bfd_put_8 (abfd
, 0, p
);
3241 for (i
= 0; i
< num_syms
; i
++)
3243 size_t length
= strlen (syms
[i
]->name
);
3245 /* If there is not enough room for the next entry, then dump the
3246 current buffer contents now and maybe allocate a larger buffer. */
3247 if (p
- tmp_space
+ 5 + length
> tmp_space_size
)
3249 /* Flush buffer before refilling or reallocating. */
3250 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
)
3254 /* Reallocate if now empty buffer still too small. */
3255 if (5 + length
> tmp_space_size
)
3257 /* See alloca above for discussion of new size. */
3258 tmp_space_size
= MAX (2 * tmp_space_size
, 5 + length
);
3259 tmp_space
= alloca (tmp_space_size
);
3262 /* Reset to beginning of the (possibly new) buffer space. */
3266 /* First element in a string table entry is the length of the
3267 string. This must always be 4 byte aligned. This is also
3268 an appropriate time to fill in the string index field in the
3269 symbol table entry. */
3270 bfd_put_32 (abfd
, length
, p
);
3274 /* Next comes the string itself + a null terminator. */
3275 strcpy (p
, syms
[i
]->name
);
3277 som_symbol_data (syms
[i
])->stringtab_offset
= strings_size
;
3279 strings_size
+= length
+ 1;
3281 /* Always align up to the next word boundary. */
3282 while (strings_size
% 4)
3284 bfd_put_8 (abfd
, 0, p
);
3290 /* Scribble out any partial block. */
3291 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
) != p
- tmp_space
)
3294 *string_sizep
= strings_size
;
3298 /* Compute variable information to be placed in the SOM headers,
3299 space/subspace dictionaries, relocation streams, etc. Begin
3300 writing parts of the object file. */
3303 som_begin_writing (abfd
)
3306 unsigned long current_offset
= 0;
3307 int strings_size
= 0;
3308 unsigned long num_spaces
, num_subspaces
, i
;
3310 unsigned int total_subspaces
= 0;
3311 struct som_exec_auxhdr
*exec_header
= NULL
;
3313 /* The file header will always be first in an object file,
3314 everything else can be in random locations. To keep things
3315 "simple" BFD will lay out the object file in the manner suggested
3316 by the PRO ABI for PA-RISC Systems. */
3318 /* Before any output can really begin offsets for all the major
3319 portions of the object file must be computed. So, starting
3320 with the initial file header compute (and sometimes write)
3321 each portion of the object file. */
3323 /* Make room for the file header, it's contents are not complete
3324 yet, so it can not be written at this time. */
3325 current_offset
+= sizeof (struct header
);
3327 /* Any auxiliary headers will follow the file header. Right now
3328 we support only the copyright and version headers. */
3329 obj_som_file_hdr (abfd
)->aux_header_location
= current_offset
;
3330 obj_som_file_hdr (abfd
)->aux_header_size
= 0;
3331 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3333 /* Parts of the exec header will be filled in later, so
3334 delay writing the header itself. Fill in the defaults,
3335 and write it later. */
3336 current_offset
+= sizeof (struct som_exec_auxhdr
);
3337 obj_som_file_hdr (abfd
)->aux_header_size
3338 += sizeof (struct som_exec_auxhdr
);
3339 exec_header
= obj_som_exec_hdr (abfd
);
3340 exec_header
->som_auxhdr
.type
= EXEC_AUX_ID
;
3341 exec_header
->som_auxhdr
.length
= 40;
3343 if (obj_som_version_hdr (abfd
) != NULL
)
3347 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) < 0)
3350 /* Write the aux_id structure and the string length. */
3351 len
= sizeof (struct aux_id
) + sizeof (unsigned int);
3352 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
3353 current_offset
+= len
;
3354 if (bfd_write ((PTR
) obj_som_version_hdr (abfd
), len
, 1, abfd
) != len
)
3357 /* Write the version string. */
3358 len
= obj_som_version_hdr (abfd
)->header_id
.length
- sizeof (int);
3359 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
3360 current_offset
+= len
;
3361 if (bfd_write ((PTR
) obj_som_version_hdr (abfd
)->user_string
,
3362 len
, 1, abfd
) != len
)
3366 if (obj_som_copyright_hdr (abfd
) != NULL
)
3370 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) < 0)
3373 /* Write the aux_id structure and the string length. */
3374 len
= sizeof (struct aux_id
) + sizeof (unsigned int);
3375 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
3376 current_offset
+= len
;
3377 if (bfd_write ((PTR
) obj_som_copyright_hdr (abfd
), len
, 1, abfd
) != len
)
3380 /* Write the copyright string. */
3381 len
= obj_som_copyright_hdr (abfd
)->header_id
.length
- sizeof (int);
3382 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
3383 current_offset
+= len
;
3384 if (bfd_write ((PTR
) obj_som_copyright_hdr (abfd
)->copyright
,
3385 len
, 1, abfd
) != len
)
3389 /* Next comes the initialization pointers; we have no initialization
3390 pointers, so current offset does not change. */
3391 obj_som_file_hdr (abfd
)->init_array_location
= current_offset
;
3392 obj_som_file_hdr (abfd
)->init_array_total
= 0;
3394 /* Next are the space records. These are fixed length records.
3396 Count the number of spaces to determine how much room is needed
3397 in the object file for the space records.
3399 The names of the spaces are stored in a separate string table,
3400 and the index for each space into the string table is computed
3401 below. Therefore, it is not possible to write the space headers
3403 num_spaces
= som_count_spaces (abfd
);
3404 obj_som_file_hdr (abfd
)->space_location
= current_offset
;
3405 obj_som_file_hdr (abfd
)->space_total
= num_spaces
;
3406 current_offset
+= num_spaces
* sizeof (struct space_dictionary_record
);
3408 /* Next are the subspace records. These are fixed length records.
3410 Count the number of subspaes to determine how much room is needed
3411 in the object file for the subspace records.
3413 A variety if fields in the subspace record are still unknown at
3414 this time (index into string table, fixup stream location/size, etc). */
3415 num_subspaces
= som_count_subspaces (abfd
);
3416 obj_som_file_hdr (abfd
)->subspace_location
= current_offset
;
3417 obj_som_file_hdr (abfd
)->subspace_total
= num_subspaces
;
3418 current_offset
+= num_subspaces
* sizeof (struct subspace_dictionary_record
);
3420 /* Next is the string table for the space/subspace names. We will
3421 build and write the string table on the fly. At the same time
3422 we will fill in the space/subspace name index fields. */
3424 /* The string table needs to be aligned on a word boundary. */
3425 if (current_offset
% 4)
3426 current_offset
+= (4 - (current_offset
% 4));
3428 /* Mark the offset of the space/subspace string table in the
3430 obj_som_file_hdr (abfd
)->space_strings_location
= current_offset
;
3432 /* Scribble out the space strings. */
3433 if (som_write_space_strings (abfd
, current_offset
, &strings_size
) == false)
3436 /* Record total string table size in the header and update the
3438 obj_som_file_hdr (abfd
)->space_strings_size
= strings_size
;
3439 current_offset
+= strings_size
;
3441 /* Next is the compilation unit. */
3442 obj_som_file_hdr (abfd
)->compiler_location
= current_offset
;
3443 obj_som_file_hdr (abfd
)->compiler_total
= 0;
3444 if (obj_som_compilation_unit (abfd
))
3446 obj_som_file_hdr (abfd
)->compiler_total
= 1;
3447 current_offset
+= COMPUNITSZ
;
3450 /* Now compute the file positions for the loadable subspaces, taking
3451 care to make sure everything stays properly aligned. */
3453 section
= abfd
->sections
;
3454 for (i
= 0; i
< num_spaces
; i
++)
3456 asection
*subsection
;
3458 unsigned int subspace_offset
= 0;
3461 while (!som_is_space (section
))
3462 section
= section
->next
;
3465 /* Now look for all its subspaces. */
3466 for (subsection
= abfd
->sections
;
3468 subsection
= subsection
->next
)
3471 if (!som_is_subspace (subsection
)
3472 || !som_is_container (section
, subsection
)
3473 || (subsection
->flags
& SEC_ALLOC
) == 0)
3476 /* If this is the first subspace in the space, and we are
3477 building an executable, then take care to make sure all
3478 the alignments are correct and update the exec header. */
3480 && (abfd
->flags
& (EXEC_P
| DYNAMIC
)))
3482 /* Demand paged executables have each space aligned to a
3483 page boundary. Sharable executables (write-protected
3484 text) have just the private (aka data & bss) space aligned
3485 to a page boundary. Ugh. Not true for HPUX.
3487 The HPUX kernel requires the text to always be page aligned
3488 within the file regardless of the executable's type. */
3489 if (abfd
->flags
& (D_PAGED
| DYNAMIC
)
3490 || (subsection
->flags
& SEC_CODE
)
3491 || ((abfd
->flags
& WP_TEXT
)
3492 && (subsection
->flags
& SEC_DATA
)))
3493 current_offset
= SOM_ALIGN (current_offset
, PA_PAGESIZE
);
3495 /* Update the exec header. */
3496 if (subsection
->flags
& SEC_CODE
&& exec_header
->exec_tfile
== 0)
3498 exec_header
->exec_tmem
= section
->vma
;
3499 exec_header
->exec_tfile
= current_offset
;
3501 if (subsection
->flags
& SEC_DATA
&& exec_header
->exec_dfile
== 0)
3503 exec_header
->exec_dmem
= section
->vma
;
3504 exec_header
->exec_dfile
= current_offset
;
3507 /* Keep track of exactly where we are within a particular
3508 space. This is necessary as the braindamaged HPUX
3509 loader will create holes between subspaces *and*
3510 subspace alignments are *NOT* preserved. What a crock. */
3511 subspace_offset
= subsection
->vma
;
3513 /* Only do this for the first subspace within each space. */
3516 else if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3518 /* The braindamaged HPUX loader may have created a hole
3519 between two subspaces. It is *not* sufficient to use
3520 the alignment specifications within the subspaces to
3521 account for these holes -- I've run into at least one
3522 case where the loader left one code subspace unaligned
3523 in a final executable.
3525 To combat this we keep a current offset within each space,
3526 and use the subspace vma fields to detect and preserve
3527 holes. What a crock!
3529 ps. This is not necessary for unloadable space/subspaces. */
3530 current_offset
+= subsection
->vma
- subspace_offset
;
3531 if (subsection
->flags
& SEC_CODE
)
3532 exec_header
->exec_tsize
+= subsection
->vma
- subspace_offset
;
3534 exec_header
->exec_dsize
+= subsection
->vma
- subspace_offset
;
3535 subspace_offset
+= subsection
->vma
- subspace_offset
;
3538 subsection
->target_index
= total_subspaces
++;
3539 /* This is real data to be loaded from the file. */
3540 if (subsection
->flags
& SEC_LOAD
)
3542 /* Update the size of the code & data. */
3543 if (abfd
->flags
& (EXEC_P
| DYNAMIC
)
3544 && subsection
->flags
& SEC_CODE
)
3545 exec_header
->exec_tsize
+= subsection
->_cooked_size
;
3546 else if (abfd
->flags
& (EXEC_P
| DYNAMIC
)
3547 && subsection
->flags
& SEC_DATA
)
3548 exec_header
->exec_dsize
+= subsection
->_cooked_size
;
3549 som_section_data (subsection
)->subspace_dict
->file_loc_init_value
3551 subsection
->filepos
= current_offset
;
3552 current_offset
+= bfd_section_size (abfd
, subsection
);
3553 subspace_offset
+= bfd_section_size (abfd
, subsection
);
3555 /* Looks like uninitialized data. */
3558 /* Update the size of the bss section. */
3559 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3560 exec_header
->exec_bsize
+= subsection
->_cooked_size
;
3562 som_section_data (subsection
)->subspace_dict
->file_loc_init_value
3564 som_section_data (subsection
)->subspace_dict
->
3565 initialization_length
= 0;
3568 /* Goto the next section. */
3569 section
= section
->next
;
3572 /* Finally compute the file positions for unloadable subspaces.
3573 If building an executable, start the unloadable stuff on its
3576 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3577 current_offset
= SOM_ALIGN (current_offset
, PA_PAGESIZE
);
3579 obj_som_file_hdr (abfd
)->unloadable_sp_location
= current_offset
;
3580 section
= abfd
->sections
;
3581 for (i
= 0; i
< num_spaces
; i
++)
3583 asection
*subsection
;
3586 while (!som_is_space (section
))
3587 section
= section
->next
;
3589 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3590 current_offset
= SOM_ALIGN (current_offset
, PA_PAGESIZE
);
3592 /* Now look for all its subspaces. */
3593 for (subsection
= abfd
->sections
;
3595 subsection
= subsection
->next
)
3598 if (!som_is_subspace (subsection
)
3599 || !som_is_container (section
, subsection
)
3600 || (subsection
->flags
& SEC_ALLOC
) != 0)
3603 subsection
->target_index
= total_subspaces
++;
3604 /* This is real data to be loaded from the file. */
3605 if ((subsection
->flags
& SEC_LOAD
) == 0)
3607 som_section_data (subsection
)->subspace_dict
->file_loc_init_value
3609 subsection
->filepos
= current_offset
;
3610 current_offset
+= bfd_section_size (abfd
, subsection
);
3612 /* Looks like uninitialized data. */
3615 som_section_data (subsection
)->subspace_dict
->file_loc_init_value
3617 som_section_data (subsection
)->subspace_dict
->
3618 initialization_length
= bfd_section_size (abfd
, subsection
);
3621 /* Goto the next section. */
3622 section
= section
->next
;
3625 /* If building an executable, then make sure to seek to and write
3626 one byte at the end of the file to make sure any necessary
3627 zeros are filled in. Ugh. */
3628 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3629 current_offset
= SOM_ALIGN (current_offset
, PA_PAGESIZE
);
3630 if (bfd_seek (abfd
, current_offset
- 1, SEEK_SET
) < 0)
3632 if (bfd_write ((PTR
) "", 1, 1, abfd
) != 1)
3635 obj_som_file_hdr (abfd
)->unloadable_sp_size
3636 = current_offset
- obj_som_file_hdr (abfd
)->unloadable_sp_location
;
3638 /* Loader fixups are not supported in any way shape or form. */
3639 obj_som_file_hdr (abfd
)->loader_fixup_location
= 0;
3640 obj_som_file_hdr (abfd
)->loader_fixup_total
= 0;
3642 /* Done. Store the total size of the SOM so far. */
3643 obj_som_file_hdr (abfd
)->som_length
= current_offset
;
3648 /* Finally, scribble out the various headers to the disk. */
3651 som_finish_writing (abfd
)
3654 int num_spaces
= som_count_spaces (abfd
);
3655 asymbol
**syms
= bfd_get_outsymbols (abfd
);
3656 int i
, num_syms
, strings_size
;
3657 int subspace_index
= 0;
3660 unsigned long current_offset
;
3661 unsigned int total_reloc_size
;
3663 /* Next is the symbol table. These are fixed length records.
3665 Count the number of symbols to determine how much room is needed
3666 in the object file for the symbol table.
3668 The names of the symbols are stored in a separate string table,
3669 and the index for each symbol name into the string table is computed
3670 below. Therefore, it is not possible to write the symbol table
3673 These used to be output before the subspace contents, but they
3674 were moved here to work around a stupid bug in the hpux linker
3675 (fixed in hpux10). */
3676 current_offset
= obj_som_file_hdr (abfd
)->som_length
;
3678 /* Make sure we're on a word boundary. */
3679 if (current_offset
% 4)
3680 current_offset
+= (4 - (current_offset
% 4));
3682 num_syms
= bfd_get_symcount (abfd
);
3683 obj_som_file_hdr (abfd
)->symbol_location
= current_offset
;
3684 obj_som_file_hdr (abfd
)->symbol_total
= num_syms
;
3685 current_offset
+= num_syms
* sizeof (struct symbol_dictionary_record
);
3687 /* Next are the symbol strings.
3688 Align them to a word boundary. */
3689 if (current_offset
% 4)
3690 current_offset
+= (4 - (current_offset
% 4));
3691 obj_som_file_hdr (abfd
)->symbol_strings_location
= current_offset
;
3693 /* Scribble out the symbol strings. */
3694 if (som_write_symbol_strings (abfd
, current_offset
, syms
,
3695 num_syms
, &strings_size
,
3696 obj_som_compilation_unit (abfd
))
3700 /* Record total string table size in header and update the
3702 obj_som_file_hdr (abfd
)->symbol_strings_size
= strings_size
;
3703 current_offset
+= strings_size
;
3705 /* Do prep work before handling fixups. */
3706 som_prep_for_fixups (abfd
,
3707 bfd_get_outsymbols (abfd
),
3708 bfd_get_symcount (abfd
));
3710 /* At the end of the file is the fixup stream which starts on a
3712 if (current_offset
% 4)
3713 current_offset
+= (4 - (current_offset
% 4));
3714 obj_som_file_hdr (abfd
)->fixup_request_location
= current_offset
;
3716 /* Write the fixups and update fields in subspace headers which
3717 relate to the fixup stream. */
3718 if (som_write_fixups (abfd
, current_offset
, &total_reloc_size
) == false)
3721 /* Record the total size of the fixup stream in the file header. */
3722 obj_som_file_hdr (abfd
)->fixup_request_total
= total_reloc_size
;
3724 /* Done. Store the total size of the SOM. */
3725 obj_som_file_hdr (abfd
)->som_length
= current_offset
+ total_reloc_size
;
3727 /* Now that the symbol table information is complete, build and
3728 write the symbol table. */
3729 if (som_build_and_write_symbol_table (abfd
) == false)
3732 /* Subspaces are written first so that we can set up information
3733 about them in their containing spaces as the subspace is written. */
3735 /* Seek to the start of the subspace dictionary records. */
3736 location
= obj_som_file_hdr (abfd
)->subspace_location
;
3737 if (bfd_seek (abfd
, location
, SEEK_SET
) < 0)
3740 section
= abfd
->sections
;
3741 /* Now for each loadable space write out records for its subspaces. */
3742 for (i
= 0; i
< num_spaces
; i
++)
3744 asection
*subsection
;
3747 while (!som_is_space (section
))
3748 section
= section
->next
;
3750 /* Now look for all its subspaces. */
3751 for (subsection
= abfd
->sections
;
3753 subsection
= subsection
->next
)
3756 /* Skip any section which does not correspond to a space
3757 or subspace. Or does not have SEC_ALLOC set (and therefore
3758 has no real bits on the disk). */
3759 if (!som_is_subspace (subsection
)
3760 || !som_is_container (section
, subsection
)
3761 || (subsection
->flags
& SEC_ALLOC
) == 0)
3764 /* If this is the first subspace for this space, then save
3765 the index of the subspace in its containing space. Also
3766 set "is_loadable" in the containing space. */
3768 if (som_section_data (section
)->space_dict
->subspace_quantity
== 0)
3770 som_section_data (section
)->space_dict
->is_loadable
= 1;
3771 som_section_data (section
)->space_dict
->subspace_index
3775 /* Increment the number of subspaces seen and the number of
3776 subspaces contained within the current space. */
3778 som_section_data (section
)->space_dict
->subspace_quantity
++;
3780 /* Mark the index of the current space within the subspace's
3781 dictionary record. */
3782 som_section_data (subsection
)->subspace_dict
->space_index
= i
;
3784 /* Dump the current subspace header. */
3785 if (bfd_write ((PTR
) som_section_data (subsection
)->subspace_dict
,
3786 sizeof (struct subspace_dictionary_record
), 1, abfd
)
3787 != sizeof (struct subspace_dictionary_record
))
3790 /* Goto the next section. */
3791 section
= section
->next
;
3794 /* Now repeat the process for unloadable subspaces. */
3795 section
= abfd
->sections
;
3796 /* Now for each space write out records for its subspaces. */
3797 for (i
= 0; i
< num_spaces
; i
++)
3799 asection
*subsection
;
3802 while (!som_is_space (section
))
3803 section
= section
->next
;
3805 /* Now look for all its subspaces. */
3806 for (subsection
= abfd
->sections
;
3808 subsection
= subsection
->next
)
3811 /* Skip any section which does not correspond to a space or
3812 subspace, or which SEC_ALLOC set (and therefore handled
3813 in the loadable spaces/subspaces code above). */
3815 if (!som_is_subspace (subsection
)
3816 || !som_is_container (section
, subsection
)
3817 || (subsection
->flags
& SEC_ALLOC
) != 0)
3820 /* If this is the first subspace for this space, then save
3821 the index of the subspace in its containing space. Clear
3824 if (som_section_data (section
)->space_dict
->subspace_quantity
== 0)
3826 som_section_data (section
)->space_dict
->is_loadable
= 0;
3827 som_section_data (section
)->space_dict
->subspace_index
3831 /* Increment the number of subspaces seen and the number of
3832 subspaces contained within the current space. */
3833 som_section_data (section
)->space_dict
->subspace_quantity
++;
3836 /* Mark the index of the current space within the subspace's
3837 dictionary record. */
3838 som_section_data (subsection
)->subspace_dict
->space_index
= i
;
3840 /* Dump this subspace header. */
3841 if (bfd_write ((PTR
) som_section_data (subsection
)->subspace_dict
,
3842 sizeof (struct subspace_dictionary_record
), 1, abfd
)
3843 != sizeof (struct subspace_dictionary_record
))
3846 /* Goto the next section. */
3847 section
= section
->next
;
3850 /* All the subspace dictiondary records are written, and all the
3851 fields are set up in the space dictionary records.
3853 Seek to the right location and start writing the space
3854 dictionary records. */
3855 location
= obj_som_file_hdr (abfd
)->space_location
;
3856 if (bfd_seek (abfd
, location
, SEEK_SET
) < 0)
3859 section
= abfd
->sections
;
3860 for (i
= 0; i
< num_spaces
; i
++)
3863 while (!som_is_space (section
))
3864 section
= section
->next
;
3866 /* Dump its header. */
3867 if (bfd_write ((PTR
) som_section_data (section
)->space_dict
,
3868 sizeof (struct space_dictionary_record
), 1, abfd
)
3869 != sizeof (struct space_dictionary_record
))
3872 /* Goto the next section. */
3873 section
= section
->next
;
3876 /* Write the compilation unit record if there is one. */
3877 if (obj_som_compilation_unit (abfd
))
3879 location
= obj_som_file_hdr (abfd
)->compiler_location
;
3880 if (bfd_seek (abfd
, location
, SEEK_SET
) < 0)
3883 if (bfd_write ((PTR
) obj_som_compilation_unit (abfd
),
3884 COMPUNITSZ
, 1, abfd
) != COMPUNITSZ
)
3888 /* Setting of the system_id has to happen very late now that copying of
3889 BFD private data happens *after* section contents are set. */
3890 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3891 obj_som_file_hdr (abfd
)->system_id
= obj_som_exec_data (abfd
)->system_id
;
3892 else if (bfd_get_mach (abfd
) == pa20
)
3893 obj_som_file_hdr (abfd
)->system_id
= CPU_PA_RISC2_0
;
3894 else if (bfd_get_mach (abfd
) == pa11
)
3895 obj_som_file_hdr (abfd
)->system_id
= CPU_PA_RISC1_1
;
3897 obj_som_file_hdr (abfd
)->system_id
= CPU_PA_RISC1_0
;
3899 /* Compute the checksum for the file header just before writing
3900 the header to disk. */
3901 obj_som_file_hdr (abfd
)->checksum
= som_compute_checksum (abfd
);
3903 /* Only thing left to do is write out the file header. It is always
3904 at location zero. Seek there and write it. */
3905 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) < 0)
3907 if (bfd_write ((PTR
) obj_som_file_hdr (abfd
),
3908 sizeof (struct header
), 1, abfd
)
3909 != sizeof (struct header
))
3912 /* Now write the exec header. */
3913 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3915 long tmp
, som_length
;
3916 struct som_exec_auxhdr
*exec_header
;
3918 exec_header
= obj_som_exec_hdr (abfd
);
3919 exec_header
->exec_entry
= bfd_get_start_address (abfd
);
3920 exec_header
->exec_flags
= obj_som_exec_data (abfd
)->exec_flags
;
3922 /* Oh joys. Ram some of the BSS data into the DATA section
3923 to be compatable with how the hp linker makes objects
3924 (saves memory space). */
3925 tmp
= exec_header
->exec_dsize
;
3926 tmp
= SOM_ALIGN (tmp
, PA_PAGESIZE
);
3927 exec_header
->exec_bsize
-= (tmp
- exec_header
->exec_dsize
);
3928 if (exec_header
->exec_bsize
< 0)
3929 exec_header
->exec_bsize
= 0;
3930 exec_header
->exec_dsize
= tmp
;
3932 /* Now perform some sanity checks. The idea is to catch bogons now and
3933 inform the user, instead of silently generating a bogus file. */
3934 som_length
= obj_som_file_hdr (abfd
)->som_length
;
3935 if (exec_header
->exec_tfile
+ exec_header
->exec_tsize
> som_length
3936 || exec_header
->exec_dfile
+ exec_header
->exec_dsize
> som_length
)
3938 bfd_set_error (bfd_error_bad_value
);
3942 if (bfd_seek (abfd
, obj_som_file_hdr (abfd
)->aux_header_location
,
3946 if (bfd_write ((PTR
) exec_header
, AUX_HDR_SIZE
, 1, abfd
)
3953 /* Compute and return the checksum for a SOM file header. */
3955 static unsigned long
3956 som_compute_checksum (abfd
)
3959 unsigned long checksum
, count
, i
;
3960 unsigned long *buffer
= (unsigned long *) obj_som_file_hdr (abfd
);
3963 count
= sizeof (struct header
) / sizeof (unsigned long);
3964 for (i
= 0; i
< count
; i
++)
3965 checksum
^= *(buffer
+ i
);
3971 som_bfd_derive_misc_symbol_info (abfd
, sym
, info
)
3972 bfd
*abfd ATTRIBUTE_UNUSED
;
3974 struct som_misc_symbol_info
*info
;
3977 memset (info
, 0, sizeof (struct som_misc_symbol_info
));
3979 /* The HP SOM linker requires detailed type information about
3980 all symbols (including undefined symbols!). Unfortunately,
3981 the type specified in an import/export statement does not
3982 always match what the linker wants. Severe braindamage. */
3984 /* Section symbols will not have a SOM symbol type assigned to
3985 them yet. Assign all section symbols type ST_DATA. */
3986 if (sym
->flags
& BSF_SECTION_SYM
)
3987 info
->symbol_type
= ST_DATA
;
3990 /* Common symbols must have scope SS_UNSAT and type
3991 ST_STORAGE or the linker will choke. */
3992 if (bfd_is_com_section (sym
->section
))
3994 info
->symbol_scope
= SS_UNSAT
;
3995 info
->symbol_type
= ST_STORAGE
;
3998 /* It is possible to have a symbol without an associated
3999 type. This happens if the user imported the symbol
4000 without a type and the symbol was never defined
4001 locally. If BSF_FUNCTION is set for this symbol, then
4002 assign it type ST_CODE (the HP linker requires undefined
4003 external functions to have type ST_CODE rather than ST_ENTRY). */
4004 else if ((som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
4005 || som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_CODE
)
4006 && bfd_is_und_section (sym
->section
)
4007 && sym
->flags
& BSF_FUNCTION
)
4008 info
->symbol_type
= ST_CODE
;
4010 /* Handle function symbols which were defined in this file.
4011 They should have type ST_ENTRY. Also retrieve the argument
4012 relocation bits from the SOM backend information. */
4013 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_ENTRY
4014 || (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_CODE
4015 && (sym
->flags
& BSF_FUNCTION
))
4016 || (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
4017 && (sym
->flags
& BSF_FUNCTION
)))
4019 info
->symbol_type
= ST_ENTRY
;
4020 info
->arg_reloc
= som_symbol_data (sym
)->tc_data
.ap
.hppa_arg_reloc
;
4021 info
->priv_level
= som_symbol_data (sym
)->tc_data
.ap
.hppa_priv_level
;
4024 /* For unknown symbols set the symbol's type based on the symbol's
4025 section (ST_DATA for DATA sections, ST_CODE for CODE sections). */
4026 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
)
4028 if (sym
->section
->flags
& SEC_CODE
)
4029 info
->symbol_type
= ST_CODE
;
4031 info
->symbol_type
= ST_DATA
;
4034 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
)
4035 info
->symbol_type
= ST_DATA
;
4037 /* From now on it's a very simple mapping. */
4038 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_ABSOLUTE
)
4039 info
->symbol_type
= ST_ABSOLUTE
;
4040 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_CODE
)
4041 info
->symbol_type
= ST_CODE
;
4042 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_DATA
)
4043 info
->symbol_type
= ST_DATA
;
4044 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_MILLICODE
)
4045 info
->symbol_type
= ST_MILLICODE
;
4046 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_PLABEL
)
4047 info
->symbol_type
= ST_PLABEL
;
4048 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_PRI_PROG
)
4049 info
->symbol_type
= ST_PRI_PROG
;
4050 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_SEC_PROG
)
4051 info
->symbol_type
= ST_SEC_PROG
;
4054 /* Now handle the symbol's scope. Exported data which is not
4055 in the common section has scope SS_UNIVERSAL. Note scope
4056 of common symbols was handled earlier! */
4057 if (bfd_is_und_section (sym
->section
))
4058 info
->symbol_scope
= SS_UNSAT
;
4059 else if (sym
->flags
& (BSF_EXPORT
| BSF_WEAK
)
4060 && ! bfd_is_com_section (sym
->section
))
4061 info
->symbol_scope
= SS_UNIVERSAL
;
4062 /* Anything else which is not in the common section has scope
4064 else if (! bfd_is_com_section (sym
->section
))
4065 info
->symbol_scope
= SS_LOCAL
;
4067 /* Now set the symbol_info field. It has no real meaning
4068 for undefined or common symbols, but the HP linker will
4069 choke if it's not set to some "reasonable" value. We
4070 use zero as a reasonable value. */
4071 if (bfd_is_com_section (sym
->section
)
4072 || bfd_is_und_section (sym
->section
)
4073 || bfd_is_abs_section (sym
->section
))
4074 info
->symbol_info
= 0;
4075 /* For all other symbols, the symbol_info field contains the
4076 subspace index of the space this symbol is contained in. */
4078 info
->symbol_info
= sym
->section
->target_index
;
4080 /* Set the symbol's value. */
4081 info
->symbol_value
= sym
->value
+ sym
->section
->vma
;
4083 /* The secondary_def field is for weak symbols. */
4084 if (sym
->flags
& BSF_WEAK
)
4085 info
->secondary_def
= true;
4087 info
->secondary_def
= false;
4091 /* Build and write, in one big chunk, the entire symbol table for
4095 som_build_and_write_symbol_table (abfd
)
4098 unsigned int num_syms
= bfd_get_symcount (abfd
);
4099 file_ptr symtab_location
= obj_som_file_hdr (abfd
)->symbol_location
;
4100 asymbol
**bfd_syms
= obj_som_sorted_syms (abfd
);
4101 struct symbol_dictionary_record
*som_symtab
= NULL
;
4104 /* Compute total symbol table size and allocate a chunk of memory
4105 to hold the symbol table as we build it. */
4106 symtab_size
= num_syms
* sizeof (struct symbol_dictionary_record
);
4107 som_symtab
= (struct symbol_dictionary_record
*) bfd_malloc (symtab_size
);
4108 if (som_symtab
== NULL
&& symtab_size
!= 0)
4110 memset (som_symtab
, 0, symtab_size
);
4112 /* Walk over each symbol. */
4113 for (i
= 0; i
< num_syms
; i
++)
4115 struct som_misc_symbol_info info
;
4117 /* This is really an index into the symbol strings table.
4118 By the time we get here, the index has already been
4119 computed and stored into the name field in the BFD symbol. */
4120 som_symtab
[i
].name
.n_strx
= som_symbol_data(bfd_syms
[i
])->stringtab_offset
;
4122 /* Derive SOM information from the BFD symbol. */
4123 som_bfd_derive_misc_symbol_info (abfd
, bfd_syms
[i
], &info
);
4126 som_symtab
[i
].symbol_type
= info
.symbol_type
;
4127 som_symtab
[i
].symbol_scope
= info
.symbol_scope
;
4128 som_symtab
[i
].arg_reloc
= info
.arg_reloc
;
4129 som_symtab
[i
].symbol_info
= info
.symbol_info
;
4130 som_symtab
[i
].xleast
= 3;
4131 som_symtab
[i
].symbol_value
= info
.symbol_value
| info
.priv_level
;
4132 som_symtab
[i
].secondary_def
= info
.secondary_def
;
4135 /* Everything is ready, seek to the right location and
4136 scribble out the symbol table. */
4137 if (bfd_seek (abfd
, symtab_location
, SEEK_SET
) != 0)
4140 if (bfd_write ((PTR
) som_symtab
, symtab_size
, 1, abfd
) != symtab_size
)
4143 if (som_symtab
!= NULL
)
4147 if (som_symtab
!= NULL
)
4152 /* Write an object in SOM format. */
4155 som_write_object_contents (abfd
)
4158 if (abfd
->output_has_begun
== false)
4160 /* Set up fixed parts of the file, space, and subspace headers.
4161 Notify the world that output has begun. */
4162 som_prep_headers (abfd
);
4163 abfd
->output_has_begun
= true;
4164 /* Start writing the object file. This include all the string
4165 tables, fixup streams, and other portions of the object file. */
4166 som_begin_writing (abfd
);
4169 return (som_finish_writing (abfd
));
4172 /* Read and save the string table associated with the given BFD. */
4175 som_slurp_string_table (abfd
)
4180 /* Use the saved version if its available. */
4181 if (obj_som_stringtab (abfd
) != NULL
)
4184 /* I don't think this can currently happen, and I'm not sure it should
4185 really be an error, but it's better than getting unpredictable results
4186 from the host's malloc when passed a size of zero. */
4187 if (obj_som_stringtab_size (abfd
) == 0)
4189 bfd_set_error (bfd_error_no_symbols
);
4193 /* Allocate and read in the string table. */
4194 stringtab
= bfd_malloc (obj_som_stringtab_size (abfd
));
4195 if (stringtab
== NULL
)
4197 memset (stringtab
, 0, obj_som_stringtab_size (abfd
));
4199 if (bfd_seek (abfd
, obj_som_str_filepos (abfd
), SEEK_SET
) < 0)
4202 if (bfd_read (stringtab
, obj_som_stringtab_size (abfd
), 1, abfd
)
4203 != obj_som_stringtab_size (abfd
))
4206 /* Save our results and return success. */
4207 obj_som_stringtab (abfd
) = stringtab
;
4211 /* Return the amount of data (in bytes) required to hold the symbol
4212 table for this object. */
4215 som_get_symtab_upper_bound (abfd
)
4218 if (!som_slurp_symbol_table (abfd
))
4221 return (bfd_get_symcount (abfd
) + 1) * (sizeof (asymbol
*));
4224 /* Convert from a SOM subspace index to a BFD section. */
4227 bfd_section_from_som_symbol (abfd
, symbol
)
4229 struct symbol_dictionary_record
*symbol
;
4233 /* The meaning of the symbol_info field changes for functions
4234 within executables. So only use the quick symbol_info mapping for
4235 incomplete objects and non-function symbols in executables. */
4236 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0
4237 || (symbol
->symbol_type
!= ST_ENTRY
4238 && symbol
->symbol_type
!= ST_PRI_PROG
4239 && symbol
->symbol_type
!= ST_SEC_PROG
4240 && symbol
->symbol_type
!= ST_MILLICODE
))
4242 unsigned int index
= symbol
->symbol_info
;
4243 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
4244 if (section
->target_index
== index
&& som_is_subspace (section
))
4247 /* Could be a symbol from an external library (such as an OMOS
4248 shared library). Don't abort. */
4249 return bfd_abs_section_ptr
;
4254 unsigned int value
= symbol
->symbol_value
;
4256 /* For executables we will have to use the symbol's address and
4257 find out what section would contain that address. Yuk. */
4258 for (section
= abfd
->sections
; section
; section
= section
->next
)
4260 if (value
>= section
->vma
4261 && value
<= section
->vma
+ section
->_cooked_size
4262 && som_is_subspace (section
))
4266 /* Could be a symbol from an external library (such as an OMOS
4267 shared library). Don't abort. */
4268 return bfd_abs_section_ptr
;
4273 /* Read and save the symbol table associated with the given BFD. */
4276 som_slurp_symbol_table (abfd
)
4279 int symbol_count
= bfd_get_symcount (abfd
);
4280 int symsize
= sizeof (struct symbol_dictionary_record
);
4282 struct symbol_dictionary_record
*buf
= NULL
, *bufp
, *endbufp
;
4283 som_symbol_type
*sym
, *symbase
;
4285 /* Return saved value if it exists. */
4286 if (obj_som_symtab (abfd
) != NULL
)
4287 goto successful_return
;
4289 /* Special case. This is *not* an error. */
4290 if (symbol_count
== 0)
4291 goto successful_return
;
4293 if (!som_slurp_string_table (abfd
))
4296 stringtab
= obj_som_stringtab (abfd
);
4298 symbase
= ((som_symbol_type
*)
4299 bfd_malloc (symbol_count
* sizeof (som_symbol_type
)));
4300 if (symbase
== NULL
)
4302 memset (symbase
, 0, symbol_count
* sizeof (som_symbol_type
));
4304 /* Read in the external SOM representation. */
4305 buf
= bfd_malloc (symbol_count
* symsize
);
4306 if (buf
== NULL
&& symbol_count
* symsize
!= 0)
4308 if (bfd_seek (abfd
, obj_som_sym_filepos (abfd
), SEEK_SET
) < 0)
4310 if (bfd_read (buf
, symbol_count
* symsize
, 1, abfd
)
4311 != symbol_count
* symsize
)
4314 /* Iterate over all the symbols and internalize them. */
4315 endbufp
= buf
+ symbol_count
;
4316 for (bufp
= buf
, sym
= symbase
; bufp
< endbufp
; ++bufp
)
4319 /* I don't think we care about these. */
4320 if (bufp
->symbol_type
== ST_SYM_EXT
4321 || bufp
->symbol_type
== ST_ARG_EXT
)
4324 /* Set some private data we care about. */
4325 if (bufp
->symbol_type
== ST_NULL
)
4326 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_UNKNOWN
;
4327 else if (bufp
->symbol_type
== ST_ABSOLUTE
)
4328 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_ABSOLUTE
;
4329 else if (bufp
->symbol_type
== ST_DATA
)
4330 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_DATA
;
4331 else if (bufp
->symbol_type
== ST_CODE
)
4332 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_CODE
;
4333 else if (bufp
->symbol_type
== ST_PRI_PROG
)
4334 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_PRI_PROG
;
4335 else if (bufp
->symbol_type
== ST_SEC_PROG
)
4336 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_SEC_PROG
;
4337 else if (bufp
->symbol_type
== ST_ENTRY
)
4338 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_ENTRY
;
4339 else if (bufp
->symbol_type
== ST_MILLICODE
)
4340 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_MILLICODE
;
4341 else if (bufp
->symbol_type
== ST_PLABEL
)
4342 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_PLABEL
;
4344 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_UNKNOWN
;
4345 som_symbol_data (sym
)->tc_data
.ap
.hppa_arg_reloc
= bufp
->arg_reloc
;
4347 /* Some reasonable defaults. */
4348 sym
->symbol
.the_bfd
= abfd
;
4349 sym
->symbol
.name
= bufp
->name
.n_strx
+ stringtab
;
4350 sym
->symbol
.value
= bufp
->symbol_value
;
4351 sym
->symbol
.section
= 0;
4352 sym
->symbol
.flags
= 0;
4354 switch (bufp
->symbol_type
)
4358 sym
->symbol
.flags
|= BSF_FUNCTION
;
4359 som_symbol_data (sym
)->tc_data
.ap
.hppa_priv_level
=
4360 sym
->symbol
.value
& 0x3;
4361 sym
->symbol
.value
&= ~0x3;
4368 som_symbol_data (sym
)->tc_data
.ap
.hppa_priv_level
=
4369 sym
->symbol
.value
& 0x3;
4370 sym
->symbol
.value
&= ~0x3;
4371 /* If the symbol's scope is SS_UNSAT, then these are
4372 undefined function symbols. */
4373 if (bufp
->symbol_scope
== SS_UNSAT
)
4374 sym
->symbol
.flags
|= BSF_FUNCTION
;
4380 /* Handle scoping and section information. */
4381 switch (bufp
->symbol_scope
)
4383 /* symbol_info field is undefined for SS_EXTERNAL and SS_UNSAT symbols,
4384 so the section associated with this symbol can't be known. */
4386 if (bufp
->symbol_type
!= ST_STORAGE
)
4387 sym
->symbol
.section
= bfd_und_section_ptr
;
4389 sym
->symbol
.section
= bfd_com_section_ptr
;
4390 sym
->symbol
.flags
|= (BSF_EXPORT
| BSF_GLOBAL
);
4394 if (bufp
->symbol_type
!= ST_STORAGE
)
4395 sym
->symbol
.section
= bfd_und_section_ptr
;
4397 sym
->symbol
.section
= bfd_com_section_ptr
;
4401 sym
->symbol
.flags
|= (BSF_EXPORT
| BSF_GLOBAL
);
4402 sym
->symbol
.section
= bfd_section_from_som_symbol (abfd
, bufp
);
4403 sym
->symbol
.value
-= sym
->symbol
.section
->vma
;
4407 /* SS_GLOBAL and SS_LOCAL are two names for the same thing.
4408 Sound dumb? It is. */
4412 sym
->symbol
.flags
|= BSF_LOCAL
;
4413 sym
->symbol
.section
= bfd_section_from_som_symbol (abfd
, bufp
);
4414 sym
->symbol
.value
-= sym
->symbol
.section
->vma
;
4418 /* Check for a weak symbol. */
4419 if (bufp
->secondary_def
)
4420 sym
->symbol
.flags
|= BSF_WEAK
;
4422 /* Mark section symbols and symbols used by the debugger.
4423 Note $START$ is a magic code symbol, NOT a section symbol. */
4424 if (sym
->symbol
.name
[0] == '$'
4425 && sym
->symbol
.name
[strlen (sym
->symbol
.name
) - 1] == '$'
4426 && !strcmp (sym
->symbol
.name
, sym
->symbol
.section
->name
))
4427 sym
->symbol
.flags
|= BSF_SECTION_SYM
;
4428 else if (!strncmp (sym
->symbol
.name
, "L$0\002", 4))
4430 sym
->symbol
.flags
|= BSF_SECTION_SYM
;
4431 sym
->symbol
.name
= sym
->symbol
.section
->name
;
4433 else if (!strncmp (sym
->symbol
.name
, "L$0\001", 4))
4434 sym
->symbol
.flags
|= BSF_DEBUGGING
;
4436 /* Note increment at bottom of loop, since we skip some symbols
4437 we can not include it as part of the for statement. */
4441 /* We modify the symbol count to record the number of BFD symbols we
4443 bfd_get_symcount (abfd
) = sym
- symbase
;
4445 /* Save our results and return success. */
4446 obj_som_symtab (abfd
) = symbase
;
4458 /* Canonicalize a SOM symbol table. Return the number of entries
4459 in the symbol table. */
4462 som_get_symtab (abfd
, location
)
4467 som_symbol_type
*symbase
;
4469 if (!som_slurp_symbol_table (abfd
))
4472 i
= bfd_get_symcount (abfd
);
4473 symbase
= obj_som_symtab (abfd
);
4475 for (; i
> 0; i
--, location
++, symbase
++)
4476 *location
= &symbase
->symbol
;
4478 /* Final null pointer. */
4480 return (bfd_get_symcount (abfd
));
4483 /* Make a SOM symbol. There is nothing special to do here. */
4486 som_make_empty_symbol (abfd
)
4489 som_symbol_type
*new =
4490 (som_symbol_type
*) bfd_zalloc (abfd
, sizeof (som_symbol_type
));
4493 new->symbol
.the_bfd
= abfd
;
4495 return &new->symbol
;
4498 /* Print symbol information. */
4501 som_print_symbol (ignore_abfd
, afile
, symbol
, how
)
4502 bfd
*ignore_abfd ATTRIBUTE_UNUSED
;
4505 bfd_print_symbol_type how
;
4507 FILE *file
= (FILE *) afile
;
4510 case bfd_print_symbol_name
:
4511 fprintf (file
, "%s", symbol
->name
);
4513 case bfd_print_symbol_more
:
4514 fprintf (file
, "som ");
4515 fprintf_vma (file
, symbol
->value
);
4516 fprintf (file
, " %lx", (long) symbol
->flags
);
4518 case bfd_print_symbol_all
:
4520 CONST
char *section_name
;
4521 section_name
= symbol
->section
? symbol
->section
->name
: "(*none*)";
4522 bfd_print_symbol_vandf ((PTR
) file
, symbol
);
4523 fprintf (file
, " %s\t%s", section_name
, symbol
->name
);
4530 som_bfd_is_local_label_name (abfd
, name
)
4531 bfd
*abfd ATTRIBUTE_UNUSED
;
4534 return (name
[0] == 'L' && name
[1] == '$');
4537 /* Count or process variable-length SOM fixup records.
4539 To avoid code duplication we use this code both to compute the number
4540 of relocations requested by a stream, and to internalize the stream.
4542 When computing the number of relocations requested by a stream the
4543 variables rptr, section, and symbols have no meaning.
4545 Return the number of relocations requested by the fixup stream. When
4548 This needs at least two or three more passes to get it cleaned up. */
4551 som_set_reloc_info (fixup
, end
, internal_relocs
, section
, symbols
, just_count
)
4552 unsigned char *fixup
;
4554 arelent
*internal_relocs
;
4559 unsigned int op
, varname
, deallocate_contents
= 0;
4560 unsigned char *end_fixups
= &fixup
[end
];
4561 const struct fixup_format
*fp
;
4563 unsigned char *save_fixup
;
4564 int variables
[26], stack
[20], c
, v
, count
, prev_fixup
, *sp
, saved_unwind_bits
;
4566 arelent
*rptr
= internal_relocs
;
4567 unsigned int offset
= 0;
4569 #define var(c) variables[(c) - 'A']
4570 #define push(v) (*sp++ = (v))
4571 #define pop() (*--sp)
4572 #define emptystack() (sp == stack)
4574 som_initialize_reloc_queue (reloc_queue
);
4575 memset (variables
, 0, sizeof (variables
));
4576 memset (stack
, 0, sizeof (stack
));
4579 saved_unwind_bits
= 0;
4582 while (fixup
< end_fixups
)
4585 /* Save pointer to the start of this fixup. We'll use
4586 it later to determine if it is necessary to put this fixup
4590 /* Get the fixup code and its associated format. */
4592 fp
= &som_fixup_formats
[op
];
4594 /* Handle a request for a previous fixup. */
4595 if (*fp
->format
== 'P')
4597 /* Get pointer to the beginning of the prev fixup, move
4598 the repeated fixup to the head of the queue. */
4599 fixup
= reloc_queue
[fp
->D
].reloc
;
4600 som_reloc_queue_fix (reloc_queue
, fp
->D
);
4603 /* Get the fixup code and its associated format. */
4605 fp
= &som_fixup_formats
[op
];
4608 /* If this fixup will be passed to BFD, set some reasonable defaults. */
4610 && som_hppa_howto_table
[op
].type
!= R_NO_RELOCATION
4611 && som_hppa_howto_table
[op
].type
!= R_DATA_OVERRIDE
)
4613 rptr
->address
= offset
;
4614 rptr
->howto
= &som_hppa_howto_table
[op
];
4616 rptr
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
4619 /* Set default input length to 0. Get the opcode class index
4623 var ('U') = saved_unwind_bits
;
4625 /* Get the opcode format. */
4628 /* Process the format string. Parsing happens in two phases,
4629 parse RHS, then assign to LHS. Repeat until no more
4630 characters in the format string. */
4633 /* The variable this pass is going to compute a value for. */
4636 /* Start processing RHS. Continue until a NULL or '=' is found. */
4641 /* If this is a variable, push it on the stack. */
4645 /* If this is a lower case letter, then it represents
4646 additional data from the fixup stream to be pushed onto
4648 else if (islower (c
))
4650 int bits
= (c
- 'a') * 8;
4651 for (v
= 0; c
> 'a'; --c
)
4652 v
= (v
<< 8) | *fixup
++;
4654 v
= sign_extend (v
, bits
);
4658 /* A decimal constant. Push it on the stack. */
4659 else if (isdigit (c
))
4662 while (isdigit (*cp
))
4663 v
= (v
* 10) + (*cp
++ - '0');
4667 /* An operator. Pop two two values from the stack and
4668 use them as operands to the given operation. Push
4669 the result of the operation back on the stack. */
4691 while (*cp
&& *cp
!= '=');
4693 /* Move over the equal operator. */
4696 /* Pop the RHS off the stack. */
4699 /* Perform the assignment. */
4702 /* Handle side effects. and special 'O' stack cases. */
4705 /* Consume some bytes from the input space. */
4709 /* A symbol to use in the relocation. Make a note
4710 of this if we are not just counting. */
4713 rptr
->sym_ptr_ptr
= &symbols
[c
];
4715 /* Argument relocation bits for a function call. */
4719 unsigned int tmp
= var ('R');
4722 if ((som_hppa_howto_table
[op
].type
== R_PCREL_CALL
4723 && R_PCREL_CALL
+ 10 > op
)
4724 || (som_hppa_howto_table
[op
].type
== R_ABS_CALL
4725 && R_ABS_CALL
+ 10 > op
))
4727 /* Simple encoding. */
4734 rptr
->addend
|= 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2;
4736 rptr
->addend
|= 1 << 8 | 1 << 6 | 1 << 4;
4738 rptr
->addend
|= 1 << 8 | 1 << 6;
4740 rptr
->addend
|= 1 << 8;
4744 unsigned int tmp1
, tmp2
;
4746 /* First part is easy -- low order two bits are
4747 directly copied, then shifted away. */
4748 rptr
->addend
= tmp
& 0x3;
4751 /* Diving the result by 10 gives us the second
4752 part. If it is 9, then the first two words
4753 are a double precision paramater, else it is
4754 3 * the first arg bits + the 2nd arg bits. */
4758 rptr
->addend
+= (0xe << 6);
4761 /* Get the two pieces. */
4764 /* Put them in the addend. */
4765 rptr
->addend
+= (tmp2
<< 8) + (tmp1
<< 6);
4768 /* What's left is the third part. It's unpacked
4769 just like the second. */
4771 rptr
->addend
+= (0xe << 2);
4776 rptr
->addend
+= (tmp2
<< 4) + (tmp
<< 2);
4779 rptr
->addend
= HPPA_R_ADDEND (rptr
->addend
, 0);
4782 /* Handle the linker expression stack. */
4787 subop
= comp1_opcodes
;
4790 subop
= comp2_opcodes
;
4793 subop
= comp3_opcodes
;
4798 while (*subop
<= (unsigned char) c
)
4802 /* The lower 32unwind bits must be persistent. */
4804 saved_unwind_bits
= var ('U');
4812 /* If we used a previous fixup, clean up after it. */
4815 fixup
= save_fixup
+ 1;
4819 else if (fixup
> save_fixup
+ 1)
4820 som_reloc_queue_insert (save_fixup
, fixup
- save_fixup
, reloc_queue
);
4822 /* We do not pass R_DATA_OVERRIDE or R_NO_RELOCATION
4824 if (som_hppa_howto_table
[op
].type
!= R_DATA_OVERRIDE
4825 && som_hppa_howto_table
[op
].type
!= R_NO_RELOCATION
)
4827 /* Done with a single reloction. Loop back to the top. */
4830 if (som_hppa_howto_table
[op
].type
== R_ENTRY
)
4831 rptr
->addend
= var ('T');
4832 else if (som_hppa_howto_table
[op
].type
== R_EXIT
)
4833 rptr
->addend
= var ('U');
4834 else if (som_hppa_howto_table
[op
].type
== R_PCREL_CALL
4835 || som_hppa_howto_table
[op
].type
== R_ABS_CALL
)
4837 else if (som_hppa_howto_table
[op
].type
== R_DATA_ONE_SYMBOL
)
4839 /* Try what was specified in R_DATA_OVERRIDE first
4840 (if anything). Then the hard way using the
4841 section contents. */
4842 rptr
->addend
= var ('V');
4844 if (rptr
->addend
== 0 && !section
->contents
)
4846 /* Got to read the damn contents first. We don't
4847 bother saving the contents (yet). Add it one
4848 day if the need arises. */
4849 section
->contents
= bfd_malloc (section
->_raw_size
);
4850 if (section
->contents
== NULL
)
4853 deallocate_contents
= 1;
4854 bfd_get_section_contents (section
->owner
,
4858 section
->_raw_size
);
4860 else if (rptr
->addend
== 0)
4861 rptr
->addend
= bfd_get_32 (section
->owner
,
4863 + offset
- var ('L')));
4867 rptr
->addend
= var ('V');
4871 /* Now that we've handled a "full" relocation, reset
4873 memset (variables
, 0, sizeof (variables
));
4874 memset (stack
, 0, sizeof (stack
));
4877 if (deallocate_contents
)
4878 free (section
->contents
);
4888 /* Read in the relocs (aka fixups in SOM terms) for a section.
4890 som_get_reloc_upper_bound calls this routine with JUST_COUNT
4891 set to true to indicate it only needs a count of the number
4892 of actual relocations. */
4895 som_slurp_reloc_table (abfd
, section
, symbols
, just_count
)
4901 char *external_relocs
;
4902 unsigned int fixup_stream_size
;
4903 arelent
*internal_relocs
;
4904 unsigned int num_relocs
;
4906 fixup_stream_size
= som_section_data (section
)->reloc_size
;
4907 /* If there were no relocations, then there is nothing to do. */
4908 if (section
->reloc_count
== 0)
4911 /* If reloc_count is -1, then the relocation stream has not been
4912 parsed. We must do so now to know how many relocations exist. */
4913 if (section
->reloc_count
== -1)
4915 external_relocs
= (char *) bfd_malloc (fixup_stream_size
);
4916 if (external_relocs
== (char *) NULL
)
4918 /* Read in the external forms. */
4920 obj_som_reloc_filepos (abfd
) + section
->rel_filepos
,
4924 if (bfd_read (external_relocs
, 1, fixup_stream_size
, abfd
)
4925 != fixup_stream_size
)
4928 /* Let callers know how many relocations found.
4929 also save the relocation stream as we will
4931 section
->reloc_count
= som_set_reloc_info (external_relocs
,
4933 NULL
, NULL
, NULL
, true);
4935 som_section_data (section
)->reloc_stream
= external_relocs
;
4938 /* If the caller only wanted a count, then return now. */
4942 num_relocs
= section
->reloc_count
;
4943 external_relocs
= som_section_data (section
)->reloc_stream
;
4944 /* Return saved information about the relocations if it is available. */
4945 if (section
->relocation
!= (arelent
*) NULL
)
4948 internal_relocs
= (arelent
*)
4949 bfd_zalloc (abfd
, (num_relocs
* sizeof (arelent
)));
4950 if (internal_relocs
== (arelent
*) NULL
)
4953 /* Process and internalize the relocations. */
4954 som_set_reloc_info (external_relocs
, fixup_stream_size
,
4955 internal_relocs
, section
, symbols
, false);
4957 /* We're done with the external relocations. Free them. */
4958 free (external_relocs
);
4959 som_section_data (section
)->reloc_stream
= NULL
;
4961 /* Save our results and return success. */
4962 section
->relocation
= internal_relocs
;
4966 /* Return the number of bytes required to store the relocation
4967 information associated with the given section. */
4970 som_get_reloc_upper_bound (abfd
, asect
)
4974 /* If section has relocations, then read in the relocation stream
4975 and parse it to determine how many relocations exist. */
4976 if (asect
->flags
& SEC_RELOC
)
4978 if (! som_slurp_reloc_table (abfd
, asect
, NULL
, true))
4980 return (asect
->reloc_count
+ 1) * sizeof (arelent
*);
4982 /* There are no relocations. */
4986 /* Convert relocations from SOM (external) form into BFD internal
4987 form. Return the number of relocations. */
4990 som_canonicalize_reloc (abfd
, section
, relptr
, symbols
)
4999 if (som_slurp_reloc_table (abfd
, section
, symbols
, false) == false)
5002 count
= section
->reloc_count
;
5003 tblptr
= section
->relocation
;
5006 *relptr
++ = tblptr
++;
5008 *relptr
= (arelent
*) NULL
;
5009 return section
->reloc_count
;
5012 extern const bfd_target som_vec
;
5014 /* A hook to set up object file dependent section information. */
5017 som_new_section_hook (abfd
, newsect
)
5021 newsect
->used_by_bfd
=
5022 (PTR
) bfd_zalloc (abfd
, sizeof (struct som_section_data_struct
));
5023 if (!newsect
->used_by_bfd
)
5025 newsect
->alignment_power
= 3;
5027 /* We allow more than three sections internally. */
5031 /* Copy any private info we understand from the input symbol
5032 to the output symbol. */
5035 som_bfd_copy_private_symbol_data (ibfd
, isymbol
, obfd
, osymbol
)
5041 struct som_symbol
*input_symbol
= (struct som_symbol
*) isymbol
;
5042 struct som_symbol
*output_symbol
= (struct som_symbol
*) osymbol
;
5044 /* One day we may try to grok other private data. */
5045 if (ibfd
->xvec
->flavour
!= bfd_target_som_flavour
5046 || obfd
->xvec
->flavour
!= bfd_target_som_flavour
)
5049 /* The only private information we need to copy is the argument relocation
5051 output_symbol
->tc_data
.ap
.hppa_arg_reloc
=
5052 input_symbol
->tc_data
.ap
.hppa_arg_reloc
;
5057 /* Copy any private info we understand from the input section
5058 to the output section. */
5061 som_bfd_copy_private_section_data (ibfd
, isection
, obfd
, osection
)
5067 /* One day we may try to grok other private data. */
5068 if (ibfd
->xvec
->flavour
!= bfd_target_som_flavour
5069 || obfd
->xvec
->flavour
!= bfd_target_som_flavour
5070 || (!som_is_space (isection
) && !som_is_subspace (isection
)))
5073 som_section_data (osection
)->copy_data
=
5074 (struct som_copyable_section_data_struct
*)
5075 bfd_zalloc (obfd
, sizeof (struct som_copyable_section_data_struct
));
5076 if (som_section_data (osection
)->copy_data
== NULL
)
5079 memcpy (som_section_data (osection
)->copy_data
,
5080 som_section_data (isection
)->copy_data
,
5081 sizeof (struct som_copyable_section_data_struct
));
5083 /* Reparent if necessary. */
5084 if (som_section_data (osection
)->copy_data
->container
)
5085 som_section_data (osection
)->copy_data
->container
=
5086 som_section_data (osection
)->copy_data
->container
->output_section
;
5091 /* Copy any private info we understand from the input bfd
5092 to the output bfd. */
5095 som_bfd_copy_private_bfd_data (ibfd
, obfd
)
5098 /* One day we may try to grok other private data. */
5099 if (ibfd
->xvec
->flavour
!= bfd_target_som_flavour
5100 || obfd
->xvec
->flavour
!= bfd_target_som_flavour
)
5103 /* Allocate some memory to hold the data we need. */
5104 obj_som_exec_data (obfd
) = (struct som_exec_data
*)
5105 bfd_zalloc (obfd
, sizeof (struct som_exec_data
));
5106 if (obj_som_exec_data (obfd
) == NULL
)
5109 /* Now copy the data. */
5110 memcpy (obj_som_exec_data (obfd
), obj_som_exec_data (ibfd
),
5111 sizeof (struct som_exec_data
));
5116 /* Set backend info for sections which can not be described
5117 in the BFD data structures. */
5120 bfd_som_set_section_attributes (section
, defined
, private, sort_key
, spnum
)
5124 unsigned int sort_key
;
5127 /* Allocate memory to hold the magic information. */
5128 if (som_section_data (section
)->copy_data
== NULL
)
5130 som_section_data (section
)->copy_data
=
5131 (struct som_copyable_section_data_struct
*)
5132 bfd_zalloc (section
->owner
,
5133 sizeof (struct som_copyable_section_data_struct
));
5134 if (som_section_data (section
)->copy_data
== NULL
)
5137 som_section_data (section
)->copy_data
->sort_key
= sort_key
;
5138 som_section_data (section
)->copy_data
->is_defined
= defined
;
5139 som_section_data (section
)->copy_data
->is_private
= private;
5140 som_section_data (section
)->copy_data
->container
= section
;
5141 som_section_data (section
)->copy_data
->space_number
= spnum
;
5145 /* Set backend info for subsections which can not be described
5146 in the BFD data structures. */
5149 bfd_som_set_subsection_attributes (section
, container
, access
,
5152 asection
*container
;
5154 unsigned int sort_key
;
5157 /* Allocate memory to hold the magic information. */
5158 if (som_section_data (section
)->copy_data
== NULL
)
5160 som_section_data (section
)->copy_data
=
5161 (struct som_copyable_section_data_struct
*)
5162 bfd_zalloc (section
->owner
,
5163 sizeof (struct som_copyable_section_data_struct
));
5164 if (som_section_data (section
)->copy_data
== NULL
)
5167 som_section_data (section
)->copy_data
->sort_key
= sort_key
;
5168 som_section_data (section
)->copy_data
->access_control_bits
= access
;
5169 som_section_data (section
)->copy_data
->quadrant
= quadrant
;
5170 som_section_data (section
)->copy_data
->container
= container
;
5174 /* Set the full SOM symbol type. SOM needs far more symbol information
5175 than any other object file format I'm aware of. It is mandatory
5176 to be able to know if a symbol is an entry point, millicode, data,
5177 code, absolute, storage request, or procedure label. If you get
5178 the symbol type wrong your program will not link. */
5181 bfd_som_set_symbol_type (symbol
, type
)
5185 som_symbol_data (symbol
)->som_type
= type
;
5188 /* Attach an auxiliary header to the BFD backend so that it may be
5189 written into the object file. */
5192 bfd_som_attach_aux_hdr (abfd
, type
, string
)
5197 if (type
== VERSION_AUX_ID
)
5199 int len
= strlen (string
);
5203 pad
= (4 - (len
% 4));
5204 obj_som_version_hdr (abfd
) = (struct user_string_aux_hdr
*)
5205 bfd_zalloc (abfd
, sizeof (struct aux_id
)
5206 + sizeof (unsigned int) + len
+ pad
);
5207 if (!obj_som_version_hdr (abfd
))
5209 obj_som_version_hdr (abfd
)->header_id
.type
= VERSION_AUX_ID
;
5210 obj_som_version_hdr (abfd
)->header_id
.length
= len
+ pad
;
5211 obj_som_version_hdr (abfd
)->header_id
.length
+= sizeof (int);
5212 obj_som_version_hdr (abfd
)->string_length
= len
;
5213 strncpy (obj_som_version_hdr (abfd
)->user_string
, string
, len
);
5215 else if (type
== COPYRIGHT_AUX_ID
)
5217 int len
= strlen (string
);
5221 pad
= (4 - (len
% 4));
5222 obj_som_copyright_hdr (abfd
) = (struct copyright_aux_hdr
*)
5223 bfd_zalloc (abfd
, sizeof (struct aux_id
)
5224 + sizeof (unsigned int) + len
+ pad
);
5225 if (!obj_som_copyright_hdr (abfd
))
5227 obj_som_copyright_hdr (abfd
)->header_id
.type
= COPYRIGHT_AUX_ID
;
5228 obj_som_copyright_hdr (abfd
)->header_id
.length
= len
+ pad
;
5229 obj_som_copyright_hdr (abfd
)->header_id
.length
+= sizeof (int);
5230 obj_som_copyright_hdr (abfd
)->string_length
= len
;
5231 strcpy (obj_som_copyright_hdr (abfd
)->copyright
, string
);
5236 /* Attach an compilation unit header to the BFD backend so that it may be
5237 written into the object file. */
5240 bfd_som_attach_compilation_unit (abfd
, name
, language_name
, product_id
,
5244 const char *language_name
;
5245 const char *product_id
;
5246 const char *version_id
;
5248 COMPUNIT
*n
= (COMPUNIT
*) bfd_zalloc (abfd
, COMPUNITSZ
);
5255 n->f.n_name = bfd_alloc (abfd, strlen (f) + 1); \
5256 if (n->f.n_name == NULL) \
5258 strcpy (n->f.n_name, f); \
5262 STRDUP (language_name
);
5263 STRDUP (product_id
);
5264 STRDUP (version_id
);
5268 obj_som_compilation_unit (abfd
) = n
;
5274 som_get_section_contents (abfd
, section
, location
, offset
, count
)
5279 bfd_size_type count
;
5281 if (count
== 0 || ((section
->flags
& SEC_HAS_CONTENTS
) == 0))
5283 if ((bfd_size_type
) (offset
+count
) > section
->_raw_size
5284 || bfd_seek (abfd
, (file_ptr
) (section
->filepos
+ offset
), SEEK_SET
) == -1
5285 || bfd_read (location
, (bfd_size_type
) 1, count
, abfd
) != count
)
5286 return (false); /* on error */
5291 som_set_section_contents (abfd
, section
, location
, offset
, count
)
5296 bfd_size_type count
;
5298 if (abfd
->output_has_begun
== false)
5300 /* Set up fixed parts of the file, space, and subspace headers.
5301 Notify the world that output has begun. */
5302 som_prep_headers (abfd
);
5303 abfd
->output_has_begun
= true;
5304 /* Start writing the object file. This include all the string
5305 tables, fixup streams, and other portions of the object file. */
5306 som_begin_writing (abfd
);
5309 /* Only write subspaces which have "real" contents (eg. the contents
5310 are not generated at run time by the OS). */
5311 if (!som_is_subspace (section
)
5312 || ((section
->flags
& SEC_HAS_CONTENTS
) == 0))
5315 /* Seek to the proper offset within the object file and write the
5317 offset
+= som_section_data (section
)->subspace_dict
->file_loc_init_value
;
5318 if (bfd_seek (abfd
, offset
, SEEK_SET
) == -1)
5321 if (bfd_write ((PTR
) location
, 1, count
, abfd
) != count
)
5327 som_set_arch_mach (abfd
, arch
, machine
)
5329 enum bfd_architecture arch
;
5330 unsigned long machine
;
5332 /* Allow any architecture to be supported by the SOM backend. */
5333 return bfd_default_set_arch_mach (abfd
, arch
, machine
);
5337 som_find_nearest_line (abfd
, section
, symbols
, offset
, filename_ptr
,
5338 functionname_ptr
, line_ptr
)
5339 bfd
*abfd ATTRIBUTE_UNUSED
;
5340 asection
*section ATTRIBUTE_UNUSED
;
5341 asymbol
**symbols ATTRIBUTE_UNUSED
;
5342 bfd_vma offset ATTRIBUTE_UNUSED
;
5343 CONST
char **filename_ptr ATTRIBUTE_UNUSED
;
5344 CONST
char **functionname_ptr ATTRIBUTE_UNUSED
;
5345 unsigned int *line_ptr ATTRIBUTE_UNUSED
;
5351 som_sizeof_headers (abfd
, reloc
)
5352 bfd
*abfd ATTRIBUTE_UNUSED
;
5353 boolean reloc ATTRIBUTE_UNUSED
;
5355 (*_bfd_error_handler
) (_("som_sizeof_headers unimplemented"));
5361 /* Return the single-character symbol type corresponding to
5362 SOM section S, or '?' for an unknown SOM section. */
5365 som_section_type (s
)
5368 const struct section_to_type
*t
;
5370 for (t
= &stt
[0]; t
->section
; t
++)
5371 if (!strcmp (s
, t
->section
))
5377 som_decode_symclass (symbol
)
5382 if (bfd_is_com_section (symbol
->section
))
5384 if (bfd_is_und_section (symbol
->section
))
5386 if (bfd_is_ind_section (symbol
->section
))
5388 if (symbol
->flags
& BSF_WEAK
)
5390 if (!(symbol
->flags
& (BSF_GLOBAL
| BSF_LOCAL
)))
5393 if (bfd_is_abs_section (symbol
->section
)
5394 || (som_symbol_data (symbol
) != NULL
5395 && som_symbol_data (symbol
)->som_type
== SYMBOL_TYPE_ABSOLUTE
))
5397 else if (symbol
->section
)
5398 c
= som_section_type (symbol
->section
->name
);
5401 if (symbol
->flags
& BSF_GLOBAL
)
5406 /* Return information about SOM symbol SYMBOL in RET. */
5409 som_get_symbol_info (ignore_abfd
, symbol
, ret
)
5410 bfd
*ignore_abfd ATTRIBUTE_UNUSED
;
5414 ret
->type
= som_decode_symclass (symbol
);
5415 if (ret
->type
!= 'U')
5416 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
5419 ret
->name
= symbol
->name
;
5422 /* Count the number of symbols in the archive symbol table. Necessary
5423 so that we can allocate space for all the carsyms at once. */
5426 som_bfd_count_ar_symbols (abfd
, lst_header
, count
)
5428 struct lst_header
*lst_header
;
5432 unsigned int *hash_table
= NULL
;
5433 file_ptr lst_filepos
= bfd_tell (abfd
) - sizeof (struct lst_header
);
5436 (unsigned int *) bfd_malloc (lst_header
->hash_size
5437 * sizeof (unsigned int));
5438 if (hash_table
== NULL
&& lst_header
->hash_size
!= 0)
5441 /* Don't forget to initialize the counter! */
5444 /* Read in the hash table. The has table is an array of 32bit file offsets
5445 which point to the hash chains. */
5446 if (bfd_read ((PTR
) hash_table
, lst_header
->hash_size
, 4, abfd
)
5447 != lst_header
->hash_size
* 4)
5450 /* Walk each chain counting the number of symbols found on that particular
5452 for (i
= 0; i
< lst_header
->hash_size
; i
++)
5454 struct lst_symbol_record lst_symbol
;
5456 /* An empty chain has zero as it's file offset. */
5457 if (hash_table
[i
] == 0)
5460 /* Seek to the first symbol in this hash chain. */
5461 if (bfd_seek (abfd
, lst_filepos
+ hash_table
[i
], SEEK_SET
) < 0)
5464 /* Read in this symbol and update the counter. */
5465 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
5466 != sizeof (lst_symbol
))
5471 /* Now iterate through the rest of the symbols on this chain. */
5472 while (lst_symbol
.next_entry
)
5475 /* Seek to the next symbol. */
5476 if (bfd_seek (abfd
, lst_filepos
+ lst_symbol
.next_entry
, SEEK_SET
)
5480 /* Read the symbol in and update the counter. */
5481 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
5482 != sizeof (lst_symbol
))
5488 if (hash_table
!= NULL
)
5493 if (hash_table
!= NULL
)
5498 /* Fill in the canonical archive symbols (SYMS) from the archive described
5499 by ABFD and LST_HEADER. */
5502 som_bfd_fill_in_ar_symbols (abfd
, lst_header
, syms
)
5504 struct lst_header
*lst_header
;
5507 unsigned int i
, len
;
5508 carsym
*set
= syms
[0];
5509 unsigned int *hash_table
= NULL
;
5510 struct som_entry
*som_dict
= NULL
;
5511 file_ptr lst_filepos
= bfd_tell (abfd
) - sizeof (struct lst_header
);
5514 (unsigned int *) bfd_malloc (lst_header
->hash_size
5515 * sizeof (unsigned int));
5516 if (hash_table
== NULL
&& lst_header
->hash_size
!= 0)
5520 (struct som_entry
*) bfd_malloc (lst_header
->module_count
5521 * sizeof (struct som_entry
));
5522 if (som_dict
== NULL
&& lst_header
->module_count
!= 0)
5525 /* Read in the hash table. The has table is an array of 32bit file offsets
5526 which point to the hash chains. */
5527 if (bfd_read ((PTR
) hash_table
, lst_header
->hash_size
, 4, abfd
)
5528 != lst_header
->hash_size
* 4)
5531 /* Seek to and read in the SOM dictionary. We will need this to fill
5532 in the carsym's filepos field. */
5533 if (bfd_seek (abfd
, lst_filepos
+ lst_header
->dir_loc
, SEEK_SET
) < 0)
5536 if (bfd_read ((PTR
) som_dict
, lst_header
->module_count
,
5537 sizeof (struct som_entry
), abfd
)
5538 != lst_header
->module_count
* sizeof (struct som_entry
))
5541 /* Walk each chain filling in the carsyms as we go along. */
5542 for (i
= 0; i
< lst_header
->hash_size
; i
++)
5544 struct lst_symbol_record lst_symbol
;
5546 /* An empty chain has zero as it's file offset. */
5547 if (hash_table
[i
] == 0)
5550 /* Seek to and read the first symbol on the chain. */
5551 if (bfd_seek (abfd
, lst_filepos
+ hash_table
[i
], SEEK_SET
) < 0)
5554 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
5555 != sizeof (lst_symbol
))
5558 /* Get the name of the symbol, first get the length which is stored
5559 as a 32bit integer just before the symbol.
5561 One might ask why we don't just read in the entire string table
5562 and index into it. Well, according to the SOM ABI the string
5563 index can point *anywhere* in the archive to save space, so just
5564 using the string table would not be safe. */
5565 if (bfd_seek (abfd
, lst_filepos
+ lst_header
->string_loc
5566 + lst_symbol
.name
.n_strx
- 4, SEEK_SET
) < 0)
5569 if (bfd_read (&len
, 1, 4, abfd
) != 4)
5572 /* Allocate space for the name and null terminate it too. */
5573 set
->name
= bfd_zalloc (abfd
, len
+ 1);
5576 if (bfd_read (set
->name
, 1, len
, abfd
) != len
)
5581 /* Fill in the file offset. Note that the "location" field points
5582 to the SOM itself, not the ar_hdr in front of it. */
5583 set
->file_offset
= som_dict
[lst_symbol
.som_index
].location
5584 - sizeof (struct ar_hdr
);
5586 /* Go to the next symbol. */
5589 /* Iterate through the rest of the chain. */
5590 while (lst_symbol
.next_entry
)
5592 /* Seek to the next symbol and read it in. */
5593 if (bfd_seek (abfd
, lst_filepos
+ lst_symbol
.next_entry
, SEEK_SET
) <0)
5596 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
5597 != sizeof (lst_symbol
))
5600 /* Seek to the name length & string and read them in. */
5601 if (bfd_seek (abfd
, lst_filepos
+ lst_header
->string_loc
5602 + lst_symbol
.name
.n_strx
- 4, SEEK_SET
) < 0)
5605 if (bfd_read (&len
, 1, 4, abfd
) != 4)
5608 /* Allocate space for the name and null terminate it too. */
5609 set
->name
= bfd_zalloc (abfd
, len
+ 1);
5613 if (bfd_read (set
->name
, 1, len
, abfd
) != len
)
5617 /* Fill in the file offset. Note that the "location" field points
5618 to the SOM itself, not the ar_hdr in front of it. */
5619 set
->file_offset
= som_dict
[lst_symbol
.som_index
].location
5620 - sizeof (struct ar_hdr
);
5622 /* Go on to the next symbol. */
5626 /* If we haven't died by now, then we successfully read the entire
5627 archive symbol table. */
5628 if (hash_table
!= NULL
)
5630 if (som_dict
!= NULL
)
5635 if (hash_table
!= NULL
)
5637 if (som_dict
!= NULL
)
5642 /* Read in the LST from the archive. */
5645 som_slurp_armap (abfd
)
5648 struct lst_header lst_header
;
5649 struct ar_hdr ar_header
;
5650 unsigned int parsed_size
;
5651 struct artdata
*ardata
= bfd_ardata (abfd
);
5653 int i
= bfd_read ((PTR
) nextname
, 1, 16, abfd
);
5655 /* Special cases. */
5661 if (bfd_seek (abfd
, (file_ptr
) - 16, SEEK_CUR
) < 0)
5664 /* For archives without .o files there is no symbol table. */
5665 if (strncmp (nextname
, "/ ", 16))
5667 bfd_has_map (abfd
) = false;
5671 /* Read in and sanity check the archive header. */
5672 if (bfd_read ((PTR
) &ar_header
, 1, sizeof (struct ar_hdr
), abfd
)
5673 != sizeof (struct ar_hdr
))
5676 if (strncmp (ar_header
.ar_fmag
, ARFMAG
, 2))
5678 bfd_set_error (bfd_error_malformed_archive
);
5682 /* How big is the archive symbol table entry? */
5684 parsed_size
= strtol (ar_header
.ar_size
, NULL
, 10);
5687 bfd_set_error (bfd_error_malformed_archive
);
5691 /* Save off the file offset of the first real user data. */
5692 ardata
->first_file_filepos
= bfd_tell (abfd
) + parsed_size
;
5694 /* Read in the library symbol table. We'll make heavy use of this
5695 in just a minute. */
5696 if (bfd_read ((PTR
) & lst_header
, 1, sizeof (struct lst_header
), abfd
)
5697 != sizeof (struct lst_header
))
5701 if (lst_header
.a_magic
!= LIBMAGIC
)
5703 bfd_set_error (bfd_error_malformed_archive
);
5707 /* Count the number of symbols in the library symbol table. */
5708 if (som_bfd_count_ar_symbols (abfd
, &lst_header
, &ardata
->symdef_count
)
5712 /* Get back to the start of the library symbol table. */
5713 if (bfd_seek (abfd
, ardata
->first_file_filepos
- parsed_size
5714 + sizeof (struct lst_header
), SEEK_SET
) < 0)
5717 /* Initializae the cache and allocate space for the library symbols. */
5719 ardata
->symdefs
= (carsym
*) bfd_alloc (abfd
,
5720 (ardata
->symdef_count
5721 * sizeof (carsym
)));
5722 if (!ardata
->symdefs
)
5725 /* Now fill in the canonical archive symbols. */
5726 if (som_bfd_fill_in_ar_symbols (abfd
, &lst_header
, &ardata
->symdefs
)
5730 /* Seek back to the "first" file in the archive. Note the "first"
5731 file may be the extended name table. */
5732 if (bfd_seek (abfd
, ardata
->first_file_filepos
, SEEK_SET
) < 0)
5735 /* Notify the generic archive code that we have a symbol map. */
5736 bfd_has_map (abfd
) = true;
5740 /* Begin preparing to write a SOM library symbol table.
5742 As part of the prep work we need to determine the number of symbols
5743 and the size of the associated string section. */
5746 som_bfd_prep_for_ar_write (abfd
, num_syms
, stringsize
)
5748 unsigned int *num_syms
, *stringsize
;
5750 bfd
*curr_bfd
= abfd
->archive_head
;
5752 /* Some initialization. */
5756 /* Iterate over each BFD within this archive. */
5757 while (curr_bfd
!= NULL
)
5759 unsigned int curr_count
, i
;
5760 som_symbol_type
*sym
;
5762 /* Don't bother for non-SOM objects. */
5763 if (curr_bfd
->format
!= bfd_object
5764 || curr_bfd
->xvec
->flavour
!= bfd_target_som_flavour
)
5766 curr_bfd
= curr_bfd
->next
;
5770 /* Make sure the symbol table has been read, then snag a pointer
5771 to it. It's a little slimey to grab the symbols via obj_som_symtab,
5772 but doing so avoids allocating lots of extra memory. */
5773 if (som_slurp_symbol_table (curr_bfd
) == false)
5776 sym
= obj_som_symtab (curr_bfd
);
5777 curr_count
= bfd_get_symcount (curr_bfd
);
5779 /* Examine each symbol to determine if it belongs in the
5780 library symbol table. */
5781 for (i
= 0; i
< curr_count
; i
++, sym
++)
5783 struct som_misc_symbol_info info
;
5785 /* Derive SOM information from the BFD symbol. */
5786 som_bfd_derive_misc_symbol_info (curr_bfd
, &sym
->symbol
, &info
);
5788 /* Should we include this symbol? */
5789 if (info
.symbol_type
== ST_NULL
5790 || info
.symbol_type
== ST_SYM_EXT
5791 || info
.symbol_type
== ST_ARG_EXT
)
5794 /* Only global symbols and unsatisfied commons. */
5795 if (info
.symbol_scope
!= SS_UNIVERSAL
5796 && info
.symbol_type
!= ST_STORAGE
)
5799 /* Do no include undefined symbols. */
5800 if (bfd_is_und_section (sym
->symbol
.section
))
5803 /* Bump the various counters, being careful to honor
5804 alignment considerations in the string table. */
5806 *stringsize
= *stringsize
+ strlen (sym
->symbol
.name
) + 5;
5807 while (*stringsize
% 4)
5811 curr_bfd
= curr_bfd
->next
;
5816 /* Hash a symbol name based on the hashing algorithm presented in the
5820 som_bfd_ar_symbol_hash (symbol
)
5823 unsigned int len
= strlen (symbol
->name
);
5825 /* Names with length 1 are special. */
5827 return 0x1000100 | (symbol
->name
[0] << 16) | symbol
->name
[0];
5829 return ((len
& 0x7f) << 24) | (symbol
->name
[1] << 16)
5830 | (symbol
->name
[len
- 2] << 8) | symbol
->name
[len
- 1];
5833 /* Do the bulk of the work required to write the SOM library
5837 som_bfd_ar_write_symbol_stuff (abfd
, nsyms
, string_size
, lst
, elength
)
5839 unsigned int nsyms
, string_size
;
5840 struct lst_header lst
;
5843 file_ptr lst_filepos
;
5844 char *strings
= NULL
, *p
;
5845 struct lst_symbol_record
*lst_syms
= NULL
, *curr_lst_sym
;
5847 unsigned int *hash_table
= NULL
;
5848 struct som_entry
*som_dict
= NULL
;
5849 struct lst_symbol_record
**last_hash_entry
= NULL
;
5850 unsigned int curr_som_offset
, som_index
= 0;
5853 (unsigned int *) bfd_malloc (lst
.hash_size
* sizeof (unsigned int));
5854 if (hash_table
== NULL
&& lst
.hash_size
!= 0)
5857 (struct som_entry
*) bfd_malloc (lst
.module_count
5858 * sizeof (struct som_entry
));
5859 if (som_dict
== NULL
&& lst
.module_count
!= 0)
5863 ((struct lst_symbol_record
**)
5864 bfd_malloc (lst
.hash_size
* sizeof (struct lst_symbol_record
*)));
5865 if (last_hash_entry
== NULL
&& lst
.hash_size
!= 0)
5868 /* Lots of fields are file positions relative to the start
5869 of the lst record. So save its location. */
5870 lst_filepos
= bfd_tell (abfd
) - sizeof (struct lst_header
);
5872 /* Some initialization. */
5873 memset (hash_table
, 0, 4 * lst
.hash_size
);
5874 memset (som_dict
, 0, lst
.module_count
* sizeof (struct som_entry
));
5875 memset (last_hash_entry
, 0,
5876 lst
.hash_size
* sizeof (struct lst_symbol_record
*));
5878 /* Symbols have som_index fields, so we have to keep track of the
5879 index of each SOM in the archive.
5881 The SOM dictionary has (among other things) the absolute file
5882 position for the SOM which a particular dictionary entry
5883 describes. We have to compute that information as we iterate
5884 through the SOMs/symbols. */
5887 /* We add in the size of the archive header twice as the location
5888 in the SOM dictionary is the actual offset of the SOM, not the
5889 archive header before the SOM. */
5890 curr_som_offset
= 8 + 2 * sizeof (struct ar_hdr
) + lst
.file_end
;
5892 /* Make room for the archive header and the contents of the
5893 extended string table. Note that elength includes the size
5894 of the archive header for the extended name table! */
5896 curr_som_offset
+= elength
;
5898 /* Make sure we're properly aligned. */
5899 curr_som_offset
= (curr_som_offset
+ 0x1) & ~0x1;
5901 /* FIXME should be done with buffers just like everything else... */
5902 lst_syms
= bfd_malloc (nsyms
* sizeof (struct lst_symbol_record
));
5903 if (lst_syms
== NULL
&& nsyms
!= 0)
5905 strings
= bfd_malloc (string_size
);
5906 if (strings
== NULL
&& string_size
!= 0)
5910 curr_lst_sym
= lst_syms
;
5912 curr_bfd
= abfd
->archive_head
;
5913 while (curr_bfd
!= NULL
)
5915 unsigned int curr_count
, i
;
5916 som_symbol_type
*sym
;
5918 /* Don't bother for non-SOM objects. */
5919 if (curr_bfd
->format
!= bfd_object
5920 || curr_bfd
->xvec
->flavour
!= bfd_target_som_flavour
)
5922 curr_bfd
= curr_bfd
->next
;
5926 /* Make sure the symbol table has been read, then snag a pointer
5927 to it. It's a little slimey to grab the symbols via obj_som_symtab,
5928 but doing so avoids allocating lots of extra memory. */
5929 if (som_slurp_symbol_table (curr_bfd
) == false)
5932 sym
= obj_som_symtab (curr_bfd
);
5933 curr_count
= bfd_get_symcount (curr_bfd
);
5935 for (i
= 0; i
< curr_count
; i
++, sym
++)
5937 struct som_misc_symbol_info info
;
5939 /* Derive SOM information from the BFD symbol. */
5940 som_bfd_derive_misc_symbol_info (curr_bfd
, &sym
->symbol
, &info
);
5942 /* Should we include this symbol? */
5943 if (info
.symbol_type
== ST_NULL
5944 || info
.symbol_type
== ST_SYM_EXT
5945 || info
.symbol_type
== ST_ARG_EXT
)
5948 /* Only global symbols and unsatisfied commons. */
5949 if (info
.symbol_scope
!= SS_UNIVERSAL
5950 && info
.symbol_type
!= ST_STORAGE
)
5953 /* Do no include undefined symbols. */
5954 if (bfd_is_und_section (sym
->symbol
.section
))
5957 /* If this is the first symbol from this SOM, then update
5958 the SOM dictionary too. */
5959 if (som_dict
[som_index
].location
== 0)
5961 som_dict
[som_index
].location
= curr_som_offset
;
5962 som_dict
[som_index
].length
= arelt_size (curr_bfd
);
5965 /* Fill in the lst symbol record. */
5966 curr_lst_sym
->hidden
= 0;
5967 curr_lst_sym
->secondary_def
= info
.secondary_def
;
5968 curr_lst_sym
->symbol_type
= info
.symbol_type
;
5969 curr_lst_sym
->symbol_scope
= info
.symbol_scope
;
5970 curr_lst_sym
->check_level
= 0;
5971 curr_lst_sym
->must_qualify
= 0;
5972 curr_lst_sym
->initially_frozen
= 0;
5973 curr_lst_sym
->memory_resident
= 0;
5974 curr_lst_sym
->is_common
= bfd_is_com_section (sym
->symbol
.section
);
5975 curr_lst_sym
->dup_common
= 0;
5976 curr_lst_sym
->xleast
= 3;
5977 curr_lst_sym
->arg_reloc
= info
.arg_reloc
;
5978 curr_lst_sym
->name
.n_strx
= p
- strings
+ 4;
5979 curr_lst_sym
->qualifier_name
.n_strx
= 0;
5980 curr_lst_sym
->symbol_info
= info
.symbol_info
;
5981 curr_lst_sym
->symbol_value
= info
.symbol_value
| info
.priv_level
;
5982 curr_lst_sym
->symbol_descriptor
= 0;
5983 curr_lst_sym
->reserved
= 0;
5984 curr_lst_sym
->som_index
= som_index
;
5985 curr_lst_sym
->symbol_key
= som_bfd_ar_symbol_hash (&sym
->symbol
);
5986 curr_lst_sym
->next_entry
= 0;
5988 /* Insert into the hash table. */
5989 if (hash_table
[curr_lst_sym
->symbol_key
% lst
.hash_size
])
5991 struct lst_symbol_record
*tmp
;
5993 /* There is already something at the head of this hash chain,
5994 so tack this symbol onto the end of the chain. */
5995 tmp
= last_hash_entry
[curr_lst_sym
->symbol_key
% lst
.hash_size
];
5997 = (curr_lst_sym
- lst_syms
) * sizeof (struct lst_symbol_record
)
5999 + lst
.module_count
* sizeof (struct som_entry
)
6000 + sizeof (struct lst_header
);
6004 /* First entry in this hash chain. */
6005 hash_table
[curr_lst_sym
->symbol_key
% lst
.hash_size
]
6006 = (curr_lst_sym
- lst_syms
) * sizeof (struct lst_symbol_record
)
6008 + lst
.module_count
* sizeof (struct som_entry
)
6009 + sizeof (struct lst_header
);
6012 /* Keep track of the last symbol we added to this chain so we can
6013 easily update its next_entry pointer. */
6014 last_hash_entry
[curr_lst_sym
->symbol_key
% lst
.hash_size
]
6017 /* Update the string table. */
6018 bfd_put_32 (abfd
, strlen (sym
->symbol
.name
), p
);
6020 strcpy (p
, sym
->symbol
.name
);
6021 p
+= strlen (sym
->symbol
.name
) + 1;
6024 bfd_put_8 (abfd
, 0, p
);
6028 /* Head to the next symbol. */
6032 /* Keep track of where each SOM will finally reside; then look
6034 curr_som_offset
+= arelt_size (curr_bfd
) + sizeof (struct ar_hdr
);
6036 /* A particular object in the archive may have an odd length; the
6037 linker requires objects begin on an even boundary. So round
6038 up the current offset as necessary. */
6039 curr_som_offset
= (curr_som_offset
+ 0x1) & ~0x1;
6040 curr_bfd
= curr_bfd
->next
;
6044 /* Now scribble out the hash table. */
6045 if (bfd_write ((PTR
) hash_table
, lst
.hash_size
, 4, abfd
)
6046 != lst
.hash_size
* 4)
6049 /* Then the SOM dictionary. */
6050 if (bfd_write ((PTR
) som_dict
, lst
.module_count
,
6051 sizeof (struct som_entry
), abfd
)
6052 != lst
.module_count
* sizeof (struct som_entry
))
6055 /* The library symbols. */
6056 if (bfd_write ((PTR
) lst_syms
, nsyms
, sizeof (struct lst_symbol_record
), abfd
)
6057 != nsyms
* sizeof (struct lst_symbol_record
))
6060 /* And finally the strings. */
6061 if (bfd_write ((PTR
) strings
, string_size
, 1, abfd
) != string_size
)
6064 if (hash_table
!= NULL
)
6066 if (som_dict
!= NULL
)
6068 if (last_hash_entry
!= NULL
)
6069 free (last_hash_entry
);
6070 if (lst_syms
!= NULL
)
6072 if (strings
!= NULL
)
6077 if (hash_table
!= NULL
)
6079 if (som_dict
!= NULL
)
6081 if (last_hash_entry
!= NULL
)
6082 free (last_hash_entry
);
6083 if (lst_syms
!= NULL
)
6085 if (strings
!= NULL
)
6091 /* Write out the LST for the archive.
6093 You'll never believe this is really how armaps are handled in SOM... */
6096 som_write_armap (abfd
, elength
, map
, orl_count
, stridx
)
6098 unsigned int elength
;
6099 struct orl
*map ATTRIBUTE_UNUSED
;
6100 unsigned int orl_count ATTRIBUTE_UNUSED
;
6101 int stridx ATTRIBUTE_UNUSED
;
6104 struct stat statbuf
;
6105 unsigned int i
, lst_size
, nsyms
, stringsize
;
6107 struct lst_header lst
;
6110 /* We'll use this for the archive's date and mode later. */
6111 if (stat (abfd
->filename
, &statbuf
) != 0)
6113 bfd_set_error (bfd_error_system_call
);
6117 bfd_ardata (abfd
)->armap_timestamp
= statbuf
.st_mtime
+ 60;
6119 /* Account for the lst header first. */
6120 lst_size
= sizeof (struct lst_header
);
6122 /* Start building the LST header. */
6123 /* FIXME: Do we need to examine each element to determine the
6124 largest id number? */
6125 lst
.system_id
= CPU_PA_RISC1_0
;
6126 lst
.a_magic
= LIBMAGIC
;
6127 lst
.version_id
= VERSION_ID
;
6128 lst
.file_time
.secs
= 0;
6129 lst
.file_time
.nanosecs
= 0;
6131 lst
.hash_loc
= lst_size
;
6132 lst
.hash_size
= SOM_LST_HASH_SIZE
;
6134 /* Hash table is a SOM_LST_HASH_SIZE 32bit offsets. */
6135 lst_size
+= 4 * SOM_LST_HASH_SIZE
;
6137 /* We need to count the number of SOMs in this archive. */
6138 curr_bfd
= abfd
->archive_head
;
6139 lst
.module_count
= 0;
6140 while (curr_bfd
!= NULL
)
6142 /* Only true SOM objects count. */
6143 if (curr_bfd
->format
== bfd_object
6144 && curr_bfd
->xvec
->flavour
== bfd_target_som_flavour
)
6146 curr_bfd
= curr_bfd
->next
;
6148 lst
.module_limit
= lst
.module_count
;
6149 lst
.dir_loc
= lst_size
;
6150 lst_size
+= sizeof (struct som_entry
) * lst
.module_count
;
6152 /* We don't support import/export tables, auxiliary headers,
6153 or free lists yet. Make the linker work a little harder
6154 to make our life easier. */
6157 lst
.export_count
= 0;
6162 /* Count how many symbols we will have on the hash chains and the
6163 size of the associated string table. */
6164 if (som_bfd_prep_for_ar_write (abfd
, &nsyms
, &stringsize
) == false)
6167 lst_size
+= sizeof (struct lst_symbol_record
) * nsyms
;
6169 /* For the string table. One day we might actually use this info
6170 to avoid small seeks/reads when reading archives. */
6171 lst
.string_loc
= lst_size
;
6172 lst
.string_size
= stringsize
;
6173 lst_size
+= stringsize
;
6175 /* SOM ABI says this must be zero. */
6177 lst
.file_end
= lst_size
;
6179 /* Compute the checksum. Must happen after the entire lst header
6183 for (i
= 0; i
< sizeof (struct lst_header
) / sizeof (int) - 1; i
++)
6184 lst
.checksum
^= *p
++;
6186 sprintf (hdr
.ar_name
, "/ ");
6187 sprintf (hdr
.ar_date
, "%ld", bfd_ardata (abfd
)->armap_timestamp
);
6188 sprintf (hdr
.ar_uid
, "%ld", (long) getuid ());
6189 sprintf (hdr
.ar_gid
, "%ld", (long) getgid ());
6190 sprintf (hdr
.ar_mode
, "%-8o", (unsigned int) statbuf
.st_mode
);
6191 sprintf (hdr
.ar_size
, "%-10d", (int) lst_size
);
6192 hdr
.ar_fmag
[0] = '`';
6193 hdr
.ar_fmag
[1] = '\012';
6195 /* Turn any nulls into spaces. */
6196 for (i
= 0; i
< sizeof (struct ar_hdr
); i
++)
6197 if (((char *) (&hdr
))[i
] == '\0')
6198 (((char *) (&hdr
))[i
]) = ' ';
6200 /* Scribble out the ar header. */
6201 if (bfd_write ((PTR
) &hdr
, 1, sizeof (struct ar_hdr
), abfd
)
6202 != sizeof (struct ar_hdr
))
6205 /* Now scribble out the lst header. */
6206 if (bfd_write ((PTR
) &lst
, 1, sizeof (struct lst_header
), abfd
)
6207 != sizeof (struct lst_header
))
6210 /* Build and write the armap. */
6211 if (som_bfd_ar_write_symbol_stuff (abfd
, nsyms
, stringsize
, lst
, elength
)
6219 /* Free all information we have cached for this BFD. We can always
6220 read it again later if we need it. */
6223 som_bfd_free_cached_info (abfd
)
6228 if (bfd_get_format (abfd
) != bfd_object
)
6231 #define FREE(x) if (x != NULL) { free (x); x = NULL; }
6232 /* Free the native string and symbol tables. */
6233 FREE (obj_som_symtab (abfd
));
6234 FREE (obj_som_stringtab (abfd
));
6235 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
6237 /* Free the native relocations. */
6238 o
->reloc_count
= -1;
6239 FREE (som_section_data (o
)->reloc_stream
);
6240 /* Free the generic relocations. */
6241 FREE (o
->relocation
);
6248 /* End of miscellaneous support functions. */
6250 /* Linker support functions. */
6253 som_bfd_link_split_section (abfd
, sec
)
6254 bfd
*abfd ATTRIBUTE_UNUSED
;
6257 return (som_is_subspace (sec
) && sec
->_raw_size
> 240000);
6260 #define som_close_and_cleanup som_bfd_free_cached_info
6262 #define som_read_ar_hdr _bfd_generic_read_ar_hdr
6263 #define som_openr_next_archived_file bfd_generic_openr_next_archived_file
6264 #define som_get_elt_at_index _bfd_generic_get_elt_at_index
6265 #define som_generic_stat_arch_elt bfd_generic_stat_arch_elt
6266 #define som_truncate_arname bfd_bsd_truncate_arname
6267 #define som_slurp_extended_name_table _bfd_slurp_extended_name_table
6268 #define som_construct_extended_name_table \
6269 _bfd_archive_coff_construct_extended_name_table
6270 #define som_update_armap_timestamp bfd_true
6271 #define som_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
6273 #define som_get_lineno _bfd_nosymbols_get_lineno
6274 #define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
6275 #define som_read_minisymbols _bfd_generic_read_minisymbols
6276 #define som_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
6277 #define som_get_section_contents_in_window \
6278 _bfd_generic_get_section_contents_in_window
6280 #define som_bfd_get_relocated_section_contents \
6281 bfd_generic_get_relocated_section_contents
6282 #define som_bfd_relax_section bfd_generic_relax_section
6283 #define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
6284 #define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
6285 #define som_bfd_final_link _bfd_generic_final_link
6287 #define som_bfd_gc_sections bfd_generic_gc_sections
6289 const bfd_target som_vec
= {
6291 bfd_target_som_flavour
,
6292 BFD_ENDIAN_BIG
, /* target byte order */
6293 BFD_ENDIAN_BIG
, /* target headers byte order */
6294 (HAS_RELOC
| EXEC_P
| /* object flags */
6295 HAS_LINENO
| HAS_DEBUG
|
6296 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
| DYNAMIC
),
6297 (SEC_CODE
| SEC_DATA
| SEC_ROM
| SEC_HAS_CONTENTS
6298 | SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
6300 /* leading_symbol_char: is the first char of a user symbol
6301 predictable, and if so what is it */
6303 '/', /* ar_pad_char */
6304 14, /* ar_max_namelen */
6305 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
6306 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
6307 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* data */
6308 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
6309 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
6310 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* hdrs */
6312 som_object_p
, /* bfd_check_format */
6313 bfd_generic_archive_p
,
6319 _bfd_generic_mkarchive
,
6324 som_write_object_contents
,
6325 _bfd_write_archive_contents
,
6330 BFD_JUMP_TABLE_GENERIC (som
),
6331 BFD_JUMP_TABLE_COPY (som
),
6332 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
6333 BFD_JUMP_TABLE_ARCHIVE (som
),
6334 BFD_JUMP_TABLE_SYMBOLS (som
),
6335 BFD_JUMP_TABLE_RELOCS (som
),
6336 BFD_JUMP_TABLE_WRITE (som
),
6337 BFD_JUMP_TABLE_LINK (som
),
6338 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),
6345 #endif /* HOST_HPPAHPUX || HOST_HPPABSD || HOST_HPPAOSF */