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 void pa_compiler
PARAMS ((int));
532 static void pa_align
PARAMS ((int));
533 static void pa_space
PARAMS ((int));
534 static void pa_spnum
PARAMS ((int));
535 static void pa_subspace
PARAMS ((int));
536 static sd_chain_struct
*create_new_space
PARAMS ((char *, int, int,
539 static ssd_chain_struct
*create_new_subspace
PARAMS ((sd_chain_struct
*,
544 static ssd_chain_struct
*update_subspace
PARAMS ((sd_chain_struct
*,
545 char *, int, int, int,
549 static sd_chain_struct
*is_defined_space
PARAMS ((char *));
550 static ssd_chain_struct
*is_defined_subspace
PARAMS ((char *));
551 static sd_chain_struct
*pa_segment_to_space
PARAMS ((asection
*));
552 static ssd_chain_struct
*pa_subsegment_to_subspace
PARAMS ((asection
*,
554 static sd_chain_struct
*pa_find_space_by_number
PARAMS ((int));
555 static unsigned int pa_subspace_start
PARAMS ((sd_chain_struct
*, int));
556 static sd_chain_struct
*pa_parse_space_stmt
PARAMS ((char *, int));
557 static int pa_next_subseg
PARAMS ((sd_chain_struct
*));
558 static void pa_spaces_begin
PARAMS ((void));
560 static void pa_ip
PARAMS ((char *));
561 static void fix_new_hppa
PARAMS ((fragS
*, int, int, symbolS
*,
562 long, expressionS
*, int,
563 bfd_reloc_code_real_type
,
564 enum hppa_reloc_field_selector_type_alt
,
566 static int is_end_of_statement
PARAMS ((void));
567 static int reg_name_search
PARAMS ((char *));
568 static int pa_chk_field_selector
PARAMS ((char **));
569 static int is_same_frag
PARAMS ((fragS
*, fragS
*));
570 static void process_exit
PARAMS ((void));
571 static int log2
PARAMS ((int));
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
},
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
},
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 #define is_DP_relative(exp) \
1118 ((exp).X_op == O_subtract \
1119 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1121 #define is_PC_relative(exp) \
1122 ((exp).X_op == O_subtract \
1123 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1125 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1126 always be able to reduce the expression to a constant, so we don't
1127 need real complex handling yet. */
1128 #define is_complex(exp) \
1129 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1131 /* Actual functions to implement the PA specific code for the assembler. */
1133 /* Called before writing the object file. Make sure entry/exit and
1134 proc/procend pairs match. */
1139 if (within_entry_exit
)
1140 as_fatal (_("Missing .exit\n"));
1142 if (within_procedure
)
1143 as_fatal (_("Missing .procend\n"));
1146 /* Returns a pointer to the label_symbol_struct for the current space.
1147 or NULL if no label_symbol_struct exists for the current space. */
1149 static label_symbol_struct
*
1152 label_symbol_struct
*label_chain
;
1154 for (label_chain
= label_symbols_rootp
;
1156 label_chain
= label_chain
->lss_next
)
1159 if (current_space
== label_chain
->lss_space
&& label_chain
->lss_label
)
1163 if (now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
)
1171 /* Defines a label for the current space. If one is already defined,
1172 this function will replace it with the new label. */
1175 pa_define_label (symbol
)
1178 label_symbol_struct
*label_chain
= pa_get_label ();
1181 label_chain
->lss_label
= symbol
;
1184 /* Create a new label entry and add it to the head of the chain. */
1186 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1187 label_chain
->lss_label
= symbol
;
1189 label_chain
->lss_space
= current_space
;
1192 label_chain
->lss_segment
= now_seg
;
1194 label_chain
->lss_next
= NULL
;
1196 if (label_symbols_rootp
)
1197 label_chain
->lss_next
= label_symbols_rootp
;
1199 label_symbols_rootp
= label_chain
;
1203 /* Removes a label definition for the current space.
1204 If there is no label_symbol_struct entry, then no action is taken. */
1207 pa_undefine_label ()
1209 label_symbol_struct
*label_chain
;
1210 label_symbol_struct
*prev_label_chain
= NULL
;
1212 for (label_chain
= label_symbols_rootp
;
1214 label_chain
= label_chain
->lss_next
)
1218 && current_space
== label_chain
->lss_space
&& label_chain
->lss_label
1221 && now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
1225 /* Remove the label from the chain and free its memory. */
1226 if (prev_label_chain
)
1227 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1229 label_symbols_rootp
= label_chain
->lss_next
;
1234 prev_label_chain
= label_chain
;
1239 /* An HPPA-specific version of fix_new. This is required because the HPPA
1240 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1241 results in the creation of an instance of an hppa_fix_struct. An
1242 hppa_fix_struct stores the extra information along with a pointer to the
1243 original fixS. This is attached to the original fixup via the
1244 tc_fix_data field. */
1247 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1248 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1252 symbolS
*add_symbol
;
1256 bfd_reloc_code_real_type r_type
;
1257 enum hppa_reloc_field_selector_type_alt r_field
;
1264 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1265 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1268 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1270 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1271 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1272 hppa_fix
->fx_r_type
= r_type
;
1273 hppa_fix
->fx_r_field
= r_field
;
1274 hppa_fix
->fx_r_format
= r_format
;
1275 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1276 hppa_fix
->segment
= now_seg
;
1278 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1279 new_fix
->fx_offset
= *unwind_bits
;
1282 /* foo-$global$ is used to access non-automatic storage. $global$
1283 is really just a marker and has served its purpose, so eliminate
1284 it now so as not to confuse write.c. */
1285 if (new_fix
->fx_subsy
1286 && !strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$"))
1287 new_fix
->fx_subsy
= NULL
;
1290 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1291 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1294 parse_cons_expression_hppa (exp
)
1297 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1301 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1302 hppa_field_selector is set by the parse_cons_expression_hppa. */
1305 cons_fix_new_hppa (frag
, where
, size
, exp
)
1311 unsigned int rel_type
;
1313 /* Get a base relocation type. */
1314 if (is_DP_relative (*exp
))
1315 rel_type
= R_HPPA_GOTOFF
;
1316 else if (is_complex (*exp
))
1317 rel_type
= R_HPPA_COMPLEX
;
1321 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1322 as_warn (_("Invalid field selector. Assuming F%%."));
1324 fix_new_hppa (frag
, where
, size
,
1325 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1326 hppa_field_selector
, size
* 8, 0, NULL
);
1328 /* Reset field selector to its default state. */
1329 hppa_field_selector
= 0;
1332 /* This function is called once, at assembler startup time. It should
1333 set up all the tables, etc. that the MD part of the assembler will need. */
1338 const char *retval
= NULL
;
1342 last_call_info
= NULL
;
1343 call_info_root
= NULL
;
1345 /* Set the default machine type. */
1346 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1347 as_warn (_("could not set architecture and machine"));
1349 /* Folding of text and data segments fails miserably on the PA.
1350 Warn user and disable "-R" option. */
1351 if (flag_readonly_data_in_text
)
1353 as_warn (_("-R option not supported on this target."));
1354 flag_readonly_data_in_text
= 0;
1361 op_hash
= hash_new ();
1363 while (i
< NUMOPCODES
)
1365 const char *name
= pa_opcodes
[i
].name
;
1366 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1367 if (retval
!= NULL
&& *retval
!= '\0')
1369 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1374 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1375 != pa_opcodes
[i
].match
)
1377 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1378 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1383 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1387 as_fatal (_("Broken assembler. No assembly attempted."));
1390 /* SOM will change text_section. To make sure we never put
1391 anything into the old one switch to the new one now. */
1392 subseg_set (text_section
, 0);
1396 dummy_symbol
= symbol_find_or_make ("L$dummy");
1397 S_SET_SEGMENT (dummy_symbol
, text_section
);
1398 /* Force the symbol to be converted to a real symbol. */
1399 (void) symbol_get_bfdsym (dummy_symbol
);
1403 /* Assemble a single instruction storing it into a frag. */
1410 /* The had better be something to assemble. */
1413 /* If we are within a procedure definition, make sure we've
1414 defined a label for the procedure; handle case where the
1415 label was defined after the .PROC directive.
1417 Note there's not need to diddle with the segment or fragment
1418 for the label symbol in this case. We have already switched
1419 into the new $CODE$ subspace at this point. */
1420 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1422 label_symbol_struct
*label_symbol
= pa_get_label ();
1426 if (label_symbol
->lss_label
)
1428 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1429 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1432 /* Also handle allocation of a fixup to hold the unwind
1433 information when the label appears after the proc/procend. */
1434 if (within_entry_exit
)
1436 char *where
= frag_more (0);
1438 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1439 NULL
, (offsetT
) 0, NULL
,
1440 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1441 (int *)&last_call_info
->ci_unwind
.descriptor
);
1446 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1449 as_bad (_("Missing function name for .PROC"));
1452 /* Assemble the instruction. Results are saved into "the_insn". */
1455 /* Get somewhere to put the assembled instrution. */
1458 /* Output the opcode. */
1459 md_number_to_chars (to
, the_insn
.opcode
, 4);
1461 /* If necessary output more stuff. */
1462 if (the_insn
.reloc
!= R_HPPA_NONE
)
1463 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1464 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1465 the_insn
.reloc
, the_insn
.field_selector
,
1466 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1469 if (debug_type
== DEBUG_DWARF2
)
1473 /* First update the notion of the current source line. */
1474 dwarf2_where (&debug_line
);
1476 /* We want the offset of the start of this instruction within the
1477 the current frag. */
1478 addr
= frag_now
->fr_address
+ frag_now_fix () - 4;
1480 /* And record the information. */
1481 dwarf2_gen_line_info (addr
, &debug_line
);
1486 /* Do the real work for assembling a single instruction. Store results
1487 into the global "the_insn" variable. */
1493 char *error_message
= "";
1494 char *s
, c
, *argstart
, *name
, *save_s
;
1498 int cmpltr
, nullif
, flag
, cond
, num
;
1499 unsigned long opcode
;
1500 struct pa_opcode
*insn
;
1503 /* We must have a valid space and subspace. */
1504 pa_check_current_space_and_subspace ();
1507 /* Convert everything up to the first whitespace character into lower
1509 for (s
= str
; *s
!= ' ' && *s
!= '\t' && *s
!= '\n' && *s
!= '\0'; s
++)
1513 /* Skip to something interesting. */
1514 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1533 as_fatal (_("Unknown opcode: `%s'"), str
);
1538 /* Look up the opcode in the has table. */
1539 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1541 as_bad ("Unknown opcode: `%s'", str
);
1550 /* Mark the location where arguments for the instruction start, then
1551 start processing them. */
1555 /* Do some initialization. */
1556 opcode
= insn
->match
;
1557 strict
= (insn
->flags
& FLAG_STRICT
);
1558 memset (&the_insn
, 0, sizeof (the_insn
));
1560 the_insn
.reloc
= R_HPPA_NONE
;
1562 /* If this instruction is specific to a particular architecture,
1563 then set a new architecture. */
1564 /* But do not automatically promote to pa2.0. The automatic promotion
1565 crud is for compatability with HP's old assemblers only. */
1567 && bfd_get_mach (stdoutput
) < insn
->arch
)
1569 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1570 as_warn (_("could not update architecture and machine"));
1572 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1578 /* Build the opcode, checking as we go to make
1579 sure that the operands match. */
1580 for (args
= insn
->args
;; ++args
)
1582 /* Absorb white space in instruction. */
1583 while (*s
== ' ' || *s
== '\t')
1589 /* End of arguments. */
1605 /* These must match exactly. */
1614 /* Handle a 5 bit register or control register field at 10. */
1617 /* This should be more strict. Small steps. */
1618 if (strict
&& *s
!= '%')
1620 num
= pa_parse_number (&s
, 0);
1621 CHECK_FIELD (num
, 31, 0, 0);
1622 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1624 /* Handle %sar or %cr11. No bits get set, we just verify that it
1627 /* Skip whitespace before register. */
1628 while (*s
== ' ' || *s
== '\t')
1631 if (!strncasecmp(s
, "%sar", 4))
1636 else if (!strncasecmp(s
, "%cr11", 5))
1643 /* Handle a 5 bit register field at 15. */
1645 /* This should be more strict. Small steps. */
1646 if (strict
&& *s
!= '%')
1648 num
= pa_parse_number (&s
, 0);
1649 CHECK_FIELD (num
, 31, 0, 0);
1650 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1652 /* Handle a 5 bit register field at 31. */
1654 /* This should be more strict. Small steps. */
1655 if (strict
&& *s
!= '%')
1657 num
= pa_parse_number (&s
, 0);
1658 CHECK_FIELD (num
, 31, 0, 0);
1659 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1661 /* Handle a 5 bit register field at 10 and 15. */
1663 /* This should be more strict. Small steps. */
1664 if (strict
&& *s
!= '%')
1666 num
= pa_parse_number (&s
, 0);
1667 CHECK_FIELD (num
, 31, 0, 0);
1668 opcode
|= num
<< 16;
1669 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1671 /* Handle a 5 bit field length at 31. */
1673 num
= pa_get_absolute_expression (&the_insn
, &s
);
1674 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1677 CHECK_FIELD (num
, 32, 1, 0);
1678 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1680 /* Handle a 5 bit immediate at 15. */
1682 num
= pa_get_absolute_expression (&the_insn
, &s
);
1683 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1686 /* When in strict mode, we want to just reject this
1687 match instead of giving an out of range error. */
1688 CHECK_FIELD (num
, 15, -16, strict
);
1689 low_sign_unext (num
, 5, &num
);
1690 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1692 /* Handle a 5 bit immediate at 31. */
1694 num
= pa_get_absolute_expression (&the_insn
, &s
);
1695 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1698 /* When in strict mode, we want to just reject this
1699 match instead of giving an out of range error. */
1700 CHECK_FIELD (num
, 15, -16, strict
)
1701 low_sign_unext (num
, 5, &num
);
1702 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1704 /* Handle an unsigned 5 bit immediate at 31. */
1706 num
= pa_get_absolute_expression (&the_insn
, &s
);
1707 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1710 CHECK_FIELD (num
, 31, 0, 0);
1711 INSERT_FIELD_AND_CONTINUE (opcode
, num
, strict
);
1713 /* Handle an unsigned 5 bit immediate at 15. */
1715 num
= pa_get_absolute_expression (&the_insn
, &s
);
1716 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1719 CHECK_FIELD (num
, 31, 0, strict
);
1720 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1722 /* Handle an unsigned 10 bit immediate at 15. */
1724 num
= pa_get_absolute_expression (&the_insn
, &s
);
1725 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1728 CHECK_FIELD (num
, 1023, 0, strict
);
1729 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1731 /* Handle a 2 bit space identifier at 17. */
1733 /* This should be more strict. Small steps. */
1734 if (strict
&& *s
!= '%')
1736 num
= pa_parse_number (&s
, 0);
1737 CHECK_FIELD (num
, 3, 0, 1);
1738 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1740 /* Handle a 3 bit space identifier at 18. */
1742 /* This should be more strict. Small steps. */
1743 if (strict
&& *s
!= '%')
1745 num
= pa_parse_number (&s
, 0);
1746 CHECK_FIELD (num
, 7, 0, 1);
1747 dis_assemble_3 (num
, &num
);
1748 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
1750 /* Handle all completers. */
1755 /* Handle a completer for an indexing load or store. */
1761 while (*s
== ',' && i
< 2)
1764 if (strncasecmp (s
, "sm", 2) == 0)
1771 else if (strncasecmp (s
, "m", 1) == 0)
1773 else if ((strncasecmp (s
, "s ", 2) == 0)
1774 || (strncasecmp (s
, "s,", 2) == 0))
1776 /* When in strict mode this is a match failure. */
1783 as_bad (_("Invalid Indexed Load Completer."));
1788 as_bad (_("Invalid Indexed Load Completer Syntax."));
1790 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1793 /* Handle a short load/store completer. */
1805 if (strncasecmp (s
, "ma", 2) == 0)
1811 else if (strncasecmp (s
, "mb", 2) == 0)
1818 /* When in strict mode, pass through for cache op. */
1819 if (!found
&& strict
)
1824 as_bad (_("Invalid Short Load/Store Completer."));
1828 /* If we did not get a ma/mb completer, then we do not
1829 consider this a positive match for 'ce'. */
1830 else if (*args
== 'e')
1833 /* 'J', 'm' and 'q' are the same, except for where they
1834 encode the before/after field. */
1838 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1840 else if (*args
== 'q')
1843 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1845 else if (*args
== 'J')
1847 /* M bit is explicit in the major opcode. */
1848 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1850 else if (*args
== 'e')
1852 /* Gross! Hide these values in the immediate field
1853 of the instruction, then pull them out later. */
1860 /* Handle a stbys completer. */
1866 while (*s
== ',' && i
< 2)
1869 if (strncasecmp (s
, "m", 1) == 0)
1871 else if ((strncasecmp (s
, "b ", 2) == 0)
1872 || (strncasecmp (s
, "b,", 2) == 0))
1874 else if (strncasecmp (s
, "e", 1) == 0)
1876 /* When in strict mode this is a match failure. */
1883 as_bad (_("Invalid Store Bytes Short Completer"));
1888 as_bad (_("Invalid Store Bytes Short Completer"));
1890 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1893 /* Handle load cache hint completer. */
1896 if (!strncmp(s
, ",sl", 3))
1901 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1903 /* Handle store cache hint completer. */
1906 if (!strncmp(s
, ",sl", 3))
1911 else if (!strncmp(s
, ",bc", 3))
1916 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1918 /* Handle load and clear cache hint completer. */
1921 if (!strncmp(s
, ",co", 3))
1926 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1928 /* Handle load ordering completer. */
1930 if (strncmp(s
, ",o", 2) != 0)
1935 /* Handle a branch gate completer. */
1937 if (strncasecmp (s
, ",gate", 5) != 0)
1942 /* Handle a branch link and push completer. */
1944 if (strncasecmp (s
, ",l,push", 7) != 0)
1949 /* Handle a branch link completer. */
1951 if (strncasecmp (s
, ",l", 2) != 0)
1956 /* Handle a branch pop completer. */
1958 if (strncasecmp (s
, ",pop", 4) != 0)
1963 /* Handle a local processor completer. */
1965 if (strncasecmp (s
, ",l", 2) != 0)
1970 /* Handle a PROBE read/write completer. */
1973 if (!strncasecmp (s
, ",w", 2))
1978 else if (!strncasecmp (s
, ",r", 2))
1984 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
1986 /* Handle MFCTL wide completer. */
1988 if (strncasecmp (s
, ",w", 2) != 0)
1993 /* Handle an RFI restore completer. */
1996 if (!strncasecmp (s
, ",r", 2))
2002 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2004 /* Handle a system control completer. */
2006 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2014 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2016 /* Handle intermediate/final completer for DCOR. */
2019 if (!strncasecmp (s
, ",i", 2))
2025 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2027 /* Handle zero/sign extension completer. */
2030 if (!strncasecmp (s
, ",z", 2))
2036 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2038 /* Handle add completer. */
2041 if (!strncasecmp (s
, ",l", 2))
2046 else if (!strncasecmp (s
, ",tsv", 4))
2052 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2054 /* Handle 64 bit carry for ADD. */
2057 if (!strncasecmp (s
, ",dc,tsv", 7) ||
2058 !strncasecmp (s
, ",tsv,dc", 7))
2063 else if (!strncasecmp (s
, ",dc", 3))
2071 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2073 /* Handle 32 bit carry for ADD. */
2076 if (!strncasecmp (s
, ",c,tsv", 6) ||
2077 !strncasecmp (s
, ",tsv,c", 6))
2082 else if (!strncasecmp (s
, ",c", 2))
2090 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2092 /* Handle trap on signed overflow. */
2095 if (!strncasecmp (s
, ",tsv", 4))
2101 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2103 /* Handle trap on condition and overflow. */
2106 if (!strncasecmp (s
, ",tc,tsv", 7) ||
2107 !strncasecmp (s
, ",tsv,tc", 7))
2112 else if (!strncasecmp (s
, ",tc", 3))
2120 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2122 /* Handle 64 bit borrow for SUB. */
2125 if (!strncasecmp (s
, ",db,tsv", 7) ||
2126 !strncasecmp (s
, ",tsv,db", 7))
2131 else if (!strncasecmp (s
, ",db", 3))
2139 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2141 /* Handle 32 bit borrow for SUB. */
2144 if (!strncasecmp (s
, ",b,tsv", 6) ||
2145 !strncasecmp (s
, ",tsv,b", 6))
2150 else if (!strncasecmp (s
, ",b", 2))
2158 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2160 /* Handle trap condition completer for UADDCM. */
2163 if (!strncasecmp (s
, ",tc", 3))
2169 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2171 /* Handle signed/unsigned at 21. */
2175 if (strncasecmp (s
, ",s", 2) == 0)
2180 else if (strncasecmp (s
, ",u", 2) == 0)
2186 INSERT_FIELD_AND_CONTINUE (opcode
, sign
, 10);
2189 /* Handle left/right combination at 17:18. */
2199 as_bad(_("Invalid left/right combination completer"));
2202 INSERT_FIELD_AND_CONTINUE (opcode
, lr
, 13);
2205 as_bad(_("Invalid left/right combination completer"));
2208 /* Handle saturation at 24:25. */
2212 if (strncasecmp (s
, ",ss", 3) == 0)
2217 else if (strncasecmp (s
, ",us", 3) == 0)
2223 INSERT_FIELD_AND_CONTINUE (opcode
, sat
, 6);
2226 /* Handle permutation completer. */
2254 as_bad(_("Invalid permutation completer"));
2256 opcode
|= perm
<< permloc
[i
];
2261 as_bad(_("Invalid permutation completer"));
2269 /* Handle all conditions. */
2275 /* Handle FP compare conditions. */
2277 cond
= pa_parse_fp_cmp_cond (&s
);
2278 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2280 /* Handle an add condition. */
2289 /* 64 bit conditions. */
2302 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2306 if (strcmp (name
, "=") == 0)
2308 else if (strcmp (name
, "<") == 0)
2310 else if (strcmp (name
, "<=") == 0)
2312 else if (strcasecmp (name
, "nuv") == 0)
2314 else if (strcasecmp (name
, "znv") == 0)
2316 else if (strcasecmp (name
, "sv") == 0)
2318 else if (strcasecmp (name
, "od") == 0)
2320 else if (strcasecmp (name
, "tr") == 0)
2325 else if (strcmp (name
, "<>") == 0)
2330 else if (strcmp (name
, ">=") == 0)
2335 else if (strcmp (name
, ">") == 0)
2340 else if (strcasecmp (name
, "uv") == 0)
2345 else if (strcasecmp (name
, "vnz") == 0)
2350 else if (strcasecmp (name
, "nsv") == 0)
2355 else if (strcasecmp (name
, "ev") == 0)
2360 /* ",*" is a valid condition. */
2361 else if (*args
== 'a')
2362 as_bad (_("Invalid Add Condition: %s"), name
);
2365 opcode
|= cmpltr
<< 13;
2366 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2368 /* Handle non-negated add and branch condition. */
2370 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2373 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2376 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2378 /* Handle 64 bit wide-mode add and branch condition. */
2380 cmpltr
= pa_parse_addb_64_cmpltr (&s
);
2383 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2388 /* Negated condition requires an opcode change. */
2389 opcode
|= (cmpltr
& 8) << 24;
2391 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2393 /* Handle a negated or non-negated add and branch
2397 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2401 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
2404 as_bad (_("Invalid Compare/Subtract Condition"));
2409 /* Negated condition requires an opcode change. */
2413 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2415 /* Handle branch on bit conditions. */
2433 if (strncmp (s
, "<", 1) == 0)
2438 else if (strncmp (s
, ">=", 2) == 0)
2444 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2446 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2448 /* Handle a compare/subtract condition. */
2457 /* 64 bit conditions. */
2470 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2474 if (strcmp (name
, "=") == 0)
2476 else if (strcmp (name
, "<") == 0)
2478 else if (strcmp (name
, "<=") == 0)
2480 else if (strcasecmp (name
, "<<") == 0)
2482 else if (strcasecmp (name
, "<<=") == 0)
2484 else if (strcasecmp (name
, "sv") == 0)
2486 else if (strcasecmp (name
, "od") == 0)
2488 else if (strcasecmp (name
, "tr") == 0)
2493 else if (strcmp (name
, "<>") == 0)
2498 else if (strcmp (name
, ">=") == 0)
2503 else if (strcmp (name
, ">") == 0)
2508 else if (strcasecmp (name
, ">>=") == 0)
2513 else if (strcasecmp (name
, ">>") == 0)
2518 else if (strcasecmp (name
, "nsv") == 0)
2523 else if (strcasecmp (name
, "ev") == 0)
2528 /* ",*" is a valid condition. */
2529 else if (*args
!= 'S')
2530 as_bad (_("Invalid Compare/Subtract Condition: %s"),
2534 opcode
|= cmpltr
<< 13;
2535 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2537 /* Handle a non-negated compare condition. */
2539 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2542 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
2545 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2547 /* Handle a 32 bit compare and branch condition. */
2550 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2554 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
2557 as_bad (_("Invalid Compare and Branch Condition."));
2562 /* Negated condition requires an opcode change. */
2567 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2569 /* Handle a 64 bit compare and branch condition. */
2571 cmpltr
= pa_parse_cmpb_64_cmpltr (&s
);
2574 /* Negated condition requires an opcode change. */
2575 opcode
|= (cmpltr
& 8) << 26;
2578 /* Not a 64 bit cond. Give 32 bit a chance. */
2581 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2583 /* Handle a 64 bit cmpib condition. */
2585 cmpltr
= pa_parse_cmpib_64_cmpltr (&s
);
2587 /* Not a 64 bit cond. Give 32 bit a chance. */
2590 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2592 /* Handle a logical instruction condition. */
2601 /* 64 bit conditions. */
2614 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2620 if (strcmp (name
, "=") == 0)
2622 else if (strcmp (name
, "<") == 0)
2624 else if (strcmp (name
, "<=") == 0)
2626 else if (strcasecmp (name
, "od") == 0)
2628 else if (strcasecmp (name
, "tr") == 0)
2633 else if (strcmp (name
, "<>") == 0)
2638 else if (strcmp (name
, ">=") == 0)
2643 else if (strcmp (name
, ">") == 0)
2648 else if (strcasecmp (name
, "ev") == 0)
2653 /* ",*" is a valid condition. */
2654 else if (*args
!= 'L')
2655 as_bad (_("Invalid Logical Instruction Condition."));
2658 opcode
|= cmpltr
<< 13;
2659 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2661 /* Handle a shift/extract/deposit condition. */
2670 /* 64 bit conditions. */
2683 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2687 if (strcmp (name
, "=") == 0)
2689 else if (strcmp (name
, "<") == 0)
2691 else if (strcasecmp (name
, "od") == 0)
2693 else if (strcasecmp (name
, "tr") == 0)
2695 else if (strcmp (name
, "<>") == 0)
2697 else if (strcmp (name
, ">=") == 0)
2699 else if (strcasecmp (name
, "ev") == 0)
2701 /* Handle movb,n. Put things back the way they were.
2702 This includes moving s back to where it started. */
2703 else if (strcasecmp (name
, "n") == 0 && *args
== 'y')
2709 /* ",*" is a valid condition. */
2710 else if (*args
!= 'X')
2711 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2714 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2716 /* Handle a unit instruction condition. */
2725 /* 64 bit conditions. */
2736 if (strncasecmp (s
, "sbz", 3) == 0)
2741 else if (strncasecmp (s
, "shz", 3) == 0)
2746 else if (strncasecmp (s
, "sdc", 3) == 0)
2751 else if (strncasecmp (s
, "sbc", 3) == 0)
2756 else if (strncasecmp (s
, "shc", 3) == 0)
2761 else if (strncasecmp (s
, "tr", 2) == 0)
2767 else if (strncasecmp (s
, "nbz", 3) == 0)
2773 else if (strncasecmp (s
, "nhz", 3) == 0)
2779 else if (strncasecmp (s
, "ndc", 3) == 0)
2785 else if (strncasecmp (s
, "nbc", 3) == 0)
2791 else if (strncasecmp (s
, "nhc", 3) == 0)
2797 else if (strncasecmp (s
, "swz", 3) == 0)
2803 else if (strncasecmp (s
, "swc", 3) == 0)
2809 else if (strncasecmp (s
, "nwz", 3) == 0)
2815 else if (strncasecmp (s
, "nwc", 3) == 0)
2821 /* ",*" is a valid condition. */
2822 else if (*args
!= 'U')
2823 as_bad (_("Invalid Unit Instruction Condition."));
2825 opcode
|= cmpltr
<< 13;
2826 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2834 /* Handle a nullification completer for branch instructions. */
2836 nullif
= pa_parse_nullif (&s
);
2837 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2839 /* Handle a nullification completer for copr and spop insns. */
2841 nullif
= pa_parse_nullif (&s
);
2842 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2844 /* Handle ,%r2 completer for new syntax branches. */
2846 if (*s
== ',' && strncasecmp (s
+ 1, "%r2", 3) == 0)
2848 else if (*s
== ',' && strncasecmp (s
+ 1, "%rp", 3) == 0)
2854 /* Handle 3 bit entry into the fp compare array. Valid values
2855 are 0..6 inclusive. */
2859 if (the_insn
.exp
.X_op
== O_constant
)
2861 num
= evaluate_absolute (&the_insn
);
2862 CHECK_FIELD (num
, 6, 0, 0);
2864 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2869 /* Handle 3 bit entry into the fp compare array. Valid values
2870 are 0..6 inclusive. */
2873 if (the_insn
.exp
.X_op
== O_constant
)
2876 num
= evaluate_absolute (&the_insn
);
2877 CHECK_FIELD (num
, 6, 0, 0);
2878 num
= (num
+ 1) ^ 1;
2879 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2884 /* Handle graphics test completers for ftest */
2887 num
= pa_parse_ftest_gfx_completer (&s
);
2888 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2891 /* Handle a 11 bit immediate at 31. */
2893 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2896 if (the_insn
.exp
.X_op
== O_constant
)
2898 num
= evaluate_absolute (&the_insn
);
2899 CHECK_FIELD (num
, 1023, -1024, 0);
2900 low_sign_unext (num
, 11, &num
);
2901 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2905 if (is_DP_relative (the_insn
.exp
))
2906 the_insn
.reloc
= R_HPPA_GOTOFF
;
2907 else if (is_PC_relative (the_insn
.exp
))
2908 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2910 the_insn
.reloc
= R_HPPA
;
2911 the_insn
.format
= 11;
2915 /* Handle a 14 bit immediate at 31. */
2917 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2920 if (the_insn
.exp
.X_op
== O_constant
)
2924 /* XXX the completer stored away tibits of information
2925 for us to extract. We need a cleaner way to do this.
2926 Now that we have lots of letters again, it would be
2927 good to rethink this. */
2928 m
= (opcode
& (1 << 8)) != 0;
2929 a
= (opcode
& (1 << 9)) != 0;
2930 opcode
&= ~ (3 << 8);
2931 num
= evaluate_absolute (&the_insn
);
2932 if ((a
== 1 && num
>= 0) || (a
== 0 && num
< 0))
2934 CHECK_FIELD (num
, 8191, -8192, 0);
2935 low_sign_unext (num
, 14, &num
);
2936 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2943 /* Handle a 14 bit immediate at 31. */
2945 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2948 if (the_insn
.exp
.X_op
== O_constant
)
2952 /* XXX the completer stored away tibits of information
2953 for us to extract. We need a cleaner way to do this.
2954 Now that we have lots of letters again, it would be
2955 good to rethink this. */
2956 m
= (opcode
& (1 << 8)) != 0;
2957 a
= (opcode
& (1 << 9)) != 0;
2958 opcode
&= ~ (3 << 8);
2959 num
= evaluate_absolute (&the_insn
);
2960 if ((a
== 1 && num
< 0) || (a
== 0 && num
> 0))
2964 CHECK_FIELD (num
, 8191, -8192, 0);
2969 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
2976 /* Handle 14 bit immediated, shifted left three times. */
2978 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2981 if (the_insn
.exp
.X_op
== O_constant
)
2983 num
= evaluate_absolute (&the_insn
);
2986 CHECK_FIELD (num
, 8191, -8192, 0);
2991 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 4);
2995 if (is_DP_relative (the_insn
.exp
))
2996 the_insn
.reloc
= R_HPPA_GOTOFF
;
2997 else if (is_PC_relative (the_insn
.exp
))
2998 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3000 the_insn
.reloc
= R_HPPA
;
3001 the_insn
.format
= 14;
3006 /* Handle 14 bit immediate, shifted left twice. */
3008 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3011 if (the_insn
.exp
.X_op
== O_constant
)
3013 num
= evaluate_absolute (&the_insn
);
3016 CHECK_FIELD (num
, 8191, -8192, 0);
3021 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3025 if (is_DP_relative (the_insn
.exp
))
3026 the_insn
.reloc
= R_HPPA_GOTOFF
;
3027 else if (is_PC_relative (the_insn
.exp
))
3028 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3030 the_insn
.reloc
= R_HPPA
;
3031 the_insn
.format
= 14;
3035 /* Handle a 14 bit immediate at 31. */
3037 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3040 if (the_insn
.exp
.X_op
== O_constant
)
3042 num
= evaluate_absolute (&the_insn
);
3043 CHECK_FIELD (num
, 8191, -8192, 0);
3044 low_sign_unext (num
, 14, &num
);
3045 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3049 if (is_DP_relative (the_insn
.exp
))
3050 the_insn
.reloc
= R_HPPA_GOTOFF
;
3051 else if (is_PC_relative (the_insn
.exp
))
3052 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3054 the_insn
.reloc
= R_HPPA
;
3055 the_insn
.format
= 14;
3059 /* Handle a 21 bit immediate at 31. */
3061 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3064 if (the_insn
.exp
.X_op
== O_constant
)
3066 num
= evaluate_absolute (&the_insn
);
3067 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
3068 dis_assemble_21 (num
, &num
);
3069 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3073 if (is_DP_relative (the_insn
.exp
))
3074 the_insn
.reloc
= R_HPPA_GOTOFF
;
3075 else if (is_PC_relative (the_insn
.exp
))
3076 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3078 the_insn
.reloc
= R_HPPA
;
3079 the_insn
.format
= 21;
3083 /* Handle a 12 bit branch displacement. */
3085 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3089 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
3091 unsigned int w1
, w
, result
;
3093 num
= evaluate_absolute (&the_insn
);
3096 as_bad (_("Branch to unaligned address"));
3099 CHECK_FIELD (num
, 8199, -8184, 0);
3100 sign_unext ((num
- 8) >> 2, 12, &result
);
3101 dis_assemble_12 (result
, &w1
, &w
);
3102 INSERT_FIELD_AND_CONTINUE (opcode
, ((w1
<< 2) | w
), 0);
3106 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3107 the_insn
.format
= 12;
3108 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3109 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3114 /* Handle a 17 bit branch displacement. */
3116 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3120 if (!the_insn
.exp
.X_add_symbol
3121 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3124 unsigned int w2
, w1
, w
, result
;
3126 num
= evaluate_absolute (&the_insn
);
3129 as_bad (_("Branch to unaligned address"));
3132 CHECK_FIELD (num
, 262143, -262144, 0);
3134 if (the_insn
.exp
.X_add_symbol
)
3137 sign_unext (num
>> 2, 17, &result
);
3138 dis_assemble_17 (result
, &w1
, &w2
, &w
);
3139 INSERT_FIELD_AND_CONTINUE (opcode
,
3140 ((w2
<< 2) | (w1
<< 16) | w
), 0);
3144 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3145 the_insn
.format
= 17;
3146 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3147 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3151 /* Handle a 22 bit branch displacement. */
3153 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3157 if (!the_insn
.exp
.X_add_symbol
3158 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3161 unsigned int w3
, w2
, w1
, w
, result
;
3163 num
= evaluate_absolute (&the_insn
);
3166 as_bad (_("Branch to unaligned address"));
3169 CHECK_FIELD (num
, 8388607, -8388608, 0);
3171 if (the_insn
.exp
.X_add_symbol
)
3174 sign_unext (num
>> 2, 22, &result
);
3175 dis_assemble_22 (result
, &w3
, &w1
, &w2
, &w
);
3176 INSERT_FIELD_AND_CONTINUE (opcode
,
3177 ((w3
<< 21) | (w2
<< 2)
3183 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3184 the_insn
.format
= 22;
3185 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3186 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3190 /* Handle an absolute 17 bit branch target. */
3192 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3196 if (!the_insn
.exp
.X_add_symbol
3197 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3200 unsigned int w2
, w1
, w
, result
;
3202 num
= evaluate_absolute (&the_insn
);
3205 as_bad (_("Branch to unaligned address"));
3208 CHECK_FIELD (num
, 262143, -262144, 0);
3210 if (the_insn
.exp
.X_add_symbol
)
3213 sign_unext (num
>> 2, 17, &result
);
3214 dis_assemble_17 (result
, &w1
, &w2
, &w
);
3215 INSERT_FIELD_AND_CONTINUE (opcode
,
3216 ((w2
<< 2) | (w1
<< 16) | w
), 0);
3220 the_insn
.reloc
= R_HPPA_ABS_CALL
;
3221 the_insn
.format
= 17;
3222 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3223 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3227 /* Handle '%r1' implicit operand of addil instruction. */
3229 if (*s
== ',' && *(s
+ 1) == '%' && *(s
+ 3) == '1'
3230 && (*(s
+ 2) == 'r' || *(s
+ 2) == 'R'))
3238 /* Handle '%sr0,%r31' implicit operand of be,l instruction. */
3240 if (strncasecmp (s
, "%sr0,%r31", 9) != 0)
3245 /* Handle immediate value of 0 for ordered load/store instructions. */
3252 /* Handle a 2 bit shift count at 25. */
3254 num
= pa_get_absolute_expression (&the_insn
, &s
);
3255 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3258 CHECK_FIELD (num
, 3, 1, strict
);
3259 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3261 /* Handle a 4 bit shift count at 25. */
3263 num
= pa_get_absolute_expression (&the_insn
, &s
);
3264 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3267 CHECK_FIELD (num
, 15, 0, strict
);
3268 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3270 /* Handle a 5 bit shift count at 26. */
3272 num
= pa_get_absolute_expression (&the_insn
, &s
);
3273 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3276 CHECK_FIELD (num
, 31, 0, strict
);
3277 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
3279 /* Handle a 6 bit shift count at 20,22:26. */
3281 num
= pa_get_absolute_expression (&the_insn
, &s
);
3282 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3285 CHECK_FIELD (num
, 63, 0, strict
);
3287 opcode
|= (num
& 0x20) << 6;
3288 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3290 /* Handle a 6 bit field length at 23,27:31. */
3293 num
= pa_get_absolute_expression (&the_insn
, &s
);
3294 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3297 CHECK_FIELD (num
, 64, 1, strict
);
3299 opcode
|= (num
& 0x20) << 3;
3300 num
= 31 - (num
& 0x1f);
3301 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3303 /* Handle a 6 bit field length at 19,27:31. */
3305 num
= pa_get_absolute_expression (&the_insn
, &s
);
3306 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3309 CHECK_FIELD (num
, 64, 1, strict
);
3311 opcode
|= (num
& 0x20) << 7;
3312 num
= 31 - (num
& 0x1f);
3313 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3315 /* Handle a 5 bit bit position at 26. */
3317 num
= pa_get_absolute_expression (&the_insn
, &s
);
3318 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3321 CHECK_FIELD (num
, 31, 0, strict
);
3322 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
3324 /* Handle a 6 bit bit position at 20,22:26. */
3326 num
= pa_get_absolute_expression (&the_insn
, &s
);
3327 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3330 CHECK_FIELD (num
, 63, 0, strict
);
3331 opcode
|= (num
& 0x20) << 6;
3332 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3334 /* Handle a 5 bit immediate at 10 with 'd' as the complement
3335 of the high bit of the immediate. */
3337 num
= pa_get_absolute_expression (&the_insn
, &s
);
3338 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3341 CHECK_FIELD (num
, 63, 0, strict
);
3345 opcode
|= (1 << 13);
3346 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 21);
3348 /* Handle a 5 bit immediate at 10. */
3350 num
= pa_get_absolute_expression (&the_insn
, &s
);
3351 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3353 if (the_insn
.exp
.X_op
!= O_constant
)
3356 CHECK_FIELD (num
, 31, 0, strict
);
3357 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3359 /* Handle a 9 bit immediate at 28. */
3361 num
= pa_get_absolute_expression (&the_insn
, &s
);
3362 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3365 CHECK_FIELD (num
, 511, 1, strict
);
3366 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3368 /* Handle a 13 bit immediate at 18. */
3370 num
= pa_get_absolute_expression (&the_insn
, &s
);
3371 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3374 CHECK_FIELD (num
, 8191, 0, strict
);
3375 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
3377 /* Handle a 26 bit immediate at 31. */
3379 num
= pa_get_absolute_expression (&the_insn
, &s
);
3380 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3383 CHECK_FIELD (num
, 671108864, 0, strict
);
3384 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3386 /* Handle a 3 bit SFU identifier at 25. */
3389 as_bad (_("Invalid SFU identifier"));
3390 num
= pa_get_absolute_expression (&the_insn
, &s
);
3391 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3394 CHECK_FIELD (num
, 7, 0, strict
);
3395 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3397 /* Handle a 20 bit SOP field for spop0. */
3399 num
= pa_get_absolute_expression (&the_insn
, &s
);
3400 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3403 CHECK_FIELD (num
, 1048575, 0, strict
);
3404 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
3405 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3407 /* Handle a 15bit SOP field for spop1. */
3409 num
= pa_get_absolute_expression (&the_insn
, &s
);
3410 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3413 CHECK_FIELD (num
, 32767, 0, strict
);
3414 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
3416 /* Handle a 10bit SOP field for spop3. */
3418 num
= pa_get_absolute_expression (&the_insn
, &s
);
3419 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3422 CHECK_FIELD (num
, 1023, 0, strict
);
3423 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
3424 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3426 /* Handle a 15 bit SOP field for spop2. */
3428 num
= pa_get_absolute_expression (&the_insn
, &s
);
3429 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3432 CHECK_FIELD (num
, 32767, 0, strict
);
3433 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
3434 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3436 /* Handle a 3-bit co-processor ID field. */
3439 as_bad (_("Invalid COPR identifier"));
3440 num
= pa_get_absolute_expression (&the_insn
, &s
);
3441 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3444 CHECK_FIELD (num
, 7, 0, strict
);
3445 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3447 /* Handle a 22bit SOP field for copr. */
3449 num
= pa_get_absolute_expression (&the_insn
, &s
);
3450 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3453 CHECK_FIELD (num
, 4194303, 0, strict
);
3454 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
3455 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3457 /* Handle a source FP operand format completer. */
3459 if (*s
== ',' && *(s
+1) == 't')
3466 flag
= pa_parse_fp_cnv_format (&s
);
3467 the_insn
.fpof1
= flag
;
3468 if (flag
== W
|| flag
== UW
)
3470 if (flag
== DW
|| flag
== UDW
)
3472 if (flag
== QW
|| flag
== UQW
)
3474 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3476 /* Handle a destination FP operand format completer. */
3478 /* pa_parse_format needs the ',' prefix. */
3480 flag
= pa_parse_fp_cnv_format (&s
);
3481 the_insn
.fpof2
= flag
;
3482 if (flag
== W
|| flag
== UW
)
3484 if (flag
== DW
|| flag
== UDW
)
3486 if (flag
== QW
|| flag
== UQW
)
3488 opcode
|= flag
<< 13;
3489 if (the_insn
.fpof1
== SGL
3490 || the_insn
.fpof1
== DBL
3491 || the_insn
.fpof1
== QUAD
)
3493 if (the_insn
.fpof2
== SGL
3494 || the_insn
.fpof2
== DBL
3495 || the_insn
.fpof2
== QUAD
)
3497 else if (the_insn
.fpof2
== W
3498 || the_insn
.fpof2
== DW
3499 || the_insn
.fpof2
== QW
)
3501 else if (the_insn
.fpof2
== UW
3502 || the_insn
.fpof2
== UDW
3503 || the_insn
.fpof2
== UQW
)
3508 else if (the_insn
.fpof1
== W
3509 || the_insn
.fpof1
== DW
3510 || the_insn
.fpof1
== QW
)
3512 if (the_insn
.fpof2
== SGL
3513 || the_insn
.fpof2
== DBL
3514 || the_insn
.fpof2
== QUAD
)
3519 else if (the_insn
.fpof1
== UW
3520 || the_insn
.fpof1
== UDW
3521 || the_insn
.fpof1
== UQW
)
3523 if (the_insn
.fpof2
== SGL
3524 || the_insn
.fpof2
== DBL
3525 || the_insn
.fpof2
== QUAD
)
3530 flag
|= the_insn
.trunc
;
3531 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 15);
3533 /* Handle a source FP operand format completer. */
3535 flag
= pa_parse_fp_format (&s
);
3536 the_insn
.fpof1
= flag
;
3537 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3539 /* Handle a destination FP operand format completer. */
3541 /* pa_parse_format needs the ',' prefix. */
3543 flag
= pa_parse_fp_format (&s
);
3544 the_insn
.fpof2
= flag
;
3545 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
3547 /* Handle a source FP operand format completer at 20. */
3549 flag
= pa_parse_fp_format (&s
);
3550 the_insn
.fpof1
= flag
;
3551 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3553 /* Handle a floating point operand format at 26.
3554 Only allows single and double precision. */
3556 flag
= pa_parse_fp_format (&s
);
3562 the_insn
.fpof1
= flag
;
3568 as_bad (_("Invalid Floating Point Operand Format."));
3572 /* Handle all floating point registers. */
3576 /* Float target register. */
3578 /* This should be more strict. Small steps. */
3579 if (strict
&& *s
!= '%')
3581 num
= pa_parse_number (&s
, 0);
3582 CHECK_FIELD (num
, 31, 0, 0);
3583 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3585 /* Float target register with L/R selection. */
3588 struct pa_11_fp_reg_struct result
;
3590 /* This should be more strict. Small steps. */
3591 if (strict
&& *s
!= '%')
3593 pa_parse_number (&s
, &result
);
3594 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3595 opcode
|= result
.number_part
;
3597 /* 0x30 opcodes are FP arithmetic operation opcodes
3598 and need to be turned into 0x38 opcodes. This
3599 is not necessary for loads/stores. */
3600 if (need_pa11_opcode (&the_insn
, &result
)
3601 && ((opcode
& 0xfc000000) == 0x30000000))
3604 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
3607 /* Float operand 1. */
3610 struct pa_11_fp_reg_struct result
;
3612 /* This should be more strict. Small steps. */
3613 if (strict
&& *s
!= '%')
3615 pa_parse_number (&s
, &result
);
3616 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3617 opcode
|= result
.number_part
<< 21;
3618 if (need_pa11_opcode (&the_insn
, &result
))
3620 opcode
|= (result
.l_r_select
& 1) << 7;
3626 /* Float operand 1 with L/R selection. */
3630 struct pa_11_fp_reg_struct result
;
3632 /* This should be more strict. Small steps. */
3633 if (strict
&& *s
!= '%')
3635 pa_parse_number (&s
, &result
);
3636 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3637 opcode
|= result
.number_part
<< 21;
3638 opcode
|= (result
.l_r_select
& 1) << 7;
3642 /* Float operand 2. */
3645 struct pa_11_fp_reg_struct result
;
3647 /* This should be more strict. Small steps. */
3648 if (strict
&& *s
!= '%')
3650 pa_parse_number (&s
, &result
);
3651 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3652 opcode
|= (result
.number_part
& 0x1f) << 16;
3653 if (need_pa11_opcode (&the_insn
, &result
))
3655 opcode
|= (result
.l_r_select
& 1) << 12;
3661 /* Float operand 2 with L/R selection. */
3664 struct pa_11_fp_reg_struct result
;
3666 /* This should be more strict. Small steps. */
3667 if (strict
&& *s
!= '%')
3669 pa_parse_number (&s
, &result
);
3670 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3671 opcode
|= (result
.number_part
& 0x1f) << 16;
3672 opcode
|= (result
.l_r_select
& 1) << 12;
3676 /* Float operand 3 for fmpyfadd, fmpynfadd. */
3679 struct pa_11_fp_reg_struct result
;
3681 /* This should be more strict. Small steps. */
3682 if (strict
&& *s
!= '%')
3684 pa_parse_number (&s
, &result
);
3685 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3686 opcode
|= (result
.number_part
& 0x1c) << 11;
3687 opcode
|= (result
.number_part
& 0x3) << 9;
3688 opcode
|= (result
.l_r_select
& 1) << 8;
3692 /* Float mult operand 1 for fmpyadd, fmpysub */
3695 struct pa_11_fp_reg_struct result
;
3697 /* This should be more strict. Small steps. */
3698 if (strict
&& *s
!= '%')
3700 pa_parse_number (&s
, &result
);
3701 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3702 if (the_insn
.fpof1
== SGL
)
3704 if (result
.number_part
< 16)
3706 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3710 result
.number_part
&= 0xF;
3711 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3713 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
3716 /* Float mult operand 2 for fmpyadd, fmpysub */
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 if (the_insn
.fpof1
== SGL
)
3728 if (result
.number_part
< 16)
3730 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3733 result
.number_part
&= 0xF;
3734 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3736 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
3739 /* Float mult target for fmpyadd, fmpysub */
3742 struct pa_11_fp_reg_struct result
;
3744 /* This should be more strict. Small steps. */
3745 if (strict
&& *s
!= '%')
3747 pa_parse_number (&s
, &result
);
3748 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3749 if (the_insn
.fpof1
== SGL
)
3751 if (result
.number_part
< 16)
3753 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3756 result
.number_part
&= 0xF;
3757 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3759 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
3762 /* Float add operand 1 for fmpyadd, fmpysub */
3765 struct pa_11_fp_reg_struct result
;
3767 /* This should be more strict. Small steps. */
3768 if (strict
&& *s
!= '%')
3770 pa_parse_number (&s
, &result
);
3771 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3772 if (the_insn
.fpof1
== SGL
)
3774 if (result
.number_part
< 16)
3776 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3779 result
.number_part
&= 0xF;
3780 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3782 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
3785 /* Float add target for fmpyadd, fmpysub */
3788 struct pa_11_fp_reg_struct result
;
3790 /* This should be more strict. Small steps. */
3791 if (strict
&& *s
!= '%')
3793 pa_parse_number (&s
, &result
);
3794 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3795 if (the_insn
.fpof1
== SGL
)
3797 if (result
.number_part
< 16)
3799 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3802 result
.number_part
&= 0xF;
3803 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3805 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
3808 /* Handle L/R register halves like 'x'. */
3811 struct pa_11_fp_reg_struct result
;
3813 if (strict
&& *s
!= '%')
3815 pa_parse_number (&s
, &result
);
3816 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3817 opcode
|= (result
.number_part
& 0x1f) << 16;
3818 if (need_pa11_opcode (&the_insn
, &result
))
3820 opcode
|= (result
.l_r_select
& 1) << 1;
3836 /* Check if the args matched. */
3839 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
3840 && !strcmp (insn
->name
, insn
[1].name
))
3848 as_bad (_("Invalid operands %s"), error_message
);
3855 the_insn
.opcode
= opcode
;
3858 /* Turn a string in input_line_pointer into a floating point constant of type
3859 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
3860 emitted is stored in *sizeP . An error message or NULL is returned. */
3862 #define MAX_LITTLENUMS 6
3865 md_atof (type
, litP
, sizeP
)
3871 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
3872 LITTLENUM_TYPE
*wordP
;
3904 return _("Bad call to MD_ATOF()");
3906 t
= atof_ieee (input_line_pointer
, type
, words
);
3908 input_line_pointer
= t
;
3909 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
3910 for (wordP
= words
; prec
--;)
3912 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
3913 litP
+= sizeof (LITTLENUM_TYPE
);
3918 /* Write out big-endian. */
3921 md_number_to_chars (buf
, val
, n
)
3926 number_to_chars_bigendian (buf
, val
, n
);
3929 /* Translate internal representation of relocation info to BFD target
3933 tc_gen_reloc (section
, fixp
)
3938 struct hppa_fix_struct
*hppa_fixp
;
3939 bfd_reloc_code_real_type code
;
3940 static arelent
*no_relocs
= NULL
;
3942 bfd_reloc_code_real_type
**codes
;
3946 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
3947 if (fixp
->fx_addsy
== 0)
3949 assert (hppa_fixp
!= 0);
3950 assert (section
!= 0);
3952 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
3954 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3955 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3956 codes
= (bfd_reloc_code_real_type
**) hppa_gen_reloc_type (stdoutput
,
3958 hppa_fixp
->fx_r_format
,
3959 hppa_fixp
->fx_r_field
,
3960 fixp
->fx_subsy
!= NULL
,
3961 symbol_get_bfdsym (fixp
->fx_addsy
));
3966 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
3969 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
3970 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
3971 for (i
= 0; i
< n_relocs
; i
++)
3972 relocs
[i
] = &reloc
[i
];
3974 relocs
[n_relocs
] = NULL
;
3977 switch (fixp
->fx_r_type
)
3980 assert (n_relocs
== 1);
3984 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3985 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3986 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
3987 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3988 reloc
->addend
= 0; /* default */
3990 assert (reloc
->howto
&& code
== reloc
->howto
->type
);
3992 /* Now, do any processing that is dependent on the relocation type. */
3995 case R_PARISC_DLTREL21L
:
3996 case R_PARISC_DLTREL14R
:
3997 case R_PARISC_DLTREL14F
:
3998 case R_PARISC_PLABEL32
:
3999 case R_PARISC_PLABEL21L
:
4000 case R_PARISC_PLABEL14R
:
4001 /* For plabel relocations, the addend of the
4002 relocation should be either 0 (no static link) or 2
4003 (static link required).
4005 FIXME: We always assume no static link!
4007 We also slam a zero addend into the DLT relative relocs;
4008 it doesn't make a lot of sense to use any addend since
4009 it gets you a different (eg unknown) DLT entry. */
4013 case R_PARISC_PCREL21L
:
4014 case R_PARISC_PCREL17R
:
4015 case R_PARISC_PCREL17F
:
4016 case R_PARISC_PCREL17C
:
4017 case R_PARISC_PCREL14R
:
4018 case R_PARISC_PCREL14F
:
4019 /* The constant is stored in the instruction. */
4020 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
4023 reloc
->addend
= fixp
->fx_offset
;
4030 /* Walk over reach relocation returned by the BFD backend. */
4031 for (i
= 0; i
< n_relocs
; i
++)
4035 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4036 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4037 relocs
[i
]->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
4038 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4043 /* The only time we ever use a R_COMP2 fixup is for the difference
4044 of two symbols. With that in mind we fill in all four
4045 relocs now and break out of the loop. */
4047 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4048 relocs
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[0]);
4049 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4050 relocs
[0]->addend
= 0;
4051 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4052 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4053 relocs
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[1]);
4054 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4055 relocs
[1]->addend
= 0;
4056 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4057 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
4058 relocs
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[2]);
4059 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4060 relocs
[2]->addend
= 0;
4061 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4062 relocs
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[3]);
4063 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4064 relocs
[3]->addend
= 0;
4065 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4066 relocs
[4]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[4]);
4067 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4068 relocs
[4]->addend
= 0;
4072 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
4078 /* For plabel relocations, the addend of the
4079 relocation should be either 0 (no static link) or 2
4080 (static link required).
4082 FIXME: We always assume no static link!
4084 We also slam a zero addend into the DLT relative relocs;
4085 it doesn't make a lot of sense to use any addend since
4086 it gets you a different (eg unknown) DLT entry. */
4087 relocs
[i
]->addend
= 0;
4102 /* There is no symbol or addend associated with these fixups. */
4103 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4104 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4105 relocs
[i
]->addend
= 0;
4111 /* There is no symbol associated with these fixups. */
4112 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4113 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4114 relocs
[i
]->addend
= fixp
->fx_offset
;
4118 relocs
[i
]->addend
= fixp
->fx_offset
;
4128 /* Process any machine dependent frag types. */
4131 md_convert_frag (abfd
, sec
, fragP
)
4133 register asection
*sec
;
4134 register fragS
*fragP
;
4136 unsigned int address
;
4138 if (fragP
->fr_type
== rs_machine_dependent
)
4140 switch ((int) fragP
->fr_subtype
)
4143 fragP
->fr_type
= rs_fill
;
4144 know (fragP
->fr_var
== 1);
4145 know (fragP
->fr_next
);
4146 address
= fragP
->fr_address
+ fragP
->fr_fix
;
4147 if (address
% fragP
->fr_offset
)
4150 fragP
->fr_next
->fr_address
4155 fragP
->fr_offset
= 0;
4161 /* Round up a section size to the appropriate boundary. */
4164 md_section_align (segment
, size
)
4168 int align
= bfd_get_section_alignment (stdoutput
, segment
);
4169 int align2
= (1 << align
) - 1;
4171 return (size
+ align2
) & ~align2
;
4174 /* Return the approximate size of a frag before relaxation has occurred. */
4176 md_estimate_size_before_relax (fragP
, segment
)
4177 register fragS
*fragP
;
4184 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
4190 CONST
char *md_shortopts
= "";
4191 struct option md_longopts
[] = {
4192 {NULL
, no_argument
, NULL
, 0}
4194 size_t md_longopts_size
= sizeof(md_longopts
);
4197 md_parse_option (c
, arg
)
4205 md_show_usage (stream
)
4210 /* We have no need to default values of symbols. */
4213 md_undefined_symbol (name
)
4219 /* Apply a fixup to an instruction. */
4222 md_apply_fix (fixP
, valp
)
4226 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
4227 struct hppa_fix_struct
*hppa_fixP
;
4228 long new_val
, result
= 0;
4229 unsigned int w1
, w2
, w
, resulti
;
4231 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
4232 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
4233 never be "applied" (they are just markers). Likewise for
4234 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
4236 if (fixP
->fx_r_type
== R_HPPA_ENTRY
4237 || fixP
->fx_r_type
== R_HPPA_EXIT
4238 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
4239 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
4240 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
4243 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
4244 fixups are considered not adjustable, which in turn causes
4245 adjust_reloc_syms to not set fx_offset. Ugh. */
4246 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
4248 fixP
->fx_offset
= *valp
;
4253 /* There should have been an HPPA specific fixup associated
4254 with the GAS fixup. */
4257 unsigned long buf_wd
= bfd_get_32 (stdoutput
, buf
);
4258 int fmt
= bfd_hppa_insn2fmt (buf_wd
);
4260 /* If there is a symbol associated with this fixup, then it's something
4261 which will need a SOM relocation (except for some PC-relative relocs).
4262 In such cases we should treat the "val" or "addend" as zero since it
4263 will be added in as needed from fx_offset in tc_gen_reloc. */
4264 if ((fixP
->fx_addsy
!= NULL
4265 || fixP
->fx_r_type
== R_HPPA_NONE
)
4270 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4272 /* These field selectors imply that we do not want an addend. */
4273 else if (hppa_fixP
->fx_r_field
== e_psel
4274 || hppa_fixP
->fx_r_field
== e_rpsel
4275 || hppa_fixP
->fx_r_field
== e_lpsel
4276 || hppa_fixP
->fx_r_field
== e_tsel
4277 || hppa_fixP
->fx_r_field
== e_rtsel
4278 || hppa_fixP
->fx_r_field
== e_ltsel
)
4279 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4280 /* This is truely disgusting. The machine independent code blindly
4281 adds in the value of the symbol being relocated against. Damn! */
4283 && fixP
->fx_addsy
!= NULL
4284 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
4285 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
4286 0, hppa_fixP
->fx_r_field
);
4289 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4291 /* Handle pc-relative exceptions from above. */
4292 #define arg_reloc_stub_needed(CALLER, CALLEE) \
4293 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
4294 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
4298 && !arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
4299 symbol_get_bfdsym (fixP
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
4300 hppa_fixP
->fx_arg_reloc
)
4302 && (((int)(*valp
) > -262144 && (int)(*valp
) < 262143) && fmt
!= 22)
4303 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
4305 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
4307 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4308 #undef arg_reloc_stub_needed
4312 /* Handle all opcodes with the 'j' operand type. */
4314 CHECK_FIELD (new_val
, 8191, -8192, 0);
4316 /* Mask off 14 bits to be changed. */
4317 bfd_put_32 (stdoutput
,
4318 bfd_get_32 (stdoutput
, buf
) & 0xffffc000,
4320 low_sign_unext (new_val
, 14, &resulti
);
4324 /* Handle all opcodes with the 'k' operand type. */
4326 CHECK_FIELD (new_val
, 2097152, 0, 0);
4328 /* Mask off 21 bits to be changed. */
4329 bfd_put_32 (stdoutput
,
4330 bfd_get_32 (stdoutput
, buf
) & 0xffe00000,
4332 dis_assemble_21 (new_val
, &resulti
);
4336 /* Handle all the opcodes with the 'i' operand type. */
4338 CHECK_FIELD (new_val
, 1023, -1023, 0);
4340 /* Mask off 11 bits to be changed. */
4341 bfd_put_32 (stdoutput
,
4342 bfd_get_32 (stdoutput
, buf
) & 0xffff800,
4344 low_sign_unext (new_val
, 11, &resulti
);
4348 /* Handle all the opcodes with the 'w' operand type. */
4350 CHECK_FIELD (new_val
, 8199, -8184, 0);
4352 /* Mask off 11 bits to be changed. */
4353 sign_unext ((new_val
- 8) >> 2, 12, &resulti
);
4354 bfd_put_32 (stdoutput
,
4355 bfd_get_32 (stdoutput
, buf
) & 0xffffe002,
4358 dis_assemble_12 (resulti
, &w1
, &w
);
4359 result
= ((w1
<< 2) | w
);
4362 /* Handle some of the opcodes with the 'W' operand type. */
4365 int distance
= *valp
;
4367 CHECK_FIELD (new_val
, 262143, -262144, 0);
4369 /* If this is an absolute branch (ie no link) with an out of
4370 range target, then we want to complain. */
4371 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
4372 && (distance
> 262143 || distance
< -262144)
4373 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
4374 CHECK_FIELD (distance
, 262143, -262144, 0);
4376 /* Mask off 17 bits to be changed. */
4377 bfd_put_32 (stdoutput
,
4378 bfd_get_32 (stdoutput
, buf
) & 0xffe0e002,
4380 sign_unext ((new_val
- 8) >> 2, 17, &resulti
);
4381 dis_assemble_17 (resulti
, &w1
, &w2
, &w
);
4382 result
= ((w2
<< 2) | (w1
<< 16) | w
);
4388 int distance
= *valp
, w3
;
4390 CHECK_FIELD (new_val
, 8388607, -8388608, 0);
4392 /* If this is an absolute branch (ie no link) with an out of
4393 range target, then we want to complain. */
4394 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
4395 && (distance
> 8388607 || distance
< -8388608)
4396 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
4397 CHECK_FIELD (distance
, 8388607, -8388608, 0);
4399 /* Mask off 22 bits to be changed. */
4400 bfd_put_32 (stdoutput
,
4401 bfd_get_32 (stdoutput
, buf
) & 0xfc00e002,
4403 sign_unext ((new_val
- 8) >> 2, 22, &resulti
);
4404 dis_assemble_22 (resulti
, &w3
, &w1
, &w2
, &w
);
4405 result
= ((w3
<< 21) | (w2
<< 2) | (w1
<< 16) | w
);
4411 bfd_put_32 (stdoutput
, new_val
, buf
);
4415 as_bad (_("Unknown relocation encountered in md_apply_fix."));
4419 /* Insert the relocation. */
4420 bfd_put_32 (stdoutput
, bfd_get_32 (stdoutput
, buf
) | result
, buf
);
4425 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
4426 (unsigned int) fixP
, fixP
->fx_r_type
);
4431 /* Exactly what point is a PC-relative offset relative TO?
4432 On the PA, they're relative to the address of the offset. */
4435 md_pcrel_from (fixP
)
4438 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
4441 /* Return nonzero if the input line pointer is at the end of
4445 is_end_of_statement ()
4447 return ((*input_line_pointer
== '\n')
4448 || (*input_line_pointer
== ';')
4449 || (*input_line_pointer
== '!'));
4452 /* Read a number from S. The number might come in one of many forms,
4453 the most common will be a hex or decimal constant, but it could be
4454 a pre-defined register (Yuk!), or an absolute symbol.
4456 Return a number or -1 for failure.
4458 When parsing PA-89 FP register numbers RESULT will be
4459 the address of a structure to return information about
4460 L/R half of FP registers, store results there as appropriate.
4462 pa_parse_number can not handle negative constants and will fail
4463 horribly if it is passed such a constant. */
4466 pa_parse_number (s
, result
)
4468 struct pa_11_fp_reg_struct
*result
;
4477 /* Skip whitespace before the number. */
4478 while (*p
== ' ' || *p
== '\t')
4481 /* Store info in RESULT if requested by caller. */
4484 result
->number_part
= -1;
4485 result
->l_r_select
= -1;
4491 /* Looks like a number. */
4494 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
4496 /* The number is specified in hex. */
4498 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
4499 || ((*p
>= 'A') && (*p
<= 'F')))
4502 num
= num
* 16 + *p
- '0';
4503 else if (*p
>= 'a' && *p
<= 'f')
4504 num
= num
* 16 + *p
- 'a' + 10;
4506 num
= num
* 16 + *p
- 'A' + 10;
4512 /* The number is specified in decimal. */
4513 while (isdigit (*p
))
4515 num
= num
* 10 + *p
- '0';
4520 /* Store info in RESULT if requested by the caller. */
4523 result
->number_part
= num
;
4525 if (IS_R_SELECT (p
))
4527 result
->l_r_select
= 1;
4530 else if (IS_L_SELECT (p
))
4532 result
->l_r_select
= 0;
4536 result
->l_r_select
= 0;
4541 /* The number might be a predefined register. */
4546 /* Tege hack: Special case for general registers as the general
4547 code makes a binary search with case translation, and is VERY
4552 if (*p
== 'e' && *(p
+ 1) == 't'
4553 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
4556 num
= *p
- '0' + 28;
4564 else if (!isdigit (*p
))
4567 as_bad (_("Undefined register: '%s'."), name
);
4573 num
= num
* 10 + *p
++ - '0';
4574 while (isdigit (*p
));
4579 /* Do a normal register search. */
4580 while (is_part_of_name (c
))
4586 status
= reg_name_search (name
);
4592 as_bad (_("Undefined register: '%s'."), name
);
4598 /* Store info in RESULT if requested by caller. */
4601 result
->number_part
= num
;
4602 if (IS_R_SELECT (p
- 1))
4603 result
->l_r_select
= 1;
4604 else if (IS_L_SELECT (p
- 1))
4605 result
->l_r_select
= 0;
4607 result
->l_r_select
= 0;
4612 /* And finally, it could be a symbol in the absolute section which
4613 is effectively a constant. */
4617 while (is_part_of_name (c
))
4623 if ((sym
= symbol_find (name
)) != NULL
)
4625 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
4626 num
= S_GET_VALUE (sym
);
4630 as_bad (_("Non-absolute symbol: '%s'."), name
);
4636 /* There is where we'd come for an undefined symbol
4637 or for an empty string. For an empty string we
4638 will return zero. That's a concession made for
4639 compatability with the braindamaged HP assemblers. */
4645 as_bad (_("Undefined absolute constant: '%s'."), name
);
4651 /* Store info in RESULT if requested by caller. */
4654 result
->number_part
= num
;
4655 if (IS_R_SELECT (p
- 1))
4656 result
->l_r_select
= 1;
4657 else if (IS_L_SELECT (p
- 1))
4658 result
->l_r_select
= 0;
4660 result
->l_r_select
= 0;
4668 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
4670 /* Given NAME, find the register number associated with that name, return
4671 the integer value associated with the given name or -1 on failure. */
4674 reg_name_search (name
)
4677 int middle
, low
, high
;
4681 high
= REG_NAME_CNT
- 1;
4685 middle
= (low
+ high
) / 2;
4686 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
4692 return pre_defined_registers
[middle
].value
;
4694 while (low
<= high
);
4700 /* Return nonzero if the given INSN and L/R information will require
4701 a new PA-1.1 opcode. */
4704 need_pa11_opcode (insn
, result
)
4706 struct pa_11_fp_reg_struct
*result
;
4708 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
4710 /* If this instruction is specific to a particular architecture,
4711 then set a new architecture. */
4712 if (bfd_get_mach (stdoutput
) < pa11
)
4714 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
4715 as_warn (_("could not update architecture and machine"));
4723 /* Parse a condition for a fcmp instruction. Return the numerical
4724 code associated with the condition. */
4727 pa_parse_fp_cmp_cond (s
)
4734 for (i
= 0; i
< 32; i
++)
4736 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
4737 strlen (fp_cond_map
[i
].string
)) == 0)
4739 cond
= fp_cond_map
[i
].cond
;
4740 *s
+= strlen (fp_cond_map
[i
].string
);
4741 /* If not a complete match, back up the input string and
4743 if (**s
!= ' ' && **s
!= '\t')
4745 *s
-= strlen (fp_cond_map
[i
].string
);
4748 while (**s
== ' ' || **s
== '\t')
4754 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
4756 /* Advance over the bogus completer. */
4757 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4763 /* Parse a graphics test complete for ftest. */
4766 pa_parse_ftest_gfx_completer (s
)
4772 if (strncasecmp (*s
, "acc8", 4) == 0)
4777 else if (strncasecmp (*s
, "acc6", 4) == 0)
4782 else if (strncasecmp (*s
, "acc4", 4) == 0)
4787 else if (strncasecmp (*s
, "acc2", 4) == 0)
4792 else if (strncasecmp (*s
, "acc", 3) == 0)
4797 else if (strncasecmp (*s
, "rej8", 4) == 0)
4802 else if (strncasecmp (*s
, "rej", 3) == 0)
4810 as_bad (_("Invalid FTEST completer: %s"), *s
);
4816 /* Parse an FP operand format completer returning the completer
4819 static fp_operand_format
4820 pa_parse_fp_cnv_format (s
)
4829 if (strncasecmp (*s
, "sgl", 3) == 0)
4834 else if (strncasecmp (*s
, "dbl", 3) == 0)
4839 else if (strncasecmp (*s
, "quad", 4) == 0)
4844 else if (strncasecmp (*s
, "w", 1) == 0)
4849 else if (strncasecmp (*s
, "uw", 2) == 0)
4854 else if (strncasecmp (*s
, "dw", 2) == 0)
4859 else if (strncasecmp (*s
, "udw", 3) == 0)
4864 else if (strncasecmp (*s
, "qw", 2) == 0)
4869 else if (strncasecmp (*s
, "uqw", 3) == 0)
4876 format
= ILLEGAL_FMT
;
4877 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
4884 /* Parse an FP operand format completer returning the completer
4887 static fp_operand_format
4888 pa_parse_fp_format (s
)
4897 if (strncasecmp (*s
, "sgl", 3) == 0)
4902 else if (strncasecmp (*s
, "dbl", 3) == 0)
4907 else if (strncasecmp (*s
, "quad", 4) == 0)
4914 format
= ILLEGAL_FMT
;
4915 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
4922 /* Convert from a selector string into a selector type. */
4925 pa_chk_field_selector (str
)
4928 int middle
, low
, high
;
4932 /* Read past any whitespace. */
4933 /* FIXME: should we read past newlines and formfeeds??? */
4934 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
4937 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
4938 name
[0] = tolower ((*str
)[0]),
4940 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
4941 name
[0] = tolower ((*str
)[0]),
4942 name
[1] = tolower ((*str
)[1]),
4944 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
4945 name
[0] = tolower ((*str
)[0]),
4946 name
[1] = tolower ((*str
)[1]),
4947 name
[2] = tolower ((*str
)[2]),
4953 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
4957 middle
= (low
+ high
) / 2;
4958 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
4965 *str
+= strlen (name
) + 1;
4967 if (selector_table
[middle
].field_selector
== e_nsel
)
4970 return selector_table
[middle
].field_selector
;
4973 while (low
<= high
);
4978 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
4981 get_expression (str
)
4987 save_in
= input_line_pointer
;
4988 input_line_pointer
= str
;
4989 seg
= expression (&the_insn
.exp
);
4990 if (!(seg
== absolute_section
4991 || seg
== undefined_section
4992 || SEG_NORMAL (seg
)))
4994 as_warn (_("Bad segment in expression."));
4995 expr_end
= input_line_pointer
;
4996 input_line_pointer
= save_in
;
4999 expr_end
= input_line_pointer
;
5000 input_line_pointer
= save_in
;
5004 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
5006 pa_get_absolute_expression (insn
, strp
)
5012 insn
->field_selector
= pa_chk_field_selector (strp
);
5013 save_in
= input_line_pointer
;
5014 input_line_pointer
= *strp
;
5015 expression (&insn
->exp
);
5016 /* This is not perfect, but is a huge improvement over doing nothing.
5018 The PA assembly syntax is ambigious in a variety of ways. Consider
5019 this string "4 %r5" Is that the number 4 followed by the register
5020 r5, or is that 4 MOD 5?
5022 If we get a modulo expresion When looking for an absolute, we try
5023 again cutting off the input string at the first whitespace character. */
5024 if (insn
->exp
.X_op
== O_modulus
)
5029 input_line_pointer
= *strp
;
5031 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
5037 retval
= pa_get_absolute_expression (insn
, strp
);
5039 input_line_pointer
= save_in
;
5041 return evaluate_absolute (insn
);
5043 /* When in strict mode we have a non-match, fix up the pointers
5044 and return to our caller. */
5045 if (insn
->exp
.X_op
!= O_constant
&& strict
)
5047 expr_end
= input_line_pointer
;
5048 input_line_pointer
= save_in
;
5051 if (insn
->exp
.X_op
!= O_constant
)
5053 as_bad (_("Bad segment (should be absolute)."));
5054 expr_end
= input_line_pointer
;
5055 input_line_pointer
= save_in
;
5058 expr_end
= input_line_pointer
;
5059 input_line_pointer
= save_in
;
5060 return evaluate_absolute (insn
);
5063 /* Evaluate an absolute expression EXP which may be modified by
5064 the selector FIELD_SELECTOR. Return the value of the expression. */
5066 evaluate_absolute (insn
)
5071 int field_selector
= insn
->field_selector
;
5074 value
= exp
.X_add_number
;
5076 switch (field_selector
)
5082 /* If bit 21 is on then add 0x800 and arithmetic shift right 11 bits. */
5084 if (value
& 0x00000400)
5086 value
= (value
& 0xfffff800) >> 11;
5089 /* Sign extend from bit 21. */
5091 if (value
& 0x00000400)
5092 value
|= 0xfffff800;
5097 /* Arithmetic shift right 11 bits. */
5099 value
= (value
& 0xfffff800) >> 11;
5102 /* Set bits 0-20 to zero. */
5104 value
= value
& 0x7ff;
5107 /* Add 0x800 and arithmetic shift right 11 bits. */
5110 value
= (value
& 0xfffff800) >> 11;
5113 /* Set bitgs 0-21 to one. */
5115 value
|= 0xfffff800;
5118 #define RSEL_ROUND(c) (((c) + 0x1000) & ~0x1fff)
5120 value
= (RSEL_ROUND (value
) & 0x7ff) + (value
- RSEL_ROUND (value
));
5124 value
= (RSEL_ROUND (value
) >> 11) & 0x1fffff;
5129 BAD_CASE (field_selector
);
5135 /* Given an argument location specification return the associated
5136 argument location number. */
5139 pa_build_arg_reloc (type_name
)
5143 if (strncasecmp (type_name
, "no", 2) == 0)
5145 if (strncasecmp (type_name
, "gr", 2) == 0)
5147 else if (strncasecmp (type_name
, "fr", 2) == 0)
5149 else if (strncasecmp (type_name
, "fu", 2) == 0)
5152 as_bad (_("Invalid argument location: %s\n"), type_name
);
5157 /* Encode and return an argument relocation specification for
5158 the given register in the location specified by arg_reloc. */
5161 pa_align_arg_reloc (reg
, arg_reloc
)
5163 unsigned int arg_reloc
;
5165 unsigned int new_reloc
;
5167 new_reloc
= arg_reloc
;
5183 as_bad (_("Invalid argument description: %d"), reg
);
5189 /* Parse a PA nullification completer (,n). Return nonzero if the
5190 completer was found; return zero if no completer was found. */
5202 if (strncasecmp (*s
, "n", 1) == 0)
5206 as_bad (_("Invalid Nullification: (%c)"), **s
);
5215 /* Parse a non-negated compare/subtract completer returning the
5216 number (for encoding in instrutions) of the given completer.
5218 ISBRANCH specifies whether or not this is parsing a condition
5219 completer for a branch (vs a nullification completer for a
5220 computational instruction. */
5223 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
5228 char *name
= *s
+ 1;
5237 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5243 if (strcmp (name
, "=") == 0)
5247 else if (strcmp (name
, "<") == 0)
5251 else if (strcmp (name
, "<=") == 0)
5255 else if (strcmp (name
, "<<") == 0)
5259 else if (strcmp (name
, "<<=") == 0)
5263 else if (strcasecmp (name
, "sv") == 0)
5267 else if (strcasecmp (name
, "od") == 0)
5271 /* If we have something like addb,n then there is no condition
5273 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5285 /* Reset pointers if this was really a ,n for a branch instruction. */
5293 /* Parse a negated compare/subtract completer returning the
5294 number (for encoding in instrutions) of the given completer.
5296 ISBRANCH specifies whether or not this is parsing a condition
5297 completer for a branch (vs a nullification completer for a
5298 computational instruction. */
5301 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
5306 char *name
= *s
+ 1;
5315 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5321 if (strcasecmp (name
, "tr") == 0)
5325 else if (strcmp (name
, "<>") == 0)
5329 else if (strcmp (name
, ">=") == 0)
5333 else if (strcmp (name
, ">") == 0)
5337 else if (strcmp (name
, ">>=") == 0)
5341 else if (strcmp (name
, ">>") == 0)
5345 else if (strcasecmp (name
, "nsv") == 0)
5349 else if (strcasecmp (name
, "ev") == 0)
5353 /* If we have something like addb,n then there is no condition
5355 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5367 /* Reset pointers if this was really a ,n for a branch instruction. */
5376 /* Parse a 64 bit compare and branch completer returning the number (for
5377 encoding in instrutions) of the given completer.
5379 Nonnegated comparisons are returned as 0-7, negated comparisons are
5380 returned as 8-15. */
5383 pa_parse_cmpb_64_cmpltr (s
)
5387 char *name
= *s
+ 1;
5395 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5400 if (strcmp (name
, "*") == 0)
5404 else if (strcmp (name
, "*=") == 0)
5408 else if (strcmp (name
, "*<") == 0)
5412 else if (strcmp (name
, "*<=") == 0)
5416 else if (strcmp (name
, "*<<") == 0)
5420 else if (strcmp (name
, "*<<=") == 0)
5424 else if (strcasecmp (name
, "*sv") == 0)
5428 else if (strcasecmp (name
, "*od") == 0)
5432 else if (strcasecmp (name
, "*tr") == 0)
5436 else if (strcmp (name
, "*<>") == 0)
5440 else if (strcmp (name
, "*>=") == 0)
5444 else if (strcmp (name
, "*>") == 0)
5448 else if (strcmp (name
, "*>>=") == 0)
5452 else if (strcmp (name
, "*>>") == 0)
5456 else if (strcasecmp (name
, "*nsv") == 0)
5460 else if (strcasecmp (name
, "*ev") == 0)
5475 /* Parse a 64 bit compare immediate and branch completer returning the number
5476 (for encoding in instrutions) of the given completer. */
5479 pa_parse_cmpib_64_cmpltr (s
)
5483 char *name
= *s
+ 1;
5491 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5496 if (strcmp (name
, "*<<") == 0)
5500 else if (strcmp (name
, "*=") == 0)
5504 else if (strcmp (name
, "*<") == 0)
5508 else if (strcmp (name
, "*<=") == 0)
5512 else if (strcmp (name
, "*>>=") == 0)
5516 else if (strcmp (name
, "*<>") == 0)
5520 else if (strcasecmp (name
, "*>=") == 0)
5524 else if (strcasecmp (name
, "*>") == 0)
5539 /* Parse a non-negated addition completer returning the number
5540 (for encoding in instrutions) of the given completer.
5542 ISBRANCH specifies whether or not this is parsing a condition
5543 completer for a branch (vs a nullification completer for a
5544 computational instruction. */
5547 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
5552 char *name
= *s
+ 1;
5560 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5564 if (strcmp (name
, "=") == 0)
5568 else if (strcmp (name
, "<") == 0)
5572 else if (strcmp (name
, "<=") == 0)
5576 else if (strcasecmp (name
, "nuv") == 0)
5580 else if (strcasecmp (name
, "znv") == 0)
5584 else if (strcasecmp (name
, "sv") == 0)
5588 else if (strcasecmp (name
, "od") == 0)
5592 /* If we have something like addb,n then there is no condition
5594 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5605 /* Reset pointers if this was really a ,n for a branch instruction. */
5606 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5612 /* Parse a negated addition completer returning the number
5613 (for encoding in instrutions) of the given completer.
5615 ISBRANCH specifies whether or not this is parsing a condition
5616 completer for a branch (vs a nullification completer for a
5617 computational instruction). */
5620 pa_parse_neg_add_cmpltr (s
, isbranch
)
5625 char *name
= *s
+ 1;
5633 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5637 if (strcasecmp (name
, "tr") == 0)
5641 else if (strcmp (name
, "<>") == 0)
5645 else if (strcmp (name
, ">=") == 0)
5649 else if (strcmp (name
, ">") == 0)
5653 else if (strcasecmp (name
, "uv") == 0)
5657 else if (strcasecmp (name
, "vnz") == 0)
5661 else if (strcasecmp (name
, "nsv") == 0)
5665 else if (strcasecmp (name
, "ev") == 0)
5669 /* If we have something like addb,n then there is no condition
5671 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5682 /* Reset pointers if this was really a ,n for a branch instruction. */
5683 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5689 /* Parse a 64 bit wide mode add and branch completer returning the number (for
5690 encoding in instrutions) of the given completer. */
5693 pa_parse_addb_64_cmpltr (s
)
5697 char *name
= *s
+ 1;
5706 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5710 if (strcmp (name
, "=") == 0)
5714 else if (strcmp (name
, "<") == 0)
5718 else if (strcmp (name
, "<=") == 0)
5722 else if (strcasecmp (name
, "nuv") == 0)
5726 else if (strcasecmp (name
, "*=") == 0)
5730 else if (strcasecmp (name
, "*<") == 0)
5734 else if (strcasecmp (name
, "*<=") == 0)
5738 else if (strcmp (name
, "tr") == 0)
5742 else if (strcmp (name
, "<>") == 0)
5746 else if (strcmp (name
, ">=") == 0)
5750 else if (strcmp (name
, ">") == 0)
5754 else if (strcasecmp (name
, "uv") == 0)
5758 else if (strcasecmp (name
, "*<>") == 0)
5762 else if (strcasecmp (name
, "*>=") == 0)
5766 else if (strcasecmp (name
, "*>") == 0)
5770 /* If we have something like addb,n then there is no condition
5772 else if (strcasecmp (name
, "n") == 0)
5784 /* Reset pointers if this was really a ,n for a branch instruction. */
5792 /* Handle an alignment directive. Special so that we can update the
5793 alignment of the subspace if necessary. */
5797 /* We must have a valid space and subspace. */
5798 pa_check_current_space_and_subspace ();
5800 /* Let the generic gas code do most of the work. */
5801 s_align_bytes (bytes
);
5803 /* If bytes is a power of 2, then update the current subspace's
5804 alignment if necessary. */
5805 if (log2 (bytes
) != -1)
5806 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
5810 /* Handle a .BLOCK type pseudo-op. */
5818 unsigned int temp_size
;
5822 /* We must have a valid space and subspace. */
5823 pa_check_current_space_and_subspace ();
5826 temp_size
= get_absolute_expression ();
5828 /* Always fill with zeros, that's what the HP assembler does. */
5831 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
5832 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
5833 memset (p
, 0, temp_size
);
5835 /* Convert 2 bytes at a time. */
5837 for (i
= 0; i
< temp_size
; i
+= 2)
5839 md_number_to_chars (p
+ i
,
5841 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
5844 pa_undefine_label ();
5845 demand_empty_rest_of_line ();
5848 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
5856 /* The BRTAB relocations are only availble in SOM (to denote
5857 the beginning and end of branch tables). */
5858 char *where
= frag_more (0);
5860 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5861 NULL
, (offsetT
) 0, NULL
,
5862 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
5863 e_fsel
, 0, 0, NULL
);
5866 demand_empty_rest_of_line ();
5869 /* Handle a .begin_try and .end_try pseudo-op. */
5877 char *where
= frag_more (0);
5882 /* The TRY relocations are only availble in SOM (to denote
5883 the beginning and end of exception handling regions). */
5885 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5886 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
5887 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
5888 e_fsel
, 0, 0, NULL
);
5891 demand_empty_rest_of_line ();
5894 /* Handle a .CALL pseudo-op. This involves storing away information
5895 about where arguments are to be found so the linker can detect
5896 (and correct) argument location mismatches between caller and callee. */
5903 /* We must have a valid space and subspace. */
5904 pa_check_current_space_and_subspace ();
5907 pa_call_args (&last_call_desc
);
5908 demand_empty_rest_of_line ();
5911 /* Do the dirty work of building a call descriptor which describes
5912 where the caller placed arguments to a function call. */
5915 pa_call_args (call_desc
)
5916 struct call_desc
*call_desc
;
5919 unsigned int temp
, arg_reloc
;
5921 while (!is_end_of_statement ())
5923 name
= input_line_pointer
;
5924 c
= get_symbol_end ();
5925 /* Process a source argument. */
5926 if ((strncasecmp (name
, "argw", 4) == 0))
5928 temp
= atoi (name
+ 4);
5929 p
= input_line_pointer
;
5931 input_line_pointer
++;
5932 name
= input_line_pointer
;
5933 c
= get_symbol_end ();
5934 arg_reloc
= pa_build_arg_reloc (name
);
5935 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
5937 /* Process a return value. */
5938 else if ((strncasecmp (name
, "rtnval", 6) == 0))
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
|= (arg_reloc
& 0x3);
5950 as_bad (_("Invalid .CALL argument: %s"), name
);
5952 p
= input_line_pointer
;
5954 if (!is_end_of_statement ())
5955 input_line_pointer
++;
5959 /* Return TRUE if FRAG1 and FRAG2 are the same. */
5962 is_same_frag (frag1
, frag2
)
5969 else if (frag2
== NULL
)
5971 else if (frag1
== frag2
)
5973 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
5974 return (is_same_frag (frag1
, frag2
->fr_next
));
5980 /* Build an entry in the UNWIND subspace from the given function
5981 attributes in CALL_INFO. This is not needed for SOM as using
5982 R_ENTRY and R_EXIT relocations allow the linker to handle building
5983 of the unwind spaces. */
5986 pa_build_unwind_subspace (call_info
)
5987 struct call_info
*call_info
;
5990 asection
*seg
, *save_seg
;
5992 subsegT subseg
, save_subseg
;
5996 if (now_seg
!= text_section
)
5999 if (bfd_get_arch_info (stdoutput
)->bits_per_address
== 32)
6000 reloc
= R_PARISC_DIR32
;
6002 reloc
= R_PARISC_SEGREL32
;
6005 save_subseg
= now_subseg
;
6006 /* Get into the right seg/subseg. This may involve creating
6007 the seg the first time through. Make sure to have the
6008 old seg/subseg so that we can reset things when we are done. */
6009 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
6010 if (seg
== ASEC_NULL
)
6012 seg
= subseg_new (UNWIND_SECTION_NAME
, 0);
6013 bfd_set_section_flags (stdoutput
, seg
,
6014 SEC_READONLY
| SEC_HAS_CONTENTS
6015 | SEC_LOAD
| SEC_RELOC
| SEC_ALLOC
| SEC_DATA
);
6016 bfd_set_section_alignment (stdoutput
, seg
, 2);
6019 subseg_set (seg
, 0);
6022 /* Get some space to hold relocation information for the unwind
6025 md_number_to_chars (p
, 0, 4);
6027 /* Relocation info. for start offset of the function. */
6028 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6029 call_info
->start_symbol
, (offsetT
) 0,
6030 (expressionS
*) NULL
, 0, reloc
,
6031 e_fsel
, 32, 0, NULL
);
6034 md_number_to_chars (p
, 0, 4);
6036 /* Relocation info. for end offset of the function.
6038 Because we allow reductions of 32bit relocations for ELF, this will be
6039 reduced to section_sym + offset which avoids putting the temporary
6040 symbol into the symbol table. It (should) end up giving the same
6041 value as call_info->start_symbol + function size once the linker is
6042 finished with its work. */
6044 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6045 call_info
->end_symbol
, (offsetT
) 0,
6046 (expressionS
*) NULL
, 0, reloc
,
6047 e_fsel
, 32, 0, NULL
);
6050 unwind
= (char *) &call_info
->ci_unwind
;
6051 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
6055 FRAG_APPEND_1_CHAR (c
);
6059 /* Return back to the original segment/subsegment. */
6060 subseg_set (save_seg
, save_subseg
);
6064 /* Process a .CALLINFO pseudo-op. This information is used later
6065 to build unwind descriptors and maybe one day to support
6066 .ENTER and .LEAVE. */
6069 pa_callinfo (unused
)
6076 /* We must have a valid space and subspace. */
6077 pa_check_current_space_and_subspace ();
6080 /* .CALLINFO must appear within a procedure definition. */
6081 if (!within_procedure
)
6082 as_bad (_(".callinfo is not within a procedure definition"));
6084 /* Mark the fact that we found the .CALLINFO for the
6085 current procedure. */
6086 callinfo_found
= TRUE
;
6088 /* Iterate over the .CALLINFO arguments. */
6089 while (!is_end_of_statement ())
6091 name
= input_line_pointer
;
6092 c
= get_symbol_end ();
6093 /* Frame size specification. */
6094 if ((strncasecmp (name
, "frame", 5) == 0))
6096 p
= input_line_pointer
;
6098 input_line_pointer
++;
6099 temp
= get_absolute_expression ();
6100 if ((temp
& 0x3) != 0)
6102 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
6106 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
6107 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
6110 /* Entry register (GR, GR and SR) specifications. */
6111 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
6113 p
= input_line_pointer
;
6115 input_line_pointer
++;
6116 temp
= get_absolute_expression ();
6117 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
6118 even though %r19 is caller saved. I think this is a bug in
6119 the HP assembler, and we are not going to emulate it. */
6120 if (temp
< 3 || temp
> 18)
6121 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
6122 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
6124 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
6126 p
= input_line_pointer
;
6128 input_line_pointer
++;
6129 temp
= get_absolute_expression ();
6130 /* Similarly the HP assembler takes 31 as the high bound even
6131 though %fr21 is the last callee saved floating point register. */
6132 if (temp
< 12 || temp
> 21)
6133 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
6134 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
6136 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
6138 p
= input_line_pointer
;
6140 input_line_pointer
++;
6141 temp
= get_absolute_expression ();
6143 as_bad (_("Value for ENTRY_SR must be 3\n"));
6145 /* Note whether or not this function performs any calls. */
6146 else if ((strncasecmp (name
, "calls", 5) == 0) ||
6147 (strncasecmp (name
, "caller", 6) == 0))
6149 p
= input_line_pointer
;
6152 else if ((strncasecmp (name
, "no_calls", 8) == 0))
6154 p
= input_line_pointer
;
6157 /* Should RP be saved into the stack. */
6158 else if ((strncasecmp (name
, "save_rp", 7) == 0))
6160 p
= input_line_pointer
;
6162 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
6164 /* Likewise for SP. */
6165 else if ((strncasecmp (name
, "save_sp", 7) == 0))
6167 p
= input_line_pointer
;
6169 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
6171 /* Is this an unwindable procedure. If so mark it so
6172 in the unwind descriptor. */
6173 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
6175 p
= input_line_pointer
;
6177 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
6179 /* Is this an interrupt routine. If so mark it in the
6180 unwind descriptor. */
6181 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
6183 p
= input_line_pointer
;
6185 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
6187 /* Is this a millicode routine. "millicode" isn't in my
6188 assembler manual, but my copy is old. The HP assembler
6189 accepts it, and there's a place in the unwind descriptor
6190 to drop the information, so we'll accept it too. */
6191 else if ((strncasecmp (name
, "millicode", 9) == 0))
6193 p
= input_line_pointer
;
6195 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
6199 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
6200 *input_line_pointer
= c
;
6202 if (!is_end_of_statement ())
6203 input_line_pointer
++;
6206 demand_empty_rest_of_line ();
6209 /* Switch into the code subspace. */
6216 current_space
= is_defined_space ("$TEXT$");
6218 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6221 pa_undefine_label ();
6224 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
6225 the .comm pseudo-op has the following symtax:
6227 <label> .comm <length>
6229 where <label> is optional and is a symbol whose address will be the start of
6230 a block of memory <length> bytes long. <length> must be an absolute
6231 expression. <length> bytes will be allocated in the current space
6234 Also note the label may not even be on the same line as the .comm.
6236 This difference in syntax means the colon function will be called
6237 on the symbol before we arrive in pa_comm. colon will set a number
6238 of attributes of the symbol that need to be fixed here. In particular
6239 the value, section pointer, fragment pointer, flags, etc. What
6242 This also makes error detection all but impossible. */
6250 label_symbol_struct
*label_symbol
= pa_get_label ();
6253 symbol
= label_symbol
->lss_label
;
6258 size
= get_absolute_expression ();
6262 S_SET_VALUE (symbol
, size
);
6263 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6264 S_SET_EXTERNAL (symbol
);
6266 /* colon() has already set the frag to the current location in the
6267 current subspace; we need to reset the fragment to the zero address
6268 fragment. We also need to reset the segment pointer. */
6269 symbol_set_frag (symbol
, &zero_address_frag
);
6271 demand_empty_rest_of_line ();
6274 /* Process a .END pseudo-op. */
6280 demand_empty_rest_of_line ();
6283 /* Process a .ENTER pseudo-op. This is not supported. */
6289 /* We must have a valid space and subspace. */
6290 pa_check_current_space_and_subspace ();
6293 as_bad (_("The .ENTER pseudo-op is not supported"));
6294 demand_empty_rest_of_line ();
6297 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
6304 /* We must have a valid space and subspace. */
6305 pa_check_current_space_and_subspace ();
6308 if (!within_procedure
)
6309 as_bad (_("Misplaced .entry. Ignored."));
6312 if (!callinfo_found
)
6313 as_bad (_("Missing .callinfo."));
6315 demand_empty_rest_of_line ();
6316 within_entry_exit
= TRUE
;
6319 /* SOM defers building of unwind descriptors until the link phase.
6320 The assembler is responsible for creating an R_ENTRY relocation
6321 to mark the beginning of a region and hold the unwind bits, and
6322 for creating an R_EXIT relocation to mark the end of the region.
6324 FIXME. ELF should be using the same conventions! The problem
6325 is an unwind requires too much relocation space. Hmmm. Maybe
6326 if we split the unwind bits up between the relocations which
6327 denote the entry and exit points. */
6328 if (last_call_info
->start_symbol
!= NULL
)
6330 char *where
= frag_more (0);
6332 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6333 NULL
, (offsetT
) 0, NULL
,
6334 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
6335 (int *) &last_call_info
->ci_unwind
.descriptor
);
6340 /* Handle a .EQU pseudo-op. */
6346 label_symbol_struct
*label_symbol
= pa_get_label ();
6351 symbol
= label_symbol
->lss_label
;
6353 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
6355 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
6356 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
6361 as_bad (_(".REG must use a label"));
6363 as_bad (_(".EQU must use a label"));
6366 pa_undefine_label ();
6367 demand_empty_rest_of_line ();
6370 /* Helper function. Does processing for the end of a function. This
6371 usually involves creating some relocations or building special
6372 symbols to mark the end of the function. */
6379 where
= frag_more (0);
6382 /* Mark the end of the function, stuff away the location of the frag
6383 for the end of the function, and finally call pa_build_unwind_subspace
6384 to add an entry in the unwind table. */
6385 hppa_elf_mark_end_of_function ();
6386 pa_build_unwind_subspace (last_call_info
);
6388 /* SOM defers building of unwind descriptors until the link phase.
6389 The assembler is responsible for creating an R_ENTRY relocation
6390 to mark the beginning of a region and hold the unwind bits, and
6391 for creating an R_EXIT relocation to mark the end of the region.
6393 FIXME. ELF should be using the same conventions! The problem
6394 is an unwind requires too much relocation space. Hmmm. Maybe
6395 if we split the unwind bits up between the relocations which
6396 denote the entry and exit points. */
6397 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6399 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
6400 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
6404 /* Process a .EXIT pseudo-op. */
6411 /* We must have a valid space and subspace. */
6412 pa_check_current_space_and_subspace ();
6415 if (!within_procedure
)
6416 as_bad (_(".EXIT must appear within a procedure"));
6419 if (!callinfo_found
)
6420 as_bad (_("Missing .callinfo"));
6423 if (!within_entry_exit
)
6424 as_bad (_("No .ENTRY for this .EXIT"));
6427 within_entry_exit
= FALSE
;
6432 demand_empty_rest_of_line ();
6435 /* Process a .EXPORT directive. This makes functions external
6436 and provides information such as argument relocation entries
6446 name
= input_line_pointer
;
6447 c
= get_symbol_end ();
6448 /* Make sure the given symbol exists. */
6449 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6451 as_bad (_("Cannot define export symbol: %s\n"), name
);
6452 p
= input_line_pointer
;
6454 input_line_pointer
++;
6458 /* OK. Set the external bits and process argument relocations. */
6459 S_SET_EXTERNAL (symbol
);
6460 p
= input_line_pointer
;
6462 if (!is_end_of_statement ())
6464 input_line_pointer
++;
6465 pa_type_args (symbol
, 1);
6469 demand_empty_rest_of_line ();
6472 /* Helper function to process arguments to a .EXPORT pseudo-op. */
6475 pa_type_args (symbolP
, is_export
)
6480 unsigned int temp
, arg_reloc
;
6481 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
6482 obj_symbol_type
*symbol
= (obj_symbol_type
*) symbol_get_bfdsym (symbolP
);
6484 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
6487 input_line_pointer
+= 8;
6488 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6489 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
6490 type
= SYMBOL_TYPE_ABSOLUTE
;
6492 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
6494 input_line_pointer
+= 4;
6495 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
6496 instead one should be IMPORTing/EXPORTing ENTRY types.
6498 Complain if one tries to EXPORT a CODE type since that's never
6499 done. Both GCC and HP C still try to IMPORT CODE types, so
6500 silently fix them to be ENTRY types. */
6501 if (S_IS_FUNCTION (symbolP
))
6504 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
6505 S_GET_NAME (symbolP
));
6507 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6508 type
= SYMBOL_TYPE_ENTRY
;
6512 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6513 type
= SYMBOL_TYPE_CODE
;
6516 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
6518 input_line_pointer
+= 4;
6519 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6520 symbol_get_bfdsym (symbolP
)->flags
|= BSF_OBJECT
;
6521 type
= SYMBOL_TYPE_DATA
;
6523 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
6525 input_line_pointer
+= 5;
6526 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6527 type
= SYMBOL_TYPE_ENTRY
;
6529 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
6531 input_line_pointer
+= 9;
6532 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6533 type
= SYMBOL_TYPE_MILLICODE
;
6535 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
6537 input_line_pointer
+= 6;
6538 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6539 type
= SYMBOL_TYPE_PLABEL
;
6541 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
6543 input_line_pointer
+= 8;
6544 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6545 type
= SYMBOL_TYPE_PRI_PROG
;
6547 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
6549 input_line_pointer
+= 8;
6550 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6551 type
= SYMBOL_TYPE_SEC_PROG
;
6554 /* SOM requires much more information about symbol types
6555 than BFD understands. This is how we get this information
6556 to the SOM BFD backend. */
6557 #ifdef obj_set_symbol_type
6558 obj_set_symbol_type (symbol_get_bfdsym (symbolP
), (int) type
);
6561 /* Now that the type of the exported symbol has been handled,
6562 handle any argument relocation information. */
6563 while (!is_end_of_statement ())
6565 if (*input_line_pointer
== ',')
6566 input_line_pointer
++;
6567 name
= input_line_pointer
;
6568 c
= get_symbol_end ();
6569 /* Argument sources. */
6570 if ((strncasecmp (name
, "argw", 4) == 0))
6572 p
= input_line_pointer
;
6574 input_line_pointer
++;
6575 temp
= atoi (name
+ 4);
6576 name
= input_line_pointer
;
6577 c
= get_symbol_end ();
6578 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
6580 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
6582 *input_line_pointer
= c
;
6584 /* The return value. */
6585 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
6587 p
= input_line_pointer
;
6589 input_line_pointer
++;
6590 name
= input_line_pointer
;
6591 c
= get_symbol_end ();
6592 arg_reloc
= pa_build_arg_reloc (name
);
6594 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
6596 *input_line_pointer
= c
;
6598 /* Privelege level. */
6599 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
6601 p
= input_line_pointer
;
6603 input_line_pointer
++;
6604 temp
= atoi (input_line_pointer
);
6606 symbol
->tc_data
.ap
.hppa_priv_level
= temp
;
6608 c
= get_symbol_end ();
6609 *input_line_pointer
= c
;
6613 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
6614 p
= input_line_pointer
;
6617 if (!is_end_of_statement ())
6618 input_line_pointer
++;
6622 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
6623 assembly file must either be defined in the assembly file, or
6624 explicitly IMPORTED from another. */
6633 name
= input_line_pointer
;
6634 c
= get_symbol_end ();
6636 symbol
= symbol_find (name
);
6637 /* Ugh. We might be importing a symbol defined earlier in the file,
6638 in which case all the code below will really screw things up
6639 (set the wrong segment, symbol flags & type, etc). */
6640 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
6642 symbol
= symbol_find_or_make (name
);
6643 p
= input_line_pointer
;
6646 if (!is_end_of_statement ())
6648 input_line_pointer
++;
6649 pa_type_args (symbol
, 0);
6653 /* Sigh. To be compatable with the HP assembler and to help
6654 poorly written assembly code, we assign a type based on
6655 the the current segment. Note only BSF_FUNCTION really
6656 matters, we do not need to set the full SYMBOL_TYPE_* info. */
6657 if (now_seg
== text_section
)
6658 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
6660 /* If the section is undefined, then the symbol is undefined
6661 Since this is an import, leave the section undefined. */
6662 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6667 /* The symbol was already defined. Just eat everything up to
6668 the end of the current statement. */
6669 while (!is_end_of_statement ())
6670 input_line_pointer
++;
6673 demand_empty_rest_of_line ();
6676 /* Handle a .LABEL pseudo-op. */
6684 name
= input_line_pointer
;
6685 c
= get_symbol_end ();
6687 if (strlen (name
) > 0)
6690 p
= input_line_pointer
;
6695 as_warn (_("Missing label name on .LABEL"));
6698 if (!is_end_of_statement ())
6700 as_warn (_("extra .LABEL arguments ignored."));
6701 ignore_rest_of_line ();
6703 demand_empty_rest_of_line ();
6706 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
6713 /* We must have a valid space and subspace. */
6714 pa_check_current_space_and_subspace ();
6717 as_bad (_("The .LEAVE pseudo-op is not supported"));
6718 demand_empty_rest_of_line ();
6721 /* Handle a .LEVEL pseudo-op. */
6729 level
= input_line_pointer
;
6730 if (strncmp (level
, "1.0", 3) == 0)
6732 input_line_pointer
+= 3;
6733 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
6734 as_warn (_("could not set architecture and machine"));
6736 else if (strncmp (level
, "1.1", 3) == 0)
6738 input_line_pointer
+= 3;
6739 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
6740 as_warn (_("could not set architecture and machine"));
6742 else if (strncmp (level
, "2.0w", 4) == 0)
6744 input_line_pointer
+= 4;
6745 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 25))
6746 as_warn (_("could not set architecture and machine"));
6748 else if (strncmp (level
, "2.0", 3) == 0)
6750 input_line_pointer
+= 3;
6751 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
6752 as_warn (_("could not set architecture and machine"));
6756 as_bad (_("Unrecognized .LEVEL argument\n"));
6757 ignore_rest_of_line ();
6759 demand_empty_rest_of_line ();
6762 /* Handle a .ORIGIN pseudo-op. */
6769 /* We must have a valid space and subspace. */
6770 pa_check_current_space_and_subspace ();
6774 pa_undefine_label ();
6777 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
6778 is for static functions. FIXME. Should share more code with .EXPORT. */
6787 name
= input_line_pointer
;
6788 c
= get_symbol_end ();
6790 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6792 as_bad (_("Cannot define static symbol: %s\n"), name
);
6793 p
= input_line_pointer
;
6795 input_line_pointer
++;
6799 S_CLEAR_EXTERNAL (symbol
);
6800 p
= input_line_pointer
;
6802 if (!is_end_of_statement ())
6804 input_line_pointer
++;
6805 pa_type_args (symbol
, 0);
6809 demand_empty_rest_of_line ();
6812 /* Handle a .PROC pseudo-op. It is used to mark the beginning
6813 of a procedure from a syntatical point of view. */
6819 struct call_info
*call_info
;
6822 /* We must have a valid space and subspace. */
6823 pa_check_current_space_and_subspace ();
6826 if (within_procedure
)
6827 as_fatal (_("Nested procedures"));
6829 /* Reset global variables for new procedure. */
6830 callinfo_found
= FALSE
;
6831 within_procedure
= TRUE
;
6833 /* Create another call_info structure. */
6834 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
6837 as_fatal (_("Cannot allocate unwind descriptor\n"));
6839 memset (call_info
, 0, sizeof (struct call_info
));
6841 call_info
->ci_next
= NULL
;
6843 if (call_info_root
== NULL
)
6845 call_info_root
= call_info
;
6846 last_call_info
= call_info
;
6850 last_call_info
->ci_next
= call_info
;
6851 last_call_info
= call_info
;
6854 /* set up defaults on call_info structure */
6856 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
6857 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
6858 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
6860 /* If we got a .PROC pseudo-op, we know that the function is defined
6861 locally. Make sure it gets into the symbol table. */
6863 label_symbol_struct
*label_symbol
= pa_get_label ();
6867 if (label_symbol
->lss_label
)
6869 last_call_info
->start_symbol
= label_symbol
->lss_label
;
6870 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
6873 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
6876 last_call_info
->start_symbol
= NULL
;
6879 demand_empty_rest_of_line ();
6882 /* Process the syntatical end of a procedure. Make sure all the
6883 appropriate pseudo-ops were found within the procedure. */
6891 /* We must have a valid space and subspace. */
6892 pa_check_current_space_and_subspace ();
6895 /* If we are within a procedure definition, make sure we've
6896 defined a label for the procedure; handle case where the
6897 label was defined after the .PROC directive.
6899 Note there's not need to diddle with the segment or fragment
6900 for the label symbol in this case. We have already switched
6901 into the new $CODE$ subspace at this point. */
6902 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
6904 label_symbol_struct
*label_symbol
= pa_get_label ();
6908 if (label_symbol
->lss_label
)
6910 last_call_info
->start_symbol
= label_symbol
->lss_label
;
6911 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
6914 /* Also handle allocation of a fixup to hold the unwind
6915 information when the label appears after the proc/procend. */
6916 if (within_entry_exit
)
6918 char *where
= frag_more (0);
6920 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6921 NULL
, (offsetT
) 0, NULL
,
6922 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
6923 (int *) &last_call_info
->ci_unwind
.descriptor
);
6928 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
6931 as_bad (_("Missing function name for .PROC"));
6934 if (!within_procedure
)
6935 as_bad (_("misplaced .procend"));
6937 if (!callinfo_found
)
6938 as_bad (_("Missing .callinfo for this procedure"));
6940 if (within_entry_exit
)
6941 as_bad (_("Missing .EXIT for a .ENTRY"));
6944 /* ELF needs to mark the end of each function so that it can compute
6945 the size of the function (apparently its needed in the symbol table). */
6946 hppa_elf_mark_end_of_function ();
6949 within_procedure
= FALSE
;
6950 demand_empty_rest_of_line ();
6951 pa_undefine_label ();
6954 /* If VALUE is an exact power of two between zero and 2^31, then
6955 return log2 (VALUE). Else return -1. */
6963 while ((1 << shift
) != value
&& shift
< 32)
6974 /* Check to make sure we have a valid space and subspace. */
6977 pa_check_current_space_and_subspace ()
6979 if (current_space
== NULL
)
6980 as_fatal (_("Not in a space.\n"));
6982 if (current_subspace
== NULL
)
6983 as_fatal (_("Not in a subspace.\n"));
6986 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
6987 then create a new space entry to hold the information specified
6988 by the parameters to the .SPACE directive. */
6990 static sd_chain_struct
*
6991 pa_parse_space_stmt (space_name
, create_flag
)
6995 char *name
, *ptemp
, c
;
6996 char loadable
, defined
, private, sort
;
6998 asection
*seg
= NULL
;
6999 sd_chain_struct
*space
;
7001 /* load default values */
7007 if (strcmp (space_name
, "$TEXT$") == 0)
7009 seg
= pa_def_spaces
[0].segment
;
7010 defined
= pa_def_spaces
[0].defined
;
7011 private = pa_def_spaces
[0].private;
7012 sort
= pa_def_spaces
[0].sort
;
7013 spnum
= pa_def_spaces
[0].spnum
;
7015 else if (strcmp (space_name
, "$PRIVATE$") == 0)
7017 seg
= pa_def_spaces
[1].segment
;
7018 defined
= pa_def_spaces
[1].defined
;
7019 private = pa_def_spaces
[1].private;
7020 sort
= pa_def_spaces
[1].sort
;
7021 spnum
= pa_def_spaces
[1].spnum
;
7024 if (!is_end_of_statement ())
7026 print_errors
= FALSE
;
7027 ptemp
= input_line_pointer
+ 1;
7028 /* First see if the space was specified as a number rather than
7029 as a name. According to the PA assembly manual the rest of
7030 the line should be ignored. */
7031 temp
= pa_parse_number (&ptemp
, 0);
7035 input_line_pointer
= ptemp
;
7039 while (!is_end_of_statement ())
7041 input_line_pointer
++;
7042 name
= input_line_pointer
;
7043 c
= get_symbol_end ();
7044 if ((strncasecmp (name
, "spnum", 5) == 0))
7046 *input_line_pointer
= c
;
7047 input_line_pointer
++;
7048 spnum
= get_absolute_expression ();
7050 else if ((strncasecmp (name
, "sort", 4) == 0))
7052 *input_line_pointer
= c
;
7053 input_line_pointer
++;
7054 sort
= get_absolute_expression ();
7056 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7058 *input_line_pointer
= c
;
7061 else if ((strncasecmp (name
, "notdefined", 10) == 0))
7063 *input_line_pointer
= c
;
7066 else if ((strncasecmp (name
, "private", 7) == 0))
7068 *input_line_pointer
= c
;
7073 as_bad (_("Invalid .SPACE argument"));
7074 *input_line_pointer
= c
;
7075 if (!is_end_of_statement ())
7076 input_line_pointer
++;
7080 print_errors
= TRUE
;
7083 if (create_flag
&& seg
== NULL
)
7084 seg
= subseg_new (space_name
, 0);
7086 /* If create_flag is nonzero, then create the new space with
7087 the attributes computed above. Else set the values in
7088 an already existing space -- this can only happen for
7089 the first occurence of a built-in space. */
7091 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
7092 private, sort
, seg
, 1);
7095 space
= is_defined_space (space_name
);
7096 SPACE_SPNUM (space
) = spnum
;
7097 SPACE_DEFINED (space
) = defined
& 1;
7098 SPACE_USER_DEFINED (space
) = 1;
7101 #ifdef obj_set_section_attributes
7102 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7108 /* Handle a .SPACE pseudo-op; this switches the current space to the
7109 given space, creating the new space if necessary. */
7115 char *name
, c
, *space_name
, *save_s
;
7117 sd_chain_struct
*sd_chain
;
7119 if (within_procedure
)
7121 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
7122 ignore_rest_of_line ();
7126 /* Check for some of the predefined spaces. FIXME: most of the code
7127 below is repeated several times, can we extract the common parts
7128 and place them into a subroutine or something similar? */
7129 /* FIXME Is this (and the next IF stmt) really right?
7130 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
7131 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
7133 input_line_pointer
+= 6;
7134 sd_chain
= is_defined_space ("$TEXT$");
7135 if (sd_chain
== NULL
)
7136 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
7137 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7138 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
7140 current_space
= sd_chain
;
7141 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
7143 = pa_subsegment_to_subspace (text_section
,
7144 sd_chain
->sd_last_subseg
);
7145 demand_empty_rest_of_line ();
7148 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
7150 input_line_pointer
+= 9;
7151 sd_chain
= is_defined_space ("$PRIVATE$");
7152 if (sd_chain
== NULL
)
7153 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
7154 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7155 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
7157 current_space
= sd_chain
;
7158 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
7160 = pa_subsegment_to_subspace (data_section
,
7161 sd_chain
->sd_last_subseg
);
7162 demand_empty_rest_of_line ();
7165 if (!strncasecmp (input_line_pointer
,
7166 GDB_DEBUG_SPACE_NAME
,
7167 strlen (GDB_DEBUG_SPACE_NAME
)))
7169 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
7170 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
7171 if (sd_chain
== NULL
)
7172 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
7173 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7174 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
7176 current_space
= sd_chain
;
7179 asection
*gdb_section
7180 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
7182 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
7184 = pa_subsegment_to_subspace (gdb_section
,
7185 sd_chain
->sd_last_subseg
);
7187 demand_empty_rest_of_line ();
7191 /* It could be a space specified by number. */
7193 save_s
= input_line_pointer
;
7194 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
7196 if ((sd_chain
= pa_find_space_by_number (temp
)))
7198 current_space
= sd_chain
;
7200 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7202 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7203 sd_chain
->sd_last_subseg
);
7204 demand_empty_rest_of_line ();
7209 /* Not a number, attempt to create a new space. */
7211 input_line_pointer
= save_s
;
7212 name
= input_line_pointer
;
7213 c
= get_symbol_end ();
7214 space_name
= xmalloc (strlen (name
) + 1);
7215 strcpy (space_name
, name
);
7216 *input_line_pointer
= c
;
7218 sd_chain
= pa_parse_space_stmt (space_name
, 1);
7219 current_space
= sd_chain
;
7221 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7222 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7223 sd_chain
->sd_last_subseg
);
7224 demand_empty_rest_of_line ();
7228 /* Switch to a new space. (I think). FIXME. */
7237 sd_chain_struct
*space
;
7239 name
= input_line_pointer
;
7240 c
= get_symbol_end ();
7241 space
= is_defined_space (name
);
7245 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
7248 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
7250 *input_line_pointer
= c
;
7251 demand_empty_rest_of_line ();
7254 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
7255 given subspace, creating the new subspace if necessary.
7257 FIXME. Should mirror pa_space more closely, in particular how
7258 they're broken up into subroutines. */
7261 pa_subspace (create_new
)
7264 char *name
, *ss_name
, c
;
7265 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
7266 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
7267 sd_chain_struct
*space
;
7268 ssd_chain_struct
*ssd
;
7271 if (current_space
== NULL
)
7272 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
7274 if (within_procedure
)
7276 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
7277 ignore_rest_of_line ();
7281 name
= input_line_pointer
;
7282 c
= get_symbol_end ();
7283 ss_name
= xmalloc (strlen (name
) + 1);
7284 strcpy (ss_name
, name
);
7285 *input_line_pointer
= c
;
7287 /* Load default values. */
7299 space
= current_space
;
7303 ssd
= is_defined_subspace (ss_name
);
7304 /* Allow user to override the builtin attributes of subspaces. But
7305 only allow the attributes to be changed once! */
7306 if (ssd
&& SUBSPACE_DEFINED (ssd
))
7308 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
7309 current_subspace
= ssd
;
7310 if (!is_end_of_statement ())
7311 as_warn (_("Parameters of an existing subspace can\'t be modified"));
7312 demand_empty_rest_of_line ();
7317 /* A new subspace. Load default values if it matches one of
7318 the builtin subspaces. */
7320 while (pa_def_subspaces
[i
].name
)
7322 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
7324 loadable
= pa_def_subspaces
[i
].loadable
;
7325 common
= pa_def_subspaces
[i
].common
;
7326 dup_common
= pa_def_subspaces
[i
].dup_common
;
7327 code_only
= pa_def_subspaces
[i
].code_only
;
7328 zero
= pa_def_subspaces
[i
].zero
;
7329 space_index
= pa_def_subspaces
[i
].space_index
;
7330 alignment
= pa_def_subspaces
[i
].alignment
;
7331 quadrant
= pa_def_subspaces
[i
].quadrant
;
7332 access
= pa_def_subspaces
[i
].access
;
7333 sort
= pa_def_subspaces
[i
].sort
;
7340 /* We should be working with a new subspace now. Fill in
7341 any information as specified by the user. */
7342 if (!is_end_of_statement ())
7344 input_line_pointer
++;
7345 while (!is_end_of_statement ())
7347 name
= input_line_pointer
;
7348 c
= get_symbol_end ();
7349 if ((strncasecmp (name
, "quad", 4) == 0))
7351 *input_line_pointer
= c
;
7352 input_line_pointer
++;
7353 quadrant
= get_absolute_expression ();
7355 else if ((strncasecmp (name
, "align", 5) == 0))
7357 *input_line_pointer
= c
;
7358 input_line_pointer
++;
7359 alignment
= get_absolute_expression ();
7360 if (log2 (alignment
) == -1)
7362 as_bad (_("Alignment must be a power of 2"));
7366 else if ((strncasecmp (name
, "access", 6) == 0))
7368 *input_line_pointer
= c
;
7369 input_line_pointer
++;
7370 access
= get_absolute_expression ();
7372 else if ((strncasecmp (name
, "sort", 4) == 0))
7374 *input_line_pointer
= c
;
7375 input_line_pointer
++;
7376 sort
= get_absolute_expression ();
7378 else if ((strncasecmp (name
, "code_only", 9) == 0))
7380 *input_line_pointer
= c
;
7383 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7385 *input_line_pointer
= c
;
7388 else if ((strncasecmp (name
, "common", 6) == 0))
7390 *input_line_pointer
= c
;
7393 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
7395 *input_line_pointer
= c
;
7398 else if ((strncasecmp (name
, "zero", 4) == 0))
7400 *input_line_pointer
= c
;
7403 else if ((strncasecmp (name
, "first", 5) == 0))
7404 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
7406 as_bad (_("Invalid .SUBSPACE argument"));
7407 if (!is_end_of_statement ())
7408 input_line_pointer
++;
7412 /* Compute a reasonable set of BFD flags based on the information
7413 in the .subspace directive. */
7414 applicable
= bfd_applicable_section_flags (stdoutput
);
7417 flags
|= (SEC_ALLOC
| SEC_LOAD
);
7420 if (common
|| dup_common
)
7421 flags
|= SEC_IS_COMMON
;
7423 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
7425 /* This is a zero-filled subspace (eg BSS). */
7427 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
7429 applicable
&= flags
;
7431 /* If this is an existing subspace, then we want to use the
7432 segment already associated with the subspace.
7434 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
7435 lots of sections. It might be a problem in the PA ELF
7436 code, I do not know yet. For now avoid creating anything
7437 but the "standard" sections for ELF. */
7439 section
= subseg_force_new (ss_name
, 0);
7441 section
= ssd
->ssd_seg
;
7443 section
= subseg_new (ss_name
, 0);
7446 seg_info (section
)->bss
= 1;
7448 /* Now set the flags. */
7449 bfd_set_section_flags (stdoutput
, section
, applicable
);
7451 /* Record any alignment request for this section. */
7452 record_alignment (section
, log2 (alignment
));
7454 /* Set the starting offset for this section. */
7455 bfd_set_section_vma (stdoutput
, section
,
7456 pa_subspace_start (space
, quadrant
));
7458 /* Now that all the flags are set, update an existing subspace,
7459 or create a new one. */
7462 current_subspace
= update_subspace (space
, ss_name
, loadable
,
7463 code_only
, common
, dup_common
,
7464 sort
, zero
, access
, space_index
,
7465 alignment
, quadrant
,
7468 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
7470 dup_common
, zero
, sort
,
7471 access
, space_index
,
7472 alignment
, quadrant
, section
);
7474 demand_empty_rest_of_line ();
7475 current_subspace
->ssd_seg
= section
;
7476 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
7478 SUBSPACE_DEFINED (current_subspace
) = 1;
7482 /* Create default space and subspace dictionaries. */
7489 space_dict_root
= NULL
;
7490 space_dict_last
= NULL
;
7493 while (pa_def_spaces
[i
].name
)
7497 /* Pick the right name to use for the new section. */
7498 name
= pa_def_spaces
[i
].name
;
7500 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
7501 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
7502 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
7503 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
7504 pa_def_spaces
[i
].segment
, 0);
7509 while (pa_def_subspaces
[i
].name
)
7512 int applicable
, subsegment
;
7513 asection
*segment
= NULL
;
7514 sd_chain_struct
*space
;
7516 /* Pick the right name for the new section and pick the right
7517 subsegment number. */
7518 name
= pa_def_subspaces
[i
].name
;
7521 /* Create the new section. */
7522 segment
= subseg_new (name
, subsegment
);
7525 /* For SOM we want to replace the standard .text, .data, and .bss
7526 sections with our own. We also want to set BFD flags for
7527 all the built-in subspaces. */
7528 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
7530 text_section
= segment
;
7531 applicable
= bfd_applicable_section_flags (stdoutput
);
7532 bfd_set_section_flags (stdoutput
, segment
,
7533 applicable
& (SEC_ALLOC
| SEC_LOAD
7534 | SEC_RELOC
| SEC_CODE
7536 | SEC_HAS_CONTENTS
));
7538 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
7540 data_section
= segment
;
7541 applicable
= bfd_applicable_section_flags (stdoutput
);
7542 bfd_set_section_flags (stdoutput
, segment
,
7543 applicable
& (SEC_ALLOC
| SEC_LOAD
7545 | SEC_HAS_CONTENTS
));
7549 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
7551 bss_section
= segment
;
7552 applicable
= bfd_applicable_section_flags (stdoutput
);
7553 bfd_set_section_flags (stdoutput
, segment
,
7554 applicable
& SEC_ALLOC
);
7556 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
7558 applicable
= bfd_applicable_section_flags (stdoutput
);
7559 bfd_set_section_flags (stdoutput
, segment
,
7560 applicable
& (SEC_ALLOC
| SEC_LOAD
7563 | SEC_HAS_CONTENTS
));
7565 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
7567 applicable
= bfd_applicable_section_flags (stdoutput
);
7568 bfd_set_section_flags (stdoutput
, segment
,
7569 applicable
& (SEC_ALLOC
| SEC_LOAD
7572 | SEC_HAS_CONTENTS
));
7574 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
7576 applicable
= bfd_applicable_section_flags (stdoutput
);
7577 bfd_set_section_flags (stdoutput
, segment
,
7578 applicable
& (SEC_ALLOC
| SEC_LOAD
7581 | SEC_HAS_CONTENTS
));
7584 /* Find the space associated with this subspace. */
7585 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
7586 def_space_index
].segment
);
7589 as_fatal (_("Internal error: Unable to find containing space for %s."),
7590 pa_def_subspaces
[i
].name
);
7593 create_new_subspace (space
, name
,
7594 pa_def_subspaces
[i
].loadable
,
7595 pa_def_subspaces
[i
].code_only
,
7596 pa_def_subspaces
[i
].common
,
7597 pa_def_subspaces
[i
].dup_common
,
7598 pa_def_subspaces
[i
].zero
,
7599 pa_def_subspaces
[i
].sort
,
7600 pa_def_subspaces
[i
].access
,
7601 pa_def_subspaces
[i
].space_index
,
7602 pa_def_subspaces
[i
].alignment
,
7603 pa_def_subspaces
[i
].quadrant
,
7611 /* Create a new space NAME, with the appropriate flags as defined
7612 by the given parameters. */
7614 static sd_chain_struct
*
7615 create_new_space (name
, spnum
, loadable
, defined
, private,
7616 sort
, seg
, user_defined
)
7626 sd_chain_struct
*chain_entry
;
7628 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
7630 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
7633 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7634 strcpy (SPACE_NAME (chain_entry
), name
);
7635 SPACE_DEFINED (chain_entry
) = defined
;
7636 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
7637 SPACE_SPNUM (chain_entry
) = spnum
;
7639 chain_entry
->sd_seg
= seg
;
7640 chain_entry
->sd_last_subseg
= -1;
7641 chain_entry
->sd_subspaces
= NULL
;
7642 chain_entry
->sd_next
= NULL
;
7644 /* Find spot for the new space based on its sort key. */
7645 if (!space_dict_last
)
7646 space_dict_last
= chain_entry
;
7648 if (space_dict_root
== NULL
)
7649 space_dict_root
= chain_entry
;
7652 sd_chain_struct
*chain_pointer
;
7653 sd_chain_struct
*prev_chain_pointer
;
7655 chain_pointer
= space_dict_root
;
7656 prev_chain_pointer
= NULL
;
7658 while (chain_pointer
)
7660 prev_chain_pointer
= chain_pointer
;
7661 chain_pointer
= chain_pointer
->sd_next
;
7664 /* At this point we've found the correct place to add the new
7665 entry. So add it and update the linked lists as appropriate. */
7666 if (prev_chain_pointer
)
7668 chain_entry
->sd_next
= chain_pointer
;
7669 prev_chain_pointer
->sd_next
= chain_entry
;
7673 space_dict_root
= chain_entry
;
7674 chain_entry
->sd_next
= chain_pointer
;
7677 if (chain_entry
->sd_next
== NULL
)
7678 space_dict_last
= chain_entry
;
7681 /* This is here to catch predefined spaces which do not get
7682 modified by the user's input. Another call is found at
7683 the bottom of pa_parse_space_stmt to handle cases where
7684 the user modifies a predefined space. */
7685 #ifdef obj_set_section_attributes
7686 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7692 /* Create a new subspace NAME, with the appropriate flags as defined
7693 by the given parameters.
7695 Add the new subspace to the subspace dictionary chain in numerical
7696 order as defined by the SORT entries. */
7698 static ssd_chain_struct
*
7699 create_new_subspace (space
, name
, loadable
, code_only
, common
,
7700 dup_common
, is_zero
, sort
, access
, space_index
,
7701 alignment
, quadrant
, seg
)
7702 sd_chain_struct
*space
;
7704 int loadable
, code_only
, common
, dup_common
, is_zero
;
7712 ssd_chain_struct
*chain_entry
;
7714 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
7716 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
7718 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7719 strcpy (SUBSPACE_NAME (chain_entry
), name
);
7721 /* Initialize subspace_defined. When we hit a .subspace directive
7722 we'll set it to 1 which "locks-in" the subspace attributes. */
7723 SUBSPACE_DEFINED (chain_entry
) = 0;
7725 chain_entry
->ssd_subseg
= 0;
7726 chain_entry
->ssd_seg
= seg
;
7727 chain_entry
->ssd_next
= NULL
;
7729 /* Find spot for the new subspace based on its sort key. */
7730 if (space
->sd_subspaces
== NULL
)
7731 space
->sd_subspaces
= chain_entry
;
7734 ssd_chain_struct
*chain_pointer
;
7735 ssd_chain_struct
*prev_chain_pointer
;
7737 chain_pointer
= space
->sd_subspaces
;
7738 prev_chain_pointer
= NULL
;
7740 while (chain_pointer
)
7742 prev_chain_pointer
= chain_pointer
;
7743 chain_pointer
= chain_pointer
->ssd_next
;
7746 /* Now we have somewhere to put the new entry. Insert it and update
7748 if (prev_chain_pointer
)
7750 chain_entry
->ssd_next
= chain_pointer
;
7751 prev_chain_pointer
->ssd_next
= chain_entry
;
7755 space
->sd_subspaces
= chain_entry
;
7756 chain_entry
->ssd_next
= chain_pointer
;
7760 #ifdef obj_set_subsection_attributes
7761 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
7768 /* Update the information for the given subspace based upon the
7769 various arguments. Return the modified subspace chain entry. */
7771 static ssd_chain_struct
*
7772 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
7773 zero
, access
, space_index
, alignment
, quadrant
, section
)
7774 sd_chain_struct
*space
;
7788 ssd_chain_struct
*chain_entry
;
7790 chain_entry
= is_defined_subspace (name
);
7792 #ifdef obj_set_subsection_attributes
7793 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
7800 /* Return the space chain entry for the space with the name NAME or
7801 NULL if no such space exists. */
7803 static sd_chain_struct
*
7804 is_defined_space (name
)
7807 sd_chain_struct
*chain_pointer
;
7809 for (chain_pointer
= space_dict_root
;
7811 chain_pointer
= chain_pointer
->sd_next
)
7813 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
7814 return chain_pointer
;
7817 /* No mapping from segment to space was found. Return NULL. */
7821 /* Find and return the space associated with the given seg. If no mapping
7822 from the given seg to a space is found, then return NULL.
7824 Unlike subspaces, the number of spaces is not expected to grow much,
7825 so a linear exhaustive search is OK here. */
7827 static sd_chain_struct
*
7828 pa_segment_to_space (seg
)
7831 sd_chain_struct
*space_chain
;
7833 /* Walk through each space looking for the correct mapping. */
7834 for (space_chain
= space_dict_root
;
7836 space_chain
= space_chain
->sd_next
)
7838 if (space_chain
->sd_seg
== seg
)
7842 /* Mapping was not found. Return NULL. */
7846 /* Return the space chain entry for the subspace with the name NAME or
7847 NULL if no such subspace exists.
7849 Uses a linear search through all the spaces and subspaces, this may
7850 not be appropriate if we ever being placing each function in its
7853 static ssd_chain_struct
*
7854 is_defined_subspace (name
)
7857 sd_chain_struct
*space_chain
;
7858 ssd_chain_struct
*subspace_chain
;
7860 /* Walk through each space. */
7861 for (space_chain
= space_dict_root
;
7863 space_chain
= space_chain
->sd_next
)
7865 /* Walk through each subspace looking for a name which matches. */
7866 for (subspace_chain
= space_chain
->sd_subspaces
;
7868 subspace_chain
= subspace_chain
->ssd_next
)
7869 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
7870 return subspace_chain
;
7873 /* Subspace wasn't found. Return NULL. */
7877 /* Find and return the subspace associated with the given seg. If no
7878 mapping from the given seg to a subspace is found, then return NULL.
7880 If we ever put each procedure/function within its own subspace
7881 (to make life easier on the compiler and linker), then this will have
7882 to become more efficient. */
7884 static ssd_chain_struct
*
7885 pa_subsegment_to_subspace (seg
, subseg
)
7889 sd_chain_struct
*space_chain
;
7890 ssd_chain_struct
*subspace_chain
;
7892 /* Walk through each space. */
7893 for (space_chain
= space_dict_root
;
7895 space_chain
= space_chain
->sd_next
)
7897 if (space_chain
->sd_seg
== seg
)
7899 /* Walk through each subspace within each space looking for
7900 the correct mapping. */
7901 for (subspace_chain
= space_chain
->sd_subspaces
;
7903 subspace_chain
= subspace_chain
->ssd_next
)
7904 if (subspace_chain
->ssd_subseg
== (int) subseg
)
7905 return subspace_chain
;
7909 /* No mapping from subsegment to subspace found. Return NULL. */
7913 /* Given a number, try and find a space with the name number.
7915 Return a pointer to a space dictionary chain entry for the space
7916 that was found or NULL on failure. */
7918 static sd_chain_struct
*
7919 pa_find_space_by_number (number
)
7922 sd_chain_struct
*space_chain
;
7924 for (space_chain
= space_dict_root
;
7926 space_chain
= space_chain
->sd_next
)
7928 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
7932 /* No appropriate space found. Return NULL. */
7936 /* Return the starting address for the given subspace. If the starting
7937 address is unknown then return zero. */
7940 pa_subspace_start (space
, quadrant
)
7941 sd_chain_struct
*space
;
7944 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
7945 is not correct for the PA OSF1 port. */
7946 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
7948 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
7955 /* FIXME. Needs documentation. */
7957 pa_next_subseg (space
)
7958 sd_chain_struct
*space
;
7961 space
->sd_last_subseg
++;
7962 return space
->sd_last_subseg
;
7966 /* Helper function for pa_stringer. Used to find the end of
7973 unsigned int c
= *s
& CHAR_MASK
;
7976 /* We must have a valid space and subspace. */
7977 pa_check_current_space_and_subspace ();
7991 /* Handle a .STRING type pseudo-op. */
7994 pa_stringer (append_zero
)
7997 char *s
, num_buf
[4];
8001 /* Preprocess the string to handle PA-specific escape sequences.
8002 For example, \xDD where DD is a hexidecimal number should be
8003 changed to \OOO where OOO is an octal number. */
8005 /* Skip the opening quote. */
8006 s
= input_line_pointer
+ 1;
8008 while (is_a_char (c
= pa_stringer_aux (s
++)))
8015 /* Handle \x<num>. */
8018 unsigned int number
;
8023 /* Get pas the 'x'. */
8025 for (num_digit
= 0, number
= 0, dg
= *s
;
8027 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
8028 || (dg
>= 'A' && dg
<= 'F'));
8032 number
= number
* 16 + dg
- '0';
8033 else if (dg
>= 'a' && dg
<= 'f')
8034 number
= number
* 16 + dg
- 'a' + 10;
8036 number
= number
* 16 + dg
- 'A' + 10;
8046 sprintf (num_buf
, "%02o", number
);
8049 sprintf (num_buf
, "%03o", number
);
8052 for (i
= 0; i
<= num_digit
; i
++)
8053 s_start
[i
] = num_buf
[i
];
8057 /* This might be a "\"", skip over the escaped char. */
8064 stringer (append_zero
);
8065 pa_undefine_label ();
8068 /* Handle a .VERSION pseudo-op. */
8075 pa_undefine_label ();
8080 /* Handle a .COMPILER pseudo-op. */
8083 pa_compiler (unused
)
8086 obj_som_compiler (0);
8087 pa_undefine_label ();
8092 /* Handle a .COPYRIGHT pseudo-op. */
8095 pa_copyright (unused
)
8099 pa_undefine_label ();
8102 /* Just like a normal cons, but when finished we have to undefine
8103 the latest space label. */
8110 pa_undefine_label ();
8113 /* Switch to the data space. As usual delete our label. */
8120 current_space
= is_defined_space ("$PRIVATE$");
8122 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
8125 pa_undefine_label ();
8128 /* Like float_cons, but we need to undefine our label. */
8131 pa_float_cons (float_type
)
8134 float_cons (float_type
);
8135 pa_undefine_label ();
8138 /* Like s_fill, but delete our label when finished. */
8145 /* We must have a valid space and subspace. */
8146 pa_check_current_space_and_subspace ();
8150 pa_undefine_label ();
8153 /* Like lcomm, but delete our label when finished. */
8156 pa_lcomm (needs_align
)
8160 /* We must have a valid space and subspace. */
8161 pa_check_current_space_and_subspace ();
8164 s_lcomm (needs_align
);
8165 pa_undefine_label ();
8168 /* Like lsym, but delete our label when finished. */
8175 /* We must have a valid space and subspace. */
8176 pa_check_current_space_and_subspace ();
8180 pa_undefine_label ();
8183 /* Switch to the text space. Like s_text, but delete our
8184 label when finished. */
8190 current_space
= is_defined_space ("$TEXT$");
8192 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
8196 pa_undefine_label ();
8199 /* On the PA relocations which involve function symbols must not be
8200 adjusted. This so that the linker can know when/how to create argument
8201 relocation stubs for indirect calls and calls to static functions.
8203 "T" field selectors create DLT relative fixups for accessing
8204 globals and statics in PIC code; each DLT relative fixup creates
8205 an entry in the DLT table. The entries contain the address of
8206 the final target (eg accessing "foo" would create a DLT entry
8207 with the address of "foo").
8209 Unfortunately, the HP linker doesn't take into account any addend
8210 when generating the DLT; so accessing $LIT$+8 puts the address of
8211 $LIT$ into the DLT rather than the address of $LIT$+8.
8213 The end result is we can't perform relocation symbol reductions for
8214 any fixup which creates entries in the DLT (eg they use "T" field
8217 Reject reductions involving symbols with external scope; such
8218 reductions make life a living hell for object file editors.
8220 FIXME. Also reject R_HPPA relocations which are 32bits wide in
8221 the code space. The SOM BFD backend doesn't know how to pull the
8222 right bits out of an instruction. */
8225 hppa_fix_adjustable (fixp
)
8228 struct hppa_fix_struct
*hppa_fix
;
8230 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8233 /* Reject reductions of symbols in 32bit relocs. */
8234 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
8237 /* Reject reductions of symbols in sym1-sym2 expressions when
8238 the fixup will occur in a CODE subspace.
8240 XXX FIXME: Long term we probably want to reject all of these;
8241 for example reducing in the debug section would lose if we ever
8242 supported using the optimizing hp linker. */
8245 && (hppa_fix
->segment
->flags
& SEC_CODE
))
8247 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
8248 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
8252 /* We can't adjust any relocs that use LR% and RR% field selectors.
8253 That confuses the HP linker. */
8254 if (hppa_fix
->fx_r_field
== e_lrsel
8255 || hppa_fix
->fx_r_field
== e_rrsel
8256 || hppa_fix
->fx_r_field
== e_nlrsel
)
8260 /* Reject reductions of symbols in DLT relative relocs,
8261 relocations with plabels. */
8262 if (hppa_fix
->fx_r_field
== e_tsel
8263 || hppa_fix
->fx_r_field
== e_ltsel
8264 || hppa_fix
->fx_r_field
== e_rtsel
8265 || hppa_fix
->fx_r_field
== e_psel
8266 || hppa_fix
->fx_r_field
== e_rpsel
8267 || hppa_fix
->fx_r_field
== e_lpsel
)
8270 if (fixp
->fx_addsy
&& S_IS_EXTERNAL (fixp
->fx_addsy
))
8273 /* Reject absolute calls (jumps). */
8274 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
8277 /* Reject reductions of function symbols. */
8278 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
8284 /* Return nonzero if the fixup in FIXP will require a relocation,
8285 even it if appears that the fixup could be completely handled
8289 hppa_force_relocation (fixp
)
8292 struct hppa_fix_struct
*hppa_fixp
;
8295 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8297 if (fixp
->fx_r_type
== R_HPPA_ENTRY
|| fixp
->fx_r_type
== R_HPPA_EXIT
8298 || fixp
->fx_r_type
== R_HPPA_BEGIN_BRTAB
8299 || fixp
->fx_r_type
== R_HPPA_END_BRTAB
8300 || fixp
->fx_r_type
== R_HPPA_BEGIN_TRY
8301 || fixp
->fx_r_type
== R_HPPA_END_TRY
8302 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
8303 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
8307 #define arg_reloc_stub_needed(CALLER, CALLEE) \
8308 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
8311 /* It is necessary to force PC-relative calls/jumps to have a relocation
8312 entry if they're going to need either a argument relocation or long
8313 call stub. FIXME. Can't we need the same for absolute calls? */
8314 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
8315 && (arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
8316 symbol_get_bfdsym (fixp
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
8317 hppa_fixp
->fx_arg_reloc
)))
8320 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
8321 - md_pcrel_from (fixp
));
8322 /* Now check and see if we're going to need a long-branch stub. */
8323 if (fixp
->fx_r_type
== R_HPPA_PCREL_CALL
8324 && (distance
> 262143 || distance
< -262144))
8327 if (fixp
->fx_r_type
== R_HPPA_ABS_CALL
)
8329 #undef arg_reloc_stub_needed
8331 /* No need (yet) to force another relocations to be emitted. */
8335 /* Now for some ELF specific code. FIXME. */
8337 /* Mark the end of a function so that it's possible to compute
8338 the size of the function in hppa_elf_final_processing. */
8341 hppa_elf_mark_end_of_function ()
8343 /* ELF does not have EXIT relocations. All we do is create a
8344 temporary symbol marking the end of the function. */
8345 char *name
= (char *)
8346 xmalloc (strlen ("L$\001end_") +
8347 strlen (S_GET_NAME (last_call_info
->start_symbol
)) + 1);
8353 strcpy (name
, "L$\001end_");
8354 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
8356 /* If we have a .exit followed by a .procend, then the
8357 symbol will have already been defined. */
8358 symbolP
= symbol_find (name
);
8361 /* The symbol has already been defined! This can
8362 happen if we have a .exit followed by a .procend.
8364 This is *not* an error. All we want to do is free
8365 the memory we just allocated for the name and continue. */
8370 /* symbol value should be the offset of the
8371 last instruction of the function */
8372 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
8376 S_CLEAR_EXTERNAL (symbolP
);
8377 symbol_table_insert (symbolP
);
8381 last_call_info
->end_symbol
= symbolP
;
8383 as_bad (_("Symbol '%s' could not be created."), name
);
8387 as_bad (_("No memory for symbol name."));
8391 /* For ELF, this function serves one purpose: to setup the st_size
8392 field of STT_FUNC symbols. To do this, we need to scan the
8393 call_info structure list, determining st_size in by taking the
8394 difference in the address of the beginning/end marker symbols. */
8397 elf_hppa_final_processing ()
8399 struct call_info
*call_info_pointer
;
8401 for (call_info_pointer
= call_info_root
;
8403 call_info_pointer
= call_info_pointer
->ci_next
)
8405 elf_symbol_type
*esym
8406 = ((elf_symbol_type
*)
8407 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
8408 esym
->internal_elf_sym
.st_size
=
8409 S_GET_VALUE (call_info_pointer
->end_symbol
)
8410 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;
8418 if (debug_type
== DEBUG_DWARF2
)