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
*));
582 static void pa_vtable_entry
PARAMS ((int));
583 static void pa_vtable_inherit
PARAMS ((int));
586 /* File and gloally scoped variable declarations. */
589 /* Root and final entry in the space chain. */
590 static sd_chain_struct
*space_dict_root
;
591 static sd_chain_struct
*space_dict_last
;
593 /* The current space and subspace. */
594 static sd_chain_struct
*current_space
;
595 static ssd_chain_struct
*current_subspace
;
598 /* Root of the call_info chain. */
599 static struct call_info
*call_info_root
;
601 /* The last call_info (for functions) structure
602 seen so it can be associated with fixups and
604 static struct call_info
*last_call_info
;
606 /* The last call description (for actual calls). */
607 static struct call_desc last_call_desc
;
609 /* handle of the OPCODE hash table */
610 static struct hash_control
*op_hash
= NULL
;
612 /* Table of pseudo ops for the PA. FIXME -- how many of these
613 are now redundant with the overall GAS and the object file
615 const pseudo_typeS md_pseudo_table
[] =
617 /* align pseudo-ops on the PA specify the actual alignment requested,
618 not the log2 of the requested alignment. */
620 {"align", pa_align
, 8},
623 {"align", s_align_bytes
, 8},
625 {"begin_brtab", pa_brtab
, 1},
626 {"begin_try", pa_try
, 1},
627 {"block", pa_block
, 1},
628 {"blockz", pa_block
, 0},
629 {"byte", pa_cons
, 1},
630 {"call", pa_call
, 0},
631 {"callinfo", pa_callinfo
, 0},
632 #if defined (OBJ_ELF) && defined (TE_LINUX)
633 {"code", obj_elf_text
, 0},
635 {"code", pa_text
, 0},
636 {"comm", pa_comm
, 0},
639 {"compiler", pa_compiler
, 0},
641 {"copyright", pa_copyright
, 0},
642 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
643 {"data", pa_data
, 0},
645 {"double", pa_float_cons
, 'd'},
646 {"dword", pa_cons
, 8},
648 {"end_brtab", pa_brtab
, 0},
649 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
650 {"end_try", pa_try
, 0},
652 {"enter", pa_enter
, 0},
653 {"entry", pa_entry
, 0},
655 {"exit", pa_exit
, 0},
656 {"export", pa_export
, 0},
658 {"file", dwarf2_directive_file
, 0 },
660 {"fill", pa_fill
, 0},
661 {"float", pa_float_cons
, 'f'},
662 {"half", pa_cons
, 2},
663 {"import", pa_import
, 0},
665 {"label", pa_label
, 0},
666 {"lcomm", pa_lcomm
, 0},
667 {"leave", pa_leave
, 0},
668 {"level", pa_level
, 0},
670 {"loc", dwarf2_directive_loc
, 0 },
672 {"long", pa_cons
, 4},
673 {"lsym", pa_lsym
, 0},
675 {"nsubspa", pa_subspace
, 1},
677 {"octa", pa_cons
, 16},
678 {"org", pa_origin
, 0},
679 {"origin", pa_origin
, 0},
680 {"param", pa_param
, 0},
681 {"proc", pa_proc
, 0},
682 {"procend", pa_procend
, 0},
683 {"quad", pa_cons
, 8},
685 {"short", pa_cons
, 2},
686 {"single", pa_float_cons
, 'f'},
688 {"space", pa_space
, 0},
689 {"spnum", pa_spnum
, 0},
691 {"string", pa_stringer
, 0},
692 {"stringz", pa_stringer
, 1},
694 {"subspa", pa_subspace
, 0},
696 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
697 {"text", pa_text
, 0},
699 {"version", pa_version
, 0},
701 {"vtable_entry", pa_vtable_entry
, 0},
702 {"vtable_inherit", pa_vtable_inherit
, 0},
704 {"word", pa_cons
, 4},
708 /* This array holds the chars that only start a comment at the beginning of
709 a line. If the line seems to have the form '# 123 filename'
710 .line and .file directives will appear in the pre-processed output.
712 Note that input_file.c hand checks for '#' at the beginning of the
713 first line of the input file. This is because the compiler outputs
714 #NO_APP at the beginning of its output.
716 Also note that C style comments will always work. */
717 const char line_comment_chars
[] = "#";
719 /* This array holds the chars that always start a comment. If the
720 pre-processor is disabled, these aren't very useful. */
721 const char comment_chars
[] = ";";
723 /* This array holds the characters which act as line separators. */
724 const char line_separator_chars
[] = "!";
726 /* Chars that can be used to separate mant from exp in floating point nums. */
727 const char EXP_CHARS
[] = "eE";
729 /* Chars that mean this number is a floating point constant.
730 As in 0f12.456 or 0d1.2345e12.
732 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
733 changed in read.c. Ideally it shouldn't hae to know abou it at
734 all, but nothing is ideal around here. */
735 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
737 static struct pa_it the_insn
;
739 /* Points to the end of an expression just parsed by get_expressoin
740 and friends. FIXME. This shouldn't be handled with a file-global
742 static char *expr_end
;
744 /* Nonzero if a .callinfo appeared within the current procedure. */
745 static int callinfo_found
;
747 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
748 static int within_entry_exit
;
750 /* Nonzero if the assembler is currently within a procedure definition. */
751 static int within_procedure
;
753 /* Handle on structure which keep track of the last symbol
754 seen in each subspace. */
755 static label_symbol_struct
*label_symbols_rootp
= NULL
;
757 /* Holds the last field selector. */
758 static int hppa_field_selector
;
760 /* Nonzero when strict syntax checking is enabled. Zero otherwise.
762 Each opcode in the table has a flag which indicates whether or not
763 strict syntax checking should be enabled for that instruction. */
764 static int strict
= 0;
767 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
768 static symbolS
*dummy_symbol
;
771 /* Nonzero if errors are to be printed. */
772 static int print_errors
= 1;
774 /* List of registers that are pre-defined:
776 Each general register has one predefined name of the form
777 %r<REGNUM> which has the value <REGNUM>.
779 Space and control registers are handled in a similar manner,
780 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
782 Likewise for the floating point registers, but of the form
783 %fr<REGNUM>. Floating point registers have additional predefined
784 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
785 again have the value <REGNUM>.
787 Many registers also have synonyms:
789 %r26 - %r23 have %arg0 - %arg3 as synonyms
790 %r28 - %r29 have %ret0 - %ret1 as synonyms
791 %r30 has %sp as a synonym
792 %r27 has %dp as a synonym
793 %r2 has %rp as a synonym
795 Almost every control register has a synonym; they are not listed
798 The table is sorted. Suitable for searching by a binary search. */
800 static const struct pd_reg pre_defined_registers
[] =
1000 /* This table is sorted by order of the length of the string. This is
1001 so we check for <> before we check for <. If we had a <> and checked
1002 for < first, we would get a false match. */
1003 static const struct fp_cond_map fp_cond_map
[] =
1039 static const struct selector_entry selector_table
[] =
1064 /* default space and subspace dictionaries */
1066 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1067 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1069 /* pre-defined subsegments (subspaces) for the HPPA. */
1070 #define SUBSEG_CODE 0
1071 #define SUBSEG_LIT 1
1072 #define SUBSEG_MILLI 2
1073 #define SUBSEG_DATA 0
1074 #define SUBSEG_BSS 2
1075 #define SUBSEG_UNWIND 3
1076 #define SUBSEG_GDB_STRINGS 0
1077 #define SUBSEG_GDB_SYMBOLS 1
1079 static struct default_subspace_dict pa_def_subspaces
[] =
1081 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE
},
1082 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA
},
1083 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT
},
1084 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI
},
1085 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS
},
1086 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1089 static struct default_space_dict pa_def_spaces
[] =
1091 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
},
1092 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
},
1093 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
}
1096 /* Misc local definitions used by the assembler. */
1098 /* These macros are used to maintain spaces/subspaces. */
1099 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1100 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1101 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1102 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1104 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1105 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1108 /* Return nonzero if the string pointed to by S potentially represents
1109 a right or left half of a FP register */
1110 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1111 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1113 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1114 main loop after insertion. */
1116 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1118 ((OPCODE) |= (FIELD) << (START)); \
1122 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1123 IGNORE is used to suppress the error message. */
1125 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1127 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1130 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1136 /* Simple alignment checking for FIELD againt ALIGN (a power of two).
1137 IGNORE is used to suppress the error message. */
1139 #define CHECK_ALIGN(FIELD, ALIGN, IGNORE) \
1141 if ((FIELD) & ((ALIGN) - 1)) \
1144 as_bad (_("Field not properly aligned [%d] (%d)."), (ALIGN), \
1150 #define is_DP_relative(exp) \
1151 ((exp).X_op == O_subtract \
1152 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1154 #define is_PC_relative(exp) \
1155 ((exp).X_op == O_subtract \
1156 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1158 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1159 always be able to reduce the expression to a constant, so we don't
1160 need real complex handling yet. */
1161 #define is_complex(exp) \
1162 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1164 /* Actual functions to implement the PA specific code for the assembler. */
1166 /* Called before writing the object file. Make sure entry/exit and
1167 proc/procend pairs match. */
1172 if (within_entry_exit
)
1173 as_fatal (_("Missing .exit\n"));
1175 if (within_procedure
)
1176 as_fatal (_("Missing .procend\n"));
1179 /* Returns a pointer to the label_symbol_struct for the current space.
1180 or NULL if no label_symbol_struct exists for the current space. */
1182 static label_symbol_struct
*
1185 label_symbol_struct
*label_chain
;
1187 for (label_chain
= label_symbols_rootp
;
1189 label_chain
= label_chain
->lss_next
)
1192 if (current_space
== label_chain
->lss_space
&& label_chain
->lss_label
)
1196 if (now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
)
1204 /* Defines a label for the current space. If one is already defined,
1205 this function will replace it with the new label. */
1208 pa_define_label (symbol
)
1211 label_symbol_struct
*label_chain
= pa_get_label ();
1214 label_chain
->lss_label
= symbol
;
1217 /* Create a new label entry and add it to the head of the chain. */
1219 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1220 label_chain
->lss_label
= symbol
;
1222 label_chain
->lss_space
= current_space
;
1225 label_chain
->lss_segment
= now_seg
;
1227 label_chain
->lss_next
= NULL
;
1229 if (label_symbols_rootp
)
1230 label_chain
->lss_next
= label_symbols_rootp
;
1232 label_symbols_rootp
= label_chain
;
1236 /* Removes a label definition for the current space.
1237 If there is no label_symbol_struct entry, then no action is taken. */
1240 pa_undefine_label ()
1242 label_symbol_struct
*label_chain
;
1243 label_symbol_struct
*prev_label_chain
= NULL
;
1245 for (label_chain
= label_symbols_rootp
;
1247 label_chain
= label_chain
->lss_next
)
1251 && current_space
== label_chain
->lss_space
&& label_chain
->lss_label
1254 && now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
1258 /* Remove the label from the chain and free its memory. */
1259 if (prev_label_chain
)
1260 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1262 label_symbols_rootp
= label_chain
->lss_next
;
1267 prev_label_chain
= label_chain
;
1272 /* An HPPA-specific version of fix_new. This is required because the HPPA
1273 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1274 results in the creation of an instance of an hppa_fix_struct. An
1275 hppa_fix_struct stores the extra information along with a pointer to the
1276 original fixS. This is attached to the original fixup via the
1277 tc_fix_data field. */
1280 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1281 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1285 symbolS
*add_symbol
;
1289 bfd_reloc_code_real_type r_type
;
1290 enum hppa_reloc_field_selector_type_alt r_field
;
1292 unsigned int arg_reloc
;
1293 int* unwind_bits ATTRIBUTE_UNUSED
;
1297 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1298 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1301 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1303 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1304 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1305 hppa_fix
->fx_r_type
= r_type
;
1306 hppa_fix
->fx_r_field
= r_field
;
1307 hppa_fix
->fx_r_format
= r_format
;
1308 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1309 hppa_fix
->segment
= now_seg
;
1311 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1312 new_fix
->fx_offset
= *unwind_bits
;
1315 /* foo-$global$ is used to access non-automatic storage. $global$
1316 is really just a marker and has served its purpose, so eliminate
1317 it now so as not to confuse write.c. Ditto for $PIC_pcrel$0. */
1318 if (new_fix
->fx_subsy
1319 && (strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$") == 0
1320 || strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$PIC_pcrel$0") == 0))
1321 new_fix
->fx_subsy
= NULL
;
1324 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1325 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1328 parse_cons_expression_hppa (exp
)
1331 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1335 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1336 hppa_field_selector is set by the parse_cons_expression_hppa. */
1339 cons_fix_new_hppa (frag
, where
, size
, exp
)
1345 unsigned int rel_type
;
1347 /* Get a base relocation type. */
1348 if (is_DP_relative (*exp
))
1349 rel_type
= R_HPPA_GOTOFF
;
1350 else if (is_complex (*exp
))
1351 rel_type
= R_HPPA_COMPLEX
;
1355 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1357 as_warn (_("Invalid field selector. Assuming F%%."));
1358 hppa_field_selector
= e_fsel
;
1361 fix_new_hppa (frag
, where
, size
,
1362 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1363 hppa_field_selector
, size
* 8, 0, NULL
);
1365 /* Reset field selector to its default state. */
1366 hppa_field_selector
= 0;
1369 /* This function is called once, at assembler startup time. It should
1370 set up all the tables, etc. that the MD part of the assembler will need. */
1375 const char *retval
= NULL
;
1379 last_call_info
= NULL
;
1380 call_info_root
= NULL
;
1382 /* Set the default machine type. */
1383 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1384 as_warn (_("could not set architecture and machine"));
1386 /* Folding of text and data segments fails miserably on the PA.
1387 Warn user and disable "-R" option. */
1388 if (flag_readonly_data_in_text
)
1390 as_warn (_("-R option not supported on this target."));
1391 flag_readonly_data_in_text
= 0;
1398 op_hash
= hash_new ();
1400 while (i
< NUMOPCODES
)
1402 const char *name
= pa_opcodes
[i
].name
;
1403 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1404 if (retval
!= NULL
&& *retval
!= '\0')
1406 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1411 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1412 != pa_opcodes
[i
].match
)
1414 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1415 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1420 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1424 as_fatal (_("Broken assembler. No assembly attempted."));
1427 /* SOM will change text_section. To make sure we never put
1428 anything into the old one switch to the new one now. */
1429 subseg_set (text_section
, 0);
1433 dummy_symbol
= symbol_find_or_make ("L$dummy");
1434 S_SET_SEGMENT (dummy_symbol
, text_section
);
1435 /* Force the symbol to be converted to a real symbol. */
1436 (void) symbol_get_bfdsym (dummy_symbol
);
1440 /* Assemble a single instruction storing it into a frag. */
1447 /* The had better be something to assemble. */
1450 /* If we are within a procedure definition, make sure we've
1451 defined a label for the procedure; handle case where the
1452 label was defined after the .PROC directive.
1454 Note there's not need to diddle with the segment or fragment
1455 for the label symbol in this case. We have already switched
1456 into the new $CODE$ subspace at this point. */
1457 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1459 label_symbol_struct
*label_symbol
= pa_get_label ();
1463 if (label_symbol
->lss_label
)
1465 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1466 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1469 /* Also handle allocation of a fixup to hold the unwind
1470 information when the label appears after the proc/procend. */
1471 if (within_entry_exit
)
1473 char *where
= frag_more (0);
1475 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1476 NULL
, (offsetT
) 0, NULL
,
1477 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1478 (int *)&last_call_info
->ci_unwind
.descriptor
);
1483 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1486 as_bad (_("Missing function name for .PROC"));
1489 /* Assemble the instruction. Results are saved into "the_insn". */
1492 /* Get somewhere to put the assembled instrution. */
1495 /* Output the opcode. */
1496 md_number_to_chars (to
, the_insn
.opcode
, 4);
1498 /* If necessary output more stuff. */
1499 if (the_insn
.reloc
!= R_HPPA_NONE
)
1500 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1501 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1502 the_insn
.reloc
, the_insn
.field_selector
,
1503 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1506 if (debug_type
== DEBUG_DWARF2
)
1510 /* First update the notion of the current source line. */
1511 dwarf2_where (&debug_line
);
1513 /* We want the offset of the start of this instruction within the
1514 the current frag. */
1515 addr
= frag_now
->fr_address
+ frag_now_fix () - 4;
1517 /* And record the information. */
1518 dwarf2_gen_line_info (addr
, &debug_line
);
1523 /* Do the real work for assembling a single instruction. Store results
1524 into the global "the_insn" variable. */
1530 char *error_message
= "";
1531 char *s
, c
, *argstart
, *name
, *save_s
;
1535 int cmpltr
, nullif
, flag
, cond
, num
;
1536 unsigned long opcode
;
1537 struct pa_opcode
*insn
;
1540 /* We must have a valid space and subspace. */
1541 pa_check_current_space_and_subspace ();
1544 /* Convert everything up to the first whitespace character into lower
1546 for (s
= str
; *s
!= ' ' && *s
!= '\t' && *s
!= '\n' && *s
!= '\0'; s
++)
1550 /* Skip to something interesting. */
1551 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1570 as_fatal (_("Unknown opcode: `%s'"), str
);
1575 /* Look up the opcode in the has table. */
1576 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1578 as_bad ("Unknown opcode: `%s'", str
);
1587 /* Mark the location where arguments for the instruction start, then
1588 start processing them. */
1592 /* Do some initialization. */
1593 opcode
= insn
->match
;
1594 strict
= (insn
->flags
& FLAG_STRICT
);
1595 memset (&the_insn
, 0, sizeof (the_insn
));
1597 the_insn
.reloc
= R_HPPA_NONE
;
1599 /* If this instruction is specific to a particular architecture,
1600 then set a new architecture. */
1601 /* But do not automatically promote to pa2.0. The automatic promotion
1602 crud is for compatability with HP's old assemblers only. */
1604 && bfd_get_mach (stdoutput
) < insn
->arch
)
1606 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1607 as_warn (_("could not update architecture and machine"));
1609 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1615 /* Build the opcode, checking as we go to make
1616 sure that the operands match. */
1617 for (args
= insn
->args
;; ++args
)
1619 /* Absorb white space in instruction. */
1620 while (*s
== ' ' || *s
== '\t')
1626 /* End of arguments. */
1642 /* These must match exactly. */
1651 /* Handle a 5 bit register or control register field at 10. */
1654 /* This should be more strict. Small steps. */
1655 if (strict
&& *s
!= '%')
1657 num
= pa_parse_number (&s
, 0);
1658 CHECK_FIELD (num
, 31, 0, 0);
1659 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1661 /* Handle %sar or %cr11. No bits get set, we just verify that it
1664 /* Skip whitespace before register. */
1665 while (*s
== ' ' || *s
== '\t')
1668 if (!strncasecmp(s
, "%sar", 4))
1673 else if (!strncasecmp(s
, "%cr11", 5))
1680 /* Handle a 5 bit register field at 15. */
1682 /* This should be more strict. Small steps. */
1683 if (strict
&& *s
!= '%')
1685 num
= pa_parse_number (&s
, 0);
1686 CHECK_FIELD (num
, 31, 0, 0);
1687 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1689 /* Handle a 5 bit register field at 31. */
1691 /* This should be more strict. Small steps. */
1692 if (strict
&& *s
!= '%')
1694 num
= pa_parse_number (&s
, 0);
1695 CHECK_FIELD (num
, 31, 0, 0);
1696 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1698 /* Handle a 5 bit register field at 10 and 15. */
1700 /* This should be more strict. Small steps. */
1701 if (strict
&& *s
!= '%')
1703 num
= pa_parse_number (&s
, 0);
1704 CHECK_FIELD (num
, 31, 0, 0);
1705 opcode
|= num
<< 16;
1706 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1708 /* Handle a 5 bit field length at 31. */
1710 num
= pa_get_absolute_expression (&the_insn
, &s
);
1711 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1714 CHECK_FIELD (num
, 32, 1, 0);
1715 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1717 /* Handle a 5 bit immediate at 15. */
1719 num
= pa_get_absolute_expression (&the_insn
, &s
);
1720 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1723 /* When in strict mode, we want to just reject this
1724 match instead of giving an out of range error. */
1725 CHECK_FIELD (num
, 15, -16, strict
);
1726 num
= low_sign_unext (num
, 5);
1727 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1729 /* Handle a 5 bit immediate at 31. */
1731 num
= pa_get_absolute_expression (&the_insn
, &s
);
1732 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1735 /* When in strict mode, we want to just reject this
1736 match instead of giving an out of range error. */
1737 CHECK_FIELD (num
, 15, -16, strict
);
1738 num
= low_sign_unext (num
, 5);
1739 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1741 /* Handle an unsigned 5 bit immediate at 31. */
1743 num
= pa_get_absolute_expression (&the_insn
, &s
);
1744 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1747 CHECK_FIELD (num
, 31, 0, strict
);
1748 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1750 /* Handle an unsigned 5 bit immediate at 15. */
1752 num
= pa_get_absolute_expression (&the_insn
, &s
);
1753 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1756 CHECK_FIELD (num
, 31, 0, strict
);
1757 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1759 /* Handle an unsigned 10 bit immediate at 15. */
1761 num
= pa_get_absolute_expression (&the_insn
, &s
);
1762 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1765 CHECK_FIELD (num
, 1023, 0, strict
);
1766 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1768 /* Handle a 2 bit space identifier at 17. */
1770 /* This should be more strict. Small steps. */
1771 if (strict
&& *s
!= '%')
1773 num
= pa_parse_number (&s
, 0);
1774 CHECK_FIELD (num
, 3, 0, 1);
1775 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1777 /* Handle a 3 bit space identifier at 18. */
1779 /* This should be more strict. Small steps. */
1780 if (strict
&& *s
!= '%')
1782 num
= pa_parse_number (&s
, 0);
1783 CHECK_FIELD (num
, 7, 0, 1);
1784 opcode
|= re_assemble_3 (num
);
1787 /* Handle all completers. */
1792 /* Handle a completer for an indexing load or store. */
1798 while (*s
== ',' && i
< 2)
1801 if (strncasecmp (s
, "sm", 2) == 0)
1808 else if (strncasecmp (s
, "m", 1) == 0)
1810 else if ((strncasecmp (s
, "s ", 2) == 0)
1811 || (strncasecmp (s
, "s,", 2) == 0))
1813 /* When in strict mode this is a match failure. */
1820 as_bad (_("Invalid Indexed Load Completer."));
1825 as_bad (_("Invalid Indexed Load Completer Syntax."));
1827 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1830 /* Handle a short load/store completer. */
1842 if (strncasecmp (s
, "ma", 2) == 0)
1848 else if (strncasecmp (s
, "mb", 2) == 0)
1855 /* When in strict mode, pass through for cache op. */
1856 if (!found
&& strict
)
1861 as_bad (_("Invalid Short Load/Store Completer."));
1865 /* If we did not get a ma/mb completer, then we do not
1866 consider this a positive match for 'ce'. */
1867 else if (*args
== 'e')
1870 /* 'J', 'm' and 'q' are the same, except for where they
1871 encode the before/after field. */
1875 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1877 else if (*args
== 'q')
1880 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1882 else if (*args
== 'J')
1884 /* M bit is explicit in the major opcode. */
1885 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1887 else if (*args
== 'e')
1889 /* Gross! Hide these values in the immediate field
1890 of the instruction, then pull them out later. */
1897 /* Handle a stbys completer. */
1903 while (*s
== ',' && i
< 2)
1906 if (strncasecmp (s
, "m", 1) == 0)
1908 else if ((strncasecmp (s
, "b ", 2) == 0)
1909 || (strncasecmp (s
, "b,", 2) == 0))
1911 else if (strncasecmp (s
, "e", 1) == 0)
1913 /* When in strict mode this is a match failure. */
1920 as_bad (_("Invalid Store Bytes Short Completer"));
1925 as_bad (_("Invalid Store Bytes Short Completer"));
1927 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1930 /* Handle load cache hint completer. */
1933 if (!strncmp(s
, ",sl", 3))
1938 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1940 /* Handle store cache hint completer. */
1943 if (!strncmp(s
, ",sl", 3))
1948 else if (!strncmp(s
, ",bc", 3))
1953 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1955 /* Handle load and clear cache hint completer. */
1958 if (!strncmp(s
, ",co", 3))
1963 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1965 /* Handle load ordering completer. */
1967 if (strncmp(s
, ",o", 2) != 0)
1972 /* Handle a branch gate completer. */
1974 if (strncasecmp (s
, ",gate", 5) != 0)
1979 /* Handle a branch link and push completer. */
1981 if (strncasecmp (s
, ",l,push", 7) != 0)
1986 /* Handle a branch link completer. */
1988 if (strncasecmp (s
, ",l", 2) != 0)
1993 /* Handle a branch pop completer. */
1995 if (strncasecmp (s
, ",pop", 4) != 0)
2000 /* Handle a local processor completer. */
2002 if (strncasecmp (s
, ",l", 2) != 0)
2007 /* Handle a PROBE read/write completer. */
2010 if (!strncasecmp (s
, ",w", 2))
2015 else if (!strncasecmp (s
, ",r", 2))
2021 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2023 /* Handle MFCTL wide completer. */
2025 if (strncasecmp (s
, ",w", 2) != 0)
2030 /* Handle an RFI restore completer. */
2033 if (!strncasecmp (s
, ",r", 2))
2039 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2041 /* Handle a system control completer. */
2043 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2051 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2053 /* Handle intermediate/final completer for DCOR. */
2056 if (!strncasecmp (s
, ",i", 2))
2062 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2064 /* Handle zero/sign extension completer. */
2067 if (!strncasecmp (s
, ",z", 2))
2073 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2075 /* Handle add completer. */
2078 if (!strncasecmp (s
, ",l", 2))
2083 else if (!strncasecmp (s
, ",tsv", 4))
2089 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2091 /* Handle 64 bit carry for ADD. */
2094 if (!strncasecmp (s
, ",dc,tsv", 7) ||
2095 !strncasecmp (s
, ",tsv,dc", 7))
2100 else if (!strncasecmp (s
, ",dc", 3))
2108 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2110 /* Handle 32 bit carry for ADD. */
2113 if (!strncasecmp (s
, ",c,tsv", 6) ||
2114 !strncasecmp (s
, ",tsv,c", 6))
2119 else if (!strncasecmp (s
, ",c", 2))
2127 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2129 /* Handle trap on signed overflow. */
2132 if (!strncasecmp (s
, ",tsv", 4))
2138 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2140 /* Handle trap on condition and overflow. */
2143 if (!strncasecmp (s
, ",tc,tsv", 7) ||
2144 !strncasecmp (s
, ",tsv,tc", 7))
2149 else if (!strncasecmp (s
, ",tc", 3))
2157 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2159 /* Handle 64 bit borrow for SUB. */
2162 if (!strncasecmp (s
, ",db,tsv", 7) ||
2163 !strncasecmp (s
, ",tsv,db", 7))
2168 else if (!strncasecmp (s
, ",db", 3))
2176 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2178 /* Handle 32 bit borrow for SUB. */
2181 if (!strncasecmp (s
, ",b,tsv", 6) ||
2182 !strncasecmp (s
, ",tsv,b", 6))
2187 else if (!strncasecmp (s
, ",b", 2))
2195 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2197 /* Handle trap condition completer for UADDCM. */
2200 if (!strncasecmp (s
, ",tc", 3))
2206 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2208 /* Handle signed/unsigned at 21. */
2212 if (strncasecmp (s
, ",s", 2) == 0)
2217 else if (strncasecmp (s
, ",u", 2) == 0)
2223 INSERT_FIELD_AND_CONTINUE (opcode
, sign
, 10);
2226 /* Handle left/right combination at 17:18. */
2236 as_bad(_("Invalid left/right combination completer"));
2239 INSERT_FIELD_AND_CONTINUE (opcode
, lr
, 13);
2242 as_bad(_("Invalid left/right combination completer"));
2245 /* Handle saturation at 24:25. */
2249 if (strncasecmp (s
, ",ss", 3) == 0)
2254 else if (strncasecmp (s
, ",us", 3) == 0)
2260 INSERT_FIELD_AND_CONTINUE (opcode
, sat
, 6);
2263 /* Handle permutation completer. */
2291 as_bad(_("Invalid permutation completer"));
2293 opcode
|= perm
<< permloc
[i
];
2298 as_bad(_("Invalid permutation completer"));
2306 /* Handle all conditions. */
2312 /* Handle FP compare conditions. */
2314 cond
= pa_parse_fp_cmp_cond (&s
);
2315 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2317 /* Handle an add condition. */
2326 /* 64 bit conditions. */
2339 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2343 if (strcmp (name
, "=") == 0)
2345 else if (strcmp (name
, "<") == 0)
2347 else if (strcmp (name
, "<=") == 0)
2349 else if (strcasecmp (name
, "nuv") == 0)
2351 else if (strcasecmp (name
, "znv") == 0)
2353 else if (strcasecmp (name
, "sv") == 0)
2355 else if (strcasecmp (name
, "od") == 0)
2357 else if (strcasecmp (name
, "tr") == 0)
2362 else if (strcmp (name
, "<>") == 0)
2367 else if (strcmp (name
, ">=") == 0)
2372 else if (strcmp (name
, ">") == 0)
2377 else if (strcasecmp (name
, "uv") == 0)
2382 else if (strcasecmp (name
, "vnz") == 0)
2387 else if (strcasecmp (name
, "nsv") == 0)
2392 else if (strcasecmp (name
, "ev") == 0)
2397 /* ",*" is a valid condition. */
2398 else if (*args
== 'a')
2399 as_bad (_("Invalid Add Condition: %s"), name
);
2402 opcode
|= cmpltr
<< 13;
2403 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2405 /* Handle non-negated add and branch condition. */
2407 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2410 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2413 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2415 /* Handle 64 bit wide-mode add and branch condition. */
2417 cmpltr
= pa_parse_addb_64_cmpltr (&s
);
2420 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2425 /* Negated condition requires an opcode change. */
2426 opcode
|= (cmpltr
& 8) << 24;
2428 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2430 /* Handle a negated or non-negated add and branch
2434 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2438 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
2441 as_bad (_("Invalid Compare/Subtract Condition"));
2446 /* Negated condition requires an opcode change. */
2450 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2452 /* Handle branch on bit conditions. */
2470 if (strncmp (s
, "<", 1) == 0)
2475 else if (strncmp (s
, ">=", 2) == 0)
2481 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2483 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2485 /* Handle a compare/subtract condition. */
2494 /* 64 bit conditions. */
2507 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2511 if (strcmp (name
, "=") == 0)
2513 else if (strcmp (name
, "<") == 0)
2515 else if (strcmp (name
, "<=") == 0)
2517 else if (strcasecmp (name
, "<<") == 0)
2519 else if (strcasecmp (name
, "<<=") == 0)
2521 else if (strcasecmp (name
, "sv") == 0)
2523 else if (strcasecmp (name
, "od") == 0)
2525 else if (strcasecmp (name
, "tr") == 0)
2530 else if (strcmp (name
, "<>") == 0)
2535 else if (strcmp (name
, ">=") == 0)
2540 else if (strcmp (name
, ">") == 0)
2545 else if (strcasecmp (name
, ">>=") == 0)
2550 else if (strcasecmp (name
, ">>") == 0)
2555 else if (strcasecmp (name
, "nsv") == 0)
2560 else if (strcasecmp (name
, "ev") == 0)
2565 /* ",*" is a valid condition. */
2566 else if (*args
!= 'S')
2567 as_bad (_("Invalid Compare/Subtract Condition: %s"),
2571 opcode
|= cmpltr
<< 13;
2572 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2574 /* Handle a non-negated compare condition. */
2576 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2579 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
2582 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2584 /* Handle a 32 bit compare and branch condition. */
2587 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2591 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
2594 as_bad (_("Invalid Compare and Branch Condition."));
2599 /* Negated condition requires an opcode change. */
2604 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2606 /* Handle a 64 bit compare and branch condition. */
2608 cmpltr
= pa_parse_cmpb_64_cmpltr (&s
);
2611 /* Negated condition requires an opcode change. */
2612 opcode
|= (cmpltr
& 8) << 26;
2615 /* Not a 64 bit cond. Give 32 bit a chance. */
2618 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2620 /* Handle a 64 bit cmpib condition. */
2622 cmpltr
= pa_parse_cmpib_64_cmpltr (&s
);
2624 /* Not a 64 bit cond. Give 32 bit a chance. */
2627 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2629 /* Handle a logical instruction condition. */
2638 /* 64 bit conditions. */
2650 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2655 if (strcmp (name
, "=") == 0)
2657 else if (strcmp (name
, "<") == 0)
2659 else if (strcmp (name
, "<=") == 0)
2661 else if (strcasecmp (name
, "od") == 0)
2663 else if (strcasecmp (name
, "tr") == 0)
2668 else if (strcmp (name
, "<>") == 0)
2673 else if (strcmp (name
, ">=") == 0)
2678 else if (strcmp (name
, ">") == 0)
2683 else if (strcasecmp (name
, "ev") == 0)
2688 /* ",*" is a valid condition. */
2689 else if (*args
!= 'L')
2690 as_bad (_("Invalid Logical Instruction Condition."));
2693 opcode
|= cmpltr
<< 13;
2694 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2696 /* Handle a shift/extract/deposit condition. */
2705 /* 64 bit conditions. */
2717 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2721 if (strcmp (name
, "=") == 0)
2723 else if (strcmp (name
, "<") == 0)
2725 else if (strcasecmp (name
, "od") == 0)
2727 else if (strcasecmp (name
, "tr") == 0)
2729 else if (strcmp (name
, "<>") == 0)
2731 else if (strcmp (name
, ">=") == 0)
2733 else if (strcasecmp (name
, "ev") == 0)
2735 /* Handle movb,n. Put things back the way they were.
2736 This includes moving s back to where it started. */
2737 else if (strcasecmp (name
, "n") == 0 && *args
== 'y')
2743 /* ",*" is a valid condition. */
2744 else if (*args
!= 'X')
2745 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2748 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2750 /* Handle a unit instruction condition. */
2759 /* 64 bit conditions. */
2770 if (strncasecmp (s
, "sbz", 3) == 0)
2775 else if (strncasecmp (s
, "shz", 3) == 0)
2780 else if (strncasecmp (s
, "sdc", 3) == 0)
2785 else if (strncasecmp (s
, "sbc", 3) == 0)
2790 else if (strncasecmp (s
, "shc", 3) == 0)
2795 else if (strncasecmp (s
, "tr", 2) == 0)
2801 else if (strncasecmp (s
, "nbz", 3) == 0)
2807 else if (strncasecmp (s
, "nhz", 3) == 0)
2813 else if (strncasecmp (s
, "ndc", 3) == 0)
2819 else if (strncasecmp (s
, "nbc", 3) == 0)
2825 else if (strncasecmp (s
, "nhc", 3) == 0)
2831 else if (strncasecmp (s
, "swz", 3) == 0)
2837 else if (strncasecmp (s
, "swc", 3) == 0)
2843 else if (strncasecmp (s
, "nwz", 3) == 0)
2849 else if (strncasecmp (s
, "nwc", 3) == 0)
2855 /* ",*" is a valid condition. */
2856 else if (*args
!= 'U')
2857 as_bad (_("Invalid Unit Instruction Condition."));
2859 opcode
|= cmpltr
<< 13;
2860 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2868 /* Handle a nullification completer for branch instructions. */
2870 nullif
= pa_parse_nullif (&s
);
2871 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2873 /* Handle a nullification completer for copr and spop insns. */
2875 nullif
= pa_parse_nullif (&s
);
2876 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2878 /* Handle ,%r2 completer for new syntax branches. */
2880 if (*s
== ',' && strncasecmp (s
+ 1, "%r2", 3) == 0)
2882 else if (*s
== ',' && strncasecmp (s
+ 1, "%rp", 3) == 0)
2888 /* Handle 3 bit entry into the fp compare array. Valid values
2889 are 0..6 inclusive. */
2893 if (the_insn
.exp
.X_op
== O_constant
)
2895 num
= evaluate_absolute (&the_insn
);
2896 CHECK_FIELD (num
, 6, 0, 0);
2898 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2903 /* Handle 3 bit entry into the fp compare array. Valid values
2904 are 0..6 inclusive. */
2907 if (the_insn
.exp
.X_op
== O_constant
)
2910 num
= evaluate_absolute (&the_insn
);
2911 CHECK_FIELD (num
, 6, 0, 0);
2912 num
= (num
+ 1) ^ 1;
2913 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2918 /* Handle graphics test completers for ftest */
2921 num
= pa_parse_ftest_gfx_completer (&s
);
2922 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2925 /* Handle a 11 bit immediate at 31. */
2927 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2930 if (the_insn
.exp
.X_op
== O_constant
)
2932 num
= evaluate_absolute (&the_insn
);
2933 CHECK_FIELD (num
, 1023, -1024, 0);
2934 num
= low_sign_unext (num
, 11);
2935 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2939 if (is_DP_relative (the_insn
.exp
))
2940 the_insn
.reloc
= R_HPPA_GOTOFF
;
2941 else if (is_PC_relative (the_insn
.exp
))
2942 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2944 the_insn
.reloc
= R_HPPA
;
2945 the_insn
.format
= 11;
2949 /* Handle a 14 bit immediate at 31. */
2951 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2954 if (the_insn
.exp
.X_op
== O_constant
)
2958 /* XXX the completer stored away tibits of information
2959 for us to extract. We need a cleaner way to do this.
2960 Now that we have lots of letters again, it would be
2961 good to rethink this. */
2962 m
= (opcode
& (1 << 8)) != 0;
2963 a
= (opcode
& (1 << 9)) != 0;
2964 opcode
&= ~ (3 << 8);
2965 num
= evaluate_absolute (&the_insn
);
2966 if ((a
== 1 && num
>= 0) || (a
== 0 && num
< 0))
2968 CHECK_FIELD (num
, 8191, -8192, 0);
2969 num
= low_sign_unext (num
, 14);
2970 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2977 /* Handle a 14 bit immediate at 31. */
2979 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2982 if (the_insn
.exp
.X_op
== O_constant
)
2986 /* XXX the completer stored away tibits of information
2987 for us to extract. We need a cleaner way to do this.
2988 Now that we have lots of letters again, it would be
2989 good to rethink this. */
2990 m
= (opcode
& (1 << 8)) != 0;
2991 a
= (opcode
& (1 << 9)) != 0;
2992 opcode
&= ~ (3 << 8);
2993 num
= evaluate_absolute (&the_insn
);
2994 if ((a
== 1 && num
< 0) || (a
== 0 && num
> 0))
2998 CHECK_FIELD (num
, 8191, -8192, 0);
3003 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3010 /* Handle 14 bit immediate, shifted left three times. */
3012 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3015 if (the_insn
.exp
.X_op
== O_constant
)
3017 num
= evaluate_absolute (&the_insn
);
3020 CHECK_FIELD (num
, 8191, -8192, 0);
3025 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 4);
3029 if (is_DP_relative (the_insn
.exp
))
3030 the_insn
.reloc
= R_HPPA_GOTOFF
;
3031 else if (is_PC_relative (the_insn
.exp
))
3032 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3034 the_insn
.reloc
= R_HPPA
;
3035 the_insn
.format
= 14;
3040 /* Handle 14 bit immediate, shifted left twice. */
3042 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3045 if (the_insn
.exp
.X_op
== O_constant
)
3047 num
= evaluate_absolute (&the_insn
);
3050 CHECK_FIELD (num
, 8191, -8192, 0);
3055 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3059 if (is_DP_relative (the_insn
.exp
))
3060 the_insn
.reloc
= R_HPPA_GOTOFF
;
3061 else if (is_PC_relative (the_insn
.exp
))
3062 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3064 the_insn
.reloc
= R_HPPA
;
3065 the_insn
.format
= 14;
3069 /* Handle a 14 bit immediate at 31. */
3071 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3074 if (the_insn
.exp
.X_op
== O_constant
)
3076 num
= evaluate_absolute (&the_insn
);
3077 CHECK_FIELD (num
, 8191, -8192, 0);
3078 num
= low_sign_unext (num
, 14);
3079 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3083 if (is_DP_relative (the_insn
.exp
))
3084 the_insn
.reloc
= R_HPPA_GOTOFF
;
3085 else if (is_PC_relative (the_insn
.exp
))
3086 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3088 the_insn
.reloc
= R_HPPA
;
3089 the_insn
.format
= 14;
3093 /* Handle a 21 bit immediate at 31. */
3095 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3098 if (the_insn
.exp
.X_op
== O_constant
)
3100 num
= evaluate_absolute (&the_insn
);
3101 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
3102 opcode
|= re_assemble_21 (num
);
3107 if (is_DP_relative (the_insn
.exp
))
3108 the_insn
.reloc
= R_HPPA_GOTOFF
;
3109 else if (is_PC_relative (the_insn
.exp
))
3110 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3112 the_insn
.reloc
= R_HPPA
;
3113 the_insn
.format
= 21;
3117 /* Handle a 16 bit immediate at 31 (PA 2.0 wide mode only). */
3119 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3122 if (the_insn
.exp
.X_op
== O_constant
)
3124 num
= evaluate_absolute (&the_insn
);
3125 CHECK_FIELD (num
, 32767, -32768, 0);
3126 opcode
|= re_assemble_16 (num
);
3131 /* ??? Is this valid for wide mode? */
3132 if (is_DP_relative (the_insn
.exp
))
3133 the_insn
.reloc
= R_HPPA_GOTOFF
;
3134 else if (is_PC_relative (the_insn
.exp
))
3135 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3137 the_insn
.reloc
= R_HPPA
;
3138 the_insn
.format
= 14;
3142 /* Handle a word-aligned 16-bit imm. at 31 (PA2.0 wide). */
3144 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3147 if (the_insn
.exp
.X_op
== O_constant
)
3149 num
= evaluate_absolute (&the_insn
);
3150 CHECK_FIELD (num
, 32767, -32768, 0);
3151 CHECK_ALIGN (num
, 4, 0);
3152 opcode
|= re_assemble_16 (num
);
3157 /* ??? Is this valid for wide mode? */
3158 if (is_DP_relative (the_insn
.exp
))
3159 the_insn
.reloc
= R_HPPA_GOTOFF
;
3160 else if (is_PC_relative (the_insn
.exp
))
3161 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3163 the_insn
.reloc
= R_HPPA
;
3164 the_insn
.format
= 14;
3168 /* Handle a dword-aligned 16-bit imm. at 31 (PA2.0 wide). */
3170 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3173 if (the_insn
.exp
.X_op
== O_constant
)
3175 num
= evaluate_absolute (&the_insn
);
3176 CHECK_FIELD (num
, 32767, -32768, 0);
3177 CHECK_ALIGN (num
, 8, 0);
3178 opcode
|= re_assemble_16 (num
);
3183 /* ??? Is this valid for wide mode? */
3184 if (is_DP_relative (the_insn
.exp
))
3185 the_insn
.reloc
= R_HPPA_GOTOFF
;
3186 else if (is_PC_relative (the_insn
.exp
))
3187 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3189 the_insn
.reloc
= R_HPPA
;
3190 the_insn
.format
= 14;
3194 /* Handle a 12 bit branch displacement. */
3196 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3200 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
3202 num
= evaluate_absolute (&the_insn
);
3205 as_bad (_("Branch to unaligned address"));
3208 CHECK_FIELD (num
, 8199, -8184, 0);
3210 opcode
|= re_assemble_12 ((num
- 8) >> 2);
3215 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3216 the_insn
.format
= 12;
3217 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3218 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3223 /* Handle a 17 bit branch displacement. */
3225 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3229 if (!the_insn
.exp
.X_add_symbol
3230 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3233 num
= evaluate_absolute (&the_insn
);
3236 as_bad (_("Branch to unaligned address"));
3239 CHECK_FIELD (num
, 262143, -262144, 0);
3241 if (the_insn
.exp
.X_add_symbol
)
3244 opcode
|= re_assemble_17 (num
>> 2);
3249 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3250 the_insn
.format
= 17;
3251 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3252 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3256 /* Handle a 22 bit branch displacement. */
3258 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3262 if (!the_insn
.exp
.X_add_symbol
3263 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3266 num
= evaluate_absolute (&the_insn
);
3269 as_bad (_("Branch to unaligned address"));
3272 CHECK_FIELD (num
, 8388607, -8388608, 0);
3274 if (the_insn
.exp
.X_add_symbol
)
3277 opcode
|= re_assemble_22 (num
>> 2);
3281 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3282 the_insn
.format
= 22;
3283 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3284 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3288 /* Handle an absolute 17 bit branch target. */
3290 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3294 if (!the_insn
.exp
.X_add_symbol
3295 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3298 num
= evaluate_absolute (&the_insn
);
3301 as_bad (_("Branch to unaligned address"));
3304 CHECK_FIELD (num
, 262143, -262144, 0);
3306 if (the_insn
.exp
.X_add_symbol
)
3309 opcode
|= re_assemble_17 (num
>> 2);
3314 the_insn
.reloc
= R_HPPA_ABS_CALL
;
3315 the_insn
.format
= 17;
3316 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3317 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3321 /* Handle '%r1' implicit operand of addil instruction. */
3323 if (*s
== ',' && *(s
+ 1) == '%' && *(s
+ 3) == '1'
3324 && (*(s
+ 2) == 'r' || *(s
+ 2) == 'R'))
3332 /* Handle '%sr0,%r31' implicit operand of be,l instruction. */
3334 if (strncasecmp (s
, "%sr0,%r31", 9) != 0)
3339 /* Handle immediate value of 0 for ordered load/store instructions. */
3346 /* Handle a 2 bit shift count at 25. */
3348 num
= pa_get_absolute_expression (&the_insn
, &s
);
3349 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3352 CHECK_FIELD (num
, 3, 1, strict
);
3353 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3355 /* Handle a 4 bit shift count at 25. */
3357 num
= pa_get_absolute_expression (&the_insn
, &s
);
3358 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3361 CHECK_FIELD (num
, 15, 0, strict
);
3362 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3364 /* Handle a 5 bit shift count at 26. */
3366 num
= pa_get_absolute_expression (&the_insn
, &s
);
3367 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3370 CHECK_FIELD (num
, 31, 0, strict
);
3371 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
3373 /* Handle a 6 bit shift count at 20,22:26. */
3375 num
= pa_get_absolute_expression (&the_insn
, &s
);
3376 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3379 CHECK_FIELD (num
, 63, 0, strict
);
3381 opcode
|= (num
& 0x20) << 6;
3382 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3384 /* Handle a 6 bit field length at 23,27:31. */
3387 num
= pa_get_absolute_expression (&the_insn
, &s
);
3388 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3391 CHECK_FIELD (num
, 64, 1, strict
);
3393 opcode
|= (num
& 0x20) << 3;
3394 num
= 31 - (num
& 0x1f);
3395 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3397 /* Handle a 6 bit field length at 19,27:31. */
3399 num
= pa_get_absolute_expression (&the_insn
, &s
);
3400 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3403 CHECK_FIELD (num
, 64, 1, strict
);
3405 opcode
|= (num
& 0x20) << 7;
3406 num
= 31 - (num
& 0x1f);
3407 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3409 /* Handle a 5 bit bit position at 26. */
3411 num
= pa_get_absolute_expression (&the_insn
, &s
);
3412 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3415 CHECK_FIELD (num
, 31, 0, strict
);
3416 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
3418 /* Handle a 6 bit bit position at 20,22:26. */
3420 num
= pa_get_absolute_expression (&the_insn
, &s
);
3421 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3424 CHECK_FIELD (num
, 63, 0, strict
);
3425 opcode
|= (num
& 0x20) << 6;
3426 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3428 /* Handle a 5 bit immediate at 10 with 'd' as the complement
3429 of the high bit of the immediate. */
3431 num
= pa_get_absolute_expression (&the_insn
, &s
);
3432 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3435 CHECK_FIELD (num
, 63, 0, strict
);
3439 opcode
|= (1 << 13);
3440 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 21);
3442 /* Handle a 5 bit immediate at 10. */
3444 num
= pa_get_absolute_expression (&the_insn
, &s
);
3445 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3447 if (the_insn
.exp
.X_op
!= O_constant
)
3450 CHECK_FIELD (num
, 31, 0, strict
);
3451 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3453 /* Handle a 9 bit immediate at 28. */
3455 num
= pa_get_absolute_expression (&the_insn
, &s
);
3456 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3459 CHECK_FIELD (num
, 511, 1, strict
);
3460 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3462 /* Handle a 13 bit immediate at 18. */
3464 num
= pa_get_absolute_expression (&the_insn
, &s
);
3465 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3468 CHECK_FIELD (num
, 8191, 0, strict
);
3469 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
3471 /* Handle a 26 bit immediate at 31. */
3473 num
= pa_get_absolute_expression (&the_insn
, &s
);
3474 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3477 CHECK_FIELD (num
, 671108864, 0, strict
);
3478 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3480 /* Handle a 3 bit SFU identifier at 25. */
3483 as_bad (_("Invalid SFU identifier"));
3484 num
= pa_get_absolute_expression (&the_insn
, &s
);
3485 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3488 CHECK_FIELD (num
, 7, 0, strict
);
3489 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3491 /* Handle a 20 bit SOP field for spop0. */
3493 num
= pa_get_absolute_expression (&the_insn
, &s
);
3494 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3497 CHECK_FIELD (num
, 1048575, 0, strict
);
3498 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
3499 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3501 /* Handle a 15bit SOP field for spop1. */
3503 num
= pa_get_absolute_expression (&the_insn
, &s
);
3504 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3507 CHECK_FIELD (num
, 32767, 0, strict
);
3508 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
3510 /* Handle a 10bit SOP field for spop3. */
3512 num
= pa_get_absolute_expression (&the_insn
, &s
);
3513 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3516 CHECK_FIELD (num
, 1023, 0, strict
);
3517 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
3518 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3520 /* Handle a 15 bit SOP field for spop2. */
3522 num
= pa_get_absolute_expression (&the_insn
, &s
);
3523 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3526 CHECK_FIELD (num
, 32767, 0, strict
);
3527 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
3528 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3530 /* Handle a 3-bit co-processor ID field. */
3533 as_bad (_("Invalid COPR identifier"));
3534 num
= pa_get_absolute_expression (&the_insn
, &s
);
3535 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3538 CHECK_FIELD (num
, 7, 0, strict
);
3539 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3541 /* Handle a 22bit SOP field for copr. */
3543 num
= pa_get_absolute_expression (&the_insn
, &s
);
3544 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3547 CHECK_FIELD (num
, 4194303, 0, strict
);
3548 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
3549 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3551 /* Handle a source FP operand format completer. */
3553 if (*s
== ',' && *(s
+1) == 't')
3560 flag
= pa_parse_fp_cnv_format (&s
);
3561 the_insn
.fpof1
= flag
;
3562 if (flag
== W
|| flag
== UW
)
3564 if (flag
== DW
|| flag
== UDW
)
3566 if (flag
== QW
|| flag
== UQW
)
3568 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3570 /* Handle a destination FP operand format completer. */
3572 /* pa_parse_format needs the ',' prefix. */
3574 flag
= pa_parse_fp_cnv_format (&s
);
3575 the_insn
.fpof2
= flag
;
3576 if (flag
== W
|| flag
== UW
)
3578 if (flag
== DW
|| flag
== UDW
)
3580 if (flag
== QW
|| flag
== UQW
)
3582 opcode
|= flag
<< 13;
3583 if (the_insn
.fpof1
== SGL
3584 || the_insn
.fpof1
== DBL
3585 || the_insn
.fpof1
== QUAD
)
3587 if (the_insn
.fpof2
== SGL
3588 || the_insn
.fpof2
== DBL
3589 || the_insn
.fpof2
== QUAD
)
3591 else if (the_insn
.fpof2
== W
3592 || the_insn
.fpof2
== DW
3593 || the_insn
.fpof2
== QW
)
3595 else if (the_insn
.fpof2
== UW
3596 || the_insn
.fpof2
== UDW
3597 || the_insn
.fpof2
== UQW
)
3602 else if (the_insn
.fpof1
== W
3603 || the_insn
.fpof1
== DW
3604 || the_insn
.fpof1
== QW
)
3606 if (the_insn
.fpof2
== SGL
3607 || the_insn
.fpof2
== DBL
3608 || the_insn
.fpof2
== QUAD
)
3613 else if (the_insn
.fpof1
== UW
3614 || the_insn
.fpof1
== UDW
3615 || the_insn
.fpof1
== UQW
)
3617 if (the_insn
.fpof2
== SGL
3618 || the_insn
.fpof2
== DBL
3619 || the_insn
.fpof2
== QUAD
)
3624 flag
|= the_insn
.trunc
;
3625 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 15);
3627 /* Handle a source FP operand format completer. */
3629 flag
= pa_parse_fp_format (&s
);
3630 the_insn
.fpof1
= flag
;
3631 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3633 /* Handle a destination FP operand format completer. */
3635 /* pa_parse_format needs the ',' prefix. */
3637 flag
= pa_parse_fp_format (&s
);
3638 the_insn
.fpof2
= flag
;
3639 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
3641 /* Handle a source FP operand format completer at 20. */
3643 flag
= pa_parse_fp_format (&s
);
3644 the_insn
.fpof1
= flag
;
3645 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3647 /* Handle a floating point operand format at 26.
3648 Only allows single and double precision. */
3650 flag
= pa_parse_fp_format (&s
);
3656 the_insn
.fpof1
= flag
;
3662 as_bad (_("Invalid Floating Point Operand Format."));
3666 /* Handle all floating point registers. */
3670 /* Float target register. */
3672 /* This should be more strict. Small steps. */
3673 if (strict
&& *s
!= '%')
3675 num
= pa_parse_number (&s
, 0);
3676 CHECK_FIELD (num
, 31, 0, 0);
3677 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3679 /* Float target register with L/R selection. */
3682 struct pa_11_fp_reg_struct result
;
3684 /* This should be more strict. Small steps. */
3685 if (strict
&& *s
!= '%')
3687 pa_parse_number (&s
, &result
);
3688 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3689 opcode
|= result
.number_part
;
3691 /* 0x30 opcodes are FP arithmetic operation opcodes
3692 and need to be turned into 0x38 opcodes. This
3693 is not necessary for loads/stores. */
3694 if (need_pa11_opcode (&the_insn
, &result
)
3695 && ((opcode
& 0xfc000000) == 0x30000000))
3698 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
3701 /* Float operand 1. */
3704 struct pa_11_fp_reg_struct result
;
3706 /* This should be more strict. Small steps. */
3707 if (strict
&& *s
!= '%')
3709 pa_parse_number (&s
, &result
);
3710 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3711 opcode
|= result
.number_part
<< 21;
3712 if (need_pa11_opcode (&the_insn
, &result
))
3714 opcode
|= (result
.l_r_select
& 1) << 7;
3720 /* Float operand 1 with L/R selection. */
3724 struct pa_11_fp_reg_struct result
;
3726 /* This should be more strict. Small steps. */
3727 if (strict
&& *s
!= '%')
3729 pa_parse_number (&s
, &result
);
3730 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3731 opcode
|= result
.number_part
<< 21;
3732 opcode
|= (result
.l_r_select
& 1) << 7;
3736 /* Float operand 2. */
3739 struct pa_11_fp_reg_struct result
;
3741 /* This should be more strict. Small steps. */
3742 if (strict
&& *s
!= '%')
3744 pa_parse_number (&s
, &result
);
3745 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3746 opcode
|= (result
.number_part
& 0x1f) << 16;
3747 if (need_pa11_opcode (&the_insn
, &result
))
3749 opcode
|= (result
.l_r_select
& 1) << 12;
3755 /* Float operand 2 with L/R selection. */
3758 struct pa_11_fp_reg_struct result
;
3760 /* This should be more strict. Small steps. */
3761 if (strict
&& *s
!= '%')
3763 pa_parse_number (&s
, &result
);
3764 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3765 opcode
|= (result
.number_part
& 0x1f) << 16;
3766 opcode
|= (result
.l_r_select
& 1) << 12;
3770 /* Float operand 3 for fmpyfadd, fmpynfadd. */
3773 struct pa_11_fp_reg_struct result
;
3775 /* This should be more strict. Small steps. */
3776 if (strict
&& *s
!= '%')
3778 pa_parse_number (&s
, &result
);
3779 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3780 opcode
|= (result
.number_part
& 0x1c) << 11;
3781 opcode
|= (result
.number_part
& 0x3) << 9;
3782 opcode
|= (result
.l_r_select
& 1) << 8;
3786 /* Float mult operand 1 for fmpyadd, fmpysub */
3789 struct pa_11_fp_reg_struct result
;
3791 /* This should be more strict. Small steps. */
3792 if (strict
&& *s
!= '%')
3794 pa_parse_number (&s
, &result
);
3795 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3796 if (the_insn
.fpof1
== SGL
)
3798 if (result
.number_part
< 16)
3800 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3804 result
.number_part
&= 0xF;
3805 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3807 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
3810 /* Float mult operand 2 for fmpyadd, fmpysub */
3813 struct pa_11_fp_reg_struct result
;
3815 /* This should be more strict. Small steps. */
3816 if (strict
&& *s
!= '%')
3818 pa_parse_number (&s
, &result
);
3819 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3820 if (the_insn
.fpof1
== SGL
)
3822 if (result
.number_part
< 16)
3824 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3827 result
.number_part
&= 0xF;
3828 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3830 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
3833 /* Float mult target for fmpyadd, fmpysub */
3836 struct pa_11_fp_reg_struct result
;
3838 /* This should be more strict. Small steps. */
3839 if (strict
&& *s
!= '%')
3841 pa_parse_number (&s
, &result
);
3842 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3843 if (the_insn
.fpof1
== SGL
)
3845 if (result
.number_part
< 16)
3847 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3850 result
.number_part
&= 0xF;
3851 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3853 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
3856 /* Float add operand 1 for fmpyadd, fmpysub */
3859 struct pa_11_fp_reg_struct result
;
3861 /* This should be more strict. Small steps. */
3862 if (strict
&& *s
!= '%')
3864 pa_parse_number (&s
, &result
);
3865 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3866 if (the_insn
.fpof1
== SGL
)
3868 if (result
.number_part
< 16)
3870 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3873 result
.number_part
&= 0xF;
3874 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3876 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
3879 /* Float add target for fmpyadd, fmpysub */
3882 struct pa_11_fp_reg_struct result
;
3884 /* This should be more strict. Small steps. */
3885 if (strict
&& *s
!= '%')
3887 pa_parse_number (&s
, &result
);
3888 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3889 if (the_insn
.fpof1
== SGL
)
3891 if (result
.number_part
< 16)
3893 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3896 result
.number_part
&= 0xF;
3897 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3899 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
3902 /* Handle L/R register halves like 'x'. */
3906 struct pa_11_fp_reg_struct result
;
3908 if (strict
&& *s
!= '%')
3910 pa_parse_number (&s
, &result
);
3911 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3912 opcode
|= (result
.number_part
& 0x1f) << 16;
3913 if (need_pa11_opcode (&the_insn
, &result
))
3915 opcode
|= (result
.l_r_select
& 1) << 1;
3920 /* Float target register (PA 2.0 wide). */
3922 /* This should be more strict. Small steps. */
3923 if (strict
&& *s
!= '%')
3925 num
= pa_parse_number (&s
, 0);
3926 CHECK_FIELD (num
, 31, 0, 0);
3927 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
3941 /* Check if the args matched. */
3944 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
3945 && !strcmp (insn
->name
, insn
[1].name
))
3953 as_bad (_("Invalid operands %s"), error_message
);
3960 the_insn
.opcode
= opcode
;
3963 /* Turn a string in input_line_pointer into a floating point constant of type
3964 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
3965 emitted is stored in *sizeP . An error message or NULL is returned. */
3967 #define MAX_LITTLENUMS 6
3970 md_atof (type
, litP
, sizeP
)
3976 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
3977 LITTLENUM_TYPE
*wordP
;
4009 return _("Bad call to MD_ATOF()");
4011 t
= atof_ieee (input_line_pointer
, type
, words
);
4013 input_line_pointer
= t
;
4014 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
4015 for (wordP
= words
; prec
--;)
4017 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
4018 litP
+= sizeof (LITTLENUM_TYPE
);
4023 /* Write out big-endian. */
4026 md_number_to_chars (buf
, val
, n
)
4031 number_to_chars_bigendian (buf
, val
, n
);
4034 /* Translate internal representation of relocation info to BFD target
4038 tc_gen_reloc (section
, fixp
)
4043 struct hppa_fix_struct
*hppa_fixp
;
4044 static arelent
*no_relocs
= NULL
;
4051 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
4052 if (fixp
->fx_addsy
== 0)
4055 assert (hppa_fixp
!= 0);
4056 assert (section
!= 0);
4058 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
4060 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4061 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4062 codes
= hppa_gen_reloc_type (stdoutput
,
4064 hppa_fixp
->fx_r_format
,
4065 hppa_fixp
->fx_r_field
,
4066 fixp
->fx_subsy
!= NULL
,
4067 symbol_get_bfdsym (fixp
->fx_addsy
));
4072 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
4075 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
4076 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
4077 for (i
= 0; i
< n_relocs
; i
++)
4078 relocs
[i
] = &reloc
[i
];
4080 relocs
[n_relocs
] = NULL
;
4083 switch (fixp
->fx_r_type
)
4086 assert (n_relocs
== 1);
4090 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4091 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4092 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
,
4093 (bfd_reloc_code_real_type
) code
);
4094 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4096 assert (reloc
->howto
&& (unsigned int) code
== reloc
->howto
->type
);
4098 /* Now, do any processing that is dependent on the relocation type. */
4101 case R_PARISC_DLTREL21L
:
4102 case R_PARISC_DLTREL14R
:
4103 case R_PARISC_DLTREL14F
:
4104 case R_PARISC_PLABEL32
:
4105 case R_PARISC_PLABEL21L
:
4106 case R_PARISC_PLABEL14R
:
4107 /* For plabel relocations, the addend of the
4108 relocation should be either 0 (no static link) or 2
4109 (static link required). This adjustment is done in
4110 bfd/elf32-hppa.c:elf32_hppa_relocate_section.
4112 We also slam a zero addend into the DLT relative relocs;
4113 it doesn't make a lot of sense to use any addend since
4114 it gets you a different (eg unknown) DLT entry. */
4118 #ifdef ELF_ARG_RELOC
4119 case R_PARISC_PCREL17R
:
4120 case R_PARISC_PCREL17F
:
4121 case R_PARISC_PCREL17C
:
4122 case R_PARISC_DIR17R
:
4123 case R_PARISC_DIR17F
:
4124 case R_PARISC_PCREL21L
:
4125 case R_PARISC_DIR21L
:
4126 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
,
4132 reloc
->addend
= fixp
->fx_offset
;
4139 /* Walk over reach relocation returned by the BFD backend. */
4140 for (i
= 0; i
< n_relocs
; i
++)
4144 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4145 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4147 bfd_reloc_type_lookup (stdoutput
,
4148 (bfd_reloc_code_real_type
) code
);
4149 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4154 /* The only time we ever use a R_COMP2 fixup is for the difference
4155 of two symbols. With that in mind we fill in all four
4156 relocs now and break out of the loop. */
4158 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4160 bfd_reloc_type_lookup (stdoutput
,
4161 (bfd_reloc_code_real_type
) *codes
[0]);
4162 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4163 relocs
[0]->addend
= 0;
4164 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4165 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4167 bfd_reloc_type_lookup (stdoutput
,
4168 (bfd_reloc_code_real_type
) *codes
[1]);
4169 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4170 relocs
[1]->addend
= 0;
4171 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4172 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
4174 bfd_reloc_type_lookup (stdoutput
,
4175 (bfd_reloc_code_real_type
) *codes
[2]);
4176 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4177 relocs
[2]->addend
= 0;
4178 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4180 bfd_reloc_type_lookup (stdoutput
,
4181 (bfd_reloc_code_real_type
) *codes
[3]);
4182 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4183 relocs
[3]->addend
= 0;
4184 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4186 bfd_reloc_type_lookup (stdoutput
,
4187 (bfd_reloc_code_real_type
) *codes
[4]);
4188 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4189 relocs
[4]->addend
= 0;
4193 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
4199 /* For plabel relocations, the addend of the
4200 relocation should be either 0 (no static link) or 2
4201 (static link required).
4203 FIXME: We always assume no static link!
4205 We also slam a zero addend into the DLT relative relocs;
4206 it doesn't make a lot of sense to use any addend since
4207 it gets you a different (eg unknown) DLT entry. */
4208 relocs
[i
]->addend
= 0;
4223 /* There is no symbol or addend associated with these fixups. */
4224 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4225 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4226 relocs
[i
]->addend
= 0;
4232 /* There is no symbol associated with these fixups. */
4233 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4234 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4235 relocs
[i
]->addend
= fixp
->fx_offset
;
4239 relocs
[i
]->addend
= fixp
->fx_offset
;
4249 /* Process any machine dependent frag types. */
4252 md_convert_frag (abfd
, sec
, fragP
)
4253 register bfd
*abfd ATTRIBUTE_UNUSED
;
4254 register asection
*sec ATTRIBUTE_UNUSED
;
4255 register fragS
*fragP
;
4257 unsigned int address
;
4259 if (fragP
->fr_type
== rs_machine_dependent
)
4261 switch ((int) fragP
->fr_subtype
)
4264 fragP
->fr_type
= rs_fill
;
4265 know (fragP
->fr_var
== 1);
4266 know (fragP
->fr_next
);
4267 address
= fragP
->fr_address
+ fragP
->fr_fix
;
4268 if (address
% fragP
->fr_offset
)
4271 fragP
->fr_next
->fr_address
4276 fragP
->fr_offset
= 0;
4282 /* Round up a section size to the appropriate boundary. */
4285 md_section_align (segment
, size
)
4289 int align
= bfd_get_section_alignment (stdoutput
, segment
);
4290 int align2
= (1 << align
) - 1;
4292 return (size
+ align2
) & ~align2
;
4295 /* Return the approximate size of a frag before relaxation has occurred. */
4297 md_estimate_size_before_relax (fragP
, segment
)
4298 register fragS
*fragP
;
4299 asection
*segment ATTRIBUTE_UNUSED
;
4305 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
4312 # ifdef WARN_COMMENTS
4313 const char *md_shortopts
= "Vc";
4315 const char *md_shortopts
= "V";
4318 # ifdef WARN_COMMENTS
4319 const char *md_shortopts
= "c";
4321 const char *md_shortopts
= "";
4325 struct option md_longopts
[] = {
4326 #ifdef WARN_COMMENTS
4327 {"warn-comment", no_argument
, NULL
, 'c'},
4329 {NULL
, no_argument
, NULL
, 0}
4331 size_t md_longopts_size
= sizeof(md_longopts
);
4334 md_parse_option (c
, arg
)
4335 int c ATTRIBUTE_UNUSED
;
4336 char *arg ATTRIBUTE_UNUSED
;
4345 print_version_id ();
4348 #ifdef WARN_COMMENTS
4359 md_show_usage (stream
)
4360 FILE *stream ATTRIBUTE_UNUSED
;
4363 fprintf (stream
, _("\
4366 #ifdef WARN_COMMENTS
4367 fprintf (stream
, _("\
4368 -c print a warning if a comment is found\n"));
4372 /* We have no need to default values of symbols. */
4375 md_undefined_symbol (name
)
4376 char *name ATTRIBUTE_UNUSED
;
4381 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
4382 #define arg_reloc_stub_needed(CALLER, CALLEE) \
4383 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
4385 #define arg_reloc_stub_needed(CALLER, CALLEE) 0
4388 /* Apply a fixup to an instruction. */
4391 md_apply_fix (fixP
, valp
)
4395 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
4396 struct hppa_fix_struct
*hppa_fixP
;
4400 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
4401 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
4402 never be "applied" (they are just markers). Likewise for
4403 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
4405 if (fixP
->fx_r_type
== R_HPPA_ENTRY
4406 || fixP
->fx_r_type
== R_HPPA_EXIT
4407 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
4408 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
4409 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
4412 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
4413 fixups are considered not adjustable, which in turn causes
4414 adjust_reloc_syms to not set fx_offset. Ugh. */
4415 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
4417 fixP
->fx_offset
= *valp
;
4422 if (fixP
->fx_r_type
== (int) R_PARISC_GNU_VTENTRY
4423 || fixP
->fx_r_type
== (int) R_PARISC_GNU_VTINHERIT
)
4427 insn
= bfd_get_32 (stdoutput
, (unsigned char *) buf
);
4428 /* There should have been an HPPA specific fixup associated
4429 with the GAS fixup. */
4432 int fmt
= bfd_hppa_insn2fmt (stdoutput
, insn
);
4434 /* If there is a symbol associated with this fixup, then it's something
4435 which will need a SOM relocation (except for some PC-relative relocs).
4436 In such cases we should treat the "val" or "addend" as zero since it
4437 will be added in as needed from fx_offset in tc_gen_reloc. */
4438 if ((fixP
->fx_addsy
!= NULL
4439 || fixP
->fx_r_type
== (int) R_HPPA_NONE
)
4444 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4446 /* These field selectors imply that we do not want an addend. */
4447 else if (hppa_fixP
->fx_r_field
== e_psel
4448 || hppa_fixP
->fx_r_field
== e_rpsel
4449 || hppa_fixP
->fx_r_field
== e_lpsel
4450 || hppa_fixP
->fx_r_field
== e_tsel
4451 || hppa_fixP
->fx_r_field
== e_rtsel
4452 || hppa_fixP
->fx_r_field
== e_ltsel
)
4453 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4454 /* This is truely disgusting. The machine independent code blindly
4455 adds in the value of the symbol being relocated against. Damn! */
4457 && fixP
->fx_addsy
!= NULL
4458 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
4459 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
4460 0, hppa_fixP
->fx_r_field
);
4463 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4465 /* Handle pc-relative exceptions from above. */
4466 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
4469 && !arg_reloc_stub_needed (symbol_arg_reloc_info (fixP
->fx_addsy
),
4470 hppa_fixP
->fx_arg_reloc
)
4471 && ((*valp
+ 8192) < 16384
4472 || (fmt
== 17 && (*valp
+ 262144) < 524288)
4473 || (fmt
== 22 && (*valp
+ 8388608) < 16777216))
4474 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
4476 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
4478 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4484 CHECK_FIELD (new_val
, 8191, -8192, 0);
4487 insn
= (insn
& ~ 0x3ff1) | (((val
& 0x1ff8) << 1)
4488 | ((val
& 0x2000) >> 13));
4491 CHECK_FIELD (new_val
, 8191, -8192, 0);
4494 insn
= (insn
& ~ 0x3ff9) | (((val
& 0x1ffc) << 1)
4495 | ((val
& 0x2000) >> 13));
4497 /* Handle all opcodes with the 'j' operand type. */
4499 CHECK_FIELD (new_val
, 8191, -8192, 0);
4502 insn
= ((insn
& ~ 0x3fff) | low_sign_unext (val
, 14));
4505 /* Handle all opcodes with the 'k' operand type. */
4507 CHECK_FIELD (new_val
, 1048575, -1048576, 0);
4510 insn
= (insn
& ~ 0x1fffff) | re_assemble_21 (val
);
4513 /* Handle all the opcodes with the 'i' operand type. */
4515 CHECK_FIELD (new_val
, 1023, -1023, 0);
4518 insn
= (insn
& ~ 0x7ff) | low_sign_unext (val
, 11);
4521 /* Handle all the opcodes with the 'w' operand type. */
4523 CHECK_FIELD (new_val
, 8199, -8184, 0);
4526 insn
= (insn
& ~ 0x1ffd) | re_assemble_12 ((val
- 8) >> 2);
4529 /* Handle some of the opcodes with the 'W' operand type. */
4532 offsetT distance
= *valp
;
4534 /* If this is an absolute branch (ie no link) with an out of
4535 range target, then we want to complain. */
4536 if (fixP
->fx_r_type
== (int) R_HPPA_PCREL_CALL
4537 && (insn
& 0xffe00000) == 0xe8000000)
4538 CHECK_FIELD (distance
, 262143, -262144, 0);
4540 CHECK_FIELD (new_val
, 262143, -262144, 0);
4543 insn
= (insn
& ~ 0x1f1ffd) | re_assemble_17 ((val
- 8) >> 2);
4549 offsetT distance
= *valp
;
4551 /* If this is an absolute branch (ie no link) with an out of
4552 range target, then we want to complain. */
4553 if (fixP
->fx_r_type
== (int) R_HPPA_PCREL_CALL
4554 && (insn
& 0xffe00000) == 0xe8000000)
4555 CHECK_FIELD (distance
, 8388607, -8388608, 0);
4557 CHECK_FIELD (new_val
, 8388607, -8388608, 0);
4560 insn
= (insn
& ~ 0x3ff1ffd) | re_assemble_22 ((val
- 8) >> 2);
4566 insn
= (insn
& ~ 0xfff1) | re_assemble_16 (val
& -8);
4571 insn
= (insn
& ~ 0xfff9) | re_assemble_16 (val
& -4);
4576 insn
= (insn
& ~ 0xffff) | re_assemble_16 (val
);
4584 as_bad (_("Unknown relocation encountered in md_apply_fix."));
4588 /* Insert the relocation. */
4589 bfd_put_32 (stdoutput
, insn
, (unsigned char *) buf
);
4594 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
4595 (unsigned int) fixP
, fixP
->fx_r_type
);
4600 /* Exactly what point is a PC-relative offset relative TO?
4601 On the PA, they're relative to the address of the offset. */
4604 md_pcrel_from (fixP
)
4607 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
4610 /* Return nonzero if the input line pointer is at the end of
4614 is_end_of_statement ()
4616 return ((*input_line_pointer
== '\n')
4617 || (*input_line_pointer
== ';')
4618 || (*input_line_pointer
== '!'));
4621 /* Read a number from S. The number might come in one of many forms,
4622 the most common will be a hex or decimal constant, but it could be
4623 a pre-defined register (Yuk!), or an absolute symbol.
4625 Return a number or -1 for failure.
4627 When parsing PA-89 FP register numbers RESULT will be
4628 the address of a structure to return information about
4629 L/R half of FP registers, store results there as appropriate.
4631 pa_parse_number can not handle negative constants and will fail
4632 horribly if it is passed such a constant. */
4635 pa_parse_number (s
, result
)
4637 struct pa_11_fp_reg_struct
*result
;
4646 /* Skip whitespace before the number. */
4647 while (*p
== ' ' || *p
== '\t')
4650 /* Store info in RESULT if requested by caller. */
4653 result
->number_part
= -1;
4654 result
->l_r_select
= -1;
4660 /* Looks like a number. */
4663 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
4665 /* The number is specified in hex. */
4667 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
4668 || ((*p
>= 'A') && (*p
<= 'F')))
4671 num
= num
* 16 + *p
- '0';
4672 else if (*p
>= 'a' && *p
<= 'f')
4673 num
= num
* 16 + *p
- 'a' + 10;
4675 num
= num
* 16 + *p
- 'A' + 10;
4681 /* The number is specified in decimal. */
4682 while (isdigit (*p
))
4684 num
= num
* 10 + *p
- '0';
4689 /* Store info in RESULT if requested by the caller. */
4692 result
->number_part
= num
;
4694 if (IS_R_SELECT (p
))
4696 result
->l_r_select
= 1;
4699 else if (IS_L_SELECT (p
))
4701 result
->l_r_select
= 0;
4705 result
->l_r_select
= 0;
4710 /* The number might be a predefined register. */
4715 /* Tege hack: Special case for general registers as the general
4716 code makes a binary search with case translation, and is VERY
4721 if (*p
== 'e' && *(p
+ 1) == 't'
4722 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
4725 num
= *p
- '0' + 28;
4733 else if (!isdigit (*p
))
4736 as_bad (_("Undefined register: '%s'."), name
);
4742 num
= num
* 10 + *p
++ - '0';
4743 while (isdigit (*p
));
4748 /* Do a normal register search. */
4749 while (is_part_of_name (c
))
4755 status
= reg_name_search (name
);
4761 as_bad (_("Undefined register: '%s'."), name
);
4767 /* Store info in RESULT if requested by caller. */
4770 result
->number_part
= num
;
4771 if (IS_R_SELECT (p
- 1))
4772 result
->l_r_select
= 1;
4773 else if (IS_L_SELECT (p
- 1))
4774 result
->l_r_select
= 0;
4776 result
->l_r_select
= 0;
4781 /* And finally, it could be a symbol in the absolute section which
4782 is effectively a constant. */
4786 while (is_part_of_name (c
))
4792 if ((sym
= symbol_find (name
)) != NULL
)
4794 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
4795 num
= S_GET_VALUE (sym
);
4799 as_bad (_("Non-absolute symbol: '%s'."), name
);
4805 /* There is where we'd come for an undefined symbol
4806 or for an empty string. For an empty string we
4807 will return zero. That's a concession made for
4808 compatability with the braindamaged HP assemblers. */
4814 as_bad (_("Undefined absolute constant: '%s'."), name
);
4820 /* Store info in RESULT if requested by caller. */
4823 result
->number_part
= num
;
4824 if (IS_R_SELECT (p
- 1))
4825 result
->l_r_select
= 1;
4826 else if (IS_L_SELECT (p
- 1))
4827 result
->l_r_select
= 0;
4829 result
->l_r_select
= 0;
4837 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
4839 /* Given NAME, find the register number associated with that name, return
4840 the integer value associated with the given name or -1 on failure. */
4843 reg_name_search (name
)
4846 int middle
, low
, high
;
4850 high
= REG_NAME_CNT
- 1;
4854 middle
= (low
+ high
) / 2;
4855 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
4861 return pre_defined_registers
[middle
].value
;
4863 while (low
<= high
);
4869 /* Return nonzero if the given INSN and L/R information will require
4870 a new PA-1.1 opcode. */
4873 need_pa11_opcode (insn
, result
)
4875 struct pa_11_fp_reg_struct
*result
;
4877 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
4879 /* If this instruction is specific to a particular architecture,
4880 then set a new architecture. */
4881 if (bfd_get_mach (stdoutput
) < pa11
)
4883 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
4884 as_warn (_("could not update architecture and machine"));
4892 /* Parse a condition for a fcmp instruction. Return the numerical
4893 code associated with the condition. */
4896 pa_parse_fp_cmp_cond (s
)
4903 for (i
= 0; i
< 32; i
++)
4905 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
4906 strlen (fp_cond_map
[i
].string
)) == 0)
4908 cond
= fp_cond_map
[i
].cond
;
4909 *s
+= strlen (fp_cond_map
[i
].string
);
4910 /* If not a complete match, back up the input string and
4912 if (**s
!= ' ' && **s
!= '\t')
4914 *s
-= strlen (fp_cond_map
[i
].string
);
4917 while (**s
== ' ' || **s
== '\t')
4923 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
4925 /* Advance over the bogus completer. */
4926 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4932 /* Parse a graphics test complete for ftest. */
4935 pa_parse_ftest_gfx_completer (s
)
4941 if (strncasecmp (*s
, "acc8", 4) == 0)
4946 else if (strncasecmp (*s
, "acc6", 4) == 0)
4951 else if (strncasecmp (*s
, "acc4", 4) == 0)
4956 else if (strncasecmp (*s
, "acc2", 4) == 0)
4961 else if (strncasecmp (*s
, "acc", 3) == 0)
4966 else if (strncasecmp (*s
, "rej8", 4) == 0)
4971 else if (strncasecmp (*s
, "rej", 3) == 0)
4979 as_bad (_("Invalid FTEST completer: %s"), *s
);
4985 /* Parse an FP operand format completer returning the completer
4988 static fp_operand_format
4989 pa_parse_fp_cnv_format (s
)
4998 if (strncasecmp (*s
, "sgl", 3) == 0)
5003 else if (strncasecmp (*s
, "dbl", 3) == 0)
5008 else if (strncasecmp (*s
, "quad", 4) == 0)
5013 else if (strncasecmp (*s
, "w", 1) == 0)
5018 else if (strncasecmp (*s
, "uw", 2) == 0)
5023 else if (strncasecmp (*s
, "dw", 2) == 0)
5028 else if (strncasecmp (*s
, "udw", 3) == 0)
5033 else if (strncasecmp (*s
, "qw", 2) == 0)
5038 else if (strncasecmp (*s
, "uqw", 3) == 0)
5045 format
= ILLEGAL_FMT
;
5046 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
5053 /* Parse an FP operand format completer returning the completer
5056 static fp_operand_format
5057 pa_parse_fp_format (s
)
5066 if (strncasecmp (*s
, "sgl", 3) == 0)
5071 else if (strncasecmp (*s
, "dbl", 3) == 0)
5076 else if (strncasecmp (*s
, "quad", 4) == 0)
5083 format
= ILLEGAL_FMT
;
5084 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
5091 /* Convert from a selector string into a selector type. */
5094 pa_chk_field_selector (str
)
5097 int middle
, low
, high
;
5101 /* Read past any whitespace. */
5102 /* FIXME: should we read past newlines and formfeeds??? */
5103 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
5106 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
5107 name
[0] = tolower ((*str
)[0]),
5109 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
5110 name
[0] = tolower ((*str
)[0]),
5111 name
[1] = tolower ((*str
)[1]),
5113 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
5114 name
[0] = tolower ((*str
)[0]),
5115 name
[1] = tolower ((*str
)[1]),
5116 name
[2] = tolower ((*str
)[2]),
5122 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
5126 middle
= (low
+ high
) / 2;
5127 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
5134 *str
+= strlen (name
) + 1;
5136 if (selector_table
[middle
].field_selector
== e_nsel
)
5139 return selector_table
[middle
].field_selector
;
5142 while (low
<= high
);
5147 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
5150 get_expression (str
)
5156 save_in
= input_line_pointer
;
5157 input_line_pointer
= str
;
5158 seg
= expression (&the_insn
.exp
);
5159 if (!(seg
== absolute_section
5160 || seg
== undefined_section
5161 || SEG_NORMAL (seg
)))
5163 as_warn (_("Bad segment in expression."));
5164 expr_end
= input_line_pointer
;
5165 input_line_pointer
= save_in
;
5168 expr_end
= input_line_pointer
;
5169 input_line_pointer
= save_in
;
5173 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
5175 pa_get_absolute_expression (insn
, strp
)
5181 insn
->field_selector
= pa_chk_field_selector (strp
);
5182 save_in
= input_line_pointer
;
5183 input_line_pointer
= *strp
;
5184 expression (&insn
->exp
);
5185 /* This is not perfect, but is a huge improvement over doing nothing.
5187 The PA assembly syntax is ambigious in a variety of ways. Consider
5188 this string "4 %r5" Is that the number 4 followed by the register
5189 r5, or is that 4 MOD 5?
5191 If we get a modulo expresion When looking for an absolute, we try
5192 again cutting off the input string at the first whitespace character. */
5193 if (insn
->exp
.X_op
== O_modulus
)
5198 input_line_pointer
= *strp
;
5200 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
5206 retval
= pa_get_absolute_expression (insn
, strp
);
5208 input_line_pointer
= save_in
;
5210 return evaluate_absolute (insn
);
5212 /* When in strict mode we have a non-match, fix up the pointers
5213 and return to our caller. */
5214 if (insn
->exp
.X_op
!= O_constant
&& strict
)
5216 expr_end
= input_line_pointer
;
5217 input_line_pointer
= save_in
;
5220 if (insn
->exp
.X_op
!= O_constant
)
5222 as_bad (_("Bad segment (should be absolute)."));
5223 expr_end
= input_line_pointer
;
5224 input_line_pointer
= save_in
;
5227 expr_end
= input_line_pointer
;
5228 input_line_pointer
= save_in
;
5229 return evaluate_absolute (insn
);
5232 /* Evaluate an absolute expression EXP which may be modified by
5233 the selector FIELD_SELECTOR. Return the value of the expression. */
5235 evaluate_absolute (insn
)
5240 int field_selector
= insn
->field_selector
;
5243 value
= exp
.X_add_number
;
5245 return hppa_field_adjust (0, value
, field_selector
);
5248 /* Given an argument location specification return the associated
5249 argument location number. */
5252 pa_build_arg_reloc (type_name
)
5256 if (strncasecmp (type_name
, "no", 2) == 0)
5258 if (strncasecmp (type_name
, "gr", 2) == 0)
5260 else if (strncasecmp (type_name
, "fr", 2) == 0)
5262 else if (strncasecmp (type_name
, "fu", 2) == 0)
5265 as_bad (_("Invalid argument location: %s\n"), type_name
);
5270 /* Encode and return an argument relocation specification for
5271 the given register in the location specified by arg_reloc. */
5274 pa_align_arg_reloc (reg
, arg_reloc
)
5276 unsigned int arg_reloc
;
5278 unsigned int new_reloc
;
5280 new_reloc
= arg_reloc
;
5296 as_bad (_("Invalid argument description: %d"), reg
);
5302 /* Parse a PA nullification completer (,n). Return nonzero if the
5303 completer was found; return zero if no completer was found. */
5315 if (strncasecmp (*s
, "n", 1) == 0)
5319 as_bad (_("Invalid Nullification: (%c)"), **s
);
5328 /* Parse a non-negated compare/subtract completer returning the
5329 number (for encoding in instrutions) of the given completer.
5331 ISBRANCH specifies whether or not this is parsing a condition
5332 completer for a branch (vs a nullification completer for a
5333 computational instruction. */
5336 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
5341 char *name
= *s
+ 1;
5350 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5356 if (strcmp (name
, "=") == 0)
5360 else if (strcmp (name
, "<") == 0)
5364 else if (strcmp (name
, "<=") == 0)
5368 else if (strcmp (name
, "<<") == 0)
5372 else if (strcmp (name
, "<<=") == 0)
5376 else if (strcasecmp (name
, "sv") == 0)
5380 else if (strcasecmp (name
, "od") == 0)
5384 /* If we have something like addb,n then there is no condition
5386 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5398 /* Reset pointers if this was really a ,n for a branch instruction. */
5406 /* Parse a negated compare/subtract completer returning the
5407 number (for encoding in instrutions) of the given completer.
5409 ISBRANCH specifies whether or not this is parsing a condition
5410 completer for a branch (vs a nullification completer for a
5411 computational instruction. */
5414 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
5419 char *name
= *s
+ 1;
5428 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5434 if (strcasecmp (name
, "tr") == 0)
5438 else if (strcmp (name
, "<>") == 0)
5442 else if (strcmp (name
, ">=") == 0)
5446 else if (strcmp (name
, ">") == 0)
5450 else if (strcmp (name
, ">>=") == 0)
5454 else if (strcmp (name
, ">>") == 0)
5458 else if (strcasecmp (name
, "nsv") == 0)
5462 else if (strcasecmp (name
, "ev") == 0)
5466 /* If we have something like addb,n then there is no condition
5468 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5480 /* Reset pointers if this was really a ,n for a branch instruction. */
5489 /* Parse a 64 bit compare and branch completer returning the number (for
5490 encoding in instrutions) of the given completer.
5492 Nonnegated comparisons are returned as 0-7, negated comparisons are
5493 returned as 8-15. */
5496 pa_parse_cmpb_64_cmpltr (s
)
5500 char *name
= *s
+ 1;
5507 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5512 if (strcmp (name
, "*") == 0)
5516 else if (strcmp (name
, "*=") == 0)
5520 else if (strcmp (name
, "*<") == 0)
5524 else if (strcmp (name
, "*<=") == 0)
5528 else if (strcmp (name
, "*<<") == 0)
5532 else if (strcmp (name
, "*<<=") == 0)
5536 else if (strcasecmp (name
, "*sv") == 0)
5540 else if (strcasecmp (name
, "*od") == 0)
5544 else if (strcasecmp (name
, "*tr") == 0)
5548 else if (strcmp (name
, "*<>") == 0)
5552 else if (strcmp (name
, "*>=") == 0)
5556 else if (strcmp (name
, "*>") == 0)
5560 else if (strcmp (name
, "*>>=") == 0)
5564 else if (strcmp (name
, "*>>") == 0)
5568 else if (strcasecmp (name
, "*nsv") == 0)
5572 else if (strcasecmp (name
, "*ev") == 0)
5587 /* Parse a 64 bit compare immediate and branch completer returning the number
5588 (for encoding in instrutions) of the given completer. */
5591 pa_parse_cmpib_64_cmpltr (s
)
5595 char *name
= *s
+ 1;
5602 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5607 if (strcmp (name
, "*<<") == 0)
5611 else if (strcmp (name
, "*=") == 0)
5615 else if (strcmp (name
, "*<") == 0)
5619 else if (strcmp (name
, "*<=") == 0)
5623 else if (strcmp (name
, "*>>=") == 0)
5627 else if (strcmp (name
, "*<>") == 0)
5631 else if (strcasecmp (name
, "*>=") == 0)
5635 else if (strcasecmp (name
, "*>") == 0)
5650 /* Parse a non-negated addition completer returning the number
5651 (for encoding in instrutions) of the given completer.
5653 ISBRANCH specifies whether or not this is parsing a condition
5654 completer for a branch (vs a nullification completer for a
5655 computational instruction. */
5658 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
5663 char *name
= *s
+ 1;
5671 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5675 if (strcmp (name
, "=") == 0)
5679 else if (strcmp (name
, "<") == 0)
5683 else if (strcmp (name
, "<=") == 0)
5687 else if (strcasecmp (name
, "nuv") == 0)
5691 else if (strcasecmp (name
, "znv") == 0)
5695 else if (strcasecmp (name
, "sv") == 0)
5699 else if (strcasecmp (name
, "od") == 0)
5703 /* If we have something like addb,n then there is no condition
5705 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5716 /* Reset pointers if this was really a ,n for a branch instruction. */
5717 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5723 /* Parse a negated addition completer returning the number
5724 (for encoding in instrutions) of the given completer.
5726 ISBRANCH specifies whether or not this is parsing a condition
5727 completer for a branch (vs a nullification completer for a
5728 computational instruction). */
5731 pa_parse_neg_add_cmpltr (s
, isbranch
)
5736 char *name
= *s
+ 1;
5744 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5748 if (strcasecmp (name
, "tr") == 0)
5752 else if (strcmp (name
, "<>") == 0)
5756 else if (strcmp (name
, ">=") == 0)
5760 else if (strcmp (name
, ">") == 0)
5764 else if (strcasecmp (name
, "uv") == 0)
5768 else if (strcasecmp (name
, "vnz") == 0)
5772 else if (strcasecmp (name
, "nsv") == 0)
5776 else if (strcasecmp (name
, "ev") == 0)
5780 /* If we have something like addb,n then there is no condition
5782 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5793 /* Reset pointers if this was really a ,n for a branch instruction. */
5794 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5800 /* Parse a 64 bit wide mode add and branch completer returning the number (for
5801 encoding in instrutions) of the given completer. */
5804 pa_parse_addb_64_cmpltr (s
)
5808 char *name
= *s
+ 1;
5817 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5821 if (strcmp (name
, "=") == 0)
5825 else if (strcmp (name
, "<") == 0)
5829 else if (strcmp (name
, "<=") == 0)
5833 else if (strcasecmp (name
, "nuv") == 0)
5837 else if (strcasecmp (name
, "*=") == 0)
5841 else if (strcasecmp (name
, "*<") == 0)
5845 else if (strcasecmp (name
, "*<=") == 0)
5849 else if (strcmp (name
, "tr") == 0)
5853 else if (strcmp (name
, "<>") == 0)
5857 else if (strcmp (name
, ">=") == 0)
5861 else if (strcmp (name
, ">") == 0)
5865 else if (strcasecmp (name
, "uv") == 0)
5869 else if (strcasecmp (name
, "*<>") == 0)
5873 else if (strcasecmp (name
, "*>=") == 0)
5877 else if (strcasecmp (name
, "*>") == 0)
5881 /* If we have something like addb,n then there is no condition
5883 else if (strcasecmp (name
, "n") == 0)
5895 /* Reset pointers if this was really a ,n for a branch instruction. */
5903 /* Handle an alignment directive. Special so that we can update the
5904 alignment of the subspace if necessary. */
5908 /* We must have a valid space and subspace. */
5909 pa_check_current_space_and_subspace ();
5911 /* Let the generic gas code do most of the work. */
5912 s_align_bytes (bytes
);
5914 /* If bytes is a power of 2, then update the current subspace's
5915 alignment if necessary. */
5916 if (log2 (bytes
) != -1)
5917 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
5921 /* Handle a .BLOCK type pseudo-op. */
5925 int z ATTRIBUTE_UNUSED
;
5929 unsigned int temp_size
;
5933 /* We must have a valid space and subspace. */
5934 pa_check_current_space_and_subspace ();
5937 temp_size
= get_absolute_expression ();
5939 /* Always fill with zeros, that's what the HP assembler does. */
5942 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
5943 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
5944 memset (p
, 0, temp_size
);
5946 /* Convert 2 bytes at a time. */
5948 for (i
= 0; i
< temp_size
; i
+= 2)
5950 md_number_to_chars (p
+ i
,
5952 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
5955 pa_undefine_label ();
5956 demand_empty_rest_of_line ();
5959 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
5963 int begin ATTRIBUTE_UNUSED
;
5967 /* The BRTAB relocations are only availble in SOM (to denote
5968 the beginning and end of branch tables). */
5969 char *where
= frag_more (0);
5971 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5972 NULL
, (offsetT
) 0, NULL
,
5973 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
5974 e_fsel
, 0, 0, NULL
);
5977 demand_empty_rest_of_line ();
5980 /* Handle a .begin_try and .end_try pseudo-op. */
5984 int begin ATTRIBUTE_UNUSED
;
5988 char *where
= frag_more (0);
5993 /* The TRY relocations are only availble in SOM (to denote
5994 the beginning and end of exception handling regions). */
5996 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5997 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
5998 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
5999 e_fsel
, 0, 0, NULL
);
6002 demand_empty_rest_of_line ();
6005 /* Handle a .CALL pseudo-op. This involves storing away information
6006 about where arguments are to be found so the linker can detect
6007 (and correct) argument location mismatches between caller and callee. */
6011 int unused ATTRIBUTE_UNUSED
;
6014 /* We must have a valid space and subspace. */
6015 pa_check_current_space_and_subspace ();
6018 pa_call_args (&last_call_desc
);
6019 demand_empty_rest_of_line ();
6022 /* Do the dirty work of building a call descriptor which describes
6023 where the caller placed arguments to a function call. */
6026 pa_call_args (call_desc
)
6027 struct call_desc
*call_desc
;
6030 unsigned int temp
, arg_reloc
;
6032 while (!is_end_of_statement ())
6034 name
= input_line_pointer
;
6035 c
= get_symbol_end ();
6036 /* Process a source argument. */
6037 if ((strncasecmp (name
, "argw", 4) == 0))
6039 temp
= atoi (name
+ 4);
6040 p
= input_line_pointer
;
6042 input_line_pointer
++;
6043 name
= input_line_pointer
;
6044 c
= get_symbol_end ();
6045 arg_reloc
= pa_build_arg_reloc (name
);
6046 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
6048 /* Process a return value. */
6049 else if ((strncasecmp (name
, "rtnval", 6) == 0))
6051 p
= input_line_pointer
;
6053 input_line_pointer
++;
6054 name
= input_line_pointer
;
6055 c
= get_symbol_end ();
6056 arg_reloc
= pa_build_arg_reloc (name
);
6057 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
6061 as_bad (_("Invalid .CALL argument: %s"), name
);
6063 p
= input_line_pointer
;
6065 if (!is_end_of_statement ())
6066 input_line_pointer
++;
6070 /* Return TRUE if FRAG1 and FRAG2 are the same. */
6073 is_same_frag (frag1
, frag2
)
6080 else if (frag2
== NULL
)
6082 else if (frag1
== frag2
)
6084 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
6085 return (is_same_frag (frag1
, frag2
->fr_next
));
6091 /* Build an entry in the UNWIND subspace from the given function
6092 attributes in CALL_INFO. This is not needed for SOM as using
6093 R_ENTRY and R_EXIT relocations allow the linker to handle building
6094 of the unwind spaces. */
6097 pa_build_unwind_subspace (call_info
)
6098 struct call_info
*call_info
;
6101 asection
*seg
, *save_seg
;
6102 subsegT save_subseg
;
6107 if (now_seg
!= text_section
)
6110 if (bfd_get_arch_info (stdoutput
)->bits_per_address
== 32)
6111 reloc
= R_PARISC_DIR32
;
6113 reloc
= R_PARISC_SEGREL32
;
6116 save_subseg
= now_subseg
;
6117 /* Get into the right seg/subseg. This may involve creating
6118 the seg the first time through. Make sure to have the
6119 old seg/subseg so that we can reset things when we are done. */
6120 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
6121 if (seg
== ASEC_NULL
)
6123 seg
= subseg_new (UNWIND_SECTION_NAME
, 0);
6124 bfd_set_section_flags (stdoutput
, seg
,
6125 SEC_READONLY
| SEC_HAS_CONTENTS
6126 | SEC_LOAD
| SEC_RELOC
| SEC_ALLOC
| SEC_DATA
);
6127 bfd_set_section_alignment (stdoutput
, seg
, 2);
6130 subseg_set (seg
, 0);
6133 /* Get some space to hold relocation information for the unwind
6136 md_number_to_chars (p
, 0, 4);
6138 /* Relocation info. for start offset of the function. */
6139 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6140 call_info
->start_symbol
, (offsetT
) 0,
6141 (expressionS
*) NULL
, 0, reloc
,
6142 e_fsel
, 32, 0, NULL
);
6145 md_number_to_chars (p
, 0, 4);
6147 /* Relocation info. for end offset of the function.
6149 Because we allow reductions of 32bit relocations for ELF, this will be
6150 reduced to section_sym + offset which avoids putting the temporary
6151 symbol into the symbol table. It (should) end up giving the same
6152 value as call_info->start_symbol + function size once the linker is
6153 finished with its work. */
6155 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6156 call_info
->end_symbol
, (offsetT
) 0,
6157 (expressionS
*) NULL
, 0, reloc
,
6158 e_fsel
, 32, 0, NULL
);
6161 unwind
= (char *) &call_info
->ci_unwind
;
6162 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
6166 FRAG_APPEND_1_CHAR (c
);
6170 /* Return back to the original segment/subsegment. */
6171 subseg_set (save_seg
, save_subseg
);
6175 /* Process a .CALLINFO pseudo-op. This information is used later
6176 to build unwind descriptors and maybe one day to support
6177 .ENTER and .LEAVE. */
6180 pa_callinfo (unused
)
6181 int unused ATTRIBUTE_UNUSED
;
6187 /* We must have a valid space and subspace. */
6188 pa_check_current_space_and_subspace ();
6191 /* .CALLINFO must appear within a procedure definition. */
6192 if (!within_procedure
)
6193 as_bad (_(".callinfo is not within a procedure definition"));
6195 /* Mark the fact that we found the .CALLINFO for the
6196 current procedure. */
6197 callinfo_found
= TRUE
;
6199 /* Iterate over the .CALLINFO arguments. */
6200 while (!is_end_of_statement ())
6202 name
= input_line_pointer
;
6203 c
= get_symbol_end ();
6204 /* Frame size specification. */
6205 if ((strncasecmp (name
, "frame", 5) == 0))
6207 p
= input_line_pointer
;
6209 input_line_pointer
++;
6210 temp
= get_absolute_expression ();
6211 if ((temp
& 0x3) != 0)
6213 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
6217 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
6218 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
6221 /* Entry register (GR, GR and SR) specifications. */
6222 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
6224 p
= input_line_pointer
;
6226 input_line_pointer
++;
6227 temp
= get_absolute_expression ();
6228 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
6229 even though %r19 is caller saved. I think this is a bug in
6230 the HP assembler, and we are not going to emulate it. */
6231 if (temp
< 3 || temp
> 18)
6232 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
6233 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
6235 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
6237 p
= input_line_pointer
;
6239 input_line_pointer
++;
6240 temp
= get_absolute_expression ();
6241 /* Similarly the HP assembler takes 31 as the high bound even
6242 though %fr21 is the last callee saved floating point register. */
6243 if (temp
< 12 || temp
> 21)
6244 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
6245 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
6247 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
6249 p
= input_line_pointer
;
6251 input_line_pointer
++;
6252 temp
= get_absolute_expression ();
6254 as_bad (_("Value for ENTRY_SR must be 3\n"));
6256 /* Note whether or not this function performs any calls. */
6257 else if ((strncasecmp (name
, "calls", 5) == 0) ||
6258 (strncasecmp (name
, "caller", 6) == 0))
6260 p
= input_line_pointer
;
6263 else if ((strncasecmp (name
, "no_calls", 8) == 0))
6265 p
= input_line_pointer
;
6268 /* Should RP be saved into the stack. */
6269 else if ((strncasecmp (name
, "save_rp", 7) == 0))
6271 p
= input_line_pointer
;
6273 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
6275 /* Likewise for SP. */
6276 else if ((strncasecmp (name
, "save_sp", 7) == 0))
6278 p
= input_line_pointer
;
6280 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
6282 /* Is this an unwindable procedure. If so mark it so
6283 in the unwind descriptor. */
6284 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
6286 p
= input_line_pointer
;
6288 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
6290 /* Is this an interrupt routine. If so mark it in the
6291 unwind descriptor. */
6292 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
6294 p
= input_line_pointer
;
6296 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
6298 /* Is this a millicode routine. "millicode" isn't in my
6299 assembler manual, but my copy is old. The HP assembler
6300 accepts it, and there's a place in the unwind descriptor
6301 to drop the information, so we'll accept it too. */
6302 else if ((strncasecmp (name
, "millicode", 9) == 0))
6304 p
= input_line_pointer
;
6306 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
6310 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
6311 *input_line_pointer
= c
;
6313 if (!is_end_of_statement ())
6314 input_line_pointer
++;
6317 demand_empty_rest_of_line ();
6320 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
6321 /* Switch to the text space. Like s_text, but delete our
6322 label when finished. */
6325 int unused ATTRIBUTE_UNUSED
;
6328 current_space
= is_defined_space ("$TEXT$");
6330 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6334 pa_undefine_label ();
6337 /* Switch to the data space. As usual delete our label. */
6340 int unused ATTRIBUTE_UNUSED
;
6343 current_space
= is_defined_space ("$PRIVATE$");
6345 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6348 pa_undefine_label ();
6351 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
6352 the .comm pseudo-op has the following symtax:
6354 <label> .comm <length>
6356 where <label> is optional and is a symbol whose address will be the start of
6357 a block of memory <length> bytes long. <length> must be an absolute
6358 expression. <length> bytes will be allocated in the current space
6361 Also note the label may not even be on the same line as the .comm.
6363 This difference in syntax means the colon function will be called
6364 on the symbol before we arrive in pa_comm. colon will set a number
6365 of attributes of the symbol that need to be fixed here. In particular
6366 the value, section pointer, fragment pointer, flags, etc. What
6369 This also makes error detection all but impossible. */
6373 int unused ATTRIBUTE_UNUSED
;
6377 label_symbol_struct
*label_symbol
= pa_get_label ();
6380 symbol
= label_symbol
->lss_label
;
6385 size
= get_absolute_expression ();
6389 S_SET_VALUE (symbol
, size
);
6390 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6391 S_SET_EXTERNAL (symbol
);
6393 /* colon() has already set the frag to the current location in the
6394 current subspace; we need to reset the fragment to the zero address
6395 fragment. We also need to reset the segment pointer. */
6396 symbol_set_frag (symbol
, &zero_address_frag
);
6398 demand_empty_rest_of_line ();
6400 #endif /* !(defined (OBJ_ELF) && defined (TE_LINUX)) */
6402 /* Process a .END pseudo-op. */
6406 int unused ATTRIBUTE_UNUSED
;
6408 demand_empty_rest_of_line ();
6411 /* Process a .ENTER pseudo-op. This is not supported. */
6414 int unused ATTRIBUTE_UNUSED
;
6417 /* We must have a valid space and subspace. */
6418 pa_check_current_space_and_subspace ();
6421 as_bad (_("The .ENTER pseudo-op is not supported"));
6422 demand_empty_rest_of_line ();
6425 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
6429 int unused ATTRIBUTE_UNUSED
;
6432 /* We must have a valid space and subspace. */
6433 pa_check_current_space_and_subspace ();
6436 if (!within_procedure
)
6437 as_bad (_("Misplaced .entry. Ignored."));
6440 if (!callinfo_found
)
6441 as_bad (_("Missing .callinfo."));
6443 demand_empty_rest_of_line ();
6444 within_entry_exit
= TRUE
;
6447 /* SOM defers building of unwind descriptors until the link phase.
6448 The assembler is responsible for creating an R_ENTRY relocation
6449 to mark the beginning of a region and hold the unwind bits, and
6450 for creating an R_EXIT relocation to mark the end of the region.
6452 FIXME. ELF should be using the same conventions! The problem
6453 is an unwind requires too much relocation space. Hmmm. Maybe
6454 if we split the unwind bits up between the relocations which
6455 denote the entry and exit points. */
6456 if (last_call_info
->start_symbol
!= NULL
)
6458 char *where
= frag_more (0);
6460 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6461 NULL
, (offsetT
) 0, NULL
,
6462 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
6463 (int *) &last_call_info
->ci_unwind
.descriptor
);
6468 /* Handle a .EQU pseudo-op. */
6474 label_symbol_struct
*label_symbol
= pa_get_label ();
6479 symbol
= label_symbol
->lss_label
;
6481 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
6483 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
6484 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
6489 as_bad (_(".REG must use a label"));
6491 as_bad (_(".EQU must use a label"));
6494 pa_undefine_label ();
6495 demand_empty_rest_of_line ();
6498 /* Helper function. Does processing for the end of a function. This
6499 usually involves creating some relocations or building special
6500 symbols to mark the end of the function. */
6507 where
= frag_more (0);
6510 /* Mark the end of the function, stuff away the location of the frag
6511 for the end of the function, and finally call pa_build_unwind_subspace
6512 to add an entry in the unwind table. */
6513 hppa_elf_mark_end_of_function ();
6514 pa_build_unwind_subspace (last_call_info
);
6516 /* SOM defers building of unwind descriptors until the link phase.
6517 The assembler is responsible for creating an R_ENTRY relocation
6518 to mark the beginning of a region and hold the unwind bits, and
6519 for creating an R_EXIT relocation to mark the end of the region.
6521 FIXME. ELF should be using the same conventions! The problem
6522 is an unwind requires too much relocation space. Hmmm. Maybe
6523 if we split the unwind bits up between the relocations which
6524 denote the entry and exit points. */
6525 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6527 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
6528 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
6532 /* Process a .EXIT pseudo-op. */
6536 int unused ATTRIBUTE_UNUSED
;
6539 /* We must have a valid space and subspace. */
6540 pa_check_current_space_and_subspace ();
6543 if (!within_procedure
)
6544 as_bad (_(".EXIT must appear within a procedure"));
6547 if (!callinfo_found
)
6548 as_bad (_("Missing .callinfo"));
6551 if (!within_entry_exit
)
6552 as_bad (_("No .ENTRY for this .EXIT"));
6555 within_entry_exit
= FALSE
;
6560 demand_empty_rest_of_line ();
6563 /* Process a .EXPORT directive. This makes functions external
6564 and provides information such as argument relocation entries
6569 int unused ATTRIBUTE_UNUSED
;
6574 name
= input_line_pointer
;
6575 c
= get_symbol_end ();
6576 /* Make sure the given symbol exists. */
6577 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6579 as_bad (_("Cannot define export symbol: %s\n"), name
);
6580 p
= input_line_pointer
;
6582 input_line_pointer
++;
6586 /* OK. Set the external bits and process argument relocations.
6587 For the HP, weak and global are not mutually exclusive.
6588 S_SET_EXTERNAL will not set BSF_GLOBAL if WEAK is set.
6589 Call S_SET_EXTERNAL to get the other processing. Manually
6590 set BSF_GLOBAL when we get back. */
6591 S_SET_EXTERNAL (symbol
);
6592 symbol_get_bfdsym (symbol
)->flags
|= BSF_GLOBAL
;
6593 p
= input_line_pointer
;
6595 if (!is_end_of_statement ())
6597 input_line_pointer
++;
6598 pa_type_args (symbol
, 1);
6602 demand_empty_rest_of_line ();
6605 /* Helper function to process arguments to a .EXPORT pseudo-op. */
6608 pa_type_args (symbolP
, is_export
)
6613 unsigned int temp
, arg_reloc
;
6614 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
6615 asymbol
*bfdsym
= symbol_get_bfdsym (symbolP
);
6617 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
6620 input_line_pointer
+= 8;
6621 bfdsym
->flags
&= ~BSF_FUNCTION
;
6622 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
6623 type
= SYMBOL_TYPE_ABSOLUTE
;
6625 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
6627 input_line_pointer
+= 4;
6628 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
6629 instead one should be IMPORTing/EXPORTing ENTRY types.
6631 Complain if one tries to EXPORT a CODE type since that's never
6632 done. Both GCC and HP C still try to IMPORT CODE types, so
6633 silently fix them to be ENTRY types. */
6634 if (S_IS_FUNCTION (symbolP
))
6637 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
6638 S_GET_NAME (symbolP
));
6640 bfdsym
->flags
|= BSF_FUNCTION
;
6641 type
= SYMBOL_TYPE_ENTRY
;
6645 bfdsym
->flags
&= ~BSF_FUNCTION
;
6646 type
= SYMBOL_TYPE_CODE
;
6649 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
6651 input_line_pointer
+= 4;
6652 bfdsym
->flags
&= ~BSF_FUNCTION
;
6653 bfdsym
->flags
|= BSF_OBJECT
;
6654 type
= SYMBOL_TYPE_DATA
;
6656 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
6658 input_line_pointer
+= 5;
6659 bfdsym
->flags
|= BSF_FUNCTION
;
6660 type
= SYMBOL_TYPE_ENTRY
;
6662 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
6664 input_line_pointer
+= 9;
6665 bfdsym
->flags
|= BSF_FUNCTION
;
6668 elf_symbol_type
*elfsym
= (elf_symbol_type
*) bfdsym
;
6669 elfsym
->internal_elf_sym
.st_info
=
6670 ELF_ST_INFO (ELF_ST_BIND (elfsym
->internal_elf_sym
.st_info
),
6674 type
= SYMBOL_TYPE_MILLICODE
;
6676 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
6678 input_line_pointer
+= 6;
6679 bfdsym
->flags
&= ~BSF_FUNCTION
;
6680 type
= SYMBOL_TYPE_PLABEL
;
6682 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
6684 input_line_pointer
+= 8;
6685 bfdsym
->flags
|= BSF_FUNCTION
;
6686 type
= SYMBOL_TYPE_PRI_PROG
;
6688 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
6690 input_line_pointer
+= 8;
6691 bfdsym
->flags
|= BSF_FUNCTION
;
6692 type
= SYMBOL_TYPE_SEC_PROG
;
6695 /* SOM requires much more information about symbol types
6696 than BFD understands. This is how we get this information
6697 to the SOM BFD backend. */
6698 #ifdef obj_set_symbol_type
6699 obj_set_symbol_type (bfdsym
, (int) type
);
6702 /* Now that the type of the exported symbol has been handled,
6703 handle any argument relocation information. */
6704 while (!is_end_of_statement ())
6706 if (*input_line_pointer
== ',')
6707 input_line_pointer
++;
6708 name
= input_line_pointer
;
6709 c
= get_symbol_end ();
6710 /* Argument sources. */
6711 if ((strncasecmp (name
, "argw", 4) == 0))
6713 p
= input_line_pointer
;
6715 input_line_pointer
++;
6716 temp
= atoi (name
+ 4);
6717 name
= input_line_pointer
;
6718 c
= get_symbol_end ();
6719 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
6720 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
6721 symbol_arg_reloc_info (symbolP
) |= arg_reloc
;
6723 *input_line_pointer
= c
;
6725 /* The return value. */
6726 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
6728 p
= input_line_pointer
;
6730 input_line_pointer
++;
6731 name
= input_line_pointer
;
6732 c
= get_symbol_end ();
6733 arg_reloc
= pa_build_arg_reloc (name
);
6734 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
6735 symbol_arg_reloc_info (symbolP
) |= arg_reloc
;
6737 *input_line_pointer
= c
;
6739 /* Privelege level. */
6740 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
6742 p
= input_line_pointer
;
6744 input_line_pointer
++;
6745 temp
= atoi (input_line_pointer
);
6747 ((obj_symbol_type
*) bfdsym
)->tc_data
.ap
.hppa_priv_level
= temp
;
6749 c
= get_symbol_end ();
6750 *input_line_pointer
= c
;
6754 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
6755 p
= input_line_pointer
;
6758 if (!is_end_of_statement ())
6759 input_line_pointer
++;
6763 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
6764 assembly file must either be defined in the assembly file, or
6765 explicitly IMPORTED from another. */
6769 int unused ATTRIBUTE_UNUSED
;
6774 name
= input_line_pointer
;
6775 c
= get_symbol_end ();
6777 symbol
= symbol_find (name
);
6778 /* Ugh. We might be importing a symbol defined earlier in the file,
6779 in which case all the code below will really screw things up
6780 (set the wrong segment, symbol flags & type, etc). */
6781 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
6783 symbol
= symbol_find_or_make (name
);
6784 p
= input_line_pointer
;
6787 if (!is_end_of_statement ())
6789 input_line_pointer
++;
6790 pa_type_args (symbol
, 0);
6794 /* Sigh. To be compatable with the HP assembler and to help
6795 poorly written assembly code, we assign a type based on
6796 the the current segment. Note only BSF_FUNCTION really
6797 matters, we do not need to set the full SYMBOL_TYPE_* info. */
6798 if (now_seg
== text_section
)
6799 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
6801 /* If the section is undefined, then the symbol is undefined
6802 Since this is an import, leave the section undefined. */
6803 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6808 /* The symbol was already defined. Just eat everything up to
6809 the end of the current statement. */
6810 while (!is_end_of_statement ())
6811 input_line_pointer
++;
6814 demand_empty_rest_of_line ();
6817 /* Handle a .LABEL pseudo-op. */
6821 int unused ATTRIBUTE_UNUSED
;
6825 name
= input_line_pointer
;
6826 c
= get_symbol_end ();
6828 if (strlen (name
) > 0)
6831 p
= input_line_pointer
;
6836 as_warn (_("Missing label name on .LABEL"));
6839 if (!is_end_of_statement ())
6841 as_warn (_("extra .LABEL arguments ignored."));
6842 ignore_rest_of_line ();
6844 demand_empty_rest_of_line ();
6847 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
6851 int unused ATTRIBUTE_UNUSED
;
6854 /* We must have a valid space and subspace. */
6855 pa_check_current_space_and_subspace ();
6858 as_bad (_("The .LEAVE pseudo-op is not supported"));
6859 demand_empty_rest_of_line ();
6862 /* Handle a .LEVEL pseudo-op. */
6866 int unused ATTRIBUTE_UNUSED
;
6870 level
= input_line_pointer
;
6871 if (strncmp (level
, "1.0", 3) == 0)
6873 input_line_pointer
+= 3;
6874 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
6875 as_warn (_("could not set architecture and machine"));
6877 else if (strncmp (level
, "1.1", 3) == 0)
6879 input_line_pointer
+= 3;
6880 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
6881 as_warn (_("could not set architecture and machine"));
6883 else if (strncmp (level
, "2.0w", 4) == 0)
6885 input_line_pointer
+= 4;
6886 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 25))
6887 as_warn (_("could not set architecture and machine"));
6889 else if (strncmp (level
, "2.0", 3) == 0)
6891 input_line_pointer
+= 3;
6892 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
6893 as_warn (_("could not set architecture and machine"));
6897 as_bad (_("Unrecognized .LEVEL argument\n"));
6898 ignore_rest_of_line ();
6900 demand_empty_rest_of_line ();
6903 /* Handle a .ORIGIN pseudo-op. */
6907 int unused ATTRIBUTE_UNUSED
;
6910 /* We must have a valid space and subspace. */
6911 pa_check_current_space_and_subspace ();
6915 pa_undefine_label ();
6918 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
6919 is for static functions. FIXME. Should share more code with .EXPORT. */
6923 int unused ATTRIBUTE_UNUSED
;
6928 name
= input_line_pointer
;
6929 c
= get_symbol_end ();
6931 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6933 as_bad (_("Cannot define static symbol: %s\n"), name
);
6934 p
= input_line_pointer
;
6936 input_line_pointer
++;
6940 S_CLEAR_EXTERNAL (symbol
);
6941 p
= input_line_pointer
;
6943 if (!is_end_of_statement ())
6945 input_line_pointer
++;
6946 pa_type_args (symbol
, 0);
6950 demand_empty_rest_of_line ();
6953 /* Handle a .PROC pseudo-op. It is used to mark the beginning
6954 of a procedure from a syntactical point of view. */
6958 int unused ATTRIBUTE_UNUSED
;
6960 struct call_info
*call_info
;
6963 /* We must have a valid space and subspace. */
6964 pa_check_current_space_and_subspace ();
6967 if (within_procedure
)
6968 as_fatal (_("Nested procedures"));
6970 /* Reset global variables for new procedure. */
6971 callinfo_found
= FALSE
;
6972 within_procedure
= TRUE
;
6974 /* Create another call_info structure. */
6975 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
6978 as_fatal (_("Cannot allocate unwind descriptor\n"));
6980 memset (call_info
, 0, sizeof (struct call_info
));
6982 call_info
->ci_next
= NULL
;
6984 if (call_info_root
== NULL
)
6986 call_info_root
= call_info
;
6987 last_call_info
= call_info
;
6991 last_call_info
->ci_next
= call_info
;
6992 last_call_info
= call_info
;
6995 /* set up defaults on call_info structure */
6997 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
6998 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
6999 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
7001 /* If we got a .PROC pseudo-op, we know that the function is defined
7002 locally. Make sure it gets into the symbol table. */
7004 label_symbol_struct
*label_symbol
= pa_get_label ();
7008 if (label_symbol
->lss_label
)
7010 last_call_info
->start_symbol
= label_symbol
->lss_label
;
7011 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
7014 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
7017 last_call_info
->start_symbol
= NULL
;
7020 demand_empty_rest_of_line ();
7023 /* Process the syntatical end of a procedure. Make sure all the
7024 appropriate pseudo-ops were found within the procedure. */
7028 int unused ATTRIBUTE_UNUSED
;
7032 /* We must have a valid space and subspace. */
7033 pa_check_current_space_and_subspace ();
7036 /* If we are within a procedure definition, make sure we've
7037 defined a label for the procedure; handle case where the
7038 label was defined after the .PROC directive.
7040 Note there's not need to diddle with the segment or fragment
7041 for the label symbol in this case. We have already switched
7042 into the new $CODE$ subspace at this point. */
7043 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
7045 label_symbol_struct
*label_symbol
= pa_get_label ();
7049 if (label_symbol
->lss_label
)
7051 last_call_info
->start_symbol
= label_symbol
->lss_label
;
7052 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
7055 /* Also handle allocation of a fixup to hold the unwind
7056 information when the label appears after the proc/procend. */
7057 if (within_entry_exit
)
7059 char *where
= frag_more (0);
7061 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
7062 NULL
, (offsetT
) 0, NULL
,
7063 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
7064 (int *) &last_call_info
->ci_unwind
.descriptor
);
7069 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
7072 as_bad (_("Missing function name for .PROC"));
7075 if (!within_procedure
)
7076 as_bad (_("misplaced .procend"));
7078 if (!callinfo_found
)
7079 as_bad (_("Missing .callinfo for this procedure"));
7081 if (within_entry_exit
)
7082 as_bad (_("Missing .EXIT for a .ENTRY"));
7085 /* ELF needs to mark the end of each function so that it can compute
7086 the size of the function (apparently its needed in the symbol table). */
7087 hppa_elf_mark_end_of_function ();
7090 within_procedure
= FALSE
;
7091 demand_empty_rest_of_line ();
7092 pa_undefine_label ();
7097 /* If VALUE is an exact power of two between zero and 2^31, then
7098 return log2 (VALUE). Else return -1. */
7106 while ((1 << shift
) != value
&& shift
< 32)
7115 /* Check to make sure we have a valid space and subspace. */
7118 pa_check_current_space_and_subspace ()
7120 if (current_space
== NULL
)
7121 as_fatal (_("Not in a space.\n"));
7123 if (current_subspace
== NULL
)
7124 as_fatal (_("Not in a subspace.\n"));
7127 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
7128 then create a new space entry to hold the information specified
7129 by the parameters to the .SPACE directive. */
7131 static sd_chain_struct
*
7132 pa_parse_space_stmt (space_name
, create_flag
)
7136 char *name
, *ptemp
, c
;
7137 char loadable
, defined
, private, sort
;
7139 asection
*seg
= NULL
;
7140 sd_chain_struct
*space
;
7142 /* load default values */
7148 if (strcmp (space_name
, "$TEXT$") == 0)
7150 seg
= pa_def_spaces
[0].segment
;
7151 defined
= pa_def_spaces
[0].defined
;
7152 private = pa_def_spaces
[0].private;
7153 sort
= pa_def_spaces
[0].sort
;
7154 spnum
= pa_def_spaces
[0].spnum
;
7156 else if (strcmp (space_name
, "$PRIVATE$") == 0)
7158 seg
= pa_def_spaces
[1].segment
;
7159 defined
= pa_def_spaces
[1].defined
;
7160 private = pa_def_spaces
[1].private;
7161 sort
= pa_def_spaces
[1].sort
;
7162 spnum
= pa_def_spaces
[1].spnum
;
7165 if (!is_end_of_statement ())
7167 print_errors
= FALSE
;
7168 ptemp
= input_line_pointer
+ 1;
7169 /* First see if the space was specified as a number rather than
7170 as a name. According to the PA assembly manual the rest of
7171 the line should be ignored. */
7172 temp
= pa_parse_number (&ptemp
, 0);
7176 input_line_pointer
= ptemp
;
7180 while (!is_end_of_statement ())
7182 input_line_pointer
++;
7183 name
= input_line_pointer
;
7184 c
= get_symbol_end ();
7185 if ((strncasecmp (name
, "spnum", 5) == 0))
7187 *input_line_pointer
= c
;
7188 input_line_pointer
++;
7189 spnum
= get_absolute_expression ();
7191 else if ((strncasecmp (name
, "sort", 4) == 0))
7193 *input_line_pointer
= c
;
7194 input_line_pointer
++;
7195 sort
= get_absolute_expression ();
7197 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7199 *input_line_pointer
= c
;
7202 else if ((strncasecmp (name
, "notdefined", 10) == 0))
7204 *input_line_pointer
= c
;
7207 else if ((strncasecmp (name
, "private", 7) == 0))
7209 *input_line_pointer
= c
;
7214 as_bad (_("Invalid .SPACE argument"));
7215 *input_line_pointer
= c
;
7216 if (!is_end_of_statement ())
7217 input_line_pointer
++;
7221 print_errors
= TRUE
;
7224 if (create_flag
&& seg
== NULL
)
7225 seg
= subseg_new (space_name
, 0);
7227 /* If create_flag is nonzero, then create the new space with
7228 the attributes computed above. Else set the values in
7229 an already existing space -- this can only happen for
7230 the first occurence of a built-in space. */
7232 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
7233 private, sort
, seg
, 1);
7236 space
= is_defined_space (space_name
);
7237 SPACE_SPNUM (space
) = spnum
;
7238 SPACE_DEFINED (space
) = defined
& 1;
7239 SPACE_USER_DEFINED (space
) = 1;
7242 #ifdef obj_set_section_attributes
7243 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7249 /* Handle a .SPACE pseudo-op; this switches the current space to the
7250 given space, creating the new space if necessary. */
7254 int unused ATTRIBUTE_UNUSED
;
7256 char *name
, c
, *space_name
, *save_s
;
7258 sd_chain_struct
*sd_chain
;
7260 if (within_procedure
)
7262 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
7263 ignore_rest_of_line ();
7267 /* Check for some of the predefined spaces. FIXME: most of the code
7268 below is repeated several times, can we extract the common parts
7269 and place them into a subroutine or something similar? */
7270 /* FIXME Is this (and the next IF stmt) really right?
7271 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
7272 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
7274 input_line_pointer
+= 6;
7275 sd_chain
= is_defined_space ("$TEXT$");
7276 if (sd_chain
== NULL
)
7277 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
7278 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7279 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
7281 current_space
= sd_chain
;
7282 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
7284 = pa_subsegment_to_subspace (text_section
,
7285 sd_chain
->sd_last_subseg
);
7286 demand_empty_rest_of_line ();
7289 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
7291 input_line_pointer
+= 9;
7292 sd_chain
= is_defined_space ("$PRIVATE$");
7293 if (sd_chain
== NULL
)
7294 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
7295 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7296 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
7298 current_space
= sd_chain
;
7299 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
7301 = pa_subsegment_to_subspace (data_section
,
7302 sd_chain
->sd_last_subseg
);
7303 demand_empty_rest_of_line ();
7306 if (!strncasecmp (input_line_pointer
,
7307 GDB_DEBUG_SPACE_NAME
,
7308 strlen (GDB_DEBUG_SPACE_NAME
)))
7310 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
7311 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
7312 if (sd_chain
== NULL
)
7313 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
7314 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7315 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
7317 current_space
= sd_chain
;
7320 asection
*gdb_section
7321 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
7323 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
7325 = pa_subsegment_to_subspace (gdb_section
,
7326 sd_chain
->sd_last_subseg
);
7328 demand_empty_rest_of_line ();
7332 /* It could be a space specified by number. */
7334 save_s
= input_line_pointer
;
7335 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
7337 if ((sd_chain
= pa_find_space_by_number (temp
)))
7339 current_space
= sd_chain
;
7341 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7343 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7344 sd_chain
->sd_last_subseg
);
7345 demand_empty_rest_of_line ();
7350 /* Not a number, attempt to create a new space. */
7352 input_line_pointer
= save_s
;
7353 name
= input_line_pointer
;
7354 c
= get_symbol_end ();
7355 space_name
= xmalloc (strlen (name
) + 1);
7356 strcpy (space_name
, name
);
7357 *input_line_pointer
= c
;
7359 sd_chain
= pa_parse_space_stmt (space_name
, 1);
7360 current_space
= sd_chain
;
7362 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7363 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7364 sd_chain
->sd_last_subseg
);
7365 demand_empty_rest_of_line ();
7369 /* Switch to a new space. (I think). FIXME. */
7373 int unused ATTRIBUTE_UNUSED
;
7378 sd_chain_struct
*space
;
7380 name
= input_line_pointer
;
7381 c
= get_symbol_end ();
7382 space
= is_defined_space (name
);
7386 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
7389 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
7391 *input_line_pointer
= c
;
7392 demand_empty_rest_of_line ();
7395 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
7396 given subspace, creating the new subspace if necessary.
7398 FIXME. Should mirror pa_space more closely, in particular how
7399 they're broken up into subroutines. */
7402 pa_subspace (create_new
)
7405 char *name
, *ss_name
, c
;
7406 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
7407 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
7408 sd_chain_struct
*space
;
7409 ssd_chain_struct
*ssd
;
7412 if (current_space
== NULL
)
7413 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
7415 if (within_procedure
)
7417 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
7418 ignore_rest_of_line ();
7422 name
= input_line_pointer
;
7423 c
= get_symbol_end ();
7424 ss_name
= xmalloc (strlen (name
) + 1);
7425 strcpy (ss_name
, name
);
7426 *input_line_pointer
= c
;
7428 /* Load default values. */
7440 space
= current_space
;
7444 ssd
= is_defined_subspace (ss_name
);
7445 /* Allow user to override the builtin attributes of subspaces. But
7446 only allow the attributes to be changed once! */
7447 if (ssd
&& SUBSPACE_DEFINED (ssd
))
7449 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
7450 current_subspace
= ssd
;
7451 if (!is_end_of_statement ())
7452 as_warn (_("Parameters of an existing subspace can\'t be modified"));
7453 demand_empty_rest_of_line ();
7458 /* A new subspace. Load default values if it matches one of
7459 the builtin subspaces. */
7461 while (pa_def_subspaces
[i
].name
)
7463 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
7465 loadable
= pa_def_subspaces
[i
].loadable
;
7466 common
= pa_def_subspaces
[i
].common
;
7467 dup_common
= pa_def_subspaces
[i
].dup_common
;
7468 code_only
= pa_def_subspaces
[i
].code_only
;
7469 zero
= pa_def_subspaces
[i
].zero
;
7470 space_index
= pa_def_subspaces
[i
].space_index
;
7471 alignment
= pa_def_subspaces
[i
].alignment
;
7472 quadrant
= pa_def_subspaces
[i
].quadrant
;
7473 access
= pa_def_subspaces
[i
].access
;
7474 sort
= pa_def_subspaces
[i
].sort
;
7481 /* We should be working with a new subspace now. Fill in
7482 any information as specified by the user. */
7483 if (!is_end_of_statement ())
7485 input_line_pointer
++;
7486 while (!is_end_of_statement ())
7488 name
= input_line_pointer
;
7489 c
= get_symbol_end ();
7490 if ((strncasecmp (name
, "quad", 4) == 0))
7492 *input_line_pointer
= c
;
7493 input_line_pointer
++;
7494 quadrant
= get_absolute_expression ();
7496 else if ((strncasecmp (name
, "align", 5) == 0))
7498 *input_line_pointer
= c
;
7499 input_line_pointer
++;
7500 alignment
= get_absolute_expression ();
7501 if (log2 (alignment
) == -1)
7503 as_bad (_("Alignment must be a power of 2"));
7507 else if ((strncasecmp (name
, "access", 6) == 0))
7509 *input_line_pointer
= c
;
7510 input_line_pointer
++;
7511 access
= get_absolute_expression ();
7513 else if ((strncasecmp (name
, "sort", 4) == 0))
7515 *input_line_pointer
= c
;
7516 input_line_pointer
++;
7517 sort
= get_absolute_expression ();
7519 else if ((strncasecmp (name
, "code_only", 9) == 0))
7521 *input_line_pointer
= c
;
7524 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7526 *input_line_pointer
= c
;
7529 else if ((strncasecmp (name
, "common", 6) == 0))
7531 *input_line_pointer
= c
;
7534 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
7536 *input_line_pointer
= c
;
7539 else if ((strncasecmp (name
, "zero", 4) == 0))
7541 *input_line_pointer
= c
;
7544 else if ((strncasecmp (name
, "first", 5) == 0))
7545 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
7547 as_bad (_("Invalid .SUBSPACE argument"));
7548 if (!is_end_of_statement ())
7549 input_line_pointer
++;
7553 /* Compute a reasonable set of BFD flags based on the information
7554 in the .subspace directive. */
7555 applicable
= bfd_applicable_section_flags (stdoutput
);
7558 flags
|= (SEC_ALLOC
| SEC_LOAD
);
7561 if (common
|| dup_common
)
7562 flags
|= SEC_IS_COMMON
;
7564 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
7566 /* This is a zero-filled subspace (eg BSS). */
7568 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
7570 applicable
&= flags
;
7572 /* If this is an existing subspace, then we want to use the
7573 segment already associated with the subspace.
7575 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
7576 lots of sections. It might be a problem in the PA ELF
7577 code, I do not know yet. For now avoid creating anything
7578 but the "standard" sections for ELF. */
7580 section
= subseg_force_new (ss_name
, 0);
7582 section
= ssd
->ssd_seg
;
7584 section
= subseg_new (ss_name
, 0);
7587 seg_info (section
)->bss
= 1;
7589 /* Now set the flags. */
7590 bfd_set_section_flags (stdoutput
, section
, applicable
);
7592 /* Record any alignment request for this section. */
7593 record_alignment (section
, log2 (alignment
));
7595 /* Set the starting offset for this section. */
7596 bfd_set_section_vma (stdoutput
, section
,
7597 pa_subspace_start (space
, quadrant
));
7599 /* Now that all the flags are set, update an existing subspace,
7600 or create a new one. */
7603 current_subspace
= update_subspace (space
, ss_name
, loadable
,
7604 code_only
, common
, dup_common
,
7605 sort
, zero
, access
, space_index
,
7606 alignment
, quadrant
,
7609 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
7611 dup_common
, zero
, sort
,
7612 access
, space_index
,
7613 alignment
, quadrant
, section
);
7615 demand_empty_rest_of_line ();
7616 current_subspace
->ssd_seg
= section
;
7617 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
7619 SUBSPACE_DEFINED (current_subspace
) = 1;
7623 /* Create default space and subspace dictionaries. */
7630 space_dict_root
= NULL
;
7631 space_dict_last
= NULL
;
7634 while (pa_def_spaces
[i
].name
)
7638 /* Pick the right name to use for the new section. */
7639 name
= pa_def_spaces
[i
].name
;
7641 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
7642 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
7643 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
7644 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
7645 pa_def_spaces
[i
].segment
, 0);
7650 while (pa_def_subspaces
[i
].name
)
7653 int applicable
, subsegment
;
7654 asection
*segment
= NULL
;
7655 sd_chain_struct
*space
;
7657 /* Pick the right name for the new section and pick the right
7658 subsegment number. */
7659 name
= pa_def_subspaces
[i
].name
;
7662 /* Create the new section. */
7663 segment
= subseg_new (name
, subsegment
);
7666 /* For SOM we want to replace the standard .text, .data, and .bss
7667 sections with our own. We also want to set BFD flags for
7668 all the built-in subspaces. */
7669 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
7671 text_section
= segment
;
7672 applicable
= bfd_applicable_section_flags (stdoutput
);
7673 bfd_set_section_flags (stdoutput
, segment
,
7674 applicable
& (SEC_ALLOC
| SEC_LOAD
7675 | SEC_RELOC
| SEC_CODE
7677 | SEC_HAS_CONTENTS
));
7679 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
7681 data_section
= segment
;
7682 applicable
= bfd_applicable_section_flags (stdoutput
);
7683 bfd_set_section_flags (stdoutput
, segment
,
7684 applicable
& (SEC_ALLOC
| SEC_LOAD
7686 | SEC_HAS_CONTENTS
));
7690 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
7692 bss_section
= segment
;
7693 applicable
= bfd_applicable_section_flags (stdoutput
);
7694 bfd_set_section_flags (stdoutput
, segment
,
7695 applicable
& SEC_ALLOC
);
7697 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
7699 applicable
= bfd_applicable_section_flags (stdoutput
);
7700 bfd_set_section_flags (stdoutput
, segment
,
7701 applicable
& (SEC_ALLOC
| SEC_LOAD
7704 | SEC_HAS_CONTENTS
));
7706 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
7708 applicable
= bfd_applicable_section_flags (stdoutput
);
7709 bfd_set_section_flags (stdoutput
, segment
,
7710 applicable
& (SEC_ALLOC
| SEC_LOAD
7713 | SEC_HAS_CONTENTS
));
7715 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
7717 applicable
= bfd_applicable_section_flags (stdoutput
);
7718 bfd_set_section_flags (stdoutput
, segment
,
7719 applicable
& (SEC_ALLOC
| SEC_LOAD
7722 | SEC_HAS_CONTENTS
));
7725 /* Find the space associated with this subspace. */
7726 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
7727 def_space_index
].segment
);
7730 as_fatal (_("Internal error: Unable to find containing space for %s."),
7731 pa_def_subspaces
[i
].name
);
7734 create_new_subspace (space
, name
,
7735 pa_def_subspaces
[i
].loadable
,
7736 pa_def_subspaces
[i
].code_only
,
7737 pa_def_subspaces
[i
].common
,
7738 pa_def_subspaces
[i
].dup_common
,
7739 pa_def_subspaces
[i
].zero
,
7740 pa_def_subspaces
[i
].sort
,
7741 pa_def_subspaces
[i
].access
,
7742 pa_def_subspaces
[i
].space_index
,
7743 pa_def_subspaces
[i
].alignment
,
7744 pa_def_subspaces
[i
].quadrant
,
7752 /* Create a new space NAME, with the appropriate flags as defined
7753 by the given parameters. */
7755 static sd_chain_struct
*
7756 create_new_space (name
, spnum
, loadable
, defined
, private,
7757 sort
, seg
, user_defined
)
7767 sd_chain_struct
*chain_entry
;
7769 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
7771 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
7774 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7775 strcpy (SPACE_NAME (chain_entry
), name
);
7776 SPACE_DEFINED (chain_entry
) = defined
;
7777 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
7778 SPACE_SPNUM (chain_entry
) = spnum
;
7780 chain_entry
->sd_seg
= seg
;
7781 chain_entry
->sd_last_subseg
= -1;
7782 chain_entry
->sd_subspaces
= NULL
;
7783 chain_entry
->sd_next
= NULL
;
7785 /* Find spot for the new space based on its sort key. */
7786 if (!space_dict_last
)
7787 space_dict_last
= chain_entry
;
7789 if (space_dict_root
== NULL
)
7790 space_dict_root
= chain_entry
;
7793 sd_chain_struct
*chain_pointer
;
7794 sd_chain_struct
*prev_chain_pointer
;
7796 chain_pointer
= space_dict_root
;
7797 prev_chain_pointer
= NULL
;
7799 while (chain_pointer
)
7801 prev_chain_pointer
= chain_pointer
;
7802 chain_pointer
= chain_pointer
->sd_next
;
7805 /* At this point we've found the correct place to add the new
7806 entry. So add it and update the linked lists as appropriate. */
7807 if (prev_chain_pointer
)
7809 chain_entry
->sd_next
= chain_pointer
;
7810 prev_chain_pointer
->sd_next
= chain_entry
;
7814 space_dict_root
= chain_entry
;
7815 chain_entry
->sd_next
= chain_pointer
;
7818 if (chain_entry
->sd_next
== NULL
)
7819 space_dict_last
= chain_entry
;
7822 /* This is here to catch predefined spaces which do not get
7823 modified by the user's input. Another call is found at
7824 the bottom of pa_parse_space_stmt to handle cases where
7825 the user modifies a predefined space. */
7826 #ifdef obj_set_section_attributes
7827 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7833 /* Create a new subspace NAME, with the appropriate flags as defined
7834 by the given parameters.
7836 Add the new subspace to the subspace dictionary chain in numerical
7837 order as defined by the SORT entries. */
7839 static ssd_chain_struct
*
7840 create_new_subspace (space
, name
, loadable
, code_only
, common
,
7841 dup_common
, is_zero
, sort
, access
, space_index
,
7842 alignment
, quadrant
, seg
)
7843 sd_chain_struct
*space
;
7845 int loadable
, code_only
, common
, dup_common
, is_zero
;
7853 ssd_chain_struct
*chain_entry
;
7855 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
7857 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
7859 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7860 strcpy (SUBSPACE_NAME (chain_entry
), name
);
7862 /* Initialize subspace_defined. When we hit a .subspace directive
7863 we'll set it to 1 which "locks-in" the subspace attributes. */
7864 SUBSPACE_DEFINED (chain_entry
) = 0;
7866 chain_entry
->ssd_subseg
= 0;
7867 chain_entry
->ssd_seg
= seg
;
7868 chain_entry
->ssd_next
= NULL
;
7870 /* Find spot for the new subspace based on its sort key. */
7871 if (space
->sd_subspaces
== NULL
)
7872 space
->sd_subspaces
= chain_entry
;
7875 ssd_chain_struct
*chain_pointer
;
7876 ssd_chain_struct
*prev_chain_pointer
;
7878 chain_pointer
= space
->sd_subspaces
;
7879 prev_chain_pointer
= NULL
;
7881 while (chain_pointer
)
7883 prev_chain_pointer
= chain_pointer
;
7884 chain_pointer
= chain_pointer
->ssd_next
;
7887 /* Now we have somewhere to put the new entry. Insert it and update
7889 if (prev_chain_pointer
)
7891 chain_entry
->ssd_next
= chain_pointer
;
7892 prev_chain_pointer
->ssd_next
= chain_entry
;
7896 space
->sd_subspaces
= chain_entry
;
7897 chain_entry
->ssd_next
= chain_pointer
;
7901 #ifdef obj_set_subsection_attributes
7902 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
7909 /* Update the information for the given subspace based upon the
7910 various arguments. Return the modified subspace chain entry. */
7912 static ssd_chain_struct
*
7913 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
7914 zero
, access
, space_index
, alignment
, quadrant
, section
)
7915 sd_chain_struct
*space
;
7929 ssd_chain_struct
*chain_entry
;
7931 chain_entry
= is_defined_subspace (name
);
7933 #ifdef obj_set_subsection_attributes
7934 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
7941 /* Return the space chain entry for the space with the name NAME or
7942 NULL if no such space exists. */
7944 static sd_chain_struct
*
7945 is_defined_space (name
)
7948 sd_chain_struct
*chain_pointer
;
7950 for (chain_pointer
= space_dict_root
;
7952 chain_pointer
= chain_pointer
->sd_next
)
7954 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
7955 return chain_pointer
;
7958 /* No mapping from segment to space was found. Return NULL. */
7962 /* Find and return the space associated with the given seg. If no mapping
7963 from the given seg to a space is found, then return NULL.
7965 Unlike subspaces, the number of spaces is not expected to grow much,
7966 so a linear exhaustive search is OK here. */
7968 static sd_chain_struct
*
7969 pa_segment_to_space (seg
)
7972 sd_chain_struct
*space_chain
;
7974 /* Walk through each space looking for the correct mapping. */
7975 for (space_chain
= space_dict_root
;
7977 space_chain
= space_chain
->sd_next
)
7979 if (space_chain
->sd_seg
== seg
)
7983 /* Mapping was not found. Return NULL. */
7987 /* Return the space chain entry for the subspace with the name NAME or
7988 NULL if no such subspace exists.
7990 Uses a linear search through all the spaces and subspaces, this may
7991 not be appropriate if we ever being placing each function in its
7994 static ssd_chain_struct
*
7995 is_defined_subspace (name
)
7998 sd_chain_struct
*space_chain
;
7999 ssd_chain_struct
*subspace_chain
;
8001 /* Walk through each space. */
8002 for (space_chain
= space_dict_root
;
8004 space_chain
= space_chain
->sd_next
)
8006 /* Walk through each subspace looking for a name which matches. */
8007 for (subspace_chain
= space_chain
->sd_subspaces
;
8009 subspace_chain
= subspace_chain
->ssd_next
)
8010 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
8011 return subspace_chain
;
8014 /* Subspace wasn't found. Return NULL. */
8018 /* Find and return the subspace associated with the given seg. If no
8019 mapping from the given seg to a subspace is found, then return NULL.
8021 If we ever put each procedure/function within its own subspace
8022 (to make life easier on the compiler and linker), then this will have
8023 to become more efficient. */
8025 static ssd_chain_struct
*
8026 pa_subsegment_to_subspace (seg
, subseg
)
8030 sd_chain_struct
*space_chain
;
8031 ssd_chain_struct
*subspace_chain
;
8033 /* Walk through each space. */
8034 for (space_chain
= space_dict_root
;
8036 space_chain
= space_chain
->sd_next
)
8038 if (space_chain
->sd_seg
== seg
)
8040 /* Walk through each subspace within each space looking for
8041 the correct mapping. */
8042 for (subspace_chain
= space_chain
->sd_subspaces
;
8044 subspace_chain
= subspace_chain
->ssd_next
)
8045 if (subspace_chain
->ssd_subseg
== (int) subseg
)
8046 return subspace_chain
;
8050 /* No mapping from subsegment to subspace found. Return NULL. */
8054 /* Given a number, try and find a space with the name number.
8056 Return a pointer to a space dictionary chain entry for the space
8057 that was found or NULL on failure. */
8059 static sd_chain_struct
*
8060 pa_find_space_by_number (number
)
8063 sd_chain_struct
*space_chain
;
8065 for (space_chain
= space_dict_root
;
8067 space_chain
= space_chain
->sd_next
)
8069 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
8073 /* No appropriate space found. Return NULL. */
8077 /* Return the starting address for the given subspace. If the starting
8078 address is unknown then return zero. */
8081 pa_subspace_start (space
, quadrant
)
8082 sd_chain_struct
*space
;
8085 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
8086 is not correct for the PA OSF1 port. */
8087 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
8089 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
8096 /* FIXME. Needs documentation. */
8098 pa_next_subseg (space
)
8099 sd_chain_struct
*space
;
8102 space
->sd_last_subseg
++;
8103 return space
->sd_last_subseg
;
8107 /* Helper function for pa_stringer. Used to find the end of
8114 unsigned int c
= *s
& CHAR_MASK
;
8127 /* Handle a .STRING type pseudo-op. */
8130 pa_stringer (append_zero
)
8133 char *s
, num_buf
[4];
8137 /* Preprocess the string to handle PA-specific escape sequences.
8138 For example, \xDD where DD is a hexadecimal number should be
8139 changed to \OOO where OOO is an octal number. */
8142 /* We must have a valid space and subspace. */
8143 pa_check_current_space_and_subspace ();
8146 /* Skip the opening quote. */
8147 s
= input_line_pointer
+ 1;
8149 while (is_a_char (c
= pa_stringer_aux (s
++)))
8156 /* Handle \x<num>. */
8159 unsigned int number
;
8164 /* Get past the 'x'. */
8166 for (num_digit
= 0, number
= 0, dg
= *s
;
8168 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
8169 || (dg
>= 'A' && dg
<= 'F'));
8173 number
= number
* 16 + dg
- '0';
8174 else if (dg
>= 'a' && dg
<= 'f')
8175 number
= number
* 16 + dg
- 'a' + 10;
8177 number
= number
* 16 + dg
- 'A' + 10;
8187 sprintf (num_buf
, "%02o", number
);
8190 sprintf (num_buf
, "%03o", number
);
8193 for (i
= 0; i
<= num_digit
; i
++)
8194 s_start
[i
] = num_buf
[i
];
8198 /* This might be a "\"", skip over the escaped char. */
8205 stringer (append_zero
);
8206 pa_undefine_label ();
8209 /* Handle a .VERSION pseudo-op. */
8213 int unused ATTRIBUTE_UNUSED
;
8216 pa_undefine_label ();
8221 /* Handle a .COMPILER pseudo-op. */
8224 pa_compiler (unused
)
8225 int unused ATTRIBUTE_UNUSED
;
8227 obj_som_compiler (0);
8228 pa_undefine_label ();
8233 /* Handle a .COPYRIGHT pseudo-op. */
8236 pa_copyright (unused
)
8237 int unused ATTRIBUTE_UNUSED
;
8240 pa_undefine_label ();
8243 /* Just like a normal cons, but when finished we have to undefine
8244 the latest space label. */
8251 pa_undefine_label ();
8254 /* Like float_cons, but we need to undefine our label. */
8257 pa_float_cons (float_type
)
8260 float_cons (float_type
);
8261 pa_undefine_label ();
8264 /* Like s_fill, but delete our label when finished. */
8268 int unused ATTRIBUTE_UNUSED
;
8271 /* We must have a valid space and subspace. */
8272 pa_check_current_space_and_subspace ();
8276 pa_undefine_label ();
8279 /* Like lcomm, but delete our label when finished. */
8282 pa_lcomm (needs_align
)
8286 /* We must have a valid space and subspace. */
8287 pa_check_current_space_and_subspace ();
8290 s_lcomm (needs_align
);
8291 pa_undefine_label ();
8294 /* Like lsym, but delete our label when finished. */
8298 int unused ATTRIBUTE_UNUSED
;
8301 /* We must have a valid space and subspace. */
8302 pa_check_current_space_and_subspace ();
8306 pa_undefine_label ();
8309 /* On the PA relocations which involve function symbols must not be
8310 adjusted. This so that the linker can know when/how to create argument
8311 relocation stubs for indirect calls and calls to static functions.
8313 "T" field selectors create DLT relative fixups for accessing
8314 globals and statics in PIC code; each DLT relative fixup creates
8315 an entry in the DLT table. The entries contain the address of
8316 the final target (eg accessing "foo" would create a DLT entry
8317 with the address of "foo").
8319 Unfortunately, the HP linker doesn't take into account any addend
8320 when generating the DLT; so accessing $LIT$+8 puts the address of
8321 $LIT$ into the DLT rather than the address of $LIT$+8.
8323 The end result is we can't perform relocation symbol reductions for
8324 any fixup which creates entries in the DLT (eg they use "T" field
8327 Reject reductions involving symbols with external scope; such
8328 reductions make life a living hell for object file editors.
8330 FIXME. Also reject R_HPPA relocations which are 32bits wide in
8331 the code space. The SOM BFD backend doesn't know how to pull the
8332 right bits out of an instruction. */
8335 hppa_fix_adjustable (fixp
)
8338 struct hppa_fix_struct
*hppa_fix
;
8340 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8343 /* Reject reductions of symbols in 32bit relocs. */
8344 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
8349 if (fixp
->fx_r_type
== (int) R_PARISC_GNU_VTINHERIT
8350 || fixp
->fx_r_type
== (int) R_PARISC_GNU_VTENTRY
)
8354 /* Reject reductions of symbols in sym1-sym2 expressions when
8355 the fixup will occur in a CODE subspace.
8357 XXX FIXME: Long term we probably want to reject all of these;
8358 for example reducing in the debug section would lose if we ever
8359 supported using the optimizing hp linker. */
8362 && (hppa_fix
->segment
->flags
& SEC_CODE
))
8364 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
8365 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
8369 /* We can't adjust any relocs that use LR% and RR% field selectors.
8371 If a symbol is reduced to a section symbol, the assembler will
8372 adjust the addend unless the symbol happens to reside right at
8373 the start of the section. Additionally, the linker has no choice
8374 but to manipulate the addends when coalescing input sections for
8375 "ld -r". Since an LR% field selector is defined to round the
8376 addend, we can't change the addend without risking that a LR% and
8377 it's corresponding (possible multiple) RR% field will no longer
8378 sum to the right value.
8381 . ldil LR%foo+0,%r21
8382 . ldw RR%foo+0(%r21),%r26
8383 . ldw RR%foo+4(%r21),%r25
8385 If foo is at address 4092 (decimal) in section `sect', then after
8386 reducing to the section symbol we get
8387 . LR%sect+4092 == (L%sect)+0
8388 . RR%sect+4092 == (R%sect)+4092
8389 . RR%sect+4096 == (R%sect)-4096
8390 and the last address loses because rounding the addend to 8k
8391 mutiples takes us up to 8192 with an offset of -4096.
8393 In cases where the LR% expression is identical to the RR% one we
8394 will never have a problem, but is so happens that gcc rounds
8395 addends involved in LR% field selectors to work around a HP
8396 linker bug. ie. We often have addresses like the last case
8397 above where the LR% expression is offset from the RR% one. */
8399 if (hppa_fix
->fx_r_field
== e_lrsel
8400 || hppa_fix
->fx_r_field
== e_rrsel
8401 || hppa_fix
->fx_r_field
== e_nlrsel
)
8404 /* Reject reductions of symbols in DLT relative relocs,
8405 relocations with plabels. */
8406 if (hppa_fix
->fx_r_field
== e_tsel
8407 || hppa_fix
->fx_r_field
== e_ltsel
8408 || hppa_fix
->fx_r_field
== e_rtsel
8409 || hppa_fix
->fx_r_field
== e_psel
8410 || hppa_fix
->fx_r_field
== e_rpsel
8411 || hppa_fix
->fx_r_field
== e_lpsel
)
8414 if (fixp
->fx_addsy
&& (S_IS_EXTERNAL (fixp
->fx_addsy
)
8415 || S_IS_WEAK (fixp
->fx_addsy
)))
8418 /* Reject absolute calls (jumps). */
8419 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
8422 /* Reject reductions of function symbols. */
8423 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
8429 /* Return nonzero if the fixup in FIXP will require a relocation,
8430 even it if appears that the fixup could be completely handled
8434 hppa_force_relocation (fixp
)
8437 struct hppa_fix_struct
*hppa_fixp
;
8440 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8442 if (fixp
->fx_r_type
== (int) R_HPPA_ENTRY
8443 || fixp
->fx_r_type
== (int) R_HPPA_EXIT
8444 || fixp
->fx_r_type
== (int) R_HPPA_BEGIN_BRTAB
8445 || fixp
->fx_r_type
== (int) R_HPPA_END_BRTAB
8446 || fixp
->fx_r_type
== (int) R_HPPA_BEGIN_TRY
8447 || fixp
->fx_r_type
== (int) R_HPPA_END_TRY
8448 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
8449 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
8453 if (fixp
->fx_r_type
== (int) R_PARISC_GNU_VTINHERIT
8454 || fixp
->fx_r_type
== (int) R_PARISC_GNU_VTENTRY
)
8458 /* It is necessary to force PC-relative calls/jumps to have a relocation
8459 entry if they're going to need either a argument relocation or long
8460 call stub. FIXME. Can't we need the same for absolute calls? */
8461 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
8462 && (arg_reloc_stub_needed (symbol_arg_reloc_info (fixp
->fx_addsy
),
8463 hppa_fixp
->fx_arg_reloc
)))
8466 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
8467 - md_pcrel_from (fixp
));
8468 /* Now check and see if we're going to need a long-branch stub. */
8469 if (fixp
->fx_r_type
== (int) R_HPPA_PCREL_CALL
8470 && (distance
> 262143 || distance
< -262144))
8473 if (fixp
->fx_r_type
== (int) R_HPPA_ABS_CALL
)
8476 /* No need (yet) to force another relocations to be emitted. */
8480 /* Now for some ELF specific code. FIXME. */
8482 /* Mark the end of a function so that it's possible to compute
8483 the size of the function in hppa_elf_final_processing. */
8486 hppa_elf_mark_end_of_function ()
8488 /* ELF does not have EXIT relocations. All we do is create a
8489 temporary symbol marking the end of the function. */
8492 if (last_call_info
== NULL
|| last_call_info
->start_symbol
== NULL
)
8494 /* We have already warned about a missing label,
8495 or other problems. */
8499 name
= (char *) xmalloc (strlen ("L$\001end_")
8500 + strlen (S_GET_NAME (last_call_info
->start_symbol
))
8506 strcpy (name
, "L$\001end_");
8507 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
8509 /* If we have a .exit followed by a .procend, then the
8510 symbol will have already been defined. */
8511 symbolP
= symbol_find (name
);
8514 /* The symbol has already been defined! This can
8515 happen if we have a .exit followed by a .procend.
8517 This is *not* an error. All we want to do is free
8518 the memory we just allocated for the name and continue. */
8523 /* symbol value should be the offset of the
8524 last instruction of the function */
8525 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
8529 S_CLEAR_EXTERNAL (symbolP
);
8530 symbol_table_insert (symbolP
);
8534 last_call_info
->end_symbol
= symbolP
;
8536 as_bad (_("Symbol '%s' could not be created."), name
);
8540 as_bad (_("No memory for symbol name."));
8544 /* For ELF, this function serves one purpose: to setup the st_size
8545 field of STT_FUNC symbols. To do this, we need to scan the
8546 call_info structure list, determining st_size in by taking the
8547 difference in the address of the beginning/end marker symbols. */
8550 elf_hppa_final_processing ()
8552 struct call_info
*call_info_pointer
;
8554 for (call_info_pointer
= call_info_root
;
8556 call_info_pointer
= call_info_pointer
->ci_next
)
8558 elf_symbol_type
*esym
8559 = ((elf_symbol_type
*)
8560 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
8561 esym
->internal_elf_sym
.st_size
=
8562 S_GET_VALUE (call_info_pointer
->end_symbol
)
8563 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;
8570 if (debug_type
== DEBUG_DWARF2
)
8575 pa_vtable_entry (ignore
)
8576 int ignore ATTRIBUTE_UNUSED
;
8578 struct fix
*new_fix
;
8580 new_fix
= obj_elf_vtable_entry (0);
8584 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
8585 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
8586 hppa_fix
->fx_r_type
= R_HPPA
;
8587 hppa_fix
->fx_r_field
= e_fsel
;
8588 hppa_fix
->fx_r_format
= 32;
8589 hppa_fix
->fx_arg_reloc
= 0;
8590 hppa_fix
->segment
= now_seg
;
8591 new_fix
->tc_fix_data
= (void *) hppa_fix
;
8592 new_fix
->fx_r_type
= (int) R_PARISC_GNU_VTENTRY
;
8597 pa_vtable_inherit (ignore
)
8598 int ignore ATTRIBUTE_UNUSED
;
8600 struct fix
*new_fix
;
8602 new_fix
= obj_elf_vtable_inherit (0);
8606 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
8607 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
8608 hppa_fix
->fx_r_type
= R_HPPA
;
8609 hppa_fix
->fx_r_field
= e_fsel
;
8610 hppa_fix
->fx_r_format
= 32;
8611 hppa_fix
->fx_arg_reloc
= 0;
8612 hppa_fix
->segment
= now_seg
;
8613 new_fix
->tc_fix_data
= (void *) hppa_fix
;
8614 new_fix
->fx_r_type
= (int) R_PARISC_GNU_VTINHERIT
;