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 /* ",*" is a valid condition. */
2798 else if (*args
!= 'U')
2799 as_bad (_("Invalid Unit Instruction Condition."));
2801 opcode
|= cmpltr
<< 13;
2802 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2810 /* Handle a nullification completer for branch instructions. */
2812 nullif
= pa_parse_nullif (&s
);
2813 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2815 /* Handle a nullification completer for copr and spop insns. */
2817 nullif
= pa_parse_nullif (&s
);
2818 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2820 /* Handle ,%r2 completer for new syntax branches. */
2822 if (*s
== ',' && strncasecmp (s
+ 1, "%r2", 3) == 0)
2824 else if (*s
== ',' && strncasecmp (s
+ 1, "%rp", 3) == 0)
2830 /* Handle 3 bit entry into the fp compare array. Valid values
2831 are 0..6 inclusive. */
2835 if (the_insn
.exp
.X_op
== O_constant
)
2837 num
= evaluate_absolute (&the_insn
);
2838 CHECK_FIELD (num
, 6, 0, 0);
2840 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2845 /* Handle 3 bit entry into the fp compare array. Valid values
2846 are 0..6 inclusive. */
2849 if (the_insn
.exp
.X_op
== O_constant
)
2852 num
= evaluate_absolute (&the_insn
);
2853 CHECK_FIELD (num
, 6, 0, 0);
2854 num
= (num
+ 1) ^ 1;
2855 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2860 /* Handle graphics test completers for ftest */
2863 num
= pa_parse_ftest_gfx_completer (&s
);
2864 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2867 /* Handle a 11 bit immediate at 31. */
2869 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2872 if (the_insn
.exp
.X_op
== O_constant
)
2874 num
= evaluate_absolute (&the_insn
);
2875 CHECK_FIELD (num
, 1023, -1024, 0);
2876 low_sign_unext (num
, 11, &num
);
2877 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2881 if (is_DP_relative (the_insn
.exp
))
2882 the_insn
.reloc
= R_HPPA_GOTOFF
;
2883 else if (is_PC_relative (the_insn
.exp
))
2884 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2886 the_insn
.reloc
= R_HPPA
;
2887 the_insn
.format
= 11;
2891 /* Handle a 14 bit immediate at 31. */
2893 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2896 if (the_insn
.exp
.X_op
== O_constant
)
2900 /* XXX the completer stored away tibits of information
2901 for us to extract. We need a cleaner way to do this.
2902 Now that we have lots of letters again, it would be
2903 good to rethink this. */
2904 m
= (opcode
& (1 << 8)) != 0;
2905 a
= (opcode
& (1 << 9)) != 0;
2906 opcode
&= ~ (3 << 8);
2907 num
= evaluate_absolute (&the_insn
);
2908 if ((a
== 1 && num
>= 0) || (a
== 0 && num
< 0))
2910 CHECK_FIELD (num
, 8191, -8192, 0);
2911 low_sign_unext (num
, 14, &num
);
2912 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2919 /* Handle a 14 bit immediate at 31. */
2921 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2924 if (the_insn
.exp
.X_op
== O_constant
)
2928 /* XXX the completer stored away tibits of information
2929 for us to extract. We need a cleaner way to do this.
2930 Now that we have lots of letters again, it would be
2931 good to rethink this. */
2932 m
= (opcode
& (1 << 8)) != 0;
2933 a
= (opcode
& (1 << 9)) != 0;
2934 opcode
&= ~ (3 << 8);
2935 num
= evaluate_absolute (&the_insn
);
2936 if ((a
== 1 && num
< 0) || (a
== 0 && num
> 0))
2940 CHECK_FIELD (num
, 8191, -8192, 0);
2945 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
2952 /* Handle 14 bit immediated, shifted left three times. */
2954 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2957 if (the_insn
.exp
.X_op
== O_constant
)
2959 num
= evaluate_absolute (&the_insn
);
2962 CHECK_FIELD (num
, 8191, -8192, 0);
2967 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 4);
2971 if (is_DP_relative (the_insn
.exp
))
2972 the_insn
.reloc
= R_HPPA_GOTOFF
;
2973 else if (is_PC_relative (the_insn
.exp
))
2974 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2976 the_insn
.reloc
= R_HPPA
;
2977 the_insn
.format
= 14;
2982 /* Handle 14 bit immediate, shifted left twice. */
2984 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2987 if (the_insn
.exp
.X_op
== O_constant
)
2989 num
= evaluate_absolute (&the_insn
);
2992 CHECK_FIELD (num
, 8191, -8192, 0);
2997 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3001 if (is_DP_relative (the_insn
.exp
))
3002 the_insn
.reloc
= R_HPPA_GOTOFF
;
3003 else if (is_PC_relative (the_insn
.exp
))
3004 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3006 the_insn
.reloc
= R_HPPA
;
3007 the_insn
.format
= 14;
3011 /* Handle a 14 bit immediate at 31. */
3013 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3016 if (the_insn
.exp
.X_op
== O_constant
)
3018 num
= evaluate_absolute (&the_insn
);
3019 CHECK_FIELD (num
, 8191, -8192, 0);
3020 low_sign_unext (num
, 14, &num
);
3021 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
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 21 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
>> 11, 1048575, -1048576, 0);
3044 dis_assemble_21 (num
, &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
= 21;
3059 /* Handle a 12 bit branch displacement. */
3061 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3065 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
3067 unsigned int w1
, w
, result
;
3069 num
= evaluate_absolute (&the_insn
);
3072 as_bad (_("Branch to unaligned address"));
3075 CHECK_FIELD (num
, 8199, -8184, 0);
3076 sign_unext ((num
- 8) >> 2, 12, &result
);
3077 dis_assemble_12 (result
, &w1
, &w
);
3078 INSERT_FIELD_AND_CONTINUE (opcode
, ((w1
<< 2) | w
), 0);
3082 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3083 the_insn
.format
= 12;
3084 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3085 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3090 /* Handle a 17 bit branch displacement. */
3092 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3096 if (!the_insn
.exp
.X_add_symbol
3097 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3100 unsigned int w2
, w1
, w
, result
;
3102 num
= evaluate_absolute (&the_insn
);
3105 as_bad (_("Branch to unaligned address"));
3108 CHECK_FIELD (num
, 262143, -262144, 0);
3110 if (the_insn
.exp
.X_add_symbol
)
3113 sign_unext (num
>> 2, 17, &result
);
3114 dis_assemble_17 (result
, &w1
, &w2
, &w
);
3115 INSERT_FIELD_AND_CONTINUE (opcode
,
3116 ((w2
<< 2) | (w1
<< 16) | w
), 0);
3120 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3121 the_insn
.format
= 17;
3122 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3123 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3127 /* Handle a 22 bit branch displacement. */
3129 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3133 if (!the_insn
.exp
.X_add_symbol
3134 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3137 unsigned int w3
, w2
, w1
, w
, result
;
3139 num
= evaluate_absolute (&the_insn
);
3142 as_bad (_("Branch to unaligned address"));
3145 CHECK_FIELD (num
, 8388607, -8388608, 0);
3147 if (the_insn
.exp
.X_add_symbol
)
3150 sign_unext (num
>> 2, 22, &result
);
3151 dis_assemble_22 (result
, &w3
, &w1
, &w2
, &w
);
3152 INSERT_FIELD_AND_CONTINUE (opcode
,
3153 ((w3
<< 21) | (w2
<< 2)
3159 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3160 the_insn
.format
= 22;
3161 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3162 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3166 /* Handle an absolute 17 bit branch target. */
3168 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3172 if (!the_insn
.exp
.X_add_symbol
3173 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3176 unsigned int w2
, w1
, w
, result
;
3178 num
= evaluate_absolute (&the_insn
);
3181 as_bad (_("Branch to unaligned address"));
3184 CHECK_FIELD (num
, 262143, -262144, 0);
3186 if (the_insn
.exp
.X_add_symbol
)
3189 sign_unext (num
>> 2, 17, &result
);
3190 dis_assemble_17 (result
, &w1
, &w2
, &w
);
3191 INSERT_FIELD_AND_CONTINUE (opcode
,
3192 ((w2
<< 2) | (w1
<< 16) | w
), 0);
3196 the_insn
.reloc
= R_HPPA_ABS_CALL
;
3197 the_insn
.format
= 17;
3198 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3199 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3203 /* Handle '%r1' implicit operand of addil instruction. */
3205 if (*s
== ',' && *(s
+ 1) == '%' && *(s
+ 3) == '1'
3206 && (*(s
+ 2) == 'r' || *(s
+ 2) == 'R'))
3214 /* Handle '%sr0,%r31' implicit operand of be,l instruction. */
3216 if (strncasecmp (s
, "%sr0,%r31", 9) != 0)
3221 /* Handle immediate value of 0 for ordered load/store instructions. */
3228 /* Handle a 2 bit shift count at 25. */
3230 num
= pa_get_absolute_expression (&the_insn
, &s
);
3231 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3234 CHECK_FIELD (num
, 3, 1, strict
);
3235 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3237 /* Handle a 4 bit shift count at 25. */
3239 num
= pa_get_absolute_expression (&the_insn
, &s
);
3240 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3243 CHECK_FIELD (num
, 15, 0, strict
);
3244 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3246 /* Handle a 5 bit shift count at 26. */
3248 num
= pa_get_absolute_expression (&the_insn
, &s
);
3249 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3252 CHECK_FIELD (num
, 31, 0, strict
);
3253 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
3255 /* Handle a 6 bit shift count at 20,22:26. */
3257 num
= pa_get_absolute_expression (&the_insn
, &s
);
3258 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3261 CHECK_FIELD (num
, 63, 0, strict
);
3263 opcode
|= (num
& 0x20) << 6;
3264 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3266 /* Handle a 6 bit field length at 23,27:31. */
3269 num
= pa_get_absolute_expression (&the_insn
, &s
);
3270 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3273 CHECK_FIELD (num
, 64, 1, strict
);
3275 opcode
|= (num
& 0x20) << 3;
3276 num
= 31 - (num
& 0x1f);
3277 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3279 /* Handle a 6 bit field length at 19,27:31. */
3281 num
= pa_get_absolute_expression (&the_insn
, &s
);
3282 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3285 CHECK_FIELD (num
, 64, 1, strict
);
3287 opcode
|= (num
& 0x20) << 7;
3288 num
= 31 - (num
& 0x1f);
3289 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3291 /* Handle a 5 bit bit position at 26. */
3293 num
= pa_get_absolute_expression (&the_insn
, &s
);
3294 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3297 CHECK_FIELD (num
, 31, 0, strict
);
3298 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
3300 /* Handle a 6 bit bit position at 20,22:26. */
3302 num
= pa_get_absolute_expression (&the_insn
, &s
);
3303 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3306 CHECK_FIELD (num
, 63, 0, strict
);
3307 opcode
|= (num
& 0x20) << 6;
3308 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3310 /* Handle a 5 bit immediate at 10. */
3312 num
= pa_get_absolute_expression (&the_insn
, &s
);
3313 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3315 if (the_insn
.exp
.X_op
!= O_constant
)
3318 CHECK_FIELD (num
, 31, 0, strict
);
3319 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3321 /* Handle a 9 bit immediate at 28. */
3323 num
= pa_get_absolute_expression (&the_insn
, &s
);
3324 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3327 CHECK_FIELD (num
, 511, 1, strict
);
3328 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3330 /* Handle a 13 bit immediate at 18. */
3332 num
= pa_get_absolute_expression (&the_insn
, &s
);
3333 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3336 CHECK_FIELD (num
, 8191, 0, strict
);
3337 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
3339 /* Handle a 26 bit immediate at 31. */
3341 num
= pa_get_absolute_expression (&the_insn
, &s
);
3342 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3345 CHECK_FIELD (num
, 671108864, 0, strict
);
3346 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3348 /* Handle a 3 bit SFU identifier at 25. */
3351 as_bad (_("Invalid SFU identifier"));
3352 num
= pa_get_absolute_expression (&the_insn
, &s
);
3353 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3356 CHECK_FIELD (num
, 7, 0, strict
);
3357 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3359 /* Handle a 20 bit SOP field for spop0. */
3361 num
= pa_get_absolute_expression (&the_insn
, &s
);
3362 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3365 CHECK_FIELD (num
, 1048575, 0, strict
);
3366 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
3367 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3369 /* Handle a 15bit SOP field for spop1. */
3371 num
= pa_get_absolute_expression (&the_insn
, &s
);
3372 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3375 CHECK_FIELD (num
, 32767, 0, strict
);
3376 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
3378 /* Handle a 10bit SOP field for spop3. */
3380 num
= pa_get_absolute_expression (&the_insn
, &s
);
3381 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3384 CHECK_FIELD (num
, 1023, 0, strict
);
3385 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
3386 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3388 /* Handle a 15 bit SOP field for spop2. */
3390 num
= pa_get_absolute_expression (&the_insn
, &s
);
3391 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3394 CHECK_FIELD (num
, 32767, 0, strict
);
3395 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
3396 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3398 /* Handle a 3-bit co-processor ID field. */
3401 as_bad (_("Invalid COPR identifier"));
3402 num
= pa_get_absolute_expression (&the_insn
, &s
);
3403 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3406 CHECK_FIELD (num
, 7, 0, strict
);
3407 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3409 /* Handle a 22bit SOP field for copr. */
3411 num
= pa_get_absolute_expression (&the_insn
, &s
);
3412 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3415 CHECK_FIELD (num
, 4194303, 0, strict
);
3416 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
3417 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3419 /* Handle a source FP operand format completer. */
3421 if (*s
== ',' && *(s
+1) == 't')
3428 flag
= pa_parse_fp_cnv_format (&s
);
3429 the_insn
.fpof1
= flag
;
3430 if (flag
== W
|| flag
== UW
)
3432 if (flag
== DW
|| flag
== UDW
)
3434 if (flag
== QW
|| flag
== UQW
)
3436 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3438 /* Handle a destination FP operand format completer. */
3440 /* pa_parse_format needs the ',' prefix. */
3442 flag
= pa_parse_fp_cnv_format (&s
);
3443 the_insn
.fpof2
= flag
;
3444 if (flag
== W
|| flag
== UW
)
3446 if (flag
== DW
|| flag
== UDW
)
3448 if (flag
== QW
|| flag
== UQW
)
3450 opcode
|= flag
<< 13;
3451 if (the_insn
.fpof1
== SGL
3452 || the_insn
.fpof1
== DBL
3453 || the_insn
.fpof1
== QUAD
)
3455 if (the_insn
.fpof2
== SGL
3456 || the_insn
.fpof2
== DBL
3457 || the_insn
.fpof2
== QUAD
)
3459 else if (the_insn
.fpof2
== W
3460 || the_insn
.fpof2
== DW
3461 || the_insn
.fpof2
== QW
)
3463 else if (the_insn
.fpof2
== UW
3464 || the_insn
.fpof2
== UDW
3465 || the_insn
.fpof2
== UQW
)
3470 else if (the_insn
.fpof1
== W
3471 || the_insn
.fpof1
== DW
3472 || the_insn
.fpof1
== QW
)
3474 if (the_insn
.fpof2
== SGL
3475 || the_insn
.fpof2
== DBL
3476 || the_insn
.fpof2
== QUAD
)
3481 else if (the_insn
.fpof1
== UW
3482 || the_insn
.fpof1
== UDW
3483 || the_insn
.fpof1
== UQW
)
3485 if (the_insn
.fpof2
== SGL
3486 || the_insn
.fpof2
== DBL
3487 || the_insn
.fpof2
== QUAD
)
3492 flag
|= the_insn
.trunc
;
3493 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 15);
3495 /* Handle a source FP operand format completer. */
3497 flag
= pa_parse_fp_format (&s
);
3498 the_insn
.fpof1
= flag
;
3499 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3501 /* Handle a destination FP operand format completer. */
3503 /* pa_parse_format needs the ',' prefix. */
3505 flag
= pa_parse_fp_format (&s
);
3506 the_insn
.fpof2
= flag
;
3507 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
3509 /* Handle a source FP operand format completer at 20. */
3511 flag
= pa_parse_fp_format (&s
);
3512 the_insn
.fpof1
= flag
;
3513 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3515 /* Handle a floating point operand format at 26.
3516 Only allows single and double precision. */
3518 flag
= pa_parse_fp_format (&s
);
3524 the_insn
.fpof1
= flag
;
3530 as_bad (_("Invalid Floating Point Operand Format."));
3534 /* Handle all floating point registers. */
3538 /* Float target register. */
3540 /* This should be more strict. Small steps. */
3541 if (strict
&& *s
!= '%')
3543 num
= pa_parse_number (&s
, 0);
3544 CHECK_FIELD (num
, 31, 0, 0);
3545 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3547 /* Float target register with L/R selection. */
3550 struct pa_11_fp_reg_struct result
;
3552 /* This should be more strict. Small steps. */
3553 if (strict
&& *s
!= '%')
3555 pa_parse_number (&s
, &result
);
3556 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3557 opcode
|= result
.number_part
;
3559 /* 0x30 opcodes are FP arithmetic operation opcodes
3560 and need to be turned into 0x38 opcodes. This
3561 is not necessary for loads/stores. */
3562 if (need_pa11_opcode (&the_insn
, &result
)
3563 && ((opcode
& 0xfc000000) == 0x30000000))
3566 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
3569 /* Float operand 1. */
3572 struct pa_11_fp_reg_struct result
;
3574 /* This should be more strict. Small steps. */
3575 if (strict
&& *s
!= '%')
3577 pa_parse_number (&s
, &result
);
3578 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3579 opcode
|= result
.number_part
<< 21;
3580 if (need_pa11_opcode (&the_insn
, &result
))
3582 opcode
|= (result
.l_r_select
& 1) << 7;
3588 /* Float operand 1 with L/R selection. */
3592 struct pa_11_fp_reg_struct result
;
3594 /* This should be more strict. Small steps. */
3595 if (strict
&& *s
!= '%')
3597 pa_parse_number (&s
, &result
);
3598 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3599 opcode
|= result
.number_part
<< 21;
3600 opcode
|= (result
.l_r_select
& 1) << 7;
3604 /* Float operand 2. */
3607 struct pa_11_fp_reg_struct result
;
3609 /* This should be more strict. Small steps. */
3610 if (strict
&& *s
!= '%')
3612 pa_parse_number (&s
, &result
);
3613 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3614 opcode
|= (result
.number_part
& 0x1f) << 16;
3615 if (need_pa11_opcode (&the_insn
, &result
))
3617 opcode
|= (result
.l_r_select
& 1) << 12;
3623 /* Float operand 2 with L/R selection. */
3626 struct pa_11_fp_reg_struct result
;
3628 /* This should be more strict. Small steps. */
3629 if (strict
&& *s
!= '%')
3631 pa_parse_number (&s
, &result
);
3632 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3633 opcode
|= (result
.number_part
& 0x1f) << 16;
3634 opcode
|= (result
.l_r_select
& 1) << 12;
3638 /* Float operand 3 for fmpyfadd, fmpynfadd. */
3641 struct pa_11_fp_reg_struct result
;
3643 /* This should be more strict. Small steps. */
3644 if (strict
&& *s
!= '%')
3646 pa_parse_number (&s
, &result
);
3647 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3648 opcode
|= (result
.number_part
& 0x1c) << 11;
3649 opcode
|= (result
.number_part
& 0x3) << 9;
3650 opcode
|= (result
.l_r_select
& 1) << 8;
3654 /* Float mult operand 1 for fmpyadd, fmpysub */
3657 struct pa_11_fp_reg_struct result
;
3659 /* This should be more strict. Small steps. */
3660 if (strict
&& *s
!= '%')
3662 pa_parse_number (&s
, &result
);
3663 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3664 if (the_insn
.fpof1
== SGL
)
3666 if (result
.number_part
< 16)
3668 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3672 result
.number_part
&= 0xF;
3673 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3675 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
3678 /* Float mult operand 2 for fmpyadd, fmpysub */
3681 struct pa_11_fp_reg_struct result
;
3683 /* This should be more strict. Small steps. */
3684 if (strict
&& *s
!= '%')
3686 pa_parse_number (&s
, &result
);
3687 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3688 if (the_insn
.fpof1
== SGL
)
3690 if (result
.number_part
< 16)
3692 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3695 result
.number_part
&= 0xF;
3696 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3698 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
3701 /* Float mult target for fmpyadd, fmpysub */
3704 struct pa_11_fp_reg_struct result
;
3706 /* This should be more strict. Small steps. */
3707 if (strict
&& *s
!= '%')
3709 pa_parse_number (&s
, &result
);
3710 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3711 if (the_insn
.fpof1
== SGL
)
3713 if (result
.number_part
< 16)
3715 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3718 result
.number_part
&= 0xF;
3719 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3721 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
3724 /* Float add operand 1 for fmpyadd, fmpysub */
3727 struct pa_11_fp_reg_struct result
;
3729 /* This should be more strict. Small steps. */
3730 if (strict
&& *s
!= '%')
3732 pa_parse_number (&s
, &result
);
3733 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3734 if (the_insn
.fpof1
== SGL
)
3736 if (result
.number_part
< 16)
3738 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3741 result
.number_part
&= 0xF;
3742 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3744 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
3747 /* Float add target for fmpyadd, fmpysub */
3750 struct pa_11_fp_reg_struct result
;
3752 /* This should be more strict. Small steps. */
3753 if (strict
&& *s
!= '%')
3755 pa_parse_number (&s
, &result
);
3756 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3757 if (the_insn
.fpof1
== SGL
)
3759 if (result
.number_part
< 16)
3761 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3764 result
.number_part
&= 0xF;
3765 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3767 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
3770 /* Handle L/R register halves like 'x'. */
3773 struct pa_11_fp_reg_struct result
;
3775 if (strict
&& *s
!= '%')
3777 pa_parse_number (&s
, &result
);
3778 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3779 opcode
|= (result
.number_part
& 0x1f) << 16;
3780 if (need_pa11_opcode (&the_insn
, &result
))
3782 opcode
|= (result
.l_r_select
& 1) << 1;
3798 /* Check if the args matched. */
3801 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
3802 && !strcmp (insn
->name
, insn
[1].name
))
3810 as_bad (_("Invalid operands %s"), error_message
);
3817 the_insn
.opcode
= opcode
;
3820 /* Turn a string in input_line_pointer into a floating point constant of type
3821 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
3822 emitted is stored in *sizeP . An error message or NULL is returned. */
3824 #define MAX_LITTLENUMS 6
3827 md_atof (type
, litP
, sizeP
)
3833 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
3834 LITTLENUM_TYPE
*wordP
;
3866 return _("Bad call to MD_ATOF()");
3868 t
= atof_ieee (input_line_pointer
, type
, words
);
3870 input_line_pointer
= t
;
3871 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
3872 for (wordP
= words
; prec
--;)
3874 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
3875 litP
+= sizeof (LITTLENUM_TYPE
);
3880 /* Write out big-endian. */
3883 md_number_to_chars (buf
, val
, n
)
3888 number_to_chars_bigendian (buf
, val
, n
);
3891 /* Translate internal representation of relocation info to BFD target
3895 tc_gen_reloc (section
, fixp
)
3900 struct hppa_fix_struct
*hppa_fixp
;
3901 bfd_reloc_code_real_type code
;
3902 static arelent
*no_relocs
= NULL
;
3904 bfd_reloc_code_real_type
**codes
;
3908 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
3909 if (fixp
->fx_addsy
== 0)
3911 assert (hppa_fixp
!= 0);
3912 assert (section
!= 0);
3914 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
3916 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3917 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3918 codes
= (bfd_reloc_code_real_type
**) hppa_gen_reloc_type (stdoutput
,
3920 hppa_fixp
->fx_r_format
,
3921 hppa_fixp
->fx_r_field
,
3922 fixp
->fx_subsy
!= NULL
,
3923 symbol_get_bfdsym (fixp
->fx_addsy
));
3928 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
3931 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
3932 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
3933 for (i
= 0; i
< n_relocs
; i
++)
3934 relocs
[i
] = &reloc
[i
];
3936 relocs
[n_relocs
] = NULL
;
3939 switch (fixp
->fx_r_type
)
3942 assert (n_relocs
== 1);
3946 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3947 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3948 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
3949 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3950 reloc
->addend
= 0; /* default */
3952 assert (reloc
->howto
&& code
== reloc
->howto
->type
);
3954 /* Now, do any processing that is dependent on the relocation type. */
3957 case R_PARISC_DLTREL21L
:
3958 case R_PARISC_DLTREL14R
:
3959 case R_PARISC_DLTREL14F
:
3960 case R_PARISC_PLABEL32
:
3961 case R_PARISC_PLABEL21L
:
3962 case R_PARISC_PLABEL14R
:
3963 /* For plabel relocations, the addend of the
3964 relocation should be either 0 (no static link) or 2
3965 (static link required).
3967 FIXME: We always assume no static link!
3969 We also slam a zero addend into the DLT relative relocs;
3970 it doesn't make a lot of sense to use any addend since
3971 it gets you a different (eg unknown) DLT entry. */
3975 case R_PARISC_PCREL21L
:
3976 case R_PARISC_PCREL17R
:
3977 case R_PARISC_PCREL17F
:
3978 case R_PARISC_PCREL17C
:
3979 case R_PARISC_PCREL14R
:
3980 case R_PARISC_PCREL14F
:
3981 /* The constant is stored in the instruction. */
3982 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
3985 reloc
->addend
= fixp
->fx_offset
;
3992 /* Walk over reach relocation returned by the BFD backend. */
3993 for (i
= 0; i
< n_relocs
; i
++)
3997 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3998 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3999 relocs
[i
]->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
4000 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4005 /* The only time we ever use a R_COMP2 fixup is for the difference
4006 of two symbols. With that in mind we fill in all four
4007 relocs now and break out of the loop. */
4009 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4010 relocs
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[0]);
4011 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4012 relocs
[0]->addend
= 0;
4013 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4014 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4015 relocs
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[1]);
4016 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4017 relocs
[1]->addend
= 0;
4018 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4019 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
4020 relocs
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[2]);
4021 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4022 relocs
[2]->addend
= 0;
4023 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4024 relocs
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[3]);
4025 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4026 relocs
[3]->addend
= 0;
4027 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4028 relocs
[4]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[4]);
4029 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4030 relocs
[4]->addend
= 0;
4034 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
4040 /* For plabel relocations, the addend of the
4041 relocation should be either 0 (no static link) or 2
4042 (static link required).
4044 FIXME: We always assume no static link!
4046 We also slam a zero addend into the DLT relative relocs;
4047 it doesn't make a lot of sense to use any addend since
4048 it gets you a different (eg unknown) DLT entry. */
4049 relocs
[i
]->addend
= 0;
4064 /* There is no symbol or addend associated with these fixups. */
4065 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4066 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4067 relocs
[i
]->addend
= 0;
4073 /* There is no symbol associated with these fixups. */
4074 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4075 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4076 relocs
[i
]->addend
= fixp
->fx_offset
;
4080 relocs
[i
]->addend
= fixp
->fx_offset
;
4090 /* Process any machine dependent frag types. */
4093 md_convert_frag (abfd
, sec
, fragP
)
4095 register asection
*sec
;
4096 register fragS
*fragP
;
4098 unsigned int address
;
4100 if (fragP
->fr_type
== rs_machine_dependent
)
4102 switch ((int) fragP
->fr_subtype
)
4105 fragP
->fr_type
= rs_fill
;
4106 know (fragP
->fr_var
== 1);
4107 know (fragP
->fr_next
);
4108 address
= fragP
->fr_address
+ fragP
->fr_fix
;
4109 if (address
% fragP
->fr_offset
)
4112 fragP
->fr_next
->fr_address
4117 fragP
->fr_offset
= 0;
4123 /* Round up a section size to the appropriate boundary. */
4126 md_section_align (segment
, size
)
4130 int align
= bfd_get_section_alignment (stdoutput
, segment
);
4131 int align2
= (1 << align
) - 1;
4133 return (size
+ align2
) & ~align2
;
4136 /* Return the approximate size of a frag before relaxation has occurred. */
4138 md_estimate_size_before_relax (fragP
, segment
)
4139 register fragS
*fragP
;
4146 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
4152 CONST
char *md_shortopts
= "";
4153 struct option md_longopts
[] = {
4154 {NULL
, no_argument
, NULL
, 0}
4156 size_t md_longopts_size
= sizeof(md_longopts
);
4159 md_parse_option (c
, arg
)
4167 md_show_usage (stream
)
4172 /* We have no need to default values of symbols. */
4175 md_undefined_symbol (name
)
4181 /* Apply a fixup to an instruction. */
4184 md_apply_fix (fixP
, valp
)
4188 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
4189 struct hppa_fix_struct
*hppa_fixP
;
4190 long new_val
, result
= 0;
4191 unsigned int w1
, w2
, w
, resulti
;
4193 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
4194 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
4195 never be "applied" (they are just markers). Likewise for
4196 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
4198 if (fixP
->fx_r_type
== R_HPPA_ENTRY
4199 || fixP
->fx_r_type
== R_HPPA_EXIT
4200 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
4201 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
4202 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
4205 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
4206 fixups are considered not adjustable, which in turn causes
4207 adjust_reloc_syms to not set fx_offset. Ugh. */
4208 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
4210 fixP
->fx_offset
= *valp
;
4215 /* There should have been an HPPA specific fixup associated
4216 with the GAS fixup. */
4219 unsigned long buf_wd
= bfd_get_32 (stdoutput
, buf
);
4220 int fmt
= bfd_hppa_insn2fmt (buf_wd
);
4222 /* If there is a symbol associated with this fixup, then it's something
4223 which will need a SOM relocation (except for some PC-relative relocs).
4224 In such cases we should treat the "val" or "addend" as zero since it
4225 will be added in as needed from fx_offset in tc_gen_reloc. */
4226 if ((fixP
->fx_addsy
!= NULL
4227 || fixP
->fx_r_type
== R_HPPA_NONE
)
4232 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4234 /* These field selectors imply that we do not want an addend. */
4235 else if (hppa_fixP
->fx_r_field
== e_psel
4236 || hppa_fixP
->fx_r_field
== e_rpsel
4237 || hppa_fixP
->fx_r_field
== e_lpsel
4238 || hppa_fixP
->fx_r_field
== e_tsel
4239 || hppa_fixP
->fx_r_field
== e_rtsel
4240 || hppa_fixP
->fx_r_field
== e_ltsel
)
4241 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4242 /* This is truely disgusting. The machine independent code blindly
4243 adds in the value of the symbol being relocated against. Damn! */
4245 && fixP
->fx_addsy
!= NULL
4246 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
4247 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
4248 0, hppa_fixP
->fx_r_field
);
4251 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4253 /* Handle pc-relative exceptions from above. */
4254 #define arg_reloc_stub_needed(CALLER, CALLEE) \
4255 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
4256 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
4260 && !arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
4261 symbol_get_bfdsym (fixP
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
4262 hppa_fixP
->fx_arg_reloc
)
4264 && (((int)(*valp
) > -262144 && (int)(*valp
) < 262143) && fmt
!= 22)
4265 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
4267 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
4269 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4270 #undef arg_reloc_stub_needed
4274 /* Handle all opcodes with the 'j' operand type. */
4276 CHECK_FIELD (new_val
, 8191, -8192, 0);
4278 /* Mask off 14 bits to be changed. */
4279 bfd_put_32 (stdoutput
,
4280 bfd_get_32 (stdoutput
, buf
) & 0xffffc000,
4282 low_sign_unext (new_val
, 14, &resulti
);
4286 /* Handle all opcodes with the 'k' operand type. */
4288 CHECK_FIELD (new_val
, 2097152, 0, 0);
4290 /* Mask off 21 bits to be changed. */
4291 bfd_put_32 (stdoutput
,
4292 bfd_get_32 (stdoutput
, buf
) & 0xffe00000,
4294 dis_assemble_21 (new_val
, &resulti
);
4298 /* Handle all the opcodes with the 'i' operand type. */
4300 CHECK_FIELD (new_val
, 1023, -1023, 0);
4302 /* Mask off 11 bits to be changed. */
4303 bfd_put_32 (stdoutput
,
4304 bfd_get_32 (stdoutput
, buf
) & 0xffff800,
4306 low_sign_unext (new_val
, 11, &resulti
);
4310 /* Handle all the opcodes with the 'w' operand type. */
4312 CHECK_FIELD (new_val
, 8199, -8184, 0);
4314 /* Mask off 11 bits to be changed. */
4315 sign_unext ((new_val
- 8) >> 2, 12, &resulti
);
4316 bfd_put_32 (stdoutput
,
4317 bfd_get_32 (stdoutput
, buf
) & 0xffffe002,
4320 dis_assemble_12 (resulti
, &w1
, &w
);
4321 result
= ((w1
<< 2) | w
);
4324 /* Handle some of the opcodes with the 'W' operand type. */
4327 int distance
= *valp
;
4329 CHECK_FIELD (new_val
, 262143, -262144, 0);
4331 /* If this is an absolute branch (ie no link) with an out of
4332 range target, then we want to complain. */
4333 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
4334 && (distance
> 262143 || distance
< -262144)
4335 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
4336 CHECK_FIELD (distance
, 262143, -262144, 0);
4338 /* Mask off 17 bits to be changed. */
4339 bfd_put_32 (stdoutput
,
4340 bfd_get_32 (stdoutput
, buf
) & 0xffe0e002,
4342 sign_unext ((new_val
- 8) >> 2, 17, &resulti
);
4343 dis_assemble_17 (resulti
, &w1
, &w2
, &w
);
4344 result
= ((w2
<< 2) | (w1
<< 16) | w
);
4350 int distance
= *valp
, w3
;
4352 CHECK_FIELD (new_val
, 8388607, -8388608, 0);
4354 /* If this is an absolute branch (ie no link) with an out of
4355 range target, then we want to complain. */
4356 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
4357 && (distance
> 8388607 || distance
< -8388608)
4358 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
4359 CHECK_FIELD (distance
, 8388607, -8388608, 0);
4361 /* Mask off 22 bits to be changed. */
4362 bfd_put_32 (stdoutput
,
4363 bfd_get_32 (stdoutput
, buf
) & 0xfc00e002,
4365 sign_unext ((new_val
- 8) >> 2, 22, &resulti
);
4366 dis_assemble_22 (resulti
, &w3
, &w1
, &w2
, &w
);
4367 result
= ((w3
<< 21) | (w2
<< 2) | (w1
<< 16) | w
);
4373 bfd_put_32 (stdoutput
, new_val
, buf
);
4377 as_bad (_("Unknown relocation encountered in md_apply_fix."));
4381 /* Insert the relocation. */
4382 bfd_put_32 (stdoutput
, bfd_get_32 (stdoutput
, buf
) | result
, buf
);
4387 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
4388 (unsigned int) fixP
, fixP
->fx_r_type
);
4393 /* Exactly what point is a PC-relative offset relative TO?
4394 On the PA, they're relative to the address of the offset. */
4397 md_pcrel_from (fixP
)
4400 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
4403 /* Return nonzero if the input line pointer is at the end of
4407 is_end_of_statement ()
4409 return ((*input_line_pointer
== '\n')
4410 || (*input_line_pointer
== ';')
4411 || (*input_line_pointer
== '!'));
4414 /* Read a number from S. The number might come in one of many forms,
4415 the most common will be a hex or decimal constant, but it could be
4416 a pre-defined register (Yuk!), or an absolute symbol.
4418 Return a number or -1 for failure.
4420 When parsing PA-89 FP register numbers RESULT will be
4421 the address of a structure to return information about
4422 L/R half of FP registers, store results there as appropriate.
4424 pa_parse_number can not handle negative constants and will fail
4425 horribly if it is passed such a constant. */
4428 pa_parse_number (s
, result
)
4430 struct pa_11_fp_reg_struct
*result
;
4439 /* Skip whitespace before the number. */
4440 while (*p
== ' ' || *p
== '\t')
4443 /* Store info in RESULT if requested by caller. */
4446 result
->number_part
= -1;
4447 result
->l_r_select
= -1;
4453 /* Looks like a number. */
4456 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
4458 /* The number is specified in hex. */
4460 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
4461 || ((*p
>= 'A') && (*p
<= 'F')))
4464 num
= num
* 16 + *p
- '0';
4465 else if (*p
>= 'a' && *p
<= 'f')
4466 num
= num
* 16 + *p
- 'a' + 10;
4468 num
= num
* 16 + *p
- 'A' + 10;
4474 /* The number is specified in decimal. */
4475 while (isdigit (*p
))
4477 num
= num
* 10 + *p
- '0';
4482 /* Store info in RESULT if requested by the caller. */
4485 result
->number_part
= num
;
4487 if (IS_R_SELECT (p
))
4489 result
->l_r_select
= 1;
4492 else if (IS_L_SELECT (p
))
4494 result
->l_r_select
= 0;
4498 result
->l_r_select
= 0;
4503 /* The number might be a predefined register. */
4508 /* Tege hack: Special case for general registers as the general
4509 code makes a binary search with case translation, and is VERY
4514 if (*p
== 'e' && *(p
+ 1) == 't'
4515 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
4518 num
= *p
- '0' + 28;
4526 else if (!isdigit (*p
))
4529 as_bad (_("Undefined register: '%s'."), name
);
4535 num
= num
* 10 + *p
++ - '0';
4536 while (isdigit (*p
));
4541 /* Do a normal register search. */
4542 while (is_part_of_name (c
))
4548 status
= reg_name_search (name
);
4554 as_bad (_("Undefined register: '%s'."), name
);
4560 /* Store info in RESULT if requested by caller. */
4563 result
->number_part
= num
;
4564 if (IS_R_SELECT (p
- 1))
4565 result
->l_r_select
= 1;
4566 else if (IS_L_SELECT (p
- 1))
4567 result
->l_r_select
= 0;
4569 result
->l_r_select
= 0;
4574 /* And finally, it could be a symbol in the absolute section which
4575 is effectively a constant. */
4579 while (is_part_of_name (c
))
4585 if ((sym
= symbol_find (name
)) != NULL
)
4587 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
4588 num
= S_GET_VALUE (sym
);
4592 as_bad (_("Non-absolute symbol: '%s'."), name
);
4598 /* There is where we'd come for an undefined symbol
4599 or for an empty string. For an empty string we
4600 will return zero. That's a concession made for
4601 compatability with the braindamaged HP assemblers. */
4607 as_bad (_("Undefined absolute constant: '%s'."), name
);
4613 /* Store info in RESULT if requested by caller. */
4616 result
->number_part
= num
;
4617 if (IS_R_SELECT (p
- 1))
4618 result
->l_r_select
= 1;
4619 else if (IS_L_SELECT (p
- 1))
4620 result
->l_r_select
= 0;
4622 result
->l_r_select
= 0;
4630 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
4632 /* Given NAME, find the register number associated with that name, return
4633 the integer value associated with the given name or -1 on failure. */
4636 reg_name_search (name
)
4639 int middle
, low
, high
;
4643 high
= REG_NAME_CNT
- 1;
4647 middle
= (low
+ high
) / 2;
4648 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
4654 return pre_defined_registers
[middle
].value
;
4656 while (low
<= high
);
4662 /* Return nonzero if the given INSN and L/R information will require
4663 a new PA-1.1 opcode. */
4666 need_pa11_opcode (insn
, result
)
4668 struct pa_11_fp_reg_struct
*result
;
4670 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
4672 /* If this instruction is specific to a particular architecture,
4673 then set a new architecture. */
4674 if (bfd_get_mach (stdoutput
) < pa11
)
4676 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
4677 as_warn (_("could not update architecture and machine"));
4685 /* Parse a condition for a fcmp instruction. Return the numerical
4686 code associated with the condition. */
4689 pa_parse_fp_cmp_cond (s
)
4696 for (i
= 0; i
< 32; i
++)
4698 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
4699 strlen (fp_cond_map
[i
].string
)) == 0)
4701 cond
= fp_cond_map
[i
].cond
;
4702 *s
+= strlen (fp_cond_map
[i
].string
);
4703 /* If not a complete match, back up the input string and
4705 if (**s
!= ' ' && **s
!= '\t')
4707 *s
-= strlen (fp_cond_map
[i
].string
);
4710 while (**s
== ' ' || **s
== '\t')
4716 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
4718 /* Advance over the bogus completer. */
4719 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4725 /* Parse a graphics test complete for ftest. */
4728 pa_parse_ftest_gfx_completer (s
)
4734 if (strncasecmp (*s
, "acc8", 4) == 0)
4739 else if (strncasecmp (*s
, "acc6", 4) == 0)
4744 else if (strncasecmp (*s
, "acc4", 4) == 0)
4749 else if (strncasecmp (*s
, "acc2", 4) == 0)
4754 else if (strncasecmp (*s
, "acc", 3) == 0)
4759 else if (strncasecmp (*s
, "rej8", 4) == 0)
4764 else if (strncasecmp (*s
, "rej", 3) == 0)
4772 as_bad (_("Invalid FTEST completer: %s"), *s
);
4778 /* Parse an FP operand format completer returning the completer
4781 static fp_operand_format
4782 pa_parse_fp_cnv_format (s
)
4791 if (strncasecmp (*s
, "sgl", 3) == 0)
4796 else if (strncasecmp (*s
, "dbl", 3) == 0)
4801 else if (strncasecmp (*s
, "quad", 4) == 0)
4806 else if (strncasecmp (*s
, "w", 1) == 0)
4811 else if (strncasecmp (*s
, "uw", 2) == 0)
4816 else if (strncasecmp (*s
, "dw", 2) == 0)
4821 else if (strncasecmp (*s
, "udw", 3) == 0)
4826 else if (strncasecmp (*s
, "qw", 2) == 0)
4831 else if (strncasecmp (*s
, "uqw", 3) == 0)
4838 format
= ILLEGAL_FMT
;
4839 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
4846 /* Parse an FP operand format completer returning the completer
4849 static fp_operand_format
4850 pa_parse_fp_format (s
)
4859 if (strncasecmp (*s
, "sgl", 3) == 0)
4864 else if (strncasecmp (*s
, "dbl", 3) == 0)
4869 else if (strncasecmp (*s
, "quad", 4) == 0)
4876 format
= ILLEGAL_FMT
;
4877 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
4884 /* Convert from a selector string into a selector type. */
4887 pa_chk_field_selector (str
)
4890 int middle
, low
, high
;
4894 /* Read past any whitespace. */
4895 /* FIXME: should we read past newlines and formfeeds??? */
4896 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
4899 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
4900 name
[0] = tolower ((*str
)[0]),
4902 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
4903 name
[0] = tolower ((*str
)[0]),
4904 name
[1] = tolower ((*str
)[1]),
4906 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
4907 name
[0] = tolower ((*str
)[0]),
4908 name
[1] = tolower ((*str
)[1]),
4909 name
[2] = tolower ((*str
)[2]),
4915 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
4919 middle
= (low
+ high
) / 2;
4920 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
4927 *str
+= strlen (name
) + 1;
4929 if (selector_table
[middle
].field_selector
== e_nsel
)
4932 return selector_table
[middle
].field_selector
;
4935 while (low
<= high
);
4940 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
4943 get_expression (str
)
4949 save_in
= input_line_pointer
;
4950 input_line_pointer
= str
;
4951 seg
= expression (&the_insn
.exp
);
4952 if (!(seg
== absolute_section
4953 || seg
== undefined_section
4954 || SEG_NORMAL (seg
)))
4956 as_warn (_("Bad segment in expression."));
4957 expr_end
= input_line_pointer
;
4958 input_line_pointer
= save_in
;
4961 expr_end
= input_line_pointer
;
4962 input_line_pointer
= save_in
;
4966 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
4968 pa_get_absolute_expression (insn
, strp
)
4974 insn
->field_selector
= pa_chk_field_selector (strp
);
4975 save_in
= input_line_pointer
;
4976 input_line_pointer
= *strp
;
4977 expression (&insn
->exp
);
4978 /* This is not perfect, but is a huge improvement over doing nothing.
4980 The PA assembly syntax is ambigious in a variety of ways. Consider
4981 this string "4 %r5" Is that the number 4 followed by the register
4982 r5, or is that 4 MOD 5?
4984 If we get a modulo expresion When looking for an absolute, we try
4985 again cutting off the input string at the first whitespace character. */
4986 if (insn
->exp
.X_op
== O_modulus
)
4991 input_line_pointer
= *strp
;
4993 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
4999 retval
= pa_get_absolute_expression (insn
, strp
);
5001 input_line_pointer
= save_in
;
5003 return evaluate_absolute (insn
);
5005 /* When in strict mode we have a non-match, fix up the pointers
5006 and return to our caller. */
5007 if (insn
->exp
.X_op
!= O_constant
&& strict
)
5009 expr_end
= input_line_pointer
;
5010 input_line_pointer
= save_in
;
5013 if (insn
->exp
.X_op
!= O_constant
)
5015 as_bad (_("Bad segment (should be absolute)."));
5016 expr_end
= input_line_pointer
;
5017 input_line_pointer
= save_in
;
5020 expr_end
= input_line_pointer
;
5021 input_line_pointer
= save_in
;
5022 return evaluate_absolute (insn
);
5025 /* Evaluate an absolute expression EXP which may be modified by
5026 the selector FIELD_SELECTOR. Return the value of the expression. */
5028 evaluate_absolute (insn
)
5033 int field_selector
= insn
->field_selector
;
5036 value
= exp
.X_add_number
;
5038 switch (field_selector
)
5044 /* If bit 21 is on then add 0x800 and arithmetic shift right 11 bits. */
5046 if (value
& 0x00000400)
5048 value
= (value
& 0xfffff800) >> 11;
5051 /* Sign extend from bit 21. */
5053 if (value
& 0x00000400)
5054 value
|= 0xfffff800;
5059 /* Arithmetic shift right 11 bits. */
5061 value
= (value
& 0xfffff800) >> 11;
5064 /* Set bits 0-20 to zero. */
5066 value
= value
& 0x7ff;
5069 /* Add 0x800 and arithmetic shift right 11 bits. */
5072 value
= (value
& 0xfffff800) >> 11;
5075 /* Set bitgs 0-21 to one. */
5077 value
|= 0xfffff800;
5080 #define RSEL_ROUND(c) (((c) + 0x1000) & ~0x1fff)
5082 value
= (RSEL_ROUND (value
) & 0x7ff) + (value
- RSEL_ROUND (value
));
5086 value
= (RSEL_ROUND (value
) >> 11) & 0x1fffff;
5091 BAD_CASE (field_selector
);
5097 /* Given an argument location specification return the associated
5098 argument location number. */
5101 pa_build_arg_reloc (type_name
)
5105 if (strncasecmp (type_name
, "no", 2) == 0)
5107 if (strncasecmp (type_name
, "gr", 2) == 0)
5109 else if (strncasecmp (type_name
, "fr", 2) == 0)
5111 else if (strncasecmp (type_name
, "fu", 2) == 0)
5114 as_bad (_("Invalid argument location: %s\n"), type_name
);
5119 /* Encode and return an argument relocation specification for
5120 the given register in the location specified by arg_reloc. */
5123 pa_align_arg_reloc (reg
, arg_reloc
)
5125 unsigned int arg_reloc
;
5127 unsigned int new_reloc
;
5129 new_reloc
= arg_reloc
;
5145 as_bad (_("Invalid argument description: %d"), reg
);
5151 /* Parse a PA nullification completer (,n). Return nonzero if the
5152 completer was found; return zero if no completer was found. */
5164 if (strncasecmp (*s
, "n", 1) == 0)
5168 as_bad (_("Invalid Nullification: (%c)"), **s
);
5177 /* Parse a non-negated compare/subtract completer returning the
5178 number (for encoding in instrutions) of the given completer.
5180 ISBRANCH specifies whether or not this is parsing a condition
5181 completer for a branch (vs a nullification completer for a
5182 computational instruction. */
5185 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
5190 char *name
= *s
+ 1;
5199 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5205 if (strcmp (name
, "=") == 0)
5209 else if (strcmp (name
, "<") == 0)
5213 else if (strcmp (name
, "<=") == 0)
5217 else if (strcmp (name
, "<<") == 0)
5221 else if (strcmp (name
, "<<=") == 0)
5225 else if (strcasecmp (name
, "sv") == 0)
5229 else if (strcasecmp (name
, "od") == 0)
5233 /* If we have something like addb,n then there is no condition
5235 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5247 /* Reset pointers if this was really a ,n for a branch instruction. */
5255 /* Parse a negated compare/subtract completer returning the
5256 number (for encoding in instrutions) of the given completer.
5258 ISBRANCH specifies whether or not this is parsing a condition
5259 completer for a branch (vs a nullification completer for a
5260 computational instruction. */
5263 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
5268 char *name
= *s
+ 1;
5277 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5283 if (strcasecmp (name
, "tr") == 0)
5287 else if (strcmp (name
, "<>") == 0)
5291 else if (strcmp (name
, ">=") == 0)
5295 else if (strcmp (name
, ">") == 0)
5299 else if (strcmp (name
, ">>=") == 0)
5303 else if (strcmp (name
, ">>") == 0)
5307 else if (strcasecmp (name
, "nsv") == 0)
5311 else if (strcasecmp (name
, "ev") == 0)
5315 /* If we have something like addb,n then there is no condition
5317 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5329 /* Reset pointers if this was really a ,n for a branch instruction. */
5338 /* Parse a 64 bit compare and branch completer returning the number (for
5339 encoding in instrutions) of the given completer.
5341 Nonnegated comparisons are returned as 0-7, negated comparisons are
5342 returned as 8-15. */
5345 pa_parse_cmpb_64_cmpltr (s
)
5349 char *name
= *s
+ 1;
5357 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5362 if (strcmp (name
, "*") == 0)
5366 else if (strcmp (name
, "*=") == 0)
5370 else if (strcmp (name
, "*<") == 0)
5374 else if (strcmp (name
, "*<=") == 0)
5378 else if (strcmp (name
, "*<<") == 0)
5382 else if (strcmp (name
, "*<<=") == 0)
5386 else if (strcasecmp (name
, "*sv") == 0)
5390 else if (strcasecmp (name
, "*od") == 0)
5394 else if (strcasecmp (name
, "*tr") == 0)
5398 else if (strcmp (name
, "*<>") == 0)
5402 else if (strcmp (name
, "*>=") == 0)
5406 else if (strcmp (name
, "*>") == 0)
5410 else if (strcmp (name
, "*>>=") == 0)
5414 else if (strcmp (name
, "*>>") == 0)
5418 else if (strcasecmp (name
, "*nsv") == 0)
5422 else if (strcasecmp (name
, "*ev") == 0)
5437 /* Parse a 64 bit compare immediate and branch completer returning the number
5438 (for encoding in instrutions) of the given completer. */
5441 pa_parse_cmpib_64_cmpltr (s
)
5445 char *name
= *s
+ 1;
5453 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5458 if (strcmp (name
, "*<<") == 0)
5462 else if (strcmp (name
, "*=") == 0)
5466 else if (strcmp (name
, "*<") == 0)
5470 else if (strcmp (name
, "*<=") == 0)
5474 else if (strcmp (name
, "*>>=") == 0)
5478 else if (strcmp (name
, "*<>") == 0)
5482 else if (strcasecmp (name
, "*>=") == 0)
5486 else if (strcasecmp (name
, "*>") == 0)
5501 /* Parse a non-negated addition completer returning the number
5502 (for encoding in instrutions) of the given completer.
5504 ISBRANCH specifies whether or not this is parsing a condition
5505 completer for a branch (vs a nullification completer for a
5506 computational instruction. */
5509 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
5514 char *name
= *s
+ 1;
5522 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5526 if (strcmp (name
, "=") == 0)
5530 else if (strcmp (name
, "<") == 0)
5534 else if (strcmp (name
, "<=") == 0)
5538 else if (strcasecmp (name
, "nuv") == 0)
5542 else if (strcasecmp (name
, "znv") == 0)
5546 else if (strcasecmp (name
, "sv") == 0)
5550 else if (strcasecmp (name
, "od") == 0)
5554 /* If we have something like addb,n then there is no condition
5556 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5567 /* Reset pointers if this was really a ,n for a branch instruction. */
5568 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5574 /* Parse a negated addition completer returning the number
5575 (for encoding in instrutions) of the given completer.
5577 ISBRANCH specifies whether or not this is parsing a condition
5578 completer for a branch (vs a nullification completer for a
5579 computational instruction). */
5582 pa_parse_neg_add_cmpltr (s
, isbranch
)
5587 char *name
= *s
+ 1;
5595 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5599 if (strcasecmp (name
, "tr") == 0)
5603 else if (strcmp (name
, "<>") == 0)
5607 else if (strcmp (name
, ">=") == 0)
5611 else if (strcmp (name
, ">") == 0)
5615 else if (strcasecmp (name
, "uv") == 0)
5619 else if (strcasecmp (name
, "vnz") == 0)
5623 else if (strcasecmp (name
, "nsv") == 0)
5627 else if (strcasecmp (name
, "ev") == 0)
5631 /* If we have something like addb,n then there is no condition
5633 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5644 /* Reset pointers if this was really a ,n for a branch instruction. */
5645 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5651 /* Parse a 64 bit wide mode add and branch completer returning the number (for
5652 encoding in instrutions) of the given completer. */
5655 pa_parse_addb_64_cmpltr (s
)
5659 char *name
= *s
+ 1;
5668 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5672 if (strcmp (name
, "=") == 0)
5676 else if (strcmp (name
, "<") == 0)
5680 else if (strcmp (name
, "<=") == 0)
5684 else if (strcasecmp (name
, "nuv") == 0)
5688 else if (strcasecmp (name
, "*=") == 0)
5692 else if (strcasecmp (name
, "*<") == 0)
5696 else if (strcasecmp (name
, "*<=") == 0)
5700 else if (strcmp (name
, "tr") == 0)
5704 else if (strcmp (name
, "<>") == 0)
5708 else if (strcmp (name
, ">=") == 0)
5712 else if (strcmp (name
, ">") == 0)
5716 else if (strcasecmp (name
, "uv") == 0)
5720 else if (strcasecmp (name
, "*<>") == 0)
5724 else if (strcasecmp (name
, "*>=") == 0)
5728 else if (strcasecmp (name
, "*>") == 0)
5732 /* If we have something like addb,n then there is no condition
5734 else if (strcasecmp (name
, "n") == 0)
5746 /* Reset pointers if this was really a ,n for a branch instruction. */
5754 /* Handle an alignment directive. Special so that we can update the
5755 alignment of the subspace if necessary. */
5759 /* We must have a valid space and subspace. */
5760 pa_check_current_space_and_subspace ();
5762 /* Let the generic gas code do most of the work. */
5763 s_align_bytes (bytes
);
5765 /* If bytes is a power of 2, then update the current subspace's
5766 alignment if necessary. */
5767 if (log2 (bytes
) != -1)
5768 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
5772 /* Handle a .BLOCK type pseudo-op. */
5780 unsigned int temp_size
;
5784 /* We must have a valid space and subspace. */
5785 pa_check_current_space_and_subspace ();
5788 temp_size
= get_absolute_expression ();
5790 /* Always fill with zeros, that's what the HP assembler does. */
5793 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
5794 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
5795 memset (p
, 0, temp_size
);
5797 /* Convert 2 bytes at a time. */
5799 for (i
= 0; i
< temp_size
; i
+= 2)
5801 md_number_to_chars (p
+ i
,
5803 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
5806 pa_undefine_label ();
5807 demand_empty_rest_of_line ();
5810 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
5818 /* The BRTAB relocations are only availble in SOM (to denote
5819 the beginning and end of branch tables). */
5820 char *where
= frag_more (0);
5822 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5823 NULL
, (offsetT
) 0, NULL
,
5824 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
5825 e_fsel
, 0, 0, NULL
);
5828 demand_empty_rest_of_line ();
5831 /* Handle a .begin_try and .end_try pseudo-op. */
5839 char *where
= frag_more (0);
5844 /* The TRY relocations are only availble in SOM (to denote
5845 the beginning and end of exception handling regions). */
5847 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5848 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
5849 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
5850 e_fsel
, 0, 0, NULL
);
5853 demand_empty_rest_of_line ();
5856 /* Handle a .CALL pseudo-op. This involves storing away information
5857 about where arguments are to be found so the linker can detect
5858 (and correct) argument location mismatches between caller and callee. */
5865 /* We must have a valid space and subspace. */
5866 pa_check_current_space_and_subspace ();
5869 pa_call_args (&last_call_desc
);
5870 demand_empty_rest_of_line ();
5873 /* Do the dirty work of building a call descriptor which describes
5874 where the caller placed arguments to a function call. */
5877 pa_call_args (call_desc
)
5878 struct call_desc
*call_desc
;
5881 unsigned int temp
, arg_reloc
;
5883 while (!is_end_of_statement ())
5885 name
= input_line_pointer
;
5886 c
= get_symbol_end ();
5887 /* Process a source argument. */
5888 if ((strncasecmp (name
, "argw", 4) == 0))
5890 temp
= atoi (name
+ 4);
5891 p
= input_line_pointer
;
5893 input_line_pointer
++;
5894 name
= input_line_pointer
;
5895 c
= get_symbol_end ();
5896 arg_reloc
= pa_build_arg_reloc (name
);
5897 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
5899 /* Process a return value. */
5900 else if ((strncasecmp (name
, "rtnval", 6) == 0))
5902 p
= input_line_pointer
;
5904 input_line_pointer
++;
5905 name
= input_line_pointer
;
5906 c
= get_symbol_end ();
5907 arg_reloc
= pa_build_arg_reloc (name
);
5908 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
5912 as_bad (_("Invalid .CALL argument: %s"), name
);
5914 p
= input_line_pointer
;
5916 if (!is_end_of_statement ())
5917 input_line_pointer
++;
5921 /* Return TRUE if FRAG1 and FRAG2 are the same. */
5924 is_same_frag (frag1
, frag2
)
5931 else if (frag2
== NULL
)
5933 else if (frag1
== frag2
)
5935 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
5936 return (is_same_frag (frag1
, frag2
->fr_next
));
5942 /* Build an entry in the UNWIND subspace from the given function
5943 attributes in CALL_INFO. This is not needed for SOM as using
5944 R_ENTRY and R_EXIT relocations allow the linker to handle building
5945 of the unwind spaces. */
5948 pa_build_unwind_subspace (call_info
)
5949 struct call_info
*call_info
;
5952 asection
*seg
, *save_seg
;
5954 subsegT subseg
, save_subseg
;
5958 if (now_seg
!= text_section
)
5961 if (bfd_get_arch_info (stdoutput
)->bits_per_address
== 32)
5962 reloc
= R_PARISC_DIR32
;
5964 reloc
= R_PARISC_SEGREL32
;
5966 /* Get into the right seg/subseg. This may involve creating
5967 the seg the first time through. Make sure to have the
5968 old seg/subseg so that we can reset things when we are done. */
5969 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
5970 if (seg
== ASEC_NULL
)
5972 seg
= bfd_make_section_old_way (stdoutput
, UNWIND_SECTION_NAME
);
5973 bfd_set_section_flags (stdoutput
, seg
,
5974 SEC_READONLY
| SEC_HAS_CONTENTS
5975 | SEC_LOAD
| SEC_RELOC
| SEC_ALLOC
| SEC_DATA
);
5976 bfd_set_section_alignment (stdoutput
, seg
, 2);
5980 save_subseg
= now_subseg
;
5981 subseg_set (seg
, 0);
5984 /* Get some space to hold relocation information for the unwind
5987 md_number_to_chars (p
, 0, 4);
5989 /* Relocation info. for start offset of the function. */
5990 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
5991 call_info
->start_symbol
, (offsetT
) 0,
5992 (expressionS
*) NULL
, 0, reloc
,
5993 e_fsel
, 32, 0, NULL
);
5996 md_number_to_chars (p
, 0, 4);
5998 /* Relocation info. for end offset of the function.
6000 Because we allow reductions of 32bit relocations for ELF, this will be
6001 reduced to section_sym + offset which avoids putting the temporary
6002 symbol into the symbol table. It (should) end up giving the same
6003 value as call_info->start_symbol + function size once the linker is
6004 finished with its work. */
6006 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6007 call_info
->end_symbol
, (offsetT
) 0,
6008 (expressionS
*) NULL
, 0, reloc
,
6009 e_fsel
, 32, 0, NULL
);
6012 unwind
= (char *) &call_info
->ci_unwind
;
6013 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
6017 FRAG_APPEND_1_CHAR (c
);
6021 /* Return back to the original segment/subsegment. */
6022 subseg_set (save_seg
, save_subseg
);
6026 /* Process a .CALLINFO pseudo-op. This information is used later
6027 to build unwind descriptors and maybe one day to support
6028 .ENTER and .LEAVE. */
6031 pa_callinfo (unused
)
6038 /* We must have a valid space and subspace. */
6039 pa_check_current_space_and_subspace ();
6042 /* .CALLINFO must appear within a procedure definition. */
6043 if (!within_procedure
)
6044 as_bad (_(".callinfo is not within a procedure definition"));
6046 /* Mark the fact that we found the .CALLINFO for the
6047 current procedure. */
6048 callinfo_found
= TRUE
;
6050 /* Iterate over the .CALLINFO arguments. */
6051 while (!is_end_of_statement ())
6053 name
= input_line_pointer
;
6054 c
= get_symbol_end ();
6055 /* Frame size specification. */
6056 if ((strncasecmp (name
, "frame", 5) == 0))
6058 p
= input_line_pointer
;
6060 input_line_pointer
++;
6061 temp
= get_absolute_expression ();
6062 if ((temp
& 0x3) != 0)
6064 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
6068 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
6069 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
6072 /* Entry register (GR, GR and SR) specifications. */
6073 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
6075 p
= input_line_pointer
;
6077 input_line_pointer
++;
6078 temp
= get_absolute_expression ();
6079 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
6080 even though %r19 is caller saved. I think this is a bug in
6081 the HP assembler, and we are not going to emulate it. */
6082 if (temp
< 3 || temp
> 18)
6083 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
6084 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
6086 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
6088 p
= input_line_pointer
;
6090 input_line_pointer
++;
6091 temp
= get_absolute_expression ();
6092 /* Similarly the HP assembler takes 31 as the high bound even
6093 though %fr21 is the last callee saved floating point register. */
6094 if (temp
< 12 || temp
> 21)
6095 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
6096 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
6098 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
6100 p
= input_line_pointer
;
6102 input_line_pointer
++;
6103 temp
= get_absolute_expression ();
6105 as_bad (_("Value for ENTRY_SR must be 3\n"));
6107 /* Note whether or not this function performs any calls. */
6108 else if ((strncasecmp (name
, "calls", 5) == 0) ||
6109 (strncasecmp (name
, "caller", 6) == 0))
6111 p
= input_line_pointer
;
6114 else if ((strncasecmp (name
, "no_calls", 8) == 0))
6116 p
= input_line_pointer
;
6119 /* Should RP be saved into the stack. */
6120 else if ((strncasecmp (name
, "save_rp", 7) == 0))
6122 p
= input_line_pointer
;
6124 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
6126 /* Likewise for SP. */
6127 else if ((strncasecmp (name
, "save_sp", 7) == 0))
6129 p
= input_line_pointer
;
6131 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
6133 /* Is this an unwindable procedure. If so mark it so
6134 in the unwind descriptor. */
6135 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
6137 p
= input_line_pointer
;
6139 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
6141 /* Is this an interrupt routine. If so mark it in the
6142 unwind descriptor. */
6143 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
6145 p
= input_line_pointer
;
6147 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
6149 /* Is this a millicode routine. "millicode" isn't in my
6150 assembler manual, but my copy is old. The HP assembler
6151 accepts it, and there's a place in the unwind descriptor
6152 to drop the information, so we'll accept it too. */
6153 else if ((strncasecmp (name
, "millicode", 9) == 0))
6155 p
= input_line_pointer
;
6157 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
6161 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
6162 *input_line_pointer
= c
;
6164 if (!is_end_of_statement ())
6165 input_line_pointer
++;
6168 demand_empty_rest_of_line ();
6171 /* Switch into the code subspace. */
6178 current_space
= is_defined_space ("$TEXT$");
6180 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6183 pa_undefine_label ();
6186 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
6187 the .comm pseudo-op has the following symtax:
6189 <label> .comm <length>
6191 where <label> is optional and is a symbol whose address will be the start of
6192 a block of memory <length> bytes long. <length> must be an absolute
6193 expression. <length> bytes will be allocated in the current space
6196 Also note the label may not even be on the same line as the .comm.
6198 This difference in syntax means the colon function will be called
6199 on the symbol before we arrive in pa_comm. colon will set a number
6200 of attributes of the symbol that need to be fixed here. In particular
6201 the value, section pointer, fragment pointer, flags, etc. What
6204 This also makes error detection all but impossible. */
6212 label_symbol_struct
*label_symbol
= pa_get_label ();
6215 symbol
= label_symbol
->lss_label
;
6220 size
= get_absolute_expression ();
6224 S_SET_VALUE (symbol
, size
);
6225 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6226 S_SET_EXTERNAL (symbol
);
6228 /* colon() has already set the frag to the current location in the
6229 current subspace; we need to reset the fragment to the zero address
6230 fragment. We also need to reset the segment pointer. */
6231 symbol_set_frag (symbol
, &zero_address_frag
);
6233 demand_empty_rest_of_line ();
6236 /* Process a .END pseudo-op. */
6242 demand_empty_rest_of_line ();
6245 /* Process a .ENTER pseudo-op. This is not supported. */
6251 /* We must have a valid space and subspace. */
6252 pa_check_current_space_and_subspace ();
6255 as_bad (_("The .ENTER pseudo-op is not supported"));
6256 demand_empty_rest_of_line ();
6259 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
6266 /* We must have a valid space and subspace. */
6267 pa_check_current_space_and_subspace ();
6270 if (!within_procedure
)
6271 as_bad (_("Misplaced .entry. Ignored."));
6274 if (!callinfo_found
)
6275 as_bad (_("Missing .callinfo."));
6277 demand_empty_rest_of_line ();
6278 within_entry_exit
= TRUE
;
6281 /* SOM defers building of unwind descriptors until the link phase.
6282 The assembler is responsible for creating an R_ENTRY relocation
6283 to mark the beginning of a region and hold the unwind bits, and
6284 for creating an R_EXIT relocation to mark the end of the region.
6286 FIXME. ELF should be using the same conventions! The problem
6287 is an unwind requires too much relocation space. Hmmm. Maybe
6288 if we split the unwind bits up between the relocations which
6289 denote the entry and exit points. */
6290 if (last_call_info
->start_symbol
!= NULL
)
6292 char *where
= frag_more (0);
6294 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6295 NULL
, (offsetT
) 0, NULL
,
6296 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
6297 (int *) &last_call_info
->ci_unwind
.descriptor
);
6302 /* Handle a .EQU pseudo-op. */
6308 label_symbol_struct
*label_symbol
= pa_get_label ();
6313 symbol
= label_symbol
->lss_label
;
6315 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
6317 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
6318 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
6323 as_bad (_(".REG must use a label"));
6325 as_bad (_(".EQU must use a label"));
6328 pa_undefine_label ();
6329 demand_empty_rest_of_line ();
6332 /* Helper function. Does processing for the end of a function. This
6333 usually involves creating some relocations or building special
6334 symbols to mark the end of the function. */
6341 where
= frag_more (0);
6344 /* Mark the end of the function, stuff away the location of the frag
6345 for the end of the function, and finally call pa_build_unwind_subspace
6346 to add an entry in the unwind table. */
6347 hppa_elf_mark_end_of_function ();
6348 pa_build_unwind_subspace (last_call_info
);
6350 /* SOM defers building of unwind descriptors until the link phase.
6351 The assembler is responsible for creating an R_ENTRY relocation
6352 to mark the beginning of a region and hold the unwind bits, and
6353 for creating an R_EXIT relocation to mark the end of the region.
6355 FIXME. ELF should be using the same conventions! The problem
6356 is an unwind requires too much relocation space. Hmmm. Maybe
6357 if we split the unwind bits up between the relocations which
6358 denote the entry and exit points. */
6359 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6361 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
6362 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
6366 /* Process a .EXIT pseudo-op. */
6373 /* We must have a valid space and subspace. */
6374 pa_check_current_space_and_subspace ();
6377 if (!within_procedure
)
6378 as_bad (_(".EXIT must appear within a procedure"));
6381 if (!callinfo_found
)
6382 as_bad (_("Missing .callinfo"));
6385 if (!within_entry_exit
)
6386 as_bad (_("No .ENTRY for this .EXIT"));
6389 within_entry_exit
= FALSE
;
6394 demand_empty_rest_of_line ();
6397 /* Process a .EXPORT directive. This makes functions external
6398 and provides information such as argument relocation entries
6408 name
= input_line_pointer
;
6409 c
= get_symbol_end ();
6410 /* Make sure the given symbol exists. */
6411 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6413 as_bad (_("Cannot define export symbol: %s\n"), name
);
6414 p
= input_line_pointer
;
6416 input_line_pointer
++;
6420 /* OK. Set the external bits and process argument relocations. */
6421 S_SET_EXTERNAL (symbol
);
6422 p
= input_line_pointer
;
6424 if (!is_end_of_statement ())
6426 input_line_pointer
++;
6427 pa_type_args (symbol
, 1);
6431 demand_empty_rest_of_line ();
6434 /* Helper function to process arguments to a .EXPORT pseudo-op. */
6437 pa_type_args (symbolP
, is_export
)
6442 unsigned int temp
, arg_reloc
;
6443 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
6444 obj_symbol_type
*symbol
= (obj_symbol_type
*) symbol_get_bfdsym (symbolP
);
6446 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
6449 input_line_pointer
+= 8;
6450 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6451 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
6452 type
= SYMBOL_TYPE_ABSOLUTE
;
6454 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
6456 input_line_pointer
+= 4;
6457 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
6458 instead one should be IMPORTing/EXPORTing ENTRY types.
6460 Complain if one tries to EXPORT a CODE type since that's never
6461 done. Both GCC and HP C still try to IMPORT CODE types, so
6462 silently fix them to be ENTRY types. */
6463 if (S_IS_FUNCTION (symbolP
))
6466 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
6467 S_GET_NAME (symbolP
));
6469 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6470 type
= SYMBOL_TYPE_ENTRY
;
6474 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6475 type
= SYMBOL_TYPE_CODE
;
6478 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
6480 input_line_pointer
+= 4;
6481 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6482 symbol_get_bfdsym (symbolP
)->flags
|= BSF_OBJECT
;
6483 type
= SYMBOL_TYPE_DATA
;
6485 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
6487 input_line_pointer
+= 5;
6488 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6489 type
= SYMBOL_TYPE_ENTRY
;
6491 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
6493 input_line_pointer
+= 9;
6494 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6495 type
= SYMBOL_TYPE_MILLICODE
;
6497 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
6499 input_line_pointer
+= 6;
6500 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6501 type
= SYMBOL_TYPE_PLABEL
;
6503 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
6505 input_line_pointer
+= 8;
6506 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6507 type
= SYMBOL_TYPE_PRI_PROG
;
6509 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
6511 input_line_pointer
+= 8;
6512 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6513 type
= SYMBOL_TYPE_SEC_PROG
;
6516 /* SOM requires much more information about symbol types
6517 than BFD understands. This is how we get this information
6518 to the SOM BFD backend. */
6519 #ifdef obj_set_symbol_type
6520 obj_set_symbol_type (symbol_get_bfdsym (symbolP
), (int) type
);
6523 /* Now that the type of the exported symbol has been handled,
6524 handle any argument relocation information. */
6525 while (!is_end_of_statement ())
6527 if (*input_line_pointer
== ',')
6528 input_line_pointer
++;
6529 name
= input_line_pointer
;
6530 c
= get_symbol_end ();
6531 /* Argument sources. */
6532 if ((strncasecmp (name
, "argw", 4) == 0))
6534 p
= input_line_pointer
;
6536 input_line_pointer
++;
6537 temp
= atoi (name
+ 4);
6538 name
= input_line_pointer
;
6539 c
= get_symbol_end ();
6540 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
6542 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
6544 *input_line_pointer
= c
;
6546 /* The return value. */
6547 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
6549 p
= input_line_pointer
;
6551 input_line_pointer
++;
6552 name
= input_line_pointer
;
6553 c
= get_symbol_end ();
6554 arg_reloc
= pa_build_arg_reloc (name
);
6556 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
6558 *input_line_pointer
= c
;
6560 /* Privelege level. */
6561 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
6563 p
= input_line_pointer
;
6565 input_line_pointer
++;
6566 temp
= atoi (input_line_pointer
);
6568 symbol
->tc_data
.ap
.hppa_priv_level
= temp
;
6570 c
= get_symbol_end ();
6571 *input_line_pointer
= c
;
6575 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
6576 p
= input_line_pointer
;
6579 if (!is_end_of_statement ())
6580 input_line_pointer
++;
6584 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
6585 assembly file must either be defined in the assembly file, or
6586 explicitly IMPORTED from another. */
6595 name
= input_line_pointer
;
6596 c
= get_symbol_end ();
6598 symbol
= symbol_find (name
);
6599 /* Ugh. We might be importing a symbol defined earlier in the file,
6600 in which case all the code below will really screw things up
6601 (set the wrong segment, symbol flags & type, etc). */
6602 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
6604 symbol
= symbol_find_or_make (name
);
6605 p
= input_line_pointer
;
6608 if (!is_end_of_statement ())
6610 input_line_pointer
++;
6611 pa_type_args (symbol
, 0);
6615 /* Sigh. To be compatable with the HP assembler and to help
6616 poorly written assembly code, we assign a type based on
6617 the the current segment. Note only BSF_FUNCTION really
6618 matters, we do not need to set the full SYMBOL_TYPE_* info. */
6619 if (now_seg
== text_section
)
6620 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
6622 /* If the section is undefined, then the symbol is undefined
6623 Since this is an import, leave the section undefined. */
6624 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6629 /* The symbol was already defined. Just eat everything up to
6630 the end of the current statement. */
6631 while (!is_end_of_statement ())
6632 input_line_pointer
++;
6635 demand_empty_rest_of_line ();
6638 /* Handle a .LABEL pseudo-op. */
6646 name
= input_line_pointer
;
6647 c
= get_symbol_end ();
6649 if (strlen (name
) > 0)
6652 p
= input_line_pointer
;
6657 as_warn (_("Missing label name on .LABEL"));
6660 if (!is_end_of_statement ())
6662 as_warn (_("extra .LABEL arguments ignored."));
6663 ignore_rest_of_line ();
6665 demand_empty_rest_of_line ();
6668 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
6675 /* We must have a valid space and subspace. */
6676 pa_check_current_space_and_subspace ();
6679 as_bad (_("The .LEAVE pseudo-op is not supported"));
6680 demand_empty_rest_of_line ();
6683 /* Handle a .LEVEL pseudo-op. */
6691 level
= input_line_pointer
;
6692 if (strncmp (level
, "1.0", 3) == 0)
6694 input_line_pointer
+= 3;
6695 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
6696 as_warn (_("could not set architecture and machine"));
6698 else if (strncmp (level
, "1.1", 3) == 0)
6700 input_line_pointer
+= 3;
6701 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
6702 as_warn (_("could not set architecture and machine"));
6704 else if (strncmp (level
, "2.0w", 4) == 0)
6706 input_line_pointer
+= 4;
6707 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 25))
6708 as_warn (_("could not set architecture and machine"));
6710 else if (strncmp (level
, "2.0", 3) == 0)
6712 input_line_pointer
+= 3;
6713 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
6714 as_warn (_("could not set architecture and machine"));
6718 as_bad (_("Unrecognized .LEVEL argument\n"));
6719 ignore_rest_of_line ();
6721 demand_empty_rest_of_line ();
6724 /* Handle a .ORIGIN pseudo-op. */
6731 /* We must have a valid space and subspace. */
6732 pa_check_current_space_and_subspace ();
6736 pa_undefine_label ();
6739 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
6740 is for static functions. FIXME. Should share more code with .EXPORT. */
6749 name
= input_line_pointer
;
6750 c
= get_symbol_end ();
6752 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6754 as_bad (_("Cannot define static symbol: %s\n"), name
);
6755 p
= input_line_pointer
;
6757 input_line_pointer
++;
6761 S_CLEAR_EXTERNAL (symbol
);
6762 p
= input_line_pointer
;
6764 if (!is_end_of_statement ())
6766 input_line_pointer
++;
6767 pa_type_args (symbol
, 0);
6771 demand_empty_rest_of_line ();
6774 /* Handle a .PROC pseudo-op. It is used to mark the beginning
6775 of a procedure from a syntatical point of view. */
6781 struct call_info
*call_info
;
6784 /* We must have a valid space and subspace. */
6785 pa_check_current_space_and_subspace ();
6788 if (within_procedure
)
6789 as_fatal (_("Nested procedures"));
6791 /* Reset global variables for new procedure. */
6792 callinfo_found
= FALSE
;
6793 within_procedure
= TRUE
;
6795 /* Create another call_info structure. */
6796 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
6799 as_fatal (_("Cannot allocate unwind descriptor\n"));
6801 memset (call_info
, 0, sizeof (struct call_info
));
6803 call_info
->ci_next
= NULL
;
6805 if (call_info_root
== NULL
)
6807 call_info_root
= call_info
;
6808 last_call_info
= call_info
;
6812 last_call_info
->ci_next
= call_info
;
6813 last_call_info
= call_info
;
6816 /* set up defaults on call_info structure */
6818 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
6819 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
6820 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
6822 /* If we got a .PROC pseudo-op, we know that the function is defined
6823 locally. Make sure it gets into the symbol table. */
6825 label_symbol_struct
*label_symbol
= pa_get_label ();
6829 if (label_symbol
->lss_label
)
6831 last_call_info
->start_symbol
= label_symbol
->lss_label
;
6832 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
6835 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
6838 last_call_info
->start_symbol
= NULL
;
6841 demand_empty_rest_of_line ();
6844 /* Process the syntatical end of a procedure. Make sure all the
6845 appropriate pseudo-ops were found within the procedure. */
6853 /* We must have a valid space and subspace. */
6854 pa_check_current_space_and_subspace ();
6857 /* If we are within a procedure definition, make sure we've
6858 defined a label for the procedure; handle case where the
6859 label was defined after the .PROC directive.
6861 Note there's not need to diddle with the segment or fragment
6862 for the label symbol in this case. We have already switched
6863 into the new $CODE$ subspace at this point. */
6864 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
6866 label_symbol_struct
*label_symbol
= pa_get_label ();
6870 if (label_symbol
->lss_label
)
6872 last_call_info
->start_symbol
= label_symbol
->lss_label
;
6873 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
6876 /* Also handle allocation of a fixup to hold the unwind
6877 information when the label appears after the proc/procend. */
6878 if (within_entry_exit
)
6880 char *where
= frag_more (0);
6882 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6883 NULL
, (offsetT
) 0, NULL
,
6884 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
6885 (int *) &last_call_info
->ci_unwind
.descriptor
);
6890 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
6893 as_bad (_("Missing function name for .PROC"));
6896 if (!within_procedure
)
6897 as_bad (_("misplaced .procend"));
6899 if (!callinfo_found
)
6900 as_bad (_("Missing .callinfo for this procedure"));
6902 if (within_entry_exit
)
6903 as_bad (_("Missing .EXIT for a .ENTRY"));
6906 /* ELF needs to mark the end of each function so that it can compute
6907 the size of the function (apparently its needed in the symbol table). */
6908 hppa_elf_mark_end_of_function ();
6911 within_procedure
= FALSE
;
6912 demand_empty_rest_of_line ();
6913 pa_undefine_label ();
6916 /* If VALUE is an exact power of two between zero and 2^31, then
6917 return log2 (VALUE). Else return -1. */
6925 while ((1 << shift
) != value
&& shift
< 32)
6936 /* Check to make sure we have a valid space and subspace. */
6939 pa_check_current_space_and_subspace ()
6941 if (current_space
== NULL
)
6942 as_fatal (_("Not in a space.\n"));
6944 if (current_subspace
== NULL
)
6945 as_fatal (_("Not in a subspace.\n"));
6948 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
6949 then create a new space entry to hold the information specified
6950 by the parameters to the .SPACE directive. */
6952 static sd_chain_struct
*
6953 pa_parse_space_stmt (space_name
, create_flag
)
6957 char *name
, *ptemp
, c
;
6958 char loadable
, defined
, private, sort
;
6960 asection
*seg
= NULL
;
6961 sd_chain_struct
*space
;
6963 /* load default values */
6969 if (strcmp (space_name
, "$TEXT$") == 0)
6971 seg
= pa_def_spaces
[0].segment
;
6972 defined
= pa_def_spaces
[0].defined
;
6973 private = pa_def_spaces
[0].private;
6974 sort
= pa_def_spaces
[0].sort
;
6975 spnum
= pa_def_spaces
[0].spnum
;
6977 else if (strcmp (space_name
, "$PRIVATE$") == 0)
6979 seg
= pa_def_spaces
[1].segment
;
6980 defined
= pa_def_spaces
[1].defined
;
6981 private = pa_def_spaces
[1].private;
6982 sort
= pa_def_spaces
[1].sort
;
6983 spnum
= pa_def_spaces
[1].spnum
;
6986 if (!is_end_of_statement ())
6988 print_errors
= FALSE
;
6989 ptemp
= input_line_pointer
+ 1;
6990 /* First see if the space was specified as a number rather than
6991 as a name. According to the PA assembly manual the rest of
6992 the line should be ignored. */
6993 temp
= pa_parse_number (&ptemp
, 0);
6997 input_line_pointer
= ptemp
;
7001 while (!is_end_of_statement ())
7003 input_line_pointer
++;
7004 name
= input_line_pointer
;
7005 c
= get_symbol_end ();
7006 if ((strncasecmp (name
, "spnum", 5) == 0))
7008 *input_line_pointer
= c
;
7009 input_line_pointer
++;
7010 spnum
= get_absolute_expression ();
7012 else if ((strncasecmp (name
, "sort", 4) == 0))
7014 *input_line_pointer
= c
;
7015 input_line_pointer
++;
7016 sort
= get_absolute_expression ();
7018 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7020 *input_line_pointer
= c
;
7023 else if ((strncasecmp (name
, "notdefined", 10) == 0))
7025 *input_line_pointer
= c
;
7028 else if ((strncasecmp (name
, "private", 7) == 0))
7030 *input_line_pointer
= c
;
7035 as_bad (_("Invalid .SPACE argument"));
7036 *input_line_pointer
= c
;
7037 if (!is_end_of_statement ())
7038 input_line_pointer
++;
7042 print_errors
= TRUE
;
7045 if (create_flag
&& seg
== NULL
)
7046 seg
= subseg_new (space_name
, 0);
7048 /* If create_flag is nonzero, then create the new space with
7049 the attributes computed above. Else set the values in
7050 an already existing space -- this can only happen for
7051 the first occurence of a built-in space. */
7053 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
7054 private, sort
, seg
, 1);
7057 space
= is_defined_space (space_name
);
7058 SPACE_SPNUM (space
) = spnum
;
7059 SPACE_DEFINED (space
) = defined
& 1;
7060 SPACE_USER_DEFINED (space
) = 1;
7063 #ifdef obj_set_section_attributes
7064 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7070 /* Handle a .SPACE pseudo-op; this switches the current space to the
7071 given space, creating the new space if necessary. */
7077 char *name
, c
, *space_name
, *save_s
;
7079 sd_chain_struct
*sd_chain
;
7081 if (within_procedure
)
7083 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
7084 ignore_rest_of_line ();
7088 /* Check for some of the predefined spaces. FIXME: most of the code
7089 below is repeated several times, can we extract the common parts
7090 and place them into a subroutine or something similar? */
7091 /* FIXME Is this (and the next IF stmt) really right?
7092 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
7093 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
7095 input_line_pointer
+= 6;
7096 sd_chain
= is_defined_space ("$TEXT$");
7097 if (sd_chain
== NULL
)
7098 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
7099 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7100 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
7102 current_space
= sd_chain
;
7103 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
7105 = pa_subsegment_to_subspace (text_section
,
7106 sd_chain
->sd_last_subseg
);
7107 demand_empty_rest_of_line ();
7110 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
7112 input_line_pointer
+= 9;
7113 sd_chain
= is_defined_space ("$PRIVATE$");
7114 if (sd_chain
== NULL
)
7115 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
7116 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7117 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
7119 current_space
= sd_chain
;
7120 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
7122 = pa_subsegment_to_subspace (data_section
,
7123 sd_chain
->sd_last_subseg
);
7124 demand_empty_rest_of_line ();
7127 if (!strncasecmp (input_line_pointer
,
7128 GDB_DEBUG_SPACE_NAME
,
7129 strlen (GDB_DEBUG_SPACE_NAME
)))
7131 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
7132 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
7133 if (sd_chain
== NULL
)
7134 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
7135 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7136 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
7138 current_space
= sd_chain
;
7141 asection
*gdb_section
7142 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
7144 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
7146 = pa_subsegment_to_subspace (gdb_section
,
7147 sd_chain
->sd_last_subseg
);
7149 demand_empty_rest_of_line ();
7153 /* It could be a space specified by number. */
7155 save_s
= input_line_pointer
;
7156 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
7158 if ((sd_chain
= pa_find_space_by_number (temp
)))
7160 current_space
= sd_chain
;
7162 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7164 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7165 sd_chain
->sd_last_subseg
);
7166 demand_empty_rest_of_line ();
7171 /* Not a number, attempt to create a new space. */
7173 input_line_pointer
= save_s
;
7174 name
= input_line_pointer
;
7175 c
= get_symbol_end ();
7176 space_name
= xmalloc (strlen (name
) + 1);
7177 strcpy (space_name
, name
);
7178 *input_line_pointer
= c
;
7180 sd_chain
= pa_parse_space_stmt (space_name
, 1);
7181 current_space
= sd_chain
;
7183 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7184 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7185 sd_chain
->sd_last_subseg
);
7186 demand_empty_rest_of_line ();
7190 /* Switch to a new space. (I think). FIXME. */
7199 sd_chain_struct
*space
;
7201 name
= input_line_pointer
;
7202 c
= get_symbol_end ();
7203 space
= is_defined_space (name
);
7207 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
7210 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
7212 *input_line_pointer
= c
;
7213 demand_empty_rest_of_line ();
7216 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
7217 given subspace, creating the new subspace if necessary.
7219 FIXME. Should mirror pa_space more closely, in particular how
7220 they're broken up into subroutines. */
7223 pa_subspace (create_new
)
7226 char *name
, *ss_name
, c
;
7227 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
7228 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
7229 sd_chain_struct
*space
;
7230 ssd_chain_struct
*ssd
;
7233 if (current_space
== NULL
)
7234 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
7236 if (within_procedure
)
7238 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
7239 ignore_rest_of_line ();
7243 name
= input_line_pointer
;
7244 c
= get_symbol_end ();
7245 ss_name
= xmalloc (strlen (name
) + 1);
7246 strcpy (ss_name
, name
);
7247 *input_line_pointer
= c
;
7249 /* Load default values. */
7261 space
= current_space
;
7265 ssd
= is_defined_subspace (ss_name
);
7266 /* Allow user to override the builtin attributes of subspaces. But
7267 only allow the attributes to be changed once! */
7268 if (ssd
&& SUBSPACE_DEFINED (ssd
))
7270 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
7271 current_subspace
= ssd
;
7272 if (!is_end_of_statement ())
7273 as_warn (_("Parameters of an existing subspace can\'t be modified"));
7274 demand_empty_rest_of_line ();
7279 /* A new subspace. Load default values if it matches one of
7280 the builtin subspaces. */
7282 while (pa_def_subspaces
[i
].name
)
7284 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
7286 loadable
= pa_def_subspaces
[i
].loadable
;
7287 common
= pa_def_subspaces
[i
].common
;
7288 dup_common
= pa_def_subspaces
[i
].dup_common
;
7289 code_only
= pa_def_subspaces
[i
].code_only
;
7290 zero
= pa_def_subspaces
[i
].zero
;
7291 space_index
= pa_def_subspaces
[i
].space_index
;
7292 alignment
= pa_def_subspaces
[i
].alignment
;
7293 quadrant
= pa_def_subspaces
[i
].quadrant
;
7294 access
= pa_def_subspaces
[i
].access
;
7295 sort
= pa_def_subspaces
[i
].sort
;
7302 /* We should be working with a new subspace now. Fill in
7303 any information as specified by the user. */
7304 if (!is_end_of_statement ())
7306 input_line_pointer
++;
7307 while (!is_end_of_statement ())
7309 name
= input_line_pointer
;
7310 c
= get_symbol_end ();
7311 if ((strncasecmp (name
, "quad", 4) == 0))
7313 *input_line_pointer
= c
;
7314 input_line_pointer
++;
7315 quadrant
= get_absolute_expression ();
7317 else if ((strncasecmp (name
, "align", 5) == 0))
7319 *input_line_pointer
= c
;
7320 input_line_pointer
++;
7321 alignment
= get_absolute_expression ();
7322 if (log2 (alignment
) == -1)
7324 as_bad (_("Alignment must be a power of 2"));
7328 else if ((strncasecmp (name
, "access", 6) == 0))
7330 *input_line_pointer
= c
;
7331 input_line_pointer
++;
7332 access
= get_absolute_expression ();
7334 else if ((strncasecmp (name
, "sort", 4) == 0))
7336 *input_line_pointer
= c
;
7337 input_line_pointer
++;
7338 sort
= get_absolute_expression ();
7340 else if ((strncasecmp (name
, "code_only", 9) == 0))
7342 *input_line_pointer
= c
;
7345 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7347 *input_line_pointer
= c
;
7350 else if ((strncasecmp (name
, "common", 6) == 0))
7352 *input_line_pointer
= c
;
7355 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
7357 *input_line_pointer
= c
;
7360 else if ((strncasecmp (name
, "zero", 4) == 0))
7362 *input_line_pointer
= c
;
7365 else if ((strncasecmp (name
, "first", 5) == 0))
7366 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
7368 as_bad (_("Invalid .SUBSPACE argument"));
7369 if (!is_end_of_statement ())
7370 input_line_pointer
++;
7374 /* Compute a reasonable set of BFD flags based on the information
7375 in the .subspace directive. */
7376 applicable
= bfd_applicable_section_flags (stdoutput
);
7379 flags
|= (SEC_ALLOC
| SEC_LOAD
);
7382 if (common
|| dup_common
)
7383 flags
|= SEC_IS_COMMON
;
7385 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
7387 /* This is a zero-filled subspace (eg BSS). */
7389 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
7391 applicable
&= flags
;
7393 /* If this is an existing subspace, then we want to use the
7394 segment already associated with the subspace.
7396 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
7397 lots of sections. It might be a problem in the PA ELF
7398 code, I do not know yet. For now avoid creating anything
7399 but the "standard" sections for ELF. */
7401 section
= subseg_force_new (ss_name
, 0);
7403 section
= ssd
->ssd_seg
;
7405 section
= subseg_new (ss_name
, 0);
7408 seg_info (section
)->bss
= 1;
7410 /* Now set the flags. */
7411 bfd_set_section_flags (stdoutput
, section
, applicable
);
7413 /* Record any alignment request for this section. */
7414 record_alignment (section
, log2 (alignment
));
7416 /* Set the starting offset for this section. */
7417 bfd_set_section_vma (stdoutput
, section
,
7418 pa_subspace_start (space
, quadrant
));
7420 /* Now that all the flags are set, update an existing subspace,
7421 or create a new one. */
7424 current_subspace
= update_subspace (space
, ss_name
, loadable
,
7425 code_only
, common
, dup_common
,
7426 sort
, zero
, access
, space_index
,
7427 alignment
, quadrant
,
7430 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
7432 dup_common
, zero
, sort
,
7433 access
, space_index
,
7434 alignment
, quadrant
, section
);
7436 demand_empty_rest_of_line ();
7437 current_subspace
->ssd_seg
= section
;
7438 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
7440 SUBSPACE_DEFINED (current_subspace
) = 1;
7444 /* Create default space and subspace dictionaries. */
7451 space_dict_root
= NULL
;
7452 space_dict_last
= NULL
;
7455 while (pa_def_spaces
[i
].name
)
7459 /* Pick the right name to use for the new section. */
7460 name
= pa_def_spaces
[i
].name
;
7462 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
7463 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
7464 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
7465 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
7466 pa_def_spaces
[i
].segment
, 0);
7471 while (pa_def_subspaces
[i
].name
)
7474 int applicable
, subsegment
;
7475 asection
*segment
= NULL
;
7476 sd_chain_struct
*space
;
7478 /* Pick the right name for the new section and pick the right
7479 subsegment number. */
7480 name
= pa_def_subspaces
[i
].name
;
7483 /* Create the new section. */
7484 segment
= subseg_new (name
, subsegment
);
7487 /* For SOM we want to replace the standard .text, .data, and .bss
7488 sections with our own. We also want to set BFD flags for
7489 all the built-in subspaces. */
7490 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
7492 text_section
= segment
;
7493 applicable
= bfd_applicable_section_flags (stdoutput
);
7494 bfd_set_section_flags (stdoutput
, segment
,
7495 applicable
& (SEC_ALLOC
| SEC_LOAD
7496 | SEC_RELOC
| SEC_CODE
7498 | SEC_HAS_CONTENTS
));
7500 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
7502 data_section
= segment
;
7503 applicable
= bfd_applicable_section_flags (stdoutput
);
7504 bfd_set_section_flags (stdoutput
, segment
,
7505 applicable
& (SEC_ALLOC
| SEC_LOAD
7507 | SEC_HAS_CONTENTS
));
7511 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
7513 bss_section
= segment
;
7514 applicable
= bfd_applicable_section_flags (stdoutput
);
7515 bfd_set_section_flags (stdoutput
, segment
,
7516 applicable
& SEC_ALLOC
);
7518 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
7520 applicable
= bfd_applicable_section_flags (stdoutput
);
7521 bfd_set_section_flags (stdoutput
, segment
,
7522 applicable
& (SEC_ALLOC
| SEC_LOAD
7525 | SEC_HAS_CONTENTS
));
7527 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
7529 applicable
= bfd_applicable_section_flags (stdoutput
);
7530 bfd_set_section_flags (stdoutput
, segment
,
7531 applicable
& (SEC_ALLOC
| SEC_LOAD
7534 | SEC_HAS_CONTENTS
));
7536 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
7538 applicable
= bfd_applicable_section_flags (stdoutput
);
7539 bfd_set_section_flags (stdoutput
, segment
,
7540 applicable
& (SEC_ALLOC
| SEC_LOAD
7543 | SEC_HAS_CONTENTS
));
7546 /* Find the space associated with this subspace. */
7547 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
7548 def_space_index
].segment
);
7551 as_fatal (_("Internal error: Unable to find containing space for %s."),
7552 pa_def_subspaces
[i
].name
);
7555 create_new_subspace (space
, name
,
7556 pa_def_subspaces
[i
].loadable
,
7557 pa_def_subspaces
[i
].code_only
,
7558 pa_def_subspaces
[i
].common
,
7559 pa_def_subspaces
[i
].dup_common
,
7560 pa_def_subspaces
[i
].zero
,
7561 pa_def_subspaces
[i
].sort
,
7562 pa_def_subspaces
[i
].access
,
7563 pa_def_subspaces
[i
].space_index
,
7564 pa_def_subspaces
[i
].alignment
,
7565 pa_def_subspaces
[i
].quadrant
,
7573 /* Create a new space NAME, with the appropriate flags as defined
7574 by the given parameters. */
7576 static sd_chain_struct
*
7577 create_new_space (name
, spnum
, loadable
, defined
, private,
7578 sort
, seg
, user_defined
)
7588 sd_chain_struct
*chain_entry
;
7590 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
7592 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
7595 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7596 strcpy (SPACE_NAME (chain_entry
), name
);
7597 SPACE_DEFINED (chain_entry
) = defined
;
7598 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
7599 SPACE_SPNUM (chain_entry
) = spnum
;
7601 chain_entry
->sd_seg
= seg
;
7602 chain_entry
->sd_last_subseg
= -1;
7603 chain_entry
->sd_subspaces
= NULL
;
7604 chain_entry
->sd_next
= NULL
;
7606 /* Find spot for the new space based on its sort key. */
7607 if (!space_dict_last
)
7608 space_dict_last
= chain_entry
;
7610 if (space_dict_root
== NULL
)
7611 space_dict_root
= chain_entry
;
7614 sd_chain_struct
*chain_pointer
;
7615 sd_chain_struct
*prev_chain_pointer
;
7617 chain_pointer
= space_dict_root
;
7618 prev_chain_pointer
= NULL
;
7620 while (chain_pointer
)
7622 prev_chain_pointer
= chain_pointer
;
7623 chain_pointer
= chain_pointer
->sd_next
;
7626 /* At this point we've found the correct place to add the new
7627 entry. So add it and update the linked lists as appropriate. */
7628 if (prev_chain_pointer
)
7630 chain_entry
->sd_next
= chain_pointer
;
7631 prev_chain_pointer
->sd_next
= chain_entry
;
7635 space_dict_root
= chain_entry
;
7636 chain_entry
->sd_next
= chain_pointer
;
7639 if (chain_entry
->sd_next
== NULL
)
7640 space_dict_last
= chain_entry
;
7643 /* This is here to catch predefined spaces which do not get
7644 modified by the user's input. Another call is found at
7645 the bottom of pa_parse_space_stmt to handle cases where
7646 the user modifies a predefined space. */
7647 #ifdef obj_set_section_attributes
7648 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7654 /* Create a new subspace NAME, with the appropriate flags as defined
7655 by the given parameters.
7657 Add the new subspace to the subspace dictionary chain in numerical
7658 order as defined by the SORT entries. */
7660 static ssd_chain_struct
*
7661 create_new_subspace (space
, name
, loadable
, code_only
, common
,
7662 dup_common
, is_zero
, sort
, access
, space_index
,
7663 alignment
, quadrant
, seg
)
7664 sd_chain_struct
*space
;
7666 int loadable
, code_only
, common
, dup_common
, is_zero
;
7674 ssd_chain_struct
*chain_entry
;
7676 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
7678 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
7680 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7681 strcpy (SUBSPACE_NAME (chain_entry
), name
);
7683 /* Initialize subspace_defined. When we hit a .subspace directive
7684 we'll set it to 1 which "locks-in" the subspace attributes. */
7685 SUBSPACE_DEFINED (chain_entry
) = 0;
7687 chain_entry
->ssd_subseg
= 0;
7688 chain_entry
->ssd_seg
= seg
;
7689 chain_entry
->ssd_next
= NULL
;
7691 /* Find spot for the new subspace based on its sort key. */
7692 if (space
->sd_subspaces
== NULL
)
7693 space
->sd_subspaces
= chain_entry
;
7696 ssd_chain_struct
*chain_pointer
;
7697 ssd_chain_struct
*prev_chain_pointer
;
7699 chain_pointer
= space
->sd_subspaces
;
7700 prev_chain_pointer
= NULL
;
7702 while (chain_pointer
)
7704 prev_chain_pointer
= chain_pointer
;
7705 chain_pointer
= chain_pointer
->ssd_next
;
7708 /* Now we have somewhere to put the new entry. Insert it and update
7710 if (prev_chain_pointer
)
7712 chain_entry
->ssd_next
= chain_pointer
;
7713 prev_chain_pointer
->ssd_next
= chain_entry
;
7717 space
->sd_subspaces
= chain_entry
;
7718 chain_entry
->ssd_next
= chain_pointer
;
7722 #ifdef obj_set_subsection_attributes
7723 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
7730 /* Update the information for the given subspace based upon the
7731 various arguments. Return the modified subspace chain entry. */
7733 static ssd_chain_struct
*
7734 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
7735 zero
, access
, space_index
, alignment
, quadrant
, section
)
7736 sd_chain_struct
*space
;
7750 ssd_chain_struct
*chain_entry
;
7752 chain_entry
= is_defined_subspace (name
);
7754 #ifdef obj_set_subsection_attributes
7755 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
7762 /* Return the space chain entry for the space with the name NAME or
7763 NULL if no such space exists. */
7765 static sd_chain_struct
*
7766 is_defined_space (name
)
7769 sd_chain_struct
*chain_pointer
;
7771 for (chain_pointer
= space_dict_root
;
7773 chain_pointer
= chain_pointer
->sd_next
)
7775 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
7776 return chain_pointer
;
7779 /* No mapping from segment to space was found. Return NULL. */
7783 /* Find and return the space associated with the given seg. If no mapping
7784 from the given seg to a space is found, then return NULL.
7786 Unlike subspaces, the number of spaces is not expected to grow much,
7787 so a linear exhaustive search is OK here. */
7789 static sd_chain_struct
*
7790 pa_segment_to_space (seg
)
7793 sd_chain_struct
*space_chain
;
7795 /* Walk through each space looking for the correct mapping. */
7796 for (space_chain
= space_dict_root
;
7798 space_chain
= space_chain
->sd_next
)
7800 if (space_chain
->sd_seg
== seg
)
7804 /* Mapping was not found. Return NULL. */
7808 /* Return the space chain entry for the subspace with the name NAME or
7809 NULL if no such subspace exists.
7811 Uses a linear search through all the spaces and subspaces, this may
7812 not be appropriate if we ever being placing each function in its
7815 static ssd_chain_struct
*
7816 is_defined_subspace (name
)
7819 sd_chain_struct
*space_chain
;
7820 ssd_chain_struct
*subspace_chain
;
7822 /* Walk through each space. */
7823 for (space_chain
= space_dict_root
;
7825 space_chain
= space_chain
->sd_next
)
7827 /* Walk through each subspace looking for a name which matches. */
7828 for (subspace_chain
= space_chain
->sd_subspaces
;
7830 subspace_chain
= subspace_chain
->ssd_next
)
7831 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
7832 return subspace_chain
;
7835 /* Subspace wasn't found. Return NULL. */
7839 /* Find and return the subspace associated with the given seg. If no
7840 mapping from the given seg to a subspace is found, then return NULL.
7842 If we ever put each procedure/function within its own subspace
7843 (to make life easier on the compiler and linker), then this will have
7844 to become more efficient. */
7846 static ssd_chain_struct
*
7847 pa_subsegment_to_subspace (seg
, subseg
)
7851 sd_chain_struct
*space_chain
;
7852 ssd_chain_struct
*subspace_chain
;
7854 /* Walk through each space. */
7855 for (space_chain
= space_dict_root
;
7857 space_chain
= space_chain
->sd_next
)
7859 if (space_chain
->sd_seg
== seg
)
7861 /* Walk through each subspace within each space looking for
7862 the correct mapping. */
7863 for (subspace_chain
= space_chain
->sd_subspaces
;
7865 subspace_chain
= subspace_chain
->ssd_next
)
7866 if (subspace_chain
->ssd_subseg
== (int) subseg
)
7867 return subspace_chain
;
7871 /* No mapping from subsegment to subspace found. Return NULL. */
7875 /* Given a number, try and find a space with the name number.
7877 Return a pointer to a space dictionary chain entry for the space
7878 that was found or NULL on failure. */
7880 static sd_chain_struct
*
7881 pa_find_space_by_number (number
)
7884 sd_chain_struct
*space_chain
;
7886 for (space_chain
= space_dict_root
;
7888 space_chain
= space_chain
->sd_next
)
7890 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
7894 /* No appropriate space found. Return NULL. */
7898 /* Return the starting address for the given subspace. If the starting
7899 address is unknown then return zero. */
7902 pa_subspace_start (space
, quadrant
)
7903 sd_chain_struct
*space
;
7906 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
7907 is not correct for the PA OSF1 port. */
7908 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
7910 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
7917 /* FIXME. Needs documentation. */
7919 pa_next_subseg (space
)
7920 sd_chain_struct
*space
;
7923 space
->sd_last_subseg
++;
7924 return space
->sd_last_subseg
;
7928 /* Helper function for pa_stringer. Used to find the end of
7935 unsigned int c
= *s
& CHAR_MASK
;
7938 /* We must have a valid space and subspace. */
7939 pa_check_current_space_and_subspace ();
7953 /* Handle a .STRING type pseudo-op. */
7956 pa_stringer (append_zero
)
7959 char *s
, num_buf
[4];
7963 /* Preprocess the string to handle PA-specific escape sequences.
7964 For example, \xDD where DD is a hexidecimal number should be
7965 changed to \OOO where OOO is an octal number. */
7967 /* Skip the opening quote. */
7968 s
= input_line_pointer
+ 1;
7970 while (is_a_char (c
= pa_stringer_aux (s
++)))
7977 /* Handle \x<num>. */
7980 unsigned int number
;
7985 /* Get pas the 'x'. */
7987 for (num_digit
= 0, number
= 0, dg
= *s
;
7989 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
7990 || (dg
>= 'A' && dg
<= 'F'));
7994 number
= number
* 16 + dg
- '0';
7995 else if (dg
>= 'a' && dg
<= 'f')
7996 number
= number
* 16 + dg
- 'a' + 10;
7998 number
= number
* 16 + dg
- 'A' + 10;
8008 sprintf (num_buf
, "%02o", number
);
8011 sprintf (num_buf
, "%03o", number
);
8014 for (i
= 0; i
<= num_digit
; i
++)
8015 s_start
[i
] = num_buf
[i
];
8019 /* This might be a "\"", skip over the escaped char. */
8026 stringer (append_zero
);
8027 pa_undefine_label ();
8030 /* Handle a .VERSION pseudo-op. */
8037 pa_undefine_label ();
8042 /* Handle a .COMPILER pseudo-op. */
8045 pa_compiler (unused
)
8048 obj_som_compiler (0);
8049 pa_undefine_label ();
8054 /* Handle a .COPYRIGHT pseudo-op. */
8057 pa_copyright (unused
)
8061 pa_undefine_label ();
8064 /* Just like a normal cons, but when finished we have to undefine
8065 the latest space label. */
8072 pa_undefine_label ();
8075 /* Switch to the data space. As usual delete our label. */
8082 current_space
= is_defined_space ("$PRIVATE$");
8084 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
8087 pa_undefine_label ();
8090 /* Like float_cons, but we need to undefine our label. */
8093 pa_float_cons (float_type
)
8096 float_cons (float_type
);
8097 pa_undefine_label ();
8100 /* Like s_fill, but delete our label when finished. */
8107 /* We must have a valid space and subspace. */
8108 pa_check_current_space_and_subspace ();
8112 pa_undefine_label ();
8115 /* Like lcomm, but delete our label when finished. */
8118 pa_lcomm (needs_align
)
8122 /* We must have a valid space and subspace. */
8123 pa_check_current_space_and_subspace ();
8126 s_lcomm (needs_align
);
8127 pa_undefine_label ();
8130 /* Like lsym, but delete our label when finished. */
8137 /* We must have a valid space and subspace. */
8138 pa_check_current_space_and_subspace ();
8142 pa_undefine_label ();
8145 /* Switch to the text space. Like s_text, but delete our
8146 label when finished. */
8152 current_space
= is_defined_space ("$TEXT$");
8154 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
8158 pa_undefine_label ();
8161 /* On the PA relocations which involve function symbols must not be
8162 adjusted. This so that the linker can know when/how to create argument
8163 relocation stubs for indirect calls and calls to static functions.
8165 "T" field selectors create DLT relative fixups for accessing
8166 globals and statics in PIC code; each DLT relative fixup creates
8167 an entry in the DLT table. The entries contain the address of
8168 the final target (eg accessing "foo" would create a DLT entry
8169 with the address of "foo").
8171 Unfortunately, the HP linker doesn't take into account any addend
8172 when generating the DLT; so accessing $LIT$+8 puts the address of
8173 $LIT$ into the DLT rather than the address of $LIT$+8.
8175 The end result is we can't perform relocation symbol reductions for
8176 any fixup which creates entries in the DLT (eg they use "T" field
8179 Reject reductions involving symbols with external scope; such
8180 reductions make life a living hell for object file editors.
8182 FIXME. Also reject R_HPPA relocations which are 32bits wide in
8183 the code space. The SOM BFD backend doesn't know how to pull the
8184 right bits out of an instruction. */
8187 hppa_fix_adjustable (fixp
)
8190 struct hppa_fix_struct
*hppa_fix
;
8192 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8195 /* Reject reductions of symbols in 32bit relocs. */
8196 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
8199 /* Reject reductions of symbols in sym1-sym2 expressions when
8200 the fixup will occur in a CODE subspace.
8202 XXX FIXME: Long term we probably want to reject all of these;
8203 for example reducing in the debug section would lose if we ever
8204 supported using the optimizing hp linker. */
8207 && (hppa_fix
->segment
->flags
& SEC_CODE
))
8209 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
8210 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
8214 /* We can't adjust any relocs that use LR% and RR% field selectors.
8215 That confuses the HP linker. */
8216 if (hppa_fix
->fx_r_field
== e_lrsel
8217 || hppa_fix
->fx_r_field
== e_rrsel
8218 || hppa_fix
->fx_r_field
== e_nlrsel
)
8222 /* Reject reductions of symbols in DLT relative relocs,
8223 relocations with plabels. */
8224 if (hppa_fix
->fx_r_field
== e_tsel
8225 || hppa_fix
->fx_r_field
== e_ltsel
8226 || hppa_fix
->fx_r_field
== e_rtsel
8227 || hppa_fix
->fx_r_field
== e_psel
8228 || hppa_fix
->fx_r_field
== e_rpsel
8229 || hppa_fix
->fx_r_field
== e_lpsel
)
8232 if (fixp
->fx_addsy
&& S_IS_EXTERNAL (fixp
->fx_addsy
))
8235 /* Reject absolute calls (jumps). */
8236 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
8239 /* Reject reductions of function symbols. */
8240 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
8246 /* Return nonzero if the fixup in FIXP will require a relocation,
8247 even it if appears that the fixup could be completely handled
8251 hppa_force_relocation (fixp
)
8254 struct hppa_fix_struct
*hppa_fixp
;
8257 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8259 if (fixp
->fx_r_type
== R_HPPA_ENTRY
|| fixp
->fx_r_type
== R_HPPA_EXIT
8260 || fixp
->fx_r_type
== R_HPPA_BEGIN_BRTAB
8261 || fixp
->fx_r_type
== R_HPPA_END_BRTAB
8262 || fixp
->fx_r_type
== R_HPPA_BEGIN_TRY
8263 || fixp
->fx_r_type
== R_HPPA_END_TRY
8264 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
8265 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
8269 #define arg_reloc_stub_needed(CALLER, CALLEE) \
8270 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
8273 /* It is necessary to force PC-relative calls/jumps to have a relocation
8274 entry if they're going to need either a argument relocation or long
8275 call stub. FIXME. Can't we need the same for absolute calls? */
8276 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
8277 && (arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
8278 symbol_get_bfdsym (fixp
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
8279 hppa_fixp
->fx_arg_reloc
)))
8282 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
8283 - md_pcrel_from (fixp
));
8284 /* Now check and see if we're going to need a long-branch stub. */
8285 if (fixp
->fx_r_type
== R_HPPA_PCREL_CALL
8286 && (distance
> 262143 || distance
< -262144))
8289 if (fixp
->fx_r_type
== R_HPPA_ABS_CALL
)
8291 #undef arg_reloc_stub_needed
8293 /* No need (yet) to force another relocations to be emitted. */
8297 /* Now for some ELF specific code. FIXME. */
8299 /* Mark the end of a function so that it's possible to compute
8300 the size of the function in hppa_elf_final_processing. */
8303 hppa_elf_mark_end_of_function ()
8305 /* ELF does not have EXIT relocations. All we do is create a
8306 temporary symbol marking the end of the function. */
8307 char *name
= (char *)
8308 xmalloc (strlen ("L$\001end_") +
8309 strlen (S_GET_NAME (last_call_info
->start_symbol
)) + 1);
8315 strcpy (name
, "L$\001end_");
8316 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
8318 /* If we have a .exit followed by a .procend, then the
8319 symbol will have already been defined. */
8320 symbolP
= symbol_find (name
);
8323 /* The symbol has already been defined! This can
8324 happen if we have a .exit followed by a .procend.
8326 This is *not* an error. All we want to do is free
8327 the memory we just allocated for the name and continue. */
8332 /* symbol value should be the offset of the
8333 last instruction of the function */
8334 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
8338 S_CLEAR_EXTERNAL (symbolP
);
8339 symbol_table_insert (symbolP
);
8343 last_call_info
->end_symbol
= symbolP
;
8345 as_bad (_("Symbol '%s' could not be created."), name
);
8349 as_bad (_("No memory for symbol name."));
8353 /* For ELF, this function serves one purpose: to setup the st_size
8354 field of STT_FUNC symbols. To do this, we need to scan the
8355 call_info structure list, determining st_size in by taking the
8356 difference in the address of the beginning/end marker symbols. */
8359 elf_hppa_final_processing ()
8361 struct call_info
*call_info_pointer
;
8363 for (call_info_pointer
= call_info_root
;
8365 call_info_pointer
= call_info_pointer
->ci_next
)
8367 elf_symbol_type
*esym
8368 = ((elf_symbol_type
*)
8369 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
8370 esym
->internal_elf_sym
.st_size
=
8371 S_GET_VALUE (call_info_pointer
->end_symbol
)
8372 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;
8380 if (debug_type
== DEBUG_DWARF2
)