1 /* tc-hppa.c -- Assemble for the PA
2 Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* HP PA-RISC support was contributed by the Center for Software Science
24 at the University of Utah. */
32 #include "bfd/libhppa.h"
33 #include "bfd/libbfd.h"
35 /* Be careful, this file includes data *declarations*. */
36 #include "opcode/hppa.h"
38 #if defined (OBJ_ELF) && defined (OBJ_SOM)
39 error only one of OBJ_ELF
and OBJ_SOM can be defined
42 /* If we are using ELF, then we probably can support dwarf2 debug
43 records. Furthermore, if we are supporting dwarf2 debug records,
44 then we want to use the assembler support for compact line numbers. */
46 #include "dwarf2dbg.h"
47 struct dwarf2_line_info debug_line
;
50 /* A "convient" place to put object file dependencies which do
51 not need to be seen outside of tc-hppa.c. */
53 /* Object file formats specify relocation types. */
54 typedef elf_hppa_reloc_type reloc_type
;
56 /* Object file formats specify BFD symbol types. */
57 typedef elf_symbol_type obj_symbol_type
;
60 /* How to generate a relocation. */
61 #define hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
63 #define hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
66 /* ELF objects can have versions, but apparently do not have anywhere
67 to store a copyright string. */
68 #define obj_version obj_elf_version
69 #define obj_copyright obj_elf_version
71 #define UNWIND_SECTION_NAME ".PARISC.unwind"
75 /* Names of various debugging spaces/subspaces. */
76 #define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$"
77 #define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$"
78 #define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$"
79 #define UNWIND_SECTION_NAME "$UNWIND$"
81 /* Object file formats specify relocation types. */
82 typedef int reloc_type
;
84 /* SOM objects can have both a version string and a copyright string. */
85 #define obj_version obj_som_version
86 #define obj_copyright obj_som_copyright
88 /* How to generate a relocation. */
89 #define hppa_gen_reloc_type hppa_som_gen_reloc_type
91 /* Object file formats specify BFD symbol types. */
92 typedef som_symbol_type obj_symbol_type
;
94 /* This apparently isn't in older versions of hpux reloc.h. */
96 #define R_DLT_REL 0x78
108 /* Various structures and types used internally in tc-hppa.c. */
110 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
114 unsigned int cannot_unwind
:1;
115 unsigned int millicode
:1;
116 unsigned int millicode_save_rest
:1;
117 unsigned int region_desc
:2;
118 unsigned int save_sr
:2;
119 unsigned int entry_fr
:4;
120 unsigned int entry_gr
:5;
121 unsigned int args_stored
:1;
122 unsigned int call_fr
:5;
123 unsigned int call_gr
:5;
124 unsigned int save_sp
:1;
125 unsigned int save_rp
:1;
126 unsigned int save_rp_in_frame
:1;
127 unsigned int extn_ptr_defined
:1;
128 unsigned int cleanup_defined
:1;
130 unsigned int hpe_interrupt_marker
:1;
131 unsigned int hpux_interrupt_marker
:1;
132 unsigned int reserved
:3;
133 unsigned int frame_size
:27;
138 /* Starting and ending offsets of the region described by
140 unsigned int start_offset
;
141 unsigned int end_offset
;
142 struct unwind_desc descriptor
;
145 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
146 control the entry and exit code they generate. It is also used in
147 creation of the correct stack unwind descriptors.
149 NOTE: GAS does not support .enter and .leave for the generation of
150 prologues and epilogues. FIXME.
152 The fields in structure roughly correspond to the arguments available on the
153 .callinfo pseudo-op. */
157 /* The unwind descriptor being built. */
158 struct unwind_table ci_unwind
;
160 /* Name of this function. */
161 symbolS
*start_symbol
;
163 /* (temporary) symbol used to mark the end of this function. */
166 /* Next entry in the chain. */
167 struct call_info
*ci_next
;
170 /* Operand formats for FP instructions. Note not all FP instructions
171 allow all four formats to be used (for example fmpysub only allows
175 SGL
, DBL
, ILLEGAL_FMT
, QUAD
, W
, UW
, DW
, UDW
, QW
, UQW
179 /* This fully describes the symbol types which may be attached to
180 an EXPORT or IMPORT directive. Only SOM uses this formation
181 (ELF has no need for it). */
185 SYMBOL_TYPE_ABSOLUTE
,
189 SYMBOL_TYPE_MILLICODE
,
191 SYMBOL_TYPE_PRI_PROG
,
192 SYMBOL_TYPE_SEC_PROG
,
196 /* This structure contains information needed to assemble
197 individual instructions. */
200 /* Holds the opcode after parsing by pa_ip. */
201 unsigned long opcode
;
203 /* Holds an expression associated with the current instruction. */
206 /* Does this instruction use PC-relative addressing. */
209 /* Floating point formats for operand1 and operand2. */
210 fp_operand_format fpof1
;
211 fp_operand_format fpof2
;
213 /* Whether or not we saw a truncation request on an fcnv insn. */
216 /* Holds the field selector for this instruction
217 (for example L%, LR%, etc). */
220 /* Holds any argument relocation bits associated with this
221 instruction. (instruction should be some sort of call). */
224 /* The format specification for this instruction. */
227 /* The relocation (if any) associated with this instruction. */
231 /* PA-89 floating point registers are arranged like this:
234 +--------------+--------------+
235 | 0 or 16L | 16 or 16R |
236 +--------------+--------------+
237 | 1 or 17L | 17 or 17R |
238 +--------------+--------------+
246 +--------------+--------------+
247 | 14 or 30L | 30 or 30R |
248 +--------------+--------------+
249 | 15 or 31L | 31 or 31R |
250 +--------------+--------------+
253 The following is a version of pa_parse_number that
254 handles the L/R notation and returns the correct
255 value to put into the instruction register field.
256 The correct value to put into the instruction is
257 encoded in the structure 'pa_11_fp_reg_struct'. */
259 struct pa_11_fp_reg_struct
261 /* The register number. */
268 /* Additional information needed to build argument relocation stubs. */
271 /* The argument relocation specification. */
272 unsigned int arg_reloc
;
274 /* Number of arguments. */
275 unsigned int arg_count
;
279 /* This structure defines an entry in the subspace dictionary
282 struct subspace_dictionary_chain
284 /* Nonzero if this space has been defined by the user code. */
285 unsigned int ssd_defined
;
287 /* Name of this subspace. */
290 /* GAS segment and subsegment associated with this subspace. */
294 /* Next space in the subspace dictionary chain. */
295 struct subspace_dictionary_chain
*ssd_next
;
298 typedef struct subspace_dictionary_chain ssd_chain_struct
;
300 /* This structure defines an entry in the subspace dictionary
303 struct space_dictionary_chain
305 /* Nonzero if this space has been defined by the user code or
306 as a default space. */
307 unsigned int sd_defined
;
309 /* Nonzero if this spaces has been defined by the user code. */
310 unsigned int sd_user_defined
;
312 /* The space number (or index). */
313 unsigned int sd_spnum
;
315 /* The name of this subspace. */
318 /* GAS segment to which this subspace corresponds. */
321 /* Current subsegment number being used. */
324 /* The chain of subspaces contained within this space. */
325 ssd_chain_struct
*sd_subspaces
;
327 /* The next entry in the space dictionary chain. */
328 struct space_dictionary_chain
*sd_next
;
331 typedef struct space_dictionary_chain sd_chain_struct
;
333 /* This structure defines attributes of the default subspace
334 dictionary entries. */
336 struct default_subspace_dict
338 /* Name of the subspace. */
341 /* FIXME. Is this still needed? */
344 /* Nonzero if this subspace is loadable. */
347 /* Nonzero if this subspace contains only code. */
350 /* Nonzero if this is a common subspace. */
353 /* Nonzero if this is a common subspace which allows symbols
354 to be multiply defined. */
357 /* Nonzero if this subspace should be zero filled. */
360 /* Sort key for this subspace. */
363 /* Access control bits for this subspace. Can represent RWX access
364 as well as privilege level changes for gateways. */
367 /* Index of containing space. */
370 /* Alignment (in bytes) of this subspace. */
373 /* Quadrant within space where this subspace should be loaded. */
376 /* An index into the default spaces array. */
379 /* Subsegment associated with this subspace. */
383 /* This structure defines attributes of the default space
384 dictionary entries. */
386 struct default_space_dict
388 /* Name of the space. */
391 /* Space number. It is possible to identify spaces within
392 assembly code numerically! */
395 /* Nonzero if this space is loadable. */
398 /* Nonzero if this space is "defined". FIXME is still needed */
401 /* Nonzero if this space can not be shared. */
404 /* Sort key for this space. */
407 /* Segment associated with this space. */
412 /* Structure for previous label tracking. Needed so that alignments,
413 callinfo declarations, etc can be easily attached to a particular
415 typedef struct label_symbol_struct
417 struct symbol
*lss_label
;
419 sd_chain_struct
*lss_space
;
424 struct label_symbol_struct
*lss_next
;
428 /* Extra information needed to perform fixups (relocations) on the PA. */
429 struct hppa_fix_struct
431 /* The field selector. */
432 enum hppa_reloc_field_selector_type_alt fx_r_field
;
437 /* Format of fixup. */
440 /* Argument relocation bits. */
443 /* The segment this fixup appears in. */
447 /* Structure to hold information about predefined registers. */
455 /* This structure defines the mapping from a FP condition string
456 to a condition number which can be recorded in an instruction. */
463 /* This structure defines a mapping from a field selector
464 string to a field selector type. */
465 struct selector_entry
471 /* Prototypes for functions local to tc-hppa.c. */
474 static void pa_check_current_space_and_subspace
PARAMS ((void));
477 static fp_operand_format pa_parse_fp_format
PARAMS ((char **s
));
478 static void pa_cons
PARAMS ((int));
479 static void pa_data
PARAMS ((int));
480 static void pa_float_cons
PARAMS ((int));
481 static void pa_fill
PARAMS ((int));
482 static void pa_lcomm
PARAMS ((int));
483 static void pa_lsym
PARAMS ((int));
484 static void pa_stringer
PARAMS ((int));
485 static void pa_text
PARAMS ((int));
486 static void pa_version
PARAMS ((int));
487 static int pa_parse_fp_cmp_cond
PARAMS ((char **));
488 static int get_expression
PARAMS ((char *));
489 static int pa_get_absolute_expression
PARAMS ((struct pa_it
*, char **));
490 static int evaluate_absolute
PARAMS ((struct pa_it
*));
491 static unsigned int pa_build_arg_reloc
PARAMS ((char *));
492 static unsigned int pa_align_arg_reloc
PARAMS ((unsigned int, unsigned int));
493 static int pa_parse_nullif
PARAMS ((char **));
494 static int pa_parse_nonneg_cmpsub_cmpltr
PARAMS ((char **, int));
495 static int pa_parse_neg_cmpsub_cmpltr
PARAMS ((char **, int));
496 static int pa_parse_neg_add_cmpltr
PARAMS ((char **, int));
497 static int pa_parse_nonneg_add_cmpltr
PARAMS ((char **, int));
498 static void pa_block
PARAMS ((int));
499 static void pa_brtab
PARAMS ((int));
500 static void pa_try
PARAMS ((int));
501 static void pa_call
PARAMS ((int));
502 static void pa_call_args
PARAMS ((struct call_desc
*));
503 static void pa_callinfo
PARAMS ((int));
504 static void pa_code
PARAMS ((int));
505 static void pa_comm
PARAMS ((int));
506 static void pa_copyright
PARAMS ((int));
507 static void pa_end
PARAMS ((int));
508 static void pa_enter
PARAMS ((int));
509 static void pa_entry
PARAMS ((int));
510 static void pa_equ
PARAMS ((int));
511 static void pa_exit
PARAMS ((int));
512 static void pa_export
PARAMS ((int));
513 static void pa_type_args
PARAMS ((symbolS
*, int));
514 static void pa_import
PARAMS ((int));
515 static void pa_label
PARAMS ((int));
516 static void pa_leave
PARAMS ((int));
517 static void pa_level
PARAMS ((int));
518 static void pa_origin
PARAMS ((int));
519 static void pa_proc
PARAMS ((int));
520 static void pa_procend
PARAMS ((int));
521 static void pa_param
PARAMS ((int));
522 static void pa_undefine_label
PARAMS ((void));
523 static int need_pa11_opcode
PARAMS ((struct pa_it
*,
524 struct pa_11_fp_reg_struct
*));
525 static int pa_parse_number
PARAMS ((char **, struct pa_11_fp_reg_struct
*));
526 static label_symbol_struct
*pa_get_label
PARAMS ((void));
528 static void pa_compiler
PARAMS ((int));
529 static void pa_align
PARAMS ((int));
530 static void pa_space
PARAMS ((int));
531 static void pa_spnum
PARAMS ((int));
532 static void pa_subspace
PARAMS ((int));
533 static sd_chain_struct
*create_new_space
PARAMS ((char *, int, int,
536 static ssd_chain_struct
*create_new_subspace
PARAMS ((sd_chain_struct
*,
541 static ssd_chain_struct
*update_subspace
PARAMS ((sd_chain_struct
*,
542 char *, int, int, int,
546 static sd_chain_struct
*is_defined_space
PARAMS ((char *));
547 static ssd_chain_struct
*is_defined_subspace
PARAMS ((char *));
548 static sd_chain_struct
*pa_segment_to_space
PARAMS ((asection
*));
549 static ssd_chain_struct
*pa_subsegment_to_subspace
PARAMS ((asection
*,
551 static sd_chain_struct
*pa_find_space_by_number
PARAMS ((int));
552 static unsigned int pa_subspace_start
PARAMS ((sd_chain_struct
*, int));
553 static sd_chain_struct
*pa_parse_space_stmt
PARAMS ((char *, int));
554 static int pa_next_subseg
PARAMS ((sd_chain_struct
*));
555 static void pa_spaces_begin
PARAMS ((void));
557 static void pa_ip
PARAMS ((char *));
558 static void fix_new_hppa
PARAMS ((fragS
*, int, int, symbolS
*,
559 long, expressionS
*, int,
560 bfd_reloc_code_real_type
,
561 enum hppa_reloc_field_selector_type_alt
,
563 static int is_end_of_statement
PARAMS ((void));
564 static int reg_name_search
PARAMS ((char *));
565 static int pa_chk_field_selector
PARAMS ((char **));
566 static int is_same_frag
PARAMS ((fragS
*, fragS
*));
567 static void process_exit
PARAMS ((void));
568 static int log2
PARAMS ((int));
569 static unsigned int pa_stringer_aux
PARAMS ((char *));
570 static fp_operand_format pa_parse_fp_cnv_format
PARAMS ((char **s
));
571 static int pa_parse_ftest_gfx_completer
PARAMS ((char **));
574 static void hppa_elf_mark_end_of_function
PARAMS ((void));
575 static void pa_build_unwind_subspace
PARAMS ((struct call_info
*));
578 /* File and gloally scoped variable declarations. */
581 /* Root and final entry in the space chain. */
582 static sd_chain_struct
*space_dict_root
;
583 static sd_chain_struct
*space_dict_last
;
585 /* The current space and subspace. */
586 static sd_chain_struct
*current_space
;
587 static ssd_chain_struct
*current_subspace
;
590 /* Root of the call_info chain. */
591 static struct call_info
*call_info_root
;
593 /* The last call_info (for functions) structure
594 seen so it can be associated with fixups and
596 static struct call_info
*last_call_info
;
598 /* The last call description (for actual calls). */
599 static struct call_desc last_call_desc
;
601 /* handle of the OPCODE hash table */
602 static struct hash_control
*op_hash
= NULL
;
604 /* This array holds the chars that always start a comment. If the
605 pre-processor is disabled, these aren't very useful. */
606 const char comment_chars
[] = ";";
608 /* Table of pseudo ops for the PA. FIXME -- how many of these
609 are now redundant with the overall GAS and the object file
611 const pseudo_typeS md_pseudo_table
[] =
613 /* align pseudo-ops on the PA specify the actual alignment requested,
614 not the log2 of the requested alignment. */
616 {"align", pa_align
, 8},
619 {"align", s_align_bytes
, 8},
621 {"begin_brtab", pa_brtab
, 1},
622 {"begin_try", pa_try
, 1},
623 {"block", pa_block
, 1},
624 {"blockz", pa_block
, 0},
625 {"byte", pa_cons
, 1},
626 {"call", pa_call
, 0},
627 {"callinfo", pa_callinfo
, 0},
628 {"code", pa_code
, 0},
629 {"comm", pa_comm
, 0},
631 {"compiler", pa_compiler
, 0},
633 {"copyright", pa_copyright
, 0},
634 {"data", pa_data
, 0},
635 {"double", pa_float_cons
, 'd'},
636 {"dword", pa_cons
, 8},
638 {"end_brtab", pa_brtab
, 0},
639 {"end_try", pa_try
, 0},
640 {"enter", pa_enter
, 0},
641 {"entry", pa_entry
, 0},
643 {"exit", pa_exit
, 0},
644 {"export", pa_export
, 0},
646 { "file", dwarf2_directive_file
},
648 {"fill", pa_fill
, 0},
649 {"float", pa_float_cons
, 'f'},
650 {"half", pa_cons
, 2},
651 {"import", pa_import
, 0},
653 {"label", pa_label
, 0},
654 {"lcomm", pa_lcomm
, 0},
655 {"leave", pa_leave
, 0},
656 {"level", pa_level
, 0},
658 { "loc", dwarf2_directive_loc
},
660 {"long", pa_cons
, 4},
661 {"lsym", pa_lsym
, 0},
663 {"nsubspa", pa_subspace
, 1},
665 {"octa", pa_cons
, 16},
666 {"org", pa_origin
, 0},
667 {"origin", pa_origin
, 0},
668 {"param", pa_param
, 0},
669 {"proc", pa_proc
, 0},
670 {"procend", pa_procend
, 0},
671 {"quad", pa_cons
, 8},
673 {"short", pa_cons
, 2},
674 {"single", pa_float_cons
, 'f'},
676 {"space", pa_space
, 0},
677 {"spnum", pa_spnum
, 0},
679 {"string", pa_stringer
, 0},
680 {"stringz", pa_stringer
, 1},
682 {"subspa", pa_subspace
, 0},
684 {"text", pa_text
, 0},
685 {"version", pa_version
, 0},
686 {"word", pa_cons
, 4},
690 /* This array holds the chars that only start a comment at the beginning of
691 a line. If the line seems to have the form '# 123 filename'
692 .line and .file directives will appear in the pre-processed output.
694 Note that input_file.c hand checks for '#' at the beginning of the
695 first line of the input file. This is because the compiler outputs
696 #NO_APP at the beginning of its output.
698 Also note that C style comments will always work. */
699 const char line_comment_chars
[] = "#";
701 /* This array holds the characters which act as line separators. */
702 const char line_separator_chars
[] = "!";
704 /* Chars that can be used to separate mant from exp in floating point nums. */
705 const char EXP_CHARS
[] = "eE";
707 /* Chars that mean this number is a floating point constant.
708 As in 0f12.456 or 0d1.2345e12.
710 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
711 changed in read.c. Ideally it shouldn't hae to know abou it at
712 all, but nothing is ideal around here. */
713 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
715 static struct pa_it the_insn
;
717 /* Points to the end of an expression just parsed by get_expressoin
718 and friends. FIXME. This shouldn't be handled with a file-global
720 static char *expr_end
;
722 /* Nonzero if a .callinfo appeared within the current procedure. */
723 static int callinfo_found
;
725 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
726 static int within_entry_exit
;
728 /* Nonzero if the assembler is currently within a procedure definition. */
729 static int within_procedure
;
731 /* Handle on strucutre which keep track of the last symbol
732 seen in each subspace. */
733 static label_symbol_struct
*label_symbols_rootp
= NULL
;
735 /* Holds the last field selector. */
736 static int hppa_field_selector
;
738 /* Nonzero when strict syntax checking is enabled. Zero otherwise.
740 Each opcode in the table has a flag which indicates whether or not
741 strict syntax checking should be enabled for that instruction. */
742 static int strict
= 0;
745 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
746 static symbolS
*dummy_symbol
;
749 /* Nonzero if errors are to be printed. */
750 static int print_errors
= 1;
752 /* List of registers that are pre-defined:
754 Each general register has one predefined name of the form
755 %r<REGNUM> which has the value <REGNUM>.
757 Space and control registers are handled in a similar manner,
758 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
760 Likewise for the floating point registers, but of the form
761 %fr<REGNUM>. Floating point registers have additional predefined
762 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
763 again have the value <REGNUM>.
765 Many registers also have synonyms:
767 %r26 - %r23 have %arg0 - %arg3 as synonyms
768 %r28 - %r29 have %ret0 - %ret1 as synonyms
769 %r30 has %sp as a synonym
770 %r27 has %dp as a synonym
771 %r2 has %rp as a synonym
773 Almost every control register has a synonym; they are not listed
776 The table is sorted. Suitable for searching by a binary search. */
778 static const struct pd_reg pre_defined_registers
[] =
978 /* This table is sorted by order of the length of the string. This is
979 so we check for <> before we check for <. If we had a <> and checked
980 for < first, we would get a false match. */
981 static const struct fp_cond_map fp_cond_map
[] =
1017 static const struct selector_entry selector_table
[] =
1042 /* default space and subspace dictionaries */
1044 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1045 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1047 /* pre-defined subsegments (subspaces) for the HPPA. */
1048 #define SUBSEG_CODE 0
1049 #define SUBSEG_LIT 1
1050 #define SUBSEG_MILLI 2
1051 #define SUBSEG_DATA 0
1052 #define SUBSEG_BSS 2
1053 #define SUBSEG_UNWIND 3
1054 #define SUBSEG_GDB_STRINGS 0
1055 #define SUBSEG_GDB_SYMBOLS 1
1057 static struct default_subspace_dict pa_def_subspaces
[] =
1059 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE
},
1060 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA
},
1061 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT
},
1062 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI
},
1063 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS
},
1064 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1067 static struct default_space_dict pa_def_spaces
[] =
1069 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
},
1070 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
},
1071 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
}
1074 /* Misc local definitions used by the assembler. */
1076 /* These macros are used to maintain spaces/subspaces. */
1077 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1078 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1079 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1080 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1082 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1083 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1086 /* Return nonzero if the string pointed to by S potentially represents
1087 a right or left half of a FP register */
1088 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1089 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1091 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1092 main loop after insertion. */
1094 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1096 ((OPCODE) |= (FIELD) << (START)); \
1100 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1101 IGNORE is used to suppress the error message. */
1103 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1105 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1108 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1114 #define is_DP_relative(exp) \
1115 ((exp).X_op == O_subtract \
1116 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1118 #define is_PC_relative(exp) \
1119 ((exp).X_op == O_subtract \
1120 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1122 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1123 always be able to reduce the expression to a constant, so we don't
1124 need real complex handling yet. */
1125 #define is_complex(exp) \
1126 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1128 /* Actual functions to implement the PA specific code for the assembler. */
1130 /* Called before writing the object file. Make sure entry/exit and
1131 proc/procend pairs match. */
1136 if (within_entry_exit
)
1137 as_fatal (_("Missing .exit\n"));
1139 if (within_procedure
)
1140 as_fatal (_("Missing .procend\n"));
1143 /* Returns a pointer to the label_symbol_struct for the current space.
1144 or NULL if no label_symbol_struct exists for the current space. */
1146 static label_symbol_struct
*
1149 label_symbol_struct
*label_chain
;
1151 for (label_chain
= label_symbols_rootp
;
1153 label_chain
= label_chain
->lss_next
)
1156 if (current_space
== label_chain
->lss_space
&& label_chain
->lss_label
)
1160 if (now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
)
1168 /* Defines a label for the current space. If one is already defined,
1169 this function will replace it with the new label. */
1172 pa_define_label (symbol
)
1175 label_symbol_struct
*label_chain
= pa_get_label ();
1178 label_chain
->lss_label
= symbol
;
1181 /* Create a new label entry and add it to the head of the chain. */
1183 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1184 label_chain
->lss_label
= symbol
;
1186 label_chain
->lss_space
= current_space
;
1189 label_chain
->lss_segment
= now_seg
;
1191 label_chain
->lss_next
= NULL
;
1193 if (label_symbols_rootp
)
1194 label_chain
->lss_next
= label_symbols_rootp
;
1196 label_symbols_rootp
= label_chain
;
1200 /* Removes a label definition for the current space.
1201 If there is no label_symbol_struct entry, then no action is taken. */
1204 pa_undefine_label ()
1206 label_symbol_struct
*label_chain
;
1207 label_symbol_struct
*prev_label_chain
= NULL
;
1209 for (label_chain
= label_symbols_rootp
;
1211 label_chain
= label_chain
->lss_next
)
1215 && current_space
== label_chain
->lss_space
&& label_chain
->lss_label
1218 && now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
1222 /* Remove the label from the chain and free its memory. */
1223 if (prev_label_chain
)
1224 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1226 label_symbols_rootp
= label_chain
->lss_next
;
1231 prev_label_chain
= label_chain
;
1236 /* An HPPA-specific version of fix_new. This is required because the HPPA
1237 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1238 results in the creation of an instance of an hppa_fix_struct. An
1239 hppa_fix_struct stores the extra information along with a pointer to the
1240 original fixS. This is attached to the original fixup via the
1241 tc_fix_data field. */
1244 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1245 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1249 symbolS
*add_symbol
;
1253 bfd_reloc_code_real_type r_type
;
1254 enum hppa_reloc_field_selector_type_alt r_field
;
1261 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1262 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1265 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1267 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1268 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1269 hppa_fix
->fx_r_type
= r_type
;
1270 hppa_fix
->fx_r_field
= r_field
;
1271 hppa_fix
->fx_r_format
= r_format
;
1272 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1273 hppa_fix
->segment
= now_seg
;
1275 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1276 new_fix
->fx_offset
= *unwind_bits
;
1279 /* foo-$global$ is used to access non-automatic storage. $global$
1280 is really just a marker and has served its purpose, so eliminate
1281 it now so as not to confuse write.c. */
1282 if (new_fix
->fx_subsy
1283 && !strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$"))
1284 new_fix
->fx_subsy
= NULL
;
1287 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1288 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1291 parse_cons_expression_hppa (exp
)
1294 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1298 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1299 hppa_field_selector is set by the parse_cons_expression_hppa. */
1302 cons_fix_new_hppa (frag
, where
, size
, exp
)
1308 unsigned int rel_type
;
1310 /* Get a base relocation type. */
1311 if (is_DP_relative (*exp
))
1312 rel_type
= R_HPPA_GOTOFF
;
1313 else if (is_complex (*exp
))
1314 rel_type
= R_HPPA_COMPLEX
;
1318 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1319 as_warn (_("Invalid field selector. Assuming F%%."));
1321 fix_new_hppa (frag
, where
, size
,
1322 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1323 hppa_field_selector
, size
* 8, 0, NULL
);
1325 /* Reset field selector to its default state. */
1326 hppa_field_selector
= 0;
1329 /* This function is called once, at assembler startup time. It should
1330 set up all the tables, etc. that the MD part of the assembler will need. */
1335 const char *retval
= NULL
;
1339 last_call_info
= NULL
;
1340 call_info_root
= NULL
;
1342 /* Set the default machine type. */
1343 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1344 as_warn (_("could not set architecture and machine"));
1346 /* Folding of text and data segments fails miserably on the PA.
1347 Warn user and disable "-R" option. */
1348 if (flag_readonly_data_in_text
)
1350 as_warn (_("-R option not supported on this target."));
1351 flag_readonly_data_in_text
= 0;
1358 op_hash
= hash_new ();
1360 while (i
< NUMOPCODES
)
1362 const char *name
= pa_opcodes
[i
].name
;
1363 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1364 if (retval
!= NULL
&& *retval
!= '\0')
1366 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1371 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1372 != pa_opcodes
[i
].match
)
1374 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1375 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1380 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1384 as_fatal (_("Broken assembler. No assembly attempted."));
1387 /* SOM will change text_section. To make sure we never put
1388 anything into the old one switch to the new one now. */
1389 subseg_set (text_section
, 0);
1393 dummy_symbol
= symbol_find_or_make ("L$dummy");
1394 S_SET_SEGMENT (dummy_symbol
, text_section
);
1395 /* Force the symbol to be converted to a real symbol. */
1396 (void) symbol_get_bfdsym (dummy_symbol
);
1400 /* Assemble a single instruction storing it into a frag. */
1407 /* The had better be something to assemble. */
1410 /* If we are within a procedure definition, make sure we've
1411 defined a label for the procedure; handle case where the
1412 label was defined after the .PROC directive.
1414 Note there's not need to diddle with the segment or fragment
1415 for the label symbol in this case. We have already switched
1416 into the new $CODE$ subspace at this point. */
1417 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1419 label_symbol_struct
*label_symbol
= pa_get_label ();
1423 if (label_symbol
->lss_label
)
1425 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1426 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1429 /* Also handle allocation of a fixup to hold the unwind
1430 information when the label appears after the proc/procend. */
1431 if (within_entry_exit
)
1433 char *where
= frag_more (0);
1435 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1436 NULL
, (offsetT
) 0, NULL
,
1437 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1438 (int *)&last_call_info
->ci_unwind
.descriptor
);
1443 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1446 as_bad (_("Missing function name for .PROC"));
1449 /* Assemble the instruction. Results are saved into "the_insn". */
1452 /* Get somewhere to put the assembled instrution. */
1455 /* Output the opcode. */
1456 md_number_to_chars (to
, the_insn
.opcode
, 4);
1458 /* If necessary output more stuff. */
1459 if (the_insn
.reloc
!= R_HPPA_NONE
)
1460 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1461 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1462 the_insn
.reloc
, the_insn
.field_selector
,
1463 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1466 if (debug_type
== DEBUG_DWARF2
)
1470 /* First update the notion of the current source line. */
1471 dwarf2_where (&debug_line
);
1473 /* We want the offset of the start of this instruction within the
1474 the current frag. */
1475 addr
= frag_now
->fr_address
+ frag_now_fix () - 4;
1477 /* And record the information. */
1478 dwarf2_gen_line_info (addr
, &debug_line
);
1483 /* Do the real work for assembling a single instruction. Store results
1484 into the global "the_insn" variable. */
1490 char *error_message
= "";
1491 char *s
, c
, *argstart
, *name
, *save_s
;
1495 int cmpltr
, nullif
, flag
, cond
, num
;
1496 unsigned long opcode
;
1497 struct pa_opcode
*insn
;
1500 /* We must have a valid space and subspace. */
1501 pa_check_current_space_and_subspace ();
1504 /* Convert everything up to the first whitespace character into lower
1506 for (s
= str
; *s
!= ' ' && *s
!= '\t' && *s
!= '\n' && *s
!= '\0'; s
++)
1510 /* Skip to something interesting. */
1511 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1530 as_fatal (_("Unknown opcode: `%s'"), str
);
1535 /* Look up the opcode in the has table. */
1536 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1538 as_bad ("Unknown opcode: `%s'", str
);
1547 /* Mark the location where arguments for the instruction start, then
1548 start processing them. */
1552 /* Do some initialization. */
1553 opcode
= insn
->match
;
1554 strict
= (insn
->flags
& FLAG_STRICT
);
1555 memset (&the_insn
, 0, sizeof (the_insn
));
1557 the_insn
.reloc
= R_HPPA_NONE
;
1559 /* If this instruction is specific to a particular architecture,
1560 then set a new architecture. */
1561 /* But do not automatically promote to pa2.0. The automatic promotion
1562 crud is for compatability with HP's old assemblers only. */
1564 && bfd_get_mach (stdoutput
) < insn
->arch
)
1566 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1567 as_warn (_("could not update architecture and machine"));
1569 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1575 /* Build the opcode, checking as we go to make
1576 sure that the operands match. */
1577 for (args
= insn
->args
;; ++args
)
1579 /* Absorb white space in instruction. */
1580 while (*s
== ' ' || *s
== '\t')
1586 /* End of arguments. */
1602 /* These must match exactly. */
1611 /* Handle a 5 bit register or control register field at 10. */
1614 /* This should be more strict. Small steps. */
1615 if (strict
&& *s
!= '%')
1617 num
= pa_parse_number (&s
, 0);
1618 CHECK_FIELD (num
, 31, 0, 0);
1619 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1621 /* Handle %sar or %cr11. No bits get set, we just verify that it
1624 /* Skip whitespace before register. */
1625 while (*s
== ' ' || *s
== '\t')
1628 if (!strncasecmp(s
, "%sar", 4))
1633 else if (!strncasecmp(s
, "%cr11", 5))
1640 /* Handle a 5 bit register field at 15. */
1642 /* This should be more strict. Small steps. */
1643 if (strict
&& *s
!= '%')
1645 num
= pa_parse_number (&s
, 0);
1646 CHECK_FIELD (num
, 31, 0, 0);
1647 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1649 /* Handle a 5 bit register field at 31. */
1651 /* This should be more strict. Small steps. */
1652 if (strict
&& *s
!= '%')
1654 num
= pa_parse_number (&s
, 0);
1655 CHECK_FIELD (num
, 31, 0, 0);
1656 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1658 /* Handle a 5 bit register field at 10 and 15. */
1660 /* This should be more strict. Small steps. */
1661 if (strict
&& *s
!= '%')
1663 num
= pa_parse_number (&s
, 0);
1664 CHECK_FIELD (num
, 31, 0, 0);
1665 opcode
|= num
<< 16;
1666 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1668 /* Handle a 5 bit field length at 31. */
1670 num
= pa_get_absolute_expression (&the_insn
, &s
);
1671 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1674 CHECK_FIELD (num
, 32, 1, 0);
1675 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1677 /* Handle a 5 bit immediate at 15. */
1679 num
= pa_get_absolute_expression (&the_insn
, &s
);
1680 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1683 /* When in strict mode, we want to just reject this
1684 match instead of giving an out of range error. */
1685 CHECK_FIELD (num
, 15, -16, strict
);
1686 low_sign_unext (num
, 5, &num
);
1687 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1689 /* Handle a 5 bit immediate at 31. */
1691 num
= pa_get_absolute_expression (&the_insn
, &s
);
1692 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1695 /* When in strict mode, we want to just reject this
1696 match instead of giving an out of range error. */
1697 CHECK_FIELD (num
, 15, -16, strict
)
1698 low_sign_unext (num
, 5, &num
);
1699 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1701 /* Handle an unsigned 5 bit immediate at 31. */
1703 num
= pa_get_absolute_expression (&the_insn
, &s
);
1704 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1707 CHECK_FIELD (num
, 31, 0, 0);
1708 INSERT_FIELD_AND_CONTINUE (opcode
, num
, strict
);
1710 /* Handle an unsigned 5 bit immediate at 15. */
1712 num
= pa_get_absolute_expression (&the_insn
, &s
);
1713 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1716 CHECK_FIELD (num
, 31, 0, strict
);
1717 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1719 /* Handle an unsigned 10 bit immediate at 15. */
1721 num
= pa_get_absolute_expression (&the_insn
, &s
);
1722 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
1725 CHECK_FIELD (num
, 1023, 0, strict
);
1726 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1728 /* Handle a 2 bit space identifier at 17. */
1730 /* This should be more strict. Small steps. */
1731 if (strict
&& *s
!= '%')
1733 num
= pa_parse_number (&s
, 0);
1734 CHECK_FIELD (num
, 3, 0, 1);
1735 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1737 /* Handle a 3 bit space identifier at 18. */
1739 /* This should be more strict. Small steps. */
1740 if (strict
&& *s
!= '%')
1742 num
= pa_parse_number (&s
, 0);
1743 CHECK_FIELD (num
, 7, 0, 1);
1744 dis_assemble_3 (num
, &num
);
1745 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
1747 /* Handle all completers. */
1752 /* Handle a completer for an indexing load or store. */
1758 while (*s
== ',' && i
< 2)
1761 if (strncasecmp (s
, "sm", 2) == 0)
1768 else if (strncasecmp (s
, "m", 1) == 0)
1770 else if (strncasecmp (s
, "s", 1) == 0)
1772 /* When in strict mode this is a match failure. */
1776 as_bad (_("Invalid Indexed Load Completer."));
1781 as_bad (_("Invalid Indexed Load Completer Syntax."));
1783 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1786 /* Handle a short load/store completer. */
1797 if (strncasecmp (s
, "ma", 2) == 0)
1802 else if (strncasecmp (s
, "mb", 2) == 0)
1807 /* When in strict mode this is a match failure. */
1811 as_bad (_("Invalid Short Load/Store Completer."));
1814 /* If we did not get a ma/mb completer, then we do not
1815 consider this a positive match for 'cc'. */
1816 else if (*args
== 'c')
1819 /* 'J', 'm' and 'q' are the same, except for where they
1820 encode the before/after field. */
1824 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1826 else if (*args
== 'q')
1829 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1831 else if (*args
== 'J')
1833 /* M bit is explicit in the major opcode. */
1834 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 2);
1836 else if (*args
== 'c')
1838 /* Gross! Hide these values in the immediate field
1839 of the instruction, then pull them out later. */
1846 /* Handle a stbys completer. */
1852 while (*s
== ',' && i
< 2)
1855 if (strncasecmp (s
, "m", 1) == 0)
1857 else if (strncasecmp (s
, "b", 1) == 0)
1859 else if (strncasecmp (s
, "e", 1) == 0)
1861 /* When in strict mode this is a match failure. */
1865 as_bad (_("Invalid Store Bytes Short Completer"));
1870 as_bad (_("Invalid Store Bytes Short Completer"));
1872 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1875 /* Handle a local processor completer. */
1877 if (strncasecmp (s
, ",l", 2) != 0)
1882 /* Handle a PROBE read/write completer. */
1885 if (!strncasecmp (s
, ",w", 2))
1890 else if (!strncasecmp (s
, ",r", 2))
1896 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
1898 /* Handle MFCTL wide completer. */
1900 if (strncasecmp (s
, ",w", 2) != 0)
1905 /* Handle an RFI restore completer. */
1908 if (!strncasecmp (s
, ",r", 2))
1914 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
1916 /* Handle a system control completer. */
1918 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
1926 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
1928 /* Handle intermediate/final completer for DCOR. */
1931 if (!strncasecmp (s
, ",i", 2))
1937 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
1939 /* Handle zero/sign extension completer. */
1942 if (!strncasecmp (s
, ",z", 2))
1948 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
1950 /* Handle add completer. */
1953 if (!strncasecmp (s
, ",l", 2))
1958 else if (!strncasecmp (s
, ",tsv", 4))
1964 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 10);
1966 /* Handle 64 bit carry for ADD. */
1969 if (!strncasecmp (s
, ",dc,tsv", 7) ||
1970 !strncasecmp (s
, ",tsv,dc", 7))
1975 else if (!strncasecmp (s
, ",dc", 3))
1983 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
1985 /* Handle 32 bit carry for ADD. */
1988 if (!strncasecmp (s
, ",c,tsv", 6) ||
1989 !strncasecmp (s
, ",tsv,c", 6))
1994 else if (!strncasecmp (s
, ",c", 2))
2002 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2004 /* Handle trap on signed overflow. */
2007 if (!strncasecmp (s
, ",tsv", 4))
2013 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2015 /* Handle trap on condition and overflow. */
2018 if (!strncasecmp (s
, ",tc,tsv", 7) ||
2019 !strncasecmp (s
, ",tsv,tc", 7))
2024 else if (!strncasecmp (s
, ",tc", 3))
2032 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2034 /* Handle 64 bit borrow for SUB. */
2037 if (!strncasecmp (s
, ",db,tsv", 7) ||
2038 !strncasecmp (s
, ",tsv,db", 7))
2043 else if (!strncasecmp (s
, ",db", 3))
2051 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2053 /* Handle 32 bit borrow for SUB. */
2056 if (!strncasecmp (s
, ",b,tsv", 6) ||
2057 !strncasecmp (s
, ",tsv,b", 6))
2062 else if (!strncasecmp (s
, ",b", 2))
2070 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2072 /* Handle trap condition completer for UADDCM. */
2075 if (!strncasecmp (s
, ",tc", 3))
2081 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 6);
2083 /* Handle signed/unsigned at 21. */
2087 if (strncasecmp (s
, ",s", 2) == 0)
2092 else if (strncasecmp (s
, ",u", 2) == 0)
2098 INSERT_FIELD_AND_CONTINUE (opcode
, sign
, 10);
2101 /* Handle left/right combination at 17:18. */
2111 as_bad(_("Invalid left/right combination completer"));
2114 INSERT_FIELD_AND_CONTINUE (opcode
, lr
, 13);
2117 as_bad(_("Invalid left/right combination completer"));
2120 /* Handle saturation at 24:25. */
2124 if (strncasecmp (s
, ",ss", 3) == 0)
2129 else if (strncasecmp (s
, ",us", 3) == 0)
2135 INSERT_FIELD_AND_CONTINUE (opcode
, sat
, 6);
2138 /* Handle permutation completer. */
2166 as_bad(_("Invalid permutation completer"));
2168 opcode
|= perm
<< permloc
[i
];
2173 as_bad(_("Invalid permutation completer"));
2181 /* Handle all conditions. */
2187 /* Handle FP compare conditions. */
2189 cond
= pa_parse_fp_cmp_cond (&s
);
2190 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2192 /* Handle an add condition. */
2201 /* 64 bit conditions. */
2214 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2218 if (strcmp (name
, "=") == 0)
2220 else if (strcmp (name
, "<") == 0)
2222 else if (strcmp (name
, "<=") == 0)
2224 else if (strcasecmp (name
, "nuv") == 0)
2226 else if (strcasecmp (name
, "znv") == 0)
2228 else if (strcasecmp (name
, "sv") == 0)
2230 else if (strcasecmp (name
, "od") == 0)
2232 else if (strcasecmp (name
, "tr") == 0)
2237 else if (strcmp (name
, "<>") == 0)
2242 else if (strcmp (name
, ">=") == 0)
2247 else if (strcmp (name
, ">") == 0)
2252 else if (strcasecmp (name
, "uv") == 0)
2257 else if (strcasecmp (name
, "vnz") == 0)
2262 else if (strcasecmp (name
, "nsv") == 0)
2267 else if (strcasecmp (name
, "ev") == 0)
2272 /* ",*" is a valid condition. */
2273 else if (*args
== 'a')
2274 as_bad (_("Invalid Add Condition: %s"), name
);
2277 opcode
|= cmpltr
<< 13;
2278 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2280 /* Handle non-negated add and branch condition. */
2282 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2285 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
2288 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2290 /* Handle negated add and branch condition. */
2294 /* Handle wide-mode non-negated add and branch condition. */
2298 /* Handle wide-mode negated add and branch condition. */
2302 /* Handle a negated or non-negated add and branch
2306 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
2310 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
2313 as_bad (_("Invalid Compare/Subtract Condition"));
2318 /* Negated condition requires an opcode change. */
2322 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2324 /* Handle branch on bit conditions. */
2342 if (strncmp (s
, "<", 1) == 0)
2347 else if (strncmp (s
, ">=", 2) == 0)
2353 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2355 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2357 /* Handle a compare/subtract condition. */
2366 /* 64 bit conditions. */
2379 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2383 if (strcmp (name
, "=") == 0)
2385 else if (strcmp (name
, "<") == 0)
2387 else if (strcmp (name
, "<=") == 0)
2389 else if (strcasecmp (name
, "<<") == 0)
2391 else if (strcasecmp (name
, "<<=") == 0)
2393 else if (strcasecmp (name
, "sv") == 0)
2395 else if (strcasecmp (name
, "od") == 0)
2397 else if (strcasecmp (name
, "tr") == 0)
2402 else if (strcmp (name
, "<>") == 0)
2407 else if (strcmp (name
, ">=") == 0)
2412 else if (strcmp (name
, ">") == 0)
2417 else if (strcasecmp (name
, ">>=") == 0)
2422 else if (strcasecmp (name
, ">>") == 0)
2427 else if (strcasecmp (name
, "nsv") == 0)
2432 else if (strcasecmp (name
, "ev") == 0)
2437 /* ",*" is a valid condition. */
2438 else if (*args
!= 'S')
2439 as_bad (_("Invalid Compare/Subtract Condition: %s"),
2443 opcode
|= cmpltr
<< 13;
2444 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2446 /* Handle a non-negated compare condition. */
2448 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2451 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
2454 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2456 /* Handle a negated compare condition. */
2460 /* Handle a 64 bit non-negated compare condition. */
2464 /* Handle a 64 bit negated compare condition. */
2468 /* Handle a 64 bit cmpib condition. */
2472 /* Handle a negated or non-negated compare/subtract
2476 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2480 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
2483 as_bad (_("Invalid Compare/Subtract Condition."));
2488 /* Negated condition requires an opcode change. */
2493 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2495 /* Handle a logical instruction condition. */
2504 /* 64 bit conditions. */
2517 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2523 if (strcmp (name
, "=") == 0)
2525 else if (strcmp (name
, "<") == 0)
2527 else if (strcmp (name
, "<=") == 0)
2529 else if (strcasecmp (name
, "od") == 0)
2531 else if (strcasecmp (name
, "tr") == 0)
2536 else if (strcmp (name
, "<>") == 0)
2541 else if (strcmp (name
, ">=") == 0)
2546 else if (strcmp (name
, ">") == 0)
2551 else if (strcasecmp (name
, "ev") == 0)
2556 /* ",*" is a valid condition. */
2557 else if (*args
!= 'L')
2558 as_bad (_("Invalid Logical Instruction Condition."));
2561 opcode
|= cmpltr
<< 13;
2562 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2564 /* Handle a shift/extract/deposit condition. */
2573 /* 64 bit conditions. */
2586 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2590 if (strcmp (name
, "=") == 0)
2592 else if (strcmp (name
, "<") == 0)
2594 else if (strcasecmp (name
, "od") == 0)
2596 else if (strcasecmp (name
, "tr") == 0)
2598 else if (strcmp (name
, "<>") == 0)
2600 else if (strcmp (name
, ">=") == 0)
2602 else if (strcasecmp (name
, "ev") == 0)
2604 /* Handle movb,n. Put things back the way they were.
2605 This includes moving s back to where it started. */
2606 else if (strcasecmp (name
, "n") == 0 && *args
== 'y')
2612 /* ",*" is a valid condition. */
2613 else if (*args
!= 'X')
2614 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2617 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2619 /* Handle a unit instruction condition. */
2628 /* 64 bit conditions. */
2639 if (strncasecmp (s
, "sbz", 3) == 0)
2644 else if (strncasecmp (s
, "shz", 3) == 0)
2649 else if (strncasecmp (s
, "sdc", 3) == 0)
2654 else if (strncasecmp (s
, "sbc", 3) == 0)
2659 else if (strncasecmp (s
, "shc", 3) == 0)
2664 else if (strncasecmp (s
, "tr", 2) == 0)
2670 else if (strncasecmp (s
, "nbz", 3) == 0)
2676 else if (strncasecmp (s
, "nhz", 3) == 0)
2682 else if (strncasecmp (s
, "ndc", 3) == 0)
2688 else if (strncasecmp (s
, "nbc", 3) == 0)
2694 else if (strncasecmp (s
, "nhc", 3) == 0)
2700 /* ",*" is a valid condition. */
2701 else if (*args
!= 'U')
2702 as_bad (_("Invalid Unit Instruction Condition."));
2704 opcode
|= cmpltr
<< 13;
2705 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2713 /* Handle a nullification completer for branch instructions. */
2715 nullif
= pa_parse_nullif (&s
);
2716 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2718 /* Handle a nullification completer for copr and spop insns. */
2720 nullif
= pa_parse_nullif (&s
);
2721 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2723 /* Handle ,gate completer for new syntax branches. */
2725 if (*s
== ',' && strncasecmp (s
+ 1, "gate", 4) == 0)
2731 /* Handle ,l completer for new syntax branches. */
2733 if (*s
== ',' && strncasecmp (s
+ 1, "l", 1) == 0)
2739 /* Handle ,push completer for new syntax branches. */
2741 if (*s
== ',' && strncasecmp (s
+ 1, "push", 4) == 0)
2747 /* Handle ,pop completer for new syntax branches. */
2749 if (*s
== ',' && strncasecmp (s
+ 1, "pop", 3) == 0)
2755 /* Handle ,%r2 completer for new syntax branches. */
2757 if (*s
== ',' && strncasecmp (s
+ 1, "%r2", 3) == 0)
2759 else if (*s
== ',' && strncasecmp (s
+ 1, "%rp", 3) == 0)
2765 /* Handle 3 bit entry into the fp compare array. Valid values
2766 are 0..6 inclusive. */
2770 if (the_insn
.exp
.X_op
== O_constant
)
2772 num
= evaluate_absolute (&the_insn
);
2773 CHECK_FIELD (num
, 6, 0, 0);
2775 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2780 /* Handle 3 bit entry into the fp compare array. Valid values
2781 are 0..6 inclusive. */
2784 if (the_insn
.exp
.X_op
== O_constant
)
2787 num
= evaluate_absolute (&the_insn
);
2788 CHECK_FIELD (num
, 6, 0, 0);
2789 num
= (num
+ 1) ^ 1;
2790 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2795 /* Handle graphics test completers for ftest */
2798 num
= pa_parse_ftest_gfx_completer (&s
);
2799 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2802 /* Handle a 11 bit immediate at 31. */
2804 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2807 if (the_insn
.exp
.X_op
== O_constant
)
2809 num
= evaluate_absolute (&the_insn
);
2810 CHECK_FIELD (num
, 1023, -1024, 0);
2811 low_sign_unext (num
, 11, &num
);
2812 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2816 if (is_DP_relative (the_insn
.exp
))
2817 the_insn
.reloc
= R_HPPA_GOTOFF
;
2818 else if (is_PC_relative (the_insn
.exp
))
2819 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2821 the_insn
.reloc
= R_HPPA
;
2822 the_insn
.format
= 11;
2826 /* Handle a 14 bit immediate at 31. */
2828 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2831 if (the_insn
.exp
.X_op
== O_constant
)
2835 /* XXX the completer stored away tibits of information
2836 for us to extract. We need a cleaner way to do this.
2837 Now that we have lots of letters again, it would be
2838 good to rethink this. */
2839 m
= (opcode
& (1 << 8)) != 0;
2840 a
= (opcode
& (1 << 9)) != 0;
2841 opcode
&= ~ (3 << 8);
2842 num
= evaluate_absolute (&the_insn
);
2843 if (a
== 1 && num
>= 0 || (a
== 0 && num
< 0))
2845 CHECK_FIELD (num
, 8191, -8192, 0);
2846 low_sign_unext (num
, 14, &num
);
2847 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2854 /* Handle a 14 bit immediate at 31. */
2856 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2859 if (the_insn
.exp
.X_op
== O_constant
)
2863 /* XXX the completer stored away tibits of information
2864 for us to extract. We need a cleaner way to do this.
2865 Now that we have lots of letters again, it would be
2866 good to rethink this. */
2867 m
= (opcode
& (1 << 8)) != 0;
2868 a
= (opcode
& (1 << 9)) != 0;
2869 opcode
&= ~ (3 << 8);
2870 num
= evaluate_absolute (&the_insn
);
2871 if (a
== 1 && num
< 0 || (a
== 0 && num
> 0))
2875 CHECK_FIELD (num
, 8191, -8192, 0);
2880 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
2887 /* Handle 14 bit immediated, shifted left three times. */
2889 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2892 if (the_insn
.exp
.X_op
== O_constant
)
2894 num
= evaluate_absolute (&the_insn
);
2897 CHECK_FIELD (num
, 8191, -8192, 0);
2902 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 4);
2906 if (is_DP_relative (the_insn
.exp
))
2907 the_insn
.reloc
= R_HPPA_GOTOFF
;
2908 else if (is_PC_relative (the_insn
.exp
))
2909 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2911 the_insn
.reloc
= R_HPPA
;
2912 the_insn
.format
= 14;
2917 /* Handle 14 bit immediate, shifted left twice. */
2919 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2922 if (the_insn
.exp
.X_op
== O_constant
)
2924 num
= evaluate_absolute (&the_insn
);
2927 CHECK_FIELD (num
, 8191, -8192, 0);
2932 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
2936 if (is_DP_relative (the_insn
.exp
))
2937 the_insn
.reloc
= R_HPPA_GOTOFF
;
2938 else if (is_PC_relative (the_insn
.exp
))
2939 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2941 the_insn
.reloc
= R_HPPA
;
2942 the_insn
.format
= 14;
2946 /* Handle a 14 bit immediate at 31. */
2948 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2951 if (the_insn
.exp
.X_op
== O_constant
)
2953 num
= evaluate_absolute (&the_insn
);
2954 CHECK_FIELD (num
, 8191, -8192, 0);
2955 low_sign_unext (num
, 14, &num
);
2956 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2960 if (is_DP_relative (the_insn
.exp
))
2961 the_insn
.reloc
= R_HPPA_GOTOFF
;
2962 else if (is_PC_relative (the_insn
.exp
))
2963 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2965 the_insn
.reloc
= R_HPPA
;
2966 the_insn
.format
= 14;
2970 /* Handle a 21 bit immediate at 31. */
2972 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2975 if (the_insn
.exp
.X_op
== O_constant
)
2977 num
= evaluate_absolute (&the_insn
);
2978 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
2979 dis_assemble_21 (num
, &num
);
2980 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2984 if (is_DP_relative (the_insn
.exp
))
2985 the_insn
.reloc
= R_HPPA_GOTOFF
;
2986 else if (is_PC_relative (the_insn
.exp
))
2987 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2989 the_insn
.reloc
= R_HPPA
;
2990 the_insn
.format
= 21;
2994 /* Handle a 12 bit branch displacement. */
2996 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3000 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
3002 unsigned int w1
, w
, result
;
3004 num
= evaluate_absolute (&the_insn
);
3007 as_bad (_("Branch to unaligned address"));
3010 CHECK_FIELD (num
, 8199, -8184, 0);
3011 sign_unext ((num
- 8) >> 2, 12, &result
);
3012 dis_assemble_12 (result
, &w1
, &w
);
3013 INSERT_FIELD_AND_CONTINUE (opcode
, ((w1
<< 2) | w
), 0);
3017 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3018 the_insn
.format
= 12;
3019 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3020 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3025 /* Handle a 17 bit branch displacement. */
3027 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3031 if (!the_insn
.exp
.X_add_symbol
3032 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3035 unsigned int w2
, w1
, w
, result
;
3037 num
= evaluate_absolute (&the_insn
);
3040 as_bad (_("Branch to unaligned address"));
3043 CHECK_FIELD (num
, 262143, -262144, 0);
3045 if (the_insn
.exp
.X_add_symbol
)
3048 sign_unext (num
>> 2, 17, &result
);
3049 dis_assemble_17 (result
, &w1
, &w2
, &w
);
3050 INSERT_FIELD_AND_CONTINUE (opcode
,
3051 ((w2
<< 2) | (w1
<< 16) | w
), 0);
3055 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3056 the_insn
.format
= 17;
3057 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3058 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3062 /* Handle a 22 bit branch displacement. */
3064 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3068 if (!the_insn
.exp
.X_add_symbol
3069 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3072 unsigned int w3
, w2
, w1
, w
, result
;
3074 num
= evaluate_absolute (&the_insn
);
3077 as_bad (_("Branch to unaligned address"));
3080 CHECK_FIELD (num
, 8388607, -8388608, 0);
3082 if (the_insn
.exp
.X_add_symbol
)
3085 sign_unext (num
>> 2, 22, &result
);
3086 dis_assemble_22 (result
, &w3
, &w1
, &w2
, &w
);
3087 INSERT_FIELD_AND_CONTINUE (opcode
,
3088 ((w3
<< 21) | (w2
<< 2)
3094 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
3095 the_insn
.format
= 22;
3096 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3097 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3101 /* Handle an absolute 17 bit branch target. */
3103 the_insn
.field_selector
= pa_chk_field_selector (&s
);
3107 if (!the_insn
.exp
.X_add_symbol
3108 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
3111 unsigned int w2
, w1
, w
, result
;
3113 num
= evaluate_absolute (&the_insn
);
3116 as_bad (_("Branch to unaligned address"));
3119 CHECK_FIELD (num
, 262143, -262144, 0);
3121 if (the_insn
.exp
.X_add_symbol
)
3124 sign_unext (num
>> 2, 17, &result
);
3125 dis_assemble_17 (result
, &w1
, &w2
, &w
);
3126 INSERT_FIELD_AND_CONTINUE (opcode
,
3127 ((w2
<< 2) | (w1
<< 16) | w
), 0);
3131 the_insn
.reloc
= R_HPPA_ABS_CALL
;
3132 the_insn
.format
= 17;
3133 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
3134 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
3138 /* Handle '%r1' implicit operand of addil instruction. */
3140 if (*s
== ',' && *(s
+ 1) == '%' && *(s
+ 3) == '1'
3141 && (*(s
+ 2) == 'r' || *(s
+ 2) == 'R'))
3149 /* Handle a 2 bit shift count at 25. */
3151 num
= pa_get_absolute_expression (&the_insn
, &s
);
3152 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3155 CHECK_FIELD (num
, 3, 1, strict
);
3156 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3158 /* Handle a 4 bit shift count at 25. */
3160 num
= pa_get_absolute_expression (&the_insn
, &s
);
3161 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3164 CHECK_FIELD (num
, 15, 0, strict
);
3165 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3167 /* Handle a 5 bit shift count at 26. */
3169 num
= pa_get_absolute_expression (&the_insn
, &s
);
3170 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3173 CHECK_FIELD (num
, 31, 0, strict
);
3174 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
3176 /* Handle a 6 bit shift count at 20,22:26. */
3178 num
= pa_get_absolute_expression (&the_insn
, &s
);
3179 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3182 CHECK_FIELD (num
, 63, 0, strict
);
3184 opcode
|= (num
& 0x20) << 6;
3185 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3187 /* Handle a 6 bit field length at 23,27:31. */
3190 num
= pa_get_absolute_expression (&the_insn
, &s
);
3191 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3194 CHECK_FIELD (num
, 64, 1, strict
);
3196 opcode
|= (num
& 0x20) << 3;
3197 num
= 31 - (num
& 0x1f);
3198 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3200 /* Handle a 6 bit field length at 19,27:31. */
3202 num
= pa_get_absolute_expression (&the_insn
, &s
);
3203 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3206 CHECK_FIELD (num
, 64, 1, strict
);
3208 opcode
|= (num
& 0x20) << 7;
3209 num
= 31 - (num
& 0x1f);
3210 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3212 /* Handle a 5 bit bit position at 26. */
3214 num
= pa_get_absolute_expression (&the_insn
, &s
);
3215 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3218 CHECK_FIELD (num
, 31, 0, strict
);
3219 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
3221 /* Handle a 6 bit bit position at 20,22:26. */
3223 num
= pa_get_absolute_expression (&the_insn
, &s
);
3224 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3227 CHECK_FIELD (num
, 63, 0, strict
);
3228 opcode
|= (num
& 0x20) << 6;
3229 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
3231 /* Handle a 5 bit immediate at 10. */
3233 num
= pa_get_absolute_expression (&the_insn
, &s
);
3234 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3236 if (the_insn
.exp
.X_op
!= O_constant
)
3239 CHECK_FIELD (num
, 31, 0, strict
);
3240 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
3242 /* Handle a 9 bit immediate at 28. */
3244 num
= pa_get_absolute_expression (&the_insn
, &s
);
3245 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3248 CHECK_FIELD (num
, 511, 1, strict
);
3249 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
3251 /* Handle a 13 bit immediate at 18. */
3253 num
= pa_get_absolute_expression (&the_insn
, &s
);
3254 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3257 CHECK_FIELD (num
, 8191, 0, strict
);
3258 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
3260 /* Handle a 26 bit immediate at 31. */
3262 num
= pa_get_absolute_expression (&the_insn
, &s
);
3263 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3266 CHECK_FIELD (num
, 671108864, 0, strict
);
3267 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3269 /* Handle a 3 bit SFU identifier at 25. */
3272 as_bad (_("Invalid SFU identifier"));
3273 num
= pa_get_absolute_expression (&the_insn
, &s
);
3274 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3277 CHECK_FIELD (num
, 7, 0, strict
);
3278 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3280 /* Handle a 20 bit SOP field for spop0. */
3282 num
= pa_get_absolute_expression (&the_insn
, &s
);
3283 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3286 CHECK_FIELD (num
, 1048575, 0, strict
);
3287 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
3288 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3290 /* Handle a 15bit SOP field for spop1. */
3292 num
= pa_get_absolute_expression (&the_insn
, &s
);
3293 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3296 CHECK_FIELD (num
, 32767, 0, strict
);
3297 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
3299 /* Handle a 10bit SOP field for spop3. */
3301 num
= pa_get_absolute_expression (&the_insn
, &s
);
3302 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3305 CHECK_FIELD (num
, 1023, 0, strict
);
3306 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
3307 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3309 /* Handle a 15 bit SOP field for spop2. */
3311 num
= pa_get_absolute_expression (&the_insn
, &s
);
3312 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3315 CHECK_FIELD (num
, 32767, 0, strict
);
3316 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
3317 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3319 /* Handle a 3-bit co-processor ID field. */
3322 as_bad (_("Invalid COPR identifier"));
3323 num
= pa_get_absolute_expression (&the_insn
, &s
);
3324 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3327 CHECK_FIELD (num
, 7, 0, strict
);
3328 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
3330 /* Handle a 22bit SOP field for copr. */
3332 num
= pa_get_absolute_expression (&the_insn
, &s
);
3333 if (strict
&& the_insn
.exp
.X_op
!= O_constant
)
3336 CHECK_FIELD (num
, 4194303, 0, strict
);
3337 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
3338 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3340 /* Handle a source FP operand format completer. */
3342 if (*s
== ',' && *(s
+1) == 't')
3349 flag
= pa_parse_fp_cnv_format (&s
);
3350 the_insn
.fpof1
= flag
;
3351 if (flag
== W
|| flag
== UW
)
3353 if (flag
== DW
|| flag
== UDW
)
3355 if (flag
== QW
|| flag
== UQW
)
3357 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3359 /* Handle a destination FP operand format completer. */
3361 /* pa_parse_format needs the ',' prefix. */
3363 flag
= pa_parse_fp_cnv_format (&s
);
3364 the_insn
.fpof2
= flag
;
3365 if (flag
== W
|| flag
== UW
)
3367 if (flag
== DW
|| flag
== UDW
)
3369 if (flag
== QW
|| flag
== UQW
)
3371 opcode
|= flag
<< 13;
3372 if (the_insn
.fpof1
== SGL
3373 || the_insn
.fpof1
== DBL
3374 || the_insn
.fpof1
== QUAD
)
3376 if (the_insn
.fpof2
== SGL
3377 || the_insn
.fpof2
== DBL
3378 || the_insn
.fpof2
== QUAD
)
3380 else if (the_insn
.fpof2
== W
3381 || the_insn
.fpof2
== DW
3382 || the_insn
.fpof2
== QW
)
3384 else if (the_insn
.fpof2
== UW
3385 || the_insn
.fpof2
== UDW
3386 || the_insn
.fpof2
== UQW
)
3391 else if (the_insn
.fpof1
== W
3392 || the_insn
.fpof1
== DW
3393 || the_insn
.fpof1
== QW
)
3395 if (the_insn
.fpof2
== SGL
3396 || the_insn
.fpof2
== DBL
3397 || the_insn
.fpof2
== QUAD
)
3402 else if (the_insn
.fpof1
== UW
3403 || the_insn
.fpof1
== UDW
3404 || the_insn
.fpof1
== UQW
)
3406 if (the_insn
.fpof2
== SGL
3407 || the_insn
.fpof2
== DBL
3408 || the_insn
.fpof2
== QUAD
)
3413 flag
|= the_insn
.trunc
;
3414 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 15);
3416 /* Handle a source FP operand format completer. */
3418 flag
= pa_parse_fp_format (&s
);
3419 the_insn
.fpof1
= flag
;
3420 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3422 /* Handle a destination FP operand format completer. */
3424 /* pa_parse_format needs the ',' prefix. */
3426 flag
= pa_parse_fp_format (&s
);
3427 the_insn
.fpof2
= flag
;
3428 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
3430 /* Handle a source FP operand format completer at 20. */
3432 flag
= pa_parse_fp_format (&s
);
3433 the_insn
.fpof1
= flag
;
3434 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
3436 /* Handle a floating point operand format at 26.
3437 Only allows single and double precision. */
3439 flag
= pa_parse_fp_format (&s
);
3445 the_insn
.fpof1
= flag
;
3451 as_bad (_("Invalid Floating Point Operand Format."));
3455 /* Handle all floating point registers. */
3459 /* Float target register. */
3461 /* This should be more strict. Small steps. */
3462 if (strict
&& *s
!= '%')
3464 num
= pa_parse_number (&s
, 0);
3465 CHECK_FIELD (num
, 31, 0, 0);
3466 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
3468 /* Float target register with L/R selection. */
3471 struct pa_11_fp_reg_struct result
;
3473 /* This should be more strict. Small steps. */
3474 if (strict
&& *s
!= '%')
3476 pa_parse_number (&s
, &result
);
3477 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3478 opcode
|= result
.number_part
;
3480 /* 0x30 opcodes are FP arithmetic operation opcodes
3481 and need to be turned into 0x38 opcodes. This
3482 is not necessary for loads/stores. */
3483 if (need_pa11_opcode (&the_insn
, &result
)
3484 && ((opcode
& 0xfc000000) == 0x30000000))
3487 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
3490 /* Float operand 1. */
3493 struct pa_11_fp_reg_struct result
;
3495 /* This should be more strict. Small steps. */
3496 if (strict
&& *s
!= '%')
3498 pa_parse_number (&s
, &result
);
3499 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3500 opcode
|= result
.number_part
<< 21;
3501 if (need_pa11_opcode (&the_insn
, &result
))
3503 opcode
|= (result
.l_r_select
& 1) << 7;
3509 /* Float operand 1 with L/R selection. */
3513 struct pa_11_fp_reg_struct result
;
3515 /* This should be more strict. Small steps. */
3516 if (strict
&& *s
!= '%')
3518 pa_parse_number (&s
, &result
);
3519 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3520 opcode
|= result
.number_part
<< 21;
3521 opcode
|= (result
.l_r_select
& 1) << 7;
3525 /* Float operand 2. */
3528 struct pa_11_fp_reg_struct result
;
3530 /* This should be more strict. Small steps. */
3531 if (strict
&& *s
!= '%')
3533 pa_parse_number (&s
, &result
);
3534 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3535 opcode
|= (result
.number_part
& 0x1f) << 16;
3536 if (need_pa11_opcode (&the_insn
, &result
))
3538 opcode
|= (result
.l_r_select
& 1) << 12;
3544 /* Float operand 2 with L/R selection. */
3547 struct pa_11_fp_reg_struct result
;
3549 /* This should be more strict. Small steps. */
3550 if (strict
&& *s
!= '%')
3552 pa_parse_number (&s
, &result
);
3553 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3554 opcode
|= (result
.number_part
& 0x1f) << 16;
3555 opcode
|= (result
.l_r_select
& 1) << 12;
3559 /* Float operand 3 for fmpyfadd, fmpynfadd. */
3562 struct pa_11_fp_reg_struct result
;
3565 /* This should be more strict. Small steps. */
3566 if (strict
&& *s
!= '%')
3568 pa_parse_number (&s
, &result
);
3569 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3570 opcode
|= (result
.number_part
& 0x1c) << 11;
3571 opcode
|= (result
.number_part
& 0x3) << 9;
3572 opcode
|= (result
.l_r_select
& 1) << 8;
3576 /* Float mult operand 1 for fmpyadd, fmpysub */
3579 struct pa_11_fp_reg_struct result
;
3581 /* This should be more strict. Small steps. */
3582 if (strict
&& *s
!= '%')
3584 pa_parse_number (&s
, &result
);
3585 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3586 if (the_insn
.fpof1
== SGL
)
3588 if (result
.number_part
< 16)
3590 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3594 result
.number_part
&= 0xF;
3595 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3597 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
3600 /* Float mult operand 2 for fmpyadd, fmpysub */
3603 struct pa_11_fp_reg_struct result
;
3605 /* This should be more strict. Small steps. */
3606 if (strict
&& *s
!= '%')
3608 pa_parse_number (&s
, &result
);
3609 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3610 if (the_insn
.fpof1
== SGL
)
3612 if (result
.number_part
< 16)
3614 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3617 result
.number_part
&= 0xF;
3618 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3620 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
3623 /* Float mult target for fmpyadd, fmpysub */
3626 struct pa_11_fp_reg_struct result
;
3628 /* This should be more strict. Small steps. */
3629 if (strict
&& *s
!= '%')
3631 pa_parse_number (&s
, &result
);
3632 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3633 if (the_insn
.fpof1
== SGL
)
3635 if (result
.number_part
< 16)
3637 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3640 result
.number_part
&= 0xF;
3641 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3643 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
3646 /* Float add operand 1 for fmpyadd, fmpysub */
3649 struct pa_11_fp_reg_struct result
;
3651 /* This should be more strict. Small steps. */
3652 if (strict
&& *s
!= '%')
3654 pa_parse_number (&s
, &result
);
3655 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3656 if (the_insn
.fpof1
== SGL
)
3658 if (result
.number_part
< 16)
3660 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3663 result
.number_part
&= 0xF;
3664 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3666 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
3669 /* Float add target for fmpyadd, fmpysub */
3672 struct pa_11_fp_reg_struct result
;
3674 /* This should be more strict. Small steps. */
3675 if (strict
&& *s
!= '%')
3677 pa_parse_number (&s
, &result
);
3678 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3679 if (the_insn
.fpof1
== SGL
)
3681 if (result
.number_part
< 16)
3683 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
3686 result
.number_part
&= 0xF;
3687 result
.number_part
|= (result
.l_r_select
& 1) << 4;
3689 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
3692 /* Handle L/R register halves like 'x'. */
3695 struct pa_11_fp_reg_struct result
;
3697 if (strict
&& *s
!= '%')
3699 pa_parse_number (&s
, &result
);
3700 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3701 opcode
|= (result
.number_part
& 0x1f) << 16;
3702 if (need_pa11_opcode (&the_insn
, &result
))
3704 opcode
|= (result
.l_r_select
& 1) << 1;
3712 /* Handle L/R register halves like 'x'. */
3715 struct pa_11_fp_reg_struct result
;
3717 /* This should be more strict. Small steps. */
3718 if (strict
&& *s
!= '%')
3720 pa_parse_number (&s
, &result
);
3721 CHECK_FIELD (result
.number_part
, 31, 0, 0);
3722 opcode
|= (result
.number_part
& 0x1f) << 16;
3723 if (need_pa11_opcode (&the_insn
, &result
))
3725 opcode
|= (result
.l_r_select
& 1) << 1;
3737 /* Check if the args matched. */
3740 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
3741 && !strcmp (insn
->name
, insn
[1].name
))
3749 as_bad (_("Invalid operands %s"), error_message
);
3756 the_insn
.opcode
= opcode
;
3759 /* Turn a string in input_line_pointer into a floating point constant of type
3760 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
3761 emitted is stored in *sizeP . An error message or NULL is returned. */
3763 #define MAX_LITTLENUMS 6
3766 md_atof (type
, litP
, sizeP
)
3772 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
3773 LITTLENUM_TYPE
*wordP
;
3805 return _("Bad call to MD_ATOF()");
3807 t
= atof_ieee (input_line_pointer
, type
, words
);
3809 input_line_pointer
= t
;
3810 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
3811 for (wordP
= words
; prec
--;)
3813 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
3814 litP
+= sizeof (LITTLENUM_TYPE
);
3819 /* Write out big-endian. */
3822 md_number_to_chars (buf
, val
, n
)
3827 number_to_chars_bigendian (buf
, val
, n
);
3830 /* Translate internal representation of relocation info to BFD target
3834 tc_gen_reloc (section
, fixp
)
3839 struct hppa_fix_struct
*hppa_fixp
;
3840 bfd_reloc_code_real_type code
;
3841 static arelent
*no_relocs
= NULL
;
3843 bfd_reloc_code_real_type
**codes
;
3847 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
3848 if (fixp
->fx_addsy
== 0)
3850 assert (hppa_fixp
!= 0);
3851 assert (section
!= 0);
3853 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
3855 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3856 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3857 codes
= (bfd_reloc_code_real_type
**) hppa_gen_reloc_type (stdoutput
,
3859 hppa_fixp
->fx_r_format
,
3860 hppa_fixp
->fx_r_field
,
3861 fixp
->fx_subsy
!= NULL
,
3862 symbol_get_bfdsym (fixp
->fx_addsy
));
3867 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
3870 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
3871 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
3872 for (i
= 0; i
< n_relocs
; i
++)
3873 relocs
[i
] = &reloc
[i
];
3875 relocs
[n_relocs
] = NULL
;
3878 switch (fixp
->fx_r_type
)
3881 assert (n_relocs
== 1);
3885 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3886 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3887 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
3888 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3889 reloc
->addend
= 0; /* default */
3891 assert (reloc
->howto
&& code
== reloc
->howto
->type
);
3893 /* Now, do any processing that is dependent on the relocation type. */
3896 case R_PARISC_DLTREL21L
:
3897 case R_PARISC_DLTREL14R
:
3898 case R_PARISC_DLTREL14F
:
3899 case R_PARISC_PLABEL32
:
3900 case R_PARISC_PLABEL21L
:
3901 case R_PARISC_PLABEL14R
:
3902 /* For plabel relocations, the addend of the
3903 relocation should be either 0 (no static link) or 2
3904 (static link required).
3906 FIXME: We always assume no static link!
3908 We also slam a zero addend into the DLT relative relocs;
3909 it doesn't make a lot of sense to use any addend since
3910 it gets you a different (eg unknown) DLT entry. */
3914 case R_PARISC_PCREL21L
:
3915 case R_PARISC_PCREL17R
:
3916 case R_PARISC_PCREL17F
:
3917 case R_PARISC_PCREL17C
:
3918 case R_PARISC_PCREL14R
:
3919 case R_PARISC_PCREL14F
:
3920 /* The constant is stored in the instruction. */
3921 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
3924 reloc
->addend
= fixp
->fx_offset
;
3931 /* Walk over reach relocation returned by the BFD backend. */
3932 for (i
= 0; i
< n_relocs
; i
++)
3936 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3937 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3938 relocs
[i
]->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
3939 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3944 /* The only time we ever use a R_COMP2 fixup is for the difference
3945 of two symbols. With that in mind we fill in all four
3946 relocs now and break out of the loop. */
3948 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
3949 relocs
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[0]);
3950 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3951 relocs
[0]->addend
= 0;
3952 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3953 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3954 relocs
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[1]);
3955 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3956 relocs
[1]->addend
= 0;
3957 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3958 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
3959 relocs
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[2]);
3960 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3961 relocs
[2]->addend
= 0;
3962 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
3963 relocs
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[3]);
3964 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3965 relocs
[3]->addend
= 0;
3966 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
3967 relocs
[4]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[4]);
3968 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3969 relocs
[4]->addend
= 0;
3973 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
3979 /* For plabel relocations, the addend of the
3980 relocation should be either 0 (no static link) or 2
3981 (static link required).
3983 FIXME: We always assume no static link!
3985 We also slam a zero addend into the DLT relative relocs;
3986 it doesn't make a lot of sense to use any addend since
3987 it gets you a different (eg unknown) DLT entry. */
3988 relocs
[i
]->addend
= 0;
4003 /* There is no symbol or addend associated with these fixups. */
4004 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4005 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4006 relocs
[i
]->addend
= 0;
4012 /* There is no symbol associated with these fixups. */
4013 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
4014 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
4015 relocs
[i
]->addend
= fixp
->fx_offset
;
4019 relocs
[i
]->addend
= fixp
->fx_offset
;
4029 /* Process any machine dependent frag types. */
4032 md_convert_frag (abfd
, sec
, fragP
)
4034 register asection
*sec
;
4035 register fragS
*fragP
;
4037 unsigned int address
;
4039 if (fragP
->fr_type
== rs_machine_dependent
)
4041 switch ((int) fragP
->fr_subtype
)
4044 fragP
->fr_type
= rs_fill
;
4045 know (fragP
->fr_var
== 1);
4046 know (fragP
->fr_next
);
4047 address
= fragP
->fr_address
+ fragP
->fr_fix
;
4048 if (address
% fragP
->fr_offset
)
4051 fragP
->fr_next
->fr_address
4056 fragP
->fr_offset
= 0;
4062 /* Round up a section size to the appropriate boundary. */
4065 md_section_align (segment
, size
)
4069 int align
= bfd_get_section_alignment (stdoutput
, segment
);
4070 int align2
= (1 << align
) - 1;
4072 return (size
+ align2
) & ~align2
;
4075 /* Return the approximate size of a frag before relaxation has occurred. */
4077 md_estimate_size_before_relax (fragP
, segment
)
4078 register fragS
*fragP
;
4085 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
4091 CONST
char *md_shortopts
= "";
4092 struct option md_longopts
[] = {
4093 {NULL
, no_argument
, NULL
, 0}
4095 size_t md_longopts_size
= sizeof(md_longopts
);
4098 md_parse_option (c
, arg
)
4106 md_show_usage (stream
)
4111 /* We have no need to default values of symbols. */
4114 md_undefined_symbol (name
)
4120 /* Apply a fixup to an instruction. */
4123 md_apply_fix (fixP
, valp
)
4127 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
4128 struct hppa_fix_struct
*hppa_fixP
;
4129 long new_val
, result
= 0;
4130 unsigned int w1
, w2
, w
, resulti
;
4132 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
4133 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
4134 never be "applied" (they are just markers). Likewise for
4135 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
4137 if (fixP
->fx_r_type
== R_HPPA_ENTRY
4138 || fixP
->fx_r_type
== R_HPPA_EXIT
4139 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
4140 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
4141 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
4144 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
4145 fixups are considered not adjustable, which in turn causes
4146 adjust_reloc_syms to not set fx_offset. Ugh. */
4147 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
4149 fixP
->fx_offset
= *valp
;
4154 /* There should have been an HPPA specific fixup associated
4155 with the GAS fixup. */
4158 unsigned long buf_wd
= bfd_get_32 (stdoutput
, buf
);
4159 unsigned char fmt
= bfd_hppa_insn2fmt (buf_wd
);
4161 /* If there is a symbol associated with this fixup, then it's something
4162 which will need a SOM relocation (except for some PC-relative relocs).
4163 In such cases we should treat the "val" or "addend" as zero since it
4164 will be added in as needed from fx_offset in tc_gen_reloc. */
4165 if ((fixP
->fx_addsy
!= NULL
4166 || fixP
->fx_r_type
== R_HPPA_NONE
)
4171 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4173 /* These field selectors imply that we do not want an addend. */
4174 else if (hppa_fixP
->fx_r_field
== e_psel
4175 || hppa_fixP
->fx_r_field
== e_rpsel
4176 || hppa_fixP
->fx_r_field
== e_lpsel
4177 || hppa_fixP
->fx_r_field
== e_tsel
4178 || hppa_fixP
->fx_r_field
== e_rtsel
4179 || hppa_fixP
->fx_r_field
== e_ltsel
)
4180 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
4181 /* This is truely disgusting. The machine independent code blindly
4182 adds in the value of the symbol being relocated against. Damn! */
4184 && fixP
->fx_addsy
!= NULL
4185 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
4186 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
4187 0, hppa_fixP
->fx_r_field
);
4190 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4192 /* Handle pc-relative exceptions from above. */
4193 #define arg_reloc_stub_needed(CALLER, CALLEE) \
4194 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
4195 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
4199 && !arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
4200 symbol_get_bfdsym (fixP
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
4201 hppa_fixP
->fx_arg_reloc
)
4203 && (((int)(*valp
) > -262144 && (int)(*valp
) < 262143) && fmt
!= 22)
4204 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
4206 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
4208 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
4209 #undef arg_reloc_stub_needed
4213 /* Handle all opcodes with the 'j' operand type. */
4215 CHECK_FIELD (new_val
, 8191, -8192, 0);
4217 /* Mask off 14 bits to be changed. */
4218 bfd_put_32 (stdoutput
,
4219 bfd_get_32 (stdoutput
, buf
) & 0xffffc000,
4221 low_sign_unext (new_val
, 14, &resulti
);
4225 /* Handle all opcodes with the 'k' operand type. */
4227 CHECK_FIELD (new_val
, 2097152, 0, 0);
4229 /* Mask off 21 bits to be changed. */
4230 bfd_put_32 (stdoutput
,
4231 bfd_get_32 (stdoutput
, buf
) & 0xffe00000,
4233 dis_assemble_21 (new_val
, &resulti
);
4237 /* Handle all the opcodes with the 'i' operand type. */
4239 CHECK_FIELD (new_val
, 1023, -1023, 0);
4241 /* Mask off 11 bits to be changed. */
4242 bfd_put_32 (stdoutput
,
4243 bfd_get_32 (stdoutput
, buf
) & 0xffff800,
4245 low_sign_unext (new_val
, 11, &resulti
);
4249 /* Handle all the opcodes with the 'w' operand type. */
4251 CHECK_FIELD (new_val
, 8199, -8184, 0);
4253 /* Mask off 11 bits to be changed. */
4254 sign_unext ((new_val
- 8) >> 2, 12, &resulti
);
4255 bfd_put_32 (stdoutput
,
4256 bfd_get_32 (stdoutput
, buf
) & 0xffffe002,
4259 dis_assemble_12 (resulti
, &w1
, &w
);
4260 result
= ((w1
<< 2) | w
);
4263 /* Handle some of the opcodes with the 'W' operand type. */
4266 int distance
= *valp
;
4268 CHECK_FIELD (new_val
, 262143, -262144, 0);
4270 /* If this is an absolute branch (ie no link) with an out of
4271 range target, then we want to complain. */
4272 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
4273 && (distance
> 262143 || distance
< -262144)
4274 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
4275 CHECK_FIELD (distance
, 262143, -262144, 0);
4277 /* Mask off 17 bits to be changed. */
4278 bfd_put_32 (stdoutput
,
4279 bfd_get_32 (stdoutput
, buf
) & 0xffe0e002,
4281 sign_unext ((new_val
- 8) >> 2, 17, &resulti
);
4282 dis_assemble_17 (resulti
, &w1
, &w2
, &w
);
4283 result
= ((w2
<< 2) | (w1
<< 16) | w
);
4289 int distance
= *valp
, w3
;
4291 CHECK_FIELD (new_val
, 8388607, -8388608, 0);
4293 /* If this is an absolute branch (ie no link) with an out of
4294 range target, then we want to complain. */
4295 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
4296 && (distance
> 8388607 || distance
< -8388608)
4297 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
4298 CHECK_FIELD (distance
, 8388607, -8388608, 0);
4300 /* Mask off 22 bits to be changed. */
4301 bfd_put_32 (stdoutput
,
4302 bfd_get_32 (stdoutput
, buf
) & 0xfc00e002,
4304 sign_unext ((new_val
- 8) >> 2, 22, &resulti
);
4305 dis_assemble_22 (resulti
, &w3
, &w1
, &w2
, &w
);
4306 result
= ((w3
<< 21) | (w2
<< 2) | (w1
<< 16) | w
);
4312 bfd_put_32 (stdoutput
, new_val
, buf
);
4316 as_bad (_("Unknown relocation encountered in md_apply_fix."));
4320 /* Insert the relocation. */
4321 bfd_put_32 (stdoutput
, bfd_get_32 (stdoutput
, buf
) | result
, buf
);
4326 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
4327 (unsigned int) fixP
, fixP
->fx_r_type
);
4332 /* Exactly what point is a PC-relative offset relative TO?
4333 On the PA, they're relative to the address of the offset. */
4336 md_pcrel_from (fixP
)
4339 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
4342 /* Return nonzero if the input line pointer is at the end of
4346 is_end_of_statement ()
4348 return ((*input_line_pointer
== '\n')
4349 || (*input_line_pointer
== ';')
4350 || (*input_line_pointer
== '!'));
4353 /* Read a number from S. The number might come in one of many forms,
4354 the most common will be a hex or decimal constant, but it could be
4355 a pre-defined register (Yuk!), or an absolute symbol.
4357 Return a number or -1 for failure.
4359 When parsing PA-89 FP register numbers RESULT will be
4360 the address of a structure to return information about
4361 L/R half of FP registers, store results there as appropriate.
4363 pa_parse_number can not handle negative constants and will fail
4364 horribly if it is passed such a constant. */
4367 pa_parse_number (s
, result
)
4369 struct pa_11_fp_reg_struct
*result
;
4378 /* Skip whitespace before the number. */
4379 while (*p
== ' ' || *p
== '\t')
4382 /* Store info in RESULT if requested by caller. */
4385 result
->number_part
= -1;
4386 result
->l_r_select
= -1;
4392 /* Looks like a number. */
4395 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
4397 /* The number is specified in hex. */
4399 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
4400 || ((*p
>= 'A') && (*p
<= 'F')))
4403 num
= num
* 16 + *p
- '0';
4404 else if (*p
>= 'a' && *p
<= 'f')
4405 num
= num
* 16 + *p
- 'a' + 10;
4407 num
= num
* 16 + *p
- 'A' + 10;
4413 /* The number is specified in decimal. */
4414 while (isdigit (*p
))
4416 num
= num
* 10 + *p
- '0';
4421 /* Store info in RESULT if requested by the caller. */
4424 result
->number_part
= num
;
4426 if (IS_R_SELECT (p
))
4428 result
->l_r_select
= 1;
4431 else if (IS_L_SELECT (p
))
4433 result
->l_r_select
= 0;
4437 result
->l_r_select
= 0;
4442 /* The number might be a predefined register. */
4447 /* Tege hack: Special case for general registers as the general
4448 code makes a binary search with case translation, and is VERY
4453 if (*p
== 'e' && *(p
+ 1) == 't'
4454 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
4457 num
= *p
- '0' + 28;
4465 else if (!isdigit (*p
))
4468 as_bad (_("Undefined register: '%s'."), name
);
4474 num
= num
* 10 + *p
++ - '0';
4475 while (isdigit (*p
));
4480 /* Do a normal register search. */
4481 while (is_part_of_name (c
))
4487 status
= reg_name_search (name
);
4493 as_bad (_("Undefined register: '%s'."), name
);
4499 /* Store info in RESULT if requested by caller. */
4502 result
->number_part
= num
;
4503 if (IS_R_SELECT (p
- 1))
4504 result
->l_r_select
= 1;
4505 else if (IS_L_SELECT (p
- 1))
4506 result
->l_r_select
= 0;
4508 result
->l_r_select
= 0;
4513 /* And finally, it could be a symbol in the absolute section which
4514 is effectively a constant. */
4518 while (is_part_of_name (c
))
4524 if ((sym
= symbol_find (name
)) != NULL
)
4526 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
4527 num
= S_GET_VALUE (sym
);
4531 as_bad (_("Non-absolute symbol: '%s'."), name
);
4537 /* There is where we'd come for an undefined symbol
4538 or for an empty string. For an empty string we
4539 will return zero. That's a concession made for
4540 compatability with the braindamaged HP assemblers. */
4546 as_bad (_("Undefined absolute constant: '%s'."), name
);
4552 /* Store info in RESULT if requested by caller. */
4555 result
->number_part
= num
;
4556 if (IS_R_SELECT (p
- 1))
4557 result
->l_r_select
= 1;
4558 else if (IS_L_SELECT (p
- 1))
4559 result
->l_r_select
= 0;
4561 result
->l_r_select
= 0;
4569 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
4571 /* Given NAME, find the register number associated with that name, return
4572 the integer value associated with the given name or -1 on failure. */
4575 reg_name_search (name
)
4578 int middle
, low
, high
;
4582 high
= REG_NAME_CNT
- 1;
4586 middle
= (low
+ high
) / 2;
4587 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
4593 return pre_defined_registers
[middle
].value
;
4595 while (low
<= high
);
4601 /* Return nonzero if the given INSN and L/R information will require
4602 a new PA-1.1 opcode. */
4605 need_pa11_opcode (insn
, result
)
4607 struct pa_11_fp_reg_struct
*result
;
4609 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
4611 /* If this instruction is specific to a particular architecture,
4612 then set a new architecture. */
4613 if (bfd_get_mach (stdoutput
) < pa11
)
4615 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
4616 as_warn (_("could not update architecture and machine"));
4624 /* Parse a condition for a fcmp instruction. Return the numerical
4625 code associated with the condition. */
4628 pa_parse_fp_cmp_cond (s
)
4635 for (i
= 0; i
< 32; i
++)
4637 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
4638 strlen (fp_cond_map
[i
].string
)) == 0)
4640 cond
= fp_cond_map
[i
].cond
;
4641 *s
+= strlen (fp_cond_map
[i
].string
);
4642 /* If not a complete match, back up the input string and
4644 if (**s
!= ' ' && **s
!= '\t')
4646 *s
-= strlen (fp_cond_map
[i
].string
);
4649 while (**s
== ' ' || **s
== '\t')
4655 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
4657 /* Advance over the bogus completer. */
4658 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4664 /* Parse a graphics test complete for ftest. */
4667 pa_parse_ftest_gfx_completer (s
)
4673 if (strncasecmp (*s
, "acc8", 4) == 0)
4678 else if (strncasecmp (*s
, "acc6", 4) == 0)
4683 else if (strncasecmp (*s
, "acc4", 4) == 0)
4688 else if (strncasecmp (*s
, "acc2", 4) == 0)
4693 else if (strncasecmp (*s
, "acc", 3) == 0)
4698 else if (strncasecmp (*s
, "rej8", 4) == 0)
4703 else if (strncasecmp (*s
, "rej", 3) == 0)
4711 as_bad (_("Invalid FTEST completer: %s"), *s
);
4717 /* Parse an FP operand format completer returning the completer
4720 static fp_operand_format
4721 pa_parse_fp_cnv_format (s
)
4730 if (strncasecmp (*s
, "sgl", 3) == 0)
4735 else if (strncasecmp (*s
, "dbl", 3) == 0)
4740 else if (strncasecmp (*s
, "quad", 4) == 0)
4745 else if (strncasecmp (*s
, "w", 1) == 0)
4750 else if (strncasecmp (*s
, "uw", 2) == 0)
4755 else if (strncasecmp (*s
, "dw", 2) == 0)
4760 else if (strncasecmp (*s
, "udw", 3) == 0)
4765 else if (strncasecmp (*s
, "qw", 2) == 0)
4770 else if (strncasecmp (*s
, "uqw", 3) == 0)
4777 format
= ILLEGAL_FMT
;
4778 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
4785 /* Parse an FP operand format completer returning the completer
4788 static fp_operand_format
4789 pa_parse_fp_format (s
)
4798 if (strncasecmp (*s
, "sgl", 3) == 0)
4803 else if (strncasecmp (*s
, "dbl", 3) == 0)
4808 else if (strncasecmp (*s
, "quad", 4) == 0)
4815 format
= ILLEGAL_FMT
;
4816 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
4823 /* Convert from a selector string into a selector type. */
4826 pa_chk_field_selector (str
)
4829 int middle
, low
, high
;
4833 /* Read past any whitespace. */
4834 /* FIXME: should we read past newlines and formfeeds??? */
4835 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
4838 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
4839 name
[0] = tolower ((*str
)[0]),
4841 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
4842 name
[0] = tolower ((*str
)[0]),
4843 name
[1] = tolower ((*str
)[1]),
4845 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
4846 name
[0] = tolower ((*str
)[0]),
4847 name
[1] = tolower ((*str
)[1]),
4848 name
[2] = tolower ((*str
)[2]),
4854 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
4858 middle
= (low
+ high
) / 2;
4859 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
4866 *str
+= strlen (name
) + 1;
4868 if (selector_table
[middle
].field_selector
== e_nsel
)
4871 return selector_table
[middle
].field_selector
;
4874 while (low
<= high
);
4879 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
4882 get_expression (str
)
4888 save_in
= input_line_pointer
;
4889 input_line_pointer
= str
;
4890 seg
= expression (&the_insn
.exp
);
4891 if (!(seg
== absolute_section
4892 || seg
== undefined_section
4893 || SEG_NORMAL (seg
)))
4895 as_warn (_("Bad segment in expression."));
4896 expr_end
= input_line_pointer
;
4897 input_line_pointer
= save_in
;
4900 expr_end
= input_line_pointer
;
4901 input_line_pointer
= save_in
;
4905 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
4907 pa_get_absolute_expression (insn
, strp
)
4913 insn
->field_selector
= pa_chk_field_selector (strp
);
4914 save_in
= input_line_pointer
;
4915 input_line_pointer
= *strp
;
4916 expression (&insn
->exp
);
4917 /* This is not perfect, but is a huge improvement over doing nothing.
4919 The PA assembly syntax is ambigious in a variety of ways. Consider
4920 this string "4 %r5" Is that the number 4 followed by the register
4921 r5, or is that 4 MOD 5?
4923 If we get a modulo expresion When looking for an absolute, we try
4924 again cutting off the input string at the first whitespace character. */
4925 if (insn
->exp
.X_op
== O_modulus
)
4930 input_line_pointer
= *strp
;
4932 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
4938 retval
= pa_get_absolute_expression (insn
, strp
);
4940 input_line_pointer
= save_in
;
4942 return evaluate_absolute (insn
);
4944 /* When in strict mode we have a non-match, fix up the pointers
4945 and return to our caller. */
4946 if (insn
->exp
.X_op
!= O_constant
&& strict
)
4948 expr_end
= input_line_pointer
;
4949 input_line_pointer
= save_in
;
4952 if (insn
->exp
.X_op
!= O_constant
)
4954 as_bad (_("Bad segment (should be absolute)."));
4955 expr_end
= input_line_pointer
;
4956 input_line_pointer
= save_in
;
4959 expr_end
= input_line_pointer
;
4960 input_line_pointer
= save_in
;
4961 return evaluate_absolute (insn
);
4964 /* Evaluate an absolute expression EXP which may be modified by
4965 the selector FIELD_SELECTOR. Return the value of the expression. */
4967 evaluate_absolute (insn
)
4972 int field_selector
= insn
->field_selector
;
4975 value
= exp
.X_add_number
;
4977 switch (field_selector
)
4983 /* If bit 21 is on then add 0x800 and arithmetic shift right 11 bits. */
4985 if (value
& 0x00000400)
4987 value
= (value
& 0xfffff800) >> 11;
4990 /* Sign extend from bit 21. */
4992 if (value
& 0x00000400)
4993 value
|= 0xfffff800;
4998 /* Arithmetic shift right 11 bits. */
5000 value
= (value
& 0xfffff800) >> 11;
5003 /* Set bits 0-20 to zero. */
5005 value
= value
& 0x7ff;
5008 /* Add 0x800 and arithmetic shift right 11 bits. */
5011 value
= (value
& 0xfffff800) >> 11;
5014 /* Set bitgs 0-21 to one. */
5016 value
|= 0xfffff800;
5019 #define RSEL_ROUND(c) (((c) + 0x1000) & ~0x1fff)
5021 value
= (RSEL_ROUND (value
) & 0x7ff) + (value
- RSEL_ROUND (value
));
5025 value
= (RSEL_ROUND (value
) >> 11) & 0x1fffff;
5030 BAD_CASE (field_selector
);
5036 /* Given an argument location specification return the associated
5037 argument location number. */
5040 pa_build_arg_reloc (type_name
)
5044 if (strncasecmp (type_name
, "no", 2) == 0)
5046 if (strncasecmp (type_name
, "gr", 2) == 0)
5048 else if (strncasecmp (type_name
, "fr", 2) == 0)
5050 else if (strncasecmp (type_name
, "fu", 2) == 0)
5053 as_bad (_("Invalid argument location: %s\n"), type_name
);
5058 /* Encode and return an argument relocation specification for
5059 the given register in the location specified by arg_reloc. */
5062 pa_align_arg_reloc (reg
, arg_reloc
)
5064 unsigned int arg_reloc
;
5066 unsigned int new_reloc
;
5068 new_reloc
= arg_reloc
;
5084 as_bad (_("Invalid argument description: %d"), reg
);
5090 /* Parse a PA nullification completer (,n). Return nonzero if the
5091 completer was found; return zero if no completer was found. */
5103 if (strncasecmp (*s
, "n", 1) == 0)
5107 as_bad (_("Invalid Nullification: (%c)"), **s
);
5116 /* Parse a non-negated compare/subtract completer returning the
5117 number (for encoding in instrutions) of the given completer.
5119 ISBRANCH specifies whether or not this is parsing a condition
5120 completer for a branch (vs a nullification completer for a
5121 computational instruction. */
5124 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
5129 char *name
= *s
+ 1;
5138 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5144 if (strcmp (name
, "=") == 0)
5148 else if (strcmp (name
, "<") == 0)
5152 else if (strcmp (name
, "<=") == 0)
5156 else if (strcmp (name
, "<<") == 0)
5160 else if (strcmp (name
, "<<=") == 0)
5164 else if (strcasecmp (name
, "sv") == 0)
5168 else if (strcasecmp (name
, "od") == 0)
5172 /* If we have something like addb,n then there is no condition
5174 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5186 /* Reset pointers if this was really a ,n for a branch instruction. */
5194 /* Parse a negated compare/subtract completer returning the
5195 number (for encoding in instrutions) of the given completer.
5197 ISBRANCH specifies whether or not this is parsing a condition
5198 completer for a branch (vs a nullification completer for a
5199 computational instruction. */
5202 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
5207 char *name
= *s
+ 1;
5216 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5222 if (strcasecmp (name
, "tr") == 0)
5226 else if (strcmp (name
, "<>") == 0)
5230 else if (strcmp (name
, ">=") == 0)
5234 else if (strcmp (name
, ">") == 0)
5238 else if (strcmp (name
, ">>=") == 0)
5242 else if (strcmp (name
, ">>") == 0)
5246 else if (strcasecmp (name
, "nsv") == 0)
5250 else if (strcasecmp (name
, "ev") == 0)
5254 /* If we have something like addb,n then there is no condition
5256 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5268 /* Reset pointers if this was really a ,n for a branch instruction. */
5277 /* Parse a non-negated addition completer returning the number
5278 (for encoding in instrutions) of the given completer.
5280 ISBRANCH specifies whether or not this is parsing a condition
5281 completer for a branch (vs a nullification completer for a
5282 computational instruction. */
5285 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
5290 char *name
= *s
+ 1;
5298 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5302 if (strcmp (name
, "=") == 0)
5306 else if (strcmp (name
, "<") == 0)
5310 else if (strcmp (name
, "<=") == 0)
5314 else if (strcasecmp (name
, "nuv") == 0)
5318 else if (strcasecmp (name
, "znv") == 0)
5322 else if (strcasecmp (name
, "sv") == 0)
5326 else if (strcasecmp (name
, "od") == 0)
5330 /* If we have something like addb,n then there is no condition
5332 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5343 /* Reset pointers if this was really a ,n for a branch instruction. */
5344 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5350 /* Parse a negated addition completer returning the number
5351 (for encoding in instrutions) of the given completer.
5353 ISBRANCH specifies whether or not this is parsing a condition
5354 completer for a branch (vs a nullification completer for a
5355 computational instruction). */
5358 pa_parse_neg_add_cmpltr (s
, isbranch
)
5363 char *name
= *s
+ 1;
5371 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
5375 if (strcasecmp (name
, "tr") == 0)
5379 else if (strcmp (name
, "<>") == 0)
5383 else if (strcmp (name
, ">=") == 0)
5387 else if (strcmp (name
, ">") == 0)
5391 else if (strcasecmp (name
, "uv") == 0)
5395 else if (strcasecmp (name
, "vnz") == 0)
5399 else if (strcasecmp (name
, "nsv") == 0)
5403 else if (strcasecmp (name
, "ev") == 0)
5407 /* If we have something like addb,n then there is no condition
5409 else if (strcasecmp (name
, "n") == 0 && isbranch
)
5420 /* Reset pointers if this was really a ,n for a branch instruction. */
5421 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
5428 /* Handle an alignment directive. Special so that we can update the
5429 alignment of the subspace if necessary. */
5433 /* We must have a valid space and subspace. */
5434 pa_check_current_space_and_subspace ();
5436 /* Let the generic gas code do most of the work. */
5437 s_align_bytes (bytes
);
5439 /* If bytes is a power of 2, then update the current subspace's
5440 alignment if necessary. */
5441 if (log2 (bytes
) != -1)
5442 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
5446 /* Handle a .BLOCK type pseudo-op. */
5454 unsigned int temp_size
;
5458 /* We must have a valid space and subspace. */
5459 pa_check_current_space_and_subspace ();
5462 temp_size
= get_absolute_expression ();
5464 /* Always fill with zeros, that's what the HP assembler does. */
5467 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
5468 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
5469 memset (p
, 0, temp_size
);
5471 /* Convert 2 bytes at a time. */
5473 for (i
= 0; i
< temp_size
; i
+= 2)
5475 md_number_to_chars (p
+ i
,
5477 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
5480 pa_undefine_label ();
5481 demand_empty_rest_of_line ();
5484 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
5492 /* The BRTAB relocations are only availble in SOM (to denote
5493 the beginning and end of branch tables). */
5494 char *where
= frag_more (0);
5496 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5497 NULL
, (offsetT
) 0, NULL
,
5498 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
5499 e_fsel
, 0, 0, NULL
);
5502 demand_empty_rest_of_line ();
5505 /* Handle a .begin_try and .end_try pseudo-op. */
5513 char *where
= frag_more (0);
5518 /* The TRY relocations are only availble in SOM (to denote
5519 the beginning and end of exception handling regions). */
5521 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5522 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
5523 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
5524 e_fsel
, 0, 0, NULL
);
5527 demand_empty_rest_of_line ();
5530 /* Handle a .CALL pseudo-op. This involves storing away information
5531 about where arguments are to be found so the linker can detect
5532 (and correct) argument location mismatches between caller and callee. */
5539 /* We must have a valid space and subspace. */
5540 pa_check_current_space_and_subspace ();
5543 pa_call_args (&last_call_desc
);
5544 demand_empty_rest_of_line ();
5547 /* Do the dirty work of building a call descriptor which describes
5548 where the caller placed arguments to a function call. */
5551 pa_call_args (call_desc
)
5552 struct call_desc
*call_desc
;
5555 unsigned int temp
, arg_reloc
;
5557 while (!is_end_of_statement ())
5559 name
= input_line_pointer
;
5560 c
= get_symbol_end ();
5561 /* Process a source argument. */
5562 if ((strncasecmp (name
, "argw", 4) == 0))
5564 temp
= atoi (name
+ 4);
5565 p
= input_line_pointer
;
5567 input_line_pointer
++;
5568 name
= input_line_pointer
;
5569 c
= get_symbol_end ();
5570 arg_reloc
= pa_build_arg_reloc (name
);
5571 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
5573 /* Process a return value. */
5574 else if ((strncasecmp (name
, "rtnval", 6) == 0))
5576 p
= input_line_pointer
;
5578 input_line_pointer
++;
5579 name
= input_line_pointer
;
5580 c
= get_symbol_end ();
5581 arg_reloc
= pa_build_arg_reloc (name
);
5582 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
5586 as_bad (_("Invalid .CALL argument: %s"), name
);
5588 p
= input_line_pointer
;
5590 if (!is_end_of_statement ())
5591 input_line_pointer
++;
5595 /* Return TRUE if FRAG1 and FRAG2 are the same. */
5598 is_same_frag (frag1
, frag2
)
5605 else if (frag2
== NULL
)
5607 else if (frag1
== frag2
)
5609 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
5610 return (is_same_frag (frag1
, frag2
->fr_next
));
5616 /* Build an entry in the UNWIND subspace from the given function
5617 attributes in CALL_INFO. This is not needed for SOM as using
5618 R_ENTRY and R_EXIT relocations allow the linker to handle building
5619 of the unwind spaces. */
5622 pa_build_unwind_subspace (call_info
)
5623 struct call_info
*call_info
;
5626 asection
*seg
, *save_seg
;
5628 subsegT subseg
, save_subseg
;
5632 if (now_seg
!= text_section
)
5635 if (bfd_get_arch_info (stdoutput
)->bits_per_address
== 32)
5636 reloc
= R_PARISC_DIR32
;
5638 reloc
= R_PARISC_SEGREL32
;
5640 /* Get into the right seg/subseg. This may involve creating
5641 the seg the first time through. Make sure to have the
5642 old seg/subseg so that we can reset things when we are done. */
5643 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
5644 if (seg
== ASEC_NULL
)
5646 seg
= bfd_make_section_old_way (stdoutput
, UNWIND_SECTION_NAME
);
5647 bfd_set_section_flags (stdoutput
, seg
,
5648 SEC_READONLY
| SEC_HAS_CONTENTS
5649 | SEC_LOAD
| SEC_RELOC
| SEC_ALLOC
| SEC_DATA
);
5650 bfd_set_section_alignment (stdoutput
, seg
, 2);
5654 save_subseg
= now_subseg
;
5655 subseg_set (seg
, 0);
5658 /* Get some space to hold relocation information for the unwind
5661 md_number_to_chars (p
, 0, 4);
5663 /* Relocation info. for start offset of the function. */
5664 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
5665 call_info
->start_symbol
, (offsetT
) 0,
5666 (expressionS
*) NULL
, 0, reloc
,
5667 e_fsel
, 32, 0, NULL
);
5670 md_number_to_chars (p
, 0, 4);
5672 /* Relocation info. for end offset of the function.
5674 Because we allow reductions of 32bit relocations for ELF, this will be
5675 reduced to section_sym + offset which avoids putting the temporary
5676 symbol into the symbol table. It (should) end up giving the same
5677 value as call_info->start_symbol + function size once the linker is
5678 finished with its work. */
5680 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
5681 call_info
->end_symbol
, (offsetT
) 0,
5682 (expressionS
*) NULL
, 0, reloc
,
5683 e_fsel
, 32, 0, NULL
);
5686 unwind
= (char *) &call_info
->ci_unwind
;
5687 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
5691 FRAG_APPEND_1_CHAR (c
);
5695 /* Return back to the original segment/subsegment. */
5696 subseg_set (save_seg
, save_subseg
);
5700 /* Process a .CALLINFO pseudo-op. This information is used later
5701 to build unwind descriptors and maybe one day to support
5702 .ENTER and .LEAVE. */
5705 pa_callinfo (unused
)
5712 /* We must have a valid space and subspace. */
5713 pa_check_current_space_and_subspace ();
5716 /* .CALLINFO must appear within a procedure definition. */
5717 if (!within_procedure
)
5718 as_bad (_(".callinfo is not within a procedure definition"));
5720 /* Mark the fact that we found the .CALLINFO for the
5721 current procedure. */
5722 callinfo_found
= TRUE
;
5724 /* Iterate over the .CALLINFO arguments. */
5725 while (!is_end_of_statement ())
5727 name
= input_line_pointer
;
5728 c
= get_symbol_end ();
5729 /* Frame size specification. */
5730 if ((strncasecmp (name
, "frame", 5) == 0))
5732 p
= input_line_pointer
;
5734 input_line_pointer
++;
5735 temp
= get_absolute_expression ();
5736 if ((temp
& 0x3) != 0)
5738 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
5742 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
5743 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
5746 /* Entry register (GR, GR and SR) specifications. */
5747 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
5749 p
= input_line_pointer
;
5751 input_line_pointer
++;
5752 temp
= get_absolute_expression ();
5753 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
5754 even though %r19 is caller saved. I think this is a bug in
5755 the HP assembler, and we are not going to emulate it. */
5756 if (temp
< 3 || temp
> 18)
5757 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
5758 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
5760 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
5762 p
= input_line_pointer
;
5764 input_line_pointer
++;
5765 temp
= get_absolute_expression ();
5766 /* Similarly the HP assembler takes 31 as the high bound even
5767 though %fr21 is the last callee saved floating point register. */
5768 if (temp
< 12 || temp
> 21)
5769 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
5770 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
5772 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
5774 p
= input_line_pointer
;
5776 input_line_pointer
++;
5777 temp
= get_absolute_expression ();
5779 as_bad (_("Value for ENTRY_SR must be 3\n"));
5781 /* Note whether or not this function performs any calls. */
5782 else if ((strncasecmp (name
, "calls", 5) == 0) ||
5783 (strncasecmp (name
, "caller", 6) == 0))
5785 p
= input_line_pointer
;
5788 else if ((strncasecmp (name
, "no_calls", 8) == 0))
5790 p
= input_line_pointer
;
5793 /* Should RP be saved into the stack. */
5794 else if ((strncasecmp (name
, "save_rp", 7) == 0))
5796 p
= input_line_pointer
;
5798 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
5800 /* Likewise for SP. */
5801 else if ((strncasecmp (name
, "save_sp", 7) == 0))
5803 p
= input_line_pointer
;
5805 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
5807 /* Is this an unwindable procedure. If so mark it so
5808 in the unwind descriptor. */
5809 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
5811 p
= input_line_pointer
;
5813 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
5815 /* Is this an interrupt routine. If so mark it in the
5816 unwind descriptor. */
5817 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
5819 p
= input_line_pointer
;
5821 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
5823 /* Is this a millicode routine. "millicode" isn't in my
5824 assembler manual, but my copy is old. The HP assembler
5825 accepts it, and there's a place in the unwind descriptor
5826 to drop the information, so we'll accept it too. */
5827 else if ((strncasecmp (name
, "millicode", 9) == 0))
5829 p
= input_line_pointer
;
5831 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
5835 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
5836 *input_line_pointer
= c
;
5838 if (!is_end_of_statement ())
5839 input_line_pointer
++;
5842 demand_empty_rest_of_line ();
5845 /* Switch into the code subspace. */
5852 current_space
= is_defined_space ("$TEXT$");
5854 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
5857 pa_undefine_label ();
5860 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
5861 the .comm pseudo-op has the following symtax:
5863 <label> .comm <length>
5865 where <label> is optional and is a symbol whose address will be the start of
5866 a block of memory <length> bytes long. <length> must be an absolute
5867 expression. <length> bytes will be allocated in the current space
5870 Also note the label may not even be on the same line as the .comm.
5872 This difference in syntax means the colon function will be called
5873 on the symbol before we arrive in pa_comm. colon will set a number
5874 of attributes of the symbol that need to be fixed here. In particular
5875 the value, section pointer, fragment pointer, flags, etc. What
5878 This also makes error detection all but impossible. */
5886 label_symbol_struct
*label_symbol
= pa_get_label ();
5889 symbol
= label_symbol
->lss_label
;
5894 size
= get_absolute_expression ();
5898 S_SET_VALUE (symbol
, size
);
5899 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
5900 S_SET_EXTERNAL (symbol
);
5902 /* colon() has already set the frag to the current location in the
5903 current subspace; we need to reset the fragment to the zero address
5904 fragment. We also need to reset the segment pointer. */
5905 symbol_set_frag (symbol
, &zero_address_frag
);
5907 demand_empty_rest_of_line ();
5910 /* Process a .END pseudo-op. */
5916 demand_empty_rest_of_line ();
5919 /* Process a .ENTER pseudo-op. This is not supported. */
5925 /* We must have a valid space and subspace. */
5926 pa_check_current_space_and_subspace ();
5929 as_bad (_("The .ENTER pseudo-op is not supported"));
5930 demand_empty_rest_of_line ();
5933 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
5940 /* We must have a valid space and subspace. */
5941 pa_check_current_space_and_subspace ();
5944 if (!within_procedure
)
5945 as_bad (_("Misplaced .entry. Ignored."));
5948 if (!callinfo_found
)
5949 as_bad (_("Missing .callinfo."));
5951 demand_empty_rest_of_line ();
5952 within_entry_exit
= TRUE
;
5955 /* SOM defers building of unwind descriptors until the link phase.
5956 The assembler is responsible for creating an R_ENTRY relocation
5957 to mark the beginning of a region and hold the unwind bits, and
5958 for creating an R_EXIT relocation to mark the end of the region.
5960 FIXME. ELF should be using the same conventions! The problem
5961 is an unwind requires too much relocation space. Hmmm. Maybe
5962 if we split the unwind bits up between the relocations which
5963 denote the entry and exit points. */
5964 if (last_call_info
->start_symbol
!= NULL
)
5966 char *where
= frag_more (0);
5968 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5969 NULL
, (offsetT
) 0, NULL
,
5970 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
5971 (int *) &last_call_info
->ci_unwind
.descriptor
);
5976 /* Handle a .EQU pseudo-op. */
5982 label_symbol_struct
*label_symbol
= pa_get_label ();
5987 symbol
= label_symbol
->lss_label
;
5989 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
5991 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
5992 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
5997 as_bad (_(".REG must use a label"));
5999 as_bad (_(".EQU must use a label"));
6002 pa_undefine_label ();
6003 demand_empty_rest_of_line ();
6006 /* Helper function. Does processing for the end of a function. This
6007 usually involves creating some relocations or building special
6008 symbols to mark the end of the function. */
6015 where
= frag_more (0);
6018 /* Mark the end of the function, stuff away the location of the frag
6019 for the end of the function, and finally call pa_build_unwind_subspace
6020 to add an entry in the unwind table. */
6021 hppa_elf_mark_end_of_function ();
6022 pa_build_unwind_subspace (last_call_info
);
6024 /* SOM defers building of unwind descriptors until the link phase.
6025 The assembler is responsible for creating an R_ENTRY relocation
6026 to mark the beginning of a region and hold the unwind bits, and
6027 for creating an R_EXIT relocation to mark the end of the region.
6029 FIXME. ELF should be using the same conventions! The problem
6030 is an unwind requires too much relocation space. Hmmm. Maybe
6031 if we split the unwind bits up between the relocations which
6032 denote the entry and exit points. */
6033 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6035 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
6036 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
6040 /* Process a .EXIT pseudo-op. */
6047 /* We must have a valid space and subspace. */
6048 pa_check_current_space_and_subspace ();
6051 if (!within_procedure
)
6052 as_bad (_(".EXIT must appear within a procedure"));
6055 if (!callinfo_found
)
6056 as_bad (_("Missing .callinfo"));
6059 if (!within_entry_exit
)
6060 as_bad (_("No .ENTRY for this .EXIT"));
6063 within_entry_exit
= FALSE
;
6068 demand_empty_rest_of_line ();
6071 /* Process a .EXPORT directive. This makes functions external
6072 and provides information such as argument relocation entries
6082 name
= input_line_pointer
;
6083 c
= get_symbol_end ();
6084 /* Make sure the given symbol exists. */
6085 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6087 as_bad (_("Cannot define export symbol: %s\n"), name
);
6088 p
= input_line_pointer
;
6090 input_line_pointer
++;
6094 /* OK. Set the external bits and process argument relocations. */
6095 S_SET_EXTERNAL (symbol
);
6096 p
= input_line_pointer
;
6098 if (!is_end_of_statement ())
6100 input_line_pointer
++;
6101 pa_type_args (symbol
, 1);
6105 demand_empty_rest_of_line ();
6108 /* Helper function to process arguments to a .EXPORT pseudo-op. */
6111 pa_type_args (symbolP
, is_export
)
6116 unsigned int temp
, arg_reloc
;
6117 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
6118 obj_symbol_type
*symbol
= (obj_symbol_type
*) symbol_get_bfdsym (symbolP
);
6120 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
6123 input_line_pointer
+= 8;
6124 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6125 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
6126 type
= SYMBOL_TYPE_ABSOLUTE
;
6128 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
6130 input_line_pointer
+= 4;
6131 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
6132 instead one should be IMPORTing/EXPORTing ENTRY types.
6134 Complain if one tries to EXPORT a CODE type since that's never
6135 done. Both GCC and HP C still try to IMPORT CODE types, so
6136 silently fix them to be ENTRY types. */
6137 if (S_IS_FUNCTION (symbolP
))
6140 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
6141 S_GET_NAME (symbolP
));
6143 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6144 type
= SYMBOL_TYPE_ENTRY
;
6148 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6149 type
= SYMBOL_TYPE_CODE
;
6152 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
6154 input_line_pointer
+= 4;
6155 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6156 symbol_get_bfdsym (symbolP
)->flags
|= BSF_OBJECT
;
6157 type
= SYMBOL_TYPE_DATA
;
6159 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
6161 input_line_pointer
+= 5;
6162 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6163 type
= SYMBOL_TYPE_ENTRY
;
6165 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
6167 input_line_pointer
+= 9;
6168 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6169 type
= SYMBOL_TYPE_MILLICODE
;
6171 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
6173 input_line_pointer
+= 6;
6174 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
6175 type
= SYMBOL_TYPE_PLABEL
;
6177 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
6179 input_line_pointer
+= 8;
6180 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6181 type
= SYMBOL_TYPE_PRI_PROG
;
6183 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
6185 input_line_pointer
+= 8;
6186 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
6187 type
= SYMBOL_TYPE_SEC_PROG
;
6190 /* SOM requires much more information about symbol types
6191 than BFD understands. This is how we get this information
6192 to the SOM BFD backend. */
6193 #ifdef obj_set_symbol_type
6194 obj_set_symbol_type (symbol_get_bfdsym (symbolP
), (int) type
);
6197 /* Now that the type of the exported symbol has been handled,
6198 handle any argument relocation information. */
6199 while (!is_end_of_statement ())
6201 if (*input_line_pointer
== ',')
6202 input_line_pointer
++;
6203 name
= input_line_pointer
;
6204 c
= get_symbol_end ();
6205 /* Argument sources. */
6206 if ((strncasecmp (name
, "argw", 4) == 0))
6208 p
= input_line_pointer
;
6210 input_line_pointer
++;
6211 temp
= atoi (name
+ 4);
6212 name
= input_line_pointer
;
6213 c
= get_symbol_end ();
6214 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
6216 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
6218 *input_line_pointer
= c
;
6220 /* The return value. */
6221 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
6223 p
= input_line_pointer
;
6225 input_line_pointer
++;
6226 name
= input_line_pointer
;
6227 c
= get_symbol_end ();
6228 arg_reloc
= pa_build_arg_reloc (name
);
6230 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
6232 *input_line_pointer
= c
;
6234 /* Privelege level. */
6235 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
6237 p
= input_line_pointer
;
6239 input_line_pointer
++;
6240 temp
= atoi (input_line_pointer
);
6242 symbol
->tc_data
.ap
.hppa_priv_level
= temp
;
6244 c
= get_symbol_end ();
6245 *input_line_pointer
= c
;
6249 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
6250 p
= input_line_pointer
;
6253 if (!is_end_of_statement ())
6254 input_line_pointer
++;
6258 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
6259 assembly file must either be defined in the assembly file, or
6260 explicitly IMPORTED from another. */
6269 name
= input_line_pointer
;
6270 c
= get_symbol_end ();
6272 symbol
= symbol_find (name
);
6273 /* Ugh. We might be importing a symbol defined earlier in the file,
6274 in which case all the code below will really screw things up
6275 (set the wrong segment, symbol flags & type, etc). */
6276 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
6278 symbol
= symbol_find_or_make (name
);
6279 p
= input_line_pointer
;
6282 if (!is_end_of_statement ())
6284 input_line_pointer
++;
6285 pa_type_args (symbol
, 0);
6289 /* Sigh. To be compatable with the HP assembler and to help
6290 poorly written assembly code, we assign a type based on
6291 the the current segment. Note only BSF_FUNCTION really
6292 matters, we do not need to set the full SYMBOL_TYPE_* info. */
6293 if (now_seg
== text_section
)
6294 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
6296 /* If the section is undefined, then the symbol is undefined
6297 Since this is an import, leave the section undefined. */
6298 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
6303 /* The symbol was already defined. Just eat everything up to
6304 the end of the current statement. */
6305 while (!is_end_of_statement ())
6306 input_line_pointer
++;
6309 demand_empty_rest_of_line ();
6312 /* Handle a .LABEL pseudo-op. */
6320 name
= input_line_pointer
;
6321 c
= get_symbol_end ();
6323 if (strlen (name
) > 0)
6326 p
= input_line_pointer
;
6331 as_warn (_("Missing label name on .LABEL"));
6334 if (!is_end_of_statement ())
6336 as_warn (_("extra .LABEL arguments ignored."));
6337 ignore_rest_of_line ();
6339 demand_empty_rest_of_line ();
6342 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
6349 /* We must have a valid space and subspace. */
6350 pa_check_current_space_and_subspace ();
6353 as_bad (_("The .LEAVE pseudo-op is not supported"));
6354 demand_empty_rest_of_line ();
6357 /* Handle a .LEVEL pseudo-op. */
6365 level
= input_line_pointer
;
6366 if (strncmp (level
, "1.0", 3) == 0)
6368 input_line_pointer
+= 3;
6369 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
6370 as_warn (_("could not set architecture and machine"));
6372 else if (strncmp (level
, "1.1", 3) == 0)
6374 input_line_pointer
+= 3;
6375 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
6376 as_warn (_("could not set architecture and machine"));
6378 else if (strncmp (level
, "2.0w", 4) == 0)
6380 input_line_pointer
+= 4;
6381 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 25))
6382 as_warn (_("could not set architecture and machine"));
6384 else if (strncmp (level
, "2.0", 3) == 0)
6386 input_line_pointer
+= 3;
6387 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
6388 as_warn (_("could not set architecture and machine"));
6392 as_bad (_("Unrecognized .LEVEL argument\n"));
6393 ignore_rest_of_line ();
6395 demand_empty_rest_of_line ();
6398 /* Handle a .ORIGIN pseudo-op. */
6405 /* We must have a valid space and subspace. */
6406 pa_check_current_space_and_subspace ();
6410 pa_undefine_label ();
6413 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
6414 is for static functions. FIXME. Should share more code with .EXPORT. */
6423 name
= input_line_pointer
;
6424 c
= get_symbol_end ();
6426 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
6428 as_bad (_("Cannot define static symbol: %s\n"), name
);
6429 p
= input_line_pointer
;
6431 input_line_pointer
++;
6435 S_CLEAR_EXTERNAL (symbol
);
6436 p
= input_line_pointer
;
6438 if (!is_end_of_statement ())
6440 input_line_pointer
++;
6441 pa_type_args (symbol
, 0);
6445 demand_empty_rest_of_line ();
6448 /* Handle a .PROC pseudo-op. It is used to mark the beginning
6449 of a procedure from a syntatical point of view. */
6455 struct call_info
*call_info
;
6458 /* We must have a valid space and subspace. */
6459 pa_check_current_space_and_subspace ();
6462 if (within_procedure
)
6463 as_fatal (_("Nested procedures"));
6465 /* Reset global variables for new procedure. */
6466 callinfo_found
= FALSE
;
6467 within_procedure
= TRUE
;
6469 /* Create another call_info structure. */
6470 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
6473 as_fatal (_("Cannot allocate unwind descriptor\n"));
6475 memset (call_info
, 0, sizeof (struct call_info
));
6477 call_info
->ci_next
= NULL
;
6479 if (call_info_root
== NULL
)
6481 call_info_root
= call_info
;
6482 last_call_info
= call_info
;
6486 last_call_info
->ci_next
= call_info
;
6487 last_call_info
= call_info
;
6490 /* set up defaults on call_info structure */
6492 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
6493 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
6494 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
6496 /* If we got a .PROC pseudo-op, we know that the function is defined
6497 locally. Make sure it gets into the symbol table. */
6499 label_symbol_struct
*label_symbol
= pa_get_label ();
6503 if (label_symbol
->lss_label
)
6505 last_call_info
->start_symbol
= label_symbol
->lss_label
;
6506 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
6509 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
6512 last_call_info
->start_symbol
= NULL
;
6515 demand_empty_rest_of_line ();
6518 /* Process the syntatical end of a procedure. Make sure all the
6519 appropriate pseudo-ops were found within the procedure. */
6527 /* We must have a valid space and subspace. */
6528 pa_check_current_space_and_subspace ();
6531 /* If we are within a procedure definition, make sure we've
6532 defined a label for the procedure; handle case where the
6533 label was defined after the .PROC directive.
6535 Note there's not need to diddle with the segment or fragment
6536 for the label symbol in this case. We have already switched
6537 into the new $CODE$ subspace at this point. */
6538 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
6540 label_symbol_struct
*label_symbol
= pa_get_label ();
6544 if (label_symbol
->lss_label
)
6546 last_call_info
->start_symbol
= label_symbol
->lss_label
;
6547 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
6550 /* Also handle allocation of a fixup to hold the unwind
6551 information when the label appears after the proc/procend. */
6552 if (within_entry_exit
)
6554 char *where
= frag_more (0);
6556 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
6557 NULL
, (offsetT
) 0, NULL
,
6558 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
6559 (int *) &last_call_info
->ci_unwind
.descriptor
);
6564 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
6567 as_bad (_("Missing function name for .PROC"));
6570 if (!within_procedure
)
6571 as_bad (_("misplaced .procend"));
6573 if (!callinfo_found
)
6574 as_bad (_("Missing .callinfo for this procedure"));
6576 if (within_entry_exit
)
6577 as_bad (_("Missing .EXIT for a .ENTRY"));
6580 /* ELF needs to mark the end of each function so that it can compute
6581 the size of the function (apparently its needed in the symbol table). */
6582 hppa_elf_mark_end_of_function ();
6585 within_procedure
= FALSE
;
6586 demand_empty_rest_of_line ();
6587 pa_undefine_label ();
6590 /* If VALUE is an exact power of two between zero and 2^31, then
6591 return log2 (VALUE). Else return -1. */
6599 while ((1 << shift
) != value
&& shift
< 32)
6610 /* Check to make sure we have a valid space and subspace. */
6613 pa_check_current_space_and_subspace ()
6615 if (current_space
== NULL
)
6616 as_fatal (_("Not in a space.\n"));
6618 if (current_subspace
== NULL
)
6619 as_fatal (_("Not in a subspace.\n"));
6622 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
6623 then create a new space entry to hold the information specified
6624 by the parameters to the .SPACE directive. */
6626 static sd_chain_struct
*
6627 pa_parse_space_stmt (space_name
, create_flag
)
6631 char *name
, *ptemp
, c
;
6632 char loadable
, defined
, private, sort
;
6634 asection
*seg
= NULL
;
6635 sd_chain_struct
*space
;
6637 /* load default values */
6643 if (strcmp (space_name
, "$TEXT$") == 0)
6645 seg
= pa_def_spaces
[0].segment
;
6646 defined
= pa_def_spaces
[0].defined
;
6647 private = pa_def_spaces
[0].private;
6648 sort
= pa_def_spaces
[0].sort
;
6649 spnum
= pa_def_spaces
[0].spnum
;
6651 else if (strcmp (space_name
, "$PRIVATE$") == 0)
6653 seg
= pa_def_spaces
[1].segment
;
6654 defined
= pa_def_spaces
[1].defined
;
6655 private = pa_def_spaces
[1].private;
6656 sort
= pa_def_spaces
[1].sort
;
6657 spnum
= pa_def_spaces
[1].spnum
;
6660 if (!is_end_of_statement ())
6662 print_errors
= FALSE
;
6663 ptemp
= input_line_pointer
+ 1;
6664 /* First see if the space was specified as a number rather than
6665 as a name. According to the PA assembly manual the rest of
6666 the line should be ignored. */
6667 temp
= pa_parse_number (&ptemp
, 0);
6671 input_line_pointer
= ptemp
;
6675 while (!is_end_of_statement ())
6677 input_line_pointer
++;
6678 name
= input_line_pointer
;
6679 c
= get_symbol_end ();
6680 if ((strncasecmp (name
, "spnum", 5) == 0))
6682 *input_line_pointer
= c
;
6683 input_line_pointer
++;
6684 spnum
= get_absolute_expression ();
6686 else if ((strncasecmp (name
, "sort", 4) == 0))
6688 *input_line_pointer
= c
;
6689 input_line_pointer
++;
6690 sort
= get_absolute_expression ();
6692 else if ((strncasecmp (name
, "unloadable", 10) == 0))
6694 *input_line_pointer
= c
;
6697 else if ((strncasecmp (name
, "notdefined", 10) == 0))
6699 *input_line_pointer
= c
;
6702 else if ((strncasecmp (name
, "private", 7) == 0))
6704 *input_line_pointer
= c
;
6709 as_bad (_("Invalid .SPACE argument"));
6710 *input_line_pointer
= c
;
6711 if (!is_end_of_statement ())
6712 input_line_pointer
++;
6716 print_errors
= TRUE
;
6719 if (create_flag
&& seg
== NULL
)
6720 seg
= subseg_new (space_name
, 0);
6722 /* If create_flag is nonzero, then create the new space with
6723 the attributes computed above. Else set the values in
6724 an already existing space -- this can only happen for
6725 the first occurence of a built-in space. */
6727 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
6728 private, sort
, seg
, 1);
6731 space
= is_defined_space (space_name
);
6732 SPACE_SPNUM (space
) = spnum
;
6733 SPACE_DEFINED (space
) = defined
& 1;
6734 SPACE_USER_DEFINED (space
) = 1;
6737 #ifdef obj_set_section_attributes
6738 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
6744 /* Handle a .SPACE pseudo-op; this switches the current space to the
6745 given space, creating the new space if necessary. */
6751 char *name
, c
, *space_name
, *save_s
;
6753 sd_chain_struct
*sd_chain
;
6755 if (within_procedure
)
6757 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
6758 ignore_rest_of_line ();
6762 /* Check for some of the predefined spaces. FIXME: most of the code
6763 below is repeated several times, can we extract the common parts
6764 and place them into a subroutine or something similar? */
6765 /* FIXME Is this (and the next IF stmt) really right?
6766 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
6767 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
6769 input_line_pointer
+= 6;
6770 sd_chain
= is_defined_space ("$TEXT$");
6771 if (sd_chain
== NULL
)
6772 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
6773 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
6774 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
6776 current_space
= sd_chain
;
6777 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
6779 = pa_subsegment_to_subspace (text_section
,
6780 sd_chain
->sd_last_subseg
);
6781 demand_empty_rest_of_line ();
6784 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
6786 input_line_pointer
+= 9;
6787 sd_chain
= is_defined_space ("$PRIVATE$");
6788 if (sd_chain
== NULL
)
6789 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
6790 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
6791 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
6793 current_space
= sd_chain
;
6794 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
6796 = pa_subsegment_to_subspace (data_section
,
6797 sd_chain
->sd_last_subseg
);
6798 demand_empty_rest_of_line ();
6801 if (!strncasecmp (input_line_pointer
,
6802 GDB_DEBUG_SPACE_NAME
,
6803 strlen (GDB_DEBUG_SPACE_NAME
)))
6805 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
6806 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
6807 if (sd_chain
== NULL
)
6808 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
6809 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
6810 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
6812 current_space
= sd_chain
;
6815 asection
*gdb_section
6816 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
6818 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
6820 = pa_subsegment_to_subspace (gdb_section
,
6821 sd_chain
->sd_last_subseg
);
6823 demand_empty_rest_of_line ();
6827 /* It could be a space specified by number. */
6829 save_s
= input_line_pointer
;
6830 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
6832 if ((sd_chain
= pa_find_space_by_number (temp
)))
6834 current_space
= sd_chain
;
6836 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
6838 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
6839 sd_chain
->sd_last_subseg
);
6840 demand_empty_rest_of_line ();
6845 /* Not a number, attempt to create a new space. */
6847 input_line_pointer
= save_s
;
6848 name
= input_line_pointer
;
6849 c
= get_symbol_end ();
6850 space_name
= xmalloc (strlen (name
) + 1);
6851 strcpy (space_name
, name
);
6852 *input_line_pointer
= c
;
6854 sd_chain
= pa_parse_space_stmt (space_name
, 1);
6855 current_space
= sd_chain
;
6857 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
6858 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
6859 sd_chain
->sd_last_subseg
);
6860 demand_empty_rest_of_line ();
6864 /* Switch to a new space. (I think). FIXME. */
6873 sd_chain_struct
*space
;
6875 name
= input_line_pointer
;
6876 c
= get_symbol_end ();
6877 space
= is_defined_space (name
);
6881 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
6884 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
6886 *input_line_pointer
= c
;
6887 demand_empty_rest_of_line ();
6890 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
6891 given subspace, creating the new subspace if necessary.
6893 FIXME. Should mirror pa_space more closely, in particular how
6894 they're broken up into subroutines. */
6897 pa_subspace (create_new
)
6900 char *name
, *ss_name
, c
;
6901 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
6902 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
6903 sd_chain_struct
*space
;
6904 ssd_chain_struct
*ssd
;
6907 if (current_space
== NULL
)
6908 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
6910 if (within_procedure
)
6912 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
6913 ignore_rest_of_line ();
6917 name
= input_line_pointer
;
6918 c
= get_symbol_end ();
6919 ss_name
= xmalloc (strlen (name
) + 1);
6920 strcpy (ss_name
, name
);
6921 *input_line_pointer
= c
;
6923 /* Load default values. */
6935 space
= current_space
;
6939 ssd
= is_defined_subspace (ss_name
);
6940 /* Allow user to override the builtin attributes of subspaces. But
6941 only allow the attributes to be changed once! */
6942 if (ssd
&& SUBSPACE_DEFINED (ssd
))
6944 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
6945 current_subspace
= ssd
;
6946 if (!is_end_of_statement ())
6947 as_warn (_("Parameters of an existing subspace can\'t be modified"));
6948 demand_empty_rest_of_line ();
6953 /* A new subspace. Load default values if it matches one of
6954 the builtin subspaces. */
6956 while (pa_def_subspaces
[i
].name
)
6958 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
6960 loadable
= pa_def_subspaces
[i
].loadable
;
6961 common
= pa_def_subspaces
[i
].common
;
6962 dup_common
= pa_def_subspaces
[i
].dup_common
;
6963 code_only
= pa_def_subspaces
[i
].code_only
;
6964 zero
= pa_def_subspaces
[i
].zero
;
6965 space_index
= pa_def_subspaces
[i
].space_index
;
6966 alignment
= pa_def_subspaces
[i
].alignment
;
6967 quadrant
= pa_def_subspaces
[i
].quadrant
;
6968 access
= pa_def_subspaces
[i
].access
;
6969 sort
= pa_def_subspaces
[i
].sort
;
6976 /* We should be working with a new subspace now. Fill in
6977 any information as specified by the user. */
6978 if (!is_end_of_statement ())
6980 input_line_pointer
++;
6981 while (!is_end_of_statement ())
6983 name
= input_line_pointer
;
6984 c
= get_symbol_end ();
6985 if ((strncasecmp (name
, "quad", 4) == 0))
6987 *input_line_pointer
= c
;
6988 input_line_pointer
++;
6989 quadrant
= get_absolute_expression ();
6991 else if ((strncasecmp (name
, "align", 5) == 0))
6993 *input_line_pointer
= c
;
6994 input_line_pointer
++;
6995 alignment
= get_absolute_expression ();
6996 if (log2 (alignment
) == -1)
6998 as_bad (_("Alignment must be a power of 2"));
7002 else if ((strncasecmp (name
, "access", 6) == 0))
7004 *input_line_pointer
= c
;
7005 input_line_pointer
++;
7006 access
= get_absolute_expression ();
7008 else if ((strncasecmp (name
, "sort", 4) == 0))
7010 *input_line_pointer
= c
;
7011 input_line_pointer
++;
7012 sort
= get_absolute_expression ();
7014 else if ((strncasecmp (name
, "code_only", 9) == 0))
7016 *input_line_pointer
= c
;
7019 else if ((strncasecmp (name
, "unloadable", 10) == 0))
7021 *input_line_pointer
= c
;
7024 else if ((strncasecmp (name
, "common", 6) == 0))
7026 *input_line_pointer
= c
;
7029 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
7031 *input_line_pointer
= c
;
7034 else if ((strncasecmp (name
, "zero", 4) == 0))
7036 *input_line_pointer
= c
;
7039 else if ((strncasecmp (name
, "first", 5) == 0))
7040 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
7042 as_bad (_("Invalid .SUBSPACE argument"));
7043 if (!is_end_of_statement ())
7044 input_line_pointer
++;
7048 /* Compute a reasonable set of BFD flags based on the information
7049 in the .subspace directive. */
7050 applicable
= bfd_applicable_section_flags (stdoutput
);
7053 flags
|= (SEC_ALLOC
| SEC_LOAD
);
7056 if (common
|| dup_common
)
7057 flags
|= SEC_IS_COMMON
;
7059 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
7061 /* This is a zero-filled subspace (eg BSS). */
7063 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
7065 applicable
&= flags
;
7067 /* If this is an existing subspace, then we want to use the
7068 segment already associated with the subspace.
7070 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
7071 lots of sections. It might be a problem in the PA ELF
7072 code, I do not know yet. For now avoid creating anything
7073 but the "standard" sections for ELF. */
7075 section
= subseg_force_new (ss_name
, 0);
7077 section
= ssd
->ssd_seg
;
7079 section
= subseg_new (ss_name
, 0);
7082 seg_info (section
)->bss
= 1;
7084 /* Now set the flags. */
7085 bfd_set_section_flags (stdoutput
, section
, applicable
);
7087 /* Record any alignment request for this section. */
7088 record_alignment (section
, log2 (alignment
));
7090 /* Set the starting offset for this section. */
7091 bfd_set_section_vma (stdoutput
, section
,
7092 pa_subspace_start (space
, quadrant
));
7094 /* Now that all the flags are set, update an existing subspace,
7095 or create a new one. */
7098 current_subspace
= update_subspace (space
, ss_name
, loadable
,
7099 code_only
, common
, dup_common
,
7100 sort
, zero
, access
, space_index
,
7101 alignment
, quadrant
,
7104 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
7106 dup_common
, zero
, sort
,
7107 access
, space_index
,
7108 alignment
, quadrant
, section
);
7110 demand_empty_rest_of_line ();
7111 current_subspace
->ssd_seg
= section
;
7112 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
7114 SUBSPACE_DEFINED (current_subspace
) = 1;
7118 /* Create default space and subspace dictionaries. */
7125 space_dict_root
= NULL
;
7126 space_dict_last
= NULL
;
7129 while (pa_def_spaces
[i
].name
)
7133 /* Pick the right name to use for the new section. */
7134 name
= pa_def_spaces
[i
].name
;
7136 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
7137 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
7138 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
7139 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
7140 pa_def_spaces
[i
].segment
, 0);
7145 while (pa_def_subspaces
[i
].name
)
7148 int applicable
, subsegment
;
7149 asection
*segment
= NULL
;
7150 sd_chain_struct
*space
;
7152 /* Pick the right name for the new section and pick the right
7153 subsegment number. */
7154 name
= pa_def_subspaces
[i
].name
;
7157 /* Create the new section. */
7158 segment
= subseg_new (name
, subsegment
);
7161 /* For SOM we want to replace the standard .text, .data, and .bss
7162 sections with our own. We also want to set BFD flags for
7163 all the built-in subspaces. */
7164 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
7166 text_section
= segment
;
7167 applicable
= bfd_applicable_section_flags (stdoutput
);
7168 bfd_set_section_flags (stdoutput
, segment
,
7169 applicable
& (SEC_ALLOC
| SEC_LOAD
7170 | SEC_RELOC
| SEC_CODE
7172 | SEC_HAS_CONTENTS
));
7174 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
7176 data_section
= segment
;
7177 applicable
= bfd_applicable_section_flags (stdoutput
);
7178 bfd_set_section_flags (stdoutput
, segment
,
7179 applicable
& (SEC_ALLOC
| SEC_LOAD
7181 | SEC_HAS_CONTENTS
));
7185 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
7187 bss_section
= segment
;
7188 applicable
= bfd_applicable_section_flags (stdoutput
);
7189 bfd_set_section_flags (stdoutput
, segment
,
7190 applicable
& SEC_ALLOC
);
7192 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
7194 applicable
= bfd_applicable_section_flags (stdoutput
);
7195 bfd_set_section_flags (stdoutput
, segment
,
7196 applicable
& (SEC_ALLOC
| SEC_LOAD
7199 | SEC_HAS_CONTENTS
));
7201 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
7203 applicable
= bfd_applicable_section_flags (stdoutput
);
7204 bfd_set_section_flags (stdoutput
, segment
,
7205 applicable
& (SEC_ALLOC
| SEC_LOAD
7208 | SEC_HAS_CONTENTS
));
7210 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
7212 applicable
= bfd_applicable_section_flags (stdoutput
);
7213 bfd_set_section_flags (stdoutput
, segment
,
7214 applicable
& (SEC_ALLOC
| SEC_LOAD
7217 | SEC_HAS_CONTENTS
));
7220 /* Find the space associated with this subspace. */
7221 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
7222 def_space_index
].segment
);
7225 as_fatal (_("Internal error: Unable to find containing space for %s."),
7226 pa_def_subspaces
[i
].name
);
7229 create_new_subspace (space
, name
,
7230 pa_def_subspaces
[i
].loadable
,
7231 pa_def_subspaces
[i
].code_only
,
7232 pa_def_subspaces
[i
].common
,
7233 pa_def_subspaces
[i
].dup_common
,
7234 pa_def_subspaces
[i
].zero
,
7235 pa_def_subspaces
[i
].sort
,
7236 pa_def_subspaces
[i
].access
,
7237 pa_def_subspaces
[i
].space_index
,
7238 pa_def_subspaces
[i
].alignment
,
7239 pa_def_subspaces
[i
].quadrant
,
7247 /* Create a new space NAME, with the appropriate flags as defined
7248 by the given parameters. */
7250 static sd_chain_struct
*
7251 create_new_space (name
, spnum
, loadable
, defined
, private,
7252 sort
, seg
, user_defined
)
7262 sd_chain_struct
*chain_entry
;
7264 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
7266 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
7269 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7270 strcpy (SPACE_NAME (chain_entry
), name
);
7271 SPACE_DEFINED (chain_entry
) = defined
;
7272 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
7273 SPACE_SPNUM (chain_entry
) = spnum
;
7275 chain_entry
->sd_seg
= seg
;
7276 chain_entry
->sd_last_subseg
= -1;
7277 chain_entry
->sd_subspaces
= NULL
;
7278 chain_entry
->sd_next
= NULL
;
7280 /* Find spot for the new space based on its sort key. */
7281 if (!space_dict_last
)
7282 space_dict_last
= chain_entry
;
7284 if (space_dict_root
== NULL
)
7285 space_dict_root
= chain_entry
;
7288 sd_chain_struct
*chain_pointer
;
7289 sd_chain_struct
*prev_chain_pointer
;
7291 chain_pointer
= space_dict_root
;
7292 prev_chain_pointer
= NULL
;
7294 while (chain_pointer
)
7296 prev_chain_pointer
= chain_pointer
;
7297 chain_pointer
= chain_pointer
->sd_next
;
7300 /* At this point we've found the correct place to add the new
7301 entry. So add it and update the linked lists as appropriate. */
7302 if (prev_chain_pointer
)
7304 chain_entry
->sd_next
= chain_pointer
;
7305 prev_chain_pointer
->sd_next
= chain_entry
;
7309 space_dict_root
= chain_entry
;
7310 chain_entry
->sd_next
= chain_pointer
;
7313 if (chain_entry
->sd_next
== NULL
)
7314 space_dict_last
= chain_entry
;
7317 /* This is here to catch predefined spaces which do not get
7318 modified by the user's input. Another call is found at
7319 the bottom of pa_parse_space_stmt to handle cases where
7320 the user modifies a predefined space. */
7321 #ifdef obj_set_section_attributes
7322 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
7328 /* Create a new subspace NAME, with the appropriate flags as defined
7329 by the given parameters.
7331 Add the new subspace to the subspace dictionary chain in numerical
7332 order as defined by the SORT entries. */
7334 static ssd_chain_struct
*
7335 create_new_subspace (space
, name
, loadable
, code_only
, common
,
7336 dup_common
, is_zero
, sort
, access
, space_index
,
7337 alignment
, quadrant
, seg
)
7338 sd_chain_struct
*space
;
7340 int loadable
, code_only
, common
, dup_common
, is_zero
;
7348 ssd_chain_struct
*chain_entry
;
7350 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
7352 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
7354 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
7355 strcpy (SUBSPACE_NAME (chain_entry
), name
);
7357 /* Initialize subspace_defined. When we hit a .subspace directive
7358 we'll set it to 1 which "locks-in" the subspace attributes. */
7359 SUBSPACE_DEFINED (chain_entry
) = 0;
7361 chain_entry
->ssd_subseg
= 0;
7362 chain_entry
->ssd_seg
= seg
;
7363 chain_entry
->ssd_next
= NULL
;
7365 /* Find spot for the new subspace based on its sort key. */
7366 if (space
->sd_subspaces
== NULL
)
7367 space
->sd_subspaces
= chain_entry
;
7370 ssd_chain_struct
*chain_pointer
;
7371 ssd_chain_struct
*prev_chain_pointer
;
7373 chain_pointer
= space
->sd_subspaces
;
7374 prev_chain_pointer
= NULL
;
7376 while (chain_pointer
)
7378 prev_chain_pointer
= chain_pointer
;
7379 chain_pointer
= chain_pointer
->ssd_next
;
7382 /* Now we have somewhere to put the new entry. Insert it and update
7384 if (prev_chain_pointer
)
7386 chain_entry
->ssd_next
= chain_pointer
;
7387 prev_chain_pointer
->ssd_next
= chain_entry
;
7391 space
->sd_subspaces
= chain_entry
;
7392 chain_entry
->ssd_next
= chain_pointer
;
7396 #ifdef obj_set_subsection_attributes
7397 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
7404 /* Update the information for the given subspace based upon the
7405 various arguments. Return the modified subspace chain entry. */
7407 static ssd_chain_struct
*
7408 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
7409 zero
, access
, space_index
, alignment
, quadrant
, section
)
7410 sd_chain_struct
*space
;
7424 ssd_chain_struct
*chain_entry
;
7426 chain_entry
= is_defined_subspace (name
);
7428 #ifdef obj_set_subsection_attributes
7429 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
7436 /* Return the space chain entry for the space with the name NAME or
7437 NULL if no such space exists. */
7439 static sd_chain_struct
*
7440 is_defined_space (name
)
7443 sd_chain_struct
*chain_pointer
;
7445 for (chain_pointer
= space_dict_root
;
7447 chain_pointer
= chain_pointer
->sd_next
)
7449 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
7450 return chain_pointer
;
7453 /* No mapping from segment to space was found. Return NULL. */
7457 /* Find and return the space associated with the given seg. If no mapping
7458 from the given seg to a space is found, then return NULL.
7460 Unlike subspaces, the number of spaces is not expected to grow much,
7461 so a linear exhaustive search is OK here. */
7463 static sd_chain_struct
*
7464 pa_segment_to_space (seg
)
7467 sd_chain_struct
*space_chain
;
7469 /* Walk through each space looking for the correct mapping. */
7470 for (space_chain
= space_dict_root
;
7472 space_chain
= space_chain
->sd_next
)
7474 if (space_chain
->sd_seg
== seg
)
7478 /* Mapping was not found. Return NULL. */
7482 /* Return the space chain entry for the subspace with the name NAME or
7483 NULL if no such subspace exists.
7485 Uses a linear search through all the spaces and subspaces, this may
7486 not be appropriate if we ever being placing each function in its
7489 static ssd_chain_struct
*
7490 is_defined_subspace (name
)
7493 sd_chain_struct
*space_chain
;
7494 ssd_chain_struct
*subspace_chain
;
7496 /* Walk through each space. */
7497 for (space_chain
= space_dict_root
;
7499 space_chain
= space_chain
->sd_next
)
7501 /* Walk through each subspace looking for a name which matches. */
7502 for (subspace_chain
= space_chain
->sd_subspaces
;
7504 subspace_chain
= subspace_chain
->ssd_next
)
7505 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
7506 return subspace_chain
;
7509 /* Subspace wasn't found. Return NULL. */
7513 /* Find and return the subspace associated with the given seg. If no
7514 mapping from the given seg to a subspace is found, then return NULL.
7516 If we ever put each procedure/function within its own subspace
7517 (to make life easier on the compiler and linker), then this will have
7518 to become more efficient. */
7520 static ssd_chain_struct
*
7521 pa_subsegment_to_subspace (seg
, subseg
)
7525 sd_chain_struct
*space_chain
;
7526 ssd_chain_struct
*subspace_chain
;
7528 /* Walk through each space. */
7529 for (space_chain
= space_dict_root
;
7531 space_chain
= space_chain
->sd_next
)
7533 if (space_chain
->sd_seg
== seg
)
7535 /* Walk through each subspace within each space looking for
7536 the correct mapping. */
7537 for (subspace_chain
= space_chain
->sd_subspaces
;
7539 subspace_chain
= subspace_chain
->ssd_next
)
7540 if (subspace_chain
->ssd_subseg
== (int) subseg
)
7541 return subspace_chain
;
7545 /* No mapping from subsegment to subspace found. Return NULL. */
7549 /* Given a number, try and find a space with the name number.
7551 Return a pointer to a space dictionary chain entry for the space
7552 that was found or NULL on failure. */
7554 static sd_chain_struct
*
7555 pa_find_space_by_number (number
)
7558 sd_chain_struct
*space_chain
;
7560 for (space_chain
= space_dict_root
;
7562 space_chain
= space_chain
->sd_next
)
7564 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
7568 /* No appropriate space found. Return NULL. */
7572 /* Return the starting address for the given subspace. If the starting
7573 address is unknown then return zero. */
7576 pa_subspace_start (space
, quadrant
)
7577 sd_chain_struct
*space
;
7580 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
7581 is not correct for the PA OSF1 port. */
7582 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
7584 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
7591 /* FIXME. Needs documentation. */
7593 pa_next_subseg (space
)
7594 sd_chain_struct
*space
;
7597 space
->sd_last_subseg
++;
7598 return space
->sd_last_subseg
;
7602 /* Helper function for pa_stringer. Used to find the end of
7609 unsigned int c
= *s
& CHAR_MASK
;
7612 /* We must have a valid space and subspace. */
7613 pa_check_current_space_and_subspace ();
7627 /* Handle a .STRING type pseudo-op. */
7630 pa_stringer (append_zero
)
7633 char *s
, num_buf
[4];
7637 /* Preprocess the string to handle PA-specific escape sequences.
7638 For example, \xDD where DD is a hexidecimal number should be
7639 changed to \OOO where OOO is an octal number. */
7641 /* Skip the opening quote. */
7642 s
= input_line_pointer
+ 1;
7644 while (is_a_char (c
= pa_stringer_aux (s
++)))
7651 /* Handle \x<num>. */
7654 unsigned int number
;
7659 /* Get pas the 'x'. */
7661 for (num_digit
= 0, number
= 0, dg
= *s
;
7663 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
7664 || (dg
>= 'A' && dg
<= 'F'));
7668 number
= number
* 16 + dg
- '0';
7669 else if (dg
>= 'a' && dg
<= 'f')
7670 number
= number
* 16 + dg
- 'a' + 10;
7672 number
= number
* 16 + dg
- 'A' + 10;
7682 sprintf (num_buf
, "%02o", number
);
7685 sprintf (num_buf
, "%03o", number
);
7688 for (i
= 0; i
<= num_digit
; i
++)
7689 s_start
[i
] = num_buf
[i
];
7693 /* This might be a "\"", skip over the escaped char. */
7700 stringer (append_zero
);
7701 pa_undefine_label ();
7704 /* Handle a .VERSION pseudo-op. */
7711 pa_undefine_label ();
7716 /* Handle a .COMPILER pseudo-op. */
7719 pa_compiler (unused
)
7722 obj_som_compiler (0);
7723 pa_undefine_label ();
7728 /* Handle a .COPYRIGHT pseudo-op. */
7731 pa_copyright (unused
)
7735 pa_undefine_label ();
7738 /* Just like a normal cons, but when finished we have to undefine
7739 the latest space label. */
7746 pa_undefine_label ();
7749 /* Switch to the data space. As usual delete our label. */
7756 current_space
= is_defined_space ("$PRIVATE$");
7758 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
7761 pa_undefine_label ();
7764 /* Like float_cons, but we need to undefine our label. */
7767 pa_float_cons (float_type
)
7770 float_cons (float_type
);
7771 pa_undefine_label ();
7774 /* Like s_fill, but delete our label when finished. */
7781 /* We must have a valid space and subspace. */
7782 pa_check_current_space_and_subspace ();
7786 pa_undefine_label ();
7789 /* Like lcomm, but delete our label when finished. */
7792 pa_lcomm (needs_align
)
7796 /* We must have a valid space and subspace. */
7797 pa_check_current_space_and_subspace ();
7800 s_lcomm (needs_align
);
7801 pa_undefine_label ();
7804 /* Like lsym, but delete our label when finished. */
7811 /* We must have a valid space and subspace. */
7812 pa_check_current_space_and_subspace ();
7816 pa_undefine_label ();
7819 /* Switch to the text space. Like s_text, but delete our
7820 label when finished. */
7826 current_space
= is_defined_space ("$TEXT$");
7828 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
7832 pa_undefine_label ();
7835 /* On the PA relocations which involve function symbols must not be
7836 adjusted. This so that the linker can know when/how to create argument
7837 relocation stubs for indirect calls and calls to static functions.
7839 "T" field selectors create DLT relative fixups for accessing
7840 globals and statics in PIC code; each DLT relative fixup creates
7841 an entry in the DLT table. The entries contain the address of
7842 the final target (eg accessing "foo" would create a DLT entry
7843 with the address of "foo").
7845 Unfortunately, the HP linker doesn't take into account any addend
7846 when generating the DLT; so accessing $LIT$+8 puts the address of
7847 $LIT$ into the DLT rather than the address of $LIT$+8.
7849 The end result is we can't perform relocation symbol reductions for
7850 any fixup which creates entries in the DLT (eg they use "T" field
7853 Reject reductions involving symbols with external scope; such
7854 reductions make life a living hell for object file editors.
7856 FIXME. Also reject R_HPPA relocations which are 32bits wide in
7857 the code space. The SOM BFD backend doesn't know how to pull the
7858 right bits out of an instruction. */
7861 hppa_fix_adjustable (fixp
)
7864 struct hppa_fix_struct
*hppa_fix
;
7866 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
7869 /* Reject reductions of symbols in 32bit relocs. */
7870 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
7873 /* Reject reductions of symbols in sym1-sym2 expressions when
7874 the fixup will occur in a CODE subspace.
7876 XXX FIXME: Long term we probably want to reject all of these;
7877 for example reducing in the debug section would lose if we ever
7878 supported using the optimizing hp linker. */
7881 && (hppa_fix
->segment
->flags
& SEC_CODE
))
7883 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
7884 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
7888 /* We can't adjust any relocs that use LR% and RR% field selectors.
7889 That confuses the HP linker. */
7890 if (hppa_fix
->fx_r_field
== e_lrsel
7891 || hppa_fix
->fx_r_field
== e_rrsel
7892 || hppa_fix
->fx_r_field
== e_nlrsel
)
7896 /* Reject reductions of symbols in DLT relative relocs,
7897 relocations with plabels. */
7898 if (hppa_fix
->fx_r_field
== e_tsel
7899 || hppa_fix
->fx_r_field
== e_ltsel
7900 || hppa_fix
->fx_r_field
== e_rtsel
7901 || hppa_fix
->fx_r_field
== e_psel
7902 || hppa_fix
->fx_r_field
== e_rpsel
7903 || hppa_fix
->fx_r_field
== e_lpsel
)
7906 if (fixp
->fx_addsy
&& S_IS_EXTERNAL (fixp
->fx_addsy
))
7909 /* Reject absolute calls (jumps). */
7910 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
7913 /* Reject reductions of function symbols. */
7914 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
7920 /* Return nonzero if the fixup in FIXP will require a relocation,
7921 even it if appears that the fixup could be completely handled
7925 hppa_force_relocation (fixp
)
7928 struct hppa_fix_struct
*hppa_fixp
;
7931 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
7933 if (fixp
->fx_r_type
== R_HPPA_ENTRY
|| fixp
->fx_r_type
== R_HPPA_EXIT
7934 || fixp
->fx_r_type
== R_HPPA_BEGIN_BRTAB
7935 || fixp
->fx_r_type
== R_HPPA_END_BRTAB
7936 || fixp
->fx_r_type
== R_HPPA_BEGIN_TRY
7937 || fixp
->fx_r_type
== R_HPPA_END_TRY
7938 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
7939 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
7943 #define arg_reloc_stub_needed(CALLER, CALLEE) \
7944 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
7947 /* It is necessary to force PC-relative calls/jumps to have a relocation
7948 entry if they're going to need either a argument relocation or long
7949 call stub. FIXME. Can't we need the same for absolute calls? */
7950 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
7951 && (arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
7952 symbol_get_bfdsym (fixp
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
7953 hppa_fixp
->fx_arg_reloc
)))
7956 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
7957 - md_pcrel_from (fixp
));
7958 /* Now check and see if we're going to need a long-branch stub. */
7959 if (fixp
->fx_r_type
== R_HPPA_PCREL_CALL
7960 && (distance
> 262143 || distance
< -262144))
7963 if (fixp
->fx_r_type
== R_HPPA_ABS_CALL
)
7965 #undef arg_reloc_stub_needed
7967 /* No need (yet) to force another relocations to be emitted. */
7971 /* Now for some ELF specific code. FIXME. */
7973 /* Mark the end of a function so that it's possible to compute
7974 the size of the function in hppa_elf_final_processing. */
7977 hppa_elf_mark_end_of_function ()
7979 /* ELF does not have EXIT relocations. All we do is create a
7980 temporary symbol marking the end of the function. */
7981 char *name
= (char *)
7982 xmalloc (strlen ("L$\001end_") +
7983 strlen (S_GET_NAME (last_call_info
->start_symbol
)) + 1);
7989 strcpy (name
, "L$\001end_");
7990 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
7992 /* If we have a .exit followed by a .procend, then the
7993 symbol will have already been defined. */
7994 symbolP
= symbol_find (name
);
7997 /* The symbol has already been defined! This can
7998 happen if we have a .exit followed by a .procend.
8000 This is *not* an error. All we want to do is free
8001 the memory we just allocated for the name and continue. */
8006 /* symbol value should be the offset of the
8007 last instruction of the function */
8008 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
8012 S_CLEAR_EXTERNAL (symbolP
);
8013 symbol_table_insert (symbolP
);
8017 last_call_info
->end_symbol
= symbolP
;
8019 as_bad (_("Symbol '%s' could not be created."), name
);
8023 as_bad (_("No memory for symbol name."));
8027 /* For ELF, this function serves one purpose: to setup the st_size
8028 field of STT_FUNC symbols. To do this, we need to scan the
8029 call_info structure list, determining st_size in by taking the
8030 difference in the address of the beginning/end marker symbols. */
8033 elf_hppa_final_processing ()
8035 struct call_info
*call_info_pointer
;
8037 for (call_info_pointer
= call_info_root
;
8039 call_info_pointer
= call_info_pointer
->ci_next
)
8041 elf_symbol_type
*esym
8042 = ((elf_symbol_type
*)
8043 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
8044 esym
->internal_elf_sym
.st_size
=
8045 S_GET_VALUE (call_info_pointer
->end_symbol
)
8046 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;
8054 if (debug_type
== DEBUG_DWARF2
)