1 /* tc-hppa.c -- Assemble for the PA
2 Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 99, 2000
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"
34 /* Be careful, this file includes data *declarations*. */
35 #include "opcode/hppa.h"
37 #if defined (OBJ_ELF) && defined (OBJ_SOM)
38 error only one of OBJ_ELF
and OBJ_SOM can be defined
41 /* If we are using ELF, then we probably can support dwarf2 debug
42 records. Furthermore, if we are supporting dwarf2 debug records,
43 then we want to use the assembler support for compact line numbers. */
45 #include "dwarf2dbg.h"
46 struct dwarf2_line_info debug_line
;
48 /* A "convient" place to put object file dependencies which do
49 not need to be seen outside of tc-hppa.c. */
51 /* Object file formats specify relocation types. */
52 typedef enum elf_hppa_reloc_type reloc_type
;
54 /* Object file formats specify BFD symbol types. */
55 typedef elf_symbol_type obj_symbol_type
;
56 #define symbol_arg_reloc_info(sym)\
57 (((obj_symbol_type *) symbol_get_bfdsym (sym))->tc_data.hppa_arg_reloc)
59 #if TARGET_ARCH_SIZE == 64
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
;
93 #define symbol_arg_reloc_info(sym)\
94 (((obj_symbol_type *) symbol_get_bfdsym (sym))->tc_data.ap.hppa_arg_reloc)
96 /* This apparently isn't in older versions of hpux reloc.h. */
98 #define R_DLT_REL 0x78
110 /* Various structures and types used internally in tc-hppa.c. */
112 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
116 unsigned int cannot_unwind
:1;
117 unsigned int millicode
:1;
118 unsigned int millicode_save_rest
:1;
119 unsigned int region_desc
:2;
120 unsigned int save_sr
:2;
121 unsigned int entry_fr
:4;
122 unsigned int entry_gr
:5;
123 unsigned int args_stored
:1;
124 unsigned int call_fr
:5;
125 unsigned int call_gr
:5;
126 unsigned int save_sp
:1;
127 unsigned int save_rp
:1;
128 unsigned int save_rp_in_frame
:1;
129 unsigned int extn_ptr_defined
:1;
130 unsigned int cleanup_defined
:1;
132 unsigned int hpe_interrupt_marker
:1;
133 unsigned int hpux_interrupt_marker
:1;
134 unsigned int reserved
:3;
135 unsigned int frame_size
:27;
140 /* Starting and ending offsets of the region described by
142 unsigned int start_offset
;
143 unsigned int end_offset
;
144 struct unwind_desc descriptor
;
147 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
148 control the entry and exit code they generate. It is also used in
149 creation of the correct stack unwind descriptors.
151 NOTE: GAS does not support .enter and .leave for the generation of
152 prologues and epilogues. FIXME.
154 The fields in structure roughly correspond to the arguments available on the
155 .callinfo pseudo-op. */
159 /* The unwind descriptor being built. */
160 struct unwind_table ci_unwind
;
162 /* Name of this function. */
163 symbolS
*start_symbol
;
165 /* (temporary) symbol used to mark the end of this function. */
168 /* Next entry in the chain. */
169 struct call_info
*ci_next
;
172 /* Operand formats for FP instructions. Note not all FP instructions
173 allow all four formats to be used (for example fmpysub only allows
177 SGL
, DBL
, ILLEGAL_FMT
, QUAD
, W
, UW
, DW
, UDW
, QW
, UQW
181 /* This fully describes the symbol types which may be attached to
182 an EXPORT or IMPORT directive. Only SOM uses this formation
183 (ELF has no need for it). */
187 SYMBOL_TYPE_ABSOLUTE
,
191 SYMBOL_TYPE_MILLICODE
,
193 SYMBOL_TYPE_PRI_PROG
,
194 SYMBOL_TYPE_SEC_PROG
,
198 /* This structure contains information needed to assemble
199 individual instructions. */
202 /* Holds the opcode after parsing by pa_ip. */
203 unsigned long opcode
;
205 /* Holds an expression associated with the current instruction. */
208 /* Does this instruction use PC-relative addressing. */
211 /* Floating point formats for operand1 and operand2. */
212 fp_operand_format fpof1
;
213 fp_operand_format fpof2
;
215 /* Whether or not we saw a truncation request on an fcnv insn. */
218 /* Holds the field selector for this instruction
219 (for example L%, LR%, etc). */
222 /* Holds any argument relocation bits associated with this
223 instruction. (instruction should be some sort of call). */
224 unsigned int arg_reloc
;
226 /* The format specification for this instruction. */
229 /* The relocation (if any) associated with this instruction. */
233 /* PA-89 floating point registers are arranged like this:
236 +--------------+--------------+
237 | 0 or 16L | 16 or 16R |
238 +--------------+--------------+
239 | 1 or 17L | 17 or 17R |
240 +--------------+--------------+
248 +--------------+--------------+
249 | 14 or 30L | 30 or 30R |
250 +--------------+--------------+
251 | 15 or 31L | 31 or 31R |
252 +--------------+--------------+
255 The following is a version of pa_parse_number that
256 handles the L/R notation and returns the correct
257 value to put into the instruction register field.
258 The correct value to put into the instruction is
259 encoded in the structure 'pa_11_fp_reg_struct'. */
261 struct pa_11_fp_reg_struct
263 /* The register number. */
270 /* Additional information needed to build argument relocation stubs. */
273 /* The argument relocation specification. */
274 unsigned int arg_reloc
;
276 /* Number of arguments. */
277 unsigned int arg_count
;
281 /* This structure defines an entry in the subspace dictionary
284 struct subspace_dictionary_chain
286 /* Nonzero if this space has been defined by the user code. */
287 unsigned int ssd_defined
;
289 /* Name of this subspace. */
292 /* GAS segment and subsegment associated with this subspace. */
296 /* Next space in the subspace dictionary chain. */
297 struct subspace_dictionary_chain
*ssd_next
;
300 typedef struct subspace_dictionary_chain ssd_chain_struct
;
302 /* This structure defines an entry in the subspace dictionary
305 struct space_dictionary_chain
307 /* Nonzero if this space has been defined by the user code or
308 as a default space. */
309 unsigned int sd_defined
;
311 /* Nonzero if this spaces has been defined by the user code. */
312 unsigned int sd_user_defined
;
314 /* The space number (or index). */
315 unsigned int sd_spnum
;
317 /* The name of this subspace. */
320 /* GAS segment to which this subspace corresponds. */
323 /* Current subsegment number being used. */
326 /* The chain of subspaces contained within this space. */
327 ssd_chain_struct
*sd_subspaces
;
329 /* The next entry in the space dictionary chain. */
330 struct space_dictionary_chain
*sd_next
;
333 typedef struct space_dictionary_chain sd_chain_struct
;
335 /* This structure defines attributes of the default subspace
336 dictionary entries. */
338 struct default_subspace_dict
340 /* Name of the subspace. */
343 /* FIXME. Is this still needed? */
346 /* Nonzero if this subspace is loadable. */
349 /* Nonzero if this subspace contains only code. */
352 /* Nonzero if this is a common subspace. */
355 /* Nonzero if this is a common subspace which allows symbols
356 to be multiply defined. */
359 /* Nonzero if this subspace should be zero filled. */
362 /* Sort key for this subspace. */
365 /* Access control bits for this subspace. Can represent RWX access
366 as well as privilege level changes for gateways. */
369 /* Index of containing space. */
372 /* Alignment (in bytes) of this subspace. */
375 /* Quadrant within space where this subspace should be loaded. */
378 /* An index into the default spaces array. */
381 /* Subsegment associated with this subspace. */
385 /* This structure defines attributes of the default space
386 dictionary entries. */
388 struct default_space_dict
390 /* Name of the space. */
393 /* Space number. It is possible to identify spaces within
394 assembly code numerically! */
397 /* Nonzero if this space is loadable. */
400 /* Nonzero if this space is "defined". FIXME is still needed */
403 /* Nonzero if this space can not be shared. */
406 /* Sort key for this space. */
409 /* Segment associated with this space. */
414 /* Structure for previous label tracking. Needed so that alignments,
415 callinfo declarations, etc can be easily attached to a particular
417 typedef struct label_symbol_struct
419 struct symbol
*lss_label
;
421 sd_chain_struct
*lss_space
;
426 struct label_symbol_struct
*lss_next
;
430 /* Extra information needed to perform fixups (relocations) on the PA. */
431 struct hppa_fix_struct
433 /* The field selector. */
434 enum hppa_reloc_field_selector_type_alt fx_r_field
;
439 /* Format of fixup. */
442 /* Argument relocation bits. */
443 unsigned int fx_arg_reloc
;
445 /* The segment this fixup appears in. */
449 /* Structure to hold information about predefined registers. */
457 /* This structure defines the mapping from a FP condition string
458 to a condition number which can be recorded in an instruction. */
465 /* This structure defines a mapping from a field selector
466 string to a field selector type. */
467 struct selector_entry
473 /* Prototypes for functions local to tc-hppa.c. */
476 static void pa_check_current_space_and_subspace
PARAMS ((void));
479 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
480 static void pa_text
PARAMS ((int));
481 static void pa_data
PARAMS ((int));
482 static void pa_comm
PARAMS ((int));
484 static fp_operand_format pa_parse_fp_format
PARAMS ((char **s
));
485 static void pa_cons
PARAMS ((int));
486 static void pa_float_cons
PARAMS ((int));
487 static void pa_fill
PARAMS ((int));
488 static void pa_lcomm
PARAMS ((int));
489 static void pa_lsym
PARAMS ((int));
490 static void pa_stringer
PARAMS ((int));
491 static void pa_version
PARAMS ((int));
492 static int pa_parse_fp_cmp_cond
PARAMS ((char **));
493 static int get_expression
PARAMS ((char *));
494 static int pa_get_absolute_expression
PARAMS ((struct pa_it
*, char **));
495 static int evaluate_absolute
PARAMS ((struct pa_it
*));
496 static unsigned int pa_build_arg_reloc
PARAMS ((char *));
497 static unsigned int pa_align_arg_reloc
PARAMS ((unsigned int, unsigned int));
498 static int pa_parse_nullif
PARAMS ((char **));
499 static int pa_parse_nonneg_cmpsub_cmpltr
PARAMS ((char **, int));
500 static int pa_parse_neg_cmpsub_cmpltr
PARAMS ((char **, int));
501 static int pa_parse_neg_add_cmpltr
PARAMS ((char **, int));
502 static int pa_parse_nonneg_add_cmpltr
PARAMS ((char **, int));
503 static int pa_parse_cmpb_64_cmpltr
PARAMS ((char **));
504 static int pa_parse_cmpib_64_cmpltr
PARAMS ((char **));
505 static int pa_parse_addb_64_cmpltr
PARAMS ((char **));
506 static void pa_block
PARAMS ((int));
507 static void pa_brtab
PARAMS ((int));
508 static void pa_try
PARAMS ((int));
509 static void pa_call
PARAMS ((int));
510 static void pa_call_args
PARAMS ((struct call_desc
*));
511 static void pa_callinfo
PARAMS ((int));
512 static void pa_copyright
PARAMS ((int));
513 static void pa_end
PARAMS ((int));
514 static void pa_enter
PARAMS ((int));
515 static void pa_entry
PARAMS ((int));
516 static void pa_equ
PARAMS ((int));
517 static void pa_exit
PARAMS ((int));
518 static void pa_export
PARAMS ((int));
519 static void pa_type_args
PARAMS ((symbolS
*, int));
520 static void pa_import
PARAMS ((int));
521 static void pa_label
PARAMS ((int));
522 static void pa_leave
PARAMS ((int));
523 static void pa_level
PARAMS ((int));
524 static void pa_origin
PARAMS ((int));
525 static void pa_proc
PARAMS ((int));
526 static void pa_procend
PARAMS ((int));
527 static void pa_param
PARAMS ((int));
528 static void pa_undefine_label
PARAMS ((void));
529 static int need_pa11_opcode
PARAMS ((struct pa_it
*,
530 struct pa_11_fp_reg_struct
*));
531 static int pa_parse_number
PARAMS ((char **, struct pa_11_fp_reg_struct
*));
532 static label_symbol_struct
*pa_get_label
PARAMS ((void));
534 static int log2
PARAMS ((int));
535 static void pa_compiler
PARAMS ((int));
536 static void pa_align
PARAMS ((int));
537 static void pa_space
PARAMS ((int));
538 static void pa_spnum
PARAMS ((int));
539 static void pa_subspace
PARAMS ((int));
540 static sd_chain_struct
*create_new_space
PARAMS ((char *, int, int,
543 static ssd_chain_struct
*create_new_subspace
PARAMS ((sd_chain_struct
*,
548 static ssd_chain_struct
*update_subspace
PARAMS ((sd_chain_struct
*,
549 char *, int, int, int,
553 static sd_chain_struct
*is_defined_space
PARAMS ((char *));
554 static ssd_chain_struct
*is_defined_subspace
PARAMS ((char *));
555 static sd_chain_struct
*pa_segment_to_space
PARAMS ((asection
*));
556 static ssd_chain_struct
*pa_subsegment_to_subspace
PARAMS ((asection
*,
558 static sd_chain_struct
*pa_find_space_by_number
PARAMS ((int));
559 static unsigned int pa_subspace_start
PARAMS ((sd_chain_struct
*, int));
560 static sd_chain_struct
*pa_parse_space_stmt
PARAMS ((char *, int));
561 static int pa_next_subseg
PARAMS ((sd_chain_struct
*));
562 static void pa_spaces_begin
PARAMS ((void));
564 static void pa_ip
PARAMS ((char *));
565 static void fix_new_hppa
PARAMS ((fragS
*, int, int, symbolS
*,
566 offsetT
, expressionS
*, int,
567 bfd_reloc_code_real_type
,
568 enum hppa_reloc_field_selector_type_alt
,
569 int, unsigned int, int *));
570 static int is_end_of_statement
PARAMS ((void));
571 static int reg_name_search
PARAMS ((char *));
572 static int pa_chk_field_selector
PARAMS ((char **));
573 static int is_same_frag
PARAMS ((fragS
*, fragS
*));
574 static void process_exit
PARAMS ((void));
575 static unsigned int pa_stringer_aux
PARAMS ((char *));
576 static fp_operand_format pa_parse_fp_cnv_format
PARAMS ((char **s
));
577 static int pa_parse_ftest_gfx_completer
PARAMS ((char **));
580 static void hppa_elf_mark_end_of_function
PARAMS ((void));
581 static void pa_build_unwind_subspace
PARAMS ((struct call_info
*));
584 /* File and gloally scoped variable declarations. */
587 /* Root and final entry in the space chain. */
588 static sd_chain_struct
*space_dict_root
;
589 static sd_chain_struct
*space_dict_last
;
591 /* The current space and subspace. */
592 static sd_chain_struct
*current_space
;
593 static ssd_chain_struct
*current_subspace
;
596 /* Root of the call_info chain. */
597 static struct call_info
*call_info_root
;
599 /* The last call_info (for functions) structure
600 seen so it can be associated with fixups and
602 static struct call_info
*last_call_info
;
604 /* The last call description (for actual calls). */
605 static struct call_desc last_call_desc
;
607 /* handle of the OPCODE hash table */
608 static struct hash_control
*op_hash
= NULL
;
610 /* Table of pseudo ops for the PA. FIXME -- how many of these
611 are now redundant with the overall GAS and the object file
613 const pseudo_typeS md_pseudo_table
[] =
615 /* align pseudo-ops on the PA specify the actual alignment requested,
616 not the log2 of the requested alignment. */
618 {"align", pa_align
, 8},
621 {"align", s_align_bytes
, 8},
623 {"begin_brtab", pa_brtab
, 1},
624 {"begin_try", pa_try
, 1},
625 {"block", pa_block
, 1},
626 {"blockz", pa_block
, 0},
627 {"byte", pa_cons
, 1},
628 {"call", pa_call
, 0},
629 {"callinfo", pa_callinfo
, 0},
630 #if defined (OBJ_ELF) && defined (TE_LINUX)
631 {"code", obj_elf_text
, 0},
633 {"code", pa_text
, 0},
634 {"comm", pa_comm
, 0},
637 {"compiler", pa_compiler
, 0},
639 {"copyright", pa_copyright
, 0},
640 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
641 {"data", pa_data
, 0},
643 {"double", pa_float_cons
, 'd'},
644 {"dword", pa_cons
, 8},
646 {"end_brtab", pa_brtab
, 0},
647 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
648 {"end_try", pa_try
, 0},
650 {"enter", pa_enter
, 0},
651 {"entry", pa_entry
, 0},
653 {"exit", pa_exit
, 0},
654 {"export", pa_export
, 0},
656 {"file", dwarf2_directive_file
, 0 },
658 {"fill", pa_fill
, 0},
659 {"float", pa_float_cons
, 'f'},
660 {"half", pa_cons
, 2},
661 {"import", pa_import
, 0},
663 {"label", pa_label
, 0},
664 {"lcomm", pa_lcomm
, 0},
665 {"leave", pa_leave
, 0},
666 {"level", pa_level
, 0},
668 {"loc", dwarf2_directive_loc
, 0 },
670 {"long", pa_cons
, 4},
671 {"lsym", pa_lsym
, 0},
673 {"nsubspa", pa_subspace
, 1},
675 {"octa", pa_cons
, 16},
676 {"org", pa_origin
, 0},
677 {"origin", pa_origin
, 0},
678 {"param", pa_param
, 0},
679 {"proc", pa_proc
, 0},
680 {"procend", pa_procend
, 0},
681 {"quad", pa_cons
, 8},
683 {"short", pa_cons
, 2},
684 {"single", pa_float_cons
, 'f'},
686 {"space", pa_space
, 0},
687 {"spnum", pa_spnum
, 0},
689 {"string", pa_stringer
, 0},
690 {"stringz", pa_stringer
, 1},
692 {"subspa", pa_subspace
, 0},
694 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
695 {"text", pa_text
, 0},
697 {"version", pa_version
, 0},
698 {"word", pa_cons
, 4},
702 /* This array holds the chars that only start a comment at the beginning of
703 a line. If the line seems to have the form '# 123 filename'
704 .line and .file directives will appear in the pre-processed output.
706 Note that input_file.c hand checks for '#' at the beginning of the
707 first line of the input file. This is because the compiler outputs
708 #NO_APP at the beginning of its output.
710 Also note that C style comments will always work. */
711 const char line_comment_chars
[] = "#";
713 /* This array holds the chars that always start a comment. If the
714 pre-processor is disabled, these aren't very useful. */
715 const char comment_chars
[] = ";";
717 /* This array holds the characters which act as line separators. */
718 const char line_separator_chars
[] = "!";
720 /* Chars that can be used to separate mant from exp in floating point nums. */
721 const char EXP_CHARS
[] = "eE";
723 /* Chars that mean this number is a floating point constant.
724 As in 0f12.456 or 0d1.2345e12.
726 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
727 changed in read.c. Ideally it shouldn't hae to know abou it at
728 all, but nothing is ideal around here. */
729 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
731 static struct pa_it the_insn
;
733 /* Points to the end of an expression just parsed by get_expressoin
734 and friends. FIXME. This shouldn't be handled with a file-global
736 static char *expr_end
;
738 /* Nonzero if a .callinfo appeared within the current procedure. */
739 static int callinfo_found
;
741 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
742 static int within_entry_exit
;
744 /* Nonzero if the assembler is currently within a procedure definition. */
745 static int within_procedure
;
747 /* Handle on structure which keep track of the last symbol
748 seen in each subspace. */
749 static label_symbol_struct
*label_symbols_rootp
= NULL
;
751 /* Holds the last field selector. */
752 static int hppa_field_selector
;
754 /* Nonzero when strict syntax checking is enabled. Zero otherwise.
756 Each opcode in the table has a flag which indicates whether or not
757 strict syntax checking should be enabled for that instruction. */
758 static int strict
= 0;
761 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
762 static symbolS
*dummy_symbol
;
765 /* Nonzero if errors are to be printed. */
766 static int print_errors
= 1;
768 /* List of registers that are pre-defined:
770 Each general register has one predefined name of the form
771 %r<REGNUM> which has the value <REGNUM>.
773 Space and control registers are handled in a similar manner,
774 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
776 Likewise for the floating point registers, but of the form
777 %fr<REGNUM>. Floating point registers have additional predefined
778 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
779 again have the value <REGNUM>.
781 Many registers also have synonyms:
783 %r26 - %r23 have %arg0 - %arg3 as synonyms
784 %r28 - %r29 have %ret0 - %ret1 as synonyms
785 %r30 has %sp as a synonym
786 %r27 has %dp as a synonym
787 %r2 has %rp as a synonym
789 Almost every control register has a synonym; they are not listed
792 The table is sorted. Suitable for searching by a binary search. */
794 static const struct pd_reg pre_defined_registers
[] =
994 /* This table is sorted by order of the length of the string. This is
995 so we check for <> before we check for <. If we had a <> and checked
996 for < first, we would get a false match. */
997 static const struct fp_cond_map fp_cond_map
[] =
1033 static const struct selector_entry selector_table
[] =
1058 /* default space and subspace dictionaries */
1060 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1061 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1063 /* pre-defined subsegments (subspaces) for the HPPA. */
1064 #define SUBSEG_CODE 0
1065 #define SUBSEG_LIT 1
1066 #define SUBSEG_MILLI 2
1067 #define SUBSEG_DATA 0
1068 #define SUBSEG_BSS 2
1069 #define SUBSEG_UNWIND 3
1070 #define SUBSEG_GDB_STRINGS 0
1071 #define SUBSEG_GDB_SYMBOLS 1
1073 static struct default_subspace_dict pa_def_subspaces
[] =
1075 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE
},
1076 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA
},
1077 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT
},
1078 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI
},
1079 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS
},
1080 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1083 static struct default_space_dict pa_def_spaces
[] =
1085 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
},
1086 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
},
1087 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
}
1090 /* Misc local definitions used by the assembler. */
1092 /* These macros are used to maintain spaces/subspaces. */
1093 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1094 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1095 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1096 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1098 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1099 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1102 /* Return nonzero if the string pointed to by S potentially represents
1103 a right or left half of a FP register */
1104 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1105 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1107 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1108 main loop after insertion. */
1110 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1112 ((OPCODE) |= (FIELD) << (START)); \
1116 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1117 IGNORE is used to suppress the error message. */
1119 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1121 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1124 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1130 /* Simple alignment checking for FIELD againt ALIGN (a power of two).
1131 IGNORE is used to suppress the error message. */
1133 #define CHECK_ALIGN(FIELD, ALIGN, IGNORE) \
1135 if ((FIELD) & ((ALIGN) - 1)) \
1138 as_bad (_("Field not properly aligned [%d] (%d)."), (ALIGN), \
1144 #define is_DP_relative(exp) \
1145 ((exp).X_op == O_subtract \
1146 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1148 #define is_PC_relative(exp) \
1149 ((exp).X_op == O_subtract \
1150 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1152 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1153 always be able to reduce the expression to a constant, so we don't
1154 need real complex handling yet. */
1155 #define is_complex(exp) \
1156 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1158 /* Actual functions to implement the PA specific code for the assembler. */
1160 /* Called before writing the object file. Make sure entry/exit and
1161 proc/procend pairs match. */
1166 if (within_entry_exit
)
1167 as_fatal (_("Missing .exit\n"));
1169 if (within_procedure
)
1170 as_fatal (_("Missing .procend\n"));
1173 /* Returns a pointer to the label_symbol_struct for the current space.
1174 or NULL if no label_symbol_struct exists for the current space. */
1176 static label_symbol_struct
*
1179 label_symbol_struct
*label_chain
;
1181 for (label_chain
= label_symbols_rootp
;
1183 label_chain
= label_chain
->lss_next
)
1186 if (current_space
== label_chain
->lss_space
&& label_chain
->lss_label
)
1190 if (now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
)
1198 /* Defines a label for the current space. If one is already defined,
1199 this function will replace it with the new label. */
1202 pa_define_label (symbol
)
1205 label_symbol_struct
*label_chain
= pa_get_label ();
1208 label_chain
->lss_label
= symbol
;
1211 /* Create a new label entry and add it to the head of the chain. */
1213 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1214 label_chain
->lss_label
= symbol
;
1216 label_chain
->lss_space
= current_space
;
1219 label_chain
->lss_segment
= now_seg
;
1221 label_chain
->lss_next
= NULL
;
1223 if (label_symbols_rootp
)
1224 label_chain
->lss_next
= label_symbols_rootp
;
1226 label_symbols_rootp
= label_chain
;
1230 /* Removes a label definition for the current space.
1231 If there is no label_symbol_struct entry, then no action is taken. */
1234 pa_undefine_label ()
1236 label_symbol_struct
*label_chain
;
1237 label_symbol_struct
*prev_label_chain
= NULL
;
1239 for (label_chain
= label_symbols_rootp
;
1241 label_chain
= label_chain
->lss_next
)
1245 && current_space
== label_chain
->lss_space
&& label_chain
->lss_label
1248 && now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
1252 /* Remove the label from the chain and free its memory. */
1253 if (prev_label_chain
)
1254 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1256 label_symbols_rootp
= label_chain
->lss_next
;
1261 prev_label_chain
= label_chain
;
1266 /* An HPPA-specific version of fix_new. This is required because the HPPA
1267 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1268 results in the creation of an instance of an hppa_fix_struct. An
1269 hppa_fix_struct stores the extra information along with a pointer to the
1270 original fixS. This is attached to the original fixup via the
1271 tc_fix_data field. */
1274 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1275 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1279 symbolS
*add_symbol
;
1283 bfd_reloc_code_real_type r_type
;
1284 enum hppa_reloc_field_selector_type_alt r_field
;
1286 unsigned int arg_reloc
;
1287 int* unwind_bits ATTRIBUTE_UNUSED
;
1291 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1292 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1295 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1297 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1298 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1299 hppa_fix
->fx_r_type
= r_type
;
1300 hppa_fix
->fx_r_field
= r_field
;
1301 hppa_fix
->fx_r_format
= r_format
;
1302 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1303 hppa_fix
->segment
= now_seg
;
1305 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1306 new_fix
->fx_offset
= *unwind_bits
;
1309 /* foo-$global$ is used to access non-automatic storage. $global$
1310 is really just a marker and has served its purpose, so eliminate
1311 it now so as not to confuse write.c. */
1312 if (new_fix
->fx_subsy
1313 && !strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$"))
1314 new_fix
->fx_subsy
= NULL
;
1317 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1318 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1321 parse_cons_expression_hppa (exp
)
1324 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1328 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1329 hppa_field_selector is set by the parse_cons_expression_hppa. */
1332 cons_fix_new_hppa (frag
, where
, size
, exp
)
1338 unsigned int rel_type
;
1340 /* Get a base relocation type. */
1341 if (is_DP_relative (*exp
))
1342 rel_type
= R_HPPA_GOTOFF
;
1343 else if (is_complex (*exp
))
1344 rel_type
= R_HPPA_COMPLEX
;
1348 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1350 as_warn (_("Invalid field selector. Assuming F%%."));
1351 hppa_field_selector
= e_fsel
;
1354 fix_new_hppa (frag
, where
, size
,
1355 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1356 hppa_field_selector
, size
* 8, 0, NULL
);
1358 /* Reset field selector to its default state. */
1359 hppa_field_selector
= 0;
1362 /* This function is called once, at assembler startup time. It should
1363 set up all the tables, etc. that the MD part of the assembler will need. */
1368 const char *retval
= NULL
;
1372 last_call_info
= NULL
;
1373 call_info_root
= NULL
;
1375 /* Set the default machine type. */
1376 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1377 as_warn (_("could not set architecture and machine"));
1379 /* Folding of text and data segments fails miserably on the PA.
1380 Warn user and disable "-R" option. */
1381 if (flag_readonly_data_in_text
)
1383 as_warn (_("-R option not supported on this target."));
1384 flag_readonly_data_in_text
= 0;
1391 op_hash
= hash_new ();
1393 while (i
< NUMOPCODES
)
1395 const char *name
= pa_opcodes
[i
].name
;
1396 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1397 if (retval
!= NULL
&& *retval
!= '\0')
1399 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1404 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1405 != pa_opcodes
[i
].match
)
1407 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1408 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1413 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1417 as_fatal (_("Broken assembler. No assembly attempted."));
1420 /* SOM will change text_section. To make sure we never put
1421 anything into the old one switch to the new one now. */
1422 subseg_set (text_section
, 0);
1426 dummy_symbol
= symbol_find_or_make ("L$dummy");
1427 S_SET_SEGMENT (dummy_symbol
, text_section
);
1428 /* Force the symbol to be converted to a real symbol. */
1429 (void) symbol_get_bfdsym (dummy_symbol
);
1433 /* Assemble a single instruction storing it into a frag. */
1440 /* The had better be something to assemble. */
1443 /* If we are within a procedure definition, make sure we've
1444 defined a label for the procedure; handle case where the
1445 label was defined after the .PROC directive.
1447 Note there's not need to diddle with the segment or fragment
1448 for the label symbol in this case. We have already switched
1449 into the new $CODE$ subspace at this point. */
1450 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1452 label_symbol_struct
*label_symbol
= pa_get_label ();
1456 if (label_symbol
->lss_label
)
1458 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1459 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1462 /* Also handle allocation of a fixup to hold the unwind
1463 information when the label appears after the proc/procend. */
1464 if (within_entry_exit
)
1466 char *where
= frag_more (0);
1468 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1469 NULL
, (offsetT
) 0, NULL
,
1470 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1471 (int *)&last_call_info
->ci_unwind
.descriptor
);
1476 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1479 as_bad (_("Missing function name for .PROC"));
1482 /* Assemble the instruction. Results are saved into "the_insn". */
1485 /* Get somewhere to put the assembled instrution. */
1488 /* Output the opcode. */
1489 md_number_to_chars (to
, the_insn
.opcode
, 4);
1491 /* If necessary output more stuff. */
1492 if (the_insn
.reloc
!= R_HPPA_NONE
)
1493 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1494 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1495 the_insn
.reloc
, the_insn
.field_selector
,
1496 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1499 if (debug_type
== DEBUG_DWARF2
)
1503 /* First update the notion of the current source line. */
1504 dwarf2_where (&debug_line
);
1506 /* We want the offset of the start of this instruction within the
1507 the current frag. */
1508 addr
= frag_now
->fr_address
+ frag_now_fix () - 4;
1510 /* And record the information. */
1511 dwarf2_gen_line_info (addr
, &debug_line
);
1516 /* Do the real work for assembling a single instruction. Store results
1517 into the global "the_insn" variable. */
1523 char *error_message
= "";
1524 char *s
, c
, *argstart
, *name
, *save_s
;
1528 int cmpltr
, nullif
, flag
, cond
, num
;
1529 unsigned long opcode
;
1530 struct pa_opcode
*insn
;
1533 /* We must have a valid space and subspace. */
1534 pa_check_current_space_and_subspace ();
1537 /* Convert everything up to the first whitespace character into lower
1539 for (s
= str
; *s
!= ' ' && *s
!= '\t' && *s
!= '\n' && *s
!= '\0'; s
++)
1543 /* Skip to something interesting. */
1544 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1563 as_fatal (_("Unknown opcode: `%s'"), str
);
1568 /* Look up the opcode in the has table. */
1569 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1571 as_bad ("Unknown opcode: `%s'", str
);
1580 /* Mark the location where arguments for the instruction start, then
1581 start processing them. */
1585 /* Do some initialization. */
1586 opcode
= insn
->match
;
1587 strict
= (insn
->flags
& FLAG_STRICT
);
1588 memset (&the_insn
, 0, sizeof (the_insn
));
1590 the_insn
.reloc
= R_HPPA_NONE
;
1592 /* If this instruction is specific to a particular architecture,
1593 then set a new architecture. */
1594 /* But do not automatically promote to pa2.0. The automatic promotion
1595 crud is for compatability with HP's old assemblers only. */
1597 && bfd_get_mach (stdoutput
) < insn
->arch
)
1599 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1600 as_warn (_("could not update architecture and machine"));
1602 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1608 /* Build the opcode, checking as we go to make
1609 sure that the operands match. */
1610 for (args
= insn
->args
;; ++args
)
1612 /* Absorb white space in instruction. */
1613 while (*s
== ' ' || *s
== '\t')
1619 /* End of arguments. */
1635 /* These must match exactly. */
1644 /* Handle a 5 bit register or control register field at 10. */
1647 /* This should be more strict. Small steps. */
1648 if (strict
&& *s
!= '%')
1650 num
= pa_parse_number (&s
, 0);
1651 CHECK_FIELD (num
, 31, 0, 0);
1652 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1654 /* Handle %sar or %cr11. No bits get set, we just verify that it
1657 /* Skip whitespace before register. */
1658 while (*s
== ' ' || *s
== '\t')
1661 if (!strncasecmp(s
, "%sar", 4))
1666 else if (!strncasecmp(s
, "%cr11", 5))
1673 /* Handle a 5 bit register field at 15. */
1675 /* This should be more strict. Small steps. */
1676 if (strict
&& *s
!= '%')
1678 num
= pa_parse_number (&s
, 0);
1679 CHECK_FIELD (num
, 31, 0, 0);
1680 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1682 /* Handle a 5 bit register field at 31. */
1684 /* This should be more strict. Small steps. */
1685 if (strict
&& *s
!= '%')
1687 num
= pa_parse_number (&s
, 0);
1688 CHECK_FIELD (num
, 31, 0, 0);
1689 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1691 /* Handle a 5 bit register field at 10 and 15. */
1693 /* This should be more strict. Small steps. */
1694 if (strict
&& *s
!= '%')
1696 num
= pa_parse_number (&s
, 0);
1697 CHECK_FIELD (num
, 31, 0, 0);
1698 opcode
|= num
<< 16;
1699 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1701 /* Handle a 5 bit field length at 31. */
1703 num
= pa_get_absolute_expression (&the_insn
, &s
);
1704 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1707 CHECK_FIELD (num
, 32, 1, 0);
1708 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1710 /* Handle a 5 bit immediate at 15. */
1712 num
= pa_get_absolute_expression (&the_insn
, &s
);
1713 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1716 /* When in strict mode, we want to just reject this
1717 match instead of giving an out of range error. */
1718 CHECK_FIELD (num
, 15, -16, strict
);
1719 num
= low_sign_unext (num
, 5);
1720 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1722 /* Handle a 5 bit immediate at 31. */
1724 num
= pa_get_absolute_expression (&the_insn
, &s
);
1725 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1728 /* When in strict mode, we want to just reject this
1729 match instead of giving an out of range error. */
1730 CHECK_FIELD (num
, 15, -16, strict
);
1731 num
= low_sign_unext (num
, 5);
1732 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1734 /* Handle an unsigned 5 bit immediate at 31. */
1736 num
= pa_get_absolute_expression (&the_insn
, &s
);
1737 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1740 CHECK_FIELD (num
, 31, 0, strict
);
1741 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1743 /* Handle an unsigned 5 bit immediate at 15. */
1745 num
= pa_get_absolute_expression (&the_insn
, &s
);
1746 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1749 CHECK_FIELD (num
, 31, 0, strict
);
1750 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1752 /* Handle an unsigned 10 bit immediate at 15. */
1754 num
= pa_get_absolute_expression (&the_insn
, &s
);
1755 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1758 CHECK_FIELD (num
, 1023, 0, strict
);
1759 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1761 /* Handle a 2 bit space identifier at 17. */
1763 /* This should be more strict. Small steps. */
1764 if (strict
&& *s
!= '%')
1766 num
= pa_parse_number (&s
, 0);
1767 CHECK_FIELD (num
, 3, 0, 1);
1768 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1770 /* Handle a 3 bit space identifier at 18. */
1772 /* This should be more strict. Small steps. */
1773 if (strict
&& *s
!= '%')
1775 num
= pa_parse_number (&s
, 0);
1776 CHECK_FIELD (num
, 7, 0, 1);
1777 opcode
|= re_assemble_3 (num
);
1780 /* Handle all completers. */
1785 /* Handle a completer for an indexing load or store. */
1791 while (*s
== ',' && i
< 2)
1794 if (strncasecmp (s
, "sm", 2) == 0)
1801 else if (strncasecmp (s
, "m", 1) == 0)
1803 else if ((strncasecmp (s
, "s ", 2) == 0)
1804 || (strncasecmp (s
, "s,", 2) == 0))
1806 /* When in strict mode this is a match failure. */
1813 as_bad (_("Invalid Indexed Load Completer."));
1818 as_bad (_("Invalid Indexed Load Completer Syntax."));
1820 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1823 /* Handle a short load/store completer. */
1835 if (strncasecmp (s
, "ma", 2) == 0)
1841 else if (strncasecmp (s
, "mb", 2) == 0)
1848 /* When in strict mode, pass through for cache op. */
1849 if (!found
&& strict
)
1854 as_bad (_("Invalid Short Load/Store Completer."));
1858 /* If we did not get a ma/mb completer, then we do not
1859 consider this a positive match for 'ce'. */
1860 else if (*args
== 'e')
1863 /* 'J', 'm' and 'q' are the same, except for where they
1864 encode the before/after field. */
1868 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1870 else if (*args
== 'q')
1873 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1875 else if (*args
== 'J')
1877 /* M bit is explicit in the major opcode. */
1878 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1880 else if (*args
== 'e')
1882 /* Gross! Hide these values in the immediate field
1883 of the instruction, then pull them out later. */
1890 /* Handle a stbys completer. */
1896 while (*s
== ',' && i
< 2)
1899 if (strncasecmp (s
, "m", 1) == 0)
1901 else if ((strncasecmp (s
, "b ", 2) == 0)
1902 || (strncasecmp (s
, "b,", 2) == 0))
1904 else if (strncasecmp (s
, "e", 1) == 0)
1906 /* When in strict mode this is a match failure. */
1913 as_bad (_("Invalid Store Bytes Short Completer"));
1918 as_bad (_("Invalid Store Bytes Short Completer"));
1920 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1923 /* Handle load cache hint completer. */
1926 if (!strncmp(s
, ",sl", 3))
1931 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1933 /* Handle store cache hint completer. */
1936 if (!strncmp(s
, ",sl", 3))
1941 else if (!strncmp(s
, ",bc", 3))
1946 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1948 /* Handle load and clear cache hint completer. */
1951 if (!strncmp(s
, ",co", 3))
1956 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1958 /* Handle load ordering completer. */
1960 if (strncmp(s
, ",o", 2) != 0)
1965 /* Handle a branch gate completer. */
1967 if (strncasecmp (s
, ",gate", 5) != 0)
1972 /* Handle a branch link and push completer. */
1974 if (strncasecmp (s
, ",l,push", 7) != 0)
1979 /* Handle a branch link completer. */
1981 if (strncasecmp (s
, ",l", 2) != 0)
1986 /* Handle a branch pop completer. */
1988 if (strncasecmp (s
, ",pop", 4) != 0)
1993 /* Handle a local processor completer. */
1995 if (strncasecmp (s
, ",l", 2) != 0)
2000 /* Handle a PROBE read/write completer. */
2003 if (!strncasecmp (s
, ",w", 2))
2008 else if (!strncasecmp (s
, ",r", 2))
2014 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2016 /* Handle MFCTL wide completer. */
2018 if (strncasecmp (s
, ",w", 2) != 0)
2023 /* Handle an RFI restore completer. */
2026 if (!strncasecmp (s
, ",r", 2))
2032 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2034 /* Handle a system control completer. */
2036 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2044 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2046 /* Handle intermediate/final completer for DCOR. */
2049 if (!strncasecmp (s
, ",i", 2))
2055 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2057 /* Handle zero/sign extension completer. */
2060 if (!strncasecmp (s
, ",z", 2))
2066 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2068 /* Handle add completer. */
2071 if (!strncasecmp (s
, ",l", 2))
2076 else if (!strncasecmp (s
, ",tsv", 4))
2082 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2084 /* Handle 64 bit carry for ADD. */
2087 if (!strncasecmp (s
, ",dc,tsv", 7) ||
2088 !strncasecmp (s
, ",tsv,dc", 7))
2093 else if (!strncasecmp (s
, ",dc", 3))
2101 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2103 /* Handle 32 bit carry for ADD. */
2106 if (!strncasecmp (s
, ",c,tsv", 6) ||
2107 !strncasecmp (s
, ",tsv,c", 6))
2112 else if (!strncasecmp (s
, ",c", 2))
2120 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2122 /* Handle trap on signed overflow. */
2125 if (!strncasecmp (s
, ",tsv", 4))
2131 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2133 /* Handle trap on condition and overflow. */
2136 if (!strncasecmp (s
, ",tc,tsv", 7) ||
2137 !strncasecmp (s
, ",tsv,tc", 7))
2142 else if (!strncasecmp (s
, ",tc", 3))
2150 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2152 /* Handle 64 bit borrow for SUB. */
2155 if (!strncasecmp (s
, ",db,tsv", 7) ||
2156 !strncasecmp (s
, ",tsv,db", 7))
2161 else if (!strncasecmp (s
, ",db", 3))
2169 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2171 /* Handle 32 bit borrow for SUB. */
2174 if (!strncasecmp (s
, ",b,tsv", 6) ||
2175 !strncasecmp (s
, ",tsv,b", 6))
2180 else if (!strncasecmp (s
, ",b", 2))
2188 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2190 /* Handle trap condition completer for UADDCM. */
2193 if (!strncasecmp (s
, ",tc", 3))
2199 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2201 /* Handle signed/unsigned at 21. */
2205 if (strncasecmp (s
, ",s", 2) == 0)
2210 else if (strncasecmp (s
, ",u", 2) == 0)
2216 INSERT_FIELD_AND_CONTINUE (opcode
, sign
, 10);
2219 /* Handle left/right combination at 17:18. */
2229 as_bad(_("Invalid left/right combination completer"));
2232 INSERT_FIELD_AND_CONTINUE (opcode
, lr
, 13);
2235 as_bad(_("Invalid left/right combination completer"));
2238 /* Handle saturation at 24:25. */
2242 if (strncasecmp (s
, ",ss", 3) == 0)
2247 else if (strncasecmp (s
, ",us", 3) == 0)
2253 INSERT_FIELD_AND_CONTINUE (opcode
, sat
, 6);
2256 /* Handle permutation completer. */
2284 as_bad(_("Invalid permutation completer"));
2286 opcode
|= perm
<< permloc
[i
];
2291 as_bad(_("Invalid permutation completer"));
2299 /* Handle all conditions. */
2305 /* Handle FP compare conditions. */
2307 cond
= pa_parse_fp_cmp_cond (&s
);
2308 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2310 /* Handle an add condition. */
2319 /* 64 bit conditions. */
2332 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2336 if (strcmp (name
, "=") == 0)
2338 else if (strcmp (name
, "<") == 0)
2340 else if (strcmp (name
, "<=") == 0)
2342 else if (strcasecmp (name
, "nuv") == 0)
2344 else if (strcasecmp (name
, "znv") == 0)
2346 else if (strcasecmp (name
, "sv") == 0)
2348 else if (strcasecmp (name
, "od") == 0)
2350 else if (strcasecmp (name
, "tr") == 0)
2355 else if (strcmp (name
, "<>") == 0)
2360 else if (strcmp (name
, ">=") == 0)
2365 else if (strcmp (name
, ">") == 0)
2370 else if (strcasecmp (name
, "uv") == 0)
2375 else if (strcasecmp (name
, "vnz") == 0)
2380 else if (strcasecmp (name
, "nsv") == 0)
2385 else if (strcasecmp (name
, "ev") == 0)
2390 /* ",*" is a valid condition. */
2391 else if (*args
== 'a')
2392 as_bad (_("Invalid Add Condition: %s"), name
);
2395 opcode
|= cmpltr
<< 13;
2396 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2398 /* Handle non-negated add and branch condition. */
2400 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2403 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2406 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2408 /* Handle 64 bit wide-mode add and branch condition. */
2410 cmpltr
= pa_parse_addb_64_cmpltr (&s
);
2413 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2418 /* Negated condition requires an opcode change. */
2419 opcode
|= (cmpltr
& 8) << 24;
2421 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2423 /* Handle a negated or non-negated add and branch
2427 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2431 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
2434 as_bad (_("Invalid Compare/Subtract Condition"));
2439 /* Negated condition requires an opcode change. */
2443 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2445 /* Handle branch on bit conditions. */
2463 if (strncmp (s
, "<", 1) == 0)
2468 else if (strncmp (s
, ">=", 2) == 0)
2474 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2476 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2478 /* Handle a compare/subtract condition. */
2487 /* 64 bit conditions. */
2500 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2504 if (strcmp (name
, "=") == 0)
2506 else if (strcmp (name
, "<") == 0)
2508 else if (strcmp (name
, "<=") == 0)
2510 else if (strcasecmp (name
, "<<") == 0)
2512 else if (strcasecmp (name
, "<<=") == 0)
2514 else if (strcasecmp (name
, "sv") == 0)
2516 else if (strcasecmp (name
, "od") == 0)
2518 else if (strcasecmp (name
, "tr") == 0)
2523 else if (strcmp (name
, "<>") == 0)
2528 else if (strcmp (name
, ">=") == 0)
2533 else if (strcmp (name
, ">") == 0)
2538 else if (strcasecmp (name
, ">>=") == 0)
2543 else if (strcasecmp (name
, ">>") == 0)
2548 else if (strcasecmp (name
, "nsv") == 0)
2553 else if (strcasecmp (name
, "ev") == 0)
2558 /* ",*" is a valid condition. */
2559 else if (*args
!= 'S')
2560 as_bad (_("Invalid Compare/Subtract Condition: %s"),
2564 opcode
|= cmpltr
<< 13;
2565 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2567 /* Handle a non-negated compare condition. */
2569 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2572 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
2575 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2577 /* Handle a 32 bit compare and branch condition. */
2580 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2584 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
2587 as_bad (_("Invalid Compare and Branch Condition."));
2592 /* Negated condition requires an opcode change. */
2597 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2599 /* Handle a 64 bit compare and branch condition. */
2601 cmpltr
= pa_parse_cmpb_64_cmpltr (&s
);
2604 /* Negated condition requires an opcode change. */
2605 opcode
|= (cmpltr
& 8) << 26;
2608 /* Not a 64 bit cond. Give 32 bit a chance. */
2611 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2613 /* Handle a 64 bit cmpib condition. */
2615 cmpltr
= pa_parse_cmpib_64_cmpltr (&s
);
2617 /* Not a 64 bit cond. Give 32 bit a chance. */
2620 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2622 /* Handle a logical instruction condition. */
2631 /* 64 bit conditions. */
2643 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2648 if (strcmp (name
, "=") == 0)
2650 else if (strcmp (name
, "<") == 0)
2652 else if (strcmp (name
, "<=") == 0)
2654 else if (strcasecmp (name
, "od") == 0)
2656 else if (strcasecmp (name
, "tr") == 0)
2661 else if (strcmp (name
, "<>") == 0)
2666 else if (strcmp (name
, ">=") == 0)
2671 else if (strcmp (name
, ">") == 0)
2676 else if (strcasecmp (name
, "ev") == 0)
2681 /* ",*" is a valid condition. */
2682 else if (*args
!= 'L')
2683 as_bad (_("Invalid Logical Instruction Condition."));
2686 opcode
|= cmpltr
<< 13;
2687 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2689 /* Handle a shift/extract/deposit condition. */
2698 /* 64 bit conditions. */
2710 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2714 if (strcmp (name
, "=") == 0)
2716 else if (strcmp (name
, "<") == 0)
2718 else if (strcasecmp (name
, "od") == 0)
2720 else if (strcasecmp (name
, "tr") == 0)
2722 else if (strcmp (name
, "<>") == 0)
2724 else if (strcmp (name
, ">=") == 0)
2726 else if (strcasecmp (name
, "ev") == 0)
2728 /* Handle movb,n. Put things back the way they were.
2729 This includes moving s back to where it started. */
2730 else if (strcasecmp (name
, "n") == 0 && *args
== 'y')
2736 /* ",*" is a valid condition. */
2737 else if (*args
!= 'X')
2738 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2741 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2743 /* Handle a unit instruction condition. */
2752 /* 64 bit conditions. */
2763 if (strncasecmp (s
, "sbz", 3) == 0)
2768 else if (strncasecmp (s
, "shz", 3) == 0)
2773 else if (strncasecmp (s
, "sdc", 3) == 0)
2778 else if (strncasecmp (s
, "sbc", 3) == 0)
2783 else if (strncasecmp (s
, "shc", 3) == 0)
2788 else if (strncasecmp (s
, "tr", 2) == 0)
2794 else if (strncasecmp (s
, "nbz", 3) == 0)
2800 else if (strncasecmp (s
, "nhz", 3) == 0)
2806 else if (strncasecmp (s
, "ndc", 3) == 0)
2812 else if (strncasecmp (s
, "nbc", 3) == 0)
2818 else if (strncasecmp (s
, "nhc", 3) == 0)
2824 else if (strncasecmp (s
, "swz", 3) == 0)
2830 else if (strncasecmp (s
, "swc", 3) == 0)
2836 else if (strncasecmp (s
, "nwz", 3) == 0)
2842 else if (strncasecmp (s
, "nwc", 3) == 0)
2848 /* ",*" is a valid condition. */
2849 else if (*args
!= 'U')
2850 as_bad (_("Invalid Unit Instruction Condition."));
2852 opcode
|= cmpltr
<< 13;
2853 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2861 /* Handle a nullification completer for branch instructions. */
2863 nullif
= pa_parse_nullif (&s
);
2864 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2866 /* Handle a nullification completer for copr and spop insns. */
2868 nullif
= pa_parse_nullif (&s
);
2869 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2871 /* Handle ,%r2 completer for new syntax branches. */
2873 if (*s
== ',' && strncasecmp (s
+ 1, "%r2", 3) == 0)
2875 else if (*s
== ',' && strncasecmp (s
+ 1, "%rp", 3) == 0)
2881 /* Handle 3 bit entry into the fp compare array. Valid values
2882 are 0..6 inclusive. */
2886 if (the_insn
.exp
.X_op
== O_constant
)
2888 num
= evaluate_absolute (&the_insn
);
2889 CHECK_FIELD (num
, 6, 0, 0);
2891 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2896 /* Handle 3 bit entry into the fp compare array. Valid values
2897 are 0..6 inclusive. */
2900 if (the_insn
.exp
.X_op
== O_constant
)
2903 num
= evaluate_absolute (&the_insn
);
2904 CHECK_FIELD (num
, 6, 0, 0);
2905 num
= (num
+ 1) ^ 1;
2906 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2911 /* Handle graphics test completers for ftest */
2914 num
= pa_parse_ftest_gfx_completer (&s
);
2915 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2918 /* Handle a 11 bit immediate at 31. */
2920 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2923 if (the_insn
.exp
.X_op
== O_constant
)
2925 num
= evaluate_absolute (&the_insn
);
2926 CHECK_FIELD (num
, 1023, -1024, 0);
2927 num
= low_sign_unext (num
, 11);
2928 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2932 if (is_DP_relative (the_insn
.exp
))
2933 the_insn
.reloc
= R_HPPA_GOTOFF
;
2934 else if (is_PC_relative (the_insn
.exp
))
2935 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2937 the_insn
.reloc
= R_HPPA
;
2938 the_insn
.format
= 11;
2942 /* Handle a 14 bit immediate at 31. */
2944 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2947 if (the_insn
.exp
.X_op
== O_constant
)
2951 /* XXX the completer stored away tibits of information
2952 for us to extract. We need a cleaner way to do this.
2953 Now that we have lots of letters again, it would be
2954 good to rethink this. */
2955 m
= (opcode
& (1 << 8)) != 0;
2956 a
= (opcode
& (1 << 9)) != 0;
2957 opcode
&= ~ (3 << 8);
2958 num
= evaluate_absolute (&the_insn
);
2959 if ((a
== 1 && num
>= 0) || (a
== 0 && num
< 0))
2961 CHECK_FIELD (num
, 8191, -8192, 0);
2962 num
= low_sign_unext (num
, 14);
2963 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2970 /* Handle a 14 bit immediate at 31. */
2972 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2975 if (the_insn
.exp
.X_op
== O_constant
)
2979 /* XXX the completer stored away tibits of information
2980 for us to extract. We need a cleaner way to do this.
2981 Now that we have lots of letters again, it would be
2982 good to rethink this. */
2983 m
= (opcode
& (1 << 8)) != 0;
2984 a
= (opcode
& (1 << 9)) != 0;
2985 opcode
&= ~ (3 << 8);
2986 num
= evaluate_absolute (&the_insn
);
2987 if ((a
== 1 && num
< 0) || (a
== 0 && num
> 0))
2991 CHECK_FIELD (num
, 8191, -8192, 0);
2996 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3003 /* Handle 14 bit immediate, shifted left three times. */
3005 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3008 if (the_insn
.exp
.X_op
== O_constant
)
3010 num
= evaluate_absolute (&the_insn
);
3013 CHECK_FIELD (num
, 8191, -8192, 0);
3018 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 4);
3022 if (is_DP_relative (the_insn
.exp
))
3023 the_insn
.reloc
= R_HPPA_GOTOFF
;
3024 else if (is_PC_relative (the_insn
.exp
))
3025 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3027 the_insn
.reloc
= R_HPPA
;
3028 the_insn
.format
= 14;
3033 /* Handle 14 bit immediate, shifted left twice. */
3035 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3038 if (the_insn
.exp
.X_op
== O_constant
)
3040 num
= evaluate_absolute (&the_insn
);
3043 CHECK_FIELD (num
, 8191, -8192, 0);
3048 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3052 if (is_DP_relative (the_insn
.exp
))
3053 the_insn
.reloc
= R_HPPA_GOTOFF
;
3054 else if (is_PC_relative (the_insn
.exp
))
3055 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3057 the_insn
.reloc
= R_HPPA
;
3058 the_insn
.format
= 14;
3062 /* Handle a 14 bit immediate at 31. */
3064 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3067 if (the_insn
.exp
.X_op
== O_constant
)
3069 num
= evaluate_absolute (&the_insn
);
3070 CHECK_FIELD (num
, 8191, -8192, 0);
3071 num
= low_sign_unext (num
, 14);
3072 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3076 if (is_DP_relative (the_insn
.exp
))
3077 the_insn
.reloc
= R_HPPA_GOTOFF
;
3078 else if (is_PC_relative (the_insn
.exp
))
3079 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3081 the_insn
.reloc
= R_HPPA
;
3082 the_insn
.format
= 14;
3086 /* Handle a 21 bit immediate at 31. */
3088 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3091 if (the_insn
.exp
.X_op
== O_constant
)
3093 num
= evaluate_absolute (&the_insn
);
3094 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
3095 opcode
|= re_assemble_21 (num
);
3100 if (is_DP_relative (the_insn
.exp
))
3101 the_insn
.reloc
= R_HPPA_GOTOFF
;
3102 else if (is_PC_relative (the_insn
.exp
))
3103 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3105 the_insn
.reloc
= R_HPPA
;
3106 the_insn
.format
= 21;
3110 /* Handle a 16 bit immediate at 31 (PA 2.0 wide mode only). */
3112 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3115 if (the_insn
.exp
.X_op
== O_constant
)
3117 num
= evaluate_absolute (&the_insn
);
3118 CHECK_FIELD (num
, 32767, -32768, 0);
3119 opcode
|= re_assemble_16 (num
);
3124 /* ??? Is this valid for wide mode? */
3125 if (is_DP_relative (the_insn
.exp
))
3126 the_insn
.reloc
= R_HPPA_GOTOFF
;
3127 else if (is_PC_relative (the_insn
.exp
))
3128 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3130 the_insn
.reloc
= R_HPPA
;
3131 the_insn
.format
= 14;
3135 /* Handle a word-aligned 16-bit imm. at 31 (PA2.0 wide). */
3137 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3140 if (the_insn
.exp
.X_op
== O_constant
)
3142 num
= evaluate_absolute (&the_insn
);
3143 CHECK_FIELD (num
, 32767, -32768, 0);
3144 CHECK_ALIGN (num
, 4, 0);
3145 opcode
|= re_assemble_16 (num
);
3150 /* ??? Is this valid for wide mode? */
3151 if (is_DP_relative (the_insn
.exp
))
3152 the_insn
.reloc
= R_HPPA_GOTOFF
;
3153 else if (is_PC_relative (the_insn
.exp
))
3154 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3156 the_insn
.reloc
= R_HPPA
;
3157 the_insn
.format
= 14;
3161 /* Handle a dword-aligned 16-bit imm. at 31 (PA2.0 wide). */
3163 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3166 if (the_insn
.exp
.X_op
== O_constant
)
3168 num
= evaluate_absolute (&the_insn
);
3169 CHECK_FIELD (num
, 32767, -32768, 0);
3170 CHECK_ALIGN (num
, 8, 0);
3171 opcode
|= re_assemble_16 (num
);
3176 /* ??? Is this valid for wide mode? */
3177 if (is_DP_relative (the_insn
.exp
))
3178 the_insn
.reloc
= R_HPPA_GOTOFF
;
3179 else if (is_PC_relative (the_insn
.exp
))
3180 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3182 the_insn
.reloc
= R_HPPA
;
3183 the_insn
.format
= 14;
3187 /* Handle a 12 bit branch displacement. */
3189 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3193 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
3195 num
= evaluate_absolute (&the_insn
);
3198 as_bad (_("Branch to unaligned address"));
3201 CHECK_FIELD (num
, 8199, -8184, 0);
3203 opcode
|= re_assemble_12 ((num
- 8) >> 2);
3208 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3209 the_insn
.format
= 12;
3210 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3211 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3216 /* Handle a 17 bit branch displacement. */
3218 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3222 if (!the_insn
.exp
.X_add_symbol
3223 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3226 num
= evaluate_absolute (&the_insn
);
3229 as_bad (_("Branch to unaligned address"));
3232 CHECK_FIELD (num
, 262143, -262144, 0);
3234 if (the_insn
.exp
.X_add_symbol
)
3237 opcode
|= re_assemble_17 (num
>> 2);
3242 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3243 the_insn
.format
= 17;
3244 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3245 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3249 /* Handle a 22 bit branch displacement. */
3251 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3255 if (!the_insn
.exp
.X_add_symbol
3256 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3259 num
= evaluate_absolute (&the_insn
);
3262 as_bad (_("Branch to unaligned address"));
3265 CHECK_FIELD (num
, 8388607, -8388608, 0);
3267 if (the_insn
.exp
.X_add_symbol
)
3270 opcode
|= re_assemble_22 (num
>> 2);
3274 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3275 the_insn
.format
= 22;
3276 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3277 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3281 /* Handle an absolute 17 bit branch target. */
3283 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3287 if (!the_insn
.exp
.X_add_symbol
3288 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3291 num
= evaluate_absolute (&the_insn
);
3294 as_bad (_("Branch to unaligned address"));
3297 CHECK_FIELD (num
, 262143, -262144, 0);
3299 if (the_insn
.exp
.X_add_symbol
)
3302 opcode
|= re_assemble_17 (num
>> 2);
3307 the_insn
.reloc
= R_HPPA_ABS_CALL
;
3308 the_insn
.format
= 17;
3309 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3310 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3314 /* Handle '%r1' implicit operand of addil instruction. */
3316 if (*s
== ',' && *(s
+ 1) == '%' && *(s
+ 3) == '1'
3317 && (*(s
+ 2) == 'r' || *(s
+ 2) == 'R'))
3325 /* Handle '%sr0,%r31' implicit operand of be,l instruction. */
3327 if (strncasecmp (s
, "%sr0,%r31", 9) != 0)
3332 /* Handle immediate value of 0 for ordered load/store instructions. */
3339 /* Handle a 2 bit shift count at 25. */
3341 num
= pa_get_absolute_expression (&the_insn
, &s
);
3342 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3345 CHECK_FIELD (num
, 3, 1, strict
);
3346 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3348 /* Handle a 4 bit shift count at 25. */
3350 num
= pa_get_absolute_expression (&the_insn
, &s
);
3351 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3354 CHECK_FIELD (num
, 15, 0, strict
);
3355 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3357 /* Handle a 5 bit shift count at 26. */
3359 num
= pa_get_absolute_expression (&the_insn
, &s
);
3360 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3363 CHECK_FIELD (num
, 31, 0, strict
);
3364 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
3366 /* Handle a 6 bit shift count at 20,22:26. */
3368 num
= pa_get_absolute_expression (&the_insn
, &s
);
3369 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3372 CHECK_FIELD (num
, 63, 0, strict
);
3374 opcode
|= (num
& 0x20) << 6;
3375 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3377 /* Handle a 6 bit field length at 23,27:31. */
3380 num
= pa_get_absolute_expression (&the_insn
, &s
);
3381 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3384 CHECK_FIELD (num
, 64, 1, strict
);
3386 opcode
|= (num
& 0x20) << 3;
3387 num
= 31 - (num
& 0x1f);
3388 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3390 /* Handle a 6 bit field length at 19,27:31. */
3392 num
= pa_get_absolute_expression (&the_insn
, &s
);
3393 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3396 CHECK_FIELD (num
, 64, 1, strict
);
3398 opcode
|= (num
& 0x20) << 7;
3399 num
= 31 - (num
& 0x1f);
3400 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3402 /* Handle a 5 bit bit position at 26. */
3404 num
= pa_get_absolute_expression (&the_insn
, &s
);
3405 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3408 CHECK_FIELD (num
, 31, 0, strict
);
3409 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
3411 /* Handle a 6 bit bit position at 20,22:26. */
3413 num
= pa_get_absolute_expression (&the_insn
, &s
);
3414 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3417 CHECK_FIELD (num
, 63, 0, strict
);
3418 opcode
|= (num
& 0x20) << 6;
3419 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3421 /* Handle a 5 bit immediate at 10 with 'd' as the complement
3422 of the high bit of the immediate. */
3424 num
= pa_get_absolute_expression (&the_insn
, &s
);
3425 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3428 CHECK_FIELD (num
, 63, 0, strict
);
3432 opcode
|= (1 << 13);
3433 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 21);
3435 /* Handle a 5 bit immediate at 10. */
3437 num
= pa_get_absolute_expression (&the_insn
, &s
);
3438 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3440 if (the_insn
.exp
.X_op
!= O_constant
)
3443 CHECK_FIELD (num
, 31, 0, strict
);
3444 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3446 /* Handle a 9 bit immediate at 28. */
3448 num
= pa_get_absolute_expression (&the_insn
, &s
);
3449 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3452 CHECK_FIELD (num
, 511, 1, strict
);
3453 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3455 /* Handle a 13 bit immediate at 18. */
3457 num
= pa_get_absolute_expression (&the_insn
, &s
);
3458 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3461 CHECK_FIELD (num
, 8191, 0, strict
);
3462 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
3464 /* Handle a 26 bit immediate at 31. */
3466 num
= pa_get_absolute_expression (&the_insn
, &s
);
3467 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3470 CHECK_FIELD (num
, 671108864, 0, strict
);
3471 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3473 /* Handle a 3 bit SFU identifier at 25. */
3476 as_bad (_("Invalid SFU identifier"));
3477 num
= pa_get_absolute_expression (&the_insn
, &s
);
3478 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3481 CHECK_FIELD (num
, 7, 0, strict
);
3482 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3484 /* Handle a 20 bit SOP field for spop0. */
3486 num
= pa_get_absolute_expression (&the_insn
, &s
);
3487 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3490 CHECK_FIELD (num
, 1048575, 0, strict
);
3491 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
3492 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3494 /* Handle a 15bit SOP field for spop1. */
3496 num
= pa_get_absolute_expression (&the_insn
, &s
);
3497 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3500 CHECK_FIELD (num
, 32767, 0, strict
);
3501 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
3503 /* Handle a 10bit SOP field for spop3. */
3505 num
= pa_get_absolute_expression (&the_insn
, &s
);
3506 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3509 CHECK_FIELD (num
, 1023, 0, strict
);
3510 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
3511 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3513 /* Handle a 15 bit SOP field for spop2. */
3515 num
= pa_get_absolute_expression (&the_insn
, &s
);
3516 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3519 CHECK_FIELD (num
, 32767, 0, strict
);
3520 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
3521 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3523 /* Handle a 3-bit co-processor ID field. */
3526 as_bad (_("Invalid COPR identifier"));
3527 num
= pa_get_absolute_expression (&the_insn
, &s
);
3528 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3531 CHECK_FIELD (num
, 7, 0, strict
);
3532 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3534 /* Handle a 22bit SOP field for copr. */
3536 num
= pa_get_absolute_expression (&the_insn
, &s
);
3537 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3540 CHECK_FIELD (num
, 4194303, 0, strict
);
3541 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
3542 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3544 /* Handle a source FP operand format completer. */
3546 if (*s
== ',' && *(s
+1) == 't')
3553 flag
= pa_parse_fp_cnv_format (&s
);
3554 the_insn
.fpof1
= flag
;
3555 if (flag
== W
|| flag
== UW
)
3557 if (flag
== DW
|| flag
== UDW
)
3559 if (flag
== QW
|| flag
== UQW
)
3561 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3563 /* Handle a destination FP operand format completer. */
3565 /* pa_parse_format needs the ',' prefix. */
3567 flag
= pa_parse_fp_cnv_format (&s
);
3568 the_insn
.fpof2
= flag
;
3569 if (flag
== W
|| flag
== UW
)
3571 if (flag
== DW
|| flag
== UDW
)
3573 if (flag
== QW
|| flag
== UQW
)
3575 opcode
|= flag
<< 13;
3576 if (the_insn
.fpof1
== SGL
3577 || the_insn
.fpof1
== DBL
3578 || the_insn
.fpof1
== QUAD
)
3580 if (the_insn
.fpof2
== SGL
3581 || the_insn
.fpof2
== DBL
3582 || the_insn
.fpof2
== QUAD
)
3584 else if (the_insn
.fpof2
== W
3585 || the_insn
.fpof2
== DW
3586 || the_insn
.fpof2
== QW
)
3588 else if (the_insn
.fpof2
== UW
3589 || the_insn
.fpof2
== UDW
3590 || the_insn
.fpof2
== UQW
)
3595 else if (the_insn
.fpof1
== W
3596 || the_insn
.fpof1
== DW
3597 || the_insn
.fpof1
== QW
)
3599 if (the_insn
.fpof2
== SGL
3600 || the_insn
.fpof2
== DBL
3601 || the_insn
.fpof2
== QUAD
)
3606 else if (the_insn
.fpof1
== UW
3607 || the_insn
.fpof1
== UDW
3608 || the_insn
.fpof1
== UQW
)
3610 if (the_insn
.fpof2
== SGL
3611 || the_insn
.fpof2
== DBL
3612 || the_insn
.fpof2
== QUAD
)
3617 flag
|= the_insn
.trunc
;
3618 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 15);
3620 /* Handle a source FP operand format completer. */
3622 flag
= pa_parse_fp_format (&s
);
3623 the_insn
.fpof1
= flag
;
3624 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3626 /* Handle a destination FP operand format completer. */
3628 /* pa_parse_format needs the ',' prefix. */
3630 flag
= pa_parse_fp_format (&s
);
3631 the_insn
.fpof2
= flag
;
3632 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
3634 /* Handle a source FP operand format completer at 20. */
3636 flag
= pa_parse_fp_format (&s
);
3637 the_insn
.fpof1
= flag
;
3638 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3640 /* Handle a floating point operand format at 26.
3641 Only allows single and double precision. */
3643 flag
= pa_parse_fp_format (&s
);
3649 the_insn
.fpof1
= flag
;
3655 as_bad (_("Invalid Floating Point Operand Format."));
3659 /* Handle all floating point registers. */
3663 /* Float target register. */
3665 /* This should be more strict. Small steps. */
3666 if (strict
&& *s
!= '%')
3668 num
= pa_parse_number (&s
, 0);
3669 CHECK_FIELD (num
, 31, 0, 0);
3670 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3672 /* Float target register with L/R selection. */
3675 struct pa_11_fp_reg_struct result
;
3677 /* This should be more strict. Small steps. */
3678 if (strict
&& *s
!= '%')
3680 pa_parse_number (&s
, &result
);
3681 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3682 opcode
|= result
.number_part
;
3684 /* 0x30 opcodes are FP arithmetic operation opcodes
3685 and need to be turned into 0x38 opcodes. This
3686 is not necessary for loads/stores. */
3687 if (need_pa11_opcode (&the_insn
, &result
)
3688 && ((opcode
& 0xfc000000) == 0x30000000))
3691 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
3694 /* Float operand 1. */
3697 struct pa_11_fp_reg_struct result
;
3699 /* This should be more strict. Small steps. */
3700 if (strict
&& *s
!= '%')
3702 pa_parse_number (&s
, &result
);
3703 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3704 opcode
|= result
.number_part
<< 21;
3705 if (need_pa11_opcode (&the_insn
, &result
))
3707 opcode
|= (result
.l_r_select
& 1) << 7;
3713 /* Float operand 1 with L/R selection. */
3717 struct pa_11_fp_reg_struct result
;
3719 /* This should be more strict. Small steps. */
3720 if (strict
&& *s
!= '%')
3722 pa_parse_number (&s
, &result
);
3723 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3724 opcode
|= result
.number_part
<< 21;
3725 opcode
|= (result
.l_r_select
& 1) << 7;
3729 /* Float operand 2. */
3732 struct pa_11_fp_reg_struct result
;
3734 /* This should be more strict. Small steps. */
3735 if (strict
&& *s
!= '%')
3737 pa_parse_number (&s
, &result
);
3738 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3739 opcode
|= (result
.number_part
& 0x1f) << 16;
3740 if (need_pa11_opcode (&the_insn
, &result
))
3742 opcode
|= (result
.l_r_select
& 1) << 12;
3748 /* Float operand 2 with L/R selection. */
3751 struct pa_11_fp_reg_struct result
;
3753 /* This should be more strict. Small steps. */
3754 if (strict
&& *s
!= '%')
3756 pa_parse_number (&s
, &result
);
3757 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3758 opcode
|= (result
.number_part
& 0x1f) << 16;
3759 opcode
|= (result
.l_r_select
& 1) << 12;
3763 /* Float operand 3 for fmpyfadd, fmpynfadd. */
3766 struct pa_11_fp_reg_struct result
;
3768 /* This should be more strict. Small steps. */
3769 if (strict
&& *s
!= '%')
3771 pa_parse_number (&s
, &result
);
3772 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3773 opcode
|= (result
.number_part
& 0x1c) << 11;
3774 opcode
|= (result
.number_part
& 0x3) << 9;
3775 opcode
|= (result
.l_r_select
& 1) << 8;
3779 /* Float mult operand 1 for fmpyadd, fmpysub */
3782 struct pa_11_fp_reg_struct result
;
3784 /* This should be more strict. Small steps. */
3785 if (strict
&& *s
!= '%')
3787 pa_parse_number (&s
, &result
);
3788 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3789 if (the_insn
.fpof1
== SGL
)
3791 if (result
.number_part
< 16)
3793 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3797 result
.number_part
&= 0xF;
3798 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3800 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
3803 /* Float mult operand 2 for fmpyadd, fmpysub */
3806 struct pa_11_fp_reg_struct result
;
3808 /* This should be more strict. Small steps. */
3809 if (strict
&& *s
!= '%')
3811 pa_parse_number (&s
, &result
);
3812 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3813 if (the_insn
.fpof1
== SGL
)
3815 if (result
.number_part
< 16)
3817 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3820 result
.number_part
&= 0xF;
3821 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3823 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
3826 /* Float mult target for fmpyadd, fmpysub */
3829 struct pa_11_fp_reg_struct result
;
3831 /* This should be more strict. Small steps. */
3832 if (strict
&& *s
!= '%')
3834 pa_parse_number (&s
, &result
);
3835 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3836 if (the_insn
.fpof1
== SGL
)
3838 if (result
.number_part
< 16)
3840 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3843 result
.number_part
&= 0xF;
3844 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3846 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
3849 /* Float add operand 1 for fmpyadd, fmpysub */
3852 struct pa_11_fp_reg_struct result
;
3854 /* This should be more strict. Small steps. */
3855 if (strict
&& *s
!= '%')
3857 pa_parse_number (&s
, &result
);
3858 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3859 if (the_insn
.fpof1
== SGL
)
3861 if (result
.number_part
< 16)
3863 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3866 result
.number_part
&= 0xF;
3867 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3869 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
3872 /* Float add target for fmpyadd, fmpysub */
3875 struct pa_11_fp_reg_struct result
;
3877 /* This should be more strict. Small steps. */
3878 if (strict
&& *s
!= '%')
3880 pa_parse_number (&s
, &result
);
3881 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3882 if (the_insn
.fpof1
== SGL
)
3884 if (result
.number_part
< 16)
3886 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3889 result
.number_part
&= 0xF;
3890 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3892 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
3895 /* Handle L/R register halves like 'x'. */
3899 struct pa_11_fp_reg_struct result
;
3901 if (strict
&& *s
!= '%')
3903 pa_parse_number (&s
, &result
);
3904 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3905 opcode
|= (result
.number_part
& 0x1f) << 16;
3906 if (need_pa11_opcode (&the_insn
, &result
))
3908 opcode
|= (result
.l_r_select
& 1) << 1;
3913 /* Float target register (PA 2.0 wide). */
3915 /* This should be more strict. Small steps. */
3916 if (strict
&& *s
!= '%')
3918 num
= pa_parse_number (&s
, 0);
3919 CHECK_FIELD (num
, 31, 0, 0);
3920 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
3934 /* Check if the args matched. */
3937 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
3938 && !strcmp (insn
->name
, insn
[1].name
))
3946 as_bad (_("Invalid operands %s"), error_message
);
3953 the_insn
.opcode
= opcode
;
3956 /* Turn a string in input_line_pointer into a floating point constant of type
3957 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
3958 emitted is stored in *sizeP . An error message or NULL is returned. */
3960 #define MAX_LITTLENUMS 6
3963 md_atof (type
, litP
, sizeP
)
3969 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
3970 LITTLENUM_TYPE
*wordP
;
4002 return _("Bad call to MD_ATOF()");
4004 t
= atof_ieee (input_line_pointer
, type
, words
);
4006 input_line_pointer
= t
;
4007 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
4008 for (wordP
= words
; prec
--;)
4010 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
4011 litP
+= sizeof (LITTLENUM_TYPE
);
4016 /* Write out big-endian. */
4019 md_number_to_chars (buf
, val
, n
)
4024 number_to_chars_bigendian (buf
, val
, n
);
4027 /* Translate internal representation of relocation info to BFD target
4031 tc_gen_reloc (section
, fixp
)
4036 struct hppa_fix_struct
*hppa_fixp
;
4037 static arelent
*no_relocs
= NULL
;
4044 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
4045 if (fixp
->fx_addsy
== 0)
4048 assert (hppa_fixp
!= 0);
4049 assert (section
!= 0);
4051 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
4053 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4054 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4055 codes
= hppa_gen_reloc_type (stdoutput
,
4057 hppa_fixp
->fx_r_format
,
4058 hppa_fixp
->fx_r_field
,
4059 fixp
->fx_subsy
!= NULL
,
4060 symbol_get_bfdsym (fixp
->fx_addsy
));
4065 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
4068 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
4069 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
4070 for (i
= 0; i
< n_relocs
; i
++)
4071 relocs
[i
] = &reloc
[i
];
4073 relocs
[n_relocs
] = NULL
;
4076 switch (fixp
->fx_r_type
)
4079 assert (n_relocs
== 1);
4083 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4084 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4085 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
,
4086 (bfd_reloc_code_real_type
) code
);
4087 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4089 assert (reloc
->howto
&& (unsigned int) code
== reloc
->howto
->type
);
4091 /* Now, do any processing that is dependent on the relocation type. */
4094 case R_PARISC_DLTREL21L
:
4095 case R_PARISC_DLTREL14R
:
4096 case R_PARISC_DLTREL14F
:
4097 case R_PARISC_PLABEL32
:
4098 case R_PARISC_PLABEL21L
:
4099 case R_PARISC_PLABEL14R
:
4100 /* For plabel relocations, the addend of the
4101 relocation should be either 0 (no static link) or 2
4102 (static link required).
4104 FIXME: We always assume no static link!
4106 We also slam a zero addend into the DLT relative relocs;
4107 it doesn't make a lot of sense to use any addend since
4108 it gets you a different (eg unknown) DLT entry. */
4112 #ifdef ELF_ARG_RELOC
4113 case R_PARISC_PCREL17R
:
4114 case R_PARISC_PCREL17F
:
4115 case R_PARISC_PCREL17C
:
4116 case R_PARISC_DIR17R
:
4117 case R_PARISC_DIR17F
:
4119 char *buf
= fixp
->fx_where
+ fixp
->fx_frag
->fr_literal
;
4120 int insn
= bfd_get_32 (stdoutput
, buf
);
4122 #ifdef ELF_ARG_RELOC_INSN
4123 /* Store the arg reloc in the instruction. */
4124 insn
= ((insn
& ~ 0x1ff8)
4125 | ((hppa_fixp
->fx_arg_reloc
<< 3) & 0x1ff8));
4126 bfd_put_32 (stdoutput
, insn
, buf
);
4127 reloc
->addend
= fixp
->fx_offset
;
4129 /* The high 22 bits of the constant are stored in the
4130 reloc. The remaining 10 bits can be retrieved from the
4132 insn
= (insn
& ~ 0x7f8) | ((fixp
->fx_offset
& 0x3fc) << 1);
4133 bfd_put_32 (stdoutput
, insn
, buf
);
4134 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
,
4135 fixp
->fx_offset
>> 10);
4140 case R_PARISC_PCREL21L
:
4141 case R_PARISC_DIR21L
:
4143 char *buf
= fixp
->fx_where
+ fixp
->fx_frag
->fr_literal
;
4144 int insn
= bfd_get_32 (stdoutput
, buf
);
4146 #ifdef ELF_ARG_RELOC_INSN
4147 /* Store the arg reloc in the instruction. */
4148 insn
= ((insn
& ~ 0xff9)
4149 | ((hppa_fixp
->fx_arg_reloc
>> 9) & 1)
4150 | ((hppa_fixp
->fx_arg_reloc
<< 3) & 0xff8));
4151 bfd_put_32 (stdoutput
, insn
, buf
);
4152 reloc
->addend
= fixp
->fx_offset
;
4154 /* In this case, the instruction stores the high bits, so
4155 the reloc stores the low 22 bits. */
4156 insn
= ((insn
& ~ 0xff9)
4157 | ((fixp
->fx_offset
>> 31) & 1)
4158 | ((fixp
->fx_offset
>> 19) & 0xff8));
4159 bfd_put_32 (stdoutput
, insn
, buf
);
4160 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
,
4168 reloc
->addend
= fixp
->fx_offset
;
4175 /* Walk over reach relocation returned by the BFD backend. */
4176 for (i
= 0; i
< n_relocs
; i
++)
4180 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4181 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4183 bfd_reloc_type_lookup (stdoutput
,
4184 (bfd_reloc_code_real_type
) code
);
4185 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4190 /* The only time we ever use a R_COMP2 fixup is for the difference
4191 of two symbols. With that in mind we fill in all four
4192 relocs now and break out of the loop. */
4194 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4196 bfd_reloc_type_lookup (stdoutput
,
4197 (bfd_reloc_code_real_type
) *codes
[0]);
4198 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4199 relocs
[0]->addend
= 0;
4200 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4201 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4203 bfd_reloc_type_lookup (stdoutput
,
4204 (bfd_reloc_code_real_type
) *codes
[1]);
4205 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4206 relocs
[1]->addend
= 0;
4207 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4208 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
4210 bfd_reloc_type_lookup (stdoutput
,
4211 (bfd_reloc_code_real_type
) *codes
[2]);
4212 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4213 relocs
[2]->addend
= 0;
4214 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4216 bfd_reloc_type_lookup (stdoutput
,
4217 (bfd_reloc_code_real_type
) *codes
[3]);
4218 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4219 relocs
[3]->addend
= 0;
4220 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4222 bfd_reloc_type_lookup (stdoutput
,
4223 (bfd_reloc_code_real_type
) *codes
[4]);
4224 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4225 relocs
[4]->addend
= 0;
4229 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
4235 /* For plabel relocations, the addend of the
4236 relocation should be either 0 (no static link) or 2
4237 (static link required).
4239 FIXME: We always assume no static link!
4241 We also slam a zero addend into the DLT relative relocs;
4242 it doesn't make a lot of sense to use any addend since
4243 it gets you a different (eg unknown) DLT entry. */
4244 relocs
[i
]->addend
= 0;
4259 /* There is no symbol or addend associated with these fixups. */
4260 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4261 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4262 relocs
[i
]->addend
= 0;
4268 /* There is no symbol associated with these fixups. */
4269 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4270 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4271 relocs
[i
]->addend
= fixp
->fx_offset
;
4275 relocs
[i
]->addend
= fixp
->fx_offset
;
4285 /* Process any machine dependent frag types. */
4288 md_convert_frag (abfd
, sec
, fragP
)
4289 register bfd
*abfd ATTRIBUTE_UNUSED
;
4290 register asection
*sec ATTRIBUTE_UNUSED
;
4291 register fragS
*fragP
;
4293 unsigned int address
;
4295 if (fragP
->fr_type
== rs_machine_dependent
)
4297 switch ((int) fragP
->fr_subtype
)
4300 fragP
->fr_type
= rs_fill
;
4301 know (fragP
->fr_var
== 1);
4302 know (fragP
->fr_next
);
4303 address
= fragP
->fr_address
+ fragP
->fr_fix
;
4304 if (address
% fragP
->fr_offset
)
4307 fragP
->fr_next
->fr_address
4312 fragP
->fr_offset
= 0;
4318 /* Round up a section size to the appropriate boundary. */
4321 md_section_align (segment
, size
)
4325 int align
= bfd_get_section_alignment (stdoutput
, segment
);
4326 int align2
= (1 << align
) - 1;
4328 return (size
+ align2
) & ~align2
;
4331 /* Return the approximate size of a frag before relaxation has occurred. */
4333 md_estimate_size_before_relax (fragP
, segment
)
4334 register fragS
*fragP
;
4335 asection
*segment ATTRIBUTE_UNUSED
;
4341 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
4348 # ifdef WARN_COMMENTS
4349 const char *md_shortopts
= "Vc";
4351 const char *md_shortopts
= "V";
4354 # ifdef WARN_COMMENTS
4355 const char *md_shortopts
= "c";
4357 const char *md_shortopts
= "";
4361 struct option md_longopts
[] = {
4362 #ifdef WARN_COMMENTS
4363 {"warn-comment", no_argument
, NULL
, 'c'},
4365 {NULL
, no_argument
, NULL
, 0}
4367 size_t md_longopts_size
= sizeof(md_longopts
);
4370 md_parse_option (c
, arg
)
4371 int c ATTRIBUTE_UNUSED
;
4372 char *arg ATTRIBUTE_UNUSED
;
4381 print_version_id ();
4384 #ifdef WARN_COMMENTS
4395 md_show_usage (stream
)
4396 FILE *stream ATTRIBUTE_UNUSED
;
4399 fprintf (stream
, _("\
4402 #ifdef WARN_COMMENTS
4403 fprintf (stream
, _("\
4404 -c print a warning if a comment is found\n"));
4408 /* We have no need to default values of symbols. */
4411 md_undefined_symbol (name
)
4412 char *name ATTRIBUTE_UNUSED
;
4417 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
4418 #define arg_reloc_stub_needed(CALLER, CALLEE) \
4419 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
4421 #define arg_reloc_stub_needed(CALLER, CALLEE) 0
4424 /* Apply a fixup to an instruction. */
4427 md_apply_fix (fixP
, valp
)
4431 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
4432 struct hppa_fix_struct
*hppa_fixP
;
4436 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
4437 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
4438 never be "applied" (they are just markers). Likewise for
4439 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
4441 if (fixP
->fx_r_type
== R_HPPA_ENTRY
4442 || fixP
->fx_r_type
== R_HPPA_EXIT
4443 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
4444 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
4445 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
4448 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
4449 fixups are considered not adjustable, which in turn causes
4450 adjust_reloc_syms to not set fx_offset. Ugh. */
4451 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
4453 fixP
->fx_offset
= *valp
;
4458 insn
= bfd_get_32 (stdoutput
, (unsigned char *) buf
);
4459 /* There should have been an HPPA specific fixup associated
4460 with the GAS fixup. */
4463 int fmt
= bfd_hppa_insn2fmt (stdoutput
, insn
);
4465 /* If there is a symbol associated with this fixup, then it's something
4466 which will need a SOM relocation (except for some PC-relative relocs).
4467 In such cases we should treat the "val" or "addend" as zero since it
4468 will be added in as needed from fx_offset in tc_gen_reloc. */
4469 if ((fixP
->fx_addsy
!= NULL
4470 || fixP
->fx_r_type
== (int) R_HPPA_NONE
)
4475 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4477 /* These field selectors imply that we do not want an addend. */
4478 else if (hppa_fixP
->fx_r_field
== e_psel
4479 || hppa_fixP
->fx_r_field
== e_rpsel
4480 || hppa_fixP
->fx_r_field
== e_lpsel
4481 || hppa_fixP
->fx_r_field
== e_tsel
4482 || hppa_fixP
->fx_r_field
== e_rtsel
4483 || hppa_fixP
->fx_r_field
== e_ltsel
)
4484 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4485 /* This is truely disgusting. The machine independent code blindly
4486 adds in the value of the symbol being relocated against. Damn! */
4488 && fixP
->fx_addsy
!= NULL
4489 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
4490 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
4491 0, hppa_fixP
->fx_r_field
);
4494 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4496 /* Handle pc-relative exceptions from above. */
4497 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
4500 && !arg_reloc_stub_needed (symbol_arg_reloc_info (fixP
->fx_addsy
),
4501 hppa_fixP
->fx_arg_reloc
)
4502 && ((*valp
+ 8192) < 16384
4503 || (fmt
== 17 && (*valp
+ 262144) < 524288)
4504 || (fmt
== 22 && (*valp
+ 8388608) < 16777216))
4505 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
4507 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
4509 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4515 CHECK_FIELD (new_val
, 8191, -8192, 0);
4518 insn
= (insn
& ~ 0x3ff1) | (((val
& 0x1ff8) << 1)
4519 | ((val
& 0x2000) >> 13));
4522 CHECK_FIELD (new_val
, 8191, -8192, 0);
4525 insn
= (insn
& ~ 0x3ff9) | (((val
& 0x1ffc) << 1)
4526 | ((val
& 0x2000) >> 13));
4528 /* Handle all opcodes with the 'j' operand type. */
4530 CHECK_FIELD (new_val
, 8191, -8192, 0);
4533 insn
= ((insn
& ~ 0x3fff) | low_sign_unext (val
, 14));
4536 /* Handle all opcodes with the 'k' operand type. */
4538 CHECK_FIELD (new_val
, 1048575, -1048576, 0);
4541 insn
= (insn
& ~ 0x1fffff) | re_assemble_21 (val
);
4544 /* Handle all the opcodes with the 'i' operand type. */
4546 CHECK_FIELD (new_val
, 1023, -1023, 0);
4549 insn
= (insn
& ~ 0x7ff) | low_sign_unext (val
, 11);
4552 /* Handle all the opcodes with the 'w' operand type. */
4554 CHECK_FIELD (new_val
, 8199, -8184, 0);
4557 insn
= (insn
& ~ 0x1ffd) | re_assemble_12 ((val
- 8) >> 2);
4560 /* Handle some of the opcodes with the 'W' operand type. */
4563 offsetT distance
= *valp
;
4565 /* If this is an absolute branch (ie no link) with an out of
4566 range target, then we want to complain. */
4567 if (fixP
->fx_r_type
== (int) R_HPPA_PCREL_CALL
4568 && (insn
& 0xffe00000) == 0xe8000000)
4569 CHECK_FIELD (distance
, 262143, -262144, 0);
4571 CHECK_FIELD (new_val
, 262143, -262144, 0);
4574 insn
= (insn
& ~ 0x1f1ffd) | re_assemble_17 ((val
- 8) >> 2);
4580 offsetT distance
= *valp
;
4582 /* If this is an absolute branch (ie no link) with an out of
4583 range target, then we want to complain. */
4584 if (fixP
->fx_r_type
== (int) R_HPPA_PCREL_CALL
4585 && (insn
& 0xffe00000) == 0xe8000000)
4586 CHECK_FIELD (distance
, 8388607, -8388608, 0);
4588 CHECK_FIELD (new_val
, 8388607, -8388608, 0);
4591 insn
= (insn
& ~ 0x3ff1ffd) | re_assemble_22 ((val
- 8) >> 2);
4597 insn
= (insn
& ~ 0xfff1) | re_assemble_16 (val
& -8);
4602 insn
= (insn
& ~ 0xfff9) | re_assemble_16 (val
& -4);
4607 insn
= (insn
& ~ 0xffff) | re_assemble_16 (val
);
4615 as_bad (_("Unknown relocation encountered in md_apply_fix."));
4619 /* Insert the relocation. */
4620 bfd_put_32 (stdoutput
, insn
, (unsigned char *) buf
);
4625 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
4626 (unsigned int) fixP
, fixP
->fx_r_type
);
4631 /* Exactly what point is a PC-relative offset relative TO?
4632 On the PA, they're relative to the address of the offset. */
4635 md_pcrel_from (fixP
)
4638 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
4641 /* Return nonzero if the input line pointer is at the end of
4645 is_end_of_statement ()
4647 return ((*input_line_pointer
== '\n')
4648 || (*input_line_pointer
== ';')
4649 || (*input_line_pointer
== '!'));
4652 /* Read a number from S. The number might come in one of many forms,
4653 the most common will be a hex or decimal constant, but it could be
4654 a pre-defined register (Yuk!), or an absolute symbol.
4656 Return a number or -1 for failure.
4658 When parsing PA-89 FP register numbers RESULT will be
4659 the address of a structure to return information about
4660 L/R half of FP registers, store results there as appropriate.
4662 pa_parse_number can not handle negative constants and will fail
4663 horribly if it is passed such a constant. */
4666 pa_parse_number (s
, result
)
4668 struct pa_11_fp_reg_struct
*result
;
4677 /* Skip whitespace before the number. */
4678 while (*p
== ' ' || *p
== '\t')
4681 /* Store info in RESULT if requested by caller. */
4684 result
->number_part
= -1;
4685 result
->l_r_select
= -1;
4691 /* Looks like a number. */
4694 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
4696 /* The number is specified in hex. */
4698 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
4699 || ((*p
>= 'A') && (*p
<= 'F')))
4702 num
= num
* 16 + *p
- '0';
4703 else if (*p
>= 'a' && *p
<= 'f')
4704 num
= num
* 16 + *p
- 'a' + 10;
4706 num
= num
* 16 + *p
- 'A' + 10;
4712 /* The number is specified in decimal. */
4713 while (isdigit (*p
))
4715 num
= num
* 10 + *p
- '0';
4720 /* Store info in RESULT if requested by the caller. */
4723 result
->number_part
= num
;
4725 if (IS_R_SELECT (p
))
4727 result
->l_r_select
= 1;
4730 else if (IS_L_SELECT (p
))
4732 result
->l_r_select
= 0;
4736 result
->l_r_select
= 0;
4741 /* The number might be a predefined register. */
4746 /* Tege hack: Special case for general registers as the general
4747 code makes a binary search with case translation, and is VERY
4752 if (*p
== 'e' && *(p
+ 1) == 't'
4753 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
4756 num
= *p
- '0' + 28;
4764 else if (!isdigit (*p
))
4767 as_bad (_("Undefined register: '%s'."), name
);
4773 num
= num
* 10 + *p
++ - '0';
4774 while (isdigit (*p
));
4779 /* Do a normal register search. */
4780 while (is_part_of_name (c
))
4786 status
= reg_name_search (name
);
4792 as_bad (_("Undefined register: '%s'."), name
);
4798 /* Store info in RESULT if requested by caller. */
4801 result
->number_part
= num
;
4802 if (IS_R_SELECT (p
- 1))
4803 result
->l_r_select
= 1;
4804 else if (IS_L_SELECT (p
- 1))
4805 result
->l_r_select
= 0;
4807 result
->l_r_select
= 0;
4812 /* And finally, it could be a symbol in the absolute section which
4813 is effectively a constant. */
4817 while (is_part_of_name (c
))
4823 if ((sym
= symbol_find (name
)) != NULL
)
4825 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
4826 num
= S_GET_VALUE (sym
);
4830 as_bad (_("Non-absolute symbol: '%s'."), name
);
4836 /* There is where we'd come for an undefined symbol
4837 or for an empty string. For an empty string we
4838 will return zero. That's a concession made for
4839 compatability with the braindamaged HP assemblers. */
4845 as_bad (_("Undefined absolute constant: '%s'."), name
);
4851 /* Store info in RESULT if requested by caller. */
4854 result
->number_part
= num
;
4855 if (IS_R_SELECT (p
- 1))
4856 result
->l_r_select
= 1;
4857 else if (IS_L_SELECT (p
- 1))
4858 result
->l_r_select
= 0;
4860 result
->l_r_select
= 0;
4868 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
4870 /* Given NAME, find the register number associated with that name, return
4871 the integer value associated with the given name or -1 on failure. */
4874 reg_name_search (name
)
4877 int middle
, low
, high
;
4881 high
= REG_NAME_CNT
- 1;
4885 middle
= (low
+ high
) / 2;
4886 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
4892 return pre_defined_registers
[middle
].value
;
4894 while (low
<= high
);
4900 /* Return nonzero if the given INSN and L/R information will require
4901 a new PA-1.1 opcode. */
4904 need_pa11_opcode (insn
, result
)
4906 struct pa_11_fp_reg_struct
*result
;
4908 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
4910 /* If this instruction is specific to a particular architecture,
4911 then set a new architecture. */
4912 if (bfd_get_mach (stdoutput
) < pa11
)
4914 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
4915 as_warn (_("could not update architecture and machine"));
4923 /* Parse a condition for a fcmp instruction. Return the numerical
4924 code associated with the condition. */
4927 pa_parse_fp_cmp_cond (s
)
4934 for (i
= 0; i
< 32; i
++)
4936 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
4937 strlen (fp_cond_map
[i
].string
)) == 0)
4939 cond
= fp_cond_map
[i
].cond
;
4940 *s
+= strlen (fp_cond_map
[i
].string
);
4941 /* If not a complete match, back up the input string and
4943 if (**s
!= ' ' && **s
!= '\t')
4945 *s
-= strlen (fp_cond_map
[i
].string
);
4948 while (**s
== ' ' || **s
== '\t')
4954 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
4956 /* Advance over the bogus completer. */
4957 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4963 /* Parse a graphics test complete for ftest. */
4966 pa_parse_ftest_gfx_completer (s
)
4972 if (strncasecmp (*s
, "acc8", 4) == 0)
4977 else if (strncasecmp (*s
, "acc6", 4) == 0)
4982 else if (strncasecmp (*s
, "acc4", 4) == 0)
4987 else if (strncasecmp (*s
, "acc2", 4) == 0)
4992 else if (strncasecmp (*s
, "acc", 3) == 0)
4997 else if (strncasecmp (*s
, "rej8", 4) == 0)
5002 else if (strncasecmp (*s
, "rej", 3) == 0)
5010 as_bad (_("Invalid FTEST completer: %s"), *s
);
5016 /* Parse an FP operand format completer returning the completer
5019 static fp_operand_format
5020 pa_parse_fp_cnv_format (s
)
5029 if (strncasecmp (*s
, "sgl", 3) == 0)
5034 else if (strncasecmp (*s
, "dbl", 3) == 0)
5039 else if (strncasecmp (*s
, "quad", 4) == 0)
5044 else if (strncasecmp (*s
, "w", 1) == 0)
5049 else if (strncasecmp (*s
, "uw", 2) == 0)
5054 else if (strncasecmp (*s
, "dw", 2) == 0)
5059 else if (strncasecmp (*s
, "udw", 3) == 0)
5064 else if (strncasecmp (*s
, "qw", 2) == 0)
5069 else if (strncasecmp (*s
, "uqw", 3) == 0)
5076 format
= ILLEGAL_FMT
;
5077 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
5084 /* Parse an FP operand format completer returning the completer
5087 static fp_operand_format
5088 pa_parse_fp_format (s
)
5097 if (strncasecmp (*s
, "sgl", 3) == 0)
5102 else if (strncasecmp (*s
, "dbl", 3) == 0)
5107 else if (strncasecmp (*s
, "quad", 4) == 0)
5114 format
= ILLEGAL_FMT
;
5115 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
5122 /* Convert from a selector string into a selector type. */
5125 pa_chk_field_selector (str
)
5128 int middle
, low
, high
;
5132 /* Read past any whitespace. */
5133 /* FIXME: should we read past newlines and formfeeds??? */
5134 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
5137 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
5138 name
[0] = tolower ((*str
)[0]),
5140 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
5141 name
[0] = tolower ((*str
)[0]),
5142 name
[1] = tolower ((*str
)[1]),
5144 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
5145 name
[0] = tolower ((*str
)[0]),
5146 name
[1] = tolower ((*str
)[1]),
5147 name
[2] = tolower ((*str
)[2]),
5153 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
5157 middle
= (low
+ high
) / 2;
5158 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
5165 *str
+= strlen (name
) + 1;
5167 if (selector_table
[middle
].field_selector
== e_nsel
)
5170 return selector_table
[middle
].field_selector
;
5173 while (low
<= high
);
5178 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
5181 get_expression (str
)
5187 save_in
= input_line_pointer
;
5188 input_line_pointer
= str
;
5189 seg
= expression (&the_insn
.exp
);
5190 if (!(seg
== absolute_section
5191 || seg
== undefined_section
5192 || SEG_NORMAL (seg
)))
5194 as_warn (_("Bad segment in expression."));
5195 expr_end
= input_line_pointer
;
5196 input_line_pointer
= save_in
;
5199 expr_end
= input_line_pointer
;
5200 input_line_pointer
= save_in
;
5204 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
5206 pa_get_absolute_expression (insn
, strp
)
5212 insn
->field_selector
= pa_chk_field_selector (strp
);
5213 save_in
= input_line_pointer
;
5214 input_line_pointer
= *strp
;
5215 expression (&insn
->exp
);
5216 /* This is not perfect, but is a huge improvement over doing nothing.
5218 The PA assembly syntax is ambigious in a variety of ways. Consider
5219 this string "4 %r5" Is that the number 4 followed by the register
5220 r5, or is that 4 MOD 5?
5222 If we get a modulo expresion When looking for an absolute, we try
5223 again cutting off the input string at the first whitespace character. */
5224 if (insn
->exp
.X_op
== O_modulus
)
5229 input_line_pointer
= *strp
;
5231 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
5237 retval
= pa_get_absolute_expression (insn
, strp
);
5239 input_line_pointer
= save_in
;
5241 return evaluate_absolute (insn
);
5243 /* When in strict mode we have a non-match, fix up the pointers
5244 and return to our caller. */
5245 if (insn
->exp
.X_op
!= O_constant
&& strict
)
5247 expr_end
= input_line_pointer
;
5248 input_line_pointer
= save_in
;
5251 if (insn
->exp
.X_op
!= O_constant
)
5253 as_bad (_("Bad segment (should be absolute)."));
5254 expr_end
= input_line_pointer
;
5255 input_line_pointer
= save_in
;
5258 expr_end
= input_line_pointer
;
5259 input_line_pointer
= save_in
;
5260 return evaluate_absolute (insn
);
5263 /* Evaluate an absolute expression EXP which may be modified by
5264 the selector FIELD_SELECTOR. Return the value of the expression. */
5266 evaluate_absolute (insn
)
5271 int field_selector
= insn
->field_selector
;
5274 value
= exp
.X_add_number
;
5276 return hppa_field_adjust (0, value
, field_selector
);
5279 /* Given an argument location specification return the associated
5280 argument location number. */
5283 pa_build_arg_reloc (type_name
)
5287 if (strncasecmp (type_name
, "no", 2) == 0)
5289 if (strncasecmp (type_name
, "gr", 2) == 0)
5291 else if (strncasecmp (type_name
, "fr", 2) == 0)
5293 else if (strncasecmp (type_name
, "fu", 2) == 0)
5296 as_bad (_("Invalid argument location: %s\n"), type_name
);
5301 /* Encode and return an argument relocation specification for
5302 the given register in the location specified by arg_reloc. */
5305 pa_align_arg_reloc (reg
, arg_reloc
)
5307 unsigned int arg_reloc
;
5309 unsigned int new_reloc
;
5311 new_reloc
= arg_reloc
;
5327 as_bad (_("Invalid argument description: %d"), reg
);
5333 /* Parse a PA nullification completer (,n). Return nonzero if the
5334 completer was found; return zero if no completer was found. */
5346 if (strncasecmp (*s
, "n", 1) == 0)
5350 as_bad (_("Invalid Nullification: (%c)"), **s
);
5359 /* Parse a non-negated compare/subtract completer returning the
5360 number (for encoding in instrutions) of the given completer.
5362 ISBRANCH specifies whether or not this is parsing a condition
5363 completer for a branch (vs a nullification completer for a
5364 computational instruction. */
5367 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
5372 char *name
= *s
+ 1;
5381 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5387 if (strcmp (name
, "=") == 0)
5391 else if (strcmp (name
, "<") == 0)
5395 else if (strcmp (name
, "<=") == 0)
5399 else if (strcmp (name
, "<<") == 0)
5403 else if (strcmp (name
, "<<=") == 0)
5407 else if (strcasecmp (name
, "sv") == 0)
5411 else if (strcasecmp (name
, "od") == 0)
5415 /* If we have something like addb,n then there is no condition
5417 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5429 /* Reset pointers if this was really a ,n for a branch instruction. */
5437 /* Parse a negated compare/subtract completer returning the
5438 number (for encoding in instrutions) of the given completer.
5440 ISBRANCH specifies whether or not this is parsing a condition
5441 completer for a branch (vs a nullification completer for a
5442 computational instruction. */
5445 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
5450 char *name
= *s
+ 1;
5459 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5465 if (strcasecmp (name
, "tr") == 0)
5469 else if (strcmp (name
, "<>") == 0)
5473 else if (strcmp (name
, ">=") == 0)
5477 else if (strcmp (name
, ">") == 0)
5481 else if (strcmp (name
, ">>=") == 0)
5485 else if (strcmp (name
, ">>") == 0)
5489 else if (strcasecmp (name
, "nsv") == 0)
5493 else if (strcasecmp (name
, "ev") == 0)
5497 /* If we have something like addb,n then there is no condition
5499 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5511 /* Reset pointers if this was really a ,n for a branch instruction. */
5520 /* Parse a 64 bit compare and branch completer returning the number (for
5521 encoding in instrutions) of the given completer.
5523 Nonnegated comparisons are returned as 0-7, negated comparisons are
5524 returned as 8-15. */
5527 pa_parse_cmpb_64_cmpltr (s
)
5531 char *name
= *s
+ 1;
5538 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5543 if (strcmp (name
, "*") == 0)
5547 else if (strcmp (name
, "*=") == 0)
5551 else if (strcmp (name
, "*<") == 0)
5555 else if (strcmp (name
, "*<=") == 0)
5559 else if (strcmp (name
, "*<<") == 0)
5563 else if (strcmp (name
, "*<<=") == 0)
5567 else if (strcasecmp (name
, "*sv") == 0)
5571 else if (strcasecmp (name
, "*od") == 0)
5575 else if (strcasecmp (name
, "*tr") == 0)
5579 else if (strcmp (name
, "*<>") == 0)
5583 else if (strcmp (name
, "*>=") == 0)
5587 else if (strcmp (name
, "*>") == 0)
5591 else if (strcmp (name
, "*>>=") == 0)
5595 else if (strcmp (name
, "*>>") == 0)
5599 else if (strcasecmp (name
, "*nsv") == 0)
5603 else if (strcasecmp (name
, "*ev") == 0)
5618 /* Parse a 64 bit compare immediate and branch completer returning the number
5619 (for encoding in instrutions) of the given completer. */
5622 pa_parse_cmpib_64_cmpltr (s
)
5626 char *name
= *s
+ 1;
5633 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5638 if (strcmp (name
, "*<<") == 0)
5642 else if (strcmp (name
, "*=") == 0)
5646 else if (strcmp (name
, "*<") == 0)
5650 else if (strcmp (name
, "*<=") == 0)
5654 else if (strcmp (name
, "*>>=") == 0)
5658 else if (strcmp (name
, "*<>") == 0)
5662 else if (strcasecmp (name
, "*>=") == 0)
5666 else if (strcasecmp (name
, "*>") == 0)
5681 /* Parse a non-negated addition completer returning the number
5682 (for encoding in instrutions) of the given completer.
5684 ISBRANCH specifies whether or not this is parsing a condition
5685 completer for a branch (vs a nullification completer for a
5686 computational instruction. */
5689 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
5694 char *name
= *s
+ 1;
5702 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5706 if (strcmp (name
, "=") == 0)
5710 else if (strcmp (name
, "<") == 0)
5714 else if (strcmp (name
, "<=") == 0)
5718 else if (strcasecmp (name
, "nuv") == 0)
5722 else if (strcasecmp (name
, "znv") == 0)
5726 else if (strcasecmp (name
, "sv") == 0)
5730 else if (strcasecmp (name
, "od") == 0)
5734 /* If we have something like addb,n then there is no condition
5736 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5747 /* Reset pointers if this was really a ,n for a branch instruction. */
5748 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5754 /* Parse a negated addition completer returning the number
5755 (for encoding in instrutions) of the given completer.
5757 ISBRANCH specifies whether or not this is parsing a condition
5758 completer for a branch (vs a nullification completer for a
5759 computational instruction). */
5762 pa_parse_neg_add_cmpltr (s
, isbranch
)
5767 char *name
= *s
+ 1;
5775 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5779 if (strcasecmp (name
, "tr") == 0)
5783 else if (strcmp (name
, "<>") == 0)
5787 else if (strcmp (name
, ">=") == 0)
5791 else if (strcmp (name
, ">") == 0)
5795 else if (strcasecmp (name
, "uv") == 0)
5799 else if (strcasecmp (name
, "vnz") == 0)
5803 else if (strcasecmp (name
, "nsv") == 0)
5807 else if (strcasecmp (name
, "ev") == 0)
5811 /* If we have something like addb,n then there is no condition
5813 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5824 /* Reset pointers if this was really a ,n for a branch instruction. */
5825 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5831 /* Parse a 64 bit wide mode add and branch completer returning the number (for
5832 encoding in instrutions) of the given completer. */
5835 pa_parse_addb_64_cmpltr (s
)
5839 char *name
= *s
+ 1;
5848 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5852 if (strcmp (name
, "=") == 0)
5856 else if (strcmp (name
, "<") == 0)
5860 else if (strcmp (name
, "<=") == 0)
5864 else if (strcasecmp (name
, "nuv") == 0)
5868 else if (strcasecmp (name
, "*=") == 0)
5872 else if (strcasecmp (name
, "*<") == 0)
5876 else if (strcasecmp (name
, "*<=") == 0)
5880 else if (strcmp (name
, "tr") == 0)
5884 else if (strcmp (name
, "<>") == 0)
5888 else if (strcmp (name
, ">=") == 0)
5892 else if (strcmp (name
, ">") == 0)
5896 else if (strcasecmp (name
, "uv") == 0)
5900 else if (strcasecmp (name
, "*<>") == 0)
5904 else if (strcasecmp (name
, "*>=") == 0)
5908 else if (strcasecmp (name
, "*>") == 0)
5912 /* If we have something like addb,n then there is no condition
5914 else if (strcasecmp (name
, "n") == 0)
5926 /* Reset pointers if this was really a ,n for a branch instruction. */
5934 /* Handle an alignment directive. Special so that we can update the
5935 alignment of the subspace if necessary. */
5939 /* We must have a valid space and subspace. */
5940 pa_check_current_space_and_subspace ();
5942 /* Let the generic gas code do most of the work. */
5943 s_align_bytes (bytes
);
5945 /* If bytes is a power of 2, then update the current subspace's
5946 alignment if necessary. */
5947 if (log2 (bytes
) != -1)
5948 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
5952 /* Handle a .BLOCK type pseudo-op. */
5956 int z ATTRIBUTE_UNUSED
;
5960 unsigned int temp_size
;
5964 /* We must have a valid space and subspace. */
5965 pa_check_current_space_and_subspace ();
5968 temp_size
= get_absolute_expression ();
5970 /* Always fill with zeros, that's what the HP assembler does. */
5973 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
5974 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
5975 memset (p
, 0, temp_size
);
5977 /* Convert 2 bytes at a time. */
5979 for (i
= 0; i
< temp_size
; i
+= 2)
5981 md_number_to_chars (p
+ i
,
5983 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
5986 pa_undefine_label ();
5987 demand_empty_rest_of_line ();
5990 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
5994 int begin ATTRIBUTE_UNUSED
;
5998 /* The BRTAB relocations are only availble in SOM (to denote
5999 the beginning and end of branch tables). */
6000 char *where
= frag_more (0);
6002 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6003 NULL
, (offsetT
) 0, NULL
,
6004 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
6005 e_fsel
, 0, 0, NULL
);
6008 demand_empty_rest_of_line ();
6011 /* Handle a .begin_try and .end_try pseudo-op. */
6015 int begin ATTRIBUTE_UNUSED
;
6019 char *where
= frag_more (0);
6024 /* The TRY relocations are only availble in SOM (to denote
6025 the beginning and end of exception handling regions). */
6027 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6028 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
6029 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
6030 e_fsel
, 0, 0, NULL
);
6033 demand_empty_rest_of_line ();
6036 /* Handle a .CALL pseudo-op. This involves storing away information
6037 about where arguments are to be found so the linker can detect
6038 (and correct) argument location mismatches between caller and callee. */
6042 int unused ATTRIBUTE_UNUSED
;
6045 /* We must have a valid space and subspace. */
6046 pa_check_current_space_and_subspace ();
6049 pa_call_args (&last_call_desc
);
6050 demand_empty_rest_of_line ();
6053 /* Do the dirty work of building a call descriptor which describes
6054 where the caller placed arguments to a function call. */
6057 pa_call_args (call_desc
)
6058 struct call_desc
*call_desc
;
6061 unsigned int temp
, arg_reloc
;
6063 while (!is_end_of_statement ())
6065 name
= input_line_pointer
;
6066 c
= get_symbol_end ();
6067 /* Process a source argument. */
6068 if ((strncasecmp (name
, "argw", 4) == 0))
6070 temp
= atoi (name
+ 4);
6071 p
= input_line_pointer
;
6073 input_line_pointer
++;
6074 name
= input_line_pointer
;
6075 c
= get_symbol_end ();
6076 arg_reloc
= pa_build_arg_reloc (name
);
6077 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
6079 /* Process a return value. */
6080 else if ((strncasecmp (name
, "rtnval", 6) == 0))
6082 p
= input_line_pointer
;
6084 input_line_pointer
++;
6085 name
= input_line_pointer
;
6086 c
= get_symbol_end ();
6087 arg_reloc
= pa_build_arg_reloc (name
);
6088 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
6092 as_bad (_("Invalid .CALL argument: %s"), name
);
6094 p
= input_line_pointer
;
6096 if (!is_end_of_statement ())
6097 input_line_pointer
++;
6101 /* Return TRUE if FRAG1 and FRAG2 are the same. */
6104 is_same_frag (frag1
, frag2
)
6111 else if (frag2
== NULL
)
6113 else if (frag1
== frag2
)
6115 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
6116 return (is_same_frag (frag1
, frag2
->fr_next
));
6122 /* Build an entry in the UNWIND subspace from the given function
6123 attributes in CALL_INFO. This is not needed for SOM as using
6124 R_ENTRY and R_EXIT relocations allow the linker to handle building
6125 of the unwind spaces. */
6128 pa_build_unwind_subspace (call_info
)
6129 struct call_info
*call_info
;
6132 asection
*seg
, *save_seg
;
6133 subsegT save_subseg
;
6138 if (now_seg
!= text_section
)
6141 if (bfd_get_arch_info (stdoutput
)->bits_per_address
== 32)
6142 reloc
= R_PARISC_DIR32
;
6144 reloc
= R_PARISC_SEGREL32
;
6147 save_subseg
= now_subseg
;
6148 /* Get into the right seg/subseg. This may involve creating
6149 the seg the first time through. Make sure to have the
6150 old seg/subseg so that we can reset things when we are done. */
6151 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
6152 if (seg
== ASEC_NULL
)
6154 seg
= subseg_new (UNWIND_SECTION_NAME
, 0);
6155 bfd_set_section_flags (stdoutput
, seg
,
6156 SEC_READONLY
| SEC_HAS_CONTENTS
6157 | SEC_LOAD
| SEC_RELOC
| SEC_ALLOC
| SEC_DATA
);
6158 bfd_set_section_alignment (stdoutput
, seg
, 2);
6161 subseg_set (seg
, 0);
6164 /* Get some space to hold relocation information for the unwind
6167 md_number_to_chars (p
, 0, 4);
6169 /* Relocation info. for start offset of the function. */
6170 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6171 call_info
->start_symbol
, (offsetT
) 0,
6172 (expressionS
*) NULL
, 0, reloc
,
6173 e_fsel
, 32, 0, NULL
);
6176 md_number_to_chars (p
, 0, 4);
6178 /* Relocation info. for end offset of the function.
6180 Because we allow reductions of 32bit relocations for ELF, this will be
6181 reduced to section_sym + offset which avoids putting the temporary
6182 symbol into the symbol table. It (should) end up giving the same
6183 value as call_info->start_symbol + function size once the linker is
6184 finished with its work. */
6186 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6187 call_info
->end_symbol
, (offsetT
) 0,
6188 (expressionS
*) NULL
, 0, reloc
,
6189 e_fsel
, 32, 0, NULL
);
6192 unwind
= (char *) &call_info
->ci_unwind
;
6193 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
6197 FRAG_APPEND_1_CHAR (c
);
6201 /* Return back to the original segment/subsegment. */
6202 subseg_set (save_seg
, save_subseg
);
6206 /* Process a .CALLINFO pseudo-op. This information is used later
6207 to build unwind descriptors and maybe one day to support
6208 .ENTER and .LEAVE. */
6211 pa_callinfo (unused
)
6212 int unused ATTRIBUTE_UNUSED
;
6218 /* We must have a valid space and subspace. */
6219 pa_check_current_space_and_subspace ();
6222 /* .CALLINFO must appear within a procedure definition. */
6223 if (!within_procedure
)
6224 as_bad (_(".callinfo is not within a procedure definition"));
6226 /* Mark the fact that we found the .CALLINFO for the
6227 current procedure. */
6228 callinfo_found
= TRUE
;
6230 /* Iterate over the .CALLINFO arguments. */
6231 while (!is_end_of_statement ())
6233 name
= input_line_pointer
;
6234 c
= get_symbol_end ();
6235 /* Frame size specification. */
6236 if ((strncasecmp (name
, "frame", 5) == 0))
6238 p
= input_line_pointer
;
6240 input_line_pointer
++;
6241 temp
= get_absolute_expression ();
6242 if ((temp
& 0x3) != 0)
6244 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
6248 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
6249 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
6252 /* Entry register (GR, GR and SR) specifications. */
6253 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
6255 p
= input_line_pointer
;
6257 input_line_pointer
++;
6258 temp
= get_absolute_expression ();
6259 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
6260 even though %r19 is caller saved. I think this is a bug in
6261 the HP assembler, and we are not going to emulate it. */
6262 if (temp
< 3 || temp
> 18)
6263 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
6264 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
6266 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
6268 p
= input_line_pointer
;
6270 input_line_pointer
++;
6271 temp
= get_absolute_expression ();
6272 /* Similarly the HP assembler takes 31 as the high bound even
6273 though %fr21 is the last callee saved floating point register. */
6274 if (temp
< 12 || temp
> 21)
6275 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
6276 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
6278 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
6280 p
= input_line_pointer
;
6282 input_line_pointer
++;
6283 temp
= get_absolute_expression ();
6285 as_bad (_("Value for ENTRY_SR must be 3\n"));
6287 /* Note whether or not this function performs any calls. */
6288 else if ((strncasecmp (name
, "calls", 5) == 0) ||
6289 (strncasecmp (name
, "caller", 6) == 0))
6291 p
= input_line_pointer
;
6294 else if ((strncasecmp (name
, "no_calls", 8) == 0))
6296 p
= input_line_pointer
;
6299 /* Should RP be saved into the stack. */
6300 else if ((strncasecmp (name
, "save_rp", 7) == 0))
6302 p
= input_line_pointer
;
6304 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
6306 /* Likewise for SP. */
6307 else if ((strncasecmp (name
, "save_sp", 7) == 0))
6309 p
= input_line_pointer
;
6311 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
6313 /* Is this an unwindable procedure. If so mark it so
6314 in the unwind descriptor. */
6315 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
6317 p
= input_line_pointer
;
6319 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
6321 /* Is this an interrupt routine. If so mark it in the
6322 unwind descriptor. */
6323 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
6325 p
= input_line_pointer
;
6327 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
6329 /* Is this a millicode routine. "millicode" isn't in my
6330 assembler manual, but my copy is old. The HP assembler
6331 accepts it, and there's a place in the unwind descriptor
6332 to drop the information, so we'll accept it too. */
6333 else if ((strncasecmp (name
, "millicode", 9) == 0))
6335 p
= input_line_pointer
;
6337 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
6341 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
6342 *input_line_pointer
= c
;
6344 if (!is_end_of_statement ())
6345 input_line_pointer
++;
6348 demand_empty_rest_of_line ();
6351 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
6352 /* Switch to the text space. Like s_text, but delete our
6353 label when finished. */
6356 int unused ATTRIBUTE_UNUSED
;
6359 current_space
= is_defined_space ("$TEXT$");
6361 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6365 pa_undefine_label ();
6368 /* Switch to the data space. As usual delete our label. */
6371 int unused ATTRIBUTE_UNUSED
;
6374 current_space
= is_defined_space ("$PRIVATE$");
6376 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6379 pa_undefine_label ();
6382 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
6383 the .comm pseudo-op has the following symtax:
6385 <label> .comm <length>
6387 where <label> is optional and is a symbol whose address will be the start of
6388 a block of memory <length> bytes long. <length> must be an absolute
6389 expression. <length> bytes will be allocated in the current space
6392 Also note the label may not even be on the same line as the .comm.
6394 This difference in syntax means the colon function will be called
6395 on the symbol before we arrive in pa_comm. colon will set a number
6396 of attributes of the symbol that need to be fixed here. In particular
6397 the value, section pointer, fragment pointer, flags, etc. What
6400 This also makes error detection all but impossible. */
6404 int unused ATTRIBUTE_UNUSED
;
6408 label_symbol_struct
*label_symbol
= pa_get_label ();
6411 symbol
= label_symbol
->lss_label
;
6416 size
= get_absolute_expression ();
6420 S_SET_VALUE (symbol
, size
);
6421 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6422 S_SET_EXTERNAL (symbol
);
6424 /* colon() has already set the frag to the current location in the
6425 current subspace; we need to reset the fragment to the zero address
6426 fragment. We also need to reset the segment pointer. */
6427 symbol_set_frag (symbol
, &zero_address_frag
);
6429 demand_empty_rest_of_line ();
6431 #endif /* !(defined (OBJ_ELF) && defined (TE_LINUX)) */
6433 /* Process a .END pseudo-op. */
6437 int unused ATTRIBUTE_UNUSED
;
6439 demand_empty_rest_of_line ();
6442 /* Process a .ENTER pseudo-op. This is not supported. */
6445 int unused ATTRIBUTE_UNUSED
;
6448 /* We must have a valid space and subspace. */
6449 pa_check_current_space_and_subspace ();
6452 as_bad (_("The .ENTER pseudo-op is not supported"));
6453 demand_empty_rest_of_line ();
6456 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
6460 int unused ATTRIBUTE_UNUSED
;
6463 /* We must have a valid space and subspace. */
6464 pa_check_current_space_and_subspace ();
6467 if (!within_procedure
)
6468 as_bad (_("Misplaced .entry. Ignored."));
6471 if (!callinfo_found
)
6472 as_bad (_("Missing .callinfo."));
6474 demand_empty_rest_of_line ();
6475 within_entry_exit
= TRUE
;
6478 /* SOM defers building of unwind descriptors until the link phase.
6479 The assembler is responsible for creating an R_ENTRY relocation
6480 to mark the beginning of a region and hold the unwind bits, and
6481 for creating an R_EXIT relocation to mark the end of the region.
6483 FIXME. ELF should be using the same conventions! The problem
6484 is an unwind requires too much relocation space. Hmmm. Maybe
6485 if we split the unwind bits up between the relocations which
6486 denote the entry and exit points. */
6487 if (last_call_info
->start_symbol
!= NULL
)
6489 char *where
= frag_more (0);
6491 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6492 NULL
, (offsetT
) 0, NULL
,
6493 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
6494 (int *) &last_call_info
->ci_unwind
.descriptor
);
6499 /* Handle a .EQU pseudo-op. */
6505 label_symbol_struct
*label_symbol
= pa_get_label ();
6510 symbol
= label_symbol
->lss_label
;
6512 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
6514 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
6515 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
6520 as_bad (_(".REG must use a label"));
6522 as_bad (_(".EQU must use a label"));
6525 pa_undefine_label ();
6526 demand_empty_rest_of_line ();
6529 /* Helper function. Does processing for the end of a function. This
6530 usually involves creating some relocations or building special
6531 symbols to mark the end of the function. */
6538 where
= frag_more (0);
6541 /* Mark the end of the function, stuff away the location of the frag
6542 for the end of the function, and finally call pa_build_unwind_subspace
6543 to add an entry in the unwind table. */
6544 hppa_elf_mark_end_of_function ();
6545 pa_build_unwind_subspace (last_call_info
);
6547 /* SOM defers building of unwind descriptors until the link phase.
6548 The assembler is responsible for creating an R_ENTRY relocation
6549 to mark the beginning of a region and hold the unwind bits, and
6550 for creating an R_EXIT relocation to mark the end of the region.
6552 FIXME. ELF should be using the same conventions! The problem
6553 is an unwind requires too much relocation space. Hmmm. Maybe
6554 if we split the unwind bits up between the relocations which
6555 denote the entry and exit points. */
6556 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6558 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
6559 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
6563 /* Process a .EXIT pseudo-op. */
6567 int unused ATTRIBUTE_UNUSED
;
6570 /* We must have a valid space and subspace. */
6571 pa_check_current_space_and_subspace ();
6574 if (!within_procedure
)
6575 as_bad (_(".EXIT must appear within a procedure"));
6578 if (!callinfo_found
)
6579 as_bad (_("Missing .callinfo"));
6582 if (!within_entry_exit
)
6583 as_bad (_("No .ENTRY for this .EXIT"));
6586 within_entry_exit
= FALSE
;
6591 demand_empty_rest_of_line ();
6594 /* Process a .EXPORT directive. This makes functions external
6595 and provides information such as argument relocation entries
6600 int unused ATTRIBUTE_UNUSED
;
6605 name
= input_line_pointer
;
6606 c
= get_symbol_end ();
6607 /* Make sure the given symbol exists. */
6608 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6610 as_bad (_("Cannot define export symbol: %s\n"), name
);
6611 p
= input_line_pointer
;
6613 input_line_pointer
++;
6617 /* OK. Set the external bits and process argument relocations.
6618 For the HP, weak and global are not mutually exclusive.
6619 S_SET_EXTERNAL will not set BSF_GLOBAL if WEAK is set.
6620 Call S_SET_EXTERNAL to get the other processing. Manually
6621 set BSF_GLOBAL when we get back. */
6622 S_SET_EXTERNAL (symbol
);
6623 symbol_get_bfdsym (symbol
)->flags
|= BSF_GLOBAL
;
6624 p
= input_line_pointer
;
6626 if (!is_end_of_statement ())
6628 input_line_pointer
++;
6629 pa_type_args (symbol
, 1);
6633 demand_empty_rest_of_line ();
6636 /* Helper function to process arguments to a .EXPORT pseudo-op. */
6639 pa_type_args (symbolP
, is_export
)
6644 unsigned int temp
, arg_reloc
;
6645 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
6647 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
6650 input_line_pointer
+= 8;
6651 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6652 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
6653 type
= SYMBOL_TYPE_ABSOLUTE
;
6655 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
6657 input_line_pointer
+= 4;
6658 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
6659 instead one should be IMPORTing/EXPORTing ENTRY types.
6661 Complain if one tries to EXPORT a CODE type since that's never
6662 done. Both GCC and HP C still try to IMPORT CODE types, so
6663 silently fix them to be ENTRY types. */
6664 if (S_IS_FUNCTION (symbolP
))
6667 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
6668 S_GET_NAME (symbolP
));
6670 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6671 type
= SYMBOL_TYPE_ENTRY
;
6675 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6676 type
= SYMBOL_TYPE_CODE
;
6679 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
6681 input_line_pointer
+= 4;
6682 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6683 symbol_get_bfdsym (symbolP
)->flags
|= BSF_OBJECT
;
6684 type
= SYMBOL_TYPE_DATA
;
6686 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
6688 input_line_pointer
+= 5;
6689 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6690 type
= SYMBOL_TYPE_ENTRY
;
6692 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
6694 input_line_pointer
+= 9;
6695 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6696 type
= SYMBOL_TYPE_MILLICODE
;
6698 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
6700 input_line_pointer
+= 6;
6701 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6702 type
= SYMBOL_TYPE_PLABEL
;
6704 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
6706 input_line_pointer
+= 8;
6707 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6708 type
= SYMBOL_TYPE_PRI_PROG
;
6710 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
6712 input_line_pointer
+= 8;
6713 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6714 type
= SYMBOL_TYPE_SEC_PROG
;
6717 /* SOM requires much more information about symbol types
6718 than BFD understands. This is how we get this information
6719 to the SOM BFD backend. */
6720 #ifdef obj_set_symbol_type
6721 obj_set_symbol_type (symbol_get_bfdsym (symbolP
), (int) type
);
6724 /* Now that the type of the exported symbol has been handled,
6725 handle any argument relocation information. */
6726 while (!is_end_of_statement ())
6728 if (*input_line_pointer
== ',')
6729 input_line_pointer
++;
6730 name
= input_line_pointer
;
6731 c
= get_symbol_end ();
6732 /* Argument sources. */
6733 if ((strncasecmp (name
, "argw", 4) == 0))
6735 p
= input_line_pointer
;
6737 input_line_pointer
++;
6738 temp
= atoi (name
+ 4);
6739 name
= input_line_pointer
;
6740 c
= get_symbol_end ();
6741 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
6742 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
6743 symbol_arg_reloc_info (symbolP
) |= arg_reloc
;
6745 *input_line_pointer
= c
;
6747 /* The return value. */
6748 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
6750 p
= input_line_pointer
;
6752 input_line_pointer
++;
6753 name
= input_line_pointer
;
6754 c
= get_symbol_end ();
6755 arg_reloc
= pa_build_arg_reloc (name
);
6756 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
6757 symbol_arg_reloc_info (symbolP
) |= arg_reloc
;
6759 *input_line_pointer
= c
;
6761 /* Privelege level. */
6762 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
6764 p
= input_line_pointer
;
6766 input_line_pointer
++;
6767 temp
= atoi (input_line_pointer
);
6769 ((obj_symbol_type
*) symbol_get_bfdsym (symbolP
))
6770 ->tc_data
.ap
.hppa_priv_level
= temp
;
6772 c
= get_symbol_end ();
6773 *input_line_pointer
= c
;
6777 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
6778 p
= input_line_pointer
;
6781 if (!is_end_of_statement ())
6782 input_line_pointer
++;
6786 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
6787 assembly file must either be defined in the assembly file, or
6788 explicitly IMPORTED from another. */
6792 int unused ATTRIBUTE_UNUSED
;
6797 name
= input_line_pointer
;
6798 c
= get_symbol_end ();
6800 symbol
= symbol_find (name
);
6801 /* Ugh. We might be importing a symbol defined earlier in the file,
6802 in which case all the code below will really screw things up
6803 (set the wrong segment, symbol flags & type, etc). */
6804 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
6806 symbol
= symbol_find_or_make (name
);
6807 p
= input_line_pointer
;
6810 if (!is_end_of_statement ())
6812 input_line_pointer
++;
6813 pa_type_args (symbol
, 0);
6817 /* Sigh. To be compatable with the HP assembler and to help
6818 poorly written assembly code, we assign a type based on
6819 the the current segment. Note only BSF_FUNCTION really
6820 matters, we do not need to set the full SYMBOL_TYPE_* info. */
6821 if (now_seg
== text_section
)
6822 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
6824 /* If the section is undefined, then the symbol is undefined
6825 Since this is an import, leave the section undefined. */
6826 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6831 /* The symbol was already defined. Just eat everything up to
6832 the end of the current statement. */
6833 while (!is_end_of_statement ())
6834 input_line_pointer
++;
6837 demand_empty_rest_of_line ();
6840 /* Handle a .LABEL pseudo-op. */
6844 int unused ATTRIBUTE_UNUSED
;
6848 name
= input_line_pointer
;
6849 c
= get_symbol_end ();
6851 if (strlen (name
) > 0)
6854 p
= input_line_pointer
;
6859 as_warn (_("Missing label name on .LABEL"));
6862 if (!is_end_of_statement ())
6864 as_warn (_("extra .LABEL arguments ignored."));
6865 ignore_rest_of_line ();
6867 demand_empty_rest_of_line ();
6870 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
6874 int unused ATTRIBUTE_UNUSED
;
6877 /* We must have a valid space and subspace. */
6878 pa_check_current_space_and_subspace ();
6881 as_bad (_("The .LEAVE pseudo-op is not supported"));
6882 demand_empty_rest_of_line ();
6885 /* Handle a .LEVEL pseudo-op. */
6889 int unused ATTRIBUTE_UNUSED
;
6893 level
= input_line_pointer
;
6894 if (strncmp (level
, "1.0", 3) == 0)
6896 input_line_pointer
+= 3;
6897 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
6898 as_warn (_("could not set architecture and machine"));
6900 else if (strncmp (level
, "1.1", 3) == 0)
6902 input_line_pointer
+= 3;
6903 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
6904 as_warn (_("could not set architecture and machine"));
6906 else if (strncmp (level
, "2.0w", 4) == 0)
6908 input_line_pointer
+= 4;
6909 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 25))
6910 as_warn (_("could not set architecture and machine"));
6912 else if (strncmp (level
, "2.0", 3) == 0)
6914 input_line_pointer
+= 3;
6915 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
6916 as_warn (_("could not set architecture and machine"));
6920 as_bad (_("Unrecognized .LEVEL argument\n"));
6921 ignore_rest_of_line ();
6923 demand_empty_rest_of_line ();
6926 /* Handle a .ORIGIN pseudo-op. */
6930 int unused ATTRIBUTE_UNUSED
;
6933 /* We must have a valid space and subspace. */
6934 pa_check_current_space_and_subspace ();
6938 pa_undefine_label ();
6941 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
6942 is for static functions. FIXME. Should share more code with .EXPORT. */
6946 int unused ATTRIBUTE_UNUSED
;
6951 name
= input_line_pointer
;
6952 c
= get_symbol_end ();
6954 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6956 as_bad (_("Cannot define static symbol: %s\n"), name
);
6957 p
= input_line_pointer
;
6959 input_line_pointer
++;
6963 S_CLEAR_EXTERNAL (symbol
);
6964 p
= input_line_pointer
;
6966 if (!is_end_of_statement ())
6968 input_line_pointer
++;
6969 pa_type_args (symbol
, 0);
6973 demand_empty_rest_of_line ();
6976 /* Handle a .PROC pseudo-op. It is used to mark the beginning
6977 of a procedure from a syntactical point of view. */
6981 int unused ATTRIBUTE_UNUSED
;
6983 struct call_info
*call_info
;
6986 /* We must have a valid space and subspace. */
6987 pa_check_current_space_and_subspace ();
6990 if (within_procedure
)
6991 as_fatal (_("Nested procedures"));
6993 /* Reset global variables for new procedure. */
6994 callinfo_found
= FALSE
;
6995 within_procedure
= TRUE
;
6997 /* Create another call_info structure. */
6998 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
7001 as_fatal (_("Cannot allocate unwind descriptor\n"));
7003 memset (call_info
, 0, sizeof (struct call_info
));
7005 call_info
->ci_next
= NULL
;
7007 if (call_info_root
== NULL
)
7009 call_info_root
= call_info
;
7010 last_call_info
= call_info
;
7014 last_call_info
->ci_next
= call_info
;
7015 last_call_info
= call_info
;
7018 /* set up defaults on call_info structure */
7020 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
7021 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
7022 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
7024 /* If we got a .PROC pseudo-op, we know that the function is defined
7025 locally. Make sure it gets into the symbol table. */
7027 label_symbol_struct
*label_symbol
= pa_get_label ();
7031 if (label_symbol
->lss_label
)
7033 last_call_info
->start_symbol
= label_symbol
->lss_label
;
7034 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
7037 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
7040 last_call_info
->start_symbol
= NULL
;
7043 demand_empty_rest_of_line ();
7046 /* Process the syntatical end of a procedure. Make sure all the
7047 appropriate pseudo-ops were found within the procedure. */
7051 int unused ATTRIBUTE_UNUSED
;
7055 /* We must have a valid space and subspace. */
7056 pa_check_current_space_and_subspace ();
7059 /* If we are within a procedure definition, make sure we've
7060 defined a label for the procedure; handle case where the
7061 label was defined after the .PROC directive.
7063 Note there's not need to diddle with the segment or fragment
7064 for the label symbol in this case. We have already switched
7065 into the new $CODE$ subspace at this point. */
7066 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
7068 label_symbol_struct
*label_symbol
= pa_get_label ();
7072 if (label_symbol
->lss_label
)
7074 last_call_info
->start_symbol
= label_symbol
->lss_label
;
7075 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
7078 /* Also handle allocation of a fixup to hold the unwind
7079 information when the label appears after the proc/procend. */
7080 if (within_entry_exit
)
7082 char *where
= frag_more (0);
7084 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
7085 NULL
, (offsetT
) 0, NULL
,
7086 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
7087 (int *) &last_call_info
->ci_unwind
.descriptor
);
7092 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
7095 as_bad (_("Missing function name for .PROC"));
7098 if (!within_procedure
)
7099 as_bad (_("misplaced .procend"));
7101 if (!callinfo_found
)
7102 as_bad (_("Missing .callinfo for this procedure"));
7104 if (within_entry_exit
)
7105 as_bad (_("Missing .EXIT for a .ENTRY"));
7108 /* ELF needs to mark the end of each function so that it can compute
7109 the size of the function (apparently its needed in the symbol table). */
7110 hppa_elf_mark_end_of_function ();
7113 within_procedure
= FALSE
;
7114 demand_empty_rest_of_line ();
7115 pa_undefine_label ();
7120 /* If VALUE is an exact power of two between zero and 2^31, then
7121 return log2 (VALUE). Else return -1. */
7129 while ((1 << shift
) != value
&& shift
< 32)
7138 /* Check to make sure we have a valid space and subspace. */
7141 pa_check_current_space_and_subspace ()
7143 if (current_space
== NULL
)
7144 as_fatal (_("Not in a space.\n"));
7146 if (current_subspace
== NULL
)
7147 as_fatal (_("Not in a subspace.\n"));
7150 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
7151 then create a new space entry to hold the information specified
7152 by the parameters to the .SPACE directive. */
7154 static sd_chain_struct
*
7155 pa_parse_space_stmt (space_name
, create_flag
)
7159 char *name
, *ptemp
, c
;
7160 char loadable
, defined
, private, sort
;
7162 asection
*seg
= NULL
;
7163 sd_chain_struct
*space
;
7165 /* load default values */
7171 if (strcmp (space_name
, "$TEXT$") == 0)
7173 seg
= pa_def_spaces
[0].segment
;
7174 defined
= pa_def_spaces
[0].defined
;
7175 private = pa_def_spaces
[0].private;
7176 sort
= pa_def_spaces
[0].sort
;
7177 spnum
= pa_def_spaces
[0].spnum
;
7179 else if (strcmp (space_name
, "$PRIVATE$") == 0)
7181 seg
= pa_def_spaces
[1].segment
;
7182 defined
= pa_def_spaces
[1].defined
;
7183 private = pa_def_spaces
[1].private;
7184 sort
= pa_def_spaces
[1].sort
;
7185 spnum
= pa_def_spaces
[1].spnum
;
7188 if (!is_end_of_statement ())
7190 print_errors
= FALSE
;
7191 ptemp
= input_line_pointer
+ 1;
7192 /* First see if the space was specified as a number rather than
7193 as a name. According to the PA assembly manual the rest of
7194 the line should be ignored. */
7195 temp
= pa_parse_number (&ptemp
, 0);
7199 input_line_pointer
= ptemp
;
7203 while (!is_end_of_statement ())
7205 input_line_pointer
++;
7206 name
= input_line_pointer
;
7207 c
= get_symbol_end ();
7208 if ((strncasecmp (name
, "spnum", 5) == 0))
7210 *input_line_pointer
= c
;
7211 input_line_pointer
++;
7212 spnum
= get_absolute_expression ();
7214 else if ((strncasecmp (name
, "sort", 4) == 0))
7216 *input_line_pointer
= c
;
7217 input_line_pointer
++;
7218 sort
= get_absolute_expression ();
7220 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7222 *input_line_pointer
= c
;
7225 else if ((strncasecmp (name
, "notdefined", 10) == 0))
7227 *input_line_pointer
= c
;
7230 else if ((strncasecmp (name
, "private", 7) == 0))
7232 *input_line_pointer
= c
;
7237 as_bad (_("Invalid .SPACE argument"));
7238 *input_line_pointer
= c
;
7239 if (!is_end_of_statement ())
7240 input_line_pointer
++;
7244 print_errors
= TRUE
;
7247 if (create_flag
&& seg
== NULL
)
7248 seg
= subseg_new (space_name
, 0);
7250 /* If create_flag is nonzero, then create the new space with
7251 the attributes computed above. Else set the values in
7252 an already existing space -- this can only happen for
7253 the first occurence of a built-in space. */
7255 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
7256 private, sort
, seg
, 1);
7259 space
= is_defined_space (space_name
);
7260 SPACE_SPNUM (space
) = spnum
;
7261 SPACE_DEFINED (space
) = defined
& 1;
7262 SPACE_USER_DEFINED (space
) = 1;
7265 #ifdef obj_set_section_attributes
7266 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7272 /* Handle a .SPACE pseudo-op; this switches the current space to the
7273 given space, creating the new space if necessary. */
7277 int unused ATTRIBUTE_UNUSED
;
7279 char *name
, c
, *space_name
, *save_s
;
7281 sd_chain_struct
*sd_chain
;
7283 if (within_procedure
)
7285 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
7286 ignore_rest_of_line ();
7290 /* Check for some of the predefined spaces. FIXME: most of the code
7291 below is repeated several times, can we extract the common parts
7292 and place them into a subroutine or something similar? */
7293 /* FIXME Is this (and the next IF stmt) really right?
7294 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
7295 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
7297 input_line_pointer
+= 6;
7298 sd_chain
= is_defined_space ("$TEXT$");
7299 if (sd_chain
== NULL
)
7300 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
7301 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7302 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
7304 current_space
= sd_chain
;
7305 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
7307 = pa_subsegment_to_subspace (text_section
,
7308 sd_chain
->sd_last_subseg
);
7309 demand_empty_rest_of_line ();
7312 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
7314 input_line_pointer
+= 9;
7315 sd_chain
= is_defined_space ("$PRIVATE$");
7316 if (sd_chain
== NULL
)
7317 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
7318 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7319 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
7321 current_space
= sd_chain
;
7322 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
7324 = pa_subsegment_to_subspace (data_section
,
7325 sd_chain
->sd_last_subseg
);
7326 demand_empty_rest_of_line ();
7329 if (!strncasecmp (input_line_pointer
,
7330 GDB_DEBUG_SPACE_NAME
,
7331 strlen (GDB_DEBUG_SPACE_NAME
)))
7333 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
7334 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
7335 if (sd_chain
== NULL
)
7336 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
7337 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7338 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
7340 current_space
= sd_chain
;
7343 asection
*gdb_section
7344 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
7346 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
7348 = pa_subsegment_to_subspace (gdb_section
,
7349 sd_chain
->sd_last_subseg
);
7351 demand_empty_rest_of_line ();
7355 /* It could be a space specified by number. */
7357 save_s
= input_line_pointer
;
7358 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
7360 if ((sd_chain
= pa_find_space_by_number (temp
)))
7362 current_space
= sd_chain
;
7364 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7366 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7367 sd_chain
->sd_last_subseg
);
7368 demand_empty_rest_of_line ();
7373 /* Not a number, attempt to create a new space. */
7375 input_line_pointer
= save_s
;
7376 name
= input_line_pointer
;
7377 c
= get_symbol_end ();
7378 space_name
= xmalloc (strlen (name
) + 1);
7379 strcpy (space_name
, name
);
7380 *input_line_pointer
= c
;
7382 sd_chain
= pa_parse_space_stmt (space_name
, 1);
7383 current_space
= sd_chain
;
7385 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7386 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7387 sd_chain
->sd_last_subseg
);
7388 demand_empty_rest_of_line ();
7392 /* Switch to a new space. (I think). FIXME. */
7396 int unused ATTRIBUTE_UNUSED
;
7401 sd_chain_struct
*space
;
7403 name
= input_line_pointer
;
7404 c
= get_symbol_end ();
7405 space
= is_defined_space (name
);
7409 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
7412 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
7414 *input_line_pointer
= c
;
7415 demand_empty_rest_of_line ();
7418 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
7419 given subspace, creating the new subspace if necessary.
7421 FIXME. Should mirror pa_space more closely, in particular how
7422 they're broken up into subroutines. */
7425 pa_subspace (create_new
)
7428 char *name
, *ss_name
, c
;
7429 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
7430 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
7431 sd_chain_struct
*space
;
7432 ssd_chain_struct
*ssd
;
7435 if (current_space
== NULL
)
7436 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
7438 if (within_procedure
)
7440 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
7441 ignore_rest_of_line ();
7445 name
= input_line_pointer
;
7446 c
= get_symbol_end ();
7447 ss_name
= xmalloc (strlen (name
) + 1);
7448 strcpy (ss_name
, name
);
7449 *input_line_pointer
= c
;
7451 /* Load default values. */
7463 space
= current_space
;
7467 ssd
= is_defined_subspace (ss_name
);
7468 /* Allow user to override the builtin attributes of subspaces. But
7469 only allow the attributes to be changed once! */
7470 if (ssd
&& SUBSPACE_DEFINED (ssd
))
7472 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
7473 current_subspace
= ssd
;
7474 if (!is_end_of_statement ())
7475 as_warn (_("Parameters of an existing subspace can\'t be modified"));
7476 demand_empty_rest_of_line ();
7481 /* A new subspace. Load default values if it matches one of
7482 the builtin subspaces. */
7484 while (pa_def_subspaces
[i
].name
)
7486 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
7488 loadable
= pa_def_subspaces
[i
].loadable
;
7489 common
= pa_def_subspaces
[i
].common
;
7490 dup_common
= pa_def_subspaces
[i
].dup_common
;
7491 code_only
= pa_def_subspaces
[i
].code_only
;
7492 zero
= pa_def_subspaces
[i
].zero
;
7493 space_index
= pa_def_subspaces
[i
].space_index
;
7494 alignment
= pa_def_subspaces
[i
].alignment
;
7495 quadrant
= pa_def_subspaces
[i
].quadrant
;
7496 access
= pa_def_subspaces
[i
].access
;
7497 sort
= pa_def_subspaces
[i
].sort
;
7504 /* We should be working with a new subspace now. Fill in
7505 any information as specified by the user. */
7506 if (!is_end_of_statement ())
7508 input_line_pointer
++;
7509 while (!is_end_of_statement ())
7511 name
= input_line_pointer
;
7512 c
= get_symbol_end ();
7513 if ((strncasecmp (name
, "quad", 4) == 0))
7515 *input_line_pointer
= c
;
7516 input_line_pointer
++;
7517 quadrant
= get_absolute_expression ();
7519 else if ((strncasecmp (name
, "align", 5) == 0))
7521 *input_line_pointer
= c
;
7522 input_line_pointer
++;
7523 alignment
= get_absolute_expression ();
7524 if (log2 (alignment
) == -1)
7526 as_bad (_("Alignment must be a power of 2"));
7530 else if ((strncasecmp (name
, "access", 6) == 0))
7532 *input_line_pointer
= c
;
7533 input_line_pointer
++;
7534 access
= get_absolute_expression ();
7536 else if ((strncasecmp (name
, "sort", 4) == 0))
7538 *input_line_pointer
= c
;
7539 input_line_pointer
++;
7540 sort
= get_absolute_expression ();
7542 else if ((strncasecmp (name
, "code_only", 9) == 0))
7544 *input_line_pointer
= c
;
7547 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7549 *input_line_pointer
= c
;
7552 else if ((strncasecmp (name
, "common", 6) == 0))
7554 *input_line_pointer
= c
;
7557 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
7559 *input_line_pointer
= c
;
7562 else if ((strncasecmp (name
, "zero", 4) == 0))
7564 *input_line_pointer
= c
;
7567 else if ((strncasecmp (name
, "first", 5) == 0))
7568 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
7570 as_bad (_("Invalid .SUBSPACE argument"));
7571 if (!is_end_of_statement ())
7572 input_line_pointer
++;
7576 /* Compute a reasonable set of BFD flags based on the information
7577 in the .subspace directive. */
7578 applicable
= bfd_applicable_section_flags (stdoutput
);
7581 flags
|= (SEC_ALLOC
| SEC_LOAD
);
7584 if (common
|| dup_common
)
7585 flags
|= SEC_IS_COMMON
;
7587 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
7589 /* This is a zero-filled subspace (eg BSS). */
7591 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
7593 applicable
&= flags
;
7595 /* If this is an existing subspace, then we want to use the
7596 segment already associated with the subspace.
7598 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
7599 lots of sections. It might be a problem in the PA ELF
7600 code, I do not know yet. For now avoid creating anything
7601 but the "standard" sections for ELF. */
7603 section
= subseg_force_new (ss_name
, 0);
7605 section
= ssd
->ssd_seg
;
7607 section
= subseg_new (ss_name
, 0);
7610 seg_info (section
)->bss
= 1;
7612 /* Now set the flags. */
7613 bfd_set_section_flags (stdoutput
, section
, applicable
);
7615 /* Record any alignment request for this section. */
7616 record_alignment (section
, log2 (alignment
));
7618 /* Set the starting offset for this section. */
7619 bfd_set_section_vma (stdoutput
, section
,
7620 pa_subspace_start (space
, quadrant
));
7622 /* Now that all the flags are set, update an existing subspace,
7623 or create a new one. */
7626 current_subspace
= update_subspace (space
, ss_name
, loadable
,
7627 code_only
, common
, dup_common
,
7628 sort
, zero
, access
, space_index
,
7629 alignment
, quadrant
,
7632 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
7634 dup_common
, zero
, sort
,
7635 access
, space_index
,
7636 alignment
, quadrant
, section
);
7638 demand_empty_rest_of_line ();
7639 current_subspace
->ssd_seg
= section
;
7640 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
7642 SUBSPACE_DEFINED (current_subspace
) = 1;
7646 /* Create default space and subspace dictionaries. */
7653 space_dict_root
= NULL
;
7654 space_dict_last
= NULL
;
7657 while (pa_def_spaces
[i
].name
)
7661 /* Pick the right name to use for the new section. */
7662 name
= pa_def_spaces
[i
].name
;
7664 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
7665 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
7666 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
7667 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
7668 pa_def_spaces
[i
].segment
, 0);
7673 while (pa_def_subspaces
[i
].name
)
7676 int applicable
, subsegment
;
7677 asection
*segment
= NULL
;
7678 sd_chain_struct
*space
;
7680 /* Pick the right name for the new section and pick the right
7681 subsegment number. */
7682 name
= pa_def_subspaces
[i
].name
;
7685 /* Create the new section. */
7686 segment
= subseg_new (name
, subsegment
);
7689 /* For SOM we want to replace the standard .text, .data, and .bss
7690 sections with our own. We also want to set BFD flags for
7691 all the built-in subspaces. */
7692 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
7694 text_section
= segment
;
7695 applicable
= bfd_applicable_section_flags (stdoutput
);
7696 bfd_set_section_flags (stdoutput
, segment
,
7697 applicable
& (SEC_ALLOC
| SEC_LOAD
7698 | SEC_RELOC
| SEC_CODE
7700 | SEC_HAS_CONTENTS
));
7702 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
7704 data_section
= segment
;
7705 applicable
= bfd_applicable_section_flags (stdoutput
);
7706 bfd_set_section_flags (stdoutput
, segment
,
7707 applicable
& (SEC_ALLOC
| SEC_LOAD
7709 | SEC_HAS_CONTENTS
));
7713 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
7715 bss_section
= segment
;
7716 applicable
= bfd_applicable_section_flags (stdoutput
);
7717 bfd_set_section_flags (stdoutput
, segment
,
7718 applicable
& SEC_ALLOC
);
7720 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
7722 applicable
= bfd_applicable_section_flags (stdoutput
);
7723 bfd_set_section_flags (stdoutput
, segment
,
7724 applicable
& (SEC_ALLOC
| SEC_LOAD
7727 | SEC_HAS_CONTENTS
));
7729 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
7731 applicable
= bfd_applicable_section_flags (stdoutput
);
7732 bfd_set_section_flags (stdoutput
, segment
,
7733 applicable
& (SEC_ALLOC
| SEC_LOAD
7736 | SEC_HAS_CONTENTS
));
7738 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
7740 applicable
= bfd_applicable_section_flags (stdoutput
);
7741 bfd_set_section_flags (stdoutput
, segment
,
7742 applicable
& (SEC_ALLOC
| SEC_LOAD
7745 | SEC_HAS_CONTENTS
));
7748 /* Find the space associated with this subspace. */
7749 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
7750 def_space_index
].segment
);
7753 as_fatal (_("Internal error: Unable to find containing space for %s."),
7754 pa_def_subspaces
[i
].name
);
7757 create_new_subspace (space
, name
,
7758 pa_def_subspaces
[i
].loadable
,
7759 pa_def_subspaces
[i
].code_only
,
7760 pa_def_subspaces
[i
].common
,
7761 pa_def_subspaces
[i
].dup_common
,
7762 pa_def_subspaces
[i
].zero
,
7763 pa_def_subspaces
[i
].sort
,
7764 pa_def_subspaces
[i
].access
,
7765 pa_def_subspaces
[i
].space_index
,
7766 pa_def_subspaces
[i
].alignment
,
7767 pa_def_subspaces
[i
].quadrant
,
7775 /* Create a new space NAME, with the appropriate flags as defined
7776 by the given parameters. */
7778 static sd_chain_struct
*
7779 create_new_space (name
, spnum
, loadable
, defined
, private,
7780 sort
, seg
, user_defined
)
7790 sd_chain_struct
*chain_entry
;
7792 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
7794 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
7797 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7798 strcpy (SPACE_NAME (chain_entry
), name
);
7799 SPACE_DEFINED (chain_entry
) = defined
;
7800 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
7801 SPACE_SPNUM (chain_entry
) = spnum
;
7803 chain_entry
->sd_seg
= seg
;
7804 chain_entry
->sd_last_subseg
= -1;
7805 chain_entry
->sd_subspaces
= NULL
;
7806 chain_entry
->sd_next
= NULL
;
7808 /* Find spot for the new space based on its sort key. */
7809 if (!space_dict_last
)
7810 space_dict_last
= chain_entry
;
7812 if (space_dict_root
== NULL
)
7813 space_dict_root
= chain_entry
;
7816 sd_chain_struct
*chain_pointer
;
7817 sd_chain_struct
*prev_chain_pointer
;
7819 chain_pointer
= space_dict_root
;
7820 prev_chain_pointer
= NULL
;
7822 while (chain_pointer
)
7824 prev_chain_pointer
= chain_pointer
;
7825 chain_pointer
= chain_pointer
->sd_next
;
7828 /* At this point we've found the correct place to add the new
7829 entry. So add it and update the linked lists as appropriate. */
7830 if (prev_chain_pointer
)
7832 chain_entry
->sd_next
= chain_pointer
;
7833 prev_chain_pointer
->sd_next
= chain_entry
;
7837 space_dict_root
= chain_entry
;
7838 chain_entry
->sd_next
= chain_pointer
;
7841 if (chain_entry
->sd_next
== NULL
)
7842 space_dict_last
= chain_entry
;
7845 /* This is here to catch predefined spaces which do not get
7846 modified by the user's input. Another call is found at
7847 the bottom of pa_parse_space_stmt to handle cases where
7848 the user modifies a predefined space. */
7849 #ifdef obj_set_section_attributes
7850 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7856 /* Create a new subspace NAME, with the appropriate flags as defined
7857 by the given parameters.
7859 Add the new subspace to the subspace dictionary chain in numerical
7860 order as defined by the SORT entries. */
7862 static ssd_chain_struct
*
7863 create_new_subspace (space
, name
, loadable
, code_only
, common
,
7864 dup_common
, is_zero
, sort
, access
, space_index
,
7865 alignment
, quadrant
, seg
)
7866 sd_chain_struct
*space
;
7868 int loadable
, code_only
, common
, dup_common
, is_zero
;
7876 ssd_chain_struct
*chain_entry
;
7878 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
7880 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
7882 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7883 strcpy (SUBSPACE_NAME (chain_entry
), name
);
7885 /* Initialize subspace_defined. When we hit a .subspace directive
7886 we'll set it to 1 which "locks-in" the subspace attributes. */
7887 SUBSPACE_DEFINED (chain_entry
) = 0;
7889 chain_entry
->ssd_subseg
= 0;
7890 chain_entry
->ssd_seg
= seg
;
7891 chain_entry
->ssd_next
= NULL
;
7893 /* Find spot for the new subspace based on its sort key. */
7894 if (space
->sd_subspaces
== NULL
)
7895 space
->sd_subspaces
= chain_entry
;
7898 ssd_chain_struct
*chain_pointer
;
7899 ssd_chain_struct
*prev_chain_pointer
;
7901 chain_pointer
= space
->sd_subspaces
;
7902 prev_chain_pointer
= NULL
;
7904 while (chain_pointer
)
7906 prev_chain_pointer
= chain_pointer
;
7907 chain_pointer
= chain_pointer
->ssd_next
;
7910 /* Now we have somewhere to put the new entry. Insert it and update
7912 if (prev_chain_pointer
)
7914 chain_entry
->ssd_next
= chain_pointer
;
7915 prev_chain_pointer
->ssd_next
= chain_entry
;
7919 space
->sd_subspaces
= chain_entry
;
7920 chain_entry
->ssd_next
= chain_pointer
;
7924 #ifdef obj_set_subsection_attributes
7925 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
7932 /* Update the information for the given subspace based upon the
7933 various arguments. Return the modified subspace chain entry. */
7935 static ssd_chain_struct
*
7936 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
7937 zero
, access
, space_index
, alignment
, quadrant
, section
)
7938 sd_chain_struct
*space
;
7952 ssd_chain_struct
*chain_entry
;
7954 chain_entry
= is_defined_subspace (name
);
7956 #ifdef obj_set_subsection_attributes
7957 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
7964 /* Return the space chain entry for the space with the name NAME or
7965 NULL if no such space exists. */
7967 static sd_chain_struct
*
7968 is_defined_space (name
)
7971 sd_chain_struct
*chain_pointer
;
7973 for (chain_pointer
= space_dict_root
;
7975 chain_pointer
= chain_pointer
->sd_next
)
7977 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
7978 return chain_pointer
;
7981 /* No mapping from segment to space was found. Return NULL. */
7985 /* Find and return the space associated with the given seg. If no mapping
7986 from the given seg to a space is found, then return NULL.
7988 Unlike subspaces, the number of spaces is not expected to grow much,
7989 so a linear exhaustive search is OK here. */
7991 static sd_chain_struct
*
7992 pa_segment_to_space (seg
)
7995 sd_chain_struct
*space_chain
;
7997 /* Walk through each space looking for the correct mapping. */
7998 for (space_chain
= space_dict_root
;
8000 space_chain
= space_chain
->sd_next
)
8002 if (space_chain
->sd_seg
== seg
)
8006 /* Mapping was not found. Return NULL. */
8010 /* Return the space chain entry for the subspace with the name NAME or
8011 NULL if no such subspace exists.
8013 Uses a linear search through all the spaces and subspaces, this may
8014 not be appropriate if we ever being placing each function in its
8017 static ssd_chain_struct
*
8018 is_defined_subspace (name
)
8021 sd_chain_struct
*space_chain
;
8022 ssd_chain_struct
*subspace_chain
;
8024 /* Walk through each space. */
8025 for (space_chain
= space_dict_root
;
8027 space_chain
= space_chain
->sd_next
)
8029 /* Walk through each subspace looking for a name which matches. */
8030 for (subspace_chain
= space_chain
->sd_subspaces
;
8032 subspace_chain
= subspace_chain
->ssd_next
)
8033 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
8034 return subspace_chain
;
8037 /* Subspace wasn't found. Return NULL. */
8041 /* Find and return the subspace associated with the given seg. If no
8042 mapping from the given seg to a subspace is found, then return NULL.
8044 If we ever put each procedure/function within its own subspace
8045 (to make life easier on the compiler and linker), then this will have
8046 to become more efficient. */
8048 static ssd_chain_struct
*
8049 pa_subsegment_to_subspace (seg
, subseg
)
8053 sd_chain_struct
*space_chain
;
8054 ssd_chain_struct
*subspace_chain
;
8056 /* Walk through each space. */
8057 for (space_chain
= space_dict_root
;
8059 space_chain
= space_chain
->sd_next
)
8061 if (space_chain
->sd_seg
== seg
)
8063 /* Walk through each subspace within each space looking for
8064 the correct mapping. */
8065 for (subspace_chain
= space_chain
->sd_subspaces
;
8067 subspace_chain
= subspace_chain
->ssd_next
)
8068 if (subspace_chain
->ssd_subseg
== (int) subseg
)
8069 return subspace_chain
;
8073 /* No mapping from subsegment to subspace found. Return NULL. */
8077 /* Given a number, try and find a space with the name number.
8079 Return a pointer to a space dictionary chain entry for the space
8080 that was found or NULL on failure. */
8082 static sd_chain_struct
*
8083 pa_find_space_by_number (number
)
8086 sd_chain_struct
*space_chain
;
8088 for (space_chain
= space_dict_root
;
8090 space_chain
= space_chain
->sd_next
)
8092 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
8096 /* No appropriate space found. Return NULL. */
8100 /* Return the starting address for the given subspace. If the starting
8101 address is unknown then return zero. */
8104 pa_subspace_start (space
, quadrant
)
8105 sd_chain_struct
*space
;
8108 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
8109 is not correct for the PA OSF1 port. */
8110 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
8112 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
8119 /* FIXME. Needs documentation. */
8121 pa_next_subseg (space
)
8122 sd_chain_struct
*space
;
8125 space
->sd_last_subseg
++;
8126 return space
->sd_last_subseg
;
8130 /* Helper function for pa_stringer. Used to find the end of
8137 unsigned int c
= *s
& CHAR_MASK
;
8150 /* Handle a .STRING type pseudo-op. */
8153 pa_stringer (append_zero
)
8156 char *s
, num_buf
[4];
8160 /* Preprocess the string to handle PA-specific escape sequences.
8161 For example, \xDD where DD is a hexadecimal number should be
8162 changed to \OOO where OOO is an octal number. */
8165 /* We must have a valid space and subspace. */
8166 pa_check_current_space_and_subspace ();
8169 /* Skip the opening quote. */
8170 s
= input_line_pointer
+ 1;
8172 while (is_a_char (c
= pa_stringer_aux (s
++)))
8179 /* Handle \x<num>. */
8182 unsigned int number
;
8187 /* Get past the 'x'. */
8189 for (num_digit
= 0, number
= 0, dg
= *s
;
8191 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
8192 || (dg
>= 'A' && dg
<= 'F'));
8196 number
= number
* 16 + dg
- '0';
8197 else if (dg
>= 'a' && dg
<= 'f')
8198 number
= number
* 16 + dg
- 'a' + 10;
8200 number
= number
* 16 + dg
- 'A' + 10;
8210 sprintf (num_buf
, "%02o", number
);
8213 sprintf (num_buf
, "%03o", number
);
8216 for (i
= 0; i
<= num_digit
; i
++)
8217 s_start
[i
] = num_buf
[i
];
8221 /* This might be a "\"", skip over the escaped char. */
8228 stringer (append_zero
);
8229 pa_undefine_label ();
8232 /* Handle a .VERSION pseudo-op. */
8236 int unused ATTRIBUTE_UNUSED
;
8239 pa_undefine_label ();
8244 /* Handle a .COMPILER pseudo-op. */
8247 pa_compiler (unused
)
8248 int unused ATTRIBUTE_UNUSED
;
8250 obj_som_compiler (0);
8251 pa_undefine_label ();
8256 /* Handle a .COPYRIGHT pseudo-op. */
8259 pa_copyright (unused
)
8260 int unused ATTRIBUTE_UNUSED
;
8263 pa_undefine_label ();
8266 /* Just like a normal cons, but when finished we have to undefine
8267 the latest space label. */
8274 pa_undefine_label ();
8277 /* Like float_cons, but we need to undefine our label. */
8280 pa_float_cons (float_type
)
8283 float_cons (float_type
);
8284 pa_undefine_label ();
8287 /* Like s_fill, but delete our label when finished. */
8291 int unused ATTRIBUTE_UNUSED
;
8294 /* We must have a valid space and subspace. */
8295 pa_check_current_space_and_subspace ();
8299 pa_undefine_label ();
8302 /* Like lcomm, but delete our label when finished. */
8305 pa_lcomm (needs_align
)
8309 /* We must have a valid space and subspace. */
8310 pa_check_current_space_and_subspace ();
8313 s_lcomm (needs_align
);
8314 pa_undefine_label ();
8317 /* Like lsym, but delete our label when finished. */
8321 int unused ATTRIBUTE_UNUSED
;
8324 /* We must have a valid space and subspace. */
8325 pa_check_current_space_and_subspace ();
8329 pa_undefine_label ();
8332 /* On the PA relocations which involve function symbols must not be
8333 adjusted. This so that the linker can know when/how to create argument
8334 relocation stubs for indirect calls and calls to static functions.
8336 "T" field selectors create DLT relative fixups for accessing
8337 globals and statics in PIC code; each DLT relative fixup creates
8338 an entry in the DLT table. The entries contain the address of
8339 the final target (eg accessing "foo" would create a DLT entry
8340 with the address of "foo").
8342 Unfortunately, the HP linker doesn't take into account any addend
8343 when generating the DLT; so accessing $LIT$+8 puts the address of
8344 $LIT$ into the DLT rather than the address of $LIT$+8.
8346 The end result is we can't perform relocation symbol reductions for
8347 any fixup which creates entries in the DLT (eg they use "T" field
8350 Reject reductions involving symbols with external scope; such
8351 reductions make life a living hell for object file editors.
8353 FIXME. Also reject R_HPPA relocations which are 32bits wide in
8354 the code space. The SOM BFD backend doesn't know how to pull the
8355 right bits out of an instruction. */
8358 hppa_fix_adjustable (fixp
)
8361 struct hppa_fix_struct
*hppa_fix
;
8363 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8366 /* Reject reductions of symbols in 32bit relocs. */
8367 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
8371 /* Reject reductions of symbols in sym1-sym2 expressions when
8372 the fixup will occur in a CODE subspace.
8374 XXX FIXME: Long term we probably want to reject all of these;
8375 for example reducing in the debug section would lose if we ever
8376 supported using the optimizing hp linker. */
8379 && (hppa_fix
->segment
->flags
& SEC_CODE
))
8381 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
8382 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
8386 /* We can't adjust any relocs that use LR% and RR% field selectors.
8388 If a symbol is reduced to a section symbol, the assembler will
8389 adjust the addend unless the symbol happens to reside right at
8390 the start of the section. Additionally, the linker has no choice
8391 but to manipulate the addends when coalescing input sections for
8392 "ld -r". Since an LR% field selector is defined to round the
8393 addend, we can't change the addend without risking that a LR% and
8394 it's corresponding (possible multiple) RR% field will no longer
8395 sum to the right value.
8398 . ldil LR%foo+0,%r21
8399 . ldw RR%foo+0(%r21),%r26
8400 . ldw RR%foo+4(%r21),%r25
8402 If foo is at address 4092 (decimal) in section `sect', then after
8403 reducing to the section symbol we get
8404 . LR%sect+4092 == (L%sect)+0
8405 . RR%sect+4092 == (R%sect)+4092
8406 . RR%sect+4096 == (R%sect)-4096
8407 and the last address loses because rounding the addend to 8k
8408 mutiples takes us up to 8192 with an offset of -4096.
8410 In cases where the LR% expression is identical to the RR% one we
8411 will never have a problem, but is so happens that gcc rounds
8412 addends involved in LR% field selectors to work around a HP
8413 linker bug. ie. We often have addresses like the last case
8414 above where the LR% expression is offset from the RR% one. */
8416 if (hppa_fix
->fx_r_field
== e_lrsel
8417 || hppa_fix
->fx_r_field
== e_rrsel
8418 || hppa_fix
->fx_r_field
== e_nlrsel
)
8421 /* Reject reductions of symbols in DLT relative relocs,
8422 relocations with plabels. */
8423 if (hppa_fix
->fx_r_field
== e_tsel
8424 || hppa_fix
->fx_r_field
== e_ltsel
8425 || hppa_fix
->fx_r_field
== e_rtsel
8426 || hppa_fix
->fx_r_field
== e_psel
8427 || hppa_fix
->fx_r_field
== e_rpsel
8428 || hppa_fix
->fx_r_field
== e_lpsel
)
8431 if (fixp
->fx_addsy
&& S_IS_EXTERNAL (fixp
->fx_addsy
))
8434 /* Reject absolute calls (jumps). */
8435 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
8438 /* Reject reductions of function symbols. */
8439 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
8445 /* Return nonzero if the fixup in FIXP will require a relocation,
8446 even it if appears that the fixup could be completely handled
8450 hppa_force_relocation (fixp
)
8453 struct hppa_fix_struct
*hppa_fixp
;
8456 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8458 if (fixp
->fx_r_type
== (int) R_HPPA_ENTRY
8459 || fixp
->fx_r_type
== (int) R_HPPA_EXIT
8460 || fixp
->fx_r_type
== (int) R_HPPA_BEGIN_BRTAB
8461 || fixp
->fx_r_type
== (int) R_HPPA_END_BRTAB
8462 || fixp
->fx_r_type
== (int) R_HPPA_BEGIN_TRY
8463 || fixp
->fx_r_type
== (int) R_HPPA_END_TRY
8464 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
8465 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
8469 /* It is necessary to force PC-relative calls/jumps to have a relocation
8470 entry if they're going to need either a argument relocation or long
8471 call stub. FIXME. Can't we need the same for absolute calls? */
8472 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
8473 && (arg_reloc_stub_needed (symbol_arg_reloc_info (fixp
->fx_addsy
),
8474 hppa_fixp
->fx_arg_reloc
)))
8477 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
8478 - md_pcrel_from (fixp
));
8479 /* Now check and see if we're going to need a long-branch stub. */
8480 if (fixp
->fx_r_type
== (int) R_HPPA_PCREL_CALL
8481 && (distance
> 262143 || distance
< -262144))
8484 if (fixp
->fx_r_type
== (int) R_HPPA_ABS_CALL
)
8487 /* No need (yet) to force another relocations to be emitted. */
8491 /* Now for some ELF specific code. FIXME. */
8493 /* Mark the end of a function so that it's possible to compute
8494 the size of the function in hppa_elf_final_processing. */
8497 hppa_elf_mark_end_of_function ()
8499 /* ELF does not have EXIT relocations. All we do is create a
8500 temporary symbol marking the end of the function. */
8503 if (last_call_info
== NULL
|| last_call_info
->start_symbol
== NULL
)
8505 /* We have already warned about a missing label,
8506 or other problems. */
8510 name
= (char *) xmalloc (strlen ("L$\001end_")
8511 + strlen (S_GET_NAME (last_call_info
->start_symbol
))
8517 strcpy (name
, "L$\001end_");
8518 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
8520 /* If we have a .exit followed by a .procend, then the
8521 symbol will have already been defined. */
8522 symbolP
= symbol_find (name
);
8525 /* The symbol has already been defined! This can
8526 happen if we have a .exit followed by a .procend.
8528 This is *not* an error. All we want to do is free
8529 the memory we just allocated for the name and continue. */
8534 /* symbol value should be the offset of the
8535 last instruction of the function */
8536 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
8540 S_CLEAR_EXTERNAL (symbolP
);
8541 symbol_table_insert (symbolP
);
8545 last_call_info
->end_symbol
= symbolP
;
8547 as_bad (_("Symbol '%s' could not be created."), name
);
8551 as_bad (_("No memory for symbol name."));
8555 /* For ELF, this function serves one purpose: to setup the st_size
8556 field of STT_FUNC symbols. To do this, we need to scan the
8557 call_info structure list, determining st_size in by taking the
8558 difference in the address of the beginning/end marker symbols. */
8561 elf_hppa_final_processing ()
8563 struct call_info
*call_info_pointer
;
8565 for (call_info_pointer
= call_info_root
;
8567 call_info_pointer
= call_info_pointer
->ci_next
)
8569 elf_symbol_type
*esym
8570 = ((elf_symbol_type
*)
8571 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
8572 esym
->internal_elf_sym
.st_size
=
8573 S_GET_VALUE (call_info_pointer
->end_symbol
)
8574 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;
8581 if (debug_type
== DEBUG_DWARF2
)