1 /* tc-hppa.c -- Assemble for the PA
2 Copyright 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 /* HP PA-RISC support was contributed by the Center for Software Science
23 at the University of Utah. */
31 #include "bfd/libhppa.h"
33 /* Be careful, this file includes data *declarations*. */
34 #include "opcode/hppa.h"
36 #if defined (OBJ_ELF) && defined (OBJ_SOM)
37 error only one of OBJ_ELF
and OBJ_SOM can be defined
40 /* If we are using ELF, then we probably can support dwarf2 debug
41 records. Furthermore, if we are supporting dwarf2 debug records,
42 then we want to use the assembler support for compact line numbers. */
44 #include "dwarf2dbg.h"
46 /* A "convient" place to put object file dependencies which do
47 not need to be seen outside of tc-hppa.c. */
49 /* Object file formats specify relocation types. */
50 typedef enum elf_hppa_reloc_type reloc_type
;
52 /* Object file formats specify BFD symbol types. */
53 typedef elf_symbol_type obj_symbol_type
;
54 #define symbol_arg_reloc_info(sym)\
55 (((obj_symbol_type *) symbol_get_bfdsym (sym))->tc_data.hppa_arg_reloc)
57 #if TARGET_ARCH_SIZE == 64
58 /* How to generate a relocation. */
59 #define hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
61 #define hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_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 /* Various structures and types used internally in tc-hppa.c. */
110 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
114 unsigned int cannot_unwind
:1;
115 unsigned int millicode
:1;
116 unsigned int millicode_save_rest
:1;
117 unsigned int region_desc
:2;
118 unsigned int save_sr
:2;
119 unsigned int entry_fr
:4;
120 unsigned int entry_gr
:5;
121 unsigned int args_stored
:1;
122 unsigned int call_fr
:5;
123 unsigned int call_gr
:5;
124 unsigned int save_sp
:1;
125 unsigned int save_rp
:1;
126 unsigned int save_rp_in_frame
:1;
127 unsigned int extn_ptr_defined
:1;
128 unsigned int cleanup_defined
:1;
130 unsigned int hpe_interrupt_marker
:1;
131 unsigned int hpux_interrupt_marker
:1;
132 unsigned int reserved
:3;
133 unsigned int frame_size
:27;
136 /* We can't rely on compilers placing bitfields in any particular
137 place, so use these macros when dumping unwind descriptors to
139 #define UNWIND_LOW32(U) \
140 (((U)->cannot_unwind << 31) \
141 | ((U)->millicode << 30) \
142 | ((U)->millicode_save_rest << 29) \
143 | ((U)->region_desc << 27) \
144 | ((U)->save_sr << 25) \
145 | ((U)->entry_fr << 21) \
146 | ((U)->entry_gr << 16) \
147 | ((U)->args_stored << 15) \
148 | ((U)->call_fr << 10) \
149 | ((U)->call_gr << 5) \
150 | ((U)->save_sp << 4) \
151 | ((U)->save_rp << 3) \
152 | ((U)->save_rp_in_frame << 2) \
153 | ((U)->extn_ptr_defined << 1) \
154 | ((U)->cleanup_defined << 0))
156 #define UNWIND_HIGH32(U) \
157 (((U)->hpe_interrupt_marker << 31) \
158 | ((U)->hpux_interrupt_marker << 30) \
159 | ((U)->frame_size << 0))
163 /* Starting and ending offsets of the region described by
165 unsigned int start_offset
;
166 unsigned int end_offset
;
167 struct unwind_desc descriptor
;
170 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
171 control the entry and exit code they generate. It is also used in
172 creation of the correct stack unwind descriptors.
174 NOTE: GAS does not support .enter and .leave for the generation of
175 prologues and epilogues. FIXME.
177 The fields in structure roughly correspond to the arguments available on the
178 .callinfo pseudo-op. */
182 /* The unwind descriptor being built. */
183 struct unwind_table ci_unwind
;
185 /* Name of this function. */
186 symbolS
*start_symbol
;
188 /* (temporary) symbol used to mark the end of this function. */
191 /* Next entry in the chain. */
192 struct call_info
*ci_next
;
195 /* Operand formats for FP instructions. Note not all FP instructions
196 allow all four formats to be used (for example fmpysub only allows
200 SGL
, DBL
, ILLEGAL_FMT
, QUAD
, W
, UW
, DW
, UDW
, QW
, UQW
204 /* This fully describes the symbol types which may be attached to
205 an EXPORT or IMPORT directive. Only SOM uses this formation
206 (ELF has no need for it). */
210 SYMBOL_TYPE_ABSOLUTE
,
214 SYMBOL_TYPE_MILLICODE
,
216 SYMBOL_TYPE_PRI_PROG
,
217 SYMBOL_TYPE_SEC_PROG
,
221 /* This structure contains information needed to assemble
222 individual instructions. */
225 /* Holds the opcode after parsing by pa_ip. */
226 unsigned long opcode
;
228 /* Holds an expression associated with the current instruction. */
231 /* Does this instruction use PC-relative addressing. */
234 /* Floating point formats for operand1 and operand2. */
235 fp_operand_format fpof1
;
236 fp_operand_format fpof2
;
238 /* Whether or not we saw a truncation request on an fcnv insn. */
241 /* Holds the field selector for this instruction
242 (for example L%, LR%, etc). */
245 /* Holds any argument relocation bits associated with this
246 instruction. (instruction should be some sort of call). */
247 unsigned int arg_reloc
;
249 /* The format specification for this instruction. */
252 /* The relocation (if any) associated with this instruction. */
256 /* PA-89 floating point registers are arranged like this:
258 +--------------+--------------+
259 | 0 or 16L | 16 or 16R |
260 +--------------+--------------+
261 | 1 or 17L | 17 or 17R |
262 +--------------+--------------+
270 +--------------+--------------+
271 | 14 or 30L | 30 or 30R |
272 +--------------+--------------+
273 | 15 or 31L | 31 or 31R |
274 +--------------+--------------+ */
276 /* Additional information needed to build argument relocation stubs. */
279 /* The argument relocation specification. */
280 unsigned int arg_reloc
;
282 /* Number of arguments. */
283 unsigned int arg_count
;
287 /* This structure defines an entry in the subspace dictionary
290 struct subspace_dictionary_chain
292 /* Nonzero if this space has been defined by the user code. */
293 unsigned int ssd_defined
;
295 /* Name of this subspace. */
298 /* GAS segment and subsegment associated with this subspace. */
302 /* Next space in the subspace dictionary chain. */
303 struct subspace_dictionary_chain
*ssd_next
;
306 typedef struct subspace_dictionary_chain ssd_chain_struct
;
308 /* This structure defines an entry in the subspace dictionary
311 struct space_dictionary_chain
313 /* Nonzero if this space has been defined by the user code or
314 as a default space. */
315 unsigned int sd_defined
;
317 /* Nonzero if this spaces has been defined by the user code. */
318 unsigned int sd_user_defined
;
320 /* The space number (or index). */
321 unsigned int sd_spnum
;
323 /* The name of this subspace. */
326 /* GAS segment to which this subspace corresponds. */
329 /* Current subsegment number being used. */
332 /* The chain of subspaces contained within this space. */
333 ssd_chain_struct
*sd_subspaces
;
335 /* The next entry in the space dictionary chain. */
336 struct space_dictionary_chain
*sd_next
;
339 typedef struct space_dictionary_chain sd_chain_struct
;
341 /* This structure defines attributes of the default subspace
342 dictionary entries. */
344 struct default_subspace_dict
346 /* Name of the subspace. */
349 /* FIXME. Is this still needed? */
352 /* Nonzero if this subspace is loadable. */
355 /* Nonzero if this subspace contains only code. */
358 /* Nonzero if this is a common subspace. */
361 /* Nonzero if this is a common subspace which allows symbols
362 to be multiply defined. */
365 /* Nonzero if this subspace should be zero filled. */
368 /* Sort key for this subspace. */
371 /* Access control bits for this subspace. Can represent RWX access
372 as well as privilege level changes for gateways. */
375 /* Index of containing space. */
378 /* Alignment (in bytes) of this subspace. */
381 /* Quadrant within space where this subspace should be loaded. */
384 /* An index into the default spaces array. */
387 /* Subsegment associated with this subspace. */
391 /* This structure defines attributes of the default space
392 dictionary entries. */
394 struct default_space_dict
396 /* Name of the space. */
399 /* Space number. It is possible to identify spaces within
400 assembly code numerically! */
403 /* Nonzero if this space is loadable. */
406 /* Nonzero if this space is "defined". FIXME is still needed */
409 /* Nonzero if this space can not be shared. */
412 /* Sort key for this space. */
415 /* Segment associated with this space. */
420 /* Structure for previous label tracking. Needed so that alignments,
421 callinfo declarations, etc can be easily attached to a particular
423 typedef struct label_symbol_struct
425 struct symbol
*lss_label
;
427 sd_chain_struct
*lss_space
;
432 struct label_symbol_struct
*lss_next
;
436 /* Extra information needed to perform fixups (relocations) on the PA. */
437 struct hppa_fix_struct
439 /* The field selector. */
440 enum hppa_reloc_field_selector_type_alt fx_r_field
;
445 /* Format of fixup. */
448 /* Argument relocation bits. */
449 unsigned int fx_arg_reloc
;
451 /* The segment this fixup appears in. */
455 /* Structure to hold information about predefined registers. */
463 /* This structure defines the mapping from a FP condition string
464 to a condition number which can be recorded in an instruction. */
471 /* This structure defines a mapping from a field selector
472 string to a field selector type. */
473 struct selector_entry
479 /* Prototypes for functions local to tc-hppa.c. */
482 static void pa_check_current_space_and_subspace
PARAMS ((void));
485 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
486 static void pa_text
PARAMS ((int));
487 static void pa_data
PARAMS ((int));
488 static void pa_comm
PARAMS ((int));
490 static fp_operand_format pa_parse_fp_format
PARAMS ((char **s
));
491 static void pa_cons
PARAMS ((int));
492 static void pa_float_cons
PARAMS ((int));
493 static void pa_fill
PARAMS ((int));
494 static void pa_lcomm
PARAMS ((int));
495 static void pa_lsym
PARAMS ((int));
496 static void pa_stringer
PARAMS ((int));
497 static void pa_version
PARAMS ((int));
498 static int pa_parse_fp_cmp_cond
PARAMS ((char **));
499 static int get_expression
PARAMS ((char *));
500 static int pa_get_absolute_expression
PARAMS ((struct pa_it
*, char **));
501 static int evaluate_absolute
PARAMS ((struct pa_it
*));
502 static unsigned int pa_build_arg_reloc
PARAMS ((char *));
503 static unsigned int pa_align_arg_reloc
PARAMS ((unsigned int, unsigned int));
504 static int pa_parse_nullif
PARAMS ((char **));
505 static int pa_parse_nonneg_cmpsub_cmpltr
PARAMS ((char **, int));
506 static int pa_parse_neg_cmpsub_cmpltr
PARAMS ((char **, int));
507 static int pa_parse_neg_add_cmpltr
PARAMS ((char **, int));
508 static int pa_parse_nonneg_add_cmpltr
PARAMS ((char **, int));
509 static int pa_parse_cmpb_64_cmpltr
PARAMS ((char **));
510 static int pa_parse_cmpib_64_cmpltr
PARAMS ((char **));
511 static int pa_parse_addb_64_cmpltr
PARAMS ((char **));
512 static void pa_block
PARAMS ((int));
513 static void pa_brtab
PARAMS ((int));
514 static void pa_try
PARAMS ((int));
515 static void pa_call
PARAMS ((int));
516 static void pa_call_args
PARAMS ((struct call_desc
*));
517 static void pa_callinfo
PARAMS ((int));
518 static void pa_copyright
PARAMS ((int));
519 static void pa_end
PARAMS ((int));
520 static void pa_enter
PARAMS ((int));
521 static void pa_entry
PARAMS ((int));
522 static void pa_equ
PARAMS ((int));
523 static void pa_exit
PARAMS ((int));
524 static void pa_export
PARAMS ((int));
525 static void pa_type_args
PARAMS ((symbolS
*, int));
526 static void pa_import
PARAMS ((int));
527 static void pa_label
PARAMS ((int));
528 static void pa_leave
PARAMS ((int));
529 static void pa_level
PARAMS ((int));
530 static void pa_origin
PARAMS ((int));
531 static void pa_proc
PARAMS ((int));
532 static void pa_procend
PARAMS ((int));
533 static void pa_param
PARAMS ((int));
534 static void pa_undefine_label
PARAMS ((void));
535 static int need_pa11_opcode
PARAMS ((void));
536 static int pa_parse_number
PARAMS ((char **, int));
537 static label_symbol_struct
*pa_get_label
PARAMS ((void));
539 static int log2
PARAMS ((int));
540 static void pa_compiler
PARAMS ((int));
541 static void pa_align
PARAMS ((int));
542 static void pa_space
PARAMS ((int));
543 static void pa_spnum
PARAMS ((int));
544 static void pa_subspace
PARAMS ((int));
545 static sd_chain_struct
*create_new_space
PARAMS ((char *, int, int,
548 static ssd_chain_struct
*create_new_subspace
PARAMS ((sd_chain_struct
*,
553 static ssd_chain_struct
*update_subspace
PARAMS ((sd_chain_struct
*,
554 char *, int, int, int,
558 static sd_chain_struct
*is_defined_space
PARAMS ((char *));
559 static ssd_chain_struct
*is_defined_subspace
PARAMS ((char *));
560 static sd_chain_struct
*pa_segment_to_space
PARAMS ((asection
*));
561 static ssd_chain_struct
*pa_subsegment_to_subspace
PARAMS ((asection
*,
563 static sd_chain_struct
*pa_find_space_by_number
PARAMS ((int));
564 static unsigned int pa_subspace_start
PARAMS ((sd_chain_struct
*, int));
565 static sd_chain_struct
*pa_parse_space_stmt
PARAMS ((char *, int));
566 static int pa_next_subseg
PARAMS ((sd_chain_struct
*));
567 static void pa_spaces_begin
PARAMS ((void));
569 static void pa_ip
PARAMS ((char *));
570 static void fix_new_hppa
PARAMS ((fragS
*, int, int, symbolS
*,
571 offsetT
, expressionS
*, int,
572 bfd_reloc_code_real_type
,
573 enum hppa_reloc_field_selector_type_alt
,
574 int, unsigned int, int));
575 static int is_end_of_statement
PARAMS ((void));
576 static int reg_name_search
PARAMS ((char *));
577 static int pa_chk_field_selector
PARAMS ((char **));
578 static int is_same_frag
PARAMS ((fragS
*, fragS
*));
579 static void process_exit
PARAMS ((void));
580 static unsigned int pa_stringer_aux
PARAMS ((char *));
581 static fp_operand_format pa_parse_fp_cnv_format
PARAMS ((char **s
));
582 static int pa_parse_ftest_gfx_completer
PARAMS ((char **));
585 static void hppa_elf_mark_end_of_function
PARAMS ((void));
586 static void pa_build_unwind_subspace
PARAMS ((struct call_info
*));
587 static void pa_vtable_entry
PARAMS ((int));
588 static void pa_vtable_inherit
PARAMS ((int));
591 /* File and gloally scoped variable declarations. */
594 /* Root and final entry in the space chain. */
595 static sd_chain_struct
*space_dict_root
;
596 static sd_chain_struct
*space_dict_last
;
598 /* The current space and subspace. */
599 static sd_chain_struct
*current_space
;
600 static ssd_chain_struct
*current_subspace
;
603 /* Root of the call_info chain. */
604 static struct call_info
*call_info_root
;
606 /* The last call_info (for functions) structure
607 seen so it can be associated with fixups and
609 static struct call_info
*last_call_info
;
611 /* The last call description (for actual calls). */
612 static struct call_desc last_call_desc
;
614 /* handle of the OPCODE hash table */
615 static struct hash_control
*op_hash
= NULL
;
617 /* Table of pseudo ops for the PA. FIXME -- how many of these
618 are now redundant with the overall GAS and the object file
620 const pseudo_typeS md_pseudo_table
[] =
622 /* align pseudo-ops on the PA specify the actual alignment requested,
623 not the log2 of the requested alignment. */
625 {"align", pa_align
, 8},
628 {"align", s_align_bytes
, 8},
630 {"begin_brtab", pa_brtab
, 1},
631 {"begin_try", pa_try
, 1},
632 {"block", pa_block
, 1},
633 {"blockz", pa_block
, 0},
634 {"byte", pa_cons
, 1},
635 {"call", pa_call
, 0},
636 {"callinfo", pa_callinfo
, 0},
637 #if defined (OBJ_ELF) && defined (TE_LINUX)
638 {"code", obj_elf_text
, 0},
640 {"code", pa_text
, 0},
641 {"comm", pa_comm
, 0},
644 {"compiler", pa_compiler
, 0},
646 {"copyright", pa_copyright
, 0},
647 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
648 {"data", pa_data
, 0},
650 {"double", pa_float_cons
, 'd'},
651 {"dword", pa_cons
, 8},
653 {"end_brtab", pa_brtab
, 0},
654 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
655 {"end_try", pa_try
, 0},
657 {"enter", pa_enter
, 0},
658 {"entry", pa_entry
, 0},
660 {"exit", pa_exit
, 0},
661 {"export", pa_export
, 0},
663 {"file", dwarf2_directive_file
, 0 },
665 {"fill", pa_fill
, 0},
666 {"float", pa_float_cons
, 'f'},
667 {"half", pa_cons
, 2},
668 {"import", pa_import
, 0},
670 {"label", pa_label
, 0},
671 {"lcomm", pa_lcomm
, 0},
672 {"leave", pa_leave
, 0},
673 {"level", pa_level
, 0},
675 {"loc", dwarf2_directive_loc
, 0 },
677 {"long", pa_cons
, 4},
678 {"lsym", pa_lsym
, 0},
680 {"nsubspa", pa_subspace
, 1},
682 {"octa", pa_cons
, 16},
683 {"org", pa_origin
, 0},
684 {"origin", pa_origin
, 0},
685 {"param", pa_param
, 0},
686 {"proc", pa_proc
, 0},
687 {"procend", pa_procend
, 0},
688 {"quad", pa_cons
, 8},
690 {"short", pa_cons
, 2},
691 {"single", pa_float_cons
, 'f'},
693 {"space", pa_space
, 0},
694 {"spnum", pa_spnum
, 0},
696 {"string", pa_stringer
, 0},
697 {"stringz", pa_stringer
, 1},
699 {"subspa", pa_subspace
, 0},
701 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
702 {"text", pa_text
, 0},
704 {"version", pa_version
, 0},
706 {"vtable_entry", pa_vtable_entry
, 0},
707 {"vtable_inherit", pa_vtable_inherit
, 0},
709 {"word", pa_cons
, 4},
713 /* This array holds the chars that only start a comment at the beginning of
714 a line. If the line seems to have the form '# 123 filename'
715 .line and .file directives will appear in the pre-processed output.
717 Note that input_file.c hand checks for '#' at the beginning of the
718 first line of the input file. This is because the compiler outputs
719 #NO_APP at the beginning of its output.
721 Also note that C style comments will always work. */
722 const char line_comment_chars
[] = "#";
724 /* This array holds the chars that always start a comment. If the
725 pre-processor is disabled, these aren't very useful. */
726 const char comment_chars
[] = ";";
728 /* This array holds the characters which act as line separators. */
729 const char line_separator_chars
[] = "!";
731 /* Chars that can be used to separate mant from exp in floating point nums. */
732 const char EXP_CHARS
[] = "eE";
734 /* Chars that mean this number is a floating point constant.
735 As in 0f12.456 or 0d1.2345e12.
737 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
738 changed in read.c. Ideally it shouldn't hae to know abou it at
739 all, but nothing is ideal around here. */
740 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
742 static struct pa_it the_insn
;
744 /* Points to the end of an expression just parsed by get_expressoin
745 and friends. FIXME. This shouldn't be handled with a file-global
747 static char *expr_end
;
749 /* Nonzero if a .callinfo appeared within the current procedure. */
750 static int callinfo_found
;
752 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
753 static int within_entry_exit
;
755 /* Nonzero if the assembler is currently within a procedure definition. */
756 static int within_procedure
;
758 /* Handle on structure which keep track of the last symbol
759 seen in each subspace. */
760 static label_symbol_struct
*label_symbols_rootp
= NULL
;
762 /* Holds the last field selector. */
763 static int hppa_field_selector
;
765 /* Nonzero when strict syntax checking is enabled. Zero otherwise.
767 Each opcode in the table has a flag which indicates whether or not
768 strict syntax checking should be enabled for that instruction. */
769 static int strict
= 0;
771 /* pa_parse_number returns values in `pa_number'. Mostly
772 pa_parse_number is used to return a register number, with floating
773 point registers being numbered from FP_REG_BASE upwards.
774 The bit specified with FP_REG_RSEL is set if the floating point
775 register has a `r' suffix. */
776 #define FP_REG_BASE 64
777 #define FP_REG_RSEL 128
778 static int pa_number
;
781 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
782 static symbolS
*dummy_symbol
;
785 /* Nonzero if errors are to be printed. */
786 static int print_errors
= 1;
788 /* List of registers that are pre-defined:
790 Each general register has one predefined name of the form
791 %r<REGNUM> which has the value <REGNUM>.
793 Space and control registers are handled in a similar manner,
794 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
796 Likewise for the floating point registers, but of the form
797 %fr<REGNUM>. Floating point registers have additional predefined
798 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
799 again have the value <REGNUM>.
801 Many registers also have synonyms:
803 %r26 - %r23 have %arg0 - %arg3 as synonyms
804 %r28 - %r29 have %ret0 - %ret1 as synonyms
805 %r30 has %sp as a synonym
806 %r27 has %dp as a synonym
807 %r2 has %rp as a synonym
809 Almost every control register has a synonym; they are not listed
812 The table is sorted. Suitable for searching by a binary search. */
814 static const struct pd_reg pre_defined_registers
[] =
848 {"%fr0", 0 + FP_REG_BASE
},
849 {"%fr0l", 0 + FP_REG_BASE
},
850 {"%fr0r", 0 + FP_REG_BASE
+ FP_REG_RSEL
},
851 {"%fr1", 1 + FP_REG_BASE
},
852 {"%fr10", 10 + FP_REG_BASE
},
853 {"%fr10l", 10 + FP_REG_BASE
},
854 {"%fr10r", 10 + FP_REG_BASE
+ FP_REG_RSEL
},
855 {"%fr11", 11 + FP_REG_BASE
},
856 {"%fr11l", 11 + FP_REG_BASE
},
857 {"%fr11r", 11 + FP_REG_BASE
+ FP_REG_RSEL
},
858 {"%fr12", 12 + FP_REG_BASE
},
859 {"%fr12l", 12 + FP_REG_BASE
},
860 {"%fr12r", 12 + FP_REG_BASE
+ FP_REG_RSEL
},
861 {"%fr13", 13 + FP_REG_BASE
},
862 {"%fr13l", 13 + FP_REG_BASE
},
863 {"%fr13r", 13 + FP_REG_BASE
+ FP_REG_RSEL
},
864 {"%fr14", 14 + FP_REG_BASE
},
865 {"%fr14l", 14 + FP_REG_BASE
},
866 {"%fr14r", 14 + FP_REG_BASE
+ FP_REG_RSEL
},
867 {"%fr15", 15 + FP_REG_BASE
},
868 {"%fr15l", 15 + FP_REG_BASE
},
869 {"%fr15r", 15 + FP_REG_BASE
+ FP_REG_RSEL
},
870 {"%fr16", 16 + FP_REG_BASE
},
871 {"%fr16l", 16 + FP_REG_BASE
},
872 {"%fr16r", 16 + FP_REG_BASE
+ FP_REG_RSEL
},
873 {"%fr17", 17 + FP_REG_BASE
},
874 {"%fr17l", 17 + FP_REG_BASE
},
875 {"%fr17r", 17 + FP_REG_BASE
+ FP_REG_RSEL
},
876 {"%fr18", 18 + FP_REG_BASE
},
877 {"%fr18l", 18 + FP_REG_BASE
},
878 {"%fr18r", 18 + FP_REG_BASE
+ FP_REG_RSEL
},
879 {"%fr19", 19 + FP_REG_BASE
},
880 {"%fr19l", 19 + FP_REG_BASE
},
881 {"%fr19r", 19 + FP_REG_BASE
+ FP_REG_RSEL
},
882 {"%fr1l", 1 + FP_REG_BASE
},
883 {"%fr1r", 1 + FP_REG_BASE
+ FP_REG_RSEL
},
884 {"%fr2", 2 + FP_REG_BASE
},
885 {"%fr20", 20 + FP_REG_BASE
},
886 {"%fr20l", 20 + FP_REG_BASE
},
887 {"%fr20r", 20 + FP_REG_BASE
+ FP_REG_RSEL
},
888 {"%fr21", 21 + FP_REG_BASE
},
889 {"%fr21l", 21 + FP_REG_BASE
},
890 {"%fr21r", 21 + FP_REG_BASE
+ FP_REG_RSEL
},
891 {"%fr22", 22 + FP_REG_BASE
},
892 {"%fr22l", 22 + FP_REG_BASE
},
893 {"%fr22r", 22 + FP_REG_BASE
+ FP_REG_RSEL
},
894 {"%fr23", 23 + FP_REG_BASE
},
895 {"%fr23l", 23 + FP_REG_BASE
},
896 {"%fr23r", 23 + FP_REG_BASE
+ FP_REG_RSEL
},
897 {"%fr24", 24 + FP_REG_BASE
},
898 {"%fr24l", 24 + FP_REG_BASE
},
899 {"%fr24r", 24 + FP_REG_BASE
+ FP_REG_RSEL
},
900 {"%fr25", 25 + FP_REG_BASE
},
901 {"%fr25l", 25 + FP_REG_BASE
},
902 {"%fr25r", 25 + FP_REG_BASE
+ FP_REG_RSEL
},
903 {"%fr26", 26 + FP_REG_BASE
},
904 {"%fr26l", 26 + FP_REG_BASE
},
905 {"%fr26r", 26 + FP_REG_BASE
+ FP_REG_RSEL
},
906 {"%fr27", 27 + FP_REG_BASE
},
907 {"%fr27l", 27 + FP_REG_BASE
},
908 {"%fr27r", 27 + FP_REG_BASE
+ FP_REG_RSEL
},
909 {"%fr28", 28 + FP_REG_BASE
},
910 {"%fr28l", 28 + FP_REG_BASE
},
911 {"%fr28r", 28 + FP_REG_BASE
+ FP_REG_RSEL
},
912 {"%fr29", 29 + FP_REG_BASE
},
913 {"%fr29l", 29 + FP_REG_BASE
},
914 {"%fr29r", 29 + FP_REG_BASE
+ FP_REG_RSEL
},
915 {"%fr2l", 2 + FP_REG_BASE
},
916 {"%fr2r", 2 + FP_REG_BASE
+ FP_REG_RSEL
},
917 {"%fr3", 3 + FP_REG_BASE
},
918 {"%fr30", 30 + FP_REG_BASE
},
919 {"%fr30l", 30 + FP_REG_BASE
},
920 {"%fr30r", 30 + FP_REG_BASE
+ FP_REG_RSEL
},
921 {"%fr31", 31 + FP_REG_BASE
},
922 {"%fr31l", 31 + FP_REG_BASE
},
923 {"%fr31r", 31 + FP_REG_BASE
+ FP_REG_RSEL
},
924 {"%fr3l", 3 + FP_REG_BASE
},
925 {"%fr3r", 3 + FP_REG_BASE
+ FP_REG_RSEL
},
926 {"%fr4", 4 + FP_REG_BASE
},
927 {"%fr4l", 4 + FP_REG_BASE
},
928 {"%fr4r", 4 + FP_REG_BASE
+ FP_REG_RSEL
},
929 {"%fr5", 5 + FP_REG_BASE
},
930 {"%fr5l", 5 + FP_REG_BASE
},
931 {"%fr5r", 5 + FP_REG_BASE
+ FP_REG_RSEL
},
932 {"%fr6", 6 + FP_REG_BASE
},
933 {"%fr6l", 6 + FP_REG_BASE
},
934 {"%fr6r", 6 + FP_REG_BASE
+ FP_REG_RSEL
},
935 {"%fr7", 7 + FP_REG_BASE
},
936 {"%fr7l", 7 + FP_REG_BASE
},
937 {"%fr7r", 7 + FP_REG_BASE
+ FP_REG_RSEL
},
938 {"%fr8", 8 + FP_REG_BASE
},
939 {"%fr8l", 8 + FP_REG_BASE
},
940 {"%fr8r", 8 + FP_REG_BASE
+ FP_REG_RSEL
},
941 {"%fr9", 9 + FP_REG_BASE
},
942 {"%fr9l", 9 + FP_REG_BASE
},
943 {"%fr9r", 9 + FP_REG_BASE
+ FP_REG_RSEL
},
1014 /* This table is sorted by order of the length of the string. This is
1015 so we check for <> before we check for <. If we had a <> and checked
1016 for < first, we would get a false match. */
1017 static const struct fp_cond_map fp_cond_map
[] =
1053 static const struct selector_entry selector_table
[] =
1078 /* default space and subspace dictionaries */
1080 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1081 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1083 /* pre-defined subsegments (subspaces) for the HPPA. */
1084 #define SUBSEG_CODE 0
1085 #define SUBSEG_LIT 1
1086 #define SUBSEG_MILLI 2
1087 #define SUBSEG_DATA 0
1088 #define SUBSEG_BSS 2
1089 #define SUBSEG_UNWIND 3
1090 #define SUBSEG_GDB_STRINGS 0
1091 #define SUBSEG_GDB_SYMBOLS 1
1093 static struct default_subspace_dict pa_def_subspaces
[] =
1095 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE
},
1096 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA
},
1097 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT
},
1098 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI
},
1099 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS
},
1100 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1103 static struct default_space_dict pa_def_spaces
[] =
1105 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
},
1106 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
},
1107 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
}
1110 /* Misc local definitions used by the assembler. */
1112 /* These macros are used to maintain spaces/subspaces. */
1113 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1114 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1115 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1116 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1118 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1119 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1122 /* Return nonzero if the string pointed to by S potentially represents
1123 a right or left half of a FP register */
1124 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1125 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1127 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1128 main loop after insertion. */
1130 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1132 ((OPCODE) |= (FIELD) << (START)); \
1136 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1137 IGNORE is used to suppress the error message. */
1139 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1141 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1144 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1150 /* Simple alignment checking for FIELD againt ALIGN (a power of two).
1151 IGNORE is used to suppress the error message. */
1153 #define CHECK_ALIGN(FIELD, ALIGN, IGNORE) \
1155 if ((FIELD) & ((ALIGN) - 1)) \
1158 as_bad (_("Field not properly aligned [%d] (%d)."), (ALIGN), \
1164 #define is_DP_relative(exp) \
1165 ((exp).X_op == O_subtract \
1166 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1168 #define is_PC_relative(exp) \
1169 ((exp).X_op == O_subtract \
1170 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1172 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1173 always be able to reduce the expression to a constant, so we don't
1174 need real complex handling yet. */
1175 #define is_complex(exp) \
1176 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1178 /* Actual functions to implement the PA specific code for the assembler. */
1180 /* Called before writing the object file. Make sure entry/exit and
1181 proc/procend pairs match. */
1186 if (within_entry_exit
)
1187 as_fatal (_("Missing .exit\n"));
1189 if (within_procedure
)
1190 as_fatal (_("Missing .procend\n"));
1193 /* Returns a pointer to the label_symbol_struct for the current space.
1194 or NULL if no label_symbol_struct exists for the current space. */
1196 static label_symbol_struct
*
1199 label_symbol_struct
*label_chain
;
1201 for (label_chain
= label_symbols_rootp
;
1203 label_chain
= label_chain
->lss_next
)
1206 if (current_space
== label_chain
->lss_space
&& label_chain
->lss_label
)
1210 if (now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
)
1218 /* Defines a label for the current space. If one is already defined,
1219 this function will replace it with the new label. */
1222 pa_define_label (symbol
)
1225 label_symbol_struct
*label_chain
= pa_get_label ();
1228 label_chain
->lss_label
= symbol
;
1231 /* Create a new label entry and add it to the head of the chain. */
1233 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1234 label_chain
->lss_label
= symbol
;
1236 label_chain
->lss_space
= current_space
;
1239 label_chain
->lss_segment
= now_seg
;
1241 label_chain
->lss_next
= NULL
;
1243 if (label_symbols_rootp
)
1244 label_chain
->lss_next
= label_symbols_rootp
;
1246 label_symbols_rootp
= label_chain
;
1250 /* Removes a label definition for the current space.
1251 If there is no label_symbol_struct entry, then no action is taken. */
1254 pa_undefine_label ()
1256 label_symbol_struct
*label_chain
;
1257 label_symbol_struct
*prev_label_chain
= NULL
;
1259 for (label_chain
= label_symbols_rootp
;
1261 label_chain
= label_chain
->lss_next
)
1265 && current_space
== label_chain
->lss_space
&& label_chain
->lss_label
1268 && now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
1272 /* Remove the label from the chain and free its memory. */
1273 if (prev_label_chain
)
1274 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1276 label_symbols_rootp
= label_chain
->lss_next
;
1281 prev_label_chain
= label_chain
;
1285 /* An HPPA-specific version of fix_new. This is required because the HPPA
1286 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1287 results in the creation of an instance of an hppa_fix_struct. An
1288 hppa_fix_struct stores the extra information along with a pointer to the
1289 original fixS. This is attached to the original fixup via the
1290 tc_fix_data field. */
1293 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1294 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1298 symbolS
*add_symbol
;
1302 bfd_reloc_code_real_type r_type
;
1303 enum hppa_reloc_field_selector_type_alt r_field
;
1305 unsigned int arg_reloc
;
1306 int unwind_bits ATTRIBUTE_UNUSED
;
1310 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1311 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1314 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1316 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1317 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1318 hppa_fix
->fx_r_type
= r_type
;
1319 hppa_fix
->fx_r_field
= r_field
;
1320 hppa_fix
->fx_r_format
= r_format
;
1321 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1322 hppa_fix
->segment
= now_seg
;
1324 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1325 new_fix
->fx_offset
= unwind_bits
;
1328 /* foo-$global$ is used to access non-automatic storage. $global$
1329 is really just a marker and has served its purpose, so eliminate
1330 it now so as not to confuse write.c. Ditto for $PIC_pcrel$0. */
1331 if (new_fix
->fx_subsy
1332 && (strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$") == 0
1333 || strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$PIC_pcrel$0") == 0))
1334 new_fix
->fx_subsy
= NULL
;
1337 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1338 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1341 parse_cons_expression_hppa (exp
)
1344 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1348 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1349 hppa_field_selector is set by the parse_cons_expression_hppa. */
1352 cons_fix_new_hppa (frag
, where
, size
, exp
)
1358 unsigned int rel_type
;
1360 /* Get a base relocation type. */
1361 if (is_DP_relative (*exp
))
1362 rel_type
= R_HPPA_GOTOFF
;
1363 else if (is_complex (*exp
))
1364 rel_type
= R_HPPA_COMPLEX
;
1368 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1370 as_warn (_("Invalid field selector. Assuming F%%."));
1371 hppa_field_selector
= e_fsel
;
1374 fix_new_hppa (frag
, where
, size
,
1375 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1376 hppa_field_selector
, size
* 8, 0, 0);
1378 /* Reset field selector to its default state. */
1379 hppa_field_selector
= 0;
1382 /* This function is called once, at assembler startup time. It should
1383 set up all the tables, etc. that the MD part of the assembler will need. */
1388 const char *retval
= NULL
;
1392 last_call_info
= NULL
;
1393 call_info_root
= NULL
;
1395 /* Set the default machine type. */
1396 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1397 as_warn (_("could not set architecture and machine"));
1399 /* Folding of text and data segments fails miserably on the PA.
1400 Warn user and disable "-R" option. */
1401 if (flag_readonly_data_in_text
)
1403 as_warn (_("-R option not supported on this target."));
1404 flag_readonly_data_in_text
= 0;
1411 op_hash
= hash_new ();
1413 while (i
< NUMOPCODES
)
1415 const char *name
= pa_opcodes
[i
].name
;
1416 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1417 if (retval
!= NULL
&& *retval
!= '\0')
1419 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1424 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1425 != pa_opcodes
[i
].match
)
1427 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1428 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1433 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1437 as_fatal (_("Broken assembler. No assembly attempted."));
1440 /* SOM will change text_section. To make sure we never put
1441 anything into the old one switch to the new one now. */
1442 subseg_set (text_section
, 0);
1446 dummy_symbol
= symbol_find_or_make ("L$dummy");
1447 S_SET_SEGMENT (dummy_symbol
, text_section
);
1448 /* Force the symbol to be converted to a real symbol. */
1449 (void) symbol_get_bfdsym (dummy_symbol
);
1453 /* Assemble a single instruction storing it into a frag. */
1460 /* The had better be something to assemble. */
1463 /* If we are within a procedure definition, make sure we've
1464 defined a label for the procedure; handle case where the
1465 label was defined after the .PROC directive.
1467 Note there's not need to diddle with the segment or fragment
1468 for the label symbol in this case. We have already switched
1469 into the new $CODE$ subspace at this point. */
1470 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1472 label_symbol_struct
*label_symbol
= pa_get_label ();
1476 if (label_symbol
->lss_label
)
1478 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1479 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1482 /* Also handle allocation of a fixup to hold the unwind
1483 information when the label appears after the proc/procend. */
1484 if (within_entry_exit
)
1489 where
= frag_more (0);
1490 u
= UNWIND_LOW32 (&last_call_info
->ci_unwind
.descriptor
);
1491 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1492 NULL
, (offsetT
) 0, NULL
,
1493 0, R_HPPA_ENTRY
, e_fsel
, 0, 0, u
);
1498 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1501 as_bad (_("Missing function name for .PROC"));
1504 /* Assemble the instruction. Results are saved into "the_insn". */
1507 /* Get somewhere to put the assembled instrution. */
1510 /* Output the opcode. */
1511 md_number_to_chars (to
, the_insn
.opcode
, 4);
1513 /* If necessary output more stuff. */
1514 if (the_insn
.reloc
!= R_HPPA_NONE
)
1515 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1516 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1517 the_insn
.reloc
, the_insn
.field_selector
,
1518 the_insn
.format
, the_insn
.arg_reloc
, 0);
1521 dwarf2_emit_insn (4);
1525 /* Do the real work for assembling a single instruction. Store results
1526 into the global "the_insn" variable. */
1532 char *error_message
= "";
1533 char *s
, c
, *argstart
, *name
, *save_s
;
1537 int cmpltr
, nullif
, flag
, cond
, num
;
1538 unsigned long opcode
;
1539 struct pa_opcode
*insn
;
1542 /* We must have a valid space and subspace. */
1543 pa_check_current_space_and_subspace ();
1546 /* Convert everything up to the first whitespace character into lower
1548 for (s
= str
; *s
!= ' ' && *s
!= '\t' && *s
!= '\n' && *s
!= '\0'; s
++)
1552 /* Skip to something interesting. */
1553 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1572 as_fatal (_("Unknown opcode: `%s'"), str
);
1577 /* Look up the opcode in the has table. */
1578 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1580 as_bad ("Unknown opcode: `%s'", str
);
1589 /* Mark the location where arguments for the instruction start, then
1590 start processing them. */
1594 /* Do some initialization. */
1595 opcode
= insn
->match
;
1596 strict
= (insn
->flags
& FLAG_STRICT
);
1597 memset (&the_insn
, 0, sizeof (the_insn
));
1599 the_insn
.reloc
= R_HPPA_NONE
;
1601 /* If this instruction is specific to a particular architecture,
1602 then set a new architecture. */
1603 /* But do not automatically promote to pa2.0. The automatic promotion
1604 crud is for compatability with HP's old assemblers only. */
1606 && bfd_get_mach (stdoutput
) < insn
->arch
)
1608 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1609 as_warn (_("could not update architecture and machine"));
1611 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1617 /* Build the opcode, checking as we go to make
1618 sure that the operands match. */
1619 for (args
= insn
->args
;; ++args
)
1621 /* Absorb white space in instruction. */
1622 while (*s
== ' ' || *s
== '\t')
1628 /* End of arguments. */
1644 /* These must match exactly. */
1653 /* Handle a 5 bit register or control register field at 10. */
1656 if (!pa_parse_number (&s
, 0))
1659 CHECK_FIELD (num
, 31, 0, 0);
1660 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1662 /* Handle %sar or %cr11. No bits get set, we just verify that it
1665 /* Skip whitespace before register. */
1666 while (*s
== ' ' || *s
== '\t')
1669 if (!strncasecmp(s
, "%sar", 4))
1674 else if (!strncasecmp(s
, "%cr11", 5))
1681 /* Handle a 5 bit register field at 15. */
1683 if (!pa_parse_number (&s
, 0))
1686 CHECK_FIELD (num
, 31, 0, 0);
1687 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1689 /* Handle a 5 bit register field at 31. */
1691 if (!pa_parse_number (&s
, 0))
1694 CHECK_FIELD (num
, 31, 0, 0);
1695 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1697 /* Handle a 5 bit register field at 10 and 15. */
1699 if (!pa_parse_number (&s
, 0))
1702 CHECK_FIELD (num
, 31, 0, 0);
1703 opcode
|= num
<< 16;
1704 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1706 /* Handle a 5 bit field length at 31. */
1708 num
= pa_get_absolute_expression (&the_insn
, &s
);
1709 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1712 CHECK_FIELD (num
, 32, 1, 0);
1713 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1715 /* Handle a 5 bit immediate at 15. */
1717 num
= pa_get_absolute_expression (&the_insn
, &s
);
1718 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1721 /* When in strict mode, we want to just reject this
1722 match instead of giving an out of range error. */
1723 CHECK_FIELD (num
, 15, -16, strict
);
1724 num
= low_sign_unext (num
, 5);
1725 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1727 /* Handle a 5 bit immediate at 31. */
1729 num
= pa_get_absolute_expression (&the_insn
, &s
);
1730 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1733 /* When in strict mode, we want to just reject this
1734 match instead of giving an out of range error. */
1735 CHECK_FIELD (num
, 15, -16, strict
);
1736 num
= low_sign_unext (num
, 5);
1737 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1739 /* Handle an unsigned 5 bit immediate at 31. */
1741 num
= pa_get_absolute_expression (&the_insn
, &s
);
1742 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1745 CHECK_FIELD (num
, 31, 0, strict
);
1746 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1748 /* Handle an unsigned 5 bit immediate at 15. */
1750 num
= pa_get_absolute_expression (&the_insn
, &s
);
1751 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1754 CHECK_FIELD (num
, 31, 0, strict
);
1755 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1757 /* Handle an unsigned 10 bit immediate at 15. */
1759 num
= pa_get_absolute_expression (&the_insn
, &s
);
1760 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1763 CHECK_FIELD (num
, 1023, 0, strict
);
1764 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1766 /* Handle a 2 bit space identifier at 17. */
1768 if (!pa_parse_number (&s
, 0))
1771 CHECK_FIELD (num
, 3, 0, 1);
1772 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1774 /* Handle a 3 bit space identifier at 18. */
1776 if (!pa_parse_number (&s
, 0))
1779 CHECK_FIELD (num
, 7, 0, 1);
1780 opcode
|= re_assemble_3 (num
);
1783 /* Handle all completers. */
1788 /* Handle a completer for an indexing load or store. */
1794 while (*s
== ',' && i
< 2)
1797 if (strncasecmp (s
, "sm", 2) == 0)
1804 else if (strncasecmp (s
, "m", 1) == 0)
1806 else if ((strncasecmp (s
, "s ", 2) == 0)
1807 || (strncasecmp (s
, "s,", 2) == 0))
1809 /* When in strict mode this is a match failure. */
1816 as_bad (_("Invalid Indexed Load Completer."));
1821 as_bad (_("Invalid Indexed Load Completer Syntax."));
1823 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1826 /* Handle a short load/store completer. */
1838 if (strncasecmp (s
, "ma", 2) == 0)
1844 else if (strncasecmp (s
, "mb", 2) == 0)
1851 /* When in strict mode, pass through for cache op. */
1852 if (!found
&& strict
)
1857 as_bad (_("Invalid Short Load/Store Completer."));
1861 /* If we did not get a ma/mb completer, then we do not
1862 consider this a positive match for 'ce'. */
1863 else if (*args
== 'e')
1866 /* 'J', 'm' and 'q' are the same, except for where they
1867 encode the before/after field. */
1871 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1873 else if (*args
== 'q')
1876 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1878 else if (*args
== 'J')
1880 /* M bit is explicit in the major opcode. */
1881 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1883 else if (*args
== 'e')
1885 /* Stash the ma/mb flag temporarily in the
1886 instruction. We will use (and remove it)
1887 later when handling 'J', 'K', '<' & '>'. */
1893 /* Handle a stbys completer. */
1899 while (*s
== ',' && i
< 2)
1902 if (strncasecmp (s
, "m", 1) == 0)
1904 else if ((strncasecmp (s
, "b ", 2) == 0)
1905 || (strncasecmp (s
, "b,", 2) == 0))
1907 else if (strncasecmp (s
, "e", 1) == 0)
1909 /* When in strict mode this is a match failure. */
1916 as_bad (_("Invalid Store Bytes Short Completer"));
1921 as_bad (_("Invalid Store Bytes Short Completer"));
1923 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1926 /* Handle load cache hint completer. */
1929 if (!strncmp(s
, ",sl", 3))
1934 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1936 /* Handle store cache hint completer. */
1939 if (!strncmp(s
, ",sl", 3))
1944 else if (!strncmp(s
, ",bc", 3))
1949 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1951 /* Handle load and clear cache hint completer. */
1954 if (!strncmp(s
, ",co", 3))
1959 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 10);
1961 /* Handle load ordering completer. */
1963 if (strncmp(s
, ",o", 2) != 0)
1968 /* Handle a branch gate completer. */
1970 if (strncasecmp (s
, ",gate", 5) != 0)
1975 /* Handle a branch link and push completer. */
1977 if (strncasecmp (s
, ",l,push", 7) != 0)
1982 /* Handle a branch link completer. */
1984 if (strncasecmp (s
, ",l", 2) != 0)
1989 /* Handle a branch pop completer. */
1991 if (strncasecmp (s
, ",pop", 4) != 0)
1996 /* Handle a local processor completer. */
1998 if (strncasecmp (s
, ",l", 2) != 0)
2003 /* Handle a PROBE read/write completer. */
2006 if (!strncasecmp (s
, ",w", 2))
2011 else if (!strncasecmp (s
, ",r", 2))
2017 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2019 /* Handle MFCTL wide completer. */
2021 if (strncasecmp (s
, ",w", 2) != 0)
2026 /* Handle an RFI restore completer. */
2029 if (!strncasecmp (s
, ",r", 2))
2035 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2037 /* Handle a system control completer. */
2039 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2047 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2049 /* Handle intermediate/final completer for DCOR. */
2052 if (!strncasecmp (s
, ",i", 2))
2058 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2060 /* Handle zero/sign extension completer. */
2063 if (!strncasecmp (s
, ",z", 2))
2069 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2071 /* Handle add completer. */
2074 if (!strncasecmp (s
, ",l", 2))
2079 else if (!strncasecmp (s
, ",tsv", 4))
2085 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
2087 /* Handle 64 bit carry for ADD. */
2090 if (!strncasecmp (s
, ",dc,tsv", 7) ||
2091 !strncasecmp (s
, ",tsv,dc", 7))
2096 else if (!strncasecmp (s
, ",dc", 3))
2104 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2106 /* Handle 32 bit carry for ADD. */
2109 if (!strncasecmp (s
, ",c,tsv", 6) ||
2110 !strncasecmp (s
, ",tsv,c", 6))
2115 else if (!strncasecmp (s
, ",c", 2))
2123 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2125 /* Handle trap on signed overflow. */
2128 if (!strncasecmp (s
, ",tsv", 4))
2134 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2136 /* Handle trap on condition and overflow. */
2139 if (!strncasecmp (s
, ",tc,tsv", 7) ||
2140 !strncasecmp (s
, ",tsv,tc", 7))
2145 else if (!strncasecmp (s
, ",tc", 3))
2153 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2155 /* Handle 64 bit borrow for SUB. */
2158 if (!strncasecmp (s
, ",db,tsv", 7) ||
2159 !strncasecmp (s
, ",tsv,db", 7))
2164 else if (!strncasecmp (s
, ",db", 3))
2172 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2174 /* Handle 32 bit borrow for SUB. */
2177 if (!strncasecmp (s
, ",b,tsv", 6) ||
2178 !strncasecmp (s
, ",tsv,b", 6))
2183 else if (!strncasecmp (s
, ",b", 2))
2191 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2193 /* Handle trap condition completer for UADDCM. */
2196 if (!strncasecmp (s
, ",tc", 3))
2202 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2204 /* Handle signed/unsigned at 21. */
2208 if (strncasecmp (s
, ",s", 2) == 0)
2213 else if (strncasecmp (s
, ",u", 2) == 0)
2219 INSERT_FIELD_AND_CONTINUE (opcode
, sign
, 10);
2222 /* Handle left/right combination at 17:18. */
2232 as_bad(_("Invalid left/right combination completer"));
2235 INSERT_FIELD_AND_CONTINUE (opcode
, lr
, 13);
2238 as_bad(_("Invalid left/right combination completer"));
2241 /* Handle saturation at 24:25. */
2245 if (strncasecmp (s
, ",ss", 3) == 0)
2250 else if (strncasecmp (s
, ",us", 3) == 0)
2256 INSERT_FIELD_AND_CONTINUE (opcode
, sat
, 6);
2259 /* Handle permutation completer. */
2287 as_bad(_("Invalid permutation completer"));
2289 opcode
|= perm
<< permloc
[i
];
2294 as_bad(_("Invalid permutation completer"));
2302 /* Handle all conditions. */
2308 /* Handle FP compare conditions. */
2310 cond
= pa_parse_fp_cmp_cond (&s
);
2311 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2313 /* Handle an add condition. */
2322 /* 64 bit conditions. */
2335 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2339 if (strcmp (name
, "=") == 0)
2341 else if (strcmp (name
, "<") == 0)
2343 else if (strcmp (name
, "<=") == 0)
2345 else if (strcasecmp (name
, "nuv") == 0)
2347 else if (strcasecmp (name
, "znv") == 0)
2349 else if (strcasecmp (name
, "sv") == 0)
2351 else if (strcasecmp (name
, "od") == 0)
2353 else if (strcasecmp (name
, "tr") == 0)
2358 else if (strcmp (name
, "<>") == 0)
2363 else if (strcmp (name
, ">=") == 0)
2368 else if (strcmp (name
, ">") == 0)
2373 else if (strcasecmp (name
, "uv") == 0)
2378 else if (strcasecmp (name
, "vnz") == 0)
2383 else if (strcasecmp (name
, "nsv") == 0)
2388 else if (strcasecmp (name
, "ev") == 0)
2393 /* ",*" is a valid condition. */
2394 else if (*args
== 'a')
2395 as_bad (_("Invalid Add Condition: %s"), name
);
2398 opcode
|= cmpltr
<< 13;
2399 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2401 /* Handle non-negated add and branch condition. */
2403 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2406 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2409 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2411 /* Handle 64 bit wide-mode add and branch condition. */
2413 cmpltr
= pa_parse_addb_64_cmpltr (&s
);
2416 as_bad (_("Invalid Add and Branch Condition: %c"), *s
);
2421 /* Negated condition requires an opcode change. */
2422 opcode
|= (cmpltr
& 8) << 24;
2424 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2426 /* Handle a negated or non-negated add and branch
2430 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2434 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
2437 as_bad (_("Invalid Compare/Subtract Condition"));
2442 /* Negated condition requires an opcode change. */
2446 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2448 /* Handle branch on bit conditions. */
2466 if (strncmp (s
, "<", 1) == 0)
2471 else if (strncmp (s
, ">=", 2) == 0)
2477 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2479 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2481 /* Handle a compare/subtract condition. */
2490 /* 64 bit conditions. */
2503 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2507 if (strcmp (name
, "=") == 0)
2509 else if (strcmp (name
, "<") == 0)
2511 else if (strcmp (name
, "<=") == 0)
2513 else if (strcasecmp (name
, "<<") == 0)
2515 else if (strcasecmp (name
, "<<=") == 0)
2517 else if (strcasecmp (name
, "sv") == 0)
2519 else if (strcasecmp (name
, "od") == 0)
2521 else if (strcasecmp (name
, "tr") == 0)
2526 else if (strcmp (name
, "<>") == 0)
2531 else if (strcmp (name
, ">=") == 0)
2536 else if (strcmp (name
, ">") == 0)
2541 else if (strcasecmp (name
, ">>=") == 0)
2546 else if (strcasecmp (name
, ">>") == 0)
2551 else if (strcasecmp (name
, "nsv") == 0)
2556 else if (strcasecmp (name
, "ev") == 0)
2561 /* ",*" is a valid condition. */
2562 else if (*args
!= 'S')
2563 as_bad (_("Invalid Compare/Subtract Condition: %s"),
2567 opcode
|= cmpltr
<< 13;
2568 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2570 /* Handle a non-negated compare condition. */
2572 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2575 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
2578 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2580 /* Handle a 32 bit compare and branch condition. */
2583 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2587 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
2590 as_bad (_("Invalid Compare and Branch Condition."));
2595 /* Negated condition requires an opcode change. */
2600 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2602 /* Handle a 64 bit compare and branch condition. */
2604 cmpltr
= pa_parse_cmpb_64_cmpltr (&s
);
2607 /* Negated condition requires an opcode change. */
2608 opcode
|= (cmpltr
& 8) << 26;
2611 /* Not a 64 bit cond. Give 32 bit a chance. */
2614 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
& 7, 13);
2616 /* Handle a 64 bit cmpib condition. */
2618 cmpltr
= pa_parse_cmpib_64_cmpltr (&s
);
2620 /* Not a 64 bit cond. Give 32 bit a chance. */
2623 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2625 /* Handle a logical instruction condition. */
2634 /* 64 bit conditions. */
2646 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2651 if (strcmp (name
, "=") == 0)
2653 else if (strcmp (name
, "<") == 0)
2655 else if (strcmp (name
, "<=") == 0)
2657 else if (strcasecmp (name
, "od") == 0)
2659 else if (strcasecmp (name
, "tr") == 0)
2664 else if (strcmp (name
, "<>") == 0)
2669 else if (strcmp (name
, ">=") == 0)
2674 else if (strcmp (name
, ">") == 0)
2679 else if (strcasecmp (name
, "ev") == 0)
2684 /* ",*" is a valid condition. */
2685 else if (*args
!= 'L')
2686 as_bad (_("Invalid Logical Instruction Condition."));
2689 opcode
|= cmpltr
<< 13;
2690 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2692 /* Handle a shift/extract/deposit condition. */
2701 /* 64 bit conditions. */
2713 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2717 if (strcmp (name
, "=") == 0)
2719 else if (strcmp (name
, "<") == 0)
2721 else if (strcasecmp (name
, "od") == 0)
2723 else if (strcasecmp (name
, "tr") == 0)
2725 else if (strcmp (name
, "<>") == 0)
2727 else if (strcmp (name
, ">=") == 0)
2729 else if (strcasecmp (name
, "ev") == 0)
2731 /* Handle movb,n. Put things back the way they were.
2732 This includes moving s back to where it started. */
2733 else if (strcasecmp (name
, "n") == 0 && *args
== 'y')
2739 /* ",*" is a valid condition. */
2740 else if (*args
!= 'X')
2741 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2744 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2746 /* Handle a unit instruction condition. */
2755 /* 64 bit conditions. */
2766 if (strncasecmp (s
, "sbz", 3) == 0)
2771 else if (strncasecmp (s
, "shz", 3) == 0)
2776 else if (strncasecmp (s
, "sdc", 3) == 0)
2781 else if (strncasecmp (s
, "sbc", 3) == 0)
2786 else if (strncasecmp (s
, "shc", 3) == 0)
2791 else if (strncasecmp (s
, "tr", 2) == 0)
2797 else if (strncasecmp (s
, "nbz", 3) == 0)
2803 else if (strncasecmp (s
, "nhz", 3) == 0)
2809 else if (strncasecmp (s
, "ndc", 3) == 0)
2815 else if (strncasecmp (s
, "nbc", 3) == 0)
2821 else if (strncasecmp (s
, "nhc", 3) == 0)
2827 else if (strncasecmp (s
, "swz", 3) == 0)
2833 else if (strncasecmp (s
, "swc", 3) == 0)
2839 else if (strncasecmp (s
, "nwz", 3) == 0)
2845 else if (strncasecmp (s
, "nwc", 3) == 0)
2851 /* ",*" is a valid condition. */
2852 else if (*args
!= 'U')
2853 as_bad (_("Invalid Unit Instruction Condition."));
2855 opcode
|= cmpltr
<< 13;
2856 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2864 /* Handle a nullification completer for branch instructions. */
2866 nullif
= pa_parse_nullif (&s
);
2867 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2869 /* Handle a nullification completer for copr and spop insns. */
2871 nullif
= pa_parse_nullif (&s
);
2872 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2874 /* Handle ,%r2 completer for new syntax branches. */
2876 if (*s
== ',' && strncasecmp (s
+ 1, "%r2", 3) == 0)
2878 else if (*s
== ',' && strncasecmp (s
+ 1, "%rp", 3) == 0)
2884 /* Handle 3 bit entry into the fp compare array. Valid values
2885 are 0..6 inclusive. */
2889 if (the_insn
.exp
.X_op
== O_constant
)
2891 num
= evaluate_absolute (&the_insn
);
2892 CHECK_FIELD (num
, 6, 0, 0);
2894 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2899 /* Handle 3 bit entry into the fp compare array. Valid values
2900 are 0..6 inclusive. */
2903 if (the_insn
.exp
.X_op
== O_constant
)
2906 num
= evaluate_absolute (&the_insn
);
2907 CHECK_FIELD (num
, 6, 0, 0);
2908 num
= (num
+ 1) ^ 1;
2909 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2914 /* Handle graphics test completers for ftest */
2917 num
= pa_parse_ftest_gfx_completer (&s
);
2918 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2921 /* Handle a 11 bit immediate at 31. */
2923 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2926 if (the_insn
.exp
.X_op
== O_constant
)
2928 num
= evaluate_absolute (&the_insn
);
2929 CHECK_FIELD (num
, 1023, -1024, 0);
2930 num
= low_sign_unext (num
, 11);
2931 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2935 if (is_DP_relative (the_insn
.exp
))
2936 the_insn
.reloc
= R_HPPA_GOTOFF
;
2937 else if (is_PC_relative (the_insn
.exp
))
2938 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2940 the_insn
.reloc
= R_HPPA
;
2941 the_insn
.format
= 11;
2945 /* Handle a 14 bit immediate at 31. */
2947 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2950 if (the_insn
.exp
.X_op
== O_constant
)
2954 /* XXX the completer stored away tidbits of information
2955 for us to extract. We need a cleaner way to do this.
2956 Now that we have lots of letters again, it would be
2957 good to rethink this. */
2960 num
= evaluate_absolute (&the_insn
);
2961 if (mb
!= (num
< 0))
2963 CHECK_FIELD (num
, 8191, -8192, 0);
2964 num
= low_sign_unext (num
, 14);
2965 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2969 /* Handle a 14 bit immediate at 31. */
2971 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2974 if (the_insn
.exp
.X_op
== O_constant
)
2980 num
= evaluate_absolute (&the_insn
);
2981 if (mb
== (num
< 0))
2985 CHECK_FIELD (num
, 8191, -8192, 0);
2986 num
= low_sign_unext (num
, 14);
2987 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2991 /* Handle a 16 bit immediate at 31. */
2993 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2996 if (the_insn
.exp
.X_op
== O_constant
)
3002 num
= evaluate_absolute (&the_insn
);
3003 if (mb
!= (num
< 0))
3005 CHECK_FIELD (num
, 32767, -32768, 0);
3006 num
= re_assemble_16 (num
);
3007 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3011 /* Handle a 16 bit immediate at 31. */
3013 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3016 if (the_insn
.exp
.X_op
== O_constant
)
3022 num
= evaluate_absolute (&the_insn
);
3023 if (mb
== (num
< 0))
3027 CHECK_FIELD (num
, 32767, -32768, 0);
3028 num
= re_assemble_16 (num
);
3029 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3033 /* Handle 14 bit immediate, shifted left three times. */
3035 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3038 if (the_insn
.exp
.X_op
== O_constant
)
3040 num
= evaluate_absolute (&the_insn
);
3043 CHECK_FIELD (num
, 8191, -8192, 0);
3048 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 4);
3052 if (is_DP_relative (the_insn
.exp
))
3053 the_insn
.reloc
= R_HPPA_GOTOFF
;
3054 else if (is_PC_relative (the_insn
.exp
))
3055 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3057 the_insn
.reloc
= R_HPPA
;
3058 the_insn
.format
= 14;
3063 /* Handle 14 bit immediate, shifted left twice. */
3065 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3068 if (the_insn
.exp
.X_op
== O_constant
)
3070 num
= evaluate_absolute (&the_insn
);
3073 CHECK_FIELD (num
, 8191, -8192, 0);
3078 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3082 if (is_DP_relative (the_insn
.exp
))
3083 the_insn
.reloc
= R_HPPA_GOTOFF
;
3084 else if (is_PC_relative (the_insn
.exp
))
3085 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3087 the_insn
.reloc
= R_HPPA
;
3088 the_insn
.format
= 14;
3092 /* Handle a 14 bit immediate at 31. */
3094 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3097 if (the_insn
.exp
.X_op
== O_constant
)
3099 num
= evaluate_absolute (&the_insn
);
3100 CHECK_FIELD (num
, 8191, -8192, 0);
3101 num
= low_sign_unext (num
, 14);
3102 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3106 if (is_DP_relative (the_insn
.exp
))
3107 the_insn
.reloc
= R_HPPA_GOTOFF
;
3108 else if (is_PC_relative (the_insn
.exp
))
3109 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3111 the_insn
.reloc
= R_HPPA
;
3112 the_insn
.format
= 14;
3116 /* Handle a 21 bit immediate at 31. */
3118 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3121 if (the_insn
.exp
.X_op
== O_constant
)
3123 num
= evaluate_absolute (&the_insn
);
3124 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
3125 opcode
|= re_assemble_21 (num
);
3130 if (is_DP_relative (the_insn
.exp
))
3131 the_insn
.reloc
= R_HPPA_GOTOFF
;
3132 else if (is_PC_relative (the_insn
.exp
))
3133 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3135 the_insn
.reloc
= R_HPPA
;
3136 the_insn
.format
= 21;
3140 /* Handle a 16 bit immediate at 31 (PA 2.0 wide mode only). */
3142 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3145 if (the_insn
.exp
.X_op
== O_constant
)
3147 num
= evaluate_absolute (&the_insn
);
3148 CHECK_FIELD (num
, 32767, -32768, 0);
3149 opcode
|= re_assemble_16 (num
);
3154 /* ??? Is this valid for wide mode? */
3155 if (is_DP_relative (the_insn
.exp
))
3156 the_insn
.reloc
= R_HPPA_GOTOFF
;
3157 else if (is_PC_relative (the_insn
.exp
))
3158 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3160 the_insn
.reloc
= R_HPPA
;
3161 the_insn
.format
= 14;
3165 /* Handle a word-aligned 16-bit imm. at 31 (PA2.0 wide). */
3167 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3170 if (the_insn
.exp
.X_op
== O_constant
)
3172 num
= evaluate_absolute (&the_insn
);
3173 CHECK_FIELD (num
, 32767, -32768, 0);
3174 CHECK_ALIGN (num
, 4, 0);
3175 opcode
|= re_assemble_16 (num
);
3180 /* ??? Is this valid for wide mode? */
3181 if (is_DP_relative (the_insn
.exp
))
3182 the_insn
.reloc
= R_HPPA_GOTOFF
;
3183 else if (is_PC_relative (the_insn
.exp
))
3184 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3186 the_insn
.reloc
= R_HPPA
;
3187 the_insn
.format
= 14;
3191 /* Handle a dword-aligned 16-bit imm. at 31 (PA2.0 wide). */
3193 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3196 if (the_insn
.exp
.X_op
== O_constant
)
3198 num
= evaluate_absolute (&the_insn
);
3199 CHECK_FIELD (num
, 32767, -32768, 0);
3200 CHECK_ALIGN (num
, 8, 0);
3201 opcode
|= re_assemble_16 (num
);
3206 /* ??? Is this valid for wide mode? */
3207 if (is_DP_relative (the_insn
.exp
))
3208 the_insn
.reloc
= R_HPPA_GOTOFF
;
3209 else if (is_PC_relative (the_insn
.exp
))
3210 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3212 the_insn
.reloc
= R_HPPA
;
3213 the_insn
.format
= 14;
3217 /* Handle a 12 bit branch displacement. */
3219 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3223 if (!the_insn
.exp
.X_add_symbol
3224 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3227 num
= evaluate_absolute (&the_insn
);
3230 as_bad (_("Branch to unaligned address"));
3233 if (the_insn
.exp
.X_add_symbol
)
3235 CHECK_FIELD (num
, 8191, -8192, 0);
3236 opcode
|= re_assemble_12 (num
>> 2);
3241 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3242 the_insn
.format
= 12;
3243 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3244 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3249 /* Handle a 17 bit branch displacement. */
3251 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3255 if (!the_insn
.exp
.X_add_symbol
3256 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3259 num
= evaluate_absolute (&the_insn
);
3262 as_bad (_("Branch to unaligned address"));
3265 if (the_insn
.exp
.X_add_symbol
)
3267 CHECK_FIELD (num
, 262143, -262144, 0);
3268 opcode
|= re_assemble_17 (num
>> 2);
3273 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3274 the_insn
.format
= 17;
3275 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3276 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3280 /* Handle a 22 bit branch displacement. */
3282 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3286 if (!the_insn
.exp
.X_add_symbol
3287 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3290 num
= evaluate_absolute (&the_insn
);
3293 as_bad (_("Branch to unaligned address"));
3296 if (the_insn
.exp
.X_add_symbol
)
3298 CHECK_FIELD (num
, 8388607, -8388608, 0);
3299 opcode
|= re_assemble_22 (num
>> 2);
3303 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3304 the_insn
.format
= 22;
3305 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3306 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3310 /* Handle an absolute 17 bit branch target. */
3312 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3316 if (!the_insn
.exp
.X_add_symbol
3317 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3320 num
= evaluate_absolute (&the_insn
);
3323 as_bad (_("Branch to unaligned address"));
3326 if (the_insn
.exp
.X_add_symbol
)
3328 CHECK_FIELD (num
, 262143, -262144, 0);
3329 opcode
|= re_assemble_17 (num
>> 2);
3334 the_insn
.reloc
= R_HPPA_ABS_CALL
;
3335 the_insn
.format
= 17;
3336 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3337 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3341 /* Handle '%r1' implicit operand of addil instruction. */
3343 if (*s
== ',' && *(s
+ 1) == '%' && *(s
+ 3) == '1'
3344 && (*(s
+ 2) == 'r' || *(s
+ 2) == 'R'))
3352 /* Handle '%sr0,%r31' implicit operand of be,l instruction. */
3354 if (strncasecmp (s
, "%sr0,%r31", 9) != 0)
3359 /* Handle immediate value of 0 for ordered load/store instructions. */
3366 /* Handle a 2 bit shift count at 25. */
3368 num
= pa_get_absolute_expression (&the_insn
, &s
);
3369 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3372 CHECK_FIELD (num
, 3, 1, strict
);
3373 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3375 /* Handle a 4 bit shift count at 25. */
3377 num
= pa_get_absolute_expression (&the_insn
, &s
);
3378 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3381 CHECK_FIELD (num
, 15, 0, strict
);
3382 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3384 /* Handle a 5 bit shift count at 26. */
3386 num
= pa_get_absolute_expression (&the_insn
, &s
);
3387 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3390 CHECK_FIELD (num
, 31, 0, strict
);
3391 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
3393 /* Handle a 6 bit shift count at 20,22:26. */
3395 num
= pa_get_absolute_expression (&the_insn
, &s
);
3396 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3399 CHECK_FIELD (num
, 63, 0, strict
);
3401 opcode
|= (num
& 0x20) << 6;
3402 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3404 /* Handle a 6 bit field length at 23,27:31. */
3407 num
= pa_get_absolute_expression (&the_insn
, &s
);
3408 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3411 CHECK_FIELD (num
, 64, 1, strict
);
3413 opcode
|= (num
& 0x20) << 3;
3414 num
= 31 - (num
& 0x1f);
3415 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3417 /* Handle a 6 bit field length at 19,27:31. */
3419 num
= pa_get_absolute_expression (&the_insn
, &s
);
3420 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3423 CHECK_FIELD (num
, 64, 1, strict
);
3425 opcode
|= (num
& 0x20) << 7;
3426 num
= 31 - (num
& 0x1f);
3427 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3429 /* Handle a 5 bit bit position at 26. */
3431 num
= pa_get_absolute_expression (&the_insn
, &s
);
3432 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3435 CHECK_FIELD (num
, 31, 0, strict
);
3436 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
3438 /* Handle a 6 bit bit position at 20,22:26. */
3440 num
= pa_get_absolute_expression (&the_insn
, &s
);
3441 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3444 CHECK_FIELD (num
, 63, 0, strict
);
3445 opcode
|= (num
& 0x20) << 6;
3446 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3448 /* Handle a 5 bit immediate at 10 with 'd' as the complement
3449 of the high bit of the immediate. */
3451 num
= pa_get_absolute_expression (&the_insn
, &s
);
3452 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3455 CHECK_FIELD (num
, 63, 0, strict
);
3459 opcode
|= (1 << 13);
3460 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 21);
3462 /* Handle a 5 bit immediate at 10. */
3464 num
= pa_get_absolute_expression (&the_insn
, &s
);
3465 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3468 CHECK_FIELD (num
, 31, 0, strict
);
3469 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3471 /* Handle a 9 bit immediate at 28. */
3473 num
= pa_get_absolute_expression (&the_insn
, &s
);
3474 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3477 CHECK_FIELD (num
, 511, 1, strict
);
3478 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3480 /* Handle a 13 bit immediate at 18. */
3482 num
= pa_get_absolute_expression (&the_insn
, &s
);
3483 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3486 CHECK_FIELD (num
, 8191, 0, strict
);
3487 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
3489 /* Handle a 26 bit immediate at 31. */
3491 num
= pa_get_absolute_expression (&the_insn
, &s
);
3492 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3495 CHECK_FIELD (num
, 67108863, 0, strict
);
3496 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3498 /* Handle a 3 bit SFU identifier at 25. */
3501 as_bad (_("Invalid SFU identifier"));
3502 num
= pa_get_absolute_expression (&the_insn
, &s
);
3503 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3506 CHECK_FIELD (num
, 7, 0, strict
);
3507 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3509 /* Handle a 20 bit SOP field for spop0. */
3511 num
= pa_get_absolute_expression (&the_insn
, &s
);
3512 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3515 CHECK_FIELD (num
, 1048575, 0, strict
);
3516 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
3517 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3519 /* Handle a 15bit SOP field for spop1. */
3521 num
= pa_get_absolute_expression (&the_insn
, &s
);
3522 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3525 CHECK_FIELD (num
, 32767, 0, strict
);
3526 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
3528 /* Handle a 10bit SOP field for spop3. */
3530 num
= pa_get_absolute_expression (&the_insn
, &s
);
3531 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3534 CHECK_FIELD (num
, 1023, 0, strict
);
3535 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
3536 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3538 /* Handle a 15 bit SOP field for spop2. */
3540 num
= pa_get_absolute_expression (&the_insn
, &s
);
3541 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3544 CHECK_FIELD (num
, 32767, 0, strict
);
3545 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
3546 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3548 /* Handle a 3-bit co-processor ID field. */
3551 as_bad (_("Invalid COPR identifier"));
3552 num
= pa_get_absolute_expression (&the_insn
, &s
);
3553 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3556 CHECK_FIELD (num
, 7, 0, strict
);
3557 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3559 /* Handle a 22bit SOP field for copr. */
3561 num
= pa_get_absolute_expression (&the_insn
, &s
);
3562 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3565 CHECK_FIELD (num
, 4194303, 0, strict
);
3566 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
3567 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3569 /* Handle a source FP operand format completer. */
3571 if (*s
== ',' && *(s
+1) == 't')
3578 flag
= pa_parse_fp_cnv_format (&s
);
3579 the_insn
.fpof1
= flag
;
3580 if (flag
== W
|| flag
== UW
)
3582 if (flag
== DW
|| flag
== UDW
)
3584 if (flag
== QW
|| flag
== UQW
)
3586 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3588 /* Handle a destination FP operand format completer. */
3590 /* pa_parse_format needs the ',' prefix. */
3592 flag
= pa_parse_fp_cnv_format (&s
);
3593 the_insn
.fpof2
= flag
;
3594 if (flag
== W
|| flag
== UW
)
3596 if (flag
== DW
|| flag
== UDW
)
3598 if (flag
== QW
|| flag
== UQW
)
3600 opcode
|= flag
<< 13;
3601 if (the_insn
.fpof1
== SGL
3602 || the_insn
.fpof1
== DBL
3603 || the_insn
.fpof1
== QUAD
)
3605 if (the_insn
.fpof2
== SGL
3606 || the_insn
.fpof2
== DBL
3607 || the_insn
.fpof2
== QUAD
)
3609 else if (the_insn
.fpof2
== W
3610 || the_insn
.fpof2
== DW
3611 || the_insn
.fpof2
== QW
)
3613 else if (the_insn
.fpof2
== UW
3614 || the_insn
.fpof2
== UDW
3615 || the_insn
.fpof2
== UQW
)
3620 else if (the_insn
.fpof1
== W
3621 || the_insn
.fpof1
== DW
3622 || the_insn
.fpof1
== QW
)
3624 if (the_insn
.fpof2
== SGL
3625 || the_insn
.fpof2
== DBL
3626 || the_insn
.fpof2
== QUAD
)
3631 else if (the_insn
.fpof1
== UW
3632 || the_insn
.fpof1
== UDW
3633 || the_insn
.fpof1
== UQW
)
3635 if (the_insn
.fpof2
== SGL
3636 || the_insn
.fpof2
== DBL
3637 || the_insn
.fpof2
== QUAD
)
3642 flag
|= the_insn
.trunc
;
3643 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 15);
3645 /* Handle a source FP operand format completer. */
3647 flag
= pa_parse_fp_format (&s
);
3648 the_insn
.fpof1
= flag
;
3649 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3651 /* Handle a destination FP operand format completer. */
3653 /* pa_parse_format needs the ',' prefix. */
3655 flag
= pa_parse_fp_format (&s
);
3656 the_insn
.fpof2
= flag
;
3657 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
3659 /* Handle a source FP operand format completer at 20. */
3661 flag
= pa_parse_fp_format (&s
);
3662 the_insn
.fpof1
= flag
;
3663 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3665 /* Handle a floating point operand format at 26.
3666 Only allows single and double precision. */
3668 flag
= pa_parse_fp_format (&s
);
3674 the_insn
.fpof1
= flag
;
3680 as_bad (_("Invalid Floating Point Operand Format."));
3684 /* Handle all floating point registers. */
3688 /* Float target register. */
3690 if (!pa_parse_number (&s
, 3))
3692 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3693 CHECK_FIELD (num
, 31, 0, 0);
3694 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3696 /* Float target register with L/R selection. */
3699 if (!pa_parse_number (&s
, 1))
3701 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3702 CHECK_FIELD (num
, 31, 0, 0);
3705 /* 0x30 opcodes are FP arithmetic operation opcodes
3706 and need to be turned into 0x38 opcodes. This
3707 is not necessary for loads/stores. */
3708 if (need_pa11_opcode ()
3709 && ((opcode
& 0xfc000000) == 0x30000000))
3712 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 6 : 0);
3716 /* Float operand 1. */
3719 if (!pa_parse_number (&s
, 1))
3721 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3722 CHECK_FIELD (num
, 31, 0, 0);
3723 opcode
|= num
<< 21;
3724 if (need_pa11_opcode ())
3726 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 7 : 0);
3732 /* Float operand 1 with L/R selection. */
3736 if (!pa_parse_number (&s
, 1))
3738 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3739 CHECK_FIELD (num
, 31, 0, 0);
3740 opcode
|= num
<< 21;
3741 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 7 : 0);
3745 /* Float operand 2. */
3748 if (!pa_parse_number (&s
, 1))
3750 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3751 CHECK_FIELD (num
, 31, 0, 0);
3752 opcode
|= num
<< 16;
3753 if (need_pa11_opcode ())
3755 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 12 : 0);
3761 /* Float operand 2 with L/R selection. */
3764 if (!pa_parse_number (&s
, 1))
3766 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3767 CHECK_FIELD (num
, 31, 0, 0);
3768 opcode
|= num
<< 16;
3769 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 12 : 0);
3773 /* Float operand 3 for fmpyfadd, fmpynfadd. */
3776 if (!pa_parse_number (&s
, 1))
3778 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3779 CHECK_FIELD (num
, 31, 0, 0);
3780 opcode
|= (num
& 0x1c) << 11;
3781 opcode
|= (num
& 0x03) << 9;
3782 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 8 : 0);
3786 /* Float mult operand 1 for fmpyadd, fmpysub */
3789 if (!pa_parse_number (&s
, 1))
3791 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3792 CHECK_FIELD (num
, 31, 0, 0);
3793 if (the_insn
.fpof1
== SGL
)
3797 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3801 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
3803 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3806 /* Float mult operand 2 for fmpyadd, fmpysub */
3809 if (!pa_parse_number (&s
, 1))
3811 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3812 CHECK_FIELD (num
, 31, 0, 0);
3813 if (the_insn
.fpof1
== SGL
)
3817 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3821 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
3823 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
3826 /* Float mult target for fmpyadd, fmpysub */
3829 if (!pa_parse_number (&s
, 1))
3831 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3832 CHECK_FIELD (num
, 31, 0, 0);
3833 if (the_insn
.fpof1
== SGL
)
3837 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3841 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
3843 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3846 /* Float add operand 1 for fmpyadd, fmpysub */
3849 if (!pa_parse_number (&s
, 1))
3851 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3852 CHECK_FIELD (num
, 31, 0, 0);
3853 if (the_insn
.fpof1
== SGL
)
3857 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3861 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
3863 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3866 /* Float add target for fmpyadd, fmpysub */
3869 if (!pa_parse_number (&s
, 1))
3871 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3872 CHECK_FIELD (num
, 31, 0, 0);
3873 if (the_insn
.fpof1
== SGL
)
3877 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3881 num
|= (pa_number
& FP_REG_RSEL
? 1 << 4 : 0);
3883 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
3886 /* Handle L/R register halves like 'x'. */
3890 if (!pa_parse_number (&s
, 1))
3892 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3893 CHECK_FIELD (num
, 31, 0, 0);
3894 opcode
|= num
<< 16;
3895 if (need_pa11_opcode ())
3897 opcode
|= (pa_number
& FP_REG_RSEL
? 1 << 1 : 0);
3902 /* Float target register (PA 2.0 wide). */
3904 if (!pa_parse_number (&s
, 3))
3906 num
= (pa_number
& ~FP_REG_RSEL
) - FP_REG_BASE
;
3907 CHECK_FIELD (num
, 31, 0, 0);
3908 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
3922 /* Check if the args matched. */
3925 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
3926 && !strcmp (insn
->name
, insn
[1].name
))
3934 as_bad (_("Invalid operands %s"), error_message
);
3941 the_insn
.opcode
= opcode
;
3944 /* Turn a string in input_line_pointer into a floating point constant of type
3945 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
3946 emitted is stored in *sizeP . An error message or NULL is returned. */
3948 #define MAX_LITTLENUMS 6
3951 md_atof (type
, litP
, sizeP
)
3957 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
3958 LITTLENUM_TYPE
*wordP
;
3990 return _("Bad call to MD_ATOF()");
3992 t
= atof_ieee (input_line_pointer
, type
, words
);
3994 input_line_pointer
= t
;
3995 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
3996 for (wordP
= words
; prec
--;)
3998 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
3999 litP
+= sizeof (LITTLENUM_TYPE
);
4004 /* Write out big-endian. */
4007 md_number_to_chars (buf
, val
, n
)
4012 number_to_chars_bigendian (buf
, val
, n
);
4015 /* Translate internal representation of relocation info to BFD target
4019 tc_gen_reloc (section
, fixp
)
4024 struct hppa_fix_struct
*hppa_fixp
;
4025 static arelent
*no_relocs
= NULL
;
4032 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
4033 if (fixp
->fx_addsy
== 0)
4036 assert (hppa_fixp
!= 0);
4037 assert (section
!= 0);
4039 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
4041 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4042 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4043 codes
= hppa_gen_reloc_type (stdoutput
,
4045 hppa_fixp
->fx_r_format
,
4046 hppa_fixp
->fx_r_field
,
4047 fixp
->fx_subsy
!= NULL
,
4048 symbol_get_bfdsym (fixp
->fx_addsy
));
4052 as_bad (_("Cannot handle fixup at %s:%d"), fixp
->fx_file
, fixp
->fx_line
);
4056 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
4059 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
4060 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
4061 for (i
= 0; i
< n_relocs
; i
++)
4062 relocs
[i
] = &reloc
[i
];
4064 relocs
[n_relocs
] = NULL
;
4067 switch (fixp
->fx_r_type
)
4070 assert (n_relocs
== 1);
4074 /* Now, do any processing that is dependent on the relocation type. */
4077 case R_PARISC_DLTREL21L
:
4078 case R_PARISC_DLTREL14R
:
4079 case R_PARISC_DLTREL14F
:
4080 case R_PARISC_PLABEL32
:
4081 case R_PARISC_PLABEL21L
:
4082 case R_PARISC_PLABEL14R
:
4083 /* For plabel relocations, the addend of the
4084 relocation should be either 0 (no static link) or 2
4085 (static link required). This adjustment is done in
4086 bfd/elf32-hppa.c:elf32_hppa_relocate_section.
4088 We also slam a zero addend into the DLT relative relocs;
4089 it doesn't make a lot of sense to use any addend since
4090 it gets you a different (eg unknown) DLT entry. */
4094 #ifdef ELF_ARG_RELOC
4095 case R_PARISC_PCREL17R
:
4096 case R_PARISC_PCREL17F
:
4097 case R_PARISC_PCREL17C
:
4098 case R_PARISC_DIR17R
:
4099 case R_PARISC_DIR17F
:
4100 case R_PARISC_PCREL21L
:
4101 case R_PARISC_DIR21L
:
4102 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
,
4107 case R_PARISC_DIR32
:
4108 /* Facilitate hand-crafted unwind info. */
4109 if (strcmp (section
->name
, UNWIND_SECTION_NAME
) == 0)
4110 code
= R_PARISC_SEGREL32
;
4114 reloc
->addend
= fixp
->fx_offset
;
4118 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4119 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4120 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
,
4121 (bfd_reloc_code_real_type
) code
);
4122 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4124 assert (reloc
->howto
&& (unsigned int) code
== reloc
->howto
->type
);
4129 /* Walk over reach relocation returned by the BFD backend. */
4130 for (i
= 0; i
< n_relocs
; i
++)
4134 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4135 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4137 bfd_reloc_type_lookup (stdoutput
,
4138 (bfd_reloc_code_real_type
) code
);
4139 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4144 /* The only time we ever use a R_COMP2 fixup is for the difference
4145 of two symbols. With that in mind we fill in all four
4146 relocs now and break out of the loop. */
4148 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4150 bfd_reloc_type_lookup (stdoutput
,
4151 (bfd_reloc_code_real_type
) *codes
[0]);
4152 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4153 relocs
[0]->addend
= 0;
4154 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4155 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
4157 bfd_reloc_type_lookup (stdoutput
,
4158 (bfd_reloc_code_real_type
) *codes
[1]);
4159 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4160 relocs
[1]->addend
= 0;
4161 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4162 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
4164 bfd_reloc_type_lookup (stdoutput
,
4165 (bfd_reloc_code_real_type
) *codes
[2]);
4166 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4167 relocs
[2]->addend
= 0;
4168 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4170 bfd_reloc_type_lookup (stdoutput
,
4171 (bfd_reloc_code_real_type
) *codes
[3]);
4172 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4173 relocs
[3]->addend
= 0;
4174 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
4176 bfd_reloc_type_lookup (stdoutput
,
4177 (bfd_reloc_code_real_type
) *codes
[4]);
4178 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
4179 relocs
[4]->addend
= 0;
4183 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
4189 /* For plabel relocations, the addend of the
4190 relocation should be either 0 (no static link) or 2
4191 (static link required).
4193 FIXME: We always assume no static link!
4195 We also slam a zero addend into the DLT relative relocs;
4196 it doesn't make a lot of sense to use any addend since
4197 it gets you a different (eg unknown) DLT entry. */
4198 relocs
[i
]->addend
= 0;
4213 /* There is no symbol or addend associated with these fixups. */
4214 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4215 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4216 relocs
[i
]->addend
= 0;
4222 /* There is no symbol associated with these fixups. */
4223 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4224 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4225 relocs
[i
]->addend
= fixp
->fx_offset
;
4229 relocs
[i
]->addend
= fixp
->fx_offset
;
4239 /* Process any machine dependent frag types. */
4242 md_convert_frag (abfd
, sec
, fragP
)
4243 register bfd
*abfd ATTRIBUTE_UNUSED
;
4244 register asection
*sec ATTRIBUTE_UNUSED
;
4245 register fragS
*fragP
;
4247 unsigned int address
;
4249 if (fragP
->fr_type
== rs_machine_dependent
)
4251 switch ((int) fragP
->fr_subtype
)
4254 fragP
->fr_type
= rs_fill
;
4255 know (fragP
->fr_var
== 1);
4256 know (fragP
->fr_next
);
4257 address
= fragP
->fr_address
+ fragP
->fr_fix
;
4258 if (address
% fragP
->fr_offset
)
4261 fragP
->fr_next
->fr_address
4266 fragP
->fr_offset
= 0;
4272 /* Round up a section size to the appropriate boundary. */
4275 md_section_align (segment
, size
)
4279 int align
= bfd_get_section_alignment (stdoutput
, segment
);
4280 int align2
= (1 << align
) - 1;
4282 return (size
+ align2
) & ~align2
;
4285 /* Return the approximate size of a frag before relaxation has occurred. */
4287 md_estimate_size_before_relax (fragP
, segment
)
4288 register fragS
*fragP
;
4289 asection
*segment ATTRIBUTE_UNUSED
;
4295 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
4302 # ifdef WARN_COMMENTS
4303 const char *md_shortopts
= "Vc";
4305 const char *md_shortopts
= "V";
4308 # ifdef WARN_COMMENTS
4309 const char *md_shortopts
= "c";
4311 const char *md_shortopts
= "";
4315 struct option md_longopts
[] = {
4316 #ifdef WARN_COMMENTS
4317 {"warn-comment", no_argument
, NULL
, 'c'},
4319 {NULL
, no_argument
, NULL
, 0}
4321 size_t md_longopts_size
= sizeof (md_longopts
);
4324 md_parse_option (c
, arg
)
4325 int c ATTRIBUTE_UNUSED
;
4326 char *arg ATTRIBUTE_UNUSED
;
4335 print_version_id ();
4338 #ifdef WARN_COMMENTS
4349 md_show_usage (stream
)
4350 FILE *stream ATTRIBUTE_UNUSED
;
4353 fprintf (stream
, _("\
4356 #ifdef WARN_COMMENTS
4357 fprintf (stream
, _("\
4358 -c print a warning if a comment is found\n"));
4362 /* We have no need to default values of symbols. */
4365 md_undefined_symbol (name
)
4366 char *name ATTRIBUTE_UNUSED
;
4371 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
4372 #define nonzero_dibits(x) \
4373 ((x) | (((x) & 0x55555555) << 1) | (((x) & 0xAAAAAAAA) >> 1))
4374 #define arg_reloc_stub_needed(CALLER, CALLEE) \
4375 (((CALLER) ^ (CALLEE)) & nonzero_dibits (CALLER) & nonzero_dibits (CALLEE))
4377 #define arg_reloc_stub_needed(CALLER, CALLEE) 0
4380 /* Apply a fixup to an instruction. */
4383 md_apply_fix (fixP
, valp
)
4388 struct hppa_fix_struct
*hppa_fixP
;
4392 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
4393 never be "applied" (they are just markers). Likewise for
4394 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
4396 if (fixP
->fx_r_type
== R_HPPA_ENTRY
4397 || fixP
->fx_r_type
== R_HPPA_EXIT
4398 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
4399 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
4400 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
4403 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
4404 fixups are considered not adjustable, which in turn causes
4405 adjust_reloc_syms to not set fx_offset. Ugh. */
4406 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
4408 fixP
->fx_offset
= *valp
;
4413 if (fixP
->fx_r_type
== (int) R_PARISC_GNU_VTENTRY
4414 || fixP
->fx_r_type
== (int) R_PARISC_GNU_VTINHERIT
)
4418 /* There should have been an HPPA specific fixup associated
4419 with the GAS fixup. */
4420 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
4421 if (hppa_fixP
== NULL
)
4423 printf (_("no hppa_fixup entry for fixup type 0x%x at %s:%d"),
4424 fixP
->fx_r_type
, fixP
->fx_file
, fixP
->fx_line
);
4428 buf
= fixP
->fx_frag
->fr_literal
+ fixP
->fx_where
;
4429 insn
= bfd_get_32 (stdoutput
, buf
);
4430 fmt
= bfd_hppa_insn2fmt (stdoutput
, insn
);
4432 /* If there is a symbol associated with this fixup, then it's something
4433 which will need a SOM relocation (except for some PC-relative relocs).
4434 In such cases we should treat the "val" or "addend" as zero since it
4435 will be added in as needed from fx_offset in tc_gen_reloc. */
4436 if ((fixP
->fx_addsy
!= NULL
4437 || fixP
->fx_r_type
== (int) R_HPPA_NONE
)
4442 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4444 /* These field selectors imply that we do not want an addend. */
4445 else if (hppa_fixP
->fx_r_field
== e_psel
4446 || hppa_fixP
->fx_r_field
== e_rpsel
4447 || hppa_fixP
->fx_r_field
== e_lpsel
4448 || hppa_fixP
->fx_r_field
== e_tsel
4449 || hppa_fixP
->fx_r_field
== e_rtsel
4450 || hppa_fixP
->fx_r_field
== e_ltsel
)
4451 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4452 /* This is truly disgusting. The machine independent code blindly
4453 adds in the value of the symbol being relocated against. Damn! */
4455 && fixP
->fx_addsy
!= NULL
4456 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
4457 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
4458 0, hppa_fixP
->fx_r_field
);
4461 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4463 /* Handle pc-relative exceptions from above. */
4464 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
4467 && !arg_reloc_stub_needed (symbol_arg_reloc_info (fixP
->fx_addsy
),
4468 hppa_fixP
->fx_arg_reloc
)
4470 && (*valp
- 8 + 8192 < 16384
4471 || (fmt
== 17 && *valp
- 8 + 262144 < 524288)
4472 || (fmt
== 22 && *valp
- 8 + 8388608 < 16777216))
4475 && (*valp
- 8 + 262144 < 524288
4476 || (fmt
== 22 && *valp
- 8 + 8388608 < 16777216))
4478 && !S_IS_EXTERNAL (fixP
->fx_addsy
)
4479 && !S_IS_WEAK (fixP
->fx_addsy
)
4480 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
4482 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
4484 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4490 CHECK_FIELD (new_val
, 8191, -8192, 0);
4493 insn
= (insn
& ~ 0x3ff1) | (((val
& 0x1ff8) << 1)
4494 | ((val
& 0x2000) >> 13));
4497 CHECK_FIELD (new_val
, 8191, -8192, 0);
4500 insn
= (insn
& ~ 0x3ff9) | (((val
& 0x1ffc) << 1)
4501 | ((val
& 0x2000) >> 13));
4503 /* Handle all opcodes with the 'j' operand type. */
4505 CHECK_FIELD (new_val
, 8191, -8192, 0);
4508 insn
= ((insn
& ~ 0x3fff) | low_sign_unext (val
, 14));
4511 /* Handle all opcodes with the 'k' operand type. */
4513 CHECK_FIELD (new_val
, 1048575, -1048576, 0);
4516 insn
= (insn
& ~ 0x1fffff) | re_assemble_21 (val
);
4519 /* Handle all the opcodes with the 'i' operand type. */
4521 CHECK_FIELD (new_val
, 1023, -1024, 0);
4524 insn
= (insn
& ~ 0x7ff) | low_sign_unext (val
, 11);
4527 /* Handle all the opcodes with the 'w' operand type. */
4529 CHECK_FIELD (new_val
- 8, 8191, -8192, 0);
4532 insn
= (insn
& ~ 0x1ffd) | re_assemble_12 (val
>> 2);
4535 /* Handle some of the opcodes with the 'W' operand type. */
4538 offsetT distance
= *valp
;
4540 /* If this is an absolute branch (ie no link) with an out of
4541 range target, then we want to complain. */
4542 if (fixP
->fx_r_type
== (int) R_HPPA_PCREL_CALL
4543 && (insn
& 0xffe00000) == 0xe8000000)
4544 CHECK_FIELD (distance
- 8, 262143, -262144, 0);
4546 CHECK_FIELD (new_val
- 8, 262143, -262144, 0);
4549 insn
= (insn
& ~ 0x1f1ffd) | re_assemble_17 (val
>> 2);
4555 offsetT distance
= *valp
;
4557 /* If this is an absolute branch (ie no link) with an out of
4558 range target, then we want to complain. */
4559 if (fixP
->fx_r_type
== (int) R_HPPA_PCREL_CALL
4560 && (insn
& 0xffe00000) == 0xe8000000)
4561 CHECK_FIELD (distance
- 8, 8388607, -8388608, 0);
4563 CHECK_FIELD (new_val
- 8, 8388607, -8388608, 0);
4566 insn
= (insn
& ~ 0x3ff1ffd) | re_assemble_22 (val
>> 2);
4572 insn
= (insn
& ~ 0xfff1) | re_assemble_16 (val
& -8);
4577 insn
= (insn
& ~ 0xfff9) | re_assemble_16 (val
& -4);
4582 insn
= (insn
& ~ 0xffff) | re_assemble_16 (val
);
4590 as_bad (_("Unknown relocation encountered in md_apply_fix."));
4594 /* Insert the relocation. */
4595 bfd_put_32 (stdoutput
, insn
, buf
);
4599 /* Exactly what point is a PC-relative offset relative TO?
4600 On the PA, they're relative to the address of the offset. */
4603 md_pcrel_from (fixP
)
4606 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
4609 /* Return nonzero if the input line pointer is at the end of
4613 is_end_of_statement ()
4615 return ((*input_line_pointer
== '\n')
4616 || (*input_line_pointer
== ';')
4617 || (*input_line_pointer
== '!'));
4620 /* Read a number from S. The number might come in one of many forms,
4621 the most common will be a hex or decimal constant, but it could be
4622 a pre-defined register (Yuk!), or an absolute symbol.
4624 Return 1 on success or 0 on failure. If STRICT, then a missing
4625 register prefix will cause a failure. The number itself is
4626 returned in `pa_number'.
4628 IS_FLOAT indicates that a PA-89 FP register number should be
4629 parsed; A `l' or `r' suffix is checked for if but 2 of IS_FLOAT is
4632 pa_parse_number can not handle negative constants and will fail
4633 horribly if it is passed such a constant. */
4636 pa_parse_number (s
, is_float
)
4646 boolean have_prefix
;
4648 /* Skip whitespace before the number. */
4649 while (*p
== ' ' || *p
== '\t')
4655 if (!strict
&& isdigit (*p
))
4657 /* Looks like a number. */
4659 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
4661 /* The number is specified in hex. */
4663 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
4664 || ((*p
>= 'A') && (*p
<= 'F')))
4667 num
= num
* 16 + *p
- '0';
4668 else if (*p
>= 'a' && *p
<= 'f')
4669 num
= num
* 16 + *p
- 'a' + 10;
4671 num
= num
* 16 + *p
- 'A' + 10;
4677 /* The number is specified in decimal. */
4678 while (isdigit (*p
))
4680 num
= num
* 10 + *p
- '0';
4687 /* Check for a `l' or `r' suffix. */
4690 pa_number
+= FP_REG_BASE
;
4691 if (! (is_float
& 2))
4693 if (IS_R_SELECT (p
))
4695 pa_number
+= FP_REG_RSEL
;
4698 else if (IS_L_SELECT (p
))
4707 /* The number might be a predefined register. */
4712 /* Tege hack: Special case for general registers as the general
4713 code makes a binary search with case translation, and is VERY
4718 if (*p
== 'e' && *(p
+ 1) == 't'
4719 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
4722 num
= *p
- '0' + 28;
4730 else if (!isdigit (*p
))
4733 as_bad (_("Undefined register: '%s'."), name
);
4739 num
= num
* 10 + *p
++ - '0';
4740 while (isdigit (*p
));
4745 /* Do a normal register search. */
4746 while (is_part_of_name (c
))
4752 status
= reg_name_search (name
);
4758 as_bad (_("Undefined register: '%s'."), name
);
4768 /* And finally, it could be a symbol in the absolute section which
4769 is effectively a constant, or a register alias symbol. */
4772 while (is_part_of_name (c
))
4778 if ((sym
= symbol_find (name
)) != NULL
)
4780 if (S_GET_SEGMENT (sym
) == reg_section
)
4782 num
= S_GET_VALUE (sym
);
4783 /* Well, we don't really have one, but we do have a
4787 else if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
4788 num
= S_GET_VALUE (sym
);
4792 as_bad (_("Non-absolute symbol: '%s'."), name
);
4798 /* There is where we'd come for an undefined symbol
4799 or for an empty string. For an empty string we
4800 will return zero. That's a concession made for
4801 compatability with the braindamaged HP assemblers. */
4807 as_bad (_("Undefined absolute constant: '%s'."), name
);
4816 if (!strict
|| have_prefix
)
4824 #define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg))
4826 /* Given NAME, find the register number associated with that name, return
4827 the integer value associated with the given name or -1 on failure. */
4830 reg_name_search (name
)
4833 int middle
, low
, high
;
4837 high
= REG_NAME_CNT
- 1;
4841 middle
= (low
+ high
) / 2;
4842 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
4848 return pre_defined_registers
[middle
].value
;
4850 while (low
<= high
);
4855 /* Return nonzero if the given INSN and L/R information will require
4856 a new PA-1.1 opcode. */
4861 if ((pa_number
& FP_REG_RSEL
) != 0
4862 && !(the_insn
.fpof1
== DBL
&& the_insn
.fpof2
== DBL
))
4864 /* If this instruction is specific to a particular architecture,
4865 then set a new architecture. */
4866 if (bfd_get_mach (stdoutput
) < pa11
)
4868 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
4869 as_warn (_("could not update architecture and machine"));
4877 /* Parse a condition for a fcmp instruction. Return the numerical
4878 code associated with the condition. */
4881 pa_parse_fp_cmp_cond (s
)
4888 for (i
= 0; i
< 32; i
++)
4890 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
4891 strlen (fp_cond_map
[i
].string
)) == 0)
4893 cond
= fp_cond_map
[i
].cond
;
4894 *s
+= strlen (fp_cond_map
[i
].string
);
4895 /* If not a complete match, back up the input string and
4897 if (**s
!= ' ' && **s
!= '\t')
4899 *s
-= strlen (fp_cond_map
[i
].string
);
4902 while (**s
== ' ' || **s
== '\t')
4908 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
4910 /* Advance over the bogus completer. */
4911 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4917 /* Parse a graphics test complete for ftest. */
4920 pa_parse_ftest_gfx_completer (s
)
4926 if (strncasecmp (*s
, "acc8", 4) == 0)
4931 else if (strncasecmp (*s
, "acc6", 4) == 0)
4936 else if (strncasecmp (*s
, "acc4", 4) == 0)
4941 else if (strncasecmp (*s
, "acc2", 4) == 0)
4946 else if (strncasecmp (*s
, "acc", 3) == 0)
4951 else if (strncasecmp (*s
, "rej8", 4) == 0)
4956 else if (strncasecmp (*s
, "rej", 3) == 0)
4964 as_bad (_("Invalid FTEST completer: %s"), *s
);
4970 /* Parse an FP operand format completer returning the completer
4973 static fp_operand_format
4974 pa_parse_fp_cnv_format (s
)
4983 if (strncasecmp (*s
, "sgl", 3) == 0)
4988 else if (strncasecmp (*s
, "dbl", 3) == 0)
4993 else if (strncasecmp (*s
, "quad", 4) == 0)
4998 else if (strncasecmp (*s
, "w", 1) == 0)
5003 else if (strncasecmp (*s
, "uw", 2) == 0)
5008 else if (strncasecmp (*s
, "dw", 2) == 0)
5013 else if (strncasecmp (*s
, "udw", 3) == 0)
5018 else if (strncasecmp (*s
, "qw", 2) == 0)
5023 else if (strncasecmp (*s
, "uqw", 3) == 0)
5030 format
= ILLEGAL_FMT
;
5031 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
5038 /* Parse an FP operand format completer returning the completer
5041 static fp_operand_format
5042 pa_parse_fp_format (s
)
5051 if (strncasecmp (*s
, "sgl", 3) == 0)
5056 else if (strncasecmp (*s
, "dbl", 3) == 0)
5061 else if (strncasecmp (*s
, "quad", 4) == 0)
5068 format
= ILLEGAL_FMT
;
5069 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
5076 /* Convert from a selector string into a selector type. */
5079 pa_chk_field_selector (str
)
5082 int middle
, low
, high
;
5086 /* Read past any whitespace. */
5087 /* FIXME: should we read past newlines and formfeeds??? */
5088 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
5091 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
5092 name
[0] = tolower ((*str
)[0]),
5094 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
5095 name
[0] = tolower ((*str
)[0]),
5096 name
[1] = tolower ((*str
)[1]),
5098 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
5099 name
[0] = tolower ((*str
)[0]),
5100 name
[1] = tolower ((*str
)[1]),
5101 name
[2] = tolower ((*str
)[2]),
5107 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
5111 middle
= (low
+ high
) / 2;
5112 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
5119 *str
+= strlen (name
) + 1;
5121 if (selector_table
[middle
].field_selector
== e_nsel
)
5124 return selector_table
[middle
].field_selector
;
5127 while (low
<= high
);
5132 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
5135 get_expression (str
)
5141 save_in
= input_line_pointer
;
5142 input_line_pointer
= str
;
5143 seg
= expression (&the_insn
.exp
);
5144 if (!(seg
== absolute_section
5145 || seg
== undefined_section
5146 || SEG_NORMAL (seg
)))
5148 as_warn (_("Bad segment in expression."));
5149 expr_end
= input_line_pointer
;
5150 input_line_pointer
= save_in
;
5153 expr_end
= input_line_pointer
;
5154 input_line_pointer
= save_in
;
5158 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
5160 pa_get_absolute_expression (insn
, strp
)
5166 insn
->field_selector
= pa_chk_field_selector (strp
);
5167 save_in
= input_line_pointer
;
5168 input_line_pointer
= *strp
;
5169 expression (&insn
->exp
);
5170 /* This is not perfect, but is a huge improvement over doing nothing.
5172 The PA assembly syntax is ambigious in a variety of ways. Consider
5173 this string "4 %r5" Is that the number 4 followed by the register
5174 r5, or is that 4 MOD r5?
5176 If we get a modulo expresion When looking for an absolute, we try
5177 again cutting off the input string at the first whitespace character. */
5178 if (insn
->exp
.X_op
== O_modulus
)
5183 input_line_pointer
= *strp
;
5185 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
5191 retval
= pa_get_absolute_expression (insn
, strp
);
5193 input_line_pointer
= save_in
;
5195 return evaluate_absolute (insn
);
5197 /* When in strict mode we have a non-match, fix up the pointers
5198 and return to our caller. */
5199 if (insn
->exp
.X_op
!= O_constant
&& strict
)
5201 expr_end
= input_line_pointer
;
5202 input_line_pointer
= save_in
;
5205 if (insn
->exp
.X_op
!= O_constant
)
5207 as_bad (_("Bad segment (should be absolute)."));
5208 expr_end
= input_line_pointer
;
5209 input_line_pointer
= save_in
;
5212 expr_end
= input_line_pointer
;
5213 input_line_pointer
= save_in
;
5214 return evaluate_absolute (insn
);
5217 /* Evaluate an absolute expression EXP which may be modified by
5218 the selector FIELD_SELECTOR. Return the value of the expression. */
5220 evaluate_absolute (insn
)
5225 int field_selector
= insn
->field_selector
;
5228 value
= exp
.X_add_number
;
5230 return hppa_field_adjust (0, value
, field_selector
);
5233 /* Given an argument location specification return the associated
5234 argument location number. */
5237 pa_build_arg_reloc (type_name
)
5241 if (strncasecmp (type_name
, "no", 2) == 0)
5243 if (strncasecmp (type_name
, "gr", 2) == 0)
5245 else if (strncasecmp (type_name
, "fr", 2) == 0)
5247 else if (strncasecmp (type_name
, "fu", 2) == 0)
5250 as_bad (_("Invalid argument location: %s\n"), type_name
);
5255 /* Encode and return an argument relocation specification for
5256 the given register in the location specified by arg_reloc. */
5259 pa_align_arg_reloc (reg
, arg_reloc
)
5261 unsigned int arg_reloc
;
5263 unsigned int new_reloc
;
5265 new_reloc
= arg_reloc
;
5281 as_bad (_("Invalid argument description: %d"), reg
);
5287 /* Parse a PA nullification completer (,n). Return nonzero if the
5288 completer was found; return zero if no completer was found. */
5300 if (strncasecmp (*s
, "n", 1) == 0)
5304 as_bad (_("Invalid Nullification: (%c)"), **s
);
5313 /* Parse a non-negated compare/subtract completer returning the
5314 number (for encoding in instrutions) of the given completer.
5316 ISBRANCH specifies whether or not this is parsing a condition
5317 completer for a branch (vs a nullification completer for a
5318 computational instruction. */
5321 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
5326 char *name
= *s
+ 1;
5335 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5340 if (strcmp (name
, "=") == 0)
5344 else if (strcmp (name
, "<") == 0)
5348 else if (strcmp (name
, "<=") == 0)
5352 else if (strcmp (name
, "<<") == 0)
5356 else if (strcmp (name
, "<<=") == 0)
5360 else if (strcasecmp (name
, "sv") == 0)
5364 else if (strcasecmp (name
, "od") == 0)
5368 /* If we have something like addb,n then there is no condition
5370 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5382 /* Reset pointers if this was really a ,n for a branch instruction. */
5389 /* Parse a negated compare/subtract completer returning the
5390 number (for encoding in instrutions) of the given completer.
5392 ISBRANCH specifies whether or not this is parsing a condition
5393 completer for a branch (vs a nullification completer for a
5394 computational instruction. */
5397 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
5402 char *name
= *s
+ 1;
5411 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5416 if (strcasecmp (name
, "tr") == 0)
5420 else if (strcmp (name
, "<>") == 0)
5424 else if (strcmp (name
, ">=") == 0)
5428 else if (strcmp (name
, ">") == 0)
5432 else if (strcmp (name
, ">>=") == 0)
5436 else if (strcmp (name
, ">>") == 0)
5440 else if (strcasecmp (name
, "nsv") == 0)
5444 else if (strcasecmp (name
, "ev") == 0)
5448 /* If we have something like addb,n then there is no condition
5450 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5462 /* Reset pointers if this was really a ,n for a branch instruction. */
5469 /* Parse a 64 bit compare and branch completer returning the number (for
5470 encoding in instrutions) of the given completer.
5472 Nonnegated comparisons are returned as 0-7, negated comparisons are
5473 returned as 8-15. */
5476 pa_parse_cmpb_64_cmpltr (s
)
5480 char *name
= *s
+ 1;
5487 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5492 if (strcmp (name
, "*") == 0)
5496 else if (strcmp (name
, "*=") == 0)
5500 else if (strcmp (name
, "*<") == 0)
5504 else if (strcmp (name
, "*<=") == 0)
5508 else if (strcmp (name
, "*<<") == 0)
5512 else if (strcmp (name
, "*<<=") == 0)
5516 else if (strcasecmp (name
, "*sv") == 0)
5520 else if (strcasecmp (name
, "*od") == 0)
5524 else if (strcasecmp (name
, "*tr") == 0)
5528 else if (strcmp (name
, "*<>") == 0)
5532 else if (strcmp (name
, "*>=") == 0)
5536 else if (strcmp (name
, "*>") == 0)
5540 else if (strcmp (name
, "*>>=") == 0)
5544 else if (strcmp (name
, "*>>") == 0)
5548 else if (strcasecmp (name
, "*nsv") == 0)
5552 else if (strcasecmp (name
, "*ev") == 0)
5566 /* Parse a 64 bit compare immediate and branch completer returning the number
5567 (for encoding in instrutions) of the given completer. */
5570 pa_parse_cmpib_64_cmpltr (s
)
5574 char *name
= *s
+ 1;
5581 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5586 if (strcmp (name
, "*<<") == 0)
5590 else if (strcmp (name
, "*=") == 0)
5594 else if (strcmp (name
, "*<") == 0)
5598 else if (strcmp (name
, "*<=") == 0)
5602 else if (strcmp (name
, "*>>=") == 0)
5606 else if (strcmp (name
, "*<>") == 0)
5610 else if (strcasecmp (name
, "*>=") == 0)
5614 else if (strcasecmp (name
, "*>") == 0)
5628 /* Parse a non-negated addition completer returning the number
5629 (for encoding in instrutions) of the given completer.
5631 ISBRANCH specifies whether or not this is parsing a condition
5632 completer for a branch (vs a nullification completer for a
5633 computational instruction. */
5636 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
5641 char *name
= *s
+ 1;
5649 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5653 if (strcmp (name
, "=") == 0)
5657 else if (strcmp (name
, "<") == 0)
5661 else if (strcmp (name
, "<=") == 0)
5665 else if (strcasecmp (name
, "nuv") == 0)
5669 else if (strcasecmp (name
, "znv") == 0)
5673 else if (strcasecmp (name
, "sv") == 0)
5677 else if (strcasecmp (name
, "od") == 0)
5681 /* If we have something like addb,n then there is no condition
5683 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5694 /* Reset pointers if this was really a ,n for a branch instruction. */
5695 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5701 /* Parse a negated addition completer returning the number
5702 (for encoding in instrutions) of the given completer.
5704 ISBRANCH specifies whether or not this is parsing a condition
5705 completer for a branch (vs a nullification completer for a
5706 computational instruction). */
5709 pa_parse_neg_add_cmpltr (s
, isbranch
)
5714 char *name
= *s
+ 1;
5722 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5726 if (strcasecmp (name
, "tr") == 0)
5730 else if (strcmp (name
, "<>") == 0)
5734 else if (strcmp (name
, ">=") == 0)
5738 else if (strcmp (name
, ">") == 0)
5742 else if (strcasecmp (name
, "uv") == 0)
5746 else if (strcasecmp (name
, "vnz") == 0)
5750 else if (strcasecmp (name
, "nsv") == 0)
5754 else if (strcasecmp (name
, "ev") == 0)
5758 /* If we have something like addb,n then there is no condition
5760 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5771 /* Reset pointers if this was really a ,n for a branch instruction. */
5772 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5778 /* Parse a 64 bit wide mode add and branch completer returning the number (for
5779 encoding in instrutions) of the given completer. */
5782 pa_parse_addb_64_cmpltr (s
)
5786 char *name
= *s
+ 1;
5795 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5799 if (strcmp (name
, "=") == 0)
5803 else if (strcmp (name
, "<") == 0)
5807 else if (strcmp (name
, "<=") == 0)
5811 else if (strcasecmp (name
, "nuv") == 0)
5815 else if (strcasecmp (name
, "*=") == 0)
5819 else if (strcasecmp (name
, "*<") == 0)
5823 else if (strcasecmp (name
, "*<=") == 0)
5827 else if (strcmp (name
, "tr") == 0)
5831 else if (strcmp (name
, "<>") == 0)
5835 else if (strcmp (name
, ">=") == 0)
5839 else if (strcmp (name
, ">") == 0)
5843 else if (strcasecmp (name
, "uv") == 0)
5847 else if (strcasecmp (name
, "*<>") == 0)
5851 else if (strcasecmp (name
, "*>=") == 0)
5855 else if (strcasecmp (name
, "*>") == 0)
5859 /* If we have something like addb,n then there is no condition
5861 else if (strcasecmp (name
, "n") == 0)
5873 /* Reset pointers if this was really a ,n for a branch instruction. */
5881 /* Handle an alignment directive. Special so that we can update the
5882 alignment of the subspace if necessary. */
5887 /* We must have a valid space and subspace. */
5888 pa_check_current_space_and_subspace ();
5890 /* Let the generic gas code do most of the work. */
5891 s_align_bytes (bytes
);
5893 /* If bytes is a power of 2, then update the current subspace's
5894 alignment if necessary. */
5895 if (log2 (bytes
) != -1)
5896 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
5900 /* Handle a .BLOCK type pseudo-op. */
5904 int z ATTRIBUTE_UNUSED
;
5908 unsigned int temp_size
;
5912 /* We must have a valid space and subspace. */
5913 pa_check_current_space_and_subspace ();
5916 temp_size
= get_absolute_expression ();
5918 /* Always fill with zeros, that's what the HP assembler does. */
5921 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
5922 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
5923 memset (p
, 0, temp_size
);
5925 /* Convert 2 bytes at a time. */
5927 for (i
= 0; i
< temp_size
; i
+= 2)
5929 md_number_to_chars (p
+ i
,
5931 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
5934 pa_undefine_label ();
5935 demand_empty_rest_of_line ();
5938 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
5942 int begin ATTRIBUTE_UNUSED
;
5946 /* The BRTAB relocations are only availble in SOM (to denote
5947 the beginning and end of branch tables). */
5948 char *where
= frag_more (0);
5950 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5951 NULL
, (offsetT
) 0, NULL
,
5952 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
5956 demand_empty_rest_of_line ();
5959 /* Handle a .begin_try and .end_try pseudo-op. */
5963 int begin ATTRIBUTE_UNUSED
;
5967 char *where
= frag_more (0);
5972 /* The TRY relocations are only availble in SOM (to denote
5973 the beginning and end of exception handling regions). */
5975 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5976 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
5977 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
5981 demand_empty_rest_of_line ();
5984 /* Handle a .CALL pseudo-op. This involves storing away information
5985 about where arguments are to be found so the linker can detect
5986 (and correct) argument location mismatches between caller and callee. */
5990 int unused ATTRIBUTE_UNUSED
;
5993 /* We must have a valid space and subspace. */
5994 pa_check_current_space_and_subspace ();
5997 pa_call_args (&last_call_desc
);
5998 demand_empty_rest_of_line ();
6001 /* Do the dirty work of building a call descriptor which describes
6002 where the caller placed arguments to a function call. */
6005 pa_call_args (call_desc
)
6006 struct call_desc
*call_desc
;
6009 unsigned int temp
, arg_reloc
;
6011 while (!is_end_of_statement ())
6013 name
= input_line_pointer
;
6014 c
= get_symbol_end ();
6015 /* Process a source argument. */
6016 if ((strncasecmp (name
, "argw", 4) == 0))
6018 temp
= atoi (name
+ 4);
6019 p
= input_line_pointer
;
6021 input_line_pointer
++;
6022 name
= input_line_pointer
;
6023 c
= get_symbol_end ();
6024 arg_reloc
= pa_build_arg_reloc (name
);
6025 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
6027 /* Process a return value. */
6028 else if ((strncasecmp (name
, "rtnval", 6) == 0))
6030 p
= input_line_pointer
;
6032 input_line_pointer
++;
6033 name
= input_line_pointer
;
6034 c
= get_symbol_end ();
6035 arg_reloc
= pa_build_arg_reloc (name
);
6036 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
6040 as_bad (_("Invalid .CALL argument: %s"), name
);
6042 p
= input_line_pointer
;
6044 if (!is_end_of_statement ())
6045 input_line_pointer
++;
6049 /* Return TRUE if FRAG1 and FRAG2 are the same. */
6052 is_same_frag (frag1
, frag2
)
6059 else if (frag2
== NULL
)
6061 else if (frag1
== frag2
)
6063 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
6064 return (is_same_frag (frag1
, frag2
->fr_next
));
6070 /* Build an entry in the UNWIND subspace from the given function
6071 attributes in CALL_INFO. This is not needed for SOM as using
6072 R_ENTRY and R_EXIT relocations allow the linker to handle building
6073 of the unwind spaces. */
6076 pa_build_unwind_subspace (call_info
)
6077 struct call_info
*call_info
;
6079 asection
*seg
, *save_seg
;
6080 subsegT save_subseg
;
6081 unsigned int unwind
;
6085 if ((bfd_get_section_flags (stdoutput
, now_seg
)
6086 & (SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
))
6087 != (SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
))
6090 reloc
= R_PARISC_SEGREL32
;
6092 save_subseg
= now_subseg
;
6093 /* Get into the right seg/subseg. This may involve creating
6094 the seg the first time through. Make sure to have the
6095 old seg/subseg so that we can reset things when we are done. */
6096 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
6097 if (seg
== ASEC_NULL
)
6099 seg
= subseg_new (UNWIND_SECTION_NAME
, 0);
6100 bfd_set_section_flags (stdoutput
, seg
,
6101 SEC_READONLY
| SEC_HAS_CONTENTS
6102 | SEC_LOAD
| SEC_RELOC
| SEC_ALLOC
| SEC_DATA
);
6103 bfd_set_section_alignment (stdoutput
, seg
, 2);
6106 subseg_set (seg
, 0);
6108 /* Get some space to hold relocation information for the unwind
6112 /* Relocation info. for start offset of the function. */
6113 md_number_to_chars (p
, 0, 4);
6114 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
6115 call_info
->start_symbol
, (offsetT
) 0,
6116 (expressionS
*) NULL
, 0, reloc
,
6119 /* Relocation info. for end offset of the function.
6121 Because we allow reductions of 32bit relocations for ELF, this will be
6122 reduced to section_sym + offset which avoids putting the temporary
6123 symbol into the symbol table. It (should) end up giving the same
6124 value as call_info->start_symbol + function size once the linker is
6125 finished with its work. */
6126 md_number_to_chars (p
+ 4, 0, 4);
6127 fix_new_hppa (frag_now
, p
+ 4 - frag_now
->fr_literal
, 4,
6128 call_info
->end_symbol
, (offsetT
) 0,
6129 (expressionS
*) NULL
, 0, reloc
,
6132 /* Dump the descriptor. */
6133 unwind
= UNWIND_LOW32 (&call_info
->ci_unwind
.descriptor
);
6134 md_number_to_chars (p
+ 8, unwind
, 4);
6136 unwind
= UNWIND_HIGH32 (&call_info
->ci_unwind
.descriptor
);
6137 md_number_to_chars (p
+ 12, unwind
, 4);
6139 /* Return back to the original segment/subsegment. */
6140 subseg_set (save_seg
, save_subseg
);
6144 /* Process a .CALLINFO pseudo-op. This information is used later
6145 to build unwind descriptors and maybe one day to support
6146 .ENTER and .LEAVE. */
6149 pa_callinfo (unused
)
6150 int unused ATTRIBUTE_UNUSED
;
6156 /* We must have a valid space and subspace. */
6157 pa_check_current_space_and_subspace ();
6160 /* .CALLINFO must appear within a procedure definition. */
6161 if (!within_procedure
)
6162 as_bad (_(".callinfo is not within a procedure definition"));
6164 /* Mark the fact that we found the .CALLINFO for the
6165 current procedure. */
6166 callinfo_found
= TRUE
;
6168 /* Iterate over the .CALLINFO arguments. */
6169 while (!is_end_of_statement ())
6171 name
= input_line_pointer
;
6172 c
= get_symbol_end ();
6173 /* Frame size specification. */
6174 if ((strncasecmp (name
, "frame", 5) == 0))
6176 p
= input_line_pointer
;
6178 input_line_pointer
++;
6179 temp
= get_absolute_expression ();
6180 if ((temp
& 0x3) != 0)
6182 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
6186 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
6187 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
6190 /* Entry register (GR, GR and SR) specifications. */
6191 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
6193 p
= input_line_pointer
;
6195 input_line_pointer
++;
6196 temp
= get_absolute_expression ();
6197 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
6198 even though %r19 is caller saved. I think this is a bug in
6199 the HP assembler, and we are not going to emulate it. */
6200 if (temp
< 3 || temp
> 18)
6201 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
6202 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
6204 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
6206 p
= input_line_pointer
;
6208 input_line_pointer
++;
6209 temp
= get_absolute_expression ();
6210 /* Similarly the HP assembler takes 31 as the high bound even
6211 though %fr21 is the last callee saved floating point register. */
6212 if (temp
< 12 || temp
> 21)
6213 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
6214 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
6216 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
6218 p
= input_line_pointer
;
6220 input_line_pointer
++;
6221 temp
= get_absolute_expression ();
6223 as_bad (_("Value for ENTRY_SR must be 3\n"));
6225 /* Note whether or not this function performs any calls. */
6226 else if ((strncasecmp (name
, "calls", 5) == 0) ||
6227 (strncasecmp (name
, "caller", 6) == 0))
6229 p
= input_line_pointer
;
6232 else if ((strncasecmp (name
, "no_calls", 8) == 0))
6234 p
= input_line_pointer
;
6237 /* Should RP be saved into the stack. */
6238 else if ((strncasecmp (name
, "save_rp", 7) == 0))
6240 p
= input_line_pointer
;
6242 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
6244 /* Likewise for SP. */
6245 else if ((strncasecmp (name
, "save_sp", 7) == 0))
6247 p
= input_line_pointer
;
6249 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
6251 /* Is this an unwindable procedure. If so mark it so
6252 in the unwind descriptor. */
6253 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
6255 p
= input_line_pointer
;
6257 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
6259 /* Is this an interrupt routine. If so mark it in the
6260 unwind descriptor. */
6261 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
6263 p
= input_line_pointer
;
6265 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
6267 /* Is this a millicode routine. "millicode" isn't in my
6268 assembler manual, but my copy is old. The HP assembler
6269 accepts it, and there's a place in the unwind descriptor
6270 to drop the information, so we'll accept it too. */
6271 else if ((strncasecmp (name
, "millicode", 9) == 0))
6273 p
= input_line_pointer
;
6275 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
6279 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
6280 *input_line_pointer
= c
;
6282 if (!is_end_of_statement ())
6283 input_line_pointer
++;
6286 demand_empty_rest_of_line ();
6289 #if !(defined (OBJ_ELF) && defined (TE_LINUX))
6290 /* Switch to the text space. Like s_text, but delete our
6291 label when finished. */
6294 int unused ATTRIBUTE_UNUSED
;
6297 current_space
= is_defined_space ("$TEXT$");
6299 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6303 pa_undefine_label ();
6306 /* Switch to the data space. As usual delete our label. */
6309 int unused ATTRIBUTE_UNUSED
;
6312 current_space
= is_defined_space ("$PRIVATE$");
6314 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6317 pa_undefine_label ();
6320 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
6321 the .comm pseudo-op has the following symtax:
6323 <label> .comm <length>
6325 where <label> is optional and is a symbol whose address will be the start of
6326 a block of memory <length> bytes long. <length> must be an absolute
6327 expression. <length> bytes will be allocated in the current space
6330 Also note the label may not even be on the same line as the .comm.
6332 This difference in syntax means the colon function will be called
6333 on the symbol before we arrive in pa_comm. colon will set a number
6334 of attributes of the symbol that need to be fixed here. In particular
6335 the value, section pointer, fragment pointer, flags, etc. What
6338 This also makes error detection all but impossible. */
6342 int unused ATTRIBUTE_UNUSED
;
6346 label_symbol_struct
*label_symbol
= pa_get_label ();
6349 symbol
= label_symbol
->lss_label
;
6354 size
= get_absolute_expression ();
6358 S_SET_VALUE (symbol
, size
);
6359 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6360 S_SET_EXTERNAL (symbol
);
6362 /* colon() has already set the frag to the current location in the
6363 current subspace; we need to reset the fragment to the zero address
6364 fragment. We also need to reset the segment pointer. */
6365 symbol_set_frag (symbol
, &zero_address_frag
);
6367 demand_empty_rest_of_line ();
6369 #endif /* !(defined (OBJ_ELF) && defined (TE_LINUX)) */
6371 /* Process a .END pseudo-op. */
6375 int unused ATTRIBUTE_UNUSED
;
6377 demand_empty_rest_of_line ();
6380 /* Process a .ENTER pseudo-op. This is not supported. */
6383 int unused ATTRIBUTE_UNUSED
;
6386 /* We must have a valid space and subspace. */
6387 pa_check_current_space_and_subspace ();
6390 as_bad (_("The .ENTER pseudo-op is not supported"));
6391 demand_empty_rest_of_line ();
6394 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
6398 int unused ATTRIBUTE_UNUSED
;
6401 /* We must have a valid space and subspace. */
6402 pa_check_current_space_and_subspace ();
6405 if (!within_procedure
)
6406 as_bad (_("Misplaced .entry. Ignored."));
6409 if (!callinfo_found
)
6410 as_bad (_("Missing .callinfo."));
6412 demand_empty_rest_of_line ();
6413 within_entry_exit
= TRUE
;
6416 /* SOM defers building of unwind descriptors until the link phase.
6417 The assembler is responsible for creating an R_ENTRY relocation
6418 to mark the beginning of a region and hold the unwind bits, and
6419 for creating an R_EXIT relocation to mark the end of the region.
6421 FIXME. ELF should be using the same conventions! The problem
6422 is an unwind requires too much relocation space. Hmmm. Maybe
6423 if we split the unwind bits up between the relocations which
6424 denote the entry and exit points. */
6425 if (last_call_info
->start_symbol
!= NULL
)
6430 where
= frag_more (0);
6431 u
= UNWIND_LOW32 (&last_call_info
->ci_unwind
.descriptor
);
6432 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6433 NULL
, (offsetT
) 0, NULL
,
6434 0, R_HPPA_ENTRY
, e_fsel
, 0, 0, u
);
6439 /* Silly nonsense for pa_equ. The only half-sensible use for this is
6440 being able to subtract two register symbols that specify a range of
6441 registers, to get the size of the range. */
6442 static int fudge_reg_expressions
;
6445 hppa_force_reg_syms_absolute (resultP
, op
, rightP
)
6446 expressionS
*resultP
;
6447 operatorT op ATTRIBUTE_UNUSED
;
6448 expressionS
*rightP
;
6450 if (fudge_reg_expressions
6451 && rightP
->X_op
== O_register
6452 && resultP
->X_op
== O_register
)
6454 rightP
->X_op
= O_constant
;
6455 resultP
->X_op
= O_constant
;
6457 return 0; /* Continue normal expr handling. */
6460 /* Handle a .EQU pseudo-op. */
6466 label_symbol_struct
*label_symbol
= pa_get_label ();
6471 symbol
= label_symbol
->lss_label
;
6475 if (!pa_parse_number (&input_line_pointer
, 0))
6476 as_bad (_(".REG expression must be a register"));
6477 S_SET_VALUE (symbol
, pa_number
);
6478 S_SET_SEGMENT (symbol
, reg_section
);
6485 fudge_reg_expressions
= 1;
6486 seg
= expression (&exp
);
6487 fudge_reg_expressions
= 0;
6488 if (exp
.X_op
!= O_constant
6489 && exp
.X_op
!= O_register
)
6491 if (exp
.X_op
!= O_absent
)
6492 as_bad (_("bad or irreducible absolute expression; zero assumed"));
6493 exp
.X_add_number
= 0;
6494 seg
= absolute_section
;
6496 S_SET_VALUE (symbol
, (unsigned int) exp
.X_add_number
);
6497 S_SET_SEGMENT (symbol
, seg
);
6503 as_bad (_(".REG must use a label"));
6505 as_bad (_(".EQU must use a label"));
6508 pa_undefine_label ();
6509 demand_empty_rest_of_line ();
6512 /* Helper function. Does processing for the end of a function. This
6513 usually involves creating some relocations or building special
6514 symbols to mark the end of the function. */
6521 where
= frag_more (0);
6524 /* Mark the end of the function, stuff away the location of the frag
6525 for the end of the function, and finally call pa_build_unwind_subspace
6526 to add an entry in the unwind table. */
6527 hppa_elf_mark_end_of_function ();
6528 pa_build_unwind_subspace (last_call_info
);
6530 /* SOM defers building of unwind descriptors until the link phase.
6531 The assembler is responsible for creating an R_ENTRY relocation
6532 to mark the beginning of a region and hold the unwind bits, and
6533 for creating an R_EXIT relocation to mark the end of the region.
6535 FIXME. ELF should be using the same conventions! The problem
6536 is an unwind requires too much relocation space. Hmmm. Maybe
6537 if we split the unwind bits up between the relocations which
6538 denote the entry and exit points. */
6539 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6541 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
6542 UNWIND_HIGH32 (&last_call_info
->ci_unwind
.descriptor
));
6546 /* Process a .EXIT pseudo-op. */
6550 int unused ATTRIBUTE_UNUSED
;
6553 /* We must have a valid space and subspace. */
6554 pa_check_current_space_and_subspace ();
6557 if (!within_procedure
)
6558 as_bad (_(".EXIT must appear within a procedure"));
6561 if (!callinfo_found
)
6562 as_bad (_("Missing .callinfo"));
6565 if (!within_entry_exit
)
6566 as_bad (_("No .ENTRY for this .EXIT"));
6569 within_entry_exit
= FALSE
;
6574 demand_empty_rest_of_line ();
6577 /* Process a .EXPORT directive. This makes functions external
6578 and provides information such as argument relocation entries
6583 int unused ATTRIBUTE_UNUSED
;
6588 name
= input_line_pointer
;
6589 c
= get_symbol_end ();
6590 /* Make sure the given symbol exists. */
6591 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6593 as_bad (_("Cannot define export symbol: %s\n"), name
);
6594 p
= input_line_pointer
;
6596 input_line_pointer
++;
6600 /* OK. Set the external bits and process argument relocations.
6601 For the HP, weak and global are not mutually exclusive.
6602 S_SET_EXTERNAL will not set BSF_GLOBAL if WEAK is set.
6603 Call S_SET_EXTERNAL to get the other processing. Manually
6604 set BSF_GLOBAL when we get back. */
6605 S_SET_EXTERNAL (symbol
);
6606 symbol_get_bfdsym (symbol
)->flags
|= BSF_GLOBAL
;
6607 p
= input_line_pointer
;
6609 if (!is_end_of_statement ())
6611 input_line_pointer
++;
6612 pa_type_args (symbol
, 1);
6616 demand_empty_rest_of_line ();
6619 /* Helper function to process arguments to a .EXPORT pseudo-op. */
6622 pa_type_args (symbolP
, is_export
)
6627 unsigned int temp
, arg_reloc
;
6628 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
6629 asymbol
*bfdsym
= symbol_get_bfdsym (symbolP
);
6631 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
6634 input_line_pointer
+= 8;
6635 bfdsym
->flags
&= ~BSF_FUNCTION
;
6636 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
6637 type
= SYMBOL_TYPE_ABSOLUTE
;
6639 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
6641 input_line_pointer
+= 4;
6642 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
6643 instead one should be IMPORTing/EXPORTing ENTRY types.
6645 Complain if one tries to EXPORT a CODE type since that's never
6646 done. Both GCC and HP C still try to IMPORT CODE types, so
6647 silently fix them to be ENTRY types. */
6648 if (S_IS_FUNCTION (symbolP
))
6651 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
6652 S_GET_NAME (symbolP
));
6654 bfdsym
->flags
|= BSF_FUNCTION
;
6655 type
= SYMBOL_TYPE_ENTRY
;
6659 bfdsym
->flags
&= ~BSF_FUNCTION
;
6660 type
= SYMBOL_TYPE_CODE
;
6663 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
6665 input_line_pointer
+= 4;
6666 bfdsym
->flags
&= ~BSF_FUNCTION
;
6667 bfdsym
->flags
|= BSF_OBJECT
;
6668 type
= SYMBOL_TYPE_DATA
;
6670 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
6672 input_line_pointer
+= 5;
6673 bfdsym
->flags
|= BSF_FUNCTION
;
6674 type
= SYMBOL_TYPE_ENTRY
;
6676 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
6678 input_line_pointer
+= 9;
6679 bfdsym
->flags
|= BSF_FUNCTION
;
6682 elf_symbol_type
*elfsym
= (elf_symbol_type
*) bfdsym
;
6683 elfsym
->internal_elf_sym
.st_info
=
6684 ELF_ST_INFO (ELF_ST_BIND (elfsym
->internal_elf_sym
.st_info
),
6688 type
= SYMBOL_TYPE_MILLICODE
;
6690 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
6692 input_line_pointer
+= 6;
6693 bfdsym
->flags
&= ~BSF_FUNCTION
;
6694 type
= SYMBOL_TYPE_PLABEL
;
6696 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
6698 input_line_pointer
+= 8;
6699 bfdsym
->flags
|= BSF_FUNCTION
;
6700 type
= SYMBOL_TYPE_PRI_PROG
;
6702 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
6704 input_line_pointer
+= 8;
6705 bfdsym
->flags
|= BSF_FUNCTION
;
6706 type
= SYMBOL_TYPE_SEC_PROG
;
6709 /* SOM requires much more information about symbol types
6710 than BFD understands. This is how we get this information
6711 to the SOM BFD backend. */
6712 #ifdef obj_set_symbol_type
6713 obj_set_symbol_type (bfdsym
, (int) type
);
6716 /* Now that the type of the exported symbol has been handled,
6717 handle any argument relocation information. */
6718 while (!is_end_of_statement ())
6720 if (*input_line_pointer
== ',')
6721 input_line_pointer
++;
6722 name
= input_line_pointer
;
6723 c
= get_symbol_end ();
6724 /* Argument sources. */
6725 if ((strncasecmp (name
, "argw", 4) == 0))
6727 p
= input_line_pointer
;
6729 input_line_pointer
++;
6730 temp
= atoi (name
+ 4);
6731 name
= input_line_pointer
;
6732 c
= get_symbol_end ();
6733 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
6734 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
6735 symbol_arg_reloc_info (symbolP
) |= arg_reloc
;
6737 *input_line_pointer
= c
;
6739 /* The return value. */
6740 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
6742 p
= input_line_pointer
;
6744 input_line_pointer
++;
6745 name
= input_line_pointer
;
6746 c
= get_symbol_end ();
6747 arg_reloc
= pa_build_arg_reloc (name
);
6748 #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC)
6749 symbol_arg_reloc_info (symbolP
) |= arg_reloc
;
6751 *input_line_pointer
= c
;
6753 /* Privelege level. */
6754 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
6756 p
= input_line_pointer
;
6758 input_line_pointer
++;
6759 temp
= atoi (input_line_pointer
);
6761 ((obj_symbol_type
*) bfdsym
)->tc_data
.ap
.hppa_priv_level
= temp
;
6763 c
= get_symbol_end ();
6764 *input_line_pointer
= c
;
6768 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
6769 p
= input_line_pointer
;
6772 if (!is_end_of_statement ())
6773 input_line_pointer
++;
6777 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
6778 assembly file must either be defined in the assembly file, or
6779 explicitly IMPORTED from another. */
6783 int unused ATTRIBUTE_UNUSED
;
6788 name
= input_line_pointer
;
6789 c
= get_symbol_end ();
6791 symbol
= symbol_find (name
);
6792 /* Ugh. We might be importing a symbol defined earlier in the file,
6793 in which case all the code below will really screw things up
6794 (set the wrong segment, symbol flags & type, etc). */
6795 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
6797 symbol
= symbol_find_or_make (name
);
6798 p
= input_line_pointer
;
6801 if (!is_end_of_statement ())
6803 input_line_pointer
++;
6804 pa_type_args (symbol
, 0);
6808 /* Sigh. To be compatable with the HP assembler and to help
6809 poorly written assembly code, we assign a type based on
6810 the the current segment. Note only BSF_FUNCTION really
6811 matters, we do not need to set the full SYMBOL_TYPE_* info. */
6812 if (now_seg
== text_section
)
6813 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
6815 /* If the section is undefined, then the symbol is undefined
6816 Since this is an import, leave the section undefined. */
6817 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6822 /* The symbol was already defined. Just eat everything up to
6823 the end of the current statement. */
6824 while (!is_end_of_statement ())
6825 input_line_pointer
++;
6828 demand_empty_rest_of_line ();
6831 /* Handle a .LABEL pseudo-op. */
6835 int unused ATTRIBUTE_UNUSED
;
6839 name
= input_line_pointer
;
6840 c
= get_symbol_end ();
6842 if (strlen (name
) > 0)
6845 p
= input_line_pointer
;
6850 as_warn (_("Missing label name on .LABEL"));
6853 if (!is_end_of_statement ())
6855 as_warn (_("extra .LABEL arguments ignored."));
6856 ignore_rest_of_line ();
6858 demand_empty_rest_of_line ();
6861 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
6865 int unused ATTRIBUTE_UNUSED
;
6868 /* We must have a valid space and subspace. */
6869 pa_check_current_space_and_subspace ();
6872 as_bad (_("The .LEAVE pseudo-op is not supported"));
6873 demand_empty_rest_of_line ();
6876 /* Handle a .LEVEL pseudo-op. */
6880 int unused ATTRIBUTE_UNUSED
;
6884 level
= input_line_pointer
;
6885 if (strncmp (level
, "1.0", 3) == 0)
6887 input_line_pointer
+= 3;
6888 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
6889 as_warn (_("could not set architecture and machine"));
6891 else if (strncmp (level
, "1.1", 3) == 0)
6893 input_line_pointer
+= 3;
6894 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
6895 as_warn (_("could not set architecture and machine"));
6897 else if (strncmp (level
, "2.0w", 4) == 0)
6899 input_line_pointer
+= 4;
6900 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 25))
6901 as_warn (_("could not set architecture and machine"));
6903 else if (strncmp (level
, "2.0", 3) == 0)
6905 input_line_pointer
+= 3;
6906 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
6907 as_warn (_("could not set architecture and machine"));
6911 as_bad (_("Unrecognized .LEVEL argument\n"));
6912 ignore_rest_of_line ();
6914 demand_empty_rest_of_line ();
6917 /* Handle a .ORIGIN pseudo-op. */
6921 int unused ATTRIBUTE_UNUSED
;
6924 /* We must have a valid space and subspace. */
6925 pa_check_current_space_and_subspace ();
6929 pa_undefine_label ();
6932 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
6933 is for static functions. FIXME. Should share more code with .EXPORT. */
6937 int unused ATTRIBUTE_UNUSED
;
6942 name
= input_line_pointer
;
6943 c
= get_symbol_end ();
6945 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6947 as_bad (_("Cannot define static symbol: %s\n"), name
);
6948 p
= input_line_pointer
;
6950 input_line_pointer
++;
6954 S_CLEAR_EXTERNAL (symbol
);
6955 p
= input_line_pointer
;
6957 if (!is_end_of_statement ())
6959 input_line_pointer
++;
6960 pa_type_args (symbol
, 0);
6964 demand_empty_rest_of_line ();
6967 /* Handle a .PROC pseudo-op. It is used to mark the beginning
6968 of a procedure from a syntactical point of view. */
6972 int unused ATTRIBUTE_UNUSED
;
6974 struct call_info
*call_info
;
6977 /* We must have a valid space and subspace. */
6978 pa_check_current_space_and_subspace ();
6981 if (within_procedure
)
6982 as_fatal (_("Nested procedures"));
6984 /* Reset global variables for new procedure. */
6985 callinfo_found
= FALSE
;
6986 within_procedure
= TRUE
;
6988 /* Create another call_info structure. */
6989 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
6992 as_fatal (_("Cannot allocate unwind descriptor\n"));
6994 memset (call_info
, 0, sizeof (struct call_info
));
6996 call_info
->ci_next
= NULL
;
6998 if (call_info_root
== NULL
)
7000 call_info_root
= call_info
;
7001 last_call_info
= call_info
;
7005 last_call_info
->ci_next
= call_info
;
7006 last_call_info
= call_info
;
7009 /* set up defaults on call_info structure */
7011 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
7012 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
7013 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
7015 /* If we got a .PROC pseudo-op, we know that the function is defined
7016 locally. Make sure it gets into the symbol table. */
7018 label_symbol_struct
*label_symbol
= pa_get_label ();
7022 if (label_symbol
->lss_label
)
7024 last_call_info
->start_symbol
= label_symbol
->lss_label
;
7025 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
7028 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
7031 last_call_info
->start_symbol
= NULL
;
7034 demand_empty_rest_of_line ();
7037 /* Process the syntatical end of a procedure. Make sure all the
7038 appropriate pseudo-ops were found within the procedure. */
7042 int unused ATTRIBUTE_UNUSED
;
7046 /* We must have a valid space and subspace. */
7047 pa_check_current_space_and_subspace ();
7050 /* If we are within a procedure definition, make sure we've
7051 defined a label for the procedure; handle case where the
7052 label was defined after the .PROC directive.
7054 Note there's not need to diddle with the segment or fragment
7055 for the label symbol in this case. We have already switched
7056 into the new $CODE$ subspace at this point. */
7057 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
7059 label_symbol_struct
*label_symbol
= pa_get_label ();
7063 if (label_symbol
->lss_label
)
7065 last_call_info
->start_symbol
= label_symbol
->lss_label
;
7066 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
7069 /* Also handle allocation of a fixup to hold the unwind
7070 information when the label appears after the proc/procend. */
7071 if (within_entry_exit
)
7076 where
= frag_more (0);
7077 u
= UNWIND_LOW32 (&last_call_info
->ci_unwind
.descriptor
);
7078 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
7079 NULL
, (offsetT
) 0, NULL
,
7080 0, R_HPPA_ENTRY
, e_fsel
, 0, 0, u
);
7085 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
7088 as_bad (_("Missing function name for .PROC"));
7091 if (!within_procedure
)
7092 as_bad (_("misplaced .procend"));
7094 if (!callinfo_found
)
7095 as_bad (_("Missing .callinfo for this procedure"));
7097 if (within_entry_exit
)
7098 as_bad (_("Missing .EXIT for a .ENTRY"));
7101 /* ELF needs to mark the end of each function so that it can compute
7102 the size of the function (apparently its needed in the symbol table). */
7103 hppa_elf_mark_end_of_function ();
7106 within_procedure
= FALSE
;
7107 demand_empty_rest_of_line ();
7108 pa_undefine_label ();
7112 /* If VALUE is an exact power of two between zero and 2^31, then
7113 return log2 (VALUE). Else return -1. */
7121 while ((1 << shift
) != value
&& shift
< 32)
7130 /* Check to make sure we have a valid space and subspace. */
7133 pa_check_current_space_and_subspace ()
7135 if (current_space
== NULL
)
7136 as_fatal (_("Not in a space.\n"));
7138 if (current_subspace
== NULL
)
7139 as_fatal (_("Not in a subspace.\n"));
7142 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
7143 then create a new space entry to hold the information specified
7144 by the parameters to the .SPACE directive. */
7146 static sd_chain_struct
*
7147 pa_parse_space_stmt (space_name
, create_flag
)
7151 char *name
, *ptemp
, c
;
7152 char loadable
, defined
, private, sort
;
7154 asection
*seg
= NULL
;
7155 sd_chain_struct
*space
;
7157 /* load default values */
7163 if (strcmp (space_name
, "$TEXT$") == 0)
7165 seg
= pa_def_spaces
[0].segment
;
7166 defined
= pa_def_spaces
[0].defined
;
7167 private = pa_def_spaces
[0].private;
7168 sort
= pa_def_spaces
[0].sort
;
7169 spnum
= pa_def_spaces
[0].spnum
;
7171 else if (strcmp (space_name
, "$PRIVATE$") == 0)
7173 seg
= pa_def_spaces
[1].segment
;
7174 defined
= pa_def_spaces
[1].defined
;
7175 private = pa_def_spaces
[1].private;
7176 sort
= pa_def_spaces
[1].sort
;
7177 spnum
= pa_def_spaces
[1].spnum
;
7180 if (!is_end_of_statement ())
7182 print_errors
= FALSE
;
7183 ptemp
= input_line_pointer
+ 1;
7184 /* First see if the space was specified as a number rather than
7185 as a name. According to the PA assembly manual the rest of
7186 the line should be ignored. */
7188 pa_parse_number (&ptemp
, 0);
7192 input_line_pointer
= ptemp
;
7196 while (!is_end_of_statement ())
7198 input_line_pointer
++;
7199 name
= input_line_pointer
;
7200 c
= get_symbol_end ();
7201 if ((strncasecmp (name
, "spnum", 5) == 0))
7203 *input_line_pointer
= c
;
7204 input_line_pointer
++;
7205 spnum
= get_absolute_expression ();
7207 else if ((strncasecmp (name
, "sort", 4) == 0))
7209 *input_line_pointer
= c
;
7210 input_line_pointer
++;
7211 sort
= get_absolute_expression ();
7213 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7215 *input_line_pointer
= c
;
7218 else if ((strncasecmp (name
, "notdefined", 10) == 0))
7220 *input_line_pointer
= c
;
7223 else if ((strncasecmp (name
, "private", 7) == 0))
7225 *input_line_pointer
= c
;
7230 as_bad (_("Invalid .SPACE argument"));
7231 *input_line_pointer
= c
;
7232 if (!is_end_of_statement ())
7233 input_line_pointer
++;
7237 print_errors
= TRUE
;
7240 if (create_flag
&& seg
== NULL
)
7241 seg
= subseg_new (space_name
, 0);
7243 /* If create_flag is nonzero, then create the new space with
7244 the attributes computed above. Else set the values in
7245 an already existing space -- this can only happen for
7246 the first occurence of a built-in space. */
7248 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
7249 private, sort
, seg
, 1);
7252 space
= is_defined_space (space_name
);
7253 SPACE_SPNUM (space
) = spnum
;
7254 SPACE_DEFINED (space
) = defined
& 1;
7255 SPACE_USER_DEFINED (space
) = 1;
7258 #ifdef obj_set_section_attributes
7259 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7265 /* Handle a .SPACE pseudo-op; this switches the current space to the
7266 given space, creating the new space if necessary. */
7270 int unused ATTRIBUTE_UNUSED
;
7272 char *name
, c
, *space_name
, *save_s
;
7273 sd_chain_struct
*sd_chain
;
7275 if (within_procedure
)
7277 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
7278 ignore_rest_of_line ();
7282 /* Check for some of the predefined spaces. FIXME: most of the code
7283 below is repeated several times, can we extract the common parts
7284 and place them into a subroutine or something similar? */
7285 /* FIXME Is this (and the next IF stmt) really right?
7286 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
7287 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
7289 input_line_pointer
+= 6;
7290 sd_chain
= is_defined_space ("$TEXT$");
7291 if (sd_chain
== NULL
)
7292 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
7293 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7294 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
7296 current_space
= sd_chain
;
7297 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
7299 = pa_subsegment_to_subspace (text_section
,
7300 sd_chain
->sd_last_subseg
);
7301 demand_empty_rest_of_line ();
7304 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
7306 input_line_pointer
+= 9;
7307 sd_chain
= is_defined_space ("$PRIVATE$");
7308 if (sd_chain
== NULL
)
7309 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
7310 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7311 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
7313 current_space
= sd_chain
;
7314 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
7316 = pa_subsegment_to_subspace (data_section
,
7317 sd_chain
->sd_last_subseg
);
7318 demand_empty_rest_of_line ();
7321 if (!strncasecmp (input_line_pointer
,
7322 GDB_DEBUG_SPACE_NAME
,
7323 strlen (GDB_DEBUG_SPACE_NAME
)))
7325 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
7326 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
7327 if (sd_chain
== NULL
)
7328 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
7329 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
7330 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
7332 current_space
= sd_chain
;
7335 asection
*gdb_section
7336 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
7338 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
7340 = pa_subsegment_to_subspace (gdb_section
,
7341 sd_chain
->sd_last_subseg
);
7343 demand_empty_rest_of_line ();
7347 /* It could be a space specified by number. */
7349 save_s
= input_line_pointer
;
7351 pa_parse_number (&input_line_pointer
, 0);
7354 if ((sd_chain
= pa_find_space_by_number (pa_number
)))
7356 current_space
= sd_chain
;
7358 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7360 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7361 sd_chain
->sd_last_subseg
);
7362 demand_empty_rest_of_line ();
7367 /* Not a number, attempt to create a new space. */
7369 input_line_pointer
= save_s
;
7370 name
= input_line_pointer
;
7371 c
= get_symbol_end ();
7372 space_name
= xmalloc (strlen (name
) + 1);
7373 strcpy (space_name
, name
);
7374 *input_line_pointer
= c
;
7376 sd_chain
= pa_parse_space_stmt (space_name
, 1);
7377 current_space
= sd_chain
;
7379 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
7380 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
7381 sd_chain
->sd_last_subseg
);
7382 demand_empty_rest_of_line ();
7386 /* Switch to a new space. (I think). FIXME. */
7390 int unused ATTRIBUTE_UNUSED
;
7395 sd_chain_struct
*space
;
7397 name
= input_line_pointer
;
7398 c
= get_symbol_end ();
7399 space
= is_defined_space (name
);
7403 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
7406 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
7408 *input_line_pointer
= c
;
7409 demand_empty_rest_of_line ();
7412 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
7413 given subspace, creating the new subspace if necessary.
7415 FIXME. Should mirror pa_space more closely, in particular how
7416 they're broken up into subroutines. */
7419 pa_subspace (create_new
)
7422 char *name
, *ss_name
, c
;
7423 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
7424 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
7425 sd_chain_struct
*space
;
7426 ssd_chain_struct
*ssd
;
7429 if (current_space
== NULL
)
7430 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
7432 if (within_procedure
)
7434 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
7435 ignore_rest_of_line ();
7439 name
= input_line_pointer
;
7440 c
= get_symbol_end ();
7441 ss_name
= xmalloc (strlen (name
) + 1);
7442 strcpy (ss_name
, name
);
7443 *input_line_pointer
= c
;
7445 /* Load default values. */
7457 space
= current_space
;
7461 ssd
= is_defined_subspace (ss_name
);
7462 /* Allow user to override the builtin attributes of subspaces. But
7463 only allow the attributes to be changed once! */
7464 if (ssd
&& SUBSPACE_DEFINED (ssd
))
7466 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
7467 current_subspace
= ssd
;
7468 if (!is_end_of_statement ())
7469 as_warn (_("Parameters of an existing subspace can\'t be modified"));
7470 demand_empty_rest_of_line ();
7475 /* A new subspace. Load default values if it matches one of
7476 the builtin subspaces. */
7478 while (pa_def_subspaces
[i
].name
)
7480 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
7482 loadable
= pa_def_subspaces
[i
].loadable
;
7483 common
= pa_def_subspaces
[i
].common
;
7484 dup_common
= pa_def_subspaces
[i
].dup_common
;
7485 code_only
= pa_def_subspaces
[i
].code_only
;
7486 zero
= pa_def_subspaces
[i
].zero
;
7487 space_index
= pa_def_subspaces
[i
].space_index
;
7488 alignment
= pa_def_subspaces
[i
].alignment
;
7489 quadrant
= pa_def_subspaces
[i
].quadrant
;
7490 access
= pa_def_subspaces
[i
].access
;
7491 sort
= pa_def_subspaces
[i
].sort
;
7498 /* We should be working with a new subspace now. Fill in
7499 any information as specified by the user. */
7500 if (!is_end_of_statement ())
7502 input_line_pointer
++;
7503 while (!is_end_of_statement ())
7505 name
= input_line_pointer
;
7506 c
= get_symbol_end ();
7507 if ((strncasecmp (name
, "quad", 4) == 0))
7509 *input_line_pointer
= c
;
7510 input_line_pointer
++;
7511 quadrant
= get_absolute_expression ();
7513 else if ((strncasecmp (name
, "align", 5) == 0))
7515 *input_line_pointer
= c
;
7516 input_line_pointer
++;
7517 alignment
= get_absolute_expression ();
7518 if (log2 (alignment
) == -1)
7520 as_bad (_("Alignment must be a power of 2"));
7524 else if ((strncasecmp (name
, "access", 6) == 0))
7526 *input_line_pointer
= c
;
7527 input_line_pointer
++;
7528 access
= get_absolute_expression ();
7530 else if ((strncasecmp (name
, "sort", 4) == 0))
7532 *input_line_pointer
= c
;
7533 input_line_pointer
++;
7534 sort
= get_absolute_expression ();
7536 else if ((strncasecmp (name
, "code_only", 9) == 0))
7538 *input_line_pointer
= c
;
7541 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7543 *input_line_pointer
= c
;
7546 else if ((strncasecmp (name
, "common", 6) == 0))
7548 *input_line_pointer
= c
;
7551 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
7553 *input_line_pointer
= c
;
7556 else if ((strncasecmp (name
, "zero", 4) == 0))
7558 *input_line_pointer
= c
;
7561 else if ((strncasecmp (name
, "first", 5) == 0))
7562 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
7564 as_bad (_("Invalid .SUBSPACE argument"));
7565 if (!is_end_of_statement ())
7566 input_line_pointer
++;
7570 /* Compute a reasonable set of BFD flags based on the information
7571 in the .subspace directive. */
7572 applicable
= bfd_applicable_section_flags (stdoutput
);
7575 flags
|= (SEC_ALLOC
| SEC_LOAD
);
7578 if (common
|| dup_common
)
7579 flags
|= SEC_IS_COMMON
;
7581 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
7583 /* This is a zero-filled subspace (eg BSS). */
7585 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
7587 applicable
&= flags
;
7589 /* If this is an existing subspace, then we want to use the
7590 segment already associated with the subspace.
7592 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
7593 lots of sections. It might be a problem in the PA ELF
7594 code, I do not know yet. For now avoid creating anything
7595 but the "standard" sections for ELF. */
7597 section
= subseg_force_new (ss_name
, 0);
7599 section
= ssd
->ssd_seg
;
7601 section
= subseg_new (ss_name
, 0);
7604 seg_info (section
)->bss
= 1;
7606 /* Now set the flags. */
7607 bfd_set_section_flags (stdoutput
, section
, applicable
);
7609 /* Record any alignment request for this section. */
7610 record_alignment (section
, log2 (alignment
));
7612 /* Set the starting offset for this section. */
7613 bfd_set_section_vma (stdoutput
, section
,
7614 pa_subspace_start (space
, quadrant
));
7616 /* Now that all the flags are set, update an existing subspace,
7617 or create a new one. */
7620 current_subspace
= update_subspace (space
, ss_name
, loadable
,
7621 code_only
, common
, dup_common
,
7622 sort
, zero
, access
, space_index
,
7623 alignment
, quadrant
,
7626 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
7628 dup_common
, zero
, sort
,
7629 access
, space_index
,
7630 alignment
, quadrant
, section
);
7632 demand_empty_rest_of_line ();
7633 current_subspace
->ssd_seg
= section
;
7634 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
7636 SUBSPACE_DEFINED (current_subspace
) = 1;
7639 /* Create default space and subspace dictionaries. */
7646 space_dict_root
= NULL
;
7647 space_dict_last
= NULL
;
7650 while (pa_def_spaces
[i
].name
)
7654 /* Pick the right name to use for the new section. */
7655 name
= pa_def_spaces
[i
].name
;
7657 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
7658 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
7659 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
7660 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
7661 pa_def_spaces
[i
].segment
, 0);
7666 while (pa_def_subspaces
[i
].name
)
7669 int applicable
, subsegment
;
7670 asection
*segment
= NULL
;
7671 sd_chain_struct
*space
;
7673 /* Pick the right name for the new section and pick the right
7674 subsegment number. */
7675 name
= pa_def_subspaces
[i
].name
;
7678 /* Create the new section. */
7679 segment
= subseg_new (name
, subsegment
);
7681 /* For SOM we want to replace the standard .text, .data, and .bss
7682 sections with our own. We also want to set BFD flags for
7683 all the built-in subspaces. */
7684 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
7686 text_section
= segment
;
7687 applicable
= bfd_applicable_section_flags (stdoutput
);
7688 bfd_set_section_flags (stdoutput
, segment
,
7689 applicable
& (SEC_ALLOC
| SEC_LOAD
7690 | SEC_RELOC
| SEC_CODE
7692 | SEC_HAS_CONTENTS
));
7694 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
7696 data_section
= segment
;
7697 applicable
= bfd_applicable_section_flags (stdoutput
);
7698 bfd_set_section_flags (stdoutput
, segment
,
7699 applicable
& (SEC_ALLOC
| SEC_LOAD
7701 | SEC_HAS_CONTENTS
));
7704 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
7706 bss_section
= segment
;
7707 applicable
= bfd_applicable_section_flags (stdoutput
);
7708 bfd_set_section_flags (stdoutput
, segment
,
7709 applicable
& SEC_ALLOC
);
7711 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
7713 applicable
= bfd_applicable_section_flags (stdoutput
);
7714 bfd_set_section_flags (stdoutput
, segment
,
7715 applicable
& (SEC_ALLOC
| SEC_LOAD
7718 | SEC_HAS_CONTENTS
));
7720 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
7722 applicable
= bfd_applicable_section_flags (stdoutput
);
7723 bfd_set_section_flags (stdoutput
, segment
,
7724 applicable
& (SEC_ALLOC
| SEC_LOAD
7727 | SEC_HAS_CONTENTS
));
7729 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
7731 applicable
= bfd_applicable_section_flags (stdoutput
);
7732 bfd_set_section_flags (stdoutput
, segment
,
7733 applicable
& (SEC_ALLOC
| SEC_LOAD
7736 | SEC_HAS_CONTENTS
));
7739 /* Find the space associated with this subspace. */
7740 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
7741 def_space_index
].segment
);
7744 as_fatal (_("Internal error: Unable to find containing space for %s."),
7745 pa_def_subspaces
[i
].name
);
7748 create_new_subspace (space
, name
,
7749 pa_def_subspaces
[i
].loadable
,
7750 pa_def_subspaces
[i
].code_only
,
7751 pa_def_subspaces
[i
].common
,
7752 pa_def_subspaces
[i
].dup_common
,
7753 pa_def_subspaces
[i
].zero
,
7754 pa_def_subspaces
[i
].sort
,
7755 pa_def_subspaces
[i
].access
,
7756 pa_def_subspaces
[i
].space_index
,
7757 pa_def_subspaces
[i
].alignment
,
7758 pa_def_subspaces
[i
].quadrant
,
7764 /* Create a new space NAME, with the appropriate flags as defined
7765 by the given parameters. */
7767 static sd_chain_struct
*
7768 create_new_space (name
, spnum
, loadable
, defined
, private,
7769 sort
, seg
, user_defined
)
7779 sd_chain_struct
*chain_entry
;
7781 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
7783 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
7786 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7787 strcpy (SPACE_NAME (chain_entry
), name
);
7788 SPACE_DEFINED (chain_entry
) = defined
;
7789 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
7790 SPACE_SPNUM (chain_entry
) = spnum
;
7792 chain_entry
->sd_seg
= seg
;
7793 chain_entry
->sd_last_subseg
= -1;
7794 chain_entry
->sd_subspaces
= NULL
;
7795 chain_entry
->sd_next
= NULL
;
7797 /* Find spot for the new space based on its sort key. */
7798 if (!space_dict_last
)
7799 space_dict_last
= chain_entry
;
7801 if (space_dict_root
== NULL
)
7802 space_dict_root
= chain_entry
;
7805 sd_chain_struct
*chain_pointer
;
7806 sd_chain_struct
*prev_chain_pointer
;
7808 chain_pointer
= space_dict_root
;
7809 prev_chain_pointer
= NULL
;
7811 while (chain_pointer
)
7813 prev_chain_pointer
= chain_pointer
;
7814 chain_pointer
= chain_pointer
->sd_next
;
7817 /* At this point we've found the correct place to add the new
7818 entry. So add it and update the linked lists as appropriate. */
7819 if (prev_chain_pointer
)
7821 chain_entry
->sd_next
= chain_pointer
;
7822 prev_chain_pointer
->sd_next
= chain_entry
;
7826 space_dict_root
= chain_entry
;
7827 chain_entry
->sd_next
= chain_pointer
;
7830 if (chain_entry
->sd_next
== NULL
)
7831 space_dict_last
= chain_entry
;
7834 /* This is here to catch predefined spaces which do not get
7835 modified by the user's input. Another call is found at
7836 the bottom of pa_parse_space_stmt to handle cases where
7837 the user modifies a predefined space. */
7838 #ifdef obj_set_section_attributes
7839 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7845 /* Create a new subspace NAME, with the appropriate flags as defined
7846 by the given parameters.
7848 Add the new subspace to the subspace dictionary chain in numerical
7849 order as defined by the SORT entries. */
7851 static ssd_chain_struct
*
7852 create_new_subspace (space
, name
, loadable
, code_only
, common
,
7853 dup_common
, is_zero
, sort
, access
, space_index
,
7854 alignment
, quadrant
, seg
)
7855 sd_chain_struct
*space
;
7857 int loadable
, code_only
, common
, dup_common
, is_zero
;
7865 ssd_chain_struct
*chain_entry
;
7867 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
7869 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
7871 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7872 strcpy (SUBSPACE_NAME (chain_entry
), name
);
7874 /* Initialize subspace_defined. When we hit a .subspace directive
7875 we'll set it to 1 which "locks-in" the subspace attributes. */
7876 SUBSPACE_DEFINED (chain_entry
) = 0;
7878 chain_entry
->ssd_subseg
= 0;
7879 chain_entry
->ssd_seg
= seg
;
7880 chain_entry
->ssd_next
= NULL
;
7882 /* Find spot for the new subspace based on its sort key. */
7883 if (space
->sd_subspaces
== NULL
)
7884 space
->sd_subspaces
= chain_entry
;
7887 ssd_chain_struct
*chain_pointer
;
7888 ssd_chain_struct
*prev_chain_pointer
;
7890 chain_pointer
= space
->sd_subspaces
;
7891 prev_chain_pointer
= NULL
;
7893 while (chain_pointer
)
7895 prev_chain_pointer
= chain_pointer
;
7896 chain_pointer
= chain_pointer
->ssd_next
;
7899 /* Now we have somewhere to put the new entry. Insert it and update
7901 if (prev_chain_pointer
)
7903 chain_entry
->ssd_next
= chain_pointer
;
7904 prev_chain_pointer
->ssd_next
= chain_entry
;
7908 space
->sd_subspaces
= chain_entry
;
7909 chain_entry
->ssd_next
= chain_pointer
;
7913 #ifdef obj_set_subsection_attributes
7914 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
7921 /* Update the information for the given subspace based upon the
7922 various arguments. Return the modified subspace chain entry. */
7924 static ssd_chain_struct
*
7925 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
7926 zero
, access
, space_index
, alignment
, quadrant
, section
)
7927 sd_chain_struct
*space
;
7941 ssd_chain_struct
*chain_entry
;
7943 chain_entry
= is_defined_subspace (name
);
7945 #ifdef obj_set_subsection_attributes
7946 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
7953 /* Return the space chain entry for the space with the name NAME or
7954 NULL if no such space exists. */
7956 static sd_chain_struct
*
7957 is_defined_space (name
)
7960 sd_chain_struct
*chain_pointer
;
7962 for (chain_pointer
= space_dict_root
;
7964 chain_pointer
= chain_pointer
->sd_next
)
7966 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
7967 return chain_pointer
;
7970 /* No mapping from segment to space was found. Return NULL. */
7974 /* Find and return the space associated with the given seg. If no mapping
7975 from the given seg to a space is found, then return NULL.
7977 Unlike subspaces, the number of spaces is not expected to grow much,
7978 so a linear exhaustive search is OK here. */
7980 static sd_chain_struct
*
7981 pa_segment_to_space (seg
)
7984 sd_chain_struct
*space_chain
;
7986 /* Walk through each space looking for the correct mapping. */
7987 for (space_chain
= space_dict_root
;
7989 space_chain
= space_chain
->sd_next
)
7991 if (space_chain
->sd_seg
== seg
)
7995 /* Mapping was not found. Return NULL. */
7999 /* Return the space chain entry for the subspace with the name NAME or
8000 NULL if no such subspace exists.
8002 Uses a linear search through all the spaces and subspaces, this may
8003 not be appropriate if we ever being placing each function in its
8006 static ssd_chain_struct
*
8007 is_defined_subspace (name
)
8010 sd_chain_struct
*space_chain
;
8011 ssd_chain_struct
*subspace_chain
;
8013 /* Walk through each space. */
8014 for (space_chain
= space_dict_root
;
8016 space_chain
= space_chain
->sd_next
)
8018 /* Walk through each subspace looking for a name which matches. */
8019 for (subspace_chain
= space_chain
->sd_subspaces
;
8021 subspace_chain
= subspace_chain
->ssd_next
)
8022 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
8023 return subspace_chain
;
8026 /* Subspace wasn't found. Return NULL. */
8030 /* Find and return the subspace associated with the given seg. If no
8031 mapping from the given seg to a subspace is found, then return NULL.
8033 If we ever put each procedure/function within its own subspace
8034 (to make life easier on the compiler and linker), then this will have
8035 to become more efficient. */
8037 static ssd_chain_struct
*
8038 pa_subsegment_to_subspace (seg
, subseg
)
8042 sd_chain_struct
*space_chain
;
8043 ssd_chain_struct
*subspace_chain
;
8045 /* Walk through each space. */
8046 for (space_chain
= space_dict_root
;
8048 space_chain
= space_chain
->sd_next
)
8050 if (space_chain
->sd_seg
== seg
)
8052 /* Walk through each subspace within each space looking for
8053 the correct mapping. */
8054 for (subspace_chain
= space_chain
->sd_subspaces
;
8056 subspace_chain
= subspace_chain
->ssd_next
)
8057 if (subspace_chain
->ssd_subseg
== (int) subseg
)
8058 return subspace_chain
;
8062 /* No mapping from subsegment to subspace found. Return NULL. */
8066 /* Given a number, try and find a space with the name number.
8068 Return a pointer to a space dictionary chain entry for the space
8069 that was found or NULL on failure. */
8071 static sd_chain_struct
*
8072 pa_find_space_by_number (number
)
8075 sd_chain_struct
*space_chain
;
8077 for (space_chain
= space_dict_root
;
8079 space_chain
= space_chain
->sd_next
)
8081 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
8085 /* No appropriate space found. Return NULL. */
8089 /* Return the starting address for the given subspace. If the starting
8090 address is unknown then return zero. */
8093 pa_subspace_start (space
, quadrant
)
8094 sd_chain_struct
*space
;
8097 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
8098 is not correct for the PA OSF1 port. */
8099 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
8101 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
8108 /* FIXME. Needs documentation. */
8110 pa_next_subseg (space
)
8111 sd_chain_struct
*space
;
8114 space
->sd_last_subseg
++;
8115 return space
->sd_last_subseg
;
8119 /* Helper function for pa_stringer. Used to find the end of
8126 unsigned int c
= *s
& CHAR_MASK
;
8139 /* Handle a .STRING type pseudo-op. */
8142 pa_stringer (append_zero
)
8145 char *s
, num_buf
[4];
8149 /* Preprocess the string to handle PA-specific escape sequences.
8150 For example, \xDD where DD is a hexadecimal number should be
8151 changed to \OOO where OOO is an octal number. */
8154 /* We must have a valid space and subspace. */
8155 pa_check_current_space_and_subspace ();
8158 /* Skip the opening quote. */
8159 s
= input_line_pointer
+ 1;
8161 while (is_a_char (c
= pa_stringer_aux (s
++)))
8168 /* Handle \x<num>. */
8171 unsigned int number
;
8176 /* Get past the 'x'. */
8178 for (num_digit
= 0, number
= 0, dg
= *s
;
8180 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
8181 || (dg
>= 'A' && dg
<= 'F'));
8185 number
= number
* 16 + dg
- '0';
8186 else if (dg
>= 'a' && dg
<= 'f')
8187 number
= number
* 16 + dg
- 'a' + 10;
8189 number
= number
* 16 + dg
- 'A' + 10;
8199 sprintf (num_buf
, "%02o", number
);
8202 sprintf (num_buf
, "%03o", number
);
8205 for (i
= 0; i
<= num_digit
; i
++)
8206 s_start
[i
] = num_buf
[i
];
8210 /* This might be a "\"", skip over the escaped char. */
8217 stringer (append_zero
);
8218 pa_undefine_label ();
8221 /* Handle a .VERSION pseudo-op. */
8225 int unused ATTRIBUTE_UNUSED
;
8228 pa_undefine_label ();
8233 /* Handle a .COMPILER pseudo-op. */
8236 pa_compiler (unused
)
8237 int unused ATTRIBUTE_UNUSED
;
8239 obj_som_compiler (0);
8240 pa_undefine_label ();
8245 /* Handle a .COPYRIGHT pseudo-op. */
8248 pa_copyright (unused
)
8249 int unused ATTRIBUTE_UNUSED
;
8252 pa_undefine_label ();
8255 /* Just like a normal cons, but when finished we have to undefine
8256 the latest space label. */
8263 pa_undefine_label ();
8266 /* Like float_cons, but we need to undefine our label. */
8269 pa_float_cons (float_type
)
8272 float_cons (float_type
);
8273 pa_undefine_label ();
8276 /* Like s_fill, but delete our label when finished. */
8280 int unused ATTRIBUTE_UNUSED
;
8283 /* We must have a valid space and subspace. */
8284 pa_check_current_space_and_subspace ();
8288 pa_undefine_label ();
8291 /* Like lcomm, but delete our label when finished. */
8294 pa_lcomm (needs_align
)
8298 /* We must have a valid space and subspace. */
8299 pa_check_current_space_and_subspace ();
8302 s_lcomm (needs_align
);
8303 pa_undefine_label ();
8306 /* Like lsym, but delete our label when finished. */
8310 int unused ATTRIBUTE_UNUSED
;
8313 /* We must have a valid space and subspace. */
8314 pa_check_current_space_and_subspace ();
8318 pa_undefine_label ();
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.
8342 FIXME. Also reject R_HPPA relocations which are 32bits wide in
8343 the code space. The SOM BFD backend doesn't know how to pull the
8344 right bits out of an instruction. */
8347 hppa_fix_adjustable (fixp
)
8350 struct hppa_fix_struct
*hppa_fix
;
8352 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8355 /* Reject reductions of symbols in 32bit relocs. */
8356 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
8361 if (fixp
->fx_r_type
== (int) R_PARISC_GNU_VTINHERIT
8362 || fixp
->fx_r_type
== (int) R_PARISC_GNU_VTENTRY
)
8366 if (fixp
->fx_addsy
&& (S_IS_EXTERNAL (fixp
->fx_addsy
)
8367 || S_IS_WEAK (fixp
->fx_addsy
)))
8370 /* Reject reductions of symbols in sym1-sym2 expressions when
8371 the fixup will occur in a CODE subspace.
8373 XXX FIXME: Long term we probably want to reject all of these;
8374 for example reducing in the debug section would lose if we ever
8375 supported using the optimizing hp linker. */
8378 && (hppa_fix
->segment
->flags
& SEC_CODE
))
8380 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
8381 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
8385 /* We can't adjust any relocs that use LR% and RR% field selectors.
8387 If a symbol is reduced to a section symbol, the assembler will
8388 adjust the addend unless the symbol happens to reside right at
8389 the start of the section. Additionally, the linker has no choice
8390 but to manipulate the addends when coalescing input sections for
8391 "ld -r". Since an LR% field selector is defined to round the
8392 addend, we can't change the addend without risking that a LR% and
8393 it's corresponding (possible multiple) RR% field will no longer
8394 sum to the right value.
8397 . ldil LR%foo+0,%r21
8398 . ldw RR%foo+0(%r21),%r26
8399 . ldw RR%foo+4(%r21),%r25
8401 If foo is at address 4092 (decimal) in section `sect', then after
8402 reducing to the section symbol we get
8403 . LR%sect+4092 == (L%sect)+0
8404 . RR%sect+4092 == (R%sect)+4092
8405 . RR%sect+4096 == (R%sect)-4096
8406 and the last address loses because rounding the addend to 8k
8407 mutiples takes us up to 8192 with an offset of -4096.
8409 In cases where the LR% expression is identical to the RR% one we
8410 will never have a problem, but is so happens that gcc rounds
8411 addends involved in LR% field selectors to work around a HP
8412 linker bug. ie. We often have addresses like the last case
8413 above where the LR% expression is offset from the RR% one. */
8415 if (hppa_fix
->fx_r_field
== e_lrsel
8416 || hppa_fix
->fx_r_field
== e_rrsel
8417 || hppa_fix
->fx_r_field
== e_nlrsel
)
8420 /* Reject reductions of symbols in DLT relative relocs,
8421 relocations with plabels. */
8422 if (hppa_fix
->fx_r_field
== e_tsel
8423 || hppa_fix
->fx_r_field
== e_ltsel
8424 || hppa_fix
->fx_r_field
== e_rtsel
8425 || hppa_fix
->fx_r_field
== e_psel
8426 || hppa_fix
->fx_r_field
== e_rpsel
8427 || hppa_fix
->fx_r_field
== e_lpsel
)
8430 /* Reject absolute calls (jumps). */
8431 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
8434 /* Reject reductions of function symbols. */
8435 if (fixp
->fx_addsy
!= 0 && S_IS_FUNCTION (fixp
->fx_addsy
))
8441 /* Return nonzero if the fixup in FIXP will require a relocation,
8442 even it if appears that the fixup could be completely handled
8446 hppa_force_relocation (fixp
)
8449 struct hppa_fix_struct
*hppa_fixp
;
8451 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
8453 if (fixp
->fx_r_type
== (int) R_HPPA_ENTRY
8454 || fixp
->fx_r_type
== (int) R_HPPA_EXIT
8455 || fixp
->fx_r_type
== (int) R_HPPA_BEGIN_BRTAB
8456 || fixp
->fx_r_type
== (int) R_HPPA_END_BRTAB
8457 || fixp
->fx_r_type
== (int) R_HPPA_BEGIN_TRY
8458 || fixp
->fx_r_type
== (int) R_HPPA_END_TRY
8459 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
8460 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
8464 if (fixp
->fx_r_type
== (int) R_PARISC_GNU_VTINHERIT
8465 || fixp
->fx_r_type
== (int) R_PARISC_GNU_VTENTRY
)
8469 assert (fixp
->fx_addsy
!= NULL
);
8471 /* Ensure we emit a relocation for global symbols so that dynamic
8473 if (S_IS_EXTERNAL (fixp
->fx_addsy
) || S_IS_WEAK (fixp
->fx_addsy
))
8476 /* It is necessary to force PC-relative calls/jumps to have a relocation
8477 entry if they're going to need either a argument relocation or long
8480 && arg_reloc_stub_needed (symbol_arg_reloc_info (fixp
->fx_addsy
),
8481 hppa_fixp
->fx_arg_reloc
))
8484 /* Now check to see if we're going to need a long-branch stub. */
8485 if (fixp
->fx_r_type
== (int) R_HPPA_PCREL_CALL
)
8489 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
8490 - md_pcrel_from (fixp
) - 8);
8491 if (distance
+ 8388608 >= 16777216
8492 || (hppa_fixp
->fx_r_format
== 17 && distance
+ 262144 >= 524288)
8494 || (hppa_fixp
->fx_r_format
== 12 && distance
+ 8192 >= 16384)
8500 if (fixp
->fx_r_type
== (int) R_HPPA_ABS_CALL
)
8503 /* No need (yet) to force another relocations to be emitted. */
8507 /* Now for some ELF specific code. FIXME. */
8509 /* Mark the end of a function so that it's possible to compute
8510 the size of the function in hppa_elf_final_processing. */
8513 hppa_elf_mark_end_of_function ()
8515 /* ELF does not have EXIT relocations. All we do is create a
8516 temporary symbol marking the end of the function. */
8519 if (last_call_info
== NULL
|| last_call_info
->start_symbol
== NULL
)
8521 /* We have already warned about a missing label,
8522 or other problems. */
8526 name
= (char *) xmalloc (strlen ("L$\001end_")
8527 + strlen (S_GET_NAME (last_call_info
->start_symbol
))
8533 strcpy (name
, "L$\001end_");
8534 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
8536 /* If we have a .exit followed by a .procend, then the
8537 symbol will have already been defined. */
8538 symbolP
= symbol_find (name
);
8541 /* The symbol has already been defined! This can
8542 happen if we have a .exit followed by a .procend.
8544 This is *not* an error. All we want to do is free
8545 the memory we just allocated for the name and continue. */
8550 /* symbol value should be the offset of the
8551 last instruction of the function */
8552 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
8556 S_CLEAR_EXTERNAL (symbolP
);
8557 symbol_table_insert (symbolP
);
8561 last_call_info
->end_symbol
= symbolP
;
8563 as_bad (_("Symbol '%s' could not be created."), name
);
8567 as_bad (_("No memory for symbol name."));
8571 /* For ELF, this function serves one purpose: to setup the st_size
8572 field of STT_FUNC symbols. To do this, we need to scan the
8573 call_info structure list, determining st_size in by taking the
8574 difference in the address of the beginning/end marker symbols. */
8577 elf_hppa_final_processing ()
8579 struct call_info
*call_info_pointer
;
8581 for (call_info_pointer
= call_info_root
;
8583 call_info_pointer
= call_info_pointer
->ci_next
)
8585 elf_symbol_type
*esym
8586 = ((elf_symbol_type
*)
8587 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
8588 esym
->internal_elf_sym
.st_size
=
8589 S_GET_VALUE (call_info_pointer
->end_symbol
)
8590 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;
8595 pa_vtable_entry (ignore
)
8596 int ignore ATTRIBUTE_UNUSED
;
8598 struct fix
*new_fix
;
8600 new_fix
= obj_elf_vtable_entry (0);
8604 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
8605 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
8606 hppa_fix
->fx_r_type
= R_HPPA
;
8607 hppa_fix
->fx_r_field
= e_fsel
;
8608 hppa_fix
->fx_r_format
= 32;
8609 hppa_fix
->fx_arg_reloc
= 0;
8610 hppa_fix
->segment
= now_seg
;
8611 new_fix
->tc_fix_data
= (void *) hppa_fix
;
8612 new_fix
->fx_r_type
= (int) R_PARISC_GNU_VTENTRY
;
8617 pa_vtable_inherit (ignore
)
8618 int ignore ATTRIBUTE_UNUSED
;
8620 struct fix
*new_fix
;
8622 new_fix
= obj_elf_vtable_inherit (0);
8626 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
8627 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
8628 hppa_fix
->fx_r_type
= R_HPPA
;
8629 hppa_fix
->fx_r_field
= e_fsel
;
8630 hppa_fix
->fx_r_format
= 32;
8631 hppa_fix
->fx_arg_reloc
= 0;
8632 hppa_fix
->segment
= now_seg
;
8633 new_fix
->tc_fix_data
= (void *) hppa_fix
;
8634 new_fix
->fx_r_type
= (int) R_PARISC_GNU_VTINHERIT
;