1 /* tc-hppa.c -- Assemble for the PA
2 Copyright 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3 2002, 2003, 2004, 2005, 2006 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, 51 Franklin Street - Fifth Floor, Boston, MA
22 /* HP PA-RISC support was contributed by the Center for Software Science
23 at the University of Utah. */
26 #include "safe-ctype.h"
29 #include "bfd/libhppa.h"
31 /* Be careful, this file includes data *declarations*. */
32 #include "opcode/hppa.h"
34 #if defined (OBJ_ELF) && defined (OBJ_SOM)
35 error only one of OBJ_ELF
and OBJ_SOM can be defined
38 /* If we are using ELF, then we probably can support dwarf2 debug
39 records. Furthermore, if we are supporting dwarf2 debug records,
40 then we want to use the assembler support for compact line numbers. */
42 #include "dwarf2dbg.h"
44 /* A "convenient" place to put object file dependencies which do
45 not need to be seen outside of tc-hppa.c. */
47 /* Object file formats specify relocation types. */
48 typedef enum elf_hppa_reloc_type reloc_type
;
50 /* Object file formats specify BFD symbol types. */
51 typedef elf_symbol_type obj_symbol_type
;
52 #define symbol_arg_reloc_info(sym)\
53 (((obj_symbol_type *) symbol_get_bfdsym (sym))->tc_data.hppa_arg_reloc)
55 #if TARGET_ARCH_SIZE == 64
56 /* How to generate a relocation. */
57 #define hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
58 #define elf_hppa_reloc_final_type elf64_hppa_reloc_final_type
60 #define hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
61 #define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type
64 /* ELF objects can have versions, but apparently do not have anywhere
65 to store a copyright string. */
66 #define obj_version obj_elf_version
67 #define obj_copyright obj_elf_version
69 #define UNWIND_SECTION_NAME ".PARISC.unwind"
73 /* Names of various debugging spaces/subspaces. */
74 #define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$"
75 #define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$"
76 #define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$"
77 #define UNWIND_SECTION_NAME "$UNWIND$"
79 /* Object file formats specify relocation types. */
80 typedef int reloc_type
;
82 /* SOM objects can have both a version string and a copyright string. */
83 #define obj_version obj_som_version
84 #define obj_copyright obj_som_copyright
86 /* How to generate a relocation. */
87 #define hppa_gen_reloc_type hppa_som_gen_reloc_type
89 /* Object file formats specify BFD symbol types. */
90 typedef som_symbol_type obj_symbol_type
;
91 #define symbol_arg_reloc_info(sym)\
92 (((obj_symbol_type *) symbol_get_bfdsym (sym))->tc_data.ap.hppa_arg_reloc)
94 /* This apparently isn't in older versions of hpux reloc.h. */
96 #define R_DLT_REL 0x78
108 #if TARGET_ARCH_SIZE == 64
109 #define DEFAULT_LEVEL 25
111 #define DEFAULT_LEVEL 10
114 /* Various structures and types used internally in tc-hppa.c. */
116 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
120 unsigned int cannot_unwind
:1;
121 unsigned int millicode
:1;
122 unsigned int millicode_save_rest
:1;
123 unsigned int region_desc
:2;
124 unsigned int save_sr
:2;
125 unsigned int entry_fr
:4;
126 unsigned int entry_gr
:5;
127 unsigned int args_stored
:1;
128 unsigned int call_fr
:5;
129 unsigned int call_gr
:5;
130 unsigned int save_sp
:1;
131 unsigned int save_rp
:1;
132 unsigned int save_rp_in_frame
:1;
133 unsigned int extn_ptr_defined
:1;
134 unsigned int cleanup_defined
:1;
136 unsigned int hpe_interrupt_marker
:1;
137 unsigned int hpux_interrupt_marker
:1;
138 unsigned int reserved
:3;
139 unsigned int frame_size
:27;
142 /* We can't rely on compilers placing bitfields in any particular
143 place, so use these macros when dumping unwind descriptors to
145 #define UNWIND_LOW32(U) \
146 (((U)->cannot_unwind << 31) \
147 | ((U)->millicode << 30) \
148 | ((U)->millicode_save_rest << 29) \
149 | ((U)->region_desc << 27) \
150 | ((U)->save_sr << 25) \
151 | ((U)->entry_fr << 21) \
152 | ((U)->entry_gr << 16) \
153 | ((U)->args_stored << 15) \
154 | ((U)->call_fr << 10) \
155 | ((U)->call_gr << 5) \
156 | ((U)->save_sp << 4) \
157 | ((U)->save_rp << 3) \
158 | ((U)->save_rp_in_frame << 2) \
159 | ((U)->extn_ptr_defined << 1) \
160 | ((U)->cleanup_defined << 0))
162 #define UNWIND_HIGH32(U) \
163 (((U)->hpe_interrupt_marker << 31) \
164 | ((U)->hpux_interrupt_marker << 30) \
165 | ((U)->frame_size << 0))
169 /* Starting and ending offsets of the region described by
171 unsigned int start_offset
;
172 unsigned int end_offset
;
173 struct unwind_desc descriptor
;
176 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
177 control the entry and exit code they generate. It is also used in
178 creation of the correct stack unwind descriptors.
180 NOTE: GAS does not support .enter and .leave for the generation of
181 prologues and epilogues. FIXME.
183 The fields in structure roughly correspond to the arguments available on the
184 .callinfo pseudo-op. */
188 /* The unwind descriptor being built. */
189 struct unwind_table ci_unwind
;
191 /* Name of this function. */
192 symbolS
*start_symbol
;
194 /* (temporary) symbol used to mark the end of this function. */
197 /* Next entry in the chain. */
198 struct call_info
*ci_next
;
201 /* Operand formats for FP instructions. Note not all FP instructions
202 allow all four formats to be used (for example fmpysub only allows
206 SGL
, DBL
, ILLEGAL_FMT
, QUAD
, W
, UW
, DW
, UDW
, QW
, UQW
210 /* This fully describes the symbol types which may be attached to
211 an EXPORT or IMPORT directive. Only SOM uses this formation
212 (ELF has no need for it). */
216 SYMBOL_TYPE_ABSOLUTE
,
220 SYMBOL_TYPE_MILLICODE
,
222 SYMBOL_TYPE_PRI_PROG
,
223 SYMBOL_TYPE_SEC_PROG
,
227 /* This structure contains information needed to assemble
228 individual instructions. */
231 /* Holds the opcode after parsing by pa_ip. */
232 unsigned long opcode
;
234 /* Holds an expression associated with the current instruction. */
237 /* Does this instruction use PC-relative addressing. */
240 /* Floating point formats for operand1 and operand2. */
241 fp_operand_format fpof1
;
242 fp_operand_format fpof2
;
244 /* Whether or not we saw a truncation request on an fcnv insn. */
247 /* Holds the field selector for this instruction
248 (for example L%, LR%, etc). */
251 /* Holds any argument relocation bits associated with this
252 instruction. (instruction should be some sort of call). */
253 unsigned int arg_reloc
;
255 /* The format specification for this instruction. */
258 /* The relocation (if any) associated with this instruction. */
262 /* PA-89 floating point registers are arranged like this:
264 +--------------+--------------+
265 | 0 or 16L | 16 or 16R |
266 +--------------+--------------+
267 | 1 or 17L | 17 or 17R |
268 +--------------+--------------+
276 +--------------+--------------+
277 | 14 or 30L | 30 or 30R |
278 +--------------+--------------+
279 | 15 or 31L | 31 or 31R |
280 +--------------+--------------+ */
282 /* Additional information needed to build argument relocation stubs. */
285 /* The argument relocation specification. */
286 unsigned int arg_reloc
;
288 /* Number of arguments. */
289 unsigned int arg_count
;
293 /* This structure defines an entry in the subspace dictionary
296 struct subspace_dictionary_chain
298 /* Nonzero if this space has been defined by the user code. */
299 unsigned int ssd_defined
;
301 /* Name of this subspace. */
304 /* GAS segment and subsegment associated with this subspace. */
308 /* Next space in the subspace dictionary chain. */
309 struct subspace_dictionary_chain
*ssd_next
;
312 typedef struct subspace_dictionary_chain ssd_chain_struct
;
314 /* This structure defines an entry in the subspace dictionary
317 struct space_dictionary_chain
319 /* Nonzero if this space has been defined by the user code or
320 as a default space. */
321 unsigned int sd_defined
;
323 /* Nonzero if this spaces has been defined by the user code. */
324 unsigned int sd_user_defined
;
326 /* The space number (or index). */
327 unsigned int sd_spnum
;
329 /* The name of this subspace. */
332 /* GAS segment to which this subspace corresponds. */
335 /* Current subsegment number being used. */
338 /* The chain of subspaces contained within this space. */
339 ssd_chain_struct
*sd_subspaces
;
341 /* The next entry in the space dictionary chain. */
342 struct space_dictionary_chain
*sd_next
;
345 typedef struct space_dictionary_chain sd_chain_struct
;
347 /* This structure defines attributes of the default subspace
348 dictionary entries. */
350 struct default_subspace_dict
352 /* Name of the subspace. */
355 /* FIXME. Is this still needed? */
358 /* Nonzero if this subspace is loadable. */
361 /* Nonzero if this subspace contains only code. */
364 /* Nonzero if this is a comdat subspace. */
367 /* Nonzero if this is a common subspace. */
370 /* Nonzero if this is a common subspace which allows symbols
371 to be multiply defined. */
374 /* Nonzero if this subspace should be zero filled. */
377 /* Sort key for this subspace. */
380 /* Access control bits for this subspace. Can represent RWX access
381 as well as privilege level changes for gateways. */
384 /* Index of containing space. */
387 /* Alignment (in bytes) of this subspace. */
390 /* Quadrant within space where this subspace should be loaded. */
393 /* An index into the default spaces array. */
396 /* Subsegment associated with this subspace. */
400 /* This structure defines attributes of the default space
401 dictionary entries. */
403 struct default_space_dict
405 /* Name of the space. */
408 /* Space number. It is possible to identify spaces within
409 assembly code numerically! */
412 /* Nonzero if this space is loadable. */
415 /* Nonzero if this space is "defined". FIXME is still needed */
418 /* Nonzero if this space can not be shared. */
421 /* Sort key for this space. */
424 /* Segment associated with this space. */
429 /* Structure for previous label tracking. Needed so that alignments,
430 callinfo declarations, etc can be easily attached to a particular
432 typedef struct label_symbol_struct
434 struct symbol
*lss_label
;
436 sd_chain_struct
*lss_space
;
441 struct label_symbol_struct
*lss_next
;
445 /* Extra information needed to perform fixups (relocations) on the PA. */
446 struct hppa_fix_struct
448 /* The field selector. */
449 enum hppa_reloc_field_selector_type_alt fx_r_field
;
454 /* Format of fixup. */
457 /* Argument relocation bits. */
458 unsigned int fx_arg_reloc
;
460 /* The segment this fixup appears in. */
464 /* Structure to hold information about predefined registers. */
472 /* This structure defines the mapping from a FP condition string
473 to a condition number which can be recorded in an instruction. */
480 /* This structure defines a mapping from a field selector
481 string to a field selector type. */
482 struct selector_entry
488 /* Prototypes for functions local to tc-hppa.c. */
491 static void pa_check_current_space_and_subspace (void);
494 #if !(defined (OBJ_ELF) && (defined (TE_LINUX) || defined (TE_NetBSD)))
495 static void pa_text (int);
496 static void pa_data (int);
497 static void pa_comm (int);
500 static int exact_log2 (int);
501 static void pa_compiler (int);
502 static void pa_align (int);
503 static void pa_space (int);
504 static void pa_spnum (int);
505 static void pa_subspace (int);
506 static sd_chain_struct
*create_new_space (char *, int, int,
509 static ssd_chain_struct
*create_new_subspace (sd_chain_struct
*,
514 static ssd_chain_struct
*update_subspace (sd_chain_struct
*,
515 char *, int, int, int,
519 static sd_chain_struct
*is_defined_space (char *);
520 static ssd_chain_struct
*is_defined_subspace (char *);
521 static sd_chain_struct
*pa_segment_to_space (asection
*);
522 static ssd_chain_struct
*pa_subsegment_to_subspace (asection
*,
524 static sd_chain_struct
*pa_find_space_by_number (int);
525 static unsigned int pa_subspace_start (sd_chain_struct
*, int);
526 static sd_chain_struct
*pa_parse_space_stmt (char *, int);
529 /* File and globally scoped variable declarations. */
532 /* Root and final entry in the space chain. */
533 static sd_chain_struct
*space_dict_root
;
534 static sd_chain_struct
*space_dict_last
;
536 /* The current space and subspace. */
537 static sd_chain_struct
*current_space
;
538 static ssd_chain_struct
*current_subspace
;
541 /* Root of the call_info chain. */
542 static struct call_info
*call_info_root
;
544 /* The last call_info (for functions) structure
545 seen so it can be associated with fixups and
547 static struct call_info
*last_call_info
;
549 /* The last call description (for actual calls). */
550 static struct call_desc last_call_desc
;
552 /* handle of the OPCODE hash table */
553 static struct hash_control
*op_hash
= NULL
;
555 /* These characters can be suffixes of opcode names and they may be
556 followed by meaningful whitespace. We don't include `,' and `!'
557 as they never appear followed by meaningful whitespace. */
558 const char hppa_symbol_chars
[] = "*?=<>";
560 /* This array holds the chars that only start a comment at the beginning of
561 a line. If the line seems to have the form '# 123 filename'
562 .line and .file directives will appear in the pre-processed output.
564 Note that input_file.c hand checks for '#' at the beginning of the
565 first line of the input file. This is because the compiler outputs
566 #NO_APP at the beginning of its output.
568 Also note that C style comments will always work. */
569 const char line_comment_chars
[] = "#";
571 /* This array holds the chars that always start a comment. If the
572 pre-processor is disabled, these aren't very useful. */
573 const char comment_chars
[] = ";";
575 /* This array holds the characters which act as line separators. */
576 const char line_separator_chars
[] = "!";
578 /* Chars that can be used to separate mant from exp in floating point nums. */
579 const char EXP_CHARS
[] = "eE";
581 /* Chars that mean this number is a floating point constant.
582 As in 0f12.456 or 0d1.2345e12.
584 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
585 changed in read.c. Ideally it shouldn't hae to know abou it at
586 all, but nothing is ideal around here. */
587 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
589 static struct pa_it the_insn
;
591 /* Points to the end of an expression just parsed by get_expression
592 and friends. FIXME. This shouldn't be handled with a file-global
594 static char *expr_end
;
596 /* Nonzero if a .callinfo appeared within the current procedure. */
597 static int callinfo_found
;
599 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
600 static int within_entry_exit
;
602 /* Nonzero if the assembler is currently within a procedure definition. */
603 static int within_procedure
;
605 /* Handle on structure which keep track of the last symbol
606 seen in each subspace. */
607 static label_symbol_struct
*label_symbols_rootp
= NULL
;
609 /* Holds the last field selector. */
610 static int hppa_field_selector
;
612 /* Nonzero when strict matching is enabled. Zero otherwise.
614 Each opcode in the table has a flag which indicates whether or
615 not strict matching should be enabled for that instruction.
617 Mainly, strict causes errors to be ignored when a match failure
618 occurs. However, it also affects the parsing of register fields
619 by pa_parse_number. */
622 /* pa_parse_number returns values in `pa_number'. Mostly
623 pa_parse_number is used to return a register number, with floating
624 point registers being numbered from FP_REG_BASE upwards.
625 The bit specified with FP_REG_RSEL is set if the floating point
626 register has a `r' suffix. */
627 #define FP_REG_BASE 64
628 #define FP_REG_RSEL 128
629 static int pa_number
;
632 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
633 static symbolS
*dummy_symbol
;
636 /* Nonzero if errors are to be printed. */
637 static int print_errors
= 1;
639 /* List of registers that are pre-defined:
641 Each general register has one predefined name of the form
642 %r<REGNUM> which has the value <REGNUM>.
644 Space and control registers are handled in a similar manner,
645 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
647 Likewise for the floating point registers, but of the form
648 %fr<REGNUM>. Floating point registers have additional predefined
649 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
650 again have the value <REGNUM>.
652 Many registers also have synonyms:
654 %r26 - %r23 have %arg0 - %arg3 as synonyms
655 %r28 - %r29 have %ret0 - %ret1 as synonyms
656 %fr4 - %fr7 have %farg0 - %farg3 as synonyms
657 %r30 has %sp as a synonym
658 %r27 has %dp as a synonym
659 %r2 has %rp as a synonym
661 Almost every control register has a synonym; they are not listed
664 The table is sorted. Suitable for searching by a binary search. */
666 static const struct pd_reg pre_defined_registers
[] =
700 {"%farg0", 4 + FP_REG_BASE
},
701 {"%farg1", 5 + FP_REG_BASE
},
702 {"%farg2", 6 + FP_REG_BASE
},
703 {"%farg3", 7 + FP_REG_BASE
},
704 {"%fr0", 0 + FP_REG_BASE
},
705 {"%fr0l", 0 + FP_REG_BASE
},
706 {"%fr0r", 0 + FP_REG_BASE
+ FP_REG_RSEL
},
707 {"%fr1", 1 + FP_REG_BASE
},
708 {"%fr10", 10 + FP_REG_BASE
},
709 {"%fr10l", 10 + FP_REG_BASE
},
710 {"%fr10r", 10 + FP_REG_BASE
+ FP_REG_RSEL
},
711 {"%fr11", 11 + FP_REG_BASE
},
712 {"%fr11l", 11 + FP_REG_BASE
},
713 {"%fr11r", 11 + FP_REG_BASE
+ FP_REG_RSEL
},
714 {"%fr12", 12 + FP_REG_BASE
},
715 {"%fr12l", 12 + FP_REG_BASE
},
716 {"%fr12r", 12 + FP_REG_BASE
+ FP_REG_RSEL
},
717 {"%fr13", 13 + FP_REG_BASE
},
718 {"%fr13l", 13 + FP_REG_BASE
},
719 {"%fr13r", 13 + FP_REG_BASE
+ FP_REG_RSEL
},
720 {"%fr14", 14 + FP_REG_BASE
},
721 {"%fr14l", 14 + FP_REG_BASE
},
722 {"%fr14r", 14 + FP_REG_BASE
+ FP_REG_RSEL
},
723 {"%fr15", 15 + FP_REG_BASE
},
724 {"%fr15l", 15 + FP_REG_BASE
},
725 {"%fr15r", 15 + FP_REG_BASE
+ FP_REG_RSEL
},
726 {"%fr16", 16 + FP_REG_BASE
},
727 {"%fr16l", 16 + FP_REG_BASE
},
728 {"%fr16r", 16 + FP_REG_BASE
+ FP_REG_RSEL
},
729 {"%fr17", 17 + FP_REG_BASE
},
730 {"%fr17l", 17 + FP_REG_BASE
},
731 {"%fr17r", 17 + FP_REG_BASE
+ FP_REG_RSEL
},
732 {"%fr18", 18 + FP_REG_BASE
},
733 {"%fr18l", 18 + FP_REG_BASE
},
734 {"%fr18r", 18 + FP_REG_BASE
+ FP_REG_RSEL
},
735 {"%fr19", 19 + FP_REG_BASE
},
736 {"%fr19l", 19 + FP_REG_BASE
},
737 {"%fr19r", 19 + FP_REG_BASE
+ FP_REG_RSEL
},
738 {"%fr1l", 1 + FP_REG_BASE
},
739 {"%fr1r", 1 + FP_REG_BASE
+ FP_REG_RSEL
},
740 {"%fr2", 2 + FP_REG_BASE
},
741 {"%fr20", 20 + FP_REG_BASE
},
742 {"%fr20l", 20 + FP_REG_BASE
},
743 {"%fr20r", 20 + FP_REG_BASE
+ FP_REG_RSEL
},
744 {"%fr21", 21 + FP_REG_BASE
},
745 {"%fr21l", 21 + FP_REG_BASE
},
746 {"%fr21r", 21 + FP_REG_BASE
+ FP_REG_RSEL
},
747 {"%fr22", 22 + FP_REG_BASE
},
748 {"%fr22l", 22 + FP_REG_BASE
},
749 {"%fr22r", 22 + FP_REG_BASE
+ FP_REG_RSEL
},
750 {"%fr23", 23 + FP_REG_BASE
},
751 {"%fr23l", 23 + FP_REG_BASE
},
752 {"%fr23r", 23 + FP_REG_BASE
+ FP_REG_RSEL
},
753 {"%fr24", 24 + FP_REG_BASE
},
754 {"%fr24l", 24 + FP_REG_BASE
},
755 {"%fr24r", 24 + FP_REG_BASE
+ FP_REG_RSEL
},
756 {"%fr25", 25 + FP_REG_BASE
},
757 {"%fr25l", 25 + FP_REG_BASE
},
758 {"%fr25r", 25 + FP_REG_BASE
+ FP_REG_RSEL
},
759 {"%fr26", 26 + FP_REG_BASE
},
760 {"%fr26l", 26 + FP_REG_BASE
},
761 {"%fr26r", 26 + FP_REG_BASE
+ FP_REG_RSEL
},
762 {"%fr27", 27 + FP_REG_BASE
},
763 {"%fr27l", 27 + FP_REG_BASE
},
764 {"%fr27r", 27 + FP_REG_BASE
+ FP_REG_RSEL
},
765 {"%fr28", 28 + FP_REG_BASE
},
766 {"%fr28l", 28 + FP_REG_BASE
},
767 {"%fr28r", 28 + FP_REG_BASE
+ FP_REG_RSEL
},
768 {"%fr29", 29 + FP_REG_BASE
},
769 {"%fr29l", 29 + FP_REG_BASE
},
770 {"%fr29r", 29 + FP_REG_BASE
+ FP_REG_RSEL
},
771 {"%fr2l", 2 + FP_REG_BASE
},
772 {"%fr2r", 2 + FP_REG_BASE
+ FP_REG_RSEL
},
773 {"%fr3", 3 + FP_REG_BASE
},
774 {"%fr30", 30 + FP_REG_BASE
},
775 {"%fr30l", 30 + FP_REG_BASE
},
776 {"%fr30r", 30 + FP_REG_BASE
+ FP_REG_RSEL
},
777 {"%fr31", 31 + FP_REG_BASE
},
778 {"%fr31l", 31 + FP_REG_BASE
},
779 {"%fr31r", 31 + FP_REG_BASE
+ FP_REG_RSEL
},
780 {"%fr3l", 3 + FP_REG_BASE
},
781 {"%fr3r", 3 + FP_REG_BASE
+ FP_REG_RSEL
},
782 {"%fr4", 4 + FP_REG_BASE
},
783 {"%fr4l", 4 + FP_REG_BASE
},
784 {"%fr4r", 4 + FP_REG_BASE
+ FP_REG_RSEL
},
785 {"%fr5", 5 + FP_REG_BASE
},
786 {"%fr5l", 5 + FP_REG_BASE
},
787 {"%fr5r", 5 + FP_REG_BASE
+ FP_REG_RSEL
},
788 {"%fr6", 6 + FP_REG_BASE
},
789 {"%fr6l", 6 + FP_REG_BASE
},
790 {"%fr6r", 6 + FP_REG_BASE
+ FP_REG_RSEL
},
791 {"%fr7", 7 + FP_REG_BASE
},
792 {"%fr7l", 7 + FP_REG_BASE
},
793 {"%fr7r", 7 + FP_REG_BASE
+ FP_REG_RSEL
},
794 {"%fr8", 8 + FP_REG_BASE
},
795 {"%fr8l", 8 + FP_REG_BASE
},
796 {"%fr8r", 8 + FP_REG_BASE
+ FP_REG_RSEL
},
797 {"%fr9", 9 + FP_REG_BASE
},
798 {"%fr9l", 9 + FP_REG_BASE
},
799 {"%fr9r", 9 + FP_REG_BASE
+ FP_REG_RSEL
},
808 #if TARGET_ARCH_SIZE == 64
884 /* This table is sorted by order of the length of the string. This is
885 so we check for <> before we check for <. If we had a <> and checked
886 for < first, we would get a false match. */
887 static const struct fp_cond_map fp_cond_map
[] =
923 static const struct selector_entry selector_table
[] =
948 /* default space and subspace dictionaries */
950 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
951 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
953 /* pre-defined subsegments (subspaces) for the HPPA. */
954 #define SUBSEG_CODE 0
956 #define SUBSEG_MILLI 2
957 #define SUBSEG_DATA 0
959 #define SUBSEG_UNWIND 3
960 #define SUBSEG_GDB_STRINGS 0
961 #define SUBSEG_GDB_SYMBOLS 1
963 static struct default_subspace_dict pa_def_subspaces
[] =
965 {"$CODE$", 1, 1, 1, 0, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE
},
966 {"$DATA$", 1, 1, 0, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA
},
967 {"$LIT$", 1, 1, 0, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT
},
968 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI
},
969 {"$BSS$", 1, 1, 0, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS
},
970 {NULL
, 0, 1, 0, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
973 static struct default_space_dict pa_def_spaces
[] =
975 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
},
976 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
},
977 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
}
980 /* Misc local definitions used by the assembler. */
982 /* These macros are used to maintain spaces/subspaces. */
983 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
984 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
985 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
986 #define SPACE_NAME(space_chain) (space_chain)->sd_name
988 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
989 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
992 /* Return nonzero if the string pointed to by S potentially represents
993 a right or left half of a FP register */
994 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
995 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
997 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
998 main loop after insertion. */
1000 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1002 ((OPCODE) |= (FIELD) << (START)); \
1006 /* Simple range checking for FIELD against HIGH and LOW bounds.
1007 IGNORE is used to suppress the error message. */
1009 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1011 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1014 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1020 /* Variant of CHECK_FIELD for use in md_apply_fix and other places where
1021 the current file and line number are not valid. */
1023 #define CHECK_FIELD_WHERE(FIELD, HIGH, LOW, FILENAME, LINE) \
1025 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1027 as_bad_where ((FILENAME), (LINE), \
1028 _("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1034 /* Simple alignment checking for FIELD against ALIGN (a power of two).
1035 IGNORE is used to suppress the error message. */
1037 #define CHECK_ALIGN(FIELD, ALIGN, IGNORE) \
1039 if ((FIELD) & ((ALIGN) - 1)) \
1042 as_bad (_("Field not properly aligned [%d] (%d)."), (ALIGN), \
1048 #define is_DP_relative(exp) \
1049 ((exp).X_op == O_subtract \
1050 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1052 #define is_PC_relative(exp) \
1053 ((exp).X_op == O_subtract \
1054 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1056 #define is_tls_gdidx(exp) \
1057 ((exp).X_op == O_subtract \
1058 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$tls_gdidx$") == 0)
1060 #define is_tls_ldidx(exp) \
1061 ((exp).X_op == O_subtract \
1062 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$tls_ldidx$") == 0)
1064 #define is_tls_dtpoff(exp) \
1065 ((exp).X_op == O_subtract \
1066 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$tls_dtpoff$") == 0)
1068 #define is_tls_ieoff(exp) \
1069 ((exp).X_op == O_subtract \
1070 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$tls_ieoff$") == 0)
1072 #define is_tls_leoff(exp) \
1073 ((exp).X_op == O_subtract \
1074 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$tls_leoff$") == 0)
1076 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1077 always be able to reduce the expression to a constant, so we don't
1078 need real complex handling yet. */
1079 #define is_complex(exp) \
1080 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1082 /* Actual functions to implement the PA specific code for the assembler. */
1084 /* Called before writing the object file. Make sure entry/exit and
1085 proc/procend pairs match. */
1090 if (within_entry_exit
)
1091 as_fatal (_("Missing .exit\n"));
1093 if (within_procedure
)
1094 as_fatal (_("Missing .procend\n"));
1097 /* Returns a pointer to the label_symbol_struct for the current space.
1098 or NULL if no label_symbol_struct exists for the current space. */
1100 static label_symbol_struct
*
1103 label_symbol_struct
*label_chain
;
1105 for (label_chain
= label_symbols_rootp
;
1107 label_chain
= label_chain
->lss_next
)
1110 if (current_space
== label_chain
->lss_space
&& label_chain
->lss_label
)
1114 if (now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
)
1122 /* Defines a label for the current space. If one is already defined,
1123 this function will replace it with the new label. */
1126 pa_define_label (symbolS
*symbol
)
1128 label_symbol_struct
*label_chain
= pa_get_label ();
1131 label_chain
->lss_label
= symbol
;
1134 /* Create a new label entry and add it to the head of the chain. */
1135 label_chain
= xmalloc (sizeof (label_symbol_struct
));
1136 label_chain
->lss_label
= symbol
;
1138 label_chain
->lss_space
= current_space
;
1141 label_chain
->lss_segment
= now_seg
;
1143 label_chain
->lss_next
= NULL
;
1145 if (label_symbols_rootp
)
1146 label_chain
->lss_next
= label_symbols_rootp
;
1148 label_symbols_rootp
= label_chain
;
1152 dwarf2_emit_label (symbol
);
1156 /* Removes a label definition for the current space.
1157 If there is no label_symbol_struct entry, then no action is taken. */
1160 pa_undefine_label (void)
1162 label_symbol_struct
*label_chain
;
1163 label_symbol_struct
*prev_label_chain
= NULL
;
1165 for (label_chain
= label_symbols_rootp
;
1167 label_chain
= label_chain
->lss_next
)
1171 && current_space
== label_chain
->lss_space
&& label_chain
->lss_label
1174 && now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
1178 /* Remove the label from the chain and free its memory. */
1179 if (prev_label_chain
)
1180 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1182 label_symbols_rootp
= label_chain
->lss_next
;
1187 prev_label_chain
= label_chain
;
1191 /* An HPPA-specific version of fix_new. This is required because the HPPA
1192 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1193 results in the creation of an instance of an hppa_fix_struct. An
1194 hppa_fix_struct stores the extra information along with a pointer to the
1195 original fixS. This is attached to the original fixup via the
1196 tc_fix_data field. */
1199 fix_new_hppa (fragS
*frag
,
1202 symbolS
*add_symbol
,
1206 bfd_reloc_code_real_type r_type
,
1207 enum hppa_reloc_field_selector_type_alt r_field
,
1209 unsigned int arg_reloc
,
1210 int unwind_bits ATTRIBUTE_UNUSED
)
1213 struct hppa_fix_struct
*hppa_fix
= obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1216 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1218 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1219 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1220 hppa_fix
->fx_r_type
= r_type
;
1221 hppa_fix
->fx_r_field
= r_field
;
1222 hppa_fix
->fx_r_format
= r_format
;
1223 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1224 hppa_fix
->segment
= now_seg
;
1226 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1227 new_fix
->fx_offset
= unwind_bits
;
1230 /* foo-$global$ is used to access non-automatic storage. $global$
1231 is really just a marker and has served its purpose, so eliminate
1232 it now so as not to confuse write.c. Ditto for $PIC_pcrel$0. */
1233 if (new_fix
->fx_subsy
1234 && (strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$") == 0
1235 || strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$PIC_pcrel$0") == 0
1236 || strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$tls_gdidx$") == 0
1237 || strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$tls_ldidx$") == 0
1238 || strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$tls_dtpoff$") == 0
1239 || strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$tls_ieoff$") == 0
1240 || strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$tls_leoff$") == 0))
1241 new_fix
->fx_subsy
= NULL
;
1244 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1245 hppa_field_selector is set by the parse_cons_expression_hppa. */
1248 cons_fix_new_hppa (fragS
*frag
, int where
, int size
, expressionS
*exp
)
1250 unsigned int rel_type
;
1252 /* Get a base relocation type. */
1253 if (is_DP_relative (*exp
))
1254 rel_type
= R_HPPA_GOTOFF
;
1255 else if (is_PC_relative (*exp
))
1256 rel_type
= R_HPPA_PCREL_CALL
;
1258 else if (is_tls_gdidx (*exp
))
1259 rel_type
= R_PARISC_TLS_GD21L
;
1260 else if (is_tls_ldidx (*exp
))
1261 rel_type
= R_PARISC_TLS_LDM21L
;
1262 else if (is_tls_dtpoff (*exp
))
1263 rel_type
= R_PARISC_TLS_LDO21L
;
1264 else if (is_tls_ieoff (*exp
))
1265 rel_type
= R_PARISC_TLS_IE21L
;
1266 else if (is_tls_leoff (*exp
))
1267 rel_type
= R_PARISC_TLS_LE21L
;
1269 else if (is_complex (*exp
))
1270 rel_type
= R_HPPA_COMPLEX
;
1274 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1276 as_warn (_("Invalid field selector. Assuming F%%."));
1277 hppa_field_selector
= e_fsel
;
1280 fix_new_hppa (frag
, where
, size
,
1281 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1282 hppa_field_selector
, size
* 8, 0, 0);
1284 /* Reset field selector to its default state. */
1285 hppa_field_selector
= 0;
1288 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
1291 get_expression (char *str
)
1296 save_in
= input_line_pointer
;
1297 input_line_pointer
= str
;
1298 seg
= expression (&the_insn
.exp
);
1299 if (!(seg
== absolute_section
1300 || seg
== undefined_section
1301 || SEG_NORMAL (seg
)))
1303 as_warn (_("Bad segment in expression."));
1304 expr_end
= input_line_pointer
;
1305 input_line_pointer
= save_in
;
1308 expr_end
= input_line_pointer
;
1309 input_line_pointer
= save_in
;
1312 /* Parse a PA nullification completer (,n). Return nonzero if the
1313 completer was found; return zero if no completer was found. */
1316 pa_parse_nullif (char **s
)
1324 if (strncasecmp (*s
, "n", 1) == 0)
1328 as_bad (_("Invalid Nullification: (%c)"), **s
);
1337 /* Turn a string in input_line_pointer into a floating point constant of type
1338 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
1339 emitted is stored in *sizeP . An error message or NULL is returned. */
1341 #define MAX_LITTLENUMS 6
1344 md_atof (int type
, char *litP
, int *sizeP
)
1347 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
1348 LITTLENUM_TYPE
*wordP
;
1380 return _("Bad call to MD_ATOF()");
1382 t
= atof_ieee (input_line_pointer
, type
, words
);
1384 input_line_pointer
= t
;
1385 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
1386 for (wordP
= words
; prec
--;)
1388 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
1389 litP
+= sizeof (LITTLENUM_TYPE
);
1394 /* Write out big-endian. */
1397 md_number_to_chars (char *buf
, valueT val
, int n
)
1399 number_to_chars_bigendian (buf
, val
, n
);
1402 /* Translate internal representation of relocation info to BFD target
1406 tc_gen_reloc (asection
*section
, fixS
*fixp
)
1409 struct hppa_fix_struct
*hppa_fixp
;
1410 static arelent
*no_relocs
= NULL
;
1417 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
1418 if (fixp
->fx_addsy
== 0)
1421 assert (hppa_fixp
!= 0);
1422 assert (section
!= 0);
1424 reloc
= xmalloc (sizeof (arelent
));
1426 reloc
->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
1427 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1428 codes
= hppa_gen_reloc_type (stdoutput
,
1430 hppa_fixp
->fx_r_format
,
1431 hppa_fixp
->fx_r_field
,
1432 fixp
->fx_subsy
!= NULL
,
1433 symbol_get_bfdsym (fixp
->fx_addsy
));
1437 as_bad_where (fixp
->fx_file
, fixp
->fx_line
, _("Cannot handle fixup"));
1441 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
1444 relocs
= xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
1445 reloc
= xmalloc (sizeof (arelent
) * n_relocs
);
1446 for (i
= 0; i
< n_relocs
; i
++)
1447 relocs
[i
] = &reloc
[i
];
1449 relocs
[n_relocs
] = NULL
;
1452 switch (fixp
->fx_r_type
)
1455 assert (n_relocs
== 1);
1459 /* Now, do any processing that is dependent on the relocation type. */
1462 case R_PARISC_DLTREL21L
:
1463 case R_PARISC_DLTREL14R
:
1464 case R_PARISC_DLTREL14F
:
1465 case R_PARISC_PLABEL32
:
1466 case R_PARISC_PLABEL21L
:
1467 case R_PARISC_PLABEL14R
:
1468 /* For plabel relocations, the addend of the
1469 relocation should be either 0 (no static link) or 2
1470 (static link required). This adjustment is done in
1471 bfd/elf32-hppa.c:elf32_hppa_relocate_section.
1473 We also slam a zero addend into the DLT relative relocs;
1474 it doesn't make a lot of sense to use any addend since
1475 it gets you a different (eg unknown) DLT entry. */
1479 #ifdef ELF_ARG_RELOC
1480 case R_PARISC_PCREL17R
:
1481 case R_PARISC_PCREL17F
:
1482 case R_PARISC_PCREL17C
:
1483 case R_PARISC_DIR17R
:
1484 case R_PARISC_DIR17F
:
1485 case R_PARISC_PCREL21L
:
1486 case R_PARISC_DIR21L
:
1487 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
,
1492 case R_PARISC_DIR32
:
1493 /* Facilitate hand-crafted unwind info. */
1494 if (strcmp (section
->name
, UNWIND_SECTION_NAME
) == 0)
1495 code
= R_PARISC_SEGREL32
;
1499 reloc
->addend
= fixp
->fx_offset
;
1503 reloc
->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
1504 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1505 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
,
1506 (bfd_reloc_code_real_type
) code
);
1507 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1509 assert (reloc
->howto
&& (unsigned int) code
== reloc
->howto
->type
);
1514 /* Walk over reach relocation returned by the BFD backend. */
1515 for (i
= 0; i
< n_relocs
; i
++)
1519 relocs
[i
]->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
1520 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1522 bfd_reloc_type_lookup (stdoutput
,
1523 (bfd_reloc_code_real_type
) code
);
1524 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1529 /* The only time we ever use a R_COMP2 fixup is for the difference
1530 of two symbols. With that in mind we fill in all four
1531 relocs now and break out of the loop. */
1533 relocs
[0]->sym_ptr_ptr
1534 = (asymbol
**) bfd_abs_section_ptr
->symbol_ptr_ptr
;
1536 = bfd_reloc_type_lookup (stdoutput
,
1537 (bfd_reloc_code_real_type
) *codes
[0]);
1538 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1539 relocs
[0]->addend
= 0;
1540 relocs
[1]->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
1541 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1543 = bfd_reloc_type_lookup (stdoutput
,
1544 (bfd_reloc_code_real_type
) *codes
[1]);
1545 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1546 relocs
[1]->addend
= 0;
1547 relocs
[2]->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
1548 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
1550 = bfd_reloc_type_lookup (stdoutput
,
1551 (bfd_reloc_code_real_type
) *codes
[2]);
1552 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1553 relocs
[2]->addend
= 0;
1554 relocs
[3]->sym_ptr_ptr
1555 = (asymbol
**) bfd_abs_section_ptr
->symbol_ptr_ptr
;
1557 = bfd_reloc_type_lookup (stdoutput
,
1558 (bfd_reloc_code_real_type
) *codes
[3]);
1559 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1560 relocs
[3]->addend
= 0;
1561 relocs
[4]->sym_ptr_ptr
1562 = (asymbol
**) bfd_abs_section_ptr
->symbol_ptr_ptr
;
1564 = bfd_reloc_type_lookup (stdoutput
,
1565 (bfd_reloc_code_real_type
) *codes
[4]);
1566 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1567 relocs
[4]->addend
= 0;
1571 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
1577 /* For plabel relocations, the addend of the
1578 relocation should be either 0 (no static link) or 2
1579 (static link required).
1581 FIXME: We always assume no static link!
1583 We also slam a zero addend into the DLT relative relocs;
1584 it doesn't make a lot of sense to use any addend since
1585 it gets you a different (eg unknown) DLT entry. */
1586 relocs
[i
]->addend
= 0;
1601 /* There is no symbol or addend associated with these fixups. */
1602 relocs
[i
]->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
1603 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
1604 relocs
[i
]->addend
= 0;
1610 /* There is no symbol associated with these fixups. */
1611 relocs
[i
]->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
1612 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
1613 relocs
[i
]->addend
= fixp
->fx_offset
;
1617 relocs
[i
]->addend
= fixp
->fx_offset
;
1627 /* Process any machine dependent frag types. */
1630 md_convert_frag (bfd
*abfd ATTRIBUTE_UNUSED
,
1631 asection
*sec ATTRIBUTE_UNUSED
,
1634 unsigned int address
;
1636 if (fragP
->fr_type
== rs_machine_dependent
)
1638 switch ((int) fragP
->fr_subtype
)
1641 fragP
->fr_type
= rs_fill
;
1642 know (fragP
->fr_var
== 1);
1643 know (fragP
->fr_next
);
1644 address
= fragP
->fr_address
+ fragP
->fr_fix
;
1645 if (address
% fragP
->fr_offset
)
1648 fragP
->fr_next
->fr_address
1653 fragP
->fr_offset
= 0;
1659 /* Round up a section size to the appropriate boundary. */
1662 md_section_align (asection
*segment
, valueT size
)
1664 int align
= bfd_get_section_alignment (stdoutput
, segment
);
1665 int align2
= (1 << align
) - 1;
1667 return (size
+ align2
) & ~align2
;
1670 /* Return the approximate size of a frag before relaxation has occurred. */
1673 md_estimate_size_before_relax (fragS
*fragP
, asection
*segment ATTRIBUTE_UNUSED
)
1679 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
1686 # ifdef WARN_COMMENTS
1687 const char *md_shortopts
= "Vc";
1689 const char *md_shortopts
= "V";
1692 # ifdef WARN_COMMENTS
1693 const char *md_shortopts
= "c";
1695 const char *md_shortopts
= "";
1699 struct option md_longopts
[] =
1701 #ifdef WARN_COMMENTS
1702 {"warn-comment", no_argument
, NULL
, 'c'},
1704 {NULL
, no_argument
, NULL
, 0}
1706 size_t md_longopts_size
= sizeof (md_longopts
);
1709 md_parse_option (int c
, char *arg ATTRIBUTE_UNUSED
)
1718 print_version_id ();
1721 #ifdef WARN_COMMENTS
1732 md_show_usage (FILE *stream ATTRIBUTE_UNUSED
)
1735 fprintf (stream
, _("\
1738 #ifdef WARN_COMMENTS
1739 fprintf (stream
, _("\
1740 -c print a warning if a comment is found\n"));
1744 /* We have no need to default values of symbols. */
1747 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
1752 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
1753 #define nonzero_dibits(x) \
1754 ((x) | (((x) & 0x55555555) << 1) | (((x) & 0xAAAAAAAA) >> 1))
1755 #define arg_reloc_stub_needed(CALLER, CALLEE) \
1756 (((CALLER) ^ (CALLEE)) & nonzero_dibits (CALLER) & nonzero_dibits (CALLEE))
1758 #define arg_reloc_stub_needed(CALLER, CALLEE) 0
1761 /* Apply a fixup to an instruction. */
1764 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg ATTRIBUTE_UNUSED
)
1767 struct hppa_fix_struct
*hppa_fixP
;
1771 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
1772 never be "applied" (they are just markers). Likewise for
1773 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
1775 if (fixP
->fx_r_type
== R_HPPA_ENTRY
1776 || fixP
->fx_r_type
== R_HPPA_EXIT
1777 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
1778 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
1779 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
1782 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
1783 fixups are considered not adjustable, which in turn causes
1784 adjust_reloc_syms to not set fx_offset. Ugh. */
1785 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
1787 fixP
->fx_offset
= * valP
;
1792 if (fixP
->fx_r_type
== (int) R_PARISC_GNU_VTENTRY
1793 || fixP
->fx_r_type
== (int) R_PARISC_GNU_VTINHERIT
)
1797 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
1800 /* There should be a HPPA specific fixup associated with the GAS fixup. */
1801 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
1802 if (hppa_fixP
== NULL
)
1804 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1805 _("no hppa_fixup entry for fixup type 0x%x"),
1810 fixpos
= fixP
->fx_frag
->fr_literal
+ fixP
->fx_where
;
1812 if (fixP
->fx_size
!= 4 || hppa_fixP
->fx_r_format
== 32)
1814 /* Handle constant output. */
1815 number_to_chars_bigendian (fixpos
, *valP
, fixP
->fx_size
);
1819 insn
= bfd_get_32 (stdoutput
, fixpos
);
1820 fmt
= bfd_hppa_insn2fmt (stdoutput
, insn
);
1822 /* If there is a symbol associated with this fixup, then it's something
1823 which will need a SOM relocation (except for some PC-relative relocs).
1824 In such cases we should treat the "val" or "addend" as zero since it
1825 will be added in as needed from fx_offset in tc_gen_reloc. */
1826 if ((fixP
->fx_addsy
!= NULL
1827 || fixP
->fx_r_type
== (int) R_HPPA_NONE
)
1832 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
1834 /* These field selectors imply that we do not want an addend. */
1835 else if (hppa_fixP
->fx_r_field
== e_psel
1836 || hppa_fixP
->fx_r_field
== e_rpsel
1837 || hppa_fixP
->fx_r_field
== e_lpsel
1838 || hppa_fixP
->fx_r_field
== e_tsel
1839 || hppa_fixP
->fx_r_field
== e_rtsel
1840 || hppa_fixP
->fx_r_field
== e_ltsel
)
1841 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
1844 new_val
= hppa_field_adjust (* valP
, 0, hppa_fixP
->fx_r_field
);
1846 /* Handle pc-relative exceptions from above. */
1847 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
1850 && !arg_reloc_stub_needed (symbol_arg_reloc_info (fixP
->fx_addsy
),
1851 hppa_fixP
->fx_arg_reloc
)
1853 && (* valP
- 8 + 8192 < 16384
1854 || (fmt
== 17 && * valP
- 8 + 262144 < 524288)
1855 || (fmt
== 22 && * valP
- 8 + 8388608 < 16777216))
1858 && (* valP
- 8 + 262144 < 524288
1859 || (fmt
== 22 && * valP
- 8 + 8388608 < 16777216))
1861 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
1862 && !S_IS_WEAK (fixP
->fx_addsy
)
1863 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
1865 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
1867 new_val
= hppa_field_adjust (* valP
, 0, hppa_fixP
->fx_r_field
);
1873 CHECK_FIELD_WHERE (new_val
, 8191, -8192,
1874 fixP
->fx_file
, fixP
->fx_line
);
1877 insn
= (insn
& ~ 0x3ff1) | (((val
& 0x1ff8) << 1)
1878 | ((val
& 0x2000) >> 13));
1881 CHECK_FIELD_WHERE (new_val
, 8191, -8192,
1882 fixP
->fx_file
, fixP
->fx_line
);
1885 insn
= (insn
& ~ 0x3ff9) | (((val
& 0x1ffc) << 1)
1886 | ((val
& 0x2000) >> 13));
1888 /* Handle all opcodes with the 'j' operand type. */
1890 CHECK_FIELD_WHERE (new_val
, 8191, -8192,
1891 fixP
->fx_file
, fixP
->fx_line
);
1894 insn
= ((insn
& ~ 0x3fff) | low_sign_unext (val
, 14));
1897 /* Handle all opcodes with the 'k' operand type. */
1899 CHECK_FIELD_WHERE (new_val
, 1048575, -1048576,
1900 fixP
->fx_file
, fixP
->fx_line
);
1903 insn
= (insn
& ~ 0x1fffff) | re_assemble_21 (val
);
1906 /* Handle all the opcodes with the 'i' operand type. */
1908 CHECK_FIELD_WHERE (new_val
, 1023, -1024,
1909 fixP
->fx_file
, fixP
->fx_line
);
1912 insn
= (insn
& ~ 0x7ff) | low_sign_unext (val
, 11);
1915 /* Handle all the opcodes with the 'w' operand type. */
1917 CHECK_FIELD_WHERE (new_val
- 8, 8191, -8192,
1918 fixP
->fx_file
, fixP
->fx_line
);
1921 insn
= (insn
& ~ 0x1ffd) | re_assemble_12 (val
>> 2);
1924 /* Handle some of the opcodes with the 'W' operand type. */
1927 offsetT distance
= * valP
;
1929 /* If this is an absolute branch (ie no link) with an out of
1930 range target, then we want to complain. */
1931 if (fixP
->fx_r_type
== (int) R_HPPA_PCREL_CALL
1932 && (insn
& 0xffe00000) == 0xe8000000)
1933 CHECK_FIELD_WHERE (distance
- 8, 262143, -262144,
1934 fixP
->fx_file
, fixP
->fx_line
);
1936 CHECK_FIELD_WHERE (new_val
- 8, 262143, -262144,
1937 fixP
->fx_file
, fixP
->fx_line
);
1940 insn
= (insn
& ~ 0x1f1ffd) | re_assemble_17 (val
>> 2);
1946 offsetT distance
= * valP
;
1948 /* If this is an absolute branch (ie no link) with an out of
1949 range target, then we want to complain. */
1950 if (fixP
->fx_r_type
== (int) R_HPPA_PCREL_CALL
1951 && (insn
& 0xffe00000) == 0xe8000000)
1952 CHECK_FIELD_WHERE (distance
- 8, 8388607, -8388608,
1953 fixP
->fx_file
, fixP
->fx_line
);
1955 CHECK_FIELD_WHERE (new_val
- 8, 8388607, -8388608,
1956 fixP
->fx_file
, fixP
->fx_line
);
1959 insn
= (insn
& ~ 0x3ff1ffd) | re_assemble_22 (val
>> 2);
1965 insn
= (insn
& ~ 0xfff1) | re_assemble_16 (val
& -8);
1970 insn
= (insn
& ~ 0xfff9) | re_assemble_16 (val
& -4);
1975 insn
= (insn
& ~ 0xffff) | re_assemble_16 (val
);
1983 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
1984 _("Unknown relocation encountered in md_apply_fix."));
1989 switch (fixP
->fx_r_type
)
1991 case R_PARISC_TLS_GD21L
:
1992 case R_PARISC_TLS_GD14R
:
1993 case R_PARISC_TLS_LDM21L
:
1994 case R_PARISC_TLS_LDM14R
:
1995 case R_PARISC_TLS_LE21L
:
1996 case R_PARISC_TLS_LE14R
:
1997 case R_PARISC_TLS_IE21L
:
1998 case R_PARISC_TLS_IE14R
:
2000 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
2007 /* Insert the relocation. */
2008 bfd_put_32 (stdoutput
, insn
, fixpos
);
2011 /* Exactly what point is a PC-relative offset relative TO?
2012 On the PA, they're relative to the address of the offset. */
2015 md_pcrel_from (fixS
*fixP
)
2017 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
2020 /* Return nonzero if the input line pointer is at the end of
2024 is_end_of_statement (void)
2026 return ((*input_line_pointer
== '\n')
2027 || (*input_line_pointer
== ';')
2028 || (*input_line_pointer
== '!'));
2031 #define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg))
2033 /* Given NAME, find the register number associated with that name, return
2034 the integer value associated with the given name or -1 on failure. */
2037 reg_name_search (char *name
)
2039 int middle
, low
, high
;
2043 high
= REG_NAME_CNT
- 1;
2047 middle
= (low
+ high
) / 2;
2048 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
2054 return pre_defined_registers
[middle
].value
;
2056 while (low
<= high
);
2061 /* Read a number from S. The number might come in one of many forms,
2062 the most common will be a hex or decimal constant, but it could be
2063 a pre-defined register (Yuk!), or an absolute symbol.
2065 Return 1 on success or 0 on failure. If STRICT, then a missing
2066 register prefix will cause a failure. The number itself is
2067 returned in `pa_number'.
2069 IS_FLOAT indicates that a PA-89 FP register number should be
2070 parsed; A `l' or `r' suffix is checked for if but 2 of IS_FLOAT is
2073 pa_parse_number can not handle negative constants and will fail
2074 horribly if it is passed such a constant. */
2077 pa_parse_number (char **s
, int is_float
)
2085 bfd_boolean have_prefix
;
2087 /* Skip whitespace before the number. */
2088 while (*p
== ' ' || *p
== '\t')
2094 if (!strict
&& ISDIGIT (*p
))
2096 /* Looks like a number. */
2098 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
2100 /* The number is specified in hex. */
2102 while (ISDIGIT (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
2103 || ((*p
>= 'A') && (*p
<= 'F')))
2106 num
= num
* 16 + *p
- '0';
2107 else if (*p
>= 'a' && *p
<= 'f')
2108 num
= num
* 16 + *p
- 'a' + 10;
2110 num
= num
* 16 + *p
- 'A' + 10;
2116 /* The number is specified in decimal. */
2117 while (ISDIGIT (*p
))
2119 num
= num
* 10 + *p
- '0';
2126 /* Check for a `l' or `r' suffix. */
2129 pa_number
+= FP_REG_BASE
;
2130 if (! (is_float
& 2))
2132 if (IS_R_SELECT (p
))
2134 pa_number
+= FP_REG_RSEL
;
2137 else if (IS_L_SELECT (p
))
2146 /* The number might be a predefined register. */
2151 /* Tege hack: Special case for general registers as the general
2152 code makes a binary search with case translation, and is VERY
2157 if (*p
== 'e' && *(p
+ 1) == 't'
2158 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
2161 num
= *p
- '0' + 28;
2169 else if (!ISDIGIT (*p
))
2172 as_bad (_("Undefined register: '%s'."), name
);
2178 num
= num
* 10 + *p
++ - '0';
2179 while (ISDIGIT (*p
));
2184 /* Do a normal register search. */
2185 while (is_part_of_name (c
))
2191 status
= reg_name_search (name
);
2197 as_bad (_("Undefined register: '%s'."), name
);
2207 /* And finally, it could be a symbol in the absolute section which
2208 is effectively a constant, or a register alias symbol. */
2211 while (is_part_of_name (c
))
2217 if ((sym
= symbol_find (name
)) != NULL
)
2219 if (S_GET_SEGMENT (sym
) == reg_section
)
2221 num
= S_GET_VALUE (sym
);
2222 /* Well, we don't really have one, but we do have a
2226 else if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
2227 num
= S_GET_VALUE (sym
);
2231 as_bad (_("Non-absolute symbol: '%s'."), name
);
2237 /* There is where we'd come for an undefined symbol
2238 or for an empty string. For an empty string we
2239 will return zero. That's a concession made for
2240 compatibility with the braindamaged HP assemblers. */
2246 as_bad (_("Undefined absolute constant: '%s'."), name
);
2255 if (!strict
|| have_prefix
)
2263 /* Return nonzero if the given INSN and L/R information will require
2264 a new PA-1.1 opcode. */
2267 need_pa11_opcode (void)
2269 if ((pa_number
& FP_REG_RSEL
) != 0
2270 && !(the_insn
.fpof1
== DBL
&& the_insn
.fpof2
== DBL
))
2272 /* If this instruction is specific to a particular architecture,
2273 then set a new architecture. */
2274 if (bfd_get_mach (stdoutput
) < pa11
)
2276 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
2277 as_warn (_("could not update architecture and machine"));
2285 /* Parse a condition for a fcmp instruction. Return the numerical
2286 code associated with the condition. */
2289 pa_parse_fp_cmp_cond (char **s
)
2295 for (i
= 0; i
< 32; i
++)
2297 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
2298 strlen (fp_cond_map
[i
].string
)) == 0)
2300 cond
= fp_cond_map
[i
].cond
;
2301 *s
+= strlen (fp_cond_map
[i
].string
);
2302 /* If not a complete match, back up the input string and
2304 if (**s
!= ' ' && **s
!= '\t')
2306 *s
-= strlen (fp_cond_map
[i
].string
);
2309 while (**s
== ' ' || **s
== '\t')
2315 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
2317 /* Advance over the bogus completer. */
2318 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
2324 /* Parse a graphics test complete for ftest. */
2327 pa_parse_ftest_gfx_completer (char **s
)
2332 if (strncasecmp (*s
, "acc8", 4) == 0)
2337 else if (strncasecmp (*s
, "acc6", 4) == 0)
2342 else if (strncasecmp (*s
, "acc4", 4) == 0)
2347 else if (strncasecmp (*s
, "acc2", 4) == 0)
2352 else if (strncasecmp (*s
, "acc", 3) == 0)
2357 else if (strncasecmp (*s
, "rej8", 4) == 0)
2362 else if (strncasecmp (*s
, "rej", 3) == 0)
2370 as_bad (_("Invalid FTEST completer: %s"), *s
);
2376 /* Parse an FP operand format completer returning the completer
2379 static fp_operand_format
2380 pa_parse_fp_cnv_format (char **s
)
2388 if (strncasecmp (*s
, "sgl", 3) == 0)
2393 else if (strncasecmp (*s
, "dbl", 3) == 0)
2398 else if (strncasecmp (*s
, "quad", 4) == 0)
2403 else if (strncasecmp (*s
, "w", 1) == 0)
2408 else if (strncasecmp (*s
, "uw", 2) == 0)
2413 else if (strncasecmp (*s
, "dw", 2) == 0)
2418 else if (strncasecmp (*s
, "udw", 3) == 0)
2423 else if (strncasecmp (*s
, "qw", 2) == 0)
2428 else if (strncasecmp (*s
, "uqw", 3) == 0)
2435 format
= ILLEGAL_FMT
;
2436 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
2443 /* Parse an FP operand format completer returning the completer
2446 static fp_operand_format
2447 pa_parse_fp_format (char **s
)
2455 if (strncasecmp (*s
, "sgl", 3) == 0)
2460 else if (strncasecmp (*s
, "dbl", 3) == 0)
2465 else if (strncasecmp (*s
, "quad", 4) == 0)
2472 format
= ILLEGAL_FMT
;
2473 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
2480 /* Convert from a selector string into a selector type. */
2483 pa_chk_field_selector (char **str
)
2485 int middle
, low
, high
;
2489 /* Read past any whitespace. */
2490 /* FIXME: should we read past newlines and formfeeds??? */
2491 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
2494 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
2495 name
[0] = TOLOWER ((*str
)[0]),
2497 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
2498 name
[0] = TOLOWER ((*str
)[0]),
2499 name
[1] = TOLOWER ((*str
)[1]),
2501 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
2502 name
[0] = TOLOWER ((*str
)[0]),
2503 name
[1] = TOLOWER ((*str
)[1]),
2504 name
[2] = TOLOWER ((*str
)[2]),
2510 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
2514 middle
= (low
+ high
) / 2;
2515 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
2522 *str
+= strlen (name
) + 1;
2524 if (selector_table
[middle
].field_selector
== e_nsel
)
2527 return selector_table
[middle
].field_selector
;
2530 while (low
<= high
);
2535 /* Parse a .byte, .word, .long expression for the HPPA. Called by
2536 cons via the TC_PARSE_CONS_EXPRESSION macro. */
2539 parse_cons_expression_hppa (expressionS
*exp
)
2541 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
2545 /* Evaluate an absolute expression EXP which may be modified by
2546 the selector FIELD_SELECTOR. Return the value of the expression. */
2548 evaluate_absolute (struct pa_it
*insn
)
2552 int field_selector
= insn
->field_selector
;
2555 value
= exp
.X_add_number
;
2557 return hppa_field_adjust (0, value
, field_selector
);
2560 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
2563 pa_get_absolute_expression (struct pa_it
*insn
, char **strp
)
2567 insn
->field_selector
= pa_chk_field_selector (strp
);
2568 save_in
= input_line_pointer
;
2569 input_line_pointer
= *strp
;
2570 expression (&insn
->exp
);
2571 /* This is not perfect, but is a huge improvement over doing nothing.
2573 The PA assembly syntax is ambiguous in a variety of ways. Consider
2574 this string "4 %r5" Is that the number 4 followed by the register
2575 r5, or is that 4 MOD r5?
2577 If we get a modulo expression when looking for an absolute, we try
2578 again cutting off the input string at the first whitespace character. */
2579 if (insn
->exp
.X_op
== O_modulus
)
2584 input_line_pointer
= *strp
;
2586 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2592 retval
= pa_get_absolute_expression (insn
, strp
);
2594 input_line_pointer
= save_in
;
2596 return evaluate_absolute (insn
);
2598 /* When in strict mode we have a non-match, fix up the pointers
2599 and return to our caller. */
2600 if (insn
->exp
.X_op
!= O_constant
&& strict
)
2602 expr_end
= input_line_pointer
;
2603 input_line_pointer
= save_in
;
2606 if (insn
->exp
.X_op
!= O_constant
)
2608 as_bad (_("Bad segment (should be absolute)."));
2609 expr_end
= input_line_pointer
;
2610 input_line_pointer
= save_in
;
2613 expr_end
= input_line_pointer
;
2614 input_line_pointer
= save_in
;
2615 return evaluate_absolute (insn
);
2618 /* Given an argument location specification return the associated
2619 argument location number. */
2622 pa_build_arg_reloc (char *type_name
)
2625 if (strncasecmp (type_name
, "no", 2) == 0)
2627 if (strncasecmp (type_name
, "gr", 2) == 0)
2629 else if (strncasecmp (type_name
, "fr", 2) == 0)
2631 else if (strncasecmp (type_name
, "fu", 2) == 0)
2634 as_bad (_("Invalid argument location: %s\n"), type_name
);
2639 /* Encode and return an argument relocation specification for
2640 the given register in the location specified by arg_reloc. */
2643 pa_align_arg_reloc (unsigned int reg
, unsigned int arg_reloc
)
2645 unsigned int new_reloc
;
2647 new_reloc
= arg_reloc
;
2663 as_bad (_("Invalid argument description: %d"), reg
);
2669 /* Parse a non-negated compare/subtract completer returning the
2670 number (for encoding in instructions) of the given completer. */
2673 pa_parse_nonneg_cmpsub_cmpltr (char **s
)
2676 char *name
= *s
+ 1;
2685 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
2690 if (strcmp (name
, "=") == 0)
2694 else if (strcmp (name
, "<") == 0)
2698 else if (strcmp (name
, "<=") == 0)
2702 else if (strcmp (name
, "<<") == 0)
2706 else if (strcmp (name
, "<<=") == 0)
2710 else if (strcasecmp (name
, "sv") == 0)
2714 else if (strcasecmp (name
, "od") == 0)
2718 /* If we have something like addb,n then there is no condition
2720 else if (strcasecmp (name
, "n") == 0)
2732 /* Reset pointers if this was really a ,n for a branch instruction. */
2739 /* Parse a negated compare/subtract completer returning the
2740 number (for encoding in instructions) of the given completer. */
2743 pa_parse_neg_cmpsub_cmpltr (char **s
)
2746 char *name
= *s
+ 1;
2755 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
2760 if (strcasecmp (name
, "tr") == 0)
2764 else if (strcmp (name
, "<>") == 0)
2768 else if (strcmp (name
, ">=") == 0)
2772 else if (strcmp (name
, ">") == 0)
2776 else if (strcmp (name
, ">>=") == 0)
2780 else if (strcmp (name
, ">>") == 0)
2784 else if (strcasecmp (name
, "nsv") == 0)
2788 else if (strcasecmp (name
, "ev") == 0)
2792 /* If we have something like addb,n then there is no condition
2794 else if (strcasecmp (name
, "n") == 0)
2806 /* Reset pointers if this was really a ,n for a branch instruction. */
2813 /* Parse a 64 bit compare and branch completer returning the number (for
2814 encoding in instructions) of the given completer.
2816 Nonnegated comparisons are returned as 0-7, negated comparisons are
2817 returned as 8-15. */
2820 pa_parse_cmpb_64_cmpltr (char **s
)
2823 char *name
= *s
+ 1;
2830 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
2835 if (strcmp (name
, "*") == 0)
2839 else if (strcmp (name
, "*=") == 0)
2843 else if (strcmp (name
, "*<") == 0)
2847 else if (strcmp (name
, "*<=") == 0)
2851 else if (strcmp (name
, "*<<") == 0)
2855 else if (strcmp (name
, "*<<=") == 0)
2859 else if (strcasecmp (name
, "*sv") == 0)
2863 else if (strcasecmp (name
, "*od") == 0)
2867 else if (strcasecmp (name
, "*tr") == 0)
2871 else if (strcmp (name
, "*<>") == 0)
2875 else if (strcmp (name
, "*>=") == 0)
2879 else if (strcmp (name
, "*>") == 0)
2883 else if (strcmp (name
, "*>>=") == 0)
2887 else if (strcmp (name
, "*>>") == 0)
2891 else if (strcasecmp (name
, "*nsv") == 0)
2895 else if (strcasecmp (name
, "*ev") == 0)
2909 /* Parse a 64 bit compare immediate and branch completer returning the number
2910 (for encoding in instructions) of the given completer. */
2913 pa_parse_cmpib_64_cmpltr (char **s
)
2916 char *name
= *s
+ 1;
2923 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
2928 if (strcmp (name
, "*<<") == 0)
2932 else if (strcmp (name
, "*=") == 0)
2936 else if (strcmp (name
, "*<") == 0)
2940 else if (strcmp (name
, "*<=") == 0)
2944 else if (strcmp (name
, "*>>=") == 0)
2948 else if (strcmp (name
, "*<>") == 0)
2952 else if (strcasecmp (name
, "*>=") == 0)
2956 else if (strcasecmp (name
, "*>") == 0)
2970 /* Parse a non-negated addition completer returning the number
2971 (for encoding in instructions) of the given completer. */
2974 pa_parse_nonneg_add_cmpltr (char **s
)
2977 char *name
= *s
+ 1;
2986 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
2990 if (strcmp (name
, "=") == 0)
2994 else if (strcmp (name
, "<") == 0)
2998 else if (strcmp (name
, "<=") == 0)
3002 else if (strcasecmp (name
, "nuv") == 0)
3006 else if (strcasecmp (name
, "znv") == 0)
3010 else if (strcasecmp (name
, "sv") == 0)
3014 else if (strcasecmp (name
, "od") == 0)
3018 /* If we have something like addb,n then there is no condition
3020 else if (strcasecmp (name
, "n") == 0)
3032 /* Reset pointers if this was really a ,n for a branch instruction. */
3039 /* Parse a negated addition completer returning the number
3040 (for encoding in instructions) of the given completer. */
3043 pa_parse_neg_add_cmpltr (char **s
)
3046 char *name
= *s
+ 1;
3055 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3059 if (strcasecmp (name
, "tr") == 0)
3063 else if (strcmp (name
, "<>") == 0)
3067 else if (strcmp (name
, ">=") == 0)
3071 else if (strcmp (name
, ">") == 0)
3075 else if (strcasecmp (name
, "uv") == 0)
3079 else if (strcasecmp (name
, "vnz") == 0)
3083 else if (strcasecmp (name
, "nsv") == 0)
3087 else if (strcasecmp (name
, "ev") == 0)
3091 /* If we have something like addb,n then there is no condition
3093 else if (strcasecmp (name
, "n") == 0)
3105 /* Reset pointers if this was really a ,n for a branch instruction. */
3112 /* Parse a 64 bit wide mode add and branch completer returning the number (for
3113 encoding in instructions) of the given completer. */
3116 pa_parse_addb_64_cmpltr (char **s
)
3119 char *name
= *s
+ 1;
3128 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3132 if (strcmp (name
, "=") == 0)
3136 else if (strcmp (name
, "<") == 0)
3140 else if (strcmp (name
, "<=") == 0)
3144 else if (strcasecmp (name
, "nuv") == 0)
3148 else if (strcasecmp (name
, "*=") == 0)
3152 else if (strcasecmp (name
, "*<") == 0)
3156 else if (strcasecmp (name
, "*<=") == 0)
3160 else if (strcmp (name
, "tr") == 0)
3164 else if (strcmp (name
, "<>") == 0)
3168 else if (strcmp (name
, ">=") == 0)
3172 else if (strcmp (name
, ">") == 0)
3176 else if (strcasecmp (name
, "uv") == 0)
3180 else if (strcasecmp (name
, "*<>") == 0)
3184 else if (strcasecmp (name
, "*>=") == 0)
3188 else if (strcasecmp (name
, "*>") == 0)
3192 /* If we have something like addb,n then there is no condition
3194 else if (strcasecmp (name
, "n") == 0)
3206 /* Reset pointers if this was really a ,n for a branch instruction. */
3213 /* Do the real work for assembling a single instruction. Store results
3214 into the global "the_insn" variable. */
3219 char *error_message
= "";
3220 char *s
, c
, *argstart
, *name
, *save_s
;
3224 int cmpltr
, nullif
, flag
, cond
, num
;
3225 unsigned long opcode
;
3226 struct pa_opcode
*insn
;
3229 /* We must have a valid space and subspace. */
3230 pa_check_current_space_and_subspace ();
3233 /* Convert everything up to the first whitespace character into lower
3235 for (s
= str
; *s
!= ' ' && *s
!= '\t' && *s
!= '\n' && *s
!= '\0'; s
++)
3238 /* Skip to something interesting. */
3240 ISUPPER (*s
) || ISLOWER (*s
) || (*s
>= '0' && *s
<= '3');
3260 as_bad (_("Unknown opcode: `%s'"), str
);
3264 /* Look up the opcode in the has table. */
3265 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
3267 as_bad ("Unknown opcode: `%s'", str
);
3274 /* Mark the location where arguments for the instruction start, then
3275 start processing them. */
3279 /* Do some initialization. */
3280 opcode
= insn
->match
;
3281 strict
= (insn
->flags
& FLAG_STRICT
);
3282 memset (&the_insn
, 0, sizeof (the_insn
));
3284 the_insn
.reloc
= R_HPPA_NONE
;
3286 if (insn
->arch
>= pa20
3287 && bfd_get_mach (stdoutput
) < insn
->arch
)
3290 /* Build the opcode, checking as we go to make
3291 sure that the operands match. */
3292 for (args
= insn
->args
;; ++args
)
3294 /* Absorb white space in instruction. */
3295 while (*s
== ' ' || *s
== '\t')
3300 /* End of arguments. */
3316 /* These must match exactly. */
3325 /* Handle a 5 bit register or control register field at 10. */
3328 if (!pa_parse_number (&s
, 0))
3331 CHECK_FIELD (num
, 31, 0, 0);
3332 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3334 /* Handle %sar or %cr11. No bits get set, we just verify that it
3337 /* Skip whitespace before register. */
3338 while (*s
== ' ' || *s
== '\t')
3341 if (!strncasecmp (s
, "%sar", 4))
3346 else if (!strncasecmp (s
, "%cr11", 5))
3353 /* Handle a 5 bit register field at 15. */
3355 if (!pa_parse_number (&s
, 0))
3358 CHECK_FIELD (num
, 31, 0, 0);
3359 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
3361 /* Handle a 5 bit register field at 31. */
3363 if (!pa_parse_number (&s
, 0))
3366 CHECK_FIELD (num
, 31, 0, 0);
3367 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3369 /* Handle a 5 bit register field at 10 and 15. */
3371 if (!pa_parse_number (&s
, 0))
3374 CHECK_FIELD (num
, 31, 0, 0);
3375 opcode
|= num
<< 16;
3376 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3378 /* Handle a 5 bit field length at 31. */
3380 num
= pa_get_absolute_expression (&the_insn
, &s
);
3381 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3384 CHECK_FIELD (num
, 32, 1, 0);
3385 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
3387 /* Handle a 5 bit immediate at 15. */
3389 num
= pa_get_absolute_expression (&the_insn
, &s
);
3390 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3393 /* When in strict mode, we want to just reject this
3394 match instead of giving an out of range error. */
3395 CHECK_FIELD (num
, 15, -16, strict
);
3396 num
= low_sign_unext (num
, 5);
3397 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
3399 /* Handle a 5 bit immediate at 31. */
3401 num
= pa_get_absolute_expression (&the_insn
, &s
);
3402 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3405 /* When in strict mode, we want to just reject this
3406 match instead of giving an out of range error. */
3407 CHECK_FIELD (num
, 15, -16, strict
);
3408 num
= low_sign_unext (num
, 5);
3409 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3411 /* Handle an unsigned 5 bit immediate at 31. */
3413 num
= pa_get_absolute_expression (&the_insn
, &s
);
3414 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3417 CHECK_FIELD (num
, 31, 0, strict
);
3418 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3420 /* Handle an unsigned 5 bit immediate at 15. */
3422 num
= pa_get_absolute_expression (&the_insn
, &s
);
3423 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3426 CHECK_FIELD (num
, 31, 0, strict
);
3427 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
3429 /* Handle an unsigned 10 bit immediate at 15. */
3431 num
= pa_get_absolute_expression (&the_insn
, &s
);
3432 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3435 CHECK_FIELD (num
, 1023, 0, strict
);
3436 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
3438 /* Handle a 2 bit space identifier at 17. */
3440 if (!pa_parse_number (&s
, 0))
3443 CHECK_FIELD (num
, 3, 0, 1);
3444 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
3446 /* Handle a 3 bit space identifier at 18. */
3448 if (!pa_parse_number (&s
, 0))
3451 CHECK_FIELD (num
, 7, 0, 1);
3452 opcode
|= re_assemble_3 (num
);
3455 /* Handle all completers. */
3460 /* Handle a completer for an indexing load or store. */
3467 while (*s
== ',' && i
< 2)
3470 if (strncasecmp (s
, "sm", 2) == 0)
3477 else if (strncasecmp (s
, "m", 1) == 0)
3479 else if ((strncasecmp (s
, "s ", 2) == 0)
3480 || (strncasecmp (s
, "s,", 2) == 0))
3484 /* This is a match failure. */
3489 as_bad (_("Invalid Indexed Load Completer."));
3494 as_bad (_("Invalid Indexed Load Completer Syntax."));
3496 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
3499 /* Handle a short load/store completer. */
3511 if (strncasecmp (s
, "ma", 2) == 0)
3517 else if (strncasecmp (s
, "mb", 2) == 0)
3524 /* This is a match failure. */
3528 as_bad (_("Invalid Short Load/Store Completer."));
3532 /* If we did not get a ma/mb completer, then we do not
3533 consider this a positive match for 'ce'. */
3534 else if (*args
== 'e')
3537 /* 'J', 'm', 'M' and 'q' are the same, except for where they
3538 encode the before/after field. */
3539 if (*args
== 'm' || *args
== 'M')
3542 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
3544 else if (*args
== 'q')
3547 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
3549 else if (*args
== 'J')
3551 /* M bit is explicit in the major opcode. */
3552 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
3554 else if (*args
== 'e')
3556 /* Stash the ma/mb flag temporarily in the
3557 instruction. We will use (and remove it)
3558 later when handling 'J', 'K', '<' & '>'. */
3564 /* Handle a stbys completer. */
3571 while (*s
== ',' && i
< 2)
3574 if (strncasecmp (s
, "m", 1) == 0)
3576 else if ((strncasecmp (s
, "b ", 2) == 0)
3577 || (strncasecmp (s
, "b,", 2) == 0))
3579 else if (strncasecmp (s
, "e", 1) == 0)
3581 /* In strict mode, this is a match failure. */
3588 as_bad (_("Invalid Store Bytes Short Completer"));
3593 as_bad (_("Invalid Store Bytes Short Completer"));
3595 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
3598 /* Handle load cache hint completer. */
3601 if (!strncmp (s
, ",sl", 3))
3606 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
3608 /* Handle store cache hint completer. */
3611 if (!strncmp (s
, ",sl", 3))
3616 else if (!strncmp (s
, ",bc", 3))
3621 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
3623 /* Handle load and clear cache hint completer. */
3626 if (!strncmp (s
, ",co", 3))
3631 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
3633 /* Handle load ordering completer. */
3635 if (strncmp (s
, ",o", 2) != 0)
3640 /* Handle a branch gate completer. */
3642 if (strncasecmp (s
, ",gate", 5) != 0)
3647 /* Handle a branch link and push completer. */
3649 if (strncasecmp (s
, ",l,push", 7) != 0)
3654 /* Handle a branch link completer. */
3656 if (strncasecmp (s
, ",l", 2) != 0)
3661 /* Handle a branch pop completer. */
3663 if (strncasecmp (s
, ",pop", 4) != 0)
3668 /* Handle a local processor completer. */
3670 if (strncasecmp (s
, ",l", 2) != 0)
3675 /* Handle a PROBE read/write completer. */
3678 if (!strncasecmp (s
, ",w", 2))
3683 else if (!strncasecmp (s
, ",r", 2))
3689 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
3691 /* Handle MFCTL wide completer. */
3693 if (strncasecmp (s
, ",w", 2) != 0)
3698 /* Handle an RFI restore completer. */
3701 if (!strncasecmp (s
, ",r", 2))
3707 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
3709 /* Handle a system control completer. */
3711 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
3719 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
3721 /* Handle intermediate/final completer for DCOR. */
3724 if (!strncasecmp (s
, ",i", 2))
3730 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
3732 /* Handle zero/sign extension completer. */
3735 if (!strncasecmp (s
, ",z", 2))
3741 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
3743 /* Handle add completer. */
3746 if (!strncasecmp (s
, ",l", 2))
3751 else if (!strncasecmp (s
, ",tsv", 4))
3757 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
3759 /* Handle 64 bit carry for ADD. */
3762 if (!strncasecmp (s
, ",dc,tsv", 7) ||
3763 !strncasecmp (s
, ",tsv,dc", 7))
3768 else if (!strncasecmp (s
, ",dc", 3))
3776 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3778 /* Handle 32 bit carry for ADD. */
3781 if (!strncasecmp (s
, ",c,tsv", 6) ||
3782 !strncasecmp (s
, ",tsv,c", 6))
3787 else if (!strncasecmp (s
, ",c", 2))
3795 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3797 /* Handle trap on signed overflow. */
3800 if (!strncasecmp (s
, ",tsv", 4))
3806 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3808 /* Handle trap on condition and overflow. */
3811 if (!strncasecmp (s
, ",tc,tsv", 7) ||
3812 !strncasecmp (s
, ",tsv,tc", 7))
3817 else if (!strncasecmp (s
, ",tc", 3))
3825 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3827 /* Handle 64 bit borrow for SUB. */
3830 if (!strncasecmp (s
, ",db,tsv", 7) ||
3831 !strncasecmp (s
, ",tsv,db", 7))
3836 else if (!strncasecmp (s
, ",db", 3))
3844 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3846 /* Handle 32 bit borrow for SUB. */
3849 if (!strncasecmp (s
, ",b,tsv", 6) ||
3850 !strncasecmp (s
, ",tsv,b", 6))
3855 else if (!strncasecmp (s
, ",b", 2))
3863 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3865 /* Handle trap condition completer for UADDCM. */
3868 if (!strncasecmp (s
, ",tc", 3))
3874 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
3876 /* Handle signed/unsigned at 21. */
3880 if (strncasecmp (s
, ",s", 2) == 0)
3885 else if (strncasecmp (s
, ",u", 2) == 0)
3891 INSERT_FIELD_AND_CONTINUE (opcode
, sign
, 10);
3894 /* Handle left/right combination at 17:18. */
3904 as_bad (_("Invalid left/right combination completer"));
3907 INSERT_FIELD_AND_CONTINUE (opcode
, lr
, 13);
3910 as_bad (_("Invalid left/right combination completer"));
3913 /* Handle saturation at 24:25. */
3917 if (strncasecmp (s
, ",ss", 3) == 0)
3922 else if (strncasecmp (s
, ",us", 3) == 0)
3928 INSERT_FIELD_AND_CONTINUE (opcode
, sat
, 6);
3931 /* Handle permutation completer. */
3959 as_bad (_("Invalid permutation completer"));
3961 opcode
|= perm
<< permloc
[i
];
3966 as_bad (_("Invalid permutation completer"));
3974 /* Handle all conditions. */
3980 /* Handle FP compare conditions. */
3982 cond
= pa_parse_fp_cmp_cond (&s
);
3983 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
3985 /* Handle an add condition. */
3994 /* 64 bit conditions. */
4006 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
4010 if (strcmp (name
, "=") == 0)
4012 else if (strcmp (name
, "<") == 0)
4014 else if (strcmp (name
, "<=") == 0)
4016 else if (strcasecmp (name
, "nuv") == 0)
4018 else if (strcasecmp (name
, "znv") == 0)
4020 else if (strcasecmp (name
, "sv") == 0)
4022 else if (strcasecmp (name
, "od") == 0)
4024 else if (strcasecmp (name
, "tr") == 0)
4029 else if (strcmp (name
, "<>") == 0)
4034 else if (strcmp (name
, ">=") == 0)
4039 else if (strcmp (name
, ">") == 0)
4044 else if (strcasecmp (name
, "uv") == 0)
4049 else if (strcasecmp (name
, "vnz") == 0)
4054 else if (strcasecmp (name
, "nsv") == 0)
4059 else if (strcasecmp (name
, "ev") == 0)
4064 /* ",*" is a valid condition. */
4065 else if (*args
== 'a' || *name
)
4066 as_bad (_("Invalid Add Condition: %s"), name
);
4069 opcode
|= cmpltr
<< 13;
4070 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
4072 /* Handle non-negated add and branch condition. */
4074 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
);
4077 as_bad (_("Invalid Add and Branch Condition"));
4080 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
4082 /* Handle 64 bit wide-mode add and branch condition. */
4084 cmpltr
= pa_parse_addb_64_cmpltr (&s
);
4087 as_bad (_("Invalid Add and Branch Condition"));
4092 /* Negated condition requires an opcode change. */
4093 opcode
|= (cmpltr
& 8) << 24;
4095 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
4097 /* Handle a negated or non-negated add and branch
4101 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
);
4105 cmpltr
= pa_parse_neg_add_cmpltr (&s
);
4108 as_bad (_("Invalid Compare/Subtract Condition"));
4113 /* Negated condition requires an opcode change. */
4117 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
4119 /* Handle branch on bit conditions. */
4137 if (strncmp (s
, "<", 1) == 0)
4142 else if (strncmp (s
, ">=", 2) == 0)
4148 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
4150 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
4152 /* Handle a compare/subtract condition. */
4161 /* 64 bit conditions. */
4173 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
4177 if (strcmp (name
, "=") == 0)
4179 else if (strcmp (name
, "<") == 0)
4181 else if (strcmp (name
, "<=") == 0)
4183 else if (strcasecmp (name
, "<<") == 0)
4185 else if (strcasecmp (name
, "<<=") == 0)
4187 else if (strcasecmp (name
, "sv") == 0)
4189 else if (strcasecmp (name
, "od") == 0)
4191 else if (strcasecmp (name
, "tr") == 0)
4196 else if (strcmp (name
, "<>") == 0)
4201 else if (strcmp (name
, ">=") == 0)
4206 else if (strcmp (name
, ">") == 0)
4211 else if (strcasecmp (name
, ">>=") == 0)
4216 else if (strcasecmp (name
, ">>") == 0)
4221 else if (strcasecmp (name
, "nsv") == 0)
4226 else if (strcasecmp (name
, "ev") == 0)
4231 /* ",*" is a valid condition. */
4232 else if (*args
!= 'S' || *name
)
4233 as_bad (_("Invalid Compare/Subtract Condition: %s"),
4237 opcode
|= cmpltr
<< 13;
4238 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
4240 /* Handle a non-negated compare condition. */
4242 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
);
4245 as_bad (_("Invalid Compare/Subtract Condition"));
4248 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
4250 /* Handle a 32 bit compare and branch condition. */
4253 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
);
4257 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
);
4260 as_bad (_("Invalid Compare and Branch Condition"));
4265 /* Negated condition requires an opcode change. */
4270 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
4272 /* Handle a 64 bit compare and branch condition. */
4274 cmpltr
= pa_parse_cmpb_64_cmpltr (&s
);
4277 /* Negated condition requires an opcode change. */
4278 opcode
|= (cmpltr
& 8) << 26;
4281 /* Not a 64 bit cond. Give 32 bit a chance. */
4284 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
4286 /* Handle a 64 bit cmpib condition. */
4288 cmpltr
= pa_parse_cmpib_64_cmpltr (&s
);
4290 /* Not a 64 bit cond. Give 32 bit a chance. */
4293 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
4295 /* Handle a logical instruction condition. */
4304 /* 64 bit conditions. */
4316 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
4321 if (strcmp (name
, "=") == 0)
4323 else if (strcmp (name
, "<") == 0)
4325 else if (strcmp (name
, "<=") == 0)
4327 else if (strcasecmp (name
, "od") == 0)
4329 else if (strcasecmp (name
, "tr") == 0)
4334 else if (strcmp (name
, "<>") == 0)
4339 else if (strcmp (name
, ">=") == 0)
4344 else if (strcmp (name
, ">") == 0)
4349 else if (strcasecmp (name
, "ev") == 0)
4354 /* ",*" is a valid condition. */
4355 else if (*args
!= 'L' || *name
)
4356 as_bad (_("Invalid Logical Instruction Condition."));
4359 opcode
|= cmpltr
<< 13;
4360 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
4362 /* Handle a shift/extract/deposit condition. */
4371 /* 64 bit conditions. */
4383 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
4387 if (strcmp (name
, "=") == 0)
4389 else if (strcmp (name
, "<") == 0)
4391 else if (strcasecmp (name
, "od") == 0)
4393 else if (strcasecmp (name
, "tr") == 0)
4395 else if (strcmp (name
, "<>") == 0)
4397 else if (strcmp (name
, ">=") == 0)
4399 else if (strcasecmp (name
, "ev") == 0)
4401 /* Handle movb,n. Put things back the way they were.
4402 This includes moving s back to where it started. */
4403 else if (strcasecmp (name
, "n") == 0 && *args
== 'y')
4409 /* ",*" is a valid condition. */
4410 else if (*args
!= 'X' || *name
)
4411 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
4414 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
4416 /* Handle a unit instruction condition. */
4425 /* 64 bit conditions. */
4436 if (strncasecmp (s
, "sbz", 3) == 0)
4441 else if (strncasecmp (s
, "shz", 3) == 0)
4446 else if (strncasecmp (s
, "sdc", 3) == 0)
4451 else if (strncasecmp (s
, "sbc", 3) == 0)
4456 else if (strncasecmp (s
, "shc", 3) == 0)
4461 else if (strncasecmp (s
, "tr", 2) == 0)
4467 else if (strncasecmp (s
, "nbz", 3) == 0)
4473 else if (strncasecmp (s
, "nhz", 3) == 0)
4479 else if (strncasecmp (s
, "ndc", 3) == 0)
4485 else if (strncasecmp (s
, "nbc", 3) == 0)
4491 else if (strncasecmp (s
, "nhc", 3) == 0)
4497 else if (strncasecmp (s
, "swz", 3) == 0)
4503 else if (strncasecmp (s
, "swc", 3) == 0)
4509 else if (strncasecmp (s
, "nwz", 3) == 0)
4515 else if (strncasecmp (s
, "nwc", 3) == 0)
4521 /* ",*" is a valid condition. */
4522 else if (*args
!= 'U' || (*s
!= ' ' && *s
!= '\t'))
4523 as_bad (_("Invalid Unit Instruction Condition."));
4525 opcode
|= cmpltr
<< 13;
4526 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
4534 /* Handle a nullification completer for branch instructions. */
4536 nullif
= pa_parse_nullif (&s
);
4537 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
4539 /* Handle a nullification completer for copr and spop insns. */
4541 nullif
= pa_parse_nullif (&s
);
4542 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
4544 /* Handle ,%r2 completer for new syntax branches. */
4546 if (*s
== ',' && strncasecmp (s
+ 1, "%r2", 3) == 0)
4548 else if (*s
== ',' && strncasecmp (s
+ 1, "%rp", 3) == 0)
4554 /* Handle 3 bit entry into the fp compare array. Valid values
4555 are 0..6 inclusive. */
4559 if (the_insn
.exp
.X_op
== O_constant
)
4561 num
= evaluate_absolute (&the_insn
);
4562 CHECK_FIELD (num
, 6, 0, 0);
4564 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
4569 /* Handle 3 bit entry into the fp compare array. Valid values
4570 are 0..6 inclusive. */
4573 if (the_insn
.exp
.X_op
== O_constant
)
4576 num
= evaluate_absolute (&the_insn
);
4577 CHECK_FIELD (num
, 6, 0, 0);
4578 num
= (num
+ 1) ^ 1;
4579 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
4584 /* Handle graphics test completers for ftest */
4587 num
= pa_parse_ftest_gfx_completer (&s
);
4588 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
4591 /* Handle a 11 bit immediate at 31. */
4593 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4596 if (the_insn
.exp
.X_op
== O_constant
)
4598 num
= evaluate_absolute (&the_insn
);
4599 CHECK_FIELD (num
, 1023, -1024, 0);
4600 num
= low_sign_unext (num
, 11);
4601 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
4605 if (is_DP_relative (the_insn
.exp
))
4606 the_insn
.reloc
= R_HPPA_GOTOFF
;
4607 else if (is_PC_relative (the_insn
.exp
))
4608 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
4610 else if (is_tls_gdidx (the_insn
.exp
))
4611 the_insn
.reloc
= R_PARISC_TLS_GD21L
;
4612 else if (is_tls_ldidx (the_insn
.exp
))
4613 the_insn
.reloc
= R_PARISC_TLS_LDM21L
;
4614 else if (is_tls_dtpoff (the_insn
.exp
))
4615 the_insn
.reloc
= R_PARISC_TLS_LDO21L
;
4616 else if (is_tls_ieoff (the_insn
.exp
))
4617 the_insn
.reloc
= R_PARISC_TLS_IE21L
;
4618 else if (is_tls_leoff (the_insn
.exp
))
4619 the_insn
.reloc
= R_PARISC_TLS_LE21L
;
4622 the_insn
.reloc
= R_HPPA
;
4623 the_insn
.format
= 11;
4627 /* Handle a 14 bit immediate at 31. */
4629 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4632 if (the_insn
.exp
.X_op
== O_constant
)
4636 /* XXX the completer stored away tidbits of information
4637 for us to extract. We need a cleaner way to do this.
4638 Now that we have lots of letters again, it would be
4639 good to rethink this. */
4642 num
= evaluate_absolute (&the_insn
);
4643 if (mb
!= (num
< 0))
4645 CHECK_FIELD (num
, 8191, -8192, 0);
4646 num
= low_sign_unext (num
, 14);
4647 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
4651 /* Handle a 14 bit immediate at 31. */
4653 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4656 if (the_insn
.exp
.X_op
== O_constant
)
4662 num
= evaluate_absolute (&the_insn
);
4663 if (mb
== (num
< 0))
4667 CHECK_FIELD (num
, 8191, -8192, 0);
4668 num
= low_sign_unext (num
, 14);
4669 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
4673 /* Handle a 16 bit immediate at 31. */
4675 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4678 if (the_insn
.exp
.X_op
== O_constant
)
4684 num
= evaluate_absolute (&the_insn
);
4685 if (mb
!= (num
< 0))
4687 CHECK_FIELD (num
, 32767, -32768, 0);
4688 num
= re_assemble_16 (num
);
4689 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
4693 /* Handle a 16 bit immediate at 31. */
4695 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4698 if (the_insn
.exp
.X_op
== O_constant
)
4704 num
= evaluate_absolute (&the_insn
);
4705 if (mb
== (num
< 0))
4709 CHECK_FIELD (num
, 32767, -32768, 0);
4710 num
= re_assemble_16 (num
);
4711 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
4715 /* Handle 14 bit immediate, shifted left three times. */
4717 if (bfd_get_mach (stdoutput
) != pa20
)
4719 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4722 if (the_insn
.exp
.X_op
== O_constant
)
4724 num
= evaluate_absolute (&the_insn
);
4727 CHECK_FIELD (num
, 8191, -8192, 0);
4732 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 4);
4736 if (is_DP_relative (the_insn
.exp
))
4737 the_insn
.reloc
= R_HPPA_GOTOFF
;
4738 else if (is_PC_relative (the_insn
.exp
))
4739 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
4741 else if (is_tls_gdidx (the_insn
.exp
))
4742 the_insn
.reloc
= R_PARISC_TLS_GD21L
;
4743 else if (is_tls_ldidx (the_insn
.exp
))
4744 the_insn
.reloc
= R_PARISC_TLS_LDM21L
;
4745 else if (is_tls_dtpoff (the_insn
.exp
))
4746 the_insn
.reloc
= R_PARISC_TLS_LDO21L
;
4747 else if (is_tls_ieoff (the_insn
.exp
))
4748 the_insn
.reloc
= R_PARISC_TLS_IE21L
;
4749 else if (is_tls_leoff (the_insn
.exp
))
4750 the_insn
.reloc
= R_PARISC_TLS_LE21L
;
4753 the_insn
.reloc
= R_HPPA
;
4754 the_insn
.format
= 14;
4759 /* Handle 14 bit immediate, shifted left twice. */
4761 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4764 if (the_insn
.exp
.X_op
== O_constant
)
4766 num
= evaluate_absolute (&the_insn
);
4769 CHECK_FIELD (num
, 8191, -8192, 0);
4774 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
4778 if (is_DP_relative (the_insn
.exp
))
4779 the_insn
.reloc
= R_HPPA_GOTOFF
;
4780 else if (is_PC_relative (the_insn
.exp
))
4781 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
4783 else if (is_tls_gdidx (the_insn
.exp
))
4784 the_insn
.reloc
= R_PARISC_TLS_GD21L
;
4785 else if (is_tls_ldidx (the_insn
.exp
))
4786 the_insn
.reloc
= R_PARISC_TLS_LDM21L
;
4787 else if (is_tls_dtpoff (the_insn
.exp
))
4788 the_insn
.reloc
= R_PARISC_TLS_LDO21L
;
4789 else if (is_tls_ieoff (the_insn
.exp
))
4790 the_insn
.reloc
= R_PARISC_TLS_IE21L
;
4791 else if (is_tls_leoff (the_insn
.exp
))
4792 the_insn
.reloc
= R_PARISC_TLS_LE21L
;
4795 the_insn
.reloc
= R_HPPA
;
4796 the_insn
.format
= 14;
4800 /* Handle a 14 bit immediate at 31. */
4802 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4805 if (the_insn
.exp
.X_op
== O_constant
)
4807 num
= evaluate_absolute (&the_insn
);
4808 CHECK_FIELD (num
, 8191, -8192, 0);
4809 num
= low_sign_unext (num
, 14);
4810 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
4814 if (is_DP_relative (the_insn
.exp
))
4815 the_insn
.reloc
= R_HPPA_GOTOFF
;
4816 else if (is_PC_relative (the_insn
.exp
))
4817 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
4819 else if (is_tls_gdidx (the_insn
.exp
))
4820 the_insn
.reloc
= R_PARISC_TLS_GD21L
;
4821 else if (is_tls_ldidx (the_insn
.exp
))
4822 the_insn
.reloc
= R_PARISC_TLS_LDM21L
;
4823 else if (is_tls_dtpoff (the_insn
.exp
))
4824 the_insn
.reloc
= R_PARISC_TLS_LDO21L
;
4825 else if (is_tls_ieoff (the_insn
.exp
))
4826 the_insn
.reloc
= R_PARISC_TLS_IE21L
;
4827 else if (is_tls_leoff (the_insn
.exp
))
4828 the_insn
.reloc
= R_PARISC_TLS_LE21L
;
4831 the_insn
.reloc
= R_HPPA
;
4832 the_insn
.format
= 14;
4836 /* Handle a 21 bit immediate at 31. */
4838 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4841 if (the_insn
.exp
.X_op
== O_constant
)
4843 num
= evaluate_absolute (&the_insn
);
4844 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
4845 opcode
|= re_assemble_21 (num
);
4850 if (is_DP_relative (the_insn
.exp
))
4851 the_insn
.reloc
= R_HPPA_GOTOFF
;
4852 else if (is_PC_relative (the_insn
.exp
))
4853 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
4855 else if (is_tls_gdidx (the_insn
.exp
))
4856 the_insn
.reloc
= R_PARISC_TLS_GD21L
;
4857 else if (is_tls_ldidx (the_insn
.exp
))
4858 the_insn
.reloc
= R_PARISC_TLS_LDM21L
;
4859 else if (is_tls_dtpoff (the_insn
.exp
))
4860 the_insn
.reloc
= R_PARISC_TLS_LDO21L
;
4861 else if (is_tls_ieoff (the_insn
.exp
))
4862 the_insn
.reloc
= R_PARISC_TLS_IE21L
;
4863 else if (is_tls_leoff (the_insn
.exp
))
4864 the_insn
.reloc
= R_PARISC_TLS_LE21L
;
4867 the_insn
.reloc
= R_HPPA
;
4868 the_insn
.format
= 21;
4872 /* Handle a 16 bit immediate at 31 (PA 2.0 wide mode only). */
4874 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4877 if (the_insn
.exp
.X_op
== O_constant
)
4879 num
= evaluate_absolute (&the_insn
);
4880 CHECK_FIELD (num
, 32767, -32768, 0);
4881 opcode
|= re_assemble_16 (num
);
4886 /* ??? Is this valid for wide mode? */
4887 if (is_DP_relative (the_insn
.exp
))
4888 the_insn
.reloc
= R_HPPA_GOTOFF
;
4889 else if (is_PC_relative (the_insn
.exp
))
4890 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
4892 else if (is_tls_gdidx (the_insn
.exp
))
4893 the_insn
.reloc
= R_PARISC_TLS_GD21L
;
4894 else if (is_tls_ldidx (the_insn
.exp
))
4895 the_insn
.reloc
= R_PARISC_TLS_LDM21L
;
4896 else if (is_tls_dtpoff (the_insn
.exp
))
4897 the_insn
.reloc
= R_PARISC_TLS_LDO21L
;
4898 else if (is_tls_ieoff (the_insn
.exp
))
4899 the_insn
.reloc
= R_PARISC_TLS_IE21L
;
4900 else if (is_tls_leoff (the_insn
.exp
))
4901 the_insn
.reloc
= R_PARISC_TLS_LE21L
;
4904 the_insn
.reloc
= R_HPPA
;
4905 the_insn
.format
= 14;
4909 /* Handle a word-aligned 16-bit imm. at 31 (PA2.0 wide). */
4911 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4914 if (the_insn
.exp
.X_op
== O_constant
)
4916 num
= evaluate_absolute (&the_insn
);
4917 CHECK_FIELD (num
, 32767, -32768, 0);
4918 CHECK_ALIGN (num
, 4, 0);
4919 opcode
|= re_assemble_16 (num
);
4924 /* ??? Is this valid for wide mode? */
4925 if (is_DP_relative (the_insn
.exp
))
4926 the_insn
.reloc
= R_HPPA_GOTOFF
;
4927 else if (is_PC_relative (the_insn
.exp
))
4928 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
4930 else if (is_tls_gdidx (the_insn
.exp
))
4931 the_insn
.reloc
= R_PARISC_TLS_GD21L
;
4932 else if (is_tls_ldidx (the_insn
.exp
))
4933 the_insn
.reloc
= R_PARISC_TLS_LDM21L
;
4934 else if (is_tls_dtpoff (the_insn
.exp
))
4935 the_insn
.reloc
= R_PARISC_TLS_LDO21L
;
4936 else if (is_tls_ieoff (the_insn
.exp
))
4937 the_insn
.reloc
= R_PARISC_TLS_IE21L
;
4938 else if (is_tls_leoff (the_insn
.exp
))
4939 the_insn
.reloc
= R_PARISC_TLS_LE21L
;
4942 the_insn
.reloc
= R_HPPA
;
4943 the_insn
.format
= 14;
4947 /* Handle a dword-aligned 16-bit imm. at 31 (PA2.0 wide). */
4949 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4952 if (the_insn
.exp
.X_op
== O_constant
)
4954 num
= evaluate_absolute (&the_insn
);
4955 CHECK_FIELD (num
, 32767, -32768, 0);
4956 CHECK_ALIGN (num
, 8, 0);
4957 opcode
|= re_assemble_16 (num
);
4962 /* ??? Is this valid for wide mode? */
4963 if (is_DP_relative (the_insn
.exp
))
4964 the_insn
.reloc
= R_HPPA_GOTOFF
;
4965 else if (is_PC_relative (the_insn
.exp
))
4966 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
4968 else if (is_tls_gdidx (the_insn
.exp
))
4969 the_insn
.reloc
= R_PARISC_TLS_GD21L
;
4970 else if (is_tls_ldidx (the_insn
.exp
))
4971 the_insn
.reloc
= R_PARISC_TLS_LDM21L
;
4972 else if (is_tls_dtpoff (the_insn
.exp
))
4973 the_insn
.reloc
= R_PARISC_TLS_LDO21L
;
4974 else if (is_tls_ieoff (the_insn
.exp
))
4975 the_insn
.reloc
= R_PARISC_TLS_IE21L
;
4976 else if (is_tls_leoff (the_insn
.exp
))
4977 the_insn
.reloc
= R_PARISC_TLS_LE21L
;
4980 the_insn
.reloc
= R_HPPA
;
4981 the_insn
.format
= 14;
4985 /* Handle a 12 bit branch displacement. */
4987 the_insn
.field_selector
= pa_chk_field_selector (&s
);
4991 if (!the_insn
.exp
.X_add_symbol
4992 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
4995 num
= evaluate_absolute (&the_insn
);
4998 as_bad (_("Branch to unaligned address"));
5001 if (the_insn
.exp
.X_add_symbol
)
5003 CHECK_FIELD (num
, 8191, -8192, 0);
5004 opcode
|= re_assemble_12 (num
>> 2);
5009 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
5010 the_insn
.format
= 12;
5011 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
5012 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
5017 /* Handle a 17 bit branch displacement. */
5019 the_insn
.field_selector
= pa_chk_field_selector (&s
);
5023 if (!the_insn
.exp
.X_add_symbol
5024 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
5027 num
= evaluate_absolute (&the_insn
);
5030 as_bad (_("Branch to unaligned address"));
5033 if (the_insn
.exp
.X_add_symbol
)
5035 CHECK_FIELD (num
, 262143, -262144, 0);
5036 opcode
|= re_assemble_17 (num
>> 2);
5041 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
5042 the_insn
.format
= 17;
5043 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
5044 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
5048 /* Handle a 22 bit branch displacement. */
5050 the_insn
.field_selector
= pa_chk_field_selector (&s
);
5054 if (!the_insn
.exp
.X_add_symbol
5055 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
5058 num
= evaluate_absolute (&the_insn
);
5061 as_bad (_("Branch to unaligned address"));
5064 if (the_insn
.exp
.X_add_symbol
)
5066 CHECK_FIELD (num
, 8388607, -8388608, 0);
5067 opcode
|= re_assemble_22 (num
>> 2);
5071 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
5072 the_insn
.format
= 22;
5073 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
5074 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
5078 /* Handle an absolute 17 bit branch target. */
5080 the_insn
.field_selector
= pa_chk_field_selector (&s
);
5084 if (!the_insn
.exp
.X_add_symbol
5085 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
5088 num
= evaluate_absolute (&the_insn
);
5091 as_bad (_("Branch to unaligned address"));
5094 if (the_insn
.exp
.X_add_symbol
)
5096 CHECK_FIELD (num
, 262143, -262144, 0);
5097 opcode
|= re_assemble_17 (num
>> 2);
5102 the_insn
.reloc
= R_HPPA_ABS_CALL
;
5103 the_insn
.format
= 17;
5104 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
5105 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
5109 /* Handle '%r1' implicit operand of addil instruction. */
5111 if (*s
== ',' && *(s
+ 1) == '%' && *(s
+ 3) == '1'
5112 && (*(s
+ 2) == 'r' || *(s
+ 2) == 'R'))
5120 /* Handle '%sr0,%r31' implicit operand of be,l instruction. */
5122 if (strncasecmp (s
, "%sr0,%r31", 9) != 0)
5127 /* Handle immediate value of 0 for ordered load/store instructions. */
5134 /* Handle a 2 bit shift count at 25. */
5136 num
= pa_get_absolute_expression (&the_insn
, &s
);
5137 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5140 CHECK_FIELD (num
, 3, 1, strict
);
5141 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
5143 /* Handle a 4 bit shift count at 25. */
5145 num
= pa_get_absolute_expression (&the_insn
, &s
);
5146 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5149 CHECK_FIELD (num
, 15, 0, strict
);
5150 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
5152 /* Handle a 5 bit shift count at 26. */
5154 num
= pa_get_absolute_expression (&the_insn
, &s
);
5155 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5158 CHECK_FIELD (num
, 31, 0, strict
);
5159 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
5161 /* Handle a 6 bit shift count at 20,22:26. */
5163 num
= pa_get_absolute_expression (&the_insn
, &s
);
5164 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5167 CHECK_FIELD (num
, 63, 0, strict
);
5169 opcode
|= (num
& 0x20) << 6;
5170 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
5172 /* Handle a 6 bit field length at 23,27:31. */
5175 num
= pa_get_absolute_expression (&the_insn
, &s
);
5176 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5179 CHECK_FIELD (num
, 64, 1, strict
);
5181 opcode
|= (num
& 0x20) << 3;
5182 num
= 31 - (num
& 0x1f);
5183 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
5185 /* Handle a 6 bit field length at 19,27:31. */
5187 num
= pa_get_absolute_expression (&the_insn
, &s
);
5188 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5191 CHECK_FIELD (num
, 64, 1, strict
);
5193 opcode
|= (num
& 0x20) << 7;
5194 num
= 31 - (num
& 0x1f);
5195 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
5197 /* Handle a 5 bit bit position at 26. */
5199 num
= pa_get_absolute_expression (&the_insn
, &s
);
5200 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5203 CHECK_FIELD (num
, 31, 0, strict
);
5204 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
5206 /* Handle a 6 bit bit position at 20,22:26. */
5208 num
= pa_get_absolute_expression (&the_insn
, &s
);
5209 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5212 CHECK_FIELD (num
, 63, 0, strict
);
5213 opcode
|= (num
& 0x20) << 6;
5214 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
5216 /* Handle a 5 bit immediate at 10 with 'd' as the complement
5217 of the high bit of the immediate. */
5219 num
= pa_get_absolute_expression (&the_insn
, &s
);
5220 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5223 CHECK_FIELD (num
, 63, 0, strict
);
5227 opcode
|= (1 << 13);
5228 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 21);
5230 /* Handle a 5 bit immediate at 10. */
5232 num
= pa_get_absolute_expression (&the_insn
, &s
);
5233 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5236 CHECK_FIELD (num
, 31, 0, strict
);
5237 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
5239 /* Handle a 9 bit immediate at 28. */
5241 num
= pa_get_absolute_expression (&the_insn
, &s
);
5242 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5245 CHECK_FIELD (num
, 511, 1, strict
);
5246 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
5248 /* Handle a 13 bit immediate at 18. */
5250 num
= pa_get_absolute_expression (&the_insn
, &s
);
5251 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5254 CHECK_FIELD (num
, 8191, 0, strict
);
5255 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
5257 /* Handle a 26 bit immediate at 31. */
5259 num
= pa_get_absolute_expression (&the_insn
, &s
);
5260 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5263 CHECK_FIELD (num
, 67108863, 0, strict
);
5264 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
5266 /* Handle a 3 bit SFU identifier at 25. */
5269 as_bad (_("Invalid SFU identifier"));
5270 num
= pa_get_absolute_expression (&the_insn
, &s
);
5271 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5274 CHECK_FIELD (num
, 7, 0, strict
);
5275 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
5277 /* Handle a 20 bit SOP field for spop0. */
5279 num
= pa_get_absolute_expression (&the_insn
, &s
);
5280 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5283 CHECK_FIELD (num
, 1048575, 0, strict
);
5284 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
5285 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
5287 /* Handle a 15bit SOP field for spop1. */
5289 num
= pa_get_absolute_expression (&the_insn
, &s
);
5290 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5293 CHECK_FIELD (num
, 32767, 0, strict
);
5294 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
5296 /* Handle a 10bit SOP field for spop3. */
5298 num
= pa_get_absolute_expression (&the_insn
, &s
);
5299 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5302 CHECK_FIELD (num
, 1023, 0, strict
);
5303 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
5304 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
5306 /* Handle a 15 bit SOP field for spop2. */
5308 num
= pa_get_absolute_expression (&the_insn
, &s
);
5309 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5312 CHECK_FIELD (num
, 32767, 0, strict
);
5313 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
5314 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
5316 /* Handle a 3-bit co-processor ID field. */
5319 as_bad (_("Invalid COPR identifier"));
5320 num
= pa_get_absolute_expression (&the_insn
, &s
);
5321 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5324 CHECK_FIELD (num
, 7, 0, strict
);
5325 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
5327 /* Handle a 22bit SOP field for copr. */
5329 num
= pa_get_absolute_expression (&the_insn
, &s
);
5330 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
5333 CHECK_FIELD (num
, 4194303, 0, strict
);
5334 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
5335 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
5337 /* Handle a source FP operand format completer. */
5339 if (*s
== ',' && *(s
+1) == 't')
5346 flag
= pa_parse_fp_cnv_format (&s
);
5347 the_insn
.fpof1
= flag
;
5348 if (flag
== W
|| flag
== UW
)
5350 if (flag
== DW
|| flag
== UDW
)
5352 if (flag
== QW
|| flag
== UQW
)
5354 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
5356 /* Handle a destination FP operand format completer. */
5358 /* pa_parse_format needs the ',' prefix. */
5360 flag
= pa_parse_fp_cnv_format (&s
);
5361 the_insn
.fpof2
= flag
;
5362 if (flag
== W
|| flag
== UW
)
5364 if (flag
== DW
|| flag
== UDW
)
5366 if (flag
== QW
|| flag
== UQW
)
5368 opcode
|= flag
<< 13;
5369 if (the_insn
.fpof1
== SGL
5370 || the_insn
.fpof1
== DBL
5371 || the_insn
.fpof1
== QUAD
)
5373 if (the_insn
.fpof2
== SGL
5374 || the_insn
.fpof2
== DBL
5375 || the_insn
.fpof2
== QUAD
)
5377 else if (the_insn
.fpof2
== W
5378 || the_insn
.fpof2
== DW
5379 || the_insn
.fpof2
== QW
)
5381 else if (the_insn
.fpof2
== UW
5382 || the_insn
.fpof2
== UDW
5383 || the_insn
.fpof2
== UQW
)
5388 else if (the_insn
.fpof1
== W
5389 || the_insn
.fpof1
== DW
5390 || the_insn
.fpof1
== QW
)
5392 if (the_insn
.fpof2
== SGL
5393 || the_insn
.fpof2
== DBL
5394 || the_insn
.fpof2
== QUAD
)
5399 else if (the_insn
.fpof1
== UW
5400 || the_insn
.fpof1
== UDW
5401 || the_insn
.fpof1
== UQW
)
5403 if (the_insn
.fpof2
== SGL
5404 || the_insn
.fpof2
== DBL
5405 || the_insn
.fpof2
== QUAD
)
5410 flag
|= the_insn
.trunc
;
5411 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 15);
5413 /* Handle a source FP operand format completer. */
5415 flag
= pa_parse_fp_format (&s
);
5416 the_insn
.fpof1
= flag
;
5417 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
5419 /* Handle a destination FP operand format completer. */
5421 /* pa_parse_format needs the ',' prefix. */
5423 flag
= pa_parse_fp_format (&s
);
5424 the_insn
.fpof2
= flag
;
5425 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
5427 /* Handle a source FP operand format completer at 20. */
5429 flag
= pa_parse_fp_format (&s
);
5430 the_insn
.fpof1
= flag
;
5431 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
5433 /* Handle a floating point operand format at 26.
5434 Only allows single and double precision. */
5436 flag
= pa_parse_fp_format (&s
);
5442 the_insn
.fpof1
= flag
;
5448 as_bad (_("Invalid Floating Point Operand Format."));
5452 /* Handle all floating point registers. */
5456 /* Float target register. */
5458 if (!pa_parse_number (&s
, 3))
5460 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5461 CHECK_FIELD (num
, 31, 0, 0);
5462 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
5464 /* Float target register with L/R selection. */
5467 if (!pa_parse_number (&s
, 1))
5469 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5470 CHECK_FIELD (num
, 31, 0, 0);
5473 /* 0x30 opcodes are FP arithmetic operation opcodes
5474 and need to be turned into 0x38 opcodes. This
5475 is not necessary for loads/stores. */
5476 if (need_pa11_opcode ()
5477 && ((opcode
& 0xfc000000) == 0x30000000))
5480 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 6 : 0);
5484 /* Float operand 1. */
5487 if (!pa_parse_number (&s
, 1))
5489 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5490 CHECK_FIELD (num
, 31, 0, 0);
5491 opcode
|= num
<< 21;
5492 if (need_pa11_opcode ())
5494 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 7 : 0);
5500 /* Float operand 1 with L/R selection. */
5504 if (!pa_parse_number (&s
, 1))
5506 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5507 CHECK_FIELD (num
, 31, 0, 0);
5508 opcode
|= num
<< 21;
5509 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 7 : 0);
5513 /* Float operand 2. */
5516 if (!pa_parse_number (&s
, 1))
5518 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5519 CHECK_FIELD (num
, 31, 0, 0);
5520 opcode
|= num
<< 16;
5521 if (need_pa11_opcode ())
5523 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 12 : 0);
5529 /* Float operand 2 with L/R selection. */
5532 if (!pa_parse_number (&s
, 1))
5534 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5535 CHECK_FIELD (num
, 31, 0, 0);
5536 opcode
|= num
<< 16;
5537 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 12 : 0);
5541 /* Float operand 3 for fmpyfadd, fmpynfadd. */
5544 if (!pa_parse_number (&s
, 1))
5546 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5547 CHECK_FIELD (num
, 31, 0, 0);
5548 opcode
|= (num
& 0x1c) << 11;
5549 opcode
|= (num
& 0x03) << 9;
5550 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 8 : 0);
5554 /* Float mult operand 1 for fmpyadd, fmpysub */
5557 if (!pa_parse_number (&s
, 1))
5559 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5560 CHECK_FIELD (num
, 31, 0, 0);
5561 if (the_insn
.fpof1
== SGL
)
5565 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
5569 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
5571 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
5574 /* Float mult operand 2 for fmpyadd, fmpysub */
5577 if (!pa_parse_number (&s
, 1))
5579 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5580 CHECK_FIELD (num
, 31, 0, 0);
5581 if (the_insn
.fpof1
== SGL
)
5585 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
5589 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
5591 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
5594 /* Float mult target for fmpyadd, fmpysub */
5597 if (!pa_parse_number (&s
, 1))
5599 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5600 CHECK_FIELD (num
, 31, 0, 0);
5601 if (the_insn
.fpof1
== SGL
)
5605 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
5609 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
5611 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
5614 /* Float add operand 1 for fmpyadd, fmpysub */
5617 if (!pa_parse_number (&s
, 1))
5619 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5620 CHECK_FIELD (num
, 31, 0, 0);
5621 if (the_insn
.fpof1
== SGL
)
5625 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
5629 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
5631 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
5634 /* Float add target for fmpyadd, fmpysub */
5637 if (!pa_parse_number (&s
, 1))
5639 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5640 CHECK_FIELD (num
, 31, 0, 0);
5641 if (the_insn
.fpof1
== SGL
)
5645 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
5649 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
5651 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
5654 /* Handle L/R register halves like 'x'. */
5658 if (!pa_parse_number (&s
, 1))
5660 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5661 CHECK_FIELD (num
, 31, 0, 0);
5662 opcode
|= num
<< 16;
5663 if (need_pa11_opcode ())
5665 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 1 : 0);
5670 /* Float target register (PA 2.0 wide). */
5672 if (!pa_parse_number (&s
, 3))
5674 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
5675 CHECK_FIELD (num
, 31, 0, 0);
5676 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
5689 /* If this instruction is specific to a particular architecture,
5690 then set a new architecture. This automatic promotion crud is
5691 for compatibility with HP's old assemblers only. */
5693 && bfd_get_mach (stdoutput
) < insn
->arch
5694 && !bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
5696 as_warn (_("could not update architecture and machine"));
5701 /* Check if the args matched. */
5704 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
5705 && !strcmp (insn
->name
, insn
[1].name
))
5713 as_bad (_("Invalid operands %s"), error_message
);
5720 the_insn
.opcode
= opcode
;
5723 /* Assemble a single instruction storing it into a frag. */
5726 md_assemble (char *str
)
5730 /* The had better be something to assemble. */
5733 /* If we are within a procedure definition, make sure we've
5734 defined a label for the procedure; handle case where the
5735 label was defined after the .PROC directive.
5737 Note there's not need to diddle with the segment or fragment
5738 for the label symbol in this case. We have already switched
5739 into the new $CODE$ subspace at this point. */
5740 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
5742 label_symbol_struct
*label_symbol
= pa_get_label ();
5746 if (label_symbol
->lss_label
)
5748 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5749 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
5752 /* Also handle allocation of a fixup to hold the unwind
5753 information when the label appears after the proc/procend. */
5754 if (within_entry_exit
)
5759 where
= frag_more (0);
5760 u
= UNWIND_LOW32 (&last_call_info
->ci_unwind
.descriptor
);
5761 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5762 NULL
, (offsetT
) 0, NULL
,
5763 0, R_HPPA_ENTRY
, e_fsel
, 0, 0, u
);
5768 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5771 as_bad (_("Missing function name for .PROC"));
5774 /* Assemble the instruction. Results are saved into "the_insn". */
5777 /* Get somewhere to put the assembled instruction. */
5780 /* Output the opcode. */
5781 md_number_to_chars (to
, the_insn
.opcode
, 4);
5783 /* If necessary output more stuff. */
5784 if (the_insn
.reloc
!= R_HPPA_NONE
)
5785 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
5786 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
5787 the_insn
.reloc
, the_insn
.field_selector
,
5788 the_insn
.format
, the_insn
.arg_reloc
, 0);
5791 dwarf2_emit_insn (4);
5796 /* Handle an alignment directive. Special so that we can update the
5797 alignment of the subspace if necessary. */
5799 pa_align (int bytes
)
5801 /* We must have a valid space and subspace. */
5802 pa_check_current_space_and_subspace ();
5804 /* Let the generic gas code do most of the work. */
5805 s_align_bytes (bytes
);
5807 /* If bytes is a power of 2, then update the current subspace's
5808 alignment if necessary. */
5809 if (exact_log2 (bytes
) != -1)
5810 record_alignment (current_subspace
->ssd_seg
, exact_log2 (bytes
));
5814 /* Handle a .BLOCK type pseudo-op. */
5817 pa_block (int z ATTRIBUTE_UNUSED
)
5819 unsigned int temp_size
;
5822 /* We must have a valid space and subspace. */
5823 pa_check_current_space_and_subspace ();
5826 temp_size
= get_absolute_expression ();
5828 if (temp_size
> 0x3FFFFFFF)
5830 as_bad (_("Argument to .BLOCK/.BLOCKZ must be between 0 and 0x3fffffff"));
5835 /* Always fill with zeros, that's what the HP assembler does. */
5836 char *p
= frag_var (rs_fill
, 1, 1, 0, NULL
, temp_size
, NULL
);
5840 pa_undefine_label ();
5841 demand_empty_rest_of_line ();
5844 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
5847 pa_brtab (int begin ATTRIBUTE_UNUSED
)
5851 /* The BRTAB relocations are only available in SOM (to denote
5852 the beginning and end of branch tables). */
5853 char *where
= frag_more (0);
5855 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5856 NULL
, (offsetT
) 0, NULL
,
5857 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
5861 demand_empty_rest_of_line ();
5864 /* Handle a .begin_try and .end_try pseudo-op. */
5867 pa_try (int begin ATTRIBUTE_UNUSED
)
5871 char *where
= frag_more (0);
5876 /* The TRY relocations are only available in SOM (to denote
5877 the beginning and end of exception handling regions). */
5879 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5880 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
5881 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
5885 demand_empty_rest_of_line ();
5888 /* Do the dirty work of building a call descriptor which describes
5889 where the caller placed arguments to a function call. */
5892 pa_call_args (struct call_desc
*call_desc
)
5895 unsigned int temp
, arg_reloc
;
5897 while (!is_end_of_statement ())
5899 name
= input_line_pointer
;
5900 c
= get_symbol_end ();
5901 /* Process a source argument. */
5902 if ((strncasecmp (name
, "argw", 4) == 0))
5904 temp
= atoi (name
+ 4);
5905 p
= input_line_pointer
;
5907 input_line_pointer
++;
5908 name
= input_line_pointer
;
5909 c
= get_symbol_end ();
5910 arg_reloc
= pa_build_arg_reloc (name
);
5911 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
5913 /* Process a return value. */
5914 else if ((strncasecmp (name
, "rtnval", 6) == 0))
5916 p
= input_line_pointer
;
5918 input_line_pointer
++;
5919 name
= input_line_pointer
;
5920 c
= get_symbol_end ();
5921 arg_reloc
= pa_build_arg_reloc (name
);
5922 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
5926 as_bad (_("Invalid .CALL argument: %s"), name
);
5928 p
= input_line_pointer
;
5930 if (!is_end_of_statement ())
5931 input_line_pointer
++;
5935 /* Handle a .CALL pseudo-op. This involves storing away information
5936 about where arguments are to be found so the linker can detect
5937 (and correct) argument location mismatches between caller and callee. */
5940 pa_call (int unused ATTRIBUTE_UNUSED
)
5943 /* We must have a valid space and subspace. */
5944 pa_check_current_space_and_subspace ();
5947 pa_call_args (&last_call_desc
);
5948 demand_empty_rest_of_line ();
5951 /* Return TRUE if FRAG1 and FRAG2 are the same. */
5954 is_same_frag (fragS
*frag1
, fragS
*frag2
)
5959 else if (frag2
== NULL
)
5961 else if (frag1
== frag2
)
5963 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
5964 return (is_same_frag (frag1
, frag2
->fr_next
));
5970 /* Build an entry in the UNWIND subspace from the given function
5971 attributes in CALL_INFO. This is not needed for SOM as using
5972 R_ENTRY and R_EXIT relocations allow the linker to handle building
5973 of the unwind spaces. */
5976 pa_build_unwind_subspace (struct call_info
*call_info
)
5978 asection
*seg
, *save_seg
;
5979 subsegT save_subseg
;
5980 unsigned int unwind
;
5984 if ((bfd_get_section_flags (stdoutput
, now_seg
)
5985 & (SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
))
5986 != (SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
))
5989 reloc
= R_PARISC_SEGREL32
;
5991 save_subseg
= now_subseg
;
5992 /* Get into the right seg/subseg. This may involve creating
5993 the seg the first time through. Make sure to have the
5994 old seg/subseg so that we can reset things when we are done. */
5995 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
5996 if (seg
== ASEC_NULL
)
5998 seg
= subseg_new (UNWIND_SECTION_NAME
, 0);
5999 bfd_set_section_flags (stdoutput
, seg
,
6000 SEC_READONLY
| SEC_HAS_CONTENTS
6001 | SEC_LOAD
| SEC_RELOC
| SEC_ALLOC
| SEC_DATA
);
6002 bfd_set_section_alignment (stdoutput
, seg
, 2);
6005 subseg_set (seg
, 0);
6007 /* Get some space to hold relocation information for the unwind
6011 /* Relocation info. for start offset of the function. */
6012 md_number_to_chars (p
, 0, 4);
6013 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6014 call_info
->start_symbol
, (offsetT
) 0,
6015 (expressionS
*) NULL
, 0, reloc
,
6018 /* Relocation info. for end offset of the function.
6020 Because we allow reductions of 32bit relocations for ELF, this will be
6021 reduced to section_sym + offset which avoids putting the temporary
6022 symbol into the symbol table. It (should) end up giving the same
6023 value as call_info->start_symbol + function size once the linker is
6024 finished with its work. */
6025 md_number_to_chars (p
+ 4, 0, 4);
6026 fix_new_hppa (frag_now
, p
+ 4 - frag_now
->fr_literal
, 4,
6027 call_info
->end_symbol
, (offsetT
) 0,
6028 (expressionS
*) NULL
, 0, reloc
,
6031 /* Dump the descriptor. */
6032 unwind
= UNWIND_LOW32 (&call_info
->ci_unwind
.descriptor
);
6033 md_number_to_chars (p
+ 8, unwind
, 4);
6035 unwind
= UNWIND_HIGH32 (&call_info
->ci_unwind
.descriptor
);
6036 md_number_to_chars (p
+ 12, unwind
, 4);
6038 /* Return back to the original segment/subsegment. */
6039 subseg_set (save_seg
, save_subseg
);
6043 /* Process a .CALLINFO pseudo-op. This information is used later
6044 to build unwind descriptors and maybe one day to support
6045 .ENTER and .LEAVE. */
6048 pa_callinfo (int unused ATTRIBUTE_UNUSED
)
6054 /* We must have a valid space and subspace. */
6055 pa_check_current_space_and_subspace ();
6058 /* .CALLINFO must appear within a procedure definition. */
6059 if (!within_procedure
)
6060 as_bad (_(".callinfo is not within a procedure definition"));
6062 /* Mark the fact that we found the .CALLINFO for the
6063 current procedure. */
6064 callinfo_found
= TRUE
;
6066 /* Iterate over the .CALLINFO arguments. */
6067 while (!is_end_of_statement ())
6069 name
= input_line_pointer
;
6070 c
= get_symbol_end ();
6071 /* Frame size specification. */
6072 if ((strncasecmp (name
, "frame", 5) == 0))
6074 p
= input_line_pointer
;
6076 input_line_pointer
++;
6077 temp
= get_absolute_expression ();
6078 if ((temp
& 0x3) != 0)
6080 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
6084 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
6085 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
6088 /* Entry register (GR, GR and SR) specifications. */
6089 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
6091 p
= input_line_pointer
;
6093 input_line_pointer
++;
6094 temp
= get_absolute_expression ();
6095 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
6096 even though %r19 is caller saved. I think this is a bug in
6097 the HP assembler, and we are not going to emulate it. */
6098 if (temp
< 3 || temp
> 18)
6099 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
6100 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
6102 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
6104 p
= input_line_pointer
;
6106 input_line_pointer
++;
6107 temp
= get_absolute_expression ();
6108 /* Similarly the HP assembler takes 31 as the high bound even
6109 though %fr21 is the last callee saved floating point register. */
6110 if (temp
< 12 || temp
> 21)
6111 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
6112 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
6114 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
6116 p
= input_line_pointer
;
6118 input_line_pointer
++;
6119 temp
= get_absolute_expression ();
6121 as_bad (_("Value for ENTRY_SR must be 3\n"));
6123 /* Note whether or not this function performs any calls. */
6124 else if ((strncasecmp (name
, "calls", 5) == 0) ||
6125 (strncasecmp (name
, "caller", 6) == 0))
6127 p
= input_line_pointer
;
6130 else if ((strncasecmp (name
, "no_calls", 8) == 0))
6132 p
= input_line_pointer
;
6135 /* Should RP be saved into the stack. */
6136 else if ((strncasecmp (name
, "save_rp", 7) == 0))
6138 p
= input_line_pointer
;
6140 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
6142 /* Likewise for SP. */
6143 else if ((strncasecmp (name
, "save_sp", 7) == 0))
6145 p
= input_line_pointer
;
6147 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
6149 /* Is this an unwindable procedure. If so mark it so
6150 in the unwind descriptor. */
6151 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
6153 p
= input_line_pointer
;
6155 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
6157 /* Is this an interrupt routine. If so mark it in the
6158 unwind descriptor. */
6159 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
6161 p
= input_line_pointer
;
6163 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
6165 /* Is this a millicode routine. "millicode" isn't in my
6166 assembler manual, but my copy is old. The HP assembler
6167 accepts it, and there's a place in the unwind descriptor
6168 to drop the information, so we'll accept it too. */
6169 else if ((strncasecmp (name
, "millicode", 9) == 0))
6171 p
= input_line_pointer
;
6173 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
6177 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
6178 *input_line_pointer
= c
;
6180 if (!is_end_of_statement ())
6181 input_line_pointer
++;
6184 demand_empty_rest_of_line ();
6187 #if !(defined (OBJ_ELF) && (defined (TE_LINUX) || defined (TE_NetBSD)))
6188 /* Switch to the text space. Like s_text, but delete our
6189 label when finished. */
6192 pa_text (int unused ATTRIBUTE_UNUSED
)
6195 current_space
= is_defined_space ("$TEXT$");
6197 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6201 pa_undefine_label ();
6204 /* Switch to the data space. As usual delete our label. */
6207 pa_data (int unused ATTRIBUTE_UNUSED
)
6210 current_space
= is_defined_space ("$PRIVATE$");
6212 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6215 pa_undefine_label ();
6218 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
6219 the .comm pseudo-op has the following symtax:
6221 <label> .comm <length>
6223 where <label> is optional and is a symbol whose address will be the start of
6224 a block of memory <length> bytes long. <length> must be an absolute
6225 expression. <length> bytes will be allocated in the current space
6228 Also note the label may not even be on the same line as the .comm.
6230 This difference in syntax means the colon function will be called
6231 on the symbol before we arrive in pa_comm. colon will set a number
6232 of attributes of the symbol that need to be fixed here. In particular
6233 the value, section pointer, fragment pointer, flags, etc. What
6236 This also makes error detection all but impossible. */
6239 pa_comm (int unused ATTRIBUTE_UNUSED
)
6243 label_symbol_struct
*label_symbol
= pa_get_label ();
6246 symbol
= label_symbol
->lss_label
;
6251 size
= get_absolute_expression ();
6255 symbol_get_bfdsym (symbol
)->flags
|= BSF_OBJECT
;
6256 S_SET_VALUE (symbol
, size
);
6257 S_SET_SEGMENT (symbol
, bfd_com_section_ptr
);
6258 S_SET_EXTERNAL (symbol
);
6260 /* colon() has already set the frag to the current location in the
6261 current subspace; we need to reset the fragment to the zero address
6262 fragment. We also need to reset the segment pointer. */
6263 symbol_set_frag (symbol
, &zero_address_frag
);
6265 demand_empty_rest_of_line ();
6267 #endif /* !(defined (OBJ_ELF) && (defined (TE_LINUX) || defined (TE_NetBSD))) */
6269 /* Process a .END pseudo-op. */
6272 pa_end (int unused ATTRIBUTE_UNUSED
)
6274 demand_empty_rest_of_line ();
6277 /* Process a .ENTER pseudo-op. This is not supported. */
6280 pa_enter (int unused ATTRIBUTE_UNUSED
)
6283 /* We must have a valid space and subspace. */
6284 pa_check_current_space_and_subspace ();
6287 as_bad (_("The .ENTER pseudo-op is not supported"));
6288 demand_empty_rest_of_line ();
6291 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
6295 pa_entry (int unused ATTRIBUTE_UNUSED
)
6298 /* We must have a valid space and subspace. */
6299 pa_check_current_space_and_subspace ();
6302 if (!within_procedure
)
6303 as_bad (_("Misplaced .entry. Ignored."));
6306 if (!callinfo_found
)
6307 as_bad (_("Missing .callinfo."));
6309 demand_empty_rest_of_line ();
6310 within_entry_exit
= TRUE
;
6313 /* SOM defers building of unwind descriptors until the link phase.
6314 The assembler is responsible for creating an R_ENTRY relocation
6315 to mark the beginning of a region and hold the unwind bits, and
6316 for creating an R_EXIT relocation to mark the end of the region.
6318 FIXME. ELF should be using the same conventions! The problem
6319 is an unwind requires too much relocation space. Hmmm. Maybe
6320 if we split the unwind bits up between the relocations which
6321 denote the entry and exit points. */
6322 if (last_call_info
->start_symbol
!= NULL
)
6327 where
= frag_more (0);
6328 u
= UNWIND_LOW32 (&last_call_info
->ci_unwind
.descriptor
);
6329 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6330 NULL
, (offsetT
) 0, NULL
,
6331 0, R_HPPA_ENTRY
, e_fsel
, 0, 0, u
);
6336 /* Silly nonsense for pa_equ. The only half-sensible use for this is
6337 being able to subtract two register symbols that specify a range of
6338 registers, to get the size of the range. */
6339 static int fudge_reg_expressions
;
6342 hppa_force_reg_syms_absolute (expressionS
*resultP
,
6343 operatorT op ATTRIBUTE_UNUSED
,
6344 expressionS
*rightP
)
6346 if (fudge_reg_expressions
6347 && rightP
->X_op
== O_register
6348 && resultP
->X_op
== O_register
)
6350 rightP
->X_op
= O_constant
;
6351 resultP
->X_op
= O_constant
;
6353 return 0; /* Continue normal expr handling. */
6356 /* Handle a .EQU pseudo-op. */
6361 label_symbol_struct
*label_symbol
= pa_get_label ();
6366 symbol
= label_symbol
->lss_label
;
6370 if (!pa_parse_number (&input_line_pointer
, 0))
6371 as_bad (_(".REG expression must be a register"));
6372 S_SET_VALUE (symbol
, pa_number
);
6373 S_SET_SEGMENT (symbol
, reg_section
);
6380 fudge_reg_expressions
= 1;
6381 seg
= expression (&exp
);
6382 fudge_reg_expressions
= 0;
6383 if (exp
.X_op
!= O_constant
6384 && exp
.X_op
!= O_register
)
6386 if (exp
.X_op
!= O_absent
)
6387 as_bad (_("bad or irreducible absolute expression; zero assumed"));
6388 exp
.X_add_number
= 0;
6389 seg
= absolute_section
;
6391 S_SET_VALUE (symbol
, (unsigned int) exp
.X_add_number
);
6392 S_SET_SEGMENT (symbol
, seg
);
6398 as_bad (_(".REG must use a label"));
6400 as_bad (_(".EQU must use a label"));
6403 pa_undefine_label ();
6404 demand_empty_rest_of_line ();
6408 /* Mark the end of a function so that it's possible to compute
6409 the size of the function in elf_hppa_final_processing. */
6412 hppa_elf_mark_end_of_function (void)
6414 /* ELF does not have EXIT relocations. All we do is create a
6415 temporary symbol marking the end of the function. */
6418 if (last_call_info
== NULL
|| last_call_info
->start_symbol
== NULL
)
6420 /* We have already warned about a missing label,
6421 or other problems. */
6425 name
= xmalloc (strlen ("L$\001end_")
6426 + strlen (S_GET_NAME (last_call_info
->start_symbol
))
6432 strcpy (name
, "L$\001end_");
6433 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
6435 /* If we have a .exit followed by a .procend, then the
6436 symbol will have already been defined. */
6437 symbolP
= symbol_find (name
);
6440 /* The symbol has already been defined! This can
6441 happen if we have a .exit followed by a .procend.
6443 This is *not* an error. All we want to do is free
6444 the memory we just allocated for the name and continue. */
6449 /* symbol value should be the offset of the
6450 last instruction of the function */
6451 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
6455 S_CLEAR_EXTERNAL (symbolP
);
6456 symbol_table_insert (symbolP
);
6460 last_call_info
->end_symbol
= symbolP
;
6462 as_bad (_("Symbol '%s' could not be created."), name
);
6466 as_bad (_("No memory for symbol name."));
6470 /* Helper function. Does processing for the end of a function. This
6471 usually involves creating some relocations or building special
6472 symbols to mark the end of the function. */
6479 where
= frag_more (0);
6482 /* Mark the end of the function, stuff away the location of the frag
6483 for the end of the function, and finally call pa_build_unwind_subspace
6484 to add an entry in the unwind table. */
6485 hppa_elf_mark_end_of_function ();
6486 pa_build_unwind_subspace (last_call_info
);
6488 /* SOM defers building of unwind descriptors until the link phase.
6489 The assembler is responsible for creating an R_ENTRY relocation
6490 to mark the beginning of a region and hold the unwind bits, and
6491 for creating an R_EXIT relocation to mark the end of the region.
6493 FIXME. ELF should be using the same conventions! The problem
6494 is an unwind requires too much relocation space. Hmmm. Maybe
6495 if we split the unwind bits up between the relocations which
6496 denote the entry and exit points. */
6497 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6499 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
6500 UNWIND_HIGH32 (&last_call_info
->ci_unwind
.descriptor
));
6504 /* Process a .EXIT pseudo-op. */
6507 pa_exit (int unused ATTRIBUTE_UNUSED
)
6510 /* We must have a valid space and subspace. */
6511 pa_check_current_space_and_subspace ();
6514 if (!within_procedure
)
6515 as_bad (_(".EXIT must appear within a procedure"));
6518 if (!callinfo_found
)
6519 as_bad (_("Missing .callinfo"));
6522 if (!within_entry_exit
)
6523 as_bad (_("No .ENTRY for this .EXIT"));
6526 within_entry_exit
= FALSE
;
6531 demand_empty_rest_of_line ();
6534 /* Helper function to process arguments to a .EXPORT pseudo-op. */
6537 pa_type_args (symbolS
*symbolP
, int is_export
)
6540 unsigned int temp
, arg_reloc
;
6541 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
6542 asymbol
*bfdsym
= symbol_get_bfdsym (symbolP
);
6544 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
6546 input_line_pointer
+= 8;
6547 bfdsym
->flags
&= ~BSF_FUNCTION
;
6548 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
6549 type
= SYMBOL_TYPE_ABSOLUTE
;
6551 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
6553 input_line_pointer
+= 4;
6554 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
6555 instead one should be IMPORTing/EXPORTing ENTRY types.
6557 Complain if one tries to EXPORT a CODE type since that's never
6558 done. Both GCC and HP C still try to IMPORT CODE types, so
6559 silently fix them to be ENTRY types. */
6560 if (S_IS_FUNCTION (symbolP
))
6563 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
6564 S_GET_NAME (symbolP
));
6566 bfdsym
->flags
|= BSF_FUNCTION
;
6567 type
= SYMBOL_TYPE_ENTRY
;
6571 bfdsym
->flags
&= ~BSF_FUNCTION
;
6572 type
= SYMBOL_TYPE_CODE
;
6575 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
6577 input_line_pointer
+= 4;
6578 bfdsym
->flags
&= ~BSF_FUNCTION
;
6579 bfdsym
->flags
|= BSF_OBJECT
;
6580 type
= SYMBOL_TYPE_DATA
;
6582 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
6584 input_line_pointer
+= 5;
6585 bfdsym
->flags
|= BSF_FUNCTION
;
6586 type
= SYMBOL_TYPE_ENTRY
;
6588 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
6590 input_line_pointer
+= 9;
6591 bfdsym
->flags
|= BSF_FUNCTION
;
6594 elf_symbol_type
*elfsym
= (elf_symbol_type
*) bfdsym
;
6595 elfsym
->internal_elf_sym
.st_info
=
6596 ELF_ST_INFO (ELF_ST_BIND (elfsym
->internal_elf_sym
.st_info
),
6600 type
= SYMBOL_TYPE_MILLICODE
;
6602 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
6604 input_line_pointer
+= 6;
6605 bfdsym
->flags
&= ~BSF_FUNCTION
;
6606 type
= SYMBOL_TYPE_PLABEL
;
6608 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
6610 input_line_pointer
+= 8;
6611 bfdsym
->flags
|= BSF_FUNCTION
;
6612 type
= SYMBOL_TYPE_PRI_PROG
;
6614 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
6616 input_line_pointer
+= 8;
6617 bfdsym
->flags
|= BSF_FUNCTION
;
6618 type
= SYMBOL_TYPE_SEC_PROG
;
6621 /* SOM requires much more information about symbol types
6622 than BFD understands. This is how we get this information
6623 to the SOM BFD backend. */
6624 #ifdef obj_set_symbol_type
6625 obj_set_symbol_type (bfdsym
, (int) type
);
6628 /* Now that the type of the exported symbol has been handled,
6629 handle any argument relocation information. */
6630 while (!is_end_of_statement ())
6632 if (*input_line_pointer
== ',')
6633 input_line_pointer
++;
6634 name
= input_line_pointer
;
6635 c
= get_symbol_end ();
6636 /* Argument sources. */
6637 if ((strncasecmp (name
, "argw", 4) == 0))
6639 p
= input_line_pointer
;
6641 input_line_pointer
++;
6642 temp
= atoi (name
+ 4);
6643 name
= input_line_pointer
;
6644 c
= get_symbol_end ();
6645 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
6646 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
6647 symbol_arg_reloc_info (symbolP
) |= arg_reloc
;
6649 *input_line_pointer
= c
;
6651 /* The return value. */
6652 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
6654 p
= input_line_pointer
;
6656 input_line_pointer
++;
6657 name
= input_line_pointer
;
6658 c
= get_symbol_end ();
6659 arg_reloc
= pa_build_arg_reloc (name
);
6660 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
6661 symbol_arg_reloc_info (symbolP
) |= arg_reloc
;
6663 *input_line_pointer
= c
;
6665 /* Privilege level. */
6666 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
6668 p
= input_line_pointer
;
6670 input_line_pointer
++;
6671 temp
= atoi (input_line_pointer
);
6673 ((obj_symbol_type
*) bfdsym
)->tc_data
.ap
.hppa_priv_level
= temp
;
6675 c
= get_symbol_end ();
6676 *input_line_pointer
= c
;
6680 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
6681 p
= input_line_pointer
;
6684 if (!is_end_of_statement ())
6685 input_line_pointer
++;
6689 /* Process a .EXPORT directive. This makes functions external
6690 and provides information such as argument relocation entries
6694 pa_export (int unused ATTRIBUTE_UNUSED
)
6699 name
= input_line_pointer
;
6700 c
= get_symbol_end ();
6701 /* Make sure the given symbol exists. */
6702 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6704 as_bad (_("Cannot define export symbol: %s\n"), name
);
6705 p
= input_line_pointer
;
6707 input_line_pointer
++;
6711 /* OK. Set the external bits and process argument relocations.
6712 For the HP, weak and global are not mutually exclusive.
6713 S_SET_EXTERNAL will not set BSF_GLOBAL if WEAK is set.
6714 Call S_SET_EXTERNAL to get the other processing. Manually
6715 set BSF_GLOBAL when we get back. */
6716 S_SET_EXTERNAL (symbol
);
6717 symbol_get_bfdsym (symbol
)->flags
|= BSF_GLOBAL
;
6718 p
= input_line_pointer
;
6720 if (!is_end_of_statement ())
6722 input_line_pointer
++;
6723 pa_type_args (symbol
, 1);
6727 demand_empty_rest_of_line ();
6730 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
6731 assembly file must either be defined in the assembly file, or
6732 explicitly IMPORTED from another. */
6735 pa_import (int unused ATTRIBUTE_UNUSED
)
6740 name
= input_line_pointer
;
6741 c
= get_symbol_end ();
6743 symbol
= symbol_find (name
);
6744 /* Ugh. We might be importing a symbol defined earlier in the file,
6745 in which case all the code below will really screw things up
6746 (set the wrong segment, symbol flags & type, etc). */
6747 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
6749 symbol
= symbol_find_or_make (name
);
6750 p
= input_line_pointer
;
6753 if (!is_end_of_statement ())
6755 input_line_pointer
++;
6756 pa_type_args (symbol
, 0);
6760 /* Sigh. To be compatible with the HP assembler and to help
6761 poorly written assembly code, we assign a type based on
6762 the current segment. Note only BSF_FUNCTION really
6763 matters, we do not need to set the full SYMBOL_TYPE_* info. */
6764 if (now_seg
== text_section
)
6765 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
6767 /* If the section is undefined, then the symbol is undefined
6768 Since this is an import, leave the section undefined. */
6769 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6774 /* The symbol was already defined. Just eat everything up to
6775 the end of the current statement. */
6776 while (!is_end_of_statement ())
6777 input_line_pointer
++;
6780 demand_empty_rest_of_line ();
6783 /* Handle a .LABEL pseudo-op. */
6786 pa_label (int unused ATTRIBUTE_UNUSED
)
6790 name
= input_line_pointer
;
6791 c
= get_symbol_end ();
6793 if (strlen (name
) > 0)
6796 p
= input_line_pointer
;
6801 as_warn (_("Missing label name on .LABEL"));
6804 if (!is_end_of_statement ())
6806 as_warn (_("extra .LABEL arguments ignored."));
6807 ignore_rest_of_line ();
6809 demand_empty_rest_of_line ();
6812 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
6815 pa_leave (int unused ATTRIBUTE_UNUSED
)
6818 /* We must have a valid space and subspace. */
6819 pa_check_current_space_and_subspace ();
6822 as_bad (_("The .LEAVE pseudo-op is not supported"));
6823 demand_empty_rest_of_line ();
6826 /* Handle a .LEVEL pseudo-op. */
6829 pa_level (int unused ATTRIBUTE_UNUSED
)
6833 level
= input_line_pointer
;
6834 if (strncmp (level
, "1.0", 3) == 0)
6836 input_line_pointer
+= 3;
6837 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
6838 as_warn (_("could not set architecture and machine"));
6840 else if (strncmp (level
, "1.1", 3) == 0)
6842 input_line_pointer
+= 3;
6843 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
6844 as_warn (_("could not set architecture and machine"));
6846 else if (strncmp (level
, "2.0w", 4) == 0)
6848 input_line_pointer
+= 4;
6849 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 25))
6850 as_warn (_("could not set architecture and machine"));
6852 else if (strncmp (level
, "2.0", 3) == 0)
6854 input_line_pointer
+= 3;
6855 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
6856 as_warn (_("could not set architecture and machine"));
6860 as_bad (_("Unrecognized .LEVEL argument\n"));
6861 ignore_rest_of_line ();
6863 demand_empty_rest_of_line ();
6866 /* Handle a .ORIGIN pseudo-op. */
6869 pa_origin (int unused ATTRIBUTE_UNUSED
)
6872 /* We must have a valid space and subspace. */
6873 pa_check_current_space_and_subspace ();
6877 pa_undefine_label ();
6880 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
6881 is for static functions. FIXME. Should share more code with .EXPORT. */
6884 pa_param (int unused ATTRIBUTE_UNUSED
)
6889 name
= input_line_pointer
;
6890 c
= get_symbol_end ();
6892 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6894 as_bad (_("Cannot define static symbol: %s\n"), name
);
6895 p
= input_line_pointer
;
6897 input_line_pointer
++;
6901 S_CLEAR_EXTERNAL (symbol
);
6902 p
= input_line_pointer
;
6904 if (!is_end_of_statement ())
6906 input_line_pointer
++;
6907 pa_type_args (symbol
, 0);
6911 demand_empty_rest_of_line ();
6914 /* Handle a .PROC pseudo-op. It is used to mark the beginning
6915 of a procedure from a syntactical point of view. */
6918 pa_proc (int unused ATTRIBUTE_UNUSED
)
6920 struct call_info
*call_info
;
6923 /* We must have a valid space and subspace. */
6924 pa_check_current_space_and_subspace ();
6927 if (within_procedure
)
6928 as_fatal (_("Nested procedures"));
6930 /* Reset global variables for new procedure. */
6931 callinfo_found
= FALSE
;
6932 within_procedure
= TRUE
;
6934 /* Create another call_info structure. */
6935 call_info
= xmalloc (sizeof (struct call_info
));
6938 as_fatal (_("Cannot allocate unwind descriptor\n"));
6940 memset (call_info
, 0, sizeof (struct call_info
));
6942 call_info
->ci_next
= NULL
;
6944 if (call_info_root
== NULL
)
6946 call_info_root
= call_info
;
6947 last_call_info
= call_info
;
6951 last_call_info
->ci_next
= call_info
;
6952 last_call_info
= call_info
;
6955 /* set up defaults on call_info structure */
6957 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
6958 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
6959 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
6961 /* If we got a .PROC pseudo-op, we know that the function is defined
6962 locally. Make sure it gets into the symbol table. */
6964 label_symbol_struct
*label_symbol
= pa_get_label ();
6968 if (label_symbol
->lss_label
)
6970 last_call_info
->start_symbol
= label_symbol
->lss_label
;
6971 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
6974 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
6977 last_call_info
->start_symbol
= NULL
;
6980 demand_empty_rest_of_line ();
6983 /* Process the syntactical end of a procedure. Make sure all the
6984 appropriate pseudo-ops were found within the procedure. */
6987 pa_procend (int unused ATTRIBUTE_UNUSED
)
6990 /* We must have a valid space and subspace. */
6991 pa_check_current_space_and_subspace ();
6994 /* If we are within a procedure definition, make sure we've
6995 defined a label for the procedure; handle case where the
6996 label was defined after the .PROC directive.
6998 Note there's not need to diddle with the segment or fragment
6999 for the label symbol in this case. We have already switched
7000 into the new $CODE$ subspace at this point. */
7001 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
7003 label_symbol_struct
*label_symbol
= pa_get_label ();
7007 if (label_symbol
->lss_label
)
7009 last_call_info
->start_symbol
= label_symbol
->lss_label
;
7010 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
7013 /* Also handle allocation of a fixup to hold the unwind
7014 information when the label appears after the proc/procend. */
7015 if (within_entry_exit
)
7020 where
= frag_more (0);
7021 u
= UNWIND_LOW32 (&last_call_info
->ci_unwind
.descriptor
);
7022 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
7023 NULL
, (offsetT
) 0, NULL
,
7024 0, R_HPPA_ENTRY
, e_fsel
, 0, 0, u
);
7029 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
7032 as_bad (_("Missing function name for .PROC"));
7035 if (!within_procedure
)
7036 as_bad (_("misplaced .procend"));
7038 if (!callinfo_found
)
7039 as_bad (_("Missing .callinfo for this procedure"));
7041 if (within_entry_exit
)
7042 as_bad (_("Missing .EXIT for a .ENTRY"));
7045 /* ELF needs to mark the end of each function so that it can compute
7046 the size of the function (apparently its needed in the symbol table). */
7047 hppa_elf_mark_end_of_function ();
7050 within_procedure
= FALSE
;
7051 demand_empty_rest_of_line ();
7052 pa_undefine_label ();
7056 /* If VALUE is an exact power of two between zero and 2^31, then
7057 return log2 (VALUE). Else return -1. */
7060 exact_log2 (int value
)
7064 while ((1 << shift
) != value
&& shift
< 32)
7073 /* Check to make sure we have a valid space and subspace. */
7076 pa_check_current_space_and_subspace (void)
7078 if (current_space
== NULL
)
7079 as_fatal (_("Not in a space.\n"));
7081 if (current_subspace
== NULL
)
7082 as_fatal (_("Not in a subspace.\n"));
7085 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
7086 then create a new space entry to hold the information specified
7087 by the parameters to the .SPACE directive. */
7089 static sd_chain_struct
*
7090 pa_parse_space_stmt (char *space_name
, int create_flag
)
7092 char *name
, *ptemp
, c
;
7093 char loadable
, defined
, private, sort
;
7095 asection
*seg
= NULL
;
7096 sd_chain_struct
*space
;
7098 /* Load default values. */
7104 if (strcmp (space_name
, "$TEXT$") == 0)
7106 seg
= pa_def_spaces
[0].segment
;
7107 defined
= pa_def_spaces
[0].defined
;
7108 private = pa_def_spaces
[0].private;
7109 sort
= pa_def_spaces
[0].sort
;
7110 spnum
= pa_def_spaces
[0].spnum
;
7112 else if (strcmp (space_name
, "$PRIVATE$") == 0)
7114 seg
= pa_def_spaces
[1].segment
;
7115 defined
= pa_def_spaces
[1].defined
;
7116 private = pa_def_spaces
[1].private;
7117 sort
= pa_def_spaces
[1].sort
;
7118 spnum
= pa_def_spaces
[1].spnum
;
7121 if (!is_end_of_statement ())
7123 print_errors
= FALSE
;
7124 ptemp
= input_line_pointer
+ 1;
7125 /* First see if the space was specified as a number rather than
7126 as a name. According to the PA assembly manual the rest of
7127 the line should be ignored. */
7129 pa_parse_number (&ptemp
, 0);
7133 input_line_pointer
= ptemp
;
7137 while (!is_end_of_statement ())
7139 input_line_pointer
++;
7140 name
= input_line_pointer
;
7141 c
= get_symbol_end ();
7142 if ((strncasecmp (name
, "spnum", 5) == 0))
7144 *input_line_pointer
= c
;
7145 input_line_pointer
++;
7146 spnum
= get_absolute_expression ();
7148 else if ((strncasecmp (name
, "sort", 4) == 0))
7150 *input_line_pointer
= c
;
7151 input_line_pointer
++;
7152 sort
= get_absolute_expression ();
7154 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7156 *input_line_pointer
= c
;
7159 else if ((strncasecmp (name
, "notdefined", 10) == 0))
7161 *input_line_pointer
= c
;
7164 else if ((strncasecmp (name
, "private", 7) == 0))
7166 *input_line_pointer
= c
;
7171 as_bad (_("Invalid .SPACE argument"));
7172 *input_line_pointer
= c
;
7173 if (!is_end_of_statement ())
7174 input_line_pointer
++;
7178 print_errors
= TRUE
;
7181 if (create_flag
&& seg
== NULL
)
7182 seg
= subseg_new (space_name
, 0);
7184 /* If create_flag is nonzero, then create the new space with
7185 the attributes computed above. Else set the values in
7186 an already existing space -- this can only happen for
7187 the first occurrence of a built-in space. */
7189 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
7190 private, sort
, seg
, 1);
7193 space
= is_defined_space (space_name
);
7194 SPACE_SPNUM (space
) = spnum
;
7195 SPACE_DEFINED (space
) = defined
& 1;
7196 SPACE_USER_DEFINED (space
) = 1;
7199 #ifdef obj_set_section_attributes
7200 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7206 /* Handle a .SPACE pseudo-op; this switches the current space to the
7207 given space, creating the new space if necessary. */
7210 pa_space (int unused ATTRIBUTE_UNUSED
)
7212 char *name
, c
, *space_name
, *save_s
;
7213 sd_chain_struct
*sd_chain
;
7215 if (within_procedure
)
7217 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
7218 ignore_rest_of_line ();
7222 /* Check for some of the predefined spaces. FIXME: most of the code
7223 below is repeated several times, can we extract the common parts
7224 and place them into a subroutine or something similar? */
7225 /* FIXME Is this (and the next IF stmt) really right?
7226 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
7227 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
7229 input_line_pointer
+= 6;
7230 sd_chain
= is_defined_space ("$TEXT$");
7231 if (sd_chain
== NULL
)
7232 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
7233 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7234 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
7236 current_space
= sd_chain
;
7237 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
7239 = pa_subsegment_to_subspace (text_section
,
7240 sd_chain
->sd_last_subseg
);
7241 demand_empty_rest_of_line ();
7244 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
7246 input_line_pointer
+= 9;
7247 sd_chain
= is_defined_space ("$PRIVATE$");
7248 if (sd_chain
== NULL
)
7249 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
7250 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7251 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
7253 current_space
= sd_chain
;
7254 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
7256 = pa_subsegment_to_subspace (data_section
,
7257 sd_chain
->sd_last_subseg
);
7258 demand_empty_rest_of_line ();
7261 if (!strncasecmp (input_line_pointer
,
7262 GDB_DEBUG_SPACE_NAME
,
7263 strlen (GDB_DEBUG_SPACE_NAME
)))
7265 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
7266 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
7267 if (sd_chain
== NULL
)
7268 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
7269 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7270 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
7272 current_space
= sd_chain
;
7275 asection
*gdb_section
7276 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
7278 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
7280 = pa_subsegment_to_subspace (gdb_section
,
7281 sd_chain
->sd_last_subseg
);
7283 demand_empty_rest_of_line ();
7287 /* It could be a space specified by number. */
7289 save_s
= input_line_pointer
;
7291 pa_parse_number (&input_line_pointer
, 0);
7294 if ((sd_chain
= pa_find_space_by_number (pa_number
)))
7296 current_space
= sd_chain
;
7298 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7300 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7301 sd_chain
->sd_last_subseg
);
7302 demand_empty_rest_of_line ();
7307 /* Not a number, attempt to create a new space. */
7309 input_line_pointer
= save_s
;
7310 name
= input_line_pointer
;
7311 c
= get_symbol_end ();
7312 space_name
= xmalloc (strlen (name
) + 1);
7313 strcpy (space_name
, name
);
7314 *input_line_pointer
= c
;
7316 sd_chain
= pa_parse_space_stmt (space_name
, 1);
7317 current_space
= sd_chain
;
7319 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7320 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7321 sd_chain
->sd_last_subseg
);
7322 demand_empty_rest_of_line ();
7326 /* Switch to a new space. (I think). FIXME. */
7329 pa_spnum (int unused ATTRIBUTE_UNUSED
)
7334 sd_chain_struct
*space
;
7336 name
= input_line_pointer
;
7337 c
= get_symbol_end ();
7338 space
= is_defined_space (name
);
7342 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
7345 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
7347 *input_line_pointer
= c
;
7348 demand_empty_rest_of_line ();
7351 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
7352 given subspace, creating the new subspace if necessary.
7354 FIXME. Should mirror pa_space more closely, in particular how
7355 they're broken up into subroutines. */
7358 pa_subspace (int create_new
)
7360 char *name
, *ss_name
, c
;
7361 char loadable
, code_only
, comdat
, common
, dup_common
, zero
, sort
;
7362 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
7363 sd_chain_struct
*space
;
7364 ssd_chain_struct
*ssd
;
7367 if (current_space
== NULL
)
7368 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
7370 if (within_procedure
)
7372 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
7373 ignore_rest_of_line ();
7377 name
= input_line_pointer
;
7378 c
= get_symbol_end ();
7379 ss_name
= xmalloc (strlen (name
) + 1);
7380 strcpy (ss_name
, name
);
7381 *input_line_pointer
= c
;
7383 /* Load default values. */
7396 space
= current_space
;
7400 ssd
= is_defined_subspace (ss_name
);
7401 /* Allow user to override the builtin attributes of subspaces. But
7402 only allow the attributes to be changed once! */
7403 if (ssd
&& SUBSPACE_DEFINED (ssd
))
7405 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
7406 current_subspace
= ssd
;
7407 if (!is_end_of_statement ())
7408 as_warn (_("Parameters of an existing subspace can\'t be modified"));
7409 demand_empty_rest_of_line ();
7414 /* A new subspace. Load default values if it matches one of
7415 the builtin subspaces. */
7417 while (pa_def_subspaces
[i
].name
)
7419 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
7421 loadable
= pa_def_subspaces
[i
].loadable
;
7422 comdat
= pa_def_subspaces
[i
].comdat
;
7423 common
= pa_def_subspaces
[i
].common
;
7424 dup_common
= pa_def_subspaces
[i
].dup_common
;
7425 code_only
= pa_def_subspaces
[i
].code_only
;
7426 zero
= pa_def_subspaces
[i
].zero
;
7427 space_index
= pa_def_subspaces
[i
].space_index
;
7428 alignment
= pa_def_subspaces
[i
].alignment
;
7429 quadrant
= pa_def_subspaces
[i
].quadrant
;
7430 access
= pa_def_subspaces
[i
].access
;
7431 sort
= pa_def_subspaces
[i
].sort
;
7438 /* We should be working with a new subspace now. Fill in
7439 any information as specified by the user. */
7440 if (!is_end_of_statement ())
7442 input_line_pointer
++;
7443 while (!is_end_of_statement ())
7445 name
= input_line_pointer
;
7446 c
= get_symbol_end ();
7447 if ((strncasecmp (name
, "quad", 4) == 0))
7449 *input_line_pointer
= c
;
7450 input_line_pointer
++;
7451 quadrant
= get_absolute_expression ();
7453 else if ((strncasecmp (name
, "align", 5) == 0))
7455 *input_line_pointer
= c
;
7456 input_line_pointer
++;
7457 alignment
= get_absolute_expression ();
7458 if (exact_log2 (alignment
) == -1)
7460 as_bad (_("Alignment must be a power of 2"));
7464 else if ((strncasecmp (name
, "access", 6) == 0))
7466 *input_line_pointer
= c
;
7467 input_line_pointer
++;
7468 access
= get_absolute_expression ();
7470 else if ((strncasecmp (name
, "sort", 4) == 0))
7472 *input_line_pointer
= c
;
7473 input_line_pointer
++;
7474 sort
= get_absolute_expression ();
7476 else if ((strncasecmp (name
, "code_only", 9) == 0))
7478 *input_line_pointer
= c
;
7481 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7483 *input_line_pointer
= c
;
7486 else if ((strncasecmp (name
, "comdat", 6) == 0))
7488 *input_line_pointer
= c
;
7491 else if ((strncasecmp (name
, "common", 6) == 0))
7493 *input_line_pointer
= c
;
7496 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
7498 *input_line_pointer
= c
;
7501 else if ((strncasecmp (name
, "zero", 4) == 0))
7503 *input_line_pointer
= c
;
7506 else if ((strncasecmp (name
, "first", 5) == 0))
7507 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
7509 as_bad (_("Invalid .SUBSPACE argument"));
7510 if (!is_end_of_statement ())
7511 input_line_pointer
++;
7515 /* Compute a reasonable set of BFD flags based on the information
7516 in the .subspace directive. */
7517 applicable
= bfd_applicable_section_flags (stdoutput
);
7520 flags
|= (SEC_ALLOC
| SEC_LOAD
);
7524 /* These flags are used to implement various flavors of initialized
7525 common. The SOM linker discards duplicate subspaces when they
7526 have the same "key" symbol name. This support is more like
7527 GNU linkonce than BFD common. Further, pc-relative relocations
7528 are converted to section relative relocations in BFD common
7529 sections. This complicates the handling of relocations in
7530 common sections containing text and isn't currently supported
7531 correctly in the SOM BFD backend. */
7532 if (comdat
|| common
|| dup_common
)
7533 flags
|= SEC_LINK_ONCE
;
7535 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
7537 /* This is a zero-filled subspace (eg BSS). */
7539 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
7541 applicable
&= flags
;
7543 /* If this is an existing subspace, then we want to use the
7544 segment already associated with the subspace.
7546 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
7547 lots of sections. It might be a problem in the PA ELF
7548 code, I do not know yet. For now avoid creating anything
7549 but the "standard" sections for ELF. */
7551 section
= subseg_force_new (ss_name
, 0);
7553 section
= ssd
->ssd_seg
;
7555 section
= subseg_new (ss_name
, 0);
7558 seg_info (section
)->bss
= 1;
7560 /* Now set the flags. */
7561 bfd_set_section_flags (stdoutput
, section
, applicable
);
7563 /* Record any alignment request for this section. */
7564 record_alignment (section
, exact_log2 (alignment
));
7566 /* Set the starting offset for this section. */
7567 bfd_set_section_vma (stdoutput
, section
,
7568 pa_subspace_start (space
, quadrant
));
7570 /* Now that all the flags are set, update an existing subspace,
7571 or create a new one. */
7574 current_subspace
= update_subspace (space
, ss_name
, loadable
,
7575 code_only
, comdat
, common
,
7576 dup_common
, sort
, zero
, access
,
7577 space_index
, alignment
, quadrant
,
7580 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
7581 code_only
, comdat
, common
,
7582 dup_common
, zero
, sort
,
7583 access
, space_index
,
7584 alignment
, quadrant
, section
);
7586 demand_empty_rest_of_line ();
7587 current_subspace
->ssd_seg
= section
;
7588 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
7590 SUBSPACE_DEFINED (current_subspace
) = 1;
7593 /* Create default space and subspace dictionaries. */
7596 pa_spaces_begin (void)
7600 space_dict_root
= NULL
;
7601 space_dict_last
= NULL
;
7604 while (pa_def_spaces
[i
].name
)
7608 /* Pick the right name to use for the new section. */
7609 name
= pa_def_spaces
[i
].name
;
7611 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
7612 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
7613 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
7614 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
7615 pa_def_spaces
[i
].segment
, 0);
7620 while (pa_def_subspaces
[i
].name
)
7623 int applicable
, subsegment
;
7624 asection
*segment
= NULL
;
7625 sd_chain_struct
*space
;
7627 /* Pick the right name for the new section and pick the right
7628 subsegment number. */
7629 name
= pa_def_subspaces
[i
].name
;
7632 /* Create the new section. */
7633 segment
= subseg_new (name
, subsegment
);
7635 /* For SOM we want to replace the standard .text, .data, and .bss
7636 sections with our own. We also want to set BFD flags for
7637 all the built-in subspaces. */
7638 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
7640 text_section
= segment
;
7641 applicable
= bfd_applicable_section_flags (stdoutput
);
7642 bfd_set_section_flags (stdoutput
, segment
,
7643 applicable
& (SEC_ALLOC
| SEC_LOAD
7644 | SEC_RELOC
| SEC_CODE
7646 | SEC_HAS_CONTENTS
));
7648 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
7650 data_section
= segment
;
7651 applicable
= bfd_applicable_section_flags (stdoutput
);
7652 bfd_set_section_flags (stdoutput
, segment
,
7653 applicable
& (SEC_ALLOC
| SEC_LOAD
7655 | SEC_HAS_CONTENTS
));
7658 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
7660 bss_section
= segment
;
7661 applicable
= bfd_applicable_section_flags (stdoutput
);
7662 bfd_set_section_flags (stdoutput
, segment
,
7663 applicable
& SEC_ALLOC
);
7665 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
7667 applicable
= bfd_applicable_section_flags (stdoutput
);
7668 bfd_set_section_flags (stdoutput
, segment
,
7669 applicable
& (SEC_ALLOC
| SEC_LOAD
7672 | SEC_HAS_CONTENTS
));
7674 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
7676 applicable
= bfd_applicable_section_flags (stdoutput
);
7677 bfd_set_section_flags (stdoutput
, segment
,
7678 applicable
& (SEC_ALLOC
| SEC_LOAD
7681 | SEC_HAS_CONTENTS
));
7683 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
7685 applicable
= bfd_applicable_section_flags (stdoutput
);
7686 bfd_set_section_flags (stdoutput
, segment
,
7687 applicable
& (SEC_ALLOC
| SEC_LOAD
7690 | SEC_HAS_CONTENTS
));
7693 /* Find the space associated with this subspace. */
7694 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
7695 def_space_index
].segment
);
7698 as_fatal (_("Internal error: Unable to find containing space for %s."),
7699 pa_def_subspaces
[i
].name
);
7702 create_new_subspace (space
, name
,
7703 pa_def_subspaces
[i
].loadable
,
7704 pa_def_subspaces
[i
].code_only
,
7705 pa_def_subspaces
[i
].comdat
,
7706 pa_def_subspaces
[i
].common
,
7707 pa_def_subspaces
[i
].dup_common
,
7708 pa_def_subspaces
[i
].zero
,
7709 pa_def_subspaces
[i
].sort
,
7710 pa_def_subspaces
[i
].access
,
7711 pa_def_subspaces
[i
].space_index
,
7712 pa_def_subspaces
[i
].alignment
,
7713 pa_def_subspaces
[i
].quadrant
,
7719 /* Create a new space NAME, with the appropriate flags as defined
7720 by the given parameters. */
7722 static sd_chain_struct
*
7723 create_new_space (char *name
,
7725 int loadable ATTRIBUTE_UNUSED
,
7732 sd_chain_struct
*chain_entry
;
7734 chain_entry
= xmalloc (sizeof (sd_chain_struct
));
7736 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
7739 SPACE_NAME (chain_entry
) = xmalloc (strlen (name
) + 1);
7740 strcpy (SPACE_NAME (chain_entry
), name
);
7741 SPACE_DEFINED (chain_entry
) = defined
;
7742 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
7743 SPACE_SPNUM (chain_entry
) = spnum
;
7745 chain_entry
->sd_seg
= seg
;
7746 chain_entry
->sd_last_subseg
= -1;
7747 chain_entry
->sd_subspaces
= NULL
;
7748 chain_entry
->sd_next
= NULL
;
7750 /* Find spot for the new space based on its sort key. */
7751 if (!space_dict_last
)
7752 space_dict_last
= chain_entry
;
7754 if (space_dict_root
== NULL
)
7755 space_dict_root
= chain_entry
;
7758 sd_chain_struct
*chain_pointer
;
7759 sd_chain_struct
*prev_chain_pointer
;
7761 chain_pointer
= space_dict_root
;
7762 prev_chain_pointer
= NULL
;
7764 while (chain_pointer
)
7766 prev_chain_pointer
= chain_pointer
;
7767 chain_pointer
= chain_pointer
->sd_next
;
7770 /* At this point we've found the correct place to add the new
7771 entry. So add it and update the linked lists as appropriate. */
7772 if (prev_chain_pointer
)
7774 chain_entry
->sd_next
= chain_pointer
;
7775 prev_chain_pointer
->sd_next
= chain_entry
;
7779 space_dict_root
= chain_entry
;
7780 chain_entry
->sd_next
= chain_pointer
;
7783 if (chain_entry
->sd_next
== NULL
)
7784 space_dict_last
= chain_entry
;
7787 /* This is here to catch predefined spaces which do not get
7788 modified by the user's input. Another call is found at
7789 the bottom of pa_parse_space_stmt to handle cases where
7790 the user modifies a predefined space. */
7791 #ifdef obj_set_section_attributes
7792 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7798 /* Create a new subspace NAME, with the appropriate flags as defined
7799 by the given parameters.
7801 Add the new subspace to the subspace dictionary chain in numerical
7802 order as defined by the SORT entries. */
7804 static ssd_chain_struct
*
7805 create_new_subspace (sd_chain_struct
*space
,
7807 int loadable ATTRIBUTE_UNUSED
,
7808 int code_only ATTRIBUTE_UNUSED
,
7812 int is_zero ATTRIBUTE_UNUSED
,
7815 int space_index ATTRIBUTE_UNUSED
,
7816 int alignment ATTRIBUTE_UNUSED
,
7820 ssd_chain_struct
*chain_entry
;
7822 chain_entry
= xmalloc (sizeof (ssd_chain_struct
));
7824 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
7826 SUBSPACE_NAME (chain_entry
) = xmalloc (strlen (name
) + 1);
7827 strcpy (SUBSPACE_NAME (chain_entry
), name
);
7829 /* Initialize subspace_defined. When we hit a .subspace directive
7830 we'll set it to 1 which "locks-in" the subspace attributes. */
7831 SUBSPACE_DEFINED (chain_entry
) = 0;
7833 chain_entry
->ssd_subseg
= 0;
7834 chain_entry
->ssd_seg
= seg
;
7835 chain_entry
->ssd_next
= NULL
;
7837 /* Find spot for the new subspace based on its sort key. */
7838 if (space
->sd_subspaces
== NULL
)
7839 space
->sd_subspaces
= chain_entry
;
7842 ssd_chain_struct
*chain_pointer
;
7843 ssd_chain_struct
*prev_chain_pointer
;
7845 chain_pointer
= space
->sd_subspaces
;
7846 prev_chain_pointer
= NULL
;
7848 while (chain_pointer
)
7850 prev_chain_pointer
= chain_pointer
;
7851 chain_pointer
= chain_pointer
->ssd_next
;
7854 /* Now we have somewhere to put the new entry. Insert it and update
7856 if (prev_chain_pointer
)
7858 chain_entry
->ssd_next
= chain_pointer
;
7859 prev_chain_pointer
->ssd_next
= chain_entry
;
7863 space
->sd_subspaces
= chain_entry
;
7864 chain_entry
->ssd_next
= chain_pointer
;
7868 #ifdef obj_set_subsection_attributes
7869 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
, sort
,
7870 quadrant
, comdat
, common
, dup_common
);
7876 /* Update the information for the given subspace based upon the
7877 various arguments. Return the modified subspace chain entry. */
7879 static ssd_chain_struct
*
7880 update_subspace (sd_chain_struct
*space
,
7882 int loadable ATTRIBUTE_UNUSED
,
7883 int code_only ATTRIBUTE_UNUSED
,
7888 int zero ATTRIBUTE_UNUSED
,
7890 int space_index ATTRIBUTE_UNUSED
,
7891 int alignment ATTRIBUTE_UNUSED
,
7895 ssd_chain_struct
*chain_entry
;
7897 chain_entry
= is_defined_subspace (name
);
7899 #ifdef obj_set_subsection_attributes
7900 obj_set_subsection_attributes (section
, space
->sd_seg
, access
, sort
,
7901 quadrant
, comdat
, common
, dup_common
);
7907 /* Return the space chain entry for the space with the name NAME or
7908 NULL if no such space exists. */
7910 static sd_chain_struct
*
7911 is_defined_space (char *name
)
7913 sd_chain_struct
*chain_pointer
;
7915 for (chain_pointer
= space_dict_root
;
7917 chain_pointer
= chain_pointer
->sd_next
)
7918 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
7919 return chain_pointer
;
7921 /* No mapping from segment to space was found. Return NULL. */
7925 /* Find and return the space associated with the given seg. If no mapping
7926 from the given seg to a space is found, then return NULL.
7928 Unlike subspaces, the number of spaces is not expected to grow much,
7929 so a linear exhaustive search is OK here. */
7931 static sd_chain_struct
*
7932 pa_segment_to_space (asection
*seg
)
7934 sd_chain_struct
*space_chain
;
7936 /* Walk through each space looking for the correct mapping. */
7937 for (space_chain
= space_dict_root
;
7939 space_chain
= space_chain
->sd_next
)
7940 if (space_chain
->sd_seg
== seg
)
7943 /* Mapping was not found. Return NULL. */
7947 /* Return the first space chain entry for the subspace with the name
7948 NAME or NULL if no such subspace exists.
7950 When there are multiple subspaces with the same name, switching to
7951 the first (i.e., default) subspace is preferable in most situations.
7952 For example, it wouldn't be desirable to merge COMDAT data with non
7955 Uses a linear search through all the spaces and subspaces, this may
7956 not be appropriate if we ever being placing each function in its
7959 static ssd_chain_struct
*
7960 is_defined_subspace (char *name
)
7962 sd_chain_struct
*space_chain
;
7963 ssd_chain_struct
*subspace_chain
;
7965 /* Walk through each space. */
7966 for (space_chain
= space_dict_root
;
7968 space_chain
= space_chain
->sd_next
)
7970 /* Walk through each subspace looking for a name which matches. */
7971 for (subspace_chain
= space_chain
->sd_subspaces
;
7973 subspace_chain
= subspace_chain
->ssd_next
)
7974 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
7975 return subspace_chain
;
7978 /* Subspace wasn't found. Return NULL. */
7982 /* Find and return the subspace associated with the given seg. If no
7983 mapping from the given seg to a subspace is found, then return NULL.
7985 If we ever put each procedure/function within its own subspace
7986 (to make life easier on the compiler and linker), then this will have
7987 to become more efficient. */
7989 static ssd_chain_struct
*
7990 pa_subsegment_to_subspace (asection
*seg
, subsegT subseg
)
7992 sd_chain_struct
*space_chain
;
7993 ssd_chain_struct
*subspace_chain
;
7995 /* Walk through each space. */
7996 for (space_chain
= space_dict_root
;
7998 space_chain
= space_chain
->sd_next
)
8000 if (space_chain
->sd_seg
== seg
)
8002 /* Walk through each subspace within each space looking for
8003 the correct mapping. */
8004 for (subspace_chain
= space_chain
->sd_subspaces
;
8006 subspace_chain
= subspace_chain
->ssd_next
)
8007 if (subspace_chain
->ssd_subseg
== (int) subseg
)
8008 return subspace_chain
;
8012 /* No mapping from subsegment to subspace found. Return NULL. */
8016 /* Given a number, try and find a space with the name number.
8018 Return a pointer to a space dictionary chain entry for the space
8019 that was found or NULL on failure. */
8021 static sd_chain_struct
*
8022 pa_find_space_by_number (int number
)
8024 sd_chain_struct
*space_chain
;
8026 for (space_chain
= space_dict_root
;
8028 space_chain
= space_chain
->sd_next
)
8030 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
8034 /* No appropriate space found. Return NULL. */
8038 /* Return the starting address for the given subspace. If the starting
8039 address is unknown then return zero. */
8042 pa_subspace_start (sd_chain_struct
*space
, int quadrant
)
8044 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
8045 is not correct for the PA OSF1 port. */
8046 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
8048 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
8056 /* Helper function for pa_stringer. Used to find the end of
8060 pa_stringer_aux (char *s
)
8062 unsigned int c
= *s
& CHAR_MASK
;
8075 /* Handle a .STRING type pseudo-op. */
8078 pa_stringer (int append_zero
)
8080 char *s
, num_buf
[4];
8084 /* Preprocess the string to handle PA-specific escape sequences.
8085 For example, \xDD where DD is a hexadecimal number should be
8086 changed to \OOO where OOO is an octal number. */
8089 /* We must have a valid space and subspace. */
8090 pa_check_current_space_and_subspace ();
8093 /* Skip the opening quote. */
8094 s
= input_line_pointer
+ 1;
8096 while (is_a_char (c
= pa_stringer_aux (s
++)))
8103 /* Handle \x<num>. */
8106 unsigned int number
;
8111 /* Get past the 'x'. */
8113 for (num_digit
= 0, number
= 0, dg
= *s
;
8115 && (ISDIGIT (dg
) || (dg
>= 'a' && dg
<= 'f')
8116 || (dg
>= 'A' && dg
<= 'F'));
8120 number
= number
* 16 + dg
- '0';
8121 else if (dg
>= 'a' && dg
<= 'f')
8122 number
= number
* 16 + dg
- 'a' + 10;
8124 number
= number
* 16 + dg
- 'A' + 10;
8134 sprintf (num_buf
, "%02o", number
);
8137 sprintf (num_buf
, "%03o", number
);
8140 for (i
= 0; i
<= num_digit
; i
++)
8141 s_start
[i
] = num_buf
[i
];
8145 /* This might be a "\"", skip over the escaped char. */
8152 stringer (append_zero
);
8153 pa_undefine_label ();
8156 /* Handle a .VERSION pseudo-op. */
8159 pa_version (int unused ATTRIBUTE_UNUSED
)
8162 pa_undefine_label ();
8167 /* Handle a .COMPILER pseudo-op. */
8170 pa_compiler (int unused ATTRIBUTE_UNUSED
)
8172 obj_som_compiler (0);
8173 pa_undefine_label ();
8178 /* Handle a .COPYRIGHT pseudo-op. */
8181 pa_copyright (int unused ATTRIBUTE_UNUSED
)
8184 pa_undefine_label ();
8187 /* Just like a normal cons, but when finished we have to undefine
8188 the latest space label. */
8191 pa_cons (int nbytes
)
8194 pa_undefine_label ();
8197 /* Like float_cons, but we need to undefine our label. */
8200 pa_float_cons (int float_type
)
8202 float_cons (float_type
);
8203 pa_undefine_label ();
8206 /* Like s_fill, but delete our label when finished. */
8209 pa_fill (int unused ATTRIBUTE_UNUSED
)
8212 /* We must have a valid space and subspace. */
8213 pa_check_current_space_and_subspace ();
8217 pa_undefine_label ();
8220 /* Like lcomm, but delete our label when finished. */
8223 pa_lcomm (int needs_align
)
8226 /* We must have a valid space and subspace. */
8227 pa_check_current_space_and_subspace ();
8230 s_lcomm (needs_align
);
8231 pa_undefine_label ();
8234 /* Like lsym, but delete our label when finished. */
8237 pa_lsym (int unused ATTRIBUTE_UNUSED
)
8240 /* We must have a valid space and subspace. */
8241 pa_check_current_space_and_subspace ();
8245 pa_undefine_label ();
8248 /* This function is called once, at assembler startup time. It should
8249 set up all the tables, etc. that the MD part of the assembler will need. */
8254 const char *retval
= NULL
;
8258 last_call_info
= NULL
;
8259 call_info_root
= NULL
;
8261 /* Set the default machine type. */
8262 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, DEFAULT_LEVEL
))
8263 as_warn (_("could not set architecture and machine"));
8265 /* Folding of text and data segments fails miserably on the PA.
8266 Warn user and disable "-R" option. */
8267 if (flag_readonly_data_in_text
)
8269 as_warn (_("-R option not supported on this target."));
8270 flag_readonly_data_in_text
= 0;
8277 op_hash
= hash_new ();
8279 while (i
< NUMOPCODES
)
8281 const char *name
= pa_opcodes
[i
].name
;
8283 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
8284 if (retval
!= NULL
&& *retval
!= '\0')
8286 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
8292 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
8293 != pa_opcodes
[i
].match
)
8295 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
8296 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
8301 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
8305 as_fatal (_("Broken assembler. No assembly attempted."));
8308 /* SOM will change text_section. To make sure we never put
8309 anything into the old one switch to the new one now. */
8310 subseg_set (text_section
, 0);
8314 dummy_symbol
= symbol_find_or_make ("L$dummy");
8315 S_SET_SEGMENT (dummy_symbol
, text_section
);
8316 /* Force the symbol to be converted to a real symbol. */
8317 (void) symbol_get_bfdsym (dummy_symbol
);
8321 /* On the PA relocations which involve function symbols must not be
8322 adjusted. This so that the linker can know when/how to create argument
8323 relocation stubs for indirect calls and calls to static functions.
8325 "T" field selectors create DLT relative fixups for accessing
8326 globals and statics in PIC code; each DLT relative fixup creates
8327 an entry in the DLT table. The entries contain the address of
8328 the final target (eg accessing "foo" would create a DLT entry
8329 with the address of "foo").
8331 Unfortunately, the HP linker doesn't take into account any addend
8332 when generating the DLT; so accessing $LIT$+8 puts the address of
8333 $LIT$ into the DLT rather than the address of $LIT$+8.
8335 The end result is we can't perform relocation symbol reductions for
8336 any fixup which creates entries in the DLT (eg they use "T" field
8339 ??? Reject reductions involving symbols with external scope; such
8340 reductions make life a living hell for object file editors. */
8343 hppa_fix_adjustable (fixS
*fixp
)
8348 struct hppa_fix_struct
*hppa_fix
;
8350 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8353 /* LR/RR selectors are implicitly used for a number of different relocation
8354 types. We must ensure that none of these types are adjusted (see below)
8355 even if they occur with a different selector. */
8356 code
= elf_hppa_reloc_final_type (stdoutput
, fixp
->fx_r_type
,
8357 hppa_fix
->fx_r_format
,
8358 hppa_fix
->fx_r_field
);
8362 /* Relocation types which use e_lrsel. */
8363 case R_PARISC_DIR21L
:
8364 case R_PARISC_DLTREL21L
:
8365 case R_PARISC_DPREL21L
:
8366 case R_PARISC_PLTOFF21L
:
8368 /* Relocation types which use e_rrsel. */
8369 case R_PARISC_DIR14R
:
8370 case R_PARISC_DIR14DR
:
8371 case R_PARISC_DIR14WR
:
8372 case R_PARISC_DIR17R
:
8373 case R_PARISC_DLTREL14R
:
8374 case R_PARISC_DLTREL14DR
:
8375 case R_PARISC_DLTREL14WR
:
8376 case R_PARISC_DPREL14R
:
8377 case R_PARISC_DPREL14DR
:
8378 case R_PARISC_DPREL14WR
:
8379 case R_PARISC_PLTOFF14R
:
8380 case R_PARISC_PLTOFF14DR
:
8381 case R_PARISC_PLTOFF14WR
:
8383 /* Other types that we reject for reduction. */
8384 case R_PARISC_GNU_VTENTRY
:
8385 case R_PARISC_GNU_VTINHERIT
:
8392 /* Reject reductions of symbols in sym1-sym2 expressions when
8393 the fixup will occur in a CODE subspace.
8395 XXX FIXME: Long term we probably want to reject all of these;
8396 for example reducing in the debug section would lose if we ever
8397 supported using the optimizing hp linker. */
8400 && (hppa_fix
->segment
->flags
& SEC_CODE
))
8403 /* We can't adjust any relocs that use LR% and RR% field selectors.
8405 If a symbol is reduced to a section symbol, the assembler will
8406 adjust the addend unless the symbol happens to reside right at
8407 the start of the section. Additionally, the linker has no choice
8408 but to manipulate the addends when coalescing input sections for
8409 "ld -r". Since an LR% field selector is defined to round the
8410 addend, we can't change the addend without risking that a LR% and
8411 it's corresponding (possible multiple) RR% field will no longer
8412 sum to the right value.
8415 . ldil LR%foo+0,%r21
8416 . ldw RR%foo+0(%r21),%r26
8417 . ldw RR%foo+4(%r21),%r25
8419 If foo is at address 4092 (decimal) in section `sect', then after
8420 reducing to the section symbol we get
8421 . LR%sect+4092 == (L%sect)+0
8422 . RR%sect+4092 == (R%sect)+4092
8423 . RR%sect+4096 == (R%sect)-4096
8424 and the last address loses because rounding the addend to 8k
8425 multiples takes us up to 8192 with an offset of -4096.
8427 In cases where the LR% expression is identical to the RR% one we
8428 will never have a problem, but is so happens that gcc rounds
8429 addends involved in LR% field selectors to work around a HP
8430 linker bug. ie. We often have addresses like the last case
8431 above where the LR% expression is offset from the RR% one. */
8433 if (hppa_fix
->fx_r_field
== e_lrsel
8434 || hppa_fix
->fx_r_field
== e_rrsel
8435 || hppa_fix
->fx_r_field
== e_nlrsel
)
8438 /* Reject reductions of symbols in DLT relative relocs,
8439 relocations with plabels. */
8440 if (hppa_fix
->fx_r_field
== e_tsel
8441 || hppa_fix
->fx_r_field
== e_ltsel
8442 || hppa_fix
->fx_r_field
== e_rtsel
8443 || hppa_fix
->fx_r_field
== e_psel
8444 || hppa_fix
->fx_r_field
== e_rpsel
8445 || hppa_fix
->fx_r_field
== e_lpsel
)
8448 /* Reject absolute calls (jumps). */
8449 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
8452 /* Reject reductions of function symbols. */
8453 if (fixp
->fx_addsy
!= 0 && S_IS_FUNCTION (fixp
->fx_addsy
))
8459 /* Return nonzero if the fixup in FIXP will require a relocation,
8460 even it if appears that the fixup could be completely handled
8464 hppa_force_relocation (struct fix
*fixp
)
8466 struct hppa_fix_struct
*hppa_fixp
;
8468 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8470 if (fixp
->fx_r_type
== (int) R_HPPA_ENTRY
8471 || fixp
->fx_r_type
== (int) R_HPPA_EXIT
8472 || fixp
->fx_r_type
== (int) R_HPPA_BEGIN_BRTAB
8473 || fixp
->fx_r_type
== (int) R_HPPA_END_BRTAB
8474 || fixp
->fx_r_type
== (int) R_HPPA_BEGIN_TRY
8475 || fixp
->fx_r_type
== (int) R_HPPA_END_TRY
8476 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
8477 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
8481 if (fixp
->fx_r_type
== (int) R_PARISC_GNU_VTINHERIT
8482 || fixp
->fx_r_type
== (int) R_PARISC_GNU_VTENTRY
)
8486 assert (fixp
->fx_addsy
!= NULL
);
8488 /* Ensure we emit a relocation for global symbols so that dynamic
8490 if (S_FORCE_RELOC (fixp
->fx_addsy
, 1))
8493 /* It is necessary to force PC-relative calls/jumps to have a relocation
8494 entry if they're going to need either an argument relocation or long
8497 && arg_reloc_stub_needed (symbol_arg_reloc_info (fixp
->fx_addsy
),
8498 hppa_fixp
->fx_arg_reloc
))
8501 /* Now check to see if we're going to need a long-branch stub. */
8502 if (fixp
->fx_r_type
== (int) R_HPPA_PCREL_CALL
)
8504 long pc
= md_pcrel_from (fixp
);
8505 valueT distance
, min_stub_distance
;
8507 distance
= fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
) - pc
- 8;
8509 /* Distance to the closest possible stub. This will detect most
8510 but not all circumstances where a stub will not work. */
8511 min_stub_distance
= pc
+ 16;
8513 if (last_call_info
!= NULL
)
8514 min_stub_distance
-= S_GET_VALUE (last_call_info
->start_symbol
);
8517 if ((distance
+ 8388608 >= 16777216
8518 && min_stub_distance
<= 8388608)
8519 || (hppa_fixp
->fx_r_format
== 17
8520 && distance
+ 262144 >= 524288
8521 && min_stub_distance
<= 262144)
8522 || (hppa_fixp
->fx_r_format
== 12
8523 && distance
+ 8192 >= 16384
8524 && min_stub_distance
<= 8192)
8529 if (fixp
->fx_r_type
== (int) R_HPPA_ABS_CALL
)
8532 /* No need (yet) to force another relocations to be emitted. */
8536 /* Now for some ELF specific code. FIXME. */
8538 /* For ELF, this function serves one purpose: to setup the st_size
8539 field of STT_FUNC symbols. To do this, we need to scan the
8540 call_info structure list, determining st_size in by taking the
8541 difference in the address of the beginning/end marker symbols. */
8544 elf_hppa_final_processing (void)
8546 struct call_info
*call_info_pointer
;
8548 for (call_info_pointer
= call_info_root
;
8550 call_info_pointer
= call_info_pointer
->ci_next
)
8552 elf_symbol_type
*esym
8553 = ((elf_symbol_type
*)
8554 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
8555 esym
->internal_elf_sym
.st_size
=
8556 S_GET_VALUE (call_info_pointer
->end_symbol
)
8557 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;
8562 pa_vtable_entry (int ignore ATTRIBUTE_UNUSED
)
8564 struct fix
*new_fix
;
8566 new_fix
= obj_elf_vtable_entry (0);
8570 struct hppa_fix_struct
* hppa_fix
= obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
8572 hppa_fix
->fx_r_type
= R_HPPA
;
8573 hppa_fix
->fx_r_field
= e_fsel
;
8574 hppa_fix
->fx_r_format
= 32;
8575 hppa_fix
->fx_arg_reloc
= 0;
8576 hppa_fix
->segment
= now_seg
;
8577 new_fix
->tc_fix_data
= (void *) hppa_fix
;
8578 new_fix
->fx_r_type
= (int) R_PARISC_GNU_VTENTRY
;
8583 pa_vtable_inherit (int ignore ATTRIBUTE_UNUSED
)
8585 struct fix
*new_fix
;
8587 new_fix
= obj_elf_vtable_inherit (0);
8591 struct hppa_fix_struct
* hppa_fix
= obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
8593 hppa_fix
->fx_r_type
= R_HPPA
;
8594 hppa_fix
->fx_r_field
= e_fsel
;
8595 hppa_fix
->fx_r_format
= 32;
8596 hppa_fix
->fx_arg_reloc
= 0;
8597 hppa_fix
->segment
= now_seg
;
8598 new_fix
->tc_fix_data
= (void *) hppa_fix
;
8599 new_fix
->fx_r_type
= (int) R_PARISC_GNU_VTINHERIT
;
8604 /* Table of pseudo ops for the PA. FIXME -- how many of these
8605 are now redundant with the overall GAS and the object file
8606 dependent tables? */
8607 const pseudo_typeS md_pseudo_table
[] =
8609 /* align pseudo-ops on the PA specify the actual alignment requested,
8610 not the log2 of the requested alignment. */
8612 {"align", pa_align
, 8},
8615 {"align", s_align_bytes
, 8},
8617 {"begin_brtab", pa_brtab
, 1},
8618 {"begin_try", pa_try
, 1},
8619 {"block", pa_block
, 1},
8620 {"blockz", pa_block
, 0},
8621 {"byte", pa_cons
, 1},
8622 {"call", pa_call
, 0},
8623 {"callinfo", pa_callinfo
, 0},
8624 #if defined (OBJ_ELF) && (defined (TE_LINUX) || defined (TE_NetBSD))
8625 {"code", obj_elf_text
, 0},
8627 {"code", pa_text
, 0},
8628 {"comm", pa_comm
, 0},
8631 {"compiler", pa_compiler
, 0},
8633 {"copyright", pa_copyright
, 0},
8634 #if !(defined (OBJ_ELF) && (defined (TE_LINUX) || defined (TE_NetBSD)))
8635 {"data", pa_data
, 0},
8637 {"double", pa_float_cons
, 'd'},
8638 {"dword", pa_cons
, 8},
8640 {"end_brtab", pa_brtab
, 0},
8641 #if !(defined (OBJ_ELF) && (defined (TE_LINUX) || defined (TE_NetBSD)))
8642 {"end_try", pa_try
, 0},
8644 {"enter", pa_enter
, 0},
8645 {"entry", pa_entry
, 0},
8647 {"exit", pa_exit
, 0},
8648 {"export", pa_export
, 0},
8649 {"fill", pa_fill
, 0},
8650 {"float", pa_float_cons
, 'f'},
8651 {"half", pa_cons
, 2},
8652 {"import", pa_import
, 0},
8653 {"int", pa_cons
, 4},
8654 {"label", pa_label
, 0},
8655 {"lcomm", pa_lcomm
, 0},
8656 {"leave", pa_leave
, 0},
8657 {"level", pa_level
, 0},
8658 {"long", pa_cons
, 4},
8659 {"lsym", pa_lsym
, 0},
8661 {"nsubspa", pa_subspace
, 1},
8663 {"octa", pa_cons
, 16},
8664 {"org", pa_origin
, 0},
8665 {"origin", pa_origin
, 0},
8666 {"param", pa_param
, 0},
8667 {"proc", pa_proc
, 0},
8668 {"procend", pa_procend
, 0},
8669 {"quad", pa_cons
, 8},
8671 {"short", pa_cons
, 2},
8672 {"single", pa_float_cons
, 'f'},
8674 {"space", pa_space
, 0},
8675 {"spnum", pa_spnum
, 0},
8677 {"string", pa_stringer
, 0},
8678 {"stringz", pa_stringer
, 1},
8680 {"subspa", pa_subspace
, 0},
8682 #if !(defined (OBJ_ELF) && (defined (TE_LINUX) || defined (TE_NetBSD)))
8683 {"text", pa_text
, 0},
8685 {"version", pa_version
, 0},
8687 {"vtable_entry", pa_vtable_entry
, 0},
8688 {"vtable_inherit", pa_vtable_inherit
, 0},
8690 {"word", pa_cons
, 4},