1 /* bfd back-end for HP PA-RISC SOM objects.
2 Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
4 Contributed by the Center for Software Science at the
5 University of Utah (pa-gdb-bugs@cs.utah.edu).
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF)
33 #include <sys/types.h>
34 #include <sys/param.h>
37 #include <machine/reg.h>
38 #include <sys/user.h> /* After a.out.h */
42 /* Magic not defined in standard HP-UX header files until 8.0 */
44 #ifndef CPU_PA_RISC1_0
45 #define CPU_PA_RISC1_0 0x20B
46 #endif /* CPU_PA_RISC1_0 */
48 #ifndef CPU_PA_RISC1_1
49 #define CPU_PA_RISC1_1 0x210
50 #endif /* CPU_PA_RISC1_1 */
52 #ifndef _PA_RISC1_0_ID
53 #define _PA_RISC1_0_ID CPU_PA_RISC1_0
54 #endif /* _PA_RISC1_0_ID */
56 #ifndef _PA_RISC1_1_ID
57 #define _PA_RISC1_1_ID CPU_PA_RISC1_1
58 #endif /* _PA_RISC1_1_ID */
60 #ifndef _PA_RISC_MAXID
61 #define _PA_RISC_MAXID 0x2FF
62 #endif /* _PA_RISC_MAXID */
65 #define _PA_RISC_ID(__m_num) \
66 (((__m_num) == _PA_RISC1_0_ID) || \
67 ((__m_num) >= _PA_RISC1_1_ID && (__m_num) <= _PA_RISC_MAXID))
68 #endif /* _PA_RISC_ID */
70 /* Size (in chars) of the temporary buffers used during fixup and string
73 #define SOM_TMP_BUFSIZE 8192
75 /* Size of the hash table in archives. */
76 #define SOM_LST_HASH_SIZE 31
78 /* Max number of SOMs to be found in an archive. */
79 #define SOM_LST_MODULE_LIMIT 1024
81 /* SOM allows any one of the four previous relocations to be reused
82 with a "R_PREV_FIXUP" relocation entry. Since R_PREV_FIXUP
83 relocations are always a single byte, using a R_PREV_FIXUP instead
84 of some multi-byte relocation makes object files smaller.
86 Note one side effect of using a R_PREV_FIXUP is the relocation that
87 is being repeated moves to the front of the queue. */
94 /* This fully describes the symbol types which may be attached to
95 an EXPORT or IMPORT directive. Only SOM uses this formation
96 (ELF has no need for it). */
100 SYMBOL_TYPE_ABSOLUTE
,
104 SYMBOL_TYPE_MILLICODE
,
106 SYMBOL_TYPE_PRI_PROG
,
107 SYMBOL_TYPE_SEC_PROG
,
110 struct section_to_type
116 /* Assorted symbol information that needs to be derived from the BFD symbol
117 and/or the BFD backend private symbol data. */
118 struct som_misc_symbol_info
120 unsigned int symbol_type
;
121 unsigned int symbol_scope
;
122 unsigned int arg_reloc
;
123 unsigned int symbol_info
;
124 unsigned int symbol_value
;
127 /* Forward declarations */
129 static boolean som_mkobject
PARAMS ((bfd
*));
130 static bfd_target
* som_object_setup
PARAMS ((bfd
*,
132 struct som_exec_auxhdr
*));
133 static asection
* make_unique_section
PARAMS ((bfd
*, CONST
char *, int));
134 static boolean setup_sections
PARAMS ((bfd
*, struct header
*));
135 static bfd_target
* som_object_p
PARAMS ((bfd
*));
136 static boolean som_write_object_contents
PARAMS ((bfd
*));
137 static boolean som_slurp_string_table
PARAMS ((bfd
*));
138 static unsigned int som_slurp_symbol_table
PARAMS ((bfd
*));
139 static unsigned int som_get_symtab_upper_bound
PARAMS ((bfd
*));
140 static unsigned int som_canonicalize_reloc
PARAMS ((bfd
*, sec_ptr
,
141 arelent
**, asymbol
**));
142 static unsigned int som_get_reloc_upper_bound
PARAMS ((bfd
*, sec_ptr
));
143 static unsigned int som_set_reloc_info
PARAMS ((unsigned char *, unsigned int,
144 arelent
*, asection
*,
145 asymbol
**, boolean
));
146 static boolean som_slurp_reloc_table
PARAMS ((bfd
*, asection
*,
147 asymbol
**, boolean
));
148 static unsigned int som_get_symtab
PARAMS ((bfd
*, asymbol
**));
149 static asymbol
* som_make_empty_symbol
PARAMS ((bfd
*));
150 static void som_print_symbol
PARAMS ((bfd
*, PTR
,
151 asymbol
*, bfd_print_symbol_type
));
152 static boolean som_new_section_hook
PARAMS ((bfd
*, asection
*));
153 static boolean som_set_section_contents
PARAMS ((bfd
*, sec_ptr
, PTR
,
154 file_ptr
, bfd_size_type
));
155 static boolean som_set_arch_mach
PARAMS ((bfd
*, enum bfd_architecture
,
157 static boolean som_find_nearest_line
PARAMS ((bfd
*, asection
*,
162 static void som_get_symbol_info
PARAMS ((bfd
*, asymbol
*, symbol_info
*));
163 static asection
* som_section_from_subspace_index
PARAMS ((bfd
*,
165 static int log2
PARAMS ((unsigned int));
166 static bfd_reloc_status_type hppa_som_reloc
PARAMS ((bfd
*, arelent
*,
170 static void som_initialize_reloc_queue
PARAMS ((struct reloc_queue
*));
171 static void som_reloc_queue_insert
PARAMS ((unsigned char *, unsigned int,
172 struct reloc_queue
*));
173 static void som_reloc_queue_fix
PARAMS ((struct reloc_queue
*, unsigned int));
174 static int som_reloc_queue_find
PARAMS ((unsigned char *, unsigned int,
175 struct reloc_queue
*));
176 static unsigned char * try_prev_fixup
PARAMS ((bfd
*, int *, unsigned char *,
178 struct reloc_queue
*));
180 static unsigned char * som_reloc_skip
PARAMS ((bfd
*, unsigned int,
181 unsigned char *, unsigned int *,
182 struct reloc_queue
*));
183 static unsigned char * som_reloc_addend
PARAMS ((bfd
*, int, unsigned char *,
185 struct reloc_queue
*));
186 static unsigned char * som_reloc_call
PARAMS ((bfd
*, unsigned char *,
189 struct reloc_queue
*));
190 static unsigned long som_count_spaces
PARAMS ((bfd
*));
191 static unsigned long som_count_subspaces
PARAMS ((bfd
*));
192 static int compare_syms
PARAMS ((asymbol
**, asymbol
**));
193 static unsigned long som_compute_checksum
PARAMS ((bfd
*));
194 static boolean som_prep_headers
PARAMS ((bfd
*));
195 static int som_sizeof_headers
PARAMS ((bfd
*, boolean
));
196 static boolean som_write_headers
PARAMS ((bfd
*));
197 static boolean som_build_and_write_symbol_table
PARAMS ((bfd
*));
198 static void som_prep_for_fixups
PARAMS ((bfd
*, asymbol
**, unsigned long));
199 static boolean som_write_fixups
PARAMS ((bfd
*, unsigned long, unsigned int *));
200 static boolean som_write_space_strings
PARAMS ((bfd
*, unsigned long,
202 static boolean som_write_symbol_strings
PARAMS ((bfd
*, unsigned long,
203 asymbol
**, unsigned int,
205 static boolean som_begin_writing
PARAMS ((bfd
*));
206 static const reloc_howto_type
* som_bfd_reloc_type_lookup
207 PARAMS ((bfd_arch_info_type
*, bfd_reloc_code_real_type
));
208 static char som_section_type
PARAMS ((const char *));
209 static int som_decode_symclass
PARAMS ((asymbol
*));
210 static boolean som_bfd_count_ar_symbols
PARAMS ((bfd
*, struct lst_header
*,
213 static boolean som_bfd_fill_in_ar_symbols
PARAMS ((bfd
*, struct lst_header
*,
215 static boolean som_slurp_armap
PARAMS ((bfd
*));
216 static boolean som_write_armap
PARAMS ((bfd
*));
217 static boolean som_slurp_extended_name_table
PARAMS ((bfd
*));
218 static void som_bfd_derive_misc_symbol_info
PARAMS ((bfd
*, asymbol
*,
219 struct som_misc_symbol_info
*));
220 static boolean som_bfd_prep_for_ar_write
PARAMS ((bfd
*, unsigned int *,
222 static unsigned int som_bfd_ar_symbol_hash
PARAMS ((asymbol
*));
223 static boolean som_bfd_ar_write_symbol_stuff
PARAMS ((bfd
*, unsigned int,
227 /* Map SOM section names to POSIX/BSD single-character symbol types.
229 This table includes all the standard subspaces as defined in the
230 current "PRO ABI for PA-RISC Systems", $UNWIND$ which for
231 some reason was left out, and sections specific to embedded stabs. */
233 static const struct section_to_type stt
[] = {
235 {"$SHLIB_INFO$", 't'},
236 {"$MILLICODE$", 't'},
239 {"$UNWIND_START$", 't'},
243 {"$SHLIB_DATA$", 'd'},
245 {"$SHORTDATA$", 'g'},
250 {"$GDB_STRINGS$", 'N'},
251 {"$GDB_SYMBOLS$", 'N'},
255 /* About the relocation formatting table...
257 There are 256 entries in the table, one for each possible
258 relocation opcode available in SOM. We index the table by
259 the relocation opcode. The names and operations are those
260 defined by a.out_800 (4).
262 Right now this table is only used to count and perform minimal
263 processing on relocation streams so that they can be internalized
264 into BFD and symbolically printed by utilities. To make actual use
265 of them would be much more difficult, BFD's concept of relocations
266 is far too simple to handle SOM relocations. The basic assumption
267 that a relocation can be completely processed independent of other
268 relocations before an object file is written is invalid for SOM.
270 The SOM relocations are meant to be processed as a stream, they
271 specify copying of data from the input section to the output section
272 while possibly modifying the data in some manner. They also can
273 specify that a variable number of zeros or uninitialized data be
274 inserted on in the output segment at the current offset. Some
275 relocations specify that some previous relocation be re-applied at
276 the current location in the input/output sections. And finally a number
277 of relocations have effects on other sections (R_ENTRY, R_EXIT,
278 R_UNWIND_AUX and a variety of others). There isn't even enough room
279 in the BFD relocation data structure to store enough information to
280 perform all the relocations.
282 Each entry in the table has three fields.
284 The first entry is an index into this "class" of relocations. This
285 index can then be used as a variable within the relocation itself.
287 The second field is a format string which actually controls processing
288 of the relocation. It uses a simple postfix machine to do calculations
289 based on variables/constants found in the string and the relocation
292 The third field specifys whether or not this relocation may use
293 a constant (V) from the previous R_DATA_OVERRIDE rather than a constant
294 stored in the instruction.
298 L = input space byte count
299 D = index into class of relocations
300 M = output space byte count
301 N = statement number (unused?)
303 R = parameter relocation bits
305 U = 64 bits of stack unwind and frame size info (we only keep 32 bits)
306 V = a literal constant (usually used in the next relocation)
307 P = a previous relocation
309 Lower case letters (starting with 'b') refer to following
310 bytes in the relocation stream. 'b' is the next 1 byte,
311 c is the next 2 bytes, d is the next 3 bytes, etc...
312 This is the variable part of the relocation entries that
313 makes our life a living hell.
315 numerical constants are also used in the format string. Note
316 the constants are represented in decimal.
318 '+', "*" and "=" represents the obvious postfix operators.
319 '<' represents a left shift.
323 Parameter Relocation Bits:
327 Previous Relocations: The index field represents which in the queue
328 of 4 previous fixups should be re-applied.
330 Literal Constants: These are generally used to represent addend
331 parts of relocations when these constants are not stored in the
332 fields of the instructions themselves. For example the instruction
333 addil foo-$global$-0x1234 would use an override for "0x1234" rather
334 than storing it into the addil itself. */
342 static const struct fixup_format som_fixup_formats
[256] =
344 /* R_NO_RELOCATION */
345 0, "LD1+4*=", /* 0x00 */
346 1, "LD1+4*=", /* 0x01 */
347 2, "LD1+4*=", /* 0x02 */
348 3, "LD1+4*=", /* 0x03 */
349 4, "LD1+4*=", /* 0x04 */
350 5, "LD1+4*=", /* 0x05 */
351 6, "LD1+4*=", /* 0x06 */
352 7, "LD1+4*=", /* 0x07 */
353 8, "LD1+4*=", /* 0x08 */
354 9, "LD1+4*=", /* 0x09 */
355 10, "LD1+4*=", /* 0x0a */
356 11, "LD1+4*=", /* 0x0b */
357 12, "LD1+4*=", /* 0x0c */
358 13, "LD1+4*=", /* 0x0d */
359 14, "LD1+4*=", /* 0x0e */
360 15, "LD1+4*=", /* 0x0f */
361 16, "LD1+4*=", /* 0x10 */
362 17, "LD1+4*=", /* 0x11 */
363 18, "LD1+4*=", /* 0x12 */
364 19, "LD1+4*=", /* 0x13 */
365 20, "LD1+4*=", /* 0x14 */
366 21, "LD1+4*=", /* 0x15 */
367 22, "LD1+4*=", /* 0x16 */
368 23, "LD1+4*=", /* 0x17 */
369 0, "LD8<b+1+4*=", /* 0x18 */
370 1, "LD8<b+1+4*=", /* 0x19 */
371 2, "LD8<b+1+4*=", /* 0x1a */
372 3, "LD8<b+1+4*=", /* 0x1b */
373 0, "LD16<c+1+4*=", /* 0x1c */
374 1, "LD16<c+1+4*=", /* 0x1d */
375 2, "LD16<c+1+4*=", /* 0x1e */
376 0, "Ld1+=", /* 0x1f */
378 0, "Lb1+4*=", /* 0x20 */
379 1, "Ld1+=", /* 0x21 */
381 0, "Lb1+4*=", /* 0x22 */
382 1, "Ld1+=", /* 0x23 */
385 /* R_DATA_ONE_SYMBOL */
386 0, "L4=Sb=", /* 0x25 */
387 1, "L4=Sd=", /* 0x26 */
389 0, "L4=Sb=", /* 0x27 */
390 1, "L4=Sd=", /* 0x28 */
393 /* R_REPEATED_INIT */
394 0, "L4=Mb1+4*=", /* 0x2a */
395 1, "Lb4*=Mb1+L*=", /* 0x2b */
396 2, "Lb4*=Md1+4*=", /* 0x2c */
397 3, "Ld1+=Me1+=", /* 0x2d */
402 0, "L4=RD=Sb=", /* 0x30 */
403 1, "L4=RD=Sb=", /* 0x31 */
404 2, "L4=RD=Sb=", /* 0x32 */
405 3, "L4=RD=Sb=", /* 0x33 */
406 4, "L4=RD=Sb=", /* 0x34 */
407 5, "L4=RD=Sb=", /* 0x35 */
408 6, "L4=RD=Sb=", /* 0x36 */
409 7, "L4=RD=Sb=", /* 0x37 */
410 8, "L4=RD=Sb=", /* 0x38 */
411 9, "L4=RD=Sb=", /* 0x39 */
412 0, "L4=RD8<b+=Sb=",/* 0x3a */
413 1, "L4=RD8<b+=Sb=",/* 0x3b */
414 0, "L4=RD8<b+=Sd=",/* 0x3c */
415 1, "L4=RD8<b+=Sd=",/* 0x3d */
420 0, "L4=RD=Sb=", /* 0x40 */
421 1, "L4=RD=Sb=", /* 0x41 */
422 2, "L4=RD=Sb=", /* 0x42 */
423 3, "L4=RD=Sb=", /* 0x43 */
424 4, "L4=RD=Sb=", /* 0x44 */
425 5, "L4=RD=Sb=", /* 0x45 */
426 6, "L4=RD=Sb=", /* 0x46 */
427 7, "L4=RD=Sb=", /* 0x47 */
428 8, "L4=RD=Sb=", /* 0x48 */
429 9, "L4=RD=Sb=", /* 0x49 */
430 0, "L4=RD8<b+=Sb=",/* 0x4a */
431 1, "L4=RD8<b+=Sb=",/* 0x4b */
432 0, "L4=RD8<b+=Sd=",/* 0x4c */
433 1, "L4=RD8<b+=Sd=",/* 0x4d */
438 0, "L4=SD=", /* 0x50 */
439 1, "L4=SD=", /* 0x51 */
440 2, "L4=SD=", /* 0x52 */
441 3, "L4=SD=", /* 0x53 */
442 4, "L4=SD=", /* 0x54 */
443 5, "L4=SD=", /* 0x55 */
444 6, "L4=SD=", /* 0x56 */
445 7, "L4=SD=", /* 0x57 */
446 8, "L4=SD=", /* 0x58 */
447 9, "L4=SD=", /* 0x59 */
448 10, "L4=SD=", /* 0x5a */
449 11, "L4=SD=", /* 0x5b */
450 12, "L4=SD=", /* 0x5c */
451 13, "L4=SD=", /* 0x5d */
452 14, "L4=SD=", /* 0x5e */
453 15, "L4=SD=", /* 0x5f */
454 16, "L4=SD=", /* 0x60 */
455 17, "L4=SD=", /* 0x61 */
456 18, "L4=SD=", /* 0x62 */
457 19, "L4=SD=", /* 0x63 */
458 20, "L4=SD=", /* 0x64 */
459 21, "L4=SD=", /* 0x65 */
460 22, "L4=SD=", /* 0x66 */
461 23, "L4=SD=", /* 0x67 */
462 24, "L4=SD=", /* 0x68 */
463 25, "L4=SD=", /* 0x69 */
464 26, "L4=SD=", /* 0x6a */
465 27, "L4=SD=", /* 0x6b */
466 28, "L4=SD=", /* 0x6c */
467 29, "L4=SD=", /* 0x6d */
468 30, "L4=SD=", /* 0x6e */
469 31, "L4=SD=", /* 0x6f */
470 32, "L4=Sb=", /* 0x70 */
471 33, "L4=Sd=", /* 0x71 */
480 0, "L4=Sb=", /* 0x78 */
481 1, "L4=Sd=", /* 0x79 */
489 /* R_CODE_ONE_SYMBOL */
490 0, "L4=SD=", /* 0x80 */
491 1, "L4=SD=", /* 0x81 */
492 2, "L4=SD=", /* 0x82 */
493 3, "L4=SD=", /* 0x83 */
494 4, "L4=SD=", /* 0x84 */
495 5, "L4=SD=", /* 0x85 */
496 6, "L4=SD=", /* 0x86 */
497 7, "L4=SD=", /* 0x87 */
498 8, "L4=SD=", /* 0x88 */
499 9, "L4=SD=", /* 0x89 */
500 10, "L4=SD=", /* 0x8q */
501 11, "L4=SD=", /* 0x8b */
502 12, "L4=SD=", /* 0x8c */
503 13, "L4=SD=", /* 0x8d */
504 14, "L4=SD=", /* 0x8e */
505 15, "L4=SD=", /* 0x8f */
506 16, "L4=SD=", /* 0x90 */
507 17, "L4=SD=", /* 0x91 */
508 18, "L4=SD=", /* 0x92 */
509 19, "L4=SD=", /* 0x93 */
510 20, "L4=SD=", /* 0x94 */
511 21, "L4=SD=", /* 0x95 */
512 22, "L4=SD=", /* 0x96 */
513 23, "L4=SD=", /* 0x97 */
514 24, "L4=SD=", /* 0x98 */
515 25, "L4=SD=", /* 0x99 */
516 26, "L4=SD=", /* 0x9a */
517 27, "L4=SD=", /* 0x9b */
518 28, "L4=SD=", /* 0x9c */
519 29, "L4=SD=", /* 0x9d */
520 30, "L4=SD=", /* 0x9e */
521 31, "L4=SD=", /* 0x9f */
522 32, "L4=Sb=", /* 0xa0 */
523 33, "L4=Sd=", /* 0xa1 */
538 0, "L4=Sb=", /* 0xae */
539 1, "L4=Sd=", /* 0xaf */
541 0, "L4=Sb=", /* 0xb0 */
542 1, "L4=Sd=", /* 0xb1 */
556 1, "Rb4*=", /* 0xb9 */
557 2, "Rd4*=", /* 0xba */
584 /* R_DATA_OVERRIDE */
597 0, "Ob=Sd=", /* 0xd1 */
599 0, "Ob=Ve=", /* 0xd2 */
649 static const int comp1_opcodes
[] =
671 static const int comp2_opcodes
[] =
680 static const int comp3_opcodes
[] =
687 /* These apparently are not in older versions of hpux reloc.h. */
689 #define R_DLT_REL 0x78
693 #define R_AUX_UNWIND 0xcf
697 #define R_SEC_STMT 0xd7
700 static reloc_howto_type som_hppa_howto_table
[] =
702 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
703 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
704 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
705 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
706 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
707 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
708 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
709 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
710 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
711 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
712 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
713 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
714 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
715 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
716 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
717 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
718 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
719 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
720 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
721 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
722 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
723 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
724 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
725 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
726 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
727 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
728 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
729 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
730 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
731 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
732 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
733 {R_NO_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_NO_RELOCATION"},
734 {R_ZEROES
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ZEROES"},
735 {R_ZEROES
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ZEROES"},
736 {R_UNINIT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_UNINIT"},
737 {R_UNINIT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_UNINIT"},
738 {R_RELOCATION
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RELOCATION"},
739 {R_DATA_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_ONE_SYMBOL"},
740 {R_DATA_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_ONE_SYMBOL"},
741 {R_DATA_PLABEL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_PLABEL"},
742 {R_DATA_PLABEL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_PLABEL"},
743 {R_SPACE_REF
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_SPACE_REF"},
744 {R_REPEATED_INIT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "REPEATED_INIT"},
745 {R_REPEATED_INIT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "REPEATED_INIT"},
746 {R_REPEATED_INIT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "REPEATED_INIT"},
747 {R_REPEATED_INIT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "REPEATED_INIT"},
748 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
749 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
750 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
751 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
752 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
753 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
754 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
755 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
756 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
757 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
758 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
759 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
760 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
761 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
762 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
763 {R_PCREL_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PCREL_CALL"},
764 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
765 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
766 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
767 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
768 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
769 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
770 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
771 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
772 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
773 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
774 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
775 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
776 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
777 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
778 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
779 {R_ABS_CALL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ABS_CALL"},
780 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
781 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
782 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
783 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
784 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
785 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
786 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
787 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
788 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
789 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
790 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
791 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
792 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
793 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
794 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
795 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
796 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
797 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
798 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
799 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
800 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
801 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
802 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
803 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
804 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
805 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
806 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
807 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
808 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
809 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
810 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
811 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
812 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
813 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
814 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
815 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
816 {R_DP_RELATIVE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DP_RELATIVE"},
817 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
818 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
819 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
820 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
821 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
822 {R_DLT_REL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DLT_REL"},
823 {R_DLT_REL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DLT_REL"},
824 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
825 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
826 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
827 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
828 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
829 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
830 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
831 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
832 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
833 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
834 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
835 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
836 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
837 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
838 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
839 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
840 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
841 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
842 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
843 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
844 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
845 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
846 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
847 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
848 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
849 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
850 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
851 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
852 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
853 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
854 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
855 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
856 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
857 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
858 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
859 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
860 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
861 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
862 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
863 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
864 {R_CODE_ONE_SYMBOL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_ONE_SYMBOL"},
865 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
866 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
867 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
868 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
869 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
870 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
871 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
872 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
873 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
874 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
875 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
876 {R_MILLI_REL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_MILLI_REL"},
877 {R_MILLI_REL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_MILLI_REL"},
878 {R_CODE_PLABEL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_PLABEL"},
879 {R_CODE_PLABEL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_PLABEL"},
880 {R_BREAKPOINT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_BREAKPOINT"},
881 {R_ENTRY
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ENTRY"},
882 {R_ENTRY
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ENTRY"},
883 {R_ALT_ENTRY
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_ALT_ENTRY"},
884 {R_EXIT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_EXIT"},
885 {R_BEGIN_TRY
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_BEGIN_TRY"},
886 {R_END_TRY
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_END_TRY"},
887 {R_END_TRY
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_END_TRY"},
888 {R_END_TRY
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_END_TRY"},
889 {R_BEGIN_BRTAB
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_BEGIN_BRTAB"},
890 {R_END_BRTAB
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_END_BRTAB"},
891 {R_STATEMENT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_STATEMENT"},
892 {R_STATEMENT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_STATEMENT"},
893 {R_STATEMENT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_STATEMENT"},
894 {R_DATA_EXPR
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_EXPR"},
895 {R_CODE_EXPR
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_CODE_EXPR"},
896 {R_FSEL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_FSEL"},
897 {R_LSEL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_LSEL"},
898 {R_RSEL
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RSEL"},
899 {R_N_MODE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_N_MODE"},
900 {R_S_MODE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_S_MODE"},
901 {R_D_MODE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_D_MODE"},
902 {R_R_MODE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_R_MODE"},
903 {R_DATA_OVERRIDE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_OVERRIDE"},
904 {R_DATA_OVERRIDE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_OVERRIDE"},
905 {R_DATA_OVERRIDE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_OVERRIDE"},
906 {R_DATA_OVERRIDE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_OVERRIDE"},
907 {R_DATA_OVERRIDE
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_DATA_OVERRIDE"},
908 {R_TRANSLATED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_TRANSLATED"},
909 {R_AUX_UNWIND
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_AUX_UNWIND"},
910 {R_COMP1
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_COMP1"},
911 {R_COMP2
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_COMP2"},
912 {R_COMP3
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_COMP3"},
913 {R_PREV_FIXUP
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PREV_FIXUP"},
914 {R_PREV_FIXUP
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PREV_FIXUP"},
915 {R_PREV_FIXUP
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PREV_FIXUP"},
916 {R_PREV_FIXUP
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_PREV_FIXUP"},
917 {R_SEC_STMT
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_SEC_STMT"},
918 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
919 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
920 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
921 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
922 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
923 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
924 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
925 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
926 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
927 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
928 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
929 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
930 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
931 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
932 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
933 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
934 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
935 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
936 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
937 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
938 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
939 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
940 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
941 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
942 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
943 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
944 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
945 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
946 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
947 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
948 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
949 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
950 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
951 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
952 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
953 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
954 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
955 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
956 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"},
957 {R_RESERVED
, 0, 0, 32, false, 0, 0, hppa_som_reloc
, "R_RESERVED"}};
960 /* Initialize the SOM relocation queue. By definition the queue holds
961 the last four multibyte fixups. */
964 som_initialize_reloc_queue (queue
)
965 struct reloc_queue
*queue
;
967 queue
[0].reloc
= NULL
;
969 queue
[1].reloc
= NULL
;
971 queue
[2].reloc
= NULL
;
973 queue
[3].reloc
= NULL
;
977 /* Insert a new relocation into the relocation queue. */
980 som_reloc_queue_insert (p
, size
, queue
)
983 struct reloc_queue
*queue
;
985 queue
[3].reloc
= queue
[2].reloc
;
986 queue
[3].size
= queue
[2].size
;
987 queue
[2].reloc
= queue
[1].reloc
;
988 queue
[2].size
= queue
[1].size
;
989 queue
[1].reloc
= queue
[0].reloc
;
990 queue
[1].size
= queue
[0].size
;
992 queue
[0].size
= size
;
995 /* When an entry in the relocation queue is reused, the entry moves
996 to the front of the queue. */
999 som_reloc_queue_fix (queue
, index
)
1000 struct reloc_queue
*queue
;
1008 unsigned char *tmp1
= queue
[0].reloc
;
1009 unsigned int tmp2
= queue
[0].size
;
1010 queue
[0].reloc
= queue
[1].reloc
;
1011 queue
[0].size
= queue
[1].size
;
1012 queue
[1].reloc
= tmp1
;
1013 queue
[1].size
= tmp2
;
1019 unsigned char *tmp1
= queue
[0].reloc
;
1020 unsigned int tmp2
= queue
[0].size
;
1021 queue
[0].reloc
= queue
[2].reloc
;
1022 queue
[0].size
= queue
[2].size
;
1023 queue
[2].reloc
= queue
[1].reloc
;
1024 queue
[2].size
= queue
[1].size
;
1025 queue
[1].reloc
= tmp1
;
1026 queue
[1].size
= tmp2
;
1032 unsigned char *tmp1
= queue
[0].reloc
;
1033 unsigned int tmp2
= queue
[0].size
;
1034 queue
[0].reloc
= queue
[3].reloc
;
1035 queue
[0].size
= queue
[3].size
;
1036 queue
[3].reloc
= queue
[2].reloc
;
1037 queue
[3].size
= queue
[2].size
;
1038 queue
[2].reloc
= queue
[1].reloc
;
1039 queue
[2].size
= queue
[1].size
;
1040 queue
[1].reloc
= tmp1
;
1041 queue
[1].size
= tmp2
;
1047 /* Search for a particular relocation in the relocation queue. */
1050 som_reloc_queue_find (p
, size
, queue
)
1053 struct reloc_queue
*queue
;
1055 if (queue
[0].reloc
&& !bcmp (p
, queue
[0].reloc
, size
)
1056 && size
== queue
[0].size
)
1058 if (queue
[1].reloc
&& !bcmp (p
, queue
[1].reloc
, size
)
1059 && size
== queue
[1].size
)
1061 if (queue
[2].reloc
&& !bcmp (p
, queue
[2].reloc
, size
)
1062 && size
== queue
[2].size
)
1064 if (queue
[3].reloc
&& !bcmp (p
, queue
[3].reloc
, size
)
1065 && size
== queue
[3].size
)
1070 static unsigned char *
1071 try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, size
, queue
)
1073 int *subspace_reloc_sizep
;
1076 struct reloc_queue
*queue
;
1078 int queue_index
= som_reloc_queue_find (p
, size
, queue
);
1080 if (queue_index
!= -1)
1082 /* Found this in a previous fixup. Undo the fixup we
1083 just built and use R_PREV_FIXUP instead. We saved
1084 a total of size - 1 bytes in the fixup stream. */
1085 bfd_put_8 (abfd
, R_PREV_FIXUP
+ queue_index
, p
);
1087 *subspace_reloc_sizep
+= 1;
1088 som_reloc_queue_fix (queue
, queue_index
);
1092 som_reloc_queue_insert (p
, size
, queue
);
1093 *subspace_reloc_sizep
+= size
;
1099 /* Emit the proper R_NO_RELOCATION fixups to map the next SKIP
1100 bytes without any relocation. Update the size of the subspace
1101 relocation stream via SUBSPACE_RELOC_SIZE_P; also return the
1102 current pointer into the relocation stream. */
1104 static unsigned char *
1105 som_reloc_skip (abfd
, skip
, p
, subspace_reloc_sizep
, queue
)
1109 unsigned int *subspace_reloc_sizep
;
1110 struct reloc_queue
*queue
;
1112 /* Use a 4 byte R_NO_RELOCATION entry with a maximal value
1113 then R_PREV_FIXUPs to get the difference down to a
1115 if (skip
>= 0x1000000)
1118 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 31, p
);
1119 bfd_put_8 (abfd
, 0xff, p
+ 1);
1120 bfd_put_16 (abfd
, 0xffff, p
+ 2);
1121 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 4, queue
);
1122 while (skip
>= 0x1000000)
1125 bfd_put_8 (abfd
, R_PREV_FIXUP
, p
);
1127 *subspace_reloc_sizep
+= 1;
1128 /* No need to adjust queue here since we are repeating the
1129 most recent fixup. */
1133 /* The difference must be less than 0x1000000. Use one
1134 more R_NO_RELOCATION entry to get to the right difference. */
1135 if ((skip
& 3) == 0 && skip
<= 0xc0000 && skip
> 0)
1137 /* Difference can be handled in a simple single-byte
1138 R_NO_RELOCATION entry. */
1141 bfd_put_8 (abfd
, R_NO_RELOCATION
+ (skip
>> 2) - 1, p
);
1142 *subspace_reloc_sizep
+= 1;
1145 /* Handle it with a two byte R_NO_RELOCATION entry. */
1146 else if (skip
<= 0x1000)
1148 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 24 + (((skip
>> 2) - 1) >> 8), p
);
1149 bfd_put_8 (abfd
, (skip
>> 2) - 1, p
+ 1);
1150 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 2, queue
);
1152 /* Handle it with a three byte R_NO_RELOCATION entry. */
1155 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 28 + (((skip
>> 2) - 1) >> 16), p
);
1156 bfd_put_16 (abfd
, (skip
>> 2) - 1, p
+ 1);
1157 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 3, queue
);
1160 /* Ugh. Punt and use a 4 byte entry. */
1163 bfd_put_8 (abfd
, R_NO_RELOCATION
+ 31, p
);
1164 bfd_put_8 (abfd
, skip
>> 16, p
+ 1);
1165 bfd_put_16 (abfd
, skip
, p
+ 2);
1166 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 4, queue
);
1171 /* Emit the proper R_DATA_OVERRIDE fixups to handle a nonzero addend
1172 from a BFD relocation. Update the size of the subspace relocation
1173 stream via SUBSPACE_RELOC_SIZE_P; also return the current pointer
1174 into the relocation stream. */
1176 static unsigned char *
1177 som_reloc_addend (abfd
, addend
, p
, subspace_reloc_sizep
, queue
)
1181 unsigned int *subspace_reloc_sizep
;
1182 struct reloc_queue
*queue
;
1184 if ((unsigned)(addend
) + 0x80 < 0x100)
1186 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 1, p
);
1187 bfd_put_8 (abfd
, addend
, p
+ 1);
1188 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 2, queue
);
1190 else if ((unsigned) (addend
) + 0x8000 < 0x10000)
1192 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 2, p
);
1193 bfd_put_16 (abfd
, addend
, p
+ 1);
1194 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 3, queue
);
1196 else if ((unsigned) (addend
) + 0x800000 < 0x1000000)
1198 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 3, p
);
1199 bfd_put_8 (abfd
, addend
>> 16, p
+ 1);
1200 bfd_put_16 (abfd
, addend
, p
+ 2);
1201 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 4, queue
);
1205 bfd_put_8 (abfd
, R_DATA_OVERRIDE
+ 4, p
);
1206 bfd_put_32 (abfd
, addend
, p
+ 1);
1207 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 5, queue
);
1212 /* Handle a single function call relocation. */
1214 static unsigned char *
1215 som_reloc_call (abfd
, p
, subspace_reloc_sizep
, bfd_reloc
, sym_num
, queue
)
1218 unsigned int *subspace_reloc_sizep
;
1221 struct reloc_queue
*queue
;
1223 int arg_bits
= HPPA_R_ARG_RELOC (bfd_reloc
->addend
);
1224 int rtn_bits
= arg_bits
& 0x3;
1227 /* You'll never believe all this is necessary to handle relocations
1228 for function calls. Having to compute and pack the argument
1229 relocation bits is the real nightmare.
1231 If you're interested in how this works, just forget it. You really
1232 do not want to know about this braindamage. */
1234 /* First see if this can be done with a "simple" relocation. Simple
1235 relocations have a symbol number < 0x100 and have simple encodings
1236 of argument relocations. */
1238 if (sym_num
< 0x100)
1250 case 1 << 8 | 1 << 6:
1251 case 1 << 8 | 1 << 6 | 1:
1254 case 1 << 8 | 1 << 6 | 1 << 4:
1255 case 1 << 8 | 1 << 6 | 1 << 4 | 1:
1258 case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2:
1259 case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2 | 1:
1263 /* Not one of the easy encodings. This will have to be
1264 handled by the more complex code below. */
1270 /* Account for the return value too. */
1274 /* Emit a 2 byte relocation. Then see if it can be handled
1275 with a relocation which is already in the relocation queue. */
1276 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ type
, p
);
1277 bfd_put_8 (abfd
, sym_num
, p
+ 1);
1278 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 2, queue
);
1283 /* If this could not be handled with a simple relocation, then do a hard
1284 one. Hard relocations occur if the symbol number was too high or if
1285 the encoding of argument relocation bits is too complex. */
1288 /* Don't ask about these magic sequences. I took them straight
1289 from gas-1.36 which took them from the a.out man page. */
1291 if ((arg_bits
>> 6 & 0xf) == 0xe)
1294 type
+= (3 * (arg_bits
>> 8 & 3) + (arg_bits
>> 6 & 3)) * 40;
1295 if ((arg_bits
>> 2 & 0xf) == 0xe)
1298 type
+= (3 * (arg_bits
>> 4 & 3) + (arg_bits
>> 2 & 3)) * 4;
1300 /* Output the first two bytes of the relocation. These describe
1301 the length of the relocation and encoding style. */
1302 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 10
1303 + 2 * (sym_num
>= 0x100) + (type
>= 0x100),
1305 bfd_put_8 (abfd
, type
, p
+ 1);
1307 /* Now output the symbol index and see if this bizarre relocation
1308 just happened to be in the relocation queue. */
1309 if (sym_num
< 0x100)
1311 bfd_put_8 (abfd
, sym_num
, p
+ 2);
1312 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 3, queue
);
1316 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 2);
1317 bfd_put_16 (abfd
, sym_num
, p
+ 3);
1318 p
= try_prev_fixup (abfd
, subspace_reloc_sizep
, p
, 5, queue
);
1325 /* Return the logarithm of X, base 2, considering X unsigned.
1326 Abort if X is not a power of two -- this should never happen (FIXME:
1327 It will happen on corrupt executables. GDB should give an error, not
1328 a coredump, in that case). */
1336 /* Test for 0 or a power of 2. */
1337 if (x
== 0 || x
!= (x
& -x
))
1340 while ((x
>>= 1) != 0)
1345 static bfd_reloc_status_type
1346 hppa_som_reloc (abfd
, reloc_entry
, symbol_in
, data
,
1347 input_section
, output_bfd
, error_message
)
1349 arelent
*reloc_entry
;
1352 asection
*input_section
;
1354 char **error_message
;
1358 reloc_entry
->address
+= input_section
->output_offset
;
1359 return bfd_reloc_ok
;
1361 return bfd_reloc_ok
;
1364 /* Given a generic HPPA relocation type, the instruction format,
1365 and a field selector, return an appropriate SOM reloation.
1367 FIXME. Need to handle %RR, %LR and the like as field selectors.
1368 These will need to generate multiple SOM relocations. */
1371 hppa_som_gen_reloc_type (abfd
, base_type
, format
, field
)
1375 enum hppa_reloc_field_selector_type field
;
1377 int *final_type
, **final_types
;
1379 final_types
= (int **) bfd_alloc_by_size_t (abfd
, sizeof (int *) * 3);
1380 final_type
= (int *) bfd_alloc_by_size_t (abfd
, sizeof (int));
1381 if (!final_types
|| !final_type
)
1383 bfd_error
= no_memory
;
1387 /* The field selector may require additional relocations to be
1388 generated. It's impossible to know at this moment if additional
1389 relocations will be needed, so we make them. The code to actually
1390 write the relocation/fixup stream is responsible for removing
1391 any redundant relocations. */
1398 final_types
[0] = final_type
;
1399 final_types
[1] = NULL
;
1400 final_types
[2] = NULL
;
1401 *final_type
= base_type
;
1407 final_types
[0] = (int *) bfd_alloc_by_size_t (abfd
, sizeof (int));
1408 if (!final_types
[0])
1410 bfd_error
= no_memory
;
1413 if (field
== e_tsel
)
1414 *final_types
[0] = R_FSEL
;
1415 else if (field
== e_ltsel
)
1416 *final_types
[0] = R_LSEL
;
1418 *final_types
[0] = R_RSEL
;
1419 final_types
[1] = final_type
;
1420 final_types
[2] = NULL
;
1421 *final_type
= base_type
;
1426 final_types
[0] = (int *) bfd_alloc_by_size_t (abfd
, sizeof (int));
1427 if (!final_types
[0])
1429 bfd_error
= no_memory
;
1432 *final_types
[0] = R_S_MODE
;
1433 final_types
[1] = final_type
;
1434 final_types
[2] = NULL
;
1435 *final_type
= base_type
;
1440 final_types
[0] = (int *) bfd_alloc_by_size_t (abfd
, sizeof (int));
1441 if (!final_types
[0])
1443 bfd_error
= no_memory
;
1446 *final_types
[0] = R_N_MODE
;
1447 final_types
[1] = final_type
;
1448 final_types
[2] = NULL
;
1449 *final_type
= base_type
;
1454 final_types
[0] = (int *) bfd_alloc_by_size_t (abfd
, sizeof (int));
1455 if (!final_types
[0])
1457 bfd_error
= no_memory
;
1460 *final_types
[0] = R_D_MODE
;
1461 final_types
[1] = final_type
;
1462 final_types
[2] = NULL
;
1463 *final_type
= base_type
;
1468 final_types
[0] = (int *) bfd_alloc_by_size_t (abfd
, sizeof (int));
1469 if (!final_types
[0])
1471 bfd_error
= no_memory
;
1474 *final_types
[0] = R_R_MODE
;
1475 final_types
[1] = final_type
;
1476 final_types
[2] = NULL
;
1477 *final_type
= base_type
;
1484 /* PLABELs get their own relocation type. */
1487 || field
== e_rpsel
)
1489 /* A PLABEL relocation that has a size of 32 bits must
1490 be a R_DATA_PLABEL. All others are R_CODE_PLABELs. */
1492 *final_type
= R_DATA_PLABEL
;
1494 *final_type
= R_CODE_PLABEL
;
1497 else if (field
== e_tsel
1499 || field
== e_rtsel
)
1500 *final_type
= R_DLT_REL
;
1501 /* A relocation in the data space is always a full 32bits. */
1502 else if (format
== 32)
1503 *final_type
= R_DATA_ONE_SYMBOL
;
1508 /* More PLABEL special cases. */
1511 || field
== e_rpsel
)
1512 *final_type
= R_DATA_PLABEL
;
1516 case R_HPPA_ABS_CALL
:
1517 case R_HPPA_PCREL_CALL
:
1518 case R_HPPA_COMPLEX
:
1519 case R_HPPA_COMPLEX_PCREL_CALL
:
1520 case R_HPPA_COMPLEX_ABS_CALL
:
1521 /* Right now we can default all these. */
1527 /* Return the address of the correct entry in the PA SOM relocation
1530 static const reloc_howto_type
*
1531 som_bfd_reloc_type_lookup (arch
, code
)
1532 bfd_arch_info_type
*arch
;
1533 bfd_reloc_code_real_type code
;
1535 if ((int) code
< (int) R_NO_RELOCATION
+ 255)
1537 BFD_ASSERT ((int) som_hppa_howto_table
[(int) code
].type
== (int) code
);
1538 return &som_hppa_howto_table
[(int) code
];
1541 return (reloc_howto_type
*) 0;
1544 /* Perform some initialization for an object. Save results of this
1545 initialization in the BFD. */
1548 som_object_setup (abfd
, file_hdrp
, aux_hdrp
)
1550 struct header
*file_hdrp
;
1551 struct som_exec_auxhdr
*aux_hdrp
;
1553 /* som_mkobject will set bfd_error if som_mkobject fails. */
1554 if (som_mkobject (abfd
) != true)
1557 /* Set BFD flags based on what information is available in the SOM. */
1558 abfd
->flags
= NO_FLAGS
;
1559 if (! file_hdrp
->entry_offset
)
1560 abfd
->flags
|= HAS_RELOC
;
1562 abfd
->flags
|= EXEC_P
;
1563 if (file_hdrp
->symbol_total
)
1564 abfd
->flags
|= HAS_LINENO
| HAS_DEBUG
| HAS_SYMS
| HAS_LOCALS
;
1566 bfd_get_start_address (abfd
) = aux_hdrp
->exec_entry
;
1567 bfd_default_set_arch_mach (abfd
, bfd_arch_hppa
, 0);
1568 bfd_get_symcount (abfd
) = file_hdrp
->symbol_total
;
1570 /* Initialize the saved symbol table and string table to NULL.
1571 Save important offsets and sizes from the SOM header into
1573 obj_som_stringtab (abfd
) = (char *) NULL
;
1574 obj_som_symtab (abfd
) = (som_symbol_type
*) NULL
;
1575 obj_som_stringtab_size (abfd
) = file_hdrp
->symbol_strings_size
;
1576 obj_som_sym_filepos (abfd
) = file_hdrp
->symbol_location
;
1577 obj_som_str_filepos (abfd
) = file_hdrp
->symbol_strings_location
;
1578 obj_som_reloc_filepos (abfd
) = file_hdrp
->fixup_request_location
;
1583 /* Create a new BFD section for NAME. If NAME already exists, then create a
1584 new unique name, with NAME as the prefix. This exists because SOM .o files
1585 may have more than one $CODE$ subspace. */
1588 make_unique_section (abfd
, name
, num
)
1597 sect
= bfd_make_section (abfd
, name
);
1600 sprintf (altname
, "%s-%d", name
, num
++);
1601 sect
= bfd_make_section (abfd
, altname
);
1604 newname
= bfd_alloc (abfd
, strlen (sect
->name
) + 1);
1607 bfd_error
= no_memory
;
1610 strcpy (newname
, sect
->name
);
1612 sect
->name
= newname
;
1616 /* Convert all of the space and subspace info into BFD sections. Each space
1617 contains a number of subspaces, which in turn describe the mapping between
1618 regions of the exec file, and the address space that the program runs in.
1619 BFD sections which correspond to spaces will overlap the sections for the
1620 associated subspaces. */
1623 setup_sections (abfd
, file_hdr
)
1625 struct header
*file_hdr
;
1627 char *space_strings
;
1629 unsigned int total_subspaces
= 0;
1631 /* First, read in space names */
1633 space_strings
= alloca (file_hdr
->space_strings_size
);
1637 if (bfd_seek (abfd
, file_hdr
->space_strings_location
, SEEK_SET
) < 0)
1639 if (bfd_read (space_strings
, 1, file_hdr
->space_strings_size
, abfd
)
1640 != file_hdr
->space_strings_size
)
1643 /* Loop over all of the space dictionaries, building up sections */
1644 for (space_index
= 0; space_index
< file_hdr
->space_total
; space_index
++)
1646 struct space_dictionary_record space
;
1647 struct subspace_dictionary_record subspace
, save_subspace
;
1649 asection
*space_asect
;
1651 /* Read the space dictionary element */
1652 if (bfd_seek (abfd
, file_hdr
->space_location
1653 + space_index
* sizeof space
, SEEK_SET
) < 0)
1655 if (bfd_read (&space
, 1, sizeof space
, abfd
) != sizeof space
)
1658 /* Setup the space name string */
1659 space
.name
.n_name
= space
.name
.n_strx
+ space_strings
;
1661 /* Make a section out of it */
1662 space_asect
= make_unique_section (abfd
, space
.name
.n_name
, space_index
);
1666 /* Now, read in the first subspace for this space */
1667 if (bfd_seek (abfd
, file_hdr
->subspace_location
1668 + space
.subspace_index
* sizeof subspace
,
1671 if (bfd_read (&subspace
, 1, sizeof subspace
, abfd
) != sizeof subspace
)
1673 /* Seek back to the start of the subspaces for loop below */
1674 if (bfd_seek (abfd
, file_hdr
->subspace_location
1675 + space
.subspace_index
* sizeof subspace
,
1679 /* Setup the start address and file loc from the first subspace record */
1680 space_asect
->vma
= subspace
.subspace_start
;
1681 space_asect
->filepos
= subspace
.file_loc_init_value
;
1682 space_asect
->alignment_power
= log2 (subspace
.alignment
);
1684 /* Initialize save_subspace so we can reliably determine if this
1685 loop placed any useful values into it. */
1686 memset (&save_subspace
, 0, sizeof (struct subspace_dictionary_record
));
1688 /* Loop over the rest of the subspaces, building up more sections */
1689 for (subspace_index
= 0; subspace_index
< space
.subspace_quantity
;
1692 asection
*subspace_asect
;
1694 /* Read in the next subspace */
1695 if (bfd_read (&subspace
, 1, sizeof subspace
, abfd
)
1699 /* Setup the subspace name string */
1700 subspace
.name
.n_name
= subspace
.name
.n_strx
+ space_strings
;
1702 /* Make a section out of this subspace */
1703 subspace_asect
= make_unique_section (abfd
, subspace
.name
.n_name
,
1704 space
.subspace_index
+ subspace_index
);
1706 if (!subspace_asect
)
1709 /* Keep an easy mapping between subspaces and sections. */
1710 som_section_data (subspace_asect
)->subspace_index
1711 = total_subspaces
++;
1713 /* Set SEC_READONLY and SEC_CODE/SEC_DATA as specified
1714 by the access_control_bits in the subspace header. */
1715 switch (subspace
.access_control_bits
>> 4)
1717 /* Readonly data. */
1719 subspace_asect
->flags
|= SEC_DATA
| SEC_READONLY
;
1724 subspace_asect
->flags
|= SEC_DATA
;
1727 /* Readonly code and the gateways.
1728 Gateways have other attributes which do not map
1729 into anything BFD knows about. */
1735 subspace_asect
->flags
|= SEC_CODE
| SEC_READONLY
;
1738 /* dynamic (writable) code. */
1740 subspace_asect
->flags
|= SEC_CODE
;
1744 if (subspace
.dup_common
|| subspace
.is_common
)
1745 subspace_asect
->flags
|= SEC_IS_COMMON
;
1746 else if (subspace
.subspace_length
> 0)
1747 subspace_asect
->flags
|= SEC_HAS_CONTENTS
;
1748 if (subspace
.is_loadable
)
1749 subspace_asect
->flags
|= SEC_ALLOC
| SEC_LOAD
;
1750 if (subspace
.code_only
)
1751 subspace_asect
->flags
|= SEC_CODE
;
1753 /* Both file_loc_init_value and initialization_length will
1754 be zero for a BSS like subspace. */
1755 if (subspace
.file_loc_init_value
== 0
1756 && subspace
.initialization_length
== 0)
1757 subspace_asect
->flags
&= ~(SEC_DATA
| SEC_LOAD
);
1759 /* This subspace has relocations.
1760 The fixup_request_quantity is a byte count for the number of
1761 entries in the relocation stream; it is not the actual number
1762 of relocations in the subspace. */
1763 if (subspace
.fixup_request_quantity
!= 0)
1765 subspace_asect
->flags
|= SEC_RELOC
;
1766 subspace_asect
->rel_filepos
= subspace
.fixup_request_index
;
1767 som_section_data (subspace_asect
)->reloc_size
1768 = subspace
.fixup_request_quantity
;
1769 /* We can not determine this yet. When we read in the
1770 relocation table the correct value will be filled in. */
1771 subspace_asect
->reloc_count
= -1;
1774 /* Update save_subspace if appropriate. */
1775 if (subspace
.file_loc_init_value
> save_subspace
.file_loc_init_value
)
1776 save_subspace
= subspace
;
1778 subspace_asect
->vma
= subspace
.subspace_start
;
1779 subspace_asect
->_cooked_size
= subspace
.subspace_length
;
1780 subspace_asect
->_raw_size
= subspace
.subspace_length
;
1781 subspace_asect
->alignment_power
= log2 (subspace
.alignment
);
1782 subspace_asect
->filepos
= subspace
.file_loc_init_value
;
1785 /* Yow! there is no subspace within the space which actually
1786 has initialized information in it; this should never happen
1787 as far as I know. */
1788 if (!save_subspace
.file_loc_init_value
)
1791 /* Setup the sizes for the space section based upon the info in the
1792 last subspace of the space. */
1793 space_asect
->_cooked_size
= save_subspace
.subspace_start
1794 - space_asect
->vma
+ save_subspace
.subspace_length
;
1795 space_asect
->_raw_size
= save_subspace
.file_loc_init_value
1796 - space_asect
->filepos
+ save_subspace
.initialization_length
;
1801 /* Read in a SOM object and make it into a BFD. */
1807 struct header file_hdr
;
1808 struct som_exec_auxhdr aux_hdr
;
1810 if (bfd_read ((PTR
) & file_hdr
, 1, FILE_HDR_SIZE
, abfd
) != FILE_HDR_SIZE
)
1812 bfd_error
= system_call_error
;
1816 if (!_PA_RISC_ID (file_hdr
.system_id
))
1818 bfd_error
= wrong_format
;
1822 switch (file_hdr
.a_magic
)
1837 #ifdef SHARED_MAGIC_CNX
1838 case SHARED_MAGIC_CNX
:
1842 bfd_error
= wrong_format
;
1846 if (file_hdr
.version_id
!= VERSION_ID
1847 && file_hdr
.version_id
!= NEW_VERSION_ID
)
1849 bfd_error
= wrong_format
;
1853 /* If the aux_header_size field in the file header is zero, then this
1854 object is an incomplete executable (a .o file). Do not try to read
1855 a non-existant auxiliary header. */
1856 memset (&aux_hdr
, 0, sizeof (struct som_exec_auxhdr
));
1857 if (file_hdr
.aux_header_size
!= 0)
1859 if (bfd_read ((PTR
) & aux_hdr
, 1, AUX_HDR_SIZE
, abfd
) != AUX_HDR_SIZE
)
1861 bfd_error
= wrong_format
;
1866 if (!setup_sections (abfd
, &file_hdr
))
1868 /* setup_sections does not bubble up a bfd error code. */
1869 bfd_error
= bad_value
;
1873 /* This appears to be a valid SOM object. Do some initialization. */
1874 return som_object_setup (abfd
, &file_hdr
, &aux_hdr
);
1877 /* Create a SOM object. */
1883 /* Allocate memory to hold backend information. */
1884 abfd
->tdata
.som_data
= (struct som_data_struct
*)
1885 bfd_zalloc (abfd
, sizeof (struct som_data_struct
));
1886 if (abfd
->tdata
.som_data
== NULL
)
1888 bfd_error
= no_memory
;
1891 obj_som_file_hdr (abfd
)
1892 = (struct header
*) bfd_zalloc (abfd
, sizeof (struct header
));
1893 if (obj_som_file_hdr (abfd
) == NULL
)
1896 bfd_error
= no_memory
;
1902 /* Initialize some information in the file header. This routine makes
1903 not attempt at doing the right thing for a full executable; it
1904 is only meant to handle relocatable objects. */
1907 som_prep_headers (abfd
)
1910 struct header
*file_hdr
= obj_som_file_hdr (abfd
);
1913 /* FIXME. This should really be conditional based on whether or not
1914 PA1.1 instructions/registers have been used. */
1915 file_hdr
->system_id
= HP9000S800_ID
;
1917 /* FIXME. Only correct for building relocatable objects. */
1918 if (abfd
->flags
& EXEC_P
)
1921 file_hdr
->a_magic
= RELOC_MAGIC
;
1923 /* Only new format SOM is supported. */
1924 file_hdr
->version_id
= NEW_VERSION_ID
;
1926 /* These fields are optional, and embedding timestamps is not always
1927 a wise thing to do, it makes comparing objects during a multi-stage
1928 bootstrap difficult. */
1929 file_hdr
->file_time
.secs
= 0;
1930 file_hdr
->file_time
.nanosecs
= 0;
1932 if (abfd
->flags
& EXEC_P
)
1936 file_hdr
->entry_space
= 0;
1937 file_hdr
->entry_subspace
= 0;
1938 file_hdr
->entry_offset
= 0;
1941 /* FIXME. I do not know if we ever need to put anything other
1942 than zero in this field. */
1943 file_hdr
->presumed_dp
= 0;
1945 /* Now iterate over the sections translating information from
1946 BFD sections to SOM spaces/subspaces. */
1948 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
1950 /* Ignore anything which has not been marked as a space or
1952 if (som_section_data (section
)->is_space
== 0
1954 && som_section_data (section
)->is_subspace
== 0)
1957 if (som_section_data (section
)->is_space
)
1959 /* Set space attributes. Note most attributes of SOM spaces
1960 are set based on the subspaces it contains. */
1961 som_section_data (section
)->space_dict
.loader_fix_index
= -1;
1962 som_section_data (section
)->space_dict
.init_pointer_index
= -1;
1966 /* Set subspace attributes. Basic stuff is done here, additional
1967 attributes are filled in later as more information becomes
1969 if (section
->flags
& SEC_IS_COMMON
)
1971 som_section_data (section
)->subspace_dict
.dup_common
= 1;
1972 som_section_data (section
)->subspace_dict
.is_common
= 1;
1975 if (section
->flags
& SEC_ALLOC
)
1976 som_section_data (section
)->subspace_dict
.is_loadable
= 1;
1978 if (section
->flags
& SEC_CODE
)
1979 som_section_data (section
)->subspace_dict
.code_only
= 1;
1981 som_section_data (section
)->subspace_dict
.subspace_start
=
1983 som_section_data (section
)->subspace_dict
.subspace_length
=
1984 bfd_section_size (abfd
, section
);
1985 som_section_data (section
)->subspace_dict
.initialization_length
=
1986 bfd_section_size (abfd
, section
);
1987 som_section_data (section
)->subspace_dict
.alignment
=
1988 1 << section
->alignment_power
;
1994 /* Count and return the number of spaces attached to the given BFD. */
1996 static unsigned long
1997 som_count_spaces (abfd
)
2003 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2004 count
+= som_section_data (section
)->is_space
;
2009 /* Count the number of subspaces attached to the given BFD. */
2011 static unsigned long
2012 som_count_subspaces (abfd
)
2018 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2019 count
+= som_section_data (section
)->is_subspace
;
2024 /* Return -1, 0, 1 indicating the relative ordering of sym1 and sym2.
2026 We desire symbols to be ordered starting with the symbol with the
2027 highest relocation count down to the symbol with the lowest relocation
2028 count. Doing so compacts the relocation stream. */
2031 compare_syms (sym1
, sym2
)
2036 unsigned int count1
, count2
;
2038 /* Get relocation count for each symbol. Note that the count
2039 is stored in the udata pointer for section symbols! */
2040 if ((*sym1
)->flags
& BSF_SECTION_SYM
)
2041 count1
= (int)(*sym1
)->udata
;
2043 count1
= som_symbol_data (*sym1
)->reloc_count
;
2045 if ((*sym2
)->flags
& BSF_SECTION_SYM
)
2046 count2
= (int)(*sym2
)->udata
;
2048 count2
= som_symbol_data (*sym2
)->reloc_count
;
2050 /* Return the appropriate value. */
2051 if (count1
< count2
)
2053 else if (count1
> count2
)
2058 /* Perform various work in preparation for emitting the fixup stream. */
2061 som_prep_for_fixups (abfd
, syms
, num_syms
)
2064 unsigned long num_syms
;
2069 /* Most SOM relocations involving a symbol have a length which is
2070 dependent on the index of the symbol. So symbols which are
2071 used often in relocations should have a small index. */
2073 /* First initialize the counters for each symbol. */
2074 for (i
= 0; i
< num_syms
; i
++)
2076 /* Handle a section symbol; these have no pointers back to the
2077 SOM symbol info. So we just use the pointer field (udata)
2078 to hold the relocation count.
2080 FIXME. While we're here set the name of any section symbol
2081 to something which will not screw GDB. How do other formats
2082 deal with this?!? */
2083 if (som_symbol_data (syms
[i
]) == NULL
)
2085 syms
[i
]->flags
|= BSF_SECTION_SYM
;
2086 syms
[i
]->name
= "L$0\002";
2087 syms
[i
]->udata
= (PTR
) 0;
2090 som_symbol_data (syms
[i
])->reloc_count
= 0;
2093 /* Now that the counters are initialized, make a weighted count
2094 of how often a given symbol is used in a relocation. */
2095 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2099 /* Does this section have any relocations? */
2100 if (section
->reloc_count
<= 0)
2103 /* Walk through each relocation for this section. */
2104 for (i
= 1; i
< section
->reloc_count
; i
++)
2106 arelent
*reloc
= section
->orelocation
[i
];
2109 /* If no symbol, then there is no counter to increase. */
2110 if (reloc
->sym_ptr_ptr
== NULL
)
2113 /* Scaling to encourage symbols involved in R_DP_RELATIVE
2114 and R_CODE_ONE_SYMBOL relocations to come first. These
2115 two relocations have single byte versions if the symbol
2116 index is very small. */
2117 if (reloc
->howto
->type
== R_DP_RELATIVE
2118 || reloc
->howto
->type
== R_CODE_ONE_SYMBOL
)
2123 /* Handle section symbols by ramming the count in the udata
2124 field. It will not be used and the count is very important
2125 for these symbols. */
2126 if ((*reloc
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
)
2128 (*reloc
->sym_ptr_ptr
)->udata
=
2129 (PTR
) ((int) (*reloc
->sym_ptr_ptr
)->udata
+ scale
);
2133 /* A normal symbol. Increment the count. */
2134 som_symbol_data (*reloc
->sym_ptr_ptr
)->reloc_count
+= scale
;
2138 /* Now sort the symbols. */
2139 qsort (syms
, num_syms
, sizeof (asymbol
*), compare_syms
);
2141 /* Compute the symbol indexes, they will be needed by the relocation
2143 for (i
= 0; i
< num_syms
; i
++)
2145 /* A section symbol. Again, there is no pointer to backend symbol
2146 information, so we reuse (abuse) the udata field again. */
2147 if (syms
[i
]->flags
& BSF_SECTION_SYM
)
2148 syms
[i
]->udata
= (PTR
) i
;
2150 som_symbol_data (syms
[i
])->index
= i
;
2155 som_write_fixups (abfd
, current_offset
, total_reloc_sizep
)
2157 unsigned long current_offset
;
2158 unsigned int *total_reloc_sizep
;
2161 unsigned char *tmp_space
, *p
;
2162 unsigned int total_reloc_size
= 0;
2163 unsigned int subspace_reloc_size
= 0;
2164 unsigned int num_spaces
= obj_som_file_hdr (abfd
)->space_total
;
2165 asection
*section
= abfd
->sections
;
2167 /* Get a chunk of memory that we can use as buffer space, then throw
2169 tmp_space
= alloca (SOM_TMP_BUFSIZE
);
2170 memset (tmp_space
, 0, SOM_TMP_BUFSIZE
);
2173 /* All the fixups for a particular subspace are emitted in a single
2174 stream. All the subspaces for a particular space are emitted
2177 So, to get all the locations correct one must iterate through all the
2178 spaces, for each space iterate through its subspaces and output a
2180 for (i
= 0; i
< num_spaces
; i
++)
2182 asection
*subsection
;
2185 while (som_section_data (section
)->is_space
== 0)
2186 section
= section
->next
;
2188 /* Now iterate through each of its subspaces. */
2189 for (subsection
= abfd
->sections
;
2191 subsection
= subsection
->next
)
2193 int reloc_offset
, current_rounding_mode
;
2195 /* Find a subspace of this space. */
2196 if (som_section_data (subsection
)->is_subspace
== 0
2197 || som_section_data (subsection
)->containing_space
!= section
)
2200 /* If this subspace had no relocations, then we're finished
2202 if (subsection
->reloc_count
<= 0)
2204 som_section_data (subsection
)->subspace_dict
.fixup_request_index
2209 /* This subspace has some relocations. Put the relocation stream
2210 index into the subspace record. */
2211 som_section_data (subsection
)->subspace_dict
.fixup_request_index
2214 /* To make life easier start over with a clean slate for
2215 each subspace. Seek to the start of the relocation stream
2216 for this subspace in preparation for writing out its fixup
2218 if (bfd_seek (abfd
, current_offset
+ total_reloc_size
, SEEK_SET
) != 0)
2220 bfd_error
= system_call_error
;
2224 /* Buffer space has already been allocated. Just perform some
2225 initialization here. */
2227 subspace_reloc_size
= 0;
2229 som_initialize_reloc_queue (reloc_queue
);
2230 current_rounding_mode
= R_N_MODE
;
2232 /* Translate each BFD relocation into one or more SOM
2234 for (j
= 0; j
< subsection
->reloc_count
; j
++)
2236 arelent
*bfd_reloc
= subsection
->orelocation
[j
];
2240 /* Get the symbol number. Remember it's stored in a
2241 special place for section symbols. */
2242 if ((*bfd_reloc
->sym_ptr_ptr
)->flags
& BSF_SECTION_SYM
)
2243 sym_num
= (int) (*bfd_reloc
->sym_ptr_ptr
)->udata
;
2245 sym_num
= som_symbol_data (*bfd_reloc
->sym_ptr_ptr
)->index
;
2247 /* If there is not enough room for the next couple relocations,
2248 then dump the current buffer contents now. Also reinitialize
2249 the relocation queue.
2251 FIXME. We assume here that no BFD relocation will expand
2252 to more than 100 bytes of SOM relocations. This should (?!?)
2254 if (p
- tmp_space
+ 100 > SOM_TMP_BUFSIZE
)
2256 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
)
2259 bfd_error
= system_call_error
;
2263 som_initialize_reloc_queue (reloc_queue
);
2266 /* Emit R_NO_RELOCATION fixups to map any bytes which were
2268 skip
= bfd_reloc
->address
- reloc_offset
;
2269 p
= som_reloc_skip (abfd
, skip
, p
,
2270 &subspace_reloc_size
, reloc_queue
);
2272 /* Update reloc_offset for the next iteration.
2274 Many relocations do not consume input bytes. They
2275 are markers, or set state necessary to perform some
2276 later relocation. */
2277 switch (bfd_reloc
->howto
->type
)
2279 /* This only needs to handle relocations that may be
2280 made by hppa_som_gen_reloc. */
2290 reloc_offset
= bfd_reloc
->address
;
2294 reloc_offset
= bfd_reloc
->address
+ 4;
2298 /* Now the actual relocation we care about. */
2299 switch (bfd_reloc
->howto
->type
)
2303 p
= som_reloc_call (abfd
, p
, &subspace_reloc_size
,
2304 bfd_reloc
, sym_num
, reloc_queue
);
2307 case R_CODE_ONE_SYMBOL
:
2309 /* Account for any addend. */
2310 if (bfd_reloc
->addend
)
2311 p
= som_reloc_addend (abfd
, bfd_reloc
->addend
, p
,
2312 &subspace_reloc_size
, reloc_queue
);
2316 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ sym_num
, p
);
2317 subspace_reloc_size
+= 1;
2320 else if (sym_num
< 0x100)
2322 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 32, p
);
2323 bfd_put_8 (abfd
, sym_num
, p
+ 1);
2324 p
= try_prev_fixup (abfd
, &subspace_reloc_size
, p
,
2327 else if (sym_num
< 0x10000000)
2329 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 33, p
);
2330 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 1);
2331 bfd_put_16 (abfd
, sym_num
, p
+ 2);
2332 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2339 case R_DATA_ONE_SYMBOL
:
2343 /* Account for any addend. */
2344 if (bfd_reloc
->addend
)
2345 p
= som_reloc_addend (abfd
, bfd_reloc
->addend
, p
,
2346 &subspace_reloc_size
, reloc_queue
);
2348 if (sym_num
< 0x100)
2350 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2351 bfd_put_8 (abfd
, sym_num
, p
+ 1);
2352 p
= try_prev_fixup (abfd
, &subspace_reloc_size
, p
,
2355 else if (sym_num
< 0x10000000)
2357 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
+ 1, p
);
2358 bfd_put_8 (abfd
, sym_num
>> 16, p
+ 1);
2359 bfd_put_16 (abfd
, sym_num
, p
+ 2);
2360 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2370 = (int *) som_symbol_data (*bfd_reloc
->sym_ptr_ptr
)->unwind
;
2371 bfd_put_8 (abfd
, R_ENTRY
, p
);
2372 bfd_put_32 (abfd
, descp
[0], p
+ 1);
2373 bfd_put_32 (abfd
, descp
[1], p
+ 5);
2374 p
= try_prev_fixup (abfd
, &subspace_reloc_size
,
2380 bfd_put_8 (abfd
, R_EXIT
, p
);
2381 subspace_reloc_size
+= 1;
2389 /* If this relocation requests the current rounding
2390 mode, then it is redundant. */
2391 if (bfd_reloc
->howto
->type
!= current_rounding_mode
)
2393 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2394 subspace_reloc_size
+= 1;
2396 current_rounding_mode
= bfd_reloc
->howto
->type
;
2403 bfd_put_8 (abfd
, bfd_reloc
->howto
->type
, p
);
2404 subspace_reloc_size
+= 1;
2408 /* Put a "R_RESERVED" relocation in the stream if
2409 we hit something we do not understand. The linker
2410 will complain loudly if this ever happens. */
2412 bfd_put_8 (abfd
, 0xff, p
);
2413 subspace_reloc_size
+= 1;
2419 /* Last BFD relocation for a subspace has been processed.
2420 Map the rest of the subspace with R_NO_RELOCATION fixups. */
2421 p
= som_reloc_skip (abfd
, bfd_section_size (abfd
, subsection
)
2423 p
, &subspace_reloc_size
, reloc_queue
);
2425 /* Scribble out the relocations. */
2426 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
)
2429 bfd_error
= system_call_error
;
2434 total_reloc_size
+= subspace_reloc_size
;
2435 som_section_data (subsection
)->subspace_dict
.fixup_request_quantity
2436 = subspace_reloc_size
;
2438 section
= section
->next
;
2440 *total_reloc_sizep
= total_reloc_size
;
2444 /* Write out the space/subspace string table. */
2447 som_write_space_strings (abfd
, current_offset
, string_sizep
)
2449 unsigned long current_offset
;
2450 unsigned int *string_sizep
;
2452 unsigned char *tmp_space
, *p
;
2453 unsigned int strings_size
= 0;
2456 /* Get a chunk of memory that we can use as buffer space, then throw
2458 tmp_space
= alloca (SOM_TMP_BUFSIZE
);
2459 memset (tmp_space
, 0, SOM_TMP_BUFSIZE
);
2462 /* Seek to the start of the space strings in preparation for writing
2464 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) != 0)
2466 bfd_error
= system_call_error
;
2470 /* Walk through all the spaces and subspaces (order is not important)
2471 building up and writing string table entries for their names. */
2472 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
2476 /* Only work with space/subspaces; avoid any other sections
2477 which might have been made (.text for example). */
2478 if (som_section_data (section
)->is_space
== 0
2479 && som_section_data (section
)->is_subspace
== 0)
2482 /* Get the length of the space/subspace name. */
2483 length
= strlen (section
->name
);
2485 /* If there is not enough room for the next entry, then dump the
2486 current buffer contents now. Each entry will take 4 bytes to
2487 hold the string length + the string itself + null terminator. */
2488 if (p
- tmp_space
+ 5 + length
> SOM_TMP_BUFSIZE
)
2490 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
)
2493 bfd_error
= system_call_error
;
2496 /* Reset to beginning of the buffer space. */
2500 /* First element in a string table entry is the length of the
2501 string. Alignment issues are already handled. */
2502 bfd_put_32 (abfd
, length
, p
);
2506 /* Record the index in the space/subspace records. */
2507 if (som_section_data (section
)->is_space
)
2508 som_section_data (section
)->space_dict
.name
.n_strx
= strings_size
;
2510 som_section_data (section
)->subspace_dict
.name
.n_strx
= strings_size
;
2512 /* Next comes the string itself + a null terminator. */
2513 strcpy (p
, section
->name
);
2515 strings_size
+= length
+ 1;
2517 /* Always align up to the next word boundary. */
2518 while (strings_size
% 4)
2520 bfd_put_8 (abfd
, 0, p
);
2526 /* Done with the space/subspace strings. Write out any information
2527 contained in a partial block. */
2528 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
) != p
- tmp_space
)
2530 bfd_error
= system_call_error
;
2533 *string_sizep
= strings_size
;
2537 /* Write out the symbol string table. */
2540 som_write_symbol_strings (abfd
, current_offset
, syms
, num_syms
, string_sizep
)
2542 unsigned long current_offset
;
2544 unsigned int num_syms
;
2545 unsigned int *string_sizep
;
2548 unsigned char *tmp_space
, *p
;
2549 unsigned int strings_size
= 0;
2551 /* Get a chunk of memory that we can use as buffer space, then throw
2553 tmp_space
= alloca (SOM_TMP_BUFSIZE
);
2554 memset (tmp_space
, 0, SOM_TMP_BUFSIZE
);
2557 /* Seek to the start of the space strings in preparation for writing
2559 if (bfd_seek (abfd
, current_offset
, SEEK_SET
) != 0)
2561 bfd_error
= system_call_error
;
2565 for (i
= 0; i
< num_syms
; i
++)
2567 int length
= strlen (syms
[i
]->name
);
2569 /* If there is not enough room for the next entry, then dump the
2570 current buffer contents now. */
2571 if (p
- tmp_space
+ 5 + length
> SOM_TMP_BUFSIZE
)
2573 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
)
2576 bfd_error
= system_call_error
;
2579 /* Reset to beginning of the buffer space. */
2583 /* First element in a string table entry is the length of the
2584 string. This must always be 4 byte aligned. This is also
2585 an appropriate time to fill in the string index field in the
2586 symbol table entry. */
2587 bfd_put_32 (abfd
, length
, p
);
2591 /* Next comes the string itself + a null terminator. */
2592 strcpy (p
, syms
[i
]->name
);
2595 syms
[i
]->name
= (char *)strings_size
;
2597 strings_size
+= length
+ 1;
2599 /* Always align up to the next word boundary. */
2600 while (strings_size
% 4)
2602 bfd_put_8 (abfd
, 0, p
);
2608 /* Scribble out any partial block. */
2609 if (bfd_write ((PTR
) tmp_space
, p
- tmp_space
, 1, abfd
) != p
- tmp_space
)
2611 bfd_error
= system_call_error
;
2615 *string_sizep
= strings_size
;
2619 /* Compute variable information to be placed in the SOM headers,
2620 space/subspace dictionaries, relocation streams, etc. Begin
2621 writing parts of the object file. */
2624 som_begin_writing (abfd
)
2627 unsigned long current_offset
= 0;
2628 int strings_size
= 0;
2629 unsigned int total_reloc_size
= 0;
2630 unsigned long num_spaces
, num_subspaces
, num_syms
, i
;
2632 asymbol
**syms
= bfd_get_outsymbols (abfd
);
2633 unsigned int total_subspaces
= 0;
2635 /* The file header will always be first in an object file,
2636 everything else can be in random locations. To keep things
2637 "simple" BFD will lay out the object file in the manner suggested
2638 by the PRO ABI for PA-RISC Systems. */
2640 /* Before any output can really begin offsets for all the major
2641 portions of the object file must be computed. So, starting
2642 with the initial file header compute (and sometimes write)
2643 each portion of the object file. */
2645 /* Make room for the file header, it's contents are not complete
2646 yet, so it can not be written at this time. */
2647 current_offset
+= sizeof (struct header
);
2649 /* Any auxiliary headers will follow the file header. Right now
2650 we support only the copyright and version headers. */
2651 obj_som_file_hdr (abfd
)->aux_header_location
= current_offset
;
2652 obj_som_file_hdr (abfd
)->aux_header_size
= 0;
2653 if (obj_som_version_hdr (abfd
) != NULL
)
2657 bfd_seek (abfd
, current_offset
, SEEK_SET
);
2659 /* Write the aux_id structure and the string length. */
2660 len
= sizeof (struct aux_id
) + sizeof (unsigned int);
2661 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
2662 current_offset
+= len
;
2663 if (bfd_write ((PTR
) obj_som_version_hdr (abfd
), len
, 1, abfd
) != len
)
2665 bfd_error
= system_call_error
;
2669 /* Write the version string. */
2670 len
= obj_som_version_hdr (abfd
)->header_id
.length
- sizeof (int);
2671 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
2672 current_offset
+= len
;
2673 if (bfd_write ((PTR
) obj_som_version_hdr (abfd
)->user_string
,
2674 len
, 1, abfd
) != len
)
2676 bfd_error
= system_call_error
;
2681 if (obj_som_copyright_hdr (abfd
) != NULL
)
2685 bfd_seek (abfd
, current_offset
, SEEK_SET
);
2687 /* Write the aux_id structure and the string length. */
2688 len
= sizeof (struct aux_id
) + sizeof (unsigned int);
2689 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
2690 current_offset
+= len
;
2691 if (bfd_write ((PTR
) obj_som_copyright_hdr (abfd
), len
, 1, abfd
) != len
)
2693 bfd_error
= system_call_error
;
2697 /* Write the copyright string. */
2698 len
= obj_som_copyright_hdr (abfd
)->header_id
.length
- sizeof (int);
2699 obj_som_file_hdr (abfd
)->aux_header_size
+= len
;
2700 current_offset
+= len
;
2701 if (bfd_write ((PTR
) obj_som_copyright_hdr (abfd
)->copyright
,
2702 len
, 1, abfd
) != len
)
2704 bfd_error
= system_call_error
;
2709 /* Next comes the initialization pointers; we have no initialization
2710 pointers, so current offset does not change. */
2711 obj_som_file_hdr (abfd
)->init_array_location
= current_offset
;
2712 obj_som_file_hdr (abfd
)->init_array_total
= 0;
2714 /* Next are the space records. These are fixed length records.
2716 Count the number of spaces to determine how much room is needed
2717 in the object file for the space records.
2719 The names of the spaces are stored in a separate string table,
2720 and the index for each space into the string table is computed
2721 below. Therefore, it is not possible to write the space headers
2723 num_spaces
= som_count_spaces (abfd
);
2724 obj_som_file_hdr (abfd
)->space_location
= current_offset
;
2725 obj_som_file_hdr (abfd
)->space_total
= num_spaces
;
2726 current_offset
+= num_spaces
* sizeof (struct space_dictionary_record
);
2728 /* Next are the subspace records. These are fixed length records.
2730 Count the number of subspaes to determine how much room is needed
2731 in the object file for the subspace records.
2733 A variety if fields in the subspace record are still unknown at
2734 this time (index into string table, fixup stream location/size, etc). */
2735 num_subspaces
= som_count_subspaces (abfd
);
2736 obj_som_file_hdr (abfd
)->subspace_location
= current_offset
;
2737 obj_som_file_hdr (abfd
)->subspace_total
= num_subspaces
;
2738 current_offset
+= num_subspaces
* sizeof (struct subspace_dictionary_record
);
2740 /* Next is the string table for the space/subspace names. We will
2741 build and write the string table on the fly. At the same time
2742 we will fill in the space/subspace name index fields. */
2744 /* The string table needs to be aligned on a word boundary. */
2745 if (current_offset
% 4)
2746 current_offset
+= (4 - (current_offset
% 4));
2748 /* Mark the offset of the space/subspace string table in the
2750 obj_som_file_hdr (abfd
)->space_strings_location
= current_offset
;
2752 /* Scribble out the space strings. */
2753 if (som_write_space_strings (abfd
, current_offset
, &strings_size
) == false)
2756 /* Record total string table size in the header and update the
2758 obj_som_file_hdr (abfd
)->space_strings_size
= strings_size
;
2759 current_offset
+= strings_size
;
2761 /* Next is the symbol table. These are fixed length records.
2763 Count the number of symbols to determine how much room is needed
2764 in the object file for the symbol table.
2766 The names of the symbols are stored in a separate string table,
2767 and the index for each symbol name into the string table is computed
2768 below. Therefore, it is not possible to write the symobl table
2770 num_syms
= bfd_get_symcount (abfd
);
2771 obj_som_file_hdr (abfd
)->symbol_location
= current_offset
;
2772 obj_som_file_hdr (abfd
)->symbol_total
= num_syms
;
2773 current_offset
+= num_syms
* sizeof (struct symbol_dictionary_record
);
2775 /* Do prep work before handling fixups. */
2776 som_prep_for_fixups (abfd
, syms
, num_syms
);
2778 /* Next comes the fixup stream which starts on a word boundary. */
2779 if (current_offset
% 4)
2780 current_offset
+= (4 - (current_offset
% 4));
2781 obj_som_file_hdr (abfd
)->fixup_request_location
= current_offset
;
2783 /* Write the fixups and update fields in subspace headers which
2784 relate to the fixup stream. */
2785 if (som_write_fixups (abfd
, current_offset
, &total_reloc_size
) == false)
2788 /* Record the total size of the fixup stream in the file header. */
2789 obj_som_file_hdr (abfd
)->fixup_request_total
= total_reloc_size
;
2790 current_offset
+= total_reloc_size
;
2792 /* Next are the symbol strings.
2793 Align them to a word boundary. */
2794 if (current_offset
% 4)
2795 current_offset
+= (4 - (current_offset
% 4));
2796 obj_som_file_hdr (abfd
)->symbol_strings_location
= current_offset
;
2798 /* Scribble out the symbol strings. */
2799 if (som_write_symbol_strings (abfd
, current_offset
, syms
,
2800 num_syms
, &strings_size
)
2804 /* Record total string table size in header and update the
2806 obj_som_file_hdr (abfd
)->symbol_strings_size
= strings_size
;
2807 current_offset
+= strings_size
;
2809 /* Next is the compiler records. We do not use these. */
2810 obj_som_file_hdr (abfd
)->compiler_location
= current_offset
;
2811 obj_som_file_hdr (abfd
)->compiler_total
= 0;
2813 /* Now compute the file positions for the loadable subspaces. */
2815 section
= abfd
->sections
;
2816 for (i
= 0; i
< num_spaces
; i
++)
2818 asection
*subsection
;
2821 while (som_section_data (section
)->is_space
== 0)
2822 section
= section
->next
;
2824 /* Now look for all its subspaces. */
2825 for (subsection
= abfd
->sections
;
2827 subsection
= subsection
->next
)
2830 if (som_section_data (subsection
)->is_subspace
== 0
2831 || som_section_data (subsection
)->containing_space
!= section
2832 || (subsection
->flags
& SEC_ALLOC
) == 0)
2835 som_section_data (subsection
)->subspace_index
= total_subspaces
++;
2836 /* This is real data to be loaded from the file. */
2837 if (subsection
->flags
& SEC_LOAD
)
2839 som_section_data (subsection
)->subspace_dict
.file_loc_init_value
2841 section
->filepos
= current_offset
;
2842 current_offset
+= bfd_section_size (abfd
, subsection
);
2844 /* Looks like uninitialized data. */
2847 som_section_data (subsection
)->subspace_dict
.file_loc_init_value
2849 som_section_data (subsection
)->subspace_dict
.
2850 initialization_length
= 0;
2853 /* Goto the next section. */
2854 section
= section
->next
;
2857 /* Finally compute the file positions for unloadable subspaces. */
2859 obj_som_file_hdr (abfd
)->unloadable_sp_location
= current_offset
;
2860 section
= abfd
->sections
;
2861 for (i
= 0; i
< num_spaces
; i
++)
2863 asection
*subsection
;
2866 while (som_section_data (section
)->is_space
== 0)
2867 section
= section
->next
;
2869 /* Now look for all its subspaces. */
2870 for (subsection
= abfd
->sections
;
2872 subsection
= subsection
->next
)
2875 if (som_section_data (subsection
)->is_subspace
== 0
2876 || som_section_data (subsection
)->containing_space
!= section
2877 || (subsection
->flags
& SEC_ALLOC
) != 0)
2880 som_section_data (subsection
)->subspace_index
= total_subspaces
++;
2881 /* This is real data to be loaded from the file. */
2882 if ((subsection
->flags
& SEC_LOAD
) == 0)
2884 som_section_data (subsection
)->subspace_dict
.file_loc_init_value
2886 section
->filepos
= current_offset
;
2887 current_offset
+= bfd_section_size (abfd
, subsection
);
2889 /* Looks like uninitialized data. */
2892 som_section_data (subsection
)->subspace_dict
.file_loc_init_value
2894 som_section_data (subsection
)->subspace_dict
.
2895 initialization_length
= bfd_section_size (abfd
, subsection
);
2898 /* Goto the next section. */
2899 section
= section
->next
;
2902 obj_som_file_hdr (abfd
)->unloadable_sp_size
2903 = current_offset
- obj_som_file_hdr (abfd
)->unloadable_sp_location
;
2905 /* Loader fixups are not supported in any way shape or form. */
2906 obj_som_file_hdr (abfd
)->loader_fixup_location
= 0;
2907 obj_som_file_hdr (abfd
)->loader_fixup_total
= 0;
2909 /* Done. Store the total size of the SOM. */
2910 obj_som_file_hdr (abfd
)->som_length
= current_offset
;
2914 /* Finally, scribble out the various headers to the disk. */
2917 som_write_headers (abfd
)
2920 int num_spaces
= som_count_spaces (abfd
);
2922 int subspace_index
= 0;
2926 /* Subspaces are written first so that we can set up information
2927 about them in their containing spaces as the subspace is written. */
2929 /* Seek to the start of the subspace dictionary records. */
2930 location
= obj_som_file_hdr (abfd
)->subspace_location
;
2931 bfd_seek (abfd
, location
, SEEK_SET
);
2932 section
= abfd
->sections
;
2933 /* Now for each loadable space write out records for its subspaces. */
2934 for (i
= 0; i
< num_spaces
; i
++)
2936 asection
*subsection
;
2939 while (som_section_data (section
)->is_space
== 0)
2940 section
= section
->next
;
2942 /* Now look for all its subspaces. */
2943 for (subsection
= abfd
->sections
;
2945 subsection
= subsection
->next
)
2948 /* Skip any section which does not correspond to a space
2949 or subspace. Or does not have SEC_ALLOC set (and therefore
2950 has no real bits on the disk). */
2951 if (som_section_data (subsection
)->is_subspace
== 0
2952 || som_section_data (subsection
)->containing_space
!= section
2953 || (subsection
->flags
& SEC_ALLOC
) == 0)
2956 /* If this is the first subspace for this space, then save
2957 the index of the subspace in its containing space. Also
2958 set "is_loadable" in the containing space. */
2960 if (som_section_data (section
)->space_dict
.subspace_quantity
== 0)
2962 som_section_data (section
)->space_dict
.is_loadable
= 1;
2963 som_section_data (section
)->space_dict
.subspace_index
2967 /* Increment the number of subspaces seen and the number of
2968 subspaces contained within the current space. */
2970 som_section_data (section
)->space_dict
.subspace_quantity
++;
2972 /* Mark the index of the current space within the subspace's
2973 dictionary record. */
2974 som_section_data (subsection
)->subspace_dict
.space_index
= i
;
2976 /* Dump the current subspace header. */
2977 if (bfd_write ((PTR
) &som_section_data (subsection
)->subspace_dict
,
2978 sizeof (struct subspace_dictionary_record
), 1, abfd
)
2979 != sizeof (struct subspace_dictionary_record
))
2981 bfd_error
= system_call_error
;
2985 /* Goto the next section. */
2986 section
= section
->next
;
2989 /* Now repeat the process for unloadable subspaces. */
2990 section
= abfd
->sections
;
2991 /* Now for each space write out records for its subspaces. */
2992 for (i
= 0; i
< num_spaces
; i
++)
2994 asection
*subsection
;
2997 while (som_section_data (section
)->is_space
== 0)
2998 section
= section
->next
;
3000 /* Now look for all its subspaces. */
3001 for (subsection
= abfd
->sections
;
3003 subsection
= subsection
->next
)
3006 /* Skip any section which does not correspond to a space or
3007 subspace, or which SEC_ALLOC set (and therefore handled
3008 in the loadable spaces/subspaces code above. */
3010 if (som_section_data (subsection
)->is_subspace
== 0
3011 || som_section_data (subsection
)->containing_space
!= section
3012 || (subsection
->flags
& SEC_ALLOC
) != 0)
3015 /* If this is the first subspace for this space, then save
3016 the index of the subspace in its containing space. Clear
3019 if (som_section_data (section
)->space_dict
.subspace_quantity
== 0)
3021 som_section_data (section
)->space_dict
.is_loadable
= 0;
3022 som_section_data (section
)->space_dict
.subspace_index
3026 /* Increment the number of subspaces seen and the number of
3027 subspaces contained within the current space. */
3028 som_section_data (section
)->space_dict
.subspace_quantity
++;
3031 /* Mark the index of the current space within the subspace's
3032 dictionary record. */
3033 som_section_data (subsection
)->subspace_dict
.space_index
= i
;
3035 /* Dump this subspace header. */
3036 if (bfd_write ((PTR
) &som_section_data (subsection
)->subspace_dict
,
3037 sizeof (struct subspace_dictionary_record
), 1, abfd
)
3038 != sizeof (struct subspace_dictionary_record
))
3040 bfd_error
= system_call_error
;
3044 /* Goto the next section. */
3045 section
= section
->next
;
3048 /* All the subspace dictiondary records are written, and all the
3049 fields are set up in the space dictionary records.
3051 Seek to the right location and start writing the space
3052 dictionary records. */
3053 location
= obj_som_file_hdr (abfd
)->space_location
;
3054 bfd_seek (abfd
, location
, SEEK_SET
);
3056 section
= abfd
->sections
;
3057 for (i
= 0; i
< num_spaces
; i
++)
3061 while (som_section_data (section
)->is_space
== 0)
3062 section
= section
->next
;
3064 /* Dump its header */
3065 if (bfd_write ((PTR
) &som_section_data (section
)->space_dict
,
3066 sizeof (struct space_dictionary_record
), 1, abfd
)
3067 != sizeof (struct space_dictionary_record
))
3069 bfd_error
= system_call_error
;
3073 /* Goto the next section. */
3074 section
= section
->next
;
3077 /* Only thing left to do is write out the file header. It is always
3078 at location zero. Seek there and write it. */
3079 bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
);
3080 if (bfd_write ((PTR
) obj_som_file_hdr (abfd
),
3081 sizeof (struct header
), 1, abfd
)
3082 != sizeof (struct header
))
3084 bfd_error
= system_call_error
;
3090 /* Compute and return the checksum for a SOM file header. */
3092 static unsigned long
3093 som_compute_checksum (abfd
)
3096 unsigned long checksum
, count
, i
;
3097 unsigned long *buffer
= (unsigned long *) obj_som_file_hdr (abfd
);
3100 count
= sizeof (struct header
) / sizeof (unsigned long);
3101 for (i
= 0; i
< count
; i
++)
3102 checksum
^= *(buffer
+ i
);
3108 som_bfd_derive_misc_symbol_info (abfd
, sym
, info
)
3111 struct som_misc_symbol_info
*info
;
3114 memset (info
, 0, sizeof (struct som_misc_symbol_info
));
3116 /* The HP SOM linker requires detailed type information about
3117 all symbols (including undefined symbols!). Unfortunately,
3118 the type specified in an import/export statement does not
3119 always match what the linker wants. Severe braindamage. */
3121 /* Section symbols will not have a SOM symbol type assigned to
3122 them yet. Assign all section symbols type ST_DATA. */
3123 if (sym
->flags
& BSF_SECTION_SYM
)
3124 info
->symbol_type
= ST_DATA
;
3127 /* Common symbols must have scope SS_UNSAT and type
3128 ST_STORAGE or the linker will choke. */
3129 if (sym
->section
== &bfd_com_section
)
3131 info
->symbol_scope
= SS_UNSAT
;
3132 info
->symbol_type
= ST_STORAGE
;
3135 /* It is possible to have a symbol without an associated
3136 type. This happens if the user imported the symbol
3137 without a type and the symbol was never defined
3138 locally. If BSF_FUNCTION is set for this symbol, then
3139 assign it type ST_CODE (the HP linker requires undefined
3140 external functions to have type ST_CODE rather than ST_ENTRY). */
3141 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
3142 && sym
->section
== &bfd_und_section
3143 && sym
->flags
& BSF_FUNCTION
)
3144 info
->symbol_type
= ST_CODE
;
3146 /* Handle function symbols which were defined in this file.
3147 They should have type ST_ENTRY. Also retrieve the argument
3148 relocation bits from the SOM backend information. */
3149 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_ENTRY
3150 || (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_CODE
3151 && (sym
->flags
& BSF_FUNCTION
))
3152 || (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
3153 && (sym
->flags
& BSF_FUNCTION
)))
3155 info
->symbol_type
= ST_ENTRY
;
3156 info
->arg_reloc
= som_symbol_data (sym
)->tc_data
.hppa_arg_reloc
;
3159 /* If the type is unknown at this point, it should be
3160 ST_DATA (functions were handled as special cases above). */
3161 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_UNKNOWN
)
3162 info
->symbol_type
= ST_DATA
;
3164 /* From now on it's a very simple mapping. */
3165 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_ABSOLUTE
)
3166 info
->symbol_type
= ST_ABSOLUTE
;
3167 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_CODE
)
3168 info
->symbol_type
= ST_CODE
;
3169 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_DATA
)
3170 info
->symbol_type
= ST_DATA
;
3171 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_MILLICODE
)
3172 info
->symbol_type
= ST_MILLICODE
;
3173 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_PLABEL
)
3174 info
->symbol_type
= ST_PLABEL
;
3175 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_PRI_PROG
)
3176 info
->symbol_type
= ST_PRI_PROG
;
3177 else if (som_symbol_data (sym
)->som_type
== SYMBOL_TYPE_SEC_PROG
)
3178 info
->symbol_type
= ST_SEC_PROG
;
3181 /* Now handle the symbol's scope. Exported data which is not
3182 in the common section has scope SS_UNIVERSAL. Note scope
3183 of common symbols was handled earlier! */
3184 if (sym
->flags
& BSF_EXPORT
&& sym
->section
!= &bfd_com_section
)
3185 info
->symbol_scope
= SS_UNIVERSAL
;
3186 /* Any undefined symbol at this point has a scope SS_UNSAT. */
3187 else if (sym
->section
== &bfd_und_section
)
3188 info
->symbol_scope
= SS_UNSAT
;
3189 /* Anything else which is not in the common section has scope
3191 else if (sym
->section
!= &bfd_com_section
)
3192 info
->symbol_scope
= SS_LOCAL
;
3194 /* Now set the symbol_info field. It has no real meaning
3195 for undefined or common symbols, but the HP linker will
3196 choke if it's not set to some "reasonable" value. We
3197 use zero as a reasonable value. */
3198 if (sym
->section
== &bfd_com_section
|| sym
->section
== &bfd_und_section
)
3199 info
->symbol_info
= 0;
3200 /* For all other symbols, the symbol_info field contains the
3201 subspace index of the space this symbol is contained in. */
3203 info
->symbol_info
= som_section_data (sym
->section
)->subspace_index
;
3205 /* Set the symbol's value. */
3206 info
->symbol_value
= sym
->value
+ sym
->section
->vma
;
3209 /* Build and write, in one big chunk, the entire symbol table for
3213 som_build_and_write_symbol_table (abfd
)
3216 unsigned int num_syms
= bfd_get_symcount (abfd
);
3217 file_ptr symtab_location
= obj_som_file_hdr (abfd
)->symbol_location
;
3218 asymbol
**bfd_syms
= bfd_get_outsymbols (abfd
);
3219 struct symbol_dictionary_record
*som_symtab
;
3222 /* Compute total symbol table size and allocate a chunk of memory
3223 to hold the symbol table as we build it. */
3224 symtab_size
= num_syms
* sizeof (struct symbol_dictionary_record
);
3225 som_symtab
= (struct symbol_dictionary_record
*) alloca (symtab_size
);
3226 memset (som_symtab
, 0, symtab_size
);
3228 /* Walk over each symbol. */
3229 for (i
= 0; i
< num_syms
; i
++)
3231 struct som_misc_symbol_info info
;
3233 /* This is really an index into the symbol strings table.
3234 By the time we get here, the index has already been
3235 computed and stored into the name field in the BFD symbol. */
3236 som_symtab
[i
].name
.n_strx
= (int) bfd_syms
[i
]->name
;
3238 /* Derive SOM information from the BFD symbol. */
3239 som_bfd_derive_misc_symbol_info (abfd
, bfd_syms
[i
], &info
);
3242 som_symtab
[i
].symbol_type
= info
.symbol_type
;
3243 som_symtab
[i
].symbol_scope
= info
.symbol_scope
;
3244 som_symtab
[i
].arg_reloc
= info
.arg_reloc
;
3245 som_symtab
[i
].symbol_info
= info
.symbol_info
;
3246 som_symtab
[i
].symbol_value
= info
.symbol_value
;
3249 /* Everything is ready, seek to the right location and
3250 scribble out the symbol table. */
3251 if (bfd_seek (abfd
, symtab_location
, SEEK_SET
) != 0)
3253 bfd_error
= system_call_error
;
3257 if (bfd_write ((PTR
) som_symtab
, symtab_size
, 1, abfd
) != symtab_size
)
3259 bfd_error
= system_call_error
;
3265 /* Write an object in SOM format. */
3268 som_write_object_contents (abfd
)
3271 if (abfd
->output_has_begun
== false)
3273 /* Set up fixed parts of the file, space, and subspace headers.
3274 Notify the world that output has begun. */
3275 som_prep_headers (abfd
);
3276 abfd
->output_has_begun
= true;
3277 /* Start writing the object file. This include all the string
3278 tables, fixup streams, and other portions of the object file. */
3279 som_begin_writing (abfd
);
3282 /* Now that the symbol table information is complete, build and
3283 write the symbol table. */
3284 if (som_build_and_write_symbol_table (abfd
) == false)
3287 /* Compute the checksum for the file header just before writing
3288 the header to disk. */
3289 obj_som_file_hdr (abfd
)->checksum
= som_compute_checksum (abfd
);
3290 return (som_write_headers (abfd
));
3294 /* Read and save the string table associated with the given BFD. */
3297 som_slurp_string_table (abfd
)
3302 /* Use the saved version if its available. */
3303 if (obj_som_stringtab (abfd
) != NULL
)
3306 /* Allocate and read in the string table. */
3307 stringtab
= bfd_zalloc (abfd
, obj_som_stringtab_size (abfd
));
3308 if (stringtab
== NULL
)
3310 bfd_error
= no_memory
;
3314 if (bfd_seek (abfd
, obj_som_str_filepos (abfd
), SEEK_SET
) < 0)
3316 bfd_error
= system_call_error
;
3320 if (bfd_read (stringtab
, obj_som_stringtab_size (abfd
), 1, abfd
)
3321 != obj_som_stringtab_size (abfd
))
3323 bfd_error
= system_call_error
;
3327 /* Save our results and return success. */
3328 obj_som_stringtab (abfd
) = stringtab
;
3332 /* Return the amount of data (in bytes) required to hold the symbol
3333 table for this object. */
3336 som_get_symtab_upper_bound (abfd
)
3339 if (!som_slurp_symbol_table (abfd
))
3342 return (bfd_get_symcount (abfd
) + 1) * (sizeof (som_symbol_type
*));
3345 /* Convert from a SOM subspace index to a BFD section. */
3348 som_section_from_subspace_index (abfd
, index
)
3354 for (section
= abfd
->sections
; section
!= NULL
; section
= section
->next
)
3355 if (som_section_data (section
)->subspace_index
== index
)
3358 /* Should never happen. */
3362 /* Read and save the symbol table associated with the given BFD. */
3365 som_slurp_symbol_table (abfd
)
3368 int symbol_count
= bfd_get_symcount (abfd
);
3369 int symsize
= sizeof (struct symbol_dictionary_record
);
3371 struct symbol_dictionary_record
*buf
, *bufp
, *endbufp
;
3372 som_symbol_type
*sym
, *symbase
;
3374 /* Return saved value if it exists. */
3375 if (obj_som_symtab (abfd
) != NULL
)
3378 /* Sanity checking. Make sure there are some symbols and that
3379 we can read the string table too. */
3380 if (symbol_count
== 0)
3382 bfd_error
= no_symbols
;
3386 if (!som_slurp_string_table (abfd
))
3389 stringtab
= obj_som_stringtab (abfd
);
3391 symbase
= (som_symbol_type
*)
3392 bfd_zalloc (abfd
, symbol_count
* sizeof (som_symbol_type
));
3393 if (symbase
== NULL
)
3395 bfd_error
= no_memory
;
3399 /* Read in the external SOM representation. */
3400 buf
= alloca (symbol_count
* symsize
);
3403 bfd_error
= no_memory
;
3406 if (bfd_seek (abfd
, obj_som_sym_filepos (abfd
), SEEK_SET
) < 0)
3408 bfd_error
= system_call_error
;
3411 if (bfd_read (buf
, symbol_count
* symsize
, 1, abfd
)
3412 != symbol_count
* symsize
)
3414 bfd_error
= no_symbols
;
3418 /* Iterate over all the symbols and internalize them. */
3419 endbufp
= buf
+ symbol_count
;
3420 for (bufp
= buf
, sym
= symbase
; bufp
< endbufp
; ++bufp
)
3423 /* I don't think we care about these. */
3424 if (bufp
->symbol_type
== ST_SYM_EXT
3425 || bufp
->symbol_type
== ST_ARG_EXT
)
3428 /* Set some private data we care about. */
3429 if (bufp
->symbol_type
== ST_NULL
)
3430 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_UNKNOWN
;
3431 else if (bufp
->symbol_type
== ST_ABSOLUTE
)
3432 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_ABSOLUTE
;
3433 else if (bufp
->symbol_type
== ST_DATA
)
3434 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_DATA
;
3435 else if (bufp
->symbol_type
== ST_CODE
)
3436 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_CODE
;
3437 else if (bufp
->symbol_type
== ST_PRI_PROG
)
3438 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_PRI_PROG
;
3439 else if (bufp
->symbol_type
== ST_SEC_PROG
)
3440 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_SEC_PROG
;
3441 else if (bufp
->symbol_type
== ST_ENTRY
)
3442 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_ENTRY
;
3443 else if (bufp
->symbol_type
== ST_MILLICODE
)
3444 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_MILLICODE
;
3445 else if (bufp
->symbol_type
== ST_PLABEL
)
3446 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_PLABEL
;
3448 som_symbol_data (sym
)->som_type
= SYMBOL_TYPE_UNKNOWN
;
3449 som_symbol_data (sym
)->tc_data
.hppa_arg_reloc
= bufp
->arg_reloc
;
3451 /* Some reasonable defaults. */
3452 sym
->symbol
.the_bfd
= abfd
;
3453 sym
->symbol
.name
= bufp
->name
.n_strx
+ stringtab
;
3454 sym
->symbol
.value
= bufp
->symbol_value
;
3455 sym
->symbol
.section
= 0;
3456 sym
->symbol
.flags
= 0;
3458 switch (bufp
->symbol_type
)
3464 sym
->symbol
.flags
|= BSF_FUNCTION
;
3465 sym
->symbol
.value
&= ~0x3;
3470 sym
->symbol
.value
&= ~0x3;
3476 /* Handle scoping and section information. */
3477 switch (bufp
->symbol_scope
)
3479 /* symbol_info field is undefined for SS_EXTERNAL and SS_UNSAT symbols,
3480 so the section associated with this symbol can't be known. */
3483 if (bufp
->symbol_type
!= ST_STORAGE
)
3484 sym
->symbol
.section
= &bfd_und_section
;
3486 sym
->symbol
.section
= &bfd_com_section
;
3487 sym
->symbol
.flags
|= (BSF_EXPORT
| BSF_GLOBAL
);
3491 sym
->symbol
.flags
|= (BSF_EXPORT
| BSF_GLOBAL
);
3493 = som_section_from_subspace_index (abfd
, bufp
->symbol_info
);
3494 sym
->symbol
.value
-= sym
->symbol
.section
->vma
;
3498 /* SS_GLOBAL and SS_LOCAL are two names for the same thing.
3499 Sound dumb? It is. */
3503 sym
->symbol
.flags
|= BSF_LOCAL
;
3505 = som_section_from_subspace_index (abfd
, bufp
->symbol_info
);
3506 sym
->symbol
.value
-= sym
->symbol
.section
->vma
;
3510 /* Mark symbols left around by the debugger. */
3511 if (strlen (sym
->symbol
.name
) >= 2
3512 && sym
->symbol
.name
[0] == 'L'
3513 && (sym
->symbol
.name
[1] == '$' || sym
->symbol
.name
[2] == '$'
3514 || sym
->symbol
.name
[3] == '$'))
3515 sym
->symbol
.flags
|= BSF_DEBUGGING
;
3517 /* Note increment at bottom of loop, since we skip some symbols
3518 we can not include it as part of the for statement. */
3522 /* Save our results and return success. */
3523 obj_som_symtab (abfd
) = symbase
;
3527 /* Canonicalize a SOM symbol table. Return the number of entries
3528 in the symbol table. */
3531 som_get_symtab (abfd
, location
)
3536 som_symbol_type
*symbase
;
3538 if (!som_slurp_symbol_table (abfd
))
3541 i
= bfd_get_symcount (abfd
);
3542 symbase
= obj_som_symtab (abfd
);
3544 for (; i
> 0; i
--, location
++, symbase
++)
3545 *location
= &symbase
->symbol
;
3547 /* Final null pointer. */
3549 return (bfd_get_symcount (abfd
));
3552 /* Make a SOM symbol. There is nothing special to do here. */
3555 som_make_empty_symbol (abfd
)
3558 som_symbol_type
*new =
3559 (som_symbol_type
*) bfd_zalloc (abfd
, sizeof (som_symbol_type
));
3562 bfd_error
= no_memory
;
3565 new->symbol
.the_bfd
= abfd
;
3567 return &new->symbol
;
3570 /* Print symbol information. */
3573 som_print_symbol (ignore_abfd
, afile
, symbol
, how
)
3577 bfd_print_symbol_type how
;
3579 FILE *file
= (FILE *) afile
;
3582 case bfd_print_symbol_name
:
3583 fprintf (file
, "%s", symbol
->name
);
3585 case bfd_print_symbol_more
:
3586 fprintf (file
, "som ");
3587 fprintf_vma (file
, symbol
->value
);
3588 fprintf (file
, " %lx", (long) symbol
->flags
);
3590 case bfd_print_symbol_all
:
3592 CONST
char *section_name
;
3593 section_name
= symbol
->section
? symbol
->section
->name
: "(*none*)";
3594 bfd_print_symbol_vandf ((PTR
) file
, symbol
);
3595 fprintf (file
, " %s\t%s", section_name
, symbol
->name
);
3601 /* Count or process variable-length SOM fixup records.
3603 To avoid code duplication we use this code both to compute the number
3604 of relocations requested by a stream, and to internalize the stream.
3606 When computing the number of relocations requested by a stream the
3607 variables rptr, section, and symbols have no meaning.
3609 Return the number of relocations requested by the fixup stream. When
3612 This needs at least two or three more passes to get it cleaned up. */
3615 som_set_reloc_info (fixup
, end
, internal_relocs
, section
, symbols
, just_count
)
3616 unsigned char *fixup
;
3618 arelent
*internal_relocs
;
3623 unsigned int op
, varname
;
3624 unsigned char *end_fixups
= &fixup
[end
];
3625 const struct fixup_format
*fp
;
3627 unsigned char *save_fixup
;
3628 int variables
[26], stack
[20], c
, v
, count
, prev_fixup
, *sp
;
3630 arelent
*rptr
= internal_relocs
;
3631 unsigned int offset
= just_count
? 0 : section
->vma
;
3633 #define var(c) variables[(c) - 'A']
3634 #define push(v) (*sp++ = (v))
3635 #define pop() (*--sp)
3636 #define emptystack() (sp == stack)
3638 som_initialize_reloc_queue (reloc_queue
);
3639 memset (variables
, 0, sizeof (variables
));
3640 memset (stack
, 0, sizeof (stack
));
3645 while (fixup
< end_fixups
)
3648 /* Save pointer to the start of this fixup. We'll use
3649 it later to determine if it is necessary to put this fixup
3653 /* Get the fixup code and its associated format. */
3655 fp
= &som_fixup_formats
[op
];
3657 /* Handle a request for a previous fixup. */
3658 if (*fp
->format
== 'P')
3660 /* Get pointer to the beginning of the prev fixup, move
3661 the repeated fixup to the head of the queue. */
3662 fixup
= reloc_queue
[fp
->D
].reloc
;
3663 som_reloc_queue_fix (reloc_queue
, fp
->D
);
3666 /* Get the fixup code and its associated format. */
3668 fp
= &som_fixup_formats
[op
];
3671 /* If we are not just counting, set some reasonable defaults. */
3674 rptr
->address
= offset
;
3675 rptr
->howto
= &som_hppa_howto_table
[op
];
3677 rptr
->sym_ptr_ptr
= bfd_abs_section
.symbol_ptr_ptr
;
3680 /* Set default input length to 0. Get the opcode class index
3685 /* Get the opcode format. */
3688 /* Process the format string. Parsing happens in two phases,
3689 parse RHS, then assign to LHS. Repeat until no more
3690 characters in the format string. */
3693 /* The variable this pass is going to compute a value for. */
3696 /* Start processing RHS. Continue until a NULL or '=' is found. */
3701 /* If this is a variable, push it on the stack. */
3705 /* If this is a lower case letter, then it represents
3706 additional data from the fixup stream to be pushed onto
3708 else if (islower (c
))
3710 for (v
= 0; c
> 'a'; --c
)
3711 v
= (v
<< 8) | *fixup
++;
3715 /* A decimal constant. Push it on the stack. */
3716 else if (isdigit (c
))
3719 while (isdigit (*cp
))
3720 v
= (v
* 10) + (*cp
++ - '0');
3725 /* An operator. Pop two two values from the stack and
3726 use them as operands to the given operation. Push
3727 the result of the operation back on the stack. */
3749 while (*cp
&& *cp
!= '=');
3751 /* Move over the equal operator. */
3754 /* Pop the RHS off the stack. */
3757 /* Perform the assignment. */
3760 /* Handle side effects. and special 'O' stack cases. */
3763 /* Consume some bytes from the input space. */
3767 /* A symbol to use in the relocation. Make a note
3768 of this if we are not just counting. */
3771 rptr
->sym_ptr_ptr
= &symbols
[c
];
3773 /* Handle the linker expression stack. */
3778 subop
= comp1_opcodes
;
3781 subop
= comp2_opcodes
;
3784 subop
= comp3_opcodes
;
3789 while (*subop
<= (unsigned char) c
)
3798 /* If we used a previous fixup, clean up after it. */
3801 fixup
= save_fixup
+ 1;
3805 else if (fixup
> save_fixup
+ 1)
3806 som_reloc_queue_insert (save_fixup
, fixup
- save_fixup
, reloc_queue
);
3808 /* We do not pass R_DATA_OVERRIDE or R_NO_RELOCATION
3810 if (som_hppa_howto_table
[op
].type
!= R_DATA_OVERRIDE
3811 && som_hppa_howto_table
[op
].type
!= R_NO_RELOCATION
)
3813 /* Done with a single reloction. Loop back to the top. */
3816 rptr
->addend
= var ('V');
3820 /* Now that we've handled a "full" relocation, reset
3822 memset (variables
, 0, sizeof (variables
));
3823 memset (stack
, 0, sizeof (stack
));
3834 /* Read in the relocs (aka fixups in SOM terms) for a section.
3836 som_get_reloc_upper_bound calls this routine with JUST_COUNT
3837 set to true to indicate it only needs a count of the number
3838 of actual relocations. */
3841 som_slurp_reloc_table (abfd
, section
, symbols
, just_count
)
3847 char *external_relocs
;
3848 unsigned int fixup_stream_size
;
3849 arelent
*internal_relocs
;
3850 unsigned int num_relocs
;
3852 fixup_stream_size
= som_section_data (section
)->reloc_size
;
3853 /* If there were no relocations, then there is nothing to do. */
3854 if (section
->reloc_count
== 0)
3857 /* If reloc_count is -1, then the relocation stream has not been
3858 parsed. We must do so now to know how many relocations exist. */
3859 if (section
->reloc_count
== -1)
3861 external_relocs
= (char *) bfd_zalloc (abfd
, fixup_stream_size
);
3862 if (external_relocs
== (char *) NULL
)
3864 bfd_error
= no_memory
;
3867 /* Read in the external forms. */
3869 obj_som_reloc_filepos (abfd
) + section
->rel_filepos
,
3873 bfd_error
= system_call_error
;
3876 if (bfd_read (external_relocs
, 1, fixup_stream_size
, abfd
)
3877 != fixup_stream_size
)
3879 bfd_error
= system_call_error
;
3882 /* Let callers know how many relocations found.
3883 also save the relocation stream as we will
3885 section
->reloc_count
= som_set_reloc_info (external_relocs
,
3887 NULL
, NULL
, NULL
, true);
3889 som_section_data (section
)->reloc_stream
= external_relocs
;
3892 /* If the caller only wanted a count, then return now. */
3896 num_relocs
= section
->reloc_count
;
3897 external_relocs
= som_section_data (section
)->reloc_stream
;
3898 /* Return saved information about the relocations if it is available. */
3899 if (section
->relocation
!= (arelent
*) NULL
)
3902 internal_relocs
= (arelent
*) bfd_zalloc (abfd
,
3903 num_relocs
* sizeof (arelent
));
3904 if (internal_relocs
== (arelent
*) NULL
)
3906 bfd_error
= no_memory
;
3910 /* Process and internalize the relocations. */
3911 som_set_reloc_info (external_relocs
, fixup_stream_size
,
3912 internal_relocs
, section
, symbols
, false);
3914 /* Save our results and return success. */
3915 section
->relocation
= internal_relocs
;
3919 /* Return the number of bytes required to store the relocation
3920 information associated with the given section. */
3923 som_get_reloc_upper_bound (abfd
, asect
)
3927 /* If section has relocations, then read in the relocation stream
3928 and parse it to determine how many relocations exist. */
3929 if (asect
->flags
& SEC_RELOC
)
3931 if (som_slurp_reloc_table (abfd
, asect
, NULL
, true))
3932 return (asect
->reloc_count
+ 1) * sizeof (arelent
);
3934 /* Either there are no relocations or an error occurred while
3935 reading and parsing the relocation stream. */
3939 /* Convert relocations from SOM (external) form into BFD internal
3940 form. Return the number of relocations. */
3943 som_canonicalize_reloc (abfd
, section
, relptr
, symbols
)
3952 if (som_slurp_reloc_table (abfd
, section
, symbols
, false) == false)
3955 count
= section
->reloc_count
;
3956 tblptr
= section
->relocation
;
3957 if (tblptr
== (arelent
*) NULL
)
3961 *relptr
++ = tblptr
++;
3963 *relptr
= (arelent
*) NULL
;
3964 return section
->reloc_count
;
3967 extern bfd_target som_vec
;
3969 /* A hook to set up object file dependent section information. */
3972 som_new_section_hook (abfd
, newsect
)
3976 newsect
->used_by_bfd
=
3977 (PTR
) bfd_zalloc (abfd
, sizeof (struct som_section_data_struct
));
3978 if (!newsect
->used_by_bfd
)
3980 bfd_error
= no_memory
;
3983 newsect
->alignment_power
= 3;
3985 /* Initialize the subspace_index field to -1 so that it does
3986 not match a subspace with an index of 0. */
3987 som_section_data (newsect
)->subspace_index
= -1;
3989 /* We allow more than three sections internally */
3993 /* Set backend info for sections which can not be described
3994 in the BFD data structures. */
3997 bfd_som_set_section_attributes (section
, defined
, private, sort_key
, spnum
)
4001 unsigned char sort_key
;
4004 struct space_dictionary_record
*space_dict
;
4006 som_section_data (section
)->is_space
= 1;
4007 space_dict
= &som_section_data (section
)->space_dict
;
4008 space_dict
->is_defined
= defined
;
4009 space_dict
->is_private
= private;
4010 space_dict
->sort_key
= sort_key
;
4011 space_dict
->space_number
= spnum
;
4014 /* Set backend info for subsections which can not be described
4015 in the BFD data structures. */
4018 bfd_som_set_subsection_attributes (section
, container
, access
,
4021 asection
*container
;
4023 unsigned int sort_key
;
4026 struct subspace_dictionary_record
*subspace_dict
;
4027 som_section_data (section
)->is_subspace
= 1;
4028 subspace_dict
= &som_section_data (section
)->subspace_dict
;
4029 subspace_dict
->access_control_bits
= access
;
4030 subspace_dict
->sort_key
= sort_key
;
4031 subspace_dict
->quadrant
= quadrant
;
4032 som_section_data (section
)->containing_space
= container
;
4035 /* Set the full SOM symbol type. SOM needs far more symbol information
4036 than any other object file format I'm aware of. It is mandatory
4037 to be able to know if a symbol is an entry point, millicode, data,
4038 code, absolute, storage request, or procedure label. If you get
4039 the symbol type wrong your program will not link. */
4042 bfd_som_set_symbol_type (symbol
, type
)
4046 som_symbol_data (symbol
)->som_type
= type
;
4049 /* Attach 64bits of unwind information to a symbol (which hopefully
4050 is a function of some kind!). It would be better to keep this
4051 in the R_ENTRY relocation, but there is not enough space. */
4054 bfd_som_attach_unwind_info (symbol
, unwind_desc
)
4058 som_symbol_data (symbol
)->unwind
= unwind_desc
;
4061 /* Attach an auxiliary header to the BFD backend so that it may be
4062 written into the object file. */
4064 bfd_som_attach_aux_hdr (abfd
, type
, string
)
4069 if (type
== VERSION_AUX_ID
)
4071 int len
= strlen (string
);
4075 pad
= (4 - (len
% 4));
4076 obj_som_version_hdr (abfd
) = (struct user_string_aux_hdr
*)
4077 bfd_zalloc (abfd
, sizeof (struct aux_id
)
4078 + sizeof (unsigned int) + len
+ pad
);
4079 if (!obj_som_version_hdr (abfd
))
4081 bfd_error
= no_memory
;
4082 abort(); /* FIXME */
4084 obj_som_version_hdr (abfd
)->header_id
.type
= VERSION_AUX_ID
;
4085 obj_som_version_hdr (abfd
)->header_id
.length
= len
+ pad
;
4086 obj_som_version_hdr (abfd
)->header_id
.length
+= sizeof (int);
4087 obj_som_version_hdr (abfd
)->string_length
= len
;
4088 strncpy (obj_som_version_hdr (abfd
)->user_string
, string
, len
);
4090 else if (type
== COPYRIGHT_AUX_ID
)
4092 int len
= strlen (string
);
4096 pad
= (4 - (len
% 4));
4097 obj_som_copyright_hdr (abfd
) = (struct copyright_aux_hdr
*)
4098 bfd_zalloc (abfd
, sizeof (struct aux_id
)
4099 + sizeof (unsigned int) + len
+ pad
);
4100 if (!obj_som_copyright_hdr (abfd
))
4102 bfd_error
= no_error
;
4103 abort(); /* FIXME */
4105 obj_som_copyright_hdr (abfd
)->header_id
.type
= COPYRIGHT_AUX_ID
;
4106 obj_som_copyright_hdr (abfd
)->header_id
.length
= len
+ pad
;
4107 obj_som_copyright_hdr (abfd
)->header_id
.length
+= sizeof (int);
4108 obj_som_copyright_hdr (abfd
)->string_length
= len
;
4109 strcpy (obj_som_copyright_hdr (abfd
)->copyright
, string
);
4116 som_set_section_contents (abfd
, section
, location
, offset
, count
)
4121 bfd_size_type count
;
4123 if (abfd
->output_has_begun
== false)
4125 /* Set up fixed parts of the file, space, and subspace headers.
4126 Notify the world that output has begun. */
4127 som_prep_headers (abfd
);
4128 abfd
->output_has_begun
= true;
4129 /* Start writing the object file. This include all the string
4130 tables, fixup streams, and other portions of the object file. */
4131 som_begin_writing (abfd
);
4134 /* Only write subspaces which have "real" contents (eg. the contents
4135 are not generated at run time by the OS). */
4136 if (som_section_data (section
)->is_subspace
!= 1
4137 || ((section
->flags
& (SEC_LOAD
| SEC_DEBUGGING
)) == 0))
4140 /* Seek to the proper offset within the object file and write the
4142 offset
+= som_section_data (section
)->subspace_dict
.file_loc_init_value
;
4143 if (bfd_seek (abfd
, offset
, SEEK_SET
) == -1)
4145 bfd_error
= system_call_error
;
4149 if (bfd_write ((PTR
) location
, 1, count
, abfd
) != count
)
4151 bfd_error
= system_call_error
;
4158 som_set_arch_mach (abfd
, arch
, machine
)
4160 enum bfd_architecture arch
;
4161 unsigned long machine
;
4163 /* Allow any architecture to be supported by the SOM backend */
4164 return bfd_default_set_arch_mach (abfd
, arch
, machine
);
4168 som_find_nearest_line (abfd
, section
, symbols
, offset
, filename_ptr
,
4169 functionname_ptr
, line_ptr
)
4174 CONST
char **filename_ptr
;
4175 CONST
char **functionname_ptr
;
4176 unsigned int *line_ptr
;
4178 fprintf (stderr
, "som_find_nearest_line unimplemented\n");
4185 som_sizeof_headers (abfd
, reloc
)
4189 fprintf (stderr
, "som_sizeof_headers unimplemented\n");
4195 /* Return the single-character symbol type corresponding to
4196 SOM section S, or '?' for an unknown SOM section. */
4199 som_section_type (s
)
4202 const struct section_to_type
*t
;
4204 for (t
= &stt
[0]; t
->section
; t
++)
4205 if (!strcmp (s
, t
->section
))
4211 som_decode_symclass (symbol
)
4216 if (bfd_is_com_section (symbol
->section
))
4218 if (symbol
->section
== &bfd_und_section
)
4220 if (symbol
->section
== &bfd_ind_section
)
4222 if (!(symbol
->flags
& (BSF_GLOBAL
|BSF_LOCAL
)))
4225 if (symbol
->section
== &bfd_abs_section
)
4227 else if (symbol
->section
)
4228 c
= som_section_type (symbol
->section
->name
);
4231 if (symbol
->flags
& BSF_GLOBAL
)
4236 /* Return information about SOM symbol SYMBOL in RET. */
4239 som_get_symbol_info (ignore_abfd
, symbol
, ret
)
4244 ret
->type
= som_decode_symclass (symbol
);
4245 if (ret
->type
!= 'U')
4246 ret
->value
= symbol
->value
+symbol
->section
->vma
;
4249 ret
->name
= symbol
->name
;
4252 /* Count the number of symbols in the archive symbol table. Necessary
4253 so that we can allocate space for all the carsyms at once. */
4256 som_bfd_count_ar_symbols (abfd
, lst_header
, count
)
4258 struct lst_header
*lst_header
;
4262 unsigned int hash_table
[lst_header
->hash_size
];
4263 file_ptr lst_filepos
= bfd_tell (abfd
) - sizeof (struct lst_header
);
4265 /* Don't forget to initialize the counter! */
4268 /* Read in the hash table. The has table is an array of 32bit file offsets
4269 which point to the hash chains. */
4270 if (bfd_read ((PTR
) hash_table
, lst_header
->hash_size
, 4, abfd
)
4271 != lst_header
->hash_size
* 4)
4273 bfd_error
= system_call_error
;
4277 /* Walk each chain counting the number of symbols found on that particular
4279 for (i
= 0; i
< lst_header
->hash_size
; i
++)
4281 struct lst_symbol_record lst_symbol
;
4283 /* An empty chain has zero as it's file offset. */
4284 if (hash_table
[i
] == 0)
4287 /* Seek to the first symbol in this hash chain. */
4288 if (bfd_seek (abfd
, lst_filepos
+ hash_table
[i
], SEEK_SET
) < 0)
4290 bfd_error
= system_call_error
;
4294 /* Read in this symbol and update the counter. */
4295 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
4296 != sizeof (lst_symbol
))
4298 bfd_error
= system_call_error
;
4303 /* Now iterate through the rest of the symbols on this chain. */
4304 while (lst_symbol
.next_entry
)
4307 /* Seek to the next symbol. */
4308 if (bfd_seek (abfd
, lst_filepos
+ lst_symbol
.next_entry
, SEEK_SET
)
4311 bfd_error
= system_call_error
;
4315 /* Read the symbol in and update the counter. */
4316 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
4317 != sizeof (lst_symbol
))
4319 bfd_error
= system_call_error
;
4328 /* Fill in the canonical archive symbols (SYMS) from the archive described
4329 by ABFD and LST_HEADER. */
4332 som_bfd_fill_in_ar_symbols (abfd
, lst_header
, syms
)
4334 struct lst_header
*lst_header
;
4337 unsigned int i
, len
;
4338 carsym
*set
= syms
[0];
4339 unsigned int hash_table
[lst_header
->hash_size
];
4340 struct som_entry som_dict
[lst_header
->module_count
];
4341 file_ptr lst_filepos
= bfd_tell (abfd
) - sizeof (struct lst_header
);
4343 /* Read in the hash table. The has table is an array of 32bit file offsets
4344 which point to the hash chains. */
4345 if (bfd_read ((PTR
) hash_table
, lst_header
->hash_size
, 4, abfd
)
4346 != lst_header
->hash_size
* 4)
4348 bfd_error
= system_call_error
;
4352 /* Seek to and read in the SOM dictionary. We will need this to fill
4353 in the carsym's filepos field. */
4354 if (bfd_seek (abfd
, lst_filepos
+ lst_header
->dir_loc
, SEEK_SET
) < 0)
4356 bfd_error
= system_call_error
;
4360 if (bfd_read ((PTR
) som_dict
, lst_header
->module_count
,
4361 sizeof (struct som_entry
), abfd
)
4362 != lst_header
->module_count
* sizeof (struct som_entry
))
4364 bfd_error
= system_call_error
;
4368 /* Walk each chain filling in the carsyms as we go along. */
4369 for (i
= 0; i
< lst_header
->hash_size
; i
++)
4371 struct lst_symbol_record lst_symbol
;
4373 /* An empty chain has zero as it's file offset. */
4374 if (hash_table
[i
] == 0)
4377 /* Seek to and read the first symbol on the chain. */
4378 if (bfd_seek (abfd
, lst_filepos
+ hash_table
[i
], SEEK_SET
) < 0)
4380 bfd_error
= system_call_error
;
4384 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
4385 != sizeof (lst_symbol
))
4387 bfd_error
= system_call_error
;
4391 /* Get the name of the symbol, first get the length which is stored
4392 as a 32bit integer just before the symbol.
4394 One might ask why we don't just read in the entire string table
4395 and index into it. Well, according to the SOM ABI the string
4396 index can point *anywhere* in the archive to save space, so just
4397 using the string table would not be safe. */
4398 if (bfd_seek (abfd
, lst_filepos
+ lst_header
->string_loc
4399 + lst_symbol
.name
.n_strx
- 4, SEEK_SET
) < 0)
4401 bfd_error
= system_call_error
;
4405 if (bfd_read (&len
, 1, 4, abfd
) != 4)
4407 bfd_error
= system_call_error
;
4411 /* Allocate space for the name and null terminate it too. */
4412 set
->name
= bfd_zalloc (abfd
, len
+ 1);
4415 bfd_error
= no_memory
;
4418 if (bfd_read (set
->name
, 1, len
, abfd
) != len
)
4420 bfd_error
= system_call_error
;
4425 /* Fill in the file offset. Note that the "location" field points
4426 to the SOM itself, not the ar_hdr in front of it. */
4427 set
->file_offset
= som_dict
[lst_symbol
.som_index
].location
4428 - sizeof (struct ar_hdr
);
4430 /* Go to the next symbol. */
4433 /* Iterate through the rest of the chain. */
4434 while (lst_symbol
.next_entry
)
4436 /* Seek to the next symbol and read it in. */
4437 if (bfd_seek (abfd
, lst_filepos
+ lst_symbol
.next_entry
, SEEK_SET
)
4440 bfd_error
= system_call_error
;
4444 if (bfd_read ((PTR
) & lst_symbol
, 1, sizeof (lst_symbol
), abfd
)
4445 != sizeof (lst_symbol
))
4447 bfd_error
= system_call_error
;
4451 /* Seek to the name length & string and read them in. */
4452 if (bfd_seek (abfd
, lst_filepos
+ lst_header
->string_loc
4453 + lst_symbol
.name
.n_strx
- 4, SEEK_SET
) < 0)
4455 bfd_error
= system_call_error
;
4459 if (bfd_read (&len
, 1, 4, abfd
) != 4)
4461 bfd_error
= system_call_error
;
4465 /* Allocate space for the name and null terminate it too. */
4466 set
->name
= bfd_zalloc (abfd
, len
+ 1);
4469 bfd_error
= no_memory
;
4472 if (bfd_read (set
->name
, 1, len
, abfd
) != len
)
4474 bfd_error
= system_call_error
;
4479 /* Fill in the file offset. Note that the "location" field points
4480 to the SOM itself, not the ar_hdr in front of it. */
4481 set
->file_offset
= som_dict
[lst_symbol
.som_index
].location
4482 - sizeof (struct ar_hdr
);
4484 /* Go on to the next symbol. */
4488 /* If we haven't died by now, then we successfully read the entire
4489 archive symbol table. */
4493 /* Read in the LST from the archive. */
4495 som_slurp_armap (abfd
)
4498 struct lst_header lst_header
;
4499 struct ar_hdr ar_header
;
4500 unsigned int parsed_size
;
4501 struct artdata
*ardata
= bfd_ardata (abfd
);
4503 int i
= bfd_read ((PTR
) nextname
, 1, 16, abfd
);
4505 /* Special cases. */
4511 if (bfd_seek (abfd
, (file_ptr
) - 16, SEEK_CUR
) < 0)
4513 bfd_error
= system_call_error
;
4517 /* For archives without .o files there is no symbol table. */
4518 if (strncmp (nextname
, "/ ", 16))
4520 bfd_has_map (abfd
) = false;
4524 /* Read in and sanity check the archive header. */
4525 if (bfd_read ((PTR
) &ar_header
, 1, sizeof (struct ar_hdr
), abfd
)
4526 != sizeof (struct ar_hdr
))
4528 bfd_error
= system_call_error
;
4532 if (strncmp (ar_header
.ar_fmag
, ARFMAG
, 2))
4534 bfd_error
= malformed_archive
;
4538 /* How big is the archive symbol table entry? */
4540 parsed_size
= strtol (ar_header
.ar_size
, NULL
, 10);
4543 bfd_error
= malformed_archive
;
4547 /* Save off the file offset of the first real user data. */
4548 ardata
->first_file_filepos
= bfd_tell (abfd
) + parsed_size
;
4550 /* Read in the library symbol table. We'll make heavy use of this
4551 in just a minute. */
4552 if (bfd_read ((PTR
) & lst_header
, 1, sizeof (struct lst_header
), abfd
)
4553 != sizeof (struct lst_header
))
4555 bfd_error
= system_call_error
;
4560 if (lst_header
.a_magic
!= LIBMAGIC
)
4562 bfd_error
= malformed_archive
;
4566 /* Count the number of symbols in the library symbol table. */
4567 if (som_bfd_count_ar_symbols (abfd
, &lst_header
, &ardata
->symdef_count
)
4571 /* Get back to the start of the library symbol table. */
4572 if (bfd_seek (abfd
, ardata
->first_file_filepos
- parsed_size
4573 + sizeof (struct lst_header
), SEEK_SET
) < 0)
4575 bfd_error
= system_call_error
;
4579 /* Initializae the cache and allocate space for the library symbols. */
4581 ardata
->symdefs
= (carsym
*) bfd_alloc (abfd
,
4582 (ardata
->symdef_count
4583 * sizeof (carsym
)));
4584 if (!ardata
->symdefs
)
4586 bfd_error
= no_memory
;
4590 /* Now fill in the canonical archive symbols. */
4591 if (som_bfd_fill_in_ar_symbols (abfd
, &lst_header
, &ardata
->symdefs
)
4595 /* Notify the generic archive code that we have a symbol map. */
4596 bfd_has_map (abfd
) = true;
4600 /* Begin preparing to write a SOM library symbol table.
4602 As part of the prep work we need to determine the number of symbols
4603 and the size of the associated string section. */
4606 som_bfd_prep_for_ar_write (abfd
, num_syms
, stringsize
)
4608 unsigned int *num_syms
, *stringsize
;
4610 bfd
*curr_bfd
= abfd
->archive_head
;
4612 /* Some initialization. */
4616 /* Iterate over each BFD within this archive. */
4617 while (curr_bfd
!= NULL
)
4619 unsigned int curr_count
, i
;
4622 /* Make sure the symbol table has been read, then snag a pointer
4623 to it. It's a little slimey to grab the symbols via obj_som_symtab,
4624 but doing so avoids allocating lots of extra memory. */
4625 if (som_slurp_symbol_table (curr_bfd
) == false)
4628 sym
= (asymbol
*)obj_som_symtab (curr_bfd
);
4629 curr_count
= bfd_get_symcount (curr_bfd
);
4631 /* Examine each symbol to determine if it belongs in the
4632 library symbol table. */
4633 for (i
= 0; i
< curr_count
; i
++, sym
++)
4635 struct som_misc_symbol_info info
;
4637 /* Derive SOM information from the BFD symbol. */
4638 som_bfd_derive_misc_symbol_info (curr_bfd
, sym
, &info
);
4640 /* Should we include this symbol? */
4641 if (info
.symbol_type
== ST_NULL
4642 || info
.symbol_type
== ST_SYM_EXT
4643 || info
.symbol_type
== ST_ARG_EXT
)
4646 /* Only global symbols and unsatisfied commons. */
4647 if (info
.symbol_scope
!= SS_UNIVERSAL
4648 && info
.symbol_type
!= ST_STORAGE
)
4651 /* Do no include undefined symbols. */
4652 if (sym
->section
== &bfd_und_section
)
4655 /* Bump the various counters, being careful to honor
4656 alignment considerations in the string table. */
4658 *stringsize
= *stringsize
+ strlen (sym
->name
) + 5;
4659 while (*stringsize
% 4)
4663 curr_bfd
= curr_bfd
->next
;
4668 /* Hash a symbol name based on the hashing algorithm presented in the
4671 som_bfd_ar_symbol_hash (symbol
)
4674 unsigned int len
= strlen (symbol
->name
);
4676 /* Names with length 1 are special. */
4678 return 0x1000100 | (symbol
->name
[0] << 16) | symbol
->name
[0];
4680 return ((len
& 0x7f) << 24) | (symbol
->name
[1] << 16)
4681 | (symbol
->name
[len
-2] << 8) | symbol
->name
[len
-1];
4684 /* Do the bulk of the work required to write the SOM library
4688 som_bfd_ar_write_symbol_stuff (abfd
, nsyms
, string_size
, lst
)
4690 unsigned int nsyms
, string_size
;
4691 struct lst_header lst
;
4693 file_ptr lst_filepos
;
4695 struct lst_symbol_record
*lst_syms
, *curr_lst_sym
;
4696 bfd
*curr_bfd
= abfd
->archive_head
;
4697 unsigned int hash_table
[lst
.hash_size
];
4698 struct som_entry som_dict
[lst
.module_count
];
4699 struct lst_symbol_record
*last_hash_entry
[lst
.hash_size
];
4700 unsigned int curr_som_offset
, som_index
;
4702 /* Lots of fields are file positions relative to the start
4703 of the lst record. So save its location. */
4704 lst_filepos
= bfd_tell (abfd
) - sizeof (struct lst_header
);
4706 /* Some initialization. */
4707 memset (hash_table
, 0, 4 * lst
.hash_size
);
4708 memset (som_dict
, 0, lst
.module_count
* sizeof (struct som_entry
));
4709 memset (last_hash_entry
, 0,
4710 lst
.hash_size
* sizeof (struct lst_symbol_record
*));
4712 /* Symbols have som_index fields, so we have to keep track of the
4713 index of each SOM in the archive.
4715 The SOM dictionary has (among other things) the absolute file
4716 position for the SOM which a particular dictionary entry
4717 describes. We have to compute that information as we iterate
4718 through the SOMs/symbols. */
4720 curr_som_offset
= 8 + 2 * sizeof (struct ar_hdr
) + lst
.file_end
;
4722 /* FIXME should be done with buffers just like everything else... */
4723 lst_syms
= alloca (nsyms
* sizeof (struct lst_symbol_record
));
4724 strings
= alloca (string_size
);
4726 curr_lst_sym
= lst_syms
;
4729 while (curr_bfd
!= NULL
)
4731 unsigned int curr_count
, i
;
4734 /* Make sure the symbol table has been read, then snag a pointer
4735 to it. It's a little slimey to grab the symbols via obj_som_symtab,
4736 but doing so avoids allocating lots of extra memory. */
4737 if (som_slurp_symbol_table (curr_bfd
) == false)
4740 sym
= (asymbol
*)obj_som_symtab (curr_bfd
);
4741 curr_count
= bfd_get_symcount (curr_bfd
);
4743 for (i
= 0; i
< curr_count
; i
++, sym
++)
4745 struct som_misc_symbol_info info
;
4747 /* Derive SOM information from the BFD symbol. */
4748 som_bfd_derive_misc_symbol_info (curr_bfd
, sym
, &info
);
4750 /* Should we include this symbol? */
4751 if (info
.symbol_type
== ST_NULL
4752 || info
.symbol_type
== ST_SYM_EXT
4753 || info
.symbol_type
== ST_ARG_EXT
)
4756 /* Only global symbols and unsatisfied commons. */
4757 if (info
.symbol_scope
!= SS_UNIVERSAL
4758 && info
.symbol_type
!= ST_STORAGE
)
4761 /* Do no include undefined symbols. */
4762 if (sym
->section
== &bfd_und_section
)
4765 /* If this is the first symbol from this SOM, then update
4766 the SOM dictionary too. */
4767 if (som_dict
[som_index
].location
== 0)
4769 som_dict
[som_index
].location
= curr_som_offset
;
4770 som_dict
[som_index
].length
= arelt_size (curr_bfd
);
4773 /* Fill in the lst symbol record. */
4774 curr_lst_sym
->hidden
= 0;
4775 curr_lst_sym
->secondary_def
= 0;
4776 curr_lst_sym
->symbol_type
= info
.symbol_type
;
4777 curr_lst_sym
->symbol_scope
= info
.symbol_scope
;
4778 curr_lst_sym
->check_level
= 0;
4779 curr_lst_sym
->must_qualify
= 0;
4780 curr_lst_sym
->initially_frozen
= 0;
4781 curr_lst_sym
->memory_resident
= 0;
4782 curr_lst_sym
->is_common
= (sym
->section
== &bfd_com_section
);
4783 curr_lst_sym
->dup_common
= 0;
4784 curr_lst_sym
->xleast
= 0;
4785 curr_lst_sym
->arg_reloc
= info
.arg_reloc
;
4786 curr_lst_sym
->name
.n_strx
= p
- strings
+ 4;
4787 curr_lst_sym
->qualifier_name
.n_strx
= 0;
4788 curr_lst_sym
->symbol_info
= info
.symbol_info
;
4789 curr_lst_sym
->symbol_value
= info
.symbol_value
;
4790 curr_lst_sym
->symbol_descriptor
= 0;
4791 curr_lst_sym
->reserved
= 0;
4792 curr_lst_sym
->som_index
= som_index
;
4793 curr_lst_sym
->symbol_key
= som_bfd_ar_symbol_hash (sym
);
4794 curr_lst_sym
->next_entry
= 0;
4796 /* Insert into the hash table. */
4797 if (hash_table
[curr_lst_sym
->symbol_key
% lst
.hash_size
])
4799 struct lst_symbol_record
*tmp
;
4801 /* There is already something at the head of this hash chain,
4802 so tack this symbol onto the end of the chain. */
4803 tmp
= last_hash_entry
[curr_lst_sym
->symbol_key
% lst
.hash_size
];
4805 = (curr_lst_sym
- lst_syms
) * sizeof (struct lst_symbol_record
)
4807 + lst
.module_count
* sizeof (struct som_entry
)
4808 + sizeof (struct lst_header
);
4812 /* First entry in this hash chain. */
4813 hash_table
[curr_lst_sym
->symbol_key
% lst
.hash_size
]
4814 = (curr_lst_sym
- lst_syms
) * sizeof (struct lst_symbol_record
)
4816 + lst
.module_count
* sizeof (struct som_entry
)
4817 + sizeof (struct lst_header
);
4820 /* Keep track of the last symbol we added to this chain so we can
4821 easily update its next_entry pointer. */
4822 last_hash_entry
[curr_lst_sym
->symbol_key
% lst
.hash_size
]
4826 /* Update the string table. */
4827 bfd_put_32 (abfd
, strlen (sym
->name
), p
);
4829 strcpy (p
, sym
->name
);
4830 p
+= strlen (sym
->name
) + 1;
4833 bfd_put_8 (abfd
, 0, p
);
4837 /* Head to the next symbol. */
4841 /* Keep track of where each SOM will finally reside; then look
4843 curr_som_offset
+= arelt_size (curr_bfd
) + sizeof (struct ar_hdr
);
4844 curr_bfd
= curr_bfd
->next
;
4848 /* Now scribble out the hash table. */
4849 if (bfd_write ((PTR
) hash_table
, lst
.hash_size
, 4, abfd
)
4850 != lst
.hash_size
* 4)
4852 bfd_error
= system_call_error
;
4856 /* Then the SOM dictionary. */
4857 if (bfd_write ((PTR
) som_dict
, lst
.module_count
,
4858 sizeof (struct som_entry
), abfd
)
4859 != lst
.module_count
* sizeof (struct som_entry
))
4861 bfd_error
= system_call_error
;
4865 /* The library symbols. */
4866 if (bfd_write ((PTR
) lst_syms
, nsyms
, sizeof (struct lst_symbol_record
), abfd
)
4867 != nsyms
* sizeof (struct lst_symbol_record
))
4869 bfd_error
= system_call_error
;
4873 /* And finally the strings. */
4874 if (bfd_write ((PTR
) strings
, string_size
, 1, abfd
) != string_size
)
4876 bfd_error
= system_call_error
;
4883 /* Write out the LST for the archive.
4885 You'll never believe this is really how armaps are handled in SOM... */
4888 som_write_armap (abfd
)
4892 struct stat statbuf
;
4893 unsigned int i
, lst_size
, nsyms
, stringsize
;
4895 struct lst_header lst
;
4898 /* We'll use this for the archive's date and mode later. */
4899 if (stat (abfd
->filename
, &statbuf
) != 0)
4901 bfd_error
= system_call_error
;
4905 bfd_ardata (abfd
)->armap_timestamp
= statbuf
.st_mtime
+ 60;
4907 /* Account for the lst header first. */
4908 lst_size
= sizeof (struct lst_header
);
4910 /* Start building the LST header. */
4911 lst
.system_id
= HP9000S800_ID
;
4912 lst
.a_magic
= LIBMAGIC
;
4913 lst
.version_id
= VERSION_ID
;
4914 lst
.file_time
.secs
= 0;
4915 lst
.file_time
.nanosecs
= 0;
4917 lst
.hash_loc
= lst_size
;
4918 lst
.hash_size
= SOM_LST_HASH_SIZE
;
4920 /* Hash table is a SOM_LST_HASH_SIZE 32bit offsets. */
4921 lst_size
+= 4 * SOM_LST_HASH_SIZE
;
4923 /* We need to count the number of SOMs in this archive. */
4924 curr_bfd
= abfd
->archive_head
;
4925 lst
.module_count
= 0;
4926 while (curr_bfd
!= NULL
)
4929 curr_bfd
= curr_bfd
->next
;
4931 lst
.module_limit
= lst
.module_count
;
4932 lst
.dir_loc
= lst_size
;
4933 lst_size
+= sizeof (struct som_entry
) * lst
.module_count
;
4935 /* We don't support import/export tables, auxiliary headers,
4936 or free lists yet. Make the linker work a little harder
4937 to make our life easier. */
4940 lst
.export_count
= 0;
4945 /* Count how many symbols we will have on the hash chains and the
4946 size of the associated string table. */
4947 if (som_bfd_prep_for_ar_write (abfd
, &nsyms
, &stringsize
) == false)
4950 lst_size
+= sizeof (struct lst_symbol_record
) * nsyms
;
4952 /* For the string table. One day we might actually use this info
4953 to avoid small seeks/reads when reading archives. */
4954 lst
.string_loc
= lst_size
;
4955 lst
.string_size
= stringsize
;
4956 lst_size
+= stringsize
;
4958 /* SOM ABI says this must be zero. */
4961 lst
.file_end
= lst_size
;
4963 /* Compute the checksum. Must happen after the entire lst header
4966 for (i
= 0; i
< sizeof (struct lst_header
)/sizeof (int) - 1; i
++)
4967 lst
.checksum
^= *p
++;
4969 sprintf (hdr
.ar_name
, "/ ");
4970 sprintf (hdr
.ar_date
, "%ld", bfd_ardata (abfd
)->armap_timestamp
);
4971 sprintf (hdr
.ar_uid
, "%d", getuid ());
4972 sprintf (hdr
.ar_gid
, "%d", getgid ());
4973 sprintf (hdr
.ar_mode
, "%-8o", (unsigned int) statbuf
.st_mode
);
4974 sprintf (hdr
.ar_size
, "%-10d", (int) lst_size
);
4975 hdr
.ar_fmag
[0] = '`';
4976 hdr
.ar_fmag
[1] = '\012';
4978 /* Turn any nulls into spaces. */
4979 for (i
= 0; i
< sizeof (struct ar_hdr
); i
++)
4980 if (((char *) (&hdr
))[i
] == '\0')
4981 (((char *) (&hdr
))[i
]) = ' ';
4983 /* Scribble out the ar header. */
4984 if (bfd_write ((PTR
) &hdr
, 1, sizeof (struct ar_hdr
), abfd
)
4985 != sizeof (struct ar_hdr
))
4987 bfd_error
= system_call_error
;
4991 /* Now scribble out the lst header. */
4992 if (bfd_write ((PTR
) &lst
, 1, sizeof (struct lst_header
), abfd
)
4993 != sizeof (struct lst_header
))
4995 bfd_error
= system_call_error
;
4999 /* Build and write the armap. */
5000 if (som_bfd_ar_write_symbol_stuff (abfd
, nsyms
, stringsize
, lst
) == false)
5007 /* Apparently the extened names are never used, even though they appear
5008 in the SOM ABI. Hmmm. */
5010 som_slurp_extended_name_table (abfd
)
5013 bfd_ardata (abfd
)->extended_names
= NULL
;
5017 /* End of miscellaneous support functions. */
5019 #define som_bfd_debug_info_start bfd_void
5020 #define som_bfd_debug_info_end bfd_void
5021 #define som_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
5023 #define som_openr_next_archived_file bfd_generic_openr_next_archived_file
5024 #define som_generic_stat_arch_elt bfd_generic_stat_arch_elt
5025 #define som_truncate_arname bfd_bsd_truncate_arname
5027 #define som_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
5028 #define som_close_and_cleanup bfd_generic_close_and_cleanup
5029 #define som_get_section_contents bfd_generic_get_section_contents
5031 #define som_bfd_get_relocated_section_contents \
5032 bfd_generic_get_relocated_section_contents
5033 #define som_bfd_relax_section bfd_generic_relax_section
5034 #define som_bfd_make_debug_symbol \
5035 ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
5036 #define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
5037 #define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
5038 #define som_bfd_final_link _bfd_generic_final_link
5040 /* Core file support is in the hpux-core backend. */
5041 #define som_core_file_failing_command _bfd_dummy_core_file_failing_command
5042 #define som_core_file_failing_signal _bfd_dummy_core_file_failing_signal
5043 #define som_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p
5045 bfd_target som_vec
=
5048 bfd_target_som_flavour
,
5049 true, /* target byte order */
5050 true, /* target headers byte order */
5051 (HAS_RELOC
| EXEC_P
| /* object flags */
5052 HAS_LINENO
| HAS_DEBUG
|
5053 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
5054 (SEC_CODE
| SEC_DATA
| SEC_ROM
| SEC_HAS_CONTENTS
5055 | SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
5057 /* leading_symbol_char: is the first char of a user symbol
5058 predictable, and if so what is it */
5060 '/', /* ar_pad_char */
5061 16, /* ar_max_namelen */
5062 3, /* minimum alignment */
5063 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
5064 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
5065 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* data */
5066 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
5067 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
5068 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* hdrs */
5070 som_object_p
, /* bfd_check_format */
5071 bfd_generic_archive_p
,
5077 _bfd_generic_mkarchive
,
5082 som_write_object_contents
,
5083 _bfd_write_archive_contents
,
5091 #endif /* HOST_HPPAHPUX || HOST_HPPABSD || HOST_HPPAOSF */