1 /* tc-hppa.c -- Assemble for the PA
2 Copyright (C) 1989, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 /* HP PA-RISC support was contributed by the Center for Software Science
23 at the University of Utah. */
31 #include "bfd/libhppa.h"
32 #include "bfd/libbfd.h"
34 /* Be careful, this file includes data *declarations*. */
35 #include "opcode/hppa.h"
37 /* A "convient" place to put object file dependencies which do
38 not need to be seen outside of tc-hppa.c. */
40 /* Names of various debugging spaces/subspaces. */
41 #define GDB_DEBUG_SPACE_NAME ".stab"
42 #define GDB_STRINGS_SUBSPACE_NAME ".stabstr"
43 #define GDB_SYMBOLS_SUBSPACE_NAME ".stab"
44 #define UNWIND_SECTION_NAME ".PARISC.unwind"
45 /* Nonzero if CODE is a fixup code needing further processing. */
47 /* Object file formats specify relocation types. */
48 typedef elf32_hppa_reloc_type reloc_type
;
50 /* Object file formats specify BFD symbol types. */
51 typedef elf_symbol_type obj_symbol_type
;
53 /* How to generate a relocation. */
54 #define hppa_gen_reloc_type hppa_elf_gen_reloc_type
56 /* ELF objects can have versions, but apparently do not have anywhere
57 to store a copyright string. */
58 #define obj_version obj_elf_version
59 #define obj_copyright obj_elf_version
61 /* Use space aliases. */
66 /* Names of various debugging spaces/subspaces. */
67 #define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$"
68 #define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$"
69 #define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$"
70 #define UNWIND_SECTION_NAME "$UNWIND$"
72 /* Object file formats specify relocation types. */
73 typedef int reloc_type
;
75 /* SOM objects can have both a version string and a copyright string. */
76 #define obj_version obj_som_version
77 #define obj_copyright obj_som_copyright
79 /* Do not use space aliases. */
82 /* How to generate a relocation. */
83 #define hppa_gen_reloc_type hppa_som_gen_reloc_type
85 /* Object file formats specify BFD symbol types. */
86 typedef som_symbol_type obj_symbol_type
;
88 /* This apparently isn't in older versions of hpux reloc.h. */
90 #define R_DLT_REL 0x78
102 /* Various structures and types used internally in tc-hppa.c. */
104 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
108 unsigned int cannot_unwind
:1;
109 unsigned int millicode
:1;
110 unsigned int millicode_save_rest
:1;
111 unsigned int region_desc
:2;
112 unsigned int save_sr
:2;
113 unsigned int entry_fr
:4;
114 unsigned int entry_gr
:5;
115 unsigned int args_stored
:1;
116 unsigned int call_fr
:5;
117 unsigned int call_gr
:5;
118 unsigned int save_sp
:1;
119 unsigned int save_rp
:1;
120 unsigned int save_rp_in_frame
:1;
121 unsigned int extn_ptr_defined
:1;
122 unsigned int cleanup_defined
:1;
124 unsigned int hpe_interrupt_marker
:1;
125 unsigned int hpux_interrupt_marker
:1;
126 unsigned int reserved
:3;
127 unsigned int frame_size
:27;
132 /* Starting and ending offsets of the region described by
134 unsigned int start_offset
;
135 unsigned int end_offset
;
136 struct unwind_desc descriptor
;
139 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
140 control the entry and exit code they generate. It is also used in
141 creation of the correct stack unwind descriptors.
143 NOTE: GAS does not support .enter and .leave for the generation of
144 prologues and epilogues. FIXME.
146 The fields in structure roughly correspond to the arguments available on the
147 .callinfo pseudo-op. */
151 /* The unwind descriptor being built. */
152 struct unwind_table ci_unwind
;
154 /* Name of this function. */
155 symbolS
*start_symbol
;
157 /* (temporary) symbol used to mark the end of this function. */
160 /* Next entry in the chain. */
161 struct call_info
*ci_next
;
164 /* Operand formats for FP instructions. Note not all FP instructions
165 allow all four formats to be used (for example fmpysub only allows
169 SGL
, DBL
, ILLEGAL_FMT
, QUAD
, W
, UW
, DW
, UDW
, QW
, UQW
173 /* This fully describes the symbol types which may be attached to
174 an EXPORT or IMPORT directive. Only SOM uses this formation
175 (ELF has no need for it). */
179 SYMBOL_TYPE_ABSOLUTE
,
183 SYMBOL_TYPE_MILLICODE
,
185 SYMBOL_TYPE_PRI_PROG
,
186 SYMBOL_TYPE_SEC_PROG
,
190 /* This structure contains information needed to assemble
191 individual instructions. */
194 /* Holds the opcode after parsing by pa_ip. */
195 unsigned long opcode
;
197 /* Holds an expression associated with the current instruction. */
200 /* Does this instruction use PC-relative addressing. */
203 /* Floating point formats for operand1 and operand2. */
204 fp_operand_format fpof1
;
205 fp_operand_format fpof2
;
208 /* Holds the field selector for this instruction
209 (for example L%, LR%, etc). */
212 /* Holds any argument relocation bits associated with this
213 instruction. (instruction should be some sort of call). */
216 /* The format specification for this instruction. */
219 /* The relocation (if any) associated with this instruction. */
223 /* PA-89 floating point registers are arranged like this:
226 +--------------+--------------+
227 | 0 or 16L | 16 or 16R |
228 +--------------+--------------+
229 | 1 or 17L | 17 or 17R |
230 +--------------+--------------+
238 +--------------+--------------+
239 | 14 or 30L | 30 or 30R |
240 +--------------+--------------+
241 | 15 or 31L | 31 or 31R |
242 +--------------+--------------+
245 The following is a version of pa_parse_number that
246 handles the L/R notation and returns the correct
247 value to put into the instruction register field.
248 The correct value to put into the instruction is
249 encoded in the structure 'pa_11_fp_reg_struct'. */
251 struct pa_11_fp_reg_struct
253 /* The register number. */
260 /* Additional information needed to build argument relocation stubs. */
263 /* The argument relocation specification. */
264 unsigned int arg_reloc
;
266 /* Number of arguments. */
267 unsigned int arg_count
;
270 /* This structure defines an entry in the subspace dictionary
273 struct subspace_dictionary_chain
275 /* Nonzero if this space has been defined by the user code. */
276 unsigned int ssd_defined
;
278 /* Name of this subspace. */
281 /* GAS segment and subsegment associated with this subspace. */
285 /* Next space in the subspace dictionary chain. */
286 struct subspace_dictionary_chain
*ssd_next
;
289 typedef struct subspace_dictionary_chain ssd_chain_struct
;
291 /* This structure defines an entry in the subspace dictionary
294 struct space_dictionary_chain
296 /* Nonzero if this space has been defined by the user code or
297 as a default space. */
298 unsigned int sd_defined
;
300 /* Nonzero if this spaces has been defined by the user code. */
301 unsigned int sd_user_defined
;
303 /* The space number (or index). */
304 unsigned int sd_spnum
;
306 /* The name of this subspace. */
309 /* GAS segment to which this subspace corresponds. */
312 /* Current subsegment number being used. */
315 /* The chain of subspaces contained within this space. */
316 ssd_chain_struct
*sd_subspaces
;
318 /* The next entry in the space dictionary chain. */
319 struct space_dictionary_chain
*sd_next
;
322 typedef struct space_dictionary_chain sd_chain_struct
;
324 /* Structure for previous label tracking. Needed so that alignments,
325 callinfo declarations, etc can be easily attached to a particular
327 typedef struct label_symbol_struct
329 struct symbol
*lss_label
;
330 sd_chain_struct
*lss_space
;
331 struct label_symbol_struct
*lss_next
;
335 /* This structure defines attributes of the default subspace
336 dictionary entries. */
338 struct default_subspace_dict
340 /* Name of the subspace. */
343 /* FIXME. Is this still needed? */
346 /* Nonzero if this subspace is loadable. */
349 /* Nonzero if this subspace contains only code. */
352 /* Nonzero if this is a common subspace. */
355 /* Nonzero if this is a common subspace which allows symbols
356 to be multiply defined. */
359 /* Nonzero if this subspace should be zero filled. */
362 /* Sort key for this subspace. */
365 /* Access control bits for this subspace. Can represent RWX access
366 as well as privilege level changes for gateways. */
369 /* Index of containing space. */
372 /* Alignment (in bytes) of this subspace. */
375 /* Quadrant within space where this subspace should be loaded. */
378 /* An index into the default spaces array. */
381 /* An alias for this section (or NULL if no alias exists). */
384 /* Subsegment associated with this subspace. */
388 /* This structure defines attributes of the default space
389 dictionary entries. */
391 struct default_space_dict
393 /* Name of the space. */
396 /* Space number. It is possible to identify spaces within
397 assembly code numerically! */
400 /* Nonzero if this space is loadable. */
403 /* Nonzero if this space is "defined". FIXME is still needed */
406 /* Nonzero if this space can not be shared. */
409 /* Sort key for this space. */
412 /* Segment associated with this space. */
415 /* An alias for this section (or NULL if no alias exists). */
419 /* Extra information needed to perform fixups (relocations) on the PA. */
420 struct hppa_fix_struct
422 /* The field selector. */
423 enum hppa_reloc_field_selector_type_alt fx_r_field
;
428 /* Format of fixup. */
431 /* Argument relocation bits. */
434 /* The segment this fixup appears in. */
438 /* Structure to hold information about predefined registers. */
446 /* This structure defines the mapping from a FP condition string
447 to a condition number which can be recorded in an instruction. */
454 /* This structure defines a mapping from a field selector
455 string to a field selector type. */
456 struct selector_entry
462 /* Prototypes for functions local to tc-hppa.c. */
464 static void pa_check_current_space_and_subspace
PARAMS ((void));
465 static fp_operand_format pa_parse_fp_format
PARAMS ((char **s
));
466 static void pa_cons
PARAMS ((int));
467 static void pa_data
PARAMS ((int));
468 static void pa_float_cons
PARAMS ((int));
469 static void pa_fill
PARAMS ((int));
470 static void pa_lcomm
PARAMS ((int));
471 static void pa_lsym
PARAMS ((int));
472 static void pa_stringer
PARAMS ((int));
473 static void pa_text
PARAMS ((int));
474 static void pa_version
PARAMS ((int));
475 static int pa_parse_fp_cmp_cond
PARAMS ((char **));
476 static int get_expression
PARAMS ((char *));
477 static int pa_get_absolute_expression
PARAMS ((struct pa_it
*, char **));
478 static int evaluate_absolute
PARAMS ((struct pa_it
*));
479 static unsigned int pa_build_arg_reloc
PARAMS ((char *));
480 static unsigned int pa_align_arg_reloc
PARAMS ((unsigned int, unsigned int));
481 static int pa_parse_nullif
PARAMS ((char **));
482 static int pa_parse_nonneg_cmpsub_cmpltr
PARAMS ((char **, int));
483 static int pa_parse_neg_cmpsub_cmpltr
PARAMS ((char **, int));
484 static int pa_parse_neg_add_cmpltr
PARAMS ((char **, int));
485 static int pa_parse_nonneg_add_cmpltr
PARAMS ((char **, int));
486 static void pa_align
PARAMS ((int));
487 static void pa_block
PARAMS ((int));
488 static void pa_brtab
PARAMS ((int));
489 static void pa_try
PARAMS ((int));
490 static void pa_call
PARAMS ((int));
491 static void pa_call_args
PARAMS ((struct call_desc
*));
492 static void pa_callinfo
PARAMS ((int));
493 static void pa_code
PARAMS ((int));
494 static void pa_comm
PARAMS ((int));
496 static void pa_compiler
PARAMS ((int));
498 static void pa_copyright
PARAMS ((int));
499 static void pa_end
PARAMS ((int));
500 static void pa_enter
PARAMS ((int));
501 static void pa_entry
PARAMS ((int));
502 static void pa_equ
PARAMS ((int));
503 static void pa_exit
PARAMS ((int));
504 static void pa_export
PARAMS ((int));
505 static void pa_type_args
PARAMS ((symbolS
*, int));
506 static void pa_import
PARAMS ((int));
507 static void pa_label
PARAMS ((int));
508 static void pa_leave
PARAMS ((int));
509 static void pa_level
PARAMS ((int));
510 static void pa_origin
PARAMS ((int));
511 static void pa_proc
PARAMS ((int));
512 static void pa_procend
PARAMS ((int));
513 static void pa_space
PARAMS ((int));
514 static void pa_spnum
PARAMS ((int));
515 static void pa_subspace
PARAMS ((int));
516 static void pa_param
PARAMS ((int));
517 static void pa_undefine_label
PARAMS ((void));
518 static int need_pa11_opcode
PARAMS ((struct pa_it
*,
519 struct pa_11_fp_reg_struct
*));
520 static int pa_parse_number
PARAMS ((char **, struct pa_11_fp_reg_struct
*));
521 static label_symbol_struct
*pa_get_label
PARAMS ((void));
522 static sd_chain_struct
*create_new_space
PARAMS ((char *, int, int,
525 static ssd_chain_struct
*create_new_subspace
PARAMS ((sd_chain_struct
*,
530 static ssd_chain_struct
*update_subspace
PARAMS ((sd_chain_struct
*,
531 char *, int, int, int,
535 static sd_chain_struct
*is_defined_space
PARAMS ((char *));
536 static ssd_chain_struct
*is_defined_subspace
PARAMS ((char *));
537 static sd_chain_struct
*pa_segment_to_space
PARAMS ((asection
*));
538 static ssd_chain_struct
*pa_subsegment_to_subspace
PARAMS ((asection
*,
540 static sd_chain_struct
*pa_find_space_by_number
PARAMS ((int));
541 static unsigned int pa_subspace_start
PARAMS ((sd_chain_struct
*, int));
542 static void pa_ip
PARAMS ((char *));
543 static void fix_new_hppa
PARAMS ((fragS
*, int, int, symbolS
*,
544 long, expressionS
*, int,
545 bfd_reloc_code_real_type
,
546 enum hppa_reloc_field_selector_type_alt
,
548 static int is_end_of_statement
PARAMS ((void));
549 static int reg_name_search
PARAMS ((char *));
550 static int pa_chk_field_selector
PARAMS ((char **));
551 static int is_same_frag
PARAMS ((fragS
*, fragS
*));
552 static void process_exit
PARAMS ((void));
553 static sd_chain_struct
*pa_parse_space_stmt
PARAMS ((char *, int));
554 static int log2
PARAMS ((int));
555 static int pa_next_subseg
PARAMS ((sd_chain_struct
*));
556 static unsigned int pa_stringer_aux
PARAMS ((char *));
557 static void pa_spaces_begin
PARAMS ((void));
560 static void hppa_elf_mark_end_of_function
PARAMS ((void));
561 static void pa_build_unwind_subspace
PARAMS ((struct call_info
*));
564 /* File and gloally scoped variable declarations. */
566 /* Root and final entry in the space chain. */
567 static sd_chain_struct
*space_dict_root
;
568 static sd_chain_struct
*space_dict_last
;
570 /* The current space and subspace. */
571 static sd_chain_struct
*current_space
;
572 static ssd_chain_struct
*current_subspace
;
574 /* Root of the call_info chain. */
575 static struct call_info
*call_info_root
;
577 /* The last call_info (for functions) structure
578 seen so it can be associated with fixups and
580 static struct call_info
*last_call_info
;
582 /* The last call description (for actual calls). */
583 static struct call_desc last_call_desc
;
585 /* handle of the OPCODE hash table */
586 static struct hash_control
*op_hash
= NULL
;
588 /* This array holds the chars that always start a comment. If the
589 pre-processor is disabled, these aren't very useful. */
590 const char comment_chars
[] = ";";
592 /* Table of pseudo ops for the PA. FIXME -- how many of these
593 are now redundant with the overall GAS and the object file
595 const pseudo_typeS md_pseudo_table
[] =
597 /* align pseudo-ops on the PA specify the actual alignment requested,
598 not the log2 of the requested alignment. */
599 {"align", pa_align
, 8},
600 {"begin_brtab", pa_brtab
, 1},
601 {"begin_try", pa_try
, 1},
602 {"block", pa_block
, 1},
603 {"blockz", pa_block
, 0},
604 {"byte", pa_cons
, 1},
605 {"call", pa_call
, 0},
606 {"callinfo", pa_callinfo
, 0},
607 {"code", pa_code
, 0},
608 {"comm", pa_comm
, 0},
610 {"compiler", pa_compiler
, 0},
612 {"copyright", pa_copyright
, 0},
613 {"data", pa_data
, 0},
614 {"double", pa_float_cons
, 'd'},
616 {"end_brtab", pa_brtab
, 0},
617 {"end_try", pa_try
, 0},
618 {"enter", pa_enter
, 0},
619 {"entry", pa_entry
, 0},
621 {"exit", pa_exit
, 0},
622 {"export", pa_export
, 0},
623 {"fill", pa_fill
, 0},
624 {"float", pa_float_cons
, 'f'},
625 {"half", pa_cons
, 2},
626 {"import", pa_import
, 0},
628 {"label", pa_label
, 0},
629 {"lcomm", pa_lcomm
, 0},
630 {"leave", pa_leave
, 0},
631 {"level", pa_level
, 0},
632 {"long", pa_cons
, 4},
633 {"lsym", pa_lsym
, 0},
634 {"nsubspa", pa_subspace
, 1},
635 {"octa", pa_cons
, 16},
636 {"org", pa_origin
, 0},
637 {"origin", pa_origin
, 0},
638 {"param", pa_param
, 0},
639 {"proc", pa_proc
, 0},
640 {"procend", pa_procend
, 0},
641 {"quad", pa_cons
, 8},
643 {"short", pa_cons
, 2},
644 {"single", pa_float_cons
, 'f'},
645 {"space", pa_space
, 0},
646 {"spnum", pa_spnum
, 0},
647 {"string", pa_stringer
, 0},
648 {"stringz", pa_stringer
, 1},
649 {"subspa", pa_subspace
, 0},
650 {"text", pa_text
, 0},
651 {"version", pa_version
, 0},
652 {"word", pa_cons
, 4},
656 /* This array holds the chars that only start a comment at the beginning of
657 a line. If the line seems to have the form '# 123 filename'
658 .line and .file directives will appear in the pre-processed output.
660 Note that input_file.c hand checks for '#' at the beginning of the
661 first line of the input file. This is because the compiler outputs
662 #NO_APP at the beginning of its output.
664 Also note that C style comments will always work. */
665 const char line_comment_chars
[] = "#";
667 /* This array holds the characters which act as line separators. */
668 const char line_separator_chars
[] = "!";
670 /* Chars that can be used to separate mant from exp in floating point nums. */
671 const char EXP_CHARS
[] = "eE";
673 /* Chars that mean this number is a floating point constant.
674 As in 0f12.456 or 0d1.2345e12.
676 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
677 changed in read.c. Ideally it shouldn't hae to know abou it at
678 all, but nothing is ideal around here. */
679 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
681 static struct pa_it the_insn
;
683 /* Points to the end of an expression just parsed by get_expressoin
684 and friends. FIXME. This shouldn't be handled with a file-global
686 static char *expr_end
;
688 /* Nonzero if a .callinfo appeared within the current procedure. */
689 static int callinfo_found
;
691 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
692 static int within_entry_exit
;
694 /* Nonzero if the assembler is currently within a procedure definition. */
695 static int within_procedure
;
697 /* Handle on strucutre which keep track of the last symbol
698 seen in each subspace. */
699 static label_symbol_struct
*label_symbols_rootp
= NULL
;
701 /* Holds the last field selector. */
702 static int hppa_field_selector
;
705 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
706 static symbolS
*dummy_symbol
;
708 /* Nonzero if errors are to be printed. */
709 static int print_errors
= 1;
711 /* List of registers that are pre-defined:
713 Each general register has one predefined name of the form
714 %r<REGNUM> which has the value <REGNUM>.
716 Space and control registers are handled in a similar manner,
717 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
719 Likewise for the floating point registers, but of the form
720 %fr<REGNUM>. Floating point registers have additional predefined
721 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
722 again have the value <REGNUM>.
724 Many registers also have synonyms:
726 %r26 - %r23 have %arg0 - %arg3 as synonyms
727 %r28 - %r29 have %ret0 - %ret1 as synonyms
728 %r30 has %sp as a synonym
729 %r27 has %dp as a synonym
730 %r2 has %rp as a synonym
732 Almost every control register has a synonym; they are not listed
735 The table is sorted. Suitable for searching by a binary search. */
737 static const struct pd_reg pre_defined_registers
[] =
937 /* This table is sorted by order of the length of the string. This is
938 so we check for <> before we check for <. If we had a <> and checked
939 for < first, we would get a false match. */
940 static const struct fp_cond_map fp_cond_map
[] =
976 static const struct selector_entry selector_table
[] =
998 /* default space and subspace dictionaries */
1000 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1001 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1003 /* pre-defined subsegments (subspaces) for the HPPA. */
1004 #define SUBSEG_CODE 0
1005 #define SUBSEG_LIT 1
1006 #define SUBSEG_MILLI 2
1007 #define SUBSEG_DATA 0
1008 #define SUBSEG_BSS 2
1009 #define SUBSEG_UNWIND 3
1010 #define SUBSEG_GDB_STRINGS 0
1011 #define SUBSEG_GDB_SYMBOLS 1
1013 static struct default_subspace_dict pa_def_subspaces
[] =
1015 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_CODE
},
1016 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, ".data", SUBSEG_DATA
},
1017 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_LIT
},
1018 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_MILLI
},
1019 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, ".bss", SUBSEG_BSS
},
1021 {"$UNWIND$", 1, 1, 0, 0, 0, 0, 64, 0x2c, 0, 4, 0, 0, ".PARISC.unwind", SUBSEG_UNWIND
},
1023 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1026 static struct default_space_dict pa_def_spaces
[] =
1028 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
, ".text"},
1029 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
, ".data"},
1030 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
, NULL
}
1033 /* Misc local definitions used by the assembler. */
1035 /* Return nonzero if the string pointed to by S potentially represents
1036 a right or left half of a FP register */
1037 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1038 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1040 /* These macros are used to maintain spaces/subspaces. */
1041 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1042 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1043 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1044 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1046 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1047 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1049 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1050 main loop after insertion. */
1052 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1054 ((OPCODE) |= (FIELD) << (START)); \
1058 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1059 IGNORE is used to suppress the error message. */
1061 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1063 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1066 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1072 #define is_DP_relative(exp) \
1073 ((exp).X_op == O_subtract \
1074 && strcmp((exp).X_op_symbol->bsym->name, "$global$") == 0)
1076 #define is_PC_relative(exp) \
1077 ((exp).X_op == O_subtract \
1078 && strcmp((exp).X_op_symbol->bsym->name, "$PIC_pcrel$0") == 0)
1080 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1081 always be able to reduce the expression to a constant, so we don't
1082 need real complex handling yet. */
1083 #define is_complex(exp) \
1084 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1086 /* Actual functions to implement the PA specific code for the assembler. */
1088 /* Called before writing the object file. Make sure entry/exit and
1089 proc/procend pairs match. */
1094 if (within_entry_exit
)
1095 as_fatal (_("Missing .exit\n"));
1097 if (within_procedure
)
1098 as_fatal (_("Missing .procend\n"));
1101 /* Check to make sure we have a valid space and subspace. */
1104 pa_check_current_space_and_subspace ()
1106 if (current_space
== NULL
)
1107 as_fatal (_("Not in a space.\n"));
1109 if (current_subspace
== NULL
)
1110 as_fatal (_("Not in a subspace.\n"));
1113 /* Returns a pointer to the label_symbol_struct for the current space.
1114 or NULL if no label_symbol_struct exists for the current space. */
1116 static label_symbol_struct
*
1119 label_symbol_struct
*label_chain
;
1120 sd_chain_struct
*space_chain
= current_space
;
1122 for (label_chain
= label_symbols_rootp
;
1124 label_chain
= label_chain
->lss_next
)
1125 if (space_chain
== label_chain
->lss_space
&& label_chain
->lss_label
)
1131 /* Defines a label for the current space. If one is already defined,
1132 this function will replace it with the new label. */
1135 pa_define_label (symbol
)
1138 label_symbol_struct
*label_chain
= pa_get_label ();
1139 sd_chain_struct
*space_chain
= current_space
;
1142 label_chain
->lss_label
= symbol
;
1145 /* Create a new label entry and add it to the head of the chain. */
1147 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1148 label_chain
->lss_label
= symbol
;
1149 label_chain
->lss_space
= space_chain
;
1150 label_chain
->lss_next
= NULL
;
1152 if (label_symbols_rootp
)
1153 label_chain
->lss_next
= label_symbols_rootp
;
1155 label_symbols_rootp
= label_chain
;
1159 /* Removes a label definition for the current space.
1160 If there is no label_symbol_struct entry, then no action is taken. */
1163 pa_undefine_label ()
1165 label_symbol_struct
*label_chain
;
1166 label_symbol_struct
*prev_label_chain
= NULL
;
1167 sd_chain_struct
*space_chain
= current_space
;
1169 for (label_chain
= label_symbols_rootp
;
1171 label_chain
= label_chain
->lss_next
)
1173 if (space_chain
== label_chain
->lss_space
&& label_chain
->lss_label
)
1175 /* Remove the label from the chain and free its memory. */
1176 if (prev_label_chain
)
1177 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1179 label_symbols_rootp
= label_chain
->lss_next
;
1184 prev_label_chain
= label_chain
;
1189 /* An HPPA-specific version of fix_new. This is required because the HPPA
1190 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1191 results in the creation of an instance of an hppa_fix_struct. An
1192 hppa_fix_struct stores the extra information along with a pointer to the
1193 original fixS. This is attached to the original fixup via the
1194 tc_fix_data field. */
1197 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1198 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1202 symbolS
*add_symbol
;
1206 bfd_reloc_code_real_type r_type
;
1207 enum hppa_reloc_field_selector_type_alt r_field
;
1214 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1215 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1218 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1220 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1221 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1222 hppa_fix
->fx_r_type
= r_type
;
1223 hppa_fix
->fx_r_field
= r_field
;
1224 hppa_fix
->fx_r_format
= r_format
;
1225 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1226 hppa_fix
->segment
= now_seg
;
1228 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1229 new_fix
->fx_offset
= *unwind_bits
;
1232 /* foo-$global$ is used to access non-automatic storage. $global$
1233 is really just a marker and has served its purpose, so eliminate
1234 it now so as not to confuse write.c. */
1235 if (new_fix
->fx_subsy
1236 && !strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$"))
1237 new_fix
->fx_subsy
= NULL
;
1240 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1241 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1244 parse_cons_expression_hppa (exp
)
1247 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1251 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1252 hppa_field_selector is set by the parse_cons_expression_hppa. */
1255 cons_fix_new_hppa (frag
, where
, size
, exp
)
1261 unsigned int rel_type
;
1263 /* Get a base relocation type. */
1264 if (is_DP_relative (*exp
))
1265 rel_type
= R_HPPA_GOTOFF
;
1266 else if (is_complex (*exp
))
1267 rel_type
= R_HPPA_COMPLEX
;
1271 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1272 as_warn (_("Invalid field selector. Assuming F%%."));
1274 fix_new_hppa (frag
, where
, size
,
1275 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1276 hppa_field_selector
, 32, 0, NULL
);
1278 /* Reset field selector to its default state. */
1279 hppa_field_selector
= 0;
1282 /* This function is called once, at assembler startup time. It should
1283 set up all the tables, etc. that the MD part of the assembler will need. */
1288 const char *retval
= NULL
;
1292 last_call_info
= NULL
;
1293 call_info_root
= NULL
;
1295 /* Set the default machine type. */
1296 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1297 as_warn (_("could not set architecture and machine"));
1299 /* Folding of text and data segments fails miserably on the PA.
1300 Warn user and disable "-R" option. */
1301 if (flag_readonly_data_in_text
)
1303 as_warn (_("-R option not supported on this target."));
1304 flag_readonly_data_in_text
= 0;
1309 op_hash
= hash_new ();
1311 while (i
< NUMOPCODES
)
1313 const char *name
= pa_opcodes
[i
].name
;
1314 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1315 if (retval
!= NULL
&& *retval
!= '\0')
1317 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1322 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1323 != pa_opcodes
[i
].match
)
1325 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1326 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1331 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1335 as_fatal (_("Broken assembler. No assembly attempted."));
1337 /* SOM will change text_section. To make sure we never put
1338 anything into the old one switch to the new one now. */
1339 subseg_set (text_section
, 0);
1341 dummy_symbol
= symbol_find_or_make ("L$dummy");
1342 S_SET_SEGMENT (dummy_symbol
, text_section
);
1345 /* Assemble a single instruction storing it into a frag. */
1352 /* The had better be something to assemble. */
1355 /* If we are within a procedure definition, make sure we've
1356 defined a label for the procedure; handle case where the
1357 label was defined after the .PROC directive.
1359 Note there's not need to diddle with the segment or fragment
1360 for the label symbol in this case. We have already switched
1361 into the new $CODE$ subspace at this point. */
1362 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1364 label_symbol_struct
*label_symbol
= pa_get_label ();
1368 if (label_symbol
->lss_label
)
1370 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1371 label_symbol
->lss_label
->bsym
->flags
|= BSF_FUNCTION
;
1373 /* Also handle allocation of a fixup to hold the unwind
1374 information when the label appears after the proc/procend. */
1375 if (within_entry_exit
)
1377 char *where
= frag_more (0);
1379 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1380 NULL
, (offsetT
) 0, NULL
,
1381 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1382 (int *)&last_call_info
->ci_unwind
.descriptor
);
1387 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1390 as_bad (_("Missing function name for .PROC"));
1393 /* Assemble the instruction. Results are saved into "the_insn". */
1396 /* Get somewhere to put the assembled instrution. */
1399 /* Output the opcode. */
1400 md_number_to_chars (to
, the_insn
.opcode
, 4);
1402 /* If necessary output more stuff. */
1403 if (the_insn
.reloc
!= R_HPPA_NONE
)
1404 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1405 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1406 the_insn
.reloc
, the_insn
.field_selector
,
1407 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1410 /* Do the real work for assembling a single instruction. Store results
1411 into the global "the_insn" variable. */
1417 char *error_message
= "";
1418 char *s
, c
, *argstart
, *name
, *save_s
;
1422 int cmpltr
, nullif
, flag
, cond
, num
;
1423 unsigned long opcode
;
1424 struct pa_opcode
*insn
;
1426 /* We must have a valid space and subspace. */
1427 pa_check_current_space_and_subspace ();
1429 /* Skip to something interesting. */
1430 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1449 as_fatal (_("Unknown opcode: `%s'"), str
);
1454 /* Convert everything into lower case. */
1457 if (isupper (*save_s
))
1458 *save_s
= tolower (*save_s
);
1462 /* Look up the opcode in the has table. */
1463 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1465 as_bad ("Unknown opcode: `%s'", str
);
1474 /* Mark the location where arguments for the instruction start, then
1475 start processing them. */
1479 /* Do some initialization. */
1480 opcode
= insn
->match
;
1481 memset (&the_insn
, 0, sizeof (the_insn
));
1483 the_insn
.reloc
= R_HPPA_NONE
;
1485 /* If this instruction is specific to a particular architecture,
1486 then set a new architecture. */
1487 /* But do not automatically promote to pa2.0. The automatic promotion
1488 crud is for compatability with HP's old assemblers only. */
1490 && bfd_get_mach (stdoutput
) < insn
->arch
)
1492 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1493 as_warn (_("could not update architecture and machine"));
1495 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1501 /* Build the opcode, checking as we go to make
1502 sure that the operands match. */
1503 for (args
= insn
->args
;; ++args
)
1508 /* End of arguments. */
1524 /* These must match exactly. */
1533 /* Handle a 5 bit register or control register field at 10. */
1536 num
= pa_parse_number (&s
, 0);
1537 CHECK_FIELD (num
, 31, 0, 0);
1538 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1540 /* Handle a 5 bit register field at 15. */
1542 num
= pa_parse_number (&s
, 0);
1543 CHECK_FIELD (num
, 31, 0, 0);
1544 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1546 /* Handle a 5 bit register field at 31. */
1549 num
= pa_parse_number (&s
, 0);
1550 CHECK_FIELD (num
, 31, 0, 0);
1551 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1553 /* Handle a 5 bit field length at 31. */
1555 num
= pa_get_absolute_expression (&the_insn
, &s
);
1557 CHECK_FIELD (num
, 32, 1, 0);
1558 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1560 /* Handle a 5 bit immediate at 15. */
1562 num
= pa_get_absolute_expression (&the_insn
, &s
);
1564 CHECK_FIELD (num
, 15, -16, 0);
1565 low_sign_unext (num
, 5, &num
);
1566 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1568 /* Handle a 5 bit immediate at 31. */
1570 num
= pa_get_absolute_expression (&the_insn
, &s
);
1572 CHECK_FIELD (num
, 15, -16, 0)
1573 low_sign_unext (num
, 5, &num
);
1574 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1576 /* Handle an unsigned 5 bit immediate at 31. */
1578 num
= pa_get_absolute_expression (&the_insn
, &s
);
1580 CHECK_FIELD (num
, 31, 0, 0);
1581 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1583 /* Handle an unsigned 5 bit immediate at 15. */
1585 num
= pa_get_absolute_expression (&the_insn
, &s
);
1587 CHECK_FIELD (num
, 31, 0, 0);
1588 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1590 /* Handle a 2 bit space identifier at 17. */
1592 num
= pa_parse_number (&s
, 0);
1593 CHECK_FIELD (num
, 3, 0, 1);
1594 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1596 /* Handle a 3 bit space identifier at 18. */
1598 num
= pa_parse_number (&s
, 0);
1599 CHECK_FIELD (num
, 7, 0, 1);
1600 dis_assemble_3 (num
, &num
);
1601 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
1603 /* Handle a completer for an indexing load or store. */
1609 while (*s
== ',' && i
< 2)
1612 if (strncasecmp (s
, "sm", 2) == 0)
1619 else if (strncasecmp (s
, "m", 1) == 0)
1621 else if (strncasecmp (s
, "s", 1) == 0)
1624 as_bad (_("Invalid Indexed Load Completer."));
1629 as_bad (_("Invalid Indexed Load Completer Syntax."));
1631 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1634 /* Handle a short load/store completer. */
1642 if (strncasecmp (s
, "ma", 2) == 0)
1647 else if (strncasecmp (s
, "mb", 2) == 0)
1653 as_bad (_("Invalid Short Load/Store Completer."));
1660 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1664 /* Handle a stbys completer. */
1670 while (*s
== ',' && i
< 2)
1673 if (strncasecmp (s
, "m", 1) == 0)
1675 else if (strncasecmp (s
, "b", 1) == 0)
1677 else if (strncasecmp (s
, "e", 1) == 0)
1680 as_bad (_("Invalid Store Bytes Short Completer"));
1685 as_bad (_("Invalid Store Bytes Short Completer"));
1687 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1690 /* Handle a non-negated compare/stubtract condition. */
1692 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
1695 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
1698 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1700 /* Handle a negated or non-negated compare/subtract condition. */
1703 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
1707 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
1710 as_bad (_("Invalid Compare/Subtract Condition."));
1715 /* Negated condition requires an opcode change. */
1720 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1722 /* Handle non-negated add condition. */
1724 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1727 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
1730 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1732 /* Handle a negated or non-negated add condition. */
1735 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1739 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
1742 as_bad (_("Invalid Compare/Subtract Condition"));
1747 /* Negated condition requires an opcode change. */
1751 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1753 /* Handle a compare/subtract condition. */
1761 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1765 if (strcmp (name
, "=") == 0)
1767 else if (strcmp (name
, "<") == 0)
1769 else if (strcmp (name
, "<=") == 0)
1771 else if (strcasecmp (name
, "<<") == 0)
1773 else if (strcasecmp (name
, "<<=") == 0)
1775 else if (strcasecmp (name
, "sv") == 0)
1777 else if (strcasecmp (name
, "od") == 0)
1779 else if (strcasecmp (name
, "tr") == 0)
1784 else if (strcmp (name
, "<>") == 0)
1789 else if (strcmp (name
, ">=") == 0)
1794 else if (strcmp (name
, ">") == 0)
1799 else if (strcasecmp (name
, ">>=") == 0)
1804 else if (strcasecmp (name
, ">>") == 0)
1809 else if (strcasecmp (name
, "nsv") == 0)
1814 else if (strcasecmp (name
, "ev") == 0)
1820 as_bad (_("Invalid Add Condition: %s"), name
);
1823 opcode
|= cmpltr
<< 13;
1824 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1826 /* Handle a non-negated add condition. */
1834 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1838 if (strcmp (name
, "=") == 0)
1840 else if (strcmp (name
, "<") == 0)
1842 else if (strcmp (name
, "<=") == 0)
1844 else if (strcasecmp (name
, "nuv") == 0)
1846 else if (strcasecmp (name
, "znv") == 0)
1848 else if (strcasecmp (name
, "sv") == 0)
1850 else if (strcasecmp (name
, "od") == 0)
1852 else if (strcasecmp (name
, "tr") == 0)
1857 else if (strcmp (name
, "<>") == 0)
1862 else if (strcmp (name
, ">=") == 0)
1867 else if (strcmp (name
, ">") == 0)
1872 else if (strcasecmp (name
, "uv") == 0)
1877 else if (strcasecmp (name
, "vnz") == 0)
1882 else if (strcasecmp (name
, "nsv") == 0)
1887 else if (strcasecmp (name
, "ev") == 0)
1893 as_bad (_("Invalid Add Condition: %s"), name
);
1896 opcode
|= cmpltr
<< 13;
1897 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1899 /* HANDLE a logical instruction condition. */
1907 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1913 if (strcmp (name
, "=") == 0)
1915 else if (strcmp (name
, "<") == 0)
1917 else if (strcmp (name
, "<=") == 0)
1919 else if (strcasecmp (name
, "od") == 0)
1921 else if (strcasecmp (name
, "tr") == 0)
1926 else if (strcmp (name
, "<>") == 0)
1931 else if (strcmp (name
, ">=") == 0)
1936 else if (strcmp (name
, ">") == 0)
1941 else if (strcasecmp (name
, "ev") == 0)
1947 as_bad (_("Invalid Logical Instruction Condition."));
1950 opcode
|= cmpltr
<< 13;
1951 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1953 /* Handle a unit instruction condition. */
1962 if (strncasecmp (s
, "sbz", 3) == 0)
1967 else if (strncasecmp (s
, "shz", 3) == 0)
1972 else if (strncasecmp (s
, "sdc", 3) == 0)
1977 else if (strncasecmp (s
, "sbc", 3) == 0)
1982 else if (strncasecmp (s
, "shc", 3) == 0)
1987 else if (strncasecmp (s
, "tr", 2) == 0)
1993 else if (strncasecmp (s
, "nbz", 3) == 0)
1999 else if (strncasecmp (s
, "nhz", 3) == 0)
2005 else if (strncasecmp (s
, "ndc", 3) == 0)
2011 else if (strncasecmp (s
, "nbc", 3) == 0)
2017 else if (strncasecmp (s
, "nhc", 3) == 0)
2024 as_bad (_("Invalid Logical Instruction Condition."));
2026 opcode
|= cmpltr
<< 13;
2027 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2029 /* Handle a shift/extract/deposit condition. */
2039 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2043 if (strcmp (name
, "=") == 0)
2045 else if (strcmp (name
, "<") == 0)
2047 else if (strcasecmp (name
, "od") == 0)
2049 else if (strcasecmp (name
, "tr") == 0)
2051 else if (strcmp (name
, "<>") == 0)
2053 else if (strcmp (name
, ">=") == 0)
2055 else if (strcasecmp (name
, "ev") == 0)
2057 /* Handle movb,n. Put things back the way they were.
2058 This includes moving s back to where it started. */
2059 else if (strcasecmp (name
, "n") == 0 && *args
== '|')
2066 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2069 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2071 /* Handle bvb and bb conditions. */
2077 if (strncmp (s
, "<", 1) == 0)
2082 else if (strncmp (s
, ">=", 2) == 0)
2088 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2090 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2092 /* Handle a system control completer. */
2094 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2102 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2104 /* Handle a nullification completer for branch instructions. */
2106 nullif
= pa_parse_nullif (&s
);
2107 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2109 /* Handle a nullification completer for copr and spop insns. */
2111 nullif
= pa_parse_nullif (&s
);
2112 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2115 /* Handle a 11 bit immediate at 31. */
2117 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2120 if (the_insn
.exp
.X_op
== O_constant
)
2122 num
= evaluate_absolute (&the_insn
);
2123 CHECK_FIELD (num
, 1023, -1024, 0);
2124 low_sign_unext (num
, 11, &num
);
2125 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2129 if (is_DP_relative (the_insn
.exp
))
2130 the_insn
.reloc
= R_HPPA_GOTOFF
;
2131 else if (is_PC_relative (the_insn
.exp
))
2132 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2134 the_insn
.reloc
= R_HPPA
;
2135 the_insn
.format
= 11;
2140 /* Handle a 14 bit immediate at 31. */
2142 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2145 if (the_insn
.exp
.X_op
== O_constant
)
2147 num
= evaluate_absolute (&the_insn
);
2148 CHECK_FIELD (num
, 8191, -8192, 0);
2149 low_sign_unext (num
, 14, &num
);
2150 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2154 if (is_DP_relative (the_insn
.exp
))
2155 the_insn
.reloc
= R_HPPA_GOTOFF
;
2156 else if (is_PC_relative (the_insn
.exp
))
2157 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2159 the_insn
.reloc
= R_HPPA
;
2160 the_insn
.format
= 14;
2164 /* Handle a 21 bit immediate at 31. */
2166 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2169 if (the_insn
.exp
.X_op
== O_constant
)
2171 num
= evaluate_absolute (&the_insn
);
2172 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
2173 dis_assemble_21 (num
, &num
);
2174 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2178 if (is_DP_relative (the_insn
.exp
))
2179 the_insn
.reloc
= R_HPPA_GOTOFF
;
2180 else if (is_PC_relative (the_insn
.exp
))
2181 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2183 the_insn
.reloc
= R_HPPA
;
2184 the_insn
.format
= 21;
2188 /* Handle a 12 bit branch displacement. */
2190 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2194 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
2196 unsigned int w1
, w
, result
;
2198 num
= evaluate_absolute (&the_insn
);
2201 as_bad (_("Branch to unaligned address"));
2204 CHECK_FIELD (num
, 8199, -8184, 0);
2205 sign_unext ((num
- 8) >> 2, 12, &result
);
2206 dis_assemble_12 (result
, &w1
, &w
);
2207 INSERT_FIELD_AND_CONTINUE (opcode
, ((w1
<< 2) | w
), 0);
2211 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2212 the_insn
.format
= 12;
2213 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2214 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2219 /* Handle a 17 bit branch displacement. */
2221 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2225 if (!the_insn
.exp
.X_add_symbol
2226 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2229 unsigned int w2
, w1
, w
, result
;
2231 num
= evaluate_absolute (&the_insn
);
2234 as_bad (_("Branch to unaligned address"));
2237 CHECK_FIELD (num
, 262143, -262144, 0);
2239 if (the_insn
.exp
.X_add_symbol
)
2242 sign_unext (num
>> 2, 17, &result
);
2243 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2244 INSERT_FIELD_AND_CONTINUE (opcode
,
2245 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2249 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2250 the_insn
.format
= 17;
2251 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2252 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2256 /* Handle an absolute 17 bit branch target. */
2258 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2262 if (!the_insn
.exp
.X_add_symbol
2263 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2266 unsigned int w2
, w1
, w
, result
;
2268 num
= evaluate_absolute (&the_insn
);
2271 as_bad (_("Branch to unaligned address"));
2274 CHECK_FIELD (num
, 262143, -262144, 0);
2276 if (the_insn
.exp
.X_add_symbol
)
2279 sign_unext (num
>> 2, 17, &result
);
2280 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2281 INSERT_FIELD_AND_CONTINUE (opcode
,
2282 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2286 the_insn
.reloc
= R_HPPA_ABS_CALL
;
2287 the_insn
.format
= 17;
2288 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2289 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2293 /* Handle a 5 bit shift count at 26. */
2295 num
= pa_get_absolute_expression (&the_insn
, &s
);
2297 CHECK_FIELD (num
, 31, 0, 0);
2298 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
2300 /* Handle a 5 bit bit position at 26. */
2302 num
= pa_get_absolute_expression (&the_insn
, &s
);
2304 CHECK_FIELD (num
, 31, 0, 0);
2305 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
2307 /* Handle a 5 bit immediate at 10. */
2310 num
= pa_get_absolute_expression (&the_insn
, &s
);
2311 if (the_insn
.exp
.X_op
!= O_constant
)
2314 CHECK_FIELD (num
, 31, 0, 0);
2315 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
2317 /* Handle a 13 bit immediate at 18. */
2319 num
= pa_get_absolute_expression (&the_insn
, &s
);
2321 CHECK_FIELD (num
, 8191, 0, 0);
2322 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2324 /* Handle a 26 bit immediate at 31. */
2326 num
= pa_get_absolute_expression (&the_insn
, &s
);
2328 CHECK_FIELD (num
, 671108864, 0, 0);
2329 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2331 /* Handle a 3 bit SFU identifier at 25. */
2334 as_bad (_("Invalid SFU identifier"));
2335 num
= pa_get_absolute_expression (&the_insn
, &s
);
2337 CHECK_FIELD (num
, 7, 0, 0);
2338 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2340 /* Handle a 20 bit SOP field for spop0. */
2342 num
= pa_get_absolute_expression (&the_insn
, &s
);
2344 CHECK_FIELD (num
, 1048575, 0, 0);
2345 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
2346 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2348 /* Handle a 15bit SOP field for spop1. */
2350 num
= pa_get_absolute_expression (&the_insn
, &s
);
2352 CHECK_FIELD (num
, 32767, 0, 0);
2353 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
2355 /* Handle a 10bit SOP field for spop3. */
2357 num
= pa_get_absolute_expression (&the_insn
, &s
);
2359 CHECK_FIELD (num
, 1023, 0, 0);
2360 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
2361 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2363 /* Handle a 15 bit SOP field for spop2. */
2365 num
= pa_get_absolute_expression (&the_insn
, &s
);
2367 CHECK_FIELD (num
, 32767, 0, 0);
2368 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
2369 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2371 /* Handle a 3-bit co-processor ID field. */
2374 as_bad (_("Invalid COPR identifier"));
2375 num
= pa_get_absolute_expression (&the_insn
, &s
);
2377 CHECK_FIELD (num
, 7, 0, 0);
2378 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2380 /* Handle a 22bit SOP field for copr. */
2382 num
= pa_get_absolute_expression (&the_insn
, &s
);
2384 CHECK_FIELD (num
, 4194303, 0, 0);
2385 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
2386 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2389 /* Handle a source FP operand format completer. */
2391 flag
= pa_parse_fp_format (&s
);
2392 the_insn
.fpof1
= flag
;
2393 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2395 /* Handle a destination FP operand format completer. */
2397 /* pa_parse_format needs the ',' prefix. */
2399 flag
= pa_parse_fp_format (&s
);
2400 the_insn
.fpof2
= flag
;
2401 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
2403 /* Handle FP compare conditions. */
2405 cond
= pa_parse_fp_cmp_cond (&s
);
2406 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2408 /* Handle L/R register halves like 't'. */
2411 struct pa_11_fp_reg_struct result
;
2413 pa_parse_number (&s
, &result
);
2414 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2415 opcode
|= result
.number_part
;
2417 /* 0x30 opcodes are FP arithmetic operation opcodes
2418 and need to be turned into 0x38 opcodes. This
2419 is not necessary for loads/stores. */
2420 if (need_pa11_opcode (&the_insn
, &result
)
2421 && ((opcode
& 0xfc000000) == 0x30000000))
2424 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
2427 /* Handle L/R register halves like 'b'. */
2430 struct pa_11_fp_reg_struct result
;
2432 pa_parse_number (&s
, &result
);
2433 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2434 opcode
|= result
.number_part
<< 21;
2435 if (need_pa11_opcode (&the_insn
, &result
))
2437 opcode
|= (result
.l_r_select
& 1) << 7;
2443 /* Handle L/R register halves like 'b'. */
2446 struct pa_11_fp_reg_struct result
;
2449 pa_parse_number (&s
, &result
);
2450 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2451 opcode
|= (result
.number_part
& 0x1c) << 11;
2452 opcode
|= (result
.number_part
& 0x3) << 9;
2453 opcode
|= (result
.l_r_select
& 1) << 8;
2457 /* Handle L/R register halves like 'x'. */
2460 struct pa_11_fp_reg_struct result
;
2462 pa_parse_number (&s
, &result
);
2463 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2464 opcode
|= (result
.number_part
& 0x1f) << 16;
2465 if (need_pa11_opcode (&the_insn
, &result
))
2467 opcode
|= (result
.l_r_select
& 1) << 1;
2472 /* Handle L/R register halves like 'x'. */
2475 struct pa_11_fp_reg_struct result
;
2477 pa_parse_number (&s
, &result
);
2478 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2479 opcode
|= (result
.number_part
& 0x1f) << 16;
2480 if (need_pa11_opcode (&the_insn
, &result
))
2482 opcode
|= (result
.l_r_select
& 1) << 12;
2488 /* Handle a 5 bit register field at 10. */
2491 struct pa_11_fp_reg_struct result
;
2493 pa_parse_number (&s
, &result
);
2494 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2495 if (the_insn
.fpof1
== SGL
)
2497 if (result
.number_part
< 16)
2499 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2503 result
.number_part
&= 0xF;
2504 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2506 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
2509 /* Handle a 5 bit register field at 15. */
2512 struct pa_11_fp_reg_struct result
;
2514 pa_parse_number (&s
, &result
);
2515 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2516 if (the_insn
.fpof1
== SGL
)
2518 if (result
.number_part
< 16)
2520 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2523 result
.number_part
&= 0xF;
2524 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2526 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
2529 /* Handle a 5 bit register field at 31. */
2532 struct pa_11_fp_reg_struct result
;
2534 pa_parse_number (&s
, &result
);
2535 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2536 if (the_insn
.fpof1
== SGL
)
2538 if (result
.number_part
< 16)
2540 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2543 result
.number_part
&= 0xF;
2544 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2546 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
2549 /* Handle a 5 bit register field at 20. */
2552 struct pa_11_fp_reg_struct result
;
2554 pa_parse_number (&s
, &result
);
2555 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2556 if (the_insn
.fpof1
== SGL
)
2558 if (result
.number_part
< 16)
2560 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2563 result
.number_part
&= 0xF;
2564 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2566 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
2569 /* Handle a 5 bit register field at 25. */
2572 struct pa_11_fp_reg_struct result
;
2574 pa_parse_number (&s
, &result
);
2575 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2576 if (the_insn
.fpof1
== SGL
)
2578 if (result
.number_part
< 16)
2580 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2583 result
.number_part
&= 0xF;
2584 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2586 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
2589 /* Handle a floating point operand format at 26.
2590 Only allows single and double precision. */
2592 flag
= pa_parse_fp_format (&s
);
2598 the_insn
.fpof1
= flag
;
2604 as_bad (_("Invalid Floating Point Operand Format."));
2615 /* Check if the args matched. */
2618 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
2619 && !strcmp (insn
->name
, insn
[1].name
))
2627 as_bad (_("Invalid operands %s"), error_message
);
2634 the_insn
.opcode
= opcode
;
2637 /* Turn a string in input_line_pointer into a floating point constant of type
2638 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
2639 emitted is stored in *sizeP . An error message or NULL is returned. */
2641 #define MAX_LITTLENUMS 6
2644 md_atof (type
, litP
, sizeP
)
2650 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
2651 LITTLENUM_TYPE
*wordP
;
2683 return _("Bad call to MD_ATOF()");
2685 t
= atof_ieee (input_line_pointer
, type
, words
);
2687 input_line_pointer
= t
;
2688 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
2689 for (wordP
= words
; prec
--;)
2691 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
2692 litP
+= sizeof (LITTLENUM_TYPE
);
2697 /* Write out big-endian. */
2700 md_number_to_chars (buf
, val
, n
)
2705 number_to_chars_bigendian (buf
, val
, n
);
2708 /* Translate internal representation of relocation info to BFD target
2712 tc_gen_reloc (section
, fixp
)
2717 struct hppa_fix_struct
*hppa_fixp
;
2718 bfd_reloc_code_real_type code
;
2719 static arelent
*no_relocs
= NULL
;
2721 bfd_reloc_code_real_type
**codes
;
2725 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
2726 if (fixp
->fx_addsy
== 0)
2728 assert (hppa_fixp
!= 0);
2729 assert (section
!= 0);
2731 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
2733 reloc
->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
2734 codes
= (bfd_reloc_code_real_type
**) hppa_gen_reloc_type (stdoutput
,
2736 hppa_fixp
->fx_r_format
,
2737 hppa_fixp
->fx_r_field
,
2738 fixp
->fx_subsy
!= NULL
,
2739 fixp
->fx_addsy
->bsym
);
2744 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
2747 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
2748 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
2749 for (i
= 0; i
< n_relocs
; i
++)
2750 relocs
[i
] = &reloc
[i
];
2752 relocs
[n_relocs
] = NULL
;
2755 switch (fixp
->fx_r_type
)
2758 assert (n_relocs
== 1);
2762 reloc
->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
2763 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2764 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2765 reloc
->addend
= 0; /* default */
2767 assert (reloc
->howto
&& code
== reloc
->howto
->type
);
2769 /* Now, do any processing that is dependent on the relocation type. */
2772 case R_PARISC_DLTREL21L
:
2773 case R_PARISC_DLTREL14R
:
2774 case R_PARISC_DLTREL14F
:
2775 case R_PARISC_PLABEL32
:
2776 case R_PARISC_PLABEL21L
:
2777 case R_PARISC_PLABEL14R
:
2778 /* For plabel relocations, the addend of the
2779 relocation should be either 0 (no static link) or 2
2780 (static link required).
2782 FIXME: We always assume no static link!
2784 We also slam a zero addend into the DLT relative relocs;
2785 it doesn't make a lot of sense to use any addend since
2786 it gets you a different (eg unknown) DLT entry. */
2790 case R_PARISC_PCREL21L
:
2791 case R_PARISC_PCREL17R
:
2792 case R_PARISC_PCREL17F
:
2793 case R_PARISC_PCREL17C
:
2794 case R_PARISC_PCREL14R
:
2795 case R_PARISC_PCREL14F
:
2796 /* The constant is stored in the instruction. */
2797 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
2800 reloc
->addend
= fixp
->fx_offset
;
2807 /* Walk over reach relocation returned by the BFD backend. */
2808 for (i
= 0; i
< n_relocs
; i
++)
2812 relocs
[i
]->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
2813 relocs
[i
]->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2814 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2819 /* The only time we ever use a R_COMP2 fixup is for the difference
2820 of two symbols. With that in mind we fill in all four
2821 relocs now and break out of the loop. */
2823 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &bfd_abs_symbol
;
2824 relocs
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[0]);
2825 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2826 relocs
[0]->addend
= 0;
2827 relocs
[1]->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
2828 relocs
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[1]);
2829 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2830 relocs
[1]->addend
= 0;
2831 relocs
[2]->sym_ptr_ptr
= &fixp
->fx_subsy
->bsym
;
2832 relocs
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[2]);
2833 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2834 relocs
[2]->addend
= 0;
2835 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &bfd_abs_symbol
;
2836 relocs
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[3]);
2837 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2838 relocs
[3]->addend
= 0;
2839 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &bfd_abs_symbol
;
2840 relocs
[4]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[4]);
2841 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2842 relocs
[4]->addend
= 0;
2846 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
2852 /* For plabel relocations, the addend of the
2853 relocation should be either 0 (no static link) or 2
2854 (static link required).
2856 FIXME: We always assume no static link!
2858 We also slam a zero addend into the DLT relative relocs;
2859 it doesn't make a lot of sense to use any addend since
2860 it gets you a different (eg unknown) DLT entry. */
2861 relocs
[i
]->addend
= 0;
2876 /* There is no symbol or addend associated with these fixups. */
2877 relocs
[i
]->sym_ptr_ptr
= &dummy_symbol
->bsym
;
2878 relocs
[i
]->addend
= 0;
2884 /* There is no symbol associated with these fixups. */
2885 relocs
[i
]->sym_ptr_ptr
= &dummy_symbol
->bsym
;
2886 relocs
[i
]->addend
= fixp
->fx_offset
;
2890 relocs
[i
]->addend
= fixp
->fx_offset
;
2900 /* Process any machine dependent frag types. */
2903 md_convert_frag (abfd
, sec
, fragP
)
2905 register asection
*sec
;
2906 register fragS
*fragP
;
2908 unsigned int address
;
2910 if (fragP
->fr_type
== rs_machine_dependent
)
2912 switch ((int) fragP
->fr_subtype
)
2915 fragP
->fr_type
= rs_fill
;
2916 know (fragP
->fr_var
== 1);
2917 know (fragP
->fr_next
);
2918 address
= fragP
->fr_address
+ fragP
->fr_fix
;
2919 if (address
% fragP
->fr_offset
)
2922 fragP
->fr_next
->fr_address
2927 fragP
->fr_offset
= 0;
2933 /* Round up a section size to the appropriate boundary. */
2936 md_section_align (segment
, size
)
2940 int align
= bfd_get_section_alignment (stdoutput
, segment
);
2941 int align2
= (1 << align
) - 1;
2943 return (size
+ align2
) & ~align2
;
2946 /* Return the approximate size of a frag before relaxation has occurred. */
2948 md_estimate_size_before_relax (fragP
, segment
)
2949 register fragS
*fragP
;
2956 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
2962 CONST
char *md_shortopts
= "";
2963 struct option md_longopts
[] = {
2964 {NULL
, no_argument
, NULL
, 0}
2966 size_t md_longopts_size
= sizeof(md_longopts
);
2969 md_parse_option (c
, arg
)
2977 md_show_usage (stream
)
2982 /* We have no need to default values of symbols. */
2985 md_undefined_symbol (name
)
2991 /* Apply a fixup to an instruction. */
2994 md_apply_fix (fixP
, valp
)
2998 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
2999 struct hppa_fix_struct
*hppa_fixP
;
3000 long new_val
, result
= 0;
3001 unsigned int w1
, w2
, w
, resulti
;
3003 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
3004 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
3005 never be "applied" (they are just markers). Likewise for
3006 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
3008 if (fixP
->fx_r_type
== R_HPPA_ENTRY
3009 || fixP
->fx_r_type
== R_HPPA_EXIT
3010 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
3011 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
3012 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
3015 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
3016 fixups are considered not adjustable, which in turn causes
3017 adjust_reloc_syms to not set fx_offset. Ugh. */
3018 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
3020 fixP
->fx_offset
= *valp
;
3025 /* There should have been an HPPA specific fixup associated
3026 with the GAS fixup. */
3029 unsigned long buf_wd
= bfd_get_32 (stdoutput
, buf
);
3030 unsigned char fmt
= bfd_hppa_insn2fmt (buf_wd
);
3032 /* If there is a symbol associated with this fixup, then it's something
3033 which will need a SOM relocation (except for some PC-relative relocs).
3034 In such cases we should treat the "val" or "addend" as zero since it
3035 will be added in as needed from fx_offset in tc_gen_reloc. */
3036 if ((fixP
->fx_addsy
!= NULL
3037 || fixP
->fx_r_type
== R_HPPA_NONE
)
3042 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3044 /* These field selectors imply that we do not want an addend. */
3045 else if (hppa_fixP
->fx_r_field
== e_psel
3046 || hppa_fixP
->fx_r_field
== e_rpsel
3047 || hppa_fixP
->fx_r_field
== e_lpsel
3048 || hppa_fixP
->fx_r_field
== e_tsel
3049 || hppa_fixP
->fx_r_field
== e_rtsel
3050 || hppa_fixP
->fx_r_field
== e_ltsel
)
3051 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3052 /* This is truely disgusting. The machine independent code blindly
3053 adds in the value of the symbol being relocated against. Damn! */
3055 && fixP
->fx_addsy
!= NULL
3056 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
3057 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
3058 0, hppa_fixP
->fx_r_field
);
3061 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3063 /* Handle pc-relative exceptions from above. */
3064 #define arg_reloc_stub_needed(CALLER, CALLEE) \
3065 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
3066 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
3069 && !arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
3070 fixP
->fx_addsy
->bsym
)->tc_data
.ap
.hppa_arg_reloc
,
3071 hppa_fixP
->fx_arg_reloc
)
3072 && (((int)(*valp
) > -262144 && (int)(*valp
) < 262143) && fmt
!= 22)
3073 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
3075 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
3077 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3078 #undef arg_reloc_stub_needed
3082 /* Handle all opcodes with the 'j' operand type. */
3084 CHECK_FIELD (new_val
, 8191, -8192, 0);
3086 /* Mask off 14 bits to be changed. */
3087 bfd_put_32 (stdoutput
,
3088 bfd_get_32 (stdoutput
, buf
) & 0xffffc000,
3090 low_sign_unext (new_val
, 14, &resulti
);
3094 /* Handle all opcodes with the 'k' operand type. */
3096 CHECK_FIELD (new_val
, 2097152, 0, 0);
3098 /* Mask off 21 bits to be changed. */
3099 bfd_put_32 (stdoutput
,
3100 bfd_get_32 (stdoutput
, buf
) & 0xffe00000,
3102 dis_assemble_21 (new_val
, &resulti
);
3106 /* Handle all the opcodes with the 'i' operand type. */
3108 CHECK_FIELD (new_val
, 1023, -1023, 0);
3110 /* Mask off 11 bits to be changed. */
3111 bfd_put_32 (stdoutput
,
3112 bfd_get_32 (stdoutput
, buf
) & 0xffff800,
3114 low_sign_unext (new_val
, 11, &resulti
);
3118 /* Handle all the opcodes with the 'w' operand type. */
3120 CHECK_FIELD (new_val
, 8199, -8184, 0);
3122 /* Mask off 11 bits to be changed. */
3123 sign_unext ((new_val
- 8) >> 2, 12, &resulti
);
3124 bfd_put_32 (stdoutput
,
3125 bfd_get_32 (stdoutput
, buf
) & 0xffffe002,
3128 dis_assemble_12 (resulti
, &w1
, &w
);
3129 result
= ((w1
<< 2) | w
);
3132 /* Handle some of the opcodes with the 'W' operand type. */
3135 int distance
= *valp
;
3137 CHECK_FIELD (new_val
, 262143, -262144, 0);
3139 /* If this is an absolute branch (ie no link) with an out of
3140 range target, then we want to complain. */
3141 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
3142 && (distance
> 262143 || distance
< -262144)
3143 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
3144 CHECK_FIELD (distance
, 262143, -262144, 0);
3146 /* Mask off 17 bits to be changed. */
3147 bfd_put_32 (stdoutput
,
3148 bfd_get_32 (stdoutput
, buf
) & 0xffe0e002,
3150 sign_unext ((new_val
- 8) >> 2, 17, &resulti
);
3151 dis_assemble_17 (resulti
, &w1
, &w2
, &w
);
3152 result
= ((w2
<< 2) | (w1
<< 16) | w
);
3158 bfd_put_32 (stdoutput
, new_val
, buf
);
3162 as_bad (_("Unknown relocation encountered in md_apply_fix."));
3166 /* Insert the relocation. */
3167 bfd_put_32 (stdoutput
, bfd_get_32 (stdoutput
, buf
) | result
, buf
);
3172 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
3173 (unsigned int) fixP
, fixP
->fx_r_type
);
3178 /* Exactly what point is a PC-relative offset relative TO?
3179 On the PA, they're relative to the address of the offset. */
3182 md_pcrel_from (fixP
)
3185 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
3188 /* Return nonzero if the input line pointer is at the end of
3192 is_end_of_statement ()
3194 return ((*input_line_pointer
== '\n')
3195 || (*input_line_pointer
== ';')
3196 || (*input_line_pointer
== '!'));
3199 /* Read a number from S. The number might come in one of many forms,
3200 the most common will be a hex or decimal constant, but it could be
3201 a pre-defined register (Yuk!), or an absolute symbol.
3203 Return a number or -1 for failure.
3205 When parsing PA-89 FP register numbers RESULT will be
3206 the address of a structure to return information about
3207 L/R half of FP registers, store results there as appropriate.
3209 pa_parse_number can not handle negative constants and will fail
3210 horribly if it is passed such a constant. */
3213 pa_parse_number (s
, result
)
3215 struct pa_11_fp_reg_struct
*result
;
3224 /* Skip whitespace before the number. */
3225 while (*p
== ' ' || *p
== '\t')
3228 /* Store info in RESULT if requested by caller. */
3231 result
->number_part
= -1;
3232 result
->l_r_select
= -1;
3238 /* Looks like a number. */
3241 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
3243 /* The number is specified in hex. */
3245 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
3246 || ((*p
>= 'A') && (*p
<= 'F')))
3249 num
= num
* 16 + *p
- '0';
3250 else if (*p
>= 'a' && *p
<= 'f')
3251 num
= num
* 16 + *p
- 'a' + 10;
3253 num
= num
* 16 + *p
- 'A' + 10;
3259 /* The number is specified in decimal. */
3260 while (isdigit (*p
))
3262 num
= num
* 10 + *p
- '0';
3267 /* Store info in RESULT if requested by the caller. */
3270 result
->number_part
= num
;
3272 if (IS_R_SELECT (p
))
3274 result
->l_r_select
= 1;
3277 else if (IS_L_SELECT (p
))
3279 result
->l_r_select
= 0;
3283 result
->l_r_select
= 0;
3288 /* The number might be a predefined register. */
3293 /* Tege hack: Special case for general registers as the general
3294 code makes a binary search with case translation, and is VERY
3299 if (*p
== 'e' && *(p
+ 1) == 't'
3300 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
3303 num
= *p
- '0' + 28;
3311 else if (!isdigit (*p
))
3314 as_bad (_("Undefined register: '%s'."), name
);
3320 num
= num
* 10 + *p
++ - '0';
3321 while (isdigit (*p
));
3326 /* Do a normal register search. */
3327 while (is_part_of_name (c
))
3333 status
= reg_name_search (name
);
3339 as_bad (_("Undefined register: '%s'."), name
);
3345 /* Store info in RESULT if requested by caller. */
3348 result
->number_part
= num
;
3349 if (IS_R_SELECT (p
- 1))
3350 result
->l_r_select
= 1;
3351 else if (IS_L_SELECT (p
- 1))
3352 result
->l_r_select
= 0;
3354 result
->l_r_select
= 0;
3359 /* And finally, it could be a symbol in the absolute section which
3360 is effectively a constant. */
3364 while (is_part_of_name (c
))
3370 if ((sym
= symbol_find (name
)) != NULL
)
3372 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
3373 num
= S_GET_VALUE (sym
);
3377 as_bad (_("Non-absolute symbol: '%s'."), name
);
3383 /* There is where we'd come for an undefined symbol
3384 or for an empty string. For an empty string we
3385 will return zero. That's a concession made for
3386 compatability with the braindamaged HP assemblers. */
3392 as_bad (_("Undefined absolute constant: '%s'."), name
);
3398 /* Store info in RESULT if requested by caller. */
3401 result
->number_part
= num
;
3402 if (IS_R_SELECT (p
- 1))
3403 result
->l_r_select
= 1;
3404 else if (IS_L_SELECT (p
- 1))
3405 result
->l_r_select
= 0;
3407 result
->l_r_select
= 0;
3415 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
3417 /* Given NAME, find the register number associated with that name, return
3418 the integer value associated with the given name or -1 on failure. */
3421 reg_name_search (name
)
3424 int middle
, low
, high
;
3428 high
= REG_NAME_CNT
- 1;
3432 middle
= (low
+ high
) / 2;
3433 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
3439 return pre_defined_registers
[middle
].value
;
3441 while (low
<= high
);
3447 /* Return nonzero if the given INSN and L/R information will require
3448 a new PA-1.1 opcode. */
3451 need_pa11_opcode (insn
, result
)
3453 struct pa_11_fp_reg_struct
*result
;
3455 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
3457 /* If this instruction is specific to a particular architecture,
3458 then set a new architecture. */
3459 if (bfd_get_mach (stdoutput
) < pa11
)
3461 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
3462 as_warn (_("could not update architecture and machine"));
3470 /* Parse a condition for a fcmp instruction. Return the numerical
3471 code associated with the condition. */
3474 pa_parse_fp_cmp_cond (s
)
3481 for (i
= 0; i
< 32; i
++)
3483 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
3484 strlen (fp_cond_map
[i
].string
)) == 0)
3486 cond
= fp_cond_map
[i
].cond
;
3487 *s
+= strlen (fp_cond_map
[i
].string
);
3488 /* If not a complete match, back up the input string and
3490 if (**s
!= ' ' && **s
!= '\t')
3492 *s
-= strlen (fp_cond_map
[i
].string
);
3495 while (**s
== ' ' || **s
== '\t')
3501 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
3503 /* Advance over the bogus completer. */
3504 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3511 /* Parse an FP operand format completer returning the completer
3514 static fp_operand_format
3515 pa_parse_fp_format (s
)
3524 if (strncasecmp (*s
, "sgl", 3) == 0)
3529 else if (strncasecmp (*s
, "dbl", 3) == 0)
3534 else if (strncasecmp (*s
, "quad", 4) == 0)
3541 format
= ILLEGAL_FMT
;
3542 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
3549 /* Convert from a selector string into a selector type. */
3552 pa_chk_field_selector (str
)
3555 int middle
, low
, high
;
3559 /* Read past any whitespace. */
3560 /* FIXME: should we read past newlines and formfeeds??? */
3561 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
3564 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
3565 name
[0] = tolower ((*str
)[0]),
3567 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
3568 name
[0] = tolower ((*str
)[0]),
3569 name
[1] = tolower ((*str
)[1]),
3572 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
3573 name
[0] = tolower ((*str
)[0]),
3574 name
[1] = tolower ((*str
)[1]),
3575 name
[2] = tolower ((*str
)[2]),
3582 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
3586 middle
= (low
+ high
) / 2;
3587 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
3594 *str
+= strlen (name
) + 1;
3596 if (selector_table
[middle
].field_selector
== e_nsel
)
3599 return selector_table
[middle
].field_selector
;
3602 while (low
<= high
);
3607 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
3610 get_expression (str
)
3616 save_in
= input_line_pointer
;
3617 input_line_pointer
= str
;
3618 seg
= expression (&the_insn
.exp
);
3619 if (!(seg
== absolute_section
3620 || seg
== undefined_section
3621 || SEG_NORMAL (seg
)))
3623 as_warn (_("Bad segment in expression."));
3624 expr_end
= input_line_pointer
;
3625 input_line_pointer
= save_in
;
3628 expr_end
= input_line_pointer
;
3629 input_line_pointer
= save_in
;
3633 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
3635 pa_get_absolute_expression (insn
, strp
)
3641 insn
->field_selector
= pa_chk_field_selector (strp
);
3642 save_in
= input_line_pointer
;
3643 input_line_pointer
= *strp
;
3644 expression (&insn
->exp
);
3645 /* This is not perfect, but is a huge improvement over doing nothing.
3647 The PA assembly syntax is ambigious in a variety of ways. Consider
3648 this string "4 %r5" Is that the number 4 followed by the register
3649 r5, or is that 4 MOD 5?
3651 If we get a modulo expresion When looking for an absolute, we try
3652 again cutting off the input string at the first whitespace character. */
3653 if (insn
->exp
.X_op
== O_modulus
)
3658 input_line_pointer
= *strp
;
3660 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
3666 retval
= pa_get_absolute_expression (insn
, strp
);
3668 input_line_pointer
= save_in
;
3670 return evaluate_absolute (insn
);
3672 if (insn
->exp
.X_op
!= O_constant
)
3674 as_bad (_("Bad segment (should be absolute)."));
3675 expr_end
= input_line_pointer
;
3676 input_line_pointer
= save_in
;
3679 expr_end
= input_line_pointer
;
3680 input_line_pointer
= save_in
;
3681 return evaluate_absolute (insn
);
3684 /* Evaluate an absolute expression EXP which may be modified by
3685 the selector FIELD_SELECTOR. Return the value of the expression. */
3687 evaluate_absolute (insn
)
3692 int field_selector
= insn
->field_selector
;
3695 value
= exp
.X_add_number
;
3697 switch (field_selector
)
3703 /* If bit 21 is on then add 0x800 and arithmetic shift right 11 bits. */
3705 if (value
& 0x00000400)
3707 value
= (value
& 0xfffff800) >> 11;
3710 /* Sign extend from bit 21. */
3712 if (value
& 0x00000400)
3713 value
|= 0xfffff800;
3718 /* Arithmetic shift right 11 bits. */
3720 value
= (value
& 0xfffff800) >> 11;
3723 /* Set bits 0-20 to zero. */
3725 value
= value
& 0x7ff;
3728 /* Add 0x800 and arithmetic shift right 11 bits. */
3731 value
= (value
& 0xfffff800) >> 11;
3734 /* Set bitgs 0-21 to one. */
3736 value
|= 0xfffff800;
3739 #define RSEL_ROUND(c) (((c) + 0x1000) & ~0x1fff)
3741 value
= (RSEL_ROUND (value
) & 0x7ff) + (value
- RSEL_ROUND (value
));
3745 value
= (RSEL_ROUND (value
) >> 11) & 0x1fffff;
3750 BAD_CASE (field_selector
);
3756 /* Given an argument location specification return the associated
3757 argument location number. */
3760 pa_build_arg_reloc (type_name
)
3764 if (strncasecmp (type_name
, "no", 2) == 0)
3766 if (strncasecmp (type_name
, "gr", 2) == 0)
3768 else if (strncasecmp (type_name
, "fr", 2) == 0)
3770 else if (strncasecmp (type_name
, "fu", 2) == 0)
3773 as_bad (_("Invalid argument location: %s\n"), type_name
);
3778 /* Encode and return an argument relocation specification for
3779 the given register in the location specified by arg_reloc. */
3782 pa_align_arg_reloc (reg
, arg_reloc
)
3784 unsigned int arg_reloc
;
3786 unsigned int new_reloc
;
3788 new_reloc
= arg_reloc
;
3804 as_bad (_("Invalid argument description: %d"), reg
);
3810 /* Parse a PA nullification completer (,n). Return nonzero if the
3811 completer was found; return zero if no completer was found. */
3823 if (strncasecmp (*s
, "n", 1) == 0)
3827 as_bad (_("Invalid Nullification: (%c)"), **s
);
3836 /* Parse a non-negated compare/subtract completer returning the
3837 number (for encoding in instrutions) of the given completer.
3839 ISBRANCH specifies whether or not this is parsing a condition
3840 completer for a branch (vs a nullification completer for a
3841 computational instruction. */
3844 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
3849 char *name
= *s
+ 1;
3858 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3864 if (strcmp (name
, "=") == 0)
3868 else if (strcmp (name
, "<") == 0)
3872 else if (strcmp (name
, "<=") == 0)
3876 else if (strcmp (name
, "<<") == 0)
3880 else if (strcmp (name
, "<<=") == 0)
3884 else if (strcasecmp (name
, "sv") == 0)
3888 else if (strcasecmp (name
, "od") == 0)
3892 /* If we have something like addb,n then there is no condition
3894 else if (strcasecmp (name
, "n") == 0 && isbranch
)
3906 /* Reset pointers if this was really a ,n for a branch instruction. */
3914 /* Parse a negated compare/subtract completer returning the
3915 number (for encoding in instrutions) of the given completer.
3917 ISBRANCH specifies whether or not this is parsing a condition
3918 completer for a branch (vs a nullification completer for a
3919 computational instruction. */
3922 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
3927 char *name
= *s
+ 1;
3936 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3942 if (strcasecmp (name
, "tr") == 0)
3946 else if (strcmp (name
, "<>") == 0)
3950 else if (strcmp (name
, ">=") == 0)
3954 else if (strcmp (name
, ">") == 0)
3958 else if (strcmp (name
, ">>=") == 0)
3962 else if (strcmp (name
, ">>") == 0)
3966 else if (strcasecmp (name
, "nsv") == 0)
3970 else if (strcasecmp (name
, "ev") == 0)
3974 /* If we have something like addb,n then there is no condition
3976 else if (strcasecmp (name
, "n") == 0 && isbranch
)
3988 /* Reset pointers if this was really a ,n for a branch instruction. */
3997 /* Parse a non-negated addition completer returning the number
3998 (for encoding in instrutions) of the given completer.
4000 ISBRANCH specifies whether or not this is parsing a condition
4001 completer for a branch (vs a nullification completer for a
4002 computational instruction. */
4005 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
4010 char *name
= *s
+ 1;
4018 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4022 if (strcmp (name
, "=") == 0)
4026 else if (strcmp (name
, "<") == 0)
4030 else if (strcmp (name
, "<=") == 0)
4034 else if (strcasecmp (name
, "nuv") == 0)
4038 else if (strcasecmp (name
, "znv") == 0)
4042 else if (strcasecmp (name
, "sv") == 0)
4046 else if (strcasecmp (name
, "od") == 0)
4050 /* If we have something like addb,n then there is no condition
4052 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4063 /* Reset pointers if this was really a ,n for a branch instruction. */
4064 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4070 /* Parse a negated addition completer returning the number
4071 (for encoding in instrutions) of the given completer.
4073 ISBRANCH specifies whether or not this is parsing a condition
4074 completer for a branch (vs a nullification completer for a
4075 computational instruction). */
4078 pa_parse_neg_add_cmpltr (s
, isbranch
)
4083 char *name
= *s
+ 1;
4091 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4095 if (strcasecmp (name
, "tr") == 0)
4099 else if (strcmp (name
, "<>") == 0)
4103 else if (strcmp (name
, ">=") == 0)
4107 else if (strcmp (name
, ">") == 0)
4111 else if (strcasecmp (name
, "uv") == 0)
4115 else if (strcasecmp (name
, "vnz") == 0)
4119 else if (strcasecmp (name
, "nsv") == 0)
4123 else if (strcasecmp (name
, "ev") == 0)
4127 /* If we have something like addb,n then there is no condition
4129 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4140 /* Reset pointers if this was really a ,n for a branch instruction. */
4141 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4147 /* Handle an alignment directive. Special so that we can update the
4148 alignment of the subspace if necessary. */
4152 /* We must have a valid space and subspace. */
4153 pa_check_current_space_and_subspace ();
4155 /* Let the generic gas code do most of the work. */
4156 s_align_bytes (bytes
);
4158 /* If bytes is a power of 2, then update the current subspace's
4159 alignment if necessary. */
4160 if (log2 (bytes
) != -1)
4161 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
4164 /* Handle a .BLOCK type pseudo-op. */
4172 unsigned int temp_size
;
4175 /* We must have a valid space and subspace. */
4176 pa_check_current_space_and_subspace ();
4178 temp_size
= get_absolute_expression ();
4180 /* Always fill with zeros, that's what the HP assembler does. */
4183 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
4184 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
4185 memset (p
, 0, temp_size
);
4187 /* Convert 2 bytes at a time. */
4189 for (i
= 0; i
< temp_size
; i
+= 2)
4191 md_number_to_chars (p
+ i
,
4193 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
4196 pa_undefine_label ();
4197 demand_empty_rest_of_line ();
4200 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
4208 /* The BRTAB relocations are only availble in SOM (to denote
4209 the beginning and end of branch tables). */
4210 char *where
= frag_more (0);
4212 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4213 NULL
, (offsetT
) 0, NULL
,
4214 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
4215 e_fsel
, 0, 0, NULL
);
4218 demand_empty_rest_of_line ();
4221 /* Handle a .begin_try and .end_try pseudo-op. */
4229 char *where
= frag_more (0);
4234 /* The TRY relocations are only availble in SOM (to denote
4235 the beginning and end of exception handling regions). */
4237 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4238 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
4239 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
4240 e_fsel
, 0, 0, NULL
);
4243 demand_empty_rest_of_line ();
4246 /* Handle a .CALL pseudo-op. This involves storing away information
4247 about where arguments are to be found so the linker can detect
4248 (and correct) argument location mismatches between caller and callee. */
4254 /* We must have a valid space and subspace. */
4255 pa_check_current_space_and_subspace ();
4257 pa_call_args (&last_call_desc
);
4258 demand_empty_rest_of_line ();
4261 /* Do the dirty work of building a call descriptor which describes
4262 where the caller placed arguments to a function call. */
4265 pa_call_args (call_desc
)
4266 struct call_desc
*call_desc
;
4269 unsigned int temp
, arg_reloc
;
4271 while (!is_end_of_statement ())
4273 name
= input_line_pointer
;
4274 c
= get_symbol_end ();
4275 /* Process a source argument. */
4276 if ((strncasecmp (name
, "argw", 4) == 0))
4278 temp
= atoi (name
+ 4);
4279 p
= input_line_pointer
;
4281 input_line_pointer
++;
4282 name
= input_line_pointer
;
4283 c
= get_symbol_end ();
4284 arg_reloc
= pa_build_arg_reloc (name
);
4285 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
4287 /* Process a return value. */
4288 else if ((strncasecmp (name
, "rtnval", 6) == 0))
4290 p
= input_line_pointer
;
4292 input_line_pointer
++;
4293 name
= input_line_pointer
;
4294 c
= get_symbol_end ();
4295 arg_reloc
= pa_build_arg_reloc (name
);
4296 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
4300 as_bad (_("Invalid .CALL argument: %s"), name
);
4302 p
= input_line_pointer
;
4304 if (!is_end_of_statement ())
4305 input_line_pointer
++;
4309 /* Return TRUE if FRAG1 and FRAG2 are the same. */
4312 is_same_frag (frag1
, frag2
)
4319 else if (frag2
== NULL
)
4321 else if (frag1
== frag2
)
4323 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
4324 return (is_same_frag (frag1
, frag2
->fr_next
));
4330 /* Build an entry in the UNWIND subspace from the given function
4331 attributes in CALL_INFO. This is not needed for SOM as using
4332 R_ENTRY and R_EXIT relocations allow the linker to handle building
4333 of the unwind spaces. */
4336 pa_build_unwind_subspace (call_info
)
4337 struct call_info
*call_info
;
4340 asection
*seg
, *save_seg
;
4341 subsegT subseg
, save_subseg
;
4345 /* Get into the right seg/subseg. This may involve creating
4346 the seg the first time through. Make sure to have the
4347 old seg/subseg so that we can reset things when we are done. */
4348 subseg
= SUBSEG_UNWIND
;
4349 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
4350 if (seg
== ASEC_NULL
)
4352 seg
= bfd_make_section_old_way (stdoutput
, UNWIND_SECTION_NAME
);
4353 bfd_set_section_flags (stdoutput
, seg
,
4354 SEC_READONLY
| SEC_HAS_CONTENTS
4355 | SEC_LOAD
| SEC_RELOC
);
4359 save_subseg
= now_subseg
;
4360 subseg_set (seg
, subseg
);
4363 /* Get some space to hold relocation information for the unwind
4366 md_number_to_chars (p
, 0, 4);
4368 /* Relocation info. for start offset of the function. */
4369 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4370 call_info
->start_symbol
, (offsetT
) 0,
4371 (expressionS
*) NULL
, 0, R_PARISC_DIR32
, e_fsel
, 32, 0, NULL
);
4374 md_number_to_chars (p
, 0, 4);
4376 /* Relocation info. for end offset of the function.
4378 Because we allow reductions of 32bit relocations for ELF, this will be
4379 reduced to section_sym + offset which avoids putting the temporary
4380 symbol into the symbol table. It (should) end up giving the same
4381 value as call_info->start_symbol + function size once the linker is
4382 finished with its work. */
4384 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4385 call_info
->end_symbol
, (offsetT
) 0,
4386 (expressionS
*) NULL
, 0, R_PARISC_DIR32
, e_fsel
, 32, 0, NULL
);
4389 unwind
= (char *) &call_info
->ci_unwind
;
4390 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
4394 FRAG_APPEND_1_CHAR (c
);
4398 /* Return back to the original segment/subsegment. */
4399 subseg_set (save_seg
, save_subseg
);
4403 /* Process a .CALLINFO pseudo-op. This information is used later
4404 to build unwind descriptors and maybe one day to support
4405 .ENTER and .LEAVE. */
4408 pa_callinfo (unused
)
4414 /* We must have a valid space and subspace. */
4415 pa_check_current_space_and_subspace ();
4417 /* .CALLINFO must appear within a procedure definition. */
4418 if (!within_procedure
)
4419 as_bad (_(".callinfo is not within a procedure definition"));
4421 /* Mark the fact that we found the .CALLINFO for the
4422 current procedure. */
4423 callinfo_found
= TRUE
;
4425 /* Iterate over the .CALLINFO arguments. */
4426 while (!is_end_of_statement ())
4428 name
= input_line_pointer
;
4429 c
= get_symbol_end ();
4430 /* Frame size specification. */
4431 if ((strncasecmp (name
, "frame", 5) == 0))
4433 p
= input_line_pointer
;
4435 input_line_pointer
++;
4436 temp
= get_absolute_expression ();
4437 if ((temp
& 0x3) != 0)
4439 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
4443 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
4444 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
4447 /* Entry register (GR, GR and SR) specifications. */
4448 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
4450 p
= input_line_pointer
;
4452 input_line_pointer
++;
4453 temp
= get_absolute_expression ();
4454 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
4455 even though %r19 is caller saved. I think this is a bug in
4456 the HP assembler, and we are not going to emulate it. */
4457 if (temp
< 3 || temp
> 18)
4458 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
4459 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
4461 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
4463 p
= input_line_pointer
;
4465 input_line_pointer
++;
4466 temp
= get_absolute_expression ();
4467 /* Similarly the HP assembler takes 31 as the high bound even
4468 though %fr21 is the last callee saved floating point register. */
4469 if (temp
< 12 || temp
> 21)
4470 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
4471 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
4473 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
4475 p
= input_line_pointer
;
4477 input_line_pointer
++;
4478 temp
= get_absolute_expression ();
4480 as_bad (_("Value for ENTRY_SR must be 3\n"));
4482 /* Note whether or not this function performs any calls. */
4483 else if ((strncasecmp (name
, "calls", 5) == 0) ||
4484 (strncasecmp (name
, "caller", 6) == 0))
4486 p
= input_line_pointer
;
4489 else if ((strncasecmp (name
, "no_calls", 8) == 0))
4491 p
= input_line_pointer
;
4494 /* Should RP be saved into the stack. */
4495 else if ((strncasecmp (name
, "save_rp", 7) == 0))
4497 p
= input_line_pointer
;
4499 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
4501 /* Likewise for SP. */
4502 else if ((strncasecmp (name
, "save_sp", 7) == 0))
4504 p
= input_line_pointer
;
4506 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
4508 /* Is this an unwindable procedure. If so mark it so
4509 in the unwind descriptor. */
4510 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
4512 p
= input_line_pointer
;
4514 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
4516 /* Is this an interrupt routine. If so mark it in the
4517 unwind descriptor. */
4518 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
4520 p
= input_line_pointer
;
4522 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
4524 /* Is this a millicode routine. "millicode" isn't in my
4525 assembler manual, but my copy is old. The HP assembler
4526 accepts it, and there's a place in the unwind descriptor
4527 to drop the information, so we'll accept it too. */
4528 else if ((strncasecmp (name
, "millicode", 9) == 0))
4530 p
= input_line_pointer
;
4532 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
4536 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
4537 *input_line_pointer
= c
;
4539 if (!is_end_of_statement ())
4540 input_line_pointer
++;
4543 demand_empty_rest_of_line ();
4546 /* Switch into the code subspace. */
4552 current_space
= is_defined_space ("$TEXT$");
4554 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
4556 pa_undefine_label ();
4559 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
4560 the .comm pseudo-op has the following symtax:
4562 <label> .comm <length>
4564 where <label> is optional and is a symbol whose address will be the start of
4565 a block of memory <length> bytes long. <length> must be an absolute
4566 expression. <length> bytes will be allocated in the current space
4569 Also note the label may not even be on the same line as the .comm.
4571 This difference in syntax means the colon function will be called
4572 on the symbol before we arrive in pa_comm. colon will set a number
4573 of attributes of the symbol that need to be fixed here. In particular
4574 the value, section pointer, fragment pointer, flags, etc. What
4577 This also makes error detection all but impossible. */
4585 label_symbol_struct
*label_symbol
= pa_get_label ();
4588 symbol
= label_symbol
->lss_label
;
4593 size
= get_absolute_expression ();
4597 S_SET_VALUE (symbol
, size
);
4598 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
4599 S_SET_EXTERNAL (symbol
);
4601 /* colon() has already set the frag to the current location in the
4602 current subspace; we need to reset the fragment to the zero address
4603 fragment. We also need to reset the segment pointer. */
4604 symbol
->sy_frag
= &zero_address_frag
;
4606 demand_empty_rest_of_line ();
4609 /* Process a .END pseudo-op. */
4615 demand_empty_rest_of_line ();
4618 /* Process a .ENTER pseudo-op. This is not supported. */
4623 /* We must have a valid space and subspace. */
4624 pa_check_current_space_and_subspace ();
4626 as_bad (_("The .ENTER pseudo-op is not supported"));
4627 demand_empty_rest_of_line ();
4630 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
4636 /* We must have a valid space and subspace. */
4637 pa_check_current_space_and_subspace ();
4639 if (!within_procedure
)
4640 as_bad (_("Misplaced .entry. Ignored."));
4643 if (!callinfo_found
)
4644 as_bad (_("Missing .callinfo."));
4646 demand_empty_rest_of_line ();
4647 within_entry_exit
= TRUE
;
4650 /* SOM defers building of unwind descriptors until the link phase.
4651 The assembler is responsible for creating an R_ENTRY relocation
4652 to mark the beginning of a region and hold the unwind bits, and
4653 for creating an R_EXIT relocation to mark the end of the region.
4655 FIXME. ELF should be using the same conventions! The problem
4656 is an unwind requires too much relocation space. Hmmm. Maybe
4657 if we split the unwind bits up between the relocations which
4658 denote the entry and exit points. */
4659 if (last_call_info
->start_symbol
!= NULL
)
4661 char *where
= frag_more (0);
4663 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4664 NULL
, (offsetT
) 0, NULL
,
4665 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
4666 (int *) &last_call_info
->ci_unwind
.descriptor
);
4671 /* Handle a .EQU pseudo-op. */
4677 label_symbol_struct
*label_symbol
= pa_get_label ();
4682 symbol
= label_symbol
->lss_label
;
4684 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
4686 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
4687 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
4692 as_bad (_(".REG must use a label"));
4694 as_bad (_(".EQU must use a label"));
4697 pa_undefine_label ();
4698 demand_empty_rest_of_line ();
4701 /* Helper function. Does processing for the end of a function. This
4702 usually involves creating some relocations or building special
4703 symbols to mark the end of the function. */
4710 where
= frag_more (0);
4713 /* Mark the end of the function, stuff away the location of the frag
4714 for the end of the function, and finally call pa_build_unwind_subspace
4715 to add an entry in the unwind table. */
4716 hppa_elf_mark_end_of_function ();
4717 pa_build_unwind_subspace (last_call_info
);
4719 /* SOM defers building of unwind descriptors until the link phase.
4720 The assembler is responsible for creating an R_ENTRY relocation
4721 to mark the beginning of a region and hold the unwind bits, and
4722 for creating an R_EXIT relocation to mark the end of the region.
4724 FIXME. ELF should be using the same conventions! The problem
4725 is an unwind requires too much relocation space. Hmmm. Maybe
4726 if we split the unwind bits up between the relocations which
4727 denote the entry and exit points. */
4728 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4730 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
4731 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
4735 /* Process a .EXIT pseudo-op. */
4741 /* We must have a valid space and subspace. */
4742 pa_check_current_space_and_subspace ();
4744 if (!within_procedure
)
4745 as_bad (_(".EXIT must appear within a procedure"));
4748 if (!callinfo_found
)
4749 as_bad (_("Missing .callinfo"));
4752 if (!within_entry_exit
)
4753 as_bad (_("No .ENTRY for this .EXIT"));
4756 within_entry_exit
= FALSE
;
4761 demand_empty_rest_of_line ();
4764 /* Process a .EXPORT directive. This makes functions external
4765 and provides information such as argument relocation entries
4775 name
= input_line_pointer
;
4776 c
= get_symbol_end ();
4777 /* Make sure the given symbol exists. */
4778 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
4780 as_bad (_("Cannot define export symbol: %s\n"), name
);
4781 p
= input_line_pointer
;
4783 input_line_pointer
++;
4787 /* OK. Set the external bits and process argument relocations. */
4788 S_SET_EXTERNAL (symbol
);
4789 p
= input_line_pointer
;
4791 if (!is_end_of_statement ())
4793 input_line_pointer
++;
4794 pa_type_args (symbol
, 1);
4798 demand_empty_rest_of_line ();
4801 /* Helper function to process arguments to a .EXPORT pseudo-op. */
4804 pa_type_args (symbolP
, is_export
)
4809 unsigned int temp
, arg_reloc
;
4810 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
4811 obj_symbol_type
*symbol
= (obj_symbol_type
*) symbolP
->bsym
;
4813 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
4816 input_line_pointer
+= 8;
4817 symbolP
->bsym
->flags
&= ~BSF_FUNCTION
;
4818 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
4819 type
= SYMBOL_TYPE_ABSOLUTE
;
4821 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
4823 input_line_pointer
+= 4;
4824 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
4825 instead one should be IMPORTing/EXPORTing ENTRY types.
4827 Complain if one tries to EXPORT a CODE type since that's never
4828 done. Both GCC and HP C still try to IMPORT CODE types, so
4829 silently fix them to be ENTRY types. */
4830 if (symbolP
->bsym
->flags
& BSF_FUNCTION
)
4833 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"), symbolP
->bsym
->name
);
4835 symbolP
->bsym
->flags
|= BSF_FUNCTION
;
4836 type
= SYMBOL_TYPE_ENTRY
;
4840 symbolP
->bsym
->flags
&= ~BSF_FUNCTION
;
4841 type
= SYMBOL_TYPE_CODE
;
4844 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
4846 input_line_pointer
+= 4;
4847 symbolP
->bsym
->flags
&= ~BSF_FUNCTION
;
4848 type
= SYMBOL_TYPE_DATA
;
4850 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
4852 input_line_pointer
+= 5;
4853 symbolP
->bsym
->flags
|= BSF_FUNCTION
;
4854 type
= SYMBOL_TYPE_ENTRY
;
4856 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
4858 input_line_pointer
+= 9;
4859 symbolP
->bsym
->flags
|= BSF_FUNCTION
;
4860 type
= SYMBOL_TYPE_MILLICODE
;
4862 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
4864 input_line_pointer
+= 6;
4865 symbolP
->bsym
->flags
&= ~BSF_FUNCTION
;
4866 type
= SYMBOL_TYPE_PLABEL
;
4868 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
4870 input_line_pointer
+= 8;
4871 symbolP
->bsym
->flags
|= BSF_FUNCTION
;
4872 type
= SYMBOL_TYPE_PRI_PROG
;
4874 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
4876 input_line_pointer
+= 8;
4877 symbolP
->bsym
->flags
|= BSF_FUNCTION
;
4878 type
= SYMBOL_TYPE_SEC_PROG
;
4881 /* SOM requires much more information about symbol types
4882 than BFD understands. This is how we get this information
4883 to the SOM BFD backend. */
4884 #ifdef obj_set_symbol_type
4885 obj_set_symbol_type (symbolP
->bsym
, (int) type
);
4888 /* Now that the type of the exported symbol has been handled,
4889 handle any argument relocation information. */
4890 while (!is_end_of_statement ())
4892 if (*input_line_pointer
== ',')
4893 input_line_pointer
++;
4894 name
= input_line_pointer
;
4895 c
= get_symbol_end ();
4896 /* Argument sources. */
4897 if ((strncasecmp (name
, "argw", 4) == 0))
4899 p
= input_line_pointer
;
4901 input_line_pointer
++;
4902 temp
= atoi (name
+ 4);
4903 name
= input_line_pointer
;
4904 c
= get_symbol_end ();
4905 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
4906 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
4907 *input_line_pointer
= c
;
4909 /* The return value. */
4910 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
4912 p
= input_line_pointer
;
4914 input_line_pointer
++;
4915 name
= input_line_pointer
;
4916 c
= get_symbol_end ();
4917 arg_reloc
= pa_build_arg_reloc (name
);
4918 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
4919 *input_line_pointer
= c
;
4921 /* Privelege level. */
4922 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
4924 p
= input_line_pointer
;
4926 input_line_pointer
++;
4927 temp
= atoi (input_line_pointer
);
4928 symbol
->tc_data
.ap
.hppa_priv_level
= temp
;
4929 c
= get_symbol_end ();
4930 *input_line_pointer
= c
;
4934 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
4935 p
= input_line_pointer
;
4938 if (!is_end_of_statement ())
4939 input_line_pointer
++;
4943 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
4944 assembly file must either be defined in the assembly file, or
4945 explicitly IMPORTED from another. */
4954 name
= input_line_pointer
;
4955 c
= get_symbol_end ();
4957 symbol
= symbol_find (name
);
4958 /* Ugh. We might be importing a symbol defined earlier in the file,
4959 in which case all the code below will really screw things up
4960 (set the wrong segment, symbol flags & type, etc). */
4961 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
4963 symbol
= symbol_find_or_make (name
);
4964 p
= input_line_pointer
;
4967 if (!is_end_of_statement ())
4969 input_line_pointer
++;
4970 pa_type_args (symbol
, 0);
4974 /* Sigh. To be compatable with the HP assembler and to help
4975 poorly written assembly code, we assign a type based on
4976 the the current segment. Note only BSF_FUNCTION really
4977 matters, we do not need to set the full SYMBOL_TYPE_* info. */
4978 if (now_seg
== text_section
)
4979 symbol
->bsym
->flags
|= BSF_FUNCTION
;
4981 /* If the section is undefined, then the symbol is undefined
4982 Since this is an import, leave the section undefined. */
4983 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
4988 /* The symbol was already defined. Just eat everything up to
4989 the end of the current statement. */
4990 while (!is_end_of_statement ())
4991 input_line_pointer
++;
4994 demand_empty_rest_of_line ();
4997 /* Handle a .LABEL pseudo-op. */
5005 name
= input_line_pointer
;
5006 c
= get_symbol_end ();
5008 if (strlen (name
) > 0)
5011 p
= input_line_pointer
;
5016 as_warn (_("Missing label name on .LABEL"));
5019 if (!is_end_of_statement ())
5021 as_warn (_("extra .LABEL arguments ignored."));
5022 ignore_rest_of_line ();
5024 demand_empty_rest_of_line ();
5027 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
5033 /* We must have a valid space and subspace. */
5034 pa_check_current_space_and_subspace ();
5036 as_bad (_("The .LEAVE pseudo-op is not supported"));
5037 demand_empty_rest_of_line ();
5040 /* Handle a .LEVEL pseudo-op. */
5048 level
= input_line_pointer
;
5049 if (strncmp (level
, "1.0", 3) == 0)
5051 input_line_pointer
+= 3;
5052 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
5053 as_warn (_("could not set architecture and machine"));
5055 else if (strncmp (level
, "1.1", 3) == 0)
5057 input_line_pointer
+= 3;
5058 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
5059 as_warn (_("could not set architecture and machine"));
5061 else if (strncmp (level
, "2.0", 3) == 0)
5063 input_line_pointer
+= 3;
5064 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
5065 as_warn (_("could not set architecture and machine"));
5069 as_bad (_("Unrecognized .LEVEL argument\n"));
5070 ignore_rest_of_line ();
5072 demand_empty_rest_of_line ();
5075 /* Handle a .ORIGIN pseudo-op. */
5081 /* We must have a valid space and subspace. */
5082 pa_check_current_space_and_subspace ();
5085 pa_undefine_label ();
5088 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
5089 is for static functions. FIXME. Should share more code with .EXPORT. */
5098 name
= input_line_pointer
;
5099 c
= get_symbol_end ();
5101 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
5103 as_bad (_("Cannot define static symbol: %s\n"), name
);
5104 p
= input_line_pointer
;
5106 input_line_pointer
++;
5110 S_CLEAR_EXTERNAL (symbol
);
5111 p
= input_line_pointer
;
5113 if (!is_end_of_statement ())
5115 input_line_pointer
++;
5116 pa_type_args (symbol
, 0);
5120 demand_empty_rest_of_line ();
5123 /* Handle a .PROC pseudo-op. It is used to mark the beginning
5124 of a procedure from a syntatical point of view. */
5130 struct call_info
*call_info
;
5132 /* We must have a valid space and subspace. */
5133 pa_check_current_space_and_subspace ();
5135 if (within_procedure
)
5136 as_fatal (_("Nested procedures"));
5138 /* Reset global variables for new procedure. */
5139 callinfo_found
= FALSE
;
5140 within_procedure
= TRUE
;
5142 /* Create another call_info structure. */
5143 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
5146 as_fatal (_("Cannot allocate unwind descriptor\n"));
5148 memset (call_info
, 0, sizeof (struct call_info
));
5150 call_info
->ci_next
= NULL
;
5152 if (call_info_root
== NULL
)
5154 call_info_root
= call_info
;
5155 last_call_info
= call_info
;
5159 last_call_info
->ci_next
= call_info
;
5160 last_call_info
= call_info
;
5163 /* set up defaults on call_info structure */
5165 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
5166 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
5167 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
5169 /* If we got a .PROC pseudo-op, we know that the function is defined
5170 locally. Make sure it gets into the symbol table. */
5172 label_symbol_struct
*label_symbol
= pa_get_label ();
5176 if (label_symbol
->lss_label
)
5178 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5179 label_symbol
->lss_label
->bsym
->flags
|= BSF_FUNCTION
;
5182 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5185 last_call_info
->start_symbol
= NULL
;
5188 demand_empty_rest_of_line ();
5191 /* Process the syntatical end of a procedure. Make sure all the
5192 appropriate pseudo-ops were found within the procedure. */
5199 /* We must have a valid space and subspace. */
5200 pa_check_current_space_and_subspace ();
5202 /* If we are within a procedure definition, make sure we've
5203 defined a label for the procedure; handle case where the
5204 label was defined after the .PROC directive.
5206 Note there's not need to diddle with the segment or fragment
5207 for the label symbol in this case. We have already switched
5208 into the new $CODE$ subspace at this point. */
5209 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
5211 label_symbol_struct
*label_symbol
= pa_get_label ();
5215 if (label_symbol
->lss_label
)
5217 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5218 label_symbol
->lss_label
->bsym
->flags
|= BSF_FUNCTION
;
5220 /* Also handle allocation of a fixup to hold the unwind
5221 information when the label appears after the proc/procend. */
5222 if (within_entry_exit
)
5224 char *where
= frag_more (0);
5226 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5227 NULL
, (offsetT
) 0, NULL
,
5228 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
5229 (int *) &last_call_info
->ci_unwind
.descriptor
);
5234 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5237 as_bad (_("Missing function name for .PROC"));
5240 if (!within_procedure
)
5241 as_bad (_("misplaced .procend"));
5243 if (!callinfo_found
)
5244 as_bad (_("Missing .callinfo for this procedure"));
5246 if (within_entry_exit
)
5247 as_bad (_("Missing .EXIT for a .ENTRY"));
5250 /* ELF needs to mark the end of each function so that it can compute
5251 the size of the function (apparently its needed in the symbol table). */
5252 hppa_elf_mark_end_of_function ();
5255 within_procedure
= FALSE
;
5256 demand_empty_rest_of_line ();
5257 pa_undefine_label ();
5260 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
5261 then create a new space entry to hold the information specified
5262 by the parameters to the .SPACE directive. */
5264 static sd_chain_struct
*
5265 pa_parse_space_stmt (space_name
, create_flag
)
5269 char *name
, *ptemp
, c
;
5270 char loadable
, defined
, private, sort
;
5272 asection
*seg
= NULL
;
5273 sd_chain_struct
*space
;
5275 /* load default values */
5281 if (strcmp (space_name
, "$TEXT$") == 0)
5283 seg
= pa_def_spaces
[0].segment
;
5284 defined
= pa_def_spaces
[0].defined
;
5285 private = pa_def_spaces
[0].private;
5286 sort
= pa_def_spaces
[0].sort
;
5287 spnum
= pa_def_spaces
[0].spnum
;
5289 else if (strcmp (space_name
, "$PRIVATE$") == 0)
5291 seg
= pa_def_spaces
[1].segment
;
5292 defined
= pa_def_spaces
[1].defined
;
5293 private = pa_def_spaces
[1].private;
5294 sort
= pa_def_spaces
[1].sort
;
5295 spnum
= pa_def_spaces
[1].spnum
;
5298 if (!is_end_of_statement ())
5300 print_errors
= FALSE
;
5301 ptemp
= input_line_pointer
+ 1;
5302 /* First see if the space was specified as a number rather than
5303 as a name. According to the PA assembly manual the rest of
5304 the line should be ignored. */
5305 temp
= pa_parse_number (&ptemp
, 0);
5309 input_line_pointer
= ptemp
;
5313 while (!is_end_of_statement ())
5315 input_line_pointer
++;
5316 name
= input_line_pointer
;
5317 c
= get_symbol_end ();
5318 if ((strncasecmp (name
, "spnum", 5) == 0))
5320 *input_line_pointer
= c
;
5321 input_line_pointer
++;
5322 spnum
= get_absolute_expression ();
5324 else if ((strncasecmp (name
, "sort", 4) == 0))
5326 *input_line_pointer
= c
;
5327 input_line_pointer
++;
5328 sort
= get_absolute_expression ();
5330 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5332 *input_line_pointer
= c
;
5335 else if ((strncasecmp (name
, "notdefined", 10) == 0))
5337 *input_line_pointer
= c
;
5340 else if ((strncasecmp (name
, "private", 7) == 0))
5342 *input_line_pointer
= c
;
5347 as_bad (_("Invalid .SPACE argument"));
5348 *input_line_pointer
= c
;
5349 if (!is_end_of_statement ())
5350 input_line_pointer
++;
5354 print_errors
= TRUE
;
5357 if (create_flag
&& seg
== NULL
)
5358 seg
= subseg_new (space_name
, 0);
5360 /* If create_flag is nonzero, then create the new space with
5361 the attributes computed above. Else set the values in
5362 an already existing space -- this can only happen for
5363 the first occurence of a built-in space. */
5365 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
5366 private, sort
, seg
, 1);
5369 space
= is_defined_space (space_name
);
5370 SPACE_SPNUM (space
) = spnum
;
5371 SPACE_DEFINED (space
) = defined
& 1;
5372 SPACE_USER_DEFINED (space
) = 1;
5375 #ifdef obj_set_section_attributes
5376 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
5382 /* Handle a .SPACE pseudo-op; this switches the current space to the
5383 given space, creating the new space if necessary. */
5389 char *name
, c
, *space_name
, *save_s
;
5391 sd_chain_struct
*sd_chain
;
5393 if (within_procedure
)
5395 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
5396 ignore_rest_of_line ();
5400 /* Check for some of the predefined spaces. FIXME: most of the code
5401 below is repeated several times, can we extract the common parts
5402 and place them into a subroutine or something similar? */
5403 /* FIXME Is this (and the next IF stmt) really right?
5404 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
5405 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
5407 input_line_pointer
+= 6;
5408 sd_chain
= is_defined_space ("$TEXT$");
5409 if (sd_chain
== NULL
)
5410 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
5411 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5412 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
5414 current_space
= sd_chain
;
5415 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
5417 = pa_subsegment_to_subspace (text_section
,
5418 sd_chain
->sd_last_subseg
);
5419 demand_empty_rest_of_line ();
5422 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
5424 input_line_pointer
+= 9;
5425 sd_chain
= is_defined_space ("$PRIVATE$");
5426 if (sd_chain
== NULL
)
5427 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
5428 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5429 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
5431 current_space
= sd_chain
;
5432 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
5434 = pa_subsegment_to_subspace (data_section
,
5435 sd_chain
->sd_last_subseg
);
5436 demand_empty_rest_of_line ();
5439 if (!strncasecmp (input_line_pointer
,
5440 GDB_DEBUG_SPACE_NAME
,
5441 strlen (GDB_DEBUG_SPACE_NAME
)))
5443 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
5444 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
5445 if (sd_chain
== NULL
)
5446 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
5447 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5448 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
5450 current_space
= sd_chain
;
5453 asection
*gdb_section
5454 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
5456 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
5458 = pa_subsegment_to_subspace (gdb_section
,
5459 sd_chain
->sd_last_subseg
);
5461 demand_empty_rest_of_line ();
5465 /* It could be a space specified by number. */
5467 save_s
= input_line_pointer
;
5468 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
5470 if ((sd_chain
= pa_find_space_by_number (temp
)))
5472 current_space
= sd_chain
;
5474 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5476 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5477 sd_chain
->sd_last_subseg
);
5478 demand_empty_rest_of_line ();
5483 /* Not a number, attempt to create a new space. */
5485 input_line_pointer
= save_s
;
5486 name
= input_line_pointer
;
5487 c
= get_symbol_end ();
5488 space_name
= xmalloc (strlen (name
) + 1);
5489 strcpy (space_name
, name
);
5490 *input_line_pointer
= c
;
5492 sd_chain
= pa_parse_space_stmt (space_name
, 1);
5493 current_space
= sd_chain
;
5495 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5496 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5497 sd_chain
->sd_last_subseg
);
5498 demand_empty_rest_of_line ();
5502 /* Switch to a new space. (I think). FIXME. */
5511 sd_chain_struct
*space
;
5513 name
= input_line_pointer
;
5514 c
= get_symbol_end ();
5515 space
= is_defined_space (name
);
5519 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
5522 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
5524 *input_line_pointer
= c
;
5525 demand_empty_rest_of_line ();
5528 /* If VALUE is an exact power of two between zero and 2^31, then
5529 return log2 (VALUE). Else return -1. */
5537 while ((1 << shift
) != value
&& shift
< 32)
5546 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
5547 given subspace, creating the new subspace if necessary.
5549 FIXME. Should mirror pa_space more closely, in particular how
5550 they're broken up into subroutines. */
5553 pa_subspace (create_new
)
5556 char *name
, *ss_name
, *alias
, c
;
5557 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
5558 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
5559 sd_chain_struct
*space
;
5560 ssd_chain_struct
*ssd
;
5563 if (current_space
== NULL
)
5564 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
5566 if (within_procedure
)
5568 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
5569 ignore_rest_of_line ();
5573 name
= input_line_pointer
;
5574 c
= get_symbol_end ();
5575 ss_name
= xmalloc (strlen (name
) + 1);
5576 strcpy (ss_name
, name
);
5577 *input_line_pointer
= c
;
5579 /* Load default values. */
5592 space
= current_space
;
5596 ssd
= is_defined_subspace (ss_name
);
5597 /* Allow user to override the builtin attributes of subspaces. But
5598 only allow the attributes to be changed once! */
5599 if (ssd
&& SUBSPACE_DEFINED (ssd
))
5601 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
5602 current_subspace
= ssd
;
5603 if (!is_end_of_statement ())
5604 as_warn (_("Parameters of an existing subspace can\'t be modified"));
5605 demand_empty_rest_of_line ();
5610 /* A new subspace. Load default values if it matches one of
5611 the builtin subspaces. */
5613 while (pa_def_subspaces
[i
].name
)
5615 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
5617 loadable
= pa_def_subspaces
[i
].loadable
;
5618 common
= pa_def_subspaces
[i
].common
;
5619 dup_common
= pa_def_subspaces
[i
].dup_common
;
5620 code_only
= pa_def_subspaces
[i
].code_only
;
5621 zero
= pa_def_subspaces
[i
].zero
;
5622 space_index
= pa_def_subspaces
[i
].space_index
;
5623 alignment
= pa_def_subspaces
[i
].alignment
;
5624 quadrant
= pa_def_subspaces
[i
].quadrant
;
5625 access
= pa_def_subspaces
[i
].access
;
5626 sort
= pa_def_subspaces
[i
].sort
;
5627 if (USE_ALIASES
&& pa_def_subspaces
[i
].alias
)
5628 alias
= pa_def_subspaces
[i
].alias
;
5635 /* We should be working with a new subspace now. Fill in
5636 any information as specified by the user. */
5637 if (!is_end_of_statement ())
5639 input_line_pointer
++;
5640 while (!is_end_of_statement ())
5642 name
= input_line_pointer
;
5643 c
= get_symbol_end ();
5644 if ((strncasecmp (name
, "quad", 4) == 0))
5646 *input_line_pointer
= c
;
5647 input_line_pointer
++;
5648 quadrant
= get_absolute_expression ();
5650 else if ((strncasecmp (name
, "align", 5) == 0))
5652 *input_line_pointer
= c
;
5653 input_line_pointer
++;
5654 alignment
= get_absolute_expression ();
5655 if (log2 (alignment
) == -1)
5657 as_bad (_("Alignment must be a power of 2"));
5661 else if ((strncasecmp (name
, "access", 6) == 0))
5663 *input_line_pointer
= c
;
5664 input_line_pointer
++;
5665 access
= get_absolute_expression ();
5667 else if ((strncasecmp (name
, "sort", 4) == 0))
5669 *input_line_pointer
= c
;
5670 input_line_pointer
++;
5671 sort
= get_absolute_expression ();
5673 else if ((strncasecmp (name
, "code_only", 9) == 0))
5675 *input_line_pointer
= c
;
5678 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5680 *input_line_pointer
= c
;
5683 else if ((strncasecmp (name
, "common", 6) == 0))
5685 *input_line_pointer
= c
;
5688 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
5690 *input_line_pointer
= c
;
5693 else if ((strncasecmp (name
, "zero", 4) == 0))
5695 *input_line_pointer
= c
;
5698 else if ((strncasecmp (name
, "first", 5) == 0))
5699 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
5701 as_bad (_("Invalid .SUBSPACE argument"));
5702 if (!is_end_of_statement ())
5703 input_line_pointer
++;
5707 /* Compute a reasonable set of BFD flags based on the information
5708 in the .subspace directive. */
5709 applicable
= bfd_applicable_section_flags (stdoutput
);
5712 flags
|= (SEC_ALLOC
| SEC_LOAD
);
5715 if (common
|| dup_common
)
5716 flags
|= SEC_IS_COMMON
;
5718 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
5720 /* This is a zero-filled subspace (eg BSS). */
5722 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
5724 applicable
&= flags
;
5726 /* If this is an existing subspace, then we want to use the
5727 segment already associated with the subspace.
5729 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
5730 lots of sections. It might be a problem in the PA ELF
5731 code, I do not know yet. For now avoid creating anything
5732 but the "standard" sections for ELF. */
5734 section
= subseg_force_new (ss_name
, 0);
5736 section
= ssd
->ssd_seg
;
5738 section
= subseg_new (alias
, 0);
5739 else if (!alias
&& USE_ALIASES
)
5741 as_warn (_("Ignoring subspace decl due to ELF BFD bugs."));
5742 demand_empty_rest_of_line ();
5746 section
= subseg_new (ss_name
, 0);
5749 seg_info (section
)->bss
= 1;
5751 /* Now set the flags. */
5752 bfd_set_section_flags (stdoutput
, section
, applicable
);
5754 /* Record any alignment request for this section. */
5755 record_alignment (section
, log2 (alignment
));
5757 /* Set the starting offset for this section. */
5758 bfd_set_section_vma (stdoutput
, section
,
5759 pa_subspace_start (space
, quadrant
));
5761 /* Now that all the flags are set, update an existing subspace,
5762 or create a new one. */
5765 current_subspace
= update_subspace (space
, ss_name
, loadable
,
5766 code_only
, common
, dup_common
,
5767 sort
, zero
, access
, space_index
,
5768 alignment
, quadrant
,
5771 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
5773 dup_common
, zero
, sort
,
5774 access
, space_index
,
5775 alignment
, quadrant
, section
);
5777 demand_empty_rest_of_line ();
5778 current_subspace
->ssd_seg
= section
;
5779 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
5781 SUBSPACE_DEFINED (current_subspace
) = 1;
5785 /* Create default space and subspace dictionaries. */
5792 space_dict_root
= NULL
;
5793 space_dict_last
= NULL
;
5796 while (pa_def_spaces
[i
].name
)
5800 /* Pick the right name to use for the new section. */
5801 if (pa_def_spaces
[i
].alias
&& USE_ALIASES
)
5802 name
= pa_def_spaces
[i
].alias
;
5804 name
= pa_def_spaces
[i
].name
;
5806 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
5807 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
5808 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
5809 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
5810 pa_def_spaces
[i
].segment
, 0);
5815 while (pa_def_subspaces
[i
].name
)
5818 int applicable
, subsegment
;
5819 asection
*segment
= NULL
;
5820 sd_chain_struct
*space
;
5822 /* Pick the right name for the new section and pick the right
5823 subsegment number. */
5824 if (pa_def_subspaces
[i
].alias
&& USE_ALIASES
)
5826 name
= pa_def_subspaces
[i
].alias
;
5827 subsegment
= pa_def_subspaces
[i
].subsegment
;
5831 name
= pa_def_subspaces
[i
].name
;
5835 /* Create the new section. */
5836 segment
= subseg_new (name
, subsegment
);
5839 /* For SOM we want to replace the standard .text, .data, and .bss
5840 sections with our own. We also want to set BFD flags for
5841 all the built-in subspaces. */
5842 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$") && !USE_ALIASES
)
5844 text_section
= segment
;
5845 applicable
= bfd_applicable_section_flags (stdoutput
);
5846 bfd_set_section_flags (stdoutput
, segment
,
5847 applicable
& (SEC_ALLOC
| SEC_LOAD
5848 | SEC_RELOC
| SEC_CODE
5850 | SEC_HAS_CONTENTS
));
5852 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$") && !USE_ALIASES
)
5854 data_section
= segment
;
5855 applicable
= bfd_applicable_section_flags (stdoutput
);
5856 bfd_set_section_flags (stdoutput
, segment
,
5857 applicable
& (SEC_ALLOC
| SEC_LOAD
5859 | SEC_HAS_CONTENTS
));
5863 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$") && !USE_ALIASES
)
5865 bss_section
= segment
;
5866 applicable
= bfd_applicable_section_flags (stdoutput
);
5867 bfd_set_section_flags (stdoutput
, segment
,
5868 applicable
& SEC_ALLOC
);
5870 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$") && !USE_ALIASES
)
5872 applicable
= bfd_applicable_section_flags (stdoutput
);
5873 bfd_set_section_flags (stdoutput
, segment
,
5874 applicable
& (SEC_ALLOC
| SEC_LOAD
5877 | SEC_HAS_CONTENTS
));
5879 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$")
5882 applicable
= bfd_applicable_section_flags (stdoutput
);
5883 bfd_set_section_flags (stdoutput
, segment
,
5884 applicable
& (SEC_ALLOC
| SEC_LOAD
5887 | SEC_HAS_CONTENTS
));
5889 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$") && !USE_ALIASES
)
5891 applicable
= bfd_applicable_section_flags (stdoutput
);
5892 bfd_set_section_flags (stdoutput
, segment
,
5893 applicable
& (SEC_ALLOC
| SEC_LOAD
5896 | SEC_HAS_CONTENTS
));
5899 /* Find the space associated with this subspace. */
5900 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
5901 def_space_index
].segment
);
5904 as_fatal (_("Internal error: Unable to find containing space for %s."),
5905 pa_def_subspaces
[i
].name
);
5908 create_new_subspace (space
, name
,
5909 pa_def_subspaces
[i
].loadable
,
5910 pa_def_subspaces
[i
].code_only
,
5911 pa_def_subspaces
[i
].common
,
5912 pa_def_subspaces
[i
].dup_common
,
5913 pa_def_subspaces
[i
].zero
,
5914 pa_def_subspaces
[i
].sort
,
5915 pa_def_subspaces
[i
].access
,
5916 pa_def_subspaces
[i
].space_index
,
5917 pa_def_subspaces
[i
].alignment
,
5918 pa_def_subspaces
[i
].quadrant
,
5926 /* Create a new space NAME, with the appropriate flags as defined
5927 by the given parameters. */
5929 static sd_chain_struct
*
5930 create_new_space (name
, spnum
, loadable
, defined
, private,
5931 sort
, seg
, user_defined
)
5941 sd_chain_struct
*chain_entry
;
5943 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
5945 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
5948 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
5949 strcpy (SPACE_NAME (chain_entry
), name
);
5950 SPACE_DEFINED (chain_entry
) = defined
;
5951 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
5952 SPACE_SPNUM (chain_entry
) = spnum
;
5954 chain_entry
->sd_seg
= seg
;
5955 chain_entry
->sd_last_subseg
= -1;
5956 chain_entry
->sd_subspaces
= NULL
;
5957 chain_entry
->sd_next
= NULL
;
5959 /* Find spot for the new space based on its sort key. */
5960 if (!space_dict_last
)
5961 space_dict_last
= chain_entry
;
5963 if (space_dict_root
== NULL
)
5964 space_dict_root
= chain_entry
;
5967 sd_chain_struct
*chain_pointer
;
5968 sd_chain_struct
*prev_chain_pointer
;
5970 chain_pointer
= space_dict_root
;
5971 prev_chain_pointer
= NULL
;
5973 while (chain_pointer
)
5975 prev_chain_pointer
= chain_pointer
;
5976 chain_pointer
= chain_pointer
->sd_next
;
5979 /* At this point we've found the correct place to add the new
5980 entry. So add it and update the linked lists as appropriate. */
5981 if (prev_chain_pointer
)
5983 chain_entry
->sd_next
= chain_pointer
;
5984 prev_chain_pointer
->sd_next
= chain_entry
;
5988 space_dict_root
= chain_entry
;
5989 chain_entry
->sd_next
= chain_pointer
;
5992 if (chain_entry
->sd_next
== NULL
)
5993 space_dict_last
= chain_entry
;
5996 /* This is here to catch predefined spaces which do not get
5997 modified by the user's input. Another call is found at
5998 the bottom of pa_parse_space_stmt to handle cases where
5999 the user modifies a predefined space. */
6000 #ifdef obj_set_section_attributes
6001 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
6007 /* Create a new subspace NAME, with the appropriate flags as defined
6008 by the given parameters.
6010 Add the new subspace to the subspace dictionary chain in numerical
6011 order as defined by the SORT entries. */
6013 static ssd_chain_struct
*
6014 create_new_subspace (space
, name
, loadable
, code_only
, common
,
6015 dup_common
, is_zero
, sort
, access
, space_index
,
6016 alignment
, quadrant
, seg
)
6017 sd_chain_struct
*space
;
6019 int loadable
, code_only
, common
, dup_common
, is_zero
;
6027 ssd_chain_struct
*chain_entry
;
6029 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
6031 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
6033 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
6034 strcpy (SUBSPACE_NAME (chain_entry
), name
);
6036 /* Initialize subspace_defined. When we hit a .subspace directive
6037 we'll set it to 1 which "locks-in" the subspace attributes. */
6038 SUBSPACE_DEFINED (chain_entry
) = 0;
6040 chain_entry
->ssd_subseg
= USE_ALIASES
? pa_next_subseg (space
) : 0;
6041 chain_entry
->ssd_seg
= seg
;
6042 chain_entry
->ssd_next
= NULL
;
6044 /* Find spot for the new subspace based on its sort key. */
6045 if (space
->sd_subspaces
== NULL
)
6046 space
->sd_subspaces
= chain_entry
;
6049 ssd_chain_struct
*chain_pointer
;
6050 ssd_chain_struct
*prev_chain_pointer
;
6052 chain_pointer
= space
->sd_subspaces
;
6053 prev_chain_pointer
= NULL
;
6055 while (chain_pointer
)
6057 prev_chain_pointer
= chain_pointer
;
6058 chain_pointer
= chain_pointer
->ssd_next
;
6061 /* Now we have somewhere to put the new entry. Insert it and update
6063 if (prev_chain_pointer
)
6065 chain_entry
->ssd_next
= chain_pointer
;
6066 prev_chain_pointer
->ssd_next
= chain_entry
;
6070 space
->sd_subspaces
= chain_entry
;
6071 chain_entry
->ssd_next
= chain_pointer
;
6075 #ifdef obj_set_subsection_attributes
6076 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
6083 /* Update the information for the given subspace based upon the
6084 various arguments. Return the modified subspace chain entry. */
6086 static ssd_chain_struct
*
6087 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
6088 zero
, access
, space_index
, alignment
, quadrant
, section
)
6089 sd_chain_struct
*space
;
6103 ssd_chain_struct
*chain_entry
;
6105 chain_entry
= is_defined_subspace (name
);
6107 #ifdef obj_set_subsection_attributes
6108 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
6115 /* Return the space chain entry for the space with the name NAME or
6116 NULL if no such space exists. */
6118 static sd_chain_struct
*
6119 is_defined_space (name
)
6122 sd_chain_struct
*chain_pointer
;
6124 for (chain_pointer
= space_dict_root
;
6126 chain_pointer
= chain_pointer
->sd_next
)
6128 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
6129 return chain_pointer
;
6132 /* No mapping from segment to space was found. Return NULL. */
6136 /* Find and return the space associated with the given seg. If no mapping
6137 from the given seg to a space is found, then return NULL.
6139 Unlike subspaces, the number of spaces is not expected to grow much,
6140 so a linear exhaustive search is OK here. */
6142 static sd_chain_struct
*
6143 pa_segment_to_space (seg
)
6146 sd_chain_struct
*space_chain
;
6148 /* Walk through each space looking for the correct mapping. */
6149 for (space_chain
= space_dict_root
;
6151 space_chain
= space_chain
->sd_next
)
6153 if (space_chain
->sd_seg
== seg
)
6157 /* Mapping was not found. Return NULL. */
6161 /* Return the space chain entry for the subspace with the name NAME or
6162 NULL if no such subspace exists.
6164 Uses a linear search through all the spaces and subspaces, this may
6165 not be appropriate if we ever being placing each function in its
6168 static ssd_chain_struct
*
6169 is_defined_subspace (name
)
6172 sd_chain_struct
*space_chain
;
6173 ssd_chain_struct
*subspace_chain
;
6175 /* Walk through each space. */
6176 for (space_chain
= space_dict_root
;
6178 space_chain
= space_chain
->sd_next
)
6180 /* Walk through each subspace looking for a name which matches. */
6181 for (subspace_chain
= space_chain
->sd_subspaces
;
6183 subspace_chain
= subspace_chain
->ssd_next
)
6184 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
6185 return subspace_chain
;
6188 /* Subspace wasn't found. Return NULL. */
6192 /* Find and return the subspace associated with the given seg. If no
6193 mapping from the given seg to a subspace is found, then return NULL.
6195 If we ever put each procedure/function within its own subspace
6196 (to make life easier on the compiler and linker), then this will have
6197 to become more efficient. */
6199 static ssd_chain_struct
*
6200 pa_subsegment_to_subspace (seg
, subseg
)
6204 sd_chain_struct
*space_chain
;
6205 ssd_chain_struct
*subspace_chain
;
6207 /* Walk through each space. */
6208 for (space_chain
= space_dict_root
;
6210 space_chain
= space_chain
->sd_next
)
6212 if (space_chain
->sd_seg
== seg
)
6214 /* Walk through each subspace within each space looking for
6215 the correct mapping. */
6216 for (subspace_chain
= space_chain
->sd_subspaces
;
6218 subspace_chain
= subspace_chain
->ssd_next
)
6219 if (subspace_chain
->ssd_subseg
== (int) subseg
)
6220 return subspace_chain
;
6224 /* No mapping from subsegment to subspace found. Return NULL. */
6228 /* Given a number, try and find a space with the name number.
6230 Return a pointer to a space dictionary chain entry for the space
6231 that was found or NULL on failure. */
6233 static sd_chain_struct
*
6234 pa_find_space_by_number (number
)
6237 sd_chain_struct
*space_chain
;
6239 for (space_chain
= space_dict_root
;
6241 space_chain
= space_chain
->sd_next
)
6243 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
6247 /* No appropriate space found. Return NULL. */
6251 /* Return the starting address for the given subspace. If the starting
6252 address is unknown then return zero. */
6255 pa_subspace_start (space
, quadrant
)
6256 sd_chain_struct
*space
;
6260 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
6261 is not correct for the PA OSF1 port. */
6262 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
6264 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
6272 /* FIXME. Needs documentation. */
6274 pa_next_subseg (space
)
6275 sd_chain_struct
*space
;
6278 space
->sd_last_subseg
++;
6279 return space
->sd_last_subseg
;
6282 /* Helper function for pa_stringer. Used to find the end of
6289 unsigned int c
= *s
& CHAR_MASK
;
6291 /* We must have a valid space and subspace. */
6292 pa_check_current_space_and_subspace ();
6305 /* Handle a .STRING type pseudo-op. */
6308 pa_stringer (append_zero
)
6311 char *s
, num_buf
[4];
6315 /* Preprocess the string to handle PA-specific escape sequences.
6316 For example, \xDD where DD is a hexidecimal number should be
6317 changed to \OOO where OOO is an octal number. */
6319 /* Skip the opening quote. */
6320 s
= input_line_pointer
+ 1;
6322 while (is_a_char (c
= pa_stringer_aux (s
++)))
6329 /* Handle \x<num>. */
6332 unsigned int number
;
6337 /* Get pas the 'x'. */
6339 for (num_digit
= 0, number
= 0, dg
= *s
;
6341 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
6342 || (dg
>= 'A' && dg
<= 'F'));
6346 number
= number
* 16 + dg
- '0';
6347 else if (dg
>= 'a' && dg
<= 'f')
6348 number
= number
* 16 + dg
- 'a' + 10;
6350 number
= number
* 16 + dg
- 'A' + 10;
6360 sprintf (num_buf
, "%02o", number
);
6363 sprintf (num_buf
, "%03o", number
);
6366 for (i
= 0; i
<= num_digit
; i
++)
6367 s_start
[i
] = num_buf
[i
];
6371 /* This might be a "\"", skip over the escaped char. */
6378 stringer (append_zero
);
6379 pa_undefine_label ();
6382 /* Handle a .VERSION pseudo-op. */
6389 pa_undefine_label ();
6394 /* Handle a .COMPILER pseudo-op. */
6397 pa_compiler (unused
)
6400 obj_som_compiler (0);
6401 pa_undefine_label ();
6406 /* Handle a .COPYRIGHT pseudo-op. */
6409 pa_copyright (unused
)
6413 pa_undefine_label ();
6416 /* Just like a normal cons, but when finished we have to undefine
6417 the latest space label. */
6424 pa_undefine_label ();
6427 /* Switch to the data space. As usual delete our label. */
6433 current_space
= is_defined_space ("$PRIVATE$");
6435 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6437 pa_undefine_label ();
6440 /* Like float_cons, but we need to undefine our label. */
6443 pa_float_cons (float_type
)
6446 float_cons (float_type
);
6447 pa_undefine_label ();
6450 /* Like s_fill, but delete our label when finished. */
6456 /* We must have a valid space and subspace. */
6457 pa_check_current_space_and_subspace ();
6460 pa_undefine_label ();
6463 /* Like lcomm, but delete our label when finished. */
6466 pa_lcomm (needs_align
)
6469 /* We must have a valid space and subspace. */
6470 pa_check_current_space_and_subspace ();
6472 s_lcomm (needs_align
);
6473 pa_undefine_label ();
6476 /* Like lsym, but delete our label when finished. */
6482 /* We must have a valid space and subspace. */
6483 pa_check_current_space_and_subspace ();
6486 pa_undefine_label ();
6489 /* Switch to the text space. Like s_text, but delete our
6490 label when finished. */
6495 current_space
= is_defined_space ("$TEXT$");
6497 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6500 pa_undefine_label ();
6503 /* On the PA relocations which involve function symbols must not be
6504 adjusted. This so that the linker can know when/how to create argument
6505 relocation stubs for indirect calls and calls to static functions.
6507 "T" field selectors create DLT relative fixups for accessing
6508 globals and statics in PIC code; each DLT relative fixup creates
6509 an entry in the DLT table. The entries contain the address of
6510 the final target (eg accessing "foo" would create a DLT entry
6511 with the address of "foo").
6513 Unfortunately, the HP linker doesn't take into account any addend
6514 when generating the DLT; so accessing $LIT$+8 puts the address of
6515 $LIT$ into the DLT rather than the address of $LIT$+8.
6517 The end result is we can't perform relocation symbol reductions for
6518 any fixup which creates entries in the DLT (eg they use "T" field
6521 Reject reductions involving symbols with external scope; such
6522 reductions make life a living hell for object file editors.
6524 FIXME. Also reject R_HPPA relocations which are 32bits wide in
6525 the code space. The SOM BFD backend doesn't know how to pull the
6526 right bits out of an instruction. */
6529 hppa_fix_adjustable (fixp
)
6532 struct hppa_fix_struct
*hppa_fix
;
6534 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6537 /* Reject reductions of symbols in 32bit relocs. */
6538 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
6541 /* Reject reductions of symbols in sym1-sym2 expressions when
6542 the fixup will occur in a CODE subspace.
6544 XXX FIXME: Long term we probably want to reject all of these;
6545 for example reducing in the debug section would lose if we ever
6546 supported using the optimizing hp linker. */
6549 && (hppa_fix
->segment
->flags
& SEC_CODE
))
6551 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
6552 fixp
->fx_subsy
->sy_used_in_reloc
= 1;
6556 /* We can't adjust any relocs that use LR% and RR% field selectors.
6557 That confuses the HP linker. */
6558 if (hppa_fix
->fx_r_field
== e_lrsel
6559 || hppa_fix
->fx_r_field
== e_rrsel
6560 || hppa_fix
->fx_r_field
== e_nlrsel
)
6564 /* Reject reductions of symbols in DLT relative relocs,
6565 relocations with plabels. */
6566 if (hppa_fix
->fx_r_field
== e_tsel
6567 || hppa_fix
->fx_r_field
== e_ltsel
6568 || hppa_fix
->fx_r_field
== e_rtsel
6569 || hppa_fix
->fx_r_field
== e_psel
6570 || hppa_fix
->fx_r_field
== e_rpsel
6571 || hppa_fix
->fx_r_field
== e_lpsel
)
6574 if (fixp
->fx_addsy
&& fixp
->fx_addsy
->bsym
->flags
& BSF_GLOBAL
)
6577 /* Reject absolute calls (jumps). */
6578 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
6581 /* Reject reductions of function symbols. */
6582 if (fixp
->fx_addsy
== 0
6583 || (fixp
->fx_addsy
->bsym
->flags
& BSF_FUNCTION
) == 0)
6589 /* Return nonzero if the fixup in FIXP will require a relocation,
6590 even it if appears that the fixup could be completely handled
6594 hppa_force_relocation (fixp
)
6597 struct hppa_fix_struct
*hppa_fixp
;
6600 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6602 if (fixp
->fx_r_type
== R_HPPA_ENTRY
|| fixp
->fx_r_type
== R_HPPA_EXIT
6603 || fixp
->fx_r_type
== R_HPPA_BEGIN_BRTAB
6604 || fixp
->fx_r_type
== R_HPPA_END_BRTAB
6605 || fixp
->fx_r_type
== R_HPPA_BEGIN_TRY
6606 || fixp
->fx_r_type
== R_HPPA_END_TRY
6607 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
6608 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
6612 #define arg_reloc_stub_needed(CALLER, CALLEE) \
6613 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
6615 /* It is necessary to force PC-relative calls/jumps to have a relocation
6616 entry if they're going to need either a argument relocation or long
6617 call stub. FIXME. Can't we need the same for absolute calls? */
6618 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
6619 && (arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
6620 fixp
->fx_addsy
->bsym
)->tc_data
.ap
.hppa_arg_reloc
,
6622 hppa_fixp
->fx_arg_reloc
)))
6624 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
6625 - md_pcrel_from (fixp
));
6626 /* Now check and see if we're going to need a long-branch stub. */
6627 if (fixp
->fx_r_type
== R_HPPA_PCREL_CALL
6628 && (distance
> 262143 || distance
< -262144))
6631 if (fixp
->fx_r_type
== R_HPPA_ABS_CALL
)
6633 #undef arg_reloc_stub_needed
6635 /* No need (yet) to force another relocations to be emitted. */
6639 /* Now for some ELF specific code. FIXME. */
6641 /* Mark the end of a function so that it's possible to compute
6642 the size of the function in hppa_elf_final_processing. */
6645 hppa_elf_mark_end_of_function ()
6647 /* ELF does not have EXIT relocations. All we do is create a
6648 temporary symbol marking the end of the function. */
6649 char *name
= (char *)
6650 xmalloc (strlen ("L$\001end_") +
6651 strlen (S_GET_NAME (last_call_info
->start_symbol
)) + 1);
6657 strcpy (name
, "L$\001end_");
6658 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
6660 /* If we have a .exit followed by a .procend, then the
6661 symbol will have already been defined. */
6662 symbolP
= symbol_find (name
);
6665 /* The symbol has already been defined! This can
6666 happen if we have a .exit followed by a .procend.
6668 This is *not* an error. All we want to do is free
6669 the memory we just allocated for the name and continue. */
6674 /* symbol value should be the offset of the
6675 last instruction of the function */
6676 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
6680 symbolP
->bsym
->flags
= BSF_LOCAL
;
6681 symbol_table_insert (symbolP
);
6685 last_call_info
->end_symbol
= symbolP
;
6687 as_bad (_("Symbol '%s' could not be created."), name
);
6691 as_bad (_("No memory for symbol name."));
6695 /* For ELF, this function serves one purpose: to setup the st_size
6696 field of STT_FUNC symbols. To do this, we need to scan the
6697 call_info structure list, determining st_size in by taking the
6698 difference in the address of the beginning/end marker symbols. */
6701 elf_hppa_final_processing ()
6703 struct call_info
*call_info_pointer
;
6705 for (call_info_pointer
= call_info_root
;
6707 call_info_pointer
= call_info_pointer
->ci_next
)
6709 elf_symbol_type
*esym
6710 = (elf_symbol_type
*) call_info_pointer
->start_symbol
->bsym
;
6711 esym
->internal_elf_sym
.st_size
=
6712 S_GET_VALUE (call_info_pointer
->end_symbol
)
6713 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;