1 /* tc-hppa.c -- Assemble for the PA
2 Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* HP PA-RISC support was contributed by the Center for Software Science
24 at the University of Utah. */
32 #include "bfd/libhppa.h"
33 #include "bfd/libbfd.h"
35 /* Be careful, this file includes data *declarations*. */
36 #include "opcode/hppa.h"
38 /* A "convient" place to put object file dependencies which do
39 not need to be seen outside of tc-hppa.c. */
41 /* Names of various debugging spaces/subspaces. */
42 #define GDB_DEBUG_SPACE_NAME ".stab"
43 #define GDB_STRINGS_SUBSPACE_NAME ".stabstr"
44 #define GDB_SYMBOLS_SUBSPACE_NAME ".stab"
45 #define UNWIND_SECTION_NAME ".PARISC.unwind"
46 /* Nonzero if CODE is a fixup code needing further processing. */
48 /* Object file formats specify relocation types. */
49 typedef elf32_hppa_reloc_type reloc_type
;
51 /* Object file formats specify BFD symbol types. */
52 typedef elf_symbol_type obj_symbol_type
;
54 /* How to generate a relocation. */
55 #define hppa_gen_reloc_type hppa_elf_gen_reloc_type
57 /* ELF objects can have versions, but apparently do not have anywhere
58 to store a copyright string. */
59 #define obj_version obj_elf_version
60 #define obj_copyright obj_elf_version
62 /* Use space aliases. */
67 /* Names of various debugging spaces/subspaces. */
68 #define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$"
69 #define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$"
70 #define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$"
71 #define UNWIND_SECTION_NAME "$UNWIND$"
73 /* Object file formats specify relocation types. */
74 typedef int reloc_type
;
76 /* SOM objects can have both a version string and a copyright string. */
77 #define obj_version obj_som_version
78 #define obj_copyright obj_som_copyright
80 /* Do not use space aliases. */
83 /* How to generate a relocation. */
84 #define hppa_gen_reloc_type hppa_som_gen_reloc_type
86 /* Object file formats specify BFD symbol types. */
87 typedef som_symbol_type obj_symbol_type
;
89 /* This apparently isn't in older versions of hpux reloc.h. */
91 #define R_DLT_REL 0x78
103 /* Various structures and types used internally in tc-hppa.c. */
105 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
109 unsigned int cannot_unwind
:1;
110 unsigned int millicode
:1;
111 unsigned int millicode_save_rest
:1;
112 unsigned int region_desc
:2;
113 unsigned int save_sr
:2;
114 unsigned int entry_fr
:4;
115 unsigned int entry_gr
:5;
116 unsigned int args_stored
:1;
117 unsigned int call_fr
:5;
118 unsigned int call_gr
:5;
119 unsigned int save_sp
:1;
120 unsigned int save_rp
:1;
121 unsigned int save_rp_in_frame
:1;
122 unsigned int extn_ptr_defined
:1;
123 unsigned int cleanup_defined
:1;
125 unsigned int hpe_interrupt_marker
:1;
126 unsigned int hpux_interrupt_marker
:1;
127 unsigned int reserved
:3;
128 unsigned int frame_size
:27;
133 /* Starting and ending offsets of the region described by
135 unsigned int start_offset
;
136 unsigned int end_offset
;
137 struct unwind_desc descriptor
;
140 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
141 control the entry and exit code they generate. It is also used in
142 creation of the correct stack unwind descriptors.
144 NOTE: GAS does not support .enter and .leave for the generation of
145 prologues and epilogues. FIXME.
147 The fields in structure roughly correspond to the arguments available on the
148 .callinfo pseudo-op. */
152 /* The unwind descriptor being built. */
153 struct unwind_table ci_unwind
;
155 /* Name of this function. */
156 symbolS
*start_symbol
;
158 /* (temporary) symbol used to mark the end of this function. */
161 /* Next entry in the chain. */
162 struct call_info
*ci_next
;
165 /* Operand formats for FP instructions. Note not all FP instructions
166 allow all four formats to be used (for example fmpysub only allows
170 SGL
, DBL
, ILLEGAL_FMT
, QUAD
, W
, UW
, DW
, UDW
, QW
, UQW
174 /* This fully describes the symbol types which may be attached to
175 an EXPORT or IMPORT directive. Only SOM uses this formation
176 (ELF has no need for it). */
180 SYMBOL_TYPE_ABSOLUTE
,
184 SYMBOL_TYPE_MILLICODE
,
186 SYMBOL_TYPE_PRI_PROG
,
187 SYMBOL_TYPE_SEC_PROG
,
191 /* This structure contains information needed to assemble
192 individual instructions. */
195 /* Holds the opcode after parsing by pa_ip. */
196 unsigned long opcode
;
198 /* Holds an expression associated with the current instruction. */
201 /* Does this instruction use PC-relative addressing. */
204 /* Floating point formats for operand1 and operand2. */
205 fp_operand_format fpof1
;
206 fp_operand_format fpof2
;
209 /* Holds the field selector for this instruction
210 (for example L%, LR%, etc). */
213 /* Holds any argument relocation bits associated with this
214 instruction. (instruction should be some sort of call). */
217 /* The format specification for this instruction. */
220 /* The relocation (if any) associated with this instruction. */
224 /* PA-89 floating point registers are arranged like this:
227 +--------------+--------------+
228 | 0 or 16L | 16 or 16R |
229 +--------------+--------------+
230 | 1 or 17L | 17 or 17R |
231 +--------------+--------------+
239 +--------------+--------------+
240 | 14 or 30L | 30 or 30R |
241 +--------------+--------------+
242 | 15 or 31L | 31 or 31R |
243 +--------------+--------------+
246 The following is a version of pa_parse_number that
247 handles the L/R notation and returns the correct
248 value to put into the instruction register field.
249 The correct value to put into the instruction is
250 encoded in the structure 'pa_11_fp_reg_struct'. */
252 struct pa_11_fp_reg_struct
254 /* The register number. */
261 /* Additional information needed to build argument relocation stubs. */
264 /* The argument relocation specification. */
265 unsigned int arg_reloc
;
267 /* Number of arguments. */
268 unsigned int arg_count
;
271 /* This structure defines an entry in the subspace dictionary
274 struct subspace_dictionary_chain
276 /* Nonzero if this space has been defined by the user code. */
277 unsigned int ssd_defined
;
279 /* Name of this subspace. */
282 /* GAS segment and subsegment associated with this subspace. */
286 /* Next space in the subspace dictionary chain. */
287 struct subspace_dictionary_chain
*ssd_next
;
290 typedef struct subspace_dictionary_chain ssd_chain_struct
;
292 /* This structure defines an entry in the subspace dictionary
295 struct space_dictionary_chain
297 /* Nonzero if this space has been defined by the user code or
298 as a default space. */
299 unsigned int sd_defined
;
301 /* Nonzero if this spaces has been defined by the user code. */
302 unsigned int sd_user_defined
;
304 /* The space number (or index). */
305 unsigned int sd_spnum
;
307 /* The name of this subspace. */
310 /* GAS segment to which this subspace corresponds. */
313 /* Current subsegment number being used. */
316 /* The chain of subspaces contained within this space. */
317 ssd_chain_struct
*sd_subspaces
;
319 /* The next entry in the space dictionary chain. */
320 struct space_dictionary_chain
*sd_next
;
323 typedef struct space_dictionary_chain sd_chain_struct
;
325 /* Structure for previous label tracking. Needed so that alignments,
326 callinfo declarations, etc can be easily attached to a particular
328 typedef struct label_symbol_struct
331 sd_chain_struct
*lss_space
;
332 struct label_symbol_struct
*lss_next
;
336 /* This structure defines attributes of the default subspace
337 dictionary entries. */
339 struct default_subspace_dict
341 /* Name of the subspace. */
344 /* FIXME. Is this still needed? */
347 /* Nonzero if this subspace is loadable. */
350 /* Nonzero if this subspace contains only code. */
353 /* Nonzero if this is a common subspace. */
356 /* Nonzero if this is a common subspace which allows symbols
357 to be multiply defined. */
360 /* Nonzero if this subspace should be zero filled. */
363 /* Sort key for this subspace. */
366 /* Access control bits for this subspace. Can represent RWX access
367 as well as privilege level changes for gateways. */
370 /* Index of containing space. */
373 /* Alignment (in bytes) of this subspace. */
376 /* Quadrant within space where this subspace should be loaded. */
379 /* An index into the default spaces array. */
382 /* An alias for this section (or NULL if no alias exists). */
385 /* Subsegment associated with this subspace. */
389 /* This structure defines attributes of the default space
390 dictionary entries. */
392 struct default_space_dict
394 /* Name of the space. */
397 /* Space number. It is possible to identify spaces within
398 assembly code numerically! */
401 /* Nonzero if this space is loadable. */
404 /* Nonzero if this space is "defined". FIXME is still needed */
407 /* Nonzero if this space can not be shared. */
410 /* Sort key for this space. */
413 /* Segment associated with this space. */
416 /* An alias for this section (or NULL if no alias exists). */
420 /* Extra information needed to perform fixups (relocations) on the PA. */
421 struct hppa_fix_struct
423 /* The field selector. */
424 enum hppa_reloc_field_selector_type_alt fx_r_field
;
429 /* Format of fixup. */
432 /* Argument relocation bits. */
435 /* The segment this fixup appears in. */
439 /* Structure to hold information about predefined registers. */
447 /* This structure defines the mapping from a FP condition string
448 to a condition number which can be recorded in an instruction. */
455 /* This structure defines a mapping from a field selector
456 string to a field selector type. */
457 struct selector_entry
463 /* Prototypes for functions local to tc-hppa.c. */
465 static void pa_check_current_space_and_subspace
PARAMS ((void));
466 static fp_operand_format pa_parse_fp_format
PARAMS ((char **s
));
467 static void pa_cons
PARAMS ((int));
468 static void pa_data
PARAMS ((int));
469 static void pa_float_cons
PARAMS ((int));
470 static void pa_fill
PARAMS ((int));
471 static void pa_lcomm
PARAMS ((int));
472 static void pa_lsym
PARAMS ((int));
473 static void pa_stringer
PARAMS ((int));
474 static void pa_text
PARAMS ((int));
475 static void pa_version
PARAMS ((int));
476 static int pa_parse_fp_cmp_cond
PARAMS ((char **));
477 static int get_expression
PARAMS ((char *));
478 static int pa_get_absolute_expression
PARAMS ((struct pa_it
*, char **));
479 static int evaluate_absolute
PARAMS ((struct pa_it
*));
480 static unsigned int pa_build_arg_reloc
PARAMS ((char *));
481 static unsigned int pa_align_arg_reloc
PARAMS ((unsigned int, unsigned int));
482 static int pa_parse_nullif
PARAMS ((char **));
483 static int pa_parse_nonneg_cmpsub_cmpltr
PARAMS ((char **, int));
484 static int pa_parse_neg_cmpsub_cmpltr
PARAMS ((char **, int));
485 static int pa_parse_neg_add_cmpltr
PARAMS ((char **, int));
486 static int pa_parse_nonneg_add_cmpltr
PARAMS ((char **, int));
487 static void pa_align
PARAMS ((int));
488 static void pa_block
PARAMS ((int));
489 static void pa_brtab
PARAMS ((int));
490 static void pa_try
PARAMS ((int));
491 static void pa_call
PARAMS ((int));
492 static void pa_call_args
PARAMS ((struct call_desc
*));
493 static void pa_callinfo
PARAMS ((int));
494 static void pa_code
PARAMS ((int));
495 static void pa_comm
PARAMS ((int));
497 static void pa_compiler
PARAMS ((int));
499 static void pa_copyright
PARAMS ((int));
500 static void pa_end
PARAMS ((int));
501 static void pa_enter
PARAMS ((int));
502 static void pa_entry
PARAMS ((int));
503 static void pa_equ
PARAMS ((int));
504 static void pa_exit
PARAMS ((int));
505 static void pa_export
PARAMS ((int));
506 static void pa_type_args
PARAMS ((symbolS
*, int));
507 static void pa_import
PARAMS ((int));
508 static void pa_label
PARAMS ((int));
509 static void pa_leave
PARAMS ((int));
510 static void pa_level
PARAMS ((int));
511 static void pa_origin
PARAMS ((int));
512 static void pa_proc
PARAMS ((int));
513 static void pa_procend
PARAMS ((int));
514 static void pa_space
PARAMS ((int));
515 static void pa_spnum
PARAMS ((int));
516 static void pa_subspace
PARAMS ((int));
517 static void pa_param
PARAMS ((int));
518 static void pa_undefine_label
PARAMS ((void));
519 static int need_pa11_opcode
PARAMS ((struct pa_it
*,
520 struct pa_11_fp_reg_struct
*));
521 static int pa_parse_number
PARAMS ((char **, struct pa_11_fp_reg_struct
*));
522 static label_symbol_struct
*pa_get_label
PARAMS ((void));
523 static sd_chain_struct
*create_new_space
PARAMS ((char *, int, int,
526 static ssd_chain_struct
*create_new_subspace
PARAMS ((sd_chain_struct
*,
531 static ssd_chain_struct
*update_subspace
PARAMS ((sd_chain_struct
*,
532 char *, int, int, int,
536 static sd_chain_struct
*is_defined_space
PARAMS ((char *));
537 static ssd_chain_struct
*is_defined_subspace
PARAMS ((char *));
538 static sd_chain_struct
*pa_segment_to_space
PARAMS ((asection
*));
539 static ssd_chain_struct
*pa_subsegment_to_subspace
PARAMS ((asection
*,
541 static sd_chain_struct
*pa_find_space_by_number
PARAMS ((int));
542 static unsigned int pa_subspace_start
PARAMS ((sd_chain_struct
*, int));
543 static void pa_ip
PARAMS ((char *));
544 static void fix_new_hppa
PARAMS ((fragS
*, int, int, symbolS
*,
545 long, expressionS
*, int,
546 bfd_reloc_code_real_type
,
547 enum hppa_reloc_field_selector_type_alt
,
549 static int is_end_of_statement
PARAMS ((void));
550 static int reg_name_search
PARAMS ((char *));
551 static int pa_chk_field_selector
PARAMS ((char **));
552 static int is_same_frag
PARAMS ((fragS
*, fragS
*));
553 static void process_exit
PARAMS ((void));
554 static sd_chain_struct
*pa_parse_space_stmt
PARAMS ((char *, int));
555 static int log2
PARAMS ((int));
556 static int pa_next_subseg
PARAMS ((sd_chain_struct
*));
557 static unsigned int pa_stringer_aux
PARAMS ((char *));
558 static void pa_spaces_begin
PARAMS ((void));
561 static void hppa_elf_mark_end_of_function
PARAMS ((void));
562 static void pa_build_unwind_subspace
PARAMS ((struct call_info
*));
565 /* File and gloally scoped variable declarations. */
567 /* Root and final entry in the space chain. */
568 static sd_chain_struct
*space_dict_root
;
569 static sd_chain_struct
*space_dict_last
;
571 /* The current space and subspace. */
572 static sd_chain_struct
*current_space
;
573 static ssd_chain_struct
*current_subspace
;
575 /* Root of the call_info chain. */
576 static struct call_info
*call_info_root
;
578 /* The last call_info (for functions) structure
579 seen so it can be associated with fixups and
581 static struct call_info
*last_call_info
;
583 /* The last call description (for actual calls). */
584 static struct call_desc last_call_desc
;
586 /* handle of the OPCODE hash table */
587 static struct hash_control
*op_hash
= NULL
;
589 /* This array holds the chars that always start a comment. If the
590 pre-processor is disabled, these aren't very useful. */
591 const char comment_chars
[] = ";";
593 /* Table of pseudo ops for the PA. FIXME -- how many of these
594 are now redundant with the overall GAS and the object file
596 const pseudo_typeS md_pseudo_table
[] =
598 /* align pseudo-ops on the PA specify the actual alignment requested,
599 not the log2 of the requested alignment. */
600 {"align", pa_align
, 8},
601 {"begin_brtab", pa_brtab
, 1},
602 {"begin_try", pa_try
, 1},
603 {"block", pa_block
, 1},
604 {"blockz", pa_block
, 0},
605 {"byte", pa_cons
, 1},
606 {"call", pa_call
, 0},
607 {"callinfo", pa_callinfo
, 0},
608 {"code", pa_code
, 0},
609 {"comm", pa_comm
, 0},
611 {"compiler", pa_compiler
, 0},
613 {"copyright", pa_copyright
, 0},
614 {"data", pa_data
, 0},
615 {"double", pa_float_cons
, 'd'},
617 {"end_brtab", pa_brtab
, 0},
618 {"end_try", pa_try
, 0},
619 {"enter", pa_enter
, 0},
620 {"entry", pa_entry
, 0},
622 {"exit", pa_exit
, 0},
623 {"export", pa_export
, 0},
624 {"fill", pa_fill
, 0},
625 {"float", pa_float_cons
, 'f'},
626 {"half", pa_cons
, 2},
627 {"import", pa_import
, 0},
629 {"label", pa_label
, 0},
630 {"lcomm", pa_lcomm
, 0},
631 {"leave", pa_leave
, 0},
632 {"level", pa_level
, 0},
633 {"long", pa_cons
, 4},
634 {"lsym", pa_lsym
, 0},
635 {"nsubspa", pa_subspace
, 1},
636 {"octa", pa_cons
, 16},
637 {"org", pa_origin
, 0},
638 {"origin", pa_origin
, 0},
639 {"param", pa_param
, 0},
640 {"proc", pa_proc
, 0},
641 {"procend", pa_procend
, 0},
642 {"quad", pa_cons
, 8},
644 {"short", pa_cons
, 2},
645 {"single", pa_float_cons
, 'f'},
646 {"space", pa_space
, 0},
647 {"spnum", pa_spnum
, 0},
648 {"string", pa_stringer
, 0},
649 {"stringz", pa_stringer
, 1},
650 {"subspa", pa_subspace
, 0},
651 {"text", pa_text
, 0},
652 {"version", pa_version
, 0},
653 {"word", pa_cons
, 4},
657 /* This array holds the chars that only start a comment at the beginning of
658 a line. If the line seems to have the form '# 123 filename'
659 .line and .file directives will appear in the pre-processed output.
661 Note that input_file.c hand checks for '#' at the beginning of the
662 first line of the input file. This is because the compiler outputs
663 #NO_APP at the beginning of its output.
665 Also note that C style comments will always work. */
666 const char line_comment_chars
[] = "#";
668 /* This array holds the characters which act as line separators. */
669 const char line_separator_chars
[] = "!";
671 /* Chars that can be used to separate mant from exp in floating point nums. */
672 const char EXP_CHARS
[] = "eE";
674 /* Chars that mean this number is a floating point constant.
675 As in 0f12.456 or 0d1.2345e12.
677 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
678 changed in read.c. Ideally it shouldn't hae to know abou it at
679 all, but nothing is ideal around here. */
680 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
682 static struct pa_it the_insn
;
684 /* Points to the end of an expression just parsed by get_expressoin
685 and friends. FIXME. This shouldn't be handled with a file-global
687 static char *expr_end
;
689 /* Nonzero if a .callinfo appeared within the current procedure. */
690 static int callinfo_found
;
692 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
693 static int within_entry_exit
;
695 /* Nonzero if the assembler is currently within a procedure definition. */
696 static int within_procedure
;
698 /* Handle on strucutre which keep track of the last symbol
699 seen in each subspace. */
700 static label_symbol_struct
*label_symbols_rootp
= NULL
;
702 /* Holds the last field selector. */
703 static int hppa_field_selector
;
706 /* A dummy bfd symbol so that all relocations have symbols of some kind. */
707 static symbolS
*dummy_symbol
;
709 /* Nonzero if errors are to be printed. */
710 static int print_errors
= 1;
712 /* List of registers that are pre-defined:
714 Each general register has one predefined name of the form
715 %r<REGNUM> which has the value <REGNUM>.
717 Space and control registers are handled in a similar manner,
718 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
720 Likewise for the floating point registers, but of the form
721 %fr<REGNUM>. Floating point registers have additional predefined
722 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
723 again have the value <REGNUM>.
725 Many registers also have synonyms:
727 %r26 - %r23 have %arg0 - %arg3 as synonyms
728 %r28 - %r29 have %ret0 - %ret1 as synonyms
729 %r30 has %sp as a synonym
730 %r27 has %dp as a synonym
731 %r2 has %rp as a synonym
733 Almost every control register has a synonym; they are not listed
736 The table is sorted. Suitable for searching by a binary search. */
738 static const struct pd_reg pre_defined_registers
[] =
938 /* This table is sorted by order of the length of the string. This is
939 so we check for <> before we check for <. If we had a <> and checked
940 for < first, we would get a false match. */
941 static const struct fp_cond_map fp_cond_map
[] =
977 static const struct selector_entry selector_table
[] =
999 /* default space and subspace dictionaries */
1001 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1002 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1004 /* pre-defined subsegments (subspaces) for the HPPA. */
1005 #define SUBSEG_CODE 0
1006 #define SUBSEG_LIT 1
1007 #define SUBSEG_MILLI 2
1008 #define SUBSEG_DATA 0
1009 #define SUBSEG_BSS 2
1010 #define SUBSEG_UNWIND 3
1011 #define SUBSEG_GDB_STRINGS 0
1012 #define SUBSEG_GDB_SYMBOLS 1
1014 static struct default_subspace_dict pa_def_subspaces
[] =
1016 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_CODE
},
1017 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, ".data", SUBSEG_DATA
},
1018 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_LIT
},
1019 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_MILLI
},
1020 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, ".bss", SUBSEG_BSS
},
1022 {"$UNWIND$", 1, 1, 0, 0, 0, 0, 64, 0x2c, 0, 4, 0, 0, ".PARISC.unwind", SUBSEG_UNWIND
},
1024 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1027 static struct default_space_dict pa_def_spaces
[] =
1029 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
, ".text"},
1030 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
, ".data"},
1031 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
, NULL
}
1034 /* Misc local definitions used by the assembler. */
1036 /* Return nonzero if the string pointed to by S potentially represents
1037 a right or left half of a FP register */
1038 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1039 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1041 /* These macros are used to maintain spaces/subspaces. */
1042 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1043 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1044 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1045 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1047 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1048 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1050 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1051 main loop after insertion. */
1053 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1055 ((OPCODE) |= (FIELD) << (START)); \
1059 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1060 IGNORE is used to suppress the error message. */
1062 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1064 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1067 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1073 #define is_DP_relative(exp) \
1074 ((exp).X_op == O_subtract \
1075 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1077 #define is_PC_relative(exp) \
1078 ((exp).X_op == O_subtract \
1079 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1081 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1082 always be able to reduce the expression to a constant, so we don't
1083 need real complex handling yet. */
1084 #define is_complex(exp) \
1085 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1087 /* Actual functions to implement the PA specific code for the assembler. */
1089 /* Called before writing the object file. Make sure entry/exit and
1090 proc/procend pairs match. */
1095 if (within_entry_exit
)
1096 as_fatal (_("Missing .exit\n"));
1098 if (within_procedure
)
1099 as_fatal (_("Missing .procend\n"));
1102 /* Check to make sure we have a valid space and subspace. */
1105 pa_check_current_space_and_subspace ()
1107 if (current_space
== NULL
)
1108 as_fatal (_("Not in a space.\n"));
1110 if (current_subspace
== NULL
)
1111 as_fatal (_("Not in a subspace.\n"));
1114 /* Returns a pointer to the label_symbol_struct for the current space.
1115 or NULL if no label_symbol_struct exists for the current space. */
1117 static label_symbol_struct
*
1120 label_symbol_struct
*label_chain
;
1121 sd_chain_struct
*space_chain
= current_space
;
1123 for (label_chain
= label_symbols_rootp
;
1125 label_chain
= label_chain
->lss_next
)
1126 if (space_chain
== label_chain
->lss_space
&& label_chain
->lss_label
)
1132 /* Defines a label for the current space. If one is already defined,
1133 this function will replace it with the new label. */
1136 pa_define_label (symbol
)
1139 label_symbol_struct
*label_chain
= pa_get_label ();
1140 sd_chain_struct
*space_chain
= current_space
;
1143 label_chain
->lss_label
= symbol
;
1146 /* Create a new label entry and add it to the head of the chain. */
1148 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1149 label_chain
->lss_label
= symbol
;
1150 label_chain
->lss_space
= space_chain
;
1151 label_chain
->lss_next
= NULL
;
1153 if (label_symbols_rootp
)
1154 label_chain
->lss_next
= label_symbols_rootp
;
1156 label_symbols_rootp
= label_chain
;
1160 /* Removes a label definition for the current space.
1161 If there is no label_symbol_struct entry, then no action is taken. */
1164 pa_undefine_label ()
1166 label_symbol_struct
*label_chain
;
1167 label_symbol_struct
*prev_label_chain
= NULL
;
1168 sd_chain_struct
*space_chain
= current_space
;
1170 for (label_chain
= label_symbols_rootp
;
1172 label_chain
= label_chain
->lss_next
)
1174 if (space_chain
== label_chain
->lss_space
&& label_chain
->lss_label
)
1176 /* Remove the label from the chain and free its memory. */
1177 if (prev_label_chain
)
1178 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1180 label_symbols_rootp
= label_chain
->lss_next
;
1185 prev_label_chain
= label_chain
;
1190 /* An HPPA-specific version of fix_new. This is required because the HPPA
1191 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1192 results in the creation of an instance of an hppa_fix_struct. An
1193 hppa_fix_struct stores the extra information along with a pointer to the
1194 original fixS. This is attached to the original fixup via the
1195 tc_fix_data field. */
1198 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1199 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1203 symbolS
*add_symbol
;
1207 bfd_reloc_code_real_type r_type
;
1208 enum hppa_reloc_field_selector_type_alt r_field
;
1215 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1216 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1219 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1221 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1222 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1223 hppa_fix
->fx_r_type
= r_type
;
1224 hppa_fix
->fx_r_field
= r_field
;
1225 hppa_fix
->fx_r_format
= r_format
;
1226 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1227 hppa_fix
->segment
= now_seg
;
1229 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1230 new_fix
->fx_offset
= *unwind_bits
;
1233 /* foo-$global$ is used to access non-automatic storage. $global$
1234 is really just a marker and has served its purpose, so eliminate
1235 it now so as not to confuse write.c. */
1236 if (new_fix
->fx_subsy
1237 && !strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$"))
1238 new_fix
->fx_subsy
= NULL
;
1241 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1242 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1245 parse_cons_expression_hppa (exp
)
1248 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1252 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1253 hppa_field_selector is set by the parse_cons_expression_hppa. */
1256 cons_fix_new_hppa (frag
, where
, size
, exp
)
1262 unsigned int rel_type
;
1264 /* Get a base relocation type. */
1265 if (is_DP_relative (*exp
))
1266 rel_type
= R_HPPA_GOTOFF
;
1267 else if (is_complex (*exp
))
1268 rel_type
= R_HPPA_COMPLEX
;
1272 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1273 as_warn (_("Invalid field selector. Assuming F%%."));
1275 fix_new_hppa (frag
, where
, size
,
1276 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1277 hppa_field_selector
, 32, 0, NULL
);
1279 /* Reset field selector to its default state. */
1280 hppa_field_selector
= 0;
1283 /* This function is called once, at assembler startup time. It should
1284 set up all the tables, etc. that the MD part of the assembler will need. */
1289 const char *retval
= NULL
;
1293 last_call_info
= NULL
;
1294 call_info_root
= NULL
;
1296 /* Set the default machine type. */
1297 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1298 as_warn (_("could not set architecture and machine"));
1300 /* Folding of text and data segments fails miserably on the PA.
1301 Warn user and disable "-R" option. */
1302 if (flag_readonly_data_in_text
)
1304 as_warn (_("-R option not supported on this target."));
1305 flag_readonly_data_in_text
= 0;
1310 op_hash
= hash_new ();
1312 while (i
< NUMOPCODES
)
1314 const char *name
= pa_opcodes
[i
].name
;
1315 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1316 if (retval
!= NULL
&& *retval
!= '\0')
1318 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1323 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1324 != pa_opcodes
[i
].match
)
1326 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1327 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1332 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1336 as_fatal (_("Broken assembler. No assembly attempted."));
1338 /* SOM will change text_section. To make sure we never put
1339 anything into the old one switch to the new one now. */
1340 subseg_set (text_section
, 0);
1342 dummy_symbol
= symbol_find_or_make ("L$dummy");
1343 S_SET_SEGMENT (dummy_symbol
, text_section
);
1346 /* Assemble a single instruction storing it into a frag. */
1353 /* The had better be something to assemble. */
1356 /* If we are within a procedure definition, make sure we've
1357 defined a label for the procedure; handle case where the
1358 label was defined after the .PROC directive.
1360 Note there's not need to diddle with the segment or fragment
1361 for the label symbol in this case. We have already switched
1362 into the new $CODE$ subspace at this point. */
1363 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1365 label_symbol_struct
*label_symbol
= pa_get_label ();
1369 if (label_symbol
->lss_label
)
1371 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1372 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1375 /* Also handle allocation of a fixup to hold the unwind
1376 information when the label appears after the proc/procend. */
1377 if (within_entry_exit
)
1379 char *where
= frag_more (0);
1381 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1382 NULL
, (offsetT
) 0, NULL
,
1383 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1384 (int *)&last_call_info
->ci_unwind
.descriptor
);
1389 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1392 as_bad (_("Missing function name for .PROC"));
1395 /* Assemble the instruction. Results are saved into "the_insn". */
1398 /* Get somewhere to put the assembled instrution. */
1401 /* Output the opcode. */
1402 md_number_to_chars (to
, the_insn
.opcode
, 4);
1404 /* If necessary output more stuff. */
1405 if (the_insn
.reloc
!= R_HPPA_NONE
)
1406 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1407 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1408 the_insn
.reloc
, the_insn
.field_selector
,
1409 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1412 /* Do the real work for assembling a single instruction. Store results
1413 into the global "the_insn" variable. */
1419 char *error_message
= "";
1420 char *s
, c
, *argstart
, *name
, *save_s
;
1424 int cmpltr
, nullif
, flag
, cond
, num
;
1425 unsigned long opcode
;
1426 struct pa_opcode
*insn
;
1428 /* We must have a valid space and subspace. */
1429 pa_check_current_space_and_subspace ();
1431 /* Skip to something interesting. */
1432 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1451 as_fatal (_("Unknown opcode: `%s'"), str
);
1456 /* Convert everything into lower case. */
1459 if (isupper (*save_s
))
1460 *save_s
= tolower (*save_s
);
1464 /* Look up the opcode in the has table. */
1465 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1467 as_bad ("Unknown opcode: `%s'", str
);
1476 /* Mark the location where arguments for the instruction start, then
1477 start processing them. */
1481 /* Do some initialization. */
1482 opcode
= insn
->match
;
1483 memset (&the_insn
, 0, sizeof (the_insn
));
1485 the_insn
.reloc
= R_HPPA_NONE
;
1487 /* If this instruction is specific to a particular architecture,
1488 then set a new architecture. */
1489 /* But do not automatically promote to pa2.0. The automatic promotion
1490 crud is for compatability with HP's old assemblers only. */
1492 && bfd_get_mach (stdoutput
) < insn
->arch
)
1494 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1495 as_warn (_("could not update architecture and machine"));
1497 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1503 /* Build the opcode, checking as we go to make
1504 sure that the operands match. */
1505 for (args
= insn
->args
;; ++args
)
1510 /* End of arguments. */
1526 /* These must match exactly. */
1535 /* Handle a 5 bit register or control register field at 10. */
1538 num
= pa_parse_number (&s
, 0);
1539 CHECK_FIELD (num
, 31, 0, 0);
1540 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1542 /* Handle a 5 bit register field at 15. */
1544 num
= pa_parse_number (&s
, 0);
1545 CHECK_FIELD (num
, 31, 0, 0);
1546 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1548 /* Handle a 5 bit register field at 31. */
1551 num
= pa_parse_number (&s
, 0);
1552 CHECK_FIELD (num
, 31, 0, 0);
1553 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1555 /* Handle a 5 bit field length at 31. */
1557 num
= pa_get_absolute_expression (&the_insn
, &s
);
1559 CHECK_FIELD (num
, 32, 1, 0);
1560 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1562 /* Handle a 5 bit immediate at 15. */
1564 num
= pa_get_absolute_expression (&the_insn
, &s
);
1566 CHECK_FIELD (num
, 15, -16, 0);
1567 low_sign_unext (num
, 5, &num
);
1568 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1570 /* Handle a 5 bit immediate at 31. */
1572 num
= pa_get_absolute_expression (&the_insn
, &s
);
1574 CHECK_FIELD (num
, 15, -16, 0)
1575 low_sign_unext (num
, 5, &num
);
1576 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1578 /* Handle an unsigned 5 bit immediate at 31. */
1580 num
= pa_get_absolute_expression (&the_insn
, &s
);
1582 CHECK_FIELD (num
, 31, 0, 0);
1583 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1585 /* Handle an unsigned 5 bit immediate at 15. */
1587 num
= pa_get_absolute_expression (&the_insn
, &s
);
1589 CHECK_FIELD (num
, 31, 0, 0);
1590 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1592 /* Handle a 2 bit space identifier at 17. */
1594 num
= pa_parse_number (&s
, 0);
1595 CHECK_FIELD (num
, 3, 0, 1);
1596 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1598 /* Handle a 3 bit space identifier at 18. */
1600 num
= pa_parse_number (&s
, 0);
1601 CHECK_FIELD (num
, 7, 0, 1);
1602 dis_assemble_3 (num
, &num
);
1603 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
1605 /* Handle a completer for an indexing load or store. */
1611 while (*s
== ',' && i
< 2)
1614 if (strncasecmp (s
, "sm", 2) == 0)
1621 else if (strncasecmp (s
, "m", 1) == 0)
1623 else if (strncasecmp (s
, "s", 1) == 0)
1626 as_bad (_("Invalid Indexed Load Completer."));
1631 as_bad (_("Invalid Indexed Load Completer Syntax."));
1633 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1636 /* Handle a short load/store completer. */
1644 if (strncasecmp (s
, "ma", 2) == 0)
1649 else if (strncasecmp (s
, "mb", 2) == 0)
1655 as_bad (_("Invalid Short Load/Store Completer."));
1662 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1666 /* Handle a stbys completer. */
1672 while (*s
== ',' && i
< 2)
1675 if (strncasecmp (s
, "m", 1) == 0)
1677 else if (strncasecmp (s
, "b", 1) == 0)
1679 else if (strncasecmp (s
, "e", 1) == 0)
1682 as_bad (_("Invalid Store Bytes Short Completer"));
1687 as_bad (_("Invalid Store Bytes Short Completer"));
1689 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1692 /* Handle a non-negated compare/stubtract condition. */
1694 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
1697 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
1700 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1702 /* Handle a negated or non-negated compare/subtract condition. */
1705 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
1709 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
1712 as_bad (_("Invalid Compare/Subtract Condition."));
1717 /* Negated condition requires an opcode change. */
1722 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1724 /* Handle non-negated add condition. */
1726 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1729 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
1732 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1734 /* Handle a negated or non-negated add condition. */
1737 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1741 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
1744 as_bad (_("Invalid Compare/Subtract Condition"));
1749 /* Negated condition requires an opcode change. */
1753 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1755 /* Handle a compare/subtract condition. */
1763 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1767 if (strcmp (name
, "=") == 0)
1769 else if (strcmp (name
, "<") == 0)
1771 else if (strcmp (name
, "<=") == 0)
1773 else if (strcasecmp (name
, "<<") == 0)
1775 else if (strcasecmp (name
, "<<=") == 0)
1777 else if (strcasecmp (name
, "sv") == 0)
1779 else if (strcasecmp (name
, "od") == 0)
1781 else if (strcasecmp (name
, "tr") == 0)
1786 else if (strcmp (name
, "<>") == 0)
1791 else if (strcmp (name
, ">=") == 0)
1796 else if (strcmp (name
, ">") == 0)
1801 else if (strcasecmp (name
, ">>=") == 0)
1806 else if (strcasecmp (name
, ">>") == 0)
1811 else if (strcasecmp (name
, "nsv") == 0)
1816 else if (strcasecmp (name
, "ev") == 0)
1822 as_bad (_("Invalid Add Condition: %s"), name
);
1825 opcode
|= cmpltr
<< 13;
1826 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1828 /* Handle a non-negated add condition. */
1836 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1840 if (strcmp (name
, "=") == 0)
1842 else if (strcmp (name
, "<") == 0)
1844 else if (strcmp (name
, "<=") == 0)
1846 else if (strcasecmp (name
, "nuv") == 0)
1848 else if (strcasecmp (name
, "znv") == 0)
1850 else if (strcasecmp (name
, "sv") == 0)
1852 else if (strcasecmp (name
, "od") == 0)
1854 else if (strcasecmp (name
, "tr") == 0)
1859 else if (strcmp (name
, "<>") == 0)
1864 else if (strcmp (name
, ">=") == 0)
1869 else if (strcmp (name
, ">") == 0)
1874 else if (strcasecmp (name
, "uv") == 0)
1879 else if (strcasecmp (name
, "vnz") == 0)
1884 else if (strcasecmp (name
, "nsv") == 0)
1889 else if (strcasecmp (name
, "ev") == 0)
1895 as_bad (_("Invalid Add Condition: %s"), name
);
1898 opcode
|= cmpltr
<< 13;
1899 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1901 /* HANDLE a logical instruction condition. */
1909 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1915 if (strcmp (name
, "=") == 0)
1917 else if (strcmp (name
, "<") == 0)
1919 else if (strcmp (name
, "<=") == 0)
1921 else if (strcasecmp (name
, "od") == 0)
1923 else if (strcasecmp (name
, "tr") == 0)
1928 else if (strcmp (name
, "<>") == 0)
1933 else if (strcmp (name
, ">=") == 0)
1938 else if (strcmp (name
, ">") == 0)
1943 else if (strcasecmp (name
, "ev") == 0)
1949 as_bad (_("Invalid Logical Instruction Condition."));
1952 opcode
|= cmpltr
<< 13;
1953 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1955 /* Handle a unit instruction condition. */
1964 if (strncasecmp (s
, "sbz", 3) == 0)
1969 else if (strncasecmp (s
, "shz", 3) == 0)
1974 else if (strncasecmp (s
, "sdc", 3) == 0)
1979 else if (strncasecmp (s
, "sbc", 3) == 0)
1984 else if (strncasecmp (s
, "shc", 3) == 0)
1989 else if (strncasecmp (s
, "tr", 2) == 0)
1995 else if (strncasecmp (s
, "nbz", 3) == 0)
2001 else if (strncasecmp (s
, "nhz", 3) == 0)
2007 else if (strncasecmp (s
, "ndc", 3) == 0)
2013 else if (strncasecmp (s
, "nbc", 3) == 0)
2019 else if (strncasecmp (s
, "nhc", 3) == 0)
2026 as_bad (_("Invalid Logical Instruction Condition."));
2028 opcode
|= cmpltr
<< 13;
2029 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2031 /* Handle a shift/extract/deposit condition. */
2041 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2045 if (strcmp (name
, "=") == 0)
2047 else if (strcmp (name
, "<") == 0)
2049 else if (strcasecmp (name
, "od") == 0)
2051 else if (strcasecmp (name
, "tr") == 0)
2053 else if (strcmp (name
, "<>") == 0)
2055 else if (strcmp (name
, ">=") == 0)
2057 else if (strcasecmp (name
, "ev") == 0)
2059 /* Handle movb,n. Put things back the way they were.
2060 This includes moving s back to where it started. */
2061 else if (strcasecmp (name
, "n") == 0 && *args
== '|')
2068 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2071 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2073 /* Handle bvb and bb conditions. */
2079 if (strncmp (s
, "<", 1) == 0)
2084 else if (strncmp (s
, ">=", 2) == 0)
2090 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2092 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2094 /* Handle a system control completer. */
2096 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2104 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2106 /* Handle a nullification completer for branch instructions. */
2108 nullif
= pa_parse_nullif (&s
);
2109 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2111 /* Handle a nullification completer for copr and spop insns. */
2113 nullif
= pa_parse_nullif (&s
);
2114 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2117 /* Handle a 11 bit immediate at 31. */
2119 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2122 if (the_insn
.exp
.X_op
== O_constant
)
2124 num
= evaluate_absolute (&the_insn
);
2125 CHECK_FIELD (num
, 1023, -1024, 0);
2126 low_sign_unext (num
, 11, &num
);
2127 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2131 if (is_DP_relative (the_insn
.exp
))
2132 the_insn
.reloc
= R_HPPA_GOTOFF
;
2133 else if (is_PC_relative (the_insn
.exp
))
2134 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2136 the_insn
.reloc
= R_HPPA
;
2137 the_insn
.format
= 11;
2142 /* Handle a 14 bit immediate at 31. */
2144 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2147 if (the_insn
.exp
.X_op
== O_constant
)
2149 num
= evaluate_absolute (&the_insn
);
2150 CHECK_FIELD (num
, 8191, -8192, 0);
2151 low_sign_unext (num
, 14, &num
);
2152 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2156 if (is_DP_relative (the_insn
.exp
))
2157 the_insn
.reloc
= R_HPPA_GOTOFF
;
2158 else if (is_PC_relative (the_insn
.exp
))
2159 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2161 the_insn
.reloc
= R_HPPA
;
2162 the_insn
.format
= 14;
2166 /* Handle a 21 bit immediate at 31. */
2168 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2171 if (the_insn
.exp
.X_op
== O_constant
)
2173 num
= evaluate_absolute (&the_insn
);
2174 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
2175 dis_assemble_21 (num
, &num
);
2176 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2180 if (is_DP_relative (the_insn
.exp
))
2181 the_insn
.reloc
= R_HPPA_GOTOFF
;
2182 else if (is_PC_relative (the_insn
.exp
))
2183 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2185 the_insn
.reloc
= R_HPPA
;
2186 the_insn
.format
= 21;
2190 /* Handle a 12 bit branch displacement. */
2192 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2196 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
2198 unsigned int w1
, w
, result
;
2200 num
= evaluate_absolute (&the_insn
);
2203 as_bad (_("Branch to unaligned address"));
2206 CHECK_FIELD (num
, 8199, -8184, 0);
2207 sign_unext ((num
- 8) >> 2, 12, &result
);
2208 dis_assemble_12 (result
, &w1
, &w
);
2209 INSERT_FIELD_AND_CONTINUE (opcode
, ((w1
<< 2) | w
), 0);
2213 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2214 the_insn
.format
= 12;
2215 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2216 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2221 /* Handle a 17 bit branch displacement. */
2223 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2227 if (!the_insn
.exp
.X_add_symbol
2228 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2231 unsigned int w2
, w1
, w
, result
;
2233 num
= evaluate_absolute (&the_insn
);
2236 as_bad (_("Branch to unaligned address"));
2239 CHECK_FIELD (num
, 262143, -262144, 0);
2241 if (the_insn
.exp
.X_add_symbol
)
2244 sign_unext (num
>> 2, 17, &result
);
2245 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2246 INSERT_FIELD_AND_CONTINUE (opcode
,
2247 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2251 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2252 the_insn
.format
= 17;
2253 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2254 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2258 /* Handle an absolute 17 bit branch target. */
2260 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2264 if (!the_insn
.exp
.X_add_symbol
2265 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2268 unsigned int w2
, w1
, w
, result
;
2270 num
= evaluate_absolute (&the_insn
);
2273 as_bad (_("Branch to unaligned address"));
2276 CHECK_FIELD (num
, 262143, -262144, 0);
2278 if (the_insn
.exp
.X_add_symbol
)
2281 sign_unext (num
>> 2, 17, &result
);
2282 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2283 INSERT_FIELD_AND_CONTINUE (opcode
,
2284 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2288 the_insn
.reloc
= R_HPPA_ABS_CALL
;
2289 the_insn
.format
= 17;
2290 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2291 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2295 /* Handle a 5 bit shift count at 26. */
2297 num
= pa_get_absolute_expression (&the_insn
, &s
);
2299 CHECK_FIELD (num
, 31, 0, 0);
2300 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
2302 /* Handle a 5 bit bit position at 26. */
2304 num
= pa_get_absolute_expression (&the_insn
, &s
);
2306 CHECK_FIELD (num
, 31, 0, 0);
2307 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
2309 /* Handle a 5 bit immediate at 10. */
2312 num
= pa_get_absolute_expression (&the_insn
, &s
);
2313 if (the_insn
.exp
.X_op
!= O_constant
)
2316 CHECK_FIELD (num
, 31, 0, 0);
2317 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
2319 /* Handle a 13 bit immediate at 18. */
2321 num
= pa_get_absolute_expression (&the_insn
, &s
);
2323 CHECK_FIELD (num
, 8191, 0, 0);
2324 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2326 /* Handle a 26 bit immediate at 31. */
2328 num
= pa_get_absolute_expression (&the_insn
, &s
);
2330 CHECK_FIELD (num
, 671108864, 0, 0);
2331 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2333 /* Handle a 3 bit SFU identifier at 25. */
2336 as_bad (_("Invalid SFU identifier"));
2337 num
= pa_get_absolute_expression (&the_insn
, &s
);
2339 CHECK_FIELD (num
, 7, 0, 0);
2340 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2342 /* Handle a 20 bit SOP field for spop0. */
2344 num
= pa_get_absolute_expression (&the_insn
, &s
);
2346 CHECK_FIELD (num
, 1048575, 0, 0);
2347 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
2348 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2350 /* Handle a 15bit SOP field for spop1. */
2352 num
= pa_get_absolute_expression (&the_insn
, &s
);
2354 CHECK_FIELD (num
, 32767, 0, 0);
2355 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
2357 /* Handle a 10bit SOP field for spop3. */
2359 num
= pa_get_absolute_expression (&the_insn
, &s
);
2361 CHECK_FIELD (num
, 1023, 0, 0);
2362 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
2363 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2365 /* Handle a 15 bit SOP field for spop2. */
2367 num
= pa_get_absolute_expression (&the_insn
, &s
);
2369 CHECK_FIELD (num
, 32767, 0, 0);
2370 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
2371 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2373 /* Handle a 3-bit co-processor ID field. */
2376 as_bad (_("Invalid COPR identifier"));
2377 num
= pa_get_absolute_expression (&the_insn
, &s
);
2379 CHECK_FIELD (num
, 7, 0, 0);
2380 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2382 /* Handle a 22bit SOP field for copr. */
2384 num
= pa_get_absolute_expression (&the_insn
, &s
);
2386 CHECK_FIELD (num
, 4194303, 0, 0);
2387 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
2388 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2391 /* Handle a source FP operand format completer. */
2393 flag
= pa_parse_fp_format (&s
);
2394 the_insn
.fpof1
= flag
;
2395 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2397 /* Handle a destination FP operand format completer. */
2399 /* pa_parse_format needs the ',' prefix. */
2401 flag
= pa_parse_fp_format (&s
);
2402 the_insn
.fpof2
= flag
;
2403 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
2405 /* Handle FP compare conditions. */
2407 cond
= pa_parse_fp_cmp_cond (&s
);
2408 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2410 /* Handle L/R register halves like 't'. */
2413 struct pa_11_fp_reg_struct result
;
2415 pa_parse_number (&s
, &result
);
2416 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2417 opcode
|= result
.number_part
;
2419 /* 0x30 opcodes are FP arithmetic operation opcodes
2420 and need to be turned into 0x38 opcodes. This
2421 is not necessary for loads/stores. */
2422 if (need_pa11_opcode (&the_insn
, &result
)
2423 && ((opcode
& 0xfc000000) == 0x30000000))
2426 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
2429 /* Handle L/R register halves like 'b'. */
2432 struct pa_11_fp_reg_struct result
;
2434 pa_parse_number (&s
, &result
);
2435 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2436 opcode
|= result
.number_part
<< 21;
2437 if (need_pa11_opcode (&the_insn
, &result
))
2439 opcode
|= (result
.l_r_select
& 1) << 7;
2445 /* Handle L/R register halves like 'b'. */
2448 struct pa_11_fp_reg_struct result
;
2451 pa_parse_number (&s
, &result
);
2452 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2453 opcode
|= (result
.number_part
& 0x1c) << 11;
2454 opcode
|= (result
.number_part
& 0x3) << 9;
2455 opcode
|= (result
.l_r_select
& 1) << 8;
2459 /* Handle L/R register halves like 'x'. */
2462 struct pa_11_fp_reg_struct result
;
2464 pa_parse_number (&s
, &result
);
2465 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2466 opcode
|= (result
.number_part
& 0x1f) << 16;
2467 if (need_pa11_opcode (&the_insn
, &result
))
2469 opcode
|= (result
.l_r_select
& 1) << 1;
2474 /* Handle L/R register halves like 'x'. */
2477 struct pa_11_fp_reg_struct result
;
2479 pa_parse_number (&s
, &result
);
2480 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2481 opcode
|= (result
.number_part
& 0x1f) << 16;
2482 if (need_pa11_opcode (&the_insn
, &result
))
2484 opcode
|= (result
.l_r_select
& 1) << 12;
2490 /* Handle a 5 bit register field at 10. */
2493 struct pa_11_fp_reg_struct result
;
2495 pa_parse_number (&s
, &result
);
2496 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2497 if (the_insn
.fpof1
== SGL
)
2499 if (result
.number_part
< 16)
2501 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2505 result
.number_part
&= 0xF;
2506 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2508 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
2511 /* Handle a 5 bit register field at 15. */
2514 struct pa_11_fp_reg_struct result
;
2516 pa_parse_number (&s
, &result
);
2517 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2518 if (the_insn
.fpof1
== SGL
)
2520 if (result
.number_part
< 16)
2522 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2525 result
.number_part
&= 0xF;
2526 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2528 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
2531 /* Handle a 5 bit register field at 31. */
2534 struct pa_11_fp_reg_struct result
;
2536 pa_parse_number (&s
, &result
);
2537 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2538 if (the_insn
.fpof1
== SGL
)
2540 if (result
.number_part
< 16)
2542 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2545 result
.number_part
&= 0xF;
2546 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2548 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
2551 /* Handle a 5 bit register field at 20. */
2554 struct pa_11_fp_reg_struct result
;
2556 pa_parse_number (&s
, &result
);
2557 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2558 if (the_insn
.fpof1
== SGL
)
2560 if (result
.number_part
< 16)
2562 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2565 result
.number_part
&= 0xF;
2566 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2568 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
2571 /* Handle a 5 bit register field at 25. */
2574 struct pa_11_fp_reg_struct result
;
2576 pa_parse_number (&s
, &result
);
2577 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2578 if (the_insn
.fpof1
== SGL
)
2580 if (result
.number_part
< 16)
2582 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2585 result
.number_part
&= 0xF;
2586 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2588 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
2591 /* Handle a floating point operand format at 26.
2592 Only allows single and double precision. */
2594 flag
= pa_parse_fp_format (&s
);
2600 the_insn
.fpof1
= flag
;
2606 as_bad (_("Invalid Floating Point Operand Format."));
2617 /* Check if the args matched. */
2620 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
2621 && !strcmp (insn
->name
, insn
[1].name
))
2629 as_bad (_("Invalid operands %s"), error_message
);
2636 the_insn
.opcode
= opcode
;
2639 /* Turn a string in input_line_pointer into a floating point constant of type
2640 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
2641 emitted is stored in *sizeP . An error message or NULL is returned. */
2643 #define MAX_LITTLENUMS 6
2646 md_atof (type
, litP
, sizeP
)
2652 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
2653 LITTLENUM_TYPE
*wordP
;
2685 return _("Bad call to MD_ATOF()");
2687 t
= atof_ieee (input_line_pointer
, type
, words
);
2689 input_line_pointer
= t
;
2690 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
2691 for (wordP
= words
; prec
--;)
2693 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
2694 litP
+= sizeof (LITTLENUM_TYPE
);
2699 /* Write out big-endian. */
2702 md_number_to_chars (buf
, val
, n
)
2707 number_to_chars_bigendian (buf
, val
, n
);
2710 /* Translate internal representation of relocation info to BFD target
2714 tc_gen_reloc (section
, fixp
)
2719 struct hppa_fix_struct
*hppa_fixp
;
2720 bfd_reloc_code_real_type code
;
2721 static arelent
*no_relocs
= NULL
;
2723 bfd_reloc_code_real_type
**codes
;
2727 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
2728 if (fixp
->fx_addsy
== 0)
2730 assert (hppa_fixp
!= 0);
2731 assert (section
!= 0);
2733 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
2735 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2736 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2737 codes
= (bfd_reloc_code_real_type
**) hppa_gen_reloc_type (stdoutput
,
2739 hppa_fixp
->fx_r_format
,
2740 hppa_fixp
->fx_r_field
,
2741 fixp
->fx_subsy
!= NULL
,
2742 symbol_get_bfdsym (fixp
->fx_addsy
));
2747 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
2750 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
2751 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
2752 for (i
= 0; i
< n_relocs
; i
++)
2753 relocs
[i
] = &reloc
[i
];
2755 relocs
[n_relocs
] = NULL
;
2758 switch (fixp
->fx_r_type
)
2761 assert (n_relocs
== 1);
2765 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2766 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2767 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2768 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2769 reloc
->addend
= 0; /* default */
2771 assert (reloc
->howto
&& code
== reloc
->howto
->type
);
2773 /* Now, do any processing that is dependent on the relocation type. */
2776 case R_PARISC_DLTREL21L
:
2777 case R_PARISC_DLTREL14R
:
2778 case R_PARISC_DLTREL14F
:
2779 case R_PARISC_PLABEL32
:
2780 case R_PARISC_PLABEL21L
:
2781 case R_PARISC_PLABEL14R
:
2782 /* For plabel relocations, the addend of the
2783 relocation should be either 0 (no static link) or 2
2784 (static link required).
2786 FIXME: We always assume no static link!
2788 We also slam a zero addend into the DLT relative relocs;
2789 it doesn't make a lot of sense to use any addend since
2790 it gets you a different (eg unknown) DLT entry. */
2794 case R_PARISC_PCREL21L
:
2795 case R_PARISC_PCREL17R
:
2796 case R_PARISC_PCREL17F
:
2797 case R_PARISC_PCREL17C
:
2798 case R_PARISC_PCREL14R
:
2799 case R_PARISC_PCREL14F
:
2800 /* The constant is stored in the instruction. */
2801 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
2804 reloc
->addend
= fixp
->fx_offset
;
2811 /* Walk over reach relocation returned by the BFD backend. */
2812 for (i
= 0; i
< n_relocs
; i
++)
2816 relocs
[i
]->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
2817 relocs
[i
]->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2818 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2823 /* The only time we ever use a R_COMP2 fixup is for the difference
2824 of two symbols. With that in mind we fill in all four
2825 relocs now and break out of the loop. */
2827 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &bfd_abs_symbol
;
2828 relocs
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[0]);
2829 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2830 relocs
[0]->addend
= 0;
2831 relocs
[1]->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
2832 relocs
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[1]);
2833 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2834 relocs
[1]->addend
= 0;
2835 relocs
[2]->sym_ptr_ptr
= &fixp
->fx_subsy
->bsym
;
2836 relocs
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[2]);
2837 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2838 relocs
[2]->addend
= 0;
2839 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &bfd_abs_symbol
;
2840 relocs
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[3]);
2841 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2842 relocs
[3]->addend
= 0;
2843 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &bfd_abs_symbol
;
2844 relocs
[4]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[4]);
2845 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2846 relocs
[4]->addend
= 0;
2850 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
2856 /* For plabel relocations, the addend of the
2857 relocation should be either 0 (no static link) or 2
2858 (static link required).
2860 FIXME: We always assume no static link!
2862 We also slam a zero addend into the DLT relative relocs;
2863 it doesn't make a lot of sense to use any addend since
2864 it gets you a different (eg unknown) DLT entry. */
2865 relocs
[i
]->addend
= 0;
2880 /* There is no symbol or addend associated with these fixups. */
2881 relocs
[i
]->sym_ptr_ptr
= &dummy_symbol
->bsym
;
2882 relocs
[i
]->addend
= 0;
2888 /* There is no symbol associated with these fixups. */
2889 relocs
[i
]->sym_ptr_ptr
= &dummy_symbol
->bsym
;
2890 relocs
[i
]->addend
= fixp
->fx_offset
;
2894 relocs
[i
]->addend
= fixp
->fx_offset
;
2904 /* Process any machine dependent frag types. */
2907 md_convert_frag (abfd
, sec
, fragP
)
2909 register asection
*sec
;
2910 register fragS
*fragP
;
2912 unsigned int address
;
2914 if (fragP
->fr_type
== rs_machine_dependent
)
2916 switch ((int) fragP
->fr_subtype
)
2919 fragP
->fr_type
= rs_fill
;
2920 know (fragP
->fr_var
== 1);
2921 know (fragP
->fr_next
);
2922 address
= fragP
->fr_address
+ fragP
->fr_fix
;
2923 if (address
% fragP
->fr_offset
)
2926 fragP
->fr_next
->fr_address
2931 fragP
->fr_offset
= 0;
2937 /* Round up a section size to the appropriate boundary. */
2940 md_section_align (segment
, size
)
2944 int align
= bfd_get_section_alignment (stdoutput
, segment
);
2945 int align2
= (1 << align
) - 1;
2947 return (size
+ align2
) & ~align2
;
2950 /* Return the approximate size of a frag before relaxation has occurred. */
2952 md_estimate_size_before_relax (fragP
, segment
)
2953 register fragS
*fragP
;
2960 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
2966 CONST
char *md_shortopts
= "";
2967 struct option md_longopts
[] = {
2968 {NULL
, no_argument
, NULL
, 0}
2970 size_t md_longopts_size
= sizeof(md_longopts
);
2973 md_parse_option (c
, arg
)
2981 md_show_usage (stream
)
2986 /* We have no need to default values of symbols. */
2989 md_undefined_symbol (name
)
2995 /* Apply a fixup to an instruction. */
2998 md_apply_fix (fixP
, valp
)
3002 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
3003 struct hppa_fix_struct
*hppa_fixP
;
3004 long new_val
, result
= 0;
3005 unsigned int w1
, w2
, w
, resulti
;
3007 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
3008 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
3009 never be "applied" (they are just markers). Likewise for
3010 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
3012 if (fixP
->fx_r_type
== R_HPPA_ENTRY
3013 || fixP
->fx_r_type
== R_HPPA_EXIT
3014 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
3015 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
3016 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
3019 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
3020 fixups are considered not adjustable, which in turn causes
3021 adjust_reloc_syms to not set fx_offset. Ugh. */
3022 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
3024 fixP
->fx_offset
= *valp
;
3029 /* There should have been an HPPA specific fixup associated
3030 with the GAS fixup. */
3033 unsigned long buf_wd
= bfd_get_32 (stdoutput
, buf
);
3034 unsigned char fmt
= bfd_hppa_insn2fmt (buf_wd
);
3036 /* If there is a symbol associated with this fixup, then it's something
3037 which will need a SOM relocation (except for some PC-relative relocs).
3038 In such cases we should treat the "val" or "addend" as zero since it
3039 will be added in as needed from fx_offset in tc_gen_reloc. */
3040 if ((fixP
->fx_addsy
!= NULL
3041 || fixP
->fx_r_type
== R_HPPA_NONE
)
3046 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3048 /* These field selectors imply that we do not want an addend. */
3049 else if (hppa_fixP
->fx_r_field
== e_psel
3050 || hppa_fixP
->fx_r_field
== e_rpsel
3051 || hppa_fixP
->fx_r_field
== e_lpsel
3052 || hppa_fixP
->fx_r_field
== e_tsel
3053 || hppa_fixP
->fx_r_field
== e_rtsel
3054 || hppa_fixP
->fx_r_field
== e_ltsel
)
3055 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3056 /* This is truely disgusting. The machine independent code blindly
3057 adds in the value of the symbol being relocated against. Damn! */
3059 && fixP
->fx_addsy
!= NULL
3060 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
3061 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
3062 0, hppa_fixP
->fx_r_field
);
3065 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3067 /* Handle pc-relative exceptions from above. */
3068 #define arg_reloc_stub_needed(CALLER, CALLEE) \
3069 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
3070 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
3073 && !arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
3074 symbol_get_bfdsym (fixP
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
3075 hppa_fixP
->fx_arg_reloc
)
3076 && (((int)(*valp
) > -262144 && (int)(*valp
) < 262143) && fmt
!= 22)
3077 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
3079 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
3081 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3082 #undef arg_reloc_stub_needed
3086 /* Handle all opcodes with the 'j' operand type. */
3088 CHECK_FIELD (new_val
, 8191, -8192, 0);
3090 /* Mask off 14 bits to be changed. */
3091 bfd_put_32 (stdoutput
,
3092 bfd_get_32 (stdoutput
, buf
) & 0xffffc000,
3094 low_sign_unext (new_val
, 14, &resulti
);
3098 /* Handle all opcodes with the 'k' operand type. */
3100 CHECK_FIELD (new_val
, 2097152, 0, 0);
3102 /* Mask off 21 bits to be changed. */
3103 bfd_put_32 (stdoutput
,
3104 bfd_get_32 (stdoutput
, buf
) & 0xffe00000,
3106 dis_assemble_21 (new_val
, &resulti
);
3110 /* Handle all the opcodes with the 'i' operand type. */
3112 CHECK_FIELD (new_val
, 1023, -1023, 0);
3114 /* Mask off 11 bits to be changed. */
3115 bfd_put_32 (stdoutput
,
3116 bfd_get_32 (stdoutput
, buf
) & 0xffff800,
3118 low_sign_unext (new_val
, 11, &resulti
);
3122 /* Handle all the opcodes with the 'w' operand type. */
3124 CHECK_FIELD (new_val
, 8199, -8184, 0);
3126 /* Mask off 11 bits to be changed. */
3127 sign_unext ((new_val
- 8) >> 2, 12, &resulti
);
3128 bfd_put_32 (stdoutput
,
3129 bfd_get_32 (stdoutput
, buf
) & 0xffffe002,
3132 dis_assemble_12 (resulti
, &w1
, &w
);
3133 result
= ((w1
<< 2) | w
);
3136 /* Handle some of the opcodes with the 'W' operand type. */
3139 int distance
= *valp
;
3141 CHECK_FIELD (new_val
, 262143, -262144, 0);
3143 /* If this is an absolute branch (ie no link) with an out of
3144 range target, then we want to complain. */
3145 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
3146 && (distance
> 262143 || distance
< -262144)
3147 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
3148 CHECK_FIELD (distance
, 262143, -262144, 0);
3150 /* Mask off 17 bits to be changed. */
3151 bfd_put_32 (stdoutput
,
3152 bfd_get_32 (stdoutput
, buf
) & 0xffe0e002,
3154 sign_unext ((new_val
- 8) >> 2, 17, &resulti
);
3155 dis_assemble_17 (resulti
, &w1
, &w2
, &w
);
3156 result
= ((w2
<< 2) | (w1
<< 16) | w
);
3162 bfd_put_32 (stdoutput
, new_val
, buf
);
3166 as_bad (_("Unknown relocation encountered in md_apply_fix."));
3170 /* Insert the relocation. */
3171 bfd_put_32 (stdoutput
, bfd_get_32 (stdoutput
, buf
) | result
, buf
);
3176 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
3177 (unsigned int) fixP
, fixP
->fx_r_type
);
3182 /* Exactly what point is a PC-relative offset relative TO?
3183 On the PA, they're relative to the address of the offset. */
3186 md_pcrel_from (fixP
)
3189 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
3192 /* Return nonzero if the input line pointer is at the end of
3196 is_end_of_statement ()
3198 return ((*input_line_pointer
== '\n')
3199 || (*input_line_pointer
== ';')
3200 || (*input_line_pointer
== '!'));
3203 /* Read a number from S. The number might come in one of many forms,
3204 the most common will be a hex or decimal constant, but it could be
3205 a pre-defined register (Yuk!), or an absolute symbol.
3207 Return a number or -1 for failure.
3209 When parsing PA-89 FP register numbers RESULT will be
3210 the address of a structure to return information about
3211 L/R half of FP registers, store results there as appropriate.
3213 pa_parse_number can not handle negative constants and will fail
3214 horribly if it is passed such a constant. */
3217 pa_parse_number (s
, result
)
3219 struct pa_11_fp_reg_struct
*result
;
3228 /* Skip whitespace before the number. */
3229 while (*p
== ' ' || *p
== '\t')
3232 /* Store info in RESULT if requested by caller. */
3235 result
->number_part
= -1;
3236 result
->l_r_select
= -1;
3242 /* Looks like a number. */
3245 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
3247 /* The number is specified in hex. */
3249 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
3250 || ((*p
>= 'A') && (*p
<= 'F')))
3253 num
= num
* 16 + *p
- '0';
3254 else if (*p
>= 'a' && *p
<= 'f')
3255 num
= num
* 16 + *p
- 'a' + 10;
3257 num
= num
* 16 + *p
- 'A' + 10;
3263 /* The number is specified in decimal. */
3264 while (isdigit (*p
))
3266 num
= num
* 10 + *p
- '0';
3271 /* Store info in RESULT if requested by the caller. */
3274 result
->number_part
= num
;
3276 if (IS_R_SELECT (p
))
3278 result
->l_r_select
= 1;
3281 else if (IS_L_SELECT (p
))
3283 result
->l_r_select
= 0;
3287 result
->l_r_select
= 0;
3292 /* The number might be a predefined register. */
3297 /* Tege hack: Special case for general registers as the general
3298 code makes a binary search with case translation, and is VERY
3303 if (*p
== 'e' && *(p
+ 1) == 't'
3304 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
3307 num
= *p
- '0' + 28;
3315 else if (!isdigit (*p
))
3318 as_bad (_("Undefined register: '%s'."), name
);
3324 num
= num
* 10 + *p
++ - '0';
3325 while (isdigit (*p
));
3330 /* Do a normal register search. */
3331 while (is_part_of_name (c
))
3337 status
= reg_name_search (name
);
3343 as_bad (_("Undefined register: '%s'."), name
);
3349 /* Store info in RESULT if requested by caller. */
3352 result
->number_part
= num
;
3353 if (IS_R_SELECT (p
- 1))
3354 result
->l_r_select
= 1;
3355 else if (IS_L_SELECT (p
- 1))
3356 result
->l_r_select
= 0;
3358 result
->l_r_select
= 0;
3363 /* And finally, it could be a symbol in the absolute section which
3364 is effectively a constant. */
3368 while (is_part_of_name (c
))
3374 if ((sym
= symbol_find (name
)) != NULL
)
3376 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
3377 num
= S_GET_VALUE (sym
);
3381 as_bad (_("Non-absolute symbol: '%s'."), name
);
3387 /* There is where we'd come for an undefined symbol
3388 or for an empty string. For an empty string we
3389 will return zero. That's a concession made for
3390 compatability with the braindamaged HP assemblers. */
3396 as_bad (_("Undefined absolute constant: '%s'."), name
);
3402 /* Store info in RESULT if requested by caller. */
3405 result
->number_part
= num
;
3406 if (IS_R_SELECT (p
- 1))
3407 result
->l_r_select
= 1;
3408 else if (IS_L_SELECT (p
- 1))
3409 result
->l_r_select
= 0;
3411 result
->l_r_select
= 0;
3419 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
3421 /* Given NAME, find the register number associated with that name, return
3422 the integer value associated with the given name or -1 on failure. */
3425 reg_name_search (name
)
3428 int middle
, low
, high
;
3432 high
= REG_NAME_CNT
- 1;
3436 middle
= (low
+ high
) / 2;
3437 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
3443 return pre_defined_registers
[middle
].value
;
3445 while (low
<= high
);
3451 /* Return nonzero if the given INSN and L/R information will require
3452 a new PA-1.1 opcode. */
3455 need_pa11_opcode (insn
, result
)
3457 struct pa_11_fp_reg_struct
*result
;
3459 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
3461 /* If this instruction is specific to a particular architecture,
3462 then set a new architecture. */
3463 if (bfd_get_mach (stdoutput
) < pa11
)
3465 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
3466 as_warn (_("could not update architecture and machine"));
3474 /* Parse a condition for a fcmp instruction. Return the numerical
3475 code associated with the condition. */
3478 pa_parse_fp_cmp_cond (s
)
3485 for (i
= 0; i
< 32; i
++)
3487 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
3488 strlen (fp_cond_map
[i
].string
)) == 0)
3490 cond
= fp_cond_map
[i
].cond
;
3491 *s
+= strlen (fp_cond_map
[i
].string
);
3492 /* If not a complete match, back up the input string and
3494 if (**s
!= ' ' && **s
!= '\t')
3496 *s
-= strlen (fp_cond_map
[i
].string
);
3499 while (**s
== ' ' || **s
== '\t')
3505 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
3507 /* Advance over the bogus completer. */
3508 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3515 /* Parse an FP operand format completer returning the completer
3518 static fp_operand_format
3519 pa_parse_fp_format (s
)
3528 if (strncasecmp (*s
, "sgl", 3) == 0)
3533 else if (strncasecmp (*s
, "dbl", 3) == 0)
3538 else if (strncasecmp (*s
, "quad", 4) == 0)
3545 format
= ILLEGAL_FMT
;
3546 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
3553 /* Convert from a selector string into a selector type. */
3556 pa_chk_field_selector (str
)
3559 int middle
, low
, high
;
3563 /* Read past any whitespace. */
3564 /* FIXME: should we read past newlines and formfeeds??? */
3565 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
3568 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
3569 name
[0] = tolower ((*str
)[0]),
3571 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
3572 name
[0] = tolower ((*str
)[0]),
3573 name
[1] = tolower ((*str
)[1]),
3576 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
3577 name
[0] = tolower ((*str
)[0]),
3578 name
[1] = tolower ((*str
)[1]),
3579 name
[2] = tolower ((*str
)[2]),
3586 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
3590 middle
= (low
+ high
) / 2;
3591 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
3598 *str
+= strlen (name
) + 1;
3600 if (selector_table
[middle
].field_selector
== e_nsel
)
3603 return selector_table
[middle
].field_selector
;
3606 while (low
<= high
);
3611 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
3614 get_expression (str
)
3620 save_in
= input_line_pointer
;
3621 input_line_pointer
= str
;
3622 seg
= expression (&the_insn
.exp
);
3623 if (!(seg
== absolute_section
3624 || seg
== undefined_section
3625 || SEG_NORMAL (seg
)))
3627 as_warn (_("Bad segment in expression."));
3628 expr_end
= input_line_pointer
;
3629 input_line_pointer
= save_in
;
3632 expr_end
= input_line_pointer
;
3633 input_line_pointer
= save_in
;
3637 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
3639 pa_get_absolute_expression (insn
, strp
)
3645 insn
->field_selector
= pa_chk_field_selector (strp
);
3646 save_in
= input_line_pointer
;
3647 input_line_pointer
= *strp
;
3648 expression (&insn
->exp
);
3649 /* This is not perfect, but is a huge improvement over doing nothing.
3651 The PA assembly syntax is ambigious in a variety of ways. Consider
3652 this string "4 %r5" Is that the number 4 followed by the register
3653 r5, or is that 4 MOD 5?
3655 If we get a modulo expresion When looking for an absolute, we try
3656 again cutting off the input string at the first whitespace character. */
3657 if (insn
->exp
.X_op
== O_modulus
)
3662 input_line_pointer
= *strp
;
3664 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
3670 retval
= pa_get_absolute_expression (insn
, strp
);
3672 input_line_pointer
= save_in
;
3674 return evaluate_absolute (insn
);
3676 if (insn
->exp
.X_op
!= O_constant
)
3678 as_bad (_("Bad segment (should be absolute)."));
3679 expr_end
= input_line_pointer
;
3680 input_line_pointer
= save_in
;
3683 expr_end
= input_line_pointer
;
3684 input_line_pointer
= save_in
;
3685 return evaluate_absolute (insn
);
3688 /* Evaluate an absolute expression EXP which may be modified by
3689 the selector FIELD_SELECTOR. Return the value of the expression. */
3691 evaluate_absolute (insn
)
3696 int field_selector
= insn
->field_selector
;
3699 value
= exp
.X_add_number
;
3701 switch (field_selector
)
3707 /* If bit 21 is on then add 0x800 and arithmetic shift right 11 bits. */
3709 if (value
& 0x00000400)
3711 value
= (value
& 0xfffff800) >> 11;
3714 /* Sign extend from bit 21. */
3716 if (value
& 0x00000400)
3717 value
|= 0xfffff800;
3722 /* Arithmetic shift right 11 bits. */
3724 value
= (value
& 0xfffff800) >> 11;
3727 /* Set bits 0-20 to zero. */
3729 value
= value
& 0x7ff;
3732 /* Add 0x800 and arithmetic shift right 11 bits. */
3735 value
= (value
& 0xfffff800) >> 11;
3738 /* Set bitgs 0-21 to one. */
3740 value
|= 0xfffff800;
3743 #define RSEL_ROUND(c) (((c) + 0x1000) & ~0x1fff)
3745 value
= (RSEL_ROUND (value
) & 0x7ff) + (value
- RSEL_ROUND (value
));
3749 value
= (RSEL_ROUND (value
) >> 11) & 0x1fffff;
3754 BAD_CASE (field_selector
);
3760 /* Given an argument location specification return the associated
3761 argument location number. */
3764 pa_build_arg_reloc (type_name
)
3768 if (strncasecmp (type_name
, "no", 2) == 0)
3770 if (strncasecmp (type_name
, "gr", 2) == 0)
3772 else if (strncasecmp (type_name
, "fr", 2) == 0)
3774 else if (strncasecmp (type_name
, "fu", 2) == 0)
3777 as_bad (_("Invalid argument location: %s\n"), type_name
);
3782 /* Encode and return an argument relocation specification for
3783 the given register in the location specified by arg_reloc. */
3786 pa_align_arg_reloc (reg
, arg_reloc
)
3788 unsigned int arg_reloc
;
3790 unsigned int new_reloc
;
3792 new_reloc
= arg_reloc
;
3808 as_bad (_("Invalid argument description: %d"), reg
);
3814 /* Parse a PA nullification completer (,n). Return nonzero if the
3815 completer was found; return zero if no completer was found. */
3827 if (strncasecmp (*s
, "n", 1) == 0)
3831 as_bad (_("Invalid Nullification: (%c)"), **s
);
3840 /* Parse a non-negated compare/subtract completer returning the
3841 number (for encoding in instrutions) of the given completer.
3843 ISBRANCH specifies whether or not this is parsing a condition
3844 completer for a branch (vs a nullification completer for a
3845 computational instruction. */
3848 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
3853 char *name
= *s
+ 1;
3862 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3868 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 (strcmp (name
, "<<=") == 0)
3888 else if (strcasecmp (name
, "sv") == 0)
3892 else if (strcasecmp (name
, "od") == 0)
3896 /* If we have something like addb,n then there is no condition
3898 else if (strcasecmp (name
, "n") == 0 && isbranch
)
3910 /* Reset pointers if this was really a ,n for a branch instruction. */
3918 /* Parse a negated compare/subtract completer returning the
3919 number (for encoding in instrutions) of the given completer.
3921 ISBRANCH specifies whether or not this is parsing a condition
3922 completer for a branch (vs a nullification completer for a
3923 computational instruction. */
3926 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
3931 char *name
= *s
+ 1;
3940 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3946 if (strcasecmp (name
, "tr") == 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 (strcmp (name
, ">>") == 0)
3970 else if (strcasecmp (name
, "nsv") == 0)
3974 else if (strcasecmp (name
, "ev") == 0)
3978 /* If we have something like addb,n then there is no condition
3980 else if (strcasecmp (name
, "n") == 0 && isbranch
)
3992 /* Reset pointers if this was really a ,n for a branch instruction. */
4001 /* Parse a non-negated addition completer returning the number
4002 (for encoding in instrutions) of the given completer.
4004 ISBRANCH specifies whether or not this is parsing a condition
4005 completer for a branch (vs a nullification completer for a
4006 computational instruction. */
4009 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
4014 char *name
= *s
+ 1;
4022 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4026 if (strcmp (name
, "=") == 0)
4030 else if (strcmp (name
, "<") == 0)
4034 else if (strcmp (name
, "<=") == 0)
4038 else if (strcasecmp (name
, "nuv") == 0)
4042 else if (strcasecmp (name
, "znv") == 0)
4046 else if (strcasecmp (name
, "sv") == 0)
4050 else if (strcasecmp (name
, "od") == 0)
4054 /* If we have something like addb,n then there is no condition
4056 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4067 /* Reset pointers if this was really a ,n for a branch instruction. */
4068 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4074 /* Parse a negated addition completer returning the number
4075 (for encoding in instrutions) of the given completer.
4077 ISBRANCH specifies whether or not this is parsing a condition
4078 completer for a branch (vs a nullification completer for a
4079 computational instruction). */
4082 pa_parse_neg_add_cmpltr (s
, isbranch
)
4087 char *name
= *s
+ 1;
4095 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4099 if (strcasecmp (name
, "tr") == 0)
4103 else if (strcmp (name
, "<>") == 0)
4107 else if (strcmp (name
, ">=") == 0)
4111 else if (strcmp (name
, ">") == 0)
4115 else if (strcasecmp (name
, "uv") == 0)
4119 else if (strcasecmp (name
, "vnz") == 0)
4123 else if (strcasecmp (name
, "nsv") == 0)
4127 else if (strcasecmp (name
, "ev") == 0)
4131 /* If we have something like addb,n then there is no condition
4133 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4144 /* Reset pointers if this was really a ,n for a branch instruction. */
4145 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4151 /* Handle an alignment directive. Special so that we can update the
4152 alignment of the subspace if necessary. */
4156 /* We must have a valid space and subspace. */
4157 pa_check_current_space_and_subspace ();
4159 /* Let the generic gas code do most of the work. */
4160 s_align_bytes (bytes
);
4162 /* If bytes is a power of 2, then update the current subspace's
4163 alignment if necessary. */
4164 if (log2 (bytes
) != -1)
4165 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
4168 /* Handle a .BLOCK type pseudo-op. */
4176 unsigned int temp_size
;
4179 /* We must have a valid space and subspace. */
4180 pa_check_current_space_and_subspace ();
4182 temp_size
= get_absolute_expression ();
4184 /* Always fill with zeros, that's what the HP assembler does. */
4187 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
4188 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
4189 memset (p
, 0, temp_size
);
4191 /* Convert 2 bytes at a time. */
4193 for (i
= 0; i
< temp_size
; i
+= 2)
4195 md_number_to_chars (p
+ i
,
4197 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
4200 pa_undefine_label ();
4201 demand_empty_rest_of_line ();
4204 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
4212 /* The BRTAB relocations are only availble in SOM (to denote
4213 the beginning and end of branch tables). */
4214 char *where
= frag_more (0);
4216 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4217 NULL
, (offsetT
) 0, NULL
,
4218 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
4219 e_fsel
, 0, 0, NULL
);
4222 demand_empty_rest_of_line ();
4225 /* Handle a .begin_try and .end_try pseudo-op. */
4233 char *where
= frag_more (0);
4238 /* The TRY relocations are only availble in SOM (to denote
4239 the beginning and end of exception handling regions). */
4241 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4242 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
4243 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
4244 e_fsel
, 0, 0, NULL
);
4247 demand_empty_rest_of_line ();
4250 /* Handle a .CALL pseudo-op. This involves storing away information
4251 about where arguments are to be found so the linker can detect
4252 (and correct) argument location mismatches between caller and callee. */
4258 /* We must have a valid space and subspace. */
4259 pa_check_current_space_and_subspace ();
4261 pa_call_args (&last_call_desc
);
4262 demand_empty_rest_of_line ();
4265 /* Do the dirty work of building a call descriptor which describes
4266 where the caller placed arguments to a function call. */
4269 pa_call_args (call_desc
)
4270 struct call_desc
*call_desc
;
4273 unsigned int temp
, arg_reloc
;
4275 while (!is_end_of_statement ())
4277 name
= input_line_pointer
;
4278 c
= get_symbol_end ();
4279 /* Process a source argument. */
4280 if ((strncasecmp (name
, "argw", 4) == 0))
4282 temp
= atoi (name
+ 4);
4283 p
= input_line_pointer
;
4285 input_line_pointer
++;
4286 name
= input_line_pointer
;
4287 c
= get_symbol_end ();
4288 arg_reloc
= pa_build_arg_reloc (name
);
4289 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
4291 /* Process a return value. */
4292 else if ((strncasecmp (name
, "rtnval", 6) == 0))
4294 p
= input_line_pointer
;
4296 input_line_pointer
++;
4297 name
= input_line_pointer
;
4298 c
= get_symbol_end ();
4299 arg_reloc
= pa_build_arg_reloc (name
);
4300 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
4304 as_bad (_("Invalid .CALL argument: %s"), name
);
4306 p
= input_line_pointer
;
4308 if (!is_end_of_statement ())
4309 input_line_pointer
++;
4313 /* Return TRUE if FRAG1 and FRAG2 are the same. */
4316 is_same_frag (frag1
, frag2
)
4323 else if (frag2
== NULL
)
4325 else if (frag1
== frag2
)
4327 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
4328 return (is_same_frag (frag1
, frag2
->fr_next
));
4334 /* Build an entry in the UNWIND subspace from the given function
4335 attributes in CALL_INFO. This is not needed for SOM as using
4336 R_ENTRY and R_EXIT relocations allow the linker to handle building
4337 of the unwind spaces. */
4340 pa_build_unwind_subspace (call_info
)
4341 struct call_info
*call_info
;
4344 asection
*seg
, *save_seg
;
4345 subsegT subseg
, save_subseg
;
4349 /* Get into the right seg/subseg. This may involve creating
4350 the seg the first time through. Make sure to have the
4351 old seg/subseg so that we can reset things when we are done. */
4352 subseg
= SUBSEG_UNWIND
;
4353 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
4354 if (seg
== ASEC_NULL
)
4356 seg
= bfd_make_section_old_way (stdoutput
, UNWIND_SECTION_NAME
);
4357 bfd_set_section_flags (stdoutput
, seg
,
4358 SEC_READONLY
| SEC_HAS_CONTENTS
4359 | SEC_LOAD
| SEC_RELOC
);
4363 save_subseg
= now_subseg
;
4364 subseg_set (seg
, subseg
);
4367 /* Get some space to hold relocation information for the unwind
4370 md_number_to_chars (p
, 0, 4);
4372 /* Relocation info. for start offset of the function. */
4373 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4374 call_info
->start_symbol
, (offsetT
) 0,
4375 (expressionS
*) NULL
, 0, R_PARISC_DIR32
, e_fsel
, 32, 0, NULL
);
4378 md_number_to_chars (p
, 0, 4);
4380 /* Relocation info. for end offset of the function.
4382 Because we allow reductions of 32bit relocations for ELF, this will be
4383 reduced to section_sym + offset which avoids putting the temporary
4384 symbol into the symbol table. It (should) end up giving the same
4385 value as call_info->start_symbol + function size once the linker is
4386 finished with its work. */
4388 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4389 call_info
->end_symbol
, (offsetT
) 0,
4390 (expressionS
*) NULL
, 0, R_PARISC_DIR32
, e_fsel
, 32, 0, NULL
);
4393 unwind
= (char *) &call_info
->ci_unwind
;
4394 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
4398 FRAG_APPEND_1_CHAR (c
);
4402 /* Return back to the original segment/subsegment. */
4403 subseg_set (save_seg
, save_subseg
);
4407 /* Process a .CALLINFO pseudo-op. This information is used later
4408 to build unwind descriptors and maybe one day to support
4409 .ENTER and .LEAVE. */
4412 pa_callinfo (unused
)
4418 /* We must have a valid space and subspace. */
4419 pa_check_current_space_and_subspace ();
4421 /* .CALLINFO must appear within a procedure definition. */
4422 if (!within_procedure
)
4423 as_bad (_(".callinfo is not within a procedure definition"));
4425 /* Mark the fact that we found the .CALLINFO for the
4426 current procedure. */
4427 callinfo_found
= TRUE
;
4429 /* Iterate over the .CALLINFO arguments. */
4430 while (!is_end_of_statement ())
4432 name
= input_line_pointer
;
4433 c
= get_symbol_end ();
4434 /* Frame size specification. */
4435 if ((strncasecmp (name
, "frame", 5) == 0))
4437 p
= input_line_pointer
;
4439 input_line_pointer
++;
4440 temp
= get_absolute_expression ();
4441 if ((temp
& 0x3) != 0)
4443 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
4447 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
4448 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
4451 /* Entry register (GR, GR and SR) specifications. */
4452 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
4454 p
= input_line_pointer
;
4456 input_line_pointer
++;
4457 temp
= get_absolute_expression ();
4458 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
4459 even though %r19 is caller saved. I think this is a bug in
4460 the HP assembler, and we are not going to emulate it. */
4461 if (temp
< 3 || temp
> 18)
4462 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
4463 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
4465 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
4467 p
= input_line_pointer
;
4469 input_line_pointer
++;
4470 temp
= get_absolute_expression ();
4471 /* Similarly the HP assembler takes 31 as the high bound even
4472 though %fr21 is the last callee saved floating point register. */
4473 if (temp
< 12 || temp
> 21)
4474 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
4475 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
4477 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
4479 p
= input_line_pointer
;
4481 input_line_pointer
++;
4482 temp
= get_absolute_expression ();
4484 as_bad (_("Value for ENTRY_SR must be 3\n"));
4486 /* Note whether or not this function performs any calls. */
4487 else if ((strncasecmp (name
, "calls", 5) == 0) ||
4488 (strncasecmp (name
, "caller", 6) == 0))
4490 p
= input_line_pointer
;
4493 else if ((strncasecmp (name
, "no_calls", 8) == 0))
4495 p
= input_line_pointer
;
4498 /* Should RP be saved into the stack. */
4499 else if ((strncasecmp (name
, "save_rp", 7) == 0))
4501 p
= input_line_pointer
;
4503 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
4505 /* Likewise for SP. */
4506 else if ((strncasecmp (name
, "save_sp", 7) == 0))
4508 p
= input_line_pointer
;
4510 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
4512 /* Is this an unwindable procedure. If so mark it so
4513 in the unwind descriptor. */
4514 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
4516 p
= input_line_pointer
;
4518 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
4520 /* Is this an interrupt routine. If so mark it in the
4521 unwind descriptor. */
4522 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
4524 p
= input_line_pointer
;
4526 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
4528 /* Is this a millicode routine. "millicode" isn't in my
4529 assembler manual, but my copy is old. The HP assembler
4530 accepts it, and there's a place in the unwind descriptor
4531 to drop the information, so we'll accept it too. */
4532 else if ((strncasecmp (name
, "millicode", 9) == 0))
4534 p
= input_line_pointer
;
4536 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
4540 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
4541 *input_line_pointer
= c
;
4543 if (!is_end_of_statement ())
4544 input_line_pointer
++;
4547 demand_empty_rest_of_line ();
4550 /* Switch into the code subspace. */
4556 current_space
= is_defined_space ("$TEXT$");
4558 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
4560 pa_undefine_label ();
4563 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
4564 the .comm pseudo-op has the following symtax:
4566 <label> .comm <length>
4568 where <label> is optional and is a symbol whose address will be the start of
4569 a block of memory <length> bytes long. <length> must be an absolute
4570 expression. <length> bytes will be allocated in the current space
4573 Also note the label may not even be on the same line as the .comm.
4575 This difference in syntax means the colon function will be called
4576 on the symbol before we arrive in pa_comm. colon will set a number
4577 of attributes of the symbol that need to be fixed here. In particular
4578 the value, section pointer, fragment pointer, flags, etc. What
4581 This also makes error detection all but impossible. */
4589 label_symbol_struct
*label_symbol
= pa_get_label ();
4592 symbol
= label_symbol
->lss_label
;
4597 size
= get_absolute_expression ();
4601 S_SET_VALUE (symbol
, size
);
4602 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
4603 S_SET_EXTERNAL (symbol
);
4605 /* colon() has already set the frag to the current location in the
4606 current subspace; we need to reset the fragment to the zero address
4607 fragment. We also need to reset the segment pointer. */
4608 symbol_set_frag (symbol
, &zero_address_frag
);
4610 demand_empty_rest_of_line ();
4613 /* Process a .END pseudo-op. */
4619 demand_empty_rest_of_line ();
4622 /* Process a .ENTER pseudo-op. This is not supported. */
4627 /* We must have a valid space and subspace. */
4628 pa_check_current_space_and_subspace ();
4630 as_bad (_("The .ENTER pseudo-op is not supported"));
4631 demand_empty_rest_of_line ();
4634 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
4640 /* We must have a valid space and subspace. */
4641 pa_check_current_space_and_subspace ();
4643 if (!within_procedure
)
4644 as_bad (_("Misplaced .entry. Ignored."));
4647 if (!callinfo_found
)
4648 as_bad (_("Missing .callinfo."));
4650 demand_empty_rest_of_line ();
4651 within_entry_exit
= TRUE
;
4654 /* SOM defers building of unwind descriptors until the link phase.
4655 The assembler is responsible for creating an R_ENTRY relocation
4656 to mark the beginning of a region and hold the unwind bits, and
4657 for creating an R_EXIT relocation to mark the end of the region.
4659 FIXME. ELF should be using the same conventions! The problem
4660 is an unwind requires too much relocation space. Hmmm. Maybe
4661 if we split the unwind bits up between the relocations which
4662 denote the entry and exit points. */
4663 if (last_call_info
->start_symbol
!= NULL
)
4665 char *where
= frag_more (0);
4667 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4668 NULL
, (offsetT
) 0, NULL
,
4669 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
4670 (int *) &last_call_info
->ci_unwind
.descriptor
);
4675 /* Handle a .EQU pseudo-op. */
4681 label_symbol_struct
*label_symbol
= pa_get_label ();
4686 symbol
= label_symbol
->lss_label
;
4688 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
4690 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
4691 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
4696 as_bad (_(".REG must use a label"));
4698 as_bad (_(".EQU must use a label"));
4701 pa_undefine_label ();
4702 demand_empty_rest_of_line ();
4705 /* Helper function. Does processing for the end of a function. This
4706 usually involves creating some relocations or building special
4707 symbols to mark the end of the function. */
4714 where
= frag_more (0);
4717 /* Mark the end of the function, stuff away the location of the frag
4718 for the end of the function, and finally call pa_build_unwind_subspace
4719 to add an entry in the unwind table. */
4720 hppa_elf_mark_end_of_function ();
4721 pa_build_unwind_subspace (last_call_info
);
4723 /* SOM defers building of unwind descriptors until the link phase.
4724 The assembler is responsible for creating an R_ENTRY relocation
4725 to mark the beginning of a region and hold the unwind bits, and
4726 for creating an R_EXIT relocation to mark the end of the region.
4728 FIXME. ELF should be using the same conventions! The problem
4729 is an unwind requires too much relocation space. Hmmm. Maybe
4730 if we split the unwind bits up between the relocations which
4731 denote the entry and exit points. */
4732 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4734 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
4735 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
4739 /* Process a .EXIT pseudo-op. */
4745 /* We must have a valid space and subspace. */
4746 pa_check_current_space_and_subspace ();
4748 if (!within_procedure
)
4749 as_bad (_(".EXIT must appear within a procedure"));
4752 if (!callinfo_found
)
4753 as_bad (_("Missing .callinfo"));
4756 if (!within_entry_exit
)
4757 as_bad (_("No .ENTRY for this .EXIT"));
4760 within_entry_exit
= FALSE
;
4765 demand_empty_rest_of_line ();
4768 /* Process a .EXPORT directive. This makes functions external
4769 and provides information such as argument relocation entries
4779 name
= input_line_pointer
;
4780 c
= get_symbol_end ();
4781 /* Make sure the given symbol exists. */
4782 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
4784 as_bad (_("Cannot define export symbol: %s\n"), name
);
4785 p
= input_line_pointer
;
4787 input_line_pointer
++;
4791 /* OK. Set the external bits and process argument relocations. */
4792 S_SET_EXTERNAL (symbol
);
4793 p
= input_line_pointer
;
4795 if (!is_end_of_statement ())
4797 input_line_pointer
++;
4798 pa_type_args (symbol
, 1);
4802 demand_empty_rest_of_line ();
4805 /* Helper function to process arguments to a .EXPORT pseudo-op. */
4808 pa_type_args (symbolP
, is_export
)
4813 unsigned int temp
, arg_reloc
;
4814 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
4815 obj_symbol_type
*symbol
= (obj_symbol_type
*) symbol_get_bfdsym (symbolP
);
4817 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
4820 input_line_pointer
+= 8;
4821 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4822 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
4823 type
= SYMBOL_TYPE_ABSOLUTE
;
4825 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
4827 input_line_pointer
+= 4;
4828 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
4829 instead one should be IMPORTing/EXPORTing ENTRY types.
4831 Complain if one tries to EXPORT a CODE type since that's never
4832 done. Both GCC and HP C still try to IMPORT CODE types, so
4833 silently fix them to be ENTRY types. */
4834 if (S_IS_FUNCTION (symbolP
))
4837 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
4838 S_GET_NAME (symbolP
));
4840 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4841 type
= SYMBOL_TYPE_ENTRY
;
4845 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4846 type
= SYMBOL_TYPE_CODE
;
4849 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
4851 input_line_pointer
+= 4;
4852 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4853 type
= SYMBOL_TYPE_DATA
;
4855 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
4857 input_line_pointer
+= 5;
4858 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4859 type
= SYMBOL_TYPE_ENTRY
;
4861 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
4863 input_line_pointer
+= 9;
4864 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4865 type
= SYMBOL_TYPE_MILLICODE
;
4867 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
4869 input_line_pointer
+= 6;
4870 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4871 type
= SYMBOL_TYPE_PLABEL
;
4873 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
4875 input_line_pointer
+= 8;
4876 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4877 type
= SYMBOL_TYPE_PRI_PROG
;
4879 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
4881 input_line_pointer
+= 8;
4882 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4883 type
= SYMBOL_TYPE_SEC_PROG
;
4886 /* SOM requires much more information about symbol types
4887 than BFD understands. This is how we get this information
4888 to the SOM BFD backend. */
4889 #ifdef obj_set_symbol_type
4890 obj_set_symbol_type (symbol_get_bfdsym (symbolP
), (int) type
);
4893 /* Now that the type of the exported symbol has been handled,
4894 handle any argument relocation information. */
4895 while (!is_end_of_statement ())
4897 if (*input_line_pointer
== ',')
4898 input_line_pointer
++;
4899 name
= input_line_pointer
;
4900 c
= get_symbol_end ();
4901 /* Argument sources. */
4902 if ((strncasecmp (name
, "argw", 4) == 0))
4904 p
= input_line_pointer
;
4906 input_line_pointer
++;
4907 temp
= atoi (name
+ 4);
4908 name
= input_line_pointer
;
4909 c
= get_symbol_end ();
4910 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
4911 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
4912 *input_line_pointer
= c
;
4914 /* The return value. */
4915 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
4917 p
= input_line_pointer
;
4919 input_line_pointer
++;
4920 name
= input_line_pointer
;
4921 c
= get_symbol_end ();
4922 arg_reloc
= pa_build_arg_reloc (name
);
4923 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
4924 *input_line_pointer
= c
;
4926 /* Privelege level. */
4927 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
4929 p
= input_line_pointer
;
4931 input_line_pointer
++;
4932 temp
= atoi (input_line_pointer
);
4933 symbol
->tc_data
.ap
.hppa_priv_level
= temp
;
4934 c
= get_symbol_end ();
4935 *input_line_pointer
= c
;
4939 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
4940 p
= input_line_pointer
;
4943 if (!is_end_of_statement ())
4944 input_line_pointer
++;
4948 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
4949 assembly file must either be defined in the assembly file, or
4950 explicitly IMPORTED from another. */
4959 name
= input_line_pointer
;
4960 c
= get_symbol_end ();
4962 symbol
= symbol_find (name
);
4963 /* Ugh. We might be importing a symbol defined earlier in the file,
4964 in which case all the code below will really screw things up
4965 (set the wrong segment, symbol flags & type, etc). */
4966 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
4968 symbol
= symbol_find_or_make (name
);
4969 p
= input_line_pointer
;
4972 if (!is_end_of_statement ())
4974 input_line_pointer
++;
4975 pa_type_args (symbol
, 0);
4979 /* Sigh. To be compatable with the HP assembler and to help
4980 poorly written assembly code, we assign a type based on
4981 the the current segment. Note only BSF_FUNCTION really
4982 matters, we do not need to set the full SYMBOL_TYPE_* info. */
4983 if (now_seg
== text_section
)
4984 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
4986 /* If the section is undefined, then the symbol is undefined
4987 Since this is an import, leave the section undefined. */
4988 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
4993 /* The symbol was already defined. Just eat everything up to
4994 the end of the current statement. */
4995 while (!is_end_of_statement ())
4996 input_line_pointer
++;
4999 demand_empty_rest_of_line ();
5002 /* Handle a .LABEL pseudo-op. */
5010 name
= input_line_pointer
;
5011 c
= get_symbol_end ();
5013 if (strlen (name
) > 0)
5016 p
= input_line_pointer
;
5021 as_warn (_("Missing label name on .LABEL"));
5024 if (!is_end_of_statement ())
5026 as_warn (_("extra .LABEL arguments ignored."));
5027 ignore_rest_of_line ();
5029 demand_empty_rest_of_line ();
5032 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
5038 /* We must have a valid space and subspace. */
5039 pa_check_current_space_and_subspace ();
5041 as_bad (_("The .LEAVE pseudo-op is not supported"));
5042 demand_empty_rest_of_line ();
5045 /* Handle a .LEVEL pseudo-op. */
5053 level
= input_line_pointer
;
5054 if (strncmp (level
, "1.0", 3) == 0)
5056 input_line_pointer
+= 3;
5057 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
5058 as_warn (_("could not set architecture and machine"));
5060 else if (strncmp (level
, "1.1", 3) == 0)
5062 input_line_pointer
+= 3;
5063 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
5064 as_warn (_("could not set architecture and machine"));
5066 else if (strncmp (level
, "2.0", 3) == 0)
5068 input_line_pointer
+= 3;
5069 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
5070 as_warn (_("could not set architecture and machine"));
5074 as_bad (_("Unrecognized .LEVEL argument\n"));
5075 ignore_rest_of_line ();
5077 demand_empty_rest_of_line ();
5080 /* Handle a .ORIGIN pseudo-op. */
5086 /* We must have a valid space and subspace. */
5087 pa_check_current_space_and_subspace ();
5090 pa_undefine_label ();
5093 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
5094 is for static functions. FIXME. Should share more code with .EXPORT. */
5103 name
= input_line_pointer
;
5104 c
= get_symbol_end ();
5106 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
5108 as_bad (_("Cannot define static symbol: %s\n"), name
);
5109 p
= input_line_pointer
;
5111 input_line_pointer
++;
5115 S_CLEAR_EXTERNAL (symbol
);
5116 p
= input_line_pointer
;
5118 if (!is_end_of_statement ())
5120 input_line_pointer
++;
5121 pa_type_args (symbol
, 0);
5125 demand_empty_rest_of_line ();
5128 /* Handle a .PROC pseudo-op. It is used to mark the beginning
5129 of a procedure from a syntatical point of view. */
5135 struct call_info
*call_info
;
5137 /* We must have a valid space and subspace. */
5138 pa_check_current_space_and_subspace ();
5140 if (within_procedure
)
5141 as_fatal (_("Nested procedures"));
5143 /* Reset global variables for new procedure. */
5144 callinfo_found
= FALSE
;
5145 within_procedure
= TRUE
;
5147 /* Create another call_info structure. */
5148 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
5151 as_fatal (_("Cannot allocate unwind descriptor\n"));
5153 memset (call_info
, 0, sizeof (struct call_info
));
5155 call_info
->ci_next
= NULL
;
5157 if (call_info_root
== NULL
)
5159 call_info_root
= call_info
;
5160 last_call_info
= call_info
;
5164 last_call_info
->ci_next
= call_info
;
5165 last_call_info
= call_info
;
5168 /* set up defaults on call_info structure */
5170 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
5171 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
5172 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
5174 /* If we got a .PROC pseudo-op, we know that the function is defined
5175 locally. Make sure it gets into the symbol table. */
5177 label_symbol_struct
*label_symbol
= pa_get_label ();
5181 if (label_symbol
->lss_label
)
5183 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5184 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
5187 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5190 last_call_info
->start_symbol
= NULL
;
5193 demand_empty_rest_of_line ();
5196 /* Process the syntatical end of a procedure. Make sure all the
5197 appropriate pseudo-ops were found within the procedure. */
5204 /* We must have a valid space and subspace. */
5205 pa_check_current_space_and_subspace ();
5207 /* If we are within a procedure definition, make sure we've
5208 defined a label for the procedure; handle case where the
5209 label was defined after the .PROC directive.
5211 Note there's not need to diddle with the segment or fragment
5212 for the label symbol in this case. We have already switched
5213 into the new $CODE$ subspace at this point. */
5214 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
5216 label_symbol_struct
*label_symbol
= pa_get_label ();
5220 if (label_symbol
->lss_label
)
5222 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5223 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
5226 /* Also handle allocation of a fixup to hold the unwind
5227 information when the label appears after the proc/procend. */
5228 if (within_entry_exit
)
5230 char *where
= frag_more (0);
5232 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5233 NULL
, (offsetT
) 0, NULL
,
5234 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
5235 (int *) &last_call_info
->ci_unwind
.descriptor
);
5240 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5243 as_bad (_("Missing function name for .PROC"));
5246 if (!within_procedure
)
5247 as_bad (_("misplaced .procend"));
5249 if (!callinfo_found
)
5250 as_bad (_("Missing .callinfo for this procedure"));
5252 if (within_entry_exit
)
5253 as_bad (_("Missing .EXIT for a .ENTRY"));
5256 /* ELF needs to mark the end of each function so that it can compute
5257 the size of the function (apparently its needed in the symbol table). */
5258 hppa_elf_mark_end_of_function ();
5261 within_procedure
= FALSE
;
5262 demand_empty_rest_of_line ();
5263 pa_undefine_label ();
5266 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
5267 then create a new space entry to hold the information specified
5268 by the parameters to the .SPACE directive. */
5270 static sd_chain_struct
*
5271 pa_parse_space_stmt (space_name
, create_flag
)
5275 char *name
, *ptemp
, c
;
5276 char loadable
, defined
, private, sort
;
5278 asection
*seg
= NULL
;
5279 sd_chain_struct
*space
;
5281 /* load default values */
5287 if (strcmp (space_name
, "$TEXT$") == 0)
5289 seg
= pa_def_spaces
[0].segment
;
5290 defined
= pa_def_spaces
[0].defined
;
5291 private = pa_def_spaces
[0].private;
5292 sort
= pa_def_spaces
[0].sort
;
5293 spnum
= pa_def_spaces
[0].spnum
;
5295 else if (strcmp (space_name
, "$PRIVATE$") == 0)
5297 seg
= pa_def_spaces
[1].segment
;
5298 defined
= pa_def_spaces
[1].defined
;
5299 private = pa_def_spaces
[1].private;
5300 sort
= pa_def_spaces
[1].sort
;
5301 spnum
= pa_def_spaces
[1].spnum
;
5304 if (!is_end_of_statement ())
5306 print_errors
= FALSE
;
5307 ptemp
= input_line_pointer
+ 1;
5308 /* First see if the space was specified as a number rather than
5309 as a name. According to the PA assembly manual the rest of
5310 the line should be ignored. */
5311 temp
= pa_parse_number (&ptemp
, 0);
5315 input_line_pointer
= ptemp
;
5319 while (!is_end_of_statement ())
5321 input_line_pointer
++;
5322 name
= input_line_pointer
;
5323 c
= get_symbol_end ();
5324 if ((strncasecmp (name
, "spnum", 5) == 0))
5326 *input_line_pointer
= c
;
5327 input_line_pointer
++;
5328 spnum
= get_absolute_expression ();
5330 else if ((strncasecmp (name
, "sort", 4) == 0))
5332 *input_line_pointer
= c
;
5333 input_line_pointer
++;
5334 sort
= get_absolute_expression ();
5336 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5338 *input_line_pointer
= c
;
5341 else if ((strncasecmp (name
, "notdefined", 10) == 0))
5343 *input_line_pointer
= c
;
5346 else if ((strncasecmp (name
, "private", 7) == 0))
5348 *input_line_pointer
= c
;
5353 as_bad (_("Invalid .SPACE argument"));
5354 *input_line_pointer
= c
;
5355 if (!is_end_of_statement ())
5356 input_line_pointer
++;
5360 print_errors
= TRUE
;
5363 if (create_flag
&& seg
== NULL
)
5364 seg
= subseg_new (space_name
, 0);
5366 /* If create_flag is nonzero, then create the new space with
5367 the attributes computed above. Else set the values in
5368 an already existing space -- this can only happen for
5369 the first occurence of a built-in space. */
5371 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
5372 private, sort
, seg
, 1);
5375 space
= is_defined_space (space_name
);
5376 SPACE_SPNUM (space
) = spnum
;
5377 SPACE_DEFINED (space
) = defined
& 1;
5378 SPACE_USER_DEFINED (space
) = 1;
5381 #ifdef obj_set_section_attributes
5382 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
5388 /* Handle a .SPACE pseudo-op; this switches the current space to the
5389 given space, creating the new space if necessary. */
5395 char *name
, c
, *space_name
, *save_s
;
5397 sd_chain_struct
*sd_chain
;
5399 if (within_procedure
)
5401 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
5402 ignore_rest_of_line ();
5406 /* Check for some of the predefined spaces. FIXME: most of the code
5407 below is repeated several times, can we extract the common parts
5408 and place them into a subroutine or something similar? */
5409 /* FIXME Is this (and the next IF stmt) really right?
5410 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
5411 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
5413 input_line_pointer
+= 6;
5414 sd_chain
= is_defined_space ("$TEXT$");
5415 if (sd_chain
== NULL
)
5416 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
5417 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5418 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
5420 current_space
= sd_chain
;
5421 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
5423 = pa_subsegment_to_subspace (text_section
,
5424 sd_chain
->sd_last_subseg
);
5425 demand_empty_rest_of_line ();
5428 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
5430 input_line_pointer
+= 9;
5431 sd_chain
= is_defined_space ("$PRIVATE$");
5432 if (sd_chain
== NULL
)
5433 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
5434 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5435 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
5437 current_space
= sd_chain
;
5438 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
5440 = pa_subsegment_to_subspace (data_section
,
5441 sd_chain
->sd_last_subseg
);
5442 demand_empty_rest_of_line ();
5445 if (!strncasecmp (input_line_pointer
,
5446 GDB_DEBUG_SPACE_NAME
,
5447 strlen (GDB_DEBUG_SPACE_NAME
)))
5449 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
5450 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
5451 if (sd_chain
== NULL
)
5452 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
5453 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5454 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
5456 current_space
= sd_chain
;
5459 asection
*gdb_section
5460 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
5462 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
5464 = pa_subsegment_to_subspace (gdb_section
,
5465 sd_chain
->sd_last_subseg
);
5467 demand_empty_rest_of_line ();
5471 /* It could be a space specified by number. */
5473 save_s
= input_line_pointer
;
5474 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
5476 if ((sd_chain
= pa_find_space_by_number (temp
)))
5478 current_space
= sd_chain
;
5480 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5482 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5483 sd_chain
->sd_last_subseg
);
5484 demand_empty_rest_of_line ();
5489 /* Not a number, attempt to create a new space. */
5491 input_line_pointer
= save_s
;
5492 name
= input_line_pointer
;
5493 c
= get_symbol_end ();
5494 space_name
= xmalloc (strlen (name
) + 1);
5495 strcpy (space_name
, name
);
5496 *input_line_pointer
= c
;
5498 sd_chain
= pa_parse_space_stmt (space_name
, 1);
5499 current_space
= sd_chain
;
5501 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5502 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5503 sd_chain
->sd_last_subseg
);
5504 demand_empty_rest_of_line ();
5508 /* Switch to a new space. (I think). FIXME. */
5517 sd_chain_struct
*space
;
5519 name
= input_line_pointer
;
5520 c
= get_symbol_end ();
5521 space
= is_defined_space (name
);
5525 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
5528 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
5530 *input_line_pointer
= c
;
5531 demand_empty_rest_of_line ();
5534 /* If VALUE is an exact power of two between zero and 2^31, then
5535 return log2 (VALUE). Else return -1. */
5543 while ((1 << shift
) != value
&& shift
< 32)
5552 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
5553 given subspace, creating the new subspace if necessary.
5555 FIXME. Should mirror pa_space more closely, in particular how
5556 they're broken up into subroutines. */
5559 pa_subspace (create_new
)
5562 char *name
, *ss_name
, *alias
, c
;
5563 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
5564 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
5565 sd_chain_struct
*space
;
5566 ssd_chain_struct
*ssd
;
5569 if (current_space
== NULL
)
5570 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
5572 if (within_procedure
)
5574 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
5575 ignore_rest_of_line ();
5579 name
= input_line_pointer
;
5580 c
= get_symbol_end ();
5581 ss_name
= xmalloc (strlen (name
) + 1);
5582 strcpy (ss_name
, name
);
5583 *input_line_pointer
= c
;
5585 /* Load default values. */
5598 space
= current_space
;
5602 ssd
= is_defined_subspace (ss_name
);
5603 /* Allow user to override the builtin attributes of subspaces. But
5604 only allow the attributes to be changed once! */
5605 if (ssd
&& SUBSPACE_DEFINED (ssd
))
5607 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
5608 current_subspace
= ssd
;
5609 if (!is_end_of_statement ())
5610 as_warn (_("Parameters of an existing subspace can\'t be modified"));
5611 demand_empty_rest_of_line ();
5616 /* A new subspace. Load default values if it matches one of
5617 the builtin subspaces. */
5619 while (pa_def_subspaces
[i
].name
)
5621 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
5623 loadable
= pa_def_subspaces
[i
].loadable
;
5624 common
= pa_def_subspaces
[i
].common
;
5625 dup_common
= pa_def_subspaces
[i
].dup_common
;
5626 code_only
= pa_def_subspaces
[i
].code_only
;
5627 zero
= pa_def_subspaces
[i
].zero
;
5628 space_index
= pa_def_subspaces
[i
].space_index
;
5629 alignment
= pa_def_subspaces
[i
].alignment
;
5630 quadrant
= pa_def_subspaces
[i
].quadrant
;
5631 access
= pa_def_subspaces
[i
].access
;
5632 sort
= pa_def_subspaces
[i
].sort
;
5633 if (USE_ALIASES
&& pa_def_subspaces
[i
].alias
)
5634 alias
= pa_def_subspaces
[i
].alias
;
5641 /* We should be working with a new subspace now. Fill in
5642 any information as specified by the user. */
5643 if (!is_end_of_statement ())
5645 input_line_pointer
++;
5646 while (!is_end_of_statement ())
5648 name
= input_line_pointer
;
5649 c
= get_symbol_end ();
5650 if ((strncasecmp (name
, "quad", 4) == 0))
5652 *input_line_pointer
= c
;
5653 input_line_pointer
++;
5654 quadrant
= get_absolute_expression ();
5656 else if ((strncasecmp (name
, "align", 5) == 0))
5658 *input_line_pointer
= c
;
5659 input_line_pointer
++;
5660 alignment
= get_absolute_expression ();
5661 if (log2 (alignment
) == -1)
5663 as_bad (_("Alignment must be a power of 2"));
5667 else if ((strncasecmp (name
, "access", 6) == 0))
5669 *input_line_pointer
= c
;
5670 input_line_pointer
++;
5671 access
= get_absolute_expression ();
5673 else if ((strncasecmp (name
, "sort", 4) == 0))
5675 *input_line_pointer
= c
;
5676 input_line_pointer
++;
5677 sort
= get_absolute_expression ();
5679 else if ((strncasecmp (name
, "code_only", 9) == 0))
5681 *input_line_pointer
= c
;
5684 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5686 *input_line_pointer
= c
;
5689 else if ((strncasecmp (name
, "common", 6) == 0))
5691 *input_line_pointer
= c
;
5694 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
5696 *input_line_pointer
= c
;
5699 else if ((strncasecmp (name
, "zero", 4) == 0))
5701 *input_line_pointer
= c
;
5704 else if ((strncasecmp (name
, "first", 5) == 0))
5705 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
5707 as_bad (_("Invalid .SUBSPACE argument"));
5708 if (!is_end_of_statement ())
5709 input_line_pointer
++;
5713 /* Compute a reasonable set of BFD flags based on the information
5714 in the .subspace directive. */
5715 applicable
= bfd_applicable_section_flags (stdoutput
);
5718 flags
|= (SEC_ALLOC
| SEC_LOAD
);
5721 if (common
|| dup_common
)
5722 flags
|= SEC_IS_COMMON
;
5724 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
5726 /* This is a zero-filled subspace (eg BSS). */
5728 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
5730 applicable
&= flags
;
5732 /* If this is an existing subspace, then we want to use the
5733 segment already associated with the subspace.
5735 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
5736 lots of sections. It might be a problem in the PA ELF
5737 code, I do not know yet. For now avoid creating anything
5738 but the "standard" sections for ELF. */
5740 section
= subseg_force_new (ss_name
, 0);
5742 section
= ssd
->ssd_seg
;
5744 section
= subseg_new (alias
, 0);
5745 else if (!alias
&& USE_ALIASES
)
5747 as_warn (_("Ignoring subspace decl due to ELF BFD bugs."));
5748 demand_empty_rest_of_line ();
5752 section
= subseg_new (ss_name
, 0);
5755 seg_info (section
)->bss
= 1;
5757 /* Now set the flags. */
5758 bfd_set_section_flags (stdoutput
, section
, applicable
);
5760 /* Record any alignment request for this section. */
5761 record_alignment (section
, log2 (alignment
));
5763 /* Set the starting offset for this section. */
5764 bfd_set_section_vma (stdoutput
, section
,
5765 pa_subspace_start (space
, quadrant
));
5767 /* Now that all the flags are set, update an existing subspace,
5768 or create a new one. */
5771 current_subspace
= update_subspace (space
, ss_name
, loadable
,
5772 code_only
, common
, dup_common
,
5773 sort
, zero
, access
, space_index
,
5774 alignment
, quadrant
,
5777 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
5779 dup_common
, zero
, sort
,
5780 access
, space_index
,
5781 alignment
, quadrant
, section
);
5783 demand_empty_rest_of_line ();
5784 current_subspace
->ssd_seg
= section
;
5785 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
5787 SUBSPACE_DEFINED (current_subspace
) = 1;
5791 /* Create default space and subspace dictionaries. */
5798 space_dict_root
= NULL
;
5799 space_dict_last
= NULL
;
5802 while (pa_def_spaces
[i
].name
)
5806 /* Pick the right name to use for the new section. */
5807 if (pa_def_spaces
[i
].alias
&& USE_ALIASES
)
5808 name
= pa_def_spaces
[i
].alias
;
5810 name
= pa_def_spaces
[i
].name
;
5812 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
5813 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
5814 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
5815 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
5816 pa_def_spaces
[i
].segment
, 0);
5821 while (pa_def_subspaces
[i
].name
)
5824 int applicable
, subsegment
;
5825 asection
*segment
= NULL
;
5826 sd_chain_struct
*space
;
5828 /* Pick the right name for the new section and pick the right
5829 subsegment number. */
5830 if (pa_def_subspaces
[i
].alias
&& USE_ALIASES
)
5832 name
= pa_def_subspaces
[i
].alias
;
5833 subsegment
= pa_def_subspaces
[i
].subsegment
;
5837 name
= pa_def_subspaces
[i
].name
;
5841 /* Create the new section. */
5842 segment
= subseg_new (name
, subsegment
);
5845 /* For SOM we want to replace the standard .text, .data, and .bss
5846 sections with our own. We also want to set BFD flags for
5847 all the built-in subspaces. */
5848 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$") && !USE_ALIASES
)
5850 text_section
= segment
;
5851 applicable
= bfd_applicable_section_flags (stdoutput
);
5852 bfd_set_section_flags (stdoutput
, segment
,
5853 applicable
& (SEC_ALLOC
| SEC_LOAD
5854 | SEC_RELOC
| SEC_CODE
5856 | SEC_HAS_CONTENTS
));
5858 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$") && !USE_ALIASES
)
5860 data_section
= segment
;
5861 applicable
= bfd_applicable_section_flags (stdoutput
);
5862 bfd_set_section_flags (stdoutput
, segment
,
5863 applicable
& (SEC_ALLOC
| SEC_LOAD
5865 | SEC_HAS_CONTENTS
));
5869 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$") && !USE_ALIASES
)
5871 bss_section
= segment
;
5872 applicable
= bfd_applicable_section_flags (stdoutput
);
5873 bfd_set_section_flags (stdoutput
, segment
,
5874 applicable
& SEC_ALLOC
);
5876 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$") && !USE_ALIASES
)
5878 applicable
= bfd_applicable_section_flags (stdoutput
);
5879 bfd_set_section_flags (stdoutput
, segment
,
5880 applicable
& (SEC_ALLOC
| SEC_LOAD
5883 | SEC_HAS_CONTENTS
));
5885 else if (!strcmp (pa_def_subspaces
[i
].name
, "$MILLICODE$")
5888 applicable
= bfd_applicable_section_flags (stdoutput
);
5889 bfd_set_section_flags (stdoutput
, segment
,
5890 applicable
& (SEC_ALLOC
| SEC_LOAD
5893 | SEC_HAS_CONTENTS
));
5895 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$") && !USE_ALIASES
)
5897 applicable
= bfd_applicable_section_flags (stdoutput
);
5898 bfd_set_section_flags (stdoutput
, segment
,
5899 applicable
& (SEC_ALLOC
| SEC_LOAD
5902 | SEC_HAS_CONTENTS
));
5905 /* Find the space associated with this subspace. */
5906 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
5907 def_space_index
].segment
);
5910 as_fatal (_("Internal error: Unable to find containing space for %s."),
5911 pa_def_subspaces
[i
].name
);
5914 create_new_subspace (space
, name
,
5915 pa_def_subspaces
[i
].loadable
,
5916 pa_def_subspaces
[i
].code_only
,
5917 pa_def_subspaces
[i
].common
,
5918 pa_def_subspaces
[i
].dup_common
,
5919 pa_def_subspaces
[i
].zero
,
5920 pa_def_subspaces
[i
].sort
,
5921 pa_def_subspaces
[i
].access
,
5922 pa_def_subspaces
[i
].space_index
,
5923 pa_def_subspaces
[i
].alignment
,
5924 pa_def_subspaces
[i
].quadrant
,
5932 /* Create a new space NAME, with the appropriate flags as defined
5933 by the given parameters. */
5935 static sd_chain_struct
*
5936 create_new_space (name
, spnum
, loadable
, defined
, private,
5937 sort
, seg
, user_defined
)
5947 sd_chain_struct
*chain_entry
;
5949 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
5951 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
5954 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
5955 strcpy (SPACE_NAME (chain_entry
), name
);
5956 SPACE_DEFINED (chain_entry
) = defined
;
5957 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
5958 SPACE_SPNUM (chain_entry
) = spnum
;
5960 chain_entry
->sd_seg
= seg
;
5961 chain_entry
->sd_last_subseg
= -1;
5962 chain_entry
->sd_subspaces
= NULL
;
5963 chain_entry
->sd_next
= NULL
;
5965 /* Find spot for the new space based on its sort key. */
5966 if (!space_dict_last
)
5967 space_dict_last
= chain_entry
;
5969 if (space_dict_root
== NULL
)
5970 space_dict_root
= chain_entry
;
5973 sd_chain_struct
*chain_pointer
;
5974 sd_chain_struct
*prev_chain_pointer
;
5976 chain_pointer
= space_dict_root
;
5977 prev_chain_pointer
= NULL
;
5979 while (chain_pointer
)
5981 prev_chain_pointer
= chain_pointer
;
5982 chain_pointer
= chain_pointer
->sd_next
;
5985 /* At this point we've found the correct place to add the new
5986 entry. So add it and update the linked lists as appropriate. */
5987 if (prev_chain_pointer
)
5989 chain_entry
->sd_next
= chain_pointer
;
5990 prev_chain_pointer
->sd_next
= chain_entry
;
5994 space_dict_root
= chain_entry
;
5995 chain_entry
->sd_next
= chain_pointer
;
5998 if (chain_entry
->sd_next
== NULL
)
5999 space_dict_last
= chain_entry
;
6002 /* This is here to catch predefined spaces which do not get
6003 modified by the user's input. Another call is found at
6004 the bottom of pa_parse_space_stmt to handle cases where
6005 the user modifies a predefined space. */
6006 #ifdef obj_set_section_attributes
6007 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
6013 /* Create a new subspace NAME, with the appropriate flags as defined
6014 by the given parameters.
6016 Add the new subspace to the subspace dictionary chain in numerical
6017 order as defined by the SORT entries. */
6019 static ssd_chain_struct
*
6020 create_new_subspace (space
, name
, loadable
, code_only
, common
,
6021 dup_common
, is_zero
, sort
, access
, space_index
,
6022 alignment
, quadrant
, seg
)
6023 sd_chain_struct
*space
;
6025 int loadable
, code_only
, common
, dup_common
, is_zero
;
6033 ssd_chain_struct
*chain_entry
;
6035 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
6037 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
6039 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
6040 strcpy (SUBSPACE_NAME (chain_entry
), name
);
6042 /* Initialize subspace_defined. When we hit a .subspace directive
6043 we'll set it to 1 which "locks-in" the subspace attributes. */
6044 SUBSPACE_DEFINED (chain_entry
) = 0;
6046 chain_entry
->ssd_subseg
= USE_ALIASES
? pa_next_subseg (space
) : 0;
6047 chain_entry
->ssd_seg
= seg
;
6048 chain_entry
->ssd_next
= NULL
;
6050 /* Find spot for the new subspace based on its sort key. */
6051 if (space
->sd_subspaces
== NULL
)
6052 space
->sd_subspaces
= chain_entry
;
6055 ssd_chain_struct
*chain_pointer
;
6056 ssd_chain_struct
*prev_chain_pointer
;
6058 chain_pointer
= space
->sd_subspaces
;
6059 prev_chain_pointer
= NULL
;
6061 while (chain_pointer
)
6063 prev_chain_pointer
= chain_pointer
;
6064 chain_pointer
= chain_pointer
->ssd_next
;
6067 /* Now we have somewhere to put the new entry. Insert it and update
6069 if (prev_chain_pointer
)
6071 chain_entry
->ssd_next
= chain_pointer
;
6072 prev_chain_pointer
->ssd_next
= chain_entry
;
6076 space
->sd_subspaces
= chain_entry
;
6077 chain_entry
->ssd_next
= chain_pointer
;
6081 #ifdef obj_set_subsection_attributes
6082 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
6089 /* Update the information for the given subspace based upon the
6090 various arguments. Return the modified subspace chain entry. */
6092 static ssd_chain_struct
*
6093 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
6094 zero
, access
, space_index
, alignment
, quadrant
, section
)
6095 sd_chain_struct
*space
;
6109 ssd_chain_struct
*chain_entry
;
6111 chain_entry
= is_defined_subspace (name
);
6113 #ifdef obj_set_subsection_attributes
6114 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
6121 /* Return the space chain entry for the space with the name NAME or
6122 NULL if no such space exists. */
6124 static sd_chain_struct
*
6125 is_defined_space (name
)
6128 sd_chain_struct
*chain_pointer
;
6130 for (chain_pointer
= space_dict_root
;
6132 chain_pointer
= chain_pointer
->sd_next
)
6134 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
6135 return chain_pointer
;
6138 /* No mapping from segment to space was found. Return NULL. */
6142 /* Find and return the space associated with the given seg. If no mapping
6143 from the given seg to a space is found, then return NULL.
6145 Unlike subspaces, the number of spaces is not expected to grow much,
6146 so a linear exhaustive search is OK here. */
6148 static sd_chain_struct
*
6149 pa_segment_to_space (seg
)
6152 sd_chain_struct
*space_chain
;
6154 /* Walk through each space looking for the correct mapping. */
6155 for (space_chain
= space_dict_root
;
6157 space_chain
= space_chain
->sd_next
)
6159 if (space_chain
->sd_seg
== seg
)
6163 /* Mapping was not found. Return NULL. */
6167 /* Return the space chain entry for the subspace with the name NAME or
6168 NULL if no such subspace exists.
6170 Uses a linear search through all the spaces and subspaces, this may
6171 not be appropriate if we ever being placing each function in its
6174 static ssd_chain_struct
*
6175 is_defined_subspace (name
)
6178 sd_chain_struct
*space_chain
;
6179 ssd_chain_struct
*subspace_chain
;
6181 /* Walk through each space. */
6182 for (space_chain
= space_dict_root
;
6184 space_chain
= space_chain
->sd_next
)
6186 /* Walk through each subspace looking for a name which matches. */
6187 for (subspace_chain
= space_chain
->sd_subspaces
;
6189 subspace_chain
= subspace_chain
->ssd_next
)
6190 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
6191 return subspace_chain
;
6194 /* Subspace wasn't found. Return NULL. */
6198 /* Find and return the subspace associated with the given seg. If no
6199 mapping from the given seg to a subspace is found, then return NULL.
6201 If we ever put each procedure/function within its own subspace
6202 (to make life easier on the compiler and linker), then this will have
6203 to become more efficient. */
6205 static ssd_chain_struct
*
6206 pa_subsegment_to_subspace (seg
, subseg
)
6210 sd_chain_struct
*space_chain
;
6211 ssd_chain_struct
*subspace_chain
;
6213 /* Walk through each space. */
6214 for (space_chain
= space_dict_root
;
6216 space_chain
= space_chain
->sd_next
)
6218 if (space_chain
->sd_seg
== seg
)
6220 /* Walk through each subspace within each space looking for
6221 the correct mapping. */
6222 for (subspace_chain
= space_chain
->sd_subspaces
;
6224 subspace_chain
= subspace_chain
->ssd_next
)
6225 if (subspace_chain
->ssd_subseg
== (int) subseg
)
6226 return subspace_chain
;
6230 /* No mapping from subsegment to subspace found. Return NULL. */
6234 /* Given a number, try and find a space with the name number.
6236 Return a pointer to a space dictionary chain entry for the space
6237 that was found or NULL on failure. */
6239 static sd_chain_struct
*
6240 pa_find_space_by_number (number
)
6243 sd_chain_struct
*space_chain
;
6245 for (space_chain
= space_dict_root
;
6247 space_chain
= space_chain
->sd_next
)
6249 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
6253 /* No appropriate space found. Return NULL. */
6257 /* Return the starting address for the given subspace. If the starting
6258 address is unknown then return zero. */
6261 pa_subspace_start (space
, quadrant
)
6262 sd_chain_struct
*space
;
6266 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
6267 is not correct for the PA OSF1 port. */
6268 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
6270 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
6278 /* FIXME. Needs documentation. */
6280 pa_next_subseg (space
)
6281 sd_chain_struct
*space
;
6284 space
->sd_last_subseg
++;
6285 return space
->sd_last_subseg
;
6288 /* Helper function for pa_stringer. Used to find the end of
6295 unsigned int c
= *s
& CHAR_MASK
;
6297 /* We must have a valid space and subspace. */
6298 pa_check_current_space_and_subspace ();
6311 /* Handle a .STRING type pseudo-op. */
6314 pa_stringer (append_zero
)
6317 char *s
, num_buf
[4];
6321 /* Preprocess the string to handle PA-specific escape sequences.
6322 For example, \xDD where DD is a hexidecimal number should be
6323 changed to \OOO where OOO is an octal number. */
6325 /* Skip the opening quote. */
6326 s
= input_line_pointer
+ 1;
6328 while (is_a_char (c
= pa_stringer_aux (s
++)))
6335 /* Handle \x<num>. */
6338 unsigned int number
;
6343 /* Get pas the 'x'. */
6345 for (num_digit
= 0, number
= 0, dg
= *s
;
6347 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
6348 || (dg
>= 'A' && dg
<= 'F'));
6352 number
= number
* 16 + dg
- '0';
6353 else if (dg
>= 'a' && dg
<= 'f')
6354 number
= number
* 16 + dg
- 'a' + 10;
6356 number
= number
* 16 + dg
- 'A' + 10;
6366 sprintf (num_buf
, "%02o", number
);
6369 sprintf (num_buf
, "%03o", number
);
6372 for (i
= 0; i
<= num_digit
; i
++)
6373 s_start
[i
] = num_buf
[i
];
6377 /* This might be a "\"", skip over the escaped char. */
6384 stringer (append_zero
);
6385 pa_undefine_label ();
6388 /* Handle a .VERSION pseudo-op. */
6395 pa_undefine_label ();
6400 /* Handle a .COMPILER pseudo-op. */
6403 pa_compiler (unused
)
6406 obj_som_compiler (0);
6407 pa_undefine_label ();
6412 /* Handle a .COPYRIGHT pseudo-op. */
6415 pa_copyright (unused
)
6419 pa_undefine_label ();
6422 /* Just like a normal cons, but when finished we have to undefine
6423 the latest space label. */
6430 pa_undefine_label ();
6433 /* Switch to the data space. As usual delete our label. */
6439 current_space
= is_defined_space ("$PRIVATE$");
6441 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6443 pa_undefine_label ();
6446 /* Like float_cons, but we need to undefine our label. */
6449 pa_float_cons (float_type
)
6452 float_cons (float_type
);
6453 pa_undefine_label ();
6456 /* Like s_fill, but delete our label when finished. */
6462 /* We must have a valid space and subspace. */
6463 pa_check_current_space_and_subspace ();
6466 pa_undefine_label ();
6469 /* Like lcomm, but delete our label when finished. */
6472 pa_lcomm (needs_align
)
6475 /* We must have a valid space and subspace. */
6476 pa_check_current_space_and_subspace ();
6478 s_lcomm (needs_align
);
6479 pa_undefine_label ();
6482 /* Like lsym, but delete our label when finished. */
6488 /* We must have a valid space and subspace. */
6489 pa_check_current_space_and_subspace ();
6492 pa_undefine_label ();
6495 /* Switch to the text space. Like s_text, but delete our
6496 label when finished. */
6501 current_space
= is_defined_space ("$TEXT$");
6503 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6506 pa_undefine_label ();
6509 /* On the PA relocations which involve function symbols must not be
6510 adjusted. This so that the linker can know when/how to create argument
6511 relocation stubs for indirect calls and calls to static functions.
6513 "T" field selectors create DLT relative fixups for accessing
6514 globals and statics in PIC code; each DLT relative fixup creates
6515 an entry in the DLT table. The entries contain the address of
6516 the final target (eg accessing "foo" would create a DLT entry
6517 with the address of "foo").
6519 Unfortunately, the HP linker doesn't take into account any addend
6520 when generating the DLT; so accessing $LIT$+8 puts the address of
6521 $LIT$ into the DLT rather than the address of $LIT$+8.
6523 The end result is we can't perform relocation symbol reductions for
6524 any fixup which creates entries in the DLT (eg they use "T" field
6527 Reject reductions involving symbols with external scope; such
6528 reductions make life a living hell for object file editors.
6530 FIXME. Also reject R_HPPA relocations which are 32bits wide in
6531 the code space. The SOM BFD backend doesn't know how to pull the
6532 right bits out of an instruction. */
6535 hppa_fix_adjustable (fixp
)
6538 struct hppa_fix_struct
*hppa_fix
;
6540 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6543 /* Reject reductions of symbols in 32bit relocs. */
6544 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
6547 /* Reject reductions of symbols in sym1-sym2 expressions when
6548 the fixup will occur in a CODE subspace.
6550 XXX FIXME: Long term we probably want to reject all of these;
6551 for example reducing in the debug section would lose if we ever
6552 supported using the optimizing hp linker. */
6555 && (hppa_fix
->segment
->flags
& SEC_CODE
))
6557 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
6558 fixp
->fx_subsy
->sy_used_in_reloc
= 1;
6562 /* We can't adjust any relocs that use LR% and RR% field selectors.
6563 That confuses the HP linker. */
6564 if (hppa_fix
->fx_r_field
== e_lrsel
6565 || hppa_fix
->fx_r_field
== e_rrsel
6566 || hppa_fix
->fx_r_field
== e_nlrsel
)
6570 /* Reject reductions of symbols in DLT relative relocs,
6571 relocations with plabels. */
6572 if (hppa_fix
->fx_r_field
== e_tsel
6573 || hppa_fix
->fx_r_field
== e_ltsel
6574 || hppa_fix
->fx_r_field
== e_rtsel
6575 || hppa_fix
->fx_r_field
== e_psel
6576 || hppa_fix
->fx_r_field
== e_rpsel
6577 || hppa_fix
->fx_r_field
== e_lpsel
)
6580 if (fixp
->fx_addsy
&& S_IS_EXTERNAL (fixp
->fx_addsy
))
6583 /* Reject absolute calls (jumps). */
6584 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
6587 /* Reject reductions of function symbols. */
6588 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
6594 /* Return nonzero if the fixup in FIXP will require a relocation,
6595 even it if appears that the fixup could be completely handled
6599 hppa_force_relocation (fixp
)
6602 struct hppa_fix_struct
*hppa_fixp
;
6605 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6607 if (fixp
->fx_r_type
== R_HPPA_ENTRY
|| fixp
->fx_r_type
== R_HPPA_EXIT
6608 || fixp
->fx_r_type
== R_HPPA_BEGIN_BRTAB
6609 || fixp
->fx_r_type
== R_HPPA_END_BRTAB
6610 || fixp
->fx_r_type
== R_HPPA_BEGIN_TRY
6611 || fixp
->fx_r_type
== R_HPPA_END_TRY
6612 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
6613 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
6617 #define arg_reloc_stub_needed(CALLER, CALLEE) \
6618 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
6620 /* It is necessary to force PC-relative calls/jumps to have a relocation
6621 entry if they're going to need either a argument relocation or long
6622 call stub. FIXME. Can't we need the same for absolute calls? */
6623 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
6624 && (arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
6625 symbol_get_bfdsym (fixp
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
6626 hppa_fixp
->fx_arg_reloc
)))
6628 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
6629 - md_pcrel_from (fixp
));
6630 /* Now check and see if we're going to need a long-branch stub. */
6631 if (fixp
->fx_r_type
== R_HPPA_PCREL_CALL
6632 && (distance
> 262143 || distance
< -262144))
6635 if (fixp
->fx_r_type
== R_HPPA_ABS_CALL
)
6637 #undef arg_reloc_stub_needed
6639 /* No need (yet) to force another relocations to be emitted. */
6643 /* Now for some ELF specific code. FIXME. */
6645 /* Mark the end of a function so that it's possible to compute
6646 the size of the function in hppa_elf_final_processing. */
6649 hppa_elf_mark_end_of_function ()
6651 /* ELF does not have EXIT relocations. All we do is create a
6652 temporary symbol marking the end of the function. */
6653 char *name
= (char *)
6654 xmalloc (strlen ("L$\001end_") +
6655 strlen (S_GET_NAME (last_call_info
->start_symbol
)) + 1);
6661 strcpy (name
, "L$\001end_");
6662 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
6664 /* If we have a .exit followed by a .procend, then the
6665 symbol will have already been defined. */
6666 symbolP
= symbol_find (name
);
6669 /* The symbol has already been defined! This can
6670 happen if we have a .exit followed by a .procend.
6672 This is *not* an error. All we want to do is free
6673 the memory we just allocated for the name and continue. */
6678 /* symbol value should be the offset of the
6679 last instruction of the function */
6680 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
6684 S_CLEAR_EXTERNAL (symbolP
);
6685 symbol_table_insert (symbolP
);
6689 last_call_info
->end_symbol
= symbolP
;
6691 as_bad (_("Symbol '%s' could not be created."), name
);
6695 as_bad (_("No memory for symbol name."));
6699 /* For ELF, this function serves one purpose: to setup the st_size
6700 field of STT_FUNC symbols. To do this, we need to scan the
6701 call_info structure list, determining st_size in by taking the
6702 difference in the address of the beginning/end marker symbols. */
6705 elf_hppa_final_processing ()
6707 struct call_info
*call_info_pointer
;
6709 for (call_info_pointer
= call_info_root
;
6711 call_info_pointer
= call_info_pointer
->ci_next
)
6713 elf_symbol_type
*esym
6714 = ((elf_symbol_type
*)
6715 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
6716 esym
->internal_elf_sym
.st_size
=
6717 S_GET_VALUE (call_info_pointer
->end_symbol
)
6718 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;