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 /* If we are using ELF, then we probably can support dwarf2 debug
43 records. Furthermore, if we are supporting dwarf2 debug records,
44 then we want to use the assembler support for compact line numbers. */
46 #include "dwarf2dbg.h"
47 struct dwarf2_line_info debug_line
;
50 /* A "convient" place to put object file dependencies which do
51 not need to be seen outside of tc-hppa.c. */
53 /* Object file formats specify relocation types. */
54 typedef elf_hppa_reloc_type reloc_type
;
56 /* Object file formats specify BFD symbol types. */
57 typedef elf_symbol_type obj_symbol_type
;
60 /* How to generate a relocation. */
61 #define hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
63 #define hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
66 /* ELF objects can have versions, but apparently do not have anywhere
67 to store a copyright string. */
68 #define obj_version obj_elf_version
69 #define obj_copyright obj_elf_version
71 #define UNWIND_SECTION_NAME ".PARISC.unwind"
75 /* Names of various debugging spaces/subspaces. */
76 #define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$"
77 #define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$"
78 #define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$"
79 #define UNWIND_SECTION_NAME "$UNWIND$"
81 /* Object file formats specify relocation types. */
82 typedef int reloc_type
;
84 /* SOM objects can have both a version string and a copyright string. */
85 #define obj_version obj_som_version
86 #define obj_copyright obj_som_copyright
88 /* How to generate a relocation. */
89 #define hppa_gen_reloc_type hppa_som_gen_reloc_type
91 /* Object file formats specify BFD symbol types. */
92 typedef som_symbol_type obj_symbol_type
;
94 /* This apparently isn't in older versions of hpux reloc.h. */
96 #define R_DLT_REL 0x78
108 /* Various structures and types used internally in tc-hppa.c. */
110 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
114 unsigned int cannot_unwind
:1;
115 unsigned int millicode
:1;
116 unsigned int millicode_save_rest
:1;
117 unsigned int region_desc
:2;
118 unsigned int save_sr
:2;
119 unsigned int entry_fr
:4;
120 unsigned int entry_gr
:5;
121 unsigned int args_stored
:1;
122 unsigned int call_fr
:5;
123 unsigned int call_gr
:5;
124 unsigned int save_sp
:1;
125 unsigned int save_rp
:1;
126 unsigned int save_rp_in_frame
:1;
127 unsigned int extn_ptr_defined
:1;
128 unsigned int cleanup_defined
:1;
130 unsigned int hpe_interrupt_marker
:1;
131 unsigned int hpux_interrupt_marker
:1;
132 unsigned int reserved
:3;
133 unsigned int frame_size
:27;
138 /* Starting and ending offsets of the region described by
140 unsigned int start_offset
;
141 unsigned int end_offset
;
142 struct unwind_desc descriptor
;
145 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
146 control the entry and exit code they generate. It is also used in
147 creation of the correct stack unwind descriptors.
149 NOTE: GAS does not support .enter and .leave for the generation of
150 prologues and epilogues. FIXME.
152 The fields in structure roughly correspond to the arguments available on the
153 .callinfo pseudo-op. */
157 /* The unwind descriptor being built. */
158 struct unwind_table ci_unwind
;
160 /* Name of this function. */
161 symbolS
*start_symbol
;
163 /* (temporary) symbol used to mark the end of this function. */
166 /* Next entry in the chain. */
167 struct call_info
*ci_next
;
170 /* Operand formats for FP instructions. Note not all FP instructions
171 allow all four formats to be used (for example fmpysub only allows
175 SGL
, DBL
, ILLEGAL_FMT
, QUAD
, W
, UW
, DW
, UDW
, QW
, UQW
179 /* This fully describes the symbol types which may be attached to
180 an EXPORT or IMPORT directive. Only SOM uses this formation
181 (ELF has no need for it). */
185 SYMBOL_TYPE_ABSOLUTE
,
189 SYMBOL_TYPE_MILLICODE
,
191 SYMBOL_TYPE_PRI_PROG
,
192 SYMBOL_TYPE_SEC_PROG
,
196 /* This structure contains information needed to assemble
197 individual instructions. */
200 /* Holds the opcode after parsing by pa_ip. */
201 unsigned long opcode
;
203 /* Holds an expression associated with the current instruction. */
206 /* Does this instruction use PC-relative addressing. */
209 /* Floating point formats for operand1 and operand2. */
210 fp_operand_format fpof1
;
211 fp_operand_format fpof2
;
213 /* Whether or not we saw a truncation request on an fcnv insn. */
216 /* Holds the field selector for this instruction
217 (for example L%, LR%, etc). */
220 /* Holds any argument relocation bits associated with this
221 instruction. (instruction should be some sort of call). */
224 /* The format specification for this instruction. */
227 /* The relocation (if any) associated with this instruction. */
231 /* PA-89 floating point registers are arranged like this:
234 +--------------+--------------+
235 | 0 or 16L | 16 or 16R |
236 +--------------+--------------+
237 | 1 or 17L | 17 or 17R |
238 +--------------+--------------+
246 +--------------+--------------+
247 | 14 or 30L | 30 or 30R |
248 +--------------+--------------+
249 | 15 or 31L | 31 or 31R |
250 +--------------+--------------+
253 The following is a version of pa_parse_number that
254 handles the L/R notation and returns the correct
255 value to put into the instruction register field.
256 The correct value to put into the instruction is
257 encoded in the structure 'pa_11_fp_reg_struct'. */
259 struct pa_11_fp_reg_struct
261 /* The register number. */
268 /* Additional information needed to build argument relocation stubs. */
271 /* The argument relocation specification. */
272 unsigned int arg_reloc
;
274 /* Number of arguments. */
275 unsigned int arg_count
;
279 /* This structure defines an entry in the subspace dictionary
282 struct subspace_dictionary_chain
284 /* Nonzero if this space has been defined by the user code. */
285 unsigned int ssd_defined
;
287 /* Name of this subspace. */
290 /* GAS segment and subsegment associated with this subspace. */
294 /* Next space in the subspace dictionary chain. */
295 struct subspace_dictionary_chain
*ssd_next
;
298 typedef struct subspace_dictionary_chain ssd_chain_struct
;
300 /* This structure defines an entry in the subspace dictionary
303 struct space_dictionary_chain
305 /* Nonzero if this space has been defined by the user code or
306 as a default space. */
307 unsigned int sd_defined
;
309 /* Nonzero if this spaces has been defined by the user code. */
310 unsigned int sd_user_defined
;
312 /* The space number (or index). */
313 unsigned int sd_spnum
;
315 /* The name of this subspace. */
318 /* GAS segment to which this subspace corresponds. */
321 /* Current subsegment number being used. */
324 /* The chain of subspaces contained within this space. */
325 ssd_chain_struct
*sd_subspaces
;
327 /* The next entry in the space dictionary chain. */
328 struct space_dictionary_chain
*sd_next
;
331 typedef struct space_dictionary_chain sd_chain_struct
;
333 /* This structure defines attributes of the default subspace
334 dictionary entries. */
336 struct default_subspace_dict
338 /* Name of the subspace. */
341 /* FIXME. Is this still needed? */
344 /* Nonzero if this subspace is loadable. */
347 /* Nonzero if this subspace contains only code. */
350 /* Nonzero if this is a common subspace. */
353 /* Nonzero if this is a common subspace which allows symbols
354 to be multiply defined. */
357 /* Nonzero if this subspace should be zero filled. */
360 /* Sort key for this subspace. */
363 /* Access control bits for this subspace. Can represent RWX access
364 as well as privilege level changes for gateways. */
367 /* Index of containing space. */
370 /* Alignment (in bytes) of this subspace. */
373 /* Quadrant within space where this subspace should be loaded. */
376 /* An index into the default spaces array. */
379 /* Subsegment associated with this subspace. */
383 /* This structure defines attributes of the default space
384 dictionary entries. */
386 struct default_space_dict
388 /* Name of the space. */
391 /* Space number. It is possible to identify spaces within
392 assembly code numerically! */
395 /* Nonzero if this space is loadable. */
398 /* Nonzero if this space is "defined". FIXME is still needed */
401 /* Nonzero if this space can not be shared. */
404 /* Sort key for this space. */
407 /* Segment associated with this space. */
412 /* Structure for previous label tracking. Needed so that alignments,
413 callinfo declarations, etc can be easily attached to a particular
415 typedef struct label_symbol_struct
417 struct symbol
*lss_label
;
419 sd_chain_struct
*lss_space
;
424 struct label_symbol_struct
*lss_next
;
428 /* Extra information needed to perform fixups (relocations) on the PA. */
429 struct hppa_fix_struct
431 /* The field selector. */
432 enum hppa_reloc_field_selector_type_alt fx_r_field
;
437 /* Format of fixup. */
440 /* Argument relocation bits. */
443 /* The segment this fixup appears in. */
447 /* Structure to hold information about predefined registers. */
455 /* This structure defines the mapping from a FP condition string
456 to a condition number which can be recorded in an instruction. */
463 /* This structure defines a mapping from a field selector
464 string to a field selector type. */
465 struct selector_entry
471 /* Prototypes for functions local to tc-hppa.c. */
474 static void pa_check_current_space_and_subspace
PARAMS ((void));
477 static fp_operand_format pa_parse_fp_format
PARAMS ((char **s
));
478 static void pa_cons
PARAMS ((int));
479 static void pa_data
PARAMS ((int));
480 static void pa_float_cons
PARAMS ((int));
481 static void pa_fill
PARAMS ((int));
482 static void pa_lcomm
PARAMS ((int));
483 static void pa_lsym
PARAMS ((int));
484 static void pa_stringer
PARAMS ((int));
485 static void pa_text
PARAMS ((int));
486 static void pa_version
PARAMS ((int));
487 static int pa_parse_fp_cmp_cond
PARAMS ((char **));
488 static int get_expression
PARAMS ((char *));
489 static int pa_get_absolute_expression
PARAMS ((struct pa_it
*, char **));
490 static int evaluate_absolute
PARAMS ((struct pa_it
*));
491 static unsigned int pa_build_arg_reloc
PARAMS ((char *));
492 static unsigned int pa_align_arg_reloc
PARAMS ((unsigned int, unsigned int));
493 static int pa_parse_nullif
PARAMS ((char **));
494 static int pa_parse_nonneg_cmpsub_cmpltr
PARAMS ((char **, int));
495 static int pa_parse_neg_cmpsub_cmpltr
PARAMS ((char **, int));
496 static int pa_parse_neg_add_cmpltr
PARAMS ((char **, int));
497 static int pa_parse_nonneg_add_cmpltr
PARAMS ((char **, int));
498 static int pa_parse_cmpb_64_cmpltr
PARAMS ((char **));
499 static int pa_parse_cmpib_64_cmpltr
PARAMS ((char **));
500 static int pa_parse_addb_64_cmpltr
PARAMS ((char **));
501 static void pa_block
PARAMS ((int));
502 static void pa_brtab
PARAMS ((int));
503 static void pa_try
PARAMS ((int));
504 static void pa_call
PARAMS ((int));
505 static void pa_call_args
PARAMS ((struct call_desc
*));
506 static void pa_callinfo
PARAMS ((int));
507 static void pa_code
PARAMS ((int));
508 static void pa_comm
PARAMS ((int));
509 static void pa_copyright
PARAMS ((int));
510 static void pa_end
PARAMS ((int));
511 static void pa_enter
PARAMS ((int));
512 static void pa_entry
PARAMS ((int));
513 static void pa_equ
PARAMS ((int));
514 static void pa_exit
PARAMS ((int));
515 static void pa_export
PARAMS ((int));
516 static void pa_type_args
PARAMS ((symbolS
*, int));
517 static void pa_import
PARAMS ((int));
518 static void pa_label
PARAMS ((int));
519 static void pa_leave
PARAMS ((int));
520 static void pa_level
PARAMS ((int));
521 static void pa_origin
PARAMS ((int));
522 static void pa_proc
PARAMS ((int));
523 static void pa_procend
PARAMS ((int));
524 static void pa_param
PARAMS ((int));
525 static void pa_undefine_label
PARAMS ((void));
526 static int need_pa11_opcode
PARAMS ((struct pa_it
*,
527 struct pa_11_fp_reg_struct
*));
528 static int pa_parse_number
PARAMS ((char **, struct pa_11_fp_reg_struct
*));
529 static label_symbol_struct
*pa_get_label
PARAMS ((void));
531 static int log2
PARAMS ((int));
532 static void pa_compiler
PARAMS ((int));
533 static void pa_align
PARAMS ((int));
534 static void pa_space
PARAMS ((int));
535 static void pa_spnum
PARAMS ((int));
536 static void pa_subspace
PARAMS ((int));
537 static sd_chain_struct
*create_new_space
PARAMS ((char *, int, int,
540 static ssd_chain_struct
*create_new_subspace
PARAMS ((sd_chain_struct
*,
545 static ssd_chain_struct
*update_subspace
PARAMS ((sd_chain_struct
*,
546 char *, int, int, int,
550 static sd_chain_struct
*is_defined_space
PARAMS ((char *));
551 static ssd_chain_struct
*is_defined_subspace
PARAMS ((char *));
552 static sd_chain_struct
*pa_segment_to_space
PARAMS ((asection
*));
553 static ssd_chain_struct
*pa_subsegment_to_subspace
PARAMS ((asection
*,
555 static sd_chain_struct
*pa_find_space_by_number
PARAMS ((int));
556 static unsigned int pa_subspace_start
PARAMS ((sd_chain_struct
*, int));
557 static sd_chain_struct
*pa_parse_space_stmt
PARAMS ((char *, int));
558 static int pa_next_subseg
PARAMS ((sd_chain_struct
*));
559 static void pa_spaces_begin
PARAMS ((void));
561 static void pa_ip
PARAMS ((char *));
562 static void fix_new_hppa
PARAMS ((fragS
*, int, int, symbolS
*,
563 long, expressionS
*, int,
564 bfd_reloc_code_real_type
,
565 enum hppa_reloc_field_selector_type_alt
,
567 static int is_end_of_statement
PARAMS ((void));
568 static int reg_name_search
PARAMS ((char *));
569 static int pa_chk_field_selector
PARAMS ((char **));
570 static int is_same_frag
PARAMS ((fragS
*, fragS
*));
571 static void process_exit
PARAMS ((void));
572 static unsigned int pa_stringer_aux
PARAMS ((char *));
573 static fp_operand_format pa_parse_fp_cnv_format
PARAMS ((char **s
));
574 static int pa_parse_ftest_gfx_completer
PARAMS ((char **));
577 static void hppa_elf_mark_end_of_function
PARAMS ((void));
578 static void pa_build_unwind_subspace
PARAMS ((struct call_info
*));
581 /* File and gloally scoped variable declarations. */
584 /* Root and final entry in the space chain. */
585 static sd_chain_struct
*space_dict_root
;
586 static sd_chain_struct
*space_dict_last
;
588 /* The current space and subspace. */
589 static sd_chain_struct
*current_space
;
590 static ssd_chain_struct
*current_subspace
;
593 /* Root of the call_info chain. */
594 static struct call_info
*call_info_root
;
596 /* The last call_info (for functions) structure
597 seen so it can be associated with fixups and
599 static struct call_info
*last_call_info
;
601 /* The last call description (for actual calls). */
602 static struct call_desc last_call_desc
;
604 /* handle of the OPCODE hash table */
605 static struct hash_control
*op_hash
= NULL
;
607 /* This array holds the chars that always start a comment. If the
608 pre-processor is disabled, these aren't very useful. */
609 const char comment_chars
[] = ";";
611 /* Table of pseudo ops for the PA. FIXME -- how many of these
612 are now redundant with the overall GAS and the object file
614 const pseudo_typeS md_pseudo_table
[] =
616 /* align pseudo-ops on the PA specify the actual alignment requested,
617 not the log2 of the requested alignment. */
619 {"align", pa_align
, 8},
622 {"align", s_align_bytes
, 8},
624 {"begin_brtab", pa_brtab
, 1},
625 {"begin_try", pa_try
, 1},
626 {"block", pa_block
, 1},
627 {"blockz", pa_block
, 0},
628 {"byte", pa_cons
, 1},
629 {"call", pa_call
, 0},
630 {"callinfo", pa_callinfo
, 0},
631 {"code", pa_code
, 0},
632 {"comm", pa_comm
, 0},
634 {"compiler", pa_compiler
, 0},
636 {"copyright", pa_copyright
, 0},
637 {"data", pa_data
, 0},
638 {"double", pa_float_cons
, 'd'},
639 {"dword", pa_cons
, 8},
641 {"end_brtab", pa_brtab
, 0},
642 {"end_try", pa_try
, 0},
643 {"enter", pa_enter
, 0},
644 {"entry", pa_entry
, 0},
646 {"exit", pa_exit
, 0},
647 {"export", pa_export
, 0},
649 { "file", dwarf2_directive_file
, 0 },
651 {"fill", pa_fill
, 0},
652 {"float", pa_float_cons
, 'f'},
653 {"half", pa_cons
, 2},
654 {"import", pa_import
, 0},
656 {"label", pa_label
, 0},
657 {"lcomm", pa_lcomm
, 0},
658 {"leave", pa_leave
, 0},
659 {"level", pa_level
, 0},
661 { "loc", dwarf2_directive_loc
, 0 },
663 {"long", pa_cons
, 4},
664 {"lsym", pa_lsym
, 0},
666 {"nsubspa", pa_subspace
, 1},
668 {"octa", pa_cons
, 16},
669 {"org", pa_origin
, 0},
670 {"origin", pa_origin
, 0},
671 {"param", pa_param
, 0},
672 {"proc", pa_proc
, 0},
673 {"procend", pa_procend
, 0},
674 {"quad", pa_cons
, 8},
676 {"short", pa_cons
, 2},
677 {"single", pa_float_cons
, 'f'},
679 {"space", pa_space
, 0},
680 {"spnum", pa_spnum
, 0},
682 {"string", pa_stringer
, 0},
683 {"stringz", pa_stringer
, 1},
685 {"subspa", pa_subspace
, 0},
687 {"text", pa_text
, 0},
688 {"version", pa_version
, 0},
689 {"word", pa_cons
, 4},
693 /* This array holds the chars that only start a comment at the beginning of
694 a line. If the line seems to have the form '# 123 filename'
695 .line and .file directives will appear in the pre-processed output.
697 Note that input_file.c hand checks for '#' at the beginning of the
698 first line of the input file. This is because the compiler outputs
699 #NO_APP at the beginning of its output.
701 Also note that C style comments will always work. */
702 const char line_comment_chars
[] = "#";
704 /* This array holds the characters which act as line separators. */
705 const char line_separator_chars
[] = "!";
707 /* Chars that can be used to separate mant from exp in floating point nums. */
708 const char EXP_CHARS
[] = "eE";
710 /* Chars that mean this number is a floating point constant.
711 As in 0f12.456 or 0d1.2345e12.
713 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
714 changed in read.c. Ideally it shouldn't hae to know abou it at
715 all, but nothing is ideal around here. */
716 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
718 static struct pa_it the_insn
;
720 /* Points to the end of an expression just parsed by get_expressoin
721 and friends. FIXME. This shouldn't be handled with a file-global
723 static char *expr_end
;
725 /* Nonzero if a .callinfo appeared within the current procedure. */
726 static int callinfo_found
;
728 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
729 static int within_entry_exit
;
731 /* Nonzero if the assembler is currently within a procedure definition. */
732 static int within_procedure
;
734 /* Handle on strucutre which keep track of the last symbol
735 seen in each subspace. */
736 static label_symbol_struct
*label_symbols_rootp
= NULL
;
738 /* Holds the last field selector. */
739 static int hppa_field_selector
;
741 /* Nonzero when strict syntax checking is enabled. Zero otherwise.
743 Each opcode in the table has a flag which indicates whether or not
744 strict syntax checking should be enabled for that instruction. */
745 static int strict
= 0;
748 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
749 static symbolS
*dummy_symbol
;
752 /* Nonzero if errors are to be printed. */
753 static int print_errors
= 1;
755 /* List of registers that are pre-defined:
757 Each general register has one predefined name of the form
758 %r<REGNUM> which has the value <REGNUM>.
760 Space and control registers are handled in a similar manner,
761 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
763 Likewise for the floating point registers, but of the form
764 %fr<REGNUM>. Floating point registers have additional predefined
765 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
766 again have the value <REGNUM>.
768 Many registers also have synonyms:
770 %r26 - %r23 have %arg0 - %arg3 as synonyms
771 %r28 - %r29 have %ret0 - %ret1 as synonyms
772 %r30 has %sp as a synonym
773 %r27 has %dp as a synonym
774 %r2 has %rp as a synonym
776 Almost every control register has a synonym; they are not listed
779 The table is sorted. Suitable for searching by a binary search. */
781 static const struct pd_reg pre_defined_registers
[] =
981 /* This table is sorted by order of the length of the string. This is
982 so we check for <> before we check for <. If we had a <> and checked
983 for < first, we would get a false match. */
984 static const struct fp_cond_map fp_cond_map
[] =
1020 static const struct selector_entry selector_table
[] =
1045 /* default space and subspace dictionaries */
1047 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1048 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1050 /* pre-defined subsegments (subspaces) for the HPPA. */
1051 #define SUBSEG_CODE 0
1052 #define SUBSEG_LIT 1
1053 #define SUBSEG_MILLI 2
1054 #define SUBSEG_DATA 0
1055 #define SUBSEG_BSS 2
1056 #define SUBSEG_UNWIND 3
1057 #define SUBSEG_GDB_STRINGS 0
1058 #define SUBSEG_GDB_SYMBOLS 1
1060 static struct default_subspace_dict pa_def_subspaces
[] =
1062 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE
},
1063 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA
},
1064 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT
},
1065 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI
},
1066 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS
},
1067 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1070 static struct default_space_dict pa_def_spaces
[] =
1072 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
},
1073 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
},
1074 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
}
1077 /* Misc local definitions used by the assembler. */
1079 /* These macros are used to maintain spaces/subspaces. */
1080 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1081 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1082 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1083 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1085 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1086 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1089 /* Return nonzero if the string pointed to by S potentially represents
1090 a right or left half of a FP register */
1091 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1092 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1094 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1095 main loop after insertion. */
1097 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1099 ((OPCODE) |= (FIELD) << (START)); \
1103 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1104 IGNORE is used to suppress the error message. */
1106 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1108 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1111 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1117 /* Simple alignment checking for FIELD againt ALIGN (a power of two).
1118 IGNORE is used to suppress the error message. */
1120 #define CHECK_ALIGN(FIELD, ALIGN, IGNORE) \
1122 if ((FIELD) & ((ALIGN) - 1)) \
1125 as_bad (_("Field not properly aligned [%d] (%d)."), (ALIGN), \
1131 #define is_DP_relative(exp) \
1132 ((exp).X_op == O_subtract \
1133 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1135 #define is_PC_relative(exp) \
1136 ((exp).X_op == O_subtract \
1137 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1139 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1140 always be able to reduce the expression to a constant, so we don't
1141 need real complex handling yet. */
1142 #define is_complex(exp) \
1143 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1145 /* Actual functions to implement the PA specific code for the assembler. */
1147 /* Called before writing the object file. Make sure entry/exit and
1148 proc/procend pairs match. */
1153 if (within_entry_exit
)
1154 as_fatal (_("Missing .exit\n"));
1156 if (within_procedure
)
1157 as_fatal (_("Missing .procend\n"));
1160 /* Returns a pointer to the label_symbol_struct for the current space.
1161 or NULL if no label_symbol_struct exists for the current space. */
1163 static label_symbol_struct
*
1166 label_symbol_struct
*label_chain
;
1168 for (label_chain
= label_symbols_rootp
;
1170 label_chain
= label_chain
->lss_next
)
1173 if (current_space
== label_chain
->lss_space
&& label_chain
->lss_label
)
1177 if (now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
)
1185 /* Defines a label for the current space. If one is already defined,
1186 this function will replace it with the new label. */
1189 pa_define_label (symbol
)
1192 label_symbol_struct
*label_chain
= pa_get_label ();
1195 label_chain
->lss_label
= symbol
;
1198 /* Create a new label entry and add it to the head of the chain. */
1200 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1201 label_chain
->lss_label
= symbol
;
1203 label_chain
->lss_space
= current_space
;
1206 label_chain
->lss_segment
= now_seg
;
1208 label_chain
->lss_next
= NULL
;
1210 if (label_symbols_rootp
)
1211 label_chain
->lss_next
= label_symbols_rootp
;
1213 label_symbols_rootp
= label_chain
;
1217 /* Removes a label definition for the current space.
1218 If there is no label_symbol_struct entry, then no action is taken. */
1221 pa_undefine_label ()
1223 label_symbol_struct
*label_chain
;
1224 label_symbol_struct
*prev_label_chain
= NULL
;
1226 for (label_chain
= label_symbols_rootp
;
1228 label_chain
= label_chain
->lss_next
)
1232 && current_space
== label_chain
->lss_space
&& label_chain
->lss_label
1235 && now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
1239 /* Remove the label from the chain and free its memory. */
1240 if (prev_label_chain
)
1241 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1243 label_symbols_rootp
= label_chain
->lss_next
;
1248 prev_label_chain
= label_chain
;
1253 /* An HPPA-specific version of fix_new. This is required because the HPPA
1254 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1255 results in the creation of an instance of an hppa_fix_struct. An
1256 hppa_fix_struct stores the extra information along with a pointer to the
1257 original fixS. This is attached to the original fixup via the
1258 tc_fix_data field. */
1261 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1262 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1266 symbolS
*add_symbol
;
1270 bfd_reloc_code_real_type r_type
;
1271 enum hppa_reloc_field_selector_type_alt r_field
;
1274 int* unwind_bits ATTRIBUTE_UNUSED
;
1278 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1279 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1282 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1284 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1285 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1286 hppa_fix
->fx_r_type
= r_type
;
1287 hppa_fix
->fx_r_field
= r_field
;
1288 hppa_fix
->fx_r_format
= r_format
;
1289 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1290 hppa_fix
->segment
= now_seg
;
1292 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1293 new_fix
->fx_offset
= *unwind_bits
;
1296 /* foo-$global$ is used to access non-automatic storage. $global$
1297 is really just a marker and has served its purpose, so eliminate
1298 it now so as not to confuse write.c. */
1299 if (new_fix
->fx_subsy
1300 && !strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$"))
1301 new_fix
->fx_subsy
= NULL
;
1304 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1305 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1308 parse_cons_expression_hppa (exp
)
1311 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1315 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1316 hppa_field_selector is set by the parse_cons_expression_hppa. */
1319 cons_fix_new_hppa (frag
, where
, size
, exp
)
1325 unsigned int rel_type
;
1327 /* Get a base relocation type. */
1328 if (is_DP_relative (*exp
))
1329 rel_type
= R_HPPA_GOTOFF
;
1330 else if (is_complex (*exp
))
1331 rel_type
= R_HPPA_COMPLEX
;
1335 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1336 as_warn (_("Invalid field selector. Assuming F%%."));
1338 fix_new_hppa (frag
, where
, size
,
1339 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1340 hppa_field_selector
, size
* 8, 0, NULL
);
1342 /* Reset field selector to its default state. */
1343 hppa_field_selector
= 0;
1346 /* This function is called once, at assembler startup time. It should
1347 set up all the tables, etc. that the MD part of the assembler will need. */
1352 const char *retval
= NULL
;
1356 last_call_info
= NULL
;
1357 call_info_root
= NULL
;
1359 /* Set the default machine type. */
1360 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1361 as_warn (_("could not set architecture and machine"));
1363 /* Folding of text and data segments fails miserably on the PA.
1364 Warn user and disable "-R" option. */
1365 if (flag_readonly_data_in_text
)
1367 as_warn (_("-R option not supported on this target."));
1368 flag_readonly_data_in_text
= 0;
1375 op_hash
= hash_new ();
1377 while (i
< NUMOPCODES
)
1379 const char *name
= pa_opcodes
[i
].name
;
1380 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1381 if (retval
!= NULL
&& *retval
!= '\0')
1383 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1388 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1389 != pa_opcodes
[i
].match
)
1391 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1392 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1397 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1401 as_fatal (_("Broken assembler. No assembly attempted."));
1404 /* SOM will change text_section. To make sure we never put
1405 anything into the old one switch to the new one now. */
1406 subseg_set (text_section
, 0);
1410 dummy_symbol
= symbol_find_or_make ("L$dummy");
1411 S_SET_SEGMENT (dummy_symbol
, text_section
);
1412 /* Force the symbol to be converted to a real symbol. */
1413 (void) symbol_get_bfdsym (dummy_symbol
);
1417 /* Assemble a single instruction storing it into a frag. */
1424 /* The had better be something to assemble. */
1427 /* If we are within a procedure definition, make sure we've
1428 defined a label for the procedure; handle case where the
1429 label was defined after the .PROC directive.
1431 Note there's not need to diddle with the segment or fragment
1432 for the label symbol in this case. We have already switched
1433 into the new $CODE$ subspace at this point. */
1434 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1436 label_symbol_struct
*label_symbol
= pa_get_label ();
1440 if (label_symbol
->lss_label
)
1442 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1443 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1446 /* Also handle allocation of a fixup to hold the unwind
1447 information when the label appears after the proc/procend. */
1448 if (within_entry_exit
)
1450 char *where
= frag_more (0);
1452 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1453 NULL
, (offsetT
) 0, NULL
,
1454 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1455 (int *)&last_call_info
->ci_unwind
.descriptor
);
1460 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1463 as_bad (_("Missing function name for .PROC"));
1466 /* Assemble the instruction. Results are saved into "the_insn". */
1469 /* Get somewhere to put the assembled instrution. */
1472 /* Output the opcode. */
1473 md_number_to_chars (to
, the_insn
.opcode
, 4);
1475 /* If necessary output more stuff. */
1476 if (the_insn
.reloc
!= R_HPPA_NONE
)
1477 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1478 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1479 the_insn
.reloc
, the_insn
.field_selector
,
1480 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1483 if (debug_type
== DEBUG_DWARF2
)
1487 /* First update the notion of the current source line. */
1488 dwarf2_where (&debug_line
);
1490 /* We want the offset of the start of this instruction within the
1491 the current frag. */
1492 addr
= frag_now
->fr_address
+ frag_now_fix () - 4;
1494 /* And record the information. */
1495 dwarf2_gen_line_info (addr
, &debug_line
);
1500 /* Do the real work for assembling a single instruction. Store results
1501 into the global "the_insn" variable. */
1507 char *error_message
= "";
1508 char *s
, c
, *argstart
, *name
, *save_s
;
1512 int cmpltr
, nullif
, flag
, cond
, num
;
1513 unsigned long opcode
;
1514 struct pa_opcode
*insn
;
1517 /* We must have a valid space and subspace. */
1518 pa_check_current_space_and_subspace ();
1521 /* Convert everything up to the first whitespace character into lower
1523 for (s
= str
; *s
!= ' ' && *s
!= '\t' && *s
!= '\n' && *s
!= '\0'; s
++)
1527 /* Skip to something interesting. */
1528 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1547 as_fatal (_("Unknown opcode: `%s'"), str
);
1552 /* Look up the opcode in the has table. */
1553 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1555 as_bad ("Unknown opcode: `%s'", str
);
1564 /* Mark the location where arguments for the instruction start, then
1565 start processing them. */
1569 /* Do some initialization. */
1570 opcode
= insn
->match
;
1571 strict
= (insn
->flags
& FLAG_STRICT
);
1572 memset (&the_insn
, 0, sizeof (the_insn
));
1574 the_insn
.reloc
= R_HPPA_NONE
;
1576 /* If this instruction is specific to a particular architecture,
1577 then set a new architecture. */
1578 /* But do not automatically promote to pa2.0. The automatic promotion
1579 crud is for compatability with HP's old assemblers only. */
1581 && bfd_get_mach (stdoutput
) < insn
->arch
)
1583 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1584 as_warn (_("could not update architecture and machine"));
1586 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1592 /* Build the opcode, checking as we go to make
1593 sure that the operands match. */
1594 for (args
= insn
->args
;; ++args
)
1596 /* Absorb white space in instruction. */
1597 while (*s
== ' ' || *s
== '\t')
1603 /* End of arguments. */
1619 /* These must match exactly. */
1628 /* Handle a 5 bit register or control register field at 10. */
1631 /* This should be more strict. Small steps. */
1632 if (strict
&& *s
!= '%')
1634 num
= pa_parse_number (&s
, 0);
1635 CHECK_FIELD (num
, 31, 0, 0);
1636 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1638 /* Handle %sar or %cr11. No bits get set, we just verify that it
1641 /* Skip whitespace before register. */
1642 while (*s
== ' ' || *s
== '\t')
1645 if (!strncasecmp(s
, "%sar", 4))
1650 else if (!strncasecmp(s
, "%cr11", 5))
1657 /* Handle a 5 bit register field at 15. */
1659 /* This should be more strict. Small steps. */
1660 if (strict
&& *s
!= '%')
1662 num
= pa_parse_number (&s
, 0);
1663 CHECK_FIELD (num
, 31, 0, 0);
1664 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1666 /* Handle a 5 bit register field at 31. */
1668 /* This should be more strict. Small steps. */
1669 if (strict
&& *s
!= '%')
1671 num
= pa_parse_number (&s
, 0);
1672 CHECK_FIELD (num
, 31, 0, 0);
1673 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1675 /* Handle a 5 bit register field at 10 and 15. */
1677 /* This should be more strict. Small steps. */
1678 if (strict
&& *s
!= '%')
1680 num
= pa_parse_number (&s
, 0);
1681 CHECK_FIELD (num
, 31, 0, 0);
1682 opcode
|= num
<< 16;
1683 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1685 /* Handle a 5 bit field length at 31. */
1687 num
= pa_get_absolute_expression (&the_insn
, &s
);
1688 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1691 CHECK_FIELD (num
, 32, 1, 0);
1692 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1694 /* Handle a 5 bit immediate at 15. */
1696 num
= pa_get_absolute_expression (&the_insn
, &s
);
1697 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1700 /* When in strict mode, we want to just reject this
1701 match instead of giving an out of range error. */
1702 CHECK_FIELD (num
, 15, -16, strict
);
1703 num
= low_sign_unext (num
, 5);
1704 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1706 /* Handle a 5 bit immediate at 31. */
1708 num
= pa_get_absolute_expression (&the_insn
, &s
);
1709 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1712 /* When in strict mode, we want to just reject this
1713 match instead of giving an out of range error. */
1714 CHECK_FIELD (num
, 15, -16, strict
)
1715 num
= low_sign_unext (num
, 5);
1716 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1718 /* Handle an unsigned 5 bit immediate at 31. */
1720 num
= pa_get_absolute_expression (&the_insn
, &s
);
1721 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1724 CHECK_FIELD (num
, 31, 0, 0);
1725 INSERT_FIELD_AND_CONTINUE (opcode
, num
, strict
);
1727 /* Handle an unsigned 5 bit immediate at 15. */
1729 num
= pa_get_absolute_expression (&the_insn
, &s
);
1730 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1733 CHECK_FIELD (num
, 31, 0, strict
);
1734 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1736 /* Handle an unsigned 10 bit immediate at 15. */
1738 num
= pa_get_absolute_expression (&the_insn
, &s
);
1739 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1742 CHECK_FIELD (num
, 1023, 0, strict
);
1743 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1745 /* Handle a 2 bit space identifier at 17. */
1747 /* This should be more strict. Small steps. */
1748 if (strict
&& *s
!= '%')
1750 num
= pa_parse_number (&s
, 0);
1751 CHECK_FIELD (num
, 3, 0, 1);
1752 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1754 /* Handle a 3 bit space identifier at 18. */
1756 /* This should be more strict. Small steps. */
1757 if (strict
&& *s
!= '%')
1759 num
= pa_parse_number (&s
, 0);
1760 CHECK_FIELD (num
, 7, 0, 1);
1761 opcode
= re_assemble_3 (opcode
, num
);
1764 /* Handle all completers. */
1769 /* Handle a completer for an indexing load or store. */
1775 while (*s
== ',' && i
< 2)
1778 if (strncasecmp (s
, "sm", 2) == 0)
1785 else if (strncasecmp (s
, "m", 1) == 0)
1787 else if ((strncasecmp (s
, "s ", 2) == 0)
1788 || (strncasecmp (s
, "s,", 2) == 0))
1790 /* When in strict mode this is a match failure. */
1797 as_bad (_("Invalid Indexed Load Completer."));
1802 as_bad (_("Invalid Indexed Load Completer Syntax."));
1804 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1807 /* Handle a short load/store completer. */
1819 if (strncasecmp (s
, "ma", 2) == 0)
1825 else if (strncasecmp (s
, "mb", 2) == 0)
1832 /* When in strict mode, pass through for cache op. */
1833 if (!found
&& strict
)
1838 as_bad (_("Invalid Short Load/Store Completer."));
1842 /* If we did not get a ma/mb completer, then we do not
1843 consider this a positive match for 'ce'. */
1844 else if (*args
== 'e')
1847 /* 'J', 'm' and 'q' are the same, except for where they
1848 encode the before/after field. */
1852 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1854 else if (*args
== 'q')
1857 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1859 else if (*args
== 'J')
1861 /* M bit is explicit in the major opcode. */
1862 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1864 else if (*args
== 'e')
1866 /* Gross! Hide these values in the immediate field
1867 of the instruction, then pull them out later. */
1874 /* Handle a stbys completer. */
1880 while (*s
== ',' && i
< 2)
1883 if (strncasecmp (s
, "m", 1) == 0)
1885 else if ((strncasecmp (s
, "b ", 2) == 0)
1886 || (strncasecmp (s
, "b,", 2) == 0))
1888 else if (strncasecmp (s
, "e", 1) == 0)
1890 /* When in strict mode this is a match failure. */
1897 as_bad (_("Invalid Store Bytes Short Completer"));
1902 as_bad (_("Invalid Store Bytes Short Completer"));
1904 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1907 /* Handle load cache hint completer. */
1910 if (!strncmp(s
, ",sl", 3))
1915 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1917 /* Handle store cache hint completer. */
1920 if (!strncmp(s
, ",sl", 3))
1925 else if (!strncmp(s
, ",bc", 3))
1930 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1932 /* Handle load and clear cache hint completer. */
1935 if (!strncmp(s
, ",co", 3))
1940 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1942 /* Handle load ordering completer. */
1944 if (strncmp(s
, ",o", 2) != 0)
1949 /* Handle a branch gate completer. */
1951 if (strncasecmp (s
, ",gate", 5) != 0)
1956 /* Handle a branch link and push completer. */
1958 if (strncasecmp (s
, ",l,push", 7) != 0)
1963 /* Handle a branch link completer. */
1965 if (strncasecmp (s
, ",l", 2) != 0)
1970 /* Handle a branch pop completer. */
1972 if (strncasecmp (s
, ",pop", 4) != 0)
1977 /* Handle a local processor completer. */
1979 if (strncasecmp (s
, ",l", 2) != 0)
1984 /* Handle a PROBE read/write completer. */
1987 if (!strncasecmp (s
, ",w", 2))
1992 else if (!strncasecmp (s
, ",r", 2))
1998 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2000 /* Handle MFCTL wide completer. */
2002 if (strncasecmp (s
, ",w", 2) != 0)
2007 /* Handle an RFI restore completer. */
2010 if (!strncasecmp (s
, ",r", 2))
2016 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2018 /* Handle a system control completer. */
2020 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2028 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2030 /* Handle intermediate/final completer for DCOR. */
2033 if (!strncasecmp (s
, ",i", 2))
2039 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2041 /* Handle zero/sign extension completer. */
2044 if (!strncasecmp (s
, ",z", 2))
2050 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2052 /* Handle add completer. */
2055 if (!strncasecmp (s
, ",l", 2))
2060 else if (!strncasecmp (s
, ",tsv", 4))
2066 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2068 /* Handle 64 bit carry for ADD. */
2071 if (!strncasecmp (s
, ",dc,tsv", 7) ||
2072 !strncasecmp (s
, ",tsv,dc", 7))
2077 else if (!strncasecmp (s
, ",dc", 3))
2085 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2087 /* Handle 32 bit carry for ADD. */
2090 if (!strncasecmp (s
, ",c,tsv", 6) ||
2091 !strncasecmp (s
, ",tsv,c", 6))
2096 else if (!strncasecmp (s
, ",c", 2))
2104 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2106 /* Handle trap on signed overflow. */
2109 if (!strncasecmp (s
, ",tsv", 4))
2115 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2117 /* Handle trap on condition and overflow. */
2120 if (!strncasecmp (s
, ",tc,tsv", 7) ||
2121 !strncasecmp (s
, ",tsv,tc", 7))
2126 else if (!strncasecmp (s
, ",tc", 3))
2134 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2136 /* Handle 64 bit borrow for SUB. */
2139 if (!strncasecmp (s
, ",db,tsv", 7) ||
2140 !strncasecmp (s
, ",tsv,db", 7))
2145 else if (!strncasecmp (s
, ",db", 3))
2153 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2155 /* Handle 32 bit borrow for SUB. */
2158 if (!strncasecmp (s
, ",b,tsv", 6) ||
2159 !strncasecmp (s
, ",tsv,b", 6))
2164 else if (!strncasecmp (s
, ",b", 2))
2172 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2174 /* Handle trap condition completer for UADDCM. */
2177 if (!strncasecmp (s
, ",tc", 3))
2183 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2185 /* Handle signed/unsigned at 21. */
2189 if (strncasecmp (s
, ",s", 2) == 0)
2194 else if (strncasecmp (s
, ",u", 2) == 0)
2200 INSERT_FIELD_AND_CONTINUE (opcode
, sign
, 10);
2203 /* Handle left/right combination at 17:18. */
2213 as_bad(_("Invalid left/right combination completer"));
2216 INSERT_FIELD_AND_CONTINUE (opcode
, lr
, 13);
2219 as_bad(_("Invalid left/right combination completer"));
2222 /* Handle saturation at 24:25. */
2226 if (strncasecmp (s
, ",ss", 3) == 0)
2231 else if (strncasecmp (s
, ",us", 3) == 0)
2237 INSERT_FIELD_AND_CONTINUE (opcode
, sat
, 6);
2240 /* Handle permutation completer. */
2268 as_bad(_("Invalid permutation completer"));
2270 opcode
|= perm
<< permloc
[i
];
2275 as_bad(_("Invalid permutation completer"));
2283 /* Handle all conditions. */
2289 /* Handle FP compare conditions. */
2291 cond
= pa_parse_fp_cmp_cond (&s
);
2292 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2294 /* Handle an add condition. */
2303 /* 64 bit conditions. */
2316 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2320 if (strcmp (name
, "=") == 0)
2322 else if (strcmp (name
, "<") == 0)
2324 else if (strcmp (name
, "<=") == 0)
2326 else if (strcasecmp (name
, "nuv") == 0)
2328 else if (strcasecmp (name
, "znv") == 0)
2330 else if (strcasecmp (name
, "sv") == 0)
2332 else if (strcasecmp (name
, "od") == 0)
2334 else if (strcasecmp (name
, "tr") == 0)
2339 else if (strcmp (name
, "<>") == 0)
2344 else if (strcmp (name
, ">=") == 0)
2349 else if (strcmp (name
, ">") == 0)
2354 else if (strcasecmp (name
, "uv") == 0)
2359 else if (strcasecmp (name
, "vnz") == 0)
2364 else if (strcasecmp (name
, "nsv") == 0)
2369 else if (strcasecmp (name
, "ev") == 0)
2374 /* ",*" is a valid condition. */
2375 else if (*args
== 'a')
2376 as_bad (_("Invalid Add Condition: %s"), name
);
2379 opcode
|= cmpltr
<< 13;
2380 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2382 /* Handle non-negated add and branch condition. */
2384 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2387 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2390 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2392 /* Handle 64 bit wide-mode add and branch condition. */
2394 cmpltr
= pa_parse_addb_64_cmpltr (&s
);
2397 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2402 /* Negated condition requires an opcode change. */
2403 opcode
|= (cmpltr
& 8) << 24;
2405 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2407 /* Handle a negated or non-negated add and branch
2411 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2415 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
2418 as_bad (_("Invalid Compare/Subtract Condition"));
2423 /* Negated condition requires an opcode change. */
2427 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2429 /* Handle branch on bit conditions. */
2447 if (strncmp (s
, "<", 1) == 0)
2452 else if (strncmp (s
, ">=", 2) == 0)
2458 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2460 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2462 /* Handle a compare/subtract condition. */
2471 /* 64 bit conditions. */
2484 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2488 if (strcmp (name
, "=") == 0)
2490 else if (strcmp (name
, "<") == 0)
2492 else if (strcmp (name
, "<=") == 0)
2494 else if (strcasecmp (name
, "<<") == 0)
2496 else if (strcasecmp (name
, "<<=") == 0)
2498 else if (strcasecmp (name
, "sv") == 0)
2500 else if (strcasecmp (name
, "od") == 0)
2502 else if (strcasecmp (name
, "tr") == 0)
2507 else if (strcmp (name
, "<>") == 0)
2512 else if (strcmp (name
, ">=") == 0)
2517 else if (strcmp (name
, ">") == 0)
2522 else if (strcasecmp (name
, ">>=") == 0)
2527 else if (strcasecmp (name
, ">>") == 0)
2532 else if (strcasecmp (name
, "nsv") == 0)
2537 else if (strcasecmp (name
, "ev") == 0)
2542 /* ",*" is a valid condition. */
2543 else if (*args
!= 'S')
2544 as_bad (_("Invalid Compare/Subtract Condition: %s"),
2548 opcode
|= cmpltr
<< 13;
2549 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2551 /* Handle a non-negated compare condition. */
2553 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2556 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
2559 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2561 /* Handle a 32 bit compare and branch condition. */
2564 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2568 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
2571 as_bad (_("Invalid Compare and Branch Condition."));
2576 /* Negated condition requires an opcode change. */
2581 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2583 /* Handle a 64 bit compare and branch condition. */
2585 cmpltr
= pa_parse_cmpb_64_cmpltr (&s
);
2588 /* Negated condition requires an opcode change. */
2589 opcode
|= (cmpltr
& 8) << 26;
2592 /* Not a 64 bit cond. Give 32 bit a chance. */
2595 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2597 /* Handle a 64 bit cmpib condition. */
2599 cmpltr
= pa_parse_cmpib_64_cmpltr (&s
);
2601 /* Not a 64 bit cond. Give 32 bit a chance. */
2604 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2606 /* Handle a logical instruction condition. */
2615 /* 64 bit conditions. */
2628 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2634 if (strcmp (name
, "=") == 0)
2636 else if (strcmp (name
, "<") == 0)
2638 else if (strcmp (name
, "<=") == 0)
2640 else if (strcasecmp (name
, "od") == 0)
2642 else if (strcasecmp (name
, "tr") == 0)
2647 else if (strcmp (name
, "<>") == 0)
2652 else if (strcmp (name
, ">=") == 0)
2657 else if (strcmp (name
, ">") == 0)
2662 else if (strcasecmp (name
, "ev") == 0)
2667 /* ",*" is a valid condition. */
2668 else if (*args
!= 'L')
2669 as_bad (_("Invalid Logical Instruction Condition."));
2672 opcode
|= cmpltr
<< 13;
2673 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2675 /* Handle a shift/extract/deposit condition. */
2684 /* 64 bit conditions. */
2697 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2701 if (strcmp (name
, "=") == 0)
2703 else if (strcmp (name
, "<") == 0)
2705 else if (strcasecmp (name
, "od") == 0)
2707 else if (strcasecmp (name
, "tr") == 0)
2709 else if (strcmp (name
, "<>") == 0)
2711 else if (strcmp (name
, ">=") == 0)
2713 else if (strcasecmp (name
, "ev") == 0)
2715 /* Handle movb,n. Put things back the way they were.
2716 This includes moving s back to where it started. */
2717 else if (strcasecmp (name
, "n") == 0 && *args
== 'y')
2723 /* ",*" is a valid condition. */
2724 else if (*args
!= 'X')
2725 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2728 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2730 /* Handle a unit instruction condition. */
2739 /* 64 bit conditions. */
2750 if (strncasecmp (s
, "sbz", 3) == 0)
2755 else if (strncasecmp (s
, "shz", 3) == 0)
2760 else if (strncasecmp (s
, "sdc", 3) == 0)
2765 else if (strncasecmp (s
, "sbc", 3) == 0)
2770 else if (strncasecmp (s
, "shc", 3) == 0)
2775 else if (strncasecmp (s
, "tr", 2) == 0)
2781 else if (strncasecmp (s
, "nbz", 3) == 0)
2787 else if (strncasecmp (s
, "nhz", 3) == 0)
2793 else if (strncasecmp (s
, "ndc", 3) == 0)
2799 else if (strncasecmp (s
, "nbc", 3) == 0)
2805 else if (strncasecmp (s
, "nhc", 3) == 0)
2811 else if (strncasecmp (s
, "swz", 3) == 0)
2817 else if (strncasecmp (s
, "swc", 3) == 0)
2823 else if (strncasecmp (s
, "nwz", 3) == 0)
2829 else if (strncasecmp (s
, "nwc", 3) == 0)
2835 /* ",*" is a valid condition. */
2836 else if (*args
!= 'U')
2837 as_bad (_("Invalid Unit Instruction Condition."));
2839 opcode
|= cmpltr
<< 13;
2840 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2848 /* Handle a nullification completer for branch instructions. */
2850 nullif
= pa_parse_nullif (&s
);
2851 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2853 /* Handle a nullification completer for copr and spop insns. */
2855 nullif
= pa_parse_nullif (&s
);
2856 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2858 /* Handle ,%r2 completer for new syntax branches. */
2860 if (*s
== ',' && strncasecmp (s
+ 1, "%r2", 3) == 0)
2862 else if (*s
== ',' && strncasecmp (s
+ 1, "%rp", 3) == 0)
2868 /* Handle 3 bit entry into the fp compare array. Valid values
2869 are 0..6 inclusive. */
2873 if (the_insn
.exp
.X_op
== O_constant
)
2875 num
= evaluate_absolute (&the_insn
);
2876 CHECK_FIELD (num
, 6, 0, 0);
2878 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2883 /* Handle 3 bit entry into the fp compare array. Valid values
2884 are 0..6 inclusive. */
2887 if (the_insn
.exp
.X_op
== O_constant
)
2890 num
= evaluate_absolute (&the_insn
);
2891 CHECK_FIELD (num
, 6, 0, 0);
2892 num
= (num
+ 1) ^ 1;
2893 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2898 /* Handle graphics test completers for ftest */
2901 num
= pa_parse_ftest_gfx_completer (&s
);
2902 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2905 /* Handle a 11 bit immediate at 31. */
2907 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2910 if (the_insn
.exp
.X_op
== O_constant
)
2912 num
= evaluate_absolute (&the_insn
);
2913 CHECK_FIELD (num
, 1023, -1024, 0);
2914 num
= low_sign_unext (num
, 11);
2915 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2919 if (is_DP_relative (the_insn
.exp
))
2920 the_insn
.reloc
= R_HPPA_GOTOFF
;
2921 else if (is_PC_relative (the_insn
.exp
))
2922 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2924 the_insn
.reloc
= R_HPPA
;
2925 the_insn
.format
= 11;
2929 /* Handle a 14 bit immediate at 31. */
2931 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2934 if (the_insn
.exp
.X_op
== O_constant
)
2938 /* XXX the completer stored away tibits of information
2939 for us to extract. We need a cleaner way to do this.
2940 Now that we have lots of letters again, it would be
2941 good to rethink this. */
2942 m
= (opcode
& (1 << 8)) != 0;
2943 a
= (opcode
& (1 << 9)) != 0;
2944 opcode
&= ~ (3 << 8);
2945 num
= evaluate_absolute (&the_insn
);
2946 if ((a
== 1 && num
>= 0) || (a
== 0 && num
< 0))
2948 CHECK_FIELD (num
, 8191, -8192, 0);
2949 num
= low_sign_unext (num
, 14);
2950 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2957 /* Handle a 14 bit immediate at 31. */
2959 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2962 if (the_insn
.exp
.X_op
== O_constant
)
2966 /* XXX the completer stored away tibits of information
2967 for us to extract. We need a cleaner way to do this.
2968 Now that we have lots of letters again, it would be
2969 good to rethink this. */
2970 m
= (opcode
& (1 << 8)) != 0;
2971 a
= (opcode
& (1 << 9)) != 0;
2972 opcode
&= ~ (3 << 8);
2973 num
= evaluate_absolute (&the_insn
);
2974 if ((a
== 1 && num
< 0) || (a
== 0 && num
> 0))
2978 CHECK_FIELD (num
, 8191, -8192, 0);
2983 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
2990 /* Handle 14 bit immediated, shifted left three times. */
2992 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2995 if (the_insn
.exp
.X_op
== O_constant
)
2997 num
= evaluate_absolute (&the_insn
);
3000 CHECK_FIELD (num
, 8191, -8192, 0);
3005 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 4);
3009 if (is_DP_relative (the_insn
.exp
))
3010 the_insn
.reloc
= R_HPPA_GOTOFF
;
3011 else if (is_PC_relative (the_insn
.exp
))
3012 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3014 the_insn
.reloc
= R_HPPA
;
3015 the_insn
.format
= 14;
3020 /* Handle 14 bit immediate, shifted left twice. */
3022 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3025 if (the_insn
.exp
.X_op
== O_constant
)
3027 num
= evaluate_absolute (&the_insn
);
3030 CHECK_FIELD (num
, 8191, -8192, 0);
3035 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3039 if (is_DP_relative (the_insn
.exp
))
3040 the_insn
.reloc
= R_HPPA_GOTOFF
;
3041 else if (is_PC_relative (the_insn
.exp
))
3042 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3044 the_insn
.reloc
= R_HPPA
;
3045 the_insn
.format
= 14;
3049 /* Handle a 14 bit immediate at 31. */
3051 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3054 if (the_insn
.exp
.X_op
== O_constant
)
3056 num
= evaluate_absolute (&the_insn
);
3057 CHECK_FIELD (num
, 8191, -8192, 0);
3058 num
= low_sign_unext (num
, 14);
3059 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3063 if (is_DP_relative (the_insn
.exp
))
3064 the_insn
.reloc
= R_HPPA_GOTOFF
;
3065 else if (is_PC_relative (the_insn
.exp
))
3066 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3068 the_insn
.reloc
= R_HPPA
;
3069 the_insn
.format
= 14;
3073 /* Handle a 21 bit immediate at 31. */
3075 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3078 if (the_insn
.exp
.X_op
== O_constant
)
3080 num
= evaluate_absolute (&the_insn
);
3081 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
3082 opcode
= re_assemble_21 (opcode
, num
);
3087 if (is_DP_relative (the_insn
.exp
))
3088 the_insn
.reloc
= R_HPPA_GOTOFF
;
3089 else if (is_PC_relative (the_insn
.exp
))
3090 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3092 the_insn
.reloc
= R_HPPA
;
3093 the_insn
.format
= 21;
3097 /* Handle a 16 bit immediate at 31 (PA 2.0 wide mode only). */
3099 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3102 if (the_insn
.exp
.X_op
== O_constant
)
3104 num
= evaluate_absolute (&the_insn
);
3105 CHECK_FIELD (num
, 32767, -32768, 0);
3106 opcode
= re_assemble_16 (opcode
, num
, 1);
3111 /* ??? Is this valid for wide mode? */
3112 if (is_DP_relative (the_insn
.exp
))
3113 the_insn
.reloc
= R_HPPA_GOTOFF
;
3114 else if (is_PC_relative (the_insn
.exp
))
3115 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3117 the_insn
.reloc
= R_HPPA
;
3118 the_insn
.format
= 14;
3122 /* Handle a word-aligned 16-bit imm. at 31 (PA2.0 wide). */
3124 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3127 if (the_insn
.exp
.X_op
== O_constant
)
3129 num
= evaluate_absolute (&the_insn
);
3130 CHECK_FIELD (num
, 32767, -32768, 0);
3131 CHECK_ALIGN (num
, 4, 0);
3132 opcode
= re_assemble_16 (opcode
, num
, 1);
3137 /* ??? Is this valid for wide mode? */
3138 if (is_DP_relative (the_insn
.exp
))
3139 the_insn
.reloc
= R_HPPA_GOTOFF
;
3140 else if (is_PC_relative (the_insn
.exp
))
3141 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3143 the_insn
.reloc
= R_HPPA
;
3144 the_insn
.format
= 14;
3148 /* Handle a dword-aligned 16-bit imm. at 31 (PA2.0 wide). */
3150 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3153 if (the_insn
.exp
.X_op
== O_constant
)
3155 num
= evaluate_absolute (&the_insn
);
3156 CHECK_FIELD (num
, 32767, -32768, 0);
3157 CHECK_ALIGN (num
, 8, 0);
3158 opcode
= re_assemble_16 (opcode
, num
, 1);
3163 /* ??? Is this valid for wide mode? */
3164 if (is_DP_relative (the_insn
.exp
))
3165 the_insn
.reloc
= R_HPPA_GOTOFF
;
3166 else if (is_PC_relative (the_insn
.exp
))
3167 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3169 the_insn
.reloc
= R_HPPA
;
3170 the_insn
.format
= 14;
3174 /* Handle a 12 bit branch displacement. */
3176 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3180 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
3182 num
= evaluate_absolute (&the_insn
);
3185 as_bad (_("Branch to unaligned address"));
3188 CHECK_FIELD (num
, 8199, -8184, 0);
3190 opcode
= re_assemble_12 (opcode
, (num
- 8) >> 2);
3195 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3196 the_insn
.format
= 12;
3197 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3198 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3203 /* Handle a 17 bit branch displacement. */
3205 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3209 if (!the_insn
.exp
.X_add_symbol
3210 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3213 num
= evaluate_absolute (&the_insn
);
3216 as_bad (_("Branch to unaligned address"));
3219 CHECK_FIELD (num
, 262143, -262144, 0);
3221 if (the_insn
.exp
.X_add_symbol
)
3224 opcode
= re_assemble_17 (opcode
, num
>> 2);
3229 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3230 the_insn
.format
= 17;
3231 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3232 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3236 /* Handle a 22 bit branch displacement. */
3238 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3242 if (!the_insn
.exp
.X_add_symbol
3243 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3246 num
= evaluate_absolute (&the_insn
);
3249 as_bad (_("Branch to unaligned address"));
3252 CHECK_FIELD (num
, 8388607, -8388608, 0);
3254 if (the_insn
.exp
.X_add_symbol
)
3257 opcode
= re_assemble_22 (opcode
, num
>> 2);
3261 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3262 the_insn
.format
= 22;
3263 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3264 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3268 /* Handle an absolute 17 bit branch target. */
3270 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3274 if (!the_insn
.exp
.X_add_symbol
3275 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3278 num
= evaluate_absolute (&the_insn
);
3281 as_bad (_("Branch to unaligned address"));
3284 CHECK_FIELD (num
, 262143, -262144, 0);
3286 if (the_insn
.exp
.X_add_symbol
)
3289 opcode
= re_assemble_17 (opcode
, num
>> 2);
3294 the_insn
.reloc
= R_HPPA_ABS_CALL
;
3295 the_insn
.format
= 17;
3296 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3297 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3301 /* Handle '%r1' implicit operand of addil instruction. */
3303 if (*s
== ',' && *(s
+ 1) == '%' && *(s
+ 3) == '1'
3304 && (*(s
+ 2) == 'r' || *(s
+ 2) == 'R'))
3312 /* Handle '%sr0,%r31' implicit operand of be,l instruction. */
3314 if (strncasecmp (s
, "%sr0,%r31", 9) != 0)
3319 /* Handle immediate value of 0 for ordered load/store instructions. */
3326 /* Handle a 2 bit shift count at 25. */
3328 num
= pa_get_absolute_expression (&the_insn
, &s
);
3329 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3332 CHECK_FIELD (num
, 3, 1, strict
);
3333 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3335 /* Handle a 4 bit shift count at 25. */
3337 num
= pa_get_absolute_expression (&the_insn
, &s
);
3338 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3341 CHECK_FIELD (num
, 15, 0, strict
);
3342 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3344 /* Handle a 5 bit shift count at 26. */
3346 num
= pa_get_absolute_expression (&the_insn
, &s
);
3347 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3350 CHECK_FIELD (num
, 31, 0, strict
);
3351 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
3353 /* Handle a 6 bit shift count at 20,22:26. */
3355 num
= pa_get_absolute_expression (&the_insn
, &s
);
3356 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3359 CHECK_FIELD (num
, 63, 0, strict
);
3361 opcode
|= (num
& 0x20) << 6;
3362 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3364 /* Handle a 6 bit field length at 23,27:31. */
3367 num
= pa_get_absolute_expression (&the_insn
, &s
);
3368 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3371 CHECK_FIELD (num
, 64, 1, strict
);
3373 opcode
|= (num
& 0x20) << 3;
3374 num
= 31 - (num
& 0x1f);
3375 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3377 /* Handle a 6 bit field length at 19,27:31. */
3379 num
= pa_get_absolute_expression (&the_insn
, &s
);
3380 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3383 CHECK_FIELD (num
, 64, 1, strict
);
3385 opcode
|= (num
& 0x20) << 7;
3386 num
= 31 - (num
& 0x1f);
3387 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3389 /* Handle a 5 bit bit position at 26. */
3391 num
= pa_get_absolute_expression (&the_insn
, &s
);
3392 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3395 CHECK_FIELD (num
, 31, 0, strict
);
3396 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
3398 /* Handle a 6 bit bit position at 20,22:26. */
3400 num
= pa_get_absolute_expression (&the_insn
, &s
);
3401 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3404 CHECK_FIELD (num
, 63, 0, strict
);
3405 opcode
|= (num
& 0x20) << 6;
3406 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3408 /* Handle a 5 bit immediate at 10 with 'd' as the complement
3409 of the high bit of the immediate. */
3411 num
= pa_get_absolute_expression (&the_insn
, &s
);
3412 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3415 CHECK_FIELD (num
, 63, 0, strict
);
3419 opcode
|= (1 << 13);
3420 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 21);
3422 /* Handle a 5 bit immediate at 10. */
3424 num
= pa_get_absolute_expression (&the_insn
, &s
);
3425 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3427 if (the_insn
.exp
.X_op
!= O_constant
)
3430 CHECK_FIELD (num
, 31, 0, strict
);
3431 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3433 /* Handle a 9 bit immediate at 28. */
3435 num
= pa_get_absolute_expression (&the_insn
, &s
);
3436 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3439 CHECK_FIELD (num
, 511, 1, strict
);
3440 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3442 /* Handle a 13 bit immediate at 18. */
3444 num
= pa_get_absolute_expression (&the_insn
, &s
);
3445 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3448 CHECK_FIELD (num
, 8191, 0, strict
);
3449 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
3451 /* Handle a 26 bit immediate at 31. */
3453 num
= pa_get_absolute_expression (&the_insn
, &s
);
3454 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3457 CHECK_FIELD (num
, 671108864, 0, strict
);
3458 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3460 /* Handle a 3 bit SFU identifier at 25. */
3463 as_bad (_("Invalid SFU identifier"));
3464 num
= pa_get_absolute_expression (&the_insn
, &s
);
3465 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3468 CHECK_FIELD (num
, 7, 0, strict
);
3469 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3471 /* Handle a 20 bit SOP field for spop0. */
3473 num
= pa_get_absolute_expression (&the_insn
, &s
);
3474 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3477 CHECK_FIELD (num
, 1048575, 0, strict
);
3478 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
3479 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3481 /* Handle a 15bit SOP field for spop1. */
3483 num
= pa_get_absolute_expression (&the_insn
, &s
);
3484 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3487 CHECK_FIELD (num
, 32767, 0, strict
);
3488 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
3490 /* Handle a 10bit SOP field for spop3. */
3492 num
= pa_get_absolute_expression (&the_insn
, &s
);
3493 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3496 CHECK_FIELD (num
, 1023, 0, strict
);
3497 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
3498 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3500 /* Handle a 15 bit SOP field for spop2. */
3502 num
= pa_get_absolute_expression (&the_insn
, &s
);
3503 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3506 CHECK_FIELD (num
, 32767, 0, strict
);
3507 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
3508 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3510 /* Handle a 3-bit co-processor ID field. */
3513 as_bad (_("Invalid COPR identifier"));
3514 num
= pa_get_absolute_expression (&the_insn
, &s
);
3515 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3518 CHECK_FIELD (num
, 7, 0, strict
);
3519 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3521 /* Handle a 22bit SOP field for copr. */
3523 num
= pa_get_absolute_expression (&the_insn
, &s
);
3524 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3527 CHECK_FIELD (num
, 4194303, 0, strict
);
3528 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
3529 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3531 /* Handle a source FP operand format completer. */
3533 if (*s
== ',' && *(s
+1) == 't')
3540 flag
= pa_parse_fp_cnv_format (&s
);
3541 the_insn
.fpof1
= flag
;
3542 if (flag
== W
|| flag
== UW
)
3544 if (flag
== DW
|| flag
== UDW
)
3546 if (flag
== QW
|| flag
== UQW
)
3548 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3550 /* Handle a destination FP operand format completer. */
3552 /* pa_parse_format needs the ',' prefix. */
3554 flag
= pa_parse_fp_cnv_format (&s
);
3555 the_insn
.fpof2
= flag
;
3556 if (flag
== W
|| flag
== UW
)
3558 if (flag
== DW
|| flag
== UDW
)
3560 if (flag
== QW
|| flag
== UQW
)
3562 opcode
|= flag
<< 13;
3563 if (the_insn
.fpof1
== SGL
3564 || the_insn
.fpof1
== DBL
3565 || the_insn
.fpof1
== QUAD
)
3567 if (the_insn
.fpof2
== SGL
3568 || the_insn
.fpof2
== DBL
3569 || the_insn
.fpof2
== QUAD
)
3571 else if (the_insn
.fpof2
== W
3572 || the_insn
.fpof2
== DW
3573 || the_insn
.fpof2
== QW
)
3575 else if (the_insn
.fpof2
== UW
3576 || the_insn
.fpof2
== UDW
3577 || the_insn
.fpof2
== UQW
)
3582 else if (the_insn
.fpof1
== W
3583 || the_insn
.fpof1
== DW
3584 || the_insn
.fpof1
== QW
)
3586 if (the_insn
.fpof2
== SGL
3587 || the_insn
.fpof2
== DBL
3588 || the_insn
.fpof2
== QUAD
)
3593 else if (the_insn
.fpof1
== UW
3594 || the_insn
.fpof1
== UDW
3595 || the_insn
.fpof1
== UQW
)
3597 if (the_insn
.fpof2
== SGL
3598 || the_insn
.fpof2
== DBL
3599 || the_insn
.fpof2
== QUAD
)
3604 flag
|= the_insn
.trunc
;
3605 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 15);
3607 /* Handle a source FP operand format completer. */
3609 flag
= pa_parse_fp_format (&s
);
3610 the_insn
.fpof1
= flag
;
3611 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3613 /* Handle a destination FP operand format completer. */
3615 /* pa_parse_format needs the ',' prefix. */
3617 flag
= pa_parse_fp_format (&s
);
3618 the_insn
.fpof2
= flag
;
3619 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
3621 /* Handle a source FP operand format completer at 20. */
3623 flag
= pa_parse_fp_format (&s
);
3624 the_insn
.fpof1
= flag
;
3625 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3627 /* Handle a floating point operand format at 26.
3628 Only allows single and double precision. */
3630 flag
= pa_parse_fp_format (&s
);
3636 the_insn
.fpof1
= flag
;
3642 as_bad (_("Invalid Floating Point Operand Format."));
3646 /* Handle all floating point registers. */
3650 /* Float target register. */
3652 /* This should be more strict. Small steps. */
3653 if (strict
&& *s
!= '%')
3655 num
= pa_parse_number (&s
, 0);
3656 CHECK_FIELD (num
, 31, 0, 0);
3657 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3659 /* Float target register with L/R selection. */
3662 struct pa_11_fp_reg_struct result
;
3664 /* This should be more strict. Small steps. */
3665 if (strict
&& *s
!= '%')
3667 pa_parse_number (&s
, &result
);
3668 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3669 opcode
|= result
.number_part
;
3671 /* 0x30 opcodes are FP arithmetic operation opcodes
3672 and need to be turned into 0x38 opcodes. This
3673 is not necessary for loads/stores. */
3674 if (need_pa11_opcode (&the_insn
, &result
)
3675 && ((opcode
& 0xfc000000) == 0x30000000))
3678 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
3681 /* Float operand 1. */
3684 struct pa_11_fp_reg_struct result
;
3686 /* This should be more strict. Small steps. */
3687 if (strict
&& *s
!= '%')
3689 pa_parse_number (&s
, &result
);
3690 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3691 opcode
|= result
.number_part
<< 21;
3692 if (need_pa11_opcode (&the_insn
, &result
))
3694 opcode
|= (result
.l_r_select
& 1) << 7;
3700 /* Float operand 1 with L/R selection. */
3704 struct pa_11_fp_reg_struct result
;
3706 /* This should be more strict. Small steps. */
3707 if (strict
&& *s
!= '%')
3709 pa_parse_number (&s
, &result
);
3710 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3711 opcode
|= result
.number_part
<< 21;
3712 opcode
|= (result
.l_r_select
& 1) << 7;
3716 /* Float operand 2. */
3719 struct pa_11_fp_reg_struct result
;
3721 /* This should be more strict. Small steps. */
3722 if (strict
&& *s
!= '%')
3724 pa_parse_number (&s
, &result
);
3725 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3726 opcode
|= (result
.number_part
& 0x1f) << 16;
3727 if (need_pa11_opcode (&the_insn
, &result
))
3729 opcode
|= (result
.l_r_select
& 1) << 12;
3735 /* Float operand 2 with L/R selection. */
3738 struct pa_11_fp_reg_struct result
;
3740 /* This should be more strict. Small steps. */
3741 if (strict
&& *s
!= '%')
3743 pa_parse_number (&s
, &result
);
3744 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3745 opcode
|= (result
.number_part
& 0x1f) << 16;
3746 opcode
|= (result
.l_r_select
& 1) << 12;
3750 /* Float operand 3 for fmpyfadd, fmpynfadd. */
3753 struct pa_11_fp_reg_struct result
;
3755 /* This should be more strict. Small steps. */
3756 if (strict
&& *s
!= '%')
3758 pa_parse_number (&s
, &result
);
3759 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3760 opcode
|= (result
.number_part
& 0x1c) << 11;
3761 opcode
|= (result
.number_part
& 0x3) << 9;
3762 opcode
|= (result
.l_r_select
& 1) << 8;
3766 /* Float mult operand 1 for fmpyadd, fmpysub */
3769 struct pa_11_fp_reg_struct result
;
3771 /* This should be more strict. Small steps. */
3772 if (strict
&& *s
!= '%')
3774 pa_parse_number (&s
, &result
);
3775 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3776 if (the_insn
.fpof1
== SGL
)
3778 if (result
.number_part
< 16)
3780 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3784 result
.number_part
&= 0xF;
3785 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3787 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
3790 /* Float mult operand 2 for fmpyadd, fmpysub */
3793 struct pa_11_fp_reg_struct result
;
3795 /* This should be more strict. Small steps. */
3796 if (strict
&& *s
!= '%')
3798 pa_parse_number (&s
, &result
);
3799 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3800 if (the_insn
.fpof1
== SGL
)
3802 if (result
.number_part
< 16)
3804 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3807 result
.number_part
&= 0xF;
3808 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3810 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
3813 /* Float mult target for fmpyadd, fmpysub */
3816 struct pa_11_fp_reg_struct result
;
3818 /* This should be more strict. Small steps. */
3819 if (strict
&& *s
!= '%')
3821 pa_parse_number (&s
, &result
);
3822 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3823 if (the_insn
.fpof1
== SGL
)
3825 if (result
.number_part
< 16)
3827 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3830 result
.number_part
&= 0xF;
3831 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3833 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
3836 /* Float add operand 1 for fmpyadd, fmpysub */
3839 struct pa_11_fp_reg_struct result
;
3841 /* This should be more strict. Small steps. */
3842 if (strict
&& *s
!= '%')
3844 pa_parse_number (&s
, &result
);
3845 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3846 if (the_insn
.fpof1
== SGL
)
3848 if (result
.number_part
< 16)
3850 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3853 result
.number_part
&= 0xF;
3854 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3856 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
3859 /* Float add target for fmpyadd, fmpysub */
3862 struct pa_11_fp_reg_struct result
;
3864 /* This should be more strict. Small steps. */
3865 if (strict
&& *s
!= '%')
3867 pa_parse_number (&s
, &result
);
3868 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3869 if (the_insn
.fpof1
== SGL
)
3871 if (result
.number_part
< 16)
3873 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3876 result
.number_part
&= 0xF;
3877 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3879 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
3882 /* Handle L/R register halves like 'x'. */
3886 struct pa_11_fp_reg_struct result
;
3888 if (strict
&& *s
!= '%')
3890 pa_parse_number (&s
, &result
);
3891 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3892 opcode
|= (result
.number_part
& 0x1f) << 16;
3893 if (need_pa11_opcode (&the_insn
, &result
))
3895 opcode
|= (result
.l_r_select
& 1) << 1;
3900 /* Float target register (PA 2.0 wide). */
3902 /* This should be more strict. Small steps. */
3903 if (strict
&& *s
!= '%')
3905 num
= pa_parse_number (&s
, 0);
3906 CHECK_FIELD (num
, 31, 0, 0);
3907 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
3921 /* Check if the args matched. */
3924 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
3925 && !strcmp (insn
->name
, insn
[1].name
))
3933 as_bad (_("Invalid operands %s"), error_message
);
3940 the_insn
.opcode
= opcode
;
3943 /* Turn a string in input_line_pointer into a floating point constant of type
3944 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
3945 emitted is stored in *sizeP . An error message or NULL is returned. */
3947 #define MAX_LITTLENUMS 6
3950 md_atof (type
, litP
, sizeP
)
3956 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
3957 LITTLENUM_TYPE
*wordP
;
3989 return _("Bad call to MD_ATOF()");
3991 t
= atof_ieee (input_line_pointer
, type
, words
);
3993 input_line_pointer
= t
;
3994 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
3995 for (wordP
= words
; prec
--;)
3997 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
3998 litP
+= sizeof (LITTLENUM_TYPE
);
4003 /* Write out big-endian. */
4006 md_number_to_chars (buf
, val
, n
)
4011 number_to_chars_bigendian (buf
, val
, n
);
4014 /* Translate internal representation of relocation info to BFD target
4018 tc_gen_reloc (section
, fixp
)
4023 struct hppa_fix_struct
*hppa_fixp
;
4024 bfd_reloc_code_real_type code
;
4025 static arelent
*no_relocs
= NULL
;
4027 bfd_reloc_code_real_type
**codes
;
4031 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
4032 if (fixp
->fx_addsy
== 0)
4034 assert (hppa_fixp
!= 0);
4035 assert (section
!= 0);
4037 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
4039 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4040 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4041 codes
= (bfd_reloc_code_real_type
**) hppa_gen_reloc_type (stdoutput
,
4043 hppa_fixp
->fx_r_format
,
4044 hppa_fixp
->fx_r_field
,
4045 fixp
->fx_subsy
!= NULL
,
4046 symbol_get_bfdsym (fixp
->fx_addsy
));
4051 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
4054 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
4055 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
4056 for (i
= 0; i
< n_relocs
; i
++)
4057 relocs
[i
] = &reloc
[i
];
4059 relocs
[n_relocs
] = NULL
;
4062 switch (fixp
->fx_r_type
)
4065 assert (n_relocs
== 1);
4069 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4070 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4071 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
4072 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4073 reloc
->addend
= 0; /* default */
4075 assert (reloc
->howto
&& code
== reloc
->howto
->type
);
4077 /* Now, do any processing that is dependent on the relocation type. */
4080 case R_PARISC_DLTREL21L
:
4081 case R_PARISC_DLTREL14R
:
4082 case R_PARISC_DLTREL14F
:
4083 case R_PARISC_PLABEL32
:
4084 case R_PARISC_PLABEL21L
:
4085 case R_PARISC_PLABEL14R
:
4086 /* For plabel relocations, the addend of the
4087 relocation should be either 0 (no static link) or 2
4088 (static link required).
4090 FIXME: We always assume no static link!
4092 We also slam a zero addend into the DLT relative relocs;
4093 it doesn't make a lot of sense to use any addend since
4094 it gets you a different (eg unknown) DLT entry. */
4098 case R_PARISC_PCREL21L
:
4099 case R_PARISC_PCREL17R
:
4100 case R_PARISC_PCREL17F
:
4101 case R_PARISC_PCREL17C
:
4102 case R_PARISC_PCREL14R
:
4103 case R_PARISC_PCREL14F
:
4104 /* The constant is stored in the instruction. */
4105 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
4108 reloc
->addend
= fixp
->fx_offset
;
4115 /* Walk over reach relocation returned by the BFD backend. */
4116 for (i
= 0; i
< n_relocs
; i
++)
4120 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4121 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4122 relocs
[i
]->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
4123 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4128 /* The only time we ever use a R_COMP2 fixup is for the difference
4129 of two symbols. With that in mind we fill in all four
4130 relocs now and break out of the loop. */
4132 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4133 relocs
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[0]);
4134 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4135 relocs
[0]->addend
= 0;
4136 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4137 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4138 relocs
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[1]);
4139 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4140 relocs
[1]->addend
= 0;
4141 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4142 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
4143 relocs
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[2]);
4144 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4145 relocs
[2]->addend
= 0;
4146 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4147 relocs
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[3]);
4148 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4149 relocs
[3]->addend
= 0;
4150 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4151 relocs
[4]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[4]);
4152 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4153 relocs
[4]->addend
= 0;
4157 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
4163 /* For plabel relocations, the addend of the
4164 relocation should be either 0 (no static link) or 2
4165 (static link required).
4167 FIXME: We always assume no static link!
4169 We also slam a zero addend into the DLT relative relocs;
4170 it doesn't make a lot of sense to use any addend since
4171 it gets you a different (eg unknown) DLT entry. */
4172 relocs
[i
]->addend
= 0;
4187 /* There is no symbol or addend associated with these fixups. */
4188 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4189 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4190 relocs
[i
]->addend
= 0;
4196 /* There is no symbol associated with these fixups. */
4197 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4198 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4199 relocs
[i
]->addend
= fixp
->fx_offset
;
4203 relocs
[i
]->addend
= fixp
->fx_offset
;
4213 /* Process any machine dependent frag types. */
4216 md_convert_frag (abfd
, sec
, fragP
)
4217 register bfd
*abfd ATTRIBUTE_UNUSED
;
4218 register asection
*sec ATTRIBUTE_UNUSED
;
4219 register fragS
*fragP
;
4221 unsigned int address
;
4223 if (fragP
->fr_type
== rs_machine_dependent
)
4225 switch ((int) fragP
->fr_subtype
)
4228 fragP
->fr_type
= rs_fill
;
4229 know (fragP
->fr_var
== 1);
4230 know (fragP
->fr_next
);
4231 address
= fragP
->fr_address
+ fragP
->fr_fix
;
4232 if (address
% fragP
->fr_offset
)
4235 fragP
->fr_next
->fr_address
4240 fragP
->fr_offset
= 0;
4246 /* Round up a section size to the appropriate boundary. */
4249 md_section_align (segment
, size
)
4253 int align
= bfd_get_section_alignment (stdoutput
, segment
);
4254 int align2
= (1 << align
) - 1;
4256 return (size
+ align2
) & ~align2
;
4259 /* Return the approximate size of a frag before relaxation has occurred. */
4261 md_estimate_size_before_relax (fragP
, segment
)
4262 register fragS
*fragP
;
4263 asection
*segment ATTRIBUTE_UNUSED
;
4269 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
4275 CONST
char *md_shortopts
= "";
4276 struct option md_longopts
[] = {
4277 {NULL
, no_argument
, NULL
, 0}
4279 size_t md_longopts_size
= sizeof(md_longopts
);
4282 md_parse_option (c
, arg
)
4283 int c ATTRIBUTE_UNUSED
;
4284 char *arg ATTRIBUTE_UNUSED
;
4290 md_show_usage (stream
)
4291 FILE *stream ATTRIBUTE_UNUSED
;
4295 /* We have no need to default values of symbols. */
4298 md_undefined_symbol (name
)
4299 char *name ATTRIBUTE_UNUSED
;
4304 /* Apply a fixup to an instruction. */
4307 md_apply_fix (fixP
, valp
)
4311 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
4312 struct hppa_fix_struct
*hppa_fixP
;
4314 unsigned int insn
, val
;
4316 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
4317 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
4318 never be "applied" (they are just markers). Likewise for
4319 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
4321 if (fixP
->fx_r_type
== R_HPPA_ENTRY
4322 || fixP
->fx_r_type
== R_HPPA_EXIT
4323 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
4324 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
4325 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
4328 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
4329 fixups are considered not adjustable, which in turn causes
4330 adjust_reloc_syms to not set fx_offset. Ugh. */
4331 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
4333 fixP
->fx_offset
= *valp
;
4338 /* There should have been an HPPA specific fixup associated
4339 with the GAS fixup. */
4342 unsigned long buf_wd
= bfd_get_32 (stdoutput
, buf
);
4343 int fmt
= bfd_hppa_insn2fmt (buf_wd
);
4345 /* If there is a symbol associated with this fixup, then it's something
4346 which will need a SOM relocation (except for some PC-relative relocs).
4347 In such cases we should treat the "val" or "addend" as zero since it
4348 will be added in as needed from fx_offset in tc_gen_reloc. */
4349 if ((fixP
->fx_addsy
!= NULL
4350 || fixP
->fx_r_type
== R_HPPA_NONE
)
4355 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4357 /* These field selectors imply that we do not want an addend. */
4358 else if (hppa_fixP
->fx_r_field
== e_psel
4359 || hppa_fixP
->fx_r_field
== e_rpsel
4360 || hppa_fixP
->fx_r_field
== e_lpsel
4361 || hppa_fixP
->fx_r_field
== e_tsel
4362 || hppa_fixP
->fx_r_field
== e_rtsel
4363 || hppa_fixP
->fx_r_field
== e_ltsel
)
4364 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4365 /* This is truely disgusting. The machine independent code blindly
4366 adds in the value of the symbol being relocated against. Damn! */
4368 && fixP
->fx_addsy
!= NULL
4369 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
4370 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
4371 0, hppa_fixP
->fx_r_field
);
4374 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4376 /* Handle pc-relative exceptions from above. */
4377 #define arg_reloc_stub_needed(CALLER, CALLEE) \
4378 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
4379 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
4383 && !arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
4384 symbol_get_bfdsym (fixP
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
4385 hppa_fixP
->fx_arg_reloc
)
4387 && (((int)(*valp
) > -262144 && (int)(*valp
) < 262143) && fmt
!= 22)
4388 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
4390 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
4392 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4393 #undef arg_reloc_stub_needed
4395 insn
= bfd_get_32 (stdoutput
, buf
);
4399 CHECK_FIELD (new_val
, 8191, -8192, 0);
4402 insn
= (insn
& ~ 0x3ff1) | (((val
& 0x1ff8) << 1)
4403 | ((val
& 0x2000) >> 13));
4406 CHECK_FIELD (new_val
, 8191, -8192, 0);
4409 insn
= (insn
& ~ 0x3ff9) | (((val
& 0x1ffc) << 1)
4410 | ((val
& 0x2000) >> 13));
4412 /* Handle all opcodes with the 'j' operand type. */
4414 CHECK_FIELD (new_val
, 8191, -8192, 0);
4417 insn
= ((insn
& ~ 0x3fff) | low_sign_unext (val
, 14));
4420 /* Handle all opcodes with the 'k' operand type. */
4422 CHECK_FIELD (new_val
, 1048576, -1048576, 0);
4425 insn
= re_assemble_21 (insn
& ~ 0x1fffff, val
);
4428 /* Handle all the opcodes with the 'i' operand type. */
4430 CHECK_FIELD (new_val
, 1023, -1023, 0);
4433 insn
= (insn
& ~ 0x7ff) | low_sign_unext (val
, 11);
4436 /* Handle all the opcodes with the 'w' operand type. */
4438 CHECK_FIELD (new_val
, 8199, -8184, 0);
4441 insn
= re_assemble_12 (insn
& ~ 0x1ffd, (val
- 8) >> 2);
4444 /* Handle some of the opcodes with the 'W' operand type. */
4447 offsetT distance
= *valp
;
4449 /* If this is an absolute branch (ie no link) with an out of
4450 range target, then we want to complain. */
4451 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
4452 && (insn
& 0xffe00000) == 0xe8000000)
4453 CHECK_FIELD (distance
, 262143, -262144, 0);
4455 CHECK_FIELD (new_val
, 262143, -262144, 0);
4458 insn
= re_assemble_17 (insn
& ~ 0x1f1ffd, (val
- 8) >> 2);
4464 offsetT distance
= *valp
;
4466 /* If this is an absolute branch (ie no link) with an out of
4467 range target, then we want to complain. */
4468 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
4469 && (insn
& 0xffe00000) == 0xe8000000)
4470 CHECK_FIELD (distance
, 8388607, -8388608, 0);
4472 CHECK_FIELD (new_val
, 8388607, -8388608, 0);
4475 insn
= re_assemble_22 (insn
& ~ 0x3ff1ffd, (val
- 8) >> 2);
4484 as_bad (_("Unknown relocation encountered in md_apply_fix."));
4488 /* Insert the relocation. */
4489 bfd_put_32 (stdoutput
, insn
, buf
);
4494 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
4495 (unsigned int) fixP
, fixP
->fx_r_type
);
4500 /* Exactly what point is a PC-relative offset relative TO?
4501 On the PA, they're relative to the address of the offset. */
4504 md_pcrel_from (fixP
)
4507 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
4510 /* Return nonzero if the input line pointer is at the end of
4514 is_end_of_statement ()
4516 return ((*input_line_pointer
== '\n')
4517 || (*input_line_pointer
== ';')
4518 || (*input_line_pointer
== '!'));
4521 /* Read a number from S. The number might come in one of many forms,
4522 the most common will be a hex or decimal constant, but it could be
4523 a pre-defined register (Yuk!), or an absolute symbol.
4525 Return a number or -1 for failure.
4527 When parsing PA-89 FP register numbers RESULT will be
4528 the address of a structure to return information about
4529 L/R half of FP registers, store results there as appropriate.
4531 pa_parse_number can not handle negative constants and will fail
4532 horribly if it is passed such a constant. */
4535 pa_parse_number (s
, result
)
4537 struct pa_11_fp_reg_struct
*result
;
4546 /* Skip whitespace before the number. */
4547 while (*p
== ' ' || *p
== '\t')
4550 /* Store info in RESULT if requested by caller. */
4553 result
->number_part
= -1;
4554 result
->l_r_select
= -1;
4560 /* Looks like a number. */
4563 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
4565 /* The number is specified in hex. */
4567 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
4568 || ((*p
>= 'A') && (*p
<= 'F')))
4571 num
= num
* 16 + *p
- '0';
4572 else if (*p
>= 'a' && *p
<= 'f')
4573 num
= num
* 16 + *p
- 'a' + 10;
4575 num
= num
* 16 + *p
- 'A' + 10;
4581 /* The number is specified in decimal. */
4582 while (isdigit (*p
))
4584 num
= num
* 10 + *p
- '0';
4589 /* Store info in RESULT if requested by the caller. */
4592 result
->number_part
= num
;
4594 if (IS_R_SELECT (p
))
4596 result
->l_r_select
= 1;
4599 else if (IS_L_SELECT (p
))
4601 result
->l_r_select
= 0;
4605 result
->l_r_select
= 0;
4610 /* The number might be a predefined register. */
4615 /* Tege hack: Special case for general registers as the general
4616 code makes a binary search with case translation, and is VERY
4621 if (*p
== 'e' && *(p
+ 1) == 't'
4622 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
4625 num
= *p
- '0' + 28;
4633 else if (!isdigit (*p
))
4636 as_bad (_("Undefined register: '%s'."), name
);
4642 num
= num
* 10 + *p
++ - '0';
4643 while (isdigit (*p
));
4648 /* Do a normal register search. */
4649 while (is_part_of_name (c
))
4655 status
= reg_name_search (name
);
4661 as_bad (_("Undefined register: '%s'."), name
);
4667 /* Store info in RESULT if requested by caller. */
4670 result
->number_part
= num
;
4671 if (IS_R_SELECT (p
- 1))
4672 result
->l_r_select
= 1;
4673 else if (IS_L_SELECT (p
- 1))
4674 result
->l_r_select
= 0;
4676 result
->l_r_select
= 0;
4681 /* And finally, it could be a symbol in the absolute section which
4682 is effectively a constant. */
4686 while (is_part_of_name (c
))
4692 if ((sym
= symbol_find (name
)) != NULL
)
4694 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
4695 num
= S_GET_VALUE (sym
);
4699 as_bad (_("Non-absolute symbol: '%s'."), name
);
4705 /* There is where we'd come for an undefined symbol
4706 or for an empty string. For an empty string we
4707 will return zero. That's a concession made for
4708 compatability with the braindamaged HP assemblers. */
4714 as_bad (_("Undefined absolute constant: '%s'."), name
);
4720 /* Store info in RESULT if requested by caller. */
4723 result
->number_part
= num
;
4724 if (IS_R_SELECT (p
- 1))
4725 result
->l_r_select
= 1;
4726 else if (IS_L_SELECT (p
- 1))
4727 result
->l_r_select
= 0;
4729 result
->l_r_select
= 0;
4737 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
4739 /* Given NAME, find the register number associated with that name, return
4740 the integer value associated with the given name or -1 on failure. */
4743 reg_name_search (name
)
4746 int middle
, low
, high
;
4750 high
= REG_NAME_CNT
- 1;
4754 middle
= (low
+ high
) / 2;
4755 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
4761 return pre_defined_registers
[middle
].value
;
4763 while (low
<= high
);
4769 /* Return nonzero if the given INSN and L/R information will require
4770 a new PA-1.1 opcode. */
4773 need_pa11_opcode (insn
, result
)
4775 struct pa_11_fp_reg_struct
*result
;
4777 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
4779 /* If this instruction is specific to a particular architecture,
4780 then set a new architecture. */
4781 if (bfd_get_mach (stdoutput
) < pa11
)
4783 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
4784 as_warn (_("could not update architecture and machine"));
4792 /* Parse a condition for a fcmp instruction. Return the numerical
4793 code associated with the condition. */
4796 pa_parse_fp_cmp_cond (s
)
4803 for (i
= 0; i
< 32; i
++)
4805 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
4806 strlen (fp_cond_map
[i
].string
)) == 0)
4808 cond
= fp_cond_map
[i
].cond
;
4809 *s
+= strlen (fp_cond_map
[i
].string
);
4810 /* If not a complete match, back up the input string and
4812 if (**s
!= ' ' && **s
!= '\t')
4814 *s
-= strlen (fp_cond_map
[i
].string
);
4817 while (**s
== ' ' || **s
== '\t')
4823 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
4825 /* Advance over the bogus completer. */
4826 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4832 /* Parse a graphics test complete for ftest. */
4835 pa_parse_ftest_gfx_completer (s
)
4841 if (strncasecmp (*s
, "acc8", 4) == 0)
4846 else if (strncasecmp (*s
, "acc6", 4) == 0)
4851 else if (strncasecmp (*s
, "acc4", 4) == 0)
4856 else if (strncasecmp (*s
, "acc2", 4) == 0)
4861 else if (strncasecmp (*s
, "acc", 3) == 0)
4866 else if (strncasecmp (*s
, "rej8", 4) == 0)
4871 else if (strncasecmp (*s
, "rej", 3) == 0)
4879 as_bad (_("Invalid FTEST completer: %s"), *s
);
4885 /* Parse an FP operand format completer returning the completer
4888 static fp_operand_format
4889 pa_parse_fp_cnv_format (s
)
4898 if (strncasecmp (*s
, "sgl", 3) == 0)
4903 else if (strncasecmp (*s
, "dbl", 3) == 0)
4908 else if (strncasecmp (*s
, "quad", 4) == 0)
4913 else if (strncasecmp (*s
, "w", 1) == 0)
4918 else if (strncasecmp (*s
, "uw", 2) == 0)
4923 else if (strncasecmp (*s
, "dw", 2) == 0)
4928 else if (strncasecmp (*s
, "udw", 3) == 0)
4933 else if (strncasecmp (*s
, "qw", 2) == 0)
4938 else if (strncasecmp (*s
, "uqw", 3) == 0)
4945 format
= ILLEGAL_FMT
;
4946 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
4953 /* Parse an FP operand format completer returning the completer
4956 static fp_operand_format
4957 pa_parse_fp_format (s
)
4966 if (strncasecmp (*s
, "sgl", 3) == 0)
4971 else if (strncasecmp (*s
, "dbl", 3) == 0)
4976 else if (strncasecmp (*s
, "quad", 4) == 0)
4983 format
= ILLEGAL_FMT
;
4984 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
4991 /* Convert from a selector string into a selector type. */
4994 pa_chk_field_selector (str
)
4997 int middle
, low
, high
;
5001 /* Read past any whitespace. */
5002 /* FIXME: should we read past newlines and formfeeds??? */
5003 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
5006 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
5007 name
[0] = tolower ((*str
)[0]),
5009 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
5010 name
[0] = tolower ((*str
)[0]),
5011 name
[1] = tolower ((*str
)[1]),
5013 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
5014 name
[0] = tolower ((*str
)[0]),
5015 name
[1] = tolower ((*str
)[1]),
5016 name
[2] = tolower ((*str
)[2]),
5022 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
5026 middle
= (low
+ high
) / 2;
5027 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
5034 *str
+= strlen (name
) + 1;
5036 if (selector_table
[middle
].field_selector
== e_nsel
)
5039 return selector_table
[middle
].field_selector
;
5042 while (low
<= high
);
5047 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
5050 get_expression (str
)
5056 save_in
= input_line_pointer
;
5057 input_line_pointer
= str
;
5058 seg
= expression (&the_insn
.exp
);
5059 if (!(seg
== absolute_section
5060 || seg
== undefined_section
5061 || SEG_NORMAL (seg
)))
5063 as_warn (_("Bad segment in expression."));
5064 expr_end
= input_line_pointer
;
5065 input_line_pointer
= save_in
;
5068 expr_end
= input_line_pointer
;
5069 input_line_pointer
= save_in
;
5073 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
5075 pa_get_absolute_expression (insn
, strp
)
5081 insn
->field_selector
= pa_chk_field_selector (strp
);
5082 save_in
= input_line_pointer
;
5083 input_line_pointer
= *strp
;
5084 expression (&insn
->exp
);
5085 /* This is not perfect, but is a huge improvement over doing nothing.
5087 The PA assembly syntax is ambigious in a variety of ways. Consider
5088 this string "4 %r5" Is that the number 4 followed by the register
5089 r5, or is that 4 MOD 5?
5091 If we get a modulo expresion When looking for an absolute, we try
5092 again cutting off the input string at the first whitespace character. */
5093 if (insn
->exp
.X_op
== O_modulus
)
5098 input_line_pointer
= *strp
;
5100 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
5106 retval
= pa_get_absolute_expression (insn
, strp
);
5108 input_line_pointer
= save_in
;
5110 return evaluate_absolute (insn
);
5112 /* When in strict mode we have a non-match, fix up the pointers
5113 and return to our caller. */
5114 if (insn
->exp
.X_op
!= O_constant
&& strict
)
5116 expr_end
= input_line_pointer
;
5117 input_line_pointer
= save_in
;
5120 if (insn
->exp
.X_op
!= O_constant
)
5122 as_bad (_("Bad segment (should be absolute)."));
5123 expr_end
= input_line_pointer
;
5124 input_line_pointer
= save_in
;
5127 expr_end
= input_line_pointer
;
5128 input_line_pointer
= save_in
;
5129 return evaluate_absolute (insn
);
5132 /* Evaluate an absolute expression EXP which may be modified by
5133 the selector FIELD_SELECTOR. Return the value of the expression. */
5135 evaluate_absolute (insn
)
5140 int field_selector
= insn
->field_selector
;
5143 value
= exp
.X_add_number
;
5145 return hppa_field_adjust (0, value
, field_selector
);
5148 /* Given an argument location specification return the associated
5149 argument location number. */
5152 pa_build_arg_reloc (type_name
)
5156 if (strncasecmp (type_name
, "no", 2) == 0)
5158 if (strncasecmp (type_name
, "gr", 2) == 0)
5160 else if (strncasecmp (type_name
, "fr", 2) == 0)
5162 else if (strncasecmp (type_name
, "fu", 2) == 0)
5165 as_bad (_("Invalid argument location: %s\n"), type_name
);
5170 /* Encode and return an argument relocation specification for
5171 the given register in the location specified by arg_reloc. */
5174 pa_align_arg_reloc (reg
, arg_reloc
)
5176 unsigned int arg_reloc
;
5178 unsigned int new_reloc
;
5180 new_reloc
= arg_reloc
;
5196 as_bad (_("Invalid argument description: %d"), reg
);
5202 /* Parse a PA nullification completer (,n). Return nonzero if the
5203 completer was found; return zero if no completer was found. */
5215 if (strncasecmp (*s
, "n", 1) == 0)
5219 as_bad (_("Invalid Nullification: (%c)"), **s
);
5228 /* Parse a non-negated compare/subtract completer returning the
5229 number (for encoding in instrutions) of the given completer.
5231 ISBRANCH specifies whether or not this is parsing a condition
5232 completer for a branch (vs a nullification completer for a
5233 computational instruction. */
5236 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
5241 char *name
= *s
+ 1;
5250 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5256 if (strcmp (name
, "=") == 0)
5260 else if (strcmp (name
, "<") == 0)
5264 else if (strcmp (name
, "<=") == 0)
5268 else if (strcmp (name
, "<<") == 0)
5272 else if (strcmp (name
, "<<=") == 0)
5276 else if (strcasecmp (name
, "sv") == 0)
5280 else if (strcasecmp (name
, "od") == 0)
5284 /* If we have something like addb,n then there is no condition
5286 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5298 /* Reset pointers if this was really a ,n for a branch instruction. */
5306 /* Parse a negated compare/subtract completer returning the
5307 number (for encoding in instrutions) of the given completer.
5309 ISBRANCH specifies whether or not this is parsing a condition
5310 completer for a branch (vs a nullification completer for a
5311 computational instruction. */
5314 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
5319 char *name
= *s
+ 1;
5328 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5334 if (strcasecmp (name
, "tr") == 0)
5338 else if (strcmp (name
, "<>") == 0)
5342 else if (strcmp (name
, ">=") == 0)
5346 else if (strcmp (name
, ">") == 0)
5350 else if (strcmp (name
, ">>=") == 0)
5354 else if (strcmp (name
, ">>") == 0)
5358 else if (strcasecmp (name
, "nsv") == 0)
5362 else if (strcasecmp (name
, "ev") == 0)
5366 /* If we have something like addb,n then there is no condition
5368 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5380 /* Reset pointers if this was really a ,n for a branch instruction. */
5389 /* Parse a 64 bit compare and branch completer returning the number (for
5390 encoding in instrutions) of the given completer.
5392 Nonnegated comparisons are returned as 0-7, negated comparisons are
5393 returned as 8-15. */
5396 pa_parse_cmpb_64_cmpltr (s
)
5400 char *name
= *s
+ 1;
5407 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5412 if (strcmp (name
, "*") == 0)
5416 else if (strcmp (name
, "*=") == 0)
5420 else if (strcmp (name
, "*<") == 0)
5424 else if (strcmp (name
, "*<=") == 0)
5428 else if (strcmp (name
, "*<<") == 0)
5432 else if (strcmp (name
, "*<<=") == 0)
5436 else if (strcasecmp (name
, "*sv") == 0)
5440 else if (strcasecmp (name
, "*od") == 0)
5444 else if (strcasecmp (name
, "*tr") == 0)
5448 else if (strcmp (name
, "*<>") == 0)
5452 else if (strcmp (name
, "*>=") == 0)
5456 else if (strcmp (name
, "*>") == 0)
5460 else if (strcmp (name
, "*>>=") == 0)
5464 else if (strcmp (name
, "*>>") == 0)
5468 else if (strcasecmp (name
, "*nsv") == 0)
5472 else if (strcasecmp (name
, "*ev") == 0)
5487 /* Parse a 64 bit compare immediate and branch completer returning the number
5488 (for encoding in instrutions) of the given completer. */
5491 pa_parse_cmpib_64_cmpltr (s
)
5495 char *name
= *s
+ 1;
5502 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5507 if (strcmp (name
, "*<<") == 0)
5511 else if (strcmp (name
, "*=") == 0)
5515 else if (strcmp (name
, "*<") == 0)
5519 else if (strcmp (name
, "*<=") == 0)
5523 else if (strcmp (name
, "*>>=") == 0)
5527 else if (strcmp (name
, "*<>") == 0)
5531 else if (strcasecmp (name
, "*>=") == 0)
5535 else if (strcasecmp (name
, "*>") == 0)
5550 /* Parse a non-negated addition completer returning the number
5551 (for encoding in instrutions) of the given completer.
5553 ISBRANCH specifies whether or not this is parsing a condition
5554 completer for a branch (vs a nullification completer for a
5555 computational instruction. */
5558 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
5563 char *name
= *s
+ 1;
5571 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5575 if (strcmp (name
, "=") == 0)
5579 else if (strcmp (name
, "<") == 0)
5583 else if (strcmp (name
, "<=") == 0)
5587 else if (strcasecmp (name
, "nuv") == 0)
5591 else if (strcasecmp (name
, "znv") == 0)
5595 else if (strcasecmp (name
, "sv") == 0)
5599 else if (strcasecmp (name
, "od") == 0)
5603 /* If we have something like addb,n then there is no condition
5605 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5616 /* Reset pointers if this was really a ,n for a branch instruction. */
5617 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5623 /* Parse a negated addition completer returning the number
5624 (for encoding in instrutions) of the given completer.
5626 ISBRANCH specifies whether or not this is parsing a condition
5627 completer for a branch (vs a nullification completer for a
5628 computational instruction). */
5631 pa_parse_neg_add_cmpltr (s
, isbranch
)
5636 char *name
= *s
+ 1;
5644 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5648 if (strcasecmp (name
, "tr") == 0)
5652 else if (strcmp (name
, "<>") == 0)
5656 else if (strcmp (name
, ">=") == 0)
5660 else if (strcmp (name
, ">") == 0)
5664 else if (strcasecmp (name
, "uv") == 0)
5668 else if (strcasecmp (name
, "vnz") == 0)
5672 else if (strcasecmp (name
, "nsv") == 0)
5676 else if (strcasecmp (name
, "ev") == 0)
5680 /* If we have something like addb,n then there is no condition
5682 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5693 /* Reset pointers if this was really a ,n for a branch instruction. */
5694 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5700 /* Parse a 64 bit wide mode add and branch completer returning the number (for
5701 encoding in instrutions) of the given completer. */
5704 pa_parse_addb_64_cmpltr (s
)
5708 char *name
= *s
+ 1;
5717 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5721 if (strcmp (name
, "=") == 0)
5725 else if (strcmp (name
, "<") == 0)
5729 else if (strcmp (name
, "<=") == 0)
5733 else if (strcasecmp (name
, "nuv") == 0)
5737 else if (strcasecmp (name
, "*=") == 0)
5741 else if (strcasecmp (name
, "*<") == 0)
5745 else if (strcasecmp (name
, "*<=") == 0)
5749 else if (strcmp (name
, "tr") == 0)
5753 else if (strcmp (name
, "<>") == 0)
5757 else if (strcmp (name
, ">=") == 0)
5761 else if (strcmp (name
, ">") == 0)
5765 else if (strcasecmp (name
, "uv") == 0)
5769 else if (strcasecmp (name
, "*<>") == 0)
5773 else if (strcasecmp (name
, "*>=") == 0)
5777 else if (strcasecmp (name
, "*>") == 0)
5781 /* If we have something like addb,n then there is no condition
5783 else if (strcasecmp (name
, "n") == 0)
5795 /* Reset pointers if this was really a ,n for a branch instruction. */
5803 /* Handle an alignment directive. Special so that we can update the
5804 alignment of the subspace if necessary. */
5808 /* We must have a valid space and subspace. */
5809 pa_check_current_space_and_subspace ();
5811 /* Let the generic gas code do most of the work. */
5812 s_align_bytes (bytes
);
5814 /* If bytes is a power of 2, then update the current subspace's
5815 alignment if necessary. */
5816 if (log2 (bytes
) != -1)
5817 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
5821 /* Handle a .BLOCK type pseudo-op. */
5825 int z ATTRIBUTE_UNUSED
;
5829 unsigned int temp_size
;
5833 /* We must have a valid space and subspace. */
5834 pa_check_current_space_and_subspace ();
5837 temp_size
= get_absolute_expression ();
5839 /* Always fill with zeros, that's what the HP assembler does. */
5842 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
5843 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
5844 memset (p
, 0, temp_size
);
5846 /* Convert 2 bytes at a time. */
5848 for (i
= 0; i
< temp_size
; i
+= 2)
5850 md_number_to_chars (p
+ i
,
5852 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
5855 pa_undefine_label ();
5856 demand_empty_rest_of_line ();
5859 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
5863 int begin ATTRIBUTE_UNUSED
;
5867 /* The BRTAB relocations are only availble in SOM (to denote
5868 the beginning and end of branch tables). */
5869 char *where
= frag_more (0);
5871 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5872 NULL
, (offsetT
) 0, NULL
,
5873 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
5874 e_fsel
, 0, 0, NULL
);
5877 demand_empty_rest_of_line ();
5880 /* Handle a .begin_try and .end_try pseudo-op. */
5884 int begin ATTRIBUTE_UNUSED
;
5888 char *where
= frag_more (0);
5893 /* The TRY relocations are only availble in SOM (to denote
5894 the beginning and end of exception handling regions). */
5896 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5897 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
5898 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
5899 e_fsel
, 0, 0, NULL
);
5902 demand_empty_rest_of_line ();
5905 /* Handle a .CALL pseudo-op. This involves storing away information
5906 about where arguments are to be found so the linker can detect
5907 (and correct) argument location mismatches between caller and callee. */
5911 int unused ATTRIBUTE_UNUSED
;
5914 /* We must have a valid space and subspace. */
5915 pa_check_current_space_and_subspace ();
5918 pa_call_args (&last_call_desc
);
5919 demand_empty_rest_of_line ();
5922 /* Do the dirty work of building a call descriptor which describes
5923 where the caller placed arguments to a function call. */
5926 pa_call_args (call_desc
)
5927 struct call_desc
*call_desc
;
5930 unsigned int temp
, arg_reloc
;
5932 while (!is_end_of_statement ())
5934 name
= input_line_pointer
;
5935 c
= get_symbol_end ();
5936 /* Process a source argument. */
5937 if ((strncasecmp (name
, "argw", 4) == 0))
5939 temp
= atoi (name
+ 4);
5940 p
= input_line_pointer
;
5942 input_line_pointer
++;
5943 name
= input_line_pointer
;
5944 c
= get_symbol_end ();
5945 arg_reloc
= pa_build_arg_reloc (name
);
5946 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
5948 /* Process a return value. */
5949 else if ((strncasecmp (name
, "rtnval", 6) == 0))
5951 p
= input_line_pointer
;
5953 input_line_pointer
++;
5954 name
= input_line_pointer
;
5955 c
= get_symbol_end ();
5956 arg_reloc
= pa_build_arg_reloc (name
);
5957 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
5961 as_bad (_("Invalid .CALL argument: %s"), name
);
5963 p
= input_line_pointer
;
5965 if (!is_end_of_statement ())
5966 input_line_pointer
++;
5970 /* Return TRUE if FRAG1 and FRAG2 are the same. */
5973 is_same_frag (frag1
, frag2
)
5980 else if (frag2
== NULL
)
5982 else if (frag1
== frag2
)
5984 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
5985 return (is_same_frag (frag1
, frag2
->fr_next
));
5991 /* Build an entry in the UNWIND subspace from the given function
5992 attributes in CALL_INFO. This is not needed for SOM as using
5993 R_ENTRY and R_EXIT relocations allow the linker to handle building
5994 of the unwind spaces. */
5997 pa_build_unwind_subspace (call_info
)
5998 struct call_info
*call_info
;
6001 asection
*seg
, *save_seg
;
6002 subsegT save_subseg
;
6007 if (now_seg
!= text_section
)
6010 if (bfd_get_arch_info (stdoutput
)->bits_per_address
== 32)
6011 reloc
= R_PARISC_DIR32
;
6013 reloc
= R_PARISC_SEGREL32
;
6016 save_subseg
= now_subseg
;
6017 /* Get into the right seg/subseg. This may involve creating
6018 the seg the first time through. Make sure to have the
6019 old seg/subseg so that we can reset things when we are done. */
6020 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
6021 if (seg
== ASEC_NULL
)
6023 seg
= subseg_new (UNWIND_SECTION_NAME
, 0);
6024 bfd_set_section_flags (stdoutput
, seg
,
6025 SEC_READONLY
| SEC_HAS_CONTENTS
6026 | SEC_LOAD
| SEC_RELOC
| SEC_ALLOC
| SEC_DATA
);
6027 bfd_set_section_alignment (stdoutput
, seg
, 2);
6030 subseg_set (seg
, 0);
6033 /* Get some space to hold relocation information for the unwind
6036 md_number_to_chars (p
, 0, 4);
6038 /* Relocation info. for start offset of the function. */
6039 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6040 call_info
->start_symbol
, (offsetT
) 0,
6041 (expressionS
*) NULL
, 0, reloc
,
6042 e_fsel
, 32, 0, NULL
);
6045 md_number_to_chars (p
, 0, 4);
6047 /* Relocation info. for end offset of the function.
6049 Because we allow reductions of 32bit relocations for ELF, this will be
6050 reduced to section_sym + offset which avoids putting the temporary
6051 symbol into the symbol table. It (should) end up giving the same
6052 value as call_info->start_symbol + function size once the linker is
6053 finished with its work. */
6055 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6056 call_info
->end_symbol
, (offsetT
) 0,
6057 (expressionS
*) NULL
, 0, reloc
,
6058 e_fsel
, 32, 0, NULL
);
6061 unwind
= (char *) &call_info
->ci_unwind
;
6062 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
6066 FRAG_APPEND_1_CHAR (c
);
6070 /* Return back to the original segment/subsegment. */
6071 subseg_set (save_seg
, save_subseg
);
6075 /* Process a .CALLINFO pseudo-op. This information is used later
6076 to build unwind descriptors and maybe one day to support
6077 .ENTER and .LEAVE. */
6080 pa_callinfo (unused
)
6081 int unused ATTRIBUTE_UNUSED
;
6087 /* We must have a valid space and subspace. */
6088 pa_check_current_space_and_subspace ();
6091 /* .CALLINFO must appear within a procedure definition. */
6092 if (!within_procedure
)
6093 as_bad (_(".callinfo is not within a procedure definition"));
6095 /* Mark the fact that we found the .CALLINFO for the
6096 current procedure. */
6097 callinfo_found
= TRUE
;
6099 /* Iterate over the .CALLINFO arguments. */
6100 while (!is_end_of_statement ())
6102 name
= input_line_pointer
;
6103 c
= get_symbol_end ();
6104 /* Frame size specification. */
6105 if ((strncasecmp (name
, "frame", 5) == 0))
6107 p
= input_line_pointer
;
6109 input_line_pointer
++;
6110 temp
= get_absolute_expression ();
6111 if ((temp
& 0x3) != 0)
6113 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
6117 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
6118 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
6121 /* Entry register (GR, GR and SR) specifications. */
6122 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
6124 p
= input_line_pointer
;
6126 input_line_pointer
++;
6127 temp
= get_absolute_expression ();
6128 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
6129 even though %r19 is caller saved. I think this is a bug in
6130 the HP assembler, and we are not going to emulate it. */
6131 if (temp
< 3 || temp
> 18)
6132 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
6133 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
6135 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
6137 p
= input_line_pointer
;
6139 input_line_pointer
++;
6140 temp
= get_absolute_expression ();
6141 /* Similarly the HP assembler takes 31 as the high bound even
6142 though %fr21 is the last callee saved floating point register. */
6143 if (temp
< 12 || temp
> 21)
6144 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
6145 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
6147 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
6149 p
= input_line_pointer
;
6151 input_line_pointer
++;
6152 temp
= get_absolute_expression ();
6154 as_bad (_("Value for ENTRY_SR must be 3\n"));
6156 /* Note whether or not this function performs any calls. */
6157 else if ((strncasecmp (name
, "calls", 5) == 0) ||
6158 (strncasecmp (name
, "caller", 6) == 0))
6160 p
= input_line_pointer
;
6163 else if ((strncasecmp (name
, "no_calls", 8) == 0))
6165 p
= input_line_pointer
;
6168 /* Should RP be saved into the stack. */
6169 else if ((strncasecmp (name
, "save_rp", 7) == 0))
6171 p
= input_line_pointer
;
6173 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
6175 /* Likewise for SP. */
6176 else if ((strncasecmp (name
, "save_sp", 7) == 0))
6178 p
= input_line_pointer
;
6180 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
6182 /* Is this an unwindable procedure. If so mark it so
6183 in the unwind descriptor. */
6184 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
6186 p
= input_line_pointer
;
6188 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
6190 /* Is this an interrupt routine. If so mark it in the
6191 unwind descriptor. */
6192 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
6194 p
= input_line_pointer
;
6196 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
6198 /* Is this a millicode routine. "millicode" isn't in my
6199 assembler manual, but my copy is old. The HP assembler
6200 accepts it, and there's a place in the unwind descriptor
6201 to drop the information, so we'll accept it too. */
6202 else if ((strncasecmp (name
, "millicode", 9) == 0))
6204 p
= input_line_pointer
;
6206 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
6210 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
6211 *input_line_pointer
= c
;
6213 if (!is_end_of_statement ())
6214 input_line_pointer
++;
6217 demand_empty_rest_of_line ();
6220 /* Switch into the code subspace. */
6224 int unused ATTRIBUTE_UNUSED
;
6227 current_space
= is_defined_space ("$TEXT$");
6229 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6232 pa_undefine_label ();
6235 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
6236 the .comm pseudo-op has the following symtax:
6238 <label> .comm <length>
6240 where <label> is optional and is a symbol whose address will be the start of
6241 a block of memory <length> bytes long. <length> must be an absolute
6242 expression. <length> bytes will be allocated in the current space
6245 Also note the label may not even be on the same line as the .comm.
6247 This difference in syntax means the colon function will be called
6248 on the symbol before we arrive in pa_comm. colon will set a number
6249 of attributes of the symbol that need to be fixed here. In particular
6250 the value, section pointer, fragment pointer, flags, etc. What
6253 This also makes error detection all but impossible. */
6257 int unused ATTRIBUTE_UNUSED
;
6261 label_symbol_struct
*label_symbol
= pa_get_label ();
6264 symbol
= label_symbol
->lss_label
;
6269 size
= get_absolute_expression ();
6273 S_SET_VALUE (symbol
, size
);
6274 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6275 S_SET_EXTERNAL (symbol
);
6277 /* colon() has already set the frag to the current location in the
6278 current subspace; we need to reset the fragment to the zero address
6279 fragment. We also need to reset the segment pointer. */
6280 symbol_set_frag (symbol
, &zero_address_frag
);
6282 demand_empty_rest_of_line ();
6285 /* Process a .END pseudo-op. */
6289 int unused ATTRIBUTE_UNUSED
;
6291 demand_empty_rest_of_line ();
6294 /* Process a .ENTER pseudo-op. This is not supported. */
6297 int unused ATTRIBUTE_UNUSED
;
6300 /* We must have a valid space and subspace. */
6301 pa_check_current_space_and_subspace ();
6304 as_bad (_("The .ENTER pseudo-op is not supported"));
6305 demand_empty_rest_of_line ();
6308 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
6312 int unused ATTRIBUTE_UNUSED
;
6315 /* We must have a valid space and subspace. */
6316 pa_check_current_space_and_subspace ();
6319 if (!within_procedure
)
6320 as_bad (_("Misplaced .entry. Ignored."));
6323 if (!callinfo_found
)
6324 as_bad (_("Missing .callinfo."));
6326 demand_empty_rest_of_line ();
6327 within_entry_exit
= TRUE
;
6330 /* SOM defers building of unwind descriptors until the link phase.
6331 The assembler is responsible for creating an R_ENTRY relocation
6332 to mark the beginning of a region and hold the unwind bits, and
6333 for creating an R_EXIT relocation to mark the end of the region.
6335 FIXME. ELF should be using the same conventions! The problem
6336 is an unwind requires too much relocation space. Hmmm. Maybe
6337 if we split the unwind bits up between the relocations which
6338 denote the entry and exit points. */
6339 if (last_call_info
->start_symbol
!= NULL
)
6341 char *where
= frag_more (0);
6343 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6344 NULL
, (offsetT
) 0, NULL
,
6345 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
6346 (int *) &last_call_info
->ci_unwind
.descriptor
);
6351 /* Handle a .EQU pseudo-op. */
6357 label_symbol_struct
*label_symbol
= pa_get_label ();
6362 symbol
= label_symbol
->lss_label
;
6364 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
6366 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
6367 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
6372 as_bad (_(".REG must use a label"));
6374 as_bad (_(".EQU must use a label"));
6377 pa_undefine_label ();
6378 demand_empty_rest_of_line ();
6381 /* Helper function. Does processing for the end of a function. This
6382 usually involves creating some relocations or building special
6383 symbols to mark the end of the function. */
6390 where
= frag_more (0);
6393 /* Mark the end of the function, stuff away the location of the frag
6394 for the end of the function, and finally call pa_build_unwind_subspace
6395 to add an entry in the unwind table. */
6396 hppa_elf_mark_end_of_function ();
6397 pa_build_unwind_subspace (last_call_info
);
6399 /* SOM defers building of unwind descriptors until the link phase.
6400 The assembler is responsible for creating an R_ENTRY relocation
6401 to mark the beginning of a region and hold the unwind bits, and
6402 for creating an R_EXIT relocation to mark the end of the region.
6404 FIXME. ELF should be using the same conventions! The problem
6405 is an unwind requires too much relocation space. Hmmm. Maybe
6406 if we split the unwind bits up between the relocations which
6407 denote the entry and exit points. */
6408 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6410 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
6411 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
6415 /* Process a .EXIT pseudo-op. */
6419 int unused ATTRIBUTE_UNUSED
;
6422 /* We must have a valid space and subspace. */
6423 pa_check_current_space_and_subspace ();
6426 if (!within_procedure
)
6427 as_bad (_(".EXIT must appear within a procedure"));
6430 if (!callinfo_found
)
6431 as_bad (_("Missing .callinfo"));
6434 if (!within_entry_exit
)
6435 as_bad (_("No .ENTRY for this .EXIT"));
6438 within_entry_exit
= FALSE
;
6443 demand_empty_rest_of_line ();
6446 /* Process a .EXPORT directive. This makes functions external
6447 and provides information such as argument relocation entries
6452 int unused ATTRIBUTE_UNUSED
;
6457 name
= input_line_pointer
;
6458 c
= get_symbol_end ();
6459 /* Make sure the given symbol exists. */
6460 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6462 as_bad (_("Cannot define export symbol: %s\n"), name
);
6463 p
= input_line_pointer
;
6465 input_line_pointer
++;
6469 /* OK. Set the external bits and process argument relocations. */
6470 S_SET_EXTERNAL (symbol
);
6471 p
= input_line_pointer
;
6473 if (!is_end_of_statement ())
6475 input_line_pointer
++;
6476 pa_type_args (symbol
, 1);
6480 demand_empty_rest_of_line ();
6483 /* Helper function to process arguments to a .EXPORT pseudo-op. */
6486 pa_type_args (symbolP
, is_export
)
6491 unsigned int temp
, arg_reloc
;
6492 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
6494 obj_symbol_type
*symbol
= (obj_symbol_type
*) symbol_get_bfdsym (symbolP
);
6497 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
6500 input_line_pointer
+= 8;
6501 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6502 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
6503 type
= SYMBOL_TYPE_ABSOLUTE
;
6505 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
6507 input_line_pointer
+= 4;
6508 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
6509 instead one should be IMPORTing/EXPORTing ENTRY types.
6511 Complain if one tries to EXPORT a CODE type since that's never
6512 done. Both GCC and HP C still try to IMPORT CODE types, so
6513 silently fix them to be ENTRY types. */
6514 if (S_IS_FUNCTION (symbolP
))
6517 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
6518 S_GET_NAME (symbolP
));
6520 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6521 type
= SYMBOL_TYPE_ENTRY
;
6525 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6526 type
= SYMBOL_TYPE_CODE
;
6529 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
6531 input_line_pointer
+= 4;
6532 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6533 symbol_get_bfdsym (symbolP
)->flags
|= BSF_OBJECT
;
6534 type
= SYMBOL_TYPE_DATA
;
6536 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
6538 input_line_pointer
+= 5;
6539 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6540 type
= SYMBOL_TYPE_ENTRY
;
6542 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
6544 input_line_pointer
+= 9;
6545 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6546 type
= SYMBOL_TYPE_MILLICODE
;
6548 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
6550 input_line_pointer
+= 6;
6551 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6552 type
= SYMBOL_TYPE_PLABEL
;
6554 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
6556 input_line_pointer
+= 8;
6557 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6558 type
= SYMBOL_TYPE_PRI_PROG
;
6560 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
6562 input_line_pointer
+= 8;
6563 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6564 type
= SYMBOL_TYPE_SEC_PROG
;
6567 /* SOM requires much more information about symbol types
6568 than BFD understands. This is how we get this information
6569 to the SOM BFD backend. */
6570 #ifdef obj_set_symbol_type
6571 obj_set_symbol_type (symbol_get_bfdsym (symbolP
), (int) type
);
6574 /* Now that the type of the exported symbol has been handled,
6575 handle any argument relocation information. */
6576 while (!is_end_of_statement ())
6578 if (*input_line_pointer
== ',')
6579 input_line_pointer
++;
6580 name
= input_line_pointer
;
6581 c
= get_symbol_end ();
6582 /* Argument sources. */
6583 if ((strncasecmp (name
, "argw", 4) == 0))
6585 p
= input_line_pointer
;
6587 input_line_pointer
++;
6588 temp
= atoi (name
+ 4);
6589 name
= input_line_pointer
;
6590 c
= get_symbol_end ();
6591 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
6593 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
6595 *input_line_pointer
= c
;
6597 /* The return value. */
6598 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
6600 p
= input_line_pointer
;
6602 input_line_pointer
++;
6603 name
= input_line_pointer
;
6604 c
= get_symbol_end ();
6605 arg_reloc
= pa_build_arg_reloc (name
);
6607 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
6609 *input_line_pointer
= c
;
6611 /* Privelege level. */
6612 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
6614 p
= input_line_pointer
;
6616 input_line_pointer
++;
6617 temp
= atoi (input_line_pointer
);
6619 symbol
->tc_data
.ap
.hppa_priv_level
= temp
;
6621 c
= get_symbol_end ();
6622 *input_line_pointer
= c
;
6626 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
6627 p
= input_line_pointer
;
6630 if (!is_end_of_statement ())
6631 input_line_pointer
++;
6635 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
6636 assembly file must either be defined in the assembly file, or
6637 explicitly IMPORTED from another. */
6641 int unused ATTRIBUTE_UNUSED
;
6646 name
= input_line_pointer
;
6647 c
= get_symbol_end ();
6649 symbol
= symbol_find (name
);
6650 /* Ugh. We might be importing a symbol defined earlier in the file,
6651 in which case all the code below will really screw things up
6652 (set the wrong segment, symbol flags & type, etc). */
6653 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
6655 symbol
= symbol_find_or_make (name
);
6656 p
= input_line_pointer
;
6659 if (!is_end_of_statement ())
6661 input_line_pointer
++;
6662 pa_type_args (symbol
, 0);
6666 /* Sigh. To be compatable with the HP assembler and to help
6667 poorly written assembly code, we assign a type based on
6668 the the current segment. Note only BSF_FUNCTION really
6669 matters, we do not need to set the full SYMBOL_TYPE_* info. */
6670 if (now_seg
== text_section
)
6671 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
6673 /* If the section is undefined, then the symbol is undefined
6674 Since this is an import, leave the section undefined. */
6675 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6680 /* The symbol was already defined. Just eat everything up to
6681 the end of the current statement. */
6682 while (!is_end_of_statement ())
6683 input_line_pointer
++;
6686 demand_empty_rest_of_line ();
6689 /* Handle a .LABEL pseudo-op. */
6693 int unused ATTRIBUTE_UNUSED
;
6697 name
= input_line_pointer
;
6698 c
= get_symbol_end ();
6700 if (strlen (name
) > 0)
6703 p
= input_line_pointer
;
6708 as_warn (_("Missing label name on .LABEL"));
6711 if (!is_end_of_statement ())
6713 as_warn (_("extra .LABEL arguments ignored."));
6714 ignore_rest_of_line ();
6716 demand_empty_rest_of_line ();
6719 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
6723 int unused ATTRIBUTE_UNUSED
;
6726 /* We must have a valid space and subspace. */
6727 pa_check_current_space_and_subspace ();
6730 as_bad (_("The .LEAVE pseudo-op is not supported"));
6731 demand_empty_rest_of_line ();
6734 /* Handle a .LEVEL pseudo-op. */
6738 int unused ATTRIBUTE_UNUSED
;
6742 level
= input_line_pointer
;
6743 if (strncmp (level
, "1.0", 3) == 0)
6745 input_line_pointer
+= 3;
6746 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
6747 as_warn (_("could not set architecture and machine"));
6749 else if (strncmp (level
, "1.1", 3) == 0)
6751 input_line_pointer
+= 3;
6752 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
6753 as_warn (_("could not set architecture and machine"));
6755 else if (strncmp (level
, "2.0w", 4) == 0)
6757 input_line_pointer
+= 4;
6758 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 25))
6759 as_warn (_("could not set architecture and machine"));
6761 else if (strncmp (level
, "2.0", 3) == 0)
6763 input_line_pointer
+= 3;
6764 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
6765 as_warn (_("could not set architecture and machine"));
6769 as_bad (_("Unrecognized .LEVEL argument\n"));
6770 ignore_rest_of_line ();
6772 demand_empty_rest_of_line ();
6775 /* Handle a .ORIGIN pseudo-op. */
6779 int unused ATTRIBUTE_UNUSED
;
6782 /* We must have a valid space and subspace. */
6783 pa_check_current_space_and_subspace ();
6787 pa_undefine_label ();
6790 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
6791 is for static functions. FIXME. Should share more code with .EXPORT. */
6795 int unused ATTRIBUTE_UNUSED
;
6800 name
= input_line_pointer
;
6801 c
= get_symbol_end ();
6803 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6805 as_bad (_("Cannot define static symbol: %s\n"), name
);
6806 p
= input_line_pointer
;
6808 input_line_pointer
++;
6812 S_CLEAR_EXTERNAL (symbol
);
6813 p
= input_line_pointer
;
6815 if (!is_end_of_statement ())
6817 input_line_pointer
++;
6818 pa_type_args (symbol
, 0);
6822 demand_empty_rest_of_line ();
6825 /* Handle a .PROC pseudo-op. It is used to mark the beginning
6826 of a procedure from a syntatical point of view. */
6830 int unused ATTRIBUTE_UNUSED
;
6832 struct call_info
*call_info
;
6835 /* We must have a valid space and subspace. */
6836 pa_check_current_space_and_subspace ();
6839 if (within_procedure
)
6840 as_fatal (_("Nested procedures"));
6842 /* Reset global variables for new procedure. */
6843 callinfo_found
= FALSE
;
6844 within_procedure
= TRUE
;
6846 /* Create another call_info structure. */
6847 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
6850 as_fatal (_("Cannot allocate unwind descriptor\n"));
6852 memset (call_info
, 0, sizeof (struct call_info
));
6854 call_info
->ci_next
= NULL
;
6856 if (call_info_root
== NULL
)
6858 call_info_root
= call_info
;
6859 last_call_info
= call_info
;
6863 last_call_info
->ci_next
= call_info
;
6864 last_call_info
= call_info
;
6867 /* set up defaults on call_info structure */
6869 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
6870 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
6871 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
6873 /* If we got a .PROC pseudo-op, we know that the function is defined
6874 locally. Make sure it gets into the symbol table. */
6876 label_symbol_struct
*label_symbol
= pa_get_label ();
6880 if (label_symbol
->lss_label
)
6882 last_call_info
->start_symbol
= label_symbol
->lss_label
;
6883 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
6886 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
6889 last_call_info
->start_symbol
= NULL
;
6892 demand_empty_rest_of_line ();
6895 /* Process the syntatical end of a procedure. Make sure all the
6896 appropriate pseudo-ops were found within the procedure. */
6900 int unused ATTRIBUTE_UNUSED
;
6904 /* We must have a valid space and subspace. */
6905 pa_check_current_space_and_subspace ();
6908 /* If we are within a procedure definition, make sure we've
6909 defined a label for the procedure; handle case where the
6910 label was defined after the .PROC directive.
6912 Note there's not need to diddle with the segment or fragment
6913 for the label symbol in this case. We have already switched
6914 into the new $CODE$ subspace at this point. */
6915 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
6917 label_symbol_struct
*label_symbol
= pa_get_label ();
6921 if (label_symbol
->lss_label
)
6923 last_call_info
->start_symbol
= label_symbol
->lss_label
;
6924 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
6927 /* Also handle allocation of a fixup to hold the unwind
6928 information when the label appears after the proc/procend. */
6929 if (within_entry_exit
)
6931 char *where
= frag_more (0);
6933 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6934 NULL
, (offsetT
) 0, NULL
,
6935 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
6936 (int *) &last_call_info
->ci_unwind
.descriptor
);
6941 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
6944 as_bad (_("Missing function name for .PROC"));
6947 if (!within_procedure
)
6948 as_bad (_("misplaced .procend"));
6950 if (!callinfo_found
)
6951 as_bad (_("Missing .callinfo for this procedure"));
6953 if (within_entry_exit
)
6954 as_bad (_("Missing .EXIT for a .ENTRY"));
6957 /* ELF needs to mark the end of each function so that it can compute
6958 the size of the function (apparently its needed in the symbol table). */
6959 hppa_elf_mark_end_of_function ();
6962 within_procedure
= FALSE
;
6963 demand_empty_rest_of_line ();
6964 pa_undefine_label ();
6969 /* If VALUE is an exact power of two between zero and 2^31, then
6970 return log2 (VALUE). Else return -1. */
6978 while ((1 << shift
) != value
&& shift
< 32)
6987 /* Check to make sure we have a valid space and subspace. */
6990 pa_check_current_space_and_subspace ()
6992 if (current_space
== NULL
)
6993 as_fatal (_("Not in a space.\n"));
6995 if (current_subspace
== NULL
)
6996 as_fatal (_("Not in a subspace.\n"));
6999 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
7000 then create a new space entry to hold the information specified
7001 by the parameters to the .SPACE directive. */
7003 static sd_chain_struct
*
7004 pa_parse_space_stmt (space_name
, create_flag
)
7008 char *name
, *ptemp
, c
;
7009 char loadable
, defined
, private, sort
;
7011 asection
*seg
= NULL
;
7012 sd_chain_struct
*space
;
7014 /* load default values */
7020 if (strcmp (space_name
, "$TEXT$") == 0)
7022 seg
= pa_def_spaces
[0].segment
;
7023 defined
= pa_def_spaces
[0].defined
;
7024 private = pa_def_spaces
[0].private;
7025 sort
= pa_def_spaces
[0].sort
;
7026 spnum
= pa_def_spaces
[0].spnum
;
7028 else if (strcmp (space_name
, "$PRIVATE$") == 0)
7030 seg
= pa_def_spaces
[1].segment
;
7031 defined
= pa_def_spaces
[1].defined
;
7032 private = pa_def_spaces
[1].private;
7033 sort
= pa_def_spaces
[1].sort
;
7034 spnum
= pa_def_spaces
[1].spnum
;
7037 if (!is_end_of_statement ())
7039 print_errors
= FALSE
;
7040 ptemp
= input_line_pointer
+ 1;
7041 /* First see if the space was specified as a number rather than
7042 as a name. According to the PA assembly manual the rest of
7043 the line should be ignored. */
7044 temp
= pa_parse_number (&ptemp
, 0);
7048 input_line_pointer
= ptemp
;
7052 while (!is_end_of_statement ())
7054 input_line_pointer
++;
7055 name
= input_line_pointer
;
7056 c
= get_symbol_end ();
7057 if ((strncasecmp (name
, "spnum", 5) == 0))
7059 *input_line_pointer
= c
;
7060 input_line_pointer
++;
7061 spnum
= get_absolute_expression ();
7063 else if ((strncasecmp (name
, "sort", 4) == 0))
7065 *input_line_pointer
= c
;
7066 input_line_pointer
++;
7067 sort
= get_absolute_expression ();
7069 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7071 *input_line_pointer
= c
;
7074 else if ((strncasecmp (name
, "notdefined", 10) == 0))
7076 *input_line_pointer
= c
;
7079 else if ((strncasecmp (name
, "private", 7) == 0))
7081 *input_line_pointer
= c
;
7086 as_bad (_("Invalid .SPACE argument"));
7087 *input_line_pointer
= c
;
7088 if (!is_end_of_statement ())
7089 input_line_pointer
++;
7093 print_errors
= TRUE
;
7096 if (create_flag
&& seg
== NULL
)
7097 seg
= subseg_new (space_name
, 0);
7099 /* If create_flag is nonzero, then create the new space with
7100 the attributes computed above. Else set the values in
7101 an already existing space -- this can only happen for
7102 the first occurence of a built-in space. */
7104 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
7105 private, sort
, seg
, 1);
7108 space
= is_defined_space (space_name
);
7109 SPACE_SPNUM (space
) = spnum
;
7110 SPACE_DEFINED (space
) = defined
& 1;
7111 SPACE_USER_DEFINED (space
) = 1;
7114 #ifdef obj_set_section_attributes
7115 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7121 /* Handle a .SPACE pseudo-op; this switches the current space to the
7122 given space, creating the new space if necessary. */
7126 int unused ATTRIBUTE_UNUSED
;
7128 char *name
, c
, *space_name
, *save_s
;
7130 sd_chain_struct
*sd_chain
;
7132 if (within_procedure
)
7134 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
7135 ignore_rest_of_line ();
7139 /* Check for some of the predefined spaces. FIXME: most of the code
7140 below is repeated several times, can we extract the common parts
7141 and place them into a subroutine or something similar? */
7142 /* FIXME Is this (and the next IF stmt) really right?
7143 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
7144 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
7146 input_line_pointer
+= 6;
7147 sd_chain
= is_defined_space ("$TEXT$");
7148 if (sd_chain
== NULL
)
7149 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
7150 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7151 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
7153 current_space
= sd_chain
;
7154 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
7156 = pa_subsegment_to_subspace (text_section
,
7157 sd_chain
->sd_last_subseg
);
7158 demand_empty_rest_of_line ();
7161 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
7163 input_line_pointer
+= 9;
7164 sd_chain
= is_defined_space ("$PRIVATE$");
7165 if (sd_chain
== NULL
)
7166 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
7167 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7168 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
7170 current_space
= sd_chain
;
7171 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
7173 = pa_subsegment_to_subspace (data_section
,
7174 sd_chain
->sd_last_subseg
);
7175 demand_empty_rest_of_line ();
7178 if (!strncasecmp (input_line_pointer
,
7179 GDB_DEBUG_SPACE_NAME
,
7180 strlen (GDB_DEBUG_SPACE_NAME
)))
7182 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
7183 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
7184 if (sd_chain
== NULL
)
7185 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
7186 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7187 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
7189 current_space
= sd_chain
;
7192 asection
*gdb_section
7193 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
7195 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
7197 = pa_subsegment_to_subspace (gdb_section
,
7198 sd_chain
->sd_last_subseg
);
7200 demand_empty_rest_of_line ();
7204 /* It could be a space specified by number. */
7206 save_s
= input_line_pointer
;
7207 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
7209 if ((sd_chain
= pa_find_space_by_number (temp
)))
7211 current_space
= sd_chain
;
7213 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7215 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7216 sd_chain
->sd_last_subseg
);
7217 demand_empty_rest_of_line ();
7222 /* Not a number, attempt to create a new space. */
7224 input_line_pointer
= save_s
;
7225 name
= input_line_pointer
;
7226 c
= get_symbol_end ();
7227 space_name
= xmalloc (strlen (name
) + 1);
7228 strcpy (space_name
, name
);
7229 *input_line_pointer
= c
;
7231 sd_chain
= pa_parse_space_stmt (space_name
, 1);
7232 current_space
= sd_chain
;
7234 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7235 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7236 sd_chain
->sd_last_subseg
);
7237 demand_empty_rest_of_line ();
7241 /* Switch to a new space. (I think). FIXME. */
7245 int unused ATTRIBUTE_UNUSED
;
7250 sd_chain_struct
*space
;
7252 name
= input_line_pointer
;
7253 c
= get_symbol_end ();
7254 space
= is_defined_space (name
);
7258 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
7261 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
7263 *input_line_pointer
= c
;
7264 demand_empty_rest_of_line ();
7267 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
7268 given subspace, creating the new subspace if necessary.
7270 FIXME. Should mirror pa_space more closely, in particular how
7271 they're broken up into subroutines. */
7274 pa_subspace (create_new
)
7277 char *name
, *ss_name
, c
;
7278 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
7279 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
7280 sd_chain_struct
*space
;
7281 ssd_chain_struct
*ssd
;
7284 if (current_space
== NULL
)
7285 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
7287 if (within_procedure
)
7289 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
7290 ignore_rest_of_line ();
7294 name
= input_line_pointer
;
7295 c
= get_symbol_end ();
7296 ss_name
= xmalloc (strlen (name
) + 1);
7297 strcpy (ss_name
, name
);
7298 *input_line_pointer
= c
;
7300 /* Load default values. */
7312 space
= current_space
;
7316 ssd
= is_defined_subspace (ss_name
);
7317 /* Allow user to override the builtin attributes of subspaces. But
7318 only allow the attributes to be changed once! */
7319 if (ssd
&& SUBSPACE_DEFINED (ssd
))
7321 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
7322 current_subspace
= ssd
;
7323 if (!is_end_of_statement ())
7324 as_warn (_("Parameters of an existing subspace can\'t be modified"));
7325 demand_empty_rest_of_line ();
7330 /* A new subspace. Load default values if it matches one of
7331 the builtin subspaces. */
7333 while (pa_def_subspaces
[i
].name
)
7335 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
7337 loadable
= pa_def_subspaces
[i
].loadable
;
7338 common
= pa_def_subspaces
[i
].common
;
7339 dup_common
= pa_def_subspaces
[i
].dup_common
;
7340 code_only
= pa_def_subspaces
[i
].code_only
;
7341 zero
= pa_def_subspaces
[i
].zero
;
7342 space_index
= pa_def_subspaces
[i
].space_index
;
7343 alignment
= pa_def_subspaces
[i
].alignment
;
7344 quadrant
= pa_def_subspaces
[i
].quadrant
;
7345 access
= pa_def_subspaces
[i
].access
;
7346 sort
= pa_def_subspaces
[i
].sort
;
7353 /* We should be working with a new subspace now. Fill in
7354 any information as specified by the user. */
7355 if (!is_end_of_statement ())
7357 input_line_pointer
++;
7358 while (!is_end_of_statement ())
7360 name
= input_line_pointer
;
7361 c
= get_symbol_end ();
7362 if ((strncasecmp (name
, "quad", 4) == 0))
7364 *input_line_pointer
= c
;
7365 input_line_pointer
++;
7366 quadrant
= get_absolute_expression ();
7368 else if ((strncasecmp (name
, "align", 5) == 0))
7370 *input_line_pointer
= c
;
7371 input_line_pointer
++;
7372 alignment
= get_absolute_expression ();
7373 if (log2 (alignment
) == -1)
7375 as_bad (_("Alignment must be a power of 2"));
7379 else if ((strncasecmp (name
, "access", 6) == 0))
7381 *input_line_pointer
= c
;
7382 input_line_pointer
++;
7383 access
= get_absolute_expression ();
7385 else if ((strncasecmp (name
, "sort", 4) == 0))
7387 *input_line_pointer
= c
;
7388 input_line_pointer
++;
7389 sort
= get_absolute_expression ();
7391 else if ((strncasecmp (name
, "code_only", 9) == 0))
7393 *input_line_pointer
= c
;
7396 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7398 *input_line_pointer
= c
;
7401 else if ((strncasecmp (name
, "common", 6) == 0))
7403 *input_line_pointer
= c
;
7406 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
7408 *input_line_pointer
= c
;
7411 else if ((strncasecmp (name
, "zero", 4) == 0))
7413 *input_line_pointer
= c
;
7416 else if ((strncasecmp (name
, "first", 5) == 0))
7417 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
7419 as_bad (_("Invalid .SUBSPACE argument"));
7420 if (!is_end_of_statement ())
7421 input_line_pointer
++;
7425 /* Compute a reasonable set of BFD flags based on the information
7426 in the .subspace directive. */
7427 applicable
= bfd_applicable_section_flags (stdoutput
);
7430 flags
|= (SEC_ALLOC
| SEC_LOAD
);
7433 if (common
|| dup_common
)
7434 flags
|= SEC_IS_COMMON
;
7436 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
7438 /* This is a zero-filled subspace (eg BSS). */
7440 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
7442 applicable
&= flags
;
7444 /* If this is an existing subspace, then we want to use the
7445 segment already associated with the subspace.
7447 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
7448 lots of sections. It might be a problem in the PA ELF
7449 code, I do not know yet. For now avoid creating anything
7450 but the "standard" sections for ELF. */
7452 section
= subseg_force_new (ss_name
, 0);
7454 section
= ssd
->ssd_seg
;
7456 section
= subseg_new (ss_name
, 0);
7459 seg_info (section
)->bss
= 1;
7461 /* Now set the flags. */
7462 bfd_set_section_flags (stdoutput
, section
, applicable
);
7464 /* Record any alignment request for this section. */
7465 record_alignment (section
, log2 (alignment
));
7467 /* Set the starting offset for this section. */
7468 bfd_set_section_vma (stdoutput
, section
,
7469 pa_subspace_start (space
, quadrant
));
7471 /* Now that all the flags are set, update an existing subspace,
7472 or create a new one. */
7475 current_subspace
= update_subspace (space
, ss_name
, loadable
,
7476 code_only
, common
, dup_common
,
7477 sort
, zero
, access
, space_index
,
7478 alignment
, quadrant
,
7481 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
7483 dup_common
, zero
, sort
,
7484 access
, space_index
,
7485 alignment
, quadrant
, section
);
7487 demand_empty_rest_of_line ();
7488 current_subspace
->ssd_seg
= section
;
7489 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
7491 SUBSPACE_DEFINED (current_subspace
) = 1;
7495 /* Create default space and subspace dictionaries. */
7502 space_dict_root
= NULL
;
7503 space_dict_last
= NULL
;
7506 while (pa_def_spaces
[i
].name
)
7510 /* Pick the right name to use for the new section. */
7511 name
= pa_def_spaces
[i
].name
;
7513 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
7514 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
7515 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
7516 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
7517 pa_def_spaces
[i
].segment
, 0);
7522 while (pa_def_subspaces
[i
].name
)
7525 int applicable
, subsegment
;
7526 asection
*segment
= NULL
;
7527 sd_chain_struct
*space
;
7529 /* Pick the right name for the new section and pick the right
7530 subsegment number. */
7531 name
= pa_def_subspaces
[i
].name
;
7534 /* Create the new section. */
7535 segment
= subseg_new (name
, subsegment
);
7538 /* For SOM we want to replace the standard .text, .data, and .bss
7539 sections with our own. We also want to set BFD flags for
7540 all the built-in subspaces. */
7541 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
7543 text_section
= segment
;
7544 applicable
= bfd_applicable_section_flags (stdoutput
);
7545 bfd_set_section_flags (stdoutput
, segment
,
7546 applicable
& (SEC_ALLOC
| SEC_LOAD
7547 | SEC_RELOC
| SEC_CODE
7549 | SEC_HAS_CONTENTS
));
7551 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
7553 data_section
= segment
;
7554 applicable
= bfd_applicable_section_flags (stdoutput
);
7555 bfd_set_section_flags (stdoutput
, segment
,
7556 applicable
& (SEC_ALLOC
| SEC_LOAD
7558 | SEC_HAS_CONTENTS
));
7562 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
7564 bss_section
= segment
;
7565 applicable
= bfd_applicable_section_flags (stdoutput
);
7566 bfd_set_section_flags (stdoutput
, segment
,
7567 applicable
& SEC_ALLOC
);
7569 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
7571 applicable
= bfd_applicable_section_flags (stdoutput
);
7572 bfd_set_section_flags (stdoutput
, segment
,
7573 applicable
& (SEC_ALLOC
| SEC_LOAD
7576 | SEC_HAS_CONTENTS
));
7578 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
7580 applicable
= bfd_applicable_section_flags (stdoutput
);
7581 bfd_set_section_flags (stdoutput
, segment
,
7582 applicable
& (SEC_ALLOC
| SEC_LOAD
7585 | SEC_HAS_CONTENTS
));
7587 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
7589 applicable
= bfd_applicable_section_flags (stdoutput
);
7590 bfd_set_section_flags (stdoutput
, segment
,
7591 applicable
& (SEC_ALLOC
| SEC_LOAD
7594 | SEC_HAS_CONTENTS
));
7597 /* Find the space associated with this subspace. */
7598 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
7599 def_space_index
].segment
);
7602 as_fatal (_("Internal error: Unable to find containing space for %s."),
7603 pa_def_subspaces
[i
].name
);
7606 create_new_subspace (space
, name
,
7607 pa_def_subspaces
[i
].loadable
,
7608 pa_def_subspaces
[i
].code_only
,
7609 pa_def_subspaces
[i
].common
,
7610 pa_def_subspaces
[i
].dup_common
,
7611 pa_def_subspaces
[i
].zero
,
7612 pa_def_subspaces
[i
].sort
,
7613 pa_def_subspaces
[i
].access
,
7614 pa_def_subspaces
[i
].space_index
,
7615 pa_def_subspaces
[i
].alignment
,
7616 pa_def_subspaces
[i
].quadrant
,
7624 /* Create a new space NAME, with the appropriate flags as defined
7625 by the given parameters. */
7627 static sd_chain_struct
*
7628 create_new_space (name
, spnum
, loadable
, defined
, private,
7629 sort
, seg
, user_defined
)
7639 sd_chain_struct
*chain_entry
;
7641 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
7643 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
7646 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7647 strcpy (SPACE_NAME (chain_entry
), name
);
7648 SPACE_DEFINED (chain_entry
) = defined
;
7649 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
7650 SPACE_SPNUM (chain_entry
) = spnum
;
7652 chain_entry
->sd_seg
= seg
;
7653 chain_entry
->sd_last_subseg
= -1;
7654 chain_entry
->sd_subspaces
= NULL
;
7655 chain_entry
->sd_next
= NULL
;
7657 /* Find spot for the new space based on its sort key. */
7658 if (!space_dict_last
)
7659 space_dict_last
= chain_entry
;
7661 if (space_dict_root
== NULL
)
7662 space_dict_root
= chain_entry
;
7665 sd_chain_struct
*chain_pointer
;
7666 sd_chain_struct
*prev_chain_pointer
;
7668 chain_pointer
= space_dict_root
;
7669 prev_chain_pointer
= NULL
;
7671 while (chain_pointer
)
7673 prev_chain_pointer
= chain_pointer
;
7674 chain_pointer
= chain_pointer
->sd_next
;
7677 /* At this point we've found the correct place to add the new
7678 entry. So add it and update the linked lists as appropriate. */
7679 if (prev_chain_pointer
)
7681 chain_entry
->sd_next
= chain_pointer
;
7682 prev_chain_pointer
->sd_next
= chain_entry
;
7686 space_dict_root
= chain_entry
;
7687 chain_entry
->sd_next
= chain_pointer
;
7690 if (chain_entry
->sd_next
== NULL
)
7691 space_dict_last
= chain_entry
;
7694 /* This is here to catch predefined spaces which do not get
7695 modified by the user's input. Another call is found at
7696 the bottom of pa_parse_space_stmt to handle cases where
7697 the user modifies a predefined space. */
7698 #ifdef obj_set_section_attributes
7699 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7705 /* Create a new subspace NAME, with the appropriate flags as defined
7706 by the given parameters.
7708 Add the new subspace to the subspace dictionary chain in numerical
7709 order as defined by the SORT entries. */
7711 static ssd_chain_struct
*
7712 create_new_subspace (space
, name
, loadable
, code_only
, common
,
7713 dup_common
, is_zero
, sort
, access
, space_index
,
7714 alignment
, quadrant
, seg
)
7715 sd_chain_struct
*space
;
7717 int loadable
, code_only
, common
, dup_common
, is_zero
;
7725 ssd_chain_struct
*chain_entry
;
7727 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
7729 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
7731 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7732 strcpy (SUBSPACE_NAME (chain_entry
), name
);
7734 /* Initialize subspace_defined. When we hit a .subspace directive
7735 we'll set it to 1 which "locks-in" the subspace attributes. */
7736 SUBSPACE_DEFINED (chain_entry
) = 0;
7738 chain_entry
->ssd_subseg
= 0;
7739 chain_entry
->ssd_seg
= seg
;
7740 chain_entry
->ssd_next
= NULL
;
7742 /* Find spot for the new subspace based on its sort key. */
7743 if (space
->sd_subspaces
== NULL
)
7744 space
->sd_subspaces
= chain_entry
;
7747 ssd_chain_struct
*chain_pointer
;
7748 ssd_chain_struct
*prev_chain_pointer
;
7750 chain_pointer
= space
->sd_subspaces
;
7751 prev_chain_pointer
= NULL
;
7753 while (chain_pointer
)
7755 prev_chain_pointer
= chain_pointer
;
7756 chain_pointer
= chain_pointer
->ssd_next
;
7759 /* Now we have somewhere to put the new entry. Insert it and update
7761 if (prev_chain_pointer
)
7763 chain_entry
->ssd_next
= chain_pointer
;
7764 prev_chain_pointer
->ssd_next
= chain_entry
;
7768 space
->sd_subspaces
= chain_entry
;
7769 chain_entry
->ssd_next
= chain_pointer
;
7773 #ifdef obj_set_subsection_attributes
7774 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
7781 /* Update the information for the given subspace based upon the
7782 various arguments. Return the modified subspace chain entry. */
7784 static ssd_chain_struct
*
7785 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
7786 zero
, access
, space_index
, alignment
, quadrant
, section
)
7787 sd_chain_struct
*space
;
7801 ssd_chain_struct
*chain_entry
;
7803 chain_entry
= is_defined_subspace (name
);
7805 #ifdef obj_set_subsection_attributes
7806 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
7813 /* Return the space chain entry for the space with the name NAME or
7814 NULL if no such space exists. */
7816 static sd_chain_struct
*
7817 is_defined_space (name
)
7820 sd_chain_struct
*chain_pointer
;
7822 for (chain_pointer
= space_dict_root
;
7824 chain_pointer
= chain_pointer
->sd_next
)
7826 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
7827 return chain_pointer
;
7830 /* No mapping from segment to space was found. Return NULL. */
7834 /* Find and return the space associated with the given seg. If no mapping
7835 from the given seg to a space is found, then return NULL.
7837 Unlike subspaces, the number of spaces is not expected to grow much,
7838 so a linear exhaustive search is OK here. */
7840 static sd_chain_struct
*
7841 pa_segment_to_space (seg
)
7844 sd_chain_struct
*space_chain
;
7846 /* Walk through each space looking for the correct mapping. */
7847 for (space_chain
= space_dict_root
;
7849 space_chain
= space_chain
->sd_next
)
7851 if (space_chain
->sd_seg
== seg
)
7855 /* Mapping was not found. Return NULL. */
7859 /* Return the space chain entry for the subspace with the name NAME or
7860 NULL if no such subspace exists.
7862 Uses a linear search through all the spaces and subspaces, this may
7863 not be appropriate if we ever being placing each function in its
7866 static ssd_chain_struct
*
7867 is_defined_subspace (name
)
7870 sd_chain_struct
*space_chain
;
7871 ssd_chain_struct
*subspace_chain
;
7873 /* Walk through each space. */
7874 for (space_chain
= space_dict_root
;
7876 space_chain
= space_chain
->sd_next
)
7878 /* Walk through each subspace looking for a name which matches. */
7879 for (subspace_chain
= space_chain
->sd_subspaces
;
7881 subspace_chain
= subspace_chain
->ssd_next
)
7882 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
7883 return subspace_chain
;
7886 /* Subspace wasn't found. Return NULL. */
7890 /* Find and return the subspace associated with the given seg. If no
7891 mapping from the given seg to a subspace is found, then return NULL.
7893 If we ever put each procedure/function within its own subspace
7894 (to make life easier on the compiler and linker), then this will have
7895 to become more efficient. */
7897 static ssd_chain_struct
*
7898 pa_subsegment_to_subspace (seg
, subseg
)
7902 sd_chain_struct
*space_chain
;
7903 ssd_chain_struct
*subspace_chain
;
7905 /* Walk through each space. */
7906 for (space_chain
= space_dict_root
;
7908 space_chain
= space_chain
->sd_next
)
7910 if (space_chain
->sd_seg
== seg
)
7912 /* Walk through each subspace within each space looking for
7913 the correct mapping. */
7914 for (subspace_chain
= space_chain
->sd_subspaces
;
7916 subspace_chain
= subspace_chain
->ssd_next
)
7917 if (subspace_chain
->ssd_subseg
== (int) subseg
)
7918 return subspace_chain
;
7922 /* No mapping from subsegment to subspace found. Return NULL. */
7926 /* Given a number, try and find a space with the name number.
7928 Return a pointer to a space dictionary chain entry for the space
7929 that was found or NULL on failure. */
7931 static sd_chain_struct
*
7932 pa_find_space_by_number (number
)
7935 sd_chain_struct
*space_chain
;
7937 for (space_chain
= space_dict_root
;
7939 space_chain
= space_chain
->sd_next
)
7941 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
7945 /* No appropriate space found. Return NULL. */
7949 /* Return the starting address for the given subspace. If the starting
7950 address is unknown then return zero. */
7953 pa_subspace_start (space
, quadrant
)
7954 sd_chain_struct
*space
;
7957 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
7958 is not correct for the PA OSF1 port. */
7959 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
7961 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
7968 /* FIXME. Needs documentation. */
7970 pa_next_subseg (space
)
7971 sd_chain_struct
*space
;
7974 space
->sd_last_subseg
++;
7975 return space
->sd_last_subseg
;
7979 /* Helper function for pa_stringer. Used to find the end of
7986 unsigned int c
= *s
& CHAR_MASK
;
7989 /* We must have a valid space and subspace. */
7990 pa_check_current_space_and_subspace ();
8004 /* Handle a .STRING type pseudo-op. */
8007 pa_stringer (append_zero
)
8010 char *s
, num_buf
[4];
8014 /* Preprocess the string to handle PA-specific escape sequences.
8015 For example, \xDD where DD is a hexidecimal number should be
8016 changed to \OOO where OOO is an octal number. */
8018 /* Skip the opening quote. */
8019 s
= input_line_pointer
+ 1;
8021 while (is_a_char (c
= pa_stringer_aux (s
++)))
8028 /* Handle \x<num>. */
8031 unsigned int number
;
8036 /* Get pas the 'x'. */
8038 for (num_digit
= 0, number
= 0, dg
= *s
;
8040 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
8041 || (dg
>= 'A' && dg
<= 'F'));
8045 number
= number
* 16 + dg
- '0';
8046 else if (dg
>= 'a' && dg
<= 'f')
8047 number
= number
* 16 + dg
- 'a' + 10;
8049 number
= number
* 16 + dg
- 'A' + 10;
8059 sprintf (num_buf
, "%02o", number
);
8062 sprintf (num_buf
, "%03o", number
);
8065 for (i
= 0; i
<= num_digit
; i
++)
8066 s_start
[i
] = num_buf
[i
];
8070 /* This might be a "\"", skip over the escaped char. */
8077 stringer (append_zero
);
8078 pa_undefine_label ();
8081 /* Handle a .VERSION pseudo-op. */
8085 int unused ATTRIBUTE_UNUSED
;
8088 pa_undefine_label ();
8093 /* Handle a .COMPILER pseudo-op. */
8096 pa_compiler (unused
)
8097 int unused ATTRIBUTE_UNUSED
;
8099 obj_som_compiler (0);
8100 pa_undefine_label ();
8105 /* Handle a .COPYRIGHT pseudo-op. */
8108 pa_copyright (unused
)
8109 int unused ATTRIBUTE_UNUSED
;
8112 pa_undefine_label ();
8115 /* Just like a normal cons, but when finished we have to undefine
8116 the latest space label. */
8123 pa_undefine_label ();
8126 /* Switch to the data space. As usual delete our label. */
8130 int unused ATTRIBUTE_UNUSED
;
8133 current_space
= is_defined_space ("$PRIVATE$");
8135 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
8138 pa_undefine_label ();
8141 /* Like float_cons, but we need to undefine our label. */
8144 pa_float_cons (float_type
)
8147 float_cons (float_type
);
8148 pa_undefine_label ();
8151 /* Like s_fill, but delete our label when finished. */
8155 int unused ATTRIBUTE_UNUSED
;
8158 /* We must have a valid space and subspace. */
8159 pa_check_current_space_and_subspace ();
8163 pa_undefine_label ();
8166 /* Like lcomm, but delete our label when finished. */
8169 pa_lcomm (needs_align
)
8173 /* We must have a valid space and subspace. */
8174 pa_check_current_space_and_subspace ();
8177 s_lcomm (needs_align
);
8178 pa_undefine_label ();
8181 /* Like lsym, but delete our label when finished. */
8185 int unused ATTRIBUTE_UNUSED
;
8188 /* We must have a valid space and subspace. */
8189 pa_check_current_space_and_subspace ();
8193 pa_undefine_label ();
8196 /* Switch to the text space. Like s_text, but delete our
8197 label when finished. */
8200 int unused ATTRIBUTE_UNUSED
;
8203 current_space
= is_defined_space ("$TEXT$");
8205 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
8209 pa_undefine_label ();
8212 /* On the PA relocations which involve function symbols must not be
8213 adjusted. This so that the linker can know when/how to create argument
8214 relocation stubs for indirect calls and calls to static functions.
8216 "T" field selectors create DLT relative fixups for accessing
8217 globals and statics in PIC code; each DLT relative fixup creates
8218 an entry in the DLT table. The entries contain the address of
8219 the final target (eg accessing "foo" would create a DLT entry
8220 with the address of "foo").
8222 Unfortunately, the HP linker doesn't take into account any addend
8223 when generating the DLT; so accessing $LIT$+8 puts the address of
8224 $LIT$ into the DLT rather than the address of $LIT$+8.
8226 The end result is we can't perform relocation symbol reductions for
8227 any fixup which creates entries in the DLT (eg they use "T" field
8230 Reject reductions involving symbols with external scope; such
8231 reductions make life a living hell for object file editors.
8233 FIXME. Also reject R_HPPA relocations which are 32bits wide in
8234 the code space. The SOM BFD backend doesn't know how to pull the
8235 right bits out of an instruction. */
8238 hppa_fix_adjustable (fixp
)
8241 struct hppa_fix_struct
*hppa_fix
;
8243 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8246 /* Reject reductions of symbols in 32bit relocs. */
8247 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
8250 /* Reject reductions of symbols in sym1-sym2 expressions when
8251 the fixup will occur in a CODE subspace.
8253 XXX FIXME: Long term we probably want to reject all of these;
8254 for example reducing in the debug section would lose if we ever
8255 supported using the optimizing hp linker. */
8258 && (hppa_fix
->segment
->flags
& SEC_CODE
))
8260 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
8261 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
8265 /* We can't adjust any relocs that use LR% and RR% field selectors.
8266 That confuses the HP linker. */
8267 if (hppa_fix
->fx_r_field
== e_lrsel
8268 || hppa_fix
->fx_r_field
== e_rrsel
8269 || hppa_fix
->fx_r_field
== e_nlrsel
)
8273 /* Reject reductions of symbols in DLT relative relocs,
8274 relocations with plabels. */
8275 if (hppa_fix
->fx_r_field
== e_tsel
8276 || hppa_fix
->fx_r_field
== e_ltsel
8277 || hppa_fix
->fx_r_field
== e_rtsel
8278 || hppa_fix
->fx_r_field
== e_psel
8279 || hppa_fix
->fx_r_field
== e_rpsel
8280 || hppa_fix
->fx_r_field
== e_lpsel
)
8283 if (fixp
->fx_addsy
&& S_IS_EXTERNAL (fixp
->fx_addsy
))
8286 /* Reject absolute calls (jumps). */
8287 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
8290 /* Reject reductions of function symbols. */
8291 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
8297 /* Return nonzero if the fixup in FIXP will require a relocation,
8298 even it if appears that the fixup could be completely handled
8302 hppa_force_relocation (fixp
)
8305 struct hppa_fix_struct
*hppa_fixp
;
8308 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8310 if (fixp
->fx_r_type
== R_HPPA_ENTRY
|| fixp
->fx_r_type
== R_HPPA_EXIT
8311 || fixp
->fx_r_type
== R_HPPA_BEGIN_BRTAB
8312 || fixp
->fx_r_type
== R_HPPA_END_BRTAB
8313 || fixp
->fx_r_type
== R_HPPA_BEGIN_TRY
8314 || fixp
->fx_r_type
== R_HPPA_END_TRY
8315 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
8316 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
8320 #define arg_reloc_stub_needed(CALLER, CALLEE) \
8321 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
8324 /* It is necessary to force PC-relative calls/jumps to have a relocation
8325 entry if they're going to need either a argument relocation or long
8326 call stub. FIXME. Can't we need the same for absolute calls? */
8327 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
8328 && (arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
8329 symbol_get_bfdsym (fixp
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
8330 hppa_fixp
->fx_arg_reloc
)))
8333 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
8334 - md_pcrel_from (fixp
));
8335 /* Now check and see if we're going to need a long-branch stub. */
8336 if (fixp
->fx_r_type
== R_HPPA_PCREL_CALL
8337 && (distance
> 262143 || distance
< -262144))
8340 if (fixp
->fx_r_type
== R_HPPA_ABS_CALL
)
8342 #undef arg_reloc_stub_needed
8344 /* No need (yet) to force another relocations to be emitted. */
8348 /* Now for some ELF specific code. FIXME. */
8350 /* Mark the end of a function so that it's possible to compute
8351 the size of the function in hppa_elf_final_processing. */
8354 hppa_elf_mark_end_of_function ()
8356 /* ELF does not have EXIT relocations. All we do is create a
8357 temporary symbol marking the end of the function. */
8358 char *name
= (char *)
8359 xmalloc (strlen ("L$\001end_") +
8360 strlen (S_GET_NAME (last_call_info
->start_symbol
)) + 1);
8366 strcpy (name
, "L$\001end_");
8367 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
8369 /* If we have a .exit followed by a .procend, then the
8370 symbol will have already been defined. */
8371 symbolP
= symbol_find (name
);
8374 /* The symbol has already been defined! This can
8375 happen if we have a .exit followed by a .procend.
8377 This is *not* an error. All we want to do is free
8378 the memory we just allocated for the name and continue. */
8383 /* symbol value should be the offset of the
8384 last instruction of the function */
8385 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
8389 S_CLEAR_EXTERNAL (symbolP
);
8390 symbol_table_insert (symbolP
);
8394 last_call_info
->end_symbol
= symbolP
;
8396 as_bad (_("Symbol '%s' could not be created."), name
);
8400 as_bad (_("No memory for symbol name."));
8404 /* For ELF, this function serves one purpose: to setup the st_size
8405 field of STT_FUNC symbols. To do this, we need to scan the
8406 call_info structure list, determining st_size in by taking the
8407 difference in the address of the beginning/end marker symbols. */
8410 elf_hppa_final_processing ()
8412 struct call_info
*call_info_pointer
;
8414 for (call_info_pointer
= call_info_root
;
8416 call_info_pointer
= call_info_pointer
->ci_next
)
8418 elf_symbol_type
*esym
8419 = ((elf_symbol_type
*)
8420 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
8421 esym
->internal_elf_sym
.st_size
=
8422 S_GET_VALUE (call_info_pointer
->end_symbol
)
8423 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;
8429 void pa_end_of_source ()
8431 if (debug_type
== DEBUG_DWARF2
)