1 /* bfd back-end for HP PA-RISC SOM objects.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 Free Software Foundation, Inc.
6 Contributed by the Center for Software Science at the
9 This file is part of BFD, the Binary File Descriptor library.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 #include "alloca-conf.h"
30 #if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) || defined(HOST_HPPAMPEIX)
35 #include <sys/param.h>
37 #include <machine/reg.h>
41 /* Magic not defined in standard HP-UX header files until 8.0 */
43 #ifndef CPU_PA_RISC1_0
44 #define CPU_PA_RISC1_0 0x20B
45 #endif /* CPU_PA_RISC1_0 */
47 #ifndef CPU_PA_RISC1_1
48 #define CPU_PA_RISC1_1 0x210
49 #endif /* CPU_PA_RISC1_1 */
51 #ifndef CPU_PA_RISC2_0
52 #define CPU_PA_RISC2_0 0x214
53 #endif /* CPU_PA_RISC2_0 */
55 #ifndef _PA_RISC1_0_ID
56 #define _PA_RISC1_0_ID CPU_PA_RISC1_0
57 #endif /* _PA_RISC1_0_ID */
59 #ifndef _PA_RISC1_1_ID
60 #define _PA_RISC1_1_ID CPU_PA_RISC1_1
61 #endif /* _PA_RISC1_1_ID */
63 #ifndef _PA_RISC2_0_ID
64 #define _PA_RISC2_0_ID CPU_PA_RISC2_0
65 #endif /* _PA_RISC2_0_ID */
67 #ifndef _PA_RISC_MAXID
68 #define _PA_RISC_MAXID 0x2FF
69 #endif /* _PA_RISC_MAXID */
72 #define _PA_RISC_ID(__m_num) \
73 (((__m_num) == _PA_RISC1_0_ID) || \
74 ((__m_num) >= _PA_RISC1_1_ID && (__m_num) <= _PA_RISC_MAXID))
75 #endif /* _PA_RISC_ID */
77 /* HIUX in it's infinite stupidity changed the names for several "well
78 known" constants. Work around such braindamage. Try the HPUX version
79 first, then the HIUX version, and finally provide a default. */
81 #define EXEC_AUX_ID HPUX_AUX_ID
84 #if !defined (EXEC_AUX_ID) && defined (HIUX_AUX_ID)
85 #define EXEC_AUX_ID HIUX_AUX_ID
92 /* Size (in chars) of the temporary buffers used during fixup and string
95 #define SOM_TMP_BUFSIZE 8192
97 /* Size of the hash table in archives. */
98 #define SOM_LST_HASH_SIZE 31
100 /* Max number of SOMs to be found in an archive. */
101 #define SOM_LST_MODULE_LIMIT 1024
103 /* Generic alignment macro. */
104 #define SOM_ALIGN(val, alignment) \
105 (((val) + (alignment) - 1) & ~((alignment) - 1))
107 /* SOM allows any one of the four previous relocations to be reused
108 with a "R_PREV_FIXUP" relocation entry. Since R_PREV_FIXUP
109 relocations are always a single byte, using a R_PREV_FIXUP instead
110 of some multi-byte relocation makes object files smaller.
112 Note one side effect of using a R_PREV_FIXUP is the relocation that
113 is being repeated moves to the front of the queue. */
115 unsigned char *reloc
;
119 /* This fully describes the symbol types which may be attached to
120 an EXPORT or IMPORT directive. Only SOM uses this formation
121 (ELF has no need for it). */
124 SYMBOL_TYPE_ABSOLUTE
,
128 SYMBOL_TYPE_MILLICODE
,
130 SYMBOL_TYPE_PRI_PROG
,
131 SYMBOL_TYPE_SEC_PROG
,
134 struct section_to_type
{
139 /* Assorted symbol information that needs to be derived from the BFD symbol
140 and/or the BFD backend private symbol data. */
141 struct som_misc_symbol_info
{
142 unsigned int symbol_type
;
143 unsigned int symbol_scope
;
144 unsigned int arg_reloc
;
145 unsigned int symbol_info
;
146 unsigned int symbol_value
;
147 unsigned int priv_level
;
148 unsigned int secondary_def
;
151 /* Forward declarations */
153 static boolean som_mkobject
PARAMS ((bfd
*));
154 static const bfd_target
* som_object_setup
PARAMS ((bfd
*,
156 struct som_exec_auxhdr
*,
158 static boolean setup_sections
PARAMS ((bfd
*, struct header
*, unsigned long));
159 static const bfd_target
* som_object_p
PARAMS ((bfd
*));
160 static boolean som_write_object_contents
PARAMS ((bfd
*));
161 static boolean som_slurp_string_table
PARAMS ((bfd
*));
162 static unsigned int som_slurp_symbol_table
PARAMS ((bfd
*));
163 static long som_get_symtab_upper_bound
PARAMS ((bfd
*));
164 static long som_canonicalize_reloc
PARAMS ((bfd
*, sec_ptr
,
165 arelent
**, asymbol
**));
166 static long som_get_reloc_upper_bound
PARAMS ((bfd
*, sec_ptr
));
167 static unsigned int som_set_reloc_info
PARAMS ((unsigned char *, unsigned int,
168 arelent
*, asection
*,
169 asymbol
**, boolean
));
170 static boolean som_slurp_reloc_table
PARAMS ((bfd
*, asection
*,
171 asymbol
**, boolean
));
172 static long som_get_symtab
PARAMS ((bfd
*, asymbol
**));
173 static asymbol
* som_make_empty_symbol
PARAMS ((bfd
*));
174 static void som_print_symbol
PARAMS ((bfd
*, PTR
,
175 asymbol
*, bfd_print_symbol_type
));
176 static boolean som_new_section_hook
PARAMS ((bfd
*, asection
*));
177 static boolean som_bfd_copy_private_symbol_data
PARAMS ((bfd
*, asymbol
*,
179 static boolean som_bfd_copy_private_section_data
PARAMS ((bfd
*, asection
*,
181 static boolean som_bfd_copy_private_bfd_data
PARAMS ((bfd
*, bfd
*));
182 #define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
183 #define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
184 static boolean som_bfd_is_local_label_name
PARAMS ((bfd
*, const char *));
185 static boolean som_set_section_contents
PARAMS ((bfd
*, sec_ptr
, PTR
,
186 file_ptr
, bfd_size_type
));
187 static boolean som_get_section_contents
PARAMS ((bfd
*, sec_ptr
, PTR
,
188 file_ptr
, bfd_size_type
));
189 static boolean som_set_arch_mach
PARAMS ((bfd
*, enum bfd_architecture
,
191 static boolean som_find_nearest_line
PARAMS ((bfd
*, asection
*,
196 static void som_get_symbol_info
PARAMS ((bfd
*, asymbol
*, symbol_info
*));
197 static asection
* bfd_section_from_som_symbol
PARAMS ((bfd
*,
198 struct symbol_dictionary_record
*));
199 static int log2
PARAMS ((unsigned int));
200 static bfd_reloc_status_type hppa_som_reloc
PARAMS ((bfd
*, arelent
*,
204 static void som_initialize_reloc_queue
PARAMS ((struct reloc_queue
*));
205 static void som_reloc_queue_insert
PARAMS ((unsigned char *, unsigned int,
206 struct reloc_queue
*));
207 static void som_reloc_queue_fix
PARAMS ((struct reloc_queue
*, unsigned int));
208 static int som_reloc_queue_find
PARAMS ((unsigned char *, unsigned int,
209 struct reloc_queue
*));
210 static unsigned char * try_prev_fixup
PARAMS ((bfd
*, int *, unsigned char *,
212 struct reloc_queue
*));
214 static unsigned char * som_reloc_skip
PARAMS ((bfd
*, unsigned int,
215 unsigned char *, unsigned int *,
216 struct reloc_queue
*));
217 static unsigned char * som_reloc_addend
PARAMS ((bfd
*, int, unsigned char *,
219 struct reloc_queue
*));
220 static unsigned char * som_reloc_call
PARAMS ((bfd
*, unsigned char *,
223 struct reloc_queue
*));
224 static unsigned long som_count_spaces
PARAMS ((bfd
*));
225 static unsigned long som_count_subspaces
PARAMS ((bfd
*));
226 static int compare_syms
PARAMS ((const void *, const void *));
227 static int compare_subspaces
PARAMS ((const void *, const void *));
228 static unsigned long som_compute_checksum
PARAMS ((bfd
*));
229 static boolean som_prep_headers
PARAMS ((bfd
*));
230 static int som_sizeof_headers
PARAMS ((bfd
*, boolean
));
231 static boolean som_finish_writing
PARAMS ((bfd
*));
232 static boolean som_build_and_write_symbol_table
PARAMS ((bfd
*));
233 static void som_prep_for_fixups
PARAMS ((bfd
*, asymbol
**, unsigned long));
234 static boolean som_write_fixups
PARAMS ((bfd
*, unsigned long, unsigned int *));
235 static boolean som_write_space_strings
PARAMS ((bfd
*, unsigned long,
237 static boolean som_write_symbol_strings
PARAMS ((bfd
*, unsigned long,
238 asymbol
**, unsigned int,
241 static boolean som_begin_writing
PARAMS ((bfd
*));
242 static reloc_howto_type
* som_bfd_reloc_type_lookup
243 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
244 static char som_section_type
PARAMS ((const char *));
245 static int som_decode_symclass
PARAMS ((asymbol
*));
246 static boolean som_bfd_count_ar_symbols
PARAMS ((bfd
*, struct lst_header
*,
249 static boolean som_bfd_fill_in_ar_symbols
PARAMS ((bfd
*, struct lst_header
*,
251 static boolean som_slurp_armap
PARAMS ((bfd
*));
252 static boolean som_write_armap
PARAMS ((bfd
*, unsigned int, struct orl
*,
254 static void som_bfd_derive_misc_symbol_info
PARAMS ((bfd
*, asymbol
*,
255 struct som_misc_symbol_info
*));
256 static boolean som_bfd_prep_for_ar_write
PARAMS ((bfd
*, unsigned int *,
258 static unsigned int som_bfd_ar_symbol_hash
PARAMS ((asymbol
*));
259 static boolean som_bfd_ar_write_symbol_stuff
PARAMS ((bfd
*, unsigned int,
263 static boolean som_is_space
PARAMS ((asection
*));
264 static boolean som_is_subspace
PARAMS ((asection
*));
265 static boolean som_is_container
PARAMS ((asection
*, asection
*));
266 static boolean som_bfd_free_cached_info
PARAMS ((bfd
*));
267 static boolean som_bfd_link_split_section
PARAMS ((bfd
*, asection
*));
269 /* Map SOM section names to POSIX/BSD single-character symbol types.
271 This table includes all the standard subspaces as defined in the
272 current "PRO ABI for PA-RISC Systems", $UNWIND$ which for
273 some reason was left out, and sections specific to embedded stabs. */
275 static const struct section_to_type stt
[] = {
277 {"$SHLIB_INFO$", 't'},
278 {"$MILLICODE$", 't'},
281 {"$UNWIND_START$", 't'},
285 {"$SHLIB_DATA$", 'd'},
287 {"$SHORTDATA$", 'g'},
292 {"$GDB_STRINGS$", 'N'},
293 {"$GDB_SYMBOLS$", 'N'},
297 /* About the relocation formatting table...
299 There are 256 entries in the table, one for each possible
300 relocation opcode available in SOM. We index the table by
301 the relocation opcode. The names and operations are those
302 defined by a.out_800 (4).
304 Right now this table is only used to count and perform minimal
305 processing on relocation streams so that they can be internalized
306 into BFD and symbolically printed by utilities. To make actual use
307 of them would be much more difficult, BFD's concept of relocations
308 is far too simple to handle SOM relocations. The basic assumption
309 that a relocation can be completely processed independent of other
310 relocations before an object file is written is invalid for SOM.
312 The SOM relocations are meant to be processed as a stream, they
313 specify copying of data from the input section to the output section
314 while possibly modifying the data in some manner. They also can
315 specify that a variable number of zeros or uninitialized data be
316 inserted on in the output segment at the current offset. Some
317 relocations specify that some previous relocation be re-applied at
318 the current location in the input/output sections. And finally a number
319 of relocations have effects on other sections (R_ENTRY, R_EXIT,
320 R_UNWIND_AUX and a variety of others). There isn't even enough room
321 in the BFD relocation data structure to store enough information to
322 perform all the relocations.
324 Each entry in the table has three fields.
326 The first entry is an index into this "class" of relocations. This
327 index can then be used as a variable within the relocation itself.
329 The second field is a format string which actually controls processing
330 of the relocation. It uses a simple postfix machine to do calculations
331 based on variables/constants found in the string and the relocation
334 The third field specifys whether or not this relocation may use
335 a constant (V) from the previous R_DATA_OVERRIDE rather than a constant
336 stored in the instruction.
340 L = input space byte count
341 D = index into class of relocations
342 M = output space byte count
343 N = statement number (unused?)
345 R = parameter relocation bits
347 T = first 32 bits of stack unwind information
348 U = second 32 bits of stack unwind information
349 V = a literal constant (usually used in the next relocation)
350 P = a previous relocation
352 Lower case letters (starting with 'b') refer to following
353 bytes in the relocation stream. 'b' is the next 1 byte,
354 c is the next 2 bytes, d is the next 3 bytes, etc...
355 This is the variable part of the relocation entries that
356 makes our life a living hell.
358 numerical constants are also used in the format string. Note
359 the constants are represented in decimal.
361 '+', "*" and "=" represents the obvious postfix operators.
362 '<' represents a left shift.
366 Parameter Relocation Bits:
370 Previous Relocations: The index field represents which in the queue
371 of 4 previous fixups should be re-applied.
373 Literal Constants: These are generally used to represent addend
374 parts of relocations when these constants are not stored in the
375 fields of the instructions themselves. For example the instruction
376 addil foo-$global$-0x1234 would use an override for "0x1234" rather
377 than storing it into the addil itself. */
379 struct fixup_format
{
384 static const struct fixup_format som_fixup_formats
[256] = {
385 /* R_NO_RELOCATION */
386 0, "LD1+4*=", /* 0x00 */
387 1, "LD1+4*=", /* 0x01 */
388 2, "LD1+4*=", /* 0x02 */
389 3, "LD1+4*=", /* 0x03 */
390 4, "LD1+4*=", /* 0x04 */
391 5, "LD1+4*=", /* 0x05 */
392 6, "LD1+4*=", /* 0x06 */
393 7, "LD1+4*=", /* 0x07 */
394 8, "LD1+4*=", /* 0x08 */
395 9, "LD1+4*=", /* 0x09 */
396 10, "LD1+4*=", /* 0x0a */
397 11, "LD1+4*=", /* 0x0b */
398 12, "LD1+4*=", /* 0x0c */
399 13, "LD1+4*=", /* 0x0d */
400 14, "LD1+4*=", /* 0x0e */
401 15, "LD1+4*=", /* 0x0f */
402 16, "LD1+4*=", /* 0x10 */
403 17, "LD1+4*=", /* 0x11 */
404 18, "LD1+4*=", /* 0x12 */
405 19, "LD1+4*=", /* 0x13 */
406 20, "LD1+4*=", /* 0x14 */
407 21, "LD1+4*=", /* 0x15 */
408 22, "LD1+4*=", /* 0x16 */
409 23, "LD1+4*=", /* 0x17 */
410 0, "LD8<b+1+4*=", /* 0x18 */
411 1, "LD8<b+1+4*=", /* 0x19 */
412 2, "LD8<b+1+4*=", /* 0x1a */
413 3, "LD8<b+1+4*=", /* 0x1b */
414 0, "LD16<c+1+4*=", /* 0x1c */
415 1, "LD16<c+1+4*=", /* 0x1d */
416 2, "LD16<c+1+4*=", /* 0x1e */
417 0, "Ld1+=", /* 0x1f */
419 0, "Lb1+4*=", /* 0x20 */
420 1, "Ld1+=", /* 0x21 */
422 0, "Lb1+4*=", /* 0x22 */
423 1, "Ld1+=", /* 0x23 */
426 /* R_DATA_ONE_SYMBOL */
427 0, "L4=Sb=", /* 0x25 */
428 1, "L4=Sd=", /* 0x26 */
430 0, "L4=Sb=", /* 0x27 */
431 1, "L4=Sd=", /* 0x28 */
434 /* R_REPEATED_INIT */
435 0, "L4=Mb1+4*=", /* 0x2a */
436 1, "Lb4*=Mb1+L*=", /* 0x2b */
437 2, "Lb4*=Md1+4*=", /* 0x2c */
438 3, "Ld1+=Me1+=", /* 0x2d */
442 0, "L4=RD=Sb=", /* 0x30 */
443 1, "L4=RD=Sb=", /* 0x31 */
444 2, "L4=RD=Sb=", /* 0x32 */
445 3, "L4=RD=Sb=", /* 0x33 */
446 4, "L4=RD=Sb=", /* 0x34 */
447 5, "L4=RD=Sb=", /* 0x35 */
448 6, "L4=RD=Sb=", /* 0x36 */
449 7, "L4=RD=Sb=", /* 0x37 */
450 8, "L4=RD=Sb=", /* 0x38 */
451 9, "L4=RD=Sb=", /* 0x39 */
452 0, "L4=RD8<b+=Sb=",/* 0x3a */
453 1, "L4=RD8<b+=Sb=",/* 0x3b */
454 0, "L4=RD8<b+=Sd=",/* 0x3c */
455 1, "L4=RD8<b+=Sd=",/* 0x3d */
456 /* R_SHORT_PCREL_MODE */
458 /* R_LONG_PCREL_MODE */
461 0, "L4=RD=Sb=", /* 0x40 */
462 1, "L4=RD=Sb=", /* 0x41 */
463 2, "L4=RD=Sb=", /* 0x42 */
464 3, "L4=RD=Sb=", /* 0x43 */
465 4, "L4=RD=Sb=", /* 0x44 */
466 5, "L4=RD=Sb=", /* 0x45 */
467 6, "L4=RD=Sb=", /* 0x46 */
468 7, "L4=RD=Sb=", /* 0x47 */
469 8, "L4=RD=Sb=", /* 0x48 */
470 9, "L4=RD=Sb=", /* 0x49 */
471 0, "L4=RD8<b+=Sb=",/* 0x4a */
472 1, "L4=RD8<b+=Sb=",/* 0x4b */
473 0, "L4=RD8<b+=Sd=",/* 0x4c */
474 1, "L4=RD8<b+=Sd=",/* 0x4d */
479 0, "L4=SD=", /* 0x50 */
480 1, "L4=SD=", /* 0x51 */
481 2, "L4=SD=", /* 0x52 */
482 3, "L4=SD=", /* 0x53 */
483 4, "L4=SD=", /* 0x54 */
484 5, "L4=SD=", /* 0x55 */
485 6, "L4=SD=", /* 0x56 */
486 7, "L4=SD=", /* 0x57 */
487 8, "L4=SD=", /* 0x58 */
488 9, "L4=SD=", /* 0x59 */
489 10, "L4=SD=", /* 0x5a */
490 11, "L4=SD=", /* 0x5b */
491 12, "L4=SD=", /* 0x5c */
492 13, "L4=SD=", /* 0x5d */
493 14, "L4=SD=", /* 0x5e */
494 15, "L4=SD=", /* 0x5f */
495 16, "L4=SD=", /* 0x60 */
496 17, "L4=SD=", /* 0x61 */
497 18, "L4=SD=", /* 0x62 */
498 19, "L4=SD=", /* 0x63 */
499 20, "L4=SD=", /* 0x64 */
500 21, "L4=SD=", /* 0x65 */
501 22, "L4=SD=", /* 0x66 */
502 23, "L4=SD=", /* 0x67 */
503 24, "L4=SD=", /* 0x68 */
504 25, "L4=SD=", /* 0x69 */
505 26, "L4=SD=", /* 0x6a */
506 27, "L4=SD=", /* 0x6b */
507 28, "L4=SD=", /* 0x6c */
508 29, "L4=SD=", /* 0x6d */
509 30, "L4=SD=", /* 0x6e */
510 31, "L4=SD=", /* 0x6f */
511 32, "L4=Sb=", /* 0x70 */
512 33, "L4=Sd=", /* 0x71 */
521 0, "L4=Sb=", /* 0x78 */
522 1, "L4=Sd=", /* 0x79 */
530 /* R_CODE_ONE_SYMBOL */
531 0, "L4=SD=", /* 0x80 */
532 1, "L4=SD=", /* 0x81 */
533 2, "L4=SD=", /* 0x82 */
534 3, "L4=SD=", /* 0x83 */
535 4, "L4=SD=", /* 0x84 */
536 5, "L4=SD=", /* 0x85 */
537 6, "L4=SD=", /* 0x86 */
538 7, "L4=SD=", /* 0x87 */
539 8, "L4=SD=", /* 0x88 */
540 9, "L4=SD=", /* 0x89 */
541 10, "L4=SD=", /* 0x8q */
542 11, "L4=SD=", /* 0x8b */
543 12, "L4=SD=", /* 0x8c */
544 13, "L4=SD=", /* 0x8d */
545 14, "L4=SD=", /* 0x8e */
546 15, "L4=SD=", /* 0x8f */
547 16, "L4=SD=", /* 0x90 */
548 17, "L4=SD=", /* 0x91 */
549 18, "L4=SD=", /* 0x92 */
550 19, "L4=SD=", /* 0x93 */
551 20, "L4=SD=", /* 0x94 */
552 21, "L4=SD=", /* 0x95 */
553 22, "L4=SD=", /* 0x96 */
554 23, "L4=SD=", /* 0x97 */
555 24, "L4=SD=", /* 0x98 */
556 25, "L4=SD=", /* 0x99 */
557 26, "L4=SD=", /* 0x9a */
558 27, "L4=SD=", /* 0x9b */
559 28, "L4=SD=", /* 0x9c */
560 29, "L4=SD=", /* 0x9d */
561 30, "L4=SD=", /* 0x9e */
562 31, "L4=SD=", /* 0x9f */
563 32, "L4=Sb=", /* 0xa0 */
564 33, "L4=Sd=", /* 0xa1 */
579 0, "L4=Sb=", /* 0xae */
580 1, "L4=Sd=", /* 0xaf */
582 0, "L4=Sb=", /* 0xb0 */
583 1, "L4=Sd=", /* 0xb1 */
587 0, "Te=Ue=", /* 0xb3 */
597 1, "Rb4*=", /* 0xb9 */
598 2, "Rd4*=", /* 0xba */
625 /* R_DATA_OVERRIDE */
634 0, "Sd=Vf=Ef=", /* 0xcf */
638 0, "Ob=Sd=", /* 0xd1 */
640 0, "Ob=Ve=", /* 0xd2 */
653 0, "Eb=Sd=Ve=", /* 0xda */
655 0, "Eb=Mb=", /* 0xdb */
659 0, "Ob=Ve=", /* 0xdd */
697 static const int comp1_opcodes
[] = {
718 static const int comp2_opcodes
[] = {
726 static const int comp3_opcodes
[] = {
732 /* These apparently are not in older versions of hpux reloc.h (hpux7). */
734 #define R_DLT_REL 0x78
738 #define R_AUX_UNWIND 0xcf
742 #define R_SEC_STMT 0xd7
745 /* And these first appeared in hpux10. */
746 #ifndef R_SHORT_PCREL_MODE
747 #define NO_PCREL_MODES
748 #define R_SHORT_PCREL_MODE 0x3e
751 #ifndef R_LONG_PCREL_MODE
752 #define R_LONG_PCREL_MODE 0x3f
764 #define R_LINETAB 0xda
767 #ifndef R_LINETAB_ESC
768 #define R_LINETAB_ESC 0xdb
771 #ifndef R_LTP_OVERRIDE
772 #define R_LTP_OVERRIDE 0xdc
776 #define R_COMMENT 0xdd
779 #define SOM_HOWTO(TYPE, NAME) \
780 HOWTO(TYPE, 0, 0, 32, false, 0, 0, hppa_som_reloc, NAME, false, 0, 0, false)
782 static reloc_howto_type som_hppa_howto_table
[] = {
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_NO_RELOCATION
, "R_NO_RELOCATION"),
815 SOM_HOWTO (R_ZEROES
, "R_ZEROES"),
816 SOM_HOWTO (R_ZEROES
, "R_ZEROES"),
817 SOM_HOWTO (R_UNINIT
, "R_UNINIT"),
818 SOM_HOWTO (R_UNINIT
, "R_UNINIT"),
819 SOM_HOWTO (R_RELOCATION
, "R_RELOCATION"),
820 SOM_HOWTO (R_DATA_ONE_SYMBOL
, "R_DATA_ONE_SYMBOL"),
821 SOM_HOWTO (R_DATA_ONE_SYMBOL
, "R_DATA_ONE_SYMBOL"),
822 SOM_HOWTO (R_DATA_PLABEL
, "R_DATA_PLABEL"),
823 SOM_HOWTO (R_DATA_PLABEL
, "R_DATA_PLABEL"),
824 SOM_HOWTO (R_SPACE_REF
, "R_SPACE_REF"),
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_REPEATED_INIT
, "REPEATED_INIT"),
829 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
830 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
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_PCREL_CALL
, "R_PCREL_CALL"),
845 SOM_HOWTO (R_SHORT_PCREL_MODE
, "R_SHORT_PCREL_MODE"),
846 SOM_HOWTO (R_LONG_PCREL_MODE
, "R_LONG_PCREL_MODE"),
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_ABS_CALL
, "R_ABS_CALL"),
861 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
862 SOM_HOWTO (R_RESERVED
, "R_RESERVED"),
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_DP_RELATIVE
, "R_DP_RELATIVE"),
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_RESERVED
, "R_RESERVED"),
903 SOM_HOWTO (R_DLT_REL
, "R_DLT_REL"),
904 SOM_HOWTO (R_DLT_REL
, "R_DLT_REL"),
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_RESERVED
, "R_RESERVED"),
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_CODE_ONE_SYMBOL
, "R_CODE_ONE_SYMBOL"),
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_RESERVED
, "R_RESERVED"),
957 SOM_HOWTO (R_MILLI_REL
, "R_MILLI_REL"),
958 SOM_HOWTO (R_MILLI_REL
, "R_MILLI_REL"),
959 SOM_HOWTO (R_CODE_PLABEL
, "R_CODE_PLABEL"),
960 SOM_HOWTO (R_CODE_PLABEL
, "R_CODE_PLABEL"),
961 SOM_HOWTO (R_BREAKPOINT
, "R_BREAKPOINT"),
962 SOM_HOWTO (R_ENTRY
, "R_ENTRY"),
963 SOM_HOWTO (R_ENTRY
, "R_ENTRY"),
964 SOM_HOWTO (R_ALT_ENTRY
, "R_ALT_ENTRY"),
965 SOM_HOWTO (R_EXIT
, "R_EXIT"),
966 SOM_HOWTO (R_BEGIN_TRY
, "R_BEGIN_TRY"),
967 SOM_HOWTO (R_END_TRY
, "R_END_TRY"),
968 SOM_HOWTO (R_END_TRY
, "R_END_TRY"),
969 SOM_HOWTO (R_END_TRY
, "R_END_TRY"),
970 SOM_HOWTO (R_BEGIN_BRTAB
, "R_BEGIN_BRTAB"),
971 SOM_HOWTO (R_END_BRTAB
, "R_END_BRTAB"),
972 SOM_HOWTO (R_STATEMENT
, "R_STATEMENT"),
973 SOM_HOWTO (R_STATEMENT
, "R_STATEMENT"),
974 SOM_HOWTO (R_STATEMENT
, "R_STATEMENT"),
975 SOM_HOWTO (R_DATA_EXPR
, "R_DATA_EXPR"),
976 SOM_HOWTO (R_CODE_EXPR
, "R_CODE_EXPR"),
977 SOM_HOWTO (R_FSEL
, "R_FSEL"),
978 SOM_HOWTO (R_LSEL
, "R_LSEL"),
979 SOM_HOWTO (R_RSEL
, "R_RSEL"),
980 SOM_HOWTO (R_N_MODE
, "R_N_MODE"),
981 SOM_HOWTO (R_S_MODE
, "R_S_MODE"),
982 SOM_HOWTO (R_D_MODE
, "R_D_MODE"),
983 SOM_HOWTO (R_R_MODE
, "R_R_MODE"),
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_DATA_OVERRIDE
, "R_DATA_OVERRIDE"),
989 SOM_HOWTO (R_TRANSLATED
, "R_TRANSLATED"),
990 SOM_HOWTO (R_AUX_UNWIND
, "R_AUX_UNWIND"),
991 SOM_HOWTO (R_COMP1
, "R_COMP1"),
992 SOM_HOWTO (R_COMP2
, "R_COMP2"),
993 SOM_HOWTO (R_COMP3
, "R_COMP3"),
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_PREV_FIXUP
, "R_PREV_FIXUP"),
998 SOM_HOWTO (R_SEC_STMT
, "R_SEC_STMT"),
999 SOM_HOWTO (R_N0SEL
, "R_N0SEL"),
1000 SOM_HOWTO (R_N1SEL
, "R_N1SEL"),
1001 SOM_HOWTO (R_LINETAB
, "R_LINETAB"),
1002 SOM_HOWTO (R_LINETAB_ESC
, "R_LINETAB_ESC"),
1003 SOM_HOWTO (R_LTP_OVERRIDE
, "R_LTP_OVERRIDE"),
1004 SOM_HOWTO (R_COMMENT
, "R_COMMENT"),
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"),
1038 SOM_HOWTO (R_RESERVED
, "R_RESERVED")
1041 /* Initialize the SOM relocation queue. By definition the queue holds
1042 the last four multibyte fixups. */
1045 som_initialize_reloc_queue (queue
)
1046 struct reloc_queue
*queue
;
1048 queue
[0].reloc
= NULL
;
1050 queue
[1].reloc
= NULL
;
1052 queue
[2].reloc
= NULL
;
1054 queue
[3].reloc
= NULL
;
1058 /* Insert a new relocation into the relocation queue. */
1061 som_reloc_queue_insert (p
, size
, queue
)
1064 struct reloc_queue
*queue
;
1066 queue
[3].reloc
= queue
[2].reloc
;
1067 queue
[3].size
= queue
[2].size
;
1068 queue
[2].reloc
= queue
[1].reloc
;
1069 queue
[2].size
= queue
[1].size
;
1070 queue
[1].reloc
= queue
[0].reloc
;
1071 queue
[1].size
= queue
[0].size
;
1073 queue
[0].size
= size
;
1076 /* When an entry in the relocation queue is reused, the entry moves
1077 to the front of the queue. */
1080 som_reloc_queue_fix (queue
, index
)
1081 struct reloc_queue
*queue
;
1089 unsigned char *tmp1
= queue
[0].reloc
;
1090 unsigned int tmp2
= queue
[0].size
;
1091 queue
[0].reloc
= queue
[1].reloc
;
1092 queue
[0].size
= queue
[1].size
;
1093 queue
[1].reloc
= tmp1
;
1094 queue
[1].size
= tmp2
;
1100 unsigned char *tmp1
= queue
[0].reloc
;
1101 unsigned int tmp2
= queue
[0].size
;
1102 queue
[0].reloc
= queue
[2].reloc
;
1103 queue
[0].size
= queue
[2].size
;
1104 queue
[2].reloc
= queue
[1].reloc
;
1105 queue
[2].size
= queue
[1].size
;
1106 queue
[1].reloc
= tmp1
;
1107 queue
[1].size
= tmp2
;
1113 unsigned char *tmp1
= queue
[0].reloc
;
1114 unsigned int tmp2
= queue
[0].size
;
1115 queue
[0].reloc
= queue
[3].reloc
;
1116 queue
[0].size
= queue
[3].size
;
1117 queue
[3].reloc
= queue
[2].reloc
;
1118 queue
[3].size
= queue
[2].size
;
1119 queue
[2].reloc
= queue
[1].reloc
;
1120 queue
[2].size
= queue
[1].size
;
1121 queue
[1].reloc
= tmp1
;
1122 queue
[1].size
= tmp2
;
1128 /* Search for a particular relocation in the relocation queue. */
1131 som_reloc_queue_find (p
, size
, queue
)
1134 struct reloc_queue
*queue
;
1136 if (queue
[0].reloc
&& !memcmp (p
, queue
[0].reloc
, size
)
1137 && size
== queue
[0].size
)
1139 if (queue
[1].reloc
&& !memcmp (p
, queue
[1].reloc
, size
)
1140 && size
== queue
[1].size
)
1142 if (queue
[2].reloc
&& !memcmp (p
, queue
[2].reloc
, size
)
1143 && size
== queue
[2].size
)
1145 if (queue
[3].reloc
&& !memcmp (p
, queue
[3].reloc
, size
)
1146 && size
== queue
[3].size
)
1151 static unsigned char *
1152 try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, size
, queue
)
1153 bfd
*abfd ATTRIBUTE_UNUSED
;
1154 int *subspace_reloc_sizep
;
1157 struct reloc_queue
*queue
;
1159 int queue_index
= som_reloc_queue_find (p
, size
, queue
);
1161 if (queue_index
!= -1)
1163 /* Found this in a previous fixup. Undo the fixup we
1164 just built and use R_PREV_FIXUP instead. We saved
1165 a total of size - 1 bytes in the fixup stream. */
1166 bfd_put_8 (abfd
, R_PREV_FIXUP
+ queue_index
, p
);
1168 *subspace_reloc_sizep
+= 1;
1169 som_reloc_queue_fix (queue
, queue_index
);
1173 som_reloc_queue_insert (p
, size
, queue
);
1174 *subspace_reloc_sizep
+= size
;
1180 /* Emit the proper R_NO_RELOCATION fixups to map the next SKIP
1181 bytes without any relocation. Update the size of the subspace
1182 relocation stream via SUBSPACE_RELOC_SIZE_P; also return the
1183 current pointer into the relocation stream. */
1185 static unsigned char *
1186 som_reloc_skip (abfd
, skip
, p
, subspace_reloc_sizep
, queue
)
1190 unsigned int *subspace_reloc_sizep
;
1191 struct reloc_queue
*queue
;
1193 /* Use a 4 byte R_NO_RELOCATION entry with a maximal value
1194 then R_PREV_FIXUPs to get the difference down to a
1196 if (skip
>= 0x1000000)
1199 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 31, p
);
1200 bfd_put_8 (abfd
, 0xff, p
+ 1);
1201 bfd_put_16 (abfd
, 0xffff, p
+ 2);
1202 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 4, queue
);
1203 while (skip
>= 0x1000000)
1206 bfd_put_8 (abfd
, R_PREV_FIXUP
, p
);
1208 *subspace_reloc_sizep
+= 1;
1209 /* No need to adjust queue here since we are repeating the
1210 most recent fixup. */
1214 /* The difference must be less than 0x1000000. Use one
1215 more R_NO_RELOCATION entry to get to the right difference. */
1216 if ((skip
& 3) == 0 && skip
<= 0xc0000 && skip
> 0)
1218 /* Difference can be handled in a simple single-byte
1219 R_NO_RELOCATION entry. */
1222 bfd_put_8 (abfd
, R_NO_RELOCATION
+ (skip
>> 2) - 1, p
);
1223 *subspace_reloc_sizep
+= 1;
1226 /* Handle it with a two byte R_NO_RELOCATION entry. */
1227 else if (skip
<= 0x1000)
1229 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 24 + (((skip
>> 2) - 1) >> 8), p
);
1230 bfd_put_8 (abfd
, (skip
>> 2) - 1, p
+ 1);
1231 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 2, queue
);
1233 /* Handle it with a three byte R_NO_RELOCATION entry. */
1236 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 28 + (((skip
>> 2) - 1) >> 16), p
);
1237 bfd_put_16 (abfd
, (skip
>> 2) - 1, p
+ 1);
1238 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 3, queue
);
1241 /* Ugh. Punt and use a 4 byte entry. */
1244 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 31, p
);
1245 bfd_put_8 (abfd
, (skip
- 1) >> 16, p
+ 1);
1246 bfd_put_16 (abfd
, skip
- 1, p
+ 2);
1247 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 4, queue
);
1252 /* Emit the proper R_DATA_OVERRIDE fixups to handle a nonzero addend
1253 from a BFD relocation. Update the size of the subspace relocation
1254 stream via SUBSPACE_RELOC_SIZE_P; also return the current pointer
1255 into the relocation stream. */
1257 static unsigned char *
1258 som_reloc_addend (abfd
, addend
, p
, subspace_reloc_sizep
, queue
)
1262 unsigned int *subspace_reloc_sizep
;
1263 struct reloc_queue
*queue
;
1265 if ((unsigned) (addend
) + 0x80 < 0x100)
1267 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 1, p
);
1268 bfd_put_8 (abfd
, addend
, p
+ 1);
1269 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 2, queue
);
1271 else if ((unsigned) (addend
) + 0x8000 < 0x10000)
1273 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 2, p
);
1274 bfd_put_16 (abfd
, addend
, p
+ 1);
1275 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 3, queue
);
1277 else if ((unsigned) (addend
) + 0x800000 < 0x1000000)
1279 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 3, p
);
1280 bfd_put_8 (abfd
, addend
>> 16, p
+ 1);
1281 bfd_put_16 (abfd
, addend
, p
+ 2);
1282 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 4, queue
);
1286 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 4, p
);
1287 bfd_put_32 (abfd
, addend
, p
+ 1);
1288 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 5, queue
);
1293 /* Handle a single function call relocation. */
1295 static unsigned char *
1296 som_reloc_call (abfd
, p
, subspace_reloc_sizep
, bfd_reloc
, sym_num
, queue
)
1299 unsigned int *subspace_reloc_sizep
;
1302 struct reloc_queue
*queue
;
1304 int arg_bits
= HPPA_R_ARG_RELOC (bfd_reloc
->addend
);
1305 int rtn_bits
= arg_bits
& 0x3;
1308 /* You'll never believe all this is necessary to handle relocations
1309 for function calls. Having to compute and pack the argument
1310 relocation bits is the real nightmare.
1312 If you're interested in how this works, just forget it. You really
1313 do not want to know about this braindamage. */
1315 /* First see if this can be done with a "simple" relocation. Simple
1316 relocations have a symbol number < 0x100 and have simple encodings
1317 of argument relocations. */
1319 if (sym_num
< 0x100)
1331 case 1 << 8 | 1 << 6:
1332 case 1 << 8 | 1 << 6 | 1:
1335 case 1 << 8 | 1 << 6 | 1 << 4:
1336 case 1 << 8 | 1 << 6 | 1 << 4 | 1:
1339 case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2:
1340 case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2 | 1:
1344 /* Not one of the easy encodings. This will have to be
1345 handled by the more complex code below. */
1351 /* Account for the return value too. */
1355 /* Emit a 2 byte relocation. Then see if it can be handled
1356 with a relocation which is already in the relocation queue. */
1357 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ type
, p
);
1358 bfd_put_8 (abfd
, sym_num
, p
+ 1);
1359 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 2, queue
);
1364 /* If this could not be handled with a simple relocation, then do a hard
1365 one. Hard relocations occur if the symbol number was too high or if
1366 the encoding of argument relocation bits is too complex. */
1369 /* Don't ask about these magic sequences. I took them straight
1370 from gas-1.36 which took them from the a.out man page. */
1372 if ((arg_bits
>> 6 & 0xf) == 0xe)
1375 type
+= (3 * (arg_bits
>> 8 & 3) + (arg_bits
>> 6 & 3)) * 40;
1376 if ((arg_bits
>> 2 & 0xf) == 0xe)
1379 type
+= (3 * (arg_bits
>> 4 & 3) + (arg_bits
>> 2 & 3)) * 4;
1381 /* Output the first two bytes of the relocation. These describe
1382 the length of the relocation and encoding style. */
1383 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 10
1384 + 2 * (sym_num
>= 0x100) + (type
>= 0x100),
1386 bfd_put_8 (abfd
, type
, p
+ 1);
1388 /* Now output the symbol index and see if this bizarre relocation
1389 just happened to be in the relocation queue. */
1390 if (sym_num
< 0x100)
1392 bfd_put_8 (abfd
, sym_num
, p
+ 2);
1393 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 3, queue
);
1397 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 2);
1398 bfd_put_16 (abfd
, sym_num
, p
+ 3);
1399 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 5, queue
);
1405 /* Return the logarithm of X, base 2, considering X unsigned.
1406 Abort -1 if X is not a power or two or is zero. */
1414 /* Test for 0 or a power of 2. */
1415 if (x
== 0 || x
!= (x
& -x
))
1418 while ((x
>>= 1) != 0)
1423 static bfd_reloc_status_type
1424 hppa_som_reloc (abfd
, reloc_entry
, symbol_in
, data
,
1425 input_section
, output_bfd
, error_message
)
1426 bfd
*abfd ATTRIBUTE_UNUSED
;
1427 arelent
*reloc_entry
;
1428 asymbol
*symbol_in ATTRIBUTE_UNUSED
;
1429 PTR data ATTRIBUTE_UNUSED
;
1430 asection
*input_section
;
1432 char **error_message ATTRIBUTE_UNUSED
;
1436 reloc_entry
->address
+= input_section
->output_offset
;
1437 return bfd_reloc_ok
;
1439 return bfd_reloc_ok
;
1442 /* Given a generic HPPA relocation type, the instruction format,
1443 and a field selector, return one or more appropriate SOM relocations. */
1446 hppa_som_gen_reloc_type (abfd
, base_type
, format
, field
, sym_diff
, sym
)
1450 enum hppa_reloc_field_selector_type_alt field
;
1454 int *final_type
, **final_types
;
1456 final_types
= (int **) bfd_alloc (abfd
, sizeof (int *) * 6);
1457 final_type
= (int *) bfd_alloc (abfd
, sizeof (int));
1458 if (!final_types
|| !final_type
)
1461 /* The field selector may require additional relocations to be
1462 generated. It's impossible to know at this moment if additional
1463 relocations will be needed, so we make them. The code to actually
1464 write the relocation/fixup stream is responsible for removing
1465 any redundant relocations. */
1472 final_types
[0] = final_type
;
1473 final_types
[1] = NULL
;
1474 final_types
[2] = NULL
;
1475 *final_type
= base_type
;
1481 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1482 if (!final_types
[0])
1484 if (field
== e_tsel
)
1485 *final_types
[0] = R_FSEL
;
1486 else if (field
== e_ltsel
)
1487 *final_types
[0] = R_LSEL
;
1489 *final_types
[0] = R_RSEL
;
1490 final_types
[1] = final_type
;
1491 final_types
[2] = NULL
;
1492 *final_type
= base_type
;
1497 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1498 if (!final_types
[0])
1500 *final_types
[0] = R_S_MODE
;
1501 final_types
[1] = final_type
;
1502 final_types
[2] = NULL
;
1503 *final_type
= base_type
;
1508 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1509 if (!final_types
[0])
1511 *final_types
[0] = R_N_MODE
;
1512 final_types
[1] = final_type
;
1513 final_types
[2] = NULL
;
1514 *final_type
= base_type
;
1519 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1520 if (!final_types
[0])
1522 *final_types
[0] = R_D_MODE
;
1523 final_types
[1] = final_type
;
1524 final_types
[2] = NULL
;
1525 *final_type
= base_type
;
1530 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1531 if (!final_types
[0])
1533 *final_types
[0] = R_R_MODE
;
1534 final_types
[1] = final_type
;
1535 final_types
[2] = NULL
;
1536 *final_type
= base_type
;
1540 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1541 if (!final_types
[0])
1543 *final_types
[0] = R_N1SEL
;
1544 final_types
[1] = final_type
;
1545 final_types
[2] = NULL
;
1546 *final_type
= base_type
;
1551 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1552 if (!final_types
[0])
1554 *final_types
[0] = R_N0SEL
;
1555 final_types
[1] = (int *) bfd_alloc (abfd
, sizeof (int));
1556 if (!final_types
[1])
1558 if (field
== e_nlsel
)
1559 *final_types
[1] = R_N_MODE
;
1561 *final_types
[1] = R_R_MODE
;
1562 final_types
[2] = final_type
;
1563 final_types
[3] = NULL
;
1564 *final_type
= base_type
;
1571 /* The difference of two symbols needs *very* special handling. */
1574 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1575 final_types
[1] = (int *) bfd_alloc (abfd
, sizeof (int));
1576 final_types
[2] = (int *) bfd_alloc (abfd
, sizeof (int));
1577 final_types
[3] = (int *) bfd_alloc (abfd
, sizeof (int));
1578 if (!final_types
[0] || !final_types
[1] || !final_types
[2])
1580 if (field
== e_fsel
)
1581 *final_types
[0] = R_FSEL
;
1582 else if (field
== e_rsel
)
1583 *final_types
[0] = R_RSEL
;
1584 else if (field
== e_lsel
)
1585 *final_types
[0] = R_LSEL
;
1586 *final_types
[1] = R_COMP2
;
1587 *final_types
[2] = R_COMP2
;
1588 *final_types
[3] = R_COMP1
;
1589 final_types
[4] = final_type
;
1591 *final_types
[4] = R_DATA_EXPR
;
1593 *final_types
[4] = R_CODE_EXPR
;
1594 final_types
[5] = NULL
;
1597 /* PLABELs get their own relocation type. */
1598 else if (field
== e_psel
1600 || field
== e_rpsel
)
1602 /* A PLABEL relocation that has a size of 32 bits must
1603 be a R_DATA_PLABEL. All others are R_CODE_PLABELs. */
1605 *final_type
= R_DATA_PLABEL
;
1607 *final_type
= R_CODE_PLABEL
;
1610 else if (field
== e_tsel
1612 || field
== e_rtsel
)
1613 *final_type
= R_DLT_REL
;
1614 /* A relocation in the data space is always a full 32bits. */
1615 else if (format
== 32)
1617 *final_type
= R_DATA_ONE_SYMBOL
;
1619 /* If there's no SOM symbol type associated with this BFD
1620 symbol, then set the symbol type to ST_DATA.
1622 Only do this if the type is going to default later when
1623 we write the object file.
1625 This is done so that the linker never encounters an
1626 R_DATA_ONE_SYMBOL reloc involving an ST_CODE symbol.
1628 This allows the compiler to generate exception handling
1631 Note that one day we may need to also emit BEGIN_BRTAB and
1632 END_BRTAB to prevent the linker from optimizing away insns
1633 in exception handling regions. */
1634 if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
1635 && (sym
->flags
& BSF_SECTION_SYM
) == 0
1636 && (sym
->flags
& BSF_FUNCTION
) == 0
1637 && ! bfd_is_com_section (sym
->section
))
1638 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_DATA
;
1643 /* More PLABEL special cases. */
1646 || field
== e_rpsel
)
1647 *final_type
= R_DATA_PLABEL
;
1650 case R_HPPA_COMPLEX
:
1651 /* The difference of two symbols needs *very* special handling. */
1654 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1655 final_types
[1] = (int *) bfd_alloc (abfd
, sizeof (int));
1656 final_types
[2] = (int *) bfd_alloc (abfd
, sizeof (int));
1657 final_types
[3] = (int *) bfd_alloc (abfd
, sizeof (int));
1658 if (!final_types
[0] || !final_types
[1] || !final_types
[2])
1660 if (field
== e_fsel
)
1661 *final_types
[0] = R_FSEL
;
1662 else if (field
== e_rsel
)
1663 *final_types
[0] = R_RSEL
;
1664 else if (field
== e_lsel
)
1665 *final_types
[0] = R_LSEL
;
1666 *final_types
[1] = R_COMP2
;
1667 *final_types
[2] = R_COMP2
;
1668 *final_types
[3] = R_COMP1
;
1669 final_types
[4] = final_type
;
1671 *final_types
[4] = R_DATA_EXPR
;
1673 *final_types
[4] = R_CODE_EXPR
;
1674 final_types
[5] = NULL
;
1681 case R_HPPA_ABS_CALL
:
1682 /* Right now we can default all these. */
1685 case R_HPPA_PCREL_CALL
:
1687 #ifndef NO_PCREL_MODES
1688 /* If we have short and long pcrel modes, then generate the proper
1689 mode selector, then the pcrel relocation. Redundant selectors
1690 will be eliminted as the relocs are sized and emitted. */
1691 final_types
[0] = (int *) bfd_alloc (abfd
, sizeof (int));
1692 if (!final_types
[0])
1695 *final_types
[0] = R_SHORT_PCREL_MODE
;
1697 *final_types
[0] = R_LONG_PCREL_MODE
;
1698 final_types
[1] = final_type
;
1699 final_types
[2] = NULL
;
1700 *final_type
= base_type
;
1708 /* Return the address of the correct entry in the PA SOM relocation
1711 static reloc_howto_type
*
1712 som_bfd_reloc_type_lookup (abfd
, code
)
1713 bfd
*abfd ATTRIBUTE_UNUSED
;
1714 bfd_reloc_code_real_type code
;
1716 if ((int) code
< (int) R_NO_RELOCATION
+ 255)
1718 BFD_ASSERT ((int) som_hppa_howto_table
[(int) code
].type
== (int) code
);
1719 return &som_hppa_howto_table
[(int) code
];
1722 return (reloc_howto_type
*) 0;
1725 /* Perform some initialization for an object. Save results of this
1726 initialization in the BFD. */
1728 static const bfd_target
*
1729 som_object_setup (abfd
, file_hdrp
, aux_hdrp
, current_offset
)
1731 struct header
*file_hdrp
;
1732 struct som_exec_auxhdr
*aux_hdrp
;
1733 unsigned long current_offset
;
1738 /* som_mkobject will set bfd_error if som_mkobject fails. */
1739 if (som_mkobject (abfd
) != true)
1742 /* Set BFD flags based on what information is available in the SOM. */
1743 abfd
->flags
= BFD_NO_FLAGS
;
1744 if (file_hdrp
->symbol_total
)
1745 abfd
->flags
|= HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
;
1747 switch (file_hdrp
->a_magic
)
1750 abfd
->flags
|= (D_PAGED
| WP_TEXT
| EXEC_P
);
1753 abfd
->flags
|= (WP_TEXT
| EXEC_P
);
1756 abfd
->flags
|= (EXEC_P
);
1759 abfd
->flags
|= HAS_RELOC
;
1767 abfd
->flags
|= DYNAMIC
;
1774 /* Allocate space to hold the saved exec header information. */
1775 obj_som_exec_data (abfd
) = (struct som_exec_data
*)
1776 bfd_zalloc (abfd
, sizeof (struct som_exec_data
));
1777 if (obj_som_exec_data (abfd
) == NULL
)
1780 /* The braindamaged OSF1 linker switched exec_flags and exec_entry!
1782 We used to identify OSF1 binaries based on NEW_VERSION_ID, but
1783 apparently the latest HPUX linker is using NEW_VERSION_ID now.
1785 It's about time, OSF has used the new id since at least 1992;
1786 HPUX didn't start till nearly 1995!.
1788 The new approach examines the entry field. If it's zero or not 4
1789 byte aligned then it's not a proper code address and we guess it's
1790 really the executable flags. */
1792 for (section
= abfd
->sections
; section
; section
= section
->next
)
1794 if ((section
->flags
& SEC_CODE
) == 0)
1796 if (aux_hdrp
->exec_entry
>= section
->vma
1797 && aux_hdrp
->exec_entry
< section
->vma
+ section
->_cooked_size
)
1800 if (aux_hdrp
->exec_entry
== 0
1801 || (aux_hdrp
->exec_entry
& 0x3) != 0
1804 bfd_get_start_address (abfd
) = aux_hdrp
->exec_flags
;
1805 obj_som_exec_data (abfd
)->exec_flags
= aux_hdrp
->exec_entry
;
1809 bfd_get_start_address (abfd
) = aux_hdrp
->exec_entry
+ current_offset
;
1810 obj_som_exec_data (abfd
)->exec_flags
= aux_hdrp
->exec_flags
;
1813 bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, pa10
);
1814 bfd_get_symcount (abfd
) = file_hdrp
->symbol_total
;
1816 /* Initialize the saved symbol table and string table to NULL.
1817 Save important offsets and sizes from the SOM header into
1819 obj_som_stringtab (abfd
) = (char *) NULL
;
1820 obj_som_symtab (abfd
) = (som_symbol_type
*) NULL
;
1821 obj_som_sorted_syms (abfd
) = NULL
;
1822 obj_som_stringtab_size (abfd
) = file_hdrp
->symbol_strings_size
;
1823 obj_som_sym_filepos (abfd
) = file_hdrp
->symbol_location
+ current_offset
;
1824 obj_som_str_filepos (abfd
) = (file_hdrp
->symbol_strings_location
1826 obj_som_reloc_filepos (abfd
) = (file_hdrp
->fixup_request_location
1828 obj_som_exec_data (abfd
)->system_id
= file_hdrp
->system_id
;
1833 /* Convert all of the space and subspace info into BFD sections. Each space
1834 contains a number of subspaces, which in turn describe the mapping between
1835 regions of the exec file, and the address space that the program runs in.
1836 BFD sections which correspond to spaces will overlap the sections for the
1837 associated subspaces. */
1840 setup_sections (abfd
, file_hdr
, current_offset
)
1842 struct header
*file_hdr
;
1843 unsigned long current_offset
;
1845 char *space_strings
;
1846 unsigned int space_index
, i
;
1847 unsigned int total_subspaces
= 0;
1848 asection
**subspace_sections
, *section
;
1850 /* First, read in space names. */
1852 space_strings
= bfd_malloc (file_hdr
->space_strings_size
);
1853 if (!space_strings
&& file_hdr
->space_strings_size
!= 0)
1856 if (bfd_seek (abfd
, current_offset
+ file_hdr
->space_strings_location
,
1859 if (bfd_read (space_strings
, 1, file_hdr
->space_strings_size
, abfd
)
1860 != file_hdr
->space_strings_size
)
1863 /* Loop over all of the space dictionaries, building up sections. */
1864 for (space_index
= 0; space_index
< file_hdr
->space_total
; space_index
++)
1866 struct space_dictionary_record space
;
1867 struct subspace_dictionary_record subspace
, save_subspace
;
1869 asection
*space_asect
;
1872 /* Read the space dictionary element. */
1874 (current_offset
+ file_hdr
->space_location
1875 + space_index
* sizeof space
),
1878 if (bfd_read (&space
, 1, sizeof space
, abfd
) != sizeof space
)
1881 /* Setup the space name string. */
1882 space
.name
.n_name
= space
.name
.n_strx
+ space_strings
;
1884 /* Make a section out of it. */
1885 newname
= bfd_alloc (abfd
, strlen (space
.name
.n_name
) + 1);
1888 strcpy (newname
, space
.name
.n_name
);
1890 space_asect
= bfd_make_section_anyway (abfd
, newname
);
1894 if (space
.is_loadable
== 0)
1895 space_asect
->flags
|= SEC_DEBUGGING
;
1897 /* Set up all the attributes for the space. */
1898 if (bfd_som_set_section_attributes (space_asect
, space
.is_defined
,
1899 space
.is_private
, space
.sort_key
,
1900 space
.space_number
) == false)
1903 /* If the space has no subspaces, then we're done. */
1904 if (space
.subspace_quantity
== 0)
1907 /* Now, read in the first subspace for this space. */
1909 (current_offset
+ file_hdr
->subspace_location
1910 + space
.subspace_index
* sizeof subspace
),
1913 if (bfd_read (&subspace
, 1, sizeof subspace
, abfd
) != sizeof subspace
)
1915 /* Seek back to the start of the subspaces for loop below. */
1917 (current_offset
+ file_hdr
->subspace_location
1918 + space
.subspace_index
* sizeof subspace
),
1922 /* Setup the start address and file loc from the first subspace
1924 space_asect
->vma
= subspace
.subspace_start
;
1925 space_asect
->filepos
= subspace
.file_loc_init_value
+ current_offset
;
1926 space_asect
->alignment_power
= log2 (subspace
.alignment
);
1927 if (space_asect
->alignment_power
== -1)
1930 /* Initialize save_subspace so we can reliably determine if this
1931 loop placed any useful values into it. */
1932 memset (&save_subspace
, 0, sizeof (struct subspace_dictionary_record
));
1934 /* Loop over the rest of the subspaces, building up more sections. */
1935 for (subspace_index
= 0; subspace_index
< space
.subspace_quantity
;
1938 asection
*subspace_asect
;
1940 /* Read in the next subspace. */
1941 if (bfd_read (&subspace
, 1, sizeof subspace
, abfd
)
1945 /* Setup the subspace name string. */
1946 subspace
.name
.n_name
= subspace
.name
.n_strx
+ space_strings
;
1948 newname
= bfd_alloc (abfd
, strlen (subspace
.name
.n_name
) + 1);
1951 strcpy (newname
, subspace
.name
.n_name
);
1953 /* Make a section out of this subspace. */
1954 subspace_asect
= bfd_make_section_anyway (abfd
, newname
);
1955 if (!subspace_asect
)
1958 /* Store private information about the section. */
1959 if (bfd_som_set_subsection_attributes (subspace_asect
, space_asect
,
1960 subspace
.access_control_bits
,
1962 subspace
.quadrant
) == false)
1965 /* Keep an easy mapping between subspaces and sections.
1966 Note we do not necessarily read the subspaces in the
1967 same order in which they appear in the object file.
1969 So to make the target index come out correctly, we
1970 store the location of the subspace header in target
1971 index, then sort using the location of the subspace
1972 header as the key. Then we can assign correct
1973 subspace indices. */
1975 subspace_asect
->target_index
= bfd_tell (abfd
) - sizeof (subspace
);
1977 /* Set SEC_READONLY and SEC_CODE/SEC_DATA as specified
1978 by the access_control_bits in the subspace header. */
1979 switch (subspace
.access_control_bits
>> 4)
1981 /* Readonly data. */
1983 subspace_asect
->flags
|= SEC_DATA
| SEC_READONLY
;
1988 subspace_asect
->flags
|= SEC_DATA
;
1991 /* Readonly code and the gateways.
1992 Gateways have other attributes which do not map
1993 into anything BFD knows about. */
1999 subspace_asect
->flags
|= SEC_CODE
| SEC_READONLY
;
2002 /* dynamic (writable) code. */
2004 subspace_asect
->flags
|= SEC_CODE
;
2008 if (subspace
.dup_common
|| subspace
.is_common
)
2009 subspace_asect
->flags
|= SEC_IS_COMMON
;
2010 else if (subspace
.subspace_length
> 0)
2011 subspace_asect
->flags
|= SEC_HAS_CONTENTS
;
2013 if (subspace
.is_loadable
)
2014 subspace_asect
->flags
|= SEC_ALLOC
| SEC_LOAD
;
2016 subspace_asect
->flags
|= SEC_DEBUGGING
;
2018 if (subspace
.code_only
)
2019 subspace_asect
->flags
|= SEC_CODE
;
2021 /* Both file_loc_init_value and initialization_length will
2022 be zero for a BSS like subspace. */
2023 if (subspace
.file_loc_init_value
== 0
2024 && subspace
.initialization_length
== 0)
2025 subspace_asect
->flags
&= ~(SEC_DATA
| SEC_LOAD
| SEC_HAS_CONTENTS
);
2027 /* This subspace has relocations.
2028 The fixup_request_quantity is a byte count for the number of
2029 entries in the relocation stream; it is not the actual number
2030 of relocations in the subspace. */
2031 if (subspace
.fixup_request_quantity
!= 0)
2033 subspace_asect
->flags
|= SEC_RELOC
;
2034 subspace_asect
->rel_filepos
= subspace
.fixup_request_index
;
2035 som_section_data (subspace_asect
)->reloc_size
2036 = subspace
.fixup_request_quantity
;
2037 /* We can not determine this yet. When we read in the
2038 relocation table the correct value will be filled in. */
2039 subspace_asect
->reloc_count
= -1;
2042 /* Update save_subspace if appropriate. */
2043 if (subspace
.file_loc_init_value
> save_subspace
.file_loc_init_value
)
2044 save_subspace
= subspace
;
2046 subspace_asect
->vma
= subspace
.subspace_start
;
2047 subspace_asect
->_cooked_size
= subspace
.subspace_length
;
2048 subspace_asect
->_raw_size
= subspace
.subspace_length
;
2049 subspace_asect
->filepos
= (subspace
.file_loc_init_value
2051 subspace_asect
->alignment_power
= log2 (subspace
.alignment
);
2052 if (subspace_asect
->alignment_power
== -1)
2056 /* This can happen for a .o which defines symbols in otherwise
2058 if (!save_subspace
.file_loc_init_value
)
2060 space_asect
->_cooked_size
= 0;
2061 space_asect
->_raw_size
= 0;
2065 /* Setup the sizes for the space section based upon the info in the
2066 last subspace of the space. */
2067 space_asect
->_cooked_size
= (save_subspace
.subspace_start
2069 + save_subspace
.subspace_length
);
2070 space_asect
->_raw_size
= (save_subspace
.file_loc_init_value
2071 - space_asect
->filepos
2072 + save_subspace
.initialization_length
);
2075 /* Now that we've read in all the subspace records, we need to assign
2076 a target index to each subspace. */
2077 subspace_sections
= (asection
**) bfd_malloc (total_subspaces
2078 * sizeof (asection
*));
2079 if (subspace_sections
== NULL
)
2082 for (i
= 0, section
= abfd
->sections
; section
; section
= section
->next
)
2084 if (!som_is_subspace (section
))
2087 subspace_sections
[i
] = section
;
2090 qsort (subspace_sections
, total_subspaces
,
2091 sizeof (asection
*), compare_subspaces
);
2093 /* subspace_sections is now sorted in the order in which the subspaces
2094 appear in the object file. Assign an index to each one now. */
2095 for (i
= 0; i
< total_subspaces
; i
++)
2096 subspace_sections
[i
]->target_index
= i
;
2098 if (space_strings
!= NULL
)
2099 free (space_strings
);
2101 if (subspace_sections
!= NULL
)
2102 free (subspace_sections
);
2107 if (space_strings
!= NULL
)
2108 free (space_strings
);
2110 if (subspace_sections
!= NULL
)
2111 free (subspace_sections
);
2115 /* Read in a SOM object and make it into a BFD. */
2117 static const bfd_target
*
2121 struct header file_hdr
;
2122 struct som_exec_auxhdr aux_hdr
;
2123 unsigned long current_offset
= 0;
2124 struct lst_header lst_header
;
2125 struct som_entry som_entry
;
2126 #define ENTRY_SIZE sizeof (struct som_entry)
2128 if (bfd_read ((PTR
) & file_hdr
, 1, FILE_HDR_SIZE
, abfd
) != FILE_HDR_SIZE
)
2130 if (bfd_get_error () != bfd_error_system_call
)
2131 bfd_set_error (bfd_error_wrong_format
);
2135 if (!_PA_RISC_ID (file_hdr
.system_id
))
2137 bfd_set_error (bfd_error_wrong_format
);
2141 switch (file_hdr
.a_magic
)
2153 #ifdef SHARED_MAGIC_CNX
2154 case SHARED_MAGIC_CNX
:
2160 /* Read the lst header and determine where the SOM directory begins. */
2162 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) < 0)
2164 if (bfd_get_error () != bfd_error_system_call
)
2165 bfd_set_error (bfd_error_wrong_format
);
2169 if (bfd_read ((PTR
) & lst_header
, 1, SLSTHDR
, abfd
) != SLSTHDR
)
2171 if (bfd_get_error () != bfd_error_system_call
)
2172 bfd_set_error (bfd_error_wrong_format
);
2176 /* Position to and read the first directory entry. */
2178 if (bfd_seek (abfd
, lst_header
.dir_loc
, SEEK_SET
) < 0)
2180 if (bfd_get_error () != bfd_error_system_call
)
2181 bfd_set_error (bfd_error_wrong_format
);
2185 if (bfd_read ((PTR
) & som_entry
, 1, ENTRY_SIZE
, abfd
) != ENTRY_SIZE
)
2187 if (bfd_get_error () != bfd_error_system_call
)
2188 bfd_set_error (bfd_error_wrong_format
);
2192 /* Now position to the first SOM. */
2194 if (bfd_seek (abfd
, som_entry
.location
, SEEK_SET
) < 0)
2196 if (bfd_get_error () != bfd_error_system_call
)
2197 bfd_set_error (bfd_error_wrong_format
);
2201 current_offset
= som_entry
.location
;
2203 /* And finally, re-read the som header. */
2205 if (bfd_read ((PTR
) & file_hdr
, 1, FILE_HDR_SIZE
, abfd
) != FILE_HDR_SIZE
)
2207 if (bfd_get_error () != bfd_error_system_call
)
2208 bfd_set_error (bfd_error_wrong_format
);
2216 bfd_set_error (bfd_error_wrong_format
);
2220 if (file_hdr
.version_id
!= VERSION_ID
2221 && file_hdr
.version_id
!= NEW_VERSION_ID
)
2223 bfd_set_error (bfd_error_wrong_format
);
2227 /* If the aux_header_size field in the file header is zero, then this
2228 object is an incomplete executable (a .o file). Do not try to read
2229 a non-existant auxiliary header. */
2230 memset (&aux_hdr
, 0, sizeof (struct som_exec_auxhdr
));
2231 if (file_hdr
.aux_header_size
!= 0)
2233 if (bfd_read ((PTR
) & aux_hdr
, 1, AUX_HDR_SIZE
, abfd
) != AUX_HDR_SIZE
)
2235 if (bfd_get_error () != bfd_error_system_call
)
2236 bfd_set_error (bfd_error_wrong_format
);
2241 if (!setup_sections (abfd
, &file_hdr
, current_offset
))
2243 /* setup_sections does not bubble up a bfd error code. */
2244 bfd_set_error (bfd_error_bad_value
);
2248 /* This appears to be a valid SOM object. Do some initialization. */
2249 return som_object_setup (abfd
, &file_hdr
, &aux_hdr
, current_offset
);
2252 /* Create a SOM object. */
2258 /* Allocate memory to hold backend information. */
2259 abfd
->tdata
.som_data
= (struct som_data_struct
*)
2260 bfd_zalloc (abfd
, sizeof (struct som_data_struct
));
2261 if (abfd
->tdata
.som_data
== NULL
)
2266 /* Initialize some information in the file header. This routine makes
2267 not attempt at doing the right thing for a full executable; it
2268 is only meant to handle relocatable objects. */
2271 som_prep_headers (abfd
)
2274 struct header
*file_hdr
;
2277 /* Make and attach a file header to the BFD. */
2278 file_hdr
= (struct header
*) bfd_zalloc (abfd
, sizeof (struct header
));
2279 if (file_hdr
== NULL
)
2281 obj_som_file_hdr (abfd
) = file_hdr
;
2283 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
2286 /* Make and attach an exec header to the BFD. */
2287 obj_som_exec_hdr (abfd
) = (struct som_exec_auxhdr
*)
2288 bfd_zalloc (abfd
, sizeof (struct som_exec_auxhdr
));
2289 if (obj_som_exec_hdr (abfd
) == NULL
)
2292 if (abfd
->flags
& D_PAGED
)
2293 file_hdr
->a_magic
= DEMAND_MAGIC
;
2294 else if (abfd
->flags
& WP_TEXT
)
2295 file_hdr
->a_magic
= SHARE_MAGIC
;
2297 else if (abfd
->flags
& DYNAMIC
)
2298 file_hdr
->a_magic
= SHL_MAGIC
;
2301 file_hdr
->a_magic
= EXEC_MAGIC
;
2304 file_hdr
->a_magic
= RELOC_MAGIC
;
2306 /* Only new format SOM is supported. */
2307 file_hdr
->version_id
= NEW_VERSION_ID
;
2309 /* These fields are optional, and embedding timestamps is not always
2310 a wise thing to do, it makes comparing objects during a multi-stage
2311 bootstrap difficult. */
2312 file_hdr
->file_time
.secs
= 0;
2313 file_hdr
->file_time
.nanosecs
= 0;
2315 file_hdr
->entry_space
= 0;
2316 file_hdr
->entry_subspace
= 0;
2317 file_hdr
->entry_offset
= 0;
2318 file_hdr
->presumed_dp
= 0;
2320 /* Now iterate over the sections translating information from
2321 BFD sections to SOM spaces/subspaces. */
2323 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2325 /* Ignore anything which has not been marked as a space or
2327 if (!som_is_space (section
) && !som_is_subspace (section
))
2330 if (som_is_space (section
))
2332 /* Allocate space for the space dictionary. */
2333 som_section_data (section
)->space_dict
=
2334 (struct space_dictionary_record
*)
2335 bfd_zalloc (abfd
, sizeof (struct space_dictionary_record
));
2336 if (som_section_data (section
)->space_dict
== NULL
)
2338 /* Set space attributes. Note most attributes of SOM spaces
2339 are set based on the subspaces it contains. */
2340 som_section_data (section
)->space_dict
->loader_fix_index
= -1;
2341 som_section_data (section
)->space_dict
->init_pointer_index
= -1;
2343 /* Set more attributes that were stuffed away in private data. */
2344 som_section_data (section
)->space_dict
->sort_key
=
2345 som_section_data (section
)->copy_data
->sort_key
;
2346 som_section_data (section
)->space_dict
->is_defined
=
2347 som_section_data (section
)->copy_data
->is_defined
;
2348 som_section_data (section
)->space_dict
->is_private
=
2349 som_section_data (section
)->copy_data
->is_private
;
2350 som_section_data (section
)->space_dict
->space_number
=
2351 som_section_data (section
)->copy_data
->space_number
;
2355 /* Allocate space for the subspace dictionary. */
2356 som_section_data (section
)->subspace_dict
2357 = (struct subspace_dictionary_record
*)
2358 bfd_zalloc (abfd
, sizeof (struct subspace_dictionary_record
));
2359 if (som_section_data (section
)->subspace_dict
== NULL
)
2362 /* Set subspace attributes. Basic stuff is done here, additional
2363 attributes are filled in later as more information becomes
2365 if (section
->flags
& SEC_IS_COMMON
)
2367 som_section_data (section
)->subspace_dict
->dup_common
= 1;
2368 som_section_data (section
)->subspace_dict
->is_common
= 1;
2371 if (section
->flags
& SEC_ALLOC
)
2372 som_section_data (section
)->subspace_dict
->is_loadable
= 1;
2374 if (section
->flags
& SEC_CODE
)
2375 som_section_data (section
)->subspace_dict
->code_only
= 1;
2377 som_section_data (section
)->subspace_dict
->subspace_start
=
2379 som_section_data (section
)->subspace_dict
->subspace_length
=
2380 bfd_section_size (abfd
, section
);
2381 som_section_data (section
)->subspace_dict
->initialization_length
=
2382 bfd_section_size (abfd
, section
);
2383 som_section_data (section
)->subspace_dict
->alignment
=
2384 1 << section
->alignment_power
;
2386 /* Set more attributes that were stuffed away in private data. */
2387 som_section_data (section
)->subspace_dict
->sort_key
=
2388 som_section_data (section
)->copy_data
->sort_key
;
2389 som_section_data (section
)->subspace_dict
->access_control_bits
=
2390 som_section_data (section
)->copy_data
->access_control_bits
;
2391 som_section_data (section
)->subspace_dict
->quadrant
=
2392 som_section_data (section
)->copy_data
->quadrant
;
2398 /* Return true if the given section is a SOM space, false otherwise. */
2401 som_is_space (section
)
2404 /* If no copy data is available, then it's neither a space nor a
2406 if (som_section_data (section
)->copy_data
== NULL
)
2409 /* If the containing space isn't the same as the given section,
2410 then this isn't a space. */
2411 if (som_section_data (section
)->copy_data
->container
!= section
2412 && (som_section_data (section
)->copy_data
->container
->output_section
2416 /* OK. Must be a space. */
2420 /* Return true if the given section is a SOM subspace, false otherwise. */
2423 som_is_subspace (section
)
2426 /* If no copy data is available, then it's neither a space nor a
2428 if (som_section_data (section
)->copy_data
== NULL
)
2431 /* If the containing space is the same as the given section,
2432 then this isn't a subspace. */
2433 if (som_section_data (section
)->copy_data
->container
== section
2434 || (som_section_data (section
)->copy_data
->container
->output_section
2438 /* OK. Must be a subspace. */
2442 /* Return true if the given space containins the given subspace. It
2443 is safe to assume space really is a space, and subspace really
2447 som_is_container (space
, subspace
)
2448 asection
*space
, *subspace
;
2450 return (som_section_data (subspace
)->copy_data
->container
== space
2451 || (som_section_data (subspace
)->copy_data
->container
->output_section
2455 /* Count and return the number of spaces attached to the given BFD. */
2457 static unsigned long
2458 som_count_spaces (abfd
)
2464 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2465 count
+= som_is_space (section
);
2470 /* Count the number of subspaces attached to the given BFD. */
2472 static unsigned long
2473 som_count_subspaces (abfd
)
2479 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2480 count
+= som_is_subspace (section
);
2485 /* Return -1, 0, 1 indicating the relative ordering of sym1 and sym2.
2487 We desire symbols to be ordered starting with the symbol with the
2488 highest relocation count down to the symbol with the lowest relocation
2489 count. Doing so compacts the relocation stream. */
2492 compare_syms (arg1
, arg2
)
2497 asymbol
**sym1
= (asymbol
**) arg1
;
2498 asymbol
**sym2
= (asymbol
**) arg2
;
2499 unsigned int count1
, count2
;
2501 /* Get relocation count for each symbol. Note that the count
2502 is stored in the udata pointer for section symbols! */
2503 if ((*sym1
)->flags
& BSF_SECTION_SYM
)
2504 count1
= (*sym1
)->udata
.i
;
2506 count1
= som_symbol_data (*sym1
)->reloc_count
;
2508 if ((*sym2
)->flags
& BSF_SECTION_SYM
)
2509 count2
= (*sym2
)->udata
.i
;
2511 count2
= som_symbol_data (*sym2
)->reloc_count
;
2513 /* Return the appropriate value. */
2514 if (count1
< count2
)
2516 else if (count1
> count2
)
2521 /* Return -1, 0, 1 indicating the relative ordering of subspace1
2525 compare_subspaces (arg1
, arg2
)
2530 asection
**subspace1
= (asection
**) arg1
;
2531 asection
**subspace2
= (asection
**) arg2
;
2533 if ((*subspace1
)->target_index
< (*subspace2
)->target_index
)
2535 else if ((*subspace2
)->target_index
< (*subspace1
)->target_index
)
2541 /* Perform various work in preparation for emitting the fixup stream. */
2544 som_prep_for_fixups (abfd
, syms
, num_syms
)
2547 unsigned long num_syms
;
2551 asymbol
**sorted_syms
;
2553 /* Most SOM relocations involving a symbol have a length which is
2554 dependent on the index of the symbol. So symbols which are
2555 used often in relocations should have a small index. */
2557 /* First initialize the counters for each symbol. */
2558 for (i
= 0; i
< num_syms
; i
++)
2560 /* Handle a section symbol; these have no pointers back to the
2561 SOM symbol info. So we just use the udata field to hold the
2562 relocation count. */
2563 if (som_symbol_data (syms
[i
]) == NULL
2564 || syms
[i
]->flags
& BSF_SECTION_SYM
)
2566 syms
[i
]->flags
|= BSF_SECTION_SYM
;
2567 syms
[i
]->udata
.i
= 0;
2570 som_symbol_data (syms
[i
])->reloc_count
= 0;
2573 /* Now that the counters are initialized, make a weighted count
2574 of how often a given symbol is used in a relocation. */
2575 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2579 /* Does this section have any relocations? */
2580 if (section
->reloc_count
<= 0)
2583 /* Walk through each relocation for this section. */
2584 for (i
= 1; i
< section
->reloc_count
; i
++)
2586 arelent
*reloc
= section
->orelocation
[i
];
2589 /* A relocation against a symbol in the *ABS* section really
2590 does not have a symbol. Likewise if the symbol isn't associated
2591 with any section. */
2592 if (reloc
->sym_ptr_ptr
== NULL
2593 || bfd_is_abs_section ((*reloc
->sym_ptr_ptr
)->section
))
2596 /* Scaling to encourage symbols involved in R_DP_RELATIVE
2597 and R_CODE_ONE_SYMBOL relocations to come first. These
2598 two relocations have single byte versions if the symbol
2599 index is very small. */
2600 if (reloc
->howto
->type
== R_DP_RELATIVE
2601 || reloc
->howto
->type
== R_CODE_ONE_SYMBOL
)
2606 /* Handle section symbols by storing the count in the udata
2607 field. It will not be used and the count is very important
2608 for these symbols. */
2609 if ((*reloc
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
)
2611 (*reloc
->sym_ptr_ptr
)->udata
.i
=
2612 (*reloc
->sym_ptr_ptr
)->udata
.i
+ scale
;
2616 /* A normal symbol. Increment the count. */
2617 som_symbol_data (*reloc
->sym_ptr_ptr
)->reloc_count
+= scale
;
2621 /* Sort a copy of the symbol table, rather than the canonical
2622 output symbol table. */
2623 sorted_syms
= (asymbol
**) bfd_zalloc (abfd
, num_syms
* sizeof (asymbol
*));
2624 memcpy (sorted_syms
, syms
, num_syms
* sizeof (asymbol
*));
2625 qsort (sorted_syms
, num_syms
, sizeof (asymbol
*), compare_syms
);
2626 obj_som_sorted_syms (abfd
) = sorted_syms
;
2628 /* Compute the symbol indexes, they will be needed by the relocation
2630 for (i
= 0; i
< num_syms
; i
++)
2632 /* A section symbol. Again, there is no pointer to backend symbol
2633 information, so we reuse the udata field again. */
2634 if (sorted_syms
[i
]->flags
& BSF_SECTION_SYM
)
2635 sorted_syms
[i
]->udata
.i
= i
;
2637 som_symbol_data (sorted_syms
[i
])->index
= i
;
2642 som_write_fixups (abfd
, current_offset
, total_reloc_sizep
)
2644 unsigned long current_offset
;
2645 unsigned int *total_reloc_sizep
;
2648 /* Chunk of memory that we can use as buffer space, then throw
2650 unsigned char tmp_space
[SOM_TMP_BUFSIZE
];
2652 unsigned int total_reloc_size
= 0;
2653 unsigned int subspace_reloc_size
= 0;
2654 unsigned int num_spaces
= obj_som_file_hdr (abfd
)->space_total
;
2655 asection
*section
= abfd
->sections
;
2657 memset (tmp_space
, 0, SOM_TMP_BUFSIZE
);
2660 /* All the fixups for a particular subspace are emitted in a single
2661 stream. All the subspaces for a particular space are emitted
2664 So, to get all the locations correct one must iterate through all the
2665 spaces, for each space iterate through its subspaces and output a
2667 for (i
= 0; i
< num_spaces
; i
++)
2669 asection
*subsection
;
2672 while (!som_is_space (section
))
2673 section
= section
->next
;
2675 /* Now iterate through each of its subspaces. */
2676 for (subsection
= abfd
->sections
;
2678 subsection
= subsection
->next
)
2680 int reloc_offset
, current_rounding_mode
;
2681 #ifndef NO_PCREL_MODES
2682 int current_call_mode
;
2685 /* Find a subspace of this space. */
2686 if (!som_is_subspace (subsection
)
2687 || !som_is_container (section
, subsection
))
2690 /* If this subspace does not have real data, then we are
2692 if ((subsection
->flags
& SEC_HAS_CONTENTS
) == 0)
2694 som_section_data (subsection
)->subspace_dict
->fixup_request_index
2699 /* This subspace has some relocations. Put the relocation stream
2700 index into the subspace record. */
2701 som_section_data (subsection
)->subspace_dict
->fixup_request_index
2704 /* To make life easier start over with a clean slate for
2705 each subspace. Seek to the start of the relocation stream
2706 for this subspace in preparation for writing out its fixup
2708 if (bfd_seek (abfd
, current_offset
+ total_reloc_size
, SEEK_SET
) < 0)
2711 /* Buffer space has already been allocated. Just perform some
2712 initialization here. */
2714 subspace_reloc_size
= 0;
2716 som_initialize_reloc_queue (reloc_queue
);
2717 current_rounding_mode
= R_N_MODE
;
2718 #ifndef NO_PCREL_MODES
2719 current_call_mode
= R_SHORT_PCREL_MODE
;
2722 /* Translate each BFD relocation into one or more SOM
2724 for (j
= 0; j
< subsection
->reloc_count
; j
++)
2726 arelent
*bfd_reloc
= subsection
->orelocation
[j
];
2730 /* Get the symbol number. Remember it's stored in a
2731 special place for section symbols. */
2732 if ((*bfd_reloc
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
)
2733 sym_num
= (*bfd_reloc
->sym_ptr_ptr
)->udata
.i
;
2735 sym_num
= som_symbol_data (*bfd_reloc
->sym_ptr_ptr
)->index
;
2737 /* If there is not enough room for the next couple relocations,
2738 then dump the current buffer contents now. Also reinitialize
2739 the relocation queue.
2741 No single BFD relocation could ever translate into more
2742 than 100 bytes of SOM relocations (20bytes is probably the
2743 upper limit, but leave lots of space for growth). */
2744 if (p
- tmp_space
+ 100 > SOM_TMP_BUFSIZE
)
2746 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
)
2751 som_initialize_reloc_queue (reloc_queue
);
2754 /* Emit R_NO_RELOCATION fixups to map any bytes which were
2756 skip
= bfd_reloc
->address
- reloc_offset
;
2757 p
= som_reloc_skip (abfd
, skip
, p
,
2758 &subspace_reloc_size
, reloc_queue
);
2760 /* Update reloc_offset for the next iteration.
2762 Many relocations do not consume input bytes. They
2763 are markers, or set state necessary to perform some
2764 later relocation. */
2765 switch (bfd_reloc
->howto
->type
)
2785 #ifndef NO_PCREL_MODES
2786 case R_SHORT_PCREL_MODE
:
2787 case R_LONG_PCREL_MODE
:
2789 reloc_offset
= bfd_reloc
->address
;
2793 reloc_offset
= bfd_reloc
->address
+ 4;
2797 /* Now the actual relocation we care about. */
2798 switch (bfd_reloc
->howto
->type
)
2802 p
= som_reloc_call (abfd
, p
, &subspace_reloc_size
,
2803 bfd_reloc
, sym_num
, reloc_queue
);
2806 case R_CODE_ONE_SYMBOL
:
2808 /* Account for any addend. */
2809 if (bfd_reloc
->addend
)
2810 p
= som_reloc_addend (abfd
, bfd_reloc
->addend
, p
,
2811 &subspace_reloc_size
, reloc_queue
);
2815 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ sym_num
, p
);
2816 subspace_reloc_size
+= 1;
2819 else if (sym_num
< 0x100)
2821 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 32, p
);
2822 bfd_put_8 (abfd
, sym_num
, p
+ 1);
2823 p
= try_prev_fixup (abfd
, &subspace_reloc_size
, p
,
2826 else if (sym_num
< 0x10000000)
2828 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 33, p
);
2829 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 1);
2830 bfd_put_16 (abfd
, sym_num
, p
+ 2);
2831 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2838 case R_DATA_ONE_SYMBOL
:
2842 /* Account for any addend using R_DATA_OVERRIDE. */
2843 if (bfd_reloc
->howto
->type
!= R_DATA_ONE_SYMBOL
2844 && bfd_reloc
->addend
)
2845 p
= som_reloc_addend (abfd
, bfd_reloc
->addend
, p
,
2846 &subspace_reloc_size
, reloc_queue
);
2848 if (sym_num
< 0x100)
2850 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2851 bfd_put_8 (abfd
, sym_num
, p
+ 1);
2852 p
= try_prev_fixup (abfd
, &subspace_reloc_size
, p
,
2855 else if (sym_num
< 0x10000000)
2857 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 1, p
);
2858 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 1);
2859 bfd_put_16 (abfd
, sym_num
, p
+ 2);
2860 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2870 arelent
*tmp_reloc
= NULL
;
2871 bfd_put_8 (abfd
, R_ENTRY
, p
);
2873 /* R_ENTRY relocations have 64 bits of associated
2874 data. Unfortunately the addend field of a bfd
2875 relocation is only 32 bits. So, we split up
2876 the 64bit unwind information and store part in
2877 the R_ENTRY relocation, and the rest in the R_EXIT
2879 bfd_put_32 (abfd
, bfd_reloc
->addend
, p
+ 1);
2881 /* Find the next R_EXIT relocation. */
2882 for (tmp
= j
; tmp
< subsection
->reloc_count
; tmp
++)
2884 tmp_reloc
= subsection
->orelocation
[tmp
];
2885 if (tmp_reloc
->howto
->type
== R_EXIT
)
2889 if (tmp
== subsection
->reloc_count
)
2892 bfd_put_32 (abfd
, tmp_reloc
->addend
, p
+ 5);
2893 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2902 /* If this relocation requests the current rounding
2903 mode, then it is redundant. */
2904 if (bfd_reloc
->howto
->type
!= current_rounding_mode
)
2906 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2907 subspace_reloc_size
+= 1;
2909 current_rounding_mode
= bfd_reloc
->howto
->type
;
2913 #ifndef NO_PCREL_MODES
2914 case R_LONG_PCREL_MODE
:
2915 case R_SHORT_PCREL_MODE
:
2916 if (bfd_reloc
->howto
->type
!= current_call_mode
)
2918 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2919 subspace_reloc_size
+= 1;
2921 current_call_mode
= bfd_reloc
->howto
->type
;
2936 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2937 subspace_reloc_size
+= 1;
2942 /* The end of a exception handling region. The reloc's
2943 addend contains the offset of the exception handling
2945 if (bfd_reloc
->addend
== 0)
2946 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2947 else if (bfd_reloc
->addend
< 1024)
2949 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 1, p
);
2950 bfd_put_8 (abfd
, bfd_reloc
->addend
/ 4, p
+ 1);
2951 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2956 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 2, p
);
2957 bfd_put_8 (abfd
, (bfd_reloc
->addend
/ 4) >> 16, p
+ 1);
2958 bfd_put_16 (abfd
, bfd_reloc
->addend
/ 4, p
+ 2);
2959 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2965 /* The only time we generate R_COMP1, R_COMP2 and
2966 R_CODE_EXPR relocs is for the difference of two
2967 symbols. Hence we can cheat here. */
2968 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2969 bfd_put_8 (abfd
, 0x44, p
+ 1);
2970 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2975 /* The only time we generate R_COMP1, R_COMP2 and
2976 R_CODE_EXPR relocs is for the difference of two
2977 symbols. Hence we can cheat here. */
2978 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2979 bfd_put_8 (abfd
, 0x80, p
+ 1);
2980 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 2);
2981 bfd_put_16 (abfd
, sym_num
, p
+ 3);
2982 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2988 /* The only time we generate R_COMP1, R_COMP2 and
2989 R_CODE_EXPR relocs is for the difference of two
2990 symbols. Hence we can cheat here. */
2991 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2992 subspace_reloc_size
+= 1;
2996 /* Put a "R_RESERVED" relocation in the stream if
2997 we hit something we do not understand. The linker
2998 will complain loudly if this ever happens. */
3000 bfd_put_8 (abfd
, 0xff, p
);
3001 subspace_reloc_size
+= 1;
3007 /* Last BFD relocation for a subspace has been processed.
3008 Map the rest of the subspace with R_NO_RELOCATION fixups. */
3009 p
= som_reloc_skip (abfd
, bfd_section_size (abfd
, subsection
)
3011 p
, &subspace_reloc_size
, reloc_queue
);
3013 /* Scribble out the relocations. */
3014 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
)
3019 total_reloc_size
+= subspace_reloc_size
;
3020 som_section_data (subsection
)->subspace_dict
->fixup_request_quantity
3021 = subspace_reloc_size
;
3023 section
= section
->next
;
3025 *total_reloc_sizep
= total_reloc_size
;
3029 /* Write out the space/subspace string table. */
3032 som_write_space_strings (abfd
, current_offset
, string_sizep
)
3034 unsigned long current_offset
;
3035 unsigned int *string_sizep
;
3037 /* Chunk of memory that we can use as buffer space, then throw
3039 size_t tmp_space_size
= SOM_TMP_BUFSIZE
;
3040 unsigned char *tmp_space
= alloca (tmp_space_size
);
3041 unsigned char *p
= tmp_space
;
3042 unsigned int strings_size
= 0;
3045 /* Seek to the start of the space strings in preparation for writing
3047 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) < 0)
3050 /* Walk through all the spaces and subspaces (order is not important)
3051 building up and writing string table entries for their names. */
3052 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3056 /* Only work with space/subspaces; avoid any other sections
3057 which might have been made (.text for example). */
3058 if (!som_is_space (section
) && !som_is_subspace (section
))
3061 /* Get the length of the space/subspace name. */
3062 length
= strlen (section
->name
);
3064 /* If there is not enough room for the next entry, then dump the
3065 current buffer contents now and maybe allocate a larger
3066 buffer. Each entry will take 4 bytes to hold the string
3067 length + the string itself + null terminator. */
3068 if (p
- tmp_space
+ 5 + length
> tmp_space_size
)
3070 /* Flush buffer before refilling or reallocating. */
3071 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
)
3075 /* Reallocate if now empty buffer still too small. */
3076 if (5 + length
> tmp_space_size
)
3078 /* Ensure a minimum growth factor to avoid O(n**2) space
3079 consumption for n strings. The optimal minimum
3080 factor seems to be 2, as no other value can guarantee
3081 wasting less then 50% space. (Note that we cannot
3082 deallocate space allocated by `alloca' without
3083 returning from this function.) The same technique is
3084 used a few more times below when a buffer is
3086 tmp_space_size
= MAX (2 * tmp_space_size
, 5 + length
);
3087 tmp_space
= alloca (tmp_space_size
);
3090 /* Reset to beginning of the (possibly new) buffer space. */
3094 /* First element in a string table entry is the length of the
3095 string. Alignment issues are already handled. */
3096 bfd_put_32 (abfd
, length
, p
);
3100 /* Record the index in the space/subspace records. */
3101 if (som_is_space (section
))
3102 som_section_data (section
)->space_dict
->name
.n_strx
= strings_size
;
3104 som_section_data (section
)->subspace_dict
->name
.n_strx
= strings_size
;
3106 /* Next comes the string itself + a null terminator. */
3107 strcpy (p
, section
->name
);
3109 strings_size
+= length
+ 1;
3111 /* Always align up to the next word boundary. */
3112 while (strings_size
% 4)
3114 bfd_put_8 (abfd
, 0, p
);
3120 /* Done with the space/subspace strings. Write out any information
3121 contained in a partial block. */
3122 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
) != p
- tmp_space
)
3124 *string_sizep
= strings_size
;
3128 /* Write out the symbol string table. */
3131 som_write_symbol_strings (abfd
, current_offset
, syms
, num_syms
, string_sizep
,
3134 unsigned long current_offset
;
3136 unsigned int num_syms
;
3137 unsigned int *string_sizep
;
3138 COMPUNIT
*compilation_unit
;
3142 /* Chunk of memory that we can use as buffer space, then throw
3144 size_t tmp_space_size
= SOM_TMP_BUFSIZE
;
3145 unsigned char *tmp_space
= alloca (tmp_space_size
);
3146 unsigned char *p
= tmp_space
;
3148 unsigned int strings_size
= 0;
3149 unsigned char *comp
[4];
3151 /* This gets a bit gruesome because of the compilation unit. The
3152 strings within the compilation unit are part of the symbol
3153 strings, but don't have symbol_dictionary entries. So, manually
3154 write them and update the compliation unit header. On input, the
3155 compilation unit header contains local copies of the strings.
3157 if (compilation_unit
)
3159 comp
[0] = compilation_unit
->name
.n_name
;
3160 comp
[1] = compilation_unit
->language_name
.n_name
;
3161 comp
[2] = compilation_unit
->product_id
.n_name
;
3162 comp
[3] = compilation_unit
->version_id
.n_name
;
3165 /* Seek to the start of the space strings in preparation for writing
3167 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) < 0)
3170 if (compilation_unit
)
3172 for (i
= 0; i
< 4; i
++)
3174 size_t length
= strlen (comp
[i
]);
3176 /* If there is not enough room for the next entry, then dump
3177 the current buffer contents now and maybe allocate a
3179 if (p
- tmp_space
+ 5 + length
> tmp_space_size
)
3181 /* Flush buffer before refilling or reallocating. */
3182 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
)
3186 /* Reallocate if now empty buffer still too small. */
3187 if (5 + length
> tmp_space_size
)
3189 /* See alloca above for discussion of new size. */
3190 tmp_space_size
= MAX (2 * tmp_space_size
, 5 + length
);
3191 tmp_space
= alloca (tmp_space_size
);
3194 /* Reset to beginning of the (possibly new) buffer
3199 /* First element in a string table entry is the length of
3200 the string. This must always be 4 byte aligned. This is
3201 also an appropriate time to fill in the string index
3202 field in the symbol table entry. */
3203 bfd_put_32 (abfd
, length
, p
);
3207 /* Next comes the string itself + a null terminator. */
3208 strcpy (p
, comp
[i
]);
3213 obj_som_compilation_unit (abfd
)->name
.n_strx
= strings_size
;
3216 obj_som_compilation_unit (abfd
)->language_name
.n_strx
=
3220 obj_som_compilation_unit (abfd
)->product_id
.n_strx
=
3224 obj_som_compilation_unit (abfd
)->version_id
.n_strx
=
3230 strings_size
+= length
+ 1;
3232 /* Always align up to the next word boundary. */
3233 while (strings_size
% 4)
3235 bfd_put_8 (abfd
, 0, p
);
3242 for (i
= 0; i
< num_syms
; i
++)
3244 size_t length
= strlen (syms
[i
]->name
);
3246 /* If there is not enough room for the next entry, then dump the
3247 current buffer contents now and maybe allocate a larger buffer. */
3248 if (p
- tmp_space
+ 5 + length
> tmp_space_size
)
3250 /* Flush buffer before refilling or reallocating. */
3251 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
)
3255 /* Reallocate if now empty buffer still too small. */
3256 if (5 + length
> tmp_space_size
)
3258 /* See alloca above for discussion of new size. */
3259 tmp_space_size
= MAX (2 * tmp_space_size
, 5 + length
);
3260 tmp_space
= alloca (tmp_space_size
);
3263 /* Reset to beginning of the (possibly new) buffer space. */
3267 /* First element in a string table entry is the length of the
3268 string. This must always be 4 byte aligned. This is also
3269 an appropriate time to fill in the string index field in the
3270 symbol table entry. */
3271 bfd_put_32 (abfd
, length
, p
);
3275 /* Next comes the string itself + a null terminator. */
3276 strcpy (p
, syms
[i
]->name
);
3278 som_symbol_data (syms
[i
])->stringtab_offset
= strings_size
;
3280 strings_size
+= length
+ 1;
3282 /* Always align up to the next word boundary. */
3283 while (strings_size
% 4)
3285 bfd_put_8 (abfd
, 0, p
);
3291 /* Scribble out any partial block. */
3292 if (bfd_write ((PTR
) &tmp_space
[0], p
- tmp_space
, 1, abfd
) != p
- tmp_space
)
3295 *string_sizep
= strings_size
;
3299 /* Compute variable information to be placed in the SOM headers,
3300 space/subspace dictionaries, relocation streams, etc. Begin
3301 writing parts of the object file. */
3304 som_begin_writing (abfd
)
3307 unsigned long current_offset
= 0;
3308 int strings_size
= 0;
3309 unsigned long num_spaces
, num_subspaces
, i
;
3311 unsigned int total_subspaces
= 0;
3312 struct som_exec_auxhdr
*exec_header
= NULL
;
3314 /* The file header will always be first in an object file,
3315 everything else can be in random locations. To keep things
3316 "simple" BFD will lay out the object file in the manner suggested
3317 by the PRO ABI for PA-RISC Systems. */
3319 /* Before any output can really begin offsets for all the major
3320 portions of the object file must be computed. So, starting
3321 with the initial file header compute (and sometimes write)
3322 each portion of the object file. */
3324 /* Make room for the file header, it's contents are not complete
3325 yet, so it can not be written at this time. */
3326 current_offset
+= sizeof (struct header
);
3328 /* Any auxiliary headers will follow the file header. Right now
3329 we support only the copyright and version headers. */
3330 obj_som_file_hdr (abfd
)->aux_header_location
= current_offset
;
3331 obj_som_file_hdr (abfd
)->aux_header_size
= 0;
3332 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3334 /* Parts of the exec header will be filled in later, so
3335 delay writing the header itself. Fill in the defaults,
3336 and write it later. */
3337 current_offset
+= sizeof (struct som_exec_auxhdr
);
3338 obj_som_file_hdr (abfd
)->aux_header_size
3339 += sizeof (struct som_exec_auxhdr
);
3340 exec_header
= obj_som_exec_hdr (abfd
);
3341 exec_header
->som_auxhdr
.type
= EXEC_AUX_ID
;
3342 exec_header
->som_auxhdr
.length
= 40;
3344 if (obj_som_version_hdr (abfd
) != NULL
)
3348 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) < 0)
3351 /* Write the aux_id structure and the string length. */
3352 len
= sizeof (struct aux_id
) + sizeof (unsigned int);
3353 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
3354 current_offset
+= len
;
3355 if (bfd_write ((PTR
) obj_som_version_hdr (abfd
), len
, 1, abfd
) != len
)
3358 /* Write the version string. */
3359 len
= obj_som_version_hdr (abfd
)->header_id
.length
- sizeof (int);
3360 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
3361 current_offset
+= len
;
3362 if (bfd_write ((PTR
) obj_som_version_hdr (abfd
)->user_string
,
3363 len
, 1, abfd
) != len
)
3367 if (obj_som_copyright_hdr (abfd
) != NULL
)
3371 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) < 0)
3374 /* Write the aux_id structure and the string length. */
3375 len
= sizeof (struct aux_id
) + sizeof (unsigned int);
3376 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
3377 current_offset
+= len
;
3378 if (bfd_write ((PTR
) obj_som_copyright_hdr (abfd
), len
, 1, abfd
) != len
)
3381 /* Write the copyright string. */
3382 len
= obj_som_copyright_hdr (abfd
)->header_id
.length
- sizeof (int);
3383 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
3384 current_offset
+= len
;
3385 if (bfd_write ((PTR
) obj_som_copyright_hdr (abfd
)->copyright
,
3386 len
, 1, abfd
) != len
)
3390 /* Next comes the initialization pointers; we have no initialization
3391 pointers, so current offset does not change. */
3392 obj_som_file_hdr (abfd
)->init_array_location
= current_offset
;
3393 obj_som_file_hdr (abfd
)->init_array_total
= 0;
3395 /* Next are the space records. These are fixed length records.
3397 Count the number of spaces to determine how much room is needed
3398 in the object file for the space records.
3400 The names of the spaces are stored in a separate string table,
3401 and the index for each space into the string table is computed
3402 below. Therefore, it is not possible to write the space headers
3404 num_spaces
= som_count_spaces (abfd
);
3405 obj_som_file_hdr (abfd
)->space_location
= current_offset
;
3406 obj_som_file_hdr (abfd
)->space_total
= num_spaces
;
3407 current_offset
+= num_spaces
* sizeof (struct space_dictionary_record
);
3409 /* Next are the subspace records. These are fixed length records.
3411 Count the number of subspaes to determine how much room is needed
3412 in the object file for the subspace records.
3414 A variety if fields in the subspace record are still unknown at
3415 this time (index into string table, fixup stream location/size, etc). */
3416 num_subspaces
= som_count_subspaces (abfd
);
3417 obj_som_file_hdr (abfd
)->subspace_location
= current_offset
;
3418 obj_som_file_hdr (abfd
)->subspace_total
= num_subspaces
;
3419 current_offset
+= num_subspaces
* sizeof (struct subspace_dictionary_record
);
3421 /* Next is the string table for the space/subspace names. We will
3422 build and write the string table on the fly. At the same time
3423 we will fill in the space/subspace name index fields. */
3425 /* The string table needs to be aligned on a word boundary. */
3426 if (current_offset
% 4)
3427 current_offset
+= (4 - (current_offset
% 4));
3429 /* Mark the offset of the space/subspace string table in the
3431 obj_som_file_hdr (abfd
)->space_strings_location
= current_offset
;
3433 /* Scribble out the space strings. */
3434 if (som_write_space_strings (abfd
, current_offset
, &strings_size
) == false)
3437 /* Record total string table size in the header and update the
3439 obj_som_file_hdr (abfd
)->space_strings_size
= strings_size
;
3440 current_offset
+= strings_size
;
3442 /* Next is the compilation unit. */
3443 obj_som_file_hdr (abfd
)->compiler_location
= current_offset
;
3444 obj_som_file_hdr (abfd
)->compiler_total
= 0;
3445 if (obj_som_compilation_unit (abfd
))
3447 obj_som_file_hdr (abfd
)->compiler_total
= 1;
3448 current_offset
+= COMPUNITSZ
;
3451 /* Now compute the file positions for the loadable subspaces, taking
3452 care to make sure everything stays properly aligned. */
3454 section
= abfd
->sections
;
3455 for (i
= 0; i
< num_spaces
; i
++)
3457 asection
*subsection
;
3459 unsigned int subspace_offset
= 0;
3462 while (!som_is_space (section
))
3463 section
= section
->next
;
3466 /* Now look for all its subspaces. */
3467 for (subsection
= abfd
->sections
;
3469 subsection
= subsection
->next
)
3472 if (!som_is_subspace (subsection
)
3473 || !som_is_container (section
, subsection
)
3474 || (subsection
->flags
& SEC_ALLOC
) == 0)
3477 /* If this is the first subspace in the space, and we are
3478 building an executable, then take care to make sure all
3479 the alignments are correct and update the exec header. */
3481 && (abfd
->flags
& (EXEC_P
| DYNAMIC
)))
3483 /* Demand paged executables have each space aligned to a
3484 page boundary. Sharable executables (write-protected
3485 text) have just the private (aka data & bss) space aligned
3486 to a page boundary. Ugh. Not true for HPUX.
3488 The HPUX kernel requires the text to always be page aligned
3489 within the file regardless of the executable's type. */
3490 if (abfd
->flags
& (D_PAGED
| DYNAMIC
)
3491 || (subsection
->flags
& SEC_CODE
)
3492 || ((abfd
->flags
& WP_TEXT
)
3493 && (subsection
->flags
& SEC_DATA
)))
3494 current_offset
= SOM_ALIGN (current_offset
, PA_PAGESIZE
);
3496 /* Update the exec header. */
3497 if (subsection
->flags
& SEC_CODE
&& exec_header
->exec_tfile
== 0)
3499 exec_header
->exec_tmem
= section
->vma
;
3500 exec_header
->exec_tfile
= current_offset
;
3502 if (subsection
->flags
& SEC_DATA
&& exec_header
->exec_dfile
== 0)
3504 exec_header
->exec_dmem
= section
->vma
;
3505 exec_header
->exec_dfile
= current_offset
;
3508 /* Keep track of exactly where we are within a particular
3509 space. This is necessary as the braindamaged HPUX
3510 loader will create holes between subspaces *and*
3511 subspace alignments are *NOT* preserved. What a crock. */
3512 subspace_offset
= subsection
->vma
;
3514 /* Only do this for the first subspace within each space. */
3517 else if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3519 /* The braindamaged HPUX loader may have created a hole
3520 between two subspaces. It is *not* sufficient to use
3521 the alignment specifications within the subspaces to
3522 account for these holes -- I've run into at least one
3523 case where the loader left one code subspace unaligned
3524 in a final executable.
3526 To combat this we keep a current offset within each space,
3527 and use the subspace vma fields to detect and preserve
3528 holes. What a crock!
3530 ps. This is not necessary for unloadable space/subspaces. */
3531 current_offset
+= subsection
->vma
- subspace_offset
;
3532 if (subsection
->flags
& SEC_CODE
)
3533 exec_header
->exec_tsize
+= subsection
->vma
- subspace_offset
;
3535 exec_header
->exec_dsize
+= subsection
->vma
- subspace_offset
;
3536 subspace_offset
+= subsection
->vma
- subspace_offset
;
3539 subsection
->target_index
= total_subspaces
++;
3540 /* This is real data to be loaded from the file. */
3541 if (subsection
->flags
& SEC_LOAD
)
3543 /* Update the size of the code & data. */
3544 if (abfd
->flags
& (EXEC_P
| DYNAMIC
)
3545 && subsection
->flags
& SEC_CODE
)
3546 exec_header
->exec_tsize
+= subsection
->_cooked_size
;
3547 else if (abfd
->flags
& (EXEC_P
| DYNAMIC
)
3548 && subsection
->flags
& SEC_DATA
)
3549 exec_header
->exec_dsize
+= subsection
->_cooked_size
;
3550 som_section_data (subsection
)->subspace_dict
->file_loc_init_value
3552 subsection
->filepos
= current_offset
;
3553 current_offset
+= bfd_section_size (abfd
, subsection
);
3554 subspace_offset
+= bfd_section_size (abfd
, subsection
);
3556 /* Looks like uninitialized data. */
3559 /* Update the size of the bss section. */
3560 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3561 exec_header
->exec_bsize
+= subsection
->_cooked_size
;
3563 som_section_data (subsection
)->subspace_dict
->file_loc_init_value
3565 som_section_data (subsection
)->subspace_dict
->
3566 initialization_length
= 0;
3569 /* Goto the next section. */
3570 section
= section
->next
;
3573 /* Finally compute the file positions for unloadable subspaces.
3574 If building an executable, start the unloadable stuff on its
3577 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3578 current_offset
= SOM_ALIGN (current_offset
, PA_PAGESIZE
);
3580 obj_som_file_hdr (abfd
)->unloadable_sp_location
= current_offset
;
3581 section
= abfd
->sections
;
3582 for (i
= 0; i
< num_spaces
; i
++)
3584 asection
*subsection
;
3587 while (!som_is_space (section
))
3588 section
= section
->next
;
3590 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3591 current_offset
= SOM_ALIGN (current_offset
, PA_PAGESIZE
);
3593 /* Now look for all its subspaces. */
3594 for (subsection
= abfd
->sections
;
3596 subsection
= subsection
->next
)
3599 if (!som_is_subspace (subsection
)
3600 || !som_is_container (section
, subsection
)
3601 || (subsection
->flags
& SEC_ALLOC
) != 0)
3604 subsection
->target_index
= total_subspaces
++;
3605 /* This is real data to be loaded from the file. */
3606 if ((subsection
->flags
& SEC_LOAD
) == 0)
3608 som_section_data (subsection
)->subspace_dict
->file_loc_init_value
3610 subsection
->filepos
= current_offset
;
3611 current_offset
+= bfd_section_size (abfd
, subsection
);
3613 /* Looks like uninitialized data. */
3616 som_section_data (subsection
)->subspace_dict
->file_loc_init_value
3618 som_section_data (subsection
)->subspace_dict
->
3619 initialization_length
= bfd_section_size (abfd
, subsection
);
3622 /* Goto the next section. */
3623 section
= section
->next
;
3626 /* If building an executable, then make sure to seek to and write
3627 one byte at the end of the file to make sure any necessary
3628 zeros are filled in. Ugh. */
3629 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3630 current_offset
= SOM_ALIGN (current_offset
, PA_PAGESIZE
);
3631 if (bfd_seek (abfd
, current_offset
- 1, SEEK_SET
) < 0)
3633 if (bfd_write ((PTR
) "", 1, 1, abfd
) != 1)
3636 obj_som_file_hdr (abfd
)->unloadable_sp_size
3637 = current_offset
- obj_som_file_hdr (abfd
)->unloadable_sp_location
;
3639 /* Loader fixups are not supported in any way shape or form. */
3640 obj_som_file_hdr (abfd
)->loader_fixup_location
= 0;
3641 obj_som_file_hdr (abfd
)->loader_fixup_total
= 0;
3643 /* Done. Store the total size of the SOM so far. */
3644 obj_som_file_hdr (abfd
)->som_length
= current_offset
;
3649 /* Finally, scribble out the various headers to the disk. */
3652 som_finish_writing (abfd
)
3655 int num_spaces
= som_count_spaces (abfd
);
3656 asymbol
**syms
= bfd_get_outsymbols (abfd
);
3657 int i
, num_syms
, strings_size
;
3658 int subspace_index
= 0;
3661 unsigned long current_offset
;
3662 unsigned int total_reloc_size
;
3664 /* Next is the symbol table. These are fixed length records.
3666 Count the number of symbols to determine how much room is needed
3667 in the object file for the symbol table.
3669 The names of the symbols are stored in a separate string table,
3670 and the index for each symbol name into the string table is computed
3671 below. Therefore, it is not possible to write the symbol table
3674 These used to be output before the subspace contents, but they
3675 were moved here to work around a stupid bug in the hpux linker
3676 (fixed in hpux10). */
3677 current_offset
= obj_som_file_hdr (abfd
)->som_length
;
3679 /* Make sure we're on a word boundary. */
3680 if (current_offset
% 4)
3681 current_offset
+= (4 - (current_offset
% 4));
3683 num_syms
= bfd_get_symcount (abfd
);
3684 obj_som_file_hdr (abfd
)->symbol_location
= current_offset
;
3685 obj_som_file_hdr (abfd
)->symbol_total
= num_syms
;
3686 current_offset
+= num_syms
* sizeof (struct symbol_dictionary_record
);
3688 /* Next are the symbol strings.
3689 Align them to a word boundary. */
3690 if (current_offset
% 4)
3691 current_offset
+= (4 - (current_offset
% 4));
3692 obj_som_file_hdr (abfd
)->symbol_strings_location
= current_offset
;
3694 /* Scribble out the symbol strings. */
3695 if (som_write_symbol_strings (abfd
, current_offset
, syms
,
3696 num_syms
, &strings_size
,
3697 obj_som_compilation_unit (abfd
))
3701 /* Record total string table size in header and update the
3703 obj_som_file_hdr (abfd
)->symbol_strings_size
= strings_size
;
3704 current_offset
+= strings_size
;
3706 /* Do prep work before handling fixups. */
3707 som_prep_for_fixups (abfd
,
3708 bfd_get_outsymbols (abfd
),
3709 bfd_get_symcount (abfd
));
3711 /* At the end of the file is the fixup stream which starts on a
3713 if (current_offset
% 4)
3714 current_offset
+= (4 - (current_offset
% 4));
3715 obj_som_file_hdr (abfd
)->fixup_request_location
= current_offset
;
3717 /* Write the fixups and update fields in subspace headers which
3718 relate to the fixup stream. */
3719 if (som_write_fixups (abfd
, current_offset
, &total_reloc_size
) == false)
3722 /* Record the total size of the fixup stream in the file header. */
3723 obj_som_file_hdr (abfd
)->fixup_request_total
= total_reloc_size
;
3725 /* Done. Store the total size of the SOM. */
3726 obj_som_file_hdr (abfd
)->som_length
= current_offset
+ total_reloc_size
;
3728 /* Now that the symbol table information is complete, build and
3729 write the symbol table. */
3730 if (som_build_and_write_symbol_table (abfd
) == false)
3733 /* Subspaces are written first so that we can set up information
3734 about them in their containing spaces as the subspace is written. */
3736 /* Seek to the start of the subspace dictionary records. */
3737 location
= obj_som_file_hdr (abfd
)->subspace_location
;
3738 if (bfd_seek (abfd
, location
, SEEK_SET
) < 0)
3741 section
= abfd
->sections
;
3742 /* Now for each loadable space write out records for its subspaces. */
3743 for (i
= 0; i
< num_spaces
; i
++)
3745 asection
*subsection
;
3748 while (!som_is_space (section
))
3749 section
= section
->next
;
3751 /* Now look for all its subspaces. */
3752 for (subsection
= abfd
->sections
;
3754 subsection
= subsection
->next
)
3757 /* Skip any section which does not correspond to a space
3758 or subspace. Or does not have SEC_ALLOC set (and therefore
3759 has no real bits on the disk). */
3760 if (!som_is_subspace (subsection
)
3761 || !som_is_container (section
, subsection
)
3762 || (subsection
->flags
& SEC_ALLOC
) == 0)
3765 /* If this is the first subspace for this space, then save
3766 the index of the subspace in its containing space. Also
3767 set "is_loadable" in the containing space. */
3769 if (som_section_data (section
)->space_dict
->subspace_quantity
== 0)
3771 som_section_data (section
)->space_dict
->is_loadable
= 1;
3772 som_section_data (section
)->space_dict
->subspace_index
3776 /* Increment the number of subspaces seen and the number of
3777 subspaces contained within the current space. */
3779 som_section_data (section
)->space_dict
->subspace_quantity
++;
3781 /* Mark the index of the current space within the subspace's
3782 dictionary record. */
3783 som_section_data (subsection
)->subspace_dict
->space_index
= i
;
3785 /* Dump the current subspace header. */
3786 if (bfd_write ((PTR
) som_section_data (subsection
)->subspace_dict
,
3787 sizeof (struct subspace_dictionary_record
), 1, abfd
)
3788 != sizeof (struct subspace_dictionary_record
))
3791 /* Goto the next section. */
3792 section
= section
->next
;
3795 /* Now repeat the process for unloadable subspaces. */
3796 section
= abfd
->sections
;
3797 /* Now for each space write out records for its subspaces. */
3798 for (i
= 0; i
< num_spaces
; i
++)
3800 asection
*subsection
;
3803 while (!som_is_space (section
))
3804 section
= section
->next
;
3806 /* Now look for all its subspaces. */
3807 for (subsection
= abfd
->sections
;
3809 subsection
= subsection
->next
)
3812 /* Skip any section which does not correspond to a space or
3813 subspace, or which SEC_ALLOC set (and therefore handled
3814 in the loadable spaces/subspaces code above). */
3816 if (!som_is_subspace (subsection
)
3817 || !som_is_container (section
, subsection
)
3818 || (subsection
->flags
& SEC_ALLOC
) != 0)
3821 /* If this is the first subspace for this space, then save
3822 the index of the subspace in its containing space. Clear
3825 if (som_section_data (section
)->space_dict
->subspace_quantity
== 0)
3827 som_section_data (section
)->space_dict
->is_loadable
= 0;
3828 som_section_data (section
)->space_dict
->subspace_index
3832 /* Increment the number of subspaces seen and the number of
3833 subspaces contained within the current space. */
3834 som_section_data (section
)->space_dict
->subspace_quantity
++;
3837 /* Mark the index of the current space within the subspace's
3838 dictionary record. */
3839 som_section_data (subsection
)->subspace_dict
->space_index
= i
;
3841 /* Dump this subspace header. */
3842 if (bfd_write ((PTR
) som_section_data (subsection
)->subspace_dict
,
3843 sizeof (struct subspace_dictionary_record
), 1, abfd
)
3844 != sizeof (struct subspace_dictionary_record
))
3847 /* Goto the next section. */
3848 section
= section
->next
;
3851 /* All the subspace dictiondary records are written, and all the
3852 fields are set up in the space dictionary records.
3854 Seek to the right location and start writing the space
3855 dictionary records. */
3856 location
= obj_som_file_hdr (abfd
)->space_location
;
3857 if (bfd_seek (abfd
, location
, SEEK_SET
) < 0)
3860 section
= abfd
->sections
;
3861 for (i
= 0; i
< num_spaces
; i
++)
3864 while (!som_is_space (section
))
3865 section
= section
->next
;
3867 /* Dump its header. */
3868 if (bfd_write ((PTR
) som_section_data (section
)->space_dict
,
3869 sizeof (struct space_dictionary_record
), 1, abfd
)
3870 != sizeof (struct space_dictionary_record
))
3873 /* Goto the next section. */
3874 section
= section
->next
;
3877 /* Write the compilation unit record if there is one. */
3878 if (obj_som_compilation_unit (abfd
))
3880 location
= obj_som_file_hdr (abfd
)->compiler_location
;
3881 if (bfd_seek (abfd
, location
, SEEK_SET
) < 0)
3884 if (bfd_write ((PTR
) obj_som_compilation_unit (abfd
),
3885 COMPUNITSZ
, 1, abfd
) != COMPUNITSZ
)
3889 /* Setting of the system_id has to happen very late now that copying of
3890 BFD private data happens *after* section contents are set. */
3891 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3892 obj_som_file_hdr (abfd
)->system_id
= obj_som_exec_data (abfd
)->system_id
;
3893 else if (bfd_get_mach (abfd
) == pa20
)
3894 obj_som_file_hdr (abfd
)->system_id
= CPU_PA_RISC2_0
;
3895 else if (bfd_get_mach (abfd
) == pa11
)
3896 obj_som_file_hdr (abfd
)->system_id
= CPU_PA_RISC1_1
;
3898 obj_som_file_hdr (abfd
)->system_id
= CPU_PA_RISC1_0
;
3900 /* Compute the checksum for the file header just before writing
3901 the header to disk. */
3902 obj_som_file_hdr (abfd
)->checksum
= som_compute_checksum (abfd
);
3904 /* Only thing left to do is write out the file header. It is always
3905 at location zero. Seek there and write it. */
3906 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) < 0)
3908 if (bfd_write ((PTR
) obj_som_file_hdr (abfd
),
3909 sizeof (struct header
), 1, abfd
)
3910 != sizeof (struct header
))
3913 /* Now write the exec header. */
3914 if (abfd
->flags
& (EXEC_P
| DYNAMIC
))
3916 long tmp
, som_length
;
3917 struct som_exec_auxhdr
*exec_header
;
3919 exec_header
= obj_som_exec_hdr (abfd
);
3920 exec_header
->exec_entry
= bfd_get_start_address (abfd
);
3921 exec_header
->exec_flags
= obj_som_exec_data (abfd
)->exec_flags
;
3923 /* Oh joys. Ram some of the BSS data into the DATA section
3924 to be compatable with how the hp linker makes objects
3925 (saves memory space). */
3926 tmp
= exec_header
->exec_dsize
;
3927 tmp
= SOM_ALIGN (tmp
, PA_PAGESIZE
);
3928 exec_header
->exec_bsize
-= (tmp
- exec_header
->exec_dsize
);
3929 if (exec_header
->exec_bsize
< 0)
3930 exec_header
->exec_bsize
= 0;
3931 exec_header
->exec_dsize
= tmp
;
3933 /* Now perform some sanity checks. The idea is to catch bogons now and
3934 inform the user, instead of silently generating a bogus file. */
3935 som_length
= obj_som_file_hdr (abfd
)->som_length
;
3936 if (exec_header
->exec_tfile
+ exec_header
->exec_tsize
> som_length
3937 || exec_header
->exec_dfile
+ exec_header
->exec_dsize
> som_length
)
3939 bfd_set_error (bfd_error_bad_value
);
3943 if (bfd_seek (abfd
, obj_som_file_hdr (abfd
)->aux_header_location
,
3947 if (bfd_write ((PTR
) exec_header
, AUX_HDR_SIZE
, 1, abfd
)
3954 /* Compute and return the checksum for a SOM file header. */
3956 static unsigned long
3957 som_compute_checksum (abfd
)
3960 unsigned long checksum
, count
, i
;
3961 unsigned long *buffer
= (unsigned long *) obj_som_file_hdr (abfd
);
3964 count
= sizeof (struct header
) / sizeof (unsigned long);
3965 for (i
= 0; i
< count
; i
++)
3966 checksum
^= *(buffer
+ i
);
3972 som_bfd_derive_misc_symbol_info (abfd
, sym
, info
)
3973 bfd
*abfd ATTRIBUTE_UNUSED
;
3975 struct som_misc_symbol_info
*info
;
3978 memset (info
, 0, sizeof (struct som_misc_symbol_info
));
3980 /* The HP SOM linker requires detailed type information about
3981 all symbols (including undefined symbols!). Unfortunately,
3982 the type specified in an import/export statement does not
3983 always match what the linker wants. Severe braindamage. */
3985 /* Section symbols will not have a SOM symbol type assigned to
3986 them yet. Assign all section symbols type ST_DATA. */
3987 if (sym
->flags
& BSF_SECTION_SYM
)
3988 info
->symbol_type
= ST_DATA
;
3991 /* Common symbols must have scope SS_UNSAT and type
3992 ST_STORAGE or the linker will choke. */
3993 if (bfd_is_com_section (sym
->section
))
3995 info
->symbol_scope
= SS_UNSAT
;
3996 info
->symbol_type
= ST_STORAGE
;
3999 /* It is possible to have a symbol without an associated
4000 type. This happens if the user imported the symbol
4001 without a type and the symbol was never defined
4002 locally. If BSF_FUNCTION is set for this symbol, then
4003 assign it type ST_CODE (the HP linker requires undefined
4004 external functions to have type ST_CODE rather than ST_ENTRY). */
4005 else if ((som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
4006 || som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_CODE
)
4007 && bfd_is_und_section (sym
->section
)
4008 && sym
->flags
& BSF_FUNCTION
)
4009 info
->symbol_type
= ST_CODE
;
4011 /* Handle function symbols which were defined in this file.
4012 They should have type ST_ENTRY. Also retrieve the argument
4013 relocation bits from the SOM backend information. */
4014 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_ENTRY
4015 || (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_CODE
4016 && (sym
->flags
& BSF_FUNCTION
))
4017 || (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
4018 && (sym
->flags
& BSF_FUNCTION
)))
4020 info
->symbol_type
= ST_ENTRY
;
4021 info
->arg_reloc
= som_symbol_data (sym
)->tc_data
.ap
.hppa_arg_reloc
;
4022 info
->priv_level
= som_symbol_data (sym
)->tc_data
.ap
.hppa_priv_level
;
4025 /* For unknown symbols set the symbol's type based on the symbol's
4026 section (ST_DATA for DATA sections, ST_CODE for CODE sections). */
4027 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
)
4029 if (sym
->section
->flags
& SEC_CODE
)
4030 info
->symbol_type
= ST_CODE
;
4032 info
->symbol_type
= ST_DATA
;
4035 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
)
4036 info
->symbol_type
= ST_DATA
;
4038 /* From now on it's a very simple mapping. */
4039 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_ABSOLUTE
)
4040 info
->symbol_type
= ST_ABSOLUTE
;
4041 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_CODE
)
4042 info
->symbol_type
= ST_CODE
;
4043 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_DATA
)
4044 info
->symbol_type
= ST_DATA
;
4045 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_MILLICODE
)
4046 info
->symbol_type
= ST_MILLICODE
;
4047 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_PLABEL
)
4048 info
->symbol_type
= ST_PLABEL
;
4049 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_PRI_PROG
)
4050 info
->symbol_type
= ST_PRI_PROG
;
4051 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_SEC_PROG
)
4052 info
->symbol_type
= ST_SEC_PROG
;
4055 /* Now handle the symbol's scope. Exported data which is not
4056 in the common section has scope SS_UNIVERSAL. Note scope
4057 of common symbols was handled earlier! */
4058 if (bfd_is_und_section (sym
->section
))
4059 info
->symbol_scope
= SS_UNSAT
;
4060 else if (sym
->flags
& (BSF_EXPORT
| BSF_WEAK
)
4061 && ! bfd_is_com_section (sym
->section
))
4062 info
->symbol_scope
= SS_UNIVERSAL
;
4063 /* Anything else which is not in the common section has scope
4065 else if (! bfd_is_com_section (sym
->section
))
4066 info
->symbol_scope
= SS_LOCAL
;
4068 /* Now set the symbol_info field. It has no real meaning
4069 for undefined or common symbols, but the HP linker will
4070 choke if it's not set to some "reasonable" value. We
4071 use zero as a reasonable value. */
4072 if (bfd_is_com_section (sym
->section
)
4073 || bfd_is_und_section (sym
->section
)
4074 || bfd_is_abs_section (sym
->section
))
4075 info
->symbol_info
= 0;
4076 /* For all other symbols, the symbol_info field contains the
4077 subspace index of the space this symbol is contained in. */
4079 info
->symbol_info
= sym
->section
->target_index
;
4081 /* Set the symbol's value. */
4082 info
->symbol_value
= sym
->value
+ sym
->section
->vma
;
4084 /* The secondary_def field is for weak symbols. */
4085 if (sym
->flags
& BSF_WEAK
)
4086 info
->secondary_def
= true;
4088 info
->secondary_def
= false;
4092 /* Build and write, in one big chunk, the entire symbol table for
4096 som_build_and_write_symbol_table (abfd
)
4099 unsigned int num_syms
= bfd_get_symcount (abfd
);
4100 file_ptr symtab_location
= obj_som_file_hdr (abfd
)->symbol_location
;
4101 asymbol
**bfd_syms
= obj_som_sorted_syms (abfd
);
4102 struct symbol_dictionary_record
*som_symtab
= NULL
;
4105 /* Compute total symbol table size and allocate a chunk of memory
4106 to hold the symbol table as we build it. */
4107 symtab_size
= num_syms
* sizeof (struct symbol_dictionary_record
);
4108 som_symtab
= (struct symbol_dictionary_record
*) bfd_malloc (symtab_size
);
4109 if (som_symtab
== NULL
&& symtab_size
!= 0)
4111 memset (som_symtab
, 0, symtab_size
);
4113 /* Walk over each symbol. */
4114 for (i
= 0; i
< num_syms
; i
++)
4116 struct som_misc_symbol_info info
;
4118 /* This is really an index into the symbol strings table.
4119 By the time we get here, the index has already been
4120 computed and stored into the name field in the BFD symbol. */
4121 som_symtab
[i
].name
.n_strx
= som_symbol_data(bfd_syms
[i
])->stringtab_offset
;
4123 /* Derive SOM information from the BFD symbol. */
4124 som_bfd_derive_misc_symbol_info (abfd
, bfd_syms
[i
], &info
);
4127 som_symtab
[i
].symbol_type
= info
.symbol_type
;
4128 som_symtab
[i
].symbol_scope
= info
.symbol_scope
;
4129 som_symtab
[i
].arg_reloc
= info
.arg_reloc
;
4130 som_symtab
[i
].symbol_info
= info
.symbol_info
;
4131 som_symtab
[i
].xleast
= 3;
4132 som_symtab
[i
].symbol_value
= info
.symbol_value
| info
.priv_level
;
4133 som_symtab
[i
].secondary_def
= info
.secondary_def
;
4136 /* Everything is ready, seek to the right location and
4137 scribble out the symbol table. */
4138 if (bfd_seek (abfd
, symtab_location
, SEEK_SET
) != 0)
4141 if (bfd_write ((PTR
) som_symtab
, symtab_size
, 1, abfd
) != symtab_size
)
4144 if (som_symtab
!= NULL
)
4148 if (som_symtab
!= NULL
)
4153 /* Write an object in SOM format. */
4156 som_write_object_contents (abfd
)
4159 if (abfd
->output_has_begun
== false)
4161 /* Set up fixed parts of the file, space, and subspace headers.
4162 Notify the world that output has begun. */
4163 som_prep_headers (abfd
);
4164 abfd
->output_has_begun
= true;
4165 /* Start writing the object file. This include all the string
4166 tables, fixup streams, and other portions of the object file. */
4167 som_begin_writing (abfd
);
4170 return (som_finish_writing (abfd
));
4173 /* Read and save the string table associated with the given BFD. */
4176 som_slurp_string_table (abfd
)
4181 /* Use the saved version if its available. */
4182 if (obj_som_stringtab (abfd
) != NULL
)
4185 /* I don't think this can currently happen, and I'm not sure it should
4186 really be an error, but it's better than getting unpredictable results
4187 from the host's malloc when passed a size of zero. */
4188 if (obj_som_stringtab_size (abfd
) == 0)
4190 bfd_set_error (bfd_error_no_symbols
);
4194 /* Allocate and read in the string table. */
4195 stringtab
= bfd_malloc (obj_som_stringtab_size (abfd
));
4196 if (stringtab
== NULL
)
4198 memset (stringtab
, 0, obj_som_stringtab_size (abfd
));
4200 if (bfd_seek (abfd
, obj_som_str_filepos (abfd
), SEEK_SET
) < 0)
4203 if (bfd_read (stringtab
, obj_som_stringtab_size (abfd
), 1, abfd
)
4204 != obj_som_stringtab_size (abfd
))
4207 /* Save our results and return success. */
4208 obj_som_stringtab (abfd
) = stringtab
;
4212 /* Return the amount of data (in bytes) required to hold the symbol
4213 table for this object. */
4216 som_get_symtab_upper_bound (abfd
)
4219 if (!som_slurp_symbol_table (abfd
))
4222 return (bfd_get_symcount (abfd
) + 1) * (sizeof (asymbol
*));
4225 /* Convert from a SOM subspace index to a BFD section. */
4228 bfd_section_from_som_symbol (abfd
, symbol
)
4230 struct symbol_dictionary_record
*symbol
;
4234 /* The meaning of the symbol_info field changes for functions
4235 within executables. So only use the quick symbol_info mapping for
4236 incomplete objects and non-function symbols in executables. */
4237 if ((abfd
->flags
& (EXEC_P
| DYNAMIC
)) == 0
4238 || (symbol
->symbol_type
!= ST_ENTRY
4239 && symbol
->symbol_type
!= ST_PRI_PROG
4240 && symbol
->symbol_type
!= ST_SEC_PROG
4241 && symbol
->symbol_type
!= ST_MILLICODE
))
4243 unsigned int index
= symbol
->symbol_info
;
4244 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
4245 if (section
->target_index
== index
&& som_is_subspace (section
))
4248 /* Could be a symbol from an external library (such as an OMOS
4249 shared library). Don't abort. */
4250 return bfd_abs_section_ptr
;
4255 unsigned int value
= symbol
->symbol_value
;
4257 /* For executables we will have to use the symbol's address and
4258 find out what section would contain that address. Yuk. */
4259 for (section
= abfd
->sections
; section
; section
= section
->next
)
4261 if (value
>= section
->vma
4262 && value
<= section
->vma
+ section
->_cooked_size
4263 && som_is_subspace (section
))
4267 /* Could be a symbol from an external library (such as an OMOS
4268 shared library). Don't abort. */
4269 return bfd_abs_section_ptr
;
4274 /* Read and save the symbol table associated with the given BFD. */
4277 som_slurp_symbol_table (abfd
)
4280 int symbol_count
= bfd_get_symcount (abfd
);
4281 int symsize
= sizeof (struct symbol_dictionary_record
);
4283 struct symbol_dictionary_record
*buf
= NULL
, *bufp
, *endbufp
;
4284 som_symbol_type
*sym
, *symbase
;
4286 /* Return saved value if it exists. */
4287 if (obj_som_symtab (abfd
) != NULL
)
4288 goto successful_return
;
4290 /* Special case. This is *not* an error. */
4291 if (symbol_count
== 0)
4292 goto successful_return
;
4294 if (!som_slurp_string_table (abfd
))
4297 stringtab
= obj_som_stringtab (abfd
);
4299 symbase
= ((som_symbol_type
*)
4300 bfd_malloc (symbol_count
* sizeof (som_symbol_type
)));
4301 if (symbase
== NULL
)
4303 memset (symbase
, 0, symbol_count
* sizeof (som_symbol_type
));
4305 /* Read in the external SOM representation. */
4306 buf
= bfd_malloc (symbol_count
* symsize
);
4307 if (buf
== NULL
&& symbol_count
* symsize
!= 0)
4309 if (bfd_seek (abfd
, obj_som_sym_filepos (abfd
), SEEK_SET
) < 0)
4311 if (bfd_read (buf
, symbol_count
* symsize
, 1, abfd
)
4312 != symbol_count
* symsize
)
4315 /* Iterate over all the symbols and internalize them. */
4316 endbufp
= buf
+ symbol_count
;
4317 for (bufp
= buf
, sym
= symbase
; bufp
< endbufp
; ++bufp
)
4320 /* I don't think we care about these. */
4321 if (bufp
->symbol_type
== ST_SYM_EXT
4322 || bufp
->symbol_type
== ST_ARG_EXT
)
4325 /* Set some private data we care about. */
4326 if (bufp
->symbol_type
== ST_NULL
)
4327 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_UNKNOWN
;
4328 else if (bufp
->symbol_type
== ST_ABSOLUTE
)
4329 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_ABSOLUTE
;
4330 else if (bufp
->symbol_type
== ST_DATA
)
4331 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_DATA
;
4332 else if (bufp
->symbol_type
== ST_CODE
)
4333 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_CODE
;
4334 else if (bufp
->symbol_type
== ST_PRI_PROG
)
4335 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_PRI_PROG
;
4336 else if (bufp
->symbol_type
== ST_SEC_PROG
)
4337 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_SEC_PROG
;
4338 else if (bufp
->symbol_type
== ST_ENTRY
)
4339 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_ENTRY
;
4340 else if (bufp
->symbol_type
== ST_MILLICODE
)
4341 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_MILLICODE
;
4342 else if (bufp
->symbol_type
== ST_PLABEL
)
4343 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_PLABEL
;
4345 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_UNKNOWN
;
4346 som_symbol_data (sym
)->tc_data
.ap
.hppa_arg_reloc
= bufp
->arg_reloc
;
4348 /* Some reasonable defaults. */
4349 sym
->symbol
.the_bfd
= abfd
;
4350 sym
->symbol
.name
= bufp
->name
.n_strx
+ stringtab
;
4351 sym
->symbol
.value
= bufp
->symbol_value
;
4352 sym
->symbol
.section
= 0;
4353 sym
->symbol
.flags
= 0;
4355 switch (bufp
->symbol_type
)
4359 sym
->symbol
.flags
|= BSF_FUNCTION
;
4360 som_symbol_data (sym
)->tc_data
.ap
.hppa_priv_level
=
4361 sym
->symbol
.value
& 0x3;
4362 sym
->symbol
.value
&= ~0x3;
4369 som_symbol_data (sym
)->tc_data
.ap
.hppa_priv_level
=
4370 sym
->symbol
.value
& 0x3;
4371 sym
->symbol
.value
&= ~0x3;
4372 /* If the symbol's scope is SS_UNSAT, then these are
4373 undefined function symbols. */
4374 if (bufp
->symbol_scope
== SS_UNSAT
)
4375 sym
->symbol
.flags
|= BSF_FUNCTION
;
4381 /* Handle scoping and section information. */
4382 switch (bufp
->symbol_scope
)
4384 /* symbol_info field is undefined for SS_EXTERNAL and SS_UNSAT symbols,
4385 so the section associated with this symbol can't be known. */
4387 if (bufp
->symbol_type
!= ST_STORAGE
)
4388 sym
->symbol
.section
= bfd_und_section_ptr
;
4390 sym
->symbol
.section
= bfd_com_section_ptr
;
4391 sym
->symbol
.flags
|= (BSF_EXPORT
| BSF_GLOBAL
);
4395 if (bufp
->symbol_type
!= ST_STORAGE
)
4396 sym
->symbol
.section
= bfd_und_section_ptr
;
4398 sym
->symbol
.section
= bfd_com_section_ptr
;
4402 sym
->symbol
.flags
|= (BSF_EXPORT
| BSF_GLOBAL
);
4403 sym
->symbol
.section
= bfd_section_from_som_symbol (abfd
, bufp
);
4404 sym
->symbol
.value
-= sym
->symbol
.section
->vma
;
4408 /* SS_GLOBAL and SS_LOCAL are two names for the same thing.
4409 Sound dumb? It is. */
4413 sym
->symbol
.flags
|= BSF_LOCAL
;
4414 sym
->symbol
.section
= bfd_section_from_som_symbol (abfd
, bufp
);
4415 sym
->symbol
.value
-= sym
->symbol
.section
->vma
;
4419 /* Check for a weak symbol. */
4420 if (bufp
->secondary_def
)
4421 sym
->symbol
.flags
|= BSF_WEAK
;
4423 /* Mark section symbols and symbols used by the debugger.
4424 Note $START$ is a magic code symbol, NOT a section symbol. */
4425 if (sym
->symbol
.name
[0] == '$'
4426 && sym
->symbol
.name
[strlen (sym
->symbol
.name
) - 1] == '$'
4427 && !strcmp (sym
->symbol
.name
, sym
->symbol
.section
->name
))
4428 sym
->symbol
.flags
|= BSF_SECTION_SYM
;
4429 else if (!strncmp (sym
->symbol
.name
, "L$0\002", 4))
4431 sym
->symbol
.flags
|= BSF_SECTION_SYM
;
4432 sym
->symbol
.name
= sym
->symbol
.section
->name
;
4434 else if (!strncmp (sym
->symbol
.name
, "L$0\001", 4))
4435 sym
->symbol
.flags
|= BSF_DEBUGGING
;
4437 /* Note increment at bottom of loop, since we skip some symbols
4438 we can not include it as part of the for statement. */
4442 /* We modify the symbol count to record the number of BFD symbols we
4444 bfd_get_symcount (abfd
) = sym
- symbase
;
4446 /* Save our results and return success. */
4447 obj_som_symtab (abfd
) = symbase
;
4459 /* Canonicalize a SOM symbol table. Return the number of entries
4460 in the symbol table. */
4463 som_get_symtab (abfd
, location
)
4468 som_symbol_type
*symbase
;
4470 if (!som_slurp_symbol_table (abfd
))
4473 i
= bfd_get_symcount (abfd
);
4474 symbase
= obj_som_symtab (abfd
);
4476 for (; i
> 0; i
--, location
++, symbase
++)
4477 *location
= &symbase
->symbol
;
4479 /* Final null pointer. */
4481 return (bfd_get_symcount (abfd
));
4484 /* Make a SOM symbol. There is nothing special to do here. */
4487 som_make_empty_symbol (abfd
)
4490 som_symbol_type
*new =
4491 (som_symbol_type
*) bfd_zalloc (abfd
, sizeof (som_symbol_type
));
4494 new->symbol
.the_bfd
= abfd
;
4496 return &new->symbol
;
4499 /* Print symbol information. */
4502 som_print_symbol (ignore_abfd
, afile
, symbol
, how
)
4503 bfd
*ignore_abfd ATTRIBUTE_UNUSED
;
4506 bfd_print_symbol_type how
;
4508 FILE *file
= (FILE *) afile
;
4511 case bfd_print_symbol_name
:
4512 fprintf (file
, "%s", symbol
->name
);
4514 case bfd_print_symbol_more
:
4515 fprintf (file
, "som ");
4516 fprintf_vma (file
, symbol
->value
);
4517 fprintf (file
, " %lx", (long) symbol
->flags
);
4519 case bfd_print_symbol_all
:
4521 CONST
char *section_name
;
4522 section_name
= symbol
->section
? symbol
->section
->name
: "(*none*)";
4523 bfd_print_symbol_vandf ((PTR
) file
, symbol
);
4524 fprintf (file
, " %s\t%s", section_name
, symbol
->name
);
4531 som_bfd_is_local_label_name (abfd
, name
)
4532 bfd
*abfd ATTRIBUTE_UNUSED
;
4535 return (name
[0] == 'L' && name
[1] == '$');
4538 /* Count or process variable-length SOM fixup records.
4540 To avoid code duplication we use this code both to compute the number
4541 of relocations requested by a stream, and to internalize the stream.
4543 When computing the number of relocations requested by a stream the
4544 variables rptr, section, and symbols have no meaning.
4546 Return the number of relocations requested by the fixup stream. When
4549 This needs at least two or three more passes to get it cleaned up. */
4552 som_set_reloc_info (fixup
, end
, internal_relocs
, section
, symbols
, just_count
)
4553 unsigned char *fixup
;
4555 arelent
*internal_relocs
;
4560 unsigned int op
, varname
, deallocate_contents
= 0;
4561 unsigned char *end_fixups
= &fixup
[end
];
4562 const struct fixup_format
*fp
;
4564 unsigned char *save_fixup
;
4565 int variables
[26], stack
[20], c
, v
, count
, prev_fixup
, *sp
, saved_unwind_bits
;
4567 arelent
*rptr
= internal_relocs
;
4568 unsigned int offset
= 0;
4570 #define var(c) variables[(c) - 'A']
4571 #define push(v) (*sp++ = (v))
4572 #define pop() (*--sp)
4573 #define emptystack() (sp == stack)
4575 som_initialize_reloc_queue (reloc_queue
);
4576 memset (variables
, 0, sizeof (variables
));
4577 memset (stack
, 0, sizeof (stack
));
4580 saved_unwind_bits
= 0;
4583 while (fixup
< end_fixups
)
4586 /* Save pointer to the start of this fixup. We'll use
4587 it later to determine if it is necessary to put this fixup
4591 /* Get the fixup code and its associated format. */
4593 fp
= &som_fixup_formats
[op
];
4595 /* Handle a request for a previous fixup. */
4596 if (*fp
->format
== 'P')
4598 /* Get pointer to the beginning of the prev fixup, move
4599 the repeated fixup to the head of the queue. */
4600 fixup
= reloc_queue
[fp
->D
].reloc
;
4601 som_reloc_queue_fix (reloc_queue
, fp
->D
);
4604 /* Get the fixup code and its associated format. */
4606 fp
= &som_fixup_formats
[op
];
4609 /* If this fixup will be passed to BFD, set some reasonable defaults. */
4611 && som_hppa_howto_table
[op
].type
!= R_NO_RELOCATION
4612 && som_hppa_howto_table
[op
].type
!= R_DATA_OVERRIDE
)
4614 rptr
->address
= offset
;
4615 rptr
->howto
= &som_hppa_howto_table
[op
];
4617 rptr
->sym_ptr_ptr
= bfd_abs_section_ptr
->symbol_ptr_ptr
;
4620 /* Set default input length to 0. Get the opcode class index
4624 var ('U') = saved_unwind_bits
;
4626 /* Get the opcode format. */
4629 /* Process the format string. Parsing happens in two phases,
4630 parse RHS, then assign to LHS. Repeat until no more
4631 characters in the format string. */
4634 /* The variable this pass is going to compute a value for. */
4637 /* Start processing RHS. Continue until a NULL or '=' is found. */
4642 /* If this is a variable, push it on the stack. */
4646 /* If this is a lower case letter, then it represents
4647 additional data from the fixup stream to be pushed onto
4649 else if (islower (c
))
4651 int bits
= (c
- 'a') * 8;
4652 for (v
= 0; c
> 'a'; --c
)
4653 v
= (v
<< 8) | *fixup
++;
4655 v
= sign_extend (v
, bits
);
4659 /* A decimal constant. Push it on the stack. */
4660 else if (isdigit (c
))
4663 while (isdigit (*cp
))
4664 v
= (v
* 10) + (*cp
++ - '0');
4668 /* An operator. Pop two two values from the stack and
4669 use them as operands to the given operation. Push
4670 the result of the operation back on the stack. */
4692 while (*cp
&& *cp
!= '=');
4694 /* Move over the equal operator. */
4697 /* Pop the RHS off the stack. */
4700 /* Perform the assignment. */
4703 /* Handle side effects. and special 'O' stack cases. */
4706 /* Consume some bytes from the input space. */
4710 /* A symbol to use in the relocation. Make a note
4711 of this if we are not just counting. */
4714 rptr
->sym_ptr_ptr
= &symbols
[c
];
4716 /* Argument relocation bits for a function call. */
4720 unsigned int tmp
= var ('R');
4723 if ((som_hppa_howto_table
[op
].type
== R_PCREL_CALL
4724 && R_PCREL_CALL
+ 10 > op
)
4725 || (som_hppa_howto_table
[op
].type
== R_ABS_CALL
4726 && R_ABS_CALL
+ 10 > op
))
4728 /* Simple encoding. */
4735 rptr
->addend
|= 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2;
4737 rptr
->addend
|= 1 << 8 | 1 << 6 | 1 << 4;
4739 rptr
->addend
|= 1 << 8 | 1 << 6;
4741 rptr
->addend
|= 1 << 8;
4745 unsigned int tmp1
, tmp2
;
4747 /* First part is easy -- low order two bits are
4748 directly copied, then shifted away. */
4749 rptr
->addend
= tmp
& 0x3;
4752 /* Diving the result by 10 gives us the second
4753 part. If it is 9, then the first two words
4754 are a double precision paramater, else it is
4755 3 * the first arg bits + the 2nd arg bits. */
4759 rptr
->addend
+= (0xe << 6);
4762 /* Get the two pieces. */
4765 /* Put them in the addend. */
4766 rptr
->addend
+= (tmp2
<< 8) + (tmp1
<< 6);
4769 /* What's left is the third part. It's unpacked
4770 just like the second. */
4772 rptr
->addend
+= (0xe << 2);
4777 rptr
->addend
+= (tmp2
<< 4) + (tmp
<< 2);
4780 rptr
->addend
= HPPA_R_ADDEND (rptr
->addend
, 0);
4783 /* Handle the linker expression stack. */
4788 subop
= comp1_opcodes
;
4791 subop
= comp2_opcodes
;
4794 subop
= comp3_opcodes
;
4799 while (*subop
<= (unsigned char) c
)
4803 /* The lower 32unwind bits must be persistent. */
4805 saved_unwind_bits
= var ('U');
4813 /* If we used a previous fixup, clean up after it. */
4816 fixup
= save_fixup
+ 1;
4820 else if (fixup
> save_fixup
+ 1)
4821 som_reloc_queue_insert (save_fixup
, fixup
- save_fixup
, reloc_queue
);
4823 /* We do not pass R_DATA_OVERRIDE or R_NO_RELOCATION
4825 if (som_hppa_howto_table
[op
].type
!= R_DATA_OVERRIDE
4826 && som_hppa_howto_table
[op
].type
!= R_NO_RELOCATION
)
4828 /* Done with a single reloction. Loop back to the top. */
4831 if (som_hppa_howto_table
[op
].type
== R_ENTRY
)
4832 rptr
->addend
= var ('T');
4833 else if (som_hppa_howto_table
[op
].type
== R_EXIT
)
4834 rptr
->addend
= var ('U');
4835 else if (som_hppa_howto_table
[op
].type
== R_PCREL_CALL
4836 || som_hppa_howto_table
[op
].type
== R_ABS_CALL
)
4838 else if (som_hppa_howto_table
[op
].type
== R_DATA_ONE_SYMBOL
)
4840 /* Try what was specified in R_DATA_OVERRIDE first
4841 (if anything). Then the hard way using the
4842 section contents. */
4843 rptr
->addend
= var ('V');
4845 if (rptr
->addend
== 0 && !section
->contents
)
4847 /* Got to read the damn contents first. We don't
4848 bother saving the contents (yet). Add it one
4849 day if the need arises. */
4850 section
->contents
= bfd_malloc (section
->_raw_size
);
4851 if (section
->contents
== NULL
)
4854 deallocate_contents
= 1;
4855 bfd_get_section_contents (section
->owner
,
4859 section
->_raw_size
);
4861 else if (rptr
->addend
== 0)
4862 rptr
->addend
= bfd_get_32 (section
->owner
,
4864 + offset
- var ('L')));
4868 rptr
->addend
= var ('V');
4872 /* Now that we've handled a "full" relocation, reset
4874 memset (variables
, 0, sizeof (variables
));
4875 memset (stack
, 0, sizeof (stack
));
4878 if (deallocate_contents
)
4879 free (section
->contents
);
4889 /* Read in the relocs (aka fixups in SOM terms) for a section.
4891 som_get_reloc_upper_bound calls this routine with JUST_COUNT
4892 set to true to indicate it only needs a count of the number
4893 of actual relocations. */
4896 som_slurp_reloc_table (abfd
, section
, symbols
, just_count
)
4902 char *external_relocs
;
4903 unsigned int fixup_stream_size
;
4904 arelent
*internal_relocs
;
4905 unsigned int num_relocs
;
4907 fixup_stream_size
= som_section_data (section
)->reloc_size
;
4908 /* If there were no relocations, then there is nothing to do. */
4909 if (section
->reloc_count
== 0)
4912 /* If reloc_count is -1, then the relocation stream has not been
4913 parsed. We must do so now to know how many relocations exist. */
4914 if (section
->reloc_count
== -1)
4916 external_relocs
= (char *) bfd_malloc (fixup_stream_size
);
4917 if (external_relocs
== (char *) NULL
)
4919 /* Read in the external forms. */
4921 obj_som_reloc_filepos (abfd
) + section
->rel_filepos
,
4925 if (bfd_read (external_relocs
, 1, fixup_stream_size
, abfd
)
4926 != fixup_stream_size
)
4929 /* Let callers know how many relocations found.
4930 also save the relocation stream as we will
4932 section
->reloc_count
= som_set_reloc_info (external_relocs
,
4934 NULL
, NULL
, NULL
, true);
4936 som_section_data (section
)->reloc_stream
= external_relocs
;
4939 /* If the caller only wanted a count, then return now. */
4943 num_relocs
= section
->reloc_count
;
4944 external_relocs
= som_section_data (section
)->reloc_stream
;
4945 /* Return saved information about the relocations if it is available. */
4946 if (section
->relocation
!= (arelent
*) NULL
)
4949 internal_relocs
= (arelent
*)
4950 bfd_zalloc (abfd
, (num_relocs
* sizeof (arelent
)));
4951 if (internal_relocs
== (arelent
*) NULL
)
4954 /* Process and internalize the relocations. */
4955 som_set_reloc_info (external_relocs
, fixup_stream_size
,
4956 internal_relocs
, section
, symbols
, false);
4958 /* We're done with the external relocations. Free them. */
4959 free (external_relocs
);
4960 som_section_data (section
)->reloc_stream
= NULL
;
4962 /* Save our results and return success. */
4963 section
->relocation
= internal_relocs
;
4967 /* Return the number of bytes required to store the relocation
4968 information associated with the given section. */
4971 som_get_reloc_upper_bound (abfd
, asect
)
4975 /* If section has relocations, then read in the relocation stream
4976 and parse it to determine how many relocations exist. */
4977 if (asect
->flags
& SEC_RELOC
)
4979 if (! som_slurp_reloc_table (abfd
, asect
, NULL
, true))
4981 return (asect
->reloc_count
+ 1) * sizeof (arelent
*);
4983 /* There are no relocations. */
4987 /* Convert relocations from SOM (external) form into BFD internal
4988 form. Return the number of relocations. */
4991 som_canonicalize_reloc (abfd
, section
, relptr
, symbols
)
5000 if (som_slurp_reloc_table (abfd
, section
, symbols
, false) == false)
5003 count
= section
->reloc_count
;
5004 tblptr
= section
->relocation
;
5007 *relptr
++ = tblptr
++;
5009 *relptr
= (arelent
*) NULL
;
5010 return section
->reloc_count
;
5013 extern const bfd_target som_vec
;
5015 /* A hook to set up object file dependent section information. */
5018 som_new_section_hook (abfd
, newsect
)
5022 newsect
->used_by_bfd
=
5023 (PTR
) bfd_zalloc (abfd
, sizeof (struct som_section_data_struct
));
5024 if (!newsect
->used_by_bfd
)
5026 newsect
->alignment_power
= 3;
5028 /* We allow more than three sections internally. */
5032 /* Copy any private info we understand from the input symbol
5033 to the output symbol. */
5036 som_bfd_copy_private_symbol_data (ibfd
, isymbol
, obfd
, osymbol
)
5042 struct som_symbol
*input_symbol
= (struct som_symbol
*) isymbol
;
5043 struct som_symbol
*output_symbol
= (struct som_symbol
*) osymbol
;
5045 /* One day we may try to grok other private data. */
5046 if (ibfd
->xvec
->flavour
!= bfd_target_som_flavour
5047 || obfd
->xvec
->flavour
!= bfd_target_som_flavour
)
5050 /* The only private information we need to copy is the argument relocation
5052 output_symbol
->tc_data
.ap
.hppa_arg_reloc
=
5053 input_symbol
->tc_data
.ap
.hppa_arg_reloc
;
5058 /* Copy any private info we understand from the input section
5059 to the output section. */
5062 som_bfd_copy_private_section_data (ibfd
, isection
, obfd
, osection
)
5068 /* One day we may try to grok other private data. */
5069 if (ibfd
->xvec
->flavour
!= bfd_target_som_flavour
5070 || obfd
->xvec
->flavour
!= bfd_target_som_flavour
5071 || (!som_is_space (isection
) && !som_is_subspace (isection
)))
5074 som_section_data (osection
)->copy_data
=
5075 (struct som_copyable_section_data_struct
*)
5076 bfd_zalloc (obfd
, sizeof (struct som_copyable_section_data_struct
));
5077 if (som_section_data (osection
)->copy_data
== NULL
)
5080 memcpy (som_section_data (osection
)->copy_data
,
5081 som_section_data (isection
)->copy_data
,
5082 sizeof (struct som_copyable_section_data_struct
));
5084 /* Reparent if necessary. */
5085 if (som_section_data (osection
)->copy_data
->container
)
5086 som_section_data (osection
)->copy_data
->container
=
5087 som_section_data (osection
)->copy_data
->container
->output_section
;
5092 /* Copy any private info we understand from the input bfd
5093 to the output bfd. */
5096 som_bfd_copy_private_bfd_data (ibfd
, obfd
)
5099 /* One day we may try to grok other private data. */
5100 if (ibfd
->xvec
->flavour
!= bfd_target_som_flavour
5101 || obfd
->xvec
->flavour
!= bfd_target_som_flavour
)
5104 /* Allocate some memory to hold the data we need. */
5105 obj_som_exec_data (obfd
) = (struct som_exec_data
*)
5106 bfd_zalloc (obfd
, sizeof (struct som_exec_data
));
5107 if (obj_som_exec_data (obfd
) == NULL
)
5110 /* Now copy the data. */
5111 memcpy (obj_som_exec_data (obfd
), obj_som_exec_data (ibfd
),
5112 sizeof (struct som_exec_data
));
5117 /* Set backend info for sections which can not be described
5118 in the BFD data structures. */
5121 bfd_som_set_section_attributes (section
, defined
, private, sort_key
, spnum
)
5125 unsigned int sort_key
;
5128 /* Allocate memory to hold the magic information. */
5129 if (som_section_data (section
)->copy_data
== NULL
)
5131 som_section_data (section
)->copy_data
=
5132 (struct som_copyable_section_data_struct
*)
5133 bfd_zalloc (section
->owner
,
5134 sizeof (struct som_copyable_section_data_struct
));
5135 if (som_section_data (section
)->copy_data
== NULL
)
5138 som_section_data (section
)->copy_data
->sort_key
= sort_key
;
5139 som_section_data (section
)->copy_data
->is_defined
= defined
;
5140 som_section_data (section
)->copy_data
->is_private
= private;
5141 som_section_data (section
)->copy_data
->container
= section
;
5142 som_section_data (section
)->copy_data
->space_number
= spnum
;
5146 /* Set backend info for subsections which can not be described
5147 in the BFD data structures. */
5150 bfd_som_set_subsection_attributes (section
, container
, access
,
5153 asection
*container
;
5155 unsigned int sort_key
;
5158 /* Allocate memory to hold the magic information. */
5159 if (som_section_data (section
)->copy_data
== NULL
)
5161 som_section_data (section
)->copy_data
=
5162 (struct som_copyable_section_data_struct
*)
5163 bfd_zalloc (section
->owner
,
5164 sizeof (struct som_copyable_section_data_struct
));
5165 if (som_section_data (section
)->copy_data
== NULL
)
5168 som_section_data (section
)->copy_data
->sort_key
= sort_key
;
5169 som_section_data (section
)->copy_data
->access_control_bits
= access
;
5170 som_section_data (section
)->copy_data
->quadrant
= quadrant
;
5171 som_section_data (section
)->copy_data
->container
= container
;
5175 /* Set the full SOM symbol type. SOM needs far more symbol information
5176 than any other object file format I'm aware of. It is mandatory
5177 to be able to know if a symbol is an entry point, millicode, data,
5178 code, absolute, storage request, or procedure label. If you get
5179 the symbol type wrong your program will not link. */
5182 bfd_som_set_symbol_type (symbol
, type
)
5186 som_symbol_data (symbol
)->som_type
= type
;
5189 /* Attach an auxiliary header to the BFD backend so that it may be
5190 written into the object file. */
5193 bfd_som_attach_aux_hdr (abfd
, type
, string
)
5198 if (type
== VERSION_AUX_ID
)
5200 int len
= strlen (string
);
5204 pad
= (4 - (len
% 4));
5205 obj_som_version_hdr (abfd
) = (struct user_string_aux_hdr
*)
5206 bfd_zalloc (abfd
, sizeof (struct aux_id
)
5207 + sizeof (unsigned int) + len
+ pad
);
5208 if (!obj_som_version_hdr (abfd
))
5210 obj_som_version_hdr (abfd
)->header_id
.type
= VERSION_AUX_ID
;
5211 obj_som_version_hdr (abfd
)->header_id
.length
= len
+ pad
;
5212 obj_som_version_hdr (abfd
)->header_id
.length
+= sizeof (int);
5213 obj_som_version_hdr (abfd
)->string_length
= len
;
5214 strncpy (obj_som_version_hdr (abfd
)->user_string
, string
, len
);
5216 else if (type
== COPYRIGHT_AUX_ID
)
5218 int len
= strlen (string
);
5222 pad
= (4 - (len
% 4));
5223 obj_som_copyright_hdr (abfd
) = (struct copyright_aux_hdr
*)
5224 bfd_zalloc (abfd
, sizeof (struct aux_id
)
5225 + sizeof (unsigned int) + len
+ pad
);
5226 if (!obj_som_copyright_hdr (abfd
))
5228 obj_som_copyright_hdr (abfd
)->header_id
.type
= COPYRIGHT_AUX_ID
;
5229 obj_som_copyright_hdr (abfd
)->header_id
.length
= len
+ pad
;
5230 obj_som_copyright_hdr (abfd
)->header_id
.length
+= sizeof (int);
5231 obj_som_copyright_hdr (abfd
)->string_length
= len
;
5232 strcpy (obj_som_copyright_hdr (abfd
)->copyright
, string
);
5237 /* Attach an compilation unit header to the BFD backend so that it may be
5238 written into the object file. */
5241 bfd_som_attach_compilation_unit (abfd
, name
, language_name
, product_id
,
5245 const char *language_name
;
5246 const char *product_id
;
5247 const char *version_id
;
5249 COMPUNIT
*n
= (COMPUNIT
*) bfd_zalloc (abfd
, COMPUNITSZ
);
5256 n->f.n_name = bfd_alloc (abfd, strlen (f) + 1); \
5257 if (n->f.n_name == NULL) \
5259 strcpy (n->f.n_name, f); \
5263 STRDUP (language_name
);
5264 STRDUP (product_id
);
5265 STRDUP (version_id
);
5269 obj_som_compilation_unit (abfd
) = n
;
5275 som_get_section_contents (abfd
, section
, location
, offset
, count
)
5280 bfd_size_type count
;
5282 if (count
== 0 || ((section
->flags
& SEC_HAS_CONTENTS
) == 0))
5284 if ((bfd_size_type
) (offset
+count
) > section
->_raw_size
5285 || bfd_seek (abfd
, (file_ptr
) (section
->filepos
+ offset
), SEEK_SET
) == -1
5286 || bfd_read (location
, (bfd_size_type
) 1, count
, abfd
) != count
)
5287 return (false); /* on error */
5292 som_set_section_contents (abfd
, section
, location
, offset
, count
)
5297 bfd_size_type count
;
5299 if (abfd
->output_has_begun
== false)
5301 /* Set up fixed parts of the file, space, and subspace headers.
5302 Notify the world that output has begun. */
5303 som_prep_headers (abfd
);
5304 abfd
->output_has_begun
= true;
5305 /* Start writing the object file. This include all the string
5306 tables, fixup streams, and other portions of the object file. */
5307 som_begin_writing (abfd
);
5310 /* Only write subspaces which have "real" contents (eg. the contents
5311 are not generated at run time by the OS). */
5312 if (!som_is_subspace (section
)
5313 || ((section
->flags
& SEC_HAS_CONTENTS
) == 0))
5316 /* Seek to the proper offset within the object file and write the
5318 offset
+= som_section_data (section
)->subspace_dict
->file_loc_init_value
;
5319 if (bfd_seek (abfd
, offset
, SEEK_SET
) == -1)
5322 if (bfd_write ((PTR
) location
, 1, count
, abfd
) != count
)
5328 som_set_arch_mach (abfd
, arch
, machine
)
5330 enum bfd_architecture arch
;
5331 unsigned long machine
;
5333 /* Allow any architecture to be supported by the SOM backend. */
5334 return bfd_default_set_arch_mach (abfd
, arch
, machine
);
5338 som_find_nearest_line (abfd
, section
, symbols
, offset
, filename_ptr
,
5339 functionname_ptr
, line_ptr
)
5340 bfd
*abfd ATTRIBUTE_UNUSED
;
5341 asection
*section ATTRIBUTE_UNUSED
;
5342 asymbol
**symbols ATTRIBUTE_UNUSED
;
5343 bfd_vma offset ATTRIBUTE_UNUSED
;
5344 CONST
char **filename_ptr ATTRIBUTE_UNUSED
;
5345 CONST
char **functionname_ptr ATTRIBUTE_UNUSED
;
5346 unsigned int *line_ptr ATTRIBUTE_UNUSED
;
5352 som_sizeof_headers (abfd
, reloc
)
5353 bfd
*abfd ATTRIBUTE_UNUSED
;
5354 boolean reloc ATTRIBUTE_UNUSED
;
5356 (*_bfd_error_handler
) (_("som_sizeof_headers unimplemented"));
5362 /* Return the single-character symbol type corresponding to
5363 SOM section S, or '?' for an unknown SOM section. */
5366 som_section_type (s
)
5369 const struct section_to_type
*t
;
5371 for (t
= &stt
[0]; t
->section
; t
++)
5372 if (!strcmp (s
, t
->section
))
5378 som_decode_symclass (symbol
)
5383 if (bfd_is_com_section (symbol
->section
))
5385 if (bfd_is_und_section (symbol
->section
))
5387 if (bfd_is_ind_section (symbol
->section
))
5389 if (symbol
->flags
& BSF_WEAK
)
5391 if (!(symbol
->flags
& (BSF_GLOBAL
| BSF_LOCAL
)))
5394 if (bfd_is_abs_section (symbol
->section
)
5395 || (som_symbol_data (symbol
) != NULL
5396 && som_symbol_data (symbol
)->som_type
== SYMBOL_TYPE_ABSOLUTE
))
5398 else if (symbol
->section
)
5399 c
= som_section_type (symbol
->section
->name
);
5402 if (symbol
->flags
& BSF_GLOBAL
)
5407 /* Return information about SOM symbol SYMBOL in RET. */
5410 som_get_symbol_info (ignore_abfd
, symbol
, ret
)
5411 bfd
*ignore_abfd ATTRIBUTE_UNUSED
;
5415 ret
->type
= som_decode_symclass (symbol
);
5416 if (ret
->type
!= 'U')
5417 ret
->value
= symbol
->value
+ symbol
->section
->vma
;
5420 ret
->name
= symbol
->name
;
5423 /* Count the number of symbols in the archive symbol table. Necessary
5424 so that we can allocate space for all the carsyms at once. */
5427 som_bfd_count_ar_symbols (abfd
, lst_header
, count
)
5429 struct lst_header
*lst_header
;
5433 unsigned int *hash_table
= NULL
;
5434 file_ptr lst_filepos
= bfd_tell (abfd
) - sizeof (struct lst_header
);
5437 (unsigned int *) bfd_malloc (lst_header
->hash_size
5438 * sizeof (unsigned int));
5439 if (hash_table
== NULL
&& lst_header
->hash_size
!= 0)
5442 /* Don't forget to initialize the counter! */
5445 /* Read in the hash table. The has table is an array of 32bit file offsets
5446 which point to the hash chains. */
5447 if (bfd_read ((PTR
) hash_table
, lst_header
->hash_size
, 4, abfd
)
5448 != lst_header
->hash_size
* 4)
5451 /* Walk each chain counting the number of symbols found on that particular
5453 for (i
= 0; i
< lst_header
->hash_size
; i
++)
5455 struct lst_symbol_record lst_symbol
;
5457 /* An empty chain has zero as it's file offset. */
5458 if (hash_table
[i
] == 0)
5461 /* Seek to the first symbol in this hash chain. */
5462 if (bfd_seek (abfd
, lst_filepos
+ hash_table
[i
], SEEK_SET
) < 0)
5465 /* Read in this symbol and update the counter. */
5466 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
5467 != sizeof (lst_symbol
))
5472 /* Now iterate through the rest of the symbols on this chain. */
5473 while (lst_symbol
.next_entry
)
5476 /* Seek to the next symbol. */
5477 if (bfd_seek (abfd
, lst_filepos
+ lst_symbol
.next_entry
, SEEK_SET
)
5481 /* Read the symbol in and update the counter. */
5482 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
5483 != sizeof (lst_symbol
))
5489 if (hash_table
!= NULL
)
5494 if (hash_table
!= NULL
)
5499 /* Fill in the canonical archive symbols (SYMS) from the archive described
5500 by ABFD and LST_HEADER. */
5503 som_bfd_fill_in_ar_symbols (abfd
, lst_header
, syms
)
5505 struct lst_header
*lst_header
;
5508 unsigned int i
, len
;
5509 carsym
*set
= syms
[0];
5510 unsigned int *hash_table
= NULL
;
5511 struct som_entry
*som_dict
= NULL
;
5512 file_ptr lst_filepos
= bfd_tell (abfd
) - sizeof (struct lst_header
);
5515 (unsigned int *) bfd_malloc (lst_header
->hash_size
5516 * sizeof (unsigned int));
5517 if (hash_table
== NULL
&& lst_header
->hash_size
!= 0)
5521 (struct som_entry
*) bfd_malloc (lst_header
->module_count
5522 * sizeof (struct som_entry
));
5523 if (som_dict
== NULL
&& lst_header
->module_count
!= 0)
5526 /* Read in the hash table. The has table is an array of 32bit file offsets
5527 which point to the hash chains. */
5528 if (bfd_read ((PTR
) hash_table
, lst_header
->hash_size
, 4, abfd
)
5529 != lst_header
->hash_size
* 4)
5532 /* Seek to and read in the SOM dictionary. We will need this to fill
5533 in the carsym's filepos field. */
5534 if (bfd_seek (abfd
, lst_filepos
+ lst_header
->dir_loc
, SEEK_SET
) < 0)
5537 if (bfd_read ((PTR
) som_dict
, lst_header
->module_count
,
5538 sizeof (struct som_entry
), abfd
)
5539 != lst_header
->module_count
* sizeof (struct som_entry
))
5542 /* Walk each chain filling in the carsyms as we go along. */
5543 for (i
= 0; i
< lst_header
->hash_size
; i
++)
5545 struct lst_symbol_record lst_symbol
;
5547 /* An empty chain has zero as it's file offset. */
5548 if (hash_table
[i
] == 0)
5551 /* Seek to and read the first symbol on the chain. */
5552 if (bfd_seek (abfd
, lst_filepos
+ hash_table
[i
], SEEK_SET
) < 0)
5555 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
5556 != sizeof (lst_symbol
))
5559 /* Get the name of the symbol, first get the length which is stored
5560 as a 32bit integer just before the symbol.
5562 One might ask why we don't just read in the entire string table
5563 and index into it. Well, according to the SOM ABI the string
5564 index can point *anywhere* in the archive to save space, so just
5565 using the string table would not be safe. */
5566 if (bfd_seek (abfd
, lst_filepos
+ lst_header
->string_loc
5567 + lst_symbol
.name
.n_strx
- 4, SEEK_SET
) < 0)
5570 if (bfd_read (&len
, 1, 4, abfd
) != 4)
5573 /* Allocate space for the name and null terminate it too. */
5574 set
->name
= bfd_zalloc (abfd
, len
+ 1);
5577 if (bfd_read (set
->name
, 1, len
, abfd
) != len
)
5582 /* Fill in the file offset. Note that the "location" field points
5583 to the SOM itself, not the ar_hdr in front of it. */
5584 set
->file_offset
= som_dict
[lst_symbol
.som_index
].location
5585 - sizeof (struct ar_hdr
);
5587 /* Go to the next symbol. */
5590 /* Iterate through the rest of the chain. */
5591 while (lst_symbol
.next_entry
)
5593 /* Seek to the next symbol and read it in. */
5594 if (bfd_seek (abfd
, lst_filepos
+ lst_symbol
.next_entry
, SEEK_SET
) <0)
5597 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
5598 != sizeof (lst_symbol
))
5601 /* Seek to the name length & string and read them in. */
5602 if (bfd_seek (abfd
, lst_filepos
+ lst_header
->string_loc
5603 + lst_symbol
.name
.n_strx
- 4, SEEK_SET
) < 0)
5606 if (bfd_read (&len
, 1, 4, abfd
) != 4)
5609 /* Allocate space for the name and null terminate it too. */
5610 set
->name
= bfd_zalloc (abfd
, len
+ 1);
5614 if (bfd_read (set
->name
, 1, len
, abfd
) != len
)
5618 /* Fill in the file offset. Note that the "location" field points
5619 to the SOM itself, not the ar_hdr in front of it. */
5620 set
->file_offset
= som_dict
[lst_symbol
.som_index
].location
5621 - sizeof (struct ar_hdr
);
5623 /* Go on to the next symbol. */
5627 /* If we haven't died by now, then we successfully read the entire
5628 archive symbol table. */
5629 if (hash_table
!= NULL
)
5631 if (som_dict
!= NULL
)
5636 if (hash_table
!= NULL
)
5638 if (som_dict
!= NULL
)
5643 /* Read in the LST from the archive. */
5646 som_slurp_armap (abfd
)
5649 struct lst_header lst_header
;
5650 struct ar_hdr ar_header
;
5651 unsigned int parsed_size
;
5652 struct artdata
*ardata
= bfd_ardata (abfd
);
5654 int i
= bfd_read ((PTR
) nextname
, 1, 16, abfd
);
5656 /* Special cases. */
5662 if (bfd_seek (abfd
, (file_ptr
) - 16, SEEK_CUR
) < 0)
5665 /* For archives without .o files there is no symbol table. */
5666 if (strncmp (nextname
, "/ ", 16))
5668 bfd_has_map (abfd
) = false;
5672 /* Read in and sanity check the archive header. */
5673 if (bfd_read ((PTR
) &ar_header
, 1, sizeof (struct ar_hdr
), abfd
)
5674 != sizeof (struct ar_hdr
))
5677 if (strncmp (ar_header
.ar_fmag
, ARFMAG
, 2))
5679 bfd_set_error (bfd_error_malformed_archive
);
5683 /* How big is the archive symbol table entry? */
5685 parsed_size
= strtol (ar_header
.ar_size
, NULL
, 10);
5688 bfd_set_error (bfd_error_malformed_archive
);
5692 /* Save off the file offset of the first real user data. */
5693 ardata
->first_file_filepos
= bfd_tell (abfd
) + parsed_size
;
5695 /* Read in the library symbol table. We'll make heavy use of this
5696 in just a minute. */
5697 if (bfd_read ((PTR
) & lst_header
, 1, sizeof (struct lst_header
), abfd
)
5698 != sizeof (struct lst_header
))
5702 if (lst_header
.a_magic
!= LIBMAGIC
)
5704 bfd_set_error (bfd_error_malformed_archive
);
5708 /* Count the number of symbols in the library symbol table. */
5709 if (som_bfd_count_ar_symbols (abfd
, &lst_header
, &ardata
->symdef_count
)
5713 /* Get back to the start of the library symbol table. */
5714 if (bfd_seek (abfd
, ardata
->first_file_filepos
- parsed_size
5715 + sizeof (struct lst_header
), SEEK_SET
) < 0)
5718 /* Initializae the cache and allocate space for the library symbols. */
5720 ardata
->symdefs
= (carsym
*) bfd_alloc (abfd
,
5721 (ardata
->symdef_count
5722 * sizeof (carsym
)));
5723 if (!ardata
->symdefs
)
5726 /* Now fill in the canonical archive symbols. */
5727 if (som_bfd_fill_in_ar_symbols (abfd
, &lst_header
, &ardata
->symdefs
)
5731 /* Seek back to the "first" file in the archive. Note the "first"
5732 file may be the extended name table. */
5733 if (bfd_seek (abfd
, ardata
->first_file_filepos
, SEEK_SET
) < 0)
5736 /* Notify the generic archive code that we have a symbol map. */
5737 bfd_has_map (abfd
) = true;
5741 /* Begin preparing to write a SOM library symbol table.
5743 As part of the prep work we need to determine the number of symbols
5744 and the size of the associated string section. */
5747 som_bfd_prep_for_ar_write (abfd
, num_syms
, stringsize
)
5749 unsigned int *num_syms
, *stringsize
;
5751 bfd
*curr_bfd
= abfd
->archive_head
;
5753 /* Some initialization. */
5757 /* Iterate over each BFD within this archive. */
5758 while (curr_bfd
!= NULL
)
5760 unsigned int curr_count
, i
;
5761 som_symbol_type
*sym
;
5763 /* Don't bother for non-SOM objects. */
5764 if (curr_bfd
->format
!= bfd_object
5765 || curr_bfd
->xvec
->flavour
!= bfd_target_som_flavour
)
5767 curr_bfd
= curr_bfd
->next
;
5771 /* Make sure the symbol table has been read, then snag a pointer
5772 to it. It's a little slimey to grab the symbols via obj_som_symtab,
5773 but doing so avoids allocating lots of extra memory. */
5774 if (som_slurp_symbol_table (curr_bfd
) == false)
5777 sym
= obj_som_symtab (curr_bfd
);
5778 curr_count
= bfd_get_symcount (curr_bfd
);
5780 /* Examine each symbol to determine if it belongs in the
5781 library symbol table. */
5782 for (i
= 0; i
< curr_count
; i
++, sym
++)
5784 struct som_misc_symbol_info info
;
5786 /* Derive SOM information from the BFD symbol. */
5787 som_bfd_derive_misc_symbol_info (curr_bfd
, &sym
->symbol
, &info
);
5789 /* Should we include this symbol? */
5790 if (info
.symbol_type
== ST_NULL
5791 || info
.symbol_type
== ST_SYM_EXT
5792 || info
.symbol_type
== ST_ARG_EXT
)
5795 /* Only global symbols and unsatisfied commons. */
5796 if (info
.symbol_scope
!= SS_UNIVERSAL
5797 && info
.symbol_type
!= ST_STORAGE
)
5800 /* Do no include undefined symbols. */
5801 if (bfd_is_und_section (sym
->symbol
.section
))
5804 /* Bump the various counters, being careful to honor
5805 alignment considerations in the string table. */
5807 *stringsize
= *stringsize
+ strlen (sym
->symbol
.name
) + 5;
5808 while (*stringsize
% 4)
5812 curr_bfd
= curr_bfd
->next
;
5817 /* Hash a symbol name based on the hashing algorithm presented in the
5821 som_bfd_ar_symbol_hash (symbol
)
5824 unsigned int len
= strlen (symbol
->name
);
5826 /* Names with length 1 are special. */
5828 return 0x1000100 | (symbol
->name
[0] << 16) | symbol
->name
[0];
5830 return ((len
& 0x7f) << 24) | (symbol
->name
[1] << 16)
5831 | (symbol
->name
[len
- 2] << 8) | symbol
->name
[len
- 1];
5834 /* Do the bulk of the work required to write the SOM library
5838 som_bfd_ar_write_symbol_stuff (abfd
, nsyms
, string_size
, lst
, elength
)
5840 unsigned int nsyms
, string_size
;
5841 struct lst_header lst
;
5844 file_ptr lst_filepos
;
5845 char *strings
= NULL
, *p
;
5846 struct lst_symbol_record
*lst_syms
= NULL
, *curr_lst_sym
;
5848 unsigned int *hash_table
= NULL
;
5849 struct som_entry
*som_dict
= NULL
;
5850 struct lst_symbol_record
**last_hash_entry
= NULL
;
5851 unsigned int curr_som_offset
, som_index
= 0;
5854 (unsigned int *) bfd_malloc (lst
.hash_size
* sizeof (unsigned int));
5855 if (hash_table
== NULL
&& lst
.hash_size
!= 0)
5858 (struct som_entry
*) bfd_malloc (lst
.module_count
5859 * sizeof (struct som_entry
));
5860 if (som_dict
== NULL
&& lst
.module_count
!= 0)
5864 ((struct lst_symbol_record
**)
5865 bfd_malloc (lst
.hash_size
* sizeof (struct lst_symbol_record
*)));
5866 if (last_hash_entry
== NULL
&& lst
.hash_size
!= 0)
5869 /* Lots of fields are file positions relative to the start
5870 of the lst record. So save its location. */
5871 lst_filepos
= bfd_tell (abfd
) - sizeof (struct lst_header
);
5873 /* Some initialization. */
5874 memset (hash_table
, 0, 4 * lst
.hash_size
);
5875 memset (som_dict
, 0, lst
.module_count
* sizeof (struct som_entry
));
5876 memset (last_hash_entry
, 0,
5877 lst
.hash_size
* sizeof (struct lst_symbol_record
*));
5879 /* Symbols have som_index fields, so we have to keep track of the
5880 index of each SOM in the archive.
5882 The SOM dictionary has (among other things) the absolute file
5883 position for the SOM which a particular dictionary entry
5884 describes. We have to compute that information as we iterate
5885 through the SOMs/symbols. */
5888 /* We add in the size of the archive header twice as the location
5889 in the SOM dictionary is the actual offset of the SOM, not the
5890 archive header before the SOM. */
5891 curr_som_offset
= 8 + 2 * sizeof (struct ar_hdr
) + lst
.file_end
;
5893 /* Make room for the archive header and the contents of the
5894 extended string table. Note that elength includes the size
5895 of the archive header for the extended name table! */
5897 curr_som_offset
+= elength
;
5899 /* Make sure we're properly aligned. */
5900 curr_som_offset
= (curr_som_offset
+ 0x1) & ~0x1;
5902 /* FIXME should be done with buffers just like everything else... */
5903 lst_syms
= bfd_malloc (nsyms
* sizeof (struct lst_symbol_record
));
5904 if (lst_syms
== NULL
&& nsyms
!= 0)
5906 strings
= bfd_malloc (string_size
);
5907 if (strings
== NULL
&& string_size
!= 0)
5911 curr_lst_sym
= lst_syms
;
5913 curr_bfd
= abfd
->archive_head
;
5914 while (curr_bfd
!= NULL
)
5916 unsigned int curr_count
, i
;
5917 som_symbol_type
*sym
;
5919 /* Don't bother for non-SOM objects. */
5920 if (curr_bfd
->format
!= bfd_object
5921 || curr_bfd
->xvec
->flavour
!= bfd_target_som_flavour
)
5923 curr_bfd
= curr_bfd
->next
;
5927 /* Make sure the symbol table has been read, then snag a pointer
5928 to it. It's a little slimey to grab the symbols via obj_som_symtab,
5929 but doing so avoids allocating lots of extra memory. */
5930 if (som_slurp_symbol_table (curr_bfd
) == false)
5933 sym
= obj_som_symtab (curr_bfd
);
5934 curr_count
= bfd_get_symcount (curr_bfd
);
5936 for (i
= 0; i
< curr_count
; i
++, sym
++)
5938 struct som_misc_symbol_info info
;
5940 /* Derive SOM information from the BFD symbol. */
5941 som_bfd_derive_misc_symbol_info (curr_bfd
, &sym
->symbol
, &info
);
5943 /* Should we include this symbol? */
5944 if (info
.symbol_type
== ST_NULL
5945 || info
.symbol_type
== ST_SYM_EXT
5946 || info
.symbol_type
== ST_ARG_EXT
)
5949 /* Only global symbols and unsatisfied commons. */
5950 if (info
.symbol_scope
!= SS_UNIVERSAL
5951 && info
.symbol_type
!= ST_STORAGE
)
5954 /* Do no include undefined symbols. */
5955 if (bfd_is_und_section (sym
->symbol
.section
))
5958 /* If this is the first symbol from this SOM, then update
5959 the SOM dictionary too. */
5960 if (som_dict
[som_index
].location
== 0)
5962 som_dict
[som_index
].location
= curr_som_offset
;
5963 som_dict
[som_index
].length
= arelt_size (curr_bfd
);
5966 /* Fill in the lst symbol record. */
5967 curr_lst_sym
->hidden
= 0;
5968 curr_lst_sym
->secondary_def
= info
.secondary_def
;
5969 curr_lst_sym
->symbol_type
= info
.symbol_type
;
5970 curr_lst_sym
->symbol_scope
= info
.symbol_scope
;
5971 curr_lst_sym
->check_level
= 0;
5972 curr_lst_sym
->must_qualify
= 0;
5973 curr_lst_sym
->initially_frozen
= 0;
5974 curr_lst_sym
->memory_resident
= 0;
5975 curr_lst_sym
->is_common
= bfd_is_com_section (sym
->symbol
.section
);
5976 curr_lst_sym
->dup_common
= 0;
5977 curr_lst_sym
->xleast
= 3;
5978 curr_lst_sym
->arg_reloc
= info
.arg_reloc
;
5979 curr_lst_sym
->name
.n_strx
= p
- strings
+ 4;
5980 curr_lst_sym
->qualifier_name
.n_strx
= 0;
5981 curr_lst_sym
->symbol_info
= info
.symbol_info
;
5982 curr_lst_sym
->symbol_value
= info
.symbol_value
| info
.priv_level
;
5983 curr_lst_sym
->symbol_descriptor
= 0;
5984 curr_lst_sym
->reserved
= 0;
5985 curr_lst_sym
->som_index
= som_index
;
5986 curr_lst_sym
->symbol_key
= som_bfd_ar_symbol_hash (&sym
->symbol
);
5987 curr_lst_sym
->next_entry
= 0;
5989 /* Insert into the hash table. */
5990 if (hash_table
[curr_lst_sym
->symbol_key
% lst
.hash_size
])
5992 struct lst_symbol_record
*tmp
;
5994 /* There is already something at the head of this hash chain,
5995 so tack this symbol onto the end of the chain. */
5996 tmp
= last_hash_entry
[curr_lst_sym
->symbol_key
% lst
.hash_size
];
5998 = (curr_lst_sym
- lst_syms
) * sizeof (struct lst_symbol_record
)
6000 + lst
.module_count
* sizeof (struct som_entry
)
6001 + sizeof (struct lst_header
);
6005 /* First entry in this hash chain. */
6006 hash_table
[curr_lst_sym
->symbol_key
% lst
.hash_size
]
6007 = (curr_lst_sym
- lst_syms
) * sizeof (struct lst_symbol_record
)
6009 + lst
.module_count
* sizeof (struct som_entry
)
6010 + sizeof (struct lst_header
);
6013 /* Keep track of the last symbol we added to this chain so we can
6014 easily update its next_entry pointer. */
6015 last_hash_entry
[curr_lst_sym
->symbol_key
% lst
.hash_size
]
6018 /* Update the string table. */
6019 bfd_put_32 (abfd
, strlen (sym
->symbol
.name
), p
);
6021 strcpy (p
, sym
->symbol
.name
);
6022 p
+= strlen (sym
->symbol
.name
) + 1;
6025 bfd_put_8 (abfd
, 0, p
);
6029 /* Head to the next symbol. */
6033 /* Keep track of where each SOM will finally reside; then look
6035 curr_som_offset
+= arelt_size (curr_bfd
) + sizeof (struct ar_hdr
);
6037 /* A particular object in the archive may have an odd length; the
6038 linker requires objects begin on an even boundary. So round
6039 up the current offset as necessary. */
6040 curr_som_offset
= (curr_som_offset
+ 0x1) & ~0x1;
6041 curr_bfd
= curr_bfd
->next
;
6045 /* Now scribble out the hash table. */
6046 if (bfd_write ((PTR
) hash_table
, lst
.hash_size
, 4, abfd
)
6047 != lst
.hash_size
* 4)
6050 /* Then the SOM dictionary. */
6051 if (bfd_write ((PTR
) som_dict
, lst
.module_count
,
6052 sizeof (struct som_entry
), abfd
)
6053 != lst
.module_count
* sizeof (struct som_entry
))
6056 /* The library symbols. */
6057 if (bfd_write ((PTR
) lst_syms
, nsyms
, sizeof (struct lst_symbol_record
), abfd
)
6058 != nsyms
* sizeof (struct lst_symbol_record
))
6061 /* And finally the strings. */
6062 if (bfd_write ((PTR
) strings
, string_size
, 1, abfd
) != string_size
)
6065 if (hash_table
!= NULL
)
6067 if (som_dict
!= NULL
)
6069 if (last_hash_entry
!= NULL
)
6070 free (last_hash_entry
);
6071 if (lst_syms
!= NULL
)
6073 if (strings
!= NULL
)
6078 if (hash_table
!= NULL
)
6080 if (som_dict
!= NULL
)
6082 if (last_hash_entry
!= NULL
)
6083 free (last_hash_entry
);
6084 if (lst_syms
!= NULL
)
6086 if (strings
!= NULL
)
6092 /* Write out the LST for the archive.
6094 You'll never believe this is really how armaps are handled in SOM... */
6097 som_write_armap (abfd
, elength
, map
, orl_count
, stridx
)
6099 unsigned int elength
;
6100 struct orl
*map ATTRIBUTE_UNUSED
;
6101 unsigned int orl_count ATTRIBUTE_UNUSED
;
6102 int stridx ATTRIBUTE_UNUSED
;
6105 struct stat statbuf
;
6106 unsigned int i
, lst_size
, nsyms
, stringsize
;
6108 struct lst_header lst
;
6111 /* We'll use this for the archive's date and mode later. */
6112 if (stat (abfd
->filename
, &statbuf
) != 0)
6114 bfd_set_error (bfd_error_system_call
);
6118 bfd_ardata (abfd
)->armap_timestamp
= statbuf
.st_mtime
+ 60;
6120 /* Account for the lst header first. */
6121 lst_size
= sizeof (struct lst_header
);
6123 /* Start building the LST header. */
6124 /* FIXME: Do we need to examine each element to determine the
6125 largest id number? */
6126 lst
.system_id
= CPU_PA_RISC1_0
;
6127 lst
.a_magic
= LIBMAGIC
;
6128 lst
.version_id
= VERSION_ID
;
6129 lst
.file_time
.secs
= 0;
6130 lst
.file_time
.nanosecs
= 0;
6132 lst
.hash_loc
= lst_size
;
6133 lst
.hash_size
= SOM_LST_HASH_SIZE
;
6135 /* Hash table is a SOM_LST_HASH_SIZE 32bit offsets. */
6136 lst_size
+= 4 * SOM_LST_HASH_SIZE
;
6138 /* We need to count the number of SOMs in this archive. */
6139 curr_bfd
= abfd
->archive_head
;
6140 lst
.module_count
= 0;
6141 while (curr_bfd
!= NULL
)
6143 /* Only true SOM objects count. */
6144 if (curr_bfd
->format
== bfd_object
6145 && curr_bfd
->xvec
->flavour
== bfd_target_som_flavour
)
6147 curr_bfd
= curr_bfd
->next
;
6149 lst
.module_limit
= lst
.module_count
;
6150 lst
.dir_loc
= lst_size
;
6151 lst_size
+= sizeof (struct som_entry
) * lst
.module_count
;
6153 /* We don't support import/export tables, auxiliary headers,
6154 or free lists yet. Make the linker work a little harder
6155 to make our life easier. */
6158 lst
.export_count
= 0;
6163 /* Count how many symbols we will have on the hash chains and the
6164 size of the associated string table. */
6165 if (som_bfd_prep_for_ar_write (abfd
, &nsyms
, &stringsize
) == false)
6168 lst_size
+= sizeof (struct lst_symbol_record
) * nsyms
;
6170 /* For the string table. One day we might actually use this info
6171 to avoid small seeks/reads when reading archives. */
6172 lst
.string_loc
= lst_size
;
6173 lst
.string_size
= stringsize
;
6174 lst_size
+= stringsize
;
6176 /* SOM ABI says this must be zero. */
6178 lst
.file_end
= lst_size
;
6180 /* Compute the checksum. Must happen after the entire lst header
6184 for (i
= 0; i
< sizeof (struct lst_header
) / sizeof (int) - 1; i
++)
6185 lst
.checksum
^= *p
++;
6187 sprintf (hdr
.ar_name
, "/ ");
6188 sprintf (hdr
.ar_date
, "%ld", bfd_ardata (abfd
)->armap_timestamp
);
6189 sprintf (hdr
.ar_uid
, "%ld", (long) getuid ());
6190 sprintf (hdr
.ar_gid
, "%ld", (long) getgid ());
6191 sprintf (hdr
.ar_mode
, "%-8o", (unsigned int) statbuf
.st_mode
);
6192 sprintf (hdr
.ar_size
, "%-10d", (int) lst_size
);
6193 hdr
.ar_fmag
[0] = '`';
6194 hdr
.ar_fmag
[1] = '\012';
6196 /* Turn any nulls into spaces. */
6197 for (i
= 0; i
< sizeof (struct ar_hdr
); i
++)
6198 if (((char *) (&hdr
))[i
] == '\0')
6199 (((char *) (&hdr
))[i
]) = ' ';
6201 /* Scribble out the ar header. */
6202 if (bfd_write ((PTR
) &hdr
, 1, sizeof (struct ar_hdr
), abfd
)
6203 != sizeof (struct ar_hdr
))
6206 /* Now scribble out the lst header. */
6207 if (bfd_write ((PTR
) &lst
, 1, sizeof (struct lst_header
), abfd
)
6208 != sizeof (struct lst_header
))
6211 /* Build and write the armap. */
6212 if (som_bfd_ar_write_symbol_stuff (abfd
, nsyms
, stringsize
, lst
, elength
)
6220 /* Free all information we have cached for this BFD. We can always
6221 read it again later if we need it. */
6224 som_bfd_free_cached_info (abfd
)
6229 if (bfd_get_format (abfd
) != bfd_object
)
6232 #define FREE(x) if (x != NULL) { free (x); x = NULL; }
6233 /* Free the native string and symbol tables. */
6234 FREE (obj_som_symtab (abfd
));
6235 FREE (obj_som_stringtab (abfd
));
6236 for (o
= abfd
->sections
; o
!= (asection
*) NULL
; o
= o
->next
)
6238 /* Free the native relocations. */
6239 o
->reloc_count
= -1;
6240 FREE (som_section_data (o
)->reloc_stream
);
6241 /* Free the generic relocations. */
6242 FREE (o
->relocation
);
6249 /* End of miscellaneous support functions. */
6251 /* Linker support functions. */
6254 som_bfd_link_split_section (abfd
, sec
)
6255 bfd
*abfd ATTRIBUTE_UNUSED
;
6258 return (som_is_subspace (sec
) && sec
->_raw_size
> 240000);
6261 #define som_close_and_cleanup som_bfd_free_cached_info
6263 #define som_read_ar_hdr _bfd_generic_read_ar_hdr
6264 #define som_openr_next_archived_file bfd_generic_openr_next_archived_file
6265 #define som_get_elt_at_index _bfd_generic_get_elt_at_index
6266 #define som_generic_stat_arch_elt bfd_generic_stat_arch_elt
6267 #define som_truncate_arname bfd_bsd_truncate_arname
6268 #define som_slurp_extended_name_table _bfd_slurp_extended_name_table
6269 #define som_construct_extended_name_table \
6270 _bfd_archive_coff_construct_extended_name_table
6271 #define som_update_armap_timestamp bfd_true
6272 #define som_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
6274 #define som_get_lineno _bfd_nosymbols_get_lineno
6275 #define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
6276 #define som_read_minisymbols _bfd_generic_read_minisymbols
6277 #define som_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
6278 #define som_get_section_contents_in_window \
6279 _bfd_generic_get_section_contents_in_window
6281 #define som_bfd_get_relocated_section_contents \
6282 bfd_generic_get_relocated_section_contents
6283 #define som_bfd_relax_section bfd_generic_relax_section
6284 #define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
6285 #define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
6286 #define som_bfd_final_link _bfd_generic_final_link
6288 #define som_bfd_gc_sections bfd_generic_gc_sections
6289 #define som_bfd_merge_sections bfd_generic_merge_sections
6291 const bfd_target som_vec
= {
6293 bfd_target_som_flavour
,
6294 BFD_ENDIAN_BIG
, /* target byte order */
6295 BFD_ENDIAN_BIG
, /* target headers byte order */
6296 (HAS_RELOC
| EXEC_P
| /* object flags */
6297 HAS_LINENO
| HAS_DEBUG
|
6298 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
| DYNAMIC
),
6299 (SEC_CODE
| SEC_DATA
| SEC_ROM
| SEC_HAS_CONTENTS
6300 | SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
6302 /* leading_symbol_char: is the first char of a user symbol
6303 predictable, and if so what is it */
6305 '/', /* ar_pad_char */
6306 14, /* ar_max_namelen */
6307 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
6308 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
6309 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* data */
6310 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
6311 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
6312 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* hdrs */
6314 som_object_p
, /* bfd_check_format */
6315 bfd_generic_archive_p
,
6321 _bfd_generic_mkarchive
,
6326 som_write_object_contents
,
6327 _bfd_write_archive_contents
,
6332 BFD_JUMP_TABLE_GENERIC (som
),
6333 BFD_JUMP_TABLE_COPY (som
),
6334 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
6335 BFD_JUMP_TABLE_ARCHIVE (som
),
6336 BFD_JUMP_TABLE_SYMBOLS (som
),
6337 BFD_JUMP_TABLE_RELOCS (som
),
6338 BFD_JUMP_TABLE_WRITE (som
),
6339 BFD_JUMP_TABLE_LINK (som
),
6340 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),
6347 #endif /* HOST_HPPAHPUX || HOST_HPPABSD || HOST_HPPAOSF */