1 /* tc-hppa.c -- Assemble for the PA
2 Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* HP PA-RISC support was contributed by the Center for Software Science
24 at the University of Utah. */
32 #include "bfd/libhppa.h"
33 #include "bfd/libbfd.h"
35 /* Be careful, this file includes data *declarations*. */
36 #include "opcode/hppa.h"
38 #if defined (OBJ_ELF) && defined (OBJ_SOM)
39 error only one of OBJ_ELF
and OBJ_SOM can be defined
42 /* A "convient" place to put object file dependencies which do
43 not need to be seen outside of tc-hppa.c. */
45 /* Object file formats specify relocation types. */
46 typedef elf_hppa_reloc_type reloc_type
;
48 /* Object file formats specify BFD symbol types. */
49 typedef elf_symbol_type obj_symbol_type
;
52 /* How to generate a relocation. */
53 #define hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
55 #define hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
58 /* ELF objects can have versions, but apparently do not have anywhere
59 to store a copyright string. */
60 #define obj_version obj_elf_version
61 #define obj_copyright obj_elf_version
65 /* Names of various debugging spaces/subspaces. */
66 #define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$"
67 #define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$"
68 #define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$"
69 #define UNWIND_SECTION_NAME "$UNWIND$"
71 /* Object file formats specify relocation types. */
72 typedef int reloc_type
;
74 /* SOM objects can have both a version string and a copyright string. */
75 #define obj_version obj_som_version
76 #define obj_copyright obj_som_copyright
78 /* How to generate a relocation. */
79 #define hppa_gen_reloc_type hppa_som_gen_reloc_type
81 /* Object file formats specify BFD symbol types. */
82 typedef som_symbol_type obj_symbol_type
;
84 /* This apparently isn't in older versions of hpux reloc.h. */
86 #define R_DLT_REL 0x78
98 /* Various structures and types used internally in tc-hppa.c. */
100 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
104 unsigned int cannot_unwind
:1;
105 unsigned int millicode
:1;
106 unsigned int millicode_save_rest
:1;
107 unsigned int region_desc
:2;
108 unsigned int save_sr
:2;
109 unsigned int entry_fr
:4;
110 unsigned int entry_gr
:5;
111 unsigned int args_stored
:1;
112 unsigned int call_fr
:5;
113 unsigned int call_gr
:5;
114 unsigned int save_sp
:1;
115 unsigned int save_rp
:1;
116 unsigned int save_rp_in_frame
:1;
117 unsigned int extn_ptr_defined
:1;
118 unsigned int cleanup_defined
:1;
120 unsigned int hpe_interrupt_marker
:1;
121 unsigned int hpux_interrupt_marker
:1;
122 unsigned int reserved
:3;
123 unsigned int frame_size
:27;
128 /* Starting and ending offsets of the region described by
130 unsigned int start_offset
;
131 unsigned int end_offset
;
132 struct unwind_desc descriptor
;
135 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
136 control the entry and exit code they generate. It is also used in
137 creation of the correct stack unwind descriptors.
139 NOTE: GAS does not support .enter and .leave for the generation of
140 prologues and epilogues. FIXME.
142 The fields in structure roughly correspond to the arguments available on the
143 .callinfo pseudo-op. */
147 /* The unwind descriptor being built. */
148 struct unwind_table ci_unwind
;
150 /* Name of this function. */
151 symbolS
*start_symbol
;
153 /* (temporary) symbol used to mark the end of this function. */
156 /* Next entry in the chain. */
157 struct call_info
*ci_next
;
160 /* Operand formats for FP instructions. Note not all FP instructions
161 allow all four formats to be used (for example fmpysub only allows
165 SGL
, DBL
, ILLEGAL_FMT
, QUAD
, W
, UW
, DW
, UDW
, QW
, UQW
169 /* This fully describes the symbol types which may be attached to
170 an EXPORT or IMPORT directive. Only SOM uses this formation
171 (ELF has no need for it). */
175 SYMBOL_TYPE_ABSOLUTE
,
179 SYMBOL_TYPE_MILLICODE
,
181 SYMBOL_TYPE_PRI_PROG
,
182 SYMBOL_TYPE_SEC_PROG
,
186 /* This structure contains information needed to assemble
187 individual instructions. */
190 /* Holds the opcode after parsing by pa_ip. */
191 unsigned long opcode
;
193 /* Holds an expression associated with the current instruction. */
196 /* Does this instruction use PC-relative addressing. */
199 /* Floating point formats for operand1 and operand2. */
200 fp_operand_format fpof1
;
201 fp_operand_format fpof2
;
204 /* Holds the field selector for this instruction
205 (for example L%, LR%, etc). */
208 /* Holds any argument relocation bits associated with this
209 instruction. (instruction should be some sort of call). */
212 /* The format specification for this instruction. */
215 /* The relocation (if any) associated with this instruction. */
219 /* PA-89 floating point registers are arranged like this:
222 +--------------+--------------+
223 | 0 or 16L | 16 or 16R |
224 +--------------+--------------+
225 | 1 or 17L | 17 or 17R |
226 +--------------+--------------+
234 +--------------+--------------+
235 | 14 or 30L | 30 or 30R |
236 +--------------+--------------+
237 | 15 or 31L | 31 or 31R |
238 +--------------+--------------+
241 The following is a version of pa_parse_number that
242 handles the L/R notation and returns the correct
243 value to put into the instruction register field.
244 The correct value to put into the instruction is
245 encoded in the structure 'pa_11_fp_reg_struct'. */
247 struct pa_11_fp_reg_struct
249 /* The register number. */
256 /* Additional information needed to build argument relocation stubs. */
259 /* The argument relocation specification. */
260 unsigned int arg_reloc
;
262 /* Number of arguments. */
263 unsigned int arg_count
;
267 /* This structure defines an entry in the subspace dictionary
270 struct subspace_dictionary_chain
272 /* Nonzero if this space has been defined by the user code. */
273 unsigned int ssd_defined
;
275 /* Name of this subspace. */
278 /* GAS segment and subsegment associated with this subspace. */
282 /* Next space in the subspace dictionary chain. */
283 struct subspace_dictionary_chain
*ssd_next
;
286 typedef struct subspace_dictionary_chain ssd_chain_struct
;
288 /* This structure defines an entry in the subspace dictionary
291 struct space_dictionary_chain
293 /* Nonzero if this space has been defined by the user code or
294 as a default space. */
295 unsigned int sd_defined
;
297 /* Nonzero if this spaces has been defined by the user code. */
298 unsigned int sd_user_defined
;
300 /* The space number (or index). */
301 unsigned int sd_spnum
;
303 /* The name of this subspace. */
306 /* GAS segment to which this subspace corresponds. */
309 /* Current subsegment number being used. */
312 /* The chain of subspaces contained within this space. */
313 ssd_chain_struct
*sd_subspaces
;
315 /* The next entry in the space dictionary chain. */
316 struct space_dictionary_chain
*sd_next
;
319 typedef struct space_dictionary_chain sd_chain_struct
;
321 /* This structure defines attributes of the default subspace
322 dictionary entries. */
324 struct default_subspace_dict
326 /* Name of the subspace. */
329 /* FIXME. Is this still needed? */
332 /* Nonzero if this subspace is loadable. */
335 /* Nonzero if this subspace contains only code. */
338 /* Nonzero if this is a common subspace. */
341 /* Nonzero if this is a common subspace which allows symbols
342 to be multiply defined. */
345 /* Nonzero if this subspace should be zero filled. */
348 /* Sort key for this subspace. */
351 /* Access control bits for this subspace. Can represent RWX access
352 as well as privilege level changes for gateways. */
355 /* Index of containing space. */
358 /* Alignment (in bytes) of this subspace. */
361 /* Quadrant within space where this subspace should be loaded. */
364 /* An index into the default spaces array. */
367 /* Subsegment associated with this subspace. */
371 /* This structure defines attributes of the default space
372 dictionary entries. */
374 struct default_space_dict
376 /* Name of the space. */
379 /* Space number. It is possible to identify spaces within
380 assembly code numerically! */
383 /* Nonzero if this space is loadable. */
386 /* Nonzero if this space is "defined". FIXME is still needed */
389 /* Nonzero if this space can not be shared. */
392 /* Sort key for this space. */
395 /* Segment associated with this space. */
400 /* Structure for previous label tracking. Needed so that alignments,
401 callinfo declarations, etc can be easily attached to a particular
403 typedef struct label_symbol_struct
405 struct symbol
*lss_label
;
407 sd_chain_struct
*lss_space
;
412 struct label_symbol_struct
*lss_next
;
416 /* Extra information needed to perform fixups (relocations) on the PA. */
417 struct hppa_fix_struct
419 /* The field selector. */
420 enum hppa_reloc_field_selector_type_alt fx_r_field
;
425 /* Format of fixup. */
428 /* Argument relocation bits. */
431 /* The segment this fixup appears in. */
435 /* Structure to hold information about predefined registers. */
443 /* This structure defines the mapping from a FP condition string
444 to a condition number which can be recorded in an instruction. */
451 /* This structure defines a mapping from a field selector
452 string to a field selector type. */
453 struct selector_entry
459 /* Prototypes for functions local to tc-hppa.c. */
462 static void pa_check_current_space_and_subspace
PARAMS ((void));
465 static fp_operand_format pa_parse_fp_format
PARAMS ((char **s
));
466 static void pa_cons
PARAMS ((int));
467 static void pa_data
PARAMS ((int));
468 static void pa_float_cons
PARAMS ((int));
469 static void pa_fill
PARAMS ((int));
470 static void pa_lcomm
PARAMS ((int));
471 static void pa_lsym
PARAMS ((int));
472 static void pa_stringer
PARAMS ((int));
473 static void pa_text
PARAMS ((int));
474 static void pa_version
PARAMS ((int));
475 static int pa_parse_fp_cmp_cond
PARAMS ((char **));
476 static int get_expression
PARAMS ((char *));
477 static int pa_get_absolute_expression
PARAMS ((struct pa_it
*, char **));
478 static int evaluate_absolute
PARAMS ((struct pa_it
*));
479 static unsigned int pa_build_arg_reloc
PARAMS ((char *));
480 static unsigned int pa_align_arg_reloc
PARAMS ((unsigned int, unsigned int));
481 static int pa_parse_nullif
PARAMS ((char **));
482 static int pa_parse_nonneg_cmpsub_cmpltr
PARAMS ((char **, int));
483 static int pa_parse_neg_cmpsub_cmpltr
PARAMS ((char **, int));
484 static int pa_parse_neg_add_cmpltr
PARAMS ((char **, int));
485 static int pa_parse_nonneg_add_cmpltr
PARAMS ((char **, int));
486 static void pa_block
PARAMS ((int));
487 static void pa_brtab
PARAMS ((int));
488 static void pa_try
PARAMS ((int));
489 static void pa_call
PARAMS ((int));
490 static void pa_call_args
PARAMS ((struct call_desc
*));
491 static void pa_callinfo
PARAMS ((int));
492 static void pa_code
PARAMS ((int));
493 static void pa_comm
PARAMS ((int));
494 static void pa_copyright
PARAMS ((int));
495 static void pa_end
PARAMS ((int));
496 static void pa_enter
PARAMS ((int));
497 static void pa_entry
PARAMS ((int));
498 static void pa_equ
PARAMS ((int));
499 static void pa_exit
PARAMS ((int));
500 static void pa_export
PARAMS ((int));
501 static void pa_type_args
PARAMS ((symbolS
*, int));
502 static void pa_import
PARAMS ((int));
503 static void pa_label
PARAMS ((int));
504 static void pa_leave
PARAMS ((int));
505 static void pa_level
PARAMS ((int));
506 static void pa_origin
PARAMS ((int));
507 static void pa_proc
PARAMS ((int));
508 static void pa_procend
PARAMS ((int));
509 static void pa_param
PARAMS ((int));
510 static void pa_undefine_label
PARAMS ((void));
511 static int need_pa11_opcode
PARAMS ((struct pa_it
*,
512 struct pa_11_fp_reg_struct
*));
513 static int pa_parse_number
PARAMS ((char **, struct pa_11_fp_reg_struct
*));
514 static label_symbol_struct
*pa_get_label
PARAMS ((void));
516 static void pa_compiler
PARAMS ((int));
517 static void pa_align
PARAMS ((int));
518 static void pa_space
PARAMS ((int));
519 static void pa_spnum
PARAMS ((int));
520 static void pa_subspace
PARAMS ((int));
521 static sd_chain_struct
*create_new_space
PARAMS ((char *, int, int,
524 static ssd_chain_struct
*create_new_subspace
PARAMS ((sd_chain_struct
*,
529 static ssd_chain_struct
*update_subspace
PARAMS ((sd_chain_struct
*,
530 char *, int, int, int,
534 static sd_chain_struct
*is_defined_space
PARAMS ((char *));
535 static ssd_chain_struct
*is_defined_subspace
PARAMS ((char *));
536 static sd_chain_struct
*pa_segment_to_space
PARAMS ((asection
*));
537 static ssd_chain_struct
*pa_subsegment_to_subspace
PARAMS ((asection
*,
539 static sd_chain_struct
*pa_find_space_by_number
PARAMS ((int));
540 static unsigned int pa_subspace_start
PARAMS ((sd_chain_struct
*, int));
541 static sd_chain_struct
*pa_parse_space_stmt
PARAMS ((char *, int));
542 static int pa_next_subseg
PARAMS ((sd_chain_struct
*));
543 static void pa_spaces_begin
PARAMS ((void));
545 static void pa_ip
PARAMS ((char *));
546 static void fix_new_hppa
PARAMS ((fragS
*, int, int, symbolS
*,
547 long, expressionS
*, int,
548 bfd_reloc_code_real_type
,
549 enum hppa_reloc_field_selector_type_alt
,
551 static int is_end_of_statement
PARAMS ((void));
552 static int reg_name_search
PARAMS ((char *));
553 static int pa_chk_field_selector
PARAMS ((char **));
554 static int is_same_frag
PARAMS ((fragS
*, fragS
*));
555 static void process_exit
PARAMS ((void));
556 static int log2
PARAMS ((int));
557 static unsigned int pa_stringer_aux
PARAMS ((char *));
560 static void hppa_elf_mark_end_of_function
PARAMS ((void));
561 static void pa_build_unwind_subspace
PARAMS ((struct call_info
*));
564 /* File and gloally scoped variable declarations. */
567 /* Root and final entry in the space chain. */
568 static sd_chain_struct
*space_dict_root
;
569 static sd_chain_struct
*space_dict_last
;
571 /* The current space and subspace. */
572 static sd_chain_struct
*current_space
;
573 static ssd_chain_struct
*current_subspace
;
576 /* Root of the call_info chain. */
577 static struct call_info
*call_info_root
;
579 /* The last call_info (for functions) structure
580 seen so it can be associated with fixups and
582 static struct call_info
*last_call_info
;
584 /* The last call description (for actual calls). */
585 static struct call_desc last_call_desc
;
587 /* handle of the OPCODE hash table */
588 static struct hash_control
*op_hash
= NULL
;
590 /* This array holds the chars that always start a comment. If the
591 pre-processor is disabled, these aren't very useful. */
592 const char comment_chars
[] = ";";
594 /* Table of pseudo ops for the PA. FIXME -- how many of these
595 are now redundant with the overall GAS and the object file
597 const pseudo_typeS md_pseudo_table
[] =
599 /* align pseudo-ops on the PA specify the actual alignment requested,
600 not the log2 of the requested alignment. */
602 {"align", pa_align
, 8},
605 {"align", s_align_bytes
, 8},
607 {"begin_brtab", pa_brtab
, 1},
608 {"begin_try", pa_try
, 1},
609 {"block", pa_block
, 1},
610 {"blockz", pa_block
, 0},
611 {"byte", pa_cons
, 1},
612 {"call", pa_call
, 0},
613 {"callinfo", pa_callinfo
, 0},
614 {"code", pa_code
, 0},
615 {"comm", pa_comm
, 0},
617 {"compiler", pa_compiler
, 0},
619 {"copyright", pa_copyright
, 0},
620 {"data", pa_data
, 0},
621 {"double", pa_float_cons
, 'd'},
623 {"end_brtab", pa_brtab
, 0},
624 {"end_try", pa_try
, 0},
625 {"enter", pa_enter
, 0},
626 {"entry", pa_entry
, 0},
628 {"exit", pa_exit
, 0},
629 {"export", pa_export
, 0},
630 {"fill", pa_fill
, 0},
631 {"float", pa_float_cons
, 'f'},
632 {"half", pa_cons
, 2},
633 {"import", pa_import
, 0},
635 {"label", pa_label
, 0},
636 {"lcomm", pa_lcomm
, 0},
637 {"leave", pa_leave
, 0},
638 {"level", pa_level
, 0},
639 {"long", pa_cons
, 4},
640 {"lsym", pa_lsym
, 0},
642 {"nsubspa", pa_subspace
, 1},
644 {"octa", pa_cons
, 16},
645 {"org", pa_origin
, 0},
646 {"origin", pa_origin
, 0},
647 {"param", pa_param
, 0},
648 {"proc", pa_proc
, 0},
649 {"procend", pa_procend
, 0},
650 {"quad", pa_cons
, 8},
652 {"short", pa_cons
, 2},
653 {"single", pa_float_cons
, 'f'},
655 {"space", pa_space
, 0},
656 {"spnum", pa_spnum
, 0},
658 {"string", pa_stringer
, 0},
659 {"stringz", pa_stringer
, 1},
661 {"subspa", pa_subspace
, 0},
663 {"text", pa_text
, 0},
664 {"version", pa_version
, 0},
665 {"word", pa_cons
, 4},
669 /* This array holds the chars that only start a comment at the beginning of
670 a line. If the line seems to have the form '# 123 filename'
671 .line and .file directives will appear in the pre-processed output.
673 Note that input_file.c hand checks for '#' at the beginning of the
674 first line of the input file. This is because the compiler outputs
675 #NO_APP at the beginning of its output.
677 Also note that C style comments will always work. */
678 const char line_comment_chars
[] = "#";
680 /* This array holds the characters which act as line separators. */
681 const char line_separator_chars
[] = "!";
683 /* Chars that can be used to separate mant from exp in floating point nums. */
684 const char EXP_CHARS
[] = "eE";
686 /* Chars that mean this number is a floating point constant.
687 As in 0f12.456 or 0d1.2345e12.
689 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
690 changed in read.c. Ideally it shouldn't hae to know abou it at
691 all, but nothing is ideal around here. */
692 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
694 static struct pa_it the_insn
;
696 /* Points to the end of an expression just parsed by get_expressoin
697 and friends. FIXME. This shouldn't be handled with a file-global
699 static char *expr_end
;
701 /* Nonzero if a .callinfo appeared within the current procedure. */
702 static int callinfo_found
;
704 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
705 static int within_entry_exit
;
707 /* Nonzero if the assembler is currently within a procedure definition. */
708 static int within_procedure
;
710 /* Handle on strucutre which keep track of the last symbol
711 seen in each subspace. */
712 static label_symbol_struct
*label_symbols_rootp
= NULL
;
714 /* Holds the last field selector. */
715 static int hppa_field_selector
;
718 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
719 static symbolS
*dummy_symbol
;
722 /* Nonzero if errors are to be printed. */
723 static int print_errors
= 1;
725 /* List of registers that are pre-defined:
727 Each general register has one predefined name of the form
728 %r<REGNUM> which has the value <REGNUM>.
730 Space and control registers are handled in a similar manner,
731 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
733 Likewise for the floating point registers, but of the form
734 %fr<REGNUM>. Floating point registers have additional predefined
735 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
736 again have the value <REGNUM>.
738 Many registers also have synonyms:
740 %r26 - %r23 have %arg0 - %arg3 as synonyms
741 %r28 - %r29 have %ret0 - %ret1 as synonyms
742 %r30 has %sp as a synonym
743 %r27 has %dp as a synonym
744 %r2 has %rp as a synonym
746 Almost every control register has a synonym; they are not listed
749 The table is sorted. Suitable for searching by a binary search. */
751 static const struct pd_reg pre_defined_registers
[] =
951 /* This table is sorted by order of the length of the string. This is
952 so we check for <> before we check for <. If we had a <> and checked
953 for < first, we would get a false match. */
954 static const struct fp_cond_map fp_cond_map
[] =
990 static const struct selector_entry selector_table
[] =
1013 /* default space and subspace dictionaries */
1015 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1016 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1018 /* pre-defined subsegments (subspaces) for the HPPA. */
1019 #define SUBSEG_CODE 0
1020 #define SUBSEG_LIT 1
1021 #define SUBSEG_MILLI 2
1022 #define SUBSEG_DATA 0
1023 #define SUBSEG_BSS 2
1024 #define SUBSEG_UNWIND 3
1025 #define SUBSEG_GDB_STRINGS 0
1026 #define SUBSEG_GDB_SYMBOLS 1
1028 static struct default_subspace_dict pa_def_subspaces
[] =
1030 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE
},
1031 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA
},
1032 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT
},
1033 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI
},
1034 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS
},
1035 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1038 static struct default_space_dict pa_def_spaces
[] =
1040 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
},
1041 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
},
1042 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
}
1045 /* Misc local definitions used by the assembler. */
1047 /* These macros are used to maintain spaces/subspaces. */
1048 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1049 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1050 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1051 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1053 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1054 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1057 /* Return nonzero if the string pointed to by S potentially represents
1058 a right or left half of a FP register */
1059 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1060 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1062 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1063 main loop after insertion. */
1065 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1067 ((OPCODE) |= (FIELD) << (START)); \
1071 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1072 IGNORE is used to suppress the error message. */
1074 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1076 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1079 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1085 #define is_DP_relative(exp) \
1086 ((exp).X_op == O_subtract \
1087 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1089 #define is_PC_relative(exp) \
1090 ((exp).X_op == O_subtract \
1091 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1093 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1094 always be able to reduce the expression to a constant, so we don't
1095 need real complex handling yet. */
1096 #define is_complex(exp) \
1097 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1099 /* Actual functions to implement the PA specific code for the assembler. */
1101 /* Called before writing the object file. Make sure entry/exit and
1102 proc/procend pairs match. */
1107 if (within_entry_exit
)
1108 as_fatal (_("Missing .exit\n"));
1110 if (within_procedure
)
1111 as_fatal (_("Missing .procend\n"));
1114 /* Returns a pointer to the label_symbol_struct for the current space.
1115 or NULL if no label_symbol_struct exists for the current space. */
1117 static label_symbol_struct
*
1120 label_symbol_struct
*label_chain
;
1122 for (label_chain
= label_symbols_rootp
;
1124 label_chain
= label_chain
->lss_next
)
1127 if (current_space
== label_chain
->lss_space
&& label_chain
->lss_label
)
1131 if (now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
)
1139 /* Defines a label for the current space. If one is already defined,
1140 this function will replace it with the new label. */
1143 pa_define_label (symbol
)
1146 label_symbol_struct
*label_chain
= pa_get_label ();
1149 label_chain
->lss_label
= symbol
;
1152 /* Create a new label entry and add it to the head of the chain. */
1154 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1155 label_chain
->lss_label
= symbol
;
1157 label_chain
->lss_space
= current_space
;
1160 label_chain
->lss_segment
= now_seg
;
1162 label_chain
->lss_next
= NULL
;
1164 if (label_symbols_rootp
)
1165 label_chain
->lss_next
= label_symbols_rootp
;
1167 label_symbols_rootp
= label_chain
;
1171 /* Removes a label definition for the current space.
1172 If there is no label_symbol_struct entry, then no action is taken. */
1175 pa_undefine_label ()
1177 label_symbol_struct
*label_chain
;
1178 label_symbol_struct
*prev_label_chain
= NULL
;
1180 for (label_chain
= label_symbols_rootp
;
1182 label_chain
= label_chain
->lss_next
)
1186 && current_space
== label_chain
->lss_space
&& label_chain
->lss_label
1189 && now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
1193 /* Remove the label from the chain and free its memory. */
1194 if (prev_label_chain
)
1195 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1197 label_symbols_rootp
= label_chain
->lss_next
;
1202 prev_label_chain
= label_chain
;
1207 /* An HPPA-specific version of fix_new. This is required because the HPPA
1208 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1209 results in the creation of an instance of an hppa_fix_struct. An
1210 hppa_fix_struct stores the extra information along with a pointer to the
1211 original fixS. This is attached to the original fixup via the
1212 tc_fix_data field. */
1215 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1216 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1220 symbolS
*add_symbol
;
1224 bfd_reloc_code_real_type r_type
;
1225 enum hppa_reloc_field_selector_type_alt r_field
;
1232 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1233 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1236 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1238 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1239 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1240 hppa_fix
->fx_r_type
= r_type
;
1241 hppa_fix
->fx_r_field
= r_field
;
1242 hppa_fix
->fx_r_format
= r_format
;
1243 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1244 hppa_fix
->segment
= now_seg
;
1246 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1247 new_fix
->fx_offset
= *unwind_bits
;
1250 /* foo-$global$ is used to access non-automatic storage. $global$
1251 is really just a marker and has served its purpose, so eliminate
1252 it now so as not to confuse write.c. */
1253 if (new_fix
->fx_subsy
1254 && !strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$"))
1255 new_fix
->fx_subsy
= NULL
;
1258 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1259 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1262 parse_cons_expression_hppa (exp
)
1265 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1269 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1270 hppa_field_selector is set by the parse_cons_expression_hppa. */
1273 cons_fix_new_hppa (frag
, where
, size
, exp
)
1279 unsigned int rel_type
;
1281 /* Get a base relocation type. */
1282 if (is_DP_relative (*exp
))
1283 rel_type
= R_HPPA_GOTOFF
;
1284 else if (is_complex (*exp
))
1285 rel_type
= R_HPPA_COMPLEX
;
1289 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1290 as_warn (_("Invalid field selector. Assuming F%%."));
1292 fix_new_hppa (frag
, where
, size
,
1293 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1294 hppa_field_selector
, 32, 0, NULL
);
1296 /* Reset field selector to its default state. */
1297 hppa_field_selector
= 0;
1300 /* This function is called once, at assembler startup time. It should
1301 set up all the tables, etc. that the MD part of the assembler will need. */
1306 const char *retval
= NULL
;
1310 last_call_info
= NULL
;
1311 call_info_root
= NULL
;
1313 /* Set the default machine type. */
1314 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1315 as_warn (_("could not set architecture and machine"));
1317 /* Folding of text and data segments fails miserably on the PA.
1318 Warn user and disable "-R" option. */
1319 if (flag_readonly_data_in_text
)
1321 as_warn (_("-R option not supported on this target."));
1322 flag_readonly_data_in_text
= 0;
1329 op_hash
= hash_new ();
1331 while (i
< NUMOPCODES
)
1333 const char *name
= pa_opcodes
[i
].name
;
1334 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1335 if (retval
!= NULL
&& *retval
!= '\0')
1337 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1342 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1343 != pa_opcodes
[i
].match
)
1345 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1346 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1351 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1355 as_fatal (_("Broken assembler. No assembly attempted."));
1358 /* SOM will change text_section. To make sure we never put
1359 anything into the old one switch to the new one now. */
1360 subseg_set (text_section
, 0);
1364 dummy_symbol
= symbol_find_or_make ("L$dummy");
1365 S_SET_SEGMENT (dummy_symbol
, text_section
);
1366 /* Force the symbol to be converted to a real symbol. */
1367 (void) symbol_get_bfdsym (dummy_symbol
);
1371 /* Assemble a single instruction storing it into a frag. */
1378 /* The had better be something to assemble. */
1381 /* If we are within a procedure definition, make sure we've
1382 defined a label for the procedure; handle case where the
1383 label was defined after the .PROC directive.
1385 Note there's not need to diddle with the segment or fragment
1386 for the label symbol in this case. We have already switched
1387 into the new $CODE$ subspace at this point. */
1388 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1390 label_symbol_struct
*label_symbol
= pa_get_label ();
1394 if (label_symbol
->lss_label
)
1396 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1397 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1400 /* Also handle allocation of a fixup to hold the unwind
1401 information when the label appears after the proc/procend. */
1402 if (within_entry_exit
)
1404 char *where
= frag_more (0);
1406 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1407 NULL
, (offsetT
) 0, NULL
,
1408 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1409 (int *)&last_call_info
->ci_unwind
.descriptor
);
1414 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1417 as_bad (_("Missing function name for .PROC"));
1420 /* Assemble the instruction. Results are saved into "the_insn". */
1423 /* Get somewhere to put the assembled instrution. */
1426 /* Output the opcode. */
1427 md_number_to_chars (to
, the_insn
.opcode
, 4);
1429 /* If necessary output more stuff. */
1430 if (the_insn
.reloc
!= R_HPPA_NONE
)
1431 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1432 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1433 the_insn
.reloc
, the_insn
.field_selector
,
1434 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1437 /* Do the real work for assembling a single instruction. Store results
1438 into the global "the_insn" variable. */
1444 char *error_message
= "";
1445 char *s
, c
, *argstart
, *name
, *save_s
;
1449 int cmpltr
, nullif
, flag
, cond
, num
;
1450 unsigned long opcode
;
1451 struct pa_opcode
*insn
;
1454 /* We must have a valid space and subspace. */
1455 pa_check_current_space_and_subspace ();
1458 /* Convert everything up to the first whitespace character into lower
1460 for (s
= str
; *s
!= ' ' && *s
!= '\t' && *s
!= '\n' && *s
!= '\0'; s
++)
1464 /* Skip to something interesting. */
1465 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1484 as_fatal (_("Unknown opcode: `%s'"), str
);
1489 /* Look up the opcode in the has table. */
1490 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1492 as_bad ("Unknown opcode: `%s'", str
);
1501 /* Mark the location where arguments for the instruction start, then
1502 start processing them. */
1506 /* Do some initialization. */
1507 opcode
= insn
->match
;
1508 memset (&the_insn
, 0, sizeof (the_insn
));
1510 the_insn
.reloc
= R_HPPA_NONE
;
1512 /* If this instruction is specific to a particular architecture,
1513 then set a new architecture. */
1514 /* But do not automatically promote to pa2.0. The automatic promotion
1515 crud is for compatability with HP's old assemblers only. */
1517 && bfd_get_mach (stdoutput
) < insn
->arch
)
1519 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1520 as_warn (_("could not update architecture and machine"));
1522 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1528 /* Build the opcode, checking as we go to make
1529 sure that the operands match. */
1530 for (args
= insn
->args
;; ++args
)
1535 /* End of arguments. */
1551 /* These must match exactly. */
1560 /* Handle a 5 bit register or control register field at 10. */
1563 num
= pa_parse_number (&s
, 0);
1564 CHECK_FIELD (num
, 31, 0, 0);
1565 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1567 /* Handle a 5 bit register field at 15. */
1569 num
= pa_parse_number (&s
, 0);
1570 CHECK_FIELD (num
, 31, 0, 0);
1571 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1573 /* Handle a 5 bit register field at 31. */
1576 num
= pa_parse_number (&s
, 0);
1577 CHECK_FIELD (num
, 31, 0, 0);
1578 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1580 /* Handle a 5 bit field length at 31. */
1582 num
= pa_get_absolute_expression (&the_insn
, &s
);
1584 CHECK_FIELD (num
, 32, 1, 0);
1585 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1587 /* Handle a 5 bit immediate at 15. */
1589 num
= pa_get_absolute_expression (&the_insn
, &s
);
1591 CHECK_FIELD (num
, 15, -16, 0);
1592 low_sign_unext (num
, 5, &num
);
1593 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1595 /* Handle a 5 bit immediate at 31. */
1597 num
= pa_get_absolute_expression (&the_insn
, &s
);
1599 CHECK_FIELD (num
, 15, -16, 0)
1600 low_sign_unext (num
, 5, &num
);
1601 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1603 /* Handle an unsigned 5 bit immediate at 31. */
1605 num
= pa_get_absolute_expression (&the_insn
, &s
);
1607 CHECK_FIELD (num
, 31, 0, 0);
1608 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1610 /* Handle an unsigned 5 bit immediate at 15. */
1612 num
= pa_get_absolute_expression (&the_insn
, &s
);
1614 CHECK_FIELD (num
, 31, 0, 0);
1615 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1617 /* Handle a 2 bit space identifier at 17. */
1619 num
= pa_parse_number (&s
, 0);
1620 CHECK_FIELD (num
, 3, 0, 1);
1621 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1623 /* Handle a 3 bit space identifier at 18. */
1625 num
= pa_parse_number (&s
, 0);
1626 CHECK_FIELD (num
, 7, 0, 1);
1627 dis_assemble_3 (num
, &num
);
1628 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
1630 /* Handle a completer for an indexing load or store. */
1636 while (*s
== ',' && i
< 2)
1639 if (strncasecmp (s
, "sm", 2) == 0)
1646 else if (strncasecmp (s
, "m", 1) == 0)
1648 else if (strncasecmp (s
, "s", 1) == 0)
1651 as_bad (_("Invalid Indexed Load Completer."));
1656 as_bad (_("Invalid Indexed Load Completer Syntax."));
1658 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1661 /* Handle a short load/store completer. */
1669 if (strncasecmp (s
, "ma", 2) == 0)
1674 else if (strncasecmp (s
, "mb", 2) == 0)
1680 as_bad (_("Invalid Short Load/Store Completer."));
1687 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1691 /* Handle a stbys completer. */
1697 while (*s
== ',' && i
< 2)
1700 if (strncasecmp (s
, "m", 1) == 0)
1702 else if (strncasecmp (s
, "b", 1) == 0)
1704 else if (strncasecmp (s
, "e", 1) == 0)
1707 as_bad (_("Invalid Store Bytes Short Completer"));
1712 as_bad (_("Invalid Store Bytes Short Completer"));
1714 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1717 /* Handle a non-negated compare/stubtract condition. */
1719 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
1722 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
1725 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1727 /* Handle a negated or non-negated compare/subtract condition. */
1730 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
1734 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
1737 as_bad (_("Invalid Compare/Subtract Condition."));
1742 /* Negated condition requires an opcode change. */
1747 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1749 /* Handle non-negated add condition. */
1751 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1754 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
1757 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1759 /* Handle a negated or non-negated add condition. */
1762 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1766 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
1769 as_bad (_("Invalid Compare/Subtract Condition"));
1774 /* Negated condition requires an opcode change. */
1778 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1780 /* Handle a compare/subtract condition. */
1788 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1792 if (strcmp (name
, "=") == 0)
1794 else if (strcmp (name
, "<") == 0)
1796 else if (strcmp (name
, "<=") == 0)
1798 else if (strcasecmp (name
, "<<") == 0)
1800 else if (strcasecmp (name
, "<<=") == 0)
1802 else if (strcasecmp (name
, "sv") == 0)
1804 else if (strcasecmp (name
, "od") == 0)
1806 else if (strcasecmp (name
, "tr") == 0)
1811 else if (strcmp (name
, "<>") == 0)
1816 else if (strcmp (name
, ">=") == 0)
1821 else if (strcmp (name
, ">") == 0)
1826 else if (strcasecmp (name
, ">>=") == 0)
1831 else if (strcasecmp (name
, ">>") == 0)
1836 else if (strcasecmp (name
, "nsv") == 0)
1841 else if (strcasecmp (name
, "ev") == 0)
1847 as_bad (_("Invalid Add Condition: %s"), name
);
1850 opcode
|= cmpltr
<< 13;
1851 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1853 /* Handle a non-negated add condition. */
1861 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1865 if (strcmp (name
, "=") == 0)
1867 else if (strcmp (name
, "<") == 0)
1869 else if (strcmp (name
, "<=") == 0)
1871 else if (strcasecmp (name
, "nuv") == 0)
1873 else if (strcasecmp (name
, "znv") == 0)
1875 else if (strcasecmp (name
, "sv") == 0)
1877 else if (strcasecmp (name
, "od") == 0)
1879 else if (strcasecmp (name
, "tr") == 0)
1884 else if (strcmp (name
, "<>") == 0)
1889 else if (strcmp (name
, ">=") == 0)
1894 else if (strcmp (name
, ">") == 0)
1899 else if (strcasecmp (name
, "uv") == 0)
1904 else if (strcasecmp (name
, "vnz") == 0)
1909 else if (strcasecmp (name
, "nsv") == 0)
1914 else if (strcasecmp (name
, "ev") == 0)
1920 as_bad (_("Invalid Add Condition: %s"), name
);
1923 opcode
|= cmpltr
<< 13;
1924 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1926 /* HANDLE a logical instruction condition. */
1934 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1940 if (strcmp (name
, "=") == 0)
1942 else if (strcmp (name
, "<") == 0)
1944 else if (strcmp (name
, "<=") == 0)
1946 else if (strcasecmp (name
, "od") == 0)
1948 else if (strcasecmp (name
, "tr") == 0)
1953 else if (strcmp (name
, "<>") == 0)
1958 else if (strcmp (name
, ">=") == 0)
1963 else if (strcmp (name
, ">") == 0)
1968 else if (strcasecmp (name
, "ev") == 0)
1974 as_bad (_("Invalid Logical Instruction Condition."));
1977 opcode
|= cmpltr
<< 13;
1978 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1980 /* Handle a unit instruction condition. */
1989 if (strncasecmp (s
, "sbz", 3) == 0)
1994 else if (strncasecmp (s
, "shz", 3) == 0)
1999 else if (strncasecmp (s
, "sdc", 3) == 0)
2004 else if (strncasecmp (s
, "sbc", 3) == 0)
2009 else if (strncasecmp (s
, "shc", 3) == 0)
2014 else if (strncasecmp (s
, "tr", 2) == 0)
2020 else if (strncasecmp (s
, "nbz", 3) == 0)
2026 else if (strncasecmp (s
, "nhz", 3) == 0)
2032 else if (strncasecmp (s
, "ndc", 3) == 0)
2038 else if (strncasecmp (s
, "nbc", 3) == 0)
2044 else if (strncasecmp (s
, "nhc", 3) == 0)
2051 as_bad (_("Invalid Logical Instruction Condition."));
2053 opcode
|= cmpltr
<< 13;
2054 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2056 /* Handle a shift/extract/deposit condition. */
2066 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2070 if (strcmp (name
, "=") == 0)
2072 else if (strcmp (name
, "<") == 0)
2074 else if (strcasecmp (name
, "od") == 0)
2076 else if (strcasecmp (name
, "tr") == 0)
2078 else if (strcmp (name
, "<>") == 0)
2080 else if (strcmp (name
, ">=") == 0)
2082 else if (strcasecmp (name
, "ev") == 0)
2084 /* Handle movb,n. Put things back the way they were.
2085 This includes moving s back to where it started. */
2086 else if (strcasecmp (name
, "n") == 0 && *args
== '|')
2093 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2096 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2098 /* Handle bvb and bb conditions. */
2104 if (strncmp (s
, "<", 1) == 0)
2109 else if (strncmp (s
, ">=", 2) == 0)
2115 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2117 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2119 /* Handle a system control completer. */
2121 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2129 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2131 /* Handle a nullification completer for branch instructions. */
2133 nullif
= pa_parse_nullif (&s
);
2134 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2136 /* Handle a nullification completer for copr and spop insns. */
2138 nullif
= pa_parse_nullif (&s
);
2139 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2142 /* Handle a 11 bit immediate at 31. */
2144 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2147 if (the_insn
.exp
.X_op
== O_constant
)
2149 num
= evaluate_absolute (&the_insn
);
2150 CHECK_FIELD (num
, 1023, -1024, 0);
2151 low_sign_unext (num
, 11, &num
);
2152 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2156 if (is_DP_relative (the_insn
.exp
))
2157 the_insn
.reloc
= R_HPPA_GOTOFF
;
2158 else if (is_PC_relative (the_insn
.exp
))
2159 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2161 the_insn
.reloc
= R_HPPA
;
2162 the_insn
.format
= 11;
2167 /* Handle a 14 bit immediate at 31. */
2169 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2172 if (the_insn
.exp
.X_op
== O_constant
)
2174 num
= evaluate_absolute (&the_insn
);
2175 CHECK_FIELD (num
, 8191, -8192, 0);
2176 low_sign_unext (num
, 14, &num
);
2177 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2181 if (is_DP_relative (the_insn
.exp
))
2182 the_insn
.reloc
= R_HPPA_GOTOFF
;
2183 else if (is_PC_relative (the_insn
.exp
))
2184 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2186 the_insn
.reloc
= R_HPPA
;
2187 the_insn
.format
= 14;
2191 /* Handle a 21 bit immediate at 31. */
2193 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2196 if (the_insn
.exp
.X_op
== O_constant
)
2198 num
= evaluate_absolute (&the_insn
);
2199 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
2200 dis_assemble_21 (num
, &num
);
2201 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2205 if (is_DP_relative (the_insn
.exp
))
2206 the_insn
.reloc
= R_HPPA_GOTOFF
;
2207 else if (is_PC_relative (the_insn
.exp
))
2208 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2210 the_insn
.reloc
= R_HPPA
;
2211 the_insn
.format
= 21;
2215 /* Handle a 12 bit branch displacement. */
2217 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2221 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
2223 unsigned int w1
, w
, result
;
2225 num
= evaluate_absolute (&the_insn
);
2228 as_bad (_("Branch to unaligned address"));
2231 CHECK_FIELD (num
, 8199, -8184, 0);
2232 sign_unext ((num
- 8) >> 2, 12, &result
);
2233 dis_assemble_12 (result
, &w1
, &w
);
2234 INSERT_FIELD_AND_CONTINUE (opcode
, ((w1
<< 2) | w
), 0);
2238 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2239 the_insn
.format
= 12;
2240 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2241 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2246 /* Handle a 17 bit branch displacement. */
2248 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2252 if (!the_insn
.exp
.X_add_symbol
2253 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2256 unsigned int w2
, w1
, w
, result
;
2258 num
= evaluate_absolute (&the_insn
);
2261 as_bad (_("Branch to unaligned address"));
2264 CHECK_FIELD (num
, 262143, -262144, 0);
2266 if (the_insn
.exp
.X_add_symbol
)
2269 sign_unext (num
>> 2, 17, &result
);
2270 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2271 INSERT_FIELD_AND_CONTINUE (opcode
,
2272 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2276 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2277 the_insn
.format
= 17;
2278 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2279 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2283 /* Handle an absolute 17 bit branch target. */
2285 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2289 if (!the_insn
.exp
.X_add_symbol
2290 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2293 unsigned int w2
, w1
, w
, result
;
2295 num
= evaluate_absolute (&the_insn
);
2298 as_bad (_("Branch to unaligned address"));
2301 CHECK_FIELD (num
, 262143, -262144, 0);
2303 if (the_insn
.exp
.X_add_symbol
)
2306 sign_unext (num
>> 2, 17, &result
);
2307 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2308 INSERT_FIELD_AND_CONTINUE (opcode
,
2309 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2313 the_insn
.reloc
= R_HPPA_ABS_CALL
;
2314 the_insn
.format
= 17;
2315 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2316 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2320 /* Handle a 5 bit shift count at 26. */
2322 num
= pa_get_absolute_expression (&the_insn
, &s
);
2324 CHECK_FIELD (num
, 31, 0, 0);
2325 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
2327 /* Handle a 5 bit bit position at 26. */
2329 num
= pa_get_absolute_expression (&the_insn
, &s
);
2331 CHECK_FIELD (num
, 31, 0, 0);
2332 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
2334 /* Handle a 5 bit immediate at 10. */
2337 num
= pa_get_absolute_expression (&the_insn
, &s
);
2338 if (the_insn
.exp
.X_op
!= O_constant
)
2341 CHECK_FIELD (num
, 31, 0, 0);
2342 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
2344 /* Handle a 13 bit immediate at 18. */
2346 num
= pa_get_absolute_expression (&the_insn
, &s
);
2348 CHECK_FIELD (num
, 8191, 0, 0);
2349 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2351 /* Handle a 26 bit immediate at 31. */
2353 num
= pa_get_absolute_expression (&the_insn
, &s
);
2355 CHECK_FIELD (num
, 671108864, 0, 0);
2356 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2358 /* Handle a 3 bit SFU identifier at 25. */
2361 as_bad (_("Invalid SFU identifier"));
2362 num
= pa_get_absolute_expression (&the_insn
, &s
);
2364 CHECK_FIELD (num
, 7, 0, 0);
2365 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2367 /* Handle a 20 bit SOP field for spop0. */
2369 num
= pa_get_absolute_expression (&the_insn
, &s
);
2371 CHECK_FIELD (num
, 1048575, 0, 0);
2372 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
2373 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2375 /* Handle a 15bit SOP field for spop1. */
2377 num
= pa_get_absolute_expression (&the_insn
, &s
);
2379 CHECK_FIELD (num
, 32767, 0, 0);
2380 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
2382 /* Handle a 10bit SOP field for spop3. */
2384 num
= pa_get_absolute_expression (&the_insn
, &s
);
2386 CHECK_FIELD (num
, 1023, 0, 0);
2387 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
2388 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2390 /* Handle a 15 bit SOP field for spop2. */
2392 num
= pa_get_absolute_expression (&the_insn
, &s
);
2394 CHECK_FIELD (num
, 32767, 0, 0);
2395 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
2396 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2398 /* Handle a 3-bit co-processor ID field. */
2401 as_bad (_("Invalid COPR identifier"));
2402 num
= pa_get_absolute_expression (&the_insn
, &s
);
2404 CHECK_FIELD (num
, 7, 0, 0);
2405 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2407 /* Handle a 22bit SOP field for copr. */
2409 num
= pa_get_absolute_expression (&the_insn
, &s
);
2411 CHECK_FIELD (num
, 4194303, 0, 0);
2412 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
2413 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2416 /* Handle a source FP operand format completer. */
2418 flag
= pa_parse_fp_format (&s
);
2419 the_insn
.fpof1
= flag
;
2420 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2422 /* Handle a destination FP operand format completer. */
2424 /* pa_parse_format needs the ',' prefix. */
2426 flag
= pa_parse_fp_format (&s
);
2427 the_insn
.fpof2
= flag
;
2428 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
2430 /* Handle FP compare conditions. */
2432 cond
= pa_parse_fp_cmp_cond (&s
);
2433 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2435 /* Handle L/R register halves like 't'. */
2438 struct pa_11_fp_reg_struct result
;
2440 pa_parse_number (&s
, &result
);
2441 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2442 opcode
|= result
.number_part
;
2444 /* 0x30 opcodes are FP arithmetic operation opcodes
2445 and need to be turned into 0x38 opcodes. This
2446 is not necessary for loads/stores. */
2447 if (need_pa11_opcode (&the_insn
, &result
)
2448 && ((opcode
& 0xfc000000) == 0x30000000))
2451 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
2454 /* Handle L/R register halves like 'b'. */
2457 struct pa_11_fp_reg_struct result
;
2459 pa_parse_number (&s
, &result
);
2460 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2461 opcode
|= result
.number_part
<< 21;
2462 if (need_pa11_opcode (&the_insn
, &result
))
2464 opcode
|= (result
.l_r_select
& 1) << 7;
2470 /* Handle L/R register halves like 'b'. */
2473 struct pa_11_fp_reg_struct result
;
2476 pa_parse_number (&s
, &result
);
2477 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2478 opcode
|= (result
.number_part
& 0x1c) << 11;
2479 opcode
|= (result
.number_part
& 0x3) << 9;
2480 opcode
|= (result
.l_r_select
& 1) << 8;
2484 /* Handle L/R register halves like 'x'. */
2487 struct pa_11_fp_reg_struct result
;
2489 pa_parse_number (&s
, &result
);
2490 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2491 opcode
|= (result
.number_part
& 0x1f) << 16;
2492 if (need_pa11_opcode (&the_insn
, &result
))
2494 opcode
|= (result
.l_r_select
& 1) << 1;
2499 /* Handle L/R register halves like 'x'. */
2502 struct pa_11_fp_reg_struct result
;
2504 pa_parse_number (&s
, &result
);
2505 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2506 opcode
|= (result
.number_part
& 0x1f) << 16;
2507 if (need_pa11_opcode (&the_insn
, &result
))
2509 opcode
|= (result
.l_r_select
& 1) << 12;
2515 /* Handle a 5 bit register field at 10. */
2518 struct pa_11_fp_reg_struct result
;
2520 pa_parse_number (&s
, &result
);
2521 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2522 if (the_insn
.fpof1
== SGL
)
2524 if (result
.number_part
< 16)
2526 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2530 result
.number_part
&= 0xF;
2531 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2533 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
2536 /* Handle a 5 bit register field at 15. */
2539 struct pa_11_fp_reg_struct result
;
2541 pa_parse_number (&s
, &result
);
2542 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2543 if (the_insn
.fpof1
== SGL
)
2545 if (result
.number_part
< 16)
2547 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2550 result
.number_part
&= 0xF;
2551 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2553 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
2556 /* Handle a 5 bit register field at 31. */
2559 struct pa_11_fp_reg_struct result
;
2561 pa_parse_number (&s
, &result
);
2562 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2563 if (the_insn
.fpof1
== SGL
)
2565 if (result
.number_part
< 16)
2567 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2570 result
.number_part
&= 0xF;
2571 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2573 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
2576 /* Handle a 5 bit register field at 20. */
2579 struct pa_11_fp_reg_struct result
;
2581 pa_parse_number (&s
, &result
);
2582 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2583 if (the_insn
.fpof1
== SGL
)
2585 if (result
.number_part
< 16)
2587 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2590 result
.number_part
&= 0xF;
2591 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2593 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
2596 /* Handle a 5 bit register field at 25. */
2599 struct pa_11_fp_reg_struct result
;
2601 pa_parse_number (&s
, &result
);
2602 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2603 if (the_insn
.fpof1
== SGL
)
2605 if (result
.number_part
< 16)
2607 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2610 result
.number_part
&= 0xF;
2611 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2613 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
2616 /* Handle a floating point operand format at 26.
2617 Only allows single and double precision. */
2619 flag
= pa_parse_fp_format (&s
);
2625 the_insn
.fpof1
= flag
;
2631 as_bad (_("Invalid Floating Point Operand Format."));
2642 /* Check if the args matched. */
2645 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
2646 && !strcmp (insn
->name
, insn
[1].name
))
2654 as_bad (_("Invalid operands %s"), error_message
);
2661 the_insn
.opcode
= opcode
;
2664 /* Turn a string in input_line_pointer into a floating point constant of type
2665 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
2666 emitted is stored in *sizeP . An error message or NULL is returned. */
2668 #define MAX_LITTLENUMS 6
2671 md_atof (type
, litP
, sizeP
)
2677 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
2678 LITTLENUM_TYPE
*wordP
;
2710 return _("Bad call to MD_ATOF()");
2712 t
= atof_ieee (input_line_pointer
, type
, words
);
2714 input_line_pointer
= t
;
2715 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
2716 for (wordP
= words
; prec
--;)
2718 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
2719 litP
+= sizeof (LITTLENUM_TYPE
);
2724 /* Write out big-endian. */
2727 md_number_to_chars (buf
, val
, n
)
2732 number_to_chars_bigendian (buf
, val
, n
);
2735 /* Translate internal representation of relocation info to BFD target
2739 tc_gen_reloc (section
, fixp
)
2744 struct hppa_fix_struct
*hppa_fixp
;
2745 bfd_reloc_code_real_type code
;
2746 static arelent
*no_relocs
= NULL
;
2748 bfd_reloc_code_real_type
**codes
;
2752 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
2753 if (fixp
->fx_addsy
== 0)
2755 assert (hppa_fixp
!= 0);
2756 assert (section
!= 0);
2758 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
2760 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2761 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2762 codes
= (bfd_reloc_code_real_type
**) hppa_gen_reloc_type (stdoutput
,
2764 hppa_fixp
->fx_r_format
,
2765 hppa_fixp
->fx_r_field
,
2766 fixp
->fx_subsy
!= NULL
,
2767 symbol_get_bfdsym (fixp
->fx_addsy
));
2772 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
2775 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
2776 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
2777 for (i
= 0; i
< n_relocs
; i
++)
2778 relocs
[i
] = &reloc
[i
];
2780 relocs
[n_relocs
] = NULL
;
2783 switch (fixp
->fx_r_type
)
2786 assert (n_relocs
== 1);
2790 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2791 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2792 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2793 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2794 reloc
->addend
= 0; /* default */
2796 assert (reloc
->howto
&& code
== reloc
->howto
->type
);
2798 /* Now, do any processing that is dependent on the relocation type. */
2801 case R_PARISC_DLTREL21L
:
2802 case R_PARISC_DLTREL14R
:
2803 case R_PARISC_DLTREL14F
:
2804 case R_PARISC_PLABEL32
:
2805 case R_PARISC_PLABEL21L
:
2806 case R_PARISC_PLABEL14R
:
2807 /* For plabel relocations, the addend of the
2808 relocation should be either 0 (no static link) or 2
2809 (static link required).
2811 FIXME: We always assume no static link!
2813 We also slam a zero addend into the DLT relative relocs;
2814 it doesn't make a lot of sense to use any addend since
2815 it gets you a different (eg unknown) DLT entry. */
2819 case R_PARISC_PCREL21L
:
2820 case R_PARISC_PCREL17R
:
2821 case R_PARISC_PCREL17F
:
2822 case R_PARISC_PCREL17C
:
2823 case R_PARISC_PCREL14R
:
2824 case R_PARISC_PCREL14F
:
2825 /* The constant is stored in the instruction. */
2826 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
2829 reloc
->addend
= fixp
->fx_offset
;
2836 /* Walk over reach relocation returned by the BFD backend. */
2837 for (i
= 0; i
< n_relocs
; i
++)
2841 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2842 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2843 relocs
[i
]->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2844 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2849 /* The only time we ever use a R_COMP2 fixup is for the difference
2850 of two symbols. With that in mind we fill in all four
2851 relocs now and break out of the loop. */
2853 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
2854 relocs
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[0]);
2855 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2856 relocs
[0]->addend
= 0;
2857 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2858 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2859 relocs
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[1]);
2860 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2861 relocs
[1]->addend
= 0;
2862 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2863 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
2864 relocs
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[2]);
2865 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2866 relocs
[2]->addend
= 0;
2867 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
2868 relocs
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[3]);
2869 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2870 relocs
[3]->addend
= 0;
2871 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
2872 relocs
[4]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[4]);
2873 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2874 relocs
[4]->addend
= 0;
2878 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
2884 /* For plabel relocations, the addend of the
2885 relocation should be either 0 (no static link) or 2
2886 (static link required).
2888 FIXME: We always assume no static link!
2890 We also slam a zero addend into the DLT relative relocs;
2891 it doesn't make a lot of sense to use any addend since
2892 it gets you a different (eg unknown) DLT entry. */
2893 relocs
[i
]->addend
= 0;
2908 /* There is no symbol or addend associated with these fixups. */
2909 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2910 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
2911 relocs
[i
]->addend
= 0;
2917 /* There is no symbol associated with these fixups. */
2918 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2919 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
2920 relocs
[i
]->addend
= fixp
->fx_offset
;
2924 relocs
[i
]->addend
= fixp
->fx_offset
;
2934 /* Process any machine dependent frag types. */
2937 md_convert_frag (abfd
, sec
, fragP
)
2939 register asection
*sec
;
2940 register fragS
*fragP
;
2942 unsigned int address
;
2944 if (fragP
->fr_type
== rs_machine_dependent
)
2946 switch ((int) fragP
->fr_subtype
)
2949 fragP
->fr_type
= rs_fill
;
2950 know (fragP
->fr_var
== 1);
2951 know (fragP
->fr_next
);
2952 address
= fragP
->fr_address
+ fragP
->fr_fix
;
2953 if (address
% fragP
->fr_offset
)
2956 fragP
->fr_next
->fr_address
2961 fragP
->fr_offset
= 0;
2967 /* Round up a section size to the appropriate boundary. */
2970 md_section_align (segment
, size
)
2974 int align
= bfd_get_section_alignment (stdoutput
, segment
);
2975 int align2
= (1 << align
) - 1;
2977 return (size
+ align2
) & ~align2
;
2980 /* Return the approximate size of a frag before relaxation has occurred. */
2982 md_estimate_size_before_relax (fragP
, segment
)
2983 register fragS
*fragP
;
2990 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
2996 CONST
char *md_shortopts
= "";
2997 struct option md_longopts
[] = {
2998 {NULL
, no_argument
, NULL
, 0}
3000 size_t md_longopts_size
= sizeof(md_longopts
);
3003 md_parse_option (c
, arg
)
3011 md_show_usage (stream
)
3016 /* We have no need to default values of symbols. */
3019 md_undefined_symbol (name
)
3025 /* Apply a fixup to an instruction. */
3028 md_apply_fix (fixP
, valp
)
3032 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
3033 struct hppa_fix_struct
*hppa_fixP
;
3034 long new_val
, result
= 0;
3035 unsigned int w1
, w2
, w
, resulti
;
3037 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
3038 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
3039 never be "applied" (they are just markers). Likewise for
3040 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
3042 if (fixP
->fx_r_type
== R_HPPA_ENTRY
3043 || fixP
->fx_r_type
== R_HPPA_EXIT
3044 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
3045 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
3046 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
3049 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
3050 fixups are considered not adjustable, which in turn causes
3051 adjust_reloc_syms to not set fx_offset. Ugh. */
3052 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
3054 fixP
->fx_offset
= *valp
;
3059 /* There should have been an HPPA specific fixup associated
3060 with the GAS fixup. */
3063 unsigned long buf_wd
= bfd_get_32 (stdoutput
, buf
);
3064 unsigned char fmt
= bfd_hppa_insn2fmt (buf_wd
);
3066 /* If there is a symbol associated with this fixup, then it's something
3067 which will need a SOM relocation (except for some PC-relative relocs).
3068 In such cases we should treat the "val" or "addend" as zero since it
3069 will be added in as needed from fx_offset in tc_gen_reloc. */
3070 if ((fixP
->fx_addsy
!= NULL
3071 || fixP
->fx_r_type
== R_HPPA_NONE
)
3076 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3078 /* These field selectors imply that we do not want an addend. */
3079 else if (hppa_fixP
->fx_r_field
== e_psel
3080 || hppa_fixP
->fx_r_field
== e_rpsel
3081 || hppa_fixP
->fx_r_field
== e_lpsel
3082 || hppa_fixP
->fx_r_field
== e_tsel
3083 || hppa_fixP
->fx_r_field
== e_rtsel
3084 || hppa_fixP
->fx_r_field
== e_ltsel
)
3085 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3086 /* This is truely disgusting. The machine independent code blindly
3087 adds in the value of the symbol being relocated against. Damn! */
3089 && fixP
->fx_addsy
!= NULL
3090 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
3091 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
3092 0, hppa_fixP
->fx_r_field
);
3095 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3097 /* Handle pc-relative exceptions from above. */
3098 #define arg_reloc_stub_needed(CALLER, CALLEE) \
3099 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
3100 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
3104 && !arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
3105 symbol_get_bfdsym (fixP
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
3106 hppa_fixP
->fx_arg_reloc
)
3108 && (((int)(*valp
) > -262144 && (int)(*valp
) < 262143) && fmt
!= 22)
3109 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
3111 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
3113 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3114 #undef arg_reloc_stub_needed
3118 /* Handle all opcodes with the 'j' operand type. */
3120 CHECK_FIELD (new_val
, 8191, -8192, 0);
3122 /* Mask off 14 bits to be changed. */
3123 bfd_put_32 (stdoutput
,
3124 bfd_get_32 (stdoutput
, buf
) & 0xffffc000,
3126 low_sign_unext (new_val
, 14, &resulti
);
3130 /* Handle all opcodes with the 'k' operand type. */
3132 CHECK_FIELD (new_val
, 2097152, 0, 0);
3134 /* Mask off 21 bits to be changed. */
3135 bfd_put_32 (stdoutput
,
3136 bfd_get_32 (stdoutput
, buf
) & 0xffe00000,
3138 dis_assemble_21 (new_val
, &resulti
);
3142 /* Handle all the opcodes with the 'i' operand type. */
3144 CHECK_FIELD (new_val
, 1023, -1023, 0);
3146 /* Mask off 11 bits to be changed. */
3147 bfd_put_32 (stdoutput
,
3148 bfd_get_32 (stdoutput
, buf
) & 0xffff800,
3150 low_sign_unext (new_val
, 11, &resulti
);
3154 /* Handle all the opcodes with the 'w' operand type. */
3156 CHECK_FIELD (new_val
, 8199, -8184, 0);
3158 /* Mask off 11 bits to be changed. */
3159 sign_unext ((new_val
- 8) >> 2, 12, &resulti
);
3160 bfd_put_32 (stdoutput
,
3161 bfd_get_32 (stdoutput
, buf
) & 0xffffe002,
3164 dis_assemble_12 (resulti
, &w1
, &w
);
3165 result
= ((w1
<< 2) | w
);
3168 /* Handle some of the opcodes with the 'W' operand type. */
3171 int distance
= *valp
;
3173 CHECK_FIELD (new_val
, 262143, -262144, 0);
3175 /* If this is an absolute branch (ie no link) with an out of
3176 range target, then we want to complain. */
3177 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
3178 && (distance
> 262143 || distance
< -262144)
3179 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
3180 CHECK_FIELD (distance
, 262143, -262144, 0);
3182 /* Mask off 17 bits to be changed. */
3183 bfd_put_32 (stdoutput
,
3184 bfd_get_32 (stdoutput
, buf
) & 0xffe0e002,
3186 sign_unext ((new_val
- 8) >> 2, 17, &resulti
);
3187 dis_assemble_17 (resulti
, &w1
, &w2
, &w
);
3188 result
= ((w2
<< 2) | (w1
<< 16) | w
);
3194 bfd_put_32 (stdoutput
, new_val
, buf
);
3198 as_bad (_("Unknown relocation encountered in md_apply_fix."));
3202 /* Insert the relocation. */
3203 bfd_put_32 (stdoutput
, bfd_get_32 (stdoutput
, buf
) | result
, buf
);
3208 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
3209 (unsigned int) fixP
, fixP
->fx_r_type
);
3214 /* Exactly what point is a PC-relative offset relative TO?
3215 On the PA, they're relative to the address of the offset. */
3218 md_pcrel_from (fixP
)
3221 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
3224 /* Return nonzero if the input line pointer is at the end of
3228 is_end_of_statement ()
3230 return ((*input_line_pointer
== '\n')
3231 || (*input_line_pointer
== ';')
3232 || (*input_line_pointer
== '!'));
3235 /* Read a number from S. The number might come in one of many forms,
3236 the most common will be a hex or decimal constant, but it could be
3237 a pre-defined register (Yuk!), or an absolute symbol.
3239 Return a number or -1 for failure.
3241 When parsing PA-89 FP register numbers RESULT will be
3242 the address of a structure to return information about
3243 L/R half of FP registers, store results there as appropriate.
3245 pa_parse_number can not handle negative constants and will fail
3246 horribly if it is passed such a constant. */
3249 pa_parse_number (s
, result
)
3251 struct pa_11_fp_reg_struct
*result
;
3260 /* Skip whitespace before the number. */
3261 while (*p
== ' ' || *p
== '\t')
3264 /* Store info in RESULT if requested by caller. */
3267 result
->number_part
= -1;
3268 result
->l_r_select
= -1;
3274 /* Looks like a number. */
3277 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
3279 /* The number is specified in hex. */
3281 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
3282 || ((*p
>= 'A') && (*p
<= 'F')))
3285 num
= num
* 16 + *p
- '0';
3286 else if (*p
>= 'a' && *p
<= 'f')
3287 num
= num
* 16 + *p
- 'a' + 10;
3289 num
= num
* 16 + *p
- 'A' + 10;
3295 /* The number is specified in decimal. */
3296 while (isdigit (*p
))
3298 num
= num
* 10 + *p
- '0';
3303 /* Store info in RESULT if requested by the caller. */
3306 result
->number_part
= num
;
3308 if (IS_R_SELECT (p
))
3310 result
->l_r_select
= 1;
3313 else if (IS_L_SELECT (p
))
3315 result
->l_r_select
= 0;
3319 result
->l_r_select
= 0;
3324 /* The number might be a predefined register. */
3329 /* Tege hack: Special case for general registers as the general
3330 code makes a binary search with case translation, and is VERY
3335 if (*p
== 'e' && *(p
+ 1) == 't'
3336 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
3339 num
= *p
- '0' + 28;
3347 else if (!isdigit (*p
))
3350 as_bad (_("Undefined register: '%s'."), name
);
3356 num
= num
* 10 + *p
++ - '0';
3357 while (isdigit (*p
));
3362 /* Do a normal register search. */
3363 while (is_part_of_name (c
))
3369 status
= reg_name_search (name
);
3375 as_bad (_("Undefined register: '%s'."), name
);
3381 /* Store info in RESULT if requested by caller. */
3384 result
->number_part
= num
;
3385 if (IS_R_SELECT (p
- 1))
3386 result
->l_r_select
= 1;
3387 else if (IS_L_SELECT (p
- 1))
3388 result
->l_r_select
= 0;
3390 result
->l_r_select
= 0;
3395 /* And finally, it could be a symbol in the absolute section which
3396 is effectively a constant. */
3400 while (is_part_of_name (c
))
3406 if ((sym
= symbol_find (name
)) != NULL
)
3408 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
3409 num
= S_GET_VALUE (sym
);
3413 as_bad (_("Non-absolute symbol: '%s'."), name
);
3419 /* There is where we'd come for an undefined symbol
3420 or for an empty string. For an empty string we
3421 will return zero. That's a concession made for
3422 compatability with the braindamaged HP assemblers. */
3428 as_bad (_("Undefined absolute constant: '%s'."), name
);
3434 /* Store info in RESULT if requested by caller. */
3437 result
->number_part
= num
;
3438 if (IS_R_SELECT (p
- 1))
3439 result
->l_r_select
= 1;
3440 else if (IS_L_SELECT (p
- 1))
3441 result
->l_r_select
= 0;
3443 result
->l_r_select
= 0;
3451 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
3453 /* Given NAME, find the register number associated with that name, return
3454 the integer value associated with the given name or -1 on failure. */
3457 reg_name_search (name
)
3460 int middle
, low
, high
;
3464 high
= REG_NAME_CNT
- 1;
3468 middle
= (low
+ high
) / 2;
3469 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
3475 return pre_defined_registers
[middle
].value
;
3477 while (low
<= high
);
3483 /* Return nonzero if the given INSN and L/R information will require
3484 a new PA-1.1 opcode. */
3487 need_pa11_opcode (insn
, result
)
3489 struct pa_11_fp_reg_struct
*result
;
3491 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
3493 /* If this instruction is specific to a particular architecture,
3494 then set a new architecture. */
3495 if (bfd_get_mach (stdoutput
) < pa11
)
3497 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
3498 as_warn (_("could not update architecture and machine"));
3506 /* Parse a condition for a fcmp instruction. Return the numerical
3507 code associated with the condition. */
3510 pa_parse_fp_cmp_cond (s
)
3517 for (i
= 0; i
< 32; i
++)
3519 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
3520 strlen (fp_cond_map
[i
].string
)) == 0)
3522 cond
= fp_cond_map
[i
].cond
;
3523 *s
+= strlen (fp_cond_map
[i
].string
);
3524 /* If not a complete match, back up the input string and
3526 if (**s
!= ' ' && **s
!= '\t')
3528 *s
-= strlen (fp_cond_map
[i
].string
);
3531 while (**s
== ' ' || **s
== '\t')
3537 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
3539 /* Advance over the bogus completer. */
3540 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3547 /* Parse an FP operand format completer returning the completer
3550 static fp_operand_format
3551 pa_parse_fp_format (s
)
3560 if (strncasecmp (*s
, "sgl", 3) == 0)
3565 else if (strncasecmp (*s
, "dbl", 3) == 0)
3570 else if (strncasecmp (*s
, "quad", 4) == 0)
3577 format
= ILLEGAL_FMT
;
3578 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
3585 /* Convert from a selector string into a selector type. */
3588 pa_chk_field_selector (str
)
3591 int middle
, low
, high
;
3595 /* Read past any whitespace. */
3596 /* FIXME: should we read past newlines and formfeeds??? */
3597 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
3600 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
3601 name
[0] = tolower ((*str
)[0]),
3603 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
3604 name
[0] = tolower ((*str
)[0]),
3605 name
[1] = tolower ((*str
)[1]),
3608 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
3609 name
[0] = tolower ((*str
)[0]),
3610 name
[1] = tolower ((*str
)[1]),
3611 name
[2] = tolower ((*str
)[2]),
3618 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
3622 middle
= (low
+ high
) / 2;
3623 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
3630 *str
+= strlen (name
) + 1;
3632 if (selector_table
[middle
].field_selector
== e_nsel
)
3635 return selector_table
[middle
].field_selector
;
3638 while (low
<= high
);
3643 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
3646 get_expression (str
)
3652 save_in
= input_line_pointer
;
3653 input_line_pointer
= str
;
3654 seg
= expression (&the_insn
.exp
);
3655 if (!(seg
== absolute_section
3656 || seg
== undefined_section
3657 || SEG_NORMAL (seg
)))
3659 as_warn (_("Bad segment in expression."));
3660 expr_end
= input_line_pointer
;
3661 input_line_pointer
= save_in
;
3664 expr_end
= input_line_pointer
;
3665 input_line_pointer
= save_in
;
3669 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
3671 pa_get_absolute_expression (insn
, strp
)
3677 insn
->field_selector
= pa_chk_field_selector (strp
);
3678 save_in
= input_line_pointer
;
3679 input_line_pointer
= *strp
;
3680 expression (&insn
->exp
);
3681 /* This is not perfect, but is a huge improvement over doing nothing.
3683 The PA assembly syntax is ambigious in a variety of ways. Consider
3684 this string "4 %r5" Is that the number 4 followed by the register
3685 r5, or is that 4 MOD 5?
3687 If we get a modulo expresion When looking for an absolute, we try
3688 again cutting off the input string at the first whitespace character. */
3689 if (insn
->exp
.X_op
== O_modulus
)
3694 input_line_pointer
= *strp
;
3696 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
3702 retval
= pa_get_absolute_expression (insn
, strp
);
3704 input_line_pointer
= save_in
;
3706 return evaluate_absolute (insn
);
3708 if (insn
->exp
.X_op
!= O_constant
)
3710 as_bad (_("Bad segment (should be absolute)."));
3711 expr_end
= input_line_pointer
;
3712 input_line_pointer
= save_in
;
3715 expr_end
= input_line_pointer
;
3716 input_line_pointer
= save_in
;
3717 return evaluate_absolute (insn
);
3720 /* Evaluate an absolute expression EXP which may be modified by
3721 the selector FIELD_SELECTOR. Return the value of the expression. */
3723 evaluate_absolute (insn
)
3728 int field_selector
= insn
->field_selector
;
3731 value
= exp
.X_add_number
;
3733 switch (field_selector
)
3739 /* If bit 21 is on then add 0x800 and arithmetic shift right 11 bits. */
3741 if (value
& 0x00000400)
3743 value
= (value
& 0xfffff800) >> 11;
3746 /* Sign extend from bit 21. */
3748 if (value
& 0x00000400)
3749 value
|= 0xfffff800;
3754 /* Arithmetic shift right 11 bits. */
3756 value
= (value
& 0xfffff800) >> 11;
3759 /* Set bits 0-20 to zero. */
3761 value
= value
& 0x7ff;
3764 /* Add 0x800 and arithmetic shift right 11 bits. */
3767 value
= (value
& 0xfffff800) >> 11;
3770 /* Set bitgs 0-21 to one. */
3772 value
|= 0xfffff800;
3775 #define RSEL_ROUND(c) (((c) + 0x1000) & ~0x1fff)
3777 value
= (RSEL_ROUND (value
) & 0x7ff) + (value
- RSEL_ROUND (value
));
3781 value
= (RSEL_ROUND (value
) >> 11) & 0x1fffff;
3786 BAD_CASE (field_selector
);
3792 /* Given an argument location specification return the associated
3793 argument location number. */
3796 pa_build_arg_reloc (type_name
)
3800 if (strncasecmp (type_name
, "no", 2) == 0)
3802 if (strncasecmp (type_name
, "gr", 2) == 0)
3804 else if (strncasecmp (type_name
, "fr", 2) == 0)
3806 else if (strncasecmp (type_name
, "fu", 2) == 0)
3809 as_bad (_("Invalid argument location: %s\n"), type_name
);
3814 /* Encode and return an argument relocation specification for
3815 the given register in the location specified by arg_reloc. */
3818 pa_align_arg_reloc (reg
, arg_reloc
)
3820 unsigned int arg_reloc
;
3822 unsigned int new_reloc
;
3824 new_reloc
= arg_reloc
;
3840 as_bad (_("Invalid argument description: %d"), reg
);
3846 /* Parse a PA nullification completer (,n). Return nonzero if the
3847 completer was found; return zero if no completer was found. */
3859 if (strncasecmp (*s
, "n", 1) == 0)
3863 as_bad (_("Invalid Nullification: (%c)"), **s
);
3872 /* Parse a non-negated compare/subtract completer returning the
3873 number (for encoding in instrutions) of the given completer.
3875 ISBRANCH specifies whether or not this is parsing a condition
3876 completer for a branch (vs a nullification completer for a
3877 computational instruction. */
3880 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
3885 char *name
= *s
+ 1;
3894 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3900 if (strcmp (name
, "=") == 0)
3904 else if (strcmp (name
, "<") == 0)
3908 else if (strcmp (name
, "<=") == 0)
3912 else if (strcmp (name
, "<<") == 0)
3916 else if (strcmp (name
, "<<=") == 0)
3920 else if (strcasecmp (name
, "sv") == 0)
3924 else if (strcasecmp (name
, "od") == 0)
3928 /* If we have something like addb,n then there is no condition
3930 else if (strcasecmp (name
, "n") == 0 && isbranch
)
3942 /* Reset pointers if this was really a ,n for a branch instruction. */
3950 /* Parse a negated compare/subtract completer returning the
3951 number (for encoding in instrutions) of the given completer.
3953 ISBRANCH specifies whether or not this is parsing a condition
3954 completer for a branch (vs a nullification completer for a
3955 computational instruction. */
3958 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
3963 char *name
= *s
+ 1;
3972 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3978 if (strcasecmp (name
, "tr") == 0)
3982 else if (strcmp (name
, "<>") == 0)
3986 else if (strcmp (name
, ">=") == 0)
3990 else if (strcmp (name
, ">") == 0)
3994 else if (strcmp (name
, ">>=") == 0)
3998 else if (strcmp (name
, ">>") == 0)
4002 else if (strcasecmp (name
, "nsv") == 0)
4006 else if (strcasecmp (name
, "ev") == 0)
4010 /* If we have something like addb,n then there is no condition
4012 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4024 /* Reset pointers if this was really a ,n for a branch instruction. */
4033 /* Parse a non-negated addition completer returning the number
4034 (for encoding in instrutions) of the given completer.
4036 ISBRANCH specifies whether or not this is parsing a condition
4037 completer for a branch (vs a nullification completer for a
4038 computational instruction. */
4041 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
4046 char *name
= *s
+ 1;
4054 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4058 if (strcmp (name
, "=") == 0)
4062 else if (strcmp (name
, "<") == 0)
4066 else if (strcmp (name
, "<=") == 0)
4070 else if (strcasecmp (name
, "nuv") == 0)
4074 else if (strcasecmp (name
, "znv") == 0)
4078 else if (strcasecmp (name
, "sv") == 0)
4082 else if (strcasecmp (name
, "od") == 0)
4086 /* If we have something like addb,n then there is no condition
4088 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4099 /* Reset pointers if this was really a ,n for a branch instruction. */
4100 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4106 /* Parse a negated addition completer returning the number
4107 (for encoding in instrutions) of the given completer.
4109 ISBRANCH specifies whether or not this is parsing a condition
4110 completer for a branch (vs a nullification completer for a
4111 computational instruction). */
4114 pa_parse_neg_add_cmpltr (s
, isbranch
)
4119 char *name
= *s
+ 1;
4127 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4131 if (strcasecmp (name
, "tr") == 0)
4135 else if (strcmp (name
, "<>") == 0)
4139 else if (strcmp (name
, ">=") == 0)
4143 else if (strcmp (name
, ">") == 0)
4147 else if (strcasecmp (name
, "uv") == 0)
4151 else if (strcasecmp (name
, "vnz") == 0)
4155 else if (strcasecmp (name
, "nsv") == 0)
4159 else if (strcasecmp (name
, "ev") == 0)
4163 /* If we have something like addb,n then there is no condition
4165 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4176 /* Reset pointers if this was really a ,n for a branch instruction. */
4177 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4184 /* Handle an alignment directive. Special so that we can update the
4185 alignment of the subspace if necessary. */
4189 /* We must have a valid space and subspace. */
4190 pa_check_current_space_and_subspace ();
4192 /* Let the generic gas code do most of the work. */
4193 s_align_bytes (bytes
);
4195 /* If bytes is a power of 2, then update the current subspace's
4196 alignment if necessary. */
4197 if (log2 (bytes
) != -1)
4198 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
4202 /* Handle a .BLOCK type pseudo-op. */
4210 unsigned int temp_size
;
4214 /* We must have a valid space and subspace. */
4215 pa_check_current_space_and_subspace ();
4218 temp_size
= get_absolute_expression ();
4220 /* Always fill with zeros, that's what the HP assembler does. */
4223 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
4224 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
4225 memset (p
, 0, temp_size
);
4227 /* Convert 2 bytes at a time. */
4229 for (i
= 0; i
< temp_size
; i
+= 2)
4231 md_number_to_chars (p
+ i
,
4233 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
4236 pa_undefine_label ();
4237 demand_empty_rest_of_line ();
4240 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
4248 /* The BRTAB relocations are only availble in SOM (to denote
4249 the beginning and end of branch tables). */
4250 char *where
= frag_more (0);
4252 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4253 NULL
, (offsetT
) 0, NULL
,
4254 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
4255 e_fsel
, 0, 0, NULL
);
4258 demand_empty_rest_of_line ();
4261 /* Handle a .begin_try and .end_try pseudo-op. */
4269 char *where
= frag_more (0);
4274 /* The TRY relocations are only availble in SOM (to denote
4275 the beginning and end of exception handling regions). */
4277 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4278 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
4279 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
4280 e_fsel
, 0, 0, NULL
);
4283 demand_empty_rest_of_line ();
4286 /* Handle a .CALL pseudo-op. This involves storing away information
4287 about where arguments are to be found so the linker can detect
4288 (and correct) argument location mismatches between caller and callee. */
4295 /* We must have a valid space and subspace. */
4296 pa_check_current_space_and_subspace ();
4299 pa_call_args (&last_call_desc
);
4300 demand_empty_rest_of_line ();
4303 /* Do the dirty work of building a call descriptor which describes
4304 where the caller placed arguments to a function call. */
4307 pa_call_args (call_desc
)
4308 struct call_desc
*call_desc
;
4311 unsigned int temp
, arg_reloc
;
4313 while (!is_end_of_statement ())
4315 name
= input_line_pointer
;
4316 c
= get_symbol_end ();
4317 /* Process a source argument. */
4318 if ((strncasecmp (name
, "argw", 4) == 0))
4320 temp
= atoi (name
+ 4);
4321 p
= input_line_pointer
;
4323 input_line_pointer
++;
4324 name
= input_line_pointer
;
4325 c
= get_symbol_end ();
4326 arg_reloc
= pa_build_arg_reloc (name
);
4327 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
4329 /* Process a return value. */
4330 else if ((strncasecmp (name
, "rtnval", 6) == 0))
4332 p
= input_line_pointer
;
4334 input_line_pointer
++;
4335 name
= input_line_pointer
;
4336 c
= get_symbol_end ();
4337 arg_reloc
= pa_build_arg_reloc (name
);
4338 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
4342 as_bad (_("Invalid .CALL argument: %s"), name
);
4344 p
= input_line_pointer
;
4346 if (!is_end_of_statement ())
4347 input_line_pointer
++;
4351 /* Return TRUE if FRAG1 and FRAG2 are the same. */
4354 is_same_frag (frag1
, frag2
)
4361 else if (frag2
== NULL
)
4363 else if (frag1
== frag2
)
4365 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
4366 return (is_same_frag (frag1
, frag2
->fr_next
));
4372 /* Build an entry in the UNWIND subspace from the given function
4373 attributes in CALL_INFO. This is not needed for SOM as using
4374 R_ENTRY and R_EXIT relocations allow the linker to handle building
4375 of the unwind spaces. */
4378 pa_build_unwind_subspace (call_info
)
4379 struct call_info
*call_info
;
4383 asection
*seg
, *save_seg
;
4384 subsegT subseg
, save_subseg
;
4388 /* Get into the right seg/subseg. This may involve creating
4389 the seg the first time through. Make sure to have the
4390 old seg/subseg so that we can reset things when we are done. */
4391 subseg
= SUBSEG_UNWIND
;
4392 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
4393 if (seg
== ASEC_NULL
)
4395 seg
= bfd_make_section_old_way (stdoutput
, UNWIND_SECTION_NAME
);
4396 bfd_set_section_flags (stdoutput
, seg
,
4397 SEC_READONLY
| SEC_HAS_CONTENTS
4398 | SEC_LOAD
| SEC_RELOC
);
4402 save_subseg
= now_subseg
;
4403 subseg_set (seg
, subseg
);
4406 /* Get some space to hold relocation information for the unwind
4409 md_number_to_chars (p
, 0, 4);
4411 /* Relocation info. for start offset of the function. */
4412 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4413 call_info
->start_symbol
, (offsetT
) 0,
4414 (expressionS
*) NULL
, 0, R_PARISC_DIR32
, e_fsel
, 32, 0, NULL
);
4417 md_number_to_chars (p
, 0, 4);
4419 /* Relocation info. for end offset of the function.
4421 Because we allow reductions of 32bit relocations for ELF, this will be
4422 reduced to section_sym + offset which avoids putting the temporary
4423 symbol into the symbol table. It (should) end up giving the same
4424 value as call_info->start_symbol + function size once the linker is
4425 finished with its work. */
4427 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4428 call_info
->end_symbol
, (offsetT
) 0,
4429 (expressionS
*) NULL
, 0, R_PARISC_DIR32
, e_fsel
, 32, 0, NULL
);
4432 unwind
= (char *) &call_info
->ci_unwind
;
4433 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
4437 FRAG_APPEND_1_CHAR (c
);
4441 /* Return back to the original segment/subsegment. */
4442 subseg_set (save_seg
, save_subseg
);
4447 /* Process a .CALLINFO pseudo-op. This information is used later
4448 to build unwind descriptors and maybe one day to support
4449 .ENTER and .LEAVE. */
4452 pa_callinfo (unused
)
4459 /* We must have a valid space and subspace. */
4460 pa_check_current_space_and_subspace ();
4463 /* .CALLINFO must appear within a procedure definition. */
4464 if (!within_procedure
)
4465 as_bad (_(".callinfo is not within a procedure definition"));
4467 /* Mark the fact that we found the .CALLINFO for the
4468 current procedure. */
4469 callinfo_found
= TRUE
;
4471 /* Iterate over the .CALLINFO arguments. */
4472 while (!is_end_of_statement ())
4474 name
= input_line_pointer
;
4475 c
= get_symbol_end ();
4476 /* Frame size specification. */
4477 if ((strncasecmp (name
, "frame", 5) == 0))
4479 p
= input_line_pointer
;
4481 input_line_pointer
++;
4482 temp
= get_absolute_expression ();
4483 if ((temp
& 0x3) != 0)
4485 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
4489 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
4490 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
4493 /* Entry register (GR, GR and SR) specifications. */
4494 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
4496 p
= input_line_pointer
;
4498 input_line_pointer
++;
4499 temp
= get_absolute_expression ();
4500 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
4501 even though %r19 is caller saved. I think this is a bug in
4502 the HP assembler, and we are not going to emulate it. */
4503 if (temp
< 3 || temp
> 18)
4504 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
4505 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
4507 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
4509 p
= input_line_pointer
;
4511 input_line_pointer
++;
4512 temp
= get_absolute_expression ();
4513 /* Similarly the HP assembler takes 31 as the high bound even
4514 though %fr21 is the last callee saved floating point register. */
4515 if (temp
< 12 || temp
> 21)
4516 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
4517 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
4519 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
4521 p
= input_line_pointer
;
4523 input_line_pointer
++;
4524 temp
= get_absolute_expression ();
4526 as_bad (_("Value for ENTRY_SR must be 3\n"));
4528 /* Note whether or not this function performs any calls. */
4529 else if ((strncasecmp (name
, "calls", 5) == 0) ||
4530 (strncasecmp (name
, "caller", 6) == 0))
4532 p
= input_line_pointer
;
4535 else if ((strncasecmp (name
, "no_calls", 8) == 0))
4537 p
= input_line_pointer
;
4540 /* Should RP be saved into the stack. */
4541 else if ((strncasecmp (name
, "save_rp", 7) == 0))
4543 p
= input_line_pointer
;
4545 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
4547 /* Likewise for SP. */
4548 else if ((strncasecmp (name
, "save_sp", 7) == 0))
4550 p
= input_line_pointer
;
4552 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
4554 /* Is this an unwindable procedure. If so mark it so
4555 in the unwind descriptor. */
4556 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
4558 p
= input_line_pointer
;
4560 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
4562 /* Is this an interrupt routine. If so mark it in the
4563 unwind descriptor. */
4564 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
4566 p
= input_line_pointer
;
4568 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
4570 /* Is this a millicode routine. "millicode" isn't in my
4571 assembler manual, but my copy is old. The HP assembler
4572 accepts it, and there's a place in the unwind descriptor
4573 to drop the information, so we'll accept it too. */
4574 else if ((strncasecmp (name
, "millicode", 9) == 0))
4576 p
= input_line_pointer
;
4578 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
4582 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
4583 *input_line_pointer
= c
;
4585 if (!is_end_of_statement ())
4586 input_line_pointer
++;
4589 demand_empty_rest_of_line ();
4592 /* Switch into the code subspace. */
4599 current_space
= is_defined_space ("$TEXT$");
4601 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
4604 pa_undefine_label ();
4607 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
4608 the .comm pseudo-op has the following symtax:
4610 <label> .comm <length>
4612 where <label> is optional and is a symbol whose address will be the start of
4613 a block of memory <length> bytes long. <length> must be an absolute
4614 expression. <length> bytes will be allocated in the current space
4617 Also note the label may not even be on the same line as the .comm.
4619 This difference in syntax means the colon function will be called
4620 on the symbol before we arrive in pa_comm. colon will set a number
4621 of attributes of the symbol that need to be fixed here. In particular
4622 the value, section pointer, fragment pointer, flags, etc. What
4625 This also makes error detection all but impossible. */
4633 label_symbol_struct
*label_symbol
= pa_get_label ();
4636 symbol
= label_symbol
->lss_label
;
4641 size
= get_absolute_expression ();
4645 S_SET_VALUE (symbol
, size
);
4646 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
4647 S_SET_EXTERNAL (symbol
);
4649 /* colon() has already set the frag to the current location in the
4650 current subspace; we need to reset the fragment to the zero address
4651 fragment. We also need to reset the segment pointer. */
4652 symbol_set_frag (symbol
, &zero_address_frag
);
4654 demand_empty_rest_of_line ();
4657 /* Process a .END pseudo-op. */
4663 demand_empty_rest_of_line ();
4666 /* Process a .ENTER pseudo-op. This is not supported. */
4672 /* We must have a valid space and subspace. */
4673 pa_check_current_space_and_subspace ();
4676 as_bad (_("The .ENTER pseudo-op is not supported"));
4677 demand_empty_rest_of_line ();
4680 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
4687 /* We must have a valid space and subspace. */
4688 pa_check_current_space_and_subspace ();
4691 if (!within_procedure
)
4692 as_bad (_("Misplaced .entry. Ignored."));
4695 if (!callinfo_found
)
4696 as_bad (_("Missing .callinfo."));
4698 demand_empty_rest_of_line ();
4699 within_entry_exit
= TRUE
;
4702 /* SOM defers building of unwind descriptors until the link phase.
4703 The assembler is responsible for creating an R_ENTRY relocation
4704 to mark the beginning of a region and hold the unwind bits, and
4705 for creating an R_EXIT relocation to mark the end of the region.
4707 FIXME. ELF should be using the same conventions! The problem
4708 is an unwind requires too much relocation space. Hmmm. Maybe
4709 if we split the unwind bits up between the relocations which
4710 denote the entry and exit points. */
4711 if (last_call_info
->start_symbol
!= NULL
)
4713 char *where
= frag_more (0);
4715 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4716 NULL
, (offsetT
) 0, NULL
,
4717 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
4718 (int *) &last_call_info
->ci_unwind
.descriptor
);
4723 /* Handle a .EQU pseudo-op. */
4729 label_symbol_struct
*label_symbol
= pa_get_label ();
4734 symbol
= label_symbol
->lss_label
;
4736 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
4738 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
4739 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
4744 as_bad (_(".REG must use a label"));
4746 as_bad (_(".EQU must use a label"));
4749 pa_undefine_label ();
4750 demand_empty_rest_of_line ();
4753 /* Helper function. Does processing for the end of a function. This
4754 usually involves creating some relocations or building special
4755 symbols to mark the end of the function. */
4762 where
= frag_more (0);
4765 /* Mark the end of the function, stuff away the location of the frag
4766 for the end of the function, and finally call pa_build_unwind_subspace
4767 to add an entry in the unwind table. */
4768 hppa_elf_mark_end_of_function ();
4769 pa_build_unwind_subspace (last_call_info
);
4771 /* SOM defers building of unwind descriptors until the link phase.
4772 The assembler is responsible for creating an R_ENTRY relocation
4773 to mark the beginning of a region and hold the unwind bits, and
4774 for creating an R_EXIT relocation to mark the end of the region.
4776 FIXME. ELF should be using the same conventions! The problem
4777 is an unwind requires too much relocation space. Hmmm. Maybe
4778 if we split the unwind bits up between the relocations which
4779 denote the entry and exit points. */
4780 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4782 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
4783 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
4787 /* Process a .EXIT pseudo-op. */
4794 /* We must have a valid space and subspace. */
4795 pa_check_current_space_and_subspace ();
4798 if (!within_procedure
)
4799 as_bad (_(".EXIT must appear within a procedure"));
4802 if (!callinfo_found
)
4803 as_bad (_("Missing .callinfo"));
4806 if (!within_entry_exit
)
4807 as_bad (_("No .ENTRY for this .EXIT"));
4810 within_entry_exit
= FALSE
;
4815 demand_empty_rest_of_line ();
4818 /* Process a .EXPORT directive. This makes functions external
4819 and provides information such as argument relocation entries
4829 name
= input_line_pointer
;
4830 c
= get_symbol_end ();
4831 /* Make sure the given symbol exists. */
4832 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
4834 as_bad (_("Cannot define export symbol: %s\n"), name
);
4835 p
= input_line_pointer
;
4837 input_line_pointer
++;
4841 /* OK. Set the external bits and process argument relocations. */
4842 S_SET_EXTERNAL (symbol
);
4843 p
= input_line_pointer
;
4845 if (!is_end_of_statement ())
4847 input_line_pointer
++;
4848 pa_type_args (symbol
, 1);
4852 demand_empty_rest_of_line ();
4855 /* Helper function to process arguments to a .EXPORT pseudo-op. */
4858 pa_type_args (symbolP
, is_export
)
4863 unsigned int temp
, arg_reloc
;
4864 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
4865 obj_symbol_type
*symbol
= (obj_symbol_type
*) symbol_get_bfdsym (symbolP
);
4867 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
4870 input_line_pointer
+= 8;
4871 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4872 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
4873 type
= SYMBOL_TYPE_ABSOLUTE
;
4875 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
4877 input_line_pointer
+= 4;
4878 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
4879 instead one should be IMPORTing/EXPORTing ENTRY types.
4881 Complain if one tries to EXPORT a CODE type since that's never
4882 done. Both GCC and HP C still try to IMPORT CODE types, so
4883 silently fix them to be ENTRY types. */
4884 if (S_IS_FUNCTION (symbolP
))
4887 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
4888 S_GET_NAME (symbolP
));
4890 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4891 type
= SYMBOL_TYPE_ENTRY
;
4895 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4896 type
= SYMBOL_TYPE_CODE
;
4899 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
4901 input_line_pointer
+= 4;
4902 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4903 type
= SYMBOL_TYPE_DATA
;
4905 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
4907 input_line_pointer
+= 5;
4908 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4909 type
= SYMBOL_TYPE_ENTRY
;
4911 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
4913 input_line_pointer
+= 9;
4914 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4915 type
= SYMBOL_TYPE_MILLICODE
;
4917 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
4919 input_line_pointer
+= 6;
4920 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4921 type
= SYMBOL_TYPE_PLABEL
;
4923 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
4925 input_line_pointer
+= 8;
4926 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4927 type
= SYMBOL_TYPE_PRI_PROG
;
4929 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
4931 input_line_pointer
+= 8;
4932 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4933 type
= SYMBOL_TYPE_SEC_PROG
;
4936 /* SOM requires much more information about symbol types
4937 than BFD understands. This is how we get this information
4938 to the SOM BFD backend. */
4939 #ifdef obj_set_symbol_type
4940 obj_set_symbol_type (symbol_get_bfdsym (symbolP
), (int) type
);
4943 /* Now that the type of the exported symbol has been handled,
4944 handle any argument relocation information. */
4945 while (!is_end_of_statement ())
4947 if (*input_line_pointer
== ',')
4948 input_line_pointer
++;
4949 name
= input_line_pointer
;
4950 c
= get_symbol_end ();
4951 /* Argument sources. */
4952 if ((strncasecmp (name
, "argw", 4) == 0))
4954 p
= input_line_pointer
;
4956 input_line_pointer
++;
4957 temp
= atoi (name
+ 4);
4958 name
= input_line_pointer
;
4959 c
= get_symbol_end ();
4960 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
4962 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
4964 *input_line_pointer
= c
;
4966 /* The return value. */
4967 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
4969 p
= input_line_pointer
;
4971 input_line_pointer
++;
4972 name
= input_line_pointer
;
4973 c
= get_symbol_end ();
4974 arg_reloc
= pa_build_arg_reloc (name
);
4976 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
4978 *input_line_pointer
= c
;
4980 /* Privelege level. */
4981 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
4983 p
= input_line_pointer
;
4985 input_line_pointer
++;
4986 temp
= atoi (input_line_pointer
);
4988 symbol
->tc_data
.ap
.hppa_priv_level
= temp
;
4990 c
= get_symbol_end ();
4991 *input_line_pointer
= c
;
4995 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
4996 p
= input_line_pointer
;
4999 if (!is_end_of_statement ())
5000 input_line_pointer
++;
5004 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
5005 assembly file must either be defined in the assembly file, or
5006 explicitly IMPORTED from another. */
5015 name
= input_line_pointer
;
5016 c
= get_symbol_end ();
5018 symbol
= symbol_find (name
);
5019 /* Ugh. We might be importing a symbol defined earlier in the file,
5020 in which case all the code below will really screw things up
5021 (set the wrong segment, symbol flags & type, etc). */
5022 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
5024 symbol
= symbol_find_or_make (name
);
5025 p
= input_line_pointer
;
5028 if (!is_end_of_statement ())
5030 input_line_pointer
++;
5031 pa_type_args (symbol
, 0);
5035 /* Sigh. To be compatable with the HP assembler and to help
5036 poorly written assembly code, we assign a type based on
5037 the the current segment. Note only BSF_FUNCTION really
5038 matters, we do not need to set the full SYMBOL_TYPE_* info. */
5039 if (now_seg
== text_section
)
5040 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
5042 /* If the section is undefined, then the symbol is undefined
5043 Since this is an import, leave the section undefined. */
5044 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
5049 /* The symbol was already defined. Just eat everything up to
5050 the end of the current statement. */
5051 while (!is_end_of_statement ())
5052 input_line_pointer
++;
5055 demand_empty_rest_of_line ();
5058 /* Handle a .LABEL pseudo-op. */
5066 name
= input_line_pointer
;
5067 c
= get_symbol_end ();
5069 if (strlen (name
) > 0)
5072 p
= input_line_pointer
;
5077 as_warn (_("Missing label name on .LABEL"));
5080 if (!is_end_of_statement ())
5082 as_warn (_("extra .LABEL arguments ignored."));
5083 ignore_rest_of_line ();
5085 demand_empty_rest_of_line ();
5088 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
5095 /* We must have a valid space and subspace. */
5096 pa_check_current_space_and_subspace ();
5099 as_bad (_("The .LEAVE pseudo-op is not supported"));
5100 demand_empty_rest_of_line ();
5103 /* Handle a .LEVEL pseudo-op. */
5111 level
= input_line_pointer
;
5112 if (strncmp (level
, "1.0", 3) == 0)
5114 input_line_pointer
+= 3;
5115 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
5116 as_warn (_("could not set architecture and machine"));
5118 else if (strncmp (level
, "1.1", 3) == 0)
5120 input_line_pointer
+= 3;
5121 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
5122 as_warn (_("could not set architecture and machine"));
5124 else if (strncmp (level
, "2.0", 3) == 0)
5126 input_line_pointer
+= 3;
5127 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
5128 as_warn (_("could not set architecture and machine"));
5132 as_bad (_("Unrecognized .LEVEL argument\n"));
5133 ignore_rest_of_line ();
5135 demand_empty_rest_of_line ();
5138 /* Handle a .ORIGIN pseudo-op. */
5145 /* We must have a valid space and subspace. */
5146 pa_check_current_space_and_subspace ();
5150 pa_undefine_label ();
5153 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
5154 is for static functions. FIXME. Should share more code with .EXPORT. */
5163 name
= input_line_pointer
;
5164 c
= get_symbol_end ();
5166 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
5168 as_bad (_("Cannot define static symbol: %s\n"), name
);
5169 p
= input_line_pointer
;
5171 input_line_pointer
++;
5175 S_CLEAR_EXTERNAL (symbol
);
5176 p
= input_line_pointer
;
5178 if (!is_end_of_statement ())
5180 input_line_pointer
++;
5181 pa_type_args (symbol
, 0);
5185 demand_empty_rest_of_line ();
5188 /* Handle a .PROC pseudo-op. It is used to mark the beginning
5189 of a procedure from a syntatical point of view. */
5195 struct call_info
*call_info
;
5198 /* We must have a valid space and subspace. */
5199 pa_check_current_space_and_subspace ();
5202 if (within_procedure
)
5203 as_fatal (_("Nested procedures"));
5205 /* Reset global variables for new procedure. */
5206 callinfo_found
= FALSE
;
5207 within_procedure
= TRUE
;
5209 /* Create another call_info structure. */
5210 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
5213 as_fatal (_("Cannot allocate unwind descriptor\n"));
5215 memset (call_info
, 0, sizeof (struct call_info
));
5217 call_info
->ci_next
= NULL
;
5219 if (call_info_root
== NULL
)
5221 call_info_root
= call_info
;
5222 last_call_info
= call_info
;
5226 last_call_info
->ci_next
= call_info
;
5227 last_call_info
= call_info
;
5230 /* set up defaults on call_info structure */
5232 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
5233 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
5234 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
5236 /* If we got a .PROC pseudo-op, we know that the function is defined
5237 locally. Make sure it gets into the symbol table. */
5239 label_symbol_struct
*label_symbol
= pa_get_label ();
5243 if (label_symbol
->lss_label
)
5245 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5246 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
5249 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5252 last_call_info
->start_symbol
= NULL
;
5255 demand_empty_rest_of_line ();
5258 /* Process the syntatical end of a procedure. Make sure all the
5259 appropriate pseudo-ops were found within the procedure. */
5267 /* We must have a valid space and subspace. */
5268 pa_check_current_space_and_subspace ();
5271 /* If we are within a procedure definition, make sure we've
5272 defined a label for the procedure; handle case where the
5273 label was defined after the .PROC directive.
5275 Note there's not need to diddle with the segment or fragment
5276 for the label symbol in this case. We have already switched
5277 into the new $CODE$ subspace at this point. */
5278 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
5280 label_symbol_struct
*label_symbol
= pa_get_label ();
5284 if (label_symbol
->lss_label
)
5286 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5287 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
5290 /* Also handle allocation of a fixup to hold the unwind
5291 information when the label appears after the proc/procend. */
5292 if (within_entry_exit
)
5294 char *where
= frag_more (0);
5296 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5297 NULL
, (offsetT
) 0, NULL
,
5298 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
5299 (int *) &last_call_info
->ci_unwind
.descriptor
);
5304 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5307 as_bad (_("Missing function name for .PROC"));
5310 if (!within_procedure
)
5311 as_bad (_("misplaced .procend"));
5313 if (!callinfo_found
)
5314 as_bad (_("Missing .callinfo for this procedure"));
5316 if (within_entry_exit
)
5317 as_bad (_("Missing .EXIT for a .ENTRY"));
5320 /* ELF needs to mark the end of each function so that it can compute
5321 the size of the function (apparently its needed in the symbol table). */
5322 hppa_elf_mark_end_of_function ();
5325 within_procedure
= FALSE
;
5326 demand_empty_rest_of_line ();
5327 pa_undefine_label ();
5330 /* If VALUE is an exact power of two between zero and 2^31, then
5331 return log2 (VALUE). Else return -1. */
5339 while ((1 << shift
) != value
&& shift
< 32)
5350 /* Check to make sure we have a valid space and subspace. */
5353 pa_check_current_space_and_subspace ()
5355 if (current_space
== NULL
)
5356 as_fatal (_("Not in a space.\n"));
5358 if (current_subspace
== NULL
)
5359 as_fatal (_("Not in a subspace.\n"));
5362 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
5363 then create a new space entry to hold the information specified
5364 by the parameters to the .SPACE directive. */
5366 static sd_chain_struct
*
5367 pa_parse_space_stmt (space_name
, create_flag
)
5371 char *name
, *ptemp
, c
;
5372 char loadable
, defined
, private, sort
;
5374 asection
*seg
= NULL
;
5375 sd_chain_struct
*space
;
5377 /* load default values */
5383 if (strcmp (space_name
, "$TEXT$") == 0)
5385 seg
= pa_def_spaces
[0].segment
;
5386 defined
= pa_def_spaces
[0].defined
;
5387 private = pa_def_spaces
[0].private;
5388 sort
= pa_def_spaces
[0].sort
;
5389 spnum
= pa_def_spaces
[0].spnum
;
5391 else if (strcmp (space_name
, "$PRIVATE$") == 0)
5393 seg
= pa_def_spaces
[1].segment
;
5394 defined
= pa_def_spaces
[1].defined
;
5395 private = pa_def_spaces
[1].private;
5396 sort
= pa_def_spaces
[1].sort
;
5397 spnum
= pa_def_spaces
[1].spnum
;
5400 if (!is_end_of_statement ())
5402 print_errors
= FALSE
;
5403 ptemp
= input_line_pointer
+ 1;
5404 /* First see if the space was specified as a number rather than
5405 as a name. According to the PA assembly manual the rest of
5406 the line should be ignored. */
5407 temp
= pa_parse_number (&ptemp
, 0);
5411 input_line_pointer
= ptemp
;
5415 while (!is_end_of_statement ())
5417 input_line_pointer
++;
5418 name
= input_line_pointer
;
5419 c
= get_symbol_end ();
5420 if ((strncasecmp (name
, "spnum", 5) == 0))
5422 *input_line_pointer
= c
;
5423 input_line_pointer
++;
5424 spnum
= get_absolute_expression ();
5426 else if ((strncasecmp (name
, "sort", 4) == 0))
5428 *input_line_pointer
= c
;
5429 input_line_pointer
++;
5430 sort
= get_absolute_expression ();
5432 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5434 *input_line_pointer
= c
;
5437 else if ((strncasecmp (name
, "notdefined", 10) == 0))
5439 *input_line_pointer
= c
;
5442 else if ((strncasecmp (name
, "private", 7) == 0))
5444 *input_line_pointer
= c
;
5449 as_bad (_("Invalid .SPACE argument"));
5450 *input_line_pointer
= c
;
5451 if (!is_end_of_statement ())
5452 input_line_pointer
++;
5456 print_errors
= TRUE
;
5459 if (create_flag
&& seg
== NULL
)
5460 seg
= subseg_new (space_name
, 0);
5462 /* If create_flag is nonzero, then create the new space with
5463 the attributes computed above. Else set the values in
5464 an already existing space -- this can only happen for
5465 the first occurence of a built-in space. */
5467 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
5468 private, sort
, seg
, 1);
5471 space
= is_defined_space (space_name
);
5472 SPACE_SPNUM (space
) = spnum
;
5473 SPACE_DEFINED (space
) = defined
& 1;
5474 SPACE_USER_DEFINED (space
) = 1;
5477 #ifdef obj_set_section_attributes
5478 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
5484 /* Handle a .SPACE pseudo-op; this switches the current space to the
5485 given space, creating the new space if necessary. */
5491 char *name
, c
, *space_name
, *save_s
;
5493 sd_chain_struct
*sd_chain
;
5495 if (within_procedure
)
5497 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
5498 ignore_rest_of_line ();
5502 /* Check for some of the predefined spaces. FIXME: most of the code
5503 below is repeated several times, can we extract the common parts
5504 and place them into a subroutine or something similar? */
5505 /* FIXME Is this (and the next IF stmt) really right?
5506 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
5507 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
5509 input_line_pointer
+= 6;
5510 sd_chain
= is_defined_space ("$TEXT$");
5511 if (sd_chain
== NULL
)
5512 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
5513 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5514 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
5516 current_space
= sd_chain
;
5517 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
5519 = pa_subsegment_to_subspace (text_section
,
5520 sd_chain
->sd_last_subseg
);
5521 demand_empty_rest_of_line ();
5524 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
5526 input_line_pointer
+= 9;
5527 sd_chain
= is_defined_space ("$PRIVATE$");
5528 if (sd_chain
== NULL
)
5529 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
5530 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5531 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
5533 current_space
= sd_chain
;
5534 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
5536 = pa_subsegment_to_subspace (data_section
,
5537 sd_chain
->sd_last_subseg
);
5538 demand_empty_rest_of_line ();
5541 if (!strncasecmp (input_line_pointer
,
5542 GDB_DEBUG_SPACE_NAME
,
5543 strlen (GDB_DEBUG_SPACE_NAME
)))
5545 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
5546 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
5547 if (sd_chain
== NULL
)
5548 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
5549 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5550 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
5552 current_space
= sd_chain
;
5555 asection
*gdb_section
5556 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
5558 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
5560 = pa_subsegment_to_subspace (gdb_section
,
5561 sd_chain
->sd_last_subseg
);
5563 demand_empty_rest_of_line ();
5567 /* It could be a space specified by number. */
5569 save_s
= input_line_pointer
;
5570 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
5572 if ((sd_chain
= pa_find_space_by_number (temp
)))
5574 current_space
= sd_chain
;
5576 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5578 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5579 sd_chain
->sd_last_subseg
);
5580 demand_empty_rest_of_line ();
5585 /* Not a number, attempt to create a new space. */
5587 input_line_pointer
= save_s
;
5588 name
= input_line_pointer
;
5589 c
= get_symbol_end ();
5590 space_name
= xmalloc (strlen (name
) + 1);
5591 strcpy (space_name
, name
);
5592 *input_line_pointer
= c
;
5594 sd_chain
= pa_parse_space_stmt (space_name
, 1);
5595 current_space
= sd_chain
;
5597 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5598 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5599 sd_chain
->sd_last_subseg
);
5600 demand_empty_rest_of_line ();
5604 /* Switch to a new space. (I think). FIXME. */
5613 sd_chain_struct
*space
;
5615 name
= input_line_pointer
;
5616 c
= get_symbol_end ();
5617 space
= is_defined_space (name
);
5621 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
5624 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
5626 *input_line_pointer
= c
;
5627 demand_empty_rest_of_line ();
5630 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
5631 given subspace, creating the new subspace if necessary.
5633 FIXME. Should mirror pa_space more closely, in particular how
5634 they're broken up into subroutines. */
5637 pa_subspace (create_new
)
5640 char *name
, *ss_name
, c
;
5641 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
5642 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
5643 sd_chain_struct
*space
;
5644 ssd_chain_struct
*ssd
;
5647 if (current_space
== NULL
)
5648 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
5650 if (within_procedure
)
5652 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
5653 ignore_rest_of_line ();
5657 name
= input_line_pointer
;
5658 c
= get_symbol_end ();
5659 ss_name
= xmalloc (strlen (name
) + 1);
5660 strcpy (ss_name
, name
);
5661 *input_line_pointer
= c
;
5663 /* Load default values. */
5675 space
= current_space
;
5679 ssd
= is_defined_subspace (ss_name
);
5680 /* Allow user to override the builtin attributes of subspaces. But
5681 only allow the attributes to be changed once! */
5682 if (ssd
&& SUBSPACE_DEFINED (ssd
))
5684 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
5685 current_subspace
= ssd
;
5686 if (!is_end_of_statement ())
5687 as_warn (_("Parameters of an existing subspace can\'t be modified"));
5688 demand_empty_rest_of_line ();
5693 /* A new subspace. Load default values if it matches one of
5694 the builtin subspaces. */
5696 while (pa_def_subspaces
[i
].name
)
5698 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
5700 loadable
= pa_def_subspaces
[i
].loadable
;
5701 common
= pa_def_subspaces
[i
].common
;
5702 dup_common
= pa_def_subspaces
[i
].dup_common
;
5703 code_only
= pa_def_subspaces
[i
].code_only
;
5704 zero
= pa_def_subspaces
[i
].zero
;
5705 space_index
= pa_def_subspaces
[i
].space_index
;
5706 alignment
= pa_def_subspaces
[i
].alignment
;
5707 quadrant
= pa_def_subspaces
[i
].quadrant
;
5708 access
= pa_def_subspaces
[i
].access
;
5709 sort
= pa_def_subspaces
[i
].sort
;
5716 /* We should be working with a new subspace now. Fill in
5717 any information as specified by the user. */
5718 if (!is_end_of_statement ())
5720 input_line_pointer
++;
5721 while (!is_end_of_statement ())
5723 name
= input_line_pointer
;
5724 c
= get_symbol_end ();
5725 if ((strncasecmp (name
, "quad", 4) == 0))
5727 *input_line_pointer
= c
;
5728 input_line_pointer
++;
5729 quadrant
= get_absolute_expression ();
5731 else if ((strncasecmp (name
, "align", 5) == 0))
5733 *input_line_pointer
= c
;
5734 input_line_pointer
++;
5735 alignment
= get_absolute_expression ();
5736 if (log2 (alignment
) == -1)
5738 as_bad (_("Alignment must be a power of 2"));
5742 else if ((strncasecmp (name
, "access", 6) == 0))
5744 *input_line_pointer
= c
;
5745 input_line_pointer
++;
5746 access
= get_absolute_expression ();
5748 else if ((strncasecmp (name
, "sort", 4) == 0))
5750 *input_line_pointer
= c
;
5751 input_line_pointer
++;
5752 sort
= get_absolute_expression ();
5754 else if ((strncasecmp (name
, "code_only", 9) == 0))
5756 *input_line_pointer
= c
;
5759 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5761 *input_line_pointer
= c
;
5764 else if ((strncasecmp (name
, "common", 6) == 0))
5766 *input_line_pointer
= c
;
5769 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
5771 *input_line_pointer
= c
;
5774 else if ((strncasecmp (name
, "zero", 4) == 0))
5776 *input_line_pointer
= c
;
5779 else if ((strncasecmp (name
, "first", 5) == 0))
5780 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
5782 as_bad (_("Invalid .SUBSPACE argument"));
5783 if (!is_end_of_statement ())
5784 input_line_pointer
++;
5788 /* Compute a reasonable set of BFD flags based on the information
5789 in the .subspace directive. */
5790 applicable
= bfd_applicable_section_flags (stdoutput
);
5793 flags
|= (SEC_ALLOC
| SEC_LOAD
);
5796 if (common
|| dup_common
)
5797 flags
|= SEC_IS_COMMON
;
5799 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
5801 /* This is a zero-filled subspace (eg BSS). */
5803 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
5805 applicable
&= flags
;
5807 /* If this is an existing subspace, then we want to use the
5808 segment already associated with the subspace.
5810 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
5811 lots of sections. It might be a problem in the PA ELF
5812 code, I do not know yet. For now avoid creating anything
5813 but the "standard" sections for ELF. */
5815 section
= subseg_force_new (ss_name
, 0);
5817 section
= ssd
->ssd_seg
;
5819 section
= subseg_new (ss_name
, 0);
5822 seg_info (section
)->bss
= 1;
5824 /* Now set the flags. */
5825 bfd_set_section_flags (stdoutput
, section
, applicable
);
5827 /* Record any alignment request for this section. */
5828 record_alignment (section
, log2 (alignment
));
5830 /* Set the starting offset for this section. */
5831 bfd_set_section_vma (stdoutput
, section
,
5832 pa_subspace_start (space
, quadrant
));
5834 /* Now that all the flags are set, update an existing subspace,
5835 or create a new one. */
5838 current_subspace
= update_subspace (space
, ss_name
, loadable
,
5839 code_only
, common
, dup_common
,
5840 sort
, zero
, access
, space_index
,
5841 alignment
, quadrant
,
5844 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
5846 dup_common
, zero
, sort
,
5847 access
, space_index
,
5848 alignment
, quadrant
, section
);
5850 demand_empty_rest_of_line ();
5851 current_subspace
->ssd_seg
= section
;
5852 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
5854 SUBSPACE_DEFINED (current_subspace
) = 1;
5858 /* Create default space and subspace dictionaries. */
5865 space_dict_root
= NULL
;
5866 space_dict_last
= NULL
;
5869 while (pa_def_spaces
[i
].name
)
5873 /* Pick the right name to use for the new section. */
5874 name
= pa_def_spaces
[i
].name
;
5876 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
5877 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
5878 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
5879 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
5880 pa_def_spaces
[i
].segment
, 0);
5885 while (pa_def_subspaces
[i
].name
)
5888 int applicable
, subsegment
;
5889 asection
*segment
= NULL
;
5890 sd_chain_struct
*space
;
5892 /* Pick the right name for the new section and pick the right
5893 subsegment number. */
5894 name
= pa_def_subspaces
[i
].name
;
5897 /* Create the new section. */
5898 segment
= subseg_new (name
, subsegment
);
5901 /* For SOM we want to replace the standard .text, .data, and .bss
5902 sections with our own. We also want to set BFD flags for
5903 all the built-in subspaces. */
5904 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
5906 text_section
= segment
;
5907 applicable
= bfd_applicable_section_flags (stdoutput
);
5908 bfd_set_section_flags (stdoutput
, segment
,
5909 applicable
& (SEC_ALLOC
| SEC_LOAD
5910 | SEC_RELOC
| SEC_CODE
5912 | SEC_HAS_CONTENTS
));
5914 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
5916 data_section
= segment
;
5917 applicable
= bfd_applicable_section_flags (stdoutput
);
5918 bfd_set_section_flags (stdoutput
, segment
,
5919 applicable
& (SEC_ALLOC
| SEC_LOAD
5921 | SEC_HAS_CONTENTS
));
5925 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
5927 bss_section
= segment
;
5928 applicable
= bfd_applicable_section_flags (stdoutput
);
5929 bfd_set_section_flags (stdoutput
, segment
,
5930 applicable
& SEC_ALLOC
);
5932 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
5934 applicable
= bfd_applicable_section_flags (stdoutput
);
5935 bfd_set_section_flags (stdoutput
, segment
,
5936 applicable
& (SEC_ALLOC
| SEC_LOAD
5939 | SEC_HAS_CONTENTS
));
5941 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
5943 applicable
= bfd_applicable_section_flags (stdoutput
);
5944 bfd_set_section_flags (stdoutput
, segment
,
5945 applicable
& (SEC_ALLOC
| SEC_LOAD
5948 | SEC_HAS_CONTENTS
));
5950 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
5952 applicable
= bfd_applicable_section_flags (stdoutput
);
5953 bfd_set_section_flags (stdoutput
, segment
,
5954 applicable
& (SEC_ALLOC
| SEC_LOAD
5957 | SEC_HAS_CONTENTS
));
5960 /* Find the space associated with this subspace. */
5961 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
5962 def_space_index
].segment
);
5965 as_fatal (_("Internal error: Unable to find containing space for %s."),
5966 pa_def_subspaces
[i
].name
);
5969 create_new_subspace (space
, name
,
5970 pa_def_subspaces
[i
].loadable
,
5971 pa_def_subspaces
[i
].code_only
,
5972 pa_def_subspaces
[i
].common
,
5973 pa_def_subspaces
[i
].dup_common
,
5974 pa_def_subspaces
[i
].zero
,
5975 pa_def_subspaces
[i
].sort
,
5976 pa_def_subspaces
[i
].access
,
5977 pa_def_subspaces
[i
].space_index
,
5978 pa_def_subspaces
[i
].alignment
,
5979 pa_def_subspaces
[i
].quadrant
,
5987 /* Create a new space NAME, with the appropriate flags as defined
5988 by the given parameters. */
5990 static sd_chain_struct
*
5991 create_new_space (name
, spnum
, loadable
, defined
, private,
5992 sort
, seg
, user_defined
)
6002 sd_chain_struct
*chain_entry
;
6004 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
6006 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
6009 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
6010 strcpy (SPACE_NAME (chain_entry
), name
);
6011 SPACE_DEFINED (chain_entry
) = defined
;
6012 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
6013 SPACE_SPNUM (chain_entry
) = spnum
;
6015 chain_entry
->sd_seg
= seg
;
6016 chain_entry
->sd_last_subseg
= -1;
6017 chain_entry
->sd_subspaces
= NULL
;
6018 chain_entry
->sd_next
= NULL
;
6020 /* Find spot for the new space based on its sort key. */
6021 if (!space_dict_last
)
6022 space_dict_last
= chain_entry
;
6024 if (space_dict_root
== NULL
)
6025 space_dict_root
= chain_entry
;
6028 sd_chain_struct
*chain_pointer
;
6029 sd_chain_struct
*prev_chain_pointer
;
6031 chain_pointer
= space_dict_root
;
6032 prev_chain_pointer
= NULL
;
6034 while (chain_pointer
)
6036 prev_chain_pointer
= chain_pointer
;
6037 chain_pointer
= chain_pointer
->sd_next
;
6040 /* At this point we've found the correct place to add the new
6041 entry. So add it and update the linked lists as appropriate. */
6042 if (prev_chain_pointer
)
6044 chain_entry
->sd_next
= chain_pointer
;
6045 prev_chain_pointer
->sd_next
= chain_entry
;
6049 space_dict_root
= chain_entry
;
6050 chain_entry
->sd_next
= chain_pointer
;
6053 if (chain_entry
->sd_next
== NULL
)
6054 space_dict_last
= chain_entry
;
6057 /* This is here to catch predefined spaces which do not get
6058 modified by the user's input. Another call is found at
6059 the bottom of pa_parse_space_stmt to handle cases where
6060 the user modifies a predefined space. */
6061 #ifdef obj_set_section_attributes
6062 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
6068 /* Create a new subspace NAME, with the appropriate flags as defined
6069 by the given parameters.
6071 Add the new subspace to the subspace dictionary chain in numerical
6072 order as defined by the SORT entries. */
6074 static ssd_chain_struct
*
6075 create_new_subspace (space
, name
, loadable
, code_only
, common
,
6076 dup_common
, is_zero
, sort
, access
, space_index
,
6077 alignment
, quadrant
, seg
)
6078 sd_chain_struct
*space
;
6080 int loadable
, code_only
, common
, dup_common
, is_zero
;
6088 ssd_chain_struct
*chain_entry
;
6090 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
6092 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
6094 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
6095 strcpy (SUBSPACE_NAME (chain_entry
), name
);
6097 /* Initialize subspace_defined. When we hit a .subspace directive
6098 we'll set it to 1 which "locks-in" the subspace attributes. */
6099 SUBSPACE_DEFINED (chain_entry
) = 0;
6101 chain_entry
->ssd_subseg
= 0;
6102 chain_entry
->ssd_seg
= seg
;
6103 chain_entry
->ssd_next
= NULL
;
6105 /* Find spot for the new subspace based on its sort key. */
6106 if (space
->sd_subspaces
== NULL
)
6107 space
->sd_subspaces
= chain_entry
;
6110 ssd_chain_struct
*chain_pointer
;
6111 ssd_chain_struct
*prev_chain_pointer
;
6113 chain_pointer
= space
->sd_subspaces
;
6114 prev_chain_pointer
= NULL
;
6116 while (chain_pointer
)
6118 prev_chain_pointer
= chain_pointer
;
6119 chain_pointer
= chain_pointer
->ssd_next
;
6122 /* Now we have somewhere to put the new entry. Insert it and update
6124 if (prev_chain_pointer
)
6126 chain_entry
->ssd_next
= chain_pointer
;
6127 prev_chain_pointer
->ssd_next
= chain_entry
;
6131 space
->sd_subspaces
= chain_entry
;
6132 chain_entry
->ssd_next
= chain_pointer
;
6136 #ifdef obj_set_subsection_attributes
6137 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
6144 /* Update the information for the given subspace based upon the
6145 various arguments. Return the modified subspace chain entry. */
6147 static ssd_chain_struct
*
6148 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
6149 zero
, access
, space_index
, alignment
, quadrant
, section
)
6150 sd_chain_struct
*space
;
6164 ssd_chain_struct
*chain_entry
;
6166 chain_entry
= is_defined_subspace (name
);
6168 #ifdef obj_set_subsection_attributes
6169 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
6176 /* Return the space chain entry for the space with the name NAME or
6177 NULL if no such space exists. */
6179 static sd_chain_struct
*
6180 is_defined_space (name
)
6183 sd_chain_struct
*chain_pointer
;
6185 for (chain_pointer
= space_dict_root
;
6187 chain_pointer
= chain_pointer
->sd_next
)
6189 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
6190 return chain_pointer
;
6193 /* No mapping from segment to space was found. Return NULL. */
6197 /* Find and return the space associated with the given seg. If no mapping
6198 from the given seg to a space is found, then return NULL.
6200 Unlike subspaces, the number of spaces is not expected to grow much,
6201 so a linear exhaustive search is OK here. */
6203 static sd_chain_struct
*
6204 pa_segment_to_space (seg
)
6207 sd_chain_struct
*space_chain
;
6209 /* Walk through each space looking for the correct mapping. */
6210 for (space_chain
= space_dict_root
;
6212 space_chain
= space_chain
->sd_next
)
6214 if (space_chain
->sd_seg
== seg
)
6218 /* Mapping was not found. Return NULL. */
6222 /* Return the space chain entry for the subspace with the name NAME or
6223 NULL if no such subspace exists.
6225 Uses a linear search through all the spaces and subspaces, this may
6226 not be appropriate if we ever being placing each function in its
6229 static ssd_chain_struct
*
6230 is_defined_subspace (name
)
6233 sd_chain_struct
*space_chain
;
6234 ssd_chain_struct
*subspace_chain
;
6236 /* Walk through each space. */
6237 for (space_chain
= space_dict_root
;
6239 space_chain
= space_chain
->sd_next
)
6241 /* Walk through each subspace looking for a name which matches. */
6242 for (subspace_chain
= space_chain
->sd_subspaces
;
6244 subspace_chain
= subspace_chain
->ssd_next
)
6245 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
6246 return subspace_chain
;
6249 /* Subspace wasn't found. Return NULL. */
6253 /* Find and return the subspace associated with the given seg. If no
6254 mapping from the given seg to a subspace is found, then return NULL.
6256 If we ever put each procedure/function within its own subspace
6257 (to make life easier on the compiler and linker), then this will have
6258 to become more efficient. */
6260 static ssd_chain_struct
*
6261 pa_subsegment_to_subspace (seg
, subseg
)
6265 sd_chain_struct
*space_chain
;
6266 ssd_chain_struct
*subspace_chain
;
6268 /* Walk through each space. */
6269 for (space_chain
= space_dict_root
;
6271 space_chain
= space_chain
->sd_next
)
6273 if (space_chain
->sd_seg
== seg
)
6275 /* Walk through each subspace within each space looking for
6276 the correct mapping. */
6277 for (subspace_chain
= space_chain
->sd_subspaces
;
6279 subspace_chain
= subspace_chain
->ssd_next
)
6280 if (subspace_chain
->ssd_subseg
== (int) subseg
)
6281 return subspace_chain
;
6285 /* No mapping from subsegment to subspace found. Return NULL. */
6289 /* Given a number, try and find a space with the name number.
6291 Return a pointer to a space dictionary chain entry for the space
6292 that was found or NULL on failure. */
6294 static sd_chain_struct
*
6295 pa_find_space_by_number (number
)
6298 sd_chain_struct
*space_chain
;
6300 for (space_chain
= space_dict_root
;
6302 space_chain
= space_chain
->sd_next
)
6304 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
6308 /* No appropriate space found. Return NULL. */
6312 /* Return the starting address for the given subspace. If the starting
6313 address is unknown then return zero. */
6316 pa_subspace_start (space
, quadrant
)
6317 sd_chain_struct
*space
;
6320 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
6321 is not correct for the PA OSF1 port. */
6322 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
6324 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
6331 /* FIXME. Needs documentation. */
6333 pa_next_subseg (space
)
6334 sd_chain_struct
*space
;
6337 space
->sd_last_subseg
++;
6338 return space
->sd_last_subseg
;
6342 /* Helper function for pa_stringer. Used to find the end of
6349 unsigned int c
= *s
& CHAR_MASK
;
6352 /* We must have a valid space and subspace. */
6353 pa_check_current_space_and_subspace ();
6367 /* Handle a .STRING type pseudo-op. */
6370 pa_stringer (append_zero
)
6373 char *s
, num_buf
[4];
6377 /* Preprocess the string to handle PA-specific escape sequences.
6378 For example, \xDD where DD is a hexidecimal number should be
6379 changed to \OOO where OOO is an octal number. */
6381 /* Skip the opening quote. */
6382 s
= input_line_pointer
+ 1;
6384 while (is_a_char (c
= pa_stringer_aux (s
++)))
6391 /* Handle \x<num>. */
6394 unsigned int number
;
6399 /* Get pas the 'x'. */
6401 for (num_digit
= 0, number
= 0, dg
= *s
;
6403 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
6404 || (dg
>= 'A' && dg
<= 'F'));
6408 number
= number
* 16 + dg
- '0';
6409 else if (dg
>= 'a' && dg
<= 'f')
6410 number
= number
* 16 + dg
- 'a' + 10;
6412 number
= number
* 16 + dg
- 'A' + 10;
6422 sprintf (num_buf
, "%02o", number
);
6425 sprintf (num_buf
, "%03o", number
);
6428 for (i
= 0; i
<= num_digit
; i
++)
6429 s_start
[i
] = num_buf
[i
];
6433 /* This might be a "\"", skip over the escaped char. */
6440 stringer (append_zero
);
6441 pa_undefine_label ();
6444 /* Handle a .VERSION pseudo-op. */
6451 pa_undefine_label ();
6456 /* Handle a .COMPILER pseudo-op. */
6459 pa_compiler (unused
)
6462 obj_som_compiler (0);
6463 pa_undefine_label ();
6468 /* Handle a .COPYRIGHT pseudo-op. */
6471 pa_copyright (unused
)
6475 pa_undefine_label ();
6478 /* Just like a normal cons, but when finished we have to undefine
6479 the latest space label. */
6486 pa_undefine_label ();
6489 /* Switch to the data space. As usual delete our label. */
6496 current_space
= is_defined_space ("$PRIVATE$");
6498 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6501 pa_undefine_label ();
6504 /* Like float_cons, but we need to undefine our label. */
6507 pa_float_cons (float_type
)
6510 float_cons (float_type
);
6511 pa_undefine_label ();
6514 /* Like s_fill, but delete our label when finished. */
6521 /* We must have a valid space and subspace. */
6522 pa_check_current_space_and_subspace ();
6526 pa_undefine_label ();
6529 /* Like lcomm, but delete our label when finished. */
6532 pa_lcomm (needs_align
)
6536 /* We must have a valid space and subspace. */
6537 pa_check_current_space_and_subspace ();
6540 s_lcomm (needs_align
);
6541 pa_undefine_label ();
6544 /* Like lsym, but delete our label when finished. */
6551 /* We must have a valid space and subspace. */
6552 pa_check_current_space_and_subspace ();
6556 pa_undefine_label ();
6559 /* Switch to the text space. Like s_text, but delete our
6560 label when finished. */
6566 current_space
= is_defined_space ("$TEXT$");
6568 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6572 pa_undefine_label ();
6575 /* On the PA relocations which involve function symbols must not be
6576 adjusted. This so that the linker can know when/how to create argument
6577 relocation stubs for indirect calls and calls to static functions.
6579 "T" field selectors create DLT relative fixups for accessing
6580 globals and statics in PIC code; each DLT relative fixup creates
6581 an entry in the DLT table. The entries contain the address of
6582 the final target (eg accessing "foo" would create a DLT entry
6583 with the address of "foo").
6585 Unfortunately, the HP linker doesn't take into account any addend
6586 when generating the DLT; so accessing $LIT$+8 puts the address of
6587 $LIT$ into the DLT rather than the address of $LIT$+8.
6589 The end result is we can't perform relocation symbol reductions for
6590 any fixup which creates entries in the DLT (eg they use "T" field
6593 Reject reductions involving symbols with external scope; such
6594 reductions make life a living hell for object file editors.
6596 FIXME. Also reject R_HPPA relocations which are 32bits wide in
6597 the code space. The SOM BFD backend doesn't know how to pull the
6598 right bits out of an instruction. */
6601 hppa_fix_adjustable (fixp
)
6604 struct hppa_fix_struct
*hppa_fix
;
6606 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6609 /* Reject reductions of symbols in 32bit relocs. */
6610 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
6613 /* Reject reductions of symbols in sym1-sym2 expressions when
6614 the fixup will occur in a CODE subspace.
6616 XXX FIXME: Long term we probably want to reject all of these;
6617 for example reducing in the debug section would lose if we ever
6618 supported using the optimizing hp linker. */
6621 && (hppa_fix
->segment
->flags
& SEC_CODE
))
6623 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
6624 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
6628 /* We can't adjust any relocs that use LR% and RR% field selectors.
6629 That confuses the HP linker. */
6630 if (hppa_fix
->fx_r_field
== e_lrsel
6631 || hppa_fix
->fx_r_field
== e_rrsel
6632 || hppa_fix
->fx_r_field
== e_nlrsel
)
6636 /* Reject reductions of symbols in DLT relative relocs,
6637 relocations with plabels. */
6638 if (hppa_fix
->fx_r_field
== e_tsel
6639 || hppa_fix
->fx_r_field
== e_ltsel
6640 || hppa_fix
->fx_r_field
== e_rtsel
6641 || hppa_fix
->fx_r_field
== e_psel
6642 || hppa_fix
->fx_r_field
== e_rpsel
6643 || hppa_fix
->fx_r_field
== e_lpsel
)
6646 if (fixp
->fx_addsy
&& S_IS_EXTERNAL (fixp
->fx_addsy
))
6649 /* Reject absolute calls (jumps). */
6650 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
6653 /* Reject reductions of function symbols. */
6654 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
6660 /* Return nonzero if the fixup in FIXP will require a relocation,
6661 even it if appears that the fixup could be completely handled
6665 hppa_force_relocation (fixp
)
6668 struct hppa_fix_struct
*hppa_fixp
;
6671 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6673 if (fixp
->fx_r_type
== R_HPPA_ENTRY
|| fixp
->fx_r_type
== R_HPPA_EXIT
6674 || fixp
->fx_r_type
== R_HPPA_BEGIN_BRTAB
6675 || fixp
->fx_r_type
== R_HPPA_END_BRTAB
6676 || fixp
->fx_r_type
== R_HPPA_BEGIN_TRY
6677 || fixp
->fx_r_type
== R_HPPA_END_TRY
6678 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
6679 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
6683 #define arg_reloc_stub_needed(CALLER, CALLEE) \
6684 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
6687 /* It is necessary to force PC-relative calls/jumps to have a relocation
6688 entry if they're going to need either a argument relocation or long
6689 call stub. FIXME. Can't we need the same for absolute calls? */
6690 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
6691 && (arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
6692 symbol_get_bfdsym (fixp
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
6693 hppa_fixp
->fx_arg_reloc
)))
6696 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
6697 - md_pcrel_from (fixp
));
6698 /* Now check and see if we're going to need a long-branch stub. */
6699 if (fixp
->fx_r_type
== R_HPPA_PCREL_CALL
6700 && (distance
> 262143 || distance
< -262144))
6703 if (fixp
->fx_r_type
== R_HPPA_ABS_CALL
)
6705 #undef arg_reloc_stub_needed
6707 /* No need (yet) to force another relocations to be emitted. */
6711 /* Now for some ELF specific code. FIXME. */
6713 /* Mark the end of a function so that it's possible to compute
6714 the size of the function in hppa_elf_final_processing. */
6717 hppa_elf_mark_end_of_function ()
6719 /* ELF does not have EXIT relocations. All we do is create a
6720 temporary symbol marking the end of the function. */
6721 char *name
= (char *)
6722 xmalloc (strlen ("L$\001end_") +
6723 strlen (S_GET_NAME (last_call_info
->start_symbol
)) + 1);
6729 strcpy (name
, "L$\001end_");
6730 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
6732 /* If we have a .exit followed by a .procend, then the
6733 symbol will have already been defined. */
6734 symbolP
= symbol_find (name
);
6737 /* The symbol has already been defined! This can
6738 happen if we have a .exit followed by a .procend.
6740 This is *not* an error. All we want to do is free
6741 the memory we just allocated for the name and continue. */
6746 /* symbol value should be the offset of the
6747 last instruction of the function */
6748 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
6752 S_CLEAR_EXTERNAL (symbolP
);
6753 symbol_table_insert (symbolP
);
6757 last_call_info
->end_symbol
= symbolP
;
6759 as_bad (_("Symbol '%s' could not be created."), name
);
6763 as_bad (_("No memory for symbol name."));
6767 /* For ELF, this function serves one purpose: to setup the st_size
6768 field of STT_FUNC symbols. To do this, we need to scan the
6769 call_info structure list, determining st_size in by taking the
6770 difference in the address of the beginning/end marker symbols. */
6773 elf_hppa_final_processing ()
6775 struct call_info
*call_info_pointer
;
6777 for (call_info_pointer
= call_info_root
;
6779 call_info_pointer
= call_info_pointer
->ci_next
)
6781 elf_symbol_type
*esym
6782 = ((elf_symbol_type
*)
6783 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
6784 esym
->internal_elf_sym
.st_size
=
6785 S_GET_VALUE (call_info_pointer
->end_symbol
)
6786 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;