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
;
710 /* Nonzero if errors are to be printed. */
711 static int print_errors
= 1;
713 /* List of registers that are pre-defined:
715 Each general register has one predefined name of the form
716 %r<REGNUM> which has the value <REGNUM>.
718 Space and control registers are handled in a similar manner,
719 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
721 Likewise for the floating point registers, but of the form
722 %fr<REGNUM>. Floating point registers have additional predefined
723 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
724 again have the value <REGNUM>.
726 Many registers also have synonyms:
728 %r26 - %r23 have %arg0 - %arg3 as synonyms
729 %r28 - %r29 have %ret0 - %ret1 as synonyms
730 %r30 has %sp as a synonym
731 %r27 has %dp as a synonym
732 %r2 has %rp as a synonym
734 Almost every control register has a synonym; they are not listed
737 The table is sorted. Suitable for searching by a binary search. */
739 static const struct pd_reg pre_defined_registers
[] =
939 /* This table is sorted by order of the length of the string. This is
940 so we check for <> before we check for <. If we had a <> and checked
941 for < first, we would get a false match. */
942 static const struct fp_cond_map fp_cond_map
[] =
978 static const struct selector_entry selector_table
[] =
1000 /* default space and subspace dictionaries */
1002 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1003 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1005 /* pre-defined subsegments (subspaces) for the HPPA. */
1006 #define SUBSEG_CODE 0
1007 #define SUBSEG_LIT 1
1008 #define SUBSEG_MILLI 2
1009 #define SUBSEG_DATA 0
1010 #define SUBSEG_BSS 2
1011 #define SUBSEG_UNWIND 3
1012 #define SUBSEG_GDB_STRINGS 0
1013 #define SUBSEG_GDB_SYMBOLS 1
1015 static struct default_subspace_dict pa_def_subspaces
[] =
1017 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_CODE
},
1018 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, ".data", SUBSEG_DATA
},
1019 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_LIT
},
1020 {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_MILLI
},
1021 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, ".bss", SUBSEG_BSS
},
1023 {"$UNWIND$", 1, 1, 0, 0, 0, 0, 64, 0x2c, 0, 4, 0, 0, ".PARISC.unwind", SUBSEG_UNWIND
},
1025 {NULL
, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1028 static struct default_space_dict pa_def_spaces
[] =
1030 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL
, ".text"},
1031 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL
, ".data"},
1032 {NULL
, 0, 0, 0, 0, 0, ASEC_NULL
, NULL
}
1035 /* Misc local definitions used by the assembler. */
1037 /* Return nonzero if the string pointed to by S potentially represents
1038 a right or left half of a FP register */
1039 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1040 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1042 /* These macros are used to maintain spaces/subspaces. */
1043 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1044 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1045 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1046 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1048 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1049 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1051 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1052 main loop after insertion. */
1054 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1056 ((OPCODE) |= (FIELD) << (START)); \
1060 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1061 IGNORE is used to suppress the error message. */
1063 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1065 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1068 as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \
1074 #define is_DP_relative(exp) \
1075 ((exp).X_op == O_subtract \
1076 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0)
1078 #define is_PC_relative(exp) \
1079 ((exp).X_op == O_subtract \
1080 && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0)
1082 /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll
1083 always be able to reduce the expression to a constant, so we don't
1084 need real complex handling yet. */
1085 #define is_complex(exp) \
1086 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1088 /* Actual functions to implement the PA specific code for the assembler. */
1090 /* Called before writing the object file. Make sure entry/exit and
1091 proc/procend pairs match. */
1096 if (within_entry_exit
)
1097 as_fatal (_("Missing .exit\n"));
1099 if (within_procedure
)
1100 as_fatal (_("Missing .procend\n"));
1103 /* Check to make sure we have a valid space and subspace. */
1106 pa_check_current_space_and_subspace ()
1108 if (current_space
== NULL
)
1109 as_fatal (_("Not in a space.\n"));
1111 if (current_subspace
== NULL
)
1112 as_fatal (_("Not in a subspace.\n"));
1115 /* Returns a pointer to the label_symbol_struct for the current space.
1116 or NULL if no label_symbol_struct exists for the current space. */
1118 static label_symbol_struct
*
1121 label_symbol_struct
*label_chain
;
1122 sd_chain_struct
*space_chain
= current_space
;
1124 for (label_chain
= label_symbols_rootp
;
1126 label_chain
= label_chain
->lss_next
)
1127 if (space_chain
== label_chain
->lss_space
&& label_chain
->lss_label
)
1133 /* Defines a label for the current space. If one is already defined,
1134 this function will replace it with the new label. */
1137 pa_define_label (symbol
)
1140 label_symbol_struct
*label_chain
= pa_get_label ();
1141 sd_chain_struct
*space_chain
= current_space
;
1144 label_chain
->lss_label
= symbol
;
1147 /* Create a new label entry and add it to the head of the chain. */
1149 = (label_symbol_struct
*) xmalloc (sizeof (label_symbol_struct
));
1150 label_chain
->lss_label
= symbol
;
1151 label_chain
->lss_space
= space_chain
;
1152 label_chain
->lss_next
= NULL
;
1154 if (label_symbols_rootp
)
1155 label_chain
->lss_next
= label_symbols_rootp
;
1157 label_symbols_rootp
= label_chain
;
1161 /* Removes a label definition for the current space.
1162 If there is no label_symbol_struct entry, then no action is taken. */
1165 pa_undefine_label ()
1167 label_symbol_struct
*label_chain
;
1168 label_symbol_struct
*prev_label_chain
= NULL
;
1169 sd_chain_struct
*space_chain
= current_space
;
1171 for (label_chain
= label_symbols_rootp
;
1173 label_chain
= label_chain
->lss_next
)
1175 if (space_chain
== label_chain
->lss_space
&& label_chain
->lss_label
)
1177 /* Remove the label from the chain and free its memory. */
1178 if (prev_label_chain
)
1179 prev_label_chain
->lss_next
= label_chain
->lss_next
;
1181 label_symbols_rootp
= label_chain
->lss_next
;
1186 prev_label_chain
= label_chain
;
1191 /* An HPPA-specific version of fix_new. This is required because the HPPA
1192 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1193 results in the creation of an instance of an hppa_fix_struct. An
1194 hppa_fix_struct stores the extra information along with a pointer to the
1195 original fixS. This is attached to the original fixup via the
1196 tc_fix_data field. */
1199 fix_new_hppa (frag
, where
, size
, add_symbol
, offset
, exp
, pcrel
,
1200 r_type
, r_field
, r_format
, arg_reloc
, unwind_bits
)
1204 symbolS
*add_symbol
;
1208 bfd_reloc_code_real_type r_type
;
1209 enum hppa_reloc_field_selector_type_alt r_field
;
1216 struct hppa_fix_struct
*hppa_fix
= (struct hppa_fix_struct
*)
1217 obstack_alloc (¬es
, sizeof (struct hppa_fix_struct
));
1220 new_fix
= fix_new_exp (frag
, where
, size
, exp
, pcrel
, r_type
);
1222 new_fix
= fix_new (frag
, where
, size
, add_symbol
, offset
, pcrel
, r_type
);
1223 new_fix
->tc_fix_data
= (void *) hppa_fix
;
1224 hppa_fix
->fx_r_type
= r_type
;
1225 hppa_fix
->fx_r_field
= r_field
;
1226 hppa_fix
->fx_r_format
= r_format
;
1227 hppa_fix
->fx_arg_reloc
= arg_reloc
;
1228 hppa_fix
->segment
= now_seg
;
1230 if (r_type
== R_ENTRY
|| r_type
== R_EXIT
)
1231 new_fix
->fx_offset
= *unwind_bits
;
1234 /* foo-$global$ is used to access non-automatic storage. $global$
1235 is really just a marker and has served its purpose, so eliminate
1236 it now so as not to confuse write.c. */
1237 if (new_fix
->fx_subsy
1238 && !strcmp (S_GET_NAME (new_fix
->fx_subsy
), "$global$"))
1239 new_fix
->fx_subsy
= NULL
;
1242 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1243 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1246 parse_cons_expression_hppa (exp
)
1249 hppa_field_selector
= pa_chk_field_selector (&input_line_pointer
);
1253 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1254 hppa_field_selector is set by the parse_cons_expression_hppa. */
1257 cons_fix_new_hppa (frag
, where
, size
, exp
)
1263 unsigned int rel_type
;
1265 /* Get a base relocation type. */
1266 if (is_DP_relative (*exp
))
1267 rel_type
= R_HPPA_GOTOFF
;
1268 else if (is_complex (*exp
))
1269 rel_type
= R_HPPA_COMPLEX
;
1273 if (hppa_field_selector
!= e_psel
&& hppa_field_selector
!= e_fsel
)
1274 as_warn (_("Invalid field selector. Assuming F%%."));
1276 fix_new_hppa (frag
, where
, size
,
1277 (symbolS
*) NULL
, (offsetT
) 0, exp
, 0, rel_type
,
1278 hppa_field_selector
, 32, 0, NULL
);
1280 /* Reset field selector to its default state. */
1281 hppa_field_selector
= 0;
1284 /* This function is called once, at assembler startup time. It should
1285 set up all the tables, etc. that the MD part of the assembler will need. */
1290 const char *retval
= NULL
;
1294 last_call_info
= NULL
;
1295 call_info_root
= NULL
;
1297 /* Set the default machine type. */
1298 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
1299 as_warn (_("could not set architecture and machine"));
1301 /* Folding of text and data segments fails miserably on the PA.
1302 Warn user and disable "-R" option. */
1303 if (flag_readonly_data_in_text
)
1305 as_warn (_("-R option not supported on this target."));
1306 flag_readonly_data_in_text
= 0;
1311 op_hash
= hash_new ();
1313 while (i
< NUMOPCODES
)
1315 const char *name
= pa_opcodes
[i
].name
;
1316 retval
= hash_insert (op_hash
, name
, (struct pa_opcode
*) &pa_opcodes
[i
]);
1317 if (retval
!= NULL
&& *retval
!= '\0')
1319 as_fatal (_("Internal error: can't hash `%s': %s\n"), name
, retval
);
1324 if ((pa_opcodes
[i
].match
& pa_opcodes
[i
].mask
)
1325 != pa_opcodes
[i
].match
)
1327 fprintf (stderr
, _("internal error: losing opcode: `%s' \"%s\"\n"),
1328 pa_opcodes
[i
].name
, pa_opcodes
[i
].args
);
1333 while (i
< NUMOPCODES
&& !strcmp (pa_opcodes
[i
].name
, name
));
1337 as_fatal (_("Broken assembler. No assembly attempted."));
1339 /* SOM will change text_section. To make sure we never put
1340 anything into the old one switch to the new one now. */
1341 subseg_set (text_section
, 0);
1344 dummy_symbol
= symbol_find_or_make ("L$dummy");
1345 S_SET_SEGMENT (dummy_symbol
, text_section
);
1346 /* Force the symbol to be converted to a real symbol. */
1347 (void) symbol_get_bfdsym (dummy_symbol
);
1351 /* Assemble a single instruction storing it into a frag. */
1358 /* The had better be something to assemble. */
1361 /* If we are within a procedure definition, make sure we've
1362 defined a label for the procedure; handle case where the
1363 label was defined after the .PROC directive.
1365 Note there's not need to diddle with the segment or fragment
1366 for the label symbol in this case. We have already switched
1367 into the new $CODE$ subspace at this point. */
1368 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
1370 label_symbol_struct
*label_symbol
= pa_get_label ();
1374 if (label_symbol
->lss_label
)
1376 last_call_info
->start_symbol
= label_symbol
->lss_label
;
1377 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
1380 /* Also handle allocation of a fixup to hold the unwind
1381 information when the label appears after the proc/procend. */
1382 if (within_entry_exit
)
1384 char *where
= frag_more (0);
1386 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
1387 NULL
, (offsetT
) 0, NULL
,
1388 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
1389 (int *)&last_call_info
->ci_unwind
.descriptor
);
1394 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
1397 as_bad (_("Missing function name for .PROC"));
1400 /* Assemble the instruction. Results are saved into "the_insn". */
1403 /* Get somewhere to put the assembled instrution. */
1406 /* Output the opcode. */
1407 md_number_to_chars (to
, the_insn
.opcode
, 4);
1409 /* If necessary output more stuff. */
1410 if (the_insn
.reloc
!= R_HPPA_NONE
)
1411 fix_new_hppa (frag_now
, (to
- frag_now
->fr_literal
), 4, NULL
,
1412 (offsetT
) 0, &the_insn
.exp
, the_insn
.pcrel
,
1413 the_insn
.reloc
, the_insn
.field_selector
,
1414 the_insn
.format
, the_insn
.arg_reloc
, NULL
);
1417 /* Do the real work for assembling a single instruction. Store results
1418 into the global "the_insn" variable. */
1424 char *error_message
= "";
1425 char *s
, c
, *argstart
, *name
, *save_s
;
1429 int cmpltr
, nullif
, flag
, cond
, num
;
1430 unsigned long opcode
;
1431 struct pa_opcode
*insn
;
1433 /* We must have a valid space and subspace. */
1434 pa_check_current_space_and_subspace ();
1436 /* Skip to something interesting. */
1437 for (s
= str
; isupper (*s
) || islower (*s
) || (*s
>= '0' && *s
<= '3'); ++s
)
1456 as_fatal (_("Unknown opcode: `%s'"), str
);
1461 /* Convert everything into lower case. */
1464 if (isupper (*save_s
))
1465 *save_s
= tolower (*save_s
);
1469 /* Look up the opcode in the has table. */
1470 if ((insn
= (struct pa_opcode
*) hash_find (op_hash
, str
)) == NULL
)
1472 as_bad ("Unknown opcode: `%s'", str
);
1481 /* Mark the location where arguments for the instruction start, then
1482 start processing them. */
1486 /* Do some initialization. */
1487 opcode
= insn
->match
;
1488 memset (&the_insn
, 0, sizeof (the_insn
));
1490 the_insn
.reloc
= R_HPPA_NONE
;
1492 /* If this instruction is specific to a particular architecture,
1493 then set a new architecture. */
1494 /* But do not automatically promote to pa2.0. The automatic promotion
1495 crud is for compatability with HP's old assemblers only. */
1497 && bfd_get_mach (stdoutput
) < insn
->arch
)
1499 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, insn
->arch
))
1500 as_warn (_("could not update architecture and machine"));
1502 else if (bfd_get_mach (stdoutput
) < insn
->arch
)
1508 /* Build the opcode, checking as we go to make
1509 sure that the operands match. */
1510 for (args
= insn
->args
;; ++args
)
1515 /* End of arguments. */
1531 /* These must match exactly. */
1540 /* Handle a 5 bit register or control register field at 10. */
1543 num
= pa_parse_number (&s
, 0);
1544 CHECK_FIELD (num
, 31, 0, 0);
1545 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
1547 /* Handle a 5 bit register field at 15. */
1549 num
= pa_parse_number (&s
, 0);
1550 CHECK_FIELD (num
, 31, 0, 0);
1551 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1553 /* Handle a 5 bit register field at 31. */
1556 num
= pa_parse_number (&s
, 0);
1557 CHECK_FIELD (num
, 31, 0, 0);
1558 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1560 /* Handle a 5 bit field length at 31. */
1562 num
= pa_get_absolute_expression (&the_insn
, &s
);
1564 CHECK_FIELD (num
, 32, 1, 0);
1565 INSERT_FIELD_AND_CONTINUE (opcode
, 32 - num
, 0);
1567 /* Handle a 5 bit immediate at 15. */
1569 num
= pa_get_absolute_expression (&the_insn
, &s
);
1571 CHECK_FIELD (num
, 15, -16, 0);
1572 low_sign_unext (num
, 5, &num
);
1573 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1575 /* Handle a 5 bit immediate at 31. */
1577 num
= pa_get_absolute_expression (&the_insn
, &s
);
1579 CHECK_FIELD (num
, 15, -16, 0)
1580 low_sign_unext (num
, 5, &num
);
1581 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1583 /* Handle an unsigned 5 bit immediate at 31. */
1585 num
= pa_get_absolute_expression (&the_insn
, &s
);
1587 CHECK_FIELD (num
, 31, 0, 0);
1588 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
1590 /* Handle an unsigned 5 bit immediate at 15. */
1592 num
= pa_get_absolute_expression (&the_insn
, &s
);
1594 CHECK_FIELD (num
, 31, 0, 0);
1595 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 16);
1597 /* Handle a 2 bit space identifier at 17. */
1599 num
= pa_parse_number (&s
, 0);
1600 CHECK_FIELD (num
, 3, 0, 1);
1601 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 14);
1603 /* Handle a 3 bit space identifier at 18. */
1605 num
= pa_parse_number (&s
, 0);
1606 CHECK_FIELD (num
, 7, 0, 1);
1607 dis_assemble_3 (num
, &num
);
1608 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
1610 /* Handle a completer for an indexing load or store. */
1616 while (*s
== ',' && i
< 2)
1619 if (strncasecmp (s
, "sm", 2) == 0)
1626 else if (strncasecmp (s
, "m", 1) == 0)
1628 else if (strncasecmp (s
, "s", 1) == 0)
1631 as_bad (_("Invalid Indexed Load Completer."));
1636 as_bad (_("Invalid Indexed Load Completer Syntax."));
1638 INSERT_FIELD_AND_CONTINUE (opcode
, uu
, 13);
1641 /* Handle a short load/store completer. */
1649 if (strncasecmp (s
, "ma", 2) == 0)
1654 else if (strncasecmp (s
, "mb", 2) == 0)
1660 as_bad (_("Invalid Short Load/Store Completer."));
1667 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1671 /* Handle a stbys completer. */
1677 while (*s
== ',' && i
< 2)
1680 if (strncasecmp (s
, "m", 1) == 0)
1682 else if (strncasecmp (s
, "b", 1) == 0)
1684 else if (strncasecmp (s
, "e", 1) == 0)
1687 as_bad (_("Invalid Store Bytes Short Completer"));
1692 as_bad (_("Invalid Store Bytes Short Completer"));
1694 INSERT_FIELD_AND_CONTINUE (opcode
, a
, 13);
1697 /* Handle a non-negated compare/stubtract condition. */
1699 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
1702 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
1705 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1707 /* Handle a negated or non-negated compare/subtract condition. */
1710 cmpltr
= pa_parse_nonneg_cmpsub_cmpltr (&s
, 1);
1714 cmpltr
= pa_parse_neg_cmpsub_cmpltr (&s
, 1);
1717 as_bad (_("Invalid Compare/Subtract Condition."));
1722 /* Negated condition requires an opcode change. */
1727 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1729 /* Handle non-negated add condition. */
1731 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1734 as_bad (_("Invalid Compare/Subtract Condition: %c"), *s
);
1737 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1739 /* Handle a negated or non-negated add condition. */
1742 cmpltr
= pa_parse_nonneg_add_cmpltr (&s
, 1);
1746 cmpltr
= pa_parse_neg_add_cmpltr (&s
, 1);
1749 as_bad (_("Invalid Compare/Subtract Condition"));
1754 /* Negated condition requires an opcode change. */
1758 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
1760 /* Handle a compare/subtract condition. */
1768 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1772 if (strcmp (name
, "=") == 0)
1774 else if (strcmp (name
, "<") == 0)
1776 else if (strcmp (name
, "<=") == 0)
1778 else if (strcasecmp (name
, "<<") == 0)
1780 else if (strcasecmp (name
, "<<=") == 0)
1782 else if (strcasecmp (name
, "sv") == 0)
1784 else if (strcasecmp (name
, "od") == 0)
1786 else if (strcasecmp (name
, "tr") == 0)
1791 else if (strcmp (name
, "<>") == 0)
1796 else if (strcmp (name
, ">=") == 0)
1801 else if (strcmp (name
, ">") == 0)
1806 else if (strcasecmp (name
, ">>=") == 0)
1811 else if (strcasecmp (name
, ">>") == 0)
1816 else if (strcasecmp (name
, "nsv") == 0)
1821 else if (strcasecmp (name
, "ev") == 0)
1827 as_bad (_("Invalid Add Condition: %s"), name
);
1830 opcode
|= cmpltr
<< 13;
1831 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1833 /* Handle a non-negated add condition. */
1841 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1845 if (strcmp (name
, "=") == 0)
1847 else if (strcmp (name
, "<") == 0)
1849 else if (strcmp (name
, "<=") == 0)
1851 else if (strcasecmp (name
, "nuv") == 0)
1853 else if (strcasecmp (name
, "znv") == 0)
1855 else if (strcasecmp (name
, "sv") == 0)
1857 else if (strcasecmp (name
, "od") == 0)
1859 else if (strcasecmp (name
, "tr") == 0)
1864 else if (strcmp (name
, "<>") == 0)
1869 else if (strcmp (name
, ">=") == 0)
1874 else if (strcmp (name
, ">") == 0)
1879 else if (strcasecmp (name
, "uv") == 0)
1884 else if (strcasecmp (name
, "vnz") == 0)
1889 else if (strcasecmp (name
, "nsv") == 0)
1894 else if (strcasecmp (name
, "ev") == 0)
1900 as_bad (_("Invalid Add Condition: %s"), name
);
1903 opcode
|= cmpltr
<< 13;
1904 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1906 /* HANDLE a logical instruction condition. */
1914 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
1920 if (strcmp (name
, "=") == 0)
1922 else if (strcmp (name
, "<") == 0)
1924 else if (strcmp (name
, "<=") == 0)
1926 else if (strcasecmp (name
, "od") == 0)
1928 else if (strcasecmp (name
, "tr") == 0)
1933 else if (strcmp (name
, "<>") == 0)
1938 else if (strcmp (name
, ">=") == 0)
1943 else if (strcmp (name
, ">") == 0)
1948 else if (strcasecmp (name
, "ev") == 0)
1954 as_bad (_("Invalid Logical Instruction Condition."));
1957 opcode
|= cmpltr
<< 13;
1958 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
1960 /* Handle a unit instruction condition. */
1969 if (strncasecmp (s
, "sbz", 3) == 0)
1974 else if (strncasecmp (s
, "shz", 3) == 0)
1979 else if (strncasecmp (s
, "sdc", 3) == 0)
1984 else if (strncasecmp (s
, "sbc", 3) == 0)
1989 else if (strncasecmp (s
, "shc", 3) == 0)
1994 else if (strncasecmp (s
, "tr", 2) == 0)
2000 else if (strncasecmp (s
, "nbz", 3) == 0)
2006 else if (strncasecmp (s
, "nhz", 3) == 0)
2012 else if (strncasecmp (s
, "ndc", 3) == 0)
2018 else if (strncasecmp (s
, "nbc", 3) == 0)
2024 else if (strncasecmp (s
, "nhc", 3) == 0)
2031 as_bad (_("Invalid Logical Instruction Condition."));
2033 opcode
|= cmpltr
<< 13;
2034 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 12);
2036 /* Handle a shift/extract/deposit condition. */
2046 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
2050 if (strcmp (name
, "=") == 0)
2052 else if (strcmp (name
, "<") == 0)
2054 else if (strcasecmp (name
, "od") == 0)
2056 else if (strcasecmp (name
, "tr") == 0)
2058 else if (strcmp (name
, "<>") == 0)
2060 else if (strcmp (name
, ">=") == 0)
2062 else if (strcasecmp (name
, "ev") == 0)
2064 /* Handle movb,n. Put things back the way they were.
2065 This includes moving s back to where it started. */
2066 else if (strcasecmp (name
, "n") == 0 && *args
== '|')
2073 as_bad (_("Invalid Shift/Extract/Deposit Condition."));
2076 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 13);
2078 /* Handle bvb and bb conditions. */
2084 if (strncmp (s
, "<", 1) == 0)
2089 else if (strncmp (s
, ">=", 2) == 0)
2095 as_bad (_("Invalid Bit Branch Condition: %c"), *s
);
2097 INSERT_FIELD_AND_CONTINUE (opcode
, cmpltr
, 15);
2099 /* Handle a system control completer. */
2101 if (*s
== ',' && (*(s
+ 1) == 'm' || *(s
+ 1) == 'M'))
2109 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 5);
2111 /* Handle a nullification completer for branch instructions. */
2113 nullif
= pa_parse_nullif (&s
);
2114 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 1);
2116 /* Handle a nullification completer for copr and spop insns. */
2118 nullif
= pa_parse_nullif (&s
);
2119 INSERT_FIELD_AND_CONTINUE (opcode
, nullif
, 5);
2122 /* Handle a 11 bit immediate at 31. */
2124 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2127 if (the_insn
.exp
.X_op
== O_constant
)
2129 num
= evaluate_absolute (&the_insn
);
2130 CHECK_FIELD (num
, 1023, -1024, 0);
2131 low_sign_unext (num
, 11, &num
);
2132 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2136 if (is_DP_relative (the_insn
.exp
))
2137 the_insn
.reloc
= R_HPPA_GOTOFF
;
2138 else if (is_PC_relative (the_insn
.exp
))
2139 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2141 the_insn
.reloc
= R_HPPA
;
2142 the_insn
.format
= 11;
2147 /* Handle a 14 bit immediate at 31. */
2149 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2152 if (the_insn
.exp
.X_op
== O_constant
)
2154 num
= evaluate_absolute (&the_insn
);
2155 CHECK_FIELD (num
, 8191, -8192, 0);
2156 low_sign_unext (num
, 14, &num
);
2157 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2161 if (is_DP_relative (the_insn
.exp
))
2162 the_insn
.reloc
= R_HPPA_GOTOFF
;
2163 else if (is_PC_relative (the_insn
.exp
))
2164 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2166 the_insn
.reloc
= R_HPPA
;
2167 the_insn
.format
= 14;
2171 /* Handle a 21 bit immediate at 31. */
2173 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2176 if (the_insn
.exp
.X_op
== O_constant
)
2178 num
= evaluate_absolute (&the_insn
);
2179 CHECK_FIELD (num
>> 11, 1048575, -1048576, 0);
2180 dis_assemble_21 (num
, &num
);
2181 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2185 if (is_DP_relative (the_insn
.exp
))
2186 the_insn
.reloc
= R_HPPA_GOTOFF
;
2187 else if (is_PC_relative (the_insn
.exp
))
2188 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2190 the_insn
.reloc
= R_HPPA
;
2191 the_insn
.format
= 21;
2195 /* Handle a 12 bit branch displacement. */
2197 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2201 if (!strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
), "L$0\001"))
2203 unsigned int w1
, w
, result
;
2205 num
= evaluate_absolute (&the_insn
);
2208 as_bad (_("Branch to unaligned address"));
2211 CHECK_FIELD (num
, 8199, -8184, 0);
2212 sign_unext ((num
- 8) >> 2, 12, &result
);
2213 dis_assemble_12 (result
, &w1
, &w
);
2214 INSERT_FIELD_AND_CONTINUE (opcode
, ((w1
<< 2) | w
), 0);
2218 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2219 the_insn
.format
= 12;
2220 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2221 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2226 /* Handle a 17 bit branch displacement. */
2228 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2232 if (!the_insn
.exp
.X_add_symbol
2233 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2236 unsigned int w2
, w1
, w
, result
;
2238 num
= evaluate_absolute (&the_insn
);
2241 as_bad (_("Branch to unaligned address"));
2244 CHECK_FIELD (num
, 262143, -262144, 0);
2246 if (the_insn
.exp
.X_add_symbol
)
2249 sign_unext (num
>> 2, 17, &result
);
2250 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2251 INSERT_FIELD_AND_CONTINUE (opcode
,
2252 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2256 the_insn
.reloc
= R_HPPA_PCREL_CALL
;
2257 the_insn
.format
= 17;
2258 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2259 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2263 /* Handle an absolute 17 bit branch target. */
2265 the_insn
.field_selector
= pa_chk_field_selector (&s
);
2269 if (!the_insn
.exp
.X_add_symbol
2270 || !strcmp (S_GET_NAME (the_insn
.exp
.X_add_symbol
),
2273 unsigned int w2
, w1
, w
, result
;
2275 num
= evaluate_absolute (&the_insn
);
2278 as_bad (_("Branch to unaligned address"));
2281 CHECK_FIELD (num
, 262143, -262144, 0);
2283 if (the_insn
.exp
.X_add_symbol
)
2286 sign_unext (num
>> 2, 17, &result
);
2287 dis_assemble_17 (result
, &w1
, &w2
, &w
);
2288 INSERT_FIELD_AND_CONTINUE (opcode
,
2289 ((w2
<< 2) | (w1
<< 16) | w
), 0);
2293 the_insn
.reloc
= R_HPPA_ABS_CALL
;
2294 the_insn
.format
= 17;
2295 the_insn
.arg_reloc
= last_call_desc
.arg_reloc
;
2296 memset (&last_call_desc
, 0, sizeof (struct call_desc
));
2300 /* Handle a 5 bit shift count at 26. */
2302 num
= pa_get_absolute_expression (&the_insn
, &s
);
2304 CHECK_FIELD (num
, 31, 0, 0);
2305 INSERT_FIELD_AND_CONTINUE (opcode
, 31 - num
, 5);
2307 /* Handle a 5 bit bit position at 26. */
2309 num
= pa_get_absolute_expression (&the_insn
, &s
);
2311 CHECK_FIELD (num
, 31, 0, 0);
2312 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 5);
2314 /* Handle a 5 bit immediate at 10. */
2317 num
= pa_get_absolute_expression (&the_insn
, &s
);
2318 if (the_insn
.exp
.X_op
!= O_constant
)
2321 CHECK_FIELD (num
, 31, 0, 0);
2322 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 21);
2324 /* Handle a 13 bit immediate at 18. */
2326 num
= pa_get_absolute_expression (&the_insn
, &s
);
2328 CHECK_FIELD (num
, 8191, 0, 0);
2329 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 13);
2331 /* Handle a 26 bit immediate at 31. */
2333 num
= pa_get_absolute_expression (&the_insn
, &s
);
2335 CHECK_FIELD (num
, 671108864, 0, 0);
2336 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2338 /* Handle a 3 bit SFU identifier at 25. */
2341 as_bad (_("Invalid SFU identifier"));
2342 num
= pa_get_absolute_expression (&the_insn
, &s
);
2344 CHECK_FIELD (num
, 7, 0, 0);
2345 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2347 /* Handle a 20 bit SOP field for spop0. */
2349 num
= pa_get_absolute_expression (&the_insn
, &s
);
2351 CHECK_FIELD (num
, 1048575, 0, 0);
2352 num
= (num
& 0x1f) | ((num
& 0x000fffe0) << 6);
2353 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2355 /* Handle a 15bit SOP field for spop1. */
2357 num
= pa_get_absolute_expression (&the_insn
, &s
);
2359 CHECK_FIELD (num
, 32767, 0, 0);
2360 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 11);
2362 /* Handle a 10bit SOP field for spop3. */
2364 num
= pa_get_absolute_expression (&the_insn
, &s
);
2366 CHECK_FIELD (num
, 1023, 0, 0);
2367 num
= (num
& 0x1f) | ((num
& 0x000003e0) << 6);
2368 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2370 /* Handle a 15 bit SOP field for spop2. */
2372 num
= pa_get_absolute_expression (&the_insn
, &s
);
2374 CHECK_FIELD (num
, 32767, 0, 0);
2375 num
= (num
& 0x1f) | ((num
& 0x00007fe0) << 6);
2376 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2378 /* Handle a 3-bit co-processor ID field. */
2381 as_bad (_("Invalid COPR identifier"));
2382 num
= pa_get_absolute_expression (&the_insn
, &s
);
2384 CHECK_FIELD (num
, 7, 0, 0);
2385 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 6);
2387 /* Handle a 22bit SOP field for copr. */
2389 num
= pa_get_absolute_expression (&the_insn
, &s
);
2391 CHECK_FIELD (num
, 4194303, 0, 0);
2392 num
= (num
& 0x1f) | ((num
& 0x003fffe0) << 4);
2393 INSERT_FIELD_AND_CONTINUE (opcode
, num
, 0);
2396 /* Handle a source FP operand format completer. */
2398 flag
= pa_parse_fp_format (&s
);
2399 the_insn
.fpof1
= flag
;
2400 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 11);
2402 /* Handle a destination FP operand format completer. */
2404 /* pa_parse_format needs the ',' prefix. */
2406 flag
= pa_parse_fp_format (&s
);
2407 the_insn
.fpof2
= flag
;
2408 INSERT_FIELD_AND_CONTINUE (opcode
, flag
, 13);
2410 /* Handle FP compare conditions. */
2412 cond
= pa_parse_fp_cmp_cond (&s
);
2413 INSERT_FIELD_AND_CONTINUE (opcode
, cond
, 0);
2415 /* Handle L/R register halves like 't'. */
2418 struct pa_11_fp_reg_struct result
;
2420 pa_parse_number (&s
, &result
);
2421 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2422 opcode
|= result
.number_part
;
2424 /* 0x30 opcodes are FP arithmetic operation opcodes
2425 and need to be turned into 0x38 opcodes. This
2426 is not necessary for loads/stores. */
2427 if (need_pa11_opcode (&the_insn
, &result
)
2428 && ((opcode
& 0xfc000000) == 0x30000000))
2431 INSERT_FIELD_AND_CONTINUE (opcode
, result
.l_r_select
& 1, 6);
2434 /* Handle L/R register halves like 'b'. */
2437 struct pa_11_fp_reg_struct result
;
2439 pa_parse_number (&s
, &result
);
2440 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2441 opcode
|= result
.number_part
<< 21;
2442 if (need_pa11_opcode (&the_insn
, &result
))
2444 opcode
|= (result
.l_r_select
& 1) << 7;
2450 /* Handle L/R register halves like 'b'. */
2453 struct pa_11_fp_reg_struct result
;
2456 pa_parse_number (&s
, &result
);
2457 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2458 opcode
|= (result
.number_part
& 0x1c) << 11;
2459 opcode
|= (result
.number_part
& 0x3) << 9;
2460 opcode
|= (result
.l_r_select
& 1) << 8;
2464 /* Handle L/R register halves like 'x'. */
2467 struct pa_11_fp_reg_struct result
;
2469 pa_parse_number (&s
, &result
);
2470 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2471 opcode
|= (result
.number_part
& 0x1f) << 16;
2472 if (need_pa11_opcode (&the_insn
, &result
))
2474 opcode
|= (result
.l_r_select
& 1) << 1;
2479 /* Handle L/R register halves like 'x'. */
2482 struct pa_11_fp_reg_struct result
;
2484 pa_parse_number (&s
, &result
);
2485 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2486 opcode
|= (result
.number_part
& 0x1f) << 16;
2487 if (need_pa11_opcode (&the_insn
, &result
))
2489 opcode
|= (result
.l_r_select
& 1) << 12;
2495 /* Handle a 5 bit register field at 10. */
2498 struct pa_11_fp_reg_struct result
;
2500 pa_parse_number (&s
, &result
);
2501 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2502 if (the_insn
.fpof1
== SGL
)
2504 if (result
.number_part
< 16)
2506 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2510 result
.number_part
&= 0xF;
2511 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2513 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 21);
2516 /* Handle a 5 bit register field at 15. */
2519 struct pa_11_fp_reg_struct result
;
2521 pa_parse_number (&s
, &result
);
2522 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2523 if (the_insn
.fpof1
== SGL
)
2525 if (result
.number_part
< 16)
2527 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2530 result
.number_part
&= 0xF;
2531 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2533 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 16);
2536 /* Handle a 5 bit register field at 31. */
2539 struct pa_11_fp_reg_struct result
;
2541 pa_parse_number (&s
, &result
);
2542 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2543 if (the_insn
.fpof1
== SGL
)
2545 if (result
.number_part
< 16)
2547 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2550 result
.number_part
&= 0xF;
2551 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2553 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 0);
2556 /* Handle a 5 bit register field at 20. */
2559 struct pa_11_fp_reg_struct result
;
2561 pa_parse_number (&s
, &result
);
2562 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2563 if (the_insn
.fpof1
== SGL
)
2565 if (result
.number_part
< 16)
2567 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2570 result
.number_part
&= 0xF;
2571 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2573 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 11);
2576 /* Handle a 5 bit register field at 25. */
2579 struct pa_11_fp_reg_struct result
;
2581 pa_parse_number (&s
, &result
);
2582 CHECK_FIELD (result
.number_part
, 31, 0, 0);
2583 if (the_insn
.fpof1
== SGL
)
2585 if (result
.number_part
< 16)
2587 as_bad (_("Invalid register for single precision fmpyadd or fmpysub"));
2590 result
.number_part
&= 0xF;
2591 result
.number_part
|= (result
.l_r_select
& 1) << 4;
2593 INSERT_FIELD_AND_CONTINUE (opcode
, result
.number_part
, 6);
2596 /* Handle a floating point operand format at 26.
2597 Only allows single and double precision. */
2599 flag
= pa_parse_fp_format (&s
);
2605 the_insn
.fpof1
= flag
;
2611 as_bad (_("Invalid Floating Point Operand Format."));
2622 /* Check if the args matched. */
2625 if (&insn
[1] - pa_opcodes
< (int) NUMOPCODES
2626 && !strcmp (insn
->name
, insn
[1].name
))
2634 as_bad (_("Invalid operands %s"), error_message
);
2641 the_insn
.opcode
= opcode
;
2644 /* Turn a string in input_line_pointer into a floating point constant of type
2645 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
2646 emitted is stored in *sizeP . An error message or NULL is returned. */
2648 #define MAX_LITTLENUMS 6
2651 md_atof (type
, litP
, sizeP
)
2657 LITTLENUM_TYPE words
[MAX_LITTLENUMS
];
2658 LITTLENUM_TYPE
*wordP
;
2690 return _("Bad call to MD_ATOF()");
2692 t
= atof_ieee (input_line_pointer
, type
, words
);
2694 input_line_pointer
= t
;
2695 *sizeP
= prec
* sizeof (LITTLENUM_TYPE
);
2696 for (wordP
= words
; prec
--;)
2698 md_number_to_chars (litP
, (valueT
) (*wordP
++), sizeof (LITTLENUM_TYPE
));
2699 litP
+= sizeof (LITTLENUM_TYPE
);
2704 /* Write out big-endian. */
2707 md_number_to_chars (buf
, val
, n
)
2712 number_to_chars_bigendian (buf
, val
, n
);
2715 /* Translate internal representation of relocation info to BFD target
2719 tc_gen_reloc (section
, fixp
)
2724 struct hppa_fix_struct
*hppa_fixp
;
2725 bfd_reloc_code_real_type code
;
2726 static arelent
*no_relocs
= NULL
;
2728 bfd_reloc_code_real_type
**codes
;
2732 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
2733 if (fixp
->fx_addsy
== 0)
2735 assert (hppa_fixp
!= 0);
2736 assert (section
!= 0);
2738 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
2740 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2741 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2742 codes
= (bfd_reloc_code_real_type
**) hppa_gen_reloc_type (stdoutput
,
2744 hppa_fixp
->fx_r_format
,
2745 hppa_fixp
->fx_r_field
,
2746 fixp
->fx_subsy
!= NULL
,
2747 symbol_get_bfdsym (fixp
->fx_addsy
));
2752 for (n_relocs
= 0; codes
[n_relocs
]; n_relocs
++)
2755 relocs
= (arelent
**) xmalloc (sizeof (arelent
*) * n_relocs
+ 1);
2756 reloc
= (arelent
*) xmalloc (sizeof (arelent
) * n_relocs
);
2757 for (i
= 0; i
< n_relocs
; i
++)
2758 relocs
[i
] = &reloc
[i
];
2760 relocs
[n_relocs
] = NULL
;
2763 switch (fixp
->fx_r_type
)
2766 assert (n_relocs
== 1);
2770 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2771 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2772 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2773 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2774 reloc
->addend
= 0; /* default */
2776 assert (reloc
->howto
&& code
== reloc
->howto
->type
);
2778 /* Now, do any processing that is dependent on the relocation type. */
2781 case R_PARISC_DLTREL21L
:
2782 case R_PARISC_DLTREL14R
:
2783 case R_PARISC_DLTREL14F
:
2784 case R_PARISC_PLABEL32
:
2785 case R_PARISC_PLABEL21L
:
2786 case R_PARISC_PLABEL14R
:
2787 /* For plabel relocations, the addend of the
2788 relocation should be either 0 (no static link) or 2
2789 (static link required).
2791 FIXME: We always assume no static link!
2793 We also slam a zero addend into the DLT relative relocs;
2794 it doesn't make a lot of sense to use any addend since
2795 it gets you a different (eg unknown) DLT entry. */
2799 case R_PARISC_PCREL21L
:
2800 case R_PARISC_PCREL17R
:
2801 case R_PARISC_PCREL17F
:
2802 case R_PARISC_PCREL17C
:
2803 case R_PARISC_PCREL14R
:
2804 case R_PARISC_PCREL14F
:
2805 /* The constant is stored in the instruction. */
2806 reloc
->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
2809 reloc
->addend
= fixp
->fx_offset
;
2816 /* Walk over reach relocation returned by the BFD backend. */
2817 for (i
= 0; i
< n_relocs
; i
++)
2821 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2822 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2823 relocs
[i
]->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
2824 relocs
[i
]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2829 /* The only time we ever use a R_COMP2 fixup is for the difference
2830 of two symbols. With that in mind we fill in all four
2831 relocs now and break out of the loop. */
2833 relocs
[0]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
2834 relocs
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[0]);
2835 relocs
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2836 relocs
[0]->addend
= 0;
2837 relocs
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2838 *relocs
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2839 relocs
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[1]);
2840 relocs
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2841 relocs
[1]->addend
= 0;
2842 relocs
[2]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2843 *relocs
[2]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
2844 relocs
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[2]);
2845 relocs
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2846 relocs
[2]->addend
= 0;
2847 relocs
[3]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
2848 relocs
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[3]);
2849 relocs
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2850 relocs
[3]->addend
= 0;
2851 relocs
[4]->sym_ptr_ptr
= (asymbol
**) &(bfd_abs_symbol
);
2852 relocs
[4]->howto
= bfd_reloc_type_lookup (stdoutput
, *codes
[4]);
2853 relocs
[4]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2854 relocs
[4]->addend
= 0;
2858 relocs
[i
]->addend
= HPPA_R_ADDEND (hppa_fixp
->fx_arg_reloc
, 0);
2864 /* For plabel relocations, the addend of the
2865 relocation should be either 0 (no static link) or 2
2866 (static link required).
2868 FIXME: We always assume no static link!
2870 We also slam a zero addend into the DLT relative relocs;
2871 it doesn't make a lot of sense to use any addend since
2872 it gets you a different (eg unknown) DLT entry. */
2873 relocs
[i
]->addend
= 0;
2888 /* There is no symbol or addend associated with these fixups. */
2889 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2890 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
2891 relocs
[i
]->addend
= 0;
2897 /* There is no symbol associated with these fixups. */
2898 relocs
[i
]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2899 *relocs
[i
]->sym_ptr_ptr
= symbol_get_bfdsym (dummy_symbol
);
2900 relocs
[i
]->addend
= fixp
->fx_offset
;
2904 relocs
[i
]->addend
= fixp
->fx_offset
;
2914 /* Process any machine dependent frag types. */
2917 md_convert_frag (abfd
, sec
, fragP
)
2919 register asection
*sec
;
2920 register fragS
*fragP
;
2922 unsigned int address
;
2924 if (fragP
->fr_type
== rs_machine_dependent
)
2926 switch ((int) fragP
->fr_subtype
)
2929 fragP
->fr_type
= rs_fill
;
2930 know (fragP
->fr_var
== 1);
2931 know (fragP
->fr_next
);
2932 address
= fragP
->fr_address
+ fragP
->fr_fix
;
2933 if (address
% fragP
->fr_offset
)
2936 fragP
->fr_next
->fr_address
2941 fragP
->fr_offset
= 0;
2947 /* Round up a section size to the appropriate boundary. */
2950 md_section_align (segment
, size
)
2954 int align
= bfd_get_section_alignment (stdoutput
, segment
);
2955 int align2
= (1 << align
) - 1;
2957 return (size
+ align2
) & ~align2
;
2960 /* Return the approximate size of a frag before relaxation has occurred. */
2962 md_estimate_size_before_relax (fragP
, segment
)
2963 register fragS
*fragP
;
2970 while ((fragP
->fr_fix
+ size
) % fragP
->fr_offset
)
2976 CONST
char *md_shortopts
= "";
2977 struct option md_longopts
[] = {
2978 {NULL
, no_argument
, NULL
, 0}
2980 size_t md_longopts_size
= sizeof(md_longopts
);
2983 md_parse_option (c
, arg
)
2991 md_show_usage (stream
)
2996 /* We have no need to default values of symbols. */
2999 md_undefined_symbol (name
)
3005 /* Apply a fixup to an instruction. */
3008 md_apply_fix (fixP
, valp
)
3012 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
3013 struct hppa_fix_struct
*hppa_fixP
;
3014 long new_val
, result
= 0;
3015 unsigned int w1
, w2
, w
, resulti
;
3017 hppa_fixP
= (struct hppa_fix_struct
*) fixP
->tc_fix_data
;
3018 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
3019 never be "applied" (they are just markers). Likewise for
3020 R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */
3022 if (fixP
->fx_r_type
== R_HPPA_ENTRY
3023 || fixP
->fx_r_type
== R_HPPA_EXIT
3024 || fixP
->fx_r_type
== R_HPPA_BEGIN_BRTAB
3025 || fixP
->fx_r_type
== R_HPPA_END_BRTAB
3026 || fixP
->fx_r_type
== R_HPPA_BEGIN_TRY
)
3029 /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY
3030 fixups are considered not adjustable, which in turn causes
3031 adjust_reloc_syms to not set fx_offset. Ugh. */
3032 if (fixP
->fx_r_type
== R_HPPA_END_TRY
)
3034 fixP
->fx_offset
= *valp
;
3039 /* There should have been an HPPA specific fixup associated
3040 with the GAS fixup. */
3043 unsigned long buf_wd
= bfd_get_32 (stdoutput
, buf
);
3044 unsigned char fmt
= bfd_hppa_insn2fmt (buf_wd
);
3046 /* If there is a symbol associated with this fixup, then it's something
3047 which will need a SOM relocation (except for some PC-relative relocs).
3048 In such cases we should treat the "val" or "addend" as zero since it
3049 will be added in as needed from fx_offset in tc_gen_reloc. */
3050 if ((fixP
->fx_addsy
!= NULL
3051 || fixP
->fx_r_type
== R_HPPA_NONE
)
3056 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3058 /* These field selectors imply that we do not want an addend. */
3059 else if (hppa_fixP
->fx_r_field
== e_psel
3060 || hppa_fixP
->fx_r_field
== e_rpsel
3061 || hppa_fixP
->fx_r_field
== e_lpsel
3062 || hppa_fixP
->fx_r_field
== e_tsel
3063 || hppa_fixP
->fx_r_field
== e_rtsel
3064 || hppa_fixP
->fx_r_field
== e_ltsel
)
3065 new_val
= ((fmt
== 12 || fmt
== 17 || fmt
== 22) ? 8 : 0);
3066 /* This is truely disgusting. The machine independent code blindly
3067 adds in the value of the symbol being relocated against. Damn! */
3069 && fixP
->fx_addsy
!= NULL
3070 && S_GET_SEGMENT (fixP
->fx_addsy
) != bfd_com_section_ptr
)
3071 new_val
= hppa_field_adjust (*valp
- S_GET_VALUE (fixP
->fx_addsy
),
3072 0, hppa_fixP
->fx_r_field
);
3075 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3077 /* Handle pc-relative exceptions from above. */
3078 #define arg_reloc_stub_needed(CALLER, CALLEE) \
3079 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
3080 if ((fmt
== 12 || fmt
== 17 || fmt
== 22)
3083 && !arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
3084 symbol_get_bfdsym (fixP
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
3085 hppa_fixP
->fx_arg_reloc
)
3086 && (((int)(*valp
) > -262144 && (int)(*valp
) < 262143) && fmt
!= 22)
3087 && S_GET_SEGMENT (fixP
->fx_addsy
) == hppa_fixP
->segment
3089 && S_GET_SEGMENT (fixP
->fx_subsy
) != hppa_fixP
->segment
))
3091 new_val
= hppa_field_adjust (*valp
, 0, hppa_fixP
->fx_r_field
);
3092 #undef arg_reloc_stub_needed
3096 /* Handle all opcodes with the 'j' operand type. */
3098 CHECK_FIELD (new_val
, 8191, -8192, 0);
3100 /* Mask off 14 bits to be changed. */
3101 bfd_put_32 (stdoutput
,
3102 bfd_get_32 (stdoutput
, buf
) & 0xffffc000,
3104 low_sign_unext (new_val
, 14, &resulti
);
3108 /* Handle all opcodes with the 'k' operand type. */
3110 CHECK_FIELD (new_val
, 2097152, 0, 0);
3112 /* Mask off 21 bits to be changed. */
3113 bfd_put_32 (stdoutput
,
3114 bfd_get_32 (stdoutput
, buf
) & 0xffe00000,
3116 dis_assemble_21 (new_val
, &resulti
);
3120 /* Handle all the opcodes with the 'i' operand type. */
3122 CHECK_FIELD (new_val
, 1023, -1023, 0);
3124 /* Mask off 11 bits to be changed. */
3125 bfd_put_32 (stdoutput
,
3126 bfd_get_32 (stdoutput
, buf
) & 0xffff800,
3128 low_sign_unext (new_val
, 11, &resulti
);
3132 /* Handle all the opcodes with the 'w' operand type. */
3134 CHECK_FIELD (new_val
, 8199, -8184, 0);
3136 /* Mask off 11 bits to be changed. */
3137 sign_unext ((new_val
- 8) >> 2, 12, &resulti
);
3138 bfd_put_32 (stdoutput
,
3139 bfd_get_32 (stdoutput
, buf
) & 0xffffe002,
3142 dis_assemble_12 (resulti
, &w1
, &w
);
3143 result
= ((w1
<< 2) | w
);
3146 /* Handle some of the opcodes with the 'W' operand type. */
3149 int distance
= *valp
;
3151 CHECK_FIELD (new_val
, 262143, -262144, 0);
3153 /* If this is an absolute branch (ie no link) with an out of
3154 range target, then we want to complain. */
3155 if (fixP
->fx_r_type
== R_HPPA_PCREL_CALL
3156 && (distance
> 262143 || distance
< -262144)
3157 && (bfd_get_32 (stdoutput
, buf
) & 0xffe00000) == 0xe8000000)
3158 CHECK_FIELD (distance
, 262143, -262144, 0);
3160 /* Mask off 17 bits to be changed. */
3161 bfd_put_32 (stdoutput
,
3162 bfd_get_32 (stdoutput
, buf
) & 0xffe0e002,
3164 sign_unext ((new_val
- 8) >> 2, 17, &resulti
);
3165 dis_assemble_17 (resulti
, &w1
, &w2
, &w
);
3166 result
= ((w2
<< 2) | (w1
<< 16) | w
);
3172 bfd_put_32 (stdoutput
, new_val
, buf
);
3176 as_bad (_("Unknown relocation encountered in md_apply_fix."));
3180 /* Insert the relocation. */
3181 bfd_put_32 (stdoutput
, bfd_get_32 (stdoutput
, buf
) | result
, buf
);
3186 printf (_("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n"),
3187 (unsigned int) fixP
, fixP
->fx_r_type
);
3192 /* Exactly what point is a PC-relative offset relative TO?
3193 On the PA, they're relative to the address of the offset. */
3196 md_pcrel_from (fixP
)
3199 return fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
3202 /* Return nonzero if the input line pointer is at the end of
3206 is_end_of_statement ()
3208 return ((*input_line_pointer
== '\n')
3209 || (*input_line_pointer
== ';')
3210 || (*input_line_pointer
== '!'));
3213 /* Read a number from S. The number might come in one of many forms,
3214 the most common will be a hex or decimal constant, but it could be
3215 a pre-defined register (Yuk!), or an absolute symbol.
3217 Return a number or -1 for failure.
3219 When parsing PA-89 FP register numbers RESULT will be
3220 the address of a structure to return information about
3221 L/R half of FP registers, store results there as appropriate.
3223 pa_parse_number can not handle negative constants and will fail
3224 horribly if it is passed such a constant. */
3227 pa_parse_number (s
, result
)
3229 struct pa_11_fp_reg_struct
*result
;
3238 /* Skip whitespace before the number. */
3239 while (*p
== ' ' || *p
== '\t')
3242 /* Store info in RESULT if requested by caller. */
3245 result
->number_part
= -1;
3246 result
->l_r_select
= -1;
3252 /* Looks like a number. */
3255 if (*p
== '0' && (*(p
+ 1) == 'x' || *(p
+ 1) == 'X'))
3257 /* The number is specified in hex. */
3259 while (isdigit (*p
) || ((*p
>= 'a') && (*p
<= 'f'))
3260 || ((*p
>= 'A') && (*p
<= 'F')))
3263 num
= num
* 16 + *p
- '0';
3264 else if (*p
>= 'a' && *p
<= 'f')
3265 num
= num
* 16 + *p
- 'a' + 10;
3267 num
= num
* 16 + *p
- 'A' + 10;
3273 /* The number is specified in decimal. */
3274 while (isdigit (*p
))
3276 num
= num
* 10 + *p
- '0';
3281 /* Store info in RESULT if requested by the caller. */
3284 result
->number_part
= num
;
3286 if (IS_R_SELECT (p
))
3288 result
->l_r_select
= 1;
3291 else if (IS_L_SELECT (p
))
3293 result
->l_r_select
= 0;
3297 result
->l_r_select
= 0;
3302 /* The number might be a predefined register. */
3307 /* Tege hack: Special case for general registers as the general
3308 code makes a binary search with case translation, and is VERY
3313 if (*p
== 'e' && *(p
+ 1) == 't'
3314 && (*(p
+ 2) == '0' || *(p
+ 2) == '1'))
3317 num
= *p
- '0' + 28;
3325 else if (!isdigit (*p
))
3328 as_bad (_("Undefined register: '%s'."), name
);
3334 num
= num
* 10 + *p
++ - '0';
3335 while (isdigit (*p
));
3340 /* Do a normal register search. */
3341 while (is_part_of_name (c
))
3347 status
= reg_name_search (name
);
3353 as_bad (_("Undefined register: '%s'."), name
);
3359 /* Store info in RESULT if requested by caller. */
3362 result
->number_part
= num
;
3363 if (IS_R_SELECT (p
- 1))
3364 result
->l_r_select
= 1;
3365 else if (IS_L_SELECT (p
- 1))
3366 result
->l_r_select
= 0;
3368 result
->l_r_select
= 0;
3373 /* And finally, it could be a symbol in the absolute section which
3374 is effectively a constant. */
3378 while (is_part_of_name (c
))
3384 if ((sym
= symbol_find (name
)) != NULL
)
3386 if (S_GET_SEGMENT (sym
) == &bfd_abs_section
)
3387 num
= S_GET_VALUE (sym
);
3391 as_bad (_("Non-absolute symbol: '%s'."), name
);
3397 /* There is where we'd come for an undefined symbol
3398 or for an empty string. For an empty string we
3399 will return zero. That's a concession made for
3400 compatability with the braindamaged HP assemblers. */
3406 as_bad (_("Undefined absolute constant: '%s'."), name
);
3412 /* Store info in RESULT if requested by caller. */
3415 result
->number_part
= num
;
3416 if (IS_R_SELECT (p
- 1))
3417 result
->l_r_select
= 1;
3418 else if (IS_L_SELECT (p
- 1))
3419 result
->l_r_select
= 0;
3421 result
->l_r_select
= 0;
3429 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
3431 /* Given NAME, find the register number associated with that name, return
3432 the integer value associated with the given name or -1 on failure. */
3435 reg_name_search (name
)
3438 int middle
, low
, high
;
3442 high
= REG_NAME_CNT
- 1;
3446 middle
= (low
+ high
) / 2;
3447 cmp
= strcasecmp (name
, pre_defined_registers
[middle
].name
);
3453 return pre_defined_registers
[middle
].value
;
3455 while (low
<= high
);
3461 /* Return nonzero if the given INSN and L/R information will require
3462 a new PA-1.1 opcode. */
3465 need_pa11_opcode (insn
, result
)
3467 struct pa_11_fp_reg_struct
*result
;
3469 if (result
->l_r_select
== 1 && !(insn
->fpof1
== DBL
&& insn
->fpof2
== DBL
))
3471 /* If this instruction is specific to a particular architecture,
3472 then set a new architecture. */
3473 if (bfd_get_mach (stdoutput
) < pa11
)
3475 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, pa11
))
3476 as_warn (_("could not update architecture and machine"));
3484 /* Parse a condition for a fcmp instruction. Return the numerical
3485 code associated with the condition. */
3488 pa_parse_fp_cmp_cond (s
)
3495 for (i
= 0; i
< 32; i
++)
3497 if (strncasecmp (*s
, fp_cond_map
[i
].string
,
3498 strlen (fp_cond_map
[i
].string
)) == 0)
3500 cond
= fp_cond_map
[i
].cond
;
3501 *s
+= strlen (fp_cond_map
[i
].string
);
3502 /* If not a complete match, back up the input string and
3504 if (**s
!= ' ' && **s
!= '\t')
3506 *s
-= strlen (fp_cond_map
[i
].string
);
3509 while (**s
== ' ' || **s
== '\t')
3515 as_bad (_("Invalid FP Compare Condition: %s"), *s
);
3517 /* Advance over the bogus completer. */
3518 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3525 /* Parse an FP operand format completer returning the completer
3528 static fp_operand_format
3529 pa_parse_fp_format (s
)
3538 if (strncasecmp (*s
, "sgl", 3) == 0)
3543 else if (strncasecmp (*s
, "dbl", 3) == 0)
3548 else if (strncasecmp (*s
, "quad", 4) == 0)
3555 format
= ILLEGAL_FMT
;
3556 as_bad (_("Invalid FP Operand Format: %3s"), *s
);
3563 /* Convert from a selector string into a selector type. */
3566 pa_chk_field_selector (str
)
3569 int middle
, low
, high
;
3573 /* Read past any whitespace. */
3574 /* FIXME: should we read past newlines and formfeeds??? */
3575 while (**str
== ' ' || **str
== '\t' || **str
== '\n' || **str
== '\f')
3578 if ((*str
)[1] == '\'' || (*str
)[1] == '%')
3579 name
[0] = tolower ((*str
)[0]),
3581 else if ((*str
)[2] == '\'' || (*str
)[2] == '%')
3582 name
[0] = tolower ((*str
)[0]),
3583 name
[1] = tolower ((*str
)[1]),
3586 else if ((*str
)[3] == '\'' || (*str
)[3] == '%')
3587 name
[0] = tolower ((*str
)[0]),
3588 name
[1] = tolower ((*str
)[1]),
3589 name
[2] = tolower ((*str
)[2]),
3596 high
= sizeof (selector_table
) / sizeof (struct selector_entry
) - 1;
3600 middle
= (low
+ high
) / 2;
3601 cmp
= strcmp (name
, selector_table
[middle
].prefix
);
3608 *str
+= strlen (name
) + 1;
3610 if (selector_table
[middle
].field_selector
== e_nsel
)
3613 return selector_table
[middle
].field_selector
;
3616 while (low
<= high
);
3621 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
3624 get_expression (str
)
3630 save_in
= input_line_pointer
;
3631 input_line_pointer
= str
;
3632 seg
= expression (&the_insn
.exp
);
3633 if (!(seg
== absolute_section
3634 || seg
== undefined_section
3635 || SEG_NORMAL (seg
)))
3637 as_warn (_("Bad segment in expression."));
3638 expr_end
= input_line_pointer
;
3639 input_line_pointer
= save_in
;
3642 expr_end
= input_line_pointer
;
3643 input_line_pointer
= save_in
;
3647 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
3649 pa_get_absolute_expression (insn
, strp
)
3655 insn
->field_selector
= pa_chk_field_selector (strp
);
3656 save_in
= input_line_pointer
;
3657 input_line_pointer
= *strp
;
3658 expression (&insn
->exp
);
3659 /* This is not perfect, but is a huge improvement over doing nothing.
3661 The PA assembly syntax is ambigious in a variety of ways. Consider
3662 this string "4 %r5" Is that the number 4 followed by the register
3663 r5, or is that 4 MOD 5?
3665 If we get a modulo expresion When looking for an absolute, we try
3666 again cutting off the input string at the first whitespace character. */
3667 if (insn
->exp
.X_op
== O_modulus
)
3672 input_line_pointer
= *strp
;
3674 while (*s
!= ',' && *s
!= ' ' && *s
!= '\t')
3680 retval
= pa_get_absolute_expression (insn
, strp
);
3682 input_line_pointer
= save_in
;
3684 return evaluate_absolute (insn
);
3686 if (insn
->exp
.X_op
!= O_constant
)
3688 as_bad (_("Bad segment (should be absolute)."));
3689 expr_end
= input_line_pointer
;
3690 input_line_pointer
= save_in
;
3693 expr_end
= input_line_pointer
;
3694 input_line_pointer
= save_in
;
3695 return evaluate_absolute (insn
);
3698 /* Evaluate an absolute expression EXP which may be modified by
3699 the selector FIELD_SELECTOR. Return the value of the expression. */
3701 evaluate_absolute (insn
)
3706 int field_selector
= insn
->field_selector
;
3709 value
= exp
.X_add_number
;
3711 switch (field_selector
)
3717 /* If bit 21 is on then add 0x800 and arithmetic shift right 11 bits. */
3719 if (value
& 0x00000400)
3721 value
= (value
& 0xfffff800) >> 11;
3724 /* Sign extend from bit 21. */
3726 if (value
& 0x00000400)
3727 value
|= 0xfffff800;
3732 /* Arithmetic shift right 11 bits. */
3734 value
= (value
& 0xfffff800) >> 11;
3737 /* Set bits 0-20 to zero. */
3739 value
= value
& 0x7ff;
3742 /* Add 0x800 and arithmetic shift right 11 bits. */
3745 value
= (value
& 0xfffff800) >> 11;
3748 /* Set bitgs 0-21 to one. */
3750 value
|= 0xfffff800;
3753 #define RSEL_ROUND(c) (((c) + 0x1000) & ~0x1fff)
3755 value
= (RSEL_ROUND (value
) & 0x7ff) + (value
- RSEL_ROUND (value
));
3759 value
= (RSEL_ROUND (value
) >> 11) & 0x1fffff;
3764 BAD_CASE (field_selector
);
3770 /* Given an argument location specification return the associated
3771 argument location number. */
3774 pa_build_arg_reloc (type_name
)
3778 if (strncasecmp (type_name
, "no", 2) == 0)
3780 if (strncasecmp (type_name
, "gr", 2) == 0)
3782 else if (strncasecmp (type_name
, "fr", 2) == 0)
3784 else if (strncasecmp (type_name
, "fu", 2) == 0)
3787 as_bad (_("Invalid argument location: %s\n"), type_name
);
3792 /* Encode and return an argument relocation specification for
3793 the given register in the location specified by arg_reloc. */
3796 pa_align_arg_reloc (reg
, arg_reloc
)
3798 unsigned int arg_reloc
;
3800 unsigned int new_reloc
;
3802 new_reloc
= arg_reloc
;
3818 as_bad (_("Invalid argument description: %d"), reg
);
3824 /* Parse a PA nullification completer (,n). Return nonzero if the
3825 completer was found; return zero if no completer was found. */
3837 if (strncasecmp (*s
, "n", 1) == 0)
3841 as_bad (_("Invalid Nullification: (%c)"), **s
);
3850 /* Parse a non-negated compare/subtract completer returning the
3851 number (for encoding in instrutions) of the given completer.
3853 ISBRANCH specifies whether or not this is parsing a condition
3854 completer for a branch (vs a nullification completer for a
3855 computational instruction. */
3858 pa_parse_nonneg_cmpsub_cmpltr (s
, isbranch
)
3863 char *name
= *s
+ 1;
3872 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3878 if (strcmp (name
, "=") == 0)
3882 else if (strcmp (name
, "<") == 0)
3886 else if (strcmp (name
, "<=") == 0)
3890 else if (strcmp (name
, "<<") == 0)
3894 else if (strcmp (name
, "<<=") == 0)
3898 else if (strcasecmp (name
, "sv") == 0)
3902 else if (strcasecmp (name
, "od") == 0)
3906 /* If we have something like addb,n then there is no condition
3908 else if (strcasecmp (name
, "n") == 0 && isbranch
)
3920 /* Reset pointers if this was really a ,n for a branch instruction. */
3928 /* Parse a negated compare/subtract completer returning the
3929 number (for encoding in instrutions) of the given completer.
3931 ISBRANCH specifies whether or not this is parsing a condition
3932 completer for a branch (vs a nullification completer for a
3933 computational instruction. */
3936 pa_parse_neg_cmpsub_cmpltr (s
, isbranch
)
3941 char *name
= *s
+ 1;
3950 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
3956 if (strcasecmp (name
, "tr") == 0)
3960 else if (strcmp (name
, "<>") == 0)
3964 else if (strcmp (name
, ">=") == 0)
3968 else if (strcmp (name
, ">") == 0)
3972 else if (strcmp (name
, ">>=") == 0)
3976 else if (strcmp (name
, ">>") == 0)
3980 else if (strcasecmp (name
, "nsv") == 0)
3984 else if (strcasecmp (name
, "ev") == 0)
3988 /* If we have something like addb,n then there is no condition
3990 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4002 /* Reset pointers if this was really a ,n for a branch instruction. */
4011 /* Parse a non-negated addition completer returning the number
4012 (for encoding in instrutions) of the given completer.
4014 ISBRANCH specifies whether or not this is parsing a condition
4015 completer for a branch (vs a nullification completer for a
4016 computational instruction. */
4019 pa_parse_nonneg_add_cmpltr (s
, isbranch
)
4024 char *name
= *s
+ 1;
4032 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4036 if (strcmp (name
, "=") == 0)
4040 else if (strcmp (name
, "<") == 0)
4044 else if (strcmp (name
, "<=") == 0)
4048 else if (strcasecmp (name
, "nuv") == 0)
4052 else if (strcasecmp (name
, "znv") == 0)
4056 else if (strcasecmp (name
, "sv") == 0)
4060 else if (strcasecmp (name
, "od") == 0)
4064 /* If we have something like addb,n then there is no condition
4066 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4077 /* Reset pointers if this was really a ,n for a branch instruction. */
4078 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4084 /* Parse a negated addition completer returning the number
4085 (for encoding in instrutions) of the given completer.
4087 ISBRANCH specifies whether or not this is parsing a condition
4088 completer for a branch (vs a nullification completer for a
4089 computational instruction). */
4092 pa_parse_neg_add_cmpltr (s
, isbranch
)
4097 char *name
= *s
+ 1;
4105 while (**s
!= ',' && **s
!= ' ' && **s
!= '\t')
4109 if (strcasecmp (name
, "tr") == 0)
4113 else if (strcmp (name
, "<>") == 0)
4117 else if (strcmp (name
, ">=") == 0)
4121 else if (strcmp (name
, ">") == 0)
4125 else if (strcasecmp (name
, "uv") == 0)
4129 else if (strcasecmp (name
, "vnz") == 0)
4133 else if (strcasecmp (name
, "nsv") == 0)
4137 else if (strcasecmp (name
, "ev") == 0)
4141 /* If we have something like addb,n then there is no condition
4143 else if (strcasecmp (name
, "n") == 0 && isbranch
)
4154 /* Reset pointers if this was really a ,n for a branch instruction. */
4155 if (cmpltr
== 0 && *name
== 'n' && isbranch
)
4161 /* Handle an alignment directive. Special so that we can update the
4162 alignment of the subspace if necessary. */
4166 /* We must have a valid space and subspace. */
4167 pa_check_current_space_and_subspace ();
4169 /* Let the generic gas code do most of the work. */
4170 s_align_bytes (bytes
);
4172 /* If bytes is a power of 2, then update the current subspace's
4173 alignment if necessary. */
4174 if (log2 (bytes
) != -1)
4175 record_alignment (current_subspace
->ssd_seg
, log2 (bytes
));
4178 /* Handle a .BLOCK type pseudo-op. */
4186 unsigned int temp_size
;
4189 /* We must have a valid space and subspace. */
4190 pa_check_current_space_and_subspace ();
4192 temp_size
= get_absolute_expression ();
4194 /* Always fill with zeros, that's what the HP assembler does. */
4197 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
,
4198 (relax_substateT
) 0, (symbolS
*) 0, (offsetT
) 1, NULL
);
4199 memset (p
, 0, temp_size
);
4201 /* Convert 2 bytes at a time. */
4203 for (i
= 0; i
< temp_size
; i
+= 2)
4205 md_number_to_chars (p
+ i
,
4207 (int) ((temp_size
- i
) > 2 ? 2 : (temp_size
- i
)));
4210 pa_undefine_label ();
4211 demand_empty_rest_of_line ();
4214 /* Handle a .begin_brtab and .end_brtab pseudo-op. */
4222 /* The BRTAB relocations are only availble in SOM (to denote
4223 the beginning and end of branch tables). */
4224 char *where
= frag_more (0);
4226 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4227 NULL
, (offsetT
) 0, NULL
,
4228 0, begin
? R_HPPA_BEGIN_BRTAB
: R_HPPA_END_BRTAB
,
4229 e_fsel
, 0, 0, NULL
);
4232 demand_empty_rest_of_line ();
4235 /* Handle a .begin_try and .end_try pseudo-op. */
4243 char *where
= frag_more (0);
4248 /* The TRY relocations are only availble in SOM (to denote
4249 the beginning and end of exception handling regions). */
4251 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4252 NULL
, (offsetT
) 0, begin
? NULL
: &exp
,
4253 0, begin
? R_HPPA_BEGIN_TRY
: R_HPPA_END_TRY
,
4254 e_fsel
, 0, 0, NULL
);
4257 demand_empty_rest_of_line ();
4260 /* Handle a .CALL pseudo-op. This involves storing away information
4261 about where arguments are to be found so the linker can detect
4262 (and correct) argument location mismatches between caller and callee. */
4268 /* We must have a valid space and subspace. */
4269 pa_check_current_space_and_subspace ();
4271 pa_call_args (&last_call_desc
);
4272 demand_empty_rest_of_line ();
4275 /* Do the dirty work of building a call descriptor which describes
4276 where the caller placed arguments to a function call. */
4279 pa_call_args (call_desc
)
4280 struct call_desc
*call_desc
;
4283 unsigned int temp
, arg_reloc
;
4285 while (!is_end_of_statement ())
4287 name
= input_line_pointer
;
4288 c
= get_symbol_end ();
4289 /* Process a source argument. */
4290 if ((strncasecmp (name
, "argw", 4) == 0))
4292 temp
= atoi (name
+ 4);
4293 p
= input_line_pointer
;
4295 input_line_pointer
++;
4296 name
= input_line_pointer
;
4297 c
= get_symbol_end ();
4298 arg_reloc
= pa_build_arg_reloc (name
);
4299 call_desc
->arg_reloc
|= pa_align_arg_reloc (temp
, arg_reloc
);
4301 /* Process a return value. */
4302 else if ((strncasecmp (name
, "rtnval", 6) == 0))
4304 p
= input_line_pointer
;
4306 input_line_pointer
++;
4307 name
= input_line_pointer
;
4308 c
= get_symbol_end ();
4309 arg_reloc
= pa_build_arg_reloc (name
);
4310 call_desc
->arg_reloc
|= (arg_reloc
& 0x3);
4314 as_bad (_("Invalid .CALL argument: %s"), name
);
4316 p
= input_line_pointer
;
4318 if (!is_end_of_statement ())
4319 input_line_pointer
++;
4323 /* Return TRUE if FRAG1 and FRAG2 are the same. */
4326 is_same_frag (frag1
, frag2
)
4333 else if (frag2
== NULL
)
4335 else if (frag1
== frag2
)
4337 else if (frag2
->fr_type
== rs_fill
&& frag2
->fr_fix
== 0)
4338 return (is_same_frag (frag1
, frag2
->fr_next
));
4344 /* Build an entry in the UNWIND subspace from the given function
4345 attributes in CALL_INFO. This is not needed for SOM as using
4346 R_ENTRY and R_EXIT relocations allow the linker to handle building
4347 of the unwind spaces. */
4350 pa_build_unwind_subspace (call_info
)
4351 struct call_info
*call_info
;
4354 asection
*seg
, *save_seg
;
4355 subsegT subseg
, save_subseg
;
4359 /* Get into the right seg/subseg. This may involve creating
4360 the seg the first time through. Make sure to have the
4361 old seg/subseg so that we can reset things when we are done. */
4362 subseg
= SUBSEG_UNWIND
;
4363 seg
= bfd_get_section_by_name (stdoutput
, UNWIND_SECTION_NAME
);
4364 if (seg
== ASEC_NULL
)
4366 seg
= bfd_make_section_old_way (stdoutput
, UNWIND_SECTION_NAME
);
4367 bfd_set_section_flags (stdoutput
, seg
,
4368 SEC_READONLY
| SEC_HAS_CONTENTS
4369 | SEC_LOAD
| SEC_RELOC
);
4373 save_subseg
= now_subseg
;
4374 subseg_set (seg
, subseg
);
4377 /* Get some space to hold relocation information for the unwind
4380 md_number_to_chars (p
, 0, 4);
4382 /* Relocation info. for start offset of the function. */
4383 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4384 call_info
->start_symbol
, (offsetT
) 0,
4385 (expressionS
*) NULL
, 0, R_PARISC_DIR32
, e_fsel
, 32, 0, NULL
);
4388 md_number_to_chars (p
, 0, 4);
4390 /* Relocation info. for end offset of the function.
4392 Because we allow reductions of 32bit relocations for ELF, this will be
4393 reduced to section_sym + offset which avoids putting the temporary
4394 symbol into the symbol table. It (should) end up giving the same
4395 value as call_info->start_symbol + function size once the linker is
4396 finished with its work. */
4398 fix_new_hppa (frag_now
, p
- frag_now
->fr_literal
, 4,
4399 call_info
->end_symbol
, (offsetT
) 0,
4400 (expressionS
*) NULL
, 0, R_PARISC_DIR32
, e_fsel
, 32, 0, NULL
);
4403 unwind
= (char *) &call_info
->ci_unwind
;
4404 for (i
= 8; i
< sizeof (struct unwind_table
); i
++)
4408 FRAG_APPEND_1_CHAR (c
);
4412 /* Return back to the original segment/subsegment. */
4413 subseg_set (save_seg
, save_subseg
);
4417 /* Process a .CALLINFO pseudo-op. This information is used later
4418 to build unwind descriptors and maybe one day to support
4419 .ENTER and .LEAVE. */
4422 pa_callinfo (unused
)
4428 /* We must have a valid space and subspace. */
4429 pa_check_current_space_and_subspace ();
4431 /* .CALLINFO must appear within a procedure definition. */
4432 if (!within_procedure
)
4433 as_bad (_(".callinfo is not within a procedure definition"));
4435 /* Mark the fact that we found the .CALLINFO for the
4436 current procedure. */
4437 callinfo_found
= TRUE
;
4439 /* Iterate over the .CALLINFO arguments. */
4440 while (!is_end_of_statement ())
4442 name
= input_line_pointer
;
4443 c
= get_symbol_end ();
4444 /* Frame size specification. */
4445 if ((strncasecmp (name
, "frame", 5) == 0))
4447 p
= input_line_pointer
;
4449 input_line_pointer
++;
4450 temp
= get_absolute_expression ();
4451 if ((temp
& 0x3) != 0)
4453 as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp
);
4457 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
4458 last_call_info
->ci_unwind
.descriptor
.frame_size
= temp
/ 8;
4461 /* Entry register (GR, GR and SR) specifications. */
4462 else if ((strncasecmp (name
, "entry_gr", 8) == 0))
4464 p
= input_line_pointer
;
4466 input_line_pointer
++;
4467 temp
= get_absolute_expression ();
4468 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
4469 even though %r19 is caller saved. I think this is a bug in
4470 the HP assembler, and we are not going to emulate it. */
4471 if (temp
< 3 || temp
> 18)
4472 as_bad (_("Value for ENTRY_GR must be in the range 3..18\n"));
4473 last_call_info
->ci_unwind
.descriptor
.entry_gr
= temp
- 2;
4475 else if ((strncasecmp (name
, "entry_fr", 8) == 0))
4477 p
= input_line_pointer
;
4479 input_line_pointer
++;
4480 temp
= get_absolute_expression ();
4481 /* Similarly the HP assembler takes 31 as the high bound even
4482 though %fr21 is the last callee saved floating point register. */
4483 if (temp
< 12 || temp
> 21)
4484 as_bad (_("Value for ENTRY_FR must be in the range 12..21\n"));
4485 last_call_info
->ci_unwind
.descriptor
.entry_fr
= temp
- 11;
4487 else if ((strncasecmp (name
, "entry_sr", 8) == 0))
4489 p
= input_line_pointer
;
4491 input_line_pointer
++;
4492 temp
= get_absolute_expression ();
4494 as_bad (_("Value for ENTRY_SR must be 3\n"));
4496 /* Note whether or not this function performs any calls. */
4497 else if ((strncasecmp (name
, "calls", 5) == 0) ||
4498 (strncasecmp (name
, "caller", 6) == 0))
4500 p
= input_line_pointer
;
4503 else if ((strncasecmp (name
, "no_calls", 8) == 0))
4505 p
= input_line_pointer
;
4508 /* Should RP be saved into the stack. */
4509 else if ((strncasecmp (name
, "save_rp", 7) == 0))
4511 p
= input_line_pointer
;
4513 last_call_info
->ci_unwind
.descriptor
.save_rp
= 1;
4515 /* Likewise for SP. */
4516 else if ((strncasecmp (name
, "save_sp", 7) == 0))
4518 p
= input_line_pointer
;
4520 last_call_info
->ci_unwind
.descriptor
.save_sp
= 1;
4522 /* Is this an unwindable procedure. If so mark it so
4523 in the unwind descriptor. */
4524 else if ((strncasecmp (name
, "no_unwind", 9) == 0))
4526 p
= input_line_pointer
;
4528 last_call_info
->ci_unwind
.descriptor
.cannot_unwind
= 1;
4530 /* Is this an interrupt routine. If so mark it in the
4531 unwind descriptor. */
4532 else if ((strncasecmp (name
, "hpux_int", 7) == 0))
4534 p
= input_line_pointer
;
4536 last_call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 1;
4538 /* Is this a millicode routine. "millicode" isn't in my
4539 assembler manual, but my copy is old. The HP assembler
4540 accepts it, and there's a place in the unwind descriptor
4541 to drop the information, so we'll accept it too. */
4542 else if ((strncasecmp (name
, "millicode", 9) == 0))
4544 p
= input_line_pointer
;
4546 last_call_info
->ci_unwind
.descriptor
.millicode
= 1;
4550 as_bad (_("Invalid .CALLINFO argument: %s"), name
);
4551 *input_line_pointer
= c
;
4553 if (!is_end_of_statement ())
4554 input_line_pointer
++;
4557 demand_empty_rest_of_line ();
4560 /* Switch into the code subspace. */
4566 current_space
= is_defined_space ("$TEXT$");
4568 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
4570 pa_undefine_label ();
4573 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
4574 the .comm pseudo-op has the following symtax:
4576 <label> .comm <length>
4578 where <label> is optional and is a symbol whose address will be the start of
4579 a block of memory <length> bytes long. <length> must be an absolute
4580 expression. <length> bytes will be allocated in the current space
4583 Also note the label may not even be on the same line as the .comm.
4585 This difference in syntax means the colon function will be called
4586 on the symbol before we arrive in pa_comm. colon will set a number
4587 of attributes of the symbol that need to be fixed here. In particular
4588 the value, section pointer, fragment pointer, flags, etc. What
4591 This also makes error detection all but impossible. */
4599 label_symbol_struct
*label_symbol
= pa_get_label ();
4602 symbol
= label_symbol
->lss_label
;
4607 size
= get_absolute_expression ();
4611 S_SET_VALUE (symbol
, size
);
4612 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
4613 S_SET_EXTERNAL (symbol
);
4615 /* colon() has already set the frag to the current location in the
4616 current subspace; we need to reset the fragment to the zero address
4617 fragment. We also need to reset the segment pointer. */
4618 symbol_set_frag (symbol
, &zero_address_frag
);
4620 demand_empty_rest_of_line ();
4623 /* Process a .END pseudo-op. */
4629 demand_empty_rest_of_line ();
4632 /* Process a .ENTER pseudo-op. This is not supported. */
4637 /* We must have a valid space and subspace. */
4638 pa_check_current_space_and_subspace ();
4640 as_bad (_("The .ENTER pseudo-op is not supported"));
4641 demand_empty_rest_of_line ();
4644 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
4650 /* We must have a valid space and subspace. */
4651 pa_check_current_space_and_subspace ();
4653 if (!within_procedure
)
4654 as_bad (_("Misplaced .entry. Ignored."));
4657 if (!callinfo_found
)
4658 as_bad (_("Missing .callinfo."));
4660 demand_empty_rest_of_line ();
4661 within_entry_exit
= TRUE
;
4664 /* SOM defers building of unwind descriptors until the link phase.
4665 The assembler is responsible for creating an R_ENTRY relocation
4666 to mark the beginning of a region and hold the unwind bits, and
4667 for creating an R_EXIT relocation to mark the end of the region.
4669 FIXME. ELF should be using the same conventions! The problem
4670 is an unwind requires too much relocation space. Hmmm. Maybe
4671 if we split the unwind bits up between the relocations which
4672 denote the entry and exit points. */
4673 if (last_call_info
->start_symbol
!= NULL
)
4675 char *where
= frag_more (0);
4677 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4678 NULL
, (offsetT
) 0, NULL
,
4679 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
4680 (int *) &last_call_info
->ci_unwind
.descriptor
);
4685 /* Handle a .EQU pseudo-op. */
4691 label_symbol_struct
*label_symbol
= pa_get_label ();
4696 symbol
= label_symbol
->lss_label
;
4698 S_SET_VALUE (symbol
, pa_parse_number (&input_line_pointer
, 0));
4700 S_SET_VALUE (symbol
, (unsigned int) get_absolute_expression ());
4701 S_SET_SEGMENT (symbol
, bfd_abs_section_ptr
);
4706 as_bad (_(".REG must use a label"));
4708 as_bad (_(".EQU must use a label"));
4711 pa_undefine_label ();
4712 demand_empty_rest_of_line ();
4715 /* Helper function. Does processing for the end of a function. This
4716 usually involves creating some relocations or building special
4717 symbols to mark the end of the function. */
4724 where
= frag_more (0);
4727 /* Mark the end of the function, stuff away the location of the frag
4728 for the end of the function, and finally call pa_build_unwind_subspace
4729 to add an entry in the unwind table. */
4730 hppa_elf_mark_end_of_function ();
4731 pa_build_unwind_subspace (last_call_info
);
4733 /* SOM defers building of unwind descriptors until the link phase.
4734 The assembler is responsible for creating an R_ENTRY relocation
4735 to mark the beginning of a region and hold the unwind bits, and
4736 for creating an R_EXIT relocation to mark the end of the region.
4738 FIXME. ELF should be using the same conventions! The problem
4739 is an unwind requires too much relocation space. Hmmm. Maybe
4740 if we split the unwind bits up between the relocations which
4741 denote the entry and exit points. */
4742 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
4744 NULL
, 0, R_HPPA_EXIT
, e_fsel
, 0, 0,
4745 (int *) &last_call_info
->ci_unwind
.descriptor
+ 1);
4749 /* Process a .EXIT pseudo-op. */
4755 /* We must have a valid space and subspace. */
4756 pa_check_current_space_and_subspace ();
4758 if (!within_procedure
)
4759 as_bad (_(".EXIT must appear within a procedure"));
4762 if (!callinfo_found
)
4763 as_bad (_("Missing .callinfo"));
4766 if (!within_entry_exit
)
4767 as_bad (_("No .ENTRY for this .EXIT"));
4770 within_entry_exit
= FALSE
;
4775 demand_empty_rest_of_line ();
4778 /* Process a .EXPORT directive. This makes functions external
4779 and provides information such as argument relocation entries
4789 name
= input_line_pointer
;
4790 c
= get_symbol_end ();
4791 /* Make sure the given symbol exists. */
4792 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
4794 as_bad (_("Cannot define export symbol: %s\n"), name
);
4795 p
= input_line_pointer
;
4797 input_line_pointer
++;
4801 /* OK. Set the external bits and process argument relocations. */
4802 S_SET_EXTERNAL (symbol
);
4803 p
= input_line_pointer
;
4805 if (!is_end_of_statement ())
4807 input_line_pointer
++;
4808 pa_type_args (symbol
, 1);
4812 demand_empty_rest_of_line ();
4815 /* Helper function to process arguments to a .EXPORT pseudo-op. */
4818 pa_type_args (symbolP
, is_export
)
4823 unsigned int temp
, arg_reloc
;
4824 pa_symbol_type type
= SYMBOL_TYPE_UNKNOWN
;
4825 obj_symbol_type
*symbol
= (obj_symbol_type
*) symbol_get_bfdsym (symbolP
);
4827 if (strncasecmp (input_line_pointer
, "absolute", 8) == 0)
4830 input_line_pointer
+= 8;
4831 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4832 S_SET_SEGMENT (symbolP
, bfd_abs_section_ptr
);
4833 type
= SYMBOL_TYPE_ABSOLUTE
;
4835 else if (strncasecmp (input_line_pointer
, "code", 4) == 0)
4837 input_line_pointer
+= 4;
4838 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
4839 instead one should be IMPORTing/EXPORTing ENTRY types.
4841 Complain if one tries to EXPORT a CODE type since that's never
4842 done. Both GCC and HP C still try to IMPORT CODE types, so
4843 silently fix them to be ENTRY types. */
4844 if (S_IS_FUNCTION (symbolP
))
4847 as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"),
4848 S_GET_NAME (symbolP
));
4850 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4851 type
= SYMBOL_TYPE_ENTRY
;
4855 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4856 type
= SYMBOL_TYPE_CODE
;
4859 else if (strncasecmp (input_line_pointer
, "data", 4) == 0)
4861 input_line_pointer
+= 4;
4862 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4863 type
= SYMBOL_TYPE_DATA
;
4865 else if ((strncasecmp (input_line_pointer
, "entry", 5) == 0))
4867 input_line_pointer
+= 5;
4868 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4869 type
= SYMBOL_TYPE_ENTRY
;
4871 else if (strncasecmp (input_line_pointer
, "millicode", 9) == 0)
4873 input_line_pointer
+= 9;
4874 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4875 type
= SYMBOL_TYPE_MILLICODE
;
4877 else if (strncasecmp (input_line_pointer
, "plabel", 6) == 0)
4879 input_line_pointer
+= 6;
4880 symbol_get_bfdsym (symbolP
)->flags
&= ~BSF_FUNCTION
;
4881 type
= SYMBOL_TYPE_PLABEL
;
4883 else if (strncasecmp (input_line_pointer
, "pri_prog", 8) == 0)
4885 input_line_pointer
+= 8;
4886 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4887 type
= SYMBOL_TYPE_PRI_PROG
;
4889 else if (strncasecmp (input_line_pointer
, "sec_prog", 8) == 0)
4891 input_line_pointer
+= 8;
4892 symbol_get_bfdsym (symbolP
)->flags
|= BSF_FUNCTION
;
4893 type
= SYMBOL_TYPE_SEC_PROG
;
4896 /* SOM requires much more information about symbol types
4897 than BFD understands. This is how we get this information
4898 to the SOM BFD backend. */
4899 #ifdef obj_set_symbol_type
4900 obj_set_symbol_type (symbol_get_bfdsym (symbolP
), (int) type
);
4903 /* Now that the type of the exported symbol has been handled,
4904 handle any argument relocation information. */
4905 while (!is_end_of_statement ())
4907 if (*input_line_pointer
== ',')
4908 input_line_pointer
++;
4909 name
= input_line_pointer
;
4910 c
= get_symbol_end ();
4911 /* Argument sources. */
4912 if ((strncasecmp (name
, "argw", 4) == 0))
4914 p
= input_line_pointer
;
4916 input_line_pointer
++;
4917 temp
= atoi (name
+ 4);
4918 name
= input_line_pointer
;
4919 c
= get_symbol_end ();
4920 arg_reloc
= pa_align_arg_reloc (temp
, pa_build_arg_reloc (name
));
4921 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
4922 *input_line_pointer
= c
;
4924 /* The return value. */
4925 else if ((strncasecmp (name
, "rtnval", 6)) == 0)
4927 p
= input_line_pointer
;
4929 input_line_pointer
++;
4930 name
= input_line_pointer
;
4931 c
= get_symbol_end ();
4932 arg_reloc
= pa_build_arg_reloc (name
);
4933 symbol
->tc_data
.ap
.hppa_arg_reloc
|= arg_reloc
;
4934 *input_line_pointer
= c
;
4936 /* Privelege level. */
4937 else if ((strncasecmp (name
, "priv_lev", 8)) == 0)
4939 p
= input_line_pointer
;
4941 input_line_pointer
++;
4942 temp
= atoi (input_line_pointer
);
4943 symbol
->tc_data
.ap
.hppa_priv_level
= temp
;
4944 c
= get_symbol_end ();
4945 *input_line_pointer
= c
;
4949 as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name
);
4950 p
= input_line_pointer
;
4953 if (!is_end_of_statement ())
4954 input_line_pointer
++;
4958 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
4959 assembly file must either be defined in the assembly file, or
4960 explicitly IMPORTED from another. */
4969 name
= input_line_pointer
;
4970 c
= get_symbol_end ();
4972 symbol
= symbol_find (name
);
4973 /* Ugh. We might be importing a symbol defined earlier in the file,
4974 in which case all the code below will really screw things up
4975 (set the wrong segment, symbol flags & type, etc). */
4976 if (symbol
== NULL
|| !S_IS_DEFINED (symbol
))
4978 symbol
= symbol_find_or_make (name
);
4979 p
= input_line_pointer
;
4982 if (!is_end_of_statement ())
4984 input_line_pointer
++;
4985 pa_type_args (symbol
, 0);
4989 /* Sigh. To be compatable with the HP assembler and to help
4990 poorly written assembly code, we assign a type based on
4991 the the current segment. Note only BSF_FUNCTION really
4992 matters, we do not need to set the full SYMBOL_TYPE_* info. */
4993 if (now_seg
== text_section
)
4994 symbol_get_bfdsym (symbol
)->flags
|= BSF_FUNCTION
;
4996 /* If the section is undefined, then the symbol is undefined
4997 Since this is an import, leave the section undefined. */
4998 S_SET_SEGMENT (symbol
, bfd_und_section_ptr
);
5003 /* The symbol was already defined. Just eat everything up to
5004 the end of the current statement. */
5005 while (!is_end_of_statement ())
5006 input_line_pointer
++;
5009 demand_empty_rest_of_line ();
5012 /* Handle a .LABEL pseudo-op. */
5020 name
= input_line_pointer
;
5021 c
= get_symbol_end ();
5023 if (strlen (name
) > 0)
5026 p
= input_line_pointer
;
5031 as_warn (_("Missing label name on .LABEL"));
5034 if (!is_end_of_statement ())
5036 as_warn (_("extra .LABEL arguments ignored."));
5037 ignore_rest_of_line ();
5039 demand_empty_rest_of_line ();
5042 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
5048 /* We must have a valid space and subspace. */
5049 pa_check_current_space_and_subspace ();
5051 as_bad (_("The .LEAVE pseudo-op is not supported"));
5052 demand_empty_rest_of_line ();
5055 /* Handle a .LEVEL pseudo-op. */
5063 level
= input_line_pointer
;
5064 if (strncmp (level
, "1.0", 3) == 0)
5066 input_line_pointer
+= 3;
5067 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 10))
5068 as_warn (_("could not set architecture and machine"));
5070 else if (strncmp (level
, "1.1", 3) == 0)
5072 input_line_pointer
+= 3;
5073 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 11))
5074 as_warn (_("could not set architecture and machine"));
5076 else if (strncmp (level
, "2.0", 3) == 0)
5078 input_line_pointer
+= 3;
5079 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_hppa
, 20))
5080 as_warn (_("could not set architecture and machine"));
5084 as_bad (_("Unrecognized .LEVEL argument\n"));
5085 ignore_rest_of_line ();
5087 demand_empty_rest_of_line ();
5090 /* Handle a .ORIGIN pseudo-op. */
5096 /* We must have a valid space and subspace. */
5097 pa_check_current_space_and_subspace ();
5100 pa_undefine_label ();
5103 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
5104 is for static functions. FIXME. Should share more code with .EXPORT. */
5113 name
= input_line_pointer
;
5114 c
= get_symbol_end ();
5116 if ((symbol
= symbol_find_or_make (name
)) == NULL
)
5118 as_bad (_("Cannot define static symbol: %s\n"), name
);
5119 p
= input_line_pointer
;
5121 input_line_pointer
++;
5125 S_CLEAR_EXTERNAL (symbol
);
5126 p
= input_line_pointer
;
5128 if (!is_end_of_statement ())
5130 input_line_pointer
++;
5131 pa_type_args (symbol
, 0);
5135 demand_empty_rest_of_line ();
5138 /* Handle a .PROC pseudo-op. It is used to mark the beginning
5139 of a procedure from a syntatical point of view. */
5145 struct call_info
*call_info
;
5147 /* We must have a valid space and subspace. */
5148 pa_check_current_space_and_subspace ();
5150 if (within_procedure
)
5151 as_fatal (_("Nested procedures"));
5153 /* Reset global variables for new procedure. */
5154 callinfo_found
= FALSE
;
5155 within_procedure
= TRUE
;
5157 /* Create another call_info structure. */
5158 call_info
= (struct call_info
*) xmalloc (sizeof (struct call_info
));
5161 as_fatal (_("Cannot allocate unwind descriptor\n"));
5163 memset (call_info
, 0, sizeof (struct call_info
));
5165 call_info
->ci_next
= NULL
;
5167 if (call_info_root
== NULL
)
5169 call_info_root
= call_info
;
5170 last_call_info
= call_info
;
5174 last_call_info
->ci_next
= call_info
;
5175 last_call_info
= call_info
;
5178 /* set up defaults on call_info structure */
5180 call_info
->ci_unwind
.descriptor
.cannot_unwind
= 0;
5181 call_info
->ci_unwind
.descriptor
.region_desc
= 1;
5182 call_info
->ci_unwind
.descriptor
.hpux_interrupt_marker
= 0;
5184 /* If we got a .PROC pseudo-op, we know that the function is defined
5185 locally. Make sure it gets into the symbol table. */
5187 label_symbol_struct
*label_symbol
= pa_get_label ();
5191 if (label_symbol
->lss_label
)
5193 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5194 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
|= BSF_FUNCTION
;
5197 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5200 last_call_info
->start_symbol
= NULL
;
5203 demand_empty_rest_of_line ();
5206 /* Process the syntatical end of a procedure. Make sure all the
5207 appropriate pseudo-ops were found within the procedure. */
5214 /* We must have a valid space and subspace. */
5215 pa_check_current_space_and_subspace ();
5217 /* If we are within a procedure definition, make sure we've
5218 defined a label for the procedure; handle case where the
5219 label was defined after the .PROC directive.
5221 Note there's not need to diddle with the segment or fragment
5222 for the label symbol in this case. We have already switched
5223 into the new $CODE$ subspace at this point. */
5224 if (within_procedure
&& last_call_info
->start_symbol
== NULL
)
5226 label_symbol_struct
*label_symbol
= pa_get_label ();
5230 if (label_symbol
->lss_label
)
5232 last_call_info
->start_symbol
= label_symbol
->lss_label
;
5233 symbol_get_bfdsym (label_symbol
->lss_label
)->flags
5236 /* Also handle allocation of a fixup to hold the unwind
5237 information when the label appears after the proc/procend. */
5238 if (within_entry_exit
)
5240 char *where
= frag_more (0);
5242 fix_new_hppa (frag_now
, where
- frag_now
->fr_literal
, 0,
5243 NULL
, (offsetT
) 0, NULL
,
5244 0, R_HPPA_ENTRY
, e_fsel
, 0, 0,
5245 (int *) &last_call_info
->ci_unwind
.descriptor
);
5250 as_bad (_("Missing function name for .PROC (corrupted label chain)"));
5253 as_bad (_("Missing function name for .PROC"));
5256 if (!within_procedure
)
5257 as_bad (_("misplaced .procend"));
5259 if (!callinfo_found
)
5260 as_bad (_("Missing .callinfo for this procedure"));
5262 if (within_entry_exit
)
5263 as_bad (_("Missing .EXIT for a .ENTRY"));
5266 /* ELF needs to mark the end of each function so that it can compute
5267 the size of the function (apparently its needed in the symbol table). */
5268 hppa_elf_mark_end_of_function ();
5271 within_procedure
= FALSE
;
5272 demand_empty_rest_of_line ();
5273 pa_undefine_label ();
5276 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
5277 then create a new space entry to hold the information specified
5278 by the parameters to the .SPACE directive. */
5280 static sd_chain_struct
*
5281 pa_parse_space_stmt (space_name
, create_flag
)
5285 char *name
, *ptemp
, c
;
5286 char loadable
, defined
, private, sort
;
5288 asection
*seg
= NULL
;
5289 sd_chain_struct
*space
;
5291 /* load default values */
5297 if (strcmp (space_name
, "$TEXT$") == 0)
5299 seg
= pa_def_spaces
[0].segment
;
5300 defined
= pa_def_spaces
[0].defined
;
5301 private = pa_def_spaces
[0].private;
5302 sort
= pa_def_spaces
[0].sort
;
5303 spnum
= pa_def_spaces
[0].spnum
;
5305 else if (strcmp (space_name
, "$PRIVATE$") == 0)
5307 seg
= pa_def_spaces
[1].segment
;
5308 defined
= pa_def_spaces
[1].defined
;
5309 private = pa_def_spaces
[1].private;
5310 sort
= pa_def_spaces
[1].sort
;
5311 spnum
= pa_def_spaces
[1].spnum
;
5314 if (!is_end_of_statement ())
5316 print_errors
= FALSE
;
5317 ptemp
= input_line_pointer
+ 1;
5318 /* First see if the space was specified as a number rather than
5319 as a name. According to the PA assembly manual the rest of
5320 the line should be ignored. */
5321 temp
= pa_parse_number (&ptemp
, 0);
5325 input_line_pointer
= ptemp
;
5329 while (!is_end_of_statement ())
5331 input_line_pointer
++;
5332 name
= input_line_pointer
;
5333 c
= get_symbol_end ();
5334 if ((strncasecmp (name
, "spnum", 5) == 0))
5336 *input_line_pointer
= c
;
5337 input_line_pointer
++;
5338 spnum
= get_absolute_expression ();
5340 else if ((strncasecmp (name
, "sort", 4) == 0))
5342 *input_line_pointer
= c
;
5343 input_line_pointer
++;
5344 sort
= get_absolute_expression ();
5346 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5348 *input_line_pointer
= c
;
5351 else if ((strncasecmp (name
, "notdefined", 10) == 0))
5353 *input_line_pointer
= c
;
5356 else if ((strncasecmp (name
, "private", 7) == 0))
5358 *input_line_pointer
= c
;
5363 as_bad (_("Invalid .SPACE argument"));
5364 *input_line_pointer
= c
;
5365 if (!is_end_of_statement ())
5366 input_line_pointer
++;
5370 print_errors
= TRUE
;
5373 if (create_flag
&& seg
== NULL
)
5374 seg
= subseg_new (space_name
, 0);
5376 /* If create_flag is nonzero, then create the new space with
5377 the attributes computed above. Else set the values in
5378 an already existing space -- this can only happen for
5379 the first occurence of a built-in space. */
5381 space
= create_new_space (space_name
, spnum
, loadable
, defined
,
5382 private, sort
, seg
, 1);
5385 space
= is_defined_space (space_name
);
5386 SPACE_SPNUM (space
) = spnum
;
5387 SPACE_DEFINED (space
) = defined
& 1;
5388 SPACE_USER_DEFINED (space
) = 1;
5391 #ifdef obj_set_section_attributes
5392 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
5398 /* Handle a .SPACE pseudo-op; this switches the current space to the
5399 given space, creating the new space if necessary. */
5405 char *name
, c
, *space_name
, *save_s
;
5407 sd_chain_struct
*sd_chain
;
5409 if (within_procedure
)
5411 as_bad (_("Can\'t change spaces within a procedure definition. Ignored"));
5412 ignore_rest_of_line ();
5416 /* Check for some of the predefined spaces. FIXME: most of the code
5417 below is repeated several times, can we extract the common parts
5418 and place them into a subroutine or something similar? */
5419 /* FIXME Is this (and the next IF stmt) really right?
5420 What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */
5421 if (strncmp (input_line_pointer
, "$TEXT$", 6) == 0)
5423 input_line_pointer
+= 6;
5424 sd_chain
= is_defined_space ("$TEXT$");
5425 if (sd_chain
== NULL
)
5426 sd_chain
= pa_parse_space_stmt ("$TEXT$", 1);
5427 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5428 sd_chain
= pa_parse_space_stmt ("$TEXT$", 0);
5430 current_space
= sd_chain
;
5431 subseg_set (text_section
, sd_chain
->sd_last_subseg
);
5433 = pa_subsegment_to_subspace (text_section
,
5434 sd_chain
->sd_last_subseg
);
5435 demand_empty_rest_of_line ();
5438 if (strncmp (input_line_pointer
, "$PRIVATE$", 9) == 0)
5440 input_line_pointer
+= 9;
5441 sd_chain
= is_defined_space ("$PRIVATE$");
5442 if (sd_chain
== NULL
)
5443 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 1);
5444 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5445 sd_chain
= pa_parse_space_stmt ("$PRIVATE$", 0);
5447 current_space
= sd_chain
;
5448 subseg_set (data_section
, sd_chain
->sd_last_subseg
);
5450 = pa_subsegment_to_subspace (data_section
,
5451 sd_chain
->sd_last_subseg
);
5452 demand_empty_rest_of_line ();
5455 if (!strncasecmp (input_line_pointer
,
5456 GDB_DEBUG_SPACE_NAME
,
5457 strlen (GDB_DEBUG_SPACE_NAME
)))
5459 input_line_pointer
+= strlen (GDB_DEBUG_SPACE_NAME
);
5460 sd_chain
= is_defined_space (GDB_DEBUG_SPACE_NAME
);
5461 if (sd_chain
== NULL
)
5462 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 1);
5463 else if (SPACE_USER_DEFINED (sd_chain
) == 0)
5464 sd_chain
= pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME
, 0);
5466 current_space
= sd_chain
;
5469 asection
*gdb_section
5470 = bfd_make_section_old_way (stdoutput
, GDB_DEBUG_SPACE_NAME
);
5472 subseg_set (gdb_section
, sd_chain
->sd_last_subseg
);
5474 = pa_subsegment_to_subspace (gdb_section
,
5475 sd_chain
->sd_last_subseg
);
5477 demand_empty_rest_of_line ();
5481 /* It could be a space specified by number. */
5483 save_s
= input_line_pointer
;
5484 if ((temp
= pa_parse_number (&input_line_pointer
, 0)) >= 0)
5486 if ((sd_chain
= pa_find_space_by_number (temp
)))
5488 current_space
= sd_chain
;
5490 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5492 = pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5493 sd_chain
->sd_last_subseg
);
5494 demand_empty_rest_of_line ();
5499 /* Not a number, attempt to create a new space. */
5501 input_line_pointer
= save_s
;
5502 name
= input_line_pointer
;
5503 c
= get_symbol_end ();
5504 space_name
= xmalloc (strlen (name
) + 1);
5505 strcpy (space_name
, name
);
5506 *input_line_pointer
= c
;
5508 sd_chain
= pa_parse_space_stmt (space_name
, 1);
5509 current_space
= sd_chain
;
5511 subseg_set (sd_chain
->sd_seg
, sd_chain
->sd_last_subseg
);
5512 current_subspace
= pa_subsegment_to_subspace (sd_chain
->sd_seg
,
5513 sd_chain
->sd_last_subseg
);
5514 demand_empty_rest_of_line ();
5518 /* Switch to a new space. (I think). FIXME. */
5527 sd_chain_struct
*space
;
5529 name
= input_line_pointer
;
5530 c
= get_symbol_end ();
5531 space
= is_defined_space (name
);
5535 md_number_to_chars (p
, SPACE_SPNUM (space
), 4);
5538 as_warn (_("Undefined space: '%s' Assuming space number = 0."), name
);
5540 *input_line_pointer
= c
;
5541 demand_empty_rest_of_line ();
5544 /* If VALUE is an exact power of two between zero and 2^31, then
5545 return log2 (VALUE). Else return -1. */
5553 while ((1 << shift
) != value
&& shift
< 32)
5562 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
5563 given subspace, creating the new subspace if necessary.
5565 FIXME. Should mirror pa_space more closely, in particular how
5566 they're broken up into subroutines. */
5569 pa_subspace (create_new
)
5572 char *name
, *ss_name
, *alias
, c
;
5573 char loadable
, code_only
, common
, dup_common
, zero
, sort
;
5574 int i
, access
, space_index
, alignment
, quadrant
, applicable
, flags
;
5575 sd_chain_struct
*space
;
5576 ssd_chain_struct
*ssd
;
5579 if (current_space
== NULL
)
5580 as_fatal (_("Must be in a space before changing or declaring subspaces.\n"));
5582 if (within_procedure
)
5584 as_bad (_("Can\'t change subspaces within a procedure definition. Ignored"));
5585 ignore_rest_of_line ();
5589 name
= input_line_pointer
;
5590 c
= get_symbol_end ();
5591 ss_name
= xmalloc (strlen (name
) + 1);
5592 strcpy (ss_name
, name
);
5593 *input_line_pointer
= c
;
5595 /* Load default values. */
5608 space
= current_space
;
5612 ssd
= is_defined_subspace (ss_name
);
5613 /* Allow user to override the builtin attributes of subspaces. But
5614 only allow the attributes to be changed once! */
5615 if (ssd
&& SUBSPACE_DEFINED (ssd
))
5617 subseg_set (ssd
->ssd_seg
, ssd
->ssd_subseg
);
5618 current_subspace
= ssd
;
5619 if (!is_end_of_statement ())
5620 as_warn (_("Parameters of an existing subspace can\'t be modified"));
5621 demand_empty_rest_of_line ();
5626 /* A new subspace. Load default values if it matches one of
5627 the builtin subspaces. */
5629 while (pa_def_subspaces
[i
].name
)
5631 if (strcasecmp (pa_def_subspaces
[i
].name
, ss_name
) == 0)
5633 loadable
= pa_def_subspaces
[i
].loadable
;
5634 common
= pa_def_subspaces
[i
].common
;
5635 dup_common
= pa_def_subspaces
[i
].dup_common
;
5636 code_only
= pa_def_subspaces
[i
].code_only
;
5637 zero
= pa_def_subspaces
[i
].zero
;
5638 space_index
= pa_def_subspaces
[i
].space_index
;
5639 alignment
= pa_def_subspaces
[i
].alignment
;
5640 quadrant
= pa_def_subspaces
[i
].quadrant
;
5641 access
= pa_def_subspaces
[i
].access
;
5642 sort
= pa_def_subspaces
[i
].sort
;
5643 if (USE_ALIASES
&& pa_def_subspaces
[i
].alias
)
5644 alias
= pa_def_subspaces
[i
].alias
;
5651 /* We should be working with a new subspace now. Fill in
5652 any information as specified by the user. */
5653 if (!is_end_of_statement ())
5655 input_line_pointer
++;
5656 while (!is_end_of_statement ())
5658 name
= input_line_pointer
;
5659 c
= get_symbol_end ();
5660 if ((strncasecmp (name
, "quad", 4) == 0))
5662 *input_line_pointer
= c
;
5663 input_line_pointer
++;
5664 quadrant
= get_absolute_expression ();
5666 else if ((strncasecmp (name
, "align", 5) == 0))
5668 *input_line_pointer
= c
;
5669 input_line_pointer
++;
5670 alignment
= get_absolute_expression ();
5671 if (log2 (alignment
) == -1)
5673 as_bad (_("Alignment must be a power of 2"));
5677 else if ((strncasecmp (name
, "access", 6) == 0))
5679 *input_line_pointer
= c
;
5680 input_line_pointer
++;
5681 access
= get_absolute_expression ();
5683 else if ((strncasecmp (name
, "sort", 4) == 0))
5685 *input_line_pointer
= c
;
5686 input_line_pointer
++;
5687 sort
= get_absolute_expression ();
5689 else if ((strncasecmp (name
, "code_only", 9) == 0))
5691 *input_line_pointer
= c
;
5694 else if ((strncasecmp (name
, "unloadable", 10) == 0))
5696 *input_line_pointer
= c
;
5699 else if ((strncasecmp (name
, "common", 6) == 0))
5701 *input_line_pointer
= c
;
5704 else if ((strncasecmp (name
, "dup_comm", 8) == 0))
5706 *input_line_pointer
= c
;
5709 else if ((strncasecmp (name
, "zero", 4) == 0))
5711 *input_line_pointer
= c
;
5714 else if ((strncasecmp (name
, "first", 5) == 0))
5715 as_bad (_("FIRST not supported as a .SUBSPACE argument"));
5717 as_bad (_("Invalid .SUBSPACE argument"));
5718 if (!is_end_of_statement ())
5719 input_line_pointer
++;
5723 /* Compute a reasonable set of BFD flags based on the information
5724 in the .subspace directive. */
5725 applicable
= bfd_applicable_section_flags (stdoutput
);
5728 flags
|= (SEC_ALLOC
| SEC_LOAD
);
5731 if (common
|| dup_common
)
5732 flags
|= SEC_IS_COMMON
;
5734 flags
|= SEC_RELOC
| SEC_HAS_CONTENTS
;
5736 /* This is a zero-filled subspace (eg BSS). */
5738 flags
&= ~(SEC_LOAD
| SEC_HAS_CONTENTS
);
5740 applicable
&= flags
;
5742 /* If this is an existing subspace, then we want to use the
5743 segment already associated with the subspace.
5745 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
5746 lots of sections. It might be a problem in the PA ELF
5747 code, I do not know yet. For now avoid creating anything
5748 but the "standard" sections for ELF. */
5750 section
= subseg_force_new (ss_name
, 0);
5752 section
= ssd
->ssd_seg
;
5754 section
= subseg_new (alias
, 0);
5755 else if (!alias
&& USE_ALIASES
)
5757 as_warn (_("Ignoring subspace decl due to ELF BFD bugs."));
5758 demand_empty_rest_of_line ();
5762 section
= subseg_new (ss_name
, 0);
5765 seg_info (section
)->bss
= 1;
5767 /* Now set the flags. */
5768 bfd_set_section_flags (stdoutput
, section
, applicable
);
5770 /* Record any alignment request for this section. */
5771 record_alignment (section
, log2 (alignment
));
5773 /* Set the starting offset for this section. */
5774 bfd_set_section_vma (stdoutput
, section
,
5775 pa_subspace_start (space
, quadrant
));
5777 /* Now that all the flags are set, update an existing subspace,
5778 or create a new one. */
5781 current_subspace
= update_subspace (space
, ss_name
, loadable
,
5782 code_only
, common
, dup_common
,
5783 sort
, zero
, access
, space_index
,
5784 alignment
, quadrant
,
5787 current_subspace
= create_new_subspace (space
, ss_name
, loadable
,
5789 dup_common
, zero
, sort
,
5790 access
, space_index
,
5791 alignment
, quadrant
, section
);
5793 demand_empty_rest_of_line ();
5794 current_subspace
->ssd_seg
= section
;
5795 subseg_set (current_subspace
->ssd_seg
, current_subspace
->ssd_subseg
);
5797 SUBSPACE_DEFINED (current_subspace
) = 1;
5801 /* Create default space and subspace dictionaries. */
5808 space_dict_root
= NULL
;
5809 space_dict_last
= NULL
;
5812 while (pa_def_spaces
[i
].name
)
5816 /* Pick the right name to use for the new section. */
5817 if (pa_def_spaces
[i
].alias
&& USE_ALIASES
)
5818 name
= pa_def_spaces
[i
].alias
;
5820 name
= pa_def_spaces
[i
].name
;
5822 pa_def_spaces
[i
].segment
= subseg_new (name
, 0);
5823 create_new_space (pa_def_spaces
[i
].name
, pa_def_spaces
[i
].spnum
,
5824 pa_def_spaces
[i
].loadable
, pa_def_spaces
[i
].defined
,
5825 pa_def_spaces
[i
].private, pa_def_spaces
[i
].sort
,
5826 pa_def_spaces
[i
].segment
, 0);
5831 while (pa_def_subspaces
[i
].name
)
5834 int applicable
, subsegment
;
5835 asection
*segment
= NULL
;
5836 sd_chain_struct
*space
;
5838 /* Pick the right name for the new section and pick the right
5839 subsegment number. */
5840 if (pa_def_subspaces
[i
].alias
&& USE_ALIASES
)
5842 name
= pa_def_subspaces
[i
].alias
;
5843 subsegment
= pa_def_subspaces
[i
].subsegment
;
5847 name
= pa_def_subspaces
[i
].name
;
5851 /* Create the new section. */
5852 segment
= subseg_new (name
, subsegment
);
5855 /* For SOM we want to replace the standard .text, .data, and .bss
5856 sections with our own. We also want to set BFD flags for
5857 all the built-in subspaces. */
5858 if (!strcmp (pa_def_subspaces
[i
].name
, "$CODE$") && !USE_ALIASES
)
5860 text_section
= segment
;
5861 applicable
= bfd_applicable_section_flags (stdoutput
);
5862 bfd_set_section_flags (stdoutput
, segment
,
5863 applicable
& (SEC_ALLOC
| SEC_LOAD
5864 | SEC_RELOC
| SEC_CODE
5866 | SEC_HAS_CONTENTS
));
5868 else if (!strcmp (pa_def_subspaces
[i
].name
, "$DATA$") && !USE_ALIASES
)
5870 data_section
= segment
;
5871 applicable
= bfd_applicable_section_flags (stdoutput
);
5872 bfd_set_section_flags (stdoutput
, segment
,
5873 applicable
& (SEC_ALLOC
| SEC_LOAD
5875 | SEC_HAS_CONTENTS
));
5879 else if (!strcmp (pa_def_subspaces
[i
].name
, "$BSS$") && !USE_ALIASES
)
5881 bss_section
= segment
;
5882 applicable
= bfd_applicable_section_flags (stdoutput
);
5883 bfd_set_section_flags (stdoutput
, segment
,
5884 applicable
& SEC_ALLOC
);
5886 else if (!strcmp (pa_def_subspaces
[i
].name
, "$LIT$") && !USE_ALIASES
)
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
, "$MILLICODE$")
5898 applicable
= bfd_applicable_section_flags (stdoutput
);
5899 bfd_set_section_flags (stdoutput
, segment
,
5900 applicable
& (SEC_ALLOC
| SEC_LOAD
5903 | SEC_HAS_CONTENTS
));
5905 else if (!strcmp (pa_def_subspaces
[i
].name
, "$UNWIND$") && !USE_ALIASES
)
5907 applicable
= bfd_applicable_section_flags (stdoutput
);
5908 bfd_set_section_flags (stdoutput
, segment
,
5909 applicable
& (SEC_ALLOC
| SEC_LOAD
5912 | SEC_HAS_CONTENTS
));
5915 /* Find the space associated with this subspace. */
5916 space
= pa_segment_to_space (pa_def_spaces
[pa_def_subspaces
[i
].
5917 def_space_index
].segment
);
5920 as_fatal (_("Internal error: Unable to find containing space for %s."),
5921 pa_def_subspaces
[i
].name
);
5924 create_new_subspace (space
, name
,
5925 pa_def_subspaces
[i
].loadable
,
5926 pa_def_subspaces
[i
].code_only
,
5927 pa_def_subspaces
[i
].common
,
5928 pa_def_subspaces
[i
].dup_common
,
5929 pa_def_subspaces
[i
].zero
,
5930 pa_def_subspaces
[i
].sort
,
5931 pa_def_subspaces
[i
].access
,
5932 pa_def_subspaces
[i
].space_index
,
5933 pa_def_subspaces
[i
].alignment
,
5934 pa_def_subspaces
[i
].quadrant
,
5942 /* Create a new space NAME, with the appropriate flags as defined
5943 by the given parameters. */
5945 static sd_chain_struct
*
5946 create_new_space (name
, spnum
, loadable
, defined
, private,
5947 sort
, seg
, user_defined
)
5957 sd_chain_struct
*chain_entry
;
5959 chain_entry
= (sd_chain_struct
*) xmalloc (sizeof (sd_chain_struct
));
5961 as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
5964 SPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
5965 strcpy (SPACE_NAME (chain_entry
), name
);
5966 SPACE_DEFINED (chain_entry
) = defined
;
5967 SPACE_USER_DEFINED (chain_entry
) = user_defined
;
5968 SPACE_SPNUM (chain_entry
) = spnum
;
5970 chain_entry
->sd_seg
= seg
;
5971 chain_entry
->sd_last_subseg
= -1;
5972 chain_entry
->sd_subspaces
= NULL
;
5973 chain_entry
->sd_next
= NULL
;
5975 /* Find spot for the new space based on its sort key. */
5976 if (!space_dict_last
)
5977 space_dict_last
= chain_entry
;
5979 if (space_dict_root
== NULL
)
5980 space_dict_root
= chain_entry
;
5983 sd_chain_struct
*chain_pointer
;
5984 sd_chain_struct
*prev_chain_pointer
;
5986 chain_pointer
= space_dict_root
;
5987 prev_chain_pointer
= NULL
;
5989 while (chain_pointer
)
5991 prev_chain_pointer
= chain_pointer
;
5992 chain_pointer
= chain_pointer
->sd_next
;
5995 /* At this point we've found the correct place to add the new
5996 entry. So add it and update the linked lists as appropriate. */
5997 if (prev_chain_pointer
)
5999 chain_entry
->sd_next
= chain_pointer
;
6000 prev_chain_pointer
->sd_next
= chain_entry
;
6004 space_dict_root
= chain_entry
;
6005 chain_entry
->sd_next
= chain_pointer
;
6008 if (chain_entry
->sd_next
== NULL
)
6009 space_dict_last
= chain_entry
;
6012 /* This is here to catch predefined spaces which do not get
6013 modified by the user's input. Another call is found at
6014 the bottom of pa_parse_space_stmt to handle cases where
6015 the user modifies a predefined space. */
6016 #ifdef obj_set_section_attributes
6017 obj_set_section_attributes (seg
, defined
, private, sort
, spnum
);
6023 /* Create a new subspace NAME, with the appropriate flags as defined
6024 by the given parameters.
6026 Add the new subspace to the subspace dictionary chain in numerical
6027 order as defined by the SORT entries. */
6029 static ssd_chain_struct
*
6030 create_new_subspace (space
, name
, loadable
, code_only
, common
,
6031 dup_common
, is_zero
, sort
, access
, space_index
,
6032 alignment
, quadrant
, seg
)
6033 sd_chain_struct
*space
;
6035 int loadable
, code_only
, common
, dup_common
, is_zero
;
6043 ssd_chain_struct
*chain_entry
;
6045 chain_entry
= (ssd_chain_struct
*) xmalloc (sizeof (ssd_chain_struct
));
6047 as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name
);
6049 SUBSPACE_NAME (chain_entry
) = (char *) xmalloc (strlen (name
) + 1);
6050 strcpy (SUBSPACE_NAME (chain_entry
), name
);
6052 /* Initialize subspace_defined. When we hit a .subspace directive
6053 we'll set it to 1 which "locks-in" the subspace attributes. */
6054 SUBSPACE_DEFINED (chain_entry
) = 0;
6056 chain_entry
->ssd_subseg
= USE_ALIASES
? pa_next_subseg (space
) : 0;
6057 chain_entry
->ssd_seg
= seg
;
6058 chain_entry
->ssd_next
= NULL
;
6060 /* Find spot for the new subspace based on its sort key. */
6061 if (space
->sd_subspaces
== NULL
)
6062 space
->sd_subspaces
= chain_entry
;
6065 ssd_chain_struct
*chain_pointer
;
6066 ssd_chain_struct
*prev_chain_pointer
;
6068 chain_pointer
= space
->sd_subspaces
;
6069 prev_chain_pointer
= NULL
;
6071 while (chain_pointer
)
6073 prev_chain_pointer
= chain_pointer
;
6074 chain_pointer
= chain_pointer
->ssd_next
;
6077 /* Now we have somewhere to put the new entry. Insert it and update
6079 if (prev_chain_pointer
)
6081 chain_entry
->ssd_next
= chain_pointer
;
6082 prev_chain_pointer
->ssd_next
= chain_entry
;
6086 space
->sd_subspaces
= chain_entry
;
6087 chain_entry
->ssd_next
= chain_pointer
;
6091 #ifdef obj_set_subsection_attributes
6092 obj_set_subsection_attributes (seg
, space
->sd_seg
, access
,
6099 /* Update the information for the given subspace based upon the
6100 various arguments. Return the modified subspace chain entry. */
6102 static ssd_chain_struct
*
6103 update_subspace (space
, name
, loadable
, code_only
, common
, dup_common
, sort
,
6104 zero
, access
, space_index
, alignment
, quadrant
, section
)
6105 sd_chain_struct
*space
;
6119 ssd_chain_struct
*chain_entry
;
6121 chain_entry
= is_defined_subspace (name
);
6123 #ifdef obj_set_subsection_attributes
6124 obj_set_subsection_attributes (section
, space
->sd_seg
, access
,
6131 /* Return the space chain entry for the space with the name NAME or
6132 NULL if no such space exists. */
6134 static sd_chain_struct
*
6135 is_defined_space (name
)
6138 sd_chain_struct
*chain_pointer
;
6140 for (chain_pointer
= space_dict_root
;
6142 chain_pointer
= chain_pointer
->sd_next
)
6144 if (strcmp (SPACE_NAME (chain_pointer
), name
) == 0)
6145 return chain_pointer
;
6148 /* No mapping from segment to space was found. Return NULL. */
6152 /* Find and return the space associated with the given seg. If no mapping
6153 from the given seg to a space is found, then return NULL.
6155 Unlike subspaces, the number of spaces is not expected to grow much,
6156 so a linear exhaustive search is OK here. */
6158 static sd_chain_struct
*
6159 pa_segment_to_space (seg
)
6162 sd_chain_struct
*space_chain
;
6164 /* Walk through each space looking for the correct mapping. */
6165 for (space_chain
= space_dict_root
;
6167 space_chain
= space_chain
->sd_next
)
6169 if (space_chain
->sd_seg
== seg
)
6173 /* Mapping was not found. Return NULL. */
6177 /* Return the space chain entry for the subspace with the name NAME or
6178 NULL if no such subspace exists.
6180 Uses a linear search through all the spaces and subspaces, this may
6181 not be appropriate if we ever being placing each function in its
6184 static ssd_chain_struct
*
6185 is_defined_subspace (name
)
6188 sd_chain_struct
*space_chain
;
6189 ssd_chain_struct
*subspace_chain
;
6191 /* Walk through each space. */
6192 for (space_chain
= space_dict_root
;
6194 space_chain
= space_chain
->sd_next
)
6196 /* Walk through each subspace looking for a name which matches. */
6197 for (subspace_chain
= space_chain
->sd_subspaces
;
6199 subspace_chain
= subspace_chain
->ssd_next
)
6200 if (strcmp (SUBSPACE_NAME (subspace_chain
), name
) == 0)
6201 return subspace_chain
;
6204 /* Subspace wasn't found. Return NULL. */
6208 /* Find and return the subspace associated with the given seg. If no
6209 mapping from the given seg to a subspace is found, then return NULL.
6211 If we ever put each procedure/function within its own subspace
6212 (to make life easier on the compiler and linker), then this will have
6213 to become more efficient. */
6215 static ssd_chain_struct
*
6216 pa_subsegment_to_subspace (seg
, subseg
)
6220 sd_chain_struct
*space_chain
;
6221 ssd_chain_struct
*subspace_chain
;
6223 /* Walk through each space. */
6224 for (space_chain
= space_dict_root
;
6226 space_chain
= space_chain
->sd_next
)
6228 if (space_chain
->sd_seg
== seg
)
6230 /* Walk through each subspace within each space looking for
6231 the correct mapping. */
6232 for (subspace_chain
= space_chain
->sd_subspaces
;
6234 subspace_chain
= subspace_chain
->ssd_next
)
6235 if (subspace_chain
->ssd_subseg
== (int) subseg
)
6236 return subspace_chain
;
6240 /* No mapping from subsegment to subspace found. Return NULL. */
6244 /* Given a number, try and find a space with the name number.
6246 Return a pointer to a space dictionary chain entry for the space
6247 that was found or NULL on failure. */
6249 static sd_chain_struct
*
6250 pa_find_space_by_number (number
)
6253 sd_chain_struct
*space_chain
;
6255 for (space_chain
= space_dict_root
;
6257 space_chain
= space_chain
->sd_next
)
6259 if (SPACE_SPNUM (space_chain
) == (unsigned int) number
)
6263 /* No appropriate space found. Return NULL. */
6267 /* Return the starting address for the given subspace. If the starting
6268 address is unknown then return zero. */
6271 pa_subspace_start (space
, quadrant
)
6272 sd_chain_struct
*space
;
6276 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
6277 is not correct for the PA OSF1 port. */
6278 if ((strcmp (SPACE_NAME (space
), "$PRIVATE$") == 0) && quadrant
== 1)
6280 else if (space
->sd_seg
== data_section
&& quadrant
== 1)
6288 /* FIXME. Needs documentation. */
6290 pa_next_subseg (space
)
6291 sd_chain_struct
*space
;
6294 space
->sd_last_subseg
++;
6295 return space
->sd_last_subseg
;
6298 /* Helper function for pa_stringer. Used to find the end of
6305 unsigned int c
= *s
& CHAR_MASK
;
6307 /* We must have a valid space and subspace. */
6308 pa_check_current_space_and_subspace ();
6321 /* Handle a .STRING type pseudo-op. */
6324 pa_stringer (append_zero
)
6327 char *s
, num_buf
[4];
6331 /* Preprocess the string to handle PA-specific escape sequences.
6332 For example, \xDD where DD is a hexidecimal number should be
6333 changed to \OOO where OOO is an octal number. */
6335 /* Skip the opening quote. */
6336 s
= input_line_pointer
+ 1;
6338 while (is_a_char (c
= pa_stringer_aux (s
++)))
6345 /* Handle \x<num>. */
6348 unsigned int number
;
6353 /* Get pas the 'x'. */
6355 for (num_digit
= 0, number
= 0, dg
= *s
;
6357 && (isdigit (dg
) || (dg
>= 'a' && dg
<= 'f')
6358 || (dg
>= 'A' && dg
<= 'F'));
6362 number
= number
* 16 + dg
- '0';
6363 else if (dg
>= 'a' && dg
<= 'f')
6364 number
= number
* 16 + dg
- 'a' + 10;
6366 number
= number
* 16 + dg
- 'A' + 10;
6376 sprintf (num_buf
, "%02o", number
);
6379 sprintf (num_buf
, "%03o", number
);
6382 for (i
= 0; i
<= num_digit
; i
++)
6383 s_start
[i
] = num_buf
[i
];
6387 /* This might be a "\"", skip over the escaped char. */
6394 stringer (append_zero
);
6395 pa_undefine_label ();
6398 /* Handle a .VERSION pseudo-op. */
6405 pa_undefine_label ();
6410 /* Handle a .COMPILER pseudo-op. */
6413 pa_compiler (unused
)
6416 obj_som_compiler (0);
6417 pa_undefine_label ();
6422 /* Handle a .COPYRIGHT pseudo-op. */
6425 pa_copyright (unused
)
6429 pa_undefine_label ();
6432 /* Just like a normal cons, but when finished we have to undefine
6433 the latest space label. */
6440 pa_undefine_label ();
6443 /* Switch to the data space. As usual delete our label. */
6449 current_space
= is_defined_space ("$PRIVATE$");
6451 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6453 pa_undefine_label ();
6456 /* Like float_cons, but we need to undefine our label. */
6459 pa_float_cons (float_type
)
6462 float_cons (float_type
);
6463 pa_undefine_label ();
6466 /* Like s_fill, but delete our label when finished. */
6472 /* We must have a valid space and subspace. */
6473 pa_check_current_space_and_subspace ();
6476 pa_undefine_label ();
6479 /* Like lcomm, but delete our label when finished. */
6482 pa_lcomm (needs_align
)
6485 /* We must have a valid space and subspace. */
6486 pa_check_current_space_and_subspace ();
6488 s_lcomm (needs_align
);
6489 pa_undefine_label ();
6492 /* Like lsym, but delete our label when finished. */
6498 /* We must have a valid space and subspace. */
6499 pa_check_current_space_and_subspace ();
6502 pa_undefine_label ();
6505 /* Switch to the text space. Like s_text, but delete our
6506 label when finished. */
6511 current_space
= is_defined_space ("$TEXT$");
6513 = pa_subsegment_to_subspace (current_space
->sd_seg
, 0);
6516 pa_undefine_label ();
6519 /* On the PA relocations which involve function symbols must not be
6520 adjusted. This so that the linker can know when/how to create argument
6521 relocation stubs for indirect calls and calls to static functions.
6523 "T" field selectors create DLT relative fixups for accessing
6524 globals and statics in PIC code; each DLT relative fixup creates
6525 an entry in the DLT table. The entries contain the address of
6526 the final target (eg accessing "foo" would create a DLT entry
6527 with the address of "foo").
6529 Unfortunately, the HP linker doesn't take into account any addend
6530 when generating the DLT; so accessing $LIT$+8 puts the address of
6531 $LIT$ into the DLT rather than the address of $LIT$+8.
6533 The end result is we can't perform relocation symbol reductions for
6534 any fixup which creates entries in the DLT (eg they use "T" field
6537 Reject reductions involving symbols with external scope; such
6538 reductions make life a living hell for object file editors.
6540 FIXME. Also reject R_HPPA relocations which are 32bits wide in
6541 the code space. The SOM BFD backend doesn't know how to pull the
6542 right bits out of an instruction. */
6545 hppa_fix_adjustable (fixp
)
6548 struct hppa_fix_struct
*hppa_fix
;
6550 hppa_fix
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6553 /* Reject reductions of symbols in 32bit relocs. */
6554 if (fixp
->fx_r_type
== R_HPPA
&& hppa_fix
->fx_r_format
== 32)
6557 /* Reject reductions of symbols in sym1-sym2 expressions when
6558 the fixup will occur in a CODE subspace.
6560 XXX FIXME: Long term we probably want to reject all of these;
6561 for example reducing in the debug section would lose if we ever
6562 supported using the optimizing hp linker. */
6565 && (hppa_fix
->segment
->flags
& SEC_CODE
))
6567 /* Apparently sy_used_in_reloc never gets set for sub symbols. */
6568 symbol_mark_used_in_reloc (fixp
->fx_subsy
);
6572 /* We can't adjust any relocs that use LR% and RR% field selectors.
6573 That confuses the HP linker. */
6574 if (hppa_fix
->fx_r_field
== e_lrsel
6575 || hppa_fix
->fx_r_field
== e_rrsel
6576 || hppa_fix
->fx_r_field
== e_nlrsel
)
6580 /* Reject reductions of symbols in DLT relative relocs,
6581 relocations with plabels. */
6582 if (hppa_fix
->fx_r_field
== e_tsel
6583 || hppa_fix
->fx_r_field
== e_ltsel
6584 || hppa_fix
->fx_r_field
== e_rtsel
6585 || hppa_fix
->fx_r_field
== e_psel
6586 || hppa_fix
->fx_r_field
== e_rpsel
6587 || hppa_fix
->fx_r_field
== e_lpsel
)
6590 if (fixp
->fx_addsy
&& S_IS_EXTERNAL (fixp
->fx_addsy
))
6593 /* Reject absolute calls (jumps). */
6594 if (hppa_fix
->fx_r_type
== R_HPPA_ABS_CALL
)
6597 /* Reject reductions of function symbols. */
6598 if (fixp
->fx_addsy
== 0 || ! S_IS_FUNCTION (fixp
->fx_addsy
))
6604 /* Return nonzero if the fixup in FIXP will require a relocation,
6605 even it if appears that the fixup could be completely handled
6609 hppa_force_relocation (fixp
)
6612 struct hppa_fix_struct
*hppa_fixp
;
6615 hppa_fixp
= (struct hppa_fix_struct
*) fixp
->tc_fix_data
;
6617 if (fixp
->fx_r_type
== R_HPPA_ENTRY
|| fixp
->fx_r_type
== R_HPPA_EXIT
6618 || fixp
->fx_r_type
== R_HPPA_BEGIN_BRTAB
6619 || fixp
->fx_r_type
== R_HPPA_END_BRTAB
6620 || fixp
->fx_r_type
== R_HPPA_BEGIN_TRY
6621 || fixp
->fx_r_type
== R_HPPA_END_TRY
6622 || (fixp
->fx_addsy
!= NULL
&& fixp
->fx_subsy
!= NULL
6623 && (hppa_fixp
->segment
->flags
& SEC_CODE
) != 0))
6627 #define arg_reloc_stub_needed(CALLER, CALLEE) \
6628 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
6630 /* It is necessary to force PC-relative calls/jumps to have a relocation
6631 entry if they're going to need either a argument relocation or long
6632 call stub. FIXME. Can't we need the same for absolute calls? */
6633 if (fixp
->fx_pcrel
&& fixp
->fx_addsy
6634 && (arg_reloc_stub_needed ((long) ((obj_symbol_type
*)
6635 symbol_get_bfdsym (fixp
->fx_addsy
))->tc_data
.ap
.hppa_arg_reloc
,
6636 hppa_fixp
->fx_arg_reloc
)))
6638 distance
= (fixp
->fx_offset
+ S_GET_VALUE (fixp
->fx_addsy
)
6639 - md_pcrel_from (fixp
));
6640 /* Now check and see if we're going to need a long-branch stub. */
6641 if (fixp
->fx_r_type
== R_HPPA_PCREL_CALL
6642 && (distance
> 262143 || distance
< -262144))
6645 if (fixp
->fx_r_type
== R_HPPA_ABS_CALL
)
6647 #undef arg_reloc_stub_needed
6649 /* No need (yet) to force another relocations to be emitted. */
6653 /* Now for some ELF specific code. FIXME. */
6655 /* Mark the end of a function so that it's possible to compute
6656 the size of the function in hppa_elf_final_processing. */
6659 hppa_elf_mark_end_of_function ()
6661 /* ELF does not have EXIT relocations. All we do is create a
6662 temporary symbol marking the end of the function. */
6663 char *name
= (char *)
6664 xmalloc (strlen ("L$\001end_") +
6665 strlen (S_GET_NAME (last_call_info
->start_symbol
)) + 1);
6671 strcpy (name
, "L$\001end_");
6672 strcat (name
, S_GET_NAME (last_call_info
->start_symbol
));
6674 /* If we have a .exit followed by a .procend, then the
6675 symbol will have already been defined. */
6676 symbolP
= symbol_find (name
);
6679 /* The symbol has already been defined! This can
6680 happen if we have a .exit followed by a .procend.
6682 This is *not* an error. All we want to do is free
6683 the memory we just allocated for the name and continue. */
6688 /* symbol value should be the offset of the
6689 last instruction of the function */
6690 symbolP
= symbol_new (name
, now_seg
, (valueT
) (frag_now_fix () - 4),
6694 S_CLEAR_EXTERNAL (symbolP
);
6695 symbol_table_insert (symbolP
);
6699 last_call_info
->end_symbol
= symbolP
;
6701 as_bad (_("Symbol '%s' could not be created."), name
);
6705 as_bad (_("No memory for symbol name."));
6709 /* For ELF, this function serves one purpose: to setup the st_size
6710 field of STT_FUNC symbols. To do this, we need to scan the
6711 call_info structure list, determining st_size in by taking the
6712 difference in the address of the beginning/end marker symbols. */
6715 elf_hppa_final_processing ()
6717 struct call_info
*call_info_pointer
;
6719 for (call_info_pointer
= call_info_root
;
6721 call_info_pointer
= call_info_pointer
->ci_next
)
6723 elf_symbol_type
*esym
6724 = ((elf_symbol_type
*)
6725 symbol_get_bfdsym (call_info_pointer
->start_symbol
));
6726 esym
->internal_elf_sym
.st_size
=
6727 S_GET_VALUE (call_info_pointer
->end_symbol
)
6728 - S_GET_VALUE (call_info_pointer
->start_symbol
) + 4;