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 /* A "convient" place to put object file dependencies which do
43 not need to be seen outside of tc-hppa.c. */
45 /* Object file formats specify relocation types. */
46 typedef elf_hppa_reloc_type reloc_type
;
48 /* Object file formats specify BFD symbol types. */
49 typedef elf_symbol_type obj_symbol_type
;
52 /* How to generate a relocation. */
53 #define hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type
55 #define hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type
58 /* ELF objects can have versions, but apparently do not have anywhere
59 to store a copyright string. */
60 #define obj_version obj_elf_version
61 #define obj_copyright obj_elf_version
63 #define UNWIND_SECTION_NAME ".PARISC.unwind"
67 /* Names of various debugging spaces/subspaces. */
68 #define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$"
69 #define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$"
70 #define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$"
71 #define UNWIND_SECTION_NAME "$UNWIND$"
73 /* Object file formats specify relocation types. */
74 typedef int reloc_type
;
76 /* SOM objects can have both a version string and a copyright string. */
77 #define obj_version obj_som_version
78 #define obj_copyright obj_som_copyright
80 /* How to generate a relocation. */
81 #define hppa_gen_reloc_type hppa_som_gen_reloc_type
83 /* Object file formats specify BFD symbol types. */
84 typedef som_symbol_type obj_symbol_type
;
86 /* This apparently isn't in older versions of hpux reloc.h. */
88 #define R_DLT_REL 0x78
100 /* Various structures and types used internally in tc-hppa.c. */
102 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
106 unsigned int cannot_unwind
:1;
107 unsigned int millicode
:1;
108 unsigned int millicode_save_rest
:1;
109 unsigned int region_desc
:2;
110 unsigned int save_sr
:2;
111 unsigned int entry_fr
:4;
112 unsigned int entry_gr
:5;
113 unsigned int args_stored
:1;
114 unsigned int call_fr
:5;
115 unsigned int call_gr
:5;
116 unsigned int save_sp
:1;
117 unsigned int save_rp
:1;
118 unsigned int save_rp_in_frame
:1;
119 unsigned int extn_ptr_defined
:1;
120 unsigned int cleanup_defined
:1;
122 unsigned int hpe_interrupt_marker
:1;
123 unsigned int hpux_interrupt_marker
:1;
124 unsigned int reserved
:3;
125 unsigned int frame_size
:27;
130 /* Starting and ending offsets of the region described by
132 unsigned int start_offset
;
133 unsigned int end_offset
;
134 struct unwind_desc descriptor
;
137 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
138 control the entry and exit code they generate. It is also used in
139 creation of the correct stack unwind descriptors.
141 NOTE: GAS does not support .enter and .leave for the generation of
142 prologues and epilogues. FIXME.
144 The fields in structure roughly correspond to the arguments available on the
145 .callinfo pseudo-op. */
149 /* The unwind descriptor being built. */
150 struct unwind_table ci_unwind
;
152 /* Name of this function. */
153 symbolS
*start_symbol
;
155 /* (temporary) symbol used to mark the end of this function. */
158 /* Next entry in the chain. */
159 struct call_info
*ci_next
;
162 /* Operand formats for FP instructions. Note not all FP instructions
163 allow all four formats to be used (for example fmpysub only allows
167 SGL
, DBL
, ILLEGAL_FMT
, QUAD
, W
, UW
, DW
, UDW
, QW
, UQW
171 /* This fully describes the symbol types which may be attached to
172 an EXPORT or IMPORT directive. Only SOM uses this formation
173 (ELF has no need for it). */
177 SYMBOL_TYPE_ABSOLUTE
,
181 SYMBOL_TYPE_MILLICODE
,
183 SYMBOL_TYPE_PRI_PROG
,
184 SYMBOL_TYPE_SEC_PROG
,
188 /* This structure contains information needed to assemble
189 individual instructions. */
192 /* Holds the opcode after parsing by pa_ip. */
193 unsigned long opcode
;
195 /* Holds an expression associated with the current instruction. */
198 /* Does this instruction use PC-relative addressing. */
201 /* Floating point formats for operand1 and operand2. */
202 fp_operand_format fpof1
;
203 fp_operand_format fpof2
;
206 /* Holds the field selector for this instruction
207 (for example L%, LR%, etc). */
210 /* Holds any argument relocation bits associated with this
211 instruction. (instruction should be some sort of call). */
214 /* The format specification for this instruction. */
217 /* The relocation (if any) associated with this instruction. */
221 /* PA-89 floating point registers are arranged like this:
224 +--------------+--------------+
225 | 0 or 16L | 16 or 16R |
226 +--------------+--------------+
227 | 1 or 17L | 17 or 17R |
228 +--------------+--------------+
236 +--------------+--------------+
237 | 14 or 30L | 30 or 30R |
238 +--------------+--------------+
239 | 15 or 31L | 31 or 31R |
240 +--------------+--------------+
243 The following is a version of pa_parse_number that
244 handles the L/R notation and returns the correct
245 value to put into the instruction register field.
246 The correct value to put into the instruction is
247 encoded in the structure 'pa_11_fp_reg_struct'. */
249 struct pa_11_fp_reg_struct
251 /* The register number. */
258 /* Additional information needed to build argument relocation stubs. */
261 /* The argument relocation specification. */
262 unsigned int arg_reloc
;
264 /* Number of arguments. */
265 unsigned int arg_count
;
269 /* This structure defines an entry in the subspace dictionary
272 struct subspace_dictionary_chain
274 /* Nonzero if this space has been defined by the user code. */
275 unsigned int ssd_defined
;
277 /* Name of this subspace. */
280 /* GAS segment and subsegment associated with this subspace. */
284 /* Next space in the subspace dictionary chain. */
285 struct subspace_dictionary_chain
*ssd_next
;
288 typedef struct subspace_dictionary_chain ssd_chain_struct
;
290 /* This structure defines an entry in the subspace dictionary
293 struct space_dictionary_chain
295 /* Nonzero if this space has been defined by the user code or
296 as a default space. */
297 unsigned int sd_defined
;
299 /* Nonzero if this spaces has been defined by the user code. */
300 unsigned int sd_user_defined
;
302 /* The space number (or index). */
303 unsigned int sd_spnum
;
305 /* The name of this subspace. */
308 /* GAS segment to which this subspace corresponds. */
311 /* Current subsegment number being used. */
314 /* The chain of subspaces contained within this space. */
315 ssd_chain_struct
*sd_subspaces
;
317 /* The next entry in the space dictionary chain. */
318 struct space_dictionary_chain
*sd_next
;
321 typedef struct space_dictionary_chain sd_chain_struct
;
323 /* This structure defines attributes of the default subspace
324 dictionary entries. */
326 struct default_subspace_dict
328 /* Name of the subspace. */
331 /* FIXME. Is this still needed? */
334 /* Nonzero if this subspace is loadable. */
337 /* Nonzero if this subspace contains only code. */
340 /* Nonzero if this is a common subspace. */
343 /* Nonzero if this is a common subspace which allows symbols
344 to be multiply defined. */
347 /* Nonzero if this subspace should be zero filled. */
350 /* Sort key for this subspace. */
353 /* Access control bits for this subspace. Can represent RWX access
354 as well as privilege level changes for gateways. */
357 /* Index of containing space. */
360 /* Alignment (in bytes) of this subspace. */
363 /* Quadrant within space where this subspace should be loaded. */
366 /* An index into the default spaces array. */
369 /* Subsegment associated with this subspace. */
373 /* This structure defines attributes of the default space
374 dictionary entries. */
376 struct default_space_dict
378 /* Name of the space. */
381 /* Space number. It is possible to identify spaces within
382 assembly code numerically! */
385 /* Nonzero if this space is loadable. */
388 /* Nonzero if this space is "defined". FIXME is still needed */
391 /* Nonzero if this space can not be shared. */
394 /* Sort key for this space. */
397 /* Segment associated with this space. */
402 /* Structure for previous label tracking. Needed so that alignments,
403 callinfo declarations, etc can be easily attached to a particular
405 typedef struct label_symbol_struct
407 struct symbol
*lss_label
;
409 sd_chain_struct
*lss_space
;
414 struct label_symbol_struct
*lss_next
;
418 /* Extra information needed to perform fixups (relocations) on the PA. */
419 struct hppa_fix_struct
421 /* The field selector. */
422 enum hppa_reloc_field_selector_type_alt fx_r_field
;
427 /* Format of fixup. */
430 /* Argument relocation bits. */
433 /* The segment this fixup appears in. */
437 /* Structure to hold information about predefined registers. */
445 /* This structure defines the mapping from a FP condition string
446 to a condition number which can be recorded in an instruction. */
453 /* This structure defines a mapping from a field selector
454 string to a field selector type. */
455 struct selector_entry
461 /* Prototypes for functions local to tc-hppa.c. */
464 static void pa_check_current_space_and_subspace
PARAMS ((void));
467 static fp_operand_format pa_parse_fp_format
PARAMS ((char **s
));
468 static void pa_cons
PARAMS ((int));
469 static void pa_data
PARAMS ((int));
470 static void pa_float_cons
PARAMS ((int));
471 static void pa_fill
PARAMS ((int));
472 static void pa_lcomm
PARAMS ((int));
473 static void pa_lsym
PARAMS ((int));
474 static void pa_stringer
PARAMS ((int));
475 static void pa_text
PARAMS ((int));
476 static void pa_version
PARAMS ((int));
477 static int pa_parse_fp_cmp_cond
PARAMS ((char **));
478 static int get_expression
PARAMS ((char *));
479 static int pa_get_absolute_expression
PARAMS ((struct pa_it
*, char **));
480 static int evaluate_absolute
PARAMS ((struct pa_it
*));
481 static unsigned int pa_build_arg_reloc
PARAMS ((char *));
482 static unsigned int pa_align_arg_reloc
PARAMS ((unsigned int, unsigned int));
483 static int pa_parse_nullif
PARAMS ((char **));
484 static int pa_parse_nonneg_cmpsub_cmpltr
PARAMS ((char **, int));
485 static int pa_parse_neg_cmpsub_cmpltr
PARAMS ((char **, int));
486 static int pa_parse_neg_add_cmpltr
PARAMS ((char **, int));
487 static int pa_parse_nonneg_add_cmpltr
PARAMS ((char **, int));
488 static void pa_block
PARAMS ((int));
489 static void pa_brtab
PARAMS ((int));
490 static void pa_try
PARAMS ((int));
491 static void pa_call
PARAMS ((int));
492 static void pa_call_args
PARAMS ((struct call_desc
*));
493 static void pa_callinfo
PARAMS ((int));
494 static void pa_code
PARAMS ((int));
495 static void pa_comm
PARAMS ((int));
496 static void pa_copyright
PARAMS ((int));
497 static void pa_end
PARAMS ((int));
498 static void pa_enter
PARAMS ((int));
499 static void pa_entry
PARAMS ((int));
500 static void pa_equ
PARAMS ((int));
501 static void pa_exit
PARAMS ((int));
502 static void pa_export
PARAMS ((int));
503 static void pa_type_args
PARAMS ((symbolS
*, int));
504 static void pa_import
PARAMS ((int));
505 static void pa_label
PARAMS ((int));
506 static void pa_leave
PARAMS ((int));
507 static void pa_level
PARAMS ((int));
508 static void pa_origin
PARAMS ((int));
509 static void pa_proc
PARAMS ((int));
510 static void pa_procend
PARAMS ((int));
511 static void pa_param
PARAMS ((int));
512 static void pa_undefine_label
PARAMS ((void));
513 static int need_pa11_opcode
PARAMS ((struct pa_it
*,
514 struct pa_11_fp_reg_struct
*));
515 static int pa_parse_number
PARAMS ((char **, struct pa_11_fp_reg_struct
*));
516 static label_symbol_struct
*pa_get_label
PARAMS ((void));
518 static void pa_compiler
PARAMS ((int));
519 static void pa_align
PARAMS ((int));
520 static void pa_space
PARAMS ((int));
521 static void pa_spnum
PARAMS ((int));
522 static void pa_subspace
PARAMS ((int));
523 static sd_chain_struct
*create_new_space
PARAMS ((char *, int, int,
526 static ssd_chain_struct
*create_new_subspace
PARAMS ((sd_chain_struct
*,
531 static ssd_chain_struct
*update_subspace
PARAMS ((sd_chain_struct
*,
532 char *, int, int, int,
536 static sd_chain_struct
*is_defined_space
PARAMS ((char *));
537 static ssd_chain_struct
*is_defined_subspace
PARAMS ((char *));
538 static sd_chain_struct
*pa_segment_to_space
PARAMS ((asection
*));
539 static ssd_chain_struct
*pa_subsegment_to_subspace
PARAMS ((asection
*,
541 static sd_chain_struct
*pa_find_space_by_number
PARAMS ((int));
542 static unsigned int pa_subspace_start
PARAMS ((sd_chain_struct
*, int));
543 static sd_chain_struct
*pa_parse_space_stmt
PARAMS ((char *, int));
544 static int pa_next_subseg
PARAMS ((sd_chain_struct
*));
545 static void pa_spaces_begin
PARAMS ((void));
547 static void pa_ip
PARAMS ((char *));
548 static void fix_new_hppa
PARAMS ((fragS
*, int, int, symbolS
*,
549 long, expressionS
*, int,
550 bfd_reloc_code_real_type
,
551 enum hppa_reloc_field_selector_type_alt
,
553 static int is_end_of_statement
PARAMS ((void));
554 static int reg_name_search
PARAMS ((char *));
555 static int pa_chk_field_selector
PARAMS ((char **));
556 static int is_same_frag
PARAMS ((fragS
*, fragS
*));
557 static void process_exit
PARAMS ((void));
558 static int log2
PARAMS ((int));
559 static unsigned int pa_stringer_aux
PARAMS ((char *));
562 static void hppa_elf_mark_end_of_function
PARAMS ((void));
563 static void pa_build_unwind_subspace
PARAMS ((struct call_info
*));
566 /* File and gloally scoped variable declarations. */
569 /* Root and final entry in the space chain. */
570 static sd_chain_struct
*space_dict_root
;
571 static sd_chain_struct
*space_dict_last
;
573 /* The current space and subspace. */
574 static sd_chain_struct
*current_space
;
575 static ssd_chain_struct
*current_subspace
;
578 /* Root of the call_info chain. */
579 static struct call_info
*call_info_root
;
581 /* The last call_info (for functions) structure
582 seen so it can be associated with fixups and
584 static struct call_info
*last_call_info
;
586 /* The last call description (for actual calls). */
587 static struct call_desc last_call_desc
;
589 /* handle of the OPCODE hash table */
590 static struct hash_control
*op_hash
= NULL
;
592 /* This array holds the chars that always start a comment. If the
593 pre-processor is disabled, these aren't very useful. */
594 const char comment_chars
[] = ";";
596 /* Table of pseudo ops for the PA. FIXME -- how many of these
597 are now redundant with the overall GAS and the object file
599 const pseudo_typeS md_pseudo_table
[] =
601 /* align pseudo-ops on the PA specify the actual alignment requested,
602 not the log2 of the requested alignment. */
604 {"align", pa_align
, 8},
607 {"align", s_align_bytes
, 8},
609 {"begin_brtab", pa_brtab
, 1},
610 {"begin_try", pa_try
, 1},
611 {"block", pa_block
, 1},
612 {"blockz", pa_block
, 0},
613 {"byte", pa_cons
, 1},
614 {"call", pa_call
, 0},
615 {"callinfo", pa_callinfo
, 0},
616 {"code", pa_code
, 0},
617 {"comm", pa_comm
, 0},
619 {"compiler", pa_compiler
, 0},
621 {"copyright", pa_copyright
, 0},
622 {"data", pa_data
, 0},
623 {"double", pa_float_cons
, 'd'},
624 {"dword", pa_cons
, 8},
626 {"end_brtab", pa_brtab
, 0},
627 {"end_try", pa_try
, 0},
628 {"enter", pa_enter
, 0},
629 {"entry", pa_entry
, 0},
631 {"exit", pa_exit
, 0},
632 {"export", pa_export
, 0},
633 {"fill", pa_fill
, 0},
634 {"float", pa_float_cons
, 'f'},
635 {"half", pa_cons
, 2},
636 {"import", pa_import
, 0},
638 {"label", pa_label
, 0},
639 {"lcomm", pa_lcomm
, 0},
640 {"leave", pa_leave
, 0},
641 {"level", pa_level
, 0},
642 {"long", pa_cons
, 4},
643 {"lsym", pa_lsym
, 0},
645 {"nsubspa", pa_subspace
, 1},
647 {"octa", pa_cons
, 16},
648 {"org", pa_origin
, 0},
649 {"origin", pa_origin
, 0},
650 {"param", pa_param
, 0},
651 {"proc", pa_proc
, 0},
652 {"procend", pa_procend
, 0},
653 {"quad", pa_cons
, 8},
655 {"short", pa_cons
, 2},
656 {"single", pa_float_cons
, 'f'},
658 {"space", pa_space
, 0},
659 {"spnum", pa_spnum
, 0},
661 {"string", pa_stringer
, 0},
662 {"stringz", pa_stringer
, 1},
664 {"subspa", pa_subspace
, 0},
666 {"text", pa_text
, 0},
667 {"version", pa_version
, 0},
668 {"word", pa_cons
, 4},
672 /* This array holds the chars that only start a comment at the beginning of
673 a line. If the line seems to have the form '# 123 filename'
674 .line and .file directives will appear in the pre-processed output.
676 Note that input_file.c hand checks for '#' at the beginning of the
677 first line of the input file. This is because the compiler outputs
678 #NO_APP at the beginning of its output.
680 Also note that C style comments will always work. */
681 const char line_comment_chars
[] = "#";
683 /* This array holds the characters which act as line separators. */
684 const char line_separator_chars
[] = "!";
686 /* Chars that can be used to separate mant from exp in floating point nums. */
687 const char EXP_CHARS
[] = "eE";
689 /* Chars that mean this number is a floating point constant.
690 As in 0f12.456 or 0d1.2345e12.
692 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
693 changed in read.c. Ideally it shouldn't hae to know abou it at
694 all, but nothing is ideal around here. */
695 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
697 static struct pa_it the_insn
;
699 /* Points to the end of an expression just parsed by get_expressoin
700 and friends. FIXME. This shouldn't be handled with a file-global
702 static char *expr_end
;
704 /* Nonzero if a .callinfo appeared within the current procedure. */
705 static int callinfo_found
;
707 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
708 static int within_entry_exit
;
710 /* Nonzero if the assembler is currently within a procedure definition. */
711 static int within_procedure
;
713 /* Handle on strucutre which keep track of the last symbol
714 seen in each subspace. */
715 static label_symbol_struct
*label_symbols_rootp
= NULL
;
717 /* Holds the last field selector. */
718 static int hppa_field_selector
;
721 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
722 static symbolS
*dummy_symbol
;
725 /* Nonzero if errors are to be printed. */
726 static int print_errors
= 1;
728 /* List of registers that are pre-defined:
730 Each general register has one predefined name of the form
731 %r<REGNUM> which has the value <REGNUM>.
733 Space and control registers are handled in a similar manner,
734 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
736 Likewise for the floating point registers, but of the form
737 %fr<REGNUM>. Floating point registers have additional predefined
738 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
739 again have the value <REGNUM>.
741 Many registers also have synonyms:
743 %r26 - %r23 have %arg0 - %arg3 as synonyms
744 %r28 - %r29 have %ret0 - %ret1 as synonyms
745 %r30 has %sp as a synonym
746 %r27 has %dp as a synonym
747 %r2 has %rp as a synonym
749 Almost every control register has a synonym; they are not listed
752 The table is sorted. Suitable for searching by a binary search. */
754 static const struct pd_reg pre_defined_registers
[] =
954 /* This table is sorted by order of the length of the string. This is
955 so we check for <> before we check for <. If we had a <> and checked
956 for < first, we would get a false match. */
957 static const struct fp_cond_map fp_cond_map
[] =
993 static const struct selector_entry selector_table
[] =
1018 /* default space and subspace dictionaries */
1020 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1021 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1023 /* pre-defined subsegments (subspaces) for the HPPA. */
1024 #define SUBSEG_CODE 0
1025 #define SUBSEG_LIT 1
1026 #define SUBSEG_MILLI 2
1027 #define SUBSEG_DATA 0
1028 #define SUBSEG_BSS 2
1029 #define SUBSEG_UNWIND 3
1030 #define SUBSEG_GDB_STRINGS 0
1031 #define SUBSEG_GDB_SYMBOLS 1
1033 static struct default_subspace_dict pa_def_subspaces
[] =
1035 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE
},
1036 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA
},
1037 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT
},
1038 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI
},
1039 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS
},
1040 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1043 static struct default_space_dict pa_def_spaces
[] =
1045 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
},
1046 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
},
1047 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
}
1050 /* Misc local definitions used by the assembler. */
1052 /* These macros are used to maintain spaces/subspaces. */
1053 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1054 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1055 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1056 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1058 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1059 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1062 /* Return nonzero if the string pointed to by S potentially represents
1063 a right or left half of a FP register */
1064 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1065 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1067 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1068 main loop after insertion. */
1070 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1072 ((OPCODE) |= (FIELD) << (START)); \
1076 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1077 IGNORE is used to suppress the error message. */
1079 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1081 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1084 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1090 #define is_DP_relative(exp) \
1091 ((exp).X_op == O_subtract \
1092 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1094 #define is_PC_relative(exp) \
1095 ((exp).X_op == O_subtract \
1096 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1098 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1099 always be able to reduce the expression to a constant, so we don't
1100 need real complex handling yet. */
1101 #define is_complex(exp) \
1102 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1104 /* Actual functions to implement the PA specific code for the assembler. */
1106 /* Called before writing the object file. Make sure entry/exit and
1107 proc/procend pairs match. */
1112 if (within_entry_exit
)
1113 as_fatal (_("Missing .exit\n"));
1115 if (within_procedure
)
1116 as_fatal (_("Missing .procend\n"));
1119 /* Returns a pointer to the label_symbol_struct for the current space.
1120 or NULL if no label_symbol_struct exists for the current space. */
1122 static label_symbol_struct
*
1125 label_symbol_struct
*label_chain
;
1127 for (label_chain
= label_symbols_rootp
;
1129 label_chain
= label_chain
->lss_next
)
1132 if (current_space
== label_chain
->lss_space
&& label_chain
->lss_label
)
1136 if (now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
)
1144 /* Defines a label for the current space. If one is already defined,
1145 this function will replace it with the new label. */
1148 pa_define_label (symbol
)
1151 label_symbol_struct
*label_chain
= pa_get_label ();
1154 label_chain
->lss_label
= symbol
;
1157 /* Create a new label entry and add it to the head of the chain. */
1159 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1160 label_chain
->lss_label
= symbol
;
1162 label_chain
->lss_space
= current_space
;
1165 label_chain
->lss_segment
= now_seg
;
1167 label_chain
->lss_next
= NULL
;
1169 if (label_symbols_rootp
)
1170 label_chain
->lss_next
= label_symbols_rootp
;
1172 label_symbols_rootp
= label_chain
;
1176 /* Removes a label definition for the current space.
1177 If there is no label_symbol_struct entry, then no action is taken. */
1180 pa_undefine_label ()
1182 label_symbol_struct
*label_chain
;
1183 label_symbol_struct
*prev_label_chain
= NULL
;
1185 for (label_chain
= label_symbols_rootp
;
1187 label_chain
= label_chain
->lss_next
)
1191 && current_space
== label_chain
->lss_space
&& label_chain
->lss_label
1194 && now_seg
== label_chain
->lss_segment
&& label_chain
->lss_label
1198 /* Remove the label from the chain and free its memory. */
1199 if (prev_label_chain
)
1200 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1202 label_symbols_rootp
= label_chain
->lss_next
;
1207 prev_label_chain
= label_chain
;
1212 /* An HPPA-specific version of fix_new. This is required because the HPPA
1213 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1214 results in the creation of an instance of an hppa_fix_struct. An
1215 hppa_fix_struct stores the extra information along with a pointer to the
1216 original fixS. This is attached to the original fixup via the
1217 tc_fix_data field. */
1220 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1221 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1225 symbolS
*add_symbol
;
1229 bfd_reloc_code_real_type r_type
;
1230 enum hppa_reloc_field_selector_type_alt r_field
;
1237 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1238 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1241 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1243 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1244 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1245 hppa_fix
->fx_r_type
= r_type
;
1246 hppa_fix
->fx_r_field
= r_field
;
1247 hppa_fix
->fx_r_format
= r_format
;
1248 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1249 hppa_fix
->segment
= now_seg
;
1251 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1252 new_fix
->fx_offset
= *unwind_bits
;
1255 /* foo-$global$ is used to access non-automatic storage. $global$
1256 is really just a marker and has served its purpose, so eliminate
1257 it now so as not to confuse write.c. */
1258 if (new_fix
->fx_subsy
1259 && !strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$"))
1260 new_fix
->fx_subsy
= NULL
;
1263 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1264 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1267 parse_cons_expression_hppa (exp
)
1270 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1274 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1275 hppa_field_selector is set by the parse_cons_expression_hppa. */
1278 cons_fix_new_hppa (frag
, where
, size
, exp
)
1284 unsigned int rel_type
;
1286 /* Get a base relocation type. */
1287 if (is_DP_relative (*exp
))
1288 rel_type
= R_HPPA_GOTOFF
;
1289 else if (is_complex (*exp
))
1290 rel_type
= R_HPPA_COMPLEX
;
1294 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1295 as_warn (_("Invalid field selector. Assuming F%%."));
1297 fix_new_hppa (frag
, where
, size
,
1298 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1299 hppa_field_selector
, size
* 8, 0, NULL
);
1301 /* Reset field selector to its default state. */
1302 hppa_field_selector
= 0;
1305 /* This function is called once, at assembler startup time. It should
1306 set up all the tables, etc. that the MD part of the assembler will need. */
1311 const char *retval
= NULL
;
1315 last_call_info
= NULL
;
1316 call_info_root
= NULL
;
1318 /* Set the default machine type. */
1319 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1320 as_warn (_("could not set architecture and machine"));
1322 /* Folding of text and data segments fails miserably on the PA.
1323 Warn user and disable "-R" option. */
1324 if (flag_readonly_data_in_text
)
1326 as_warn (_("-R option not supported on this target."));
1327 flag_readonly_data_in_text
= 0;
1334 op_hash
= hash_new ();
1336 while (i
< NUMOPCODES
)
1338 const char *name
= pa_opcodes
[i
].name
;
1339 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1340 if (retval
!= NULL
&& *retval
!= '\0')
1342 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1347 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1348 != pa_opcodes
[i
].match
)
1350 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1351 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1356 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1360 as_fatal (_("Broken assembler. No assembly attempted."));
1363 /* SOM will change text_section. To make sure we never put
1364 anything into the old one switch to the new one now. */
1365 subseg_set (text_section
, 0);
1369 dummy_symbol
= symbol_find_or_make ("L$dummy");
1370 S_SET_SEGMENT (dummy_symbol
, text_section
);
1371 /* Force the symbol to be converted to a real symbol. */
1372 (void) symbol_get_bfdsym (dummy_symbol
);
1376 /* Assemble a single instruction storing it into a frag. */
1383 /* The had better be something to assemble. */
1386 /* If we are within a procedure definition, make sure we've
1387 defined a label for the procedure; handle case where the
1388 label was defined after the .PROC directive.
1390 Note there's not need to diddle with the segment or fragment
1391 for the label symbol in this case. We have already switched
1392 into the new $CODE$ subspace at this point. */
1393 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1395 label_symbol_struct
*label_symbol
= pa_get_label ();
1399 if (label_symbol
->lss_label
)
1401 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1402 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1405 /* Also handle allocation of a fixup to hold the unwind
1406 information when the label appears after the proc/procend. */
1407 if (within_entry_exit
)
1409 char *where
= frag_more (0);
1411 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1412 NULL
, (offsetT
) 0, NULL
,
1413 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1414 (int *)&last_call_info
->ci_unwind
.descriptor
);
1419 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1422 as_bad (_("Missing function name for .PROC"));
1425 /* Assemble the instruction. Results are saved into "the_insn". */
1428 /* Get somewhere to put the assembled instrution. */
1431 /* Output the opcode. */
1432 md_number_to_chars (to
, the_insn
.opcode
, 4);
1434 /* If necessary output more stuff. */
1435 if (the_insn
.reloc
!= R_HPPA_NONE
)
1436 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1437 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1438 the_insn
.reloc
, the_insn
.field_selector
,
1439 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1442 /* Do the real work for assembling a single instruction. Store results
1443 into the global "the_insn" variable. */
1449 char *error_message
= "";
1450 char *s
, c
, *argstart
, *name
, *save_s
;
1454 int cmpltr
, nullif
, flag
, cond
, num
;
1455 unsigned long opcode
;
1456 struct pa_opcode
*insn
;
1459 /* We must have a valid space and subspace. */
1460 pa_check_current_space_and_subspace ();
1463 /* Convert everything up to the first whitespace character into lower
1465 for (s
= str
; *s
!= ' ' && *s
!= '\t' && *s
!= '\n' && *s
!= '\0'; s
++)
1469 /* Skip to something interesting. */
1470 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1489 as_fatal (_("Unknown opcode: `%s'"), str
);
1494 /* Look up the opcode in the has table. */
1495 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1497 as_bad ("Unknown opcode: `%s'", str
);
1506 /* Mark the location where arguments for the instruction start, then
1507 start processing them. */
1511 /* Do some initialization. */
1512 opcode
= insn
->match
;
1513 memset (&the_insn
, 0, sizeof (the_insn
));
1515 the_insn
.reloc
= R_HPPA_NONE
;
1517 /* If this instruction is specific to a particular architecture,
1518 then set a new architecture. */
1519 /* But do not automatically promote to pa2.0. The automatic promotion
1520 crud is for compatability with HP's old assemblers only. */
1522 && bfd_get_mach (stdoutput
) < insn
->arch
)
1524 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1525 as_warn (_("could not update architecture and machine"));
1527 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1533 /* Build the opcode, checking as we go to make
1534 sure that the operands match. */
1535 for (args
= insn
->args
;; ++args
)
1540 /* End of arguments. */
1556 /* These must match exactly. */
1565 /* Handle a 5 bit register or control register field at 10. */
1568 num
= pa_parse_number (&s
, 0);
1569 CHECK_FIELD (num
, 31, 0, 0);
1570 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1572 /* Handle %sar or %cr11. No bits get set, we just verify that it
1575 /* Skip whitespace before register. */
1576 while (*s
== ' ' || *s
== '\t')
1579 if (!strncasecmp(s
, "%sar", 4))
1584 else if (!strncasecmp(s
, "%cr11", 5))
1591 /* Handle a 5 bit register field at 15. */
1593 num
= pa_parse_number (&s
, 0);
1594 CHECK_FIELD (num
, 31, 0, 0);
1595 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1597 /* Handle a 5 bit register field at 31. */
1600 num
= pa_parse_number (&s
, 0);
1601 CHECK_FIELD (num
, 31, 0, 0);
1602 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1604 /* Handle a 5 bit field length at 31. */
1606 num
= pa_get_absolute_expression (&the_insn
, &s
);
1608 CHECK_FIELD (num
, 32, 1, 0);
1609 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1611 /* Handle a 5 bit immediate at 15. */
1613 num
= pa_get_absolute_expression (&the_insn
, &s
);
1615 CHECK_FIELD (num
, 15, -16, 0);
1616 low_sign_unext (num
, 5, &num
);
1617 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1619 /* Handle a 5 bit immediate at 31. */
1621 num
= pa_get_absolute_expression (&the_insn
, &s
);
1623 CHECK_FIELD (num
, 15, -16, 0)
1624 low_sign_unext (num
, 5, &num
);
1625 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1627 /* Handle an unsigned 5 bit immediate at 31. */
1629 num
= pa_get_absolute_expression (&the_insn
, &s
);
1631 CHECK_FIELD (num
, 31, 0, 0);
1632 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1634 /* Handle an unsigned 5 bit immediate at 15. */
1636 num
= pa_get_absolute_expression (&the_insn
, &s
);
1638 CHECK_FIELD (num
, 31, 0, 0);
1639 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1641 /* Handle a 2 bit space identifier at 17. */
1643 num
= pa_parse_number (&s
, 0);
1644 CHECK_FIELD (num
, 3, 0, 1);
1645 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1647 /* Handle a 3 bit space identifier at 18. */
1649 num
= pa_parse_number (&s
, 0);
1650 CHECK_FIELD (num
, 7, 0, 1);
1651 dis_assemble_3 (num
, &num
);
1652 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
1654 /* Handle a completer for an indexing load or store. */
1660 while (*s
== ',' && i
< 2)
1663 if (strncasecmp (s
, "sm", 2) == 0)
1670 else if (strncasecmp (s
, "m", 1) == 0)
1672 else if (strncasecmp (s
, "s", 1) == 0)
1675 as_bad (_("Invalid Indexed Load Completer."));
1680 as_bad (_("Invalid Indexed Load Completer Syntax."));
1682 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1685 /* Handle a short load/store completer. */
1693 if (strncasecmp (s
, "ma", 2) == 0)
1698 else if (strncasecmp (s
, "mb", 2) == 0)
1704 as_bad (_("Invalid Short Load/Store Completer."));
1711 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1715 /* Handle a stbys completer. */
1721 while (*s
== ',' && i
< 2)
1724 if (strncasecmp (s
, "m", 1) == 0)
1726 else if (strncasecmp (s
, "b", 1) == 0)
1728 else if (strncasecmp (s
, "e", 1) == 0)
1731 as_bad (_("Invalid Store Bytes Short Completer"));
1736 as_bad (_("Invalid Store Bytes Short Completer"));
1738 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1741 /* Handle all conditions. */
1747 /* Handle FP compare conditions. */
1749 cond
= pa_parse_fp_cmp_cond (&s
);
1750 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
1752 /* Handle an add condition. */
1761 /* 64 bit conditions. */
1773 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1777 if (strcmp (name
, "=") == 0)
1779 else if (strcmp (name
, "<") == 0)
1781 else if (strcmp (name
, "<=") == 0)
1783 else if (strcasecmp (name
, "nuv") == 0)
1785 else if (strcasecmp (name
, "znv") == 0)
1787 else if (strcasecmp (name
, "sv") == 0)
1789 else if (strcasecmp (name
, "od") == 0)
1791 else if (strcasecmp (name
, "tr") == 0)
1796 else if (strcmp (name
, "<>") == 0)
1801 else if (strcmp (name
, ">=") == 0)
1806 else if (strcmp (name
, ">") == 0)
1811 else if (strcasecmp (name
, "uv") == 0)
1816 else if (strcasecmp (name
, "vnz") == 0)
1821 else if (strcasecmp (name
, "nsv") == 0)
1826 else if (strcasecmp (name
, "ev") == 0)
1831 /* ",*" is a valid condition. */
1832 else if (*args
== 'a')
1833 as_bad (_("Invalid Add Condition: %s"), name
);
1836 opcode
|= cmpltr
<< 13;
1837 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1839 /* Handle non-negated add and branch condition. */
1841 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1844 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
1847 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1849 /* Handle negated add and branch condition. */
1853 /* Handle wide-mode non-negated add and branch condition. */
1857 /* Handle wide-mode negated add and branch condition. */
1861 /* Handle a negated or non-negated add and branch
1865 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1869 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
1872 as_bad (_("Invalid Compare/Subtract Condition"));
1877 /* Negated condition requires an opcode change. */
1881 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1883 /* Handle branch on bit conditions. */
1901 if (strncmp (s
, "<", 1) == 0)
1906 else if (strncmp (s
, ">=", 2) == 0)
1912 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
1914 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
1916 /* Handle a compare/subtract condition. */
1925 /* 64 bit conditions. */
1937 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1941 if (strcmp (name
, "=") == 0)
1943 else if (strcmp (name
, "<") == 0)
1945 else if (strcmp (name
, "<=") == 0)
1947 else if (strcasecmp (name
, "<<") == 0)
1949 else if (strcasecmp (name
, "<<=") == 0)
1951 else if (strcasecmp (name
, "sv") == 0)
1953 else if (strcasecmp (name
, "od") == 0)
1955 else if (strcasecmp (name
, "tr") == 0)
1960 else if (strcmp (name
, "<>") == 0)
1965 else if (strcmp (name
, ">=") == 0)
1970 else if (strcmp (name
, ">") == 0)
1975 else if (strcasecmp (name
, ">>=") == 0)
1980 else if (strcasecmp (name
, ">>") == 0)
1985 else if (strcasecmp (name
, "nsv") == 0)
1990 else if (strcasecmp (name
, "ev") == 0)
1995 /* ",*" is a valid condition. */
1996 else if (*args
!= 'S')
1997 as_bad (_("Invalid Compare/Subtract Condition: %s"),
2001 opcode
|= cmpltr
<< 13;
2002 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2004 /* Handle a non-negated compare condition. */
2006 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2009 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
2012 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2014 /* Handle a negated compare condition. */
2018 /* Handle a 64 bit non-negated compare condition. */
2022 /* Handle a 64 bit negated compare condition. */
2026 /* Handle a 64 bit cmpib condition. */
2030 /* Handle a negated or non-negated compare/subtract
2034 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
2038 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
2041 as_bad (_("Invalid Compare/Subtract Condition."));
2046 /* Negated condition requires an opcode change. */
2051 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2053 /* Handle a logical instruction condition. */
2062 /* 64 bit conditions. */
2074 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2080 if (strcmp (name
, "=") == 0)
2082 else if (strcmp (name
, "<") == 0)
2084 else if (strcmp (name
, "<=") == 0)
2086 else if (strcasecmp (name
, "od") == 0)
2088 else if (strcasecmp (name
, "tr") == 0)
2093 else if (strcmp (name
, "<>") == 0)
2098 else if (strcmp (name
, ">=") == 0)
2103 else if (strcmp (name
, ">") == 0)
2108 else if (strcasecmp (name
, "ev") == 0)
2113 /* ",*" is a valid condition. */
2114 else if (*args
!= 'L')
2115 as_bad (_("Invalid Logical Instruction Condition."));
2118 opcode
|= cmpltr
<< 13;
2119 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2121 /* Handle a shift/extract/deposit condition. */
2130 /* 64 bit conditions. */
2142 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2146 if (strcmp (name
, "=") == 0)
2148 else if (strcmp (name
, "<") == 0)
2150 else if (strcasecmp (name
, "od") == 0)
2152 else if (strcasecmp (name
, "tr") == 0)
2154 else if (strcmp (name
, "<>") == 0)
2156 else if (strcmp (name
, ">=") == 0)
2158 else if (strcasecmp (name
, "ev") == 0)
2160 /* Handle movb,n. Put things back the way they were.
2161 This includes moving s back to where it started. */
2162 else if (strcasecmp (name
, "n") == 0 && *args
== 'y')
2168 /* ",*" is a valid condition. */
2169 else if (*args
!= 'X')
2170 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2173 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2175 /* Handle a unit instruction condition. */
2184 /* 64 bit conditions. */
2195 if (strncasecmp (s
, "sbz", 3) == 0)
2200 else if (strncasecmp (s
, "shz", 3) == 0)
2205 else if (strncasecmp (s
, "sdc", 3) == 0)
2210 else if (strncasecmp (s
, "sbc", 3) == 0)
2215 else if (strncasecmp (s
, "shc", 3) == 0)
2220 else if (strncasecmp (s
, "tr", 2) == 0)
2226 else if (strncasecmp (s
, "nbz", 3) == 0)
2232 else if (strncasecmp (s
, "nhz", 3) == 0)
2238 else if (strncasecmp (s
, "ndc", 3) == 0)
2244 else if (strncasecmp (s
, "nbc", 3) == 0)
2250 else if (strncasecmp (s
, "nhc", 3) == 0)
2256 /* ",*" is a valid condition. */
2257 else if (*args
!= 'U')
2258 as_bad (_("Invalid Unit Instruction Condition."));
2260 opcode
|= cmpltr
<< 13;
2261 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2269 /* Handle a system control completer. */
2271 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2279 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2281 /* Handle a nullification completer for branch instructions. */
2283 nullif
= pa_parse_nullif (&s
);
2284 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2286 /* Handle a nullification completer for copr and spop insns. */
2288 nullif
= pa_parse_nullif (&s
);
2289 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2292 /* Handle a 11 bit immediate at 31. */
2294 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2297 if (the_insn
.exp
.X_op
== O_constant
)
2299 num
= evaluate_absolute (&the_insn
);
2300 CHECK_FIELD (num
, 1023, -1024, 0);
2301 low_sign_unext (num
, 11, &num
);
2302 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2306 if (is_DP_relative (the_insn
.exp
))
2307 the_insn
.reloc
= R_HPPA_GOTOFF
;
2308 else if (is_PC_relative (the_insn
.exp
))
2309 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2311 the_insn
.reloc
= R_HPPA
;
2312 the_insn
.format
= 11;
2317 /* Handle a 14 bit immediate at 31. */
2319 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2322 if (the_insn
.exp
.X_op
== O_constant
)
2324 num
= evaluate_absolute (&the_insn
);
2325 CHECK_FIELD (num
, 8191, -8192, 0);
2326 low_sign_unext (num
, 14, &num
);
2327 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2331 if (is_DP_relative (the_insn
.exp
))
2332 the_insn
.reloc
= R_HPPA_GOTOFF
;
2333 else if (is_PC_relative (the_insn
.exp
))
2334 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2336 the_insn
.reloc
= R_HPPA
;
2337 the_insn
.format
= 14;
2341 /* Handle a 21 bit immediate at 31. */
2343 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2346 if (the_insn
.exp
.X_op
== O_constant
)
2348 num
= evaluate_absolute (&the_insn
);
2349 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
2350 dis_assemble_21 (num
, &num
);
2351 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2355 if (is_DP_relative (the_insn
.exp
))
2356 the_insn
.reloc
= R_HPPA_GOTOFF
;
2357 else if (is_PC_relative (the_insn
.exp
))
2358 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2360 the_insn
.reloc
= R_HPPA
;
2361 the_insn
.format
= 21;
2365 /* Handle a 12 bit branch displacement. */
2367 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2371 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
2373 unsigned int w1
, w
, result
;
2375 num
= evaluate_absolute (&the_insn
);
2378 as_bad (_("Branch to unaligned address"));
2381 CHECK_FIELD (num
, 8199, -8184, 0);
2382 sign_unext ((num
- 8) >> 2, 12, &result
);
2383 dis_assemble_12 (result
, &w1
, &w
);
2384 INSERT_FIELD_AND_CONTINUE (opcode
, ((w1
<< 2) | w
), 0);
2388 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2389 the_insn
.format
= 12;
2390 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2391 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2396 /* Handle a 17 bit branch displacement. */
2398 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2402 if (!the_insn
.exp
.X_add_symbol
2403 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2406 unsigned int w2
, w1
, w
, result
;
2408 num
= evaluate_absolute (&the_insn
);
2411 as_bad (_("Branch to unaligned address"));
2414 CHECK_FIELD (num
, 262143, -262144, 0);
2416 if (the_insn
.exp
.X_add_symbol
)
2419 sign_unext (num
>> 2, 17, &result
);
2420 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2421 INSERT_FIELD_AND_CONTINUE (opcode
,
2422 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2426 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2427 the_insn
.format
= 17;
2428 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2429 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2433 /* Handle an absolute 17 bit branch target. */
2435 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2439 if (!the_insn
.exp
.X_add_symbol
2440 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2443 unsigned int w2
, w1
, w
, result
;
2445 num
= evaluate_absolute (&the_insn
);
2448 as_bad (_("Branch to unaligned address"));
2451 CHECK_FIELD (num
, 262143, -262144, 0);
2453 if (the_insn
.exp
.X_add_symbol
)
2456 sign_unext (num
>> 2, 17, &result
);
2457 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2458 INSERT_FIELD_AND_CONTINUE (opcode
,
2459 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2463 the_insn
.reloc
= R_HPPA_ABS_CALL
;
2464 the_insn
.format
= 17;
2465 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2466 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2470 /* Handle a 2 bit shift count at 25. */
2472 num
= pa_get_absolute_expression (&the_insn
, &s
);
2474 CHECK_FIELD (num
, 3, 1, 0);
2475 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2477 /* Handle a 5 bit shift count at 26. */
2479 num
= pa_get_absolute_expression (&the_insn
, &s
);
2481 CHECK_FIELD (num
, 31, 0, 0);
2482 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
2484 /* Handle a 6 bit shift count at 20,22:26. */
2486 num
= pa_get_absolute_expression (&the_insn
, &s
);
2488 CHECK_FIELD (num
, 63, 0, 0);
2490 opcode
|= (num
& 0x20) << 6;
2491 INSERT_FIELD_AND_CONTINUE (opcode
, num
& 0x1f, 5);
2493 /* Handle a 5 bit bit position at 26. */
2495 num
= pa_get_absolute_expression (&the_insn
, &s
);
2497 CHECK_FIELD (num
, 31, 0, 0);
2498 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
2500 /* Handle a 5 bit immediate at 10. */
2503 num
= pa_get_absolute_expression (&the_insn
, &s
);
2504 if (the_insn
.exp
.X_op
!= O_constant
)
2507 CHECK_FIELD (num
, 31, 0, 0);
2508 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
2510 /* Handle a 9 bit immediate at 28. */
2512 num
= pa_get_absolute_expression (&the_insn
, &s
);
2514 CHECK_FIELD (num
, 511, 1, 0);
2515 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 3);
2517 /* Handle a 13 bit immediate at 18. */
2519 num
= pa_get_absolute_expression (&the_insn
, &s
);
2521 CHECK_FIELD (num
, 8191, 0, 0);
2522 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2524 /* Handle a 26 bit immediate at 31. */
2526 num
= pa_get_absolute_expression (&the_insn
, &s
);
2528 CHECK_FIELD (num
, 671108864, 0, 0);
2529 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2531 /* Handle a 3 bit SFU identifier at 25. */
2534 as_bad (_("Invalid SFU identifier"));
2535 num
= pa_get_absolute_expression (&the_insn
, &s
);
2537 CHECK_FIELD (num
, 7, 0, 0);
2538 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2540 /* Handle a 20 bit SOP field for spop0. */
2542 num
= pa_get_absolute_expression (&the_insn
, &s
);
2544 CHECK_FIELD (num
, 1048575, 0, 0);
2545 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
2546 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2548 /* Handle a 15bit SOP field for spop1. */
2550 num
= pa_get_absolute_expression (&the_insn
, &s
);
2552 CHECK_FIELD (num
, 32767, 0, 0);
2553 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
2555 /* Handle a 10bit SOP field for spop3. */
2557 num
= pa_get_absolute_expression (&the_insn
, &s
);
2559 CHECK_FIELD (num
, 1023, 0, 0);
2560 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
2561 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2563 /* Handle a 15 bit SOP field for spop2. */
2565 num
= pa_get_absolute_expression (&the_insn
, &s
);
2567 CHECK_FIELD (num
, 32767, 0, 0);
2568 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
2569 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2571 /* Handle a 3-bit co-processor ID field. */
2574 as_bad (_("Invalid COPR identifier"));
2575 num
= pa_get_absolute_expression (&the_insn
, &s
);
2577 CHECK_FIELD (num
, 7, 0, 0);
2578 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2580 /* Handle a 22bit SOP field for copr. */
2582 num
= pa_get_absolute_expression (&the_insn
, &s
);
2584 CHECK_FIELD (num
, 4194303, 0, 0);
2585 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
2586 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2589 /* Handle a source FP operand format completer. */
2591 flag
= pa_parse_fp_format (&s
);
2592 the_insn
.fpof1
= flag
;
2593 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2595 /* Handle a destination FP operand format completer. */
2597 /* pa_parse_format needs the ',' prefix. */
2599 flag
= pa_parse_fp_format (&s
);
2600 the_insn
.fpof2
= flag
;
2601 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
2603 /* Handle a source FP operand format completer at 20. */
2605 flag
= pa_parse_fp_format (&s
);
2606 the_insn
.fpof1
= flag
;
2607 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2609 /* Handle L/R register halves like 't'. */
2612 struct pa_11_fp_reg_struct result
;
2614 pa_parse_number (&s
, &result
);
2615 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2616 opcode
|= result
.number_part
;
2618 /* 0x30 opcodes are FP arithmetic operation opcodes
2619 and need to be turned into 0x38 opcodes. This
2620 is not necessary for loads/stores. */
2621 if (need_pa11_opcode (&the_insn
, &result
)
2622 && ((opcode
& 0xfc000000) == 0x30000000))
2625 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
2628 /* Handle L/R register halves like 'b'. */
2631 struct pa_11_fp_reg_struct result
;
2633 pa_parse_number (&s
, &result
);
2634 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2635 opcode
|= result
.number_part
<< 21;
2636 if (need_pa11_opcode (&the_insn
, &result
))
2638 opcode
|= (result
.l_r_select
& 1) << 7;
2644 /* Float operand 1 similar to 'b' but with l/r registers. */
2647 struct pa_11_fp_reg_struct result
;
2649 pa_parse_number (&s
, &result
);
2650 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2651 opcode
|= result
.number_part
<< 21;
2652 opcode
|= (result
.l_r_select
& 1) << 7;
2656 /* Handle L/R register halves like 'b'. */
2659 struct pa_11_fp_reg_struct result
;
2662 pa_parse_number (&s
, &result
);
2663 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2664 opcode
|= (result
.number_part
& 0x1c) << 11;
2665 opcode
|= (result
.number_part
& 0x3) << 9;
2666 opcode
|= (result
.l_r_select
& 1) << 8;
2670 /* Handle L/R register halves like 'x'. */
2673 struct pa_11_fp_reg_struct result
;
2675 pa_parse_number (&s
, &result
);
2676 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2677 opcode
|= (result
.number_part
& 0x1f) << 16;
2678 if (need_pa11_opcode (&the_insn
, &result
))
2680 opcode
|= (result
.l_r_select
& 1) << 1;
2685 /* Handle L/R register halves like 'x'. */
2688 struct pa_11_fp_reg_struct result
;
2690 pa_parse_number (&s
, &result
);
2691 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2692 opcode
|= (result
.number_part
& 0x1f) << 16;
2693 if (need_pa11_opcode (&the_insn
, &result
))
2695 opcode
|= (result
.l_r_select
& 1) << 12;
2701 /* Float operand 2, like 'x' but with l/r register halves. */
2704 struct pa_11_fp_reg_struct result
;
2706 pa_parse_number (&s
, &result
);
2707 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2708 opcode
|= (result
.number_part
& 0x1f) << 16;
2709 opcode
|= (result
.l_r_select
& 1) << 12;
2713 /* Handle a 5 bit register field at 10. */
2716 struct pa_11_fp_reg_struct result
;
2718 pa_parse_number (&s
, &result
);
2719 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2720 if (the_insn
.fpof1
== SGL
)
2722 if (result
.number_part
< 16)
2724 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2728 result
.number_part
&= 0xF;
2729 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2731 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
2734 /* Handle a 5 bit register field at 15. */
2737 struct pa_11_fp_reg_struct result
;
2739 pa_parse_number (&s
, &result
);
2740 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2741 if (the_insn
.fpof1
== SGL
)
2743 if (result
.number_part
< 16)
2745 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2748 result
.number_part
&= 0xF;
2749 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2751 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
2754 /* Handle a 5 bit register field at 31. */
2757 struct pa_11_fp_reg_struct result
;
2759 pa_parse_number (&s
, &result
);
2760 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2761 if (the_insn
.fpof1
== SGL
)
2763 if (result
.number_part
< 16)
2765 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2768 result
.number_part
&= 0xF;
2769 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2771 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
2774 /* Handle a 5 bit register field at 20. */
2777 struct pa_11_fp_reg_struct result
;
2779 pa_parse_number (&s
, &result
);
2780 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2781 if (the_insn
.fpof1
== SGL
)
2783 if (result
.number_part
< 16)
2785 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2788 result
.number_part
&= 0xF;
2789 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2791 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
2794 /* Handle a 5 bit register field at 25. */
2797 struct pa_11_fp_reg_struct result
;
2799 pa_parse_number (&s
, &result
);
2800 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2801 if (the_insn
.fpof1
== SGL
)
2803 if (result
.number_part
< 16)
2805 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2808 result
.number_part
&= 0xF;
2809 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2811 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
2814 /* Handle a floating point operand format at 26.
2815 Only allows single and double precision. */
2817 flag
= pa_parse_fp_format (&s
);
2823 the_insn
.fpof1
= flag
;
2829 as_bad (_("Invalid Floating Point Operand Format."));
2840 /* Check if the args matched. */
2843 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
2844 && !strcmp (insn
->name
, insn
[1].name
))
2852 as_bad (_("Invalid operands %s"), error_message
);
2859 the_insn
.opcode
= opcode
;
2862 /* Turn a string in input_line_pointer into a floating point constant of type
2863 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
2864 emitted is stored in *sizeP . An error message or NULL is returned. */
2866 #define MAX_LITTLENUMS 6
2869 md_atof (type
, litP
, sizeP
)
2875 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
2876 LITTLENUM_TYPE
*wordP
;
2908 return _("Bad call to MD_ATOF()");
2910 t
= atof_ieee (input_line_pointer
, type
, words
);
2912 input_line_pointer
= t
;
2913 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
2914 for (wordP
= words
; prec
--;)
2916 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
2917 litP
+= sizeof (LITTLENUM_TYPE
);
2922 /* Write out big-endian. */
2925 md_number_to_chars (buf
, val
, n
)
2930 number_to_chars_bigendian (buf
, val
, n
);
2933 /* Translate internal representation of relocation info to BFD target
2937 tc_gen_reloc (section
, fixp
)
2942 struct hppa_fix_struct
*hppa_fixp
;
2943 bfd_reloc_code_real_type code
;
2944 static arelent
*no_relocs
= NULL
;
2946 bfd_reloc_code_real_type
**codes
;
2950 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
2951 if (fixp
->fx_addsy
== 0)
2953 assert (hppa_fixp
!= 0);
2954 assert (section
!= 0);
2956 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
2958 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2959 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2960 codes
= (bfd_reloc_code_real_type
**) hppa_gen_reloc_type (stdoutput
,
2962 hppa_fixp
->fx_r_format
,
2963 hppa_fixp
->fx_r_field
,
2964 fixp
->fx_subsy
!= NULL
,
2965 symbol_get_bfdsym (fixp
->fx_addsy
));
2970 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
2973 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
2974 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
2975 for (i
= 0; i
< n_relocs
; i
++)
2976 relocs
[i
] = &reloc
[i
];
2978 relocs
[n_relocs
] = NULL
;
2981 switch (fixp
->fx_r_type
)
2984 assert (n_relocs
== 1);
2988 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2989 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2990 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2991 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2992 reloc
->addend
= 0; /* default */
2994 assert (reloc
->howto
&& code
== reloc
->howto
->type
);
2996 /* Now, do any processing that is dependent on the relocation type. */
2999 case R_PARISC_DLTREL21L
:
3000 case R_PARISC_DLTREL14R
:
3001 case R_PARISC_DLTREL14F
:
3002 case R_PARISC_PLABEL32
:
3003 case R_PARISC_PLABEL21L
:
3004 case R_PARISC_PLABEL14R
:
3005 /* For plabel relocations, the addend of the
3006 relocation should be either 0 (no static link) or 2
3007 (static link required).
3009 FIXME: We always assume no static link!
3011 We also slam a zero addend into the DLT relative relocs;
3012 it doesn't make a lot of sense to use any addend since
3013 it gets you a different (eg unknown) DLT entry. */
3017 case R_PARISC_PCREL21L
:
3018 case R_PARISC_PCREL17R
:
3019 case R_PARISC_PCREL17F
:
3020 case R_PARISC_PCREL17C
:
3021 case R_PARISC_PCREL14R
:
3022 case R_PARISC_PCREL14F
:
3023 /* The constant is stored in the instruction. */
3024 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
3027 reloc
->addend
= fixp
->fx_offset
;
3034 /* Walk over reach relocation returned by the BFD backend. */
3035 for (i
= 0; i
< n_relocs
; i
++)
3039 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3040 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3041 relocs
[i
]->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
3042 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3047 /* The only time we ever use a R_COMP2 fixup is for the difference
3048 of two symbols. With that in mind we fill in all four
3049 relocs now and break out of the loop. */
3051 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
3052 relocs
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[0]);
3053 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3054 relocs
[0]->addend
= 0;
3055 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3056 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3057 relocs
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[1]);
3058 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3059 relocs
[1]->addend
= 0;
3060 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3061 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
3062 relocs
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[2]);
3063 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3064 relocs
[2]->addend
= 0;
3065 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
3066 relocs
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[3]);
3067 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3068 relocs
[3]->addend
= 0;
3069 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
3070 relocs
[4]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[4]);
3071 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3072 relocs
[4]->addend
= 0;
3076 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
3082 /* For plabel relocations, the addend of the
3083 relocation should be either 0 (no static link) or 2
3084 (static link required).
3086 FIXME: We always assume no static link!
3088 We also slam a zero addend into the DLT relative relocs;
3089 it doesn't make a lot of sense to use any addend since
3090 it gets you a different (eg unknown) DLT entry. */
3091 relocs
[i
]->addend
= 0;
3106 /* There is no symbol or addend associated with these fixups. */
3107 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3108 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
3109 relocs
[i
]->addend
= 0;
3115 /* There is no symbol associated with these fixups. */
3116 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3117 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
3118 relocs
[i
]->addend
= fixp
->fx_offset
;
3122 relocs
[i
]->addend
= fixp
->fx_offset
;
3132 /* Process any machine dependent frag types. */
3135 md_convert_frag (abfd
, sec
, fragP
)
3137 register asection
*sec
;
3138 register fragS
*fragP
;
3140 unsigned int address
;
3142 if (fragP
->fr_type
== rs_machine_dependent
)
3144 switch ((int) fragP
->fr_subtype
)
3147 fragP
->fr_type
= rs_fill
;
3148 know (fragP
->fr_var
== 1);
3149 know (fragP
->fr_next
);
3150 address
= fragP
->fr_address
+ fragP
->fr_fix
;
3151 if (address
% fragP
->fr_offset
)
3154 fragP
->fr_next
->fr_address
3159 fragP
->fr_offset
= 0;
3165 /* Round up a section size to the appropriate boundary. */
3168 md_section_align (segment
, size
)
3172 int align
= bfd_get_section_alignment (stdoutput
, segment
);
3173 int align2
= (1 << align
) - 1;
3175 return (size
+ align2
) & ~align2
;
3178 /* Return the approximate size of a frag before relaxation has occurred. */
3180 md_estimate_size_before_relax (fragP
, segment
)
3181 register fragS
*fragP
;
3188 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
3194 CONST
char *md_shortopts
= "";
3195 struct option md_longopts
[] = {
3196 {NULL
, no_argument
, NULL
, 0}
3198 size_t md_longopts_size
= sizeof(md_longopts
);
3201 md_parse_option (c
, arg
)
3209 md_show_usage (stream
)
3214 /* We have no need to default values of symbols. */
3217 md_undefined_symbol (name
)
3223 /* Apply a fixup to an instruction. */
3226 md_apply_fix (fixP
, valp
)
3230 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
3231 struct hppa_fix_struct
*hppa_fixP
;
3232 long new_val
, result
= 0;
3233 unsigned int w1
, w2
, w
, resulti
;
3235 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
3236 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
3237 never be "applied" (they are just markers). Likewise for
3238 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
3240 if (fixP
->fx_r_type
== R_HPPA_ENTRY
3241 || fixP
->fx_r_type
== R_HPPA_EXIT
3242 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
3243 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
3244 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
3247 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
3248 fixups are considered not adjustable, which in turn causes
3249 adjust_reloc_syms to not set fx_offset. Ugh. */
3250 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
3252 fixP
->fx_offset
= *valp
;
3257 /* There should have been an HPPA specific fixup associated
3258 with the GAS fixup. */
3261 unsigned long buf_wd
= bfd_get_32 (stdoutput
, buf
);
3262 unsigned char fmt
= bfd_hppa_insn2fmt (buf_wd
);
3264 /* If there is a symbol associated with this fixup, then it's something
3265 which will need a SOM relocation (except for some PC-relative relocs).
3266 In such cases we should treat the "val" or "addend" as zero since it
3267 will be added in as needed from fx_offset in tc_gen_reloc. */
3268 if ((fixP
->fx_addsy
!= NULL
3269 || fixP
->fx_r_type
== R_HPPA_NONE
)
3274 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3276 /* These field selectors imply that we do not want an addend. */
3277 else if (hppa_fixP
->fx_r_field
== e_psel
3278 || hppa_fixP
->fx_r_field
== e_rpsel
3279 || hppa_fixP
->fx_r_field
== e_lpsel
3280 || hppa_fixP
->fx_r_field
== e_tsel
3281 || hppa_fixP
->fx_r_field
== e_rtsel
3282 || hppa_fixP
->fx_r_field
== e_ltsel
)
3283 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3284 /* This is truely disgusting. The machine independent code blindly
3285 adds in the value of the symbol being relocated against. Damn! */
3287 && fixP
->fx_addsy
!= NULL
3288 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
3289 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
3290 0, hppa_fixP
->fx_r_field
);
3293 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3295 /* Handle pc-relative exceptions from above. */
3296 #define arg_reloc_stub_needed(CALLER, CALLEE) \
3297 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
3298 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
3302 && !arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
3303 symbol_get_bfdsym (fixP
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
3304 hppa_fixP
->fx_arg_reloc
)
3306 && (((int)(*valp
) > -262144 && (int)(*valp
) < 262143) && fmt
!= 22)
3307 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
3309 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
3311 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3312 #undef arg_reloc_stub_needed
3316 /* Handle all opcodes with the 'j' operand type. */
3318 CHECK_FIELD (new_val
, 8191, -8192, 0);
3320 /* Mask off 14 bits to be changed. */
3321 bfd_put_32 (stdoutput
,
3322 bfd_get_32 (stdoutput
, buf
) & 0xffffc000,
3324 low_sign_unext (new_val
, 14, &resulti
);
3328 /* Handle all opcodes with the 'k' operand type. */
3330 CHECK_FIELD (new_val
, 2097152, 0, 0);
3332 /* Mask off 21 bits to be changed. */
3333 bfd_put_32 (stdoutput
,
3334 bfd_get_32 (stdoutput
, buf
) & 0xffe00000,
3336 dis_assemble_21 (new_val
, &resulti
);
3340 /* Handle all the opcodes with the 'i' operand type. */
3342 CHECK_FIELD (new_val
, 1023, -1023, 0);
3344 /* Mask off 11 bits to be changed. */
3345 bfd_put_32 (stdoutput
,
3346 bfd_get_32 (stdoutput
, buf
) & 0xffff800,
3348 low_sign_unext (new_val
, 11, &resulti
);
3352 /* Handle all the opcodes with the 'w' operand type. */
3354 CHECK_FIELD (new_val
, 8199, -8184, 0);
3356 /* Mask off 11 bits to be changed. */
3357 sign_unext ((new_val
- 8) >> 2, 12, &resulti
);
3358 bfd_put_32 (stdoutput
,
3359 bfd_get_32 (stdoutput
, buf
) & 0xffffe002,
3362 dis_assemble_12 (resulti
, &w1
, &w
);
3363 result
= ((w1
<< 2) | w
);
3366 /* Handle some of the opcodes with the 'W' operand type. */
3369 int distance
= *valp
;
3371 CHECK_FIELD (new_val
, 262143, -262144, 0);
3373 /* If this is an absolute branch (ie no link) with an out of
3374 range target, then we want to complain. */
3375 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
3376 && (distance
> 262143 || distance
< -262144)
3377 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
3378 CHECK_FIELD (distance
, 262143, -262144, 0);
3380 /* Mask off 17 bits to be changed. */
3381 bfd_put_32 (stdoutput
,
3382 bfd_get_32 (stdoutput
, buf
) & 0xffe0e002,
3384 sign_unext ((new_val
- 8) >> 2, 17, &resulti
);
3385 dis_assemble_17 (resulti
, &w1
, &w2
, &w
);
3386 result
= ((w2
<< 2) | (w1
<< 16) | w
);
3392 bfd_put_32 (stdoutput
, new_val
, buf
);
3396 as_bad (_("Unknown relocation encountered in md_apply_fix."));
3400 /* Insert the relocation. */
3401 bfd_put_32 (stdoutput
, bfd_get_32 (stdoutput
, buf
) | result
, buf
);
3406 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
3407 (unsigned int) fixP
, fixP
->fx_r_type
);
3412 /* Exactly what point is a PC-relative offset relative TO?
3413 On the PA, they're relative to the address of the offset. */
3416 md_pcrel_from (fixP
)
3419 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
3422 /* Return nonzero if the input line pointer is at the end of
3426 is_end_of_statement ()
3428 return ((*input_line_pointer
== '\n')
3429 || (*input_line_pointer
== ';')
3430 || (*input_line_pointer
== '!'));
3433 /* Read a number from S. The number might come in one of many forms,
3434 the most common will be a hex or decimal constant, but it could be
3435 a pre-defined register (Yuk!), or an absolute symbol.
3437 Return a number or -1 for failure.
3439 When parsing PA-89 FP register numbers RESULT will be
3440 the address of a structure to return information about
3441 L/R half of FP registers, store results there as appropriate.
3443 pa_parse_number can not handle negative constants and will fail
3444 horribly if it is passed such a constant. */
3447 pa_parse_number (s
, result
)
3449 struct pa_11_fp_reg_struct
*result
;
3458 /* Skip whitespace before the number. */
3459 while (*p
== ' ' || *p
== '\t')
3462 /* Store info in RESULT if requested by caller. */
3465 result
->number_part
= -1;
3466 result
->l_r_select
= -1;
3472 /* Looks like a number. */
3475 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
3477 /* The number is specified in hex. */
3479 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
3480 || ((*p
>= 'A') && (*p
<= 'F')))
3483 num
= num
* 16 + *p
- '0';
3484 else if (*p
>= 'a' && *p
<= 'f')
3485 num
= num
* 16 + *p
- 'a' + 10;
3487 num
= num
* 16 + *p
- 'A' + 10;
3493 /* The number is specified in decimal. */
3494 while (isdigit (*p
))
3496 num
= num
* 10 + *p
- '0';
3501 /* Store info in RESULT if requested by the caller. */
3504 result
->number_part
= num
;
3506 if (IS_R_SELECT (p
))
3508 result
->l_r_select
= 1;
3511 else if (IS_L_SELECT (p
))
3513 result
->l_r_select
= 0;
3517 result
->l_r_select
= 0;
3522 /* The number might be a predefined register. */
3527 /* Tege hack: Special case for general registers as the general
3528 code makes a binary search with case translation, and is VERY
3533 if (*p
== 'e' && *(p
+ 1) == 't'
3534 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
3537 num
= *p
- '0' + 28;
3545 else if (!isdigit (*p
))
3548 as_bad (_("Undefined register: '%s'."), name
);
3554 num
= num
* 10 + *p
++ - '0';
3555 while (isdigit (*p
));
3560 /* Do a normal register search. */
3561 while (is_part_of_name (c
))
3567 status
= reg_name_search (name
);
3573 as_bad (_("Undefined register: '%s'."), name
);
3579 /* Store info in RESULT if requested by caller. */
3582 result
->number_part
= num
;
3583 if (IS_R_SELECT (p
- 1))
3584 result
->l_r_select
= 1;
3585 else if (IS_L_SELECT (p
- 1))
3586 result
->l_r_select
= 0;
3588 result
->l_r_select
= 0;
3593 /* And finally, it could be a symbol in the absolute section which
3594 is effectively a constant. */
3598 while (is_part_of_name (c
))
3604 if ((sym
= symbol_find (name
)) != NULL
)
3606 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
3607 num
= S_GET_VALUE (sym
);
3611 as_bad (_("Non-absolute symbol: '%s'."), name
);
3617 /* There is where we'd come for an undefined symbol
3618 or for an empty string. For an empty string we
3619 will return zero. That's a concession made for
3620 compatability with the braindamaged HP assemblers. */
3626 as_bad (_("Undefined absolute constant: '%s'."), name
);
3632 /* Store info in RESULT if requested by caller. */
3635 result
->number_part
= num
;
3636 if (IS_R_SELECT (p
- 1))
3637 result
->l_r_select
= 1;
3638 else if (IS_L_SELECT (p
- 1))
3639 result
->l_r_select
= 0;
3641 result
->l_r_select
= 0;
3649 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
3651 /* Given NAME, find the register number associated with that name, return
3652 the integer value associated with the given name or -1 on failure. */
3655 reg_name_search (name
)
3658 int middle
, low
, high
;
3662 high
= REG_NAME_CNT
- 1;
3666 middle
= (low
+ high
) / 2;
3667 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
3673 return pre_defined_registers
[middle
].value
;
3675 while (low
<= high
);
3681 /* Return nonzero if the given INSN and L/R information will require
3682 a new PA-1.1 opcode. */
3685 need_pa11_opcode (insn
, result
)
3687 struct pa_11_fp_reg_struct
*result
;
3689 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
3691 /* If this instruction is specific to a particular architecture,
3692 then set a new architecture. */
3693 if (bfd_get_mach (stdoutput
) < pa11
)
3695 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
3696 as_warn (_("could not update architecture and machine"));
3704 /* Parse a condition for a fcmp instruction. Return the numerical
3705 code associated with the condition. */
3708 pa_parse_fp_cmp_cond (s
)
3715 for (i
= 0; i
< 32; i
++)
3717 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
3718 strlen (fp_cond_map
[i
].string
)) == 0)
3720 cond
= fp_cond_map
[i
].cond
;
3721 *s
+= strlen (fp_cond_map
[i
].string
);
3722 /* If not a complete match, back up the input string and
3724 if (**s
!= ' ' && **s
!= '\t')
3726 *s
-= strlen (fp_cond_map
[i
].string
);
3729 while (**s
== ' ' || **s
== '\t')
3735 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
3737 /* Advance over the bogus completer. */
3738 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3745 /* Parse an FP operand format completer returning the completer
3748 static fp_operand_format
3749 pa_parse_fp_format (s
)
3758 if (strncasecmp (*s
, "sgl", 3) == 0)
3763 else if (strncasecmp (*s
, "dbl", 3) == 0)
3768 else if (strncasecmp (*s
, "quad", 4) == 0)
3775 format
= ILLEGAL_FMT
;
3776 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
3783 /* Convert from a selector string into a selector type. */
3786 pa_chk_field_selector (str
)
3789 int middle
, low
, high
;
3793 /* Read past any whitespace. */
3794 /* FIXME: should we read past newlines and formfeeds??? */
3795 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
3798 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
3799 name
[0] = tolower ((*str
)[0]),
3801 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
3802 name
[0] = tolower ((*str
)[0]),
3803 name
[1] = tolower ((*str
)[1]),
3805 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
3806 name
[0] = tolower ((*str
)[0]),
3807 name
[1] = tolower ((*str
)[1]),
3808 name
[2] = tolower ((*str
)[2]),
3814 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
3818 middle
= (low
+ high
) / 2;
3819 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
3826 *str
+= strlen (name
) + 1;
3828 if (selector_table
[middle
].field_selector
== e_nsel
)
3831 return selector_table
[middle
].field_selector
;
3834 while (low
<= high
);
3839 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
3842 get_expression (str
)
3848 save_in
= input_line_pointer
;
3849 input_line_pointer
= str
;
3850 seg
= expression (&the_insn
.exp
);
3851 if (!(seg
== absolute_section
3852 || seg
== undefined_section
3853 || SEG_NORMAL (seg
)))
3855 as_warn (_("Bad segment in expression."));
3856 expr_end
= input_line_pointer
;
3857 input_line_pointer
= save_in
;
3860 expr_end
= input_line_pointer
;
3861 input_line_pointer
= save_in
;
3865 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
3867 pa_get_absolute_expression (insn
, strp
)
3873 insn
->field_selector
= pa_chk_field_selector (strp
);
3874 save_in
= input_line_pointer
;
3875 input_line_pointer
= *strp
;
3876 expression (&insn
->exp
);
3877 /* This is not perfect, but is a huge improvement over doing nothing.
3879 The PA assembly syntax is ambigious in a variety of ways. Consider
3880 this string "4 %r5" Is that the number 4 followed by the register
3881 r5, or is that 4 MOD 5?
3883 If we get a modulo expresion When looking for an absolute, we try
3884 again cutting off the input string at the first whitespace character. */
3885 if (insn
->exp
.X_op
== O_modulus
)
3890 input_line_pointer
= *strp
;
3892 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
3898 retval
= pa_get_absolute_expression (insn
, strp
);
3900 input_line_pointer
= save_in
;
3902 return evaluate_absolute (insn
);
3904 if (insn
->exp
.X_op
!= O_constant
)
3906 as_bad (_("Bad segment (should be absolute)."));
3907 expr_end
= input_line_pointer
;
3908 input_line_pointer
= save_in
;
3911 expr_end
= input_line_pointer
;
3912 input_line_pointer
= save_in
;
3913 return evaluate_absolute (insn
);
3916 /* Evaluate an absolute expression EXP which may be modified by
3917 the selector FIELD_SELECTOR. Return the value of the expression. */
3919 evaluate_absolute (insn
)
3924 int field_selector
= insn
->field_selector
;
3927 value
= exp
.X_add_number
;
3929 switch (field_selector
)
3935 /* If bit 21 is on then add 0x800 and arithmetic shift right 11 bits. */
3937 if (value
& 0x00000400)
3939 value
= (value
& 0xfffff800) >> 11;
3942 /* Sign extend from bit 21. */
3944 if (value
& 0x00000400)
3945 value
|= 0xfffff800;
3950 /* Arithmetic shift right 11 bits. */
3952 value
= (value
& 0xfffff800) >> 11;
3955 /* Set bits 0-20 to zero. */
3957 value
= value
& 0x7ff;
3960 /* Add 0x800 and arithmetic shift right 11 bits. */
3963 value
= (value
& 0xfffff800) >> 11;
3966 /* Set bitgs 0-21 to one. */
3968 value
|= 0xfffff800;
3971 #define RSEL_ROUND(c) (((c) + 0x1000) & ~0x1fff)
3973 value
= (RSEL_ROUND (value
) & 0x7ff) + (value
- RSEL_ROUND (value
));
3977 value
= (RSEL_ROUND (value
) >> 11) & 0x1fffff;
3982 BAD_CASE (field_selector
);
3988 /* Given an argument location specification return the associated
3989 argument location number. */
3992 pa_build_arg_reloc (type_name
)
3996 if (strncasecmp (type_name
, "no", 2) == 0)
3998 if (strncasecmp (type_name
, "gr", 2) == 0)
4000 else if (strncasecmp (type_name
, "fr", 2) == 0)
4002 else if (strncasecmp (type_name
, "fu", 2) == 0)
4005 as_bad (_("Invalid argument location: %s\n"), type_name
);
4010 /* Encode and return an argument relocation specification for
4011 the given register in the location specified by arg_reloc. */
4014 pa_align_arg_reloc (reg
, arg_reloc
)
4016 unsigned int arg_reloc
;
4018 unsigned int new_reloc
;
4020 new_reloc
= arg_reloc
;
4036 as_bad (_("Invalid argument description: %d"), reg
);
4042 /* Parse a PA nullification completer (,n). Return nonzero if the
4043 completer was found; return zero if no completer was found. */
4055 if (strncasecmp (*s
, "n", 1) == 0)
4059 as_bad (_("Invalid Nullification: (%c)"), **s
);
4068 /* Parse a non-negated compare/subtract completer returning the
4069 number (for encoding in instrutions) of the given completer.
4071 ISBRANCH specifies whether or not this is parsing a condition
4072 completer for a branch (vs a nullification completer for a
4073 computational instruction. */
4076 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
4081 char *name
= *s
+ 1;
4090 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4096 if (strcmp (name
, "=") == 0)
4100 else if (strcmp (name
, "<") == 0)
4104 else if (strcmp (name
, "<=") == 0)
4108 else if (strcmp (name
, "<<") == 0)
4112 else if (strcmp (name
, "<<=") == 0)
4116 else if (strcasecmp (name
, "sv") == 0)
4120 else if (strcasecmp (name
, "od") == 0)
4124 /* If we have something like addb,n then there is no condition
4126 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4138 /* Reset pointers if this was really a ,n for a branch instruction. */
4146 /* Parse a negated compare/subtract completer returning the
4147 number (for encoding in instrutions) of the given completer.
4149 ISBRANCH specifies whether or not this is parsing a condition
4150 completer for a branch (vs a nullification completer for a
4151 computational instruction. */
4154 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
4159 char *name
= *s
+ 1;
4168 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4174 if (strcasecmp (name
, "tr") == 0)
4178 else if (strcmp (name
, "<>") == 0)
4182 else if (strcmp (name
, ">=") == 0)
4186 else if (strcmp (name
, ">") == 0)
4190 else if (strcmp (name
, ">>=") == 0)
4194 else if (strcmp (name
, ">>") == 0)
4198 else if (strcasecmp (name
, "nsv") == 0)
4202 else if (strcasecmp (name
, "ev") == 0)
4206 /* If we have something like addb,n then there is no condition
4208 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4220 /* Reset pointers if this was really a ,n for a branch instruction. */
4229 /* Parse a non-negated addition completer returning the number
4230 (for encoding in instrutions) of the given completer.
4232 ISBRANCH specifies whether or not this is parsing a condition
4233 completer for a branch (vs a nullification completer for a
4234 computational instruction. */
4237 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
4242 char *name
= *s
+ 1;
4250 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4254 if (strcmp (name
, "=") == 0)
4258 else if (strcmp (name
, "<") == 0)
4262 else if (strcmp (name
, "<=") == 0)
4266 else if (strcasecmp (name
, "nuv") == 0)
4270 else if (strcasecmp (name
, "znv") == 0)
4274 else if (strcasecmp (name
, "sv") == 0)
4278 else if (strcasecmp (name
, "od") == 0)
4282 /* If we have something like addb,n then there is no condition
4284 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4295 /* Reset pointers if this was really a ,n for a branch instruction. */
4296 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4302 /* Parse a negated addition completer returning the number
4303 (for encoding in instrutions) of the given completer.
4305 ISBRANCH specifies whether or not this is parsing a condition
4306 completer for a branch (vs a nullification completer for a
4307 computational instruction). */
4310 pa_parse_neg_add_cmpltr (s
, isbranch
)
4315 char *name
= *s
+ 1;
4323 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4327 if (strcasecmp (name
, "tr") == 0)
4331 else if (strcmp (name
, "<>") == 0)
4335 else if (strcmp (name
, ">=") == 0)
4339 else if (strcmp (name
, ">") == 0)
4343 else if (strcasecmp (name
, "uv") == 0)
4347 else if (strcasecmp (name
, "vnz") == 0)
4351 else if (strcasecmp (name
, "nsv") == 0)
4355 else if (strcasecmp (name
, "ev") == 0)
4359 /* If we have something like addb,n then there is no condition
4361 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4372 /* Reset pointers if this was really a ,n for a branch instruction. */
4373 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4380 /* Handle an alignment directive. Special so that we can update the
4381 alignment of the subspace if necessary. */
4385 /* We must have a valid space and subspace. */
4386 pa_check_current_space_and_subspace ();
4388 /* Let the generic gas code do most of the work. */
4389 s_align_bytes (bytes
);
4391 /* If bytes is a power of 2, then update the current subspace's
4392 alignment if necessary. */
4393 if (log2 (bytes
) != -1)
4394 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
4398 /* Handle a .BLOCK type pseudo-op. */
4406 unsigned int temp_size
;
4410 /* We must have a valid space and subspace. */
4411 pa_check_current_space_and_subspace ();
4414 temp_size
= get_absolute_expression ();
4416 /* Always fill with zeros, that's what the HP assembler does. */
4419 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
4420 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
4421 memset (p
, 0, temp_size
);
4423 /* Convert 2 bytes at a time. */
4425 for (i
= 0; i
< temp_size
; i
+= 2)
4427 md_number_to_chars (p
+ i
,
4429 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
4432 pa_undefine_label ();
4433 demand_empty_rest_of_line ();
4436 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
4444 /* The BRTAB relocations are only availble in SOM (to denote
4445 the beginning and end of branch tables). */
4446 char *where
= frag_more (0);
4448 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4449 NULL
, (offsetT
) 0, NULL
,
4450 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
4451 e_fsel
, 0, 0, NULL
);
4454 demand_empty_rest_of_line ();
4457 /* Handle a .begin_try and .end_try pseudo-op. */
4465 char *where
= frag_more (0);
4470 /* The TRY relocations are only availble in SOM (to denote
4471 the beginning and end of exception handling regions). */
4473 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4474 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
4475 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
4476 e_fsel
, 0, 0, NULL
);
4479 demand_empty_rest_of_line ();
4482 /* Handle a .CALL pseudo-op. This involves storing away information
4483 about where arguments are to be found so the linker can detect
4484 (and correct) argument location mismatches between caller and callee. */
4491 /* We must have a valid space and subspace. */
4492 pa_check_current_space_and_subspace ();
4495 pa_call_args (&last_call_desc
);
4496 demand_empty_rest_of_line ();
4499 /* Do the dirty work of building a call descriptor which describes
4500 where the caller placed arguments to a function call. */
4503 pa_call_args (call_desc
)
4504 struct call_desc
*call_desc
;
4507 unsigned int temp
, arg_reloc
;
4509 while (!is_end_of_statement ())
4511 name
= input_line_pointer
;
4512 c
= get_symbol_end ();
4513 /* Process a source argument. */
4514 if ((strncasecmp (name
, "argw", 4) == 0))
4516 temp
= atoi (name
+ 4);
4517 p
= input_line_pointer
;
4519 input_line_pointer
++;
4520 name
= input_line_pointer
;
4521 c
= get_symbol_end ();
4522 arg_reloc
= pa_build_arg_reloc (name
);
4523 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
4525 /* Process a return value. */
4526 else if ((strncasecmp (name
, "rtnval", 6) == 0))
4528 p
= input_line_pointer
;
4530 input_line_pointer
++;
4531 name
= input_line_pointer
;
4532 c
= get_symbol_end ();
4533 arg_reloc
= pa_build_arg_reloc (name
);
4534 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
4538 as_bad (_("Invalid .CALL argument: %s"), name
);
4540 p
= input_line_pointer
;
4542 if (!is_end_of_statement ())
4543 input_line_pointer
++;
4547 /* Return TRUE if FRAG1 and FRAG2 are the same. */
4550 is_same_frag (frag1
, frag2
)
4557 else if (frag2
== NULL
)
4559 else if (frag1
== frag2
)
4561 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
4562 return (is_same_frag (frag1
, frag2
->fr_next
));
4568 /* Build an entry in the UNWIND subspace from the given function
4569 attributes in CALL_INFO. This is not needed for SOM as using
4570 R_ENTRY and R_EXIT relocations allow the linker to handle building
4571 of the unwind spaces. */
4574 pa_build_unwind_subspace (call_info
)
4575 struct call_info
*call_info
;
4578 asection
*seg
, *save_seg
;
4580 subsegT subseg
, save_subseg
;
4584 if (bfd_get_arch_info (stdoutput
)->bits_per_address
== 32)
4585 reloc
= R_PARISC_DIR32
;
4587 reloc
= R_PARISC_SEGREL32
;
4589 /* Get into the right seg/subseg. This may involve creating
4590 the seg the first time through. Make sure to have the
4591 old seg/subseg so that we can reset things when we are done. */
4592 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
4593 if (seg
== ASEC_NULL
)
4595 seg
= bfd_make_section_old_way (stdoutput
, UNWIND_SECTION_NAME
);
4596 bfd_set_section_flags (stdoutput
, seg
,
4597 SEC_READONLY
| SEC_HAS_CONTENTS
4598 | SEC_LOAD
| SEC_RELOC
| SEC_ALLOC
| SEC_DATA
);
4599 bfd_set_section_alignment (stdoutput
, seg
, 2);
4603 save_subseg
= now_subseg
;
4604 subseg_set (seg
, 0);
4607 /* Get some space to hold relocation information for the unwind
4610 md_number_to_chars (p
, 0, 4);
4612 /* Relocation info. for start offset of the function. */
4613 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4614 call_info
->start_symbol
, (offsetT
) 0,
4615 (expressionS
*) NULL
, 0, reloc
,
4616 e_fsel
, 32, 0, NULL
);
4619 md_number_to_chars (p
, 0, 4);
4621 /* Relocation info. for end offset of the function.
4623 Because we allow reductions of 32bit relocations for ELF, this will be
4624 reduced to section_sym + offset which avoids putting the temporary
4625 symbol into the symbol table. It (should) end up giving the same
4626 value as call_info->start_symbol + function size once the linker is
4627 finished with its work. */
4629 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4630 call_info
->end_symbol
, (offsetT
) 0,
4631 (expressionS
*) NULL
, 0, reloc
,
4632 e_fsel
, 32, 0, NULL
);
4635 unwind
= (char *) &call_info
->ci_unwind
;
4636 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
4640 FRAG_APPEND_1_CHAR (c
);
4644 /* Return back to the original segment/subsegment. */
4645 subseg_set (save_seg
, save_subseg
);
4649 /* Process a .CALLINFO pseudo-op. This information is used later
4650 to build unwind descriptors and maybe one day to support
4651 .ENTER and .LEAVE. */
4654 pa_callinfo (unused
)
4661 /* We must have a valid space and subspace. */
4662 pa_check_current_space_and_subspace ();
4665 /* .CALLINFO must appear within a procedure definition. */
4666 if (!within_procedure
)
4667 as_bad (_(".callinfo is not within a procedure definition"));
4669 /* Mark the fact that we found the .CALLINFO for the
4670 current procedure. */
4671 callinfo_found
= TRUE
;
4673 /* Iterate over the .CALLINFO arguments. */
4674 while (!is_end_of_statement ())
4676 name
= input_line_pointer
;
4677 c
= get_symbol_end ();
4678 /* Frame size specification. */
4679 if ((strncasecmp (name
, "frame", 5) == 0))
4681 p
= input_line_pointer
;
4683 input_line_pointer
++;
4684 temp
= get_absolute_expression ();
4685 if ((temp
& 0x3) != 0)
4687 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
4691 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
4692 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
4695 /* Entry register (GR, GR and SR) specifications. */
4696 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
4698 p
= input_line_pointer
;
4700 input_line_pointer
++;
4701 temp
= get_absolute_expression ();
4702 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
4703 even though %r19 is caller saved. I think this is a bug in
4704 the HP assembler, and we are not going to emulate it. */
4705 if (temp
< 3 || temp
> 18)
4706 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
4707 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
4709 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
4711 p
= input_line_pointer
;
4713 input_line_pointer
++;
4714 temp
= get_absolute_expression ();
4715 /* Similarly the HP assembler takes 31 as the high bound even
4716 though %fr21 is the last callee saved floating point register. */
4717 if (temp
< 12 || temp
> 21)
4718 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
4719 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
4721 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
4723 p
= input_line_pointer
;
4725 input_line_pointer
++;
4726 temp
= get_absolute_expression ();
4728 as_bad (_("Value for ENTRY_SR must be 3\n"));
4730 /* Note whether or not this function performs any calls. */
4731 else if ((strncasecmp (name
, "calls", 5) == 0) ||
4732 (strncasecmp (name
, "caller", 6) == 0))
4734 p
= input_line_pointer
;
4737 else if ((strncasecmp (name
, "no_calls", 8) == 0))
4739 p
= input_line_pointer
;
4742 /* Should RP be saved into the stack. */
4743 else if ((strncasecmp (name
, "save_rp", 7) == 0))
4745 p
= input_line_pointer
;
4747 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
4749 /* Likewise for SP. */
4750 else if ((strncasecmp (name
, "save_sp", 7) == 0))
4752 p
= input_line_pointer
;
4754 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
4756 /* Is this an unwindable procedure. If so mark it so
4757 in the unwind descriptor. */
4758 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
4760 p
= input_line_pointer
;
4762 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
4764 /* Is this an interrupt routine. If so mark it in the
4765 unwind descriptor. */
4766 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
4768 p
= input_line_pointer
;
4770 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
4772 /* Is this a millicode routine. "millicode" isn't in my
4773 assembler manual, but my copy is old. The HP assembler
4774 accepts it, and there's a place in the unwind descriptor
4775 to drop the information, so we'll accept it too. */
4776 else if ((strncasecmp (name
, "millicode", 9) == 0))
4778 p
= input_line_pointer
;
4780 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
4784 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
4785 *input_line_pointer
= c
;
4787 if (!is_end_of_statement ())
4788 input_line_pointer
++;
4791 demand_empty_rest_of_line ();
4794 /* Switch into the code subspace. */
4801 current_space
= is_defined_space ("$TEXT$");
4803 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
4806 pa_undefine_label ();
4809 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
4810 the .comm pseudo-op has the following symtax:
4812 <label> .comm <length>
4814 where <label> is optional and is a symbol whose address will be the start of
4815 a block of memory <length> bytes long. <length> must be an absolute
4816 expression. <length> bytes will be allocated in the current space
4819 Also note the label may not even be on the same line as the .comm.
4821 This difference in syntax means the colon function will be called
4822 on the symbol before we arrive in pa_comm. colon will set a number
4823 of attributes of the symbol that need to be fixed here. In particular
4824 the value, section pointer, fragment pointer, flags, etc. What
4827 This also makes error detection all but impossible. */
4835 label_symbol_struct
*label_symbol
= pa_get_label ();
4838 symbol
= label_symbol
->lss_label
;
4843 size
= get_absolute_expression ();
4847 S_SET_VALUE (symbol
, size
);
4848 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
4849 S_SET_EXTERNAL (symbol
);
4851 /* colon() has already set the frag to the current location in the
4852 current subspace; we need to reset the fragment to the zero address
4853 fragment. We also need to reset the segment pointer. */
4854 symbol_set_frag (symbol
, &zero_address_frag
);
4856 demand_empty_rest_of_line ();
4859 /* Process a .END pseudo-op. */
4865 demand_empty_rest_of_line ();
4868 /* Process a .ENTER pseudo-op. This is not supported. */
4874 /* We must have a valid space and subspace. */
4875 pa_check_current_space_and_subspace ();
4878 as_bad (_("The .ENTER pseudo-op is not supported"));
4879 demand_empty_rest_of_line ();
4882 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
4889 /* We must have a valid space and subspace. */
4890 pa_check_current_space_and_subspace ();
4893 if (!within_procedure
)
4894 as_bad (_("Misplaced .entry. Ignored."));
4897 if (!callinfo_found
)
4898 as_bad (_("Missing .callinfo."));
4900 demand_empty_rest_of_line ();
4901 within_entry_exit
= TRUE
;
4904 /* SOM defers building of unwind descriptors until the link phase.
4905 The assembler is responsible for creating an R_ENTRY relocation
4906 to mark the beginning of a region and hold the unwind bits, and
4907 for creating an R_EXIT relocation to mark the end of the region.
4909 FIXME. ELF should be using the same conventions! The problem
4910 is an unwind requires too much relocation space. Hmmm. Maybe
4911 if we split the unwind bits up between the relocations which
4912 denote the entry and exit points. */
4913 if (last_call_info
->start_symbol
!= NULL
)
4915 char *where
= frag_more (0);
4917 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4918 NULL
, (offsetT
) 0, NULL
,
4919 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
4920 (int *) &last_call_info
->ci_unwind
.descriptor
);
4925 /* Handle a .EQU pseudo-op. */
4931 label_symbol_struct
*label_symbol
= pa_get_label ();
4936 symbol
= label_symbol
->lss_label
;
4938 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
4940 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
4941 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
4946 as_bad (_(".REG must use a label"));
4948 as_bad (_(".EQU must use a label"));
4951 pa_undefine_label ();
4952 demand_empty_rest_of_line ();
4955 /* Helper function. Does processing for the end of a function. This
4956 usually involves creating some relocations or building special
4957 symbols to mark the end of the function. */
4964 where
= frag_more (0);
4967 /* Mark the end of the function, stuff away the location of the frag
4968 for the end of the function, and finally call pa_build_unwind_subspace
4969 to add an entry in the unwind table. */
4970 hppa_elf_mark_end_of_function ();
4971 pa_build_unwind_subspace (last_call_info
);
4973 /* SOM defers building of unwind descriptors until the link phase.
4974 The assembler is responsible for creating an R_ENTRY relocation
4975 to mark the beginning of a region and hold the unwind bits, and
4976 for creating an R_EXIT relocation to mark the end of the region.
4978 FIXME. ELF should be using the same conventions! The problem
4979 is an unwind requires too much relocation space. Hmmm. Maybe
4980 if we split the unwind bits up between the relocations which
4981 denote the entry and exit points. */
4982 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4984 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
4985 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
4989 /* Process a .EXIT pseudo-op. */
4996 /* We must have a valid space and subspace. */
4997 pa_check_current_space_and_subspace ();
5000 if (!within_procedure
)
5001 as_bad (_(".EXIT must appear within a procedure"));
5004 if (!callinfo_found
)
5005 as_bad (_("Missing .callinfo"));
5008 if (!within_entry_exit
)
5009 as_bad (_("No .ENTRY for this .EXIT"));
5012 within_entry_exit
= FALSE
;
5017 demand_empty_rest_of_line ();
5020 /* Process a .EXPORT directive. This makes functions external
5021 and provides information such as argument relocation entries
5031 name
= input_line_pointer
;
5032 c
= get_symbol_end ();
5033 /* Make sure the given symbol exists. */
5034 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
5036 as_bad (_("Cannot define export symbol: %s\n"), name
);
5037 p
= input_line_pointer
;
5039 input_line_pointer
++;
5043 /* OK. Set the external bits and process argument relocations. */
5044 S_SET_EXTERNAL (symbol
);
5045 p
= input_line_pointer
;
5047 if (!is_end_of_statement ())
5049 input_line_pointer
++;
5050 pa_type_args (symbol
, 1);
5054 demand_empty_rest_of_line ();
5057 /* Helper function to process arguments to a .EXPORT pseudo-op. */
5060 pa_type_args (symbolP
, is_export
)
5065 unsigned int temp
, arg_reloc
;
5066 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
5067 obj_symbol_type
*symbol
= (obj_symbol_type
*) symbol_get_bfdsym (symbolP
);
5069 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
5072 input_line_pointer
+= 8;
5073 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
5074 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
5075 type
= SYMBOL_TYPE_ABSOLUTE
;
5077 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
5079 input_line_pointer
+= 4;
5080 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
5081 instead one should be IMPORTing/EXPORTing ENTRY types.
5083 Complain if one tries to EXPORT a CODE type since that's never
5084 done. Both GCC and HP C still try to IMPORT CODE types, so
5085 silently fix them to be ENTRY types. */
5086 if (S_IS_FUNCTION (symbolP
))
5089 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
5090 S_GET_NAME (symbolP
));
5092 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
5093 type
= SYMBOL_TYPE_ENTRY
;
5097 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
5098 type
= SYMBOL_TYPE_CODE
;
5101 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
5103 input_line_pointer
+= 4;
5104 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
5105 type
= SYMBOL_TYPE_DATA
;
5107 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
5109 input_line_pointer
+= 5;
5110 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
5111 type
= SYMBOL_TYPE_ENTRY
;
5113 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
5115 input_line_pointer
+= 9;
5116 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
5117 type
= SYMBOL_TYPE_MILLICODE
;
5119 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
5121 input_line_pointer
+= 6;
5122 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
5123 type
= SYMBOL_TYPE_PLABEL
;
5125 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
5127 input_line_pointer
+= 8;
5128 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
5129 type
= SYMBOL_TYPE_PRI_PROG
;
5131 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
5133 input_line_pointer
+= 8;
5134 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
5135 type
= SYMBOL_TYPE_SEC_PROG
;
5138 /* SOM requires much more information about symbol types
5139 than BFD understands. This is how we get this information
5140 to the SOM BFD backend. */
5141 #ifdef obj_set_symbol_type
5142 obj_set_symbol_type (symbol_get_bfdsym (symbolP
), (int) type
);
5145 /* Now that the type of the exported symbol has been handled,
5146 handle any argument relocation information. */
5147 while (!is_end_of_statement ())
5149 if (*input_line_pointer
== ',')
5150 input_line_pointer
++;
5151 name
= input_line_pointer
;
5152 c
= get_symbol_end ();
5153 /* Argument sources. */
5154 if ((strncasecmp (name
, "argw", 4) == 0))
5156 p
= input_line_pointer
;
5158 input_line_pointer
++;
5159 temp
= atoi (name
+ 4);
5160 name
= input_line_pointer
;
5161 c
= get_symbol_end ();
5162 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
5164 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
5166 *input_line_pointer
= c
;
5168 /* The return value. */
5169 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
5171 p
= input_line_pointer
;
5173 input_line_pointer
++;
5174 name
= input_line_pointer
;
5175 c
= get_symbol_end ();
5176 arg_reloc
= pa_build_arg_reloc (name
);
5178 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
5180 *input_line_pointer
= c
;
5182 /* Privelege level. */
5183 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
5185 p
= input_line_pointer
;
5187 input_line_pointer
++;
5188 temp
= atoi (input_line_pointer
);
5190 symbol
->tc_data
.ap
.hppa_priv_level
= temp
;
5192 c
= get_symbol_end ();
5193 *input_line_pointer
= c
;
5197 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
5198 p
= input_line_pointer
;
5201 if (!is_end_of_statement ())
5202 input_line_pointer
++;
5206 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
5207 assembly file must either be defined in the assembly file, or
5208 explicitly IMPORTED from another. */
5217 name
= input_line_pointer
;
5218 c
= get_symbol_end ();
5220 symbol
= symbol_find (name
);
5221 /* Ugh. We might be importing a symbol defined earlier in the file,
5222 in which case all the code below will really screw things up
5223 (set the wrong segment, symbol flags & type, etc). */
5224 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
5226 symbol
= symbol_find_or_make (name
);
5227 p
= input_line_pointer
;
5230 if (!is_end_of_statement ())
5232 input_line_pointer
++;
5233 pa_type_args (symbol
, 0);
5237 /* Sigh. To be compatable with the HP assembler and to help
5238 poorly written assembly code, we assign a type based on
5239 the the current segment. Note only BSF_FUNCTION really
5240 matters, we do not need to set the full SYMBOL_TYPE_* info. */
5241 if (now_seg
== text_section
)
5242 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
5244 /* If the section is undefined, then the symbol is undefined
5245 Since this is an import, leave the section undefined. */
5246 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
5251 /* The symbol was already defined. Just eat everything up to
5252 the end of the current statement. */
5253 while (!is_end_of_statement ())
5254 input_line_pointer
++;
5257 demand_empty_rest_of_line ();
5260 /* Handle a .LABEL pseudo-op. */
5268 name
= input_line_pointer
;
5269 c
= get_symbol_end ();
5271 if (strlen (name
) > 0)
5274 p
= input_line_pointer
;
5279 as_warn (_("Missing label name on .LABEL"));
5282 if (!is_end_of_statement ())
5284 as_warn (_("extra .LABEL arguments ignored."));
5285 ignore_rest_of_line ();
5287 demand_empty_rest_of_line ();
5290 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
5297 /* We must have a valid space and subspace. */
5298 pa_check_current_space_and_subspace ();
5301 as_bad (_("The .LEAVE pseudo-op is not supported"));
5302 demand_empty_rest_of_line ();
5305 /* Handle a .LEVEL pseudo-op. */
5313 level
= input_line_pointer
;
5314 if (strncmp (level
, "1.0", 3) == 0)
5316 input_line_pointer
+= 3;
5317 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
5318 as_warn (_("could not set architecture and machine"));
5320 else if (strncmp (level
, "1.1", 3) == 0)
5322 input_line_pointer
+= 3;
5323 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
5324 as_warn (_("could not set architecture and machine"));
5326 else if (strncmp (level
, "2.0w", 4) == 0)
5328 input_line_pointer
+= 4;
5329 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 25))
5330 as_warn (_("could not set architecture and machine"));
5332 else if (strncmp (level
, "2.0", 3) == 0)
5334 input_line_pointer
+= 3;
5335 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
5336 as_warn (_("could not set architecture and machine"));
5340 as_bad (_("Unrecognized .LEVEL argument\n"));
5341 ignore_rest_of_line ();
5343 demand_empty_rest_of_line ();
5346 /* Handle a .ORIGIN pseudo-op. */
5353 /* We must have a valid space and subspace. */
5354 pa_check_current_space_and_subspace ();
5358 pa_undefine_label ();
5361 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
5362 is for static functions. FIXME. Should share more code with .EXPORT. */
5371 name
= input_line_pointer
;
5372 c
= get_symbol_end ();
5374 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
5376 as_bad (_("Cannot define static symbol: %s\n"), name
);
5377 p
= input_line_pointer
;
5379 input_line_pointer
++;
5383 S_CLEAR_EXTERNAL (symbol
);
5384 p
= input_line_pointer
;
5386 if (!is_end_of_statement ())
5388 input_line_pointer
++;
5389 pa_type_args (symbol
, 0);
5393 demand_empty_rest_of_line ();
5396 /* Handle a .PROC pseudo-op. It is used to mark the beginning
5397 of a procedure from a syntatical point of view. */
5403 struct call_info
*call_info
;
5406 /* We must have a valid space and subspace. */
5407 pa_check_current_space_and_subspace ();
5410 if (within_procedure
)
5411 as_fatal (_("Nested procedures"));
5413 /* Reset global variables for new procedure. */
5414 callinfo_found
= FALSE
;
5415 within_procedure
= TRUE
;
5417 /* Create another call_info structure. */
5418 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
5421 as_fatal (_("Cannot allocate unwind descriptor\n"));
5423 memset (call_info
, 0, sizeof (struct call_info
));
5425 call_info
->ci_next
= NULL
;
5427 if (call_info_root
== NULL
)
5429 call_info_root
= call_info
;
5430 last_call_info
= call_info
;
5434 last_call_info
->ci_next
= call_info
;
5435 last_call_info
= call_info
;
5438 /* set up defaults on call_info structure */
5440 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
5441 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
5442 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
5444 /* If we got a .PROC pseudo-op, we know that the function is defined
5445 locally. Make sure it gets into the symbol table. */
5447 label_symbol_struct
*label_symbol
= pa_get_label ();
5451 if (label_symbol
->lss_label
)
5453 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5454 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
5457 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5460 last_call_info
->start_symbol
= NULL
;
5463 demand_empty_rest_of_line ();
5466 /* Process the syntatical end of a procedure. Make sure all the
5467 appropriate pseudo-ops were found within the procedure. */
5475 /* We must have a valid space and subspace. */
5476 pa_check_current_space_and_subspace ();
5479 /* If we are within a procedure definition, make sure we've
5480 defined a label for the procedure; handle case where the
5481 label was defined after the .PROC directive.
5483 Note there's not need to diddle with the segment or fragment
5484 for the label symbol in this case. We have already switched
5485 into the new $CODE$ subspace at this point. */
5486 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
5488 label_symbol_struct
*label_symbol
= pa_get_label ();
5492 if (label_symbol
->lss_label
)
5494 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5495 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
5498 /* Also handle allocation of a fixup to hold the unwind
5499 information when the label appears after the proc/procend. */
5500 if (within_entry_exit
)
5502 char *where
= frag_more (0);
5504 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5505 NULL
, (offsetT
) 0, NULL
,
5506 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
5507 (int *) &last_call_info
->ci_unwind
.descriptor
);
5512 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5515 as_bad (_("Missing function name for .PROC"));
5518 if (!within_procedure
)
5519 as_bad (_("misplaced .procend"));
5521 if (!callinfo_found
)
5522 as_bad (_("Missing .callinfo for this procedure"));
5524 if (within_entry_exit
)
5525 as_bad (_("Missing .EXIT for a .ENTRY"));
5528 /* ELF needs to mark the end of each function so that it can compute
5529 the size of the function (apparently its needed in the symbol table). */
5530 hppa_elf_mark_end_of_function ();
5533 within_procedure
= FALSE
;
5534 demand_empty_rest_of_line ();
5535 pa_undefine_label ();
5538 /* If VALUE is an exact power of two between zero and 2^31, then
5539 return log2 (VALUE). Else return -1. */
5547 while ((1 << shift
) != value
&& shift
< 32)
5558 /* Check to make sure we have a valid space and subspace. */
5561 pa_check_current_space_and_subspace ()
5563 if (current_space
== NULL
)
5564 as_fatal (_("Not in a space.\n"));
5566 if (current_subspace
== NULL
)
5567 as_fatal (_("Not in a subspace.\n"));
5570 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
5571 then create a new space entry to hold the information specified
5572 by the parameters to the .SPACE directive. */
5574 static sd_chain_struct
*
5575 pa_parse_space_stmt (space_name
, create_flag
)
5579 char *name
, *ptemp
, c
;
5580 char loadable
, defined
, private, sort
;
5582 asection
*seg
= NULL
;
5583 sd_chain_struct
*space
;
5585 /* load default values */
5591 if (strcmp (space_name
, "$TEXT$") == 0)
5593 seg
= pa_def_spaces
[0].segment
;
5594 defined
= pa_def_spaces
[0].defined
;
5595 private = pa_def_spaces
[0].private;
5596 sort
= pa_def_spaces
[0].sort
;
5597 spnum
= pa_def_spaces
[0].spnum
;
5599 else if (strcmp (space_name
, "$PRIVATE$") == 0)
5601 seg
= pa_def_spaces
[1].segment
;
5602 defined
= pa_def_spaces
[1].defined
;
5603 private = pa_def_spaces
[1].private;
5604 sort
= pa_def_spaces
[1].sort
;
5605 spnum
= pa_def_spaces
[1].spnum
;
5608 if (!is_end_of_statement ())
5610 print_errors
= FALSE
;
5611 ptemp
= input_line_pointer
+ 1;
5612 /* First see if the space was specified as a number rather than
5613 as a name. According to the PA assembly manual the rest of
5614 the line should be ignored. */
5615 temp
= pa_parse_number (&ptemp
, 0);
5619 input_line_pointer
= ptemp
;
5623 while (!is_end_of_statement ())
5625 input_line_pointer
++;
5626 name
= input_line_pointer
;
5627 c
= get_symbol_end ();
5628 if ((strncasecmp (name
, "spnum", 5) == 0))
5630 *input_line_pointer
= c
;
5631 input_line_pointer
++;
5632 spnum
= get_absolute_expression ();
5634 else if ((strncasecmp (name
, "sort", 4) == 0))
5636 *input_line_pointer
= c
;
5637 input_line_pointer
++;
5638 sort
= get_absolute_expression ();
5640 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5642 *input_line_pointer
= c
;
5645 else if ((strncasecmp (name
, "notdefined", 10) == 0))
5647 *input_line_pointer
= c
;
5650 else if ((strncasecmp (name
, "private", 7) == 0))
5652 *input_line_pointer
= c
;
5657 as_bad (_("Invalid .SPACE argument"));
5658 *input_line_pointer
= c
;
5659 if (!is_end_of_statement ())
5660 input_line_pointer
++;
5664 print_errors
= TRUE
;
5667 if (create_flag
&& seg
== NULL
)
5668 seg
= subseg_new (space_name
, 0);
5670 /* If create_flag is nonzero, then create the new space with
5671 the attributes computed above. Else set the values in
5672 an already existing space -- this can only happen for
5673 the first occurence of a built-in space. */
5675 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
5676 private, sort
, seg
, 1);
5679 space
= is_defined_space (space_name
);
5680 SPACE_SPNUM (space
) = spnum
;
5681 SPACE_DEFINED (space
) = defined
& 1;
5682 SPACE_USER_DEFINED (space
) = 1;
5685 #ifdef obj_set_section_attributes
5686 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
5692 /* Handle a .SPACE pseudo-op; this switches the current space to the
5693 given space, creating the new space if necessary. */
5699 char *name
, c
, *space_name
, *save_s
;
5701 sd_chain_struct
*sd_chain
;
5703 if (within_procedure
)
5705 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
5706 ignore_rest_of_line ();
5710 /* Check for some of the predefined spaces. FIXME: most of the code
5711 below is repeated several times, can we extract the common parts
5712 and place them into a subroutine or something similar? */
5713 /* FIXME Is this (and the next IF stmt) really right?
5714 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
5715 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
5717 input_line_pointer
+= 6;
5718 sd_chain
= is_defined_space ("$TEXT$");
5719 if (sd_chain
== NULL
)
5720 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
5721 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5722 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
5724 current_space
= sd_chain
;
5725 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
5727 = pa_subsegment_to_subspace (text_section
,
5728 sd_chain
->sd_last_subseg
);
5729 demand_empty_rest_of_line ();
5732 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
5734 input_line_pointer
+= 9;
5735 sd_chain
= is_defined_space ("$PRIVATE$");
5736 if (sd_chain
== NULL
)
5737 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
5738 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5739 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
5741 current_space
= sd_chain
;
5742 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
5744 = pa_subsegment_to_subspace (data_section
,
5745 sd_chain
->sd_last_subseg
);
5746 demand_empty_rest_of_line ();
5749 if (!strncasecmp (input_line_pointer
,
5750 GDB_DEBUG_SPACE_NAME
,
5751 strlen (GDB_DEBUG_SPACE_NAME
)))
5753 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
5754 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
5755 if (sd_chain
== NULL
)
5756 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
5757 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5758 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
5760 current_space
= sd_chain
;
5763 asection
*gdb_section
5764 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
5766 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
5768 = pa_subsegment_to_subspace (gdb_section
,
5769 sd_chain
->sd_last_subseg
);
5771 demand_empty_rest_of_line ();
5775 /* It could be a space specified by number. */
5777 save_s
= input_line_pointer
;
5778 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
5780 if ((sd_chain
= pa_find_space_by_number (temp
)))
5782 current_space
= sd_chain
;
5784 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5786 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5787 sd_chain
->sd_last_subseg
);
5788 demand_empty_rest_of_line ();
5793 /* Not a number, attempt to create a new space. */
5795 input_line_pointer
= save_s
;
5796 name
= input_line_pointer
;
5797 c
= get_symbol_end ();
5798 space_name
= xmalloc (strlen (name
) + 1);
5799 strcpy (space_name
, name
);
5800 *input_line_pointer
= c
;
5802 sd_chain
= pa_parse_space_stmt (space_name
, 1);
5803 current_space
= sd_chain
;
5805 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5806 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5807 sd_chain
->sd_last_subseg
);
5808 demand_empty_rest_of_line ();
5812 /* Switch to a new space. (I think). FIXME. */
5821 sd_chain_struct
*space
;
5823 name
= input_line_pointer
;
5824 c
= get_symbol_end ();
5825 space
= is_defined_space (name
);
5829 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
5832 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
5834 *input_line_pointer
= c
;
5835 demand_empty_rest_of_line ();
5838 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
5839 given subspace, creating the new subspace if necessary.
5841 FIXME. Should mirror pa_space more closely, in particular how
5842 they're broken up into subroutines. */
5845 pa_subspace (create_new
)
5848 char *name
, *ss_name
, c
;
5849 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
5850 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
5851 sd_chain_struct
*space
;
5852 ssd_chain_struct
*ssd
;
5855 if (current_space
== NULL
)
5856 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
5858 if (within_procedure
)
5860 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
5861 ignore_rest_of_line ();
5865 name
= input_line_pointer
;
5866 c
= get_symbol_end ();
5867 ss_name
= xmalloc (strlen (name
) + 1);
5868 strcpy (ss_name
, name
);
5869 *input_line_pointer
= c
;
5871 /* Load default values. */
5883 space
= current_space
;
5887 ssd
= is_defined_subspace (ss_name
);
5888 /* Allow user to override the builtin attributes of subspaces. But
5889 only allow the attributes to be changed once! */
5890 if (ssd
&& SUBSPACE_DEFINED (ssd
))
5892 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
5893 current_subspace
= ssd
;
5894 if (!is_end_of_statement ())
5895 as_warn (_("Parameters of an existing subspace can\'t be modified"));
5896 demand_empty_rest_of_line ();
5901 /* A new subspace. Load default values if it matches one of
5902 the builtin subspaces. */
5904 while (pa_def_subspaces
[i
].name
)
5906 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
5908 loadable
= pa_def_subspaces
[i
].loadable
;
5909 common
= pa_def_subspaces
[i
].common
;
5910 dup_common
= pa_def_subspaces
[i
].dup_common
;
5911 code_only
= pa_def_subspaces
[i
].code_only
;
5912 zero
= pa_def_subspaces
[i
].zero
;
5913 space_index
= pa_def_subspaces
[i
].space_index
;
5914 alignment
= pa_def_subspaces
[i
].alignment
;
5915 quadrant
= pa_def_subspaces
[i
].quadrant
;
5916 access
= pa_def_subspaces
[i
].access
;
5917 sort
= pa_def_subspaces
[i
].sort
;
5924 /* We should be working with a new subspace now. Fill in
5925 any information as specified by the user. */
5926 if (!is_end_of_statement ())
5928 input_line_pointer
++;
5929 while (!is_end_of_statement ())
5931 name
= input_line_pointer
;
5932 c
= get_symbol_end ();
5933 if ((strncasecmp (name
, "quad", 4) == 0))
5935 *input_line_pointer
= c
;
5936 input_line_pointer
++;
5937 quadrant
= get_absolute_expression ();
5939 else if ((strncasecmp (name
, "align", 5) == 0))
5941 *input_line_pointer
= c
;
5942 input_line_pointer
++;
5943 alignment
= get_absolute_expression ();
5944 if (log2 (alignment
) == -1)
5946 as_bad (_("Alignment must be a power of 2"));
5950 else if ((strncasecmp (name
, "access", 6) == 0))
5952 *input_line_pointer
= c
;
5953 input_line_pointer
++;
5954 access
= get_absolute_expression ();
5956 else if ((strncasecmp (name
, "sort", 4) == 0))
5958 *input_line_pointer
= c
;
5959 input_line_pointer
++;
5960 sort
= get_absolute_expression ();
5962 else if ((strncasecmp (name
, "code_only", 9) == 0))
5964 *input_line_pointer
= c
;
5967 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5969 *input_line_pointer
= c
;
5972 else if ((strncasecmp (name
, "common", 6) == 0))
5974 *input_line_pointer
= c
;
5977 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
5979 *input_line_pointer
= c
;
5982 else if ((strncasecmp (name
, "zero", 4) == 0))
5984 *input_line_pointer
= c
;
5987 else if ((strncasecmp (name
, "first", 5) == 0))
5988 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
5990 as_bad (_("Invalid .SUBSPACE argument"));
5991 if (!is_end_of_statement ())
5992 input_line_pointer
++;
5996 /* Compute a reasonable set of BFD flags based on the information
5997 in the .subspace directive. */
5998 applicable
= bfd_applicable_section_flags (stdoutput
);
6001 flags
|= (SEC_ALLOC
| SEC_LOAD
);
6004 if (common
|| dup_common
)
6005 flags
|= SEC_IS_COMMON
;
6007 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
6009 /* This is a zero-filled subspace (eg BSS). */
6011 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
6013 applicable
&= flags
;
6015 /* If this is an existing subspace, then we want to use the
6016 segment already associated with the subspace.
6018 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
6019 lots of sections. It might be a problem in the PA ELF
6020 code, I do not know yet. For now avoid creating anything
6021 but the "standard" sections for ELF. */
6023 section
= subseg_force_new (ss_name
, 0);
6025 section
= ssd
->ssd_seg
;
6027 section
= subseg_new (ss_name
, 0);
6030 seg_info (section
)->bss
= 1;
6032 /* Now set the flags. */
6033 bfd_set_section_flags (stdoutput
, section
, applicable
);
6035 /* Record any alignment request for this section. */
6036 record_alignment (section
, log2 (alignment
));
6038 /* Set the starting offset for this section. */
6039 bfd_set_section_vma (stdoutput
, section
,
6040 pa_subspace_start (space
, quadrant
));
6042 /* Now that all the flags are set, update an existing subspace,
6043 or create a new one. */
6046 current_subspace
= update_subspace (space
, ss_name
, loadable
,
6047 code_only
, common
, dup_common
,
6048 sort
, zero
, access
, space_index
,
6049 alignment
, quadrant
,
6052 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
6054 dup_common
, zero
, sort
,
6055 access
, space_index
,
6056 alignment
, quadrant
, section
);
6058 demand_empty_rest_of_line ();
6059 current_subspace
->ssd_seg
= section
;
6060 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
6062 SUBSPACE_DEFINED (current_subspace
) = 1;
6066 /* Create default space and subspace dictionaries. */
6073 space_dict_root
= NULL
;
6074 space_dict_last
= NULL
;
6077 while (pa_def_spaces
[i
].name
)
6081 /* Pick the right name to use for the new section. */
6082 name
= pa_def_spaces
[i
].name
;
6084 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
6085 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
6086 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
6087 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
6088 pa_def_spaces
[i
].segment
, 0);
6093 while (pa_def_subspaces
[i
].name
)
6096 int applicable
, subsegment
;
6097 asection
*segment
= NULL
;
6098 sd_chain_struct
*space
;
6100 /* Pick the right name for the new section and pick the right
6101 subsegment number. */
6102 name
= pa_def_subspaces
[i
].name
;
6105 /* Create the new section. */
6106 segment
= subseg_new (name
, subsegment
);
6109 /* For SOM we want to replace the standard .text, .data, and .bss
6110 sections with our own. We also want to set BFD flags for
6111 all the built-in subspaces. */
6112 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$"))
6114 text_section
= segment
;
6115 applicable
= bfd_applicable_section_flags (stdoutput
);
6116 bfd_set_section_flags (stdoutput
, segment
,
6117 applicable
& (SEC_ALLOC
| SEC_LOAD
6118 | SEC_RELOC
| SEC_CODE
6120 | SEC_HAS_CONTENTS
));
6122 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$"))
6124 data_section
= segment
;
6125 applicable
= bfd_applicable_section_flags (stdoutput
);
6126 bfd_set_section_flags (stdoutput
, segment
,
6127 applicable
& (SEC_ALLOC
| SEC_LOAD
6129 | SEC_HAS_CONTENTS
));
6133 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$"))
6135 bss_section
= segment
;
6136 applicable
= bfd_applicable_section_flags (stdoutput
);
6137 bfd_set_section_flags (stdoutput
, segment
,
6138 applicable
& SEC_ALLOC
);
6140 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$"))
6142 applicable
= bfd_applicable_section_flags (stdoutput
);
6143 bfd_set_section_flags (stdoutput
, segment
,
6144 applicable
& (SEC_ALLOC
| SEC_LOAD
6147 | SEC_HAS_CONTENTS
));
6149 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$"))
6151 applicable
= bfd_applicable_section_flags (stdoutput
);
6152 bfd_set_section_flags (stdoutput
, segment
,
6153 applicable
& (SEC_ALLOC
| SEC_LOAD
6156 | SEC_HAS_CONTENTS
));
6158 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$"))
6160 applicable
= bfd_applicable_section_flags (stdoutput
);
6161 bfd_set_section_flags (stdoutput
, segment
,
6162 applicable
& (SEC_ALLOC
| SEC_LOAD
6165 | SEC_HAS_CONTENTS
));
6168 /* Find the space associated with this subspace. */
6169 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
6170 def_space_index
].segment
);
6173 as_fatal (_("Internal error: Unable to find containing space for %s."),
6174 pa_def_subspaces
[i
].name
);
6177 create_new_subspace (space
, name
,
6178 pa_def_subspaces
[i
].loadable
,
6179 pa_def_subspaces
[i
].code_only
,
6180 pa_def_subspaces
[i
].common
,
6181 pa_def_subspaces
[i
].dup_common
,
6182 pa_def_subspaces
[i
].zero
,
6183 pa_def_subspaces
[i
].sort
,
6184 pa_def_subspaces
[i
].access
,
6185 pa_def_subspaces
[i
].space_index
,
6186 pa_def_subspaces
[i
].alignment
,
6187 pa_def_subspaces
[i
].quadrant
,
6195 /* Create a new space NAME, with the appropriate flags as defined
6196 by the given parameters. */
6198 static sd_chain_struct
*
6199 create_new_space (name
, spnum
, loadable
, defined
, private,
6200 sort
, seg
, user_defined
)
6210 sd_chain_struct
*chain_entry
;
6212 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
6214 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
6217 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
6218 strcpy (SPACE_NAME (chain_entry
), name
);
6219 SPACE_DEFINED (chain_entry
) = defined
;
6220 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
6221 SPACE_SPNUM (chain_entry
) = spnum
;
6223 chain_entry
->sd_seg
= seg
;
6224 chain_entry
->sd_last_subseg
= -1;
6225 chain_entry
->sd_subspaces
= NULL
;
6226 chain_entry
->sd_next
= NULL
;
6228 /* Find spot for the new space based on its sort key. */
6229 if (!space_dict_last
)
6230 space_dict_last
= chain_entry
;
6232 if (space_dict_root
== NULL
)
6233 space_dict_root
= chain_entry
;
6236 sd_chain_struct
*chain_pointer
;
6237 sd_chain_struct
*prev_chain_pointer
;
6239 chain_pointer
= space_dict_root
;
6240 prev_chain_pointer
= NULL
;
6242 while (chain_pointer
)
6244 prev_chain_pointer
= chain_pointer
;
6245 chain_pointer
= chain_pointer
->sd_next
;
6248 /* At this point we've found the correct place to add the new
6249 entry. So add it and update the linked lists as appropriate. */
6250 if (prev_chain_pointer
)
6252 chain_entry
->sd_next
= chain_pointer
;
6253 prev_chain_pointer
->sd_next
= chain_entry
;
6257 space_dict_root
= chain_entry
;
6258 chain_entry
->sd_next
= chain_pointer
;
6261 if (chain_entry
->sd_next
== NULL
)
6262 space_dict_last
= chain_entry
;
6265 /* This is here to catch predefined spaces which do not get
6266 modified by the user's input. Another call is found at
6267 the bottom of pa_parse_space_stmt to handle cases where
6268 the user modifies a predefined space. */
6269 #ifdef obj_set_section_attributes
6270 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
6276 /* Create a new subspace NAME, with the appropriate flags as defined
6277 by the given parameters.
6279 Add the new subspace to the subspace dictionary chain in numerical
6280 order as defined by the SORT entries. */
6282 static ssd_chain_struct
*
6283 create_new_subspace (space
, name
, loadable
, code_only
, common
,
6284 dup_common
, is_zero
, sort
, access
, space_index
,
6285 alignment
, quadrant
, seg
)
6286 sd_chain_struct
*space
;
6288 int loadable
, code_only
, common
, dup_common
, is_zero
;
6296 ssd_chain_struct
*chain_entry
;
6298 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
6300 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
6302 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
6303 strcpy (SUBSPACE_NAME (chain_entry
), name
);
6305 /* Initialize subspace_defined. When we hit a .subspace directive
6306 we'll set it to 1 which "locks-in" the subspace attributes. */
6307 SUBSPACE_DEFINED (chain_entry
) = 0;
6309 chain_entry
->ssd_subseg
= 0;
6310 chain_entry
->ssd_seg
= seg
;
6311 chain_entry
->ssd_next
= NULL
;
6313 /* Find spot for the new subspace based on its sort key. */
6314 if (space
->sd_subspaces
== NULL
)
6315 space
->sd_subspaces
= chain_entry
;
6318 ssd_chain_struct
*chain_pointer
;
6319 ssd_chain_struct
*prev_chain_pointer
;
6321 chain_pointer
= space
->sd_subspaces
;
6322 prev_chain_pointer
= NULL
;
6324 while (chain_pointer
)
6326 prev_chain_pointer
= chain_pointer
;
6327 chain_pointer
= chain_pointer
->ssd_next
;
6330 /* Now we have somewhere to put the new entry. Insert it and update
6332 if (prev_chain_pointer
)
6334 chain_entry
->ssd_next
= chain_pointer
;
6335 prev_chain_pointer
->ssd_next
= chain_entry
;
6339 space
->sd_subspaces
= chain_entry
;
6340 chain_entry
->ssd_next
= chain_pointer
;
6344 #ifdef obj_set_subsection_attributes
6345 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
6352 /* Update the information for the given subspace based upon the
6353 various arguments. Return the modified subspace chain entry. */
6355 static ssd_chain_struct
*
6356 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
6357 zero
, access
, space_index
, alignment
, quadrant
, section
)
6358 sd_chain_struct
*space
;
6372 ssd_chain_struct
*chain_entry
;
6374 chain_entry
= is_defined_subspace (name
);
6376 #ifdef obj_set_subsection_attributes
6377 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
6384 /* Return the space chain entry for the space with the name NAME or
6385 NULL if no such space exists. */
6387 static sd_chain_struct
*
6388 is_defined_space (name
)
6391 sd_chain_struct
*chain_pointer
;
6393 for (chain_pointer
= space_dict_root
;
6395 chain_pointer
= chain_pointer
->sd_next
)
6397 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
6398 return chain_pointer
;
6401 /* No mapping from segment to space was found. Return NULL. */
6405 /* Find and return the space associated with the given seg. If no mapping
6406 from the given seg to a space is found, then return NULL.
6408 Unlike subspaces, the number of spaces is not expected to grow much,
6409 so a linear exhaustive search is OK here. */
6411 static sd_chain_struct
*
6412 pa_segment_to_space (seg
)
6415 sd_chain_struct
*space_chain
;
6417 /* Walk through each space looking for the correct mapping. */
6418 for (space_chain
= space_dict_root
;
6420 space_chain
= space_chain
->sd_next
)
6422 if (space_chain
->sd_seg
== seg
)
6426 /* Mapping was not found. Return NULL. */
6430 /* Return the space chain entry for the subspace with the name NAME or
6431 NULL if no such subspace exists.
6433 Uses a linear search through all the spaces and subspaces, this may
6434 not be appropriate if we ever being placing each function in its
6437 static ssd_chain_struct
*
6438 is_defined_subspace (name
)
6441 sd_chain_struct
*space_chain
;
6442 ssd_chain_struct
*subspace_chain
;
6444 /* Walk through each space. */
6445 for (space_chain
= space_dict_root
;
6447 space_chain
= space_chain
->sd_next
)
6449 /* Walk through each subspace looking for a name which matches. */
6450 for (subspace_chain
= space_chain
->sd_subspaces
;
6452 subspace_chain
= subspace_chain
->ssd_next
)
6453 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
6454 return subspace_chain
;
6457 /* Subspace wasn't found. Return NULL. */
6461 /* Find and return the subspace associated with the given seg. If no
6462 mapping from the given seg to a subspace is found, then return NULL.
6464 If we ever put each procedure/function within its own subspace
6465 (to make life easier on the compiler and linker), then this will have
6466 to become more efficient. */
6468 static ssd_chain_struct
*
6469 pa_subsegment_to_subspace (seg
, subseg
)
6473 sd_chain_struct
*space_chain
;
6474 ssd_chain_struct
*subspace_chain
;
6476 /* Walk through each space. */
6477 for (space_chain
= space_dict_root
;
6479 space_chain
= space_chain
->sd_next
)
6481 if (space_chain
->sd_seg
== seg
)
6483 /* Walk through each subspace within each space looking for
6484 the correct mapping. */
6485 for (subspace_chain
= space_chain
->sd_subspaces
;
6487 subspace_chain
= subspace_chain
->ssd_next
)
6488 if (subspace_chain
->ssd_subseg
== (int) subseg
)
6489 return subspace_chain
;
6493 /* No mapping from subsegment to subspace found. Return NULL. */
6497 /* Given a number, try and find a space with the name number.
6499 Return a pointer to a space dictionary chain entry for the space
6500 that was found or NULL on failure. */
6502 static sd_chain_struct
*
6503 pa_find_space_by_number (number
)
6506 sd_chain_struct
*space_chain
;
6508 for (space_chain
= space_dict_root
;
6510 space_chain
= space_chain
->sd_next
)
6512 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
6516 /* No appropriate space found. Return NULL. */
6520 /* Return the starting address for the given subspace. If the starting
6521 address is unknown then return zero. */
6524 pa_subspace_start (space
, quadrant
)
6525 sd_chain_struct
*space
;
6528 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
6529 is not correct for the PA OSF1 port. */
6530 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
6532 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
6539 /* FIXME. Needs documentation. */
6541 pa_next_subseg (space
)
6542 sd_chain_struct
*space
;
6545 space
->sd_last_subseg
++;
6546 return space
->sd_last_subseg
;
6550 /* Helper function for pa_stringer. Used to find the end of
6557 unsigned int c
= *s
& CHAR_MASK
;
6560 /* We must have a valid space and subspace. */
6561 pa_check_current_space_and_subspace ();
6575 /* Handle a .STRING type pseudo-op. */
6578 pa_stringer (append_zero
)
6581 char *s
, num_buf
[4];
6585 /* Preprocess the string to handle PA-specific escape sequences.
6586 For example, \xDD where DD is a hexidecimal number should be
6587 changed to \OOO where OOO is an octal number. */
6589 /* Skip the opening quote. */
6590 s
= input_line_pointer
+ 1;
6592 while (is_a_char (c
= pa_stringer_aux (s
++)))
6599 /* Handle \x<num>. */
6602 unsigned int number
;
6607 /* Get pas the 'x'. */
6609 for (num_digit
= 0, number
= 0, dg
= *s
;
6611 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
6612 || (dg
>= 'A' && dg
<= 'F'));
6616 number
= number
* 16 + dg
- '0';
6617 else if (dg
>= 'a' && dg
<= 'f')
6618 number
= number
* 16 + dg
- 'a' + 10;
6620 number
= number
* 16 + dg
- 'A' + 10;
6630 sprintf (num_buf
, "%02o", number
);
6633 sprintf (num_buf
, "%03o", number
);
6636 for (i
= 0; i
<= num_digit
; i
++)
6637 s_start
[i
] = num_buf
[i
];
6641 /* This might be a "\"", skip over the escaped char. */
6648 stringer (append_zero
);
6649 pa_undefine_label ();
6652 /* Handle a .VERSION pseudo-op. */
6659 pa_undefine_label ();
6664 /* Handle a .COMPILER pseudo-op. */
6667 pa_compiler (unused
)
6670 obj_som_compiler (0);
6671 pa_undefine_label ();
6676 /* Handle a .COPYRIGHT pseudo-op. */
6679 pa_copyright (unused
)
6683 pa_undefine_label ();
6686 /* Just like a normal cons, but when finished we have to undefine
6687 the latest space label. */
6694 pa_undefine_label ();
6697 /* Switch to the data space. As usual delete our label. */
6704 current_space
= is_defined_space ("$PRIVATE$");
6706 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6709 pa_undefine_label ();
6712 /* Like float_cons, but we need to undefine our label. */
6715 pa_float_cons (float_type
)
6718 float_cons (float_type
);
6719 pa_undefine_label ();
6722 /* Like s_fill, but delete our label when finished. */
6729 /* We must have a valid space and subspace. */
6730 pa_check_current_space_and_subspace ();
6734 pa_undefine_label ();
6737 /* Like lcomm, but delete our label when finished. */
6740 pa_lcomm (needs_align
)
6744 /* We must have a valid space and subspace. */
6745 pa_check_current_space_and_subspace ();
6748 s_lcomm (needs_align
);
6749 pa_undefine_label ();
6752 /* Like lsym, but delete our label when finished. */
6759 /* We must have a valid space and subspace. */
6760 pa_check_current_space_and_subspace ();
6764 pa_undefine_label ();
6767 /* Switch to the text space. Like s_text, but delete our
6768 label when finished. */
6774 current_space
= is_defined_space ("$TEXT$");
6776 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6780 pa_undefine_label ();
6783 /* On the PA relocations which involve function symbols must not be
6784 adjusted. This so that the linker can know when/how to create argument
6785 relocation stubs for indirect calls and calls to static functions.
6787 "T" field selectors create DLT relative fixups for accessing
6788 globals and statics in PIC code; each DLT relative fixup creates
6789 an entry in the DLT table. The entries contain the address of
6790 the final target (eg accessing "foo" would create a DLT entry
6791 with the address of "foo").
6793 Unfortunately, the HP linker doesn't take into account any addend
6794 when generating the DLT; so accessing $LIT$+8 puts the address of
6795 $LIT$ into the DLT rather than the address of $LIT$+8.
6797 The end result is we can't perform relocation symbol reductions for
6798 any fixup which creates entries in the DLT (eg they use "T" field
6801 Reject reductions involving symbols with external scope; such
6802 reductions make life a living hell for object file editors.
6804 FIXME. Also reject R_HPPA relocations which are 32bits wide in
6805 the code space. The SOM BFD backend doesn't know how to pull the
6806 right bits out of an instruction. */
6809 hppa_fix_adjustable (fixp
)
6812 struct hppa_fix_struct
*hppa_fix
;
6814 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6817 /* Reject reductions of symbols in 32bit relocs. */
6818 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
6821 /* Reject reductions of symbols in sym1-sym2 expressions when
6822 the fixup will occur in a CODE subspace.
6824 XXX FIXME: Long term we probably want to reject all of these;
6825 for example reducing in the debug section would lose if we ever
6826 supported using the optimizing hp linker. */
6829 && (hppa_fix
->segment
->flags
& SEC_CODE
))
6831 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
6832 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
6836 /* We can't adjust any relocs that use LR% and RR% field selectors.
6837 That confuses the HP linker. */
6838 if (hppa_fix
->fx_r_field
== e_lrsel
6839 || hppa_fix
->fx_r_field
== e_rrsel
6840 || hppa_fix
->fx_r_field
== e_nlrsel
)
6844 /* Reject reductions of symbols in DLT relative relocs,
6845 relocations with plabels. */
6846 if (hppa_fix
->fx_r_field
== e_tsel
6847 || hppa_fix
->fx_r_field
== e_ltsel
6848 || hppa_fix
->fx_r_field
== e_rtsel
6849 || hppa_fix
->fx_r_field
== e_psel
6850 || hppa_fix
->fx_r_field
== e_rpsel
6851 || hppa_fix
->fx_r_field
== e_lpsel
)
6854 if (fixp
->fx_addsy
&& S_IS_EXTERNAL (fixp
->fx_addsy
))
6857 /* Reject absolute calls (jumps). */
6858 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
6861 /* Reject reductions of function symbols. */
6862 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
6868 /* Return nonzero if the fixup in FIXP will require a relocation,
6869 even it if appears that the fixup could be completely handled
6873 hppa_force_relocation (fixp
)
6876 struct hppa_fix_struct
*hppa_fixp
;
6879 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6881 if (fixp
->fx_r_type
== R_HPPA_ENTRY
|| fixp
->fx_r_type
== R_HPPA_EXIT
6882 || fixp
->fx_r_type
== R_HPPA_BEGIN_BRTAB
6883 || fixp
->fx_r_type
== R_HPPA_END_BRTAB
6884 || fixp
->fx_r_type
== R_HPPA_BEGIN_TRY
6885 || fixp
->fx_r_type
== R_HPPA_END_TRY
6886 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
6887 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
6891 #define arg_reloc_stub_needed(CALLER, CALLEE) \
6892 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
6895 /* It is necessary to force PC-relative calls/jumps to have a relocation
6896 entry if they're going to need either a argument relocation or long
6897 call stub. FIXME. Can't we need the same for absolute calls? */
6898 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
6899 && (arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
6900 symbol_get_bfdsym (fixp
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
6901 hppa_fixp
->fx_arg_reloc
)))
6904 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
6905 - md_pcrel_from (fixp
));
6906 /* Now check and see if we're going to need a long-branch stub. */
6907 if (fixp
->fx_r_type
== R_HPPA_PCREL_CALL
6908 && (distance
> 262143 || distance
< -262144))
6911 if (fixp
->fx_r_type
== R_HPPA_ABS_CALL
)
6913 #undef arg_reloc_stub_needed
6915 /* No need (yet) to force another relocations to be emitted. */
6919 /* Now for some ELF specific code. FIXME. */
6921 /* Mark the end of a function so that it's possible to compute
6922 the size of the function in hppa_elf_final_processing. */
6925 hppa_elf_mark_end_of_function ()
6927 /* ELF does not have EXIT relocations. All we do is create a
6928 temporary symbol marking the end of the function. */
6929 char *name
= (char *)
6930 xmalloc (strlen ("L$\001end_") +
6931 strlen (S_GET_NAME (last_call_info
->start_symbol
)) + 1);
6937 strcpy (name
, "L$\001end_");
6938 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
6940 /* If we have a .exit followed by a .procend, then the
6941 symbol will have already been defined. */
6942 symbolP
= symbol_find (name
);
6945 /* The symbol has already been defined! This can
6946 happen if we have a .exit followed by a .procend.
6948 This is *not* an error. All we want to do is free
6949 the memory we just allocated for the name and continue. */
6954 /* symbol value should be the offset of the
6955 last instruction of the function */
6956 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
6960 S_CLEAR_EXTERNAL (symbolP
);
6961 symbol_table_insert (symbolP
);
6965 last_call_info
->end_symbol
= symbolP
;
6967 as_bad (_("Symbol '%s' could not be created."), name
);
6971 as_bad (_("No memory for symbol name."));
6975 /* For ELF, this function serves one purpose: to setup the st_size
6976 field of STT_FUNC symbols. To do this, we need to scan the
6977 call_info structure list, determining st_size in by taking the
6978 difference in the address of the beginning/end marker symbols. */
6981 elf_hppa_final_processing ()
6983 struct call_info
*call_info_pointer
;
6985 for (call_info_pointer
= call_info_root
;
6987 call_info_pointer
= call_info_pointer
->ci_next
)
6989 elf_symbol_type
*esym
6990 = ((elf_symbol_type
*)
6991 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
6992 esym
->internal_elf_sym
.st_size
=
6993 S_GET_VALUE (call_info_pointer
->end_symbol
)
6994 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;