* config/tc-hppa.c (hppa_elf_mark_end_of_function): New function.
[deliverable/binutils-gdb.git] / gas / config / tc-hppa.c
1 /* tc-hppa.c -- Assemble for the PA
2 Copyright (C) 1989 Free Software Foundation, Inc.
3
4 This file is part of GAS, the GNU Assembler.
5
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
9 any later version.
10
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21 /* HP PA-RISC support was contributed by the Center for Software Science
22 at the University of Utah. */
23
24 #include <stdio.h>
25 #include <ctype.h>
26
27 #include "as.h"
28 #include "subsegs.h"
29
30 #include "../bfd/libhppa.h"
31 #include "../bfd/libbfd.h"
32
33 /* Be careful, this file includes data *declarations*. */
34 #include "opcode/hppa.h"
35
36 /* A "convient" place to put object file dependencies which do
37 not need to be seen outside of tc-hppa.c. */
38 #ifdef OBJ_ELF
39 /* Names of various debugging spaces/subspaces. */
40 #define GDB_DEBUG_SPACE_NAME ".stab"
41 #define GDB_STRINGS_SUBSPACE_NAME ".stabstr"
42 #define GDB_SYMBOLS_SUBSPACE_NAME ".stab"
43 #define UNWIND_SECTION_NAME ".hppa_unwind"
44 /* Nonzero if CODE is a fixup code needing further processing. */
45
46 /* Object file formats specify relocation types. */
47 typedef elf32_hppa_reloc_type reloc_type;
48
49 /* Object file formats specify BFD symbol types. */
50 typedef elf_symbol_type obj_symbol_type;
51
52 /* How to generate a relocation. */
53 #define hppa_gen_reloc_type hppa_elf_gen_reloc_type
54
55 /* Who knows. */
56 #define obj_version obj_elf_version
57
58 /* Use space aliases. */
59 #define USE_ALIASES 1
60
61 /* Some local functions only used by ELF. */
62 static void pa_build_symextn_section PARAMS ((void));
63 static void hppa_tc_make_symextn_section PARAMS ((void));
64 #endif
65
66 #ifdef OBJ_SOM
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$"
72
73 /* Object file formats specify relocation types. */
74 typedef int reloc_type;
75
76 /* Who knows. */
77 #define obj_version obj_som_version
78
79 /* Do not use space aliases. */
80 #define USE_ALIASES 0
81
82 /* How to generate a relocation. */
83 #define hppa_gen_reloc_type hppa_som_gen_reloc_type
84
85 /* Object file formats specify BFD symbol types. */
86 typedef som_symbol_type obj_symbol_type;
87 #endif
88
89 /* Various structures and types used internally in tc-hppa.c. */
90
91 /* Unwind table and descriptor. FIXME: Sync this with GDB version. */
92
93 struct unwind_desc
94 {
95 unsigned int cannot_unwind:1;
96 unsigned int millicode:1;
97 unsigned int millicode_save_rest:1;
98 unsigned int region_desc:2;
99 unsigned int save_sr:2;
100 unsigned int entry_fr:4;
101 unsigned int entry_gr:5;
102 unsigned int args_stored:1;
103 unsigned int call_fr:5;
104 unsigned int call_gr:5;
105 unsigned int save_sp:1;
106 unsigned int save_rp:1;
107 unsigned int save_rp_in_frame:1;
108 unsigned int extn_ptr_defined:1;
109 unsigned int cleanup_defined:1;
110
111 unsigned int hpe_interrupt_marker:1;
112 unsigned int hpux_interrupt_marker:1;
113 unsigned int reserved:3;
114 unsigned int frame_size:27;
115 };
116
117 struct unwind_table
118 {
119 /* Starting and ending offsets of the region described by
120 descriptor. */
121 unsigned int start_offset;
122 unsigned int end_offset;
123 struct unwind_desc descriptor;
124 };
125
126 /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to
127 control the entry and exit code they generate. It is also used in
128 creation of the correct stack unwind descriptors.
129
130 NOTE: GAS does not support .enter and .leave for the generation of
131 prologues and epilogues. FIXME.
132
133 The fields in structure roughly correspond to the arguments available on the
134 .callinfo pseudo-op. */
135
136 struct call_info
137 {
138 /* Should sr3 be saved in the prologue? */
139 int entry_sr;
140
141 /* Does this function make calls? */
142 int makes_calls;
143
144 /* The unwind descriptor being built. */
145 struct unwind_table ci_unwind;
146
147 /* Name of this function. */
148 symbolS *start_symbol;
149
150 /* (temporary) symbol used to mark the end of this function. */
151 symbolS *end_symbol;
152
153 /* frags associated with start and end of this function. */
154 fragS *start_frag;
155 fragS *end_frag;
156
157 /* frags for starting/ending offset of this descriptor. */
158 fragS *start_offset_frag;
159 fragS *end_offset_frag;
160
161 /* The location within {start,end}_offset_frag to find the
162 {start,end}_offset. */
163 int start_frag_where;
164 int end_frag_where;
165
166 /* Fixups (relocations) for start_offset and end_offset. */
167 fixS *start_fix;
168 fixS *end_fix;
169
170 /* Next entry in the chain. */
171 struct call_info *ci_next;
172 };
173
174 /* Operand formats for FP instructions. Note not all FP instructions
175 allow all four formats to be used (for example fmpysub only allows
176 SGL and DBL). */
177 typedef enum
178 {
179 SGL, DBL, ILLEGAL_FMT, QUAD
180 }
181 fp_operand_format;
182
183 /* This fully describes the symbol types which may be attached to
184 an EXPORT or IMPORT directive. Only SOM uses this formation
185 (ELF has no need for it). */
186 typedef enum
187 {
188 SYMBOL_TYPE_UNKNOWN,
189 SYMBOL_TYPE_ABSOLUTE,
190 SYMBOL_TYPE_CODE,
191 SYMBOL_TYPE_DATA,
192 SYMBOL_TYPE_ENTRY,
193 SYMBOL_TYPE_MILLICODE,
194 SYMBOL_TYPE_PLABEL,
195 SYMBOL_TYPE_PRI_PROG,
196 SYMBOL_TYPE_SEC_PROG,
197 }
198 pa_symbol_type;
199
200 /* This structure contains information needed to assemble
201 individual instructions. */
202 struct pa_it
203 {
204 /* Holds the opcode after parsing by pa_ip. */
205 unsigned long opcode;
206
207 /* Holds an expression associated with the current instruction. */
208 expressionS exp;
209
210 /* Does this instruction use PC-relative addressing. */
211 int pcrel;
212
213 /* Floating point formats for operand1 and operand2. */
214 fp_operand_format fpof1;
215 fp_operand_format fpof2;
216
217 /* Holds the field selector for this instruction
218 (for example L%, LR%, etc). */
219 long field_selector;
220
221 /* Holds any argument relocation bits associated with this
222 instruction. (instruction should be some sort of call). */
223 long arg_reloc;
224
225 /* The format specification for this instruction. */
226 int format;
227
228 /* The relocation (if any) associated with this instruction. */
229 reloc_type reloc;
230 };
231
232 /* PA-89 floating point registers are arranged like this:
233
234
235 +--------------+--------------+
236 | 0 or 16L | 16 or 16R |
237 +--------------+--------------+
238 | 1 or 17L | 17 or 17R |
239 +--------------+--------------+
240 | | |
241
242 . . .
243 . . .
244 . . .
245
246 | | |
247 +--------------+--------------+
248 | 14 or 30L | 30 or 30R |
249 +--------------+--------------+
250 | 15 or 31L | 31 or 31R |
251 +--------------+--------------+
252
253
254 The following is a version of pa_parse_number that
255 handles the L/R notation and returns the correct
256 value to put into the instruction register field.
257 The correct value to put into the instruction is
258 encoded in the structure 'pa_89_fp_reg_struct'. */
259
260 struct pa_89_fp_reg_struct
261 {
262 /* The register number. */
263 char number_part;
264
265 /* L/R selector. */
266 char l_r_select;
267 };
268
269 /* Additional information needed to build argument relocation stubs. */
270 struct call_desc
271 {
272 /* The argument relocation specification. */
273 unsigned int arg_reloc;
274
275 /* Number of arguments. */
276 unsigned int arg_count;
277 };
278
279 /* This structure defines an entry in the subspace dictionary
280 chain. */
281
282 struct subspace_dictionary_chain
283 {
284 /* Index of containing space. */
285 unsigned long ssd_space_index;
286
287 /* Nonzero if this space has been defined by the user code. */
288 unsigned int ssd_defined;
289
290 /* Which quadrant within the space this subspace should be loaded into. */
291 unsigned char ssd_quadrant;
292
293 /* Alignment (in bytes) for this subspace. */
294 unsigned long ssd_alignment;
295
296 /* Access control bits to determine read/write/execute permissions
297 as well as gateway privilege promotions. */
298 unsigned char ssd_access_control_bits;
299
300 /* A sorting key so that it is possible to specify ordering of
301 subspaces within a space. */
302 unsigned char ssd_sort_key;
303
304 /* Nonzero of this space should be zero filled. */
305 unsigned long ssd_zero;
306
307 /* Nonzero if this is a common subspace. */
308 unsigned char ssd_common;
309
310 /* Nonzero if this is a common subspace which allows symbols to be
311 multiply defined. */
312 unsigned char ssd_dup_common;
313
314 /* Nonzero if this subspace is loadable. Note loadable subspaces
315 must be contained within loadable spaces; unloadable subspaces
316 must be contained in unloadable spaces. */
317 unsigned char ssd_loadable;
318
319 /* Nonzero if this subspace contains only code. */
320 unsigned char ssd_code_only;
321
322 /* Starting offset of this subspace. */
323 unsigned long ssd_subspace_start;
324
325 /* Length of this subspace. */
326 unsigned long ssd_subspace_length;
327
328 /* Name of this subspace. */
329 char *ssd_name;
330
331 /* GAS segment and subsegment associated with this subspace. */
332 asection *ssd_seg;
333 int ssd_subseg;
334
335 /* Index of this subspace within the subspace dictionary of the object
336 file. Not used until object file is written. */
337 int object_file_index;
338
339 /* The size of the last alignment request for this subspace. */
340 int ssd_last_align;
341
342 /* Next space in the subspace dictionary chain. */
343 struct subspace_dictionary_chain *ssd_next;
344 };
345
346 typedef struct subspace_dictionary_chain ssd_chain_struct;
347
348 /* This structure defines an entry in the subspace dictionary
349 chain. */
350
351 struct space_dictionary_chain
352 {
353
354 /* Holds the index into the string table of the name of this
355 space. */
356 unsigned int sd_name_index;
357
358 /* Nonzero if the space is loadable. */
359 unsigned int sd_loadable;
360
361 /* Nonzero if this space has been defined by the user code or
362 as a default space. */
363 unsigned int sd_defined;
364
365 /* Nonzero if this spaces has been defined by the user code. */
366 unsigned int sd_user_defined;
367
368 /* Nonzero if this space is not sharable. */
369 unsigned int sd_private;
370
371 /* The space number (or index). */
372 unsigned int sd_spnum;
373
374 /* The sort key for this space. May be used to determine how to lay
375 out the spaces within the object file. */
376 unsigned char sd_sort_key;
377
378 /* The name of this subspace. */
379 char *sd_name;
380
381 /* GAS segment to which this subspace corresponds. */
382 asection *sd_seg;
383
384 /* Current subsegment number being used. */
385 int sd_last_subseg;
386
387 /* The chain of subspaces contained within this space. */
388 ssd_chain_struct *sd_subspaces;
389
390 /* The next entry in the space dictionary chain. */
391 struct space_dictionary_chain *sd_next;
392 };
393
394 typedef struct space_dictionary_chain sd_chain_struct;
395
396 /* Structure for previous label tracking. Needed so that alignments,
397 callinfo declarations, etc can be easily attached to a particular
398 label. */
399 typedef struct label_symbol_struct
400 {
401 struct symbol *lss_label;
402 sd_chain_struct *lss_space;
403 struct label_symbol_struct *lss_next;
404 }
405 label_symbol_struct;
406
407 /* This structure defines attributes of the default subspace
408 dictionary entries. */
409
410 struct default_subspace_dict
411 {
412 /* Name of the subspace. */
413 char *name;
414
415 /* FIXME. Is this still needed? */
416 char defined;
417
418 /* Nonzero if this subspace is loadable. */
419 char loadable;
420
421 /* Nonzero if this subspace contains only code. */
422 char code_only;
423
424 /* Nonzero if this is a common subspace. */
425 char common;
426
427 /* Nonzero if this is a common subspace which allows symbols
428 to be multiply defined. */
429 char dup_common;
430
431 /* Nonzero if this subspace should be zero filled. */
432 char zero;
433
434 /* Sort key for this subspace. */
435 unsigned char sort;
436
437 /* Access control bits for this subspace. Can represent RWX access
438 as well as privilege level changes for gateways. */
439 int access;
440
441 /* Index of containing space. */
442 int space_index;
443
444 /* Alignment (in bytes) of this subspace. */
445 int alignment;
446
447 /* Quadrant within space where this subspace should be loaded. */
448 int quadrant;
449
450 /* An index into the default spaces array. */
451 int def_space_index;
452
453 /* An alias for this section (or NULL if no alias exists). */
454 char *alias;
455
456 /* Subsegment associated with this subspace. */
457 subsegT subsegment;
458 };
459
460 /* This structure defines attributes of the default space
461 dictionary entries. */
462
463 struct default_space_dict
464 {
465 /* Name of the space. */
466 char *name;
467
468 /* Space number. It is possible to identify spaces within
469 assembly code numerically! */
470 int spnum;
471
472 /* Nonzero if this space is loadable. */
473 char loadable;
474
475 /* Nonzero if this space is "defined". FIXME is still needed */
476 char defined;
477
478 /* Nonzero if this space can not be shared. */
479 char private;
480
481 /* Sort key for this space. */
482 unsigned char sort;
483
484 /* Segment associated with this space. */
485 asection *segment;
486
487 /* An alias for this section (or NULL if no alias exists). */
488 char *alias;
489 };
490
491 /* Extra information needed to perform fixups (relocations) on the PA. */
492 struct hppa_fix_struct
493 {
494 /* The field selector. */
495 enum hppa_reloc_field_selector_type fx_r_field;
496
497 /* Type of fixup. */
498 int fx_r_type;
499
500 /* Format of fixup. */
501 int fx_r_format;
502
503 /* Argument relocation bits. */
504 long fx_arg_reloc;
505
506 /* The unwind descriptor associated with this fixup. */
507 char fx_unwind[8];
508 };
509
510 /* Structure to hold information about predefined registers. */
511
512 struct pd_reg
513 {
514 char *name;
515 int value;
516 };
517
518 /* This structure defines the mapping from a FP condition string
519 to a condition number which can be recorded in an instruction. */
520 struct fp_cond_map
521 {
522 char *string;
523 int cond;
524 };
525
526 /* This structure defines a mapping from a field selector
527 string to a field selector type. */
528 struct selector_entry
529 {
530 char *prefix;
531 int field_selector;
532 };
533
534 /* Prototypes for functions local to tc-hppa.c. */
535
536 static fp_operand_format pa_parse_fp_format PARAMS ((char **s));
537 static void pa_cons PARAMS ((int));
538 static void pa_data PARAMS ((int));
539 static void pa_desc PARAMS ((int));
540 static void pa_float_cons PARAMS ((int));
541 static void pa_fill PARAMS ((int));
542 static void pa_lcomm PARAMS ((int));
543 static void pa_lsym PARAMS ((int));
544 static void pa_stringer PARAMS ((int));
545 static void pa_text PARAMS ((int));
546 static void pa_version PARAMS ((int));
547 static int pa_parse_fp_cmp_cond PARAMS ((char **));
548 static int get_expression PARAMS ((char *));
549 static int pa_get_absolute_expression PARAMS ((struct pa_it *, char **));
550 static int evaluate_absolute PARAMS ((struct pa_it *));
551 static unsigned int pa_build_arg_reloc PARAMS ((char *));
552 static unsigned int pa_align_arg_reloc PARAMS ((unsigned int, unsigned int));
553 static int pa_parse_nullif PARAMS ((char **));
554 static int pa_parse_nonneg_cmpsub_cmpltr PARAMS ((char **, int));
555 static int pa_parse_neg_cmpsub_cmpltr PARAMS ((char **, int));
556 static int pa_parse_neg_add_cmpltr PARAMS ((char **, int));
557 static int pa_parse_nonneg_add_cmpltr PARAMS ((char **, int));
558 static void pa_block PARAMS ((int));
559 static void pa_call PARAMS ((int));
560 static void pa_call_args PARAMS ((struct call_desc *));
561 static void pa_callinfo PARAMS ((int));
562 static void pa_code PARAMS ((int));
563 static void pa_comm PARAMS ((int));
564 static void pa_copyright PARAMS ((int));
565 static void pa_end PARAMS ((int));
566 static void pa_enter PARAMS ((int));
567 static void pa_entry PARAMS ((int));
568 static void pa_equ PARAMS ((int));
569 static void pa_exit PARAMS ((int));
570 static void pa_export PARAMS ((int));
571 static void pa_type_args PARAMS ((symbolS *, int));
572 static void pa_import PARAMS ((int));
573 static void pa_label PARAMS ((int));
574 static void pa_leave PARAMS ((int));
575 static void pa_origin PARAMS ((int));
576 static void pa_proc PARAMS ((int));
577 static void pa_procend PARAMS ((int));
578 static void pa_space PARAMS ((int));
579 static void pa_spnum PARAMS ((int));
580 static void pa_subspace PARAMS ((int));
581 static void pa_param PARAMS ((int));
582 static void pa_undefine_label PARAMS ((void));
583 static int need_89_opcode PARAMS ((struct pa_it *,
584 struct pa_89_fp_reg_struct *));
585 static int pa_parse_number PARAMS ((char **, struct pa_89_fp_reg_struct *));
586 static label_symbol_struct *pa_get_label PARAMS ((void));
587 static sd_chain_struct *create_new_space PARAMS ((char *, int, char,
588 char, char, char,
589 asection *, int));
590 static ssd_chain_struct *create_new_subspace PARAMS ((sd_chain_struct *,
591 char *, char, char,
592 char, char, char,
593 char, int, int, int,
594 int, asection *));
595 static ssd_chain_struct *update_subspace PARAMS ((sd_chain_struct *,
596 char *, char, char, char,
597 char, char, char, int,
598 int, int, int,
599 asection *));
600 static sd_chain_struct *is_defined_space PARAMS ((char *));
601 static ssd_chain_struct *is_defined_subspace PARAMS ((char *));
602 static sd_chain_struct *pa_segment_to_space PARAMS ((asection *));
603 static ssd_chain_struct *pa_subsegment_to_subspace PARAMS ((asection *,
604 subsegT));
605 static sd_chain_struct *pa_find_space_by_number PARAMS ((int));
606 static unsigned int pa_subspace_start PARAMS ((sd_chain_struct *, int));
607 static void pa_ip PARAMS ((char *));
608 static void fix_new_hppa PARAMS ((fragS *, int, short int, symbolS *,
609 long, expressionS *, int,
610 bfd_reloc_code_real_type,
611 enum hppa_reloc_field_selector_type,
612 int, long, char *));
613 static void md_apply_fix_1 PARAMS ((fixS *, long));
614 static int is_end_of_statement PARAMS ((void));
615 static int reg_name_search PARAMS ((char *));
616 static int pa_chk_field_selector PARAMS ((char **));
617 static int is_same_frag PARAMS ((fragS *, fragS *));
618 static void pa_build_unwind_subspace PARAMS ((struct call_info *));
619 static void process_exit PARAMS ((void));
620 static sd_chain_struct *pa_parse_space_stmt PARAMS ((char *, int));
621 static int log2 PARAMS ((int));
622 static int pa_next_subseg PARAMS ((sd_chain_struct *));
623 static unsigned int pa_stringer_aux PARAMS ((char *));
624 static void pa_spaces_begin PARAMS ((void));
625 static void hppa_elf_mark_end_of_function PARAMS ((void));
626
627 /* File and gloally scoped variable declarations. */
628
629 /* Root and final entry in the space chain. */
630 static sd_chain_struct *space_dict_root;
631 static sd_chain_struct *space_dict_last;
632
633 /* The current space and subspace. */
634 static sd_chain_struct *current_space;
635 static ssd_chain_struct *current_subspace;
636
637 /* Root of the call_info chain. */
638 static struct call_info *call_info_root;
639
640 /* The last call_info (for functions) structure
641 seen so it can be associated with fixups and
642 function labels. */
643 static struct call_info *last_call_info;
644
645 /* The last call description (for actual calls). */
646 static struct call_desc last_call_desc;
647
648 /* Relaxation isn't supported for the PA yet. */
649 const relax_typeS md_relax_table[] =
650 {0};
651
652 /* Jumps are always the same size -- one instruction. */
653 int md_short_jump_size = 4;
654 int md_long_jump_size = 4;
655
656 /* handle of the OPCODE hash table */
657 static struct hash_control *op_hash = NULL;
658
659 /* This array holds the chars that always start a comment. If the
660 pre-processor is disabled, these aren't very useful. */
661 const char comment_chars[] = ";";
662
663 /* Table of pseudo ops for the PA. FIXME -- how many of these
664 are now redundant with the overall GAS and the object file
665 dependent tables? */
666 const pseudo_typeS md_pseudo_table[] =
667 {
668 /* align pseudo-ops on the PA specify the actual alignment requested,
669 not the log2 of the requested alignment. */
670 {"align", s_align_bytes, 8},
671 {"ALIGN", s_align_bytes, 8},
672 {"block", pa_block, 1},
673 {"BLOCK", pa_block, 1},
674 {"blockz", pa_block, 0},
675 {"BLOCKZ", pa_block, 0},
676 {"byte", pa_cons, 1},
677 {"BYTE", pa_cons, 1},
678 {"call", pa_call, 0},
679 {"CALL", pa_call, 0},
680 {"callinfo", pa_callinfo, 0},
681 {"CALLINFO", pa_callinfo, 0},
682 {"code", pa_code, 0},
683 {"CODE", pa_code, 0},
684 {"comm", pa_comm, 0},
685 {"COMM", pa_comm, 0},
686 {"copyright", pa_copyright, 0},
687 {"COPYRIGHT", pa_copyright, 0},
688 {"data", pa_data, 0},
689 {"DATA", pa_data, 0},
690 {"desc", pa_desc, 0},
691 {"DESC", pa_desc, 0},
692 {"double", pa_float_cons, 'd'},
693 {"DOUBLE", pa_float_cons, 'd'},
694 {"end", pa_end, 0},
695 {"END", pa_end, 0},
696 {"enter", pa_enter, 0},
697 {"ENTER", pa_enter, 0},
698 {"entry", pa_entry, 0},
699 {"ENTRY", pa_entry, 0},
700 {"equ", pa_equ, 0},
701 {"EQU", pa_equ, 0},
702 {"exit", pa_exit, 0},
703 {"EXIT", pa_exit, 0},
704 {"export", pa_export, 0},
705 {"EXPORT", pa_export, 0},
706 {"fill", pa_fill, 0},
707 {"FILL", pa_fill, 0},
708 {"float", pa_float_cons, 'f'},
709 {"FLOAT", pa_float_cons, 'f'},
710 {"half", pa_cons, 2},
711 {"HALF", pa_cons, 2},
712 {"import", pa_import, 0},
713 {"IMPORT", pa_import, 0},
714 {"int", pa_cons, 4},
715 {"INT", pa_cons, 4},
716 {"label", pa_label, 0},
717 {"LABEL", pa_label, 0},
718 {"lcomm", pa_lcomm, 0},
719 {"LCOMM", pa_lcomm, 0},
720 {"leave", pa_leave, 0},
721 {"LEAVE", pa_leave, 0},
722 {"long", pa_cons, 4},
723 {"LONG", pa_cons, 4},
724 {"lsym", pa_lsym, 0},
725 {"LSYM", pa_lsym, 0},
726 {"octa", pa_cons, 16},
727 {"OCTA", pa_cons, 16},
728 {"org", pa_origin, 0},
729 {"ORG", pa_origin, 0},
730 {"origin", pa_origin, 0},
731 {"ORIGIN", pa_origin, 0},
732 {"param", pa_param, 0},
733 {"PARAM", pa_param, 0},
734 {"proc", pa_proc, 0},
735 {"PROC", pa_proc, 0},
736 {"procend", pa_procend, 0},
737 {"PROCEND", pa_procend, 0},
738 {"quad", pa_cons, 8},
739 {"QUAD", pa_cons, 8},
740 {"reg", pa_equ, 1},
741 {"REG", pa_equ, 1},
742 {"short", pa_cons, 2},
743 {"SHORT", pa_cons, 2},
744 {"single", pa_float_cons, 'f'},
745 {"SINGLE", pa_float_cons, 'f'},
746 {"space", pa_space, 0},
747 {"SPACE", pa_space, 0},
748 {"spnum", pa_spnum, 0},
749 {"SPNUM", pa_spnum, 0},
750 {"string", pa_stringer, 0},
751 {"STRING", pa_stringer, 0},
752 {"stringz", pa_stringer, 1},
753 {"STRINGZ", pa_stringer, 1},
754 {"subspa", pa_subspace, 0},
755 {"SUBSPA", pa_subspace, 0},
756 {"text", pa_text, 0},
757 {"TEXT", pa_text, 0},
758 {"version", pa_version, 0},
759 {"VERSION", pa_version, 0},
760 {"word", pa_cons, 4},
761 {"WORD", pa_cons, 4},
762 {NULL, 0, 0}
763 };
764
765 /* This array holds the chars that only start a comment at the beginning of
766 a line. If the line seems to have the form '# 123 filename'
767 .line and .file directives will appear in the pre-processed output.
768
769 Note that input_file.c hand checks for '#' at the beginning of the
770 first line of the input file. This is because the compiler outputs
771 #NO_APP at the beginning of its output.
772
773 Also note that '/*' will always start a comment. */
774 const char line_comment_chars[] = "#";
775
776 /* This array holds the characters which act as line separators. */
777 const char line_separator_chars[] = "!";
778
779 /* Chars that can be used to separate mant from exp in floating point nums. */
780 const char EXP_CHARS[] = "eE";
781
782 /* Chars that mean this number is a floating point constant.
783 As in 0f12.456 or 0d1.2345e12.
784
785 Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
786 changed in read.c. Ideally it shouldn't hae to know abou it at
787 all, but nothing is ideal around here. */
788 const char FLT_CHARS[] = "rRsSfFdDxXpP";
789
790 static struct pa_it the_insn;
791
792 /* Points to the end of an expression just parsed by get_expressoin
793 and friends. FIXME. This shouldn't be handled with a file-global
794 variable. */
795 static char *expr_end;
796
797 /* Nonzero if a .callinfo appeared within the current procedure. */
798 static int callinfo_found;
799
800 /* Nonzero if the assembler is currently within a .entry/.exit pair. */
801 static int within_entry_exit;
802
803 /* Nonzero if the assembler is currently within a procedure definition. */
804 static int within_procedure;
805
806 /* Handle on strucutre which keep track of the last symbol
807 seen in each subspace. */
808 static label_symbol_struct *label_symbols_rootp = NULL;
809
810 /* Holds the last field selector. */
811 static int hppa_field_selector;
812
813 /* Nonzero if errors are to be printed. */
814 static int print_errors = 1;
815
816 /* List of registers that are pre-defined:
817
818 Each general register has one predefined name of the form
819 %r<REGNUM> which has the value <REGNUM>.
820
821 Space and control registers are handled in a similar manner,
822 but use %sr<REGNUM> and %cr<REGNUM> as their predefined names.
823
824 Likewise for the floating point registers, but of the form
825 %fr<REGNUM>. Floating point registers have additional predefined
826 names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which
827 again have the value <REGNUM>.
828
829 Many registers also have synonyms:
830
831 %r26 - %r23 have %arg0 - %arg3 as synonyms
832 %r28 - %r29 have %ret0 - %ret1 as synonyms
833 %r30 has %sp as a synonym
834 %r27 has %dp as a synonym
835 %r2 has %rp as a synonym
836
837 Almost every control register has a synonym; they are not listed
838 here for brevity.
839
840 The table is sorted. Suitable for searching by a binary search. */
841
842 static const struct pd_reg pre_defined_registers[] =
843 {
844 {"%arg0", 26},
845 {"%arg1", 25},
846 {"%arg2", 24},
847 {"%arg3", 23},
848 {"%cr0", 0},
849 {"%cr10", 10},
850 {"%cr11", 11},
851 {"%cr12", 12},
852 {"%cr13", 13},
853 {"%cr14", 14},
854 {"%cr15", 15},
855 {"%cr16", 16},
856 {"%cr17", 17},
857 {"%cr18", 18},
858 {"%cr19", 19},
859 {"%cr20", 20},
860 {"%cr21", 21},
861 {"%cr22", 22},
862 {"%cr23", 23},
863 {"%cr24", 24},
864 {"%cr25", 25},
865 {"%cr26", 26},
866 {"%cr27", 27},
867 {"%cr28", 28},
868 {"%cr29", 29},
869 {"%cr30", 30},
870 {"%cr31", 31},
871 {"%cr8", 8},
872 {"%cr9", 9},
873 {"%dp", 27},
874 {"%eiem", 15},
875 {"%eirr", 23},
876 {"%fr0", 0},
877 {"%fr0L", 0},
878 {"%fr0R", 0},
879 {"%fr1", 1},
880 {"%fr10", 10},
881 {"%fr10L", 10},
882 {"%fr10R", 10},
883 {"%fr11", 11},
884 {"%fr11L", 11},
885 {"%fr11R", 11},
886 {"%fr12", 12},
887 {"%fr12L", 12},
888 {"%fr12R", 12},
889 {"%fr13", 13},
890 {"%fr13L", 13},
891 {"%fr13R", 13},
892 {"%fr14", 14},
893 {"%fr14L", 14},
894 {"%fr14R", 14},
895 {"%fr15", 15},
896 {"%fr15L", 15},
897 {"%fr15R", 15},
898 {"%fr16", 16},
899 {"%fr16L", 16},
900 {"%fr16R", 16},
901 {"%fr17", 17},
902 {"%fr17L", 17},
903 {"%fr17R", 17},
904 {"%fr18", 18},
905 {"%fr18L", 18},
906 {"%fr18R", 18},
907 {"%fr19", 19},
908 {"%fr19L", 19},
909 {"%fr19R", 19},
910 {"%fr1L", 1},
911 {"%fr1R", 1},
912 {"%fr2", 2},
913 {"%fr20", 20},
914 {"%fr20L", 20},
915 {"%fr20R", 20},
916 {"%fr21", 21},
917 {"%fr21L", 21},
918 {"%fr21R", 21},
919 {"%fr22", 22},
920 {"%fr22L", 22},
921 {"%fr22R", 22},
922 {"%fr23", 23},
923 {"%fr23L", 23},
924 {"%fr23R", 23},
925 {"%fr24", 24},
926 {"%fr24L", 24},
927 {"%fr24R", 24},
928 {"%fr25", 25},
929 {"%fr25L", 25},
930 {"%fr25R", 25},
931 {"%fr26", 26},
932 {"%fr26L", 26},
933 {"%fr26R", 26},
934 {"%fr27", 27},
935 {"%fr27L", 27},
936 {"%fr27R", 27},
937 {"%fr28", 28},
938 {"%fr28L", 28},
939 {"%fr28R", 28},
940 {"%fr29", 29},
941 {"%fr29L", 29},
942 {"%fr29R", 29},
943 {"%fr2L", 2},
944 {"%fr2R", 2},
945 {"%fr3", 3},
946 {"%fr30", 30},
947 {"%fr30L", 30},
948 {"%fr30R", 30},
949 {"%fr31", 31},
950 {"%fr31L", 31},
951 {"%fr31R", 31},
952 {"%fr3L", 3},
953 {"%fr3R", 3},
954 {"%fr4", 4},
955 {"%fr4L", 4},
956 {"%fr4R", 4},
957 {"%fr5", 5},
958 {"%fr5L", 5},
959 {"%fr5R", 5},
960 {"%fr6", 6},
961 {"%fr6L", 6},
962 {"%fr6R", 6},
963 {"%fr7", 7},
964 {"%fr7L", 7},
965 {"%fr7R", 7},
966 {"%fr8", 8},
967 {"%fr8L", 8},
968 {"%fr8R", 8},
969 {"%fr9", 9},
970 {"%fr9L", 9},
971 {"%fr9R", 9},
972 {"%hta", 25},
973 {"%iir", 19},
974 {"%ior", 21},
975 {"%ipsw", 22},
976 {"%isr", 20},
977 {"%itmr", 16},
978 {"%iva", 14},
979 {"%pcoq", 18},
980 {"%pcsq", 17},
981 {"%pidr1", 8},
982 {"%pidr2", 9},
983 {"%pidr3", 12},
984 {"%pidr4", 13},
985 {"%ppda", 24},
986 {"%r0", 0},
987 {"%r1", 1},
988 {"%r10", 10},
989 {"%r11", 11},
990 {"%r12", 12},
991 {"%r13", 13},
992 {"%r14", 14},
993 {"%r15", 15},
994 {"%r16", 16},
995 {"%r17", 17},
996 {"%r18", 18},
997 {"%r19", 19},
998 {"%r2", 2},
999 {"%r20", 20},
1000 {"%r21", 21},
1001 {"%r22", 22},
1002 {"%r23", 23},
1003 {"%r24", 24},
1004 {"%r25", 25},
1005 {"%r26", 26},
1006 {"%r27", 27},
1007 {"%r28", 28},
1008 {"%r29", 29},
1009 {"%r3", 3},
1010 {"%r30", 30},
1011 {"%r31", 31},
1012 {"%r4", 4},
1013 {"%r4L", 4},
1014 {"%r4R", 4},
1015 {"%r5", 5},
1016 {"%r5L", 5},
1017 {"%r5R", 5},
1018 {"%r6", 6},
1019 {"%r6L", 6},
1020 {"%r6R", 6},
1021 {"%r7", 7},
1022 {"%r7L", 7},
1023 {"%r7R", 7},
1024 {"%r8", 8},
1025 {"%r8L", 8},
1026 {"%r8R", 8},
1027 {"%r9", 9},
1028 {"%r9L", 9},
1029 {"%r9R", 9},
1030 {"%rctr", 0},
1031 {"%ret0", 28},
1032 {"%ret1", 29},
1033 {"%rp", 2},
1034 {"%sar", 11},
1035 {"%sp", 30},
1036 {"%sr0", 0},
1037 {"%sr1", 1},
1038 {"%sr2", 2},
1039 {"%sr3", 3},
1040 {"%sr4", 4},
1041 {"%sr5", 5},
1042 {"%sr6", 6},
1043 {"%sr7", 7},
1044 {"%tr0", 24},
1045 {"%tr1", 25},
1046 {"%tr2", 26},
1047 {"%tr3", 27},
1048 {"%tr4", 28},
1049 {"%tr5", 29},
1050 {"%tr6", 30},
1051 {"%tr7", 31}
1052 };
1053
1054 /* This table is sorted by order of the length of the string. This is
1055 so we check for <> before we check for <. If we had a <> and checked
1056 for < first, we would get a false match. */
1057 static const struct fp_cond_map fp_cond_map[] =
1058 {
1059 {"false?", 0},
1060 {"false", 1},
1061 {"true?", 30},
1062 {"true", 31},
1063 {"!<=>", 3},
1064 {"!?>=", 8},
1065 {"!?<=", 16},
1066 {"!<>", 7},
1067 {"!>=", 11},
1068 {"!?>", 12},
1069 {"?<=", 14},
1070 {"!<=", 19},
1071 {"!?<", 20},
1072 {"?>=", 22},
1073 {"!?=", 24},
1074 {"!=t", 27},
1075 {"<=>", 29},
1076 {"=t", 5},
1077 {"?=", 6},
1078 {"?<", 10},
1079 {"<=", 13},
1080 {"!>", 15},
1081 {"?>", 18},
1082 {">=", 21},
1083 {"!<", 23},
1084 {"<>", 25},
1085 {"!=", 26},
1086 {"!?", 28},
1087 {"?", 2},
1088 {"=", 4},
1089 {"<", 9},
1090 {">", 17}
1091 };
1092
1093 static const struct selector_entry selector_table[] =
1094 {
1095 {"F'", e_fsel},
1096 {"F%", e_fsel},
1097 {"LS'", e_lssel},
1098 {"LS%", e_lssel},
1099 {"RS'", e_rssel},
1100 {"RS%", e_rssel},
1101 {"L'", e_lsel},
1102 {"L%", e_lsel},
1103 {"R'", e_rsel},
1104 {"R%", e_rsel},
1105 {"LD'", e_ldsel},
1106 {"LD%", e_ldsel},
1107 {"RD'", e_rdsel},
1108 {"RD%", e_rdsel},
1109 {"LR'", e_lrsel},
1110 {"LR%", e_lrsel},
1111 {"RR'", e_rrsel},
1112 {"RR%", e_rrsel},
1113 {"P'", e_psel},
1114 {"P%", e_psel},
1115 {"RP'", e_rpsel},
1116 {"RP%", e_rpsel},
1117 {"LP'", e_lpsel},
1118 {"LP%", e_lpsel},
1119 {"T'", e_tsel},
1120 {"T%", e_tsel},
1121 {"RT'", e_rtsel},
1122 {"RT%", e_rtsel},
1123 {"LT'", e_ltsel},
1124 {"LT%", e_ltsel},
1125 {NULL, e_fsel}
1126 };
1127
1128 /* default space and subspace dictionaries */
1129
1130 #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME
1131 #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME
1132
1133 /* pre-defined subsegments (subspaces) for the HPPA. */
1134 #define SUBSEG_CODE 0
1135 #define SUBSEG_DATA 0
1136 #define SUBSEG_LIT 1
1137 #define SUBSEG_BSS 2
1138 #define SUBSEG_UNWIND 3
1139 #define SUBSEG_GDB_STRINGS 0
1140 #define SUBSEG_GDB_SYMBOLS 1
1141
1142 static struct default_subspace_dict pa_def_subspaces[] =
1143 {
1144 {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_CODE},
1145 {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, ".data", SUBSEG_DATA},
1146 {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, ".text", SUBSEG_LIT},
1147 {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, ".bss", SUBSEG_BSS},
1148 #ifdef OBJ_ELF
1149 {"$UNWIND$", 1, 1, 0, 0, 0, 0, 64, 0x2c, 0, 4, 0, 0, ".hppa_unwind", SUBSEG_UNWIND},
1150 #endif
1151 {NULL, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
1152 };
1153
1154 static struct default_space_dict pa_def_spaces[] =
1155 {
1156 {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL, ".text"},
1157 {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL, ".data"},
1158 {NULL, 0, 0, 0, 0, 0, ASEC_NULL, NULL}
1159 };
1160
1161 /* Misc local definitions used by the assembler. */
1162
1163 /* Return nonzero if the string pointed to by S potentially represents
1164 a right or left half of a FP register */
1165 #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r')
1166 #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l')
1167
1168 /* These macros are used to maintain spaces/subspaces. */
1169 #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined
1170 #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined
1171 #define SPACE_PRIVATE(space_chain) (space_chain)->sd_private
1172 #define SPACE_LOADABLE(space_chain) (space_chain)->sd_loadable
1173 #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum
1174 #define SPACE_SORT(space_chain) (space_chain)->sd_sort_key
1175 #define SPACE_NAME(space_chain) (space_chain)->sd_name
1176 #define SPACE_NAME_INDEX(space_chain) (space_chain)->sd_name_index
1177
1178 #define SUBSPACE_SPACE_INDEX(ss_chain) (ss_chain)->ssd_space_index
1179 #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined
1180 #define SUBSPACE_QUADRANT(ss_chain) (ss_chain)->ssd_quadrant
1181 #define SUBSPACE_ALIGN(ss_chain) (ss_chain)->ssd_alignment
1182 #define SUBSPACE_ACCESS(ss_chain) (ss_chain)->ssd_access_control_bits
1183 #define SUBSPACE_SORT(ss_chain) (ss_chain)->ssd_sort_key
1184 #define SUBSPACE_COMMON(ss_chain) (ss_chain)->ssd_common
1185 #define SUBSPACE_ZERO(ss_chain) (ss_chain)->ssd_zero
1186 #define SUBSPACE_DUP_COMM(ss_chain) (ss_chain)->ssd_dup_common
1187 #define SUBSPACE_CODE_ONLY(ss_chain) (ss_chain)->ssd_code_only
1188 #define SUBSPACE_LOADABLE(ss_chain) (ss_chain)->ssd_loadable
1189 #define SUBSPACE_SUBSPACE_START(ss_chain) (ss_chain)->ssd_subspace_start
1190 #define SUBSPACE_SUBSPACE_LENGTH(ss_chain) (ss_chain)->ssd_subspace_length
1191 #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name
1192
1193 /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip
1194 main loop after insertion. */
1195
1196 #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \
1197 { \
1198 ((OPCODE) |= (FIELD) << (START)); \
1199 continue; \
1200 }
1201
1202 /* Simple range checking for FIELD againt HIGH and LOW bounds.
1203 IGNORE is used to suppress the error message. */
1204
1205 #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \
1206 { \
1207 if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \
1208 { \
1209 if (! IGNORE) \
1210 as_bad ("Field out of range [%d..%d] (%d).", (LOW), (HIGH), \
1211 (int) (FIELD));\
1212 break; \
1213 } \
1214 }
1215
1216 #define is_DP_relative(exp) \
1217 ((exp).X_op == O_subtract \
1218 && strcmp((exp).X_op_symbol->bsym->name, "$global$") == 0)
1219
1220 #define is_PC_relative(exp) \
1221 ((exp).X_op == O_subtract \
1222 && strcmp((exp).X_op_symbol->bsym->name, "$PIC_pcrel$0") == 0)
1223
1224 #define is_complex(exp) \
1225 ((exp).X_op != O_constant && (exp).X_op != O_symbol)
1226
1227 /* Actual functions to implement the PA specific code for the assembler. */
1228
1229 /* Returns a pointer to the label_symbol_struct for the current space.
1230 or NULL if no label_symbol_struct exists for the current space. */
1231
1232 static label_symbol_struct *
1233 pa_get_label ()
1234 {
1235 label_symbol_struct *label_chain;
1236 sd_chain_struct *space_chain = current_space;
1237
1238 for (label_chain = label_symbols_rootp;
1239 label_chain;
1240 label_chain = label_chain->lss_next)
1241 if (space_chain == label_chain->lss_space && label_chain->lss_label)
1242 return label_chain;
1243
1244 return NULL;
1245 }
1246
1247 /* Defines a label for the current space. If one is already defined,
1248 this function will replace it with the new label. */
1249
1250 void
1251 pa_define_label (symbol)
1252 symbolS *symbol;
1253 {
1254 label_symbol_struct *label_chain = pa_get_label ();
1255 sd_chain_struct *space_chain = current_space;
1256
1257 if (label_chain)
1258 label_chain->lss_label = symbol;
1259 else
1260 {
1261 /* Create a new label entry and add it to the head of the chain. */
1262 label_chain
1263 = (label_symbol_struct *) xmalloc (sizeof (label_symbol_struct));
1264 label_chain->lss_label = symbol;
1265 label_chain->lss_space = space_chain;
1266 label_chain->lss_next = NULL;
1267
1268 if (label_symbols_rootp)
1269 label_chain->lss_next = label_symbols_rootp;
1270
1271 label_symbols_rootp = label_chain;
1272 }
1273 }
1274
1275 /* Removes a label definition for the current space.
1276 If there is no label_symbol_struct entry, then no action is taken. */
1277
1278 static void
1279 pa_undefine_label ()
1280 {
1281 label_symbol_struct *label_chain;
1282 label_symbol_struct *prev_label_chain = NULL;
1283 sd_chain_struct *space_chain = current_space;
1284
1285 for (label_chain = label_symbols_rootp;
1286 label_chain;
1287 label_chain = label_chain->lss_next)
1288 {
1289 if (space_chain == label_chain->lss_space && label_chain->lss_label)
1290 {
1291 /* Remove the label from the chain and free its memory. */
1292 if (prev_label_chain)
1293 prev_label_chain->lss_next = label_chain->lss_next;
1294 else
1295 label_symbols_rootp = label_chain->lss_next;
1296
1297 free (label_chain);
1298 break;
1299 }
1300 prev_label_chain = label_chain;
1301 }
1302 }
1303
1304
1305 /* An HPPA-specific version of fix_new. This is required because the HPPA
1306 code needs to keep track of some extra stuff. Each call to fix_new_hppa
1307 results in the creation of an instance of an hppa_fix_struct. An
1308 hppa_fix_struct stores the extra information along with a pointer to the
1309 original fixS. This is attached to the original fixup via the
1310 tc_fix_data field. */
1311
1312 static void
1313 fix_new_hppa (frag, where, size, add_symbol, offset, exp, pcrel,
1314 r_type, r_field, r_format, arg_reloc, unwind_desc)
1315 fragS *frag;
1316 int where;
1317 short int size;
1318 symbolS *add_symbol;
1319 long offset;
1320 expressionS *exp;
1321 int pcrel;
1322 bfd_reloc_code_real_type r_type;
1323 enum hppa_reloc_field_selector_type r_field;
1324 int r_format;
1325 long arg_reloc;
1326 char *unwind_desc;
1327 {
1328 fixS *new_fix;
1329
1330 struct hppa_fix_struct *hppa_fix = (struct hppa_fix_struct *)
1331 obstack_alloc (&notes, sizeof (struct hppa_fix_struct));
1332
1333 if (exp != NULL)
1334 new_fix = fix_new_exp (frag, where, size, exp, pcrel, r_type);
1335 else
1336 new_fix = fix_new (frag, where, size, add_symbol, offset, pcrel, r_type);
1337 new_fix->tc_fix_data = hppa_fix;
1338 hppa_fix->fx_r_type = r_type;
1339 hppa_fix->fx_r_field = r_field;
1340 hppa_fix->fx_r_format = r_format;
1341 hppa_fix->fx_arg_reloc = arg_reloc;
1342 if (unwind_desc)
1343 {
1344 bcopy (unwind_desc, hppa_fix->fx_unwind, 8);
1345
1346 /* If necessary call BFD backend function to attach the
1347 unwind bits to the target dependent parts of a BFD symbol.
1348 Yuk. */
1349 #ifdef obj_attach_unwind_info
1350 obj_attach_unwind_info (add_symbol->bsym, unwind_desc);
1351 #endif
1352 }
1353
1354 /* foo-$global$ is used to access non-automatic storage. $global$
1355 is really just a marker and has served its purpose, so eliminate
1356 it now so as not to confuse write.c. */
1357 if (new_fix->fx_subsy
1358 && !strcmp (S_GET_NAME (new_fix->fx_subsy), "$global$"))
1359 new_fix->fx_subsy = NULL;
1360 }
1361
1362 /* Parse a .byte, .word, .long expression for the HPPA. Called by
1363 cons via the TC_PARSE_CONS_EXPRESSION macro. */
1364
1365 void
1366 parse_cons_expression_hppa (exp)
1367 expressionS *exp;
1368 {
1369 hppa_field_selector = pa_chk_field_selector (&input_line_pointer);
1370 expression (exp);
1371 }
1372
1373 /* This fix_new is called by cons via TC_CONS_FIX_NEW.
1374 hppa_field_selector is set by the parse_cons_expression_hppa. */
1375
1376 void
1377 cons_fix_new_hppa (frag, where, size, exp)
1378 fragS *frag;
1379 int where;
1380 int size;
1381 expressionS *exp;
1382 {
1383 unsigned int reloc_type;
1384
1385 if (is_DP_relative (*exp))
1386 reloc_type = R_HPPA_GOTOFF;
1387 else if (is_complex (*exp))
1388 reloc_type = R_HPPA_COMPLEX;
1389 else
1390 reloc_type = R_HPPA;
1391
1392 if (hppa_field_selector != e_psel && hppa_field_selector != e_fsel)
1393 as_warn ("Invalid field selector. Assuming F%%.");
1394
1395 fix_new_hppa (frag, where, size,
1396 (symbolS *) NULL, (offsetT) 0, exp, 0, reloc_type,
1397 hppa_field_selector, 32, 0, (char *) 0);
1398
1399 /* Reset field selector to its default state. */
1400 hppa_field_selector = 0;
1401 }
1402
1403 /* This function is called once, at assembler startup time. It should
1404 set up all the tables, etc. that the MD part of the assembler will need. */
1405
1406 void
1407 md_begin ()
1408 {
1409 const char *retval = NULL;
1410 int lose = 0;
1411 unsigned int i = 0;
1412
1413 last_call_info = NULL;
1414 call_info_root = NULL;
1415
1416 /* Folding of text and data segments fails miserably on the PA.
1417 Warn user and disable "-R" option. */
1418 if (flagseen['R'])
1419 {
1420 as_warn ("-R option not supported on this target.");
1421 flag_readonly_data_in_text = 0;
1422 flagseen['R'] = 0;
1423 }
1424
1425 pa_spaces_begin ();
1426
1427 op_hash = hash_new ();
1428 if (op_hash == NULL)
1429 as_fatal ("Virtual memory exhausted");
1430
1431 while (i < NUMOPCODES)
1432 {
1433 const char *name = pa_opcodes[i].name;
1434 retval = hash_insert (op_hash, name, (struct pa_opcode *) &pa_opcodes[i]);
1435 if (retval != NULL && *retval != '\0')
1436 {
1437 as_fatal ("Internal error: can't hash `%s': %s\n", name, retval);
1438 lose = 1;
1439 }
1440 do
1441 {
1442 if ((pa_opcodes[i].match & pa_opcodes[i].mask)
1443 != pa_opcodes[i].match)
1444 {
1445 fprintf (stderr, "internal error: losing opcode: `%s' \"%s\"\n",
1446 pa_opcodes[i].name, pa_opcodes[i].args);
1447 lose = 1;
1448 }
1449 ++i;
1450 }
1451 while (i < NUMOPCODES && !strcmp (pa_opcodes[i].name, name));
1452 }
1453
1454 if (lose)
1455 as_fatal ("Broken assembler. No assembly attempted.");
1456
1457 /* SOM will change text_section. To make sure we never put
1458 anything into the old one switch to the new one now. */
1459 subseg_set (text_section, 0);
1460 }
1461
1462 /* Called at the end of assembling a source file. Nothing to do
1463 at this point on the PA. */
1464
1465 void
1466 md_end ()
1467 {
1468 return;
1469 }
1470
1471 /* Assemble a single instruction storing it into a frag. */
1472 void
1473 md_assemble (str)
1474 char *str;
1475 {
1476 char *to;
1477
1478 /* The had better be something to assemble. */
1479 assert (str);
1480
1481 /* Assemble the instruction. Results are saved into "the_insn". */
1482 pa_ip (str);
1483
1484 /* Get somewhere to put the assembled instrution. */
1485 to = frag_more (4);
1486
1487 /* Output the opcode. */
1488 md_number_to_chars (to, the_insn.opcode, 4);
1489
1490 /* If necessary output more stuff. */
1491 if (the_insn.reloc != R_HPPA_NONE)
1492 fix_new_hppa (frag_now, (to - frag_now->fr_literal), 4, NULL,
1493 (offsetT) 0, &the_insn.exp, the_insn.pcrel,
1494 the_insn.reloc, the_insn.field_selector,
1495 the_insn.format, the_insn.arg_reloc, NULL);
1496
1497 }
1498
1499 /* Do the real work for assembling a single instruction. Store results
1500 into the global "the_insn" variable.
1501
1502 FIXME: Should define and use some functions/macros to handle
1503 various common insertions of information into the opcode. */
1504
1505 static void
1506 pa_ip (str)
1507 char *str;
1508 {
1509 char *error_message = "";
1510 char *s, c, *argstart, *name, *save_s;
1511 const char *args;
1512 int match = FALSE;
1513 int comma = 0;
1514 int cmpltr, nullif, flag, cond, num;
1515 unsigned long opcode;
1516 struct pa_opcode *insn;
1517
1518 /* Skip to something interesting. */
1519 for (s = str; isupper (*s) || islower (*s) || (*s >= '0' && *s <= '3'); ++s)
1520 ;
1521
1522 switch (*s)
1523 {
1524
1525 case '\0':
1526 break;
1527
1528 case ',':
1529 comma = 1;
1530
1531 /*FALLTHROUGH */
1532
1533 case ' ':
1534 *s++ = '\0';
1535 break;
1536
1537 default:
1538 as_bad ("Unknown opcode: `%s'", str);
1539 exit (1);
1540 }
1541
1542 save_s = str;
1543
1544 /* Convert everything into lower case. */
1545 while (*save_s)
1546 {
1547 if (isupper (*save_s))
1548 *save_s = tolower (*save_s);
1549 save_s++;
1550 }
1551
1552 /* Look up the opcode in the has table. */
1553 if ((insn = (struct pa_opcode *) hash_find (op_hash, str)) == NULL)
1554 {
1555 as_bad ("Unknown opcode: `%s'", str);
1556 return;
1557 }
1558
1559 if (comma)
1560 {
1561 *--s = ',';
1562 }
1563
1564 /* Mark the location where arguments for the instruction start, then
1565 start processing them. */
1566 argstart = s;
1567 for (;;)
1568 {
1569 /* Do some initialization. */
1570 opcode = insn->match;
1571 bzero (&the_insn, sizeof (the_insn));
1572
1573 the_insn.reloc = R_HPPA_NONE;
1574
1575 /* Build the opcode, checking as we go to make
1576 sure that the operands match. */
1577 for (args = insn->args;; ++args)
1578 {
1579 switch (*args)
1580 {
1581
1582 /* End of arguments. */
1583 case '\0':
1584 if (*s == '\0')
1585 match = TRUE;
1586 break;
1587
1588 case '+':
1589 if (*s == '+')
1590 {
1591 ++s;
1592 continue;
1593 }
1594 if (*s == '-')
1595 continue;
1596 break;
1597
1598 /* These must match exactly. */
1599 case '(':
1600 case ')':
1601 case ',':
1602 case ' ':
1603 if (*s++ == *args)
1604 continue;
1605 break;
1606
1607 /* Handle a 5 bit register or control register field at 10. */
1608 case 'b':
1609 case '^':
1610 num = pa_parse_number (&s, 0);
1611 CHECK_FIELD (num, 31, 0, 0);
1612 INSERT_FIELD_AND_CONTINUE (opcode, num, 21);
1613
1614 /* Handle a 5 bit register field at 15. */
1615 case 'x':
1616 num = pa_parse_number (&s, 0);
1617 CHECK_FIELD (num, 31, 0, 0);
1618 INSERT_FIELD_AND_CONTINUE (opcode, num, 16);
1619
1620 /* Handle a 5 bit register field at 31. */
1621 case 'y':
1622 case 't':
1623 num = pa_parse_number (&s, 0);
1624 CHECK_FIELD (num, 31, 0, 0);
1625 INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
1626
1627 /* Handle a 5 bit field length at 31. */
1628 case 'T':
1629 num = pa_get_absolute_expression (&the_insn, &s);
1630 s = expr_end;
1631 CHECK_FIELD (num, 32, 1, 0);
1632 INSERT_FIELD_AND_CONTINUE (opcode, 32 - num, 0);
1633
1634 /* Handle a 5 bit immediate at 15. */
1635 case '5':
1636 num = pa_get_absolute_expression (&the_insn, &s);
1637 s = expr_end;
1638 CHECK_FIELD (num, 15, -16, 0);
1639 low_sign_unext (num, 5, &num);
1640 INSERT_FIELD_AND_CONTINUE (opcode, num, 16);
1641
1642 /* Handle a 5 bit immediate at 31. */
1643 case 'V':
1644 num = pa_get_absolute_expression (&the_insn, &s);
1645 s = expr_end;
1646 CHECK_FIELD (num, 15, -16, 0)
1647 low_sign_unext (num, 5, &num);
1648 INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
1649
1650 /* Handle an unsigned 5 bit immediate at 31. */
1651 case 'r':
1652 num = pa_get_absolute_expression (&the_insn, &s);
1653 s = expr_end;
1654 CHECK_FIELD (num, 31, 0, 0);
1655 INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
1656
1657 /* Handle an unsigned 5 bit immediate at 15. */
1658 case 'R':
1659 num = pa_get_absolute_expression (&the_insn, &s);
1660 s = expr_end;
1661 CHECK_FIELD (num, 31, 0, 0);
1662 INSERT_FIELD_AND_CONTINUE (opcode, num, 16);
1663
1664 /* Handle a 2 bit space identifier at 17. */
1665 case 's':
1666 num = pa_parse_number (&s, 0);
1667 CHECK_FIELD (num, 3, 0, 1);
1668 INSERT_FIELD_AND_CONTINUE (opcode, num, 14);
1669
1670 /* Handle a 3 bit space identifier at 18. */
1671 case 'S':
1672 num = pa_parse_number (&s, 0);
1673 CHECK_FIELD (num, 7, 0, 1);
1674 dis_assemble_3 (num, &num);
1675 INSERT_FIELD_AND_CONTINUE (opcode, num, 13);
1676
1677 /* Handle a completer for an indexing load or store. */
1678 case 'c':
1679 {
1680 int uu = 0;
1681 int m = 0;
1682 int i = 0;
1683 while (*s == ',' && i < 2)
1684 {
1685 s++;
1686 if (strncasecmp (s, "sm", 2) == 0)
1687 {
1688 uu = 1;
1689 m = 1;
1690 s++;
1691 i++;
1692 }
1693 else if (strncasecmp (s, "m", 1) == 0)
1694 m = 1;
1695 else if (strncasecmp (s, "s", 1) == 0)
1696 uu = 1;
1697 else
1698 as_bad ("Invalid Indexed Load Completer.");
1699 s++;
1700 i++;
1701 }
1702 if (i > 2)
1703 as_bad ("Invalid Indexed Load Completer Syntax.");
1704 opcode |= m << 5;
1705 INSERT_FIELD_AND_CONTINUE (opcode, uu, 13);
1706 }
1707
1708 /* Handle a short load/store completer. */
1709 case 'C':
1710 {
1711 int a = 0;
1712 int m = 0;
1713 if (*s == ',')
1714 {
1715 s++;
1716 if (strncasecmp (s, "ma", 2) == 0)
1717 {
1718 a = 0;
1719 m = 1;
1720 }
1721 else if (strncasecmp (s, "mb", 2) == 0)
1722 {
1723 a = 1;
1724 m = 1;
1725 }
1726 else
1727 as_bad ("Invalid Short Load/Store Completer.");
1728 s += 2;
1729 }
1730 opcode |= m << 5;
1731 INSERT_FIELD_AND_CONTINUE (opcode, a, 13);
1732 }
1733
1734 /* Handle a stbys completer. */
1735 case 'Y':
1736 {
1737 int a = 0;
1738 int m = 0;
1739 int i = 0;
1740 while (*s == ',' && i < 2)
1741 {
1742 s++;
1743 if (strncasecmp (s, "m", 1) == 0)
1744 m = 1;
1745 else if (strncasecmp (s, "b", 1) == 0)
1746 a = 0;
1747 else if (strncasecmp (s, "e", 1) == 0)
1748 a = 1;
1749 else
1750 as_bad ("Invalid Store Bytes Short Completer");
1751 s++;
1752 i++;
1753 }
1754 if (i > 2)
1755 as_bad ("Invalid Store Bytes Short Completer");
1756 opcode |= m << 5;
1757 INSERT_FIELD_AND_CONTINUE (opcode, a, 13);
1758 }
1759
1760 /* Handle a non-negated compare/stubtract condition. */
1761 case '<':
1762 cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s, 1);
1763 if (cmpltr < 0)
1764 {
1765 as_bad ("Invalid Compare/Subtract Condition: %c", *s);
1766 cmpltr = 0;
1767 }
1768 INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13);
1769
1770 /* Handle a negated or non-negated compare/subtract condition. */
1771 case '?':
1772 save_s = s;
1773 cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s, 1);
1774 if (cmpltr < 0)
1775 {
1776 s = save_s;
1777 cmpltr = pa_parse_neg_cmpsub_cmpltr (&s, 1);
1778 if (cmpltr < 0)
1779 {
1780 as_bad ("Invalid Compare/Subtract Condition.");
1781 cmpltr = 0;
1782 }
1783 else
1784 {
1785 /* Negated condition requires an opcode change. */
1786 opcode |= 1 << 27;
1787 }
1788 }
1789 INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13);
1790
1791 /* Handle a negated or non-negated add condition. */
1792 case '!':
1793 save_s = s;
1794 cmpltr = pa_parse_nonneg_add_cmpltr (&s, 1);
1795 if (cmpltr < 0)
1796 {
1797 s = save_s;
1798 cmpltr = pa_parse_neg_add_cmpltr (&s, 1);
1799 if (cmpltr < 0)
1800 {
1801 as_bad ("Invalid Compare/Subtract Condition");
1802 cmpltr = 0;
1803 }
1804 else
1805 {
1806 /* Negated condition requires an opcode change. */
1807 opcode |= 1 << 27;
1808 }
1809 }
1810 INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13);
1811
1812 /* Handle a compare/subtract condition. */
1813 case 'a':
1814 cmpltr = 0;
1815 flag = 0;
1816 save_s = s;
1817 if (*s == ',')
1818 {
1819 cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s, 0);
1820 if (cmpltr < 0)
1821 {
1822 flag = 1;
1823 s = save_s;
1824 cmpltr = pa_parse_neg_cmpsub_cmpltr (&s, 0);
1825 if (cmpltr < 0)
1826 {
1827 as_bad ("Invalid Compare/Subtract Condition");
1828 }
1829 }
1830 }
1831 opcode |= cmpltr << 13;
1832 INSERT_FIELD_AND_CONTINUE (opcode, flag, 12);
1833
1834 /* Handle a non-negated add condition. */
1835 case 'd':
1836 cmpltr = 0;
1837 nullif = 0;
1838 flag = 0;
1839 if (*s == ',')
1840 {
1841 s++;
1842 name = s;
1843 while (*s != ',' && *s != ' ' && *s != '\t')
1844 s += 1;
1845 c = *s;
1846 *s = 0x00;
1847 if (strcmp (name, "=") == 0)
1848 cmpltr = 1;
1849 else if (strcmp (name, "<") == 0)
1850 cmpltr = 2;
1851 else if (strcmp (name, "<=") == 0)
1852 cmpltr = 3;
1853 else if (strcasecmp (name, "nuv") == 0)
1854 cmpltr = 4;
1855 else if (strcasecmp (name, "znv") == 0)
1856 cmpltr = 5;
1857 else if (strcasecmp (name, "sv") == 0)
1858 cmpltr = 6;
1859 else if (strcasecmp (name, "od") == 0)
1860 cmpltr = 7;
1861 else if (strcasecmp (name, "n") == 0)
1862 nullif = 1;
1863 else if (strcasecmp (name, "tr") == 0)
1864 {
1865 cmpltr = 0;
1866 flag = 1;
1867 }
1868 else if (strcasecmp (name, "<>") == 0)
1869 {
1870 cmpltr = 1;
1871 flag = 1;
1872 }
1873 else if (strcasecmp (name, ">=") == 0)
1874 {
1875 cmpltr = 2;
1876 flag = 1;
1877 }
1878 else if (strcasecmp (name, ">") == 0)
1879 {
1880 cmpltr = 3;
1881 flag = 1;
1882 }
1883 else if (strcasecmp (name, "uv") == 0)
1884 {
1885 cmpltr = 4;
1886 flag = 1;
1887 }
1888 else if (strcasecmp (name, "vnz") == 0)
1889 {
1890 cmpltr = 5;
1891 flag = 1;
1892 }
1893 else if (strcasecmp (name, "nsv") == 0)
1894 {
1895 cmpltr = 6;
1896 flag = 1;
1897 }
1898 else if (strcasecmp (name, "ev") == 0)
1899 {
1900 cmpltr = 7;
1901 flag = 1;
1902 }
1903 else
1904 as_bad ("Invalid Add Condition: %s", name);
1905 *s = c;
1906 }
1907 nullif = pa_parse_nullif (&s);
1908 opcode |= nullif << 1;
1909 opcode |= cmpltr << 13;
1910 INSERT_FIELD_AND_CONTINUE (opcode, flag, 12);
1911
1912 /* HANDLE a logical instruction condition. */
1913 case '&':
1914 cmpltr = 0;
1915 flag = 0;
1916 if (*s == ',')
1917 {
1918 s++;
1919 name = s;
1920 while (*s != ',' && *s != ' ' && *s != '\t')
1921 s += 1;
1922 c = *s;
1923 *s = 0x00;
1924 if (strcmp (name, "=") == 0)
1925 cmpltr = 1;
1926 else if (strcmp (name, "<") == 0)
1927 cmpltr = 2;
1928 else if (strcmp (name, "<=") == 0)
1929 cmpltr = 3;
1930 else if (strcasecmp (name, "od") == 0)
1931 cmpltr = 7;
1932 else if (strcasecmp (name, "tr") == 0)
1933 {
1934 cmpltr = 0;
1935 flag = 1;
1936 }
1937 else if (strcmp (name, "<>") == 0)
1938 {
1939 cmpltr = 1;
1940 flag = 1;
1941 }
1942 else if (strcmp (name, ">=") == 0)
1943 {
1944 cmpltr = 2;
1945 flag = 1;
1946 }
1947 else if (strcmp (name, ">") == 0)
1948 {
1949 cmpltr = 3;
1950 flag = 1;
1951 }
1952 else if (strcasecmp (name, "ev") == 0)
1953 {
1954 cmpltr = 7;
1955 flag = 1;
1956 }
1957 else
1958 as_bad ("Invalid Logical Instruction Condition.");
1959 *s = c;
1960 }
1961 opcode |= cmpltr << 13;
1962 INSERT_FIELD_AND_CONTINUE (opcode, flag, 12);
1963
1964 /* Handle a unit instruction condition. */
1965 case 'U':
1966 cmpltr = 0;
1967 flag = 0;
1968 if (*s == ',')
1969 {
1970 s++;
1971 if (strncasecmp (s, "sbz", 3) == 0)
1972 {
1973 cmpltr = 2;
1974 s += 3;
1975 }
1976 else if (strncasecmp (s, "shz", 3) == 0)
1977 {
1978 cmpltr = 3;
1979 s += 3;
1980 }
1981 else if (strncasecmp (s, "sdc", 3) == 0)
1982 {
1983 cmpltr = 4;
1984 s += 3;
1985 }
1986 else if (strncasecmp (s, "sbc", 3) == 0)
1987 {
1988 cmpltr = 6;
1989 s += 3;
1990 }
1991 else if (strncasecmp (s, "shc", 3) == 0)
1992 {
1993 cmpltr = 7;
1994 s += 3;
1995 }
1996 else if (strncasecmp (s, "tr", 2) == 0)
1997 {
1998 cmpltr = 0;
1999 flag = 1;
2000 s += 2;
2001 }
2002 else if (strncasecmp (s, "nbz", 3) == 0)
2003 {
2004 cmpltr = 2;
2005 flag = 1;
2006 s += 3;
2007 }
2008 else if (strncasecmp (s, "nhz", 3) == 0)
2009 {
2010 cmpltr = 3;
2011 flag = 1;
2012 s += 3;
2013 }
2014 else if (strncasecmp (s, "ndc", 3) == 0)
2015 {
2016 cmpltr = 4;
2017 flag = 1;
2018 s += 3;
2019 }
2020 else if (strncasecmp (s, "nbc", 3) == 0)
2021 {
2022 cmpltr = 6;
2023 flag = 1;
2024 s += 3;
2025 }
2026 else if (strncasecmp (s, "nhc", 3) == 0)
2027 {
2028 cmpltr = 7;
2029 flag = 1;
2030 s += 3;
2031 }
2032 else
2033 as_bad ("Invalid Logical Instruction Condition.");
2034 }
2035 opcode |= cmpltr << 13;
2036 INSERT_FIELD_AND_CONTINUE (opcode, flag, 12);
2037
2038 /* Handle a shift/extract/deposit condition. */
2039 case '|':
2040 case '>':
2041 cmpltr = 0;
2042 if (*s == ',')
2043 {
2044 save_s = s++;
2045 name = s;
2046 while (*s != ',' && *s != ' ' && *s != '\t')
2047 s += 1;
2048 c = *s;
2049 *s = 0x00;
2050 if (strcmp (name, "=") == 0)
2051 cmpltr = 1;
2052 else if (strcmp (name, "<") == 0)
2053 cmpltr = 2;
2054 else if (strcasecmp (name, "od") == 0)
2055 cmpltr = 3;
2056 else if (strcasecmp (name, "tr") == 0)
2057 cmpltr = 4;
2058 else if (strcmp (name, "<>") == 0)
2059 cmpltr = 5;
2060 else if (strcmp (name, ">=") == 0)
2061 cmpltr = 6;
2062 else if (strcasecmp (name, "ev") == 0)
2063 cmpltr = 7;
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 == '|')
2067 {
2068 *s = c;
2069 s = save_s;
2070 continue;
2071 }
2072 else
2073 as_bad ("Invalid Shift/Extract/Deposit Condition.");
2074 *s = c;
2075 }
2076 INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13);
2077
2078 /* Handle bvb and bb conditions. */
2079 case '~':
2080 cmpltr = 0;
2081 if (*s == ',')
2082 {
2083 s++;
2084 if (strncmp (s, "<", 1) == 0)
2085 {
2086 cmpltr = 2;
2087 s++;
2088 }
2089 else if (strncmp (s, ">=", 2) == 0)
2090 {
2091 cmpltr = 6;
2092 s += 2;
2093 }
2094 else
2095 as_bad ("Invalid Bit Branch Condition: %c", *s);
2096 }
2097 INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13);
2098
2099 /* Handle a system control completer. */
2100 case 'Z':
2101 if (*s == ',' && (*(s + 1) == 'm' || *(s + 1) == 'M'))
2102 {
2103 flag = 1;
2104 s += 2;
2105 }
2106 else
2107 flag = 0;
2108
2109 INSERT_FIELD_AND_CONTINUE (opcode, flag, 5);
2110
2111 /* Handle a nullification completer for branch instructions. */
2112 case 'n':
2113 nullif = pa_parse_nullif (&s);
2114 INSERT_FIELD_AND_CONTINUE (opcode, nullif, 1);
2115
2116 /* Handle a 11 bit immediate at 31. */
2117 case 'i':
2118 the_insn.field_selector = pa_chk_field_selector (&s);
2119 get_expression (s);
2120 s = expr_end;
2121 if (the_insn.exp.X_op == O_constant)
2122 {
2123 num = evaluate_absolute (&the_insn);
2124 CHECK_FIELD (num, 1023, -1024, 0);
2125 low_sign_unext (num, 11, &num);
2126 INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
2127 }
2128 else
2129 {
2130 if (is_DP_relative (the_insn.exp))
2131 the_insn.reloc = R_HPPA_GOTOFF;
2132 else if (is_PC_relative (the_insn.exp))
2133 the_insn.reloc = R_HPPA_PCREL_CALL;
2134 else if (is_complex (the_insn.exp))
2135 the_insn.reloc = R_HPPA_COMPLEX;
2136 else
2137 the_insn.reloc = R_HPPA;
2138 the_insn.format = 11;
2139 continue;
2140 }
2141
2142 /* Handle a 14 bit immediate at 31. */
2143 case 'j':
2144 the_insn.field_selector = pa_chk_field_selector (&s);
2145 get_expression (s);
2146 s = expr_end;
2147 if (the_insn.exp.X_op == O_constant)
2148 {
2149 num = evaluate_absolute (&the_insn);
2150 CHECK_FIELD (num, 8191, -8192, 0);
2151 low_sign_unext (num, 14, &num);
2152 INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
2153 }
2154 else
2155 {
2156 if (is_DP_relative (the_insn.exp))
2157 the_insn.reloc = R_HPPA_GOTOFF;
2158 else if (is_PC_relative (the_insn.exp))
2159 the_insn.reloc = R_HPPA_PCREL_CALL;
2160 else if (is_complex (the_insn.exp))
2161 the_insn.reloc = R_HPPA_COMPLEX;
2162 else
2163 the_insn.reloc = R_HPPA;
2164 the_insn.format = 14;
2165 continue;
2166 }
2167
2168 /* Handle a 21 bit immediate at 31. */
2169 case 'k':
2170 the_insn.field_selector = pa_chk_field_selector (&s);
2171 get_expression (s);
2172 s = expr_end;
2173 if (the_insn.exp.X_op == O_constant)
2174 {
2175 num = evaluate_absolute (&the_insn);
2176 CHECK_FIELD (num >> 11, 1048575, -1048576, 0);
2177 dis_assemble_21 (num, &num);
2178 INSERT_FIELD_AND_CONTINUE (opcode, num, 0);
2179 }
2180 else
2181 {
2182 if (is_DP_relative (the_insn.exp))
2183 the_insn.reloc = R_HPPA_GOTOFF;
2184 else if (is_PC_relative (the_insn.exp))
2185 the_insn.reloc = R_HPPA_PCREL_CALL;
2186 else if (is_complex (the_insn.exp))
2187 the_insn.reloc = R_HPPA_COMPLEX;
2188 else
2189 the_insn.reloc = R_HPPA;
2190 the_insn.format = 21;
2191 continue;
2192 }
2193
2194 /* Handle a 12 bit branch displacement. */
2195 case 'w':
2196 the_insn.field_selector = pa_chk_field_selector (&s);
2197 get_expression (s);
2198 s = expr_end;
2199 the_insn.pcrel = 1;
2200 if (!strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), "L$0\001"))
2201 {
2202 unsigned int w1, w, result;
2203
2204 num = evaluate_absolute (&the_insn);
2205 if (num % 4)
2206 {
2207 as_bad ("Branch to unaligned address");
2208 break;
2209 }
2210 CHECK_FIELD (num, 8191, -8192, 0);
2211 sign_unext ((num - 8) >> 2, 12, &result);
2212 dis_assemble_12 (result, &w1, &w);
2213 INSERT_FIELD_AND_CONTINUE (opcode, ((w1 << 2) | w), 0);
2214 }
2215 else
2216 {
2217 if (is_complex (the_insn.exp))
2218 the_insn.reloc = R_HPPA_COMPLEX_PCREL_CALL;
2219 else
2220 the_insn.reloc = R_HPPA_PCREL_CALL;
2221 the_insn.format = 12;
2222 the_insn.arg_reloc = last_call_desc.arg_reloc;
2223 bzero (&last_call_desc, sizeof (struct call_desc));
2224 s = expr_end;
2225 continue;
2226 }
2227
2228 /* Handle a 17 bit branch displacement. */
2229 case 'W':
2230 the_insn.field_selector = pa_chk_field_selector (&s);
2231 get_expression (s);
2232 s = expr_end;
2233 the_insn.pcrel = 1;
2234 if (!the_insn.exp.X_add_symbol
2235 || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol),
2236 "L$0\001"))
2237 {
2238 unsigned int w2, w1, w, result;
2239
2240 num = evaluate_absolute (&the_insn);
2241 if (num % 4)
2242 {
2243 as_bad ("Branch to unaligned address");
2244 break;
2245 }
2246 CHECK_FIELD (num, 262143, -262144, 0);
2247
2248 if (the_insn.exp.X_add_symbol)
2249 num -= 8;
2250
2251 sign_unext (num >> 2, 17, &result);
2252 dis_assemble_17 (result, &w1, &w2, &w);
2253 INSERT_FIELD_AND_CONTINUE (opcode,
2254 ((w2 << 2) | (w1 << 16) | w), 0);
2255 }
2256 else
2257 {
2258 if (is_complex (the_insn.exp))
2259 the_insn.reloc = R_HPPA_COMPLEX_PCREL_CALL;
2260 else
2261 the_insn.reloc = R_HPPA_PCREL_CALL;
2262 the_insn.format = 17;
2263 the_insn.arg_reloc = last_call_desc.arg_reloc;
2264 bzero (&last_call_desc, sizeof (struct call_desc));
2265 continue;
2266 }
2267
2268 /* Handle an absolute 17 bit branch target. */
2269 case 'z':
2270 the_insn.field_selector = pa_chk_field_selector (&s);
2271 get_expression (s);
2272 s = expr_end;
2273 the_insn.pcrel = 0;
2274 if (!the_insn.exp.X_add_symbol
2275 || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol),
2276 "L$0\001"))
2277 {
2278 unsigned int w2, w1, w, result;
2279
2280 num = evaluate_absolute (&the_insn);
2281 if (num % 4)
2282 {
2283 as_bad ("Branch to unaligned address");
2284 break;
2285 }
2286 CHECK_FIELD (num, 262143, -262144, 0);
2287
2288 if (the_insn.exp.X_add_symbol)
2289 num -= 8;
2290
2291 sign_unext (num >> 2, 17, &result);
2292 dis_assemble_17 (result, &w1, &w2, &w);
2293 INSERT_FIELD_AND_CONTINUE (opcode,
2294 ((w2 << 2) | (w1 << 16) | w), 0);
2295 }
2296 else
2297 {
2298 if (is_complex (the_insn.exp))
2299 the_insn.reloc = R_HPPA_COMPLEX_ABS_CALL;
2300 else
2301 the_insn.reloc = R_HPPA_ABS_CALL;
2302 the_insn.format = 17;
2303 continue;
2304 }
2305
2306 /* Handle a 5 bit shift count at 26. */
2307 case 'p':
2308 num = pa_get_absolute_expression (&the_insn, &s);
2309 s = expr_end;
2310 CHECK_FIELD (num, 31, 0, 0);
2311 INSERT_FIELD_AND_CONTINUE (opcode, 31 - num, 5);
2312
2313 /* Handle a 5 bit bit position at 26. */
2314 case 'P':
2315 num = pa_get_absolute_expression (&the_insn, &s);
2316 s = expr_end;
2317 CHECK_FIELD (num, 31, 0, 0);
2318 INSERT_FIELD_AND_CONTINUE (opcode, num, 5);
2319
2320 /* Handle a 5 bit immediate at 10. */
2321 case 'Q':
2322 num = pa_get_absolute_expression (&the_insn, &s);
2323 s = expr_end;
2324 CHECK_FIELD (num, 31, 0, 0);
2325 INSERT_FIELD_AND_CONTINUE (opcode, num, 21);
2326
2327 /* Handle a 13 bit immediate at 18. */
2328 case 'A':
2329 num = pa_get_absolute_expression (&the_insn, &s);
2330 s = expr_end;
2331 CHECK_FIELD (num, 4095, -4096, 0);
2332 INSERT_FIELD_AND_CONTINUE (opcode, num, 13);
2333
2334 /* Handle a 26 bit immediate at 31. */
2335 case 'D':
2336 num = pa_get_absolute_expression (&the_insn, &s);
2337 s = expr_end;
2338 CHECK_FIELD (num, 671108864, 0, 0);
2339 INSERT_FIELD_AND_CONTINUE (opcode, num, 1);
2340
2341 /* Handle a 3 bit SFU identifier at 25. */
2342 case 'f':
2343 num = pa_get_absolute_expression (&the_insn, &s);
2344 s = expr_end;
2345 CHECK_FIELD (num, 7, 0, 0);
2346 INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
2347
2348 /* We don't support any of these. FIXME. */
2349 case 'O':
2350 get_expression (s);
2351 s = expr_end;
2352 abort ();
2353 continue;
2354
2355 /* Handle a source FP operand format completer. */
2356 case 'F':
2357 flag = pa_parse_fp_format (&s);
2358 the_insn.fpof1 = flag;
2359 INSERT_FIELD_AND_CONTINUE (opcode, flag, 11);
2360
2361 /* Handle a destination FP operand format completer. */
2362 case 'G':
2363 /* pa_parse_format needs the ',' prefix. */
2364 s--;
2365 flag = pa_parse_fp_format (&s);
2366 the_insn.fpof2 = flag;
2367 INSERT_FIELD_AND_CONTINUE (opcode, flag, 13);
2368
2369 /* Handle FP compare conditions. */
2370 case 'M':
2371 cond = pa_parse_fp_cmp_cond (&s);
2372 INSERT_FIELD_AND_CONTINUE (opcode, cond, 0);
2373
2374 /* Handle L/R register halves like 't'. */
2375 case 'v':
2376 {
2377 struct pa_89_fp_reg_struct result;
2378
2379 pa_parse_number (&s, &result);
2380 CHECK_FIELD (result.number_part, 31, 0, 0);
2381 opcode |= result.number_part;
2382
2383 /* 0x30 opcodes are FP arithmetic operation opcodes
2384 and need to be turned into 0x38 opcodes. This
2385 is not necessary for loads/stores. */
2386 if (need_89_opcode (&the_insn, &result)
2387 && ((opcode & 0xfc000000) == 0x30000000))
2388 opcode |= 1 << 27;
2389
2390 INSERT_FIELD_AND_CONTINUE (opcode, result.l_r_select & 1, 6);
2391 }
2392
2393 /* Handle L/R register halves like 'b'. */
2394 case 'E':
2395 {
2396 struct pa_89_fp_reg_struct result;
2397
2398 pa_parse_number (&s, &result);
2399 CHECK_FIELD (result.number_part, 31, 0, 0);
2400 opcode |= result.number_part << 21;
2401 if (need_89_opcode (&the_insn, &result))
2402 {
2403 opcode |= (result.l_r_select & 1) << 7;
2404 opcode |= 1 << 27;
2405 }
2406 continue;
2407 }
2408
2409 /* Handle L/R register halves like 'x'. */
2410 case 'X':
2411 {
2412 struct pa_89_fp_reg_struct result;
2413
2414 pa_parse_number (&s, &result);
2415 CHECK_FIELD (result.number_part, 31, 0, 0);
2416 opcode |= (result.number_part & 0x1f) << 16;
2417 if (need_89_opcode (&the_insn, &result))
2418 {
2419 opcode |= (result.l_r_select & 1) << 12;
2420 opcode |= 1 << 27;
2421 }
2422 continue;
2423 }
2424
2425 /* Handle a 5 bit register field at 10. */
2426 case '4':
2427 {
2428 struct pa_89_fp_reg_struct result;
2429
2430 pa_parse_number (&s, &result);
2431 CHECK_FIELD (result.number_part, 31, 0, 0);
2432 if (the_insn.fpof1 == SGL)
2433 {
2434 result.number_part &= 0xF;
2435 result.number_part |= (result.l_r_select & 1) << 4;
2436 }
2437 INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 21);
2438 }
2439
2440 /* Handle a 5 bit register field at 15. */
2441 case '6':
2442 {
2443 struct pa_89_fp_reg_struct result;
2444
2445 pa_parse_number (&s, &result);
2446 CHECK_FIELD (result.number_part, 31, 0, 0);
2447 if (the_insn.fpof1 == SGL)
2448 {
2449 result.number_part &= 0xF;
2450 result.number_part |= (result.l_r_select & 1) << 4;
2451 }
2452 INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 16);
2453 }
2454
2455 /* Handle a 5 bit register field at 31. */
2456 case '7':
2457 {
2458 struct pa_89_fp_reg_struct result;
2459
2460 pa_parse_number (&s, &result);
2461 CHECK_FIELD (result.number_part, 31, 0, 0);
2462 if (the_insn.fpof1 == SGL)
2463 {
2464 result.number_part &= 0xF;
2465 result.number_part |= (result.l_r_select & 1) << 4;
2466 }
2467 INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 0);
2468 }
2469
2470 /* Handle a 5 bit register field at 20. */
2471 case '8':
2472 {
2473 struct pa_89_fp_reg_struct result;
2474
2475 pa_parse_number (&s, &result);
2476 CHECK_FIELD (result.number_part, 31, 0, 0);
2477 if (the_insn.fpof1 == SGL)
2478 {
2479 result.number_part &= 0xF;
2480 result.number_part |= (result.l_r_select & 1) << 4;
2481 }
2482 INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 11);
2483 }
2484
2485 /* Handle a 5 bit register field at 25. */
2486 case '9':
2487 {
2488 struct pa_89_fp_reg_struct result;
2489
2490 pa_parse_number (&s, &result);
2491 CHECK_FIELD (result.number_part, 31, 0, 0);
2492 if (the_insn.fpof1 == SGL)
2493 {
2494 result.number_part &= 0xF;
2495 result.number_part |= (result.l_r_select & 1) << 4;
2496 }
2497 INSERT_FIELD_AND_CONTINUE (opcode, result.number_part, 6);
2498 }
2499
2500 /* Handle a floating point operand format at 26.
2501 Only allows single and double precision. */
2502 case 'H':
2503 flag = pa_parse_fp_format (&s);
2504 switch (flag)
2505 {
2506 case SGL:
2507 opcode |= 0x20;
2508 case DBL:
2509 the_insn.fpof1 = flag;
2510 continue;
2511
2512 case QUAD:
2513 case ILLEGAL_FMT:
2514 default:
2515 as_bad ("Invalid Floating Point Operand Format.");
2516 }
2517 break;
2518
2519 default:
2520 abort ();
2521 }
2522 break;
2523 }
2524
2525 /* Check if the args matched. */
2526 if (match == FALSE)
2527 {
2528 if (&insn[1] - pa_opcodes < NUMOPCODES
2529 && !strcmp (insn->name, insn[1].name))
2530 {
2531 ++insn;
2532 s = argstart;
2533 continue;
2534 }
2535 else
2536 {
2537 as_bad ("Invalid operands %s", error_message);
2538 return;
2539 }
2540 }
2541 break;
2542 }
2543
2544 the_insn.opcode = opcode;
2545 return;
2546 }
2547
2548 /* Turn a string in input_line_pointer into a floating point constant of type
2549 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
2550 emitted is stored in *sizeP . An error message or NULL is returned. */
2551
2552 #define MAX_LITTLENUMS 6
2553
2554 char *
2555 md_atof (type, litP, sizeP)
2556 char type;
2557 char *litP;
2558 int *sizeP;
2559 {
2560 int prec;
2561 LITTLENUM_TYPE words[MAX_LITTLENUMS];
2562 LITTLENUM_TYPE *wordP;
2563 char *t;
2564
2565 switch (type)
2566 {
2567
2568 case 'f':
2569 case 'F':
2570 case 's':
2571 case 'S':
2572 prec = 2;
2573 break;
2574
2575 case 'd':
2576 case 'D':
2577 case 'r':
2578 case 'R':
2579 prec = 4;
2580 break;
2581
2582 case 'x':
2583 case 'X':
2584 prec = 6;
2585 break;
2586
2587 case 'p':
2588 case 'P':
2589 prec = 6;
2590 break;
2591
2592 default:
2593 *sizeP = 0;
2594 return "Bad call to MD_ATOF()";
2595 }
2596 t = atof_ieee (input_line_pointer, type, words);
2597 if (t)
2598 input_line_pointer = t;
2599 *sizeP = prec * sizeof (LITTLENUM_TYPE);
2600 for (wordP = words; prec--;)
2601 {
2602 md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE));
2603 litP += sizeof (LITTLENUM_TYPE);
2604 }
2605 return NULL;
2606 }
2607
2608 /* Write out big-endian. */
2609
2610 void
2611 md_number_to_chars (buf, val, n)
2612 char *buf;
2613 valueT val;
2614 int n;
2615 {
2616
2617 switch (n)
2618 {
2619 case 4:
2620 *buf++ = val >> 24;
2621 *buf++ = val >> 16;
2622 case 2:
2623 *buf++ = val >> 8;
2624 case 1:
2625 *buf = val;
2626 break;
2627 default:
2628 abort ();
2629 }
2630 return;
2631 }
2632
2633 /* Translate internal representation of relocation info to BFD target
2634 format. */
2635
2636 arelent **
2637 tc_gen_reloc (section, fixp)
2638 asection *section;
2639 fixS *fixp;
2640 {
2641 arelent *reloc;
2642 struct hppa_fix_struct *hppa_fixp = fixp->tc_fix_data;
2643 bfd_reloc_code_real_type code;
2644 static int unwind_reloc_fixp_cnt = 0;
2645 static arelent *unwind_reloc_entryP = NULL;
2646 static arelent *no_relocs = NULL;
2647 arelent **relocs;
2648 bfd_reloc_code_real_type **codes;
2649 int n_relocs;
2650 int i;
2651
2652 if (fixp->fx_addsy == 0)
2653 return &no_relocs;
2654 assert (hppa_fixp != 0);
2655 assert (section != 0);
2656
2657 #ifdef OBJ_ELF
2658 /* Yuk. I would really like to push all this ELF specific unwind
2659 crud into BFD and the linker. That's how SOM does it -- and
2660 if we could make ELF emulate that then we could share more code
2661 in GAS (and potentially a gnu-linker later).
2662
2663 Unwind section relocations are handled in a special way.
2664 The relocations for the .unwind section are originally
2665 built in the usual way. That is, for each unwind table
2666 entry there are two relocations: one for the beginning of
2667 the function and one for the end.
2668
2669 The first time we enter this function we create a
2670 relocation of the type R_HPPA_UNWIND_ENTRIES. The addend
2671 of the relocation is initialized to 0. Each additional
2672 pair of times this function is called for the unwind
2673 section represents an additional unwind table entry. Thus,
2674 the addend of the relocation should end up to be the number
2675 of unwind table entries. */
2676 if (strcmp (UNWIND_SECTION_NAME, section->name) == 0)
2677 {
2678 if (unwind_reloc_entryP == NULL)
2679 {
2680 reloc = (arelent *) bfd_alloc_by_size_t (stdoutput,
2681 sizeof (arelent));
2682 assert (reloc != 0);
2683 unwind_reloc_entryP = reloc;
2684 unwind_reloc_fixp_cnt++;
2685 unwind_reloc_entryP->address
2686 = fixp->fx_frag->fr_address + fixp->fx_where;
2687 /* A pointer to any function will do. We only
2688 need one to tell us what section the unwind
2689 relocations are for. */
2690 unwind_reloc_entryP->sym_ptr_ptr = &fixp->fx_addsy->bsym;
2691 hppa_fixp->fx_r_type = code = R_HPPA_UNWIND_ENTRIES;
2692 fixp->fx_r_type = R_HPPA_UNWIND;
2693 unwind_reloc_entryP->howto = bfd_reloc_type_lookup (stdoutput, code);
2694 unwind_reloc_entryP->addend = unwind_reloc_fixp_cnt / 2;
2695 relocs = (arelent **) bfd_alloc_by_size_t (stdoutput,
2696 sizeof (arelent *) * 2);
2697 assert (relocs != 0);
2698 relocs[0] = unwind_reloc_entryP;
2699 relocs[1] = NULL;
2700 return relocs;
2701 }
2702 unwind_reloc_fixp_cnt++;
2703 unwind_reloc_entryP->addend = unwind_reloc_fixp_cnt / 2;
2704
2705 return &no_relocs;
2706 }
2707 #endif
2708
2709 reloc = (arelent *) bfd_alloc_by_size_t (stdoutput, sizeof (arelent));
2710 assert (reloc != 0);
2711
2712 reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym;
2713 codes = hppa_gen_reloc_type (stdoutput,
2714 fixp->fx_r_type,
2715 hppa_fixp->fx_r_format,
2716 hppa_fixp->fx_r_field);
2717
2718 for (n_relocs = 0; codes[n_relocs]; n_relocs++)
2719 ;
2720
2721 relocs = (arelent **)
2722 bfd_alloc_by_size_t (stdoutput, sizeof (arelent *) * n_relocs + 1);
2723 assert (relocs != 0);
2724
2725 reloc = (arelent *) bfd_alloc_by_size_t (stdoutput,
2726 sizeof (arelent) * n_relocs);
2727 if (n_relocs > 0)
2728 assert (reloc != 0);
2729
2730 for (i = 0; i < n_relocs; i++)
2731 relocs[i] = &reloc[i];
2732
2733 relocs[n_relocs] = NULL;
2734
2735 #ifdef OBJ_ELF
2736 switch (fixp->fx_r_type)
2737 {
2738 case R_HPPA_COMPLEX:
2739 case R_HPPA_COMPLEX_PCREL_CALL:
2740 case R_HPPA_COMPLEX_ABS_CALL:
2741 assert (n_relocs == 5);
2742
2743 for (i = 0; i < n_relocs; i++)
2744 {
2745 reloc[i].sym_ptr_ptr = NULL;
2746 reloc[i].address = 0;
2747 reloc[i].addend = 0;
2748 reloc[i].howto = bfd_reloc_type_lookup (stdoutput, *codes[i]);
2749 assert (reloc[i].howto && *codes[i] == reloc[i].howto->type);
2750 }
2751
2752 reloc[0].sym_ptr_ptr = &fixp->fx_addsy->bsym;
2753 reloc[1].sym_ptr_ptr = &fixp->fx_subsy->bsym;
2754 reloc[4].address = fixp->fx_frag->fr_address + fixp->fx_where;
2755
2756 if (fixp->fx_r_type == R_HPPA_COMPLEX)
2757 reloc[3].addend = fixp->fx_addnumber;
2758 else if (fixp->fx_r_type == R_HPPA_COMPLEX_PCREL_CALL ||
2759 fixp->fx_r_type == R_HPPA_COMPLEX_ABS_CALL)
2760 reloc[1].addend = fixp->fx_addnumber;
2761
2762 break;
2763
2764 default:
2765 assert (n_relocs == 1);
2766
2767 code = *codes[0];
2768
2769 reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym;
2770 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
2771 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
2772 reloc->addend = 0; /* default */
2773
2774 assert (reloc->howto && code == reloc->howto->type);
2775
2776 /* Now, do any processing that is dependent on the relocation type. */
2777 switch (code)
2778 {
2779 case R_HPPA_PLABEL_32:
2780 case R_HPPA_PLABEL_11:
2781 case R_HPPA_PLABEL_14:
2782 case R_HPPA_PLABEL_L21:
2783 case R_HPPA_PLABEL_R11:
2784 case R_HPPA_PLABEL_R14:
2785 /* For plabel relocations, the addend of the
2786 relocation should be either 0 (no static link) or 2
2787 (static link required).
2788
2789 FIXME: assume that fx_addnumber contains this
2790 information */
2791 reloc->addend = fixp->fx_addnumber;
2792 break;
2793
2794 case R_HPPA_ABS_CALL_11:
2795 case R_HPPA_ABS_CALL_14:
2796 case R_HPPA_ABS_CALL_17:
2797 case R_HPPA_ABS_CALL_L21:
2798 case R_HPPA_ABS_CALL_R11:
2799 case R_HPPA_ABS_CALL_R14:
2800 case R_HPPA_ABS_CALL_R17:
2801 case R_HPPA_ABS_CALL_LS21:
2802 case R_HPPA_ABS_CALL_RS11:
2803 case R_HPPA_ABS_CALL_RS14:
2804 case R_HPPA_ABS_CALL_RS17:
2805 case R_HPPA_ABS_CALL_LD21:
2806 case R_HPPA_ABS_CALL_RD11:
2807 case R_HPPA_ABS_CALL_RD14:
2808 case R_HPPA_ABS_CALL_RD17:
2809 case R_HPPA_ABS_CALL_LR21:
2810 case R_HPPA_ABS_CALL_RR14:
2811 case R_HPPA_ABS_CALL_RR17:
2812
2813 case R_HPPA_PCREL_CALL_11:
2814 case R_HPPA_PCREL_CALL_14:
2815 case R_HPPA_PCREL_CALL_17:
2816 case R_HPPA_PCREL_CALL_L21:
2817 case R_HPPA_PCREL_CALL_R11:
2818 case R_HPPA_PCREL_CALL_R14:
2819 case R_HPPA_PCREL_CALL_R17:
2820 case R_HPPA_PCREL_CALL_LS21:
2821 case R_HPPA_PCREL_CALL_RS11:
2822 case R_HPPA_PCREL_CALL_RS14:
2823 case R_HPPA_PCREL_CALL_RS17:
2824 case R_HPPA_PCREL_CALL_LD21:
2825 case R_HPPA_PCREL_CALL_RD11:
2826 case R_HPPA_PCREL_CALL_RD14:
2827 case R_HPPA_PCREL_CALL_RD17:
2828 case R_HPPA_PCREL_CALL_LR21:
2829 case R_HPPA_PCREL_CALL_RR14:
2830 case R_HPPA_PCREL_CALL_RR17:
2831 /* The constant is stored in the instruction. */
2832 reloc->addend = HPPA_R_ADDEND (hppa_fixp->fx_arg_reloc, 0);
2833 break;
2834 default:
2835 reloc->addend = fixp->fx_addnumber;
2836 break;
2837 }
2838 break;
2839 }
2840 #else /* OBJ_SOM */
2841
2842 /* Preliminary relocation handling for SOM. Needs to handle
2843 COMPLEX relocations (yes, I've seen them occur) and it will
2844 need to handle R_ENTRY/R_EXIT relocations in the very near future
2845 (for generating unwinds). */
2846 switch (fixp->fx_r_type)
2847 {
2848 case R_HPPA_COMPLEX:
2849 case R_HPPA_COMPLEX_PCREL_CALL:
2850 case R_HPPA_COMPLEX_ABS_CALL:
2851 abort ();
2852 break;
2853 default:
2854 assert (n_relocs == 1);
2855
2856 code = *codes[0];
2857
2858 reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym;
2859 reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
2860 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
2861
2862 switch (code)
2863 {
2864 case R_PCREL_CALL:
2865 case R_ABS_CALL:
2866 reloc->addend = HPPA_R_ADDEND (hppa_fixp->fx_arg_reloc, 0);
2867 break;
2868
2869 case R_DATA_PLABEL:
2870 case R_CODE_PLABEL:
2871 /* For plabel relocations, the addend of the
2872 relocation should be either 0 (no static link) or 2
2873 (static link required).
2874
2875 FIXME: We always assume no static link! */
2876 reloc->addend = 0;
2877 break;
2878
2879 default:
2880 reloc->addend = fixp->fx_addnumber;
2881 break;
2882 }
2883 break;
2884 }
2885 #endif
2886
2887 return relocs;
2888 }
2889
2890 /* Process any machine dependent frag types. */
2891
2892 void
2893 md_convert_frag (abfd, sec, fragP)
2894 register bfd *abfd;
2895 register asection *sec;
2896 register fragS *fragP;
2897 {
2898 unsigned int address;
2899
2900 if (fragP->fr_type == rs_machine_dependent)
2901 {
2902 switch ((int) fragP->fr_subtype)
2903 {
2904 case 0:
2905 fragP->fr_type = rs_fill;
2906 know (fragP->fr_var == 1);
2907 know (fragP->fr_next);
2908 address = fragP->fr_address + fragP->fr_fix;
2909 if (address % fragP->fr_offset)
2910 {
2911 fragP->fr_offset =
2912 fragP->fr_next->fr_address
2913 - fragP->fr_address
2914 - fragP->fr_fix;
2915 }
2916 else
2917 fragP->fr_offset = 0;
2918 break;
2919 }
2920 }
2921 }
2922
2923 /* Round up a section size to the appropriate boundary. */
2924
2925 valueT
2926 md_section_align (segment, size)
2927 asection *segment;
2928 valueT size;
2929 {
2930 int align = bfd_get_section_alignment (stdoutput, segment);
2931 int align2 = (1 << align) - 1;
2932
2933 return (size + align2) & ~align2;
2934
2935 }
2936
2937 /* Create a short jump from FROM_ADDR to TO_ADDR. Not used on the PA. */
2938 void
2939 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
2940 char *ptr;
2941 addressT from_addr, to_addr;
2942 fragS *frag;
2943 symbolS *to_symbol;
2944 {
2945 fprintf (stderr, "pa_create_short_jmp\n");
2946 abort ();
2947 }
2948
2949 /* Create a long jump from FROM_ADDR to TO_ADDR. Not used on the PA. */
2950 void
2951 md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
2952 char *ptr;
2953 addressT from_addr, to_addr;
2954 fragS *frag;
2955 symbolS *to_symbol;
2956 {
2957 fprintf (stderr, "pa_create_long_jump\n");
2958 abort ();
2959 }
2960
2961 /* Return the approximate size of a frag before relaxation has occurred. */
2962 int
2963 md_estimate_size_before_relax (fragP, segment)
2964 register fragS *fragP;
2965 asection *segment;
2966 {
2967 int size;
2968
2969 size = 0;
2970
2971 while ((fragP->fr_fix + size) % fragP->fr_offset)
2972 size++;
2973
2974 return size;
2975 }
2976
2977 /* Parse machine dependent options. There are none on the PA. */
2978 int
2979 md_parse_option (argP, cntP, vecP)
2980 char **argP;
2981 int *cntP;
2982 char ***vecP;
2983 {
2984 return 1;
2985 }
2986
2987 /* We have no need to default values of symbols. */
2988
2989 symbolS *
2990 md_undefined_symbol (name)
2991 char *name;
2992 {
2993 return 0;
2994 }
2995
2996 /* Parse an operand that is machine-specific.
2997 We just return without modifying the expression as we have nothing
2998 to do on the PA. */
2999
3000 void
3001 md_operand (expressionP)
3002 expressionS *expressionP;
3003 {
3004 }
3005
3006 /* Helper function for md_apply_fix. Actually determine if the fix
3007 can be applied, and if so, apply it.
3008
3009 If a fix is applied, then set fx_addsy to NULL which indicates
3010 the fix was applied and need not be emitted into the object file. */
3011
3012 static void
3013 md_apply_fix_1 (fixP, val)
3014 fixS *fixP;
3015 long val;
3016 {
3017 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
3018 struct hppa_fix_struct *hppa_fixP = fixP->tc_fix_data;
3019 long new_val, result;
3020 unsigned int w1, w2, w;
3021
3022 /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can
3023 never be "applied". They must always be emitted. */
3024 #ifdef OBJ_SOM
3025 if (fixP->fx_r_type == R_HPPA_ENTRY
3026 || fixP->fx_r_type == R_HPPA_EXIT)
3027 return;
3028 #endif
3029
3030 /* There should have been an HPPA specific fixup associated
3031 with the GAS fixup. */
3032 if (hppa_fixP)
3033 {
3034 unsigned long buf_wd = bfd_get_32 (stdoutput, buf);
3035 unsigned char fmt = bfd_hppa_insn2fmt (buf_wd);
3036
3037 if (fixP->fx_r_type == R_HPPA_NONE)
3038 fmt = 0;
3039
3040 /* Remember this value for emit_reloc. FIXME, is this braindamage
3041 documented anywhere!?! */
3042 fixP->fx_addnumber = val;
3043
3044 /* Check if this is an undefined symbol. No relocation can
3045 possibly be performed in this case. */
3046 if ((fixP->fx_addsy && fixP->fx_addsy->bsym->section == &bfd_und_section)
3047 || (fixP->fx_subsy
3048 && fixP->fx_subsy->bsym->section == &bfd_und_section))
3049 return;
3050
3051 if (fmt != 0 && hppa_fixP->fx_r_field != R_HPPA_PSEL
3052 && hppa_fixP->fx_r_field != R_HPPA_LPSEL
3053 && hppa_fixP->fx_r_field != R_HPPA_RPSEL)
3054 new_val = hppa_field_adjust (val, 0, hppa_fixP->fx_r_field);
3055 else
3056 new_val = 0;
3057
3058 switch (fmt)
3059 {
3060 /* Handle all opcodes with the 'j' operand type. */
3061 case 14:
3062 CHECK_FIELD (new_val, 8191, -8192, 0);
3063
3064 /* Mask off 14 bits to be changed. */
3065 bfd_put_32 (stdoutput,
3066 bfd_get_32 (stdoutput, buf) & 0xffffc000,
3067 buf);
3068 low_sign_unext (new_val, 14, &result);
3069 break;
3070
3071 /* Handle all opcodes with the 'k' operand type. */
3072 case 21:
3073 CHECK_FIELD (new_val, 2097152, 0, 0);
3074
3075 /* Mask off 21 bits to be changed. */
3076 bfd_put_32 (stdoutput,
3077 bfd_get_32 (stdoutput, buf) & 0xffe00000,
3078 buf);
3079 dis_assemble_21 (new_val, &result);
3080 break;
3081
3082 /* Handle all the opcodes with the 'i' operand type. */
3083 case 11:
3084 CHECK_FIELD (new_val, 1023, -1023, 0);
3085
3086 /* Mask off 11 bits to be changed. */
3087 bfd_put_32 (stdoutput,
3088 bfd_get_32 (stdoutput, buf) & 0xffff800,
3089 buf);
3090 low_sign_unext (new_val, 11, &result);
3091 break;
3092
3093 /* Handle all the opcodes with the 'w' operand type. */
3094 case 12:
3095 CHECK_FIELD (new_val, 8191, -8192, 0)
3096
3097 /* Mask off 11 bits to be changed. */
3098 sign_unext ((new_val - 8) >> 2, 12, &result);
3099 bfd_put_32 (stdoutput,
3100 bfd_get_32 (stdoutput, buf) & 0xffffe002,
3101 buf);
3102
3103 dis_assemble_12 (result, &w1, &w);
3104 result = ((w1 << 2) | w);
3105 break;
3106
3107 #define stub_needed(CALLER, CALLEE) \
3108 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
3109
3110 /* Handle some of the opcodes with the 'W' operand type. */
3111 case 17:
3112 /* If a long-call stub or argument relocation stub is
3113 needed, then we can not apply this relocation, instead
3114 the linker must handle it. */
3115 if (new_val > 262143 || new_val < -262144
3116 || stub_needed (((obj_symbol_type *)
3117 fixP->fx_addsy->bsym)->tc_data.hppa_arg_reloc,
3118 hppa_fixP->fx_arg_reloc))
3119 return;
3120
3121 /* No stubs were needed, we can perform this relocation. */
3122 CHECK_FIELD (new_val, 262143, -262144, 0);
3123
3124 /* Mask off 17 bits to be changed. */
3125 bfd_put_32 (stdoutput,
3126 bfd_get_32 (stdoutput, buf) & 0xffe0e002,
3127 buf);
3128 sign_unext ((new_val - 8) >> 2, 17, &result);
3129 dis_assemble_17 (result, &w1, &w2, &w);
3130 result = ((w2 << 2) | (w1 << 16) | w);
3131 break;
3132
3133 #undef too_far
3134 #undef stub_needed
3135
3136 case 32:
3137 #ifdef OBJ_ELF
3138 /* These are ELF specific relocations. ELF unfortunately
3139 handles unwinds in a completely different manner. */
3140 if (hppa_fixP->fx_r_type == R_HPPA_UNWIND_ENTRY
3141 || hppa_fixP->fx_r_type == R_HPPA_UNWIND_ENTRIES)
3142 result = fixP->fx_addnumber;
3143 else
3144 #endif
3145 {
3146 result = 0;
3147 fixP->fx_addnumber = fixP->fx_offset;
3148 bfd_put_32 (stdoutput, 0, buf);
3149 return;
3150 }
3151 break;
3152
3153 case 0:
3154 return;
3155
3156 default:
3157 as_bad ("Unknown relocation encountered in md_apply_fix.");
3158 return;
3159 }
3160
3161 /* Insert the relocation. */
3162 bfd_put_32 (stdoutput, bfd_get_32 (stdoutput, buf) | result, buf);
3163 }
3164 else
3165 printf ("no hppa_fixup entry for this fixup (fixP = 0x%x, type = 0x%x)\n",
3166 (unsigned int) fixP, fixP->fx_r_type);
3167 }
3168
3169 /* Apply a fix into a frag's data (if possible). */
3170
3171 int
3172 md_apply_fix (fixP, valp)
3173 fixS *fixP;
3174 valueT *valp;
3175 {
3176 md_apply_fix_1 (fixP, (long) *valp);
3177 return 1;
3178 }
3179
3180 /* Exactly what point is a PC-relative offset relative TO?
3181 On the PA, they're relative to the address of the offset. */
3182
3183 long
3184 md_pcrel_from (fixP)
3185 fixS *fixP;
3186 {
3187 return fixP->fx_where + fixP->fx_frag->fr_address;
3188 }
3189
3190 /* Return nonzero if the input line pointer is at the end of
3191 a statement. */
3192
3193 static int
3194 is_end_of_statement ()
3195 {
3196 return ((*input_line_pointer == '\n')
3197 || (*input_line_pointer == ';')
3198 || (*input_line_pointer == '!'));
3199 }
3200
3201 /* Read a number from S. The number might come in one of many forms,
3202 the most common will be a hex or decimal constant, but it could be
3203 a pre-defined register (Yuk!), or an absolute symbol.
3204
3205 Return a number or -1 for failure.
3206
3207 When parsing PA-89 FP register numbers RESULT will be
3208 the address of a structure to return information about
3209 L/R half of FP registers, store results there as appropriate.
3210
3211 pa_parse_number can not handle negative constants and will fail
3212 horribly if it is passed such a constant. */
3213
3214 static int
3215 pa_parse_number (s, result)
3216 char **s;
3217 struct pa_89_fp_reg_struct *result;
3218 {
3219 int num;
3220 char *name;
3221 char c;
3222 symbolS *sym;
3223 int status;
3224 char *p = *s;
3225
3226 /* Skip whitespace before the number. */
3227 while (*p == ' ' || *p == '\t')
3228 p = p + 1;
3229
3230 /* Store info in RESULT if requested by caller. */
3231 if (result)
3232 {
3233 result->number_part = -1;
3234 result->l_r_select = -1;
3235 }
3236 num = -1;
3237
3238 if (isdigit (*p))
3239 {
3240 /* Looks like a number. */
3241 num = 0;
3242
3243 if (*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X'))
3244 {
3245 /* The number is specified in hex. */
3246 p += 2;
3247 while (isdigit (*p) || ((*p >= 'a') && (*p <= 'f'))
3248 || ((*p >= 'A') && (*p <= 'F')))
3249 {
3250 if (isdigit (*p))
3251 num = num * 16 + *p - '0';
3252 else if (*p >= 'a' && *p <= 'f')
3253 num = num * 16 + *p - 'a' + 10;
3254 else
3255 num = num * 16 + *p - 'A' + 10;
3256 ++p;
3257 }
3258 }
3259 else
3260 {
3261 /* The number is specified in decimal. */
3262 while (isdigit (*p))
3263 {
3264 num = num * 10 + *p - '0';
3265 ++p;
3266 }
3267 }
3268
3269 /* Store info in RESULT if requested by the caller. */
3270 if (result)
3271 {
3272 result->number_part = num;
3273
3274 if (IS_R_SELECT (p))
3275 {
3276 result->l_r_select = 1;
3277 ++p;
3278 }
3279 else if (IS_L_SELECT (p))
3280 {
3281 result->l_r_select = 0;
3282 ++p;
3283 }
3284 else
3285 result->l_r_select = 0;
3286 }
3287 }
3288 else if (*p == '%')
3289 {
3290 /* The number might be a predefined register. */
3291 num = 0;
3292 name = p;
3293 p++;
3294 c = *p;
3295 /* Tege hack: Special case for general registers as the general
3296 code makes a binary search with case translation, and is VERY
3297 slow. */
3298 if (c == 'r')
3299 {
3300 p++;
3301 if (*p == 'e' && *(p + 1) == 't'
3302 && (*(p + 2) == '0' || *(p + 2) == '1'))
3303 {
3304 p += 2;
3305 num = *p - '0' + 28;
3306 p++;
3307 }
3308 else if (*p == 'p')
3309 {
3310 num = 2;
3311 p++;
3312 }
3313 else if (!isdigit (*p))
3314 {
3315 if (print_errors)
3316 as_bad ("Undefined register: '%s'.", name);
3317 num = -1;
3318 }
3319 else
3320 {
3321 do
3322 num = num * 10 + *p++ - '0';
3323 while (isdigit (*p));
3324 }
3325 }
3326 else
3327 {
3328 /* Do a normal register search. */
3329 while (is_part_of_name (c))
3330 {
3331 p = p + 1;
3332 c = *p;
3333 }
3334 *p = 0;
3335 status = reg_name_search (name);
3336 if (status >= 0)
3337 num = status;
3338 else
3339 {
3340 if (print_errors)
3341 as_bad ("Undefined register: '%s'.", name);
3342 num = -1;
3343 }
3344 *p = c;
3345 }
3346
3347 /* Store info in RESULT if requested by caller. */
3348 if (result)
3349 {
3350 result->number_part = num;
3351 if (IS_R_SELECT (p - 1))
3352 result->l_r_select = 1;
3353 else if (IS_L_SELECT (p - 1))
3354 result->l_r_select = 0;
3355 else
3356 result->l_r_select = 0;
3357 }
3358 }
3359 else
3360 {
3361 /* And finally, it could be a symbol in the absolute section which
3362 is effectively a constant. */
3363 num = 0;
3364 name = p;
3365 c = *p;
3366 while (is_part_of_name (c))
3367 {
3368 p = p + 1;
3369 c = *p;
3370 }
3371 *p = 0;
3372 if ((sym = symbol_find (name)) != NULL)
3373 {
3374 if (S_GET_SEGMENT (sym) == &bfd_abs_section)
3375 num = S_GET_VALUE (sym);
3376 else
3377 {
3378 if (print_errors)
3379 as_bad ("Non-absolute symbol: '%s'.", name);
3380 num = -1;
3381 }
3382 }
3383 else
3384 {
3385 /* There is where we'd come for an undefined symbol
3386 or for an empty string. For an empty string we
3387 will return zero. That's a concession made for
3388 compatability with the braindamaged HP assemblers. */
3389 if (*name == 0)
3390 num = 0;
3391 else
3392 {
3393 if (print_errors)
3394 as_bad ("Undefined absolute constant: '%s'.", name);
3395 num = -1;
3396 }
3397 }
3398 *p = c;
3399
3400 /* Store info in RESULT if requested by caller. */
3401 if (result)
3402 {
3403 result->number_part = num;
3404 if (IS_R_SELECT (p - 1))
3405 result->l_r_select = 1;
3406 else if (IS_L_SELECT (p - 1))
3407 result->l_r_select = 0;
3408 else
3409 result->l_r_select = 0;
3410 }
3411 }
3412
3413 *s = p;
3414 return num;
3415 }
3416
3417 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
3418
3419 /* Given NAME, find the register number associated with that name, return
3420 the integer value associated with the given name or -1 on failure. */
3421
3422 static int
3423 reg_name_search (name)
3424 char *name;
3425 {
3426 int middle, low, high;
3427
3428 low = 0;
3429 high = REG_NAME_CNT - 1;
3430
3431 do
3432 {
3433 middle = (low + high) / 2;
3434 if (strcasecmp (name, pre_defined_registers[middle].name) < 0)
3435 high = middle - 1;
3436 else
3437 low = middle + 1;
3438 }
3439 while (!((strcasecmp (name, pre_defined_registers[middle].name) == 0) ||
3440 (low > high)));
3441
3442 if (strcasecmp (name, pre_defined_registers[middle].name) == 0)
3443 return (pre_defined_registers[middle].value);
3444 else
3445 return (-1);
3446 }
3447
3448
3449 /* Return nonzero if the given INSN and L/R information will require
3450 a new PA-89 opcode. */
3451
3452 static int
3453 need_89_opcode (insn, result)
3454 struct pa_it *insn;
3455 struct pa_89_fp_reg_struct *result;
3456 {
3457 if (result->l_r_select == 1 && !(insn->fpof1 == DBL && insn->fpof2 == DBL))
3458 return TRUE;
3459 else
3460 return FALSE;
3461 }
3462
3463 /* Parse a condition for a fcmp instruction. Return the numerical
3464 code associated with the condition. */
3465
3466 static int
3467 pa_parse_fp_cmp_cond (s)
3468 char **s;
3469 {
3470 int cond, i;
3471
3472 cond = 0;
3473
3474 for (i = 0; i < 32; i++)
3475 {
3476 if (strncasecmp (*s, fp_cond_map[i].string,
3477 strlen (fp_cond_map[i].string)) == 0)
3478 {
3479 cond = fp_cond_map[i].cond;
3480 *s += strlen (fp_cond_map[i].string);
3481 while (**s == ' ' || **s == '\t')
3482 *s = *s + 1;
3483 return cond;
3484 }
3485 }
3486
3487 as_bad ("Invalid FP Compare Condition: %c", **s);
3488 return 0;
3489 }
3490
3491 /* Parse an FP operand format completer returning the completer
3492 type. */
3493
3494 static fp_operand_format
3495 pa_parse_fp_format (s)
3496 char **s;
3497 {
3498 int format;
3499
3500 format = SGL;
3501 if (**s == ',')
3502 {
3503 *s += 1;
3504 if (strncasecmp (*s, "sgl", 3) == 0)
3505 {
3506 format = SGL;
3507 *s += 4;
3508 }
3509 else if (strncasecmp (*s, "dbl", 3) == 0)
3510 {
3511 format = DBL;
3512 *s += 4;
3513 }
3514 else if (strncasecmp (*s, "quad", 4) == 0)
3515 {
3516 format = QUAD;
3517 *s += 5;
3518 }
3519 else
3520 {
3521 format = ILLEGAL_FMT;
3522 as_bad ("Invalid FP Operand Format: %3s", *s);
3523 }
3524 }
3525
3526 return format;
3527 }
3528
3529 /* Convert from a selector string into a selector type. */
3530
3531 static int
3532 pa_chk_field_selector (str)
3533 char **str;
3534 {
3535 int selector;
3536 const struct selector_entry *tablep;
3537
3538 selector = e_fsel;
3539
3540 /* Read past any whitespace. */
3541 while (**str == ' ' || **str == '\t' || **str == '\n' || **str == '\f')
3542 *str = *str + 1;
3543
3544 /* Yuk. Looks like a linear search through the table. With the
3545 frequence of some selectors it might make sense to sort the
3546 table by usage. */
3547 for (tablep = selector_table; tablep->prefix; tablep++)
3548 {
3549 if (strncasecmp (tablep->prefix, *str, strlen (tablep->prefix)) == 0)
3550 {
3551 *str += strlen (tablep->prefix);
3552 selector = tablep->field_selector;
3553 break;
3554 }
3555 }
3556 return selector;
3557 }
3558
3559 /* Mark (via expr_end) the end of an expression (I think). FIXME. */
3560
3561 static int
3562 get_expression (str)
3563 char *str;
3564 {
3565 char *save_in;
3566 asection *seg;
3567
3568 save_in = input_line_pointer;
3569 input_line_pointer = str;
3570 seg = expression (&the_insn.exp);
3571 if (!(seg == absolute_section
3572 || seg == undefined_section
3573 || SEG_NORMAL (seg)))
3574 {
3575 as_warn ("Bad segment in expression.");
3576 expr_end = input_line_pointer;
3577 input_line_pointer = save_in;
3578 return 1;
3579 }
3580 expr_end = input_line_pointer;
3581 input_line_pointer = save_in;
3582 return 0;
3583 }
3584
3585 /* Mark (via expr_end) the end of an absolute expression. FIXME. */
3586 static int
3587 pa_get_absolute_expression (insn, strp)
3588 struct pa_it *insn;
3589 char **strp;
3590 {
3591 char *save_in;
3592
3593 insn->field_selector = pa_chk_field_selector (strp);
3594 save_in = input_line_pointer;
3595 input_line_pointer = *strp;
3596 expression (&insn->exp);
3597 if (insn->exp.X_op != O_constant)
3598 {
3599 as_bad ("Bad segment (should be absolute).");
3600 expr_end = input_line_pointer;
3601 input_line_pointer = save_in;
3602 return 0;
3603 }
3604 expr_end = input_line_pointer;
3605 input_line_pointer = save_in;
3606 return evaluate_absolute (insn);
3607 }
3608
3609 /* Evaluate an absolute expression EXP which may be modified by
3610 the selector FIELD_SELECTOR. Return the value of the expression. */
3611 static int
3612 evaluate_absolute (insn)
3613 struct pa_it *insn;
3614 {
3615 int value;
3616 expressionS exp;
3617 int field_selector = insn->field_selector;
3618
3619 exp = insn->exp;
3620 value = exp.X_add_number;
3621
3622 switch (field_selector)
3623 {
3624 /* No change. */
3625 case e_fsel:
3626 break;
3627
3628 /* If bit 21 is on then add 0x800 and arithmetic shift right 11 bits. */
3629 case e_lssel:
3630 if (value & 0x00000400)
3631 value += 0x800;
3632 value = (value & 0xfffff800) >> 11;
3633 break;
3634
3635 /* Sign extend from bit 21. */
3636 case e_rssel:
3637 if (value & 0x00000400)
3638 value |= 0xfffff800;
3639 else
3640 value &= 0x7ff;
3641 break;
3642
3643 /* Arithmetic shift right 11 bits. */
3644 case e_lsel:
3645 value = (value & 0xfffff800) >> 11;
3646 break;
3647
3648 /* Set bits 0-20 to zero. */
3649 case e_rsel:
3650 value = value & 0x7ff;
3651 break;
3652
3653 /* Add 0x800 and arithmetic shift right 11 bits. */
3654 case e_ldsel:
3655 value += 0x800;
3656
3657
3658 value = (value & 0xfffff800) >> 11;
3659 break;
3660
3661 /* Set bitgs 0-21 to one. */
3662 case e_rdsel:
3663 value |= 0xfffff800;
3664 break;
3665
3666 /* This had better get fixed. It looks like we're quickly moving
3667 to LR/RR. FIXME. */
3668 case e_rrsel:
3669 case e_lrsel:
3670 abort ();
3671
3672 default:
3673 BAD_CASE (field_selector);
3674 break;
3675 }
3676 return value;
3677 }
3678
3679 /* Given an argument location specification return the associated
3680 argument location number. */
3681
3682 static unsigned int
3683 pa_build_arg_reloc (type_name)
3684 char *type_name;
3685 {
3686
3687 if (strncasecmp (type_name, "no", 2) == 0)
3688 return 0;
3689 if (strncasecmp (type_name, "gr", 2) == 0)
3690 return 1;
3691 else if (strncasecmp (type_name, "fr", 2) == 0)
3692 return 2;
3693 else if (strncasecmp (type_name, "fu", 2) == 0)
3694 return 3;
3695 else
3696 as_bad ("Invalid argument location: %s\n", type_name);
3697
3698 return 0;
3699 }
3700
3701 /* Encode and return an argument relocation specification for
3702 the given register in the location specified by arg_reloc. */
3703
3704 static unsigned int
3705 pa_align_arg_reloc (reg, arg_reloc)
3706 unsigned int reg;
3707 unsigned int arg_reloc;
3708 {
3709 unsigned int new_reloc;
3710
3711 new_reloc = arg_reloc;
3712 switch (reg)
3713 {
3714 case 0:
3715 new_reloc <<= 8;
3716 break;
3717 case 1:
3718 new_reloc <<= 6;
3719 break;
3720 case 2:
3721 new_reloc <<= 4;
3722 break;
3723 case 3:
3724 new_reloc <<= 2;
3725 break;
3726 default:
3727 as_bad ("Invalid argument description: %d", reg);
3728 }
3729
3730 return new_reloc;
3731 }
3732
3733 /* Parse a PA nullification completer (,n). Return nonzero if the
3734 completer was found; return zero if no completer was found. */
3735
3736 static int
3737 pa_parse_nullif (s)
3738 char **s;
3739 {
3740 int nullif;
3741
3742 nullif = 0;
3743 if (**s == ',')
3744 {
3745 *s = *s + 1;
3746 if (strncasecmp (*s, "n", 1) == 0)
3747 nullif = 1;
3748 else
3749 {
3750 as_bad ("Invalid Nullification: (%c)", **s);
3751 nullif = 0;
3752 }
3753 *s = *s + 1;
3754 }
3755
3756 return nullif;
3757 }
3758
3759 /* Parse a non-negated compare/subtract completer returning the
3760 number (for encoding in instrutions) of the given completer.
3761
3762 ISBRANCH specifies whether or not this is parsing a condition
3763 completer for a branch (vs a nullification completer for a
3764 computational instruction. */
3765
3766 static int
3767 pa_parse_nonneg_cmpsub_cmpltr (s, isbranch)
3768 char **s;
3769 int isbranch;
3770 {
3771 int cmpltr;
3772 char *name = *s + 1;
3773 char c;
3774 char *save_s = *s;
3775
3776 cmpltr = 0;
3777 if (**s == ',')
3778 {
3779 *s += 1;
3780 while (**s != ',' && **s != ' ' && **s != '\t')
3781 *s += 1;
3782 c = **s;
3783 **s = 0x00;
3784 if (strcmp (name, "=") == 0)
3785 {
3786 cmpltr = 1;
3787 }
3788 else if (strcmp (name, "<") == 0)
3789 {
3790 cmpltr = 2;
3791 }
3792 else if (strcmp (name, "<=") == 0)
3793 {
3794 cmpltr = 3;
3795 }
3796 else if (strcmp (name, "<<") == 0)
3797 {
3798 cmpltr = 4;
3799 }
3800 else if (strcmp (name, "<<=") == 0)
3801 {
3802 cmpltr = 5;
3803 }
3804 else if (strcasecmp (name, "sv") == 0)
3805 {
3806 cmpltr = 6;
3807 }
3808 else if (strcasecmp (name, "od") == 0)
3809 {
3810 cmpltr = 7;
3811 }
3812 /* If we have something like addb,n then there is no condition
3813 completer. */
3814 else if (strcasecmp (name, "n") == 0 && isbranch)
3815 {
3816 cmpltr = 0;
3817 }
3818 else
3819 {
3820 cmpltr = -1;
3821 }
3822 **s = c;
3823 }
3824
3825 /* Reset pointers if this was really a ,n for a branch instruction. */
3826 if (cmpltr == 0 && *name == 'n' && isbranch)
3827 *s = save_s;
3828
3829 return cmpltr;
3830 }
3831
3832 /* Parse a negated compare/subtract completer returning the
3833 number (for encoding in instrutions) of the given completer.
3834
3835 ISBRANCH specifies whether or not this is parsing a condition
3836 completer for a branch (vs a nullification completer for a
3837 computational instruction. */
3838
3839 static int
3840 pa_parse_neg_cmpsub_cmpltr (s, isbranch)
3841 char **s;
3842 int isbranch;
3843 {
3844 int cmpltr;
3845 char *name = *s + 1;
3846 char c;
3847 char *save_s = *s;
3848
3849 cmpltr = 0;
3850 if (**s == ',')
3851 {
3852 *s += 1;
3853 while (**s != ',' && **s != ' ' && **s != '\t')
3854 *s += 1;
3855 c = **s;
3856 **s = 0x00;
3857 if (strcasecmp (name, "tr") == 0)
3858 {
3859 cmpltr = 0;
3860 }
3861 else if (strcmp (name, "<>") == 0)
3862 {
3863 cmpltr = 1;
3864 }
3865 else if (strcmp (name, ">=") == 0)
3866 {
3867 cmpltr = 2;
3868 }
3869 else if (strcmp (name, ">") == 0)
3870 {
3871 cmpltr = 3;
3872 }
3873 else if (strcmp (name, ">>=") == 0)
3874 {
3875 cmpltr = 4;
3876 }
3877 else if (strcmp (name, ">>") == 0)
3878 {
3879 cmpltr = 5;
3880 }
3881 else if (strcasecmp (name, "nsv") == 0)
3882 {
3883 cmpltr = 6;
3884 }
3885 else if (strcasecmp (name, "ev") == 0)
3886 {
3887 cmpltr = 7;
3888 }
3889 /* If we have something like addb,n then there is no condition
3890 completer. */
3891 else if (strcasecmp (name, "n") == 0 && isbranch)
3892 {
3893 cmpltr = 0;
3894 }
3895 else
3896 {
3897 cmpltr = -1;
3898 }
3899 **s = c;
3900 }
3901
3902 /* Reset pointers if this was really a ,n for a branch instruction. */
3903 if (cmpltr == 0 && *name == 'n' && isbranch)
3904 *s = save_s;
3905
3906 return cmpltr;
3907 }
3908
3909 /* Parse a non-negated addition completer returning the number
3910 (for encoding in instrutions) of the given completer.
3911
3912 ISBRANCH specifies whether or not this is parsing a condition
3913 completer for a branch (vs a nullification completer for a
3914 computational instruction. */
3915
3916 static int
3917 pa_parse_nonneg_add_cmpltr (s, isbranch)
3918 char **s;
3919 int isbranch;
3920 {
3921 int cmpltr;
3922 char *name = *s + 1;
3923 char c;
3924 char *save_s = *s;
3925
3926 cmpltr = 0;
3927 if (**s == ',')
3928 {
3929 *s += 1;
3930 while (**s != ',' && **s != ' ' && **s != '\t')
3931 *s += 1;
3932 c = **s;
3933 **s = 0x00;
3934 if (strcmp (name, "=") == 0)
3935 {
3936 cmpltr = 1;
3937 }
3938 else if (strcmp (name, "<") == 0)
3939 {
3940 cmpltr = 2;
3941 }
3942 else if (strcmp (name, "<=") == 0)
3943 {
3944 cmpltr = 3;
3945 }
3946 else if (strcasecmp (name, "nuv") == 0)
3947 {
3948 cmpltr = 4;
3949 }
3950 else if (strcasecmp (name, "znv") == 0)
3951 {
3952 cmpltr = 5;
3953 }
3954 else if (strcasecmp (name, "sv") == 0)
3955 {
3956 cmpltr = 6;
3957 }
3958 else if (strcasecmp (name, "od") == 0)
3959 {
3960 cmpltr = 7;
3961 }
3962 /* If we have something like addb,n then there is no condition
3963 completer. */
3964 else if (strcasecmp (name, "n") == 0 && isbranch)
3965 {
3966 cmpltr = 0;
3967 }
3968 else
3969 {
3970 cmpltr = -1;
3971 }
3972 **s = c;
3973 }
3974
3975 /* Reset pointers if this was really a ,n for a branch instruction. */
3976 if (cmpltr == 0 && *name == 'n' && isbranch)
3977 *s = save_s;
3978
3979 return cmpltr;
3980 }
3981
3982 /* Parse a negated addition completer returning the number
3983 (for encoding in instrutions) of the given completer.
3984
3985 ISBRANCH specifies whether or not this is parsing a condition
3986 completer for a branch (vs a nullification completer for a
3987 computational instruction. */
3988
3989 static int
3990 pa_parse_neg_add_cmpltr (s, isbranch)
3991 char **s;
3992 int isbranch;
3993 {
3994 int cmpltr;
3995 char *name = *s + 1;
3996 char c;
3997 char *save_s = *s;
3998
3999 cmpltr = 0;
4000 if (**s == ',')
4001 {
4002 *s += 1;
4003 while (**s != ',' && **s != ' ' && **s != '\t')
4004 *s += 1;
4005 c = **s;
4006 **s = 0x00;
4007 if (strcasecmp (name, "tr") == 0)
4008 {
4009 cmpltr = 0;
4010 }
4011 else if (strcmp (name, "<>") == 0)
4012 {
4013 cmpltr = 1;
4014 }
4015 else if (strcmp (name, ">=") == 0)
4016 {
4017 cmpltr = 2;
4018 }
4019 else if (strcmp (name, ">") == 0)
4020 {
4021 cmpltr = 3;
4022 }
4023 else if (strcmp (name, "uv") == 0)
4024 {
4025 cmpltr = 4;
4026 }
4027 else if (strcmp (name, "vnz") == 0)
4028 {
4029 cmpltr = 5;
4030 }
4031 else if (strcasecmp (name, "nsv") == 0)
4032 {
4033 cmpltr = 6;
4034 }
4035 else if (strcasecmp (name, "ev") == 0)
4036 {
4037 cmpltr = 7;
4038 }
4039 /* If we have something like addb,n then there is no condition
4040 completer. */
4041 else if (strcasecmp (name, "n") == 0 && isbranch)
4042 {
4043 cmpltr = 0;
4044 }
4045 else
4046 {
4047 cmpltr = -1;
4048 }
4049 **s = c;
4050 }
4051
4052 /* Reset pointers if this was really a ,n for a branch instruction. */
4053 if (cmpltr == 0 && *name == 'n' && isbranch)
4054 *s = save_s;
4055
4056 return cmpltr;
4057 }
4058
4059 /* Handle a .BLOCK type pseudo-op. */
4060
4061 static void
4062 pa_block (z)
4063 int z;
4064 {
4065 char *p;
4066 long int temp_fill;
4067 unsigned int temp_size;
4068 int i;
4069
4070 temp_size = get_absolute_expression ();
4071
4072 /* Always fill with zeros, that's what the HP assembler does. */
4073 temp_fill = 0;
4074
4075 p = frag_var (rs_fill, (int) temp_size, (int) temp_size,
4076 (relax_substateT) 0, (symbolS *) 0, 1, NULL);
4077 bzero (p, temp_size);
4078
4079 /* Convert 2 bytes at a time. */
4080
4081 for (i = 0; i < temp_size; i += 2)
4082 {
4083 md_number_to_chars (p + i,
4084 (valueT) temp_fill,
4085 (int) ((temp_size - i) > 2 ? 2 : (temp_size - i)));
4086 }
4087
4088 pa_undefine_label ();
4089 demand_empty_rest_of_line ();
4090 return;
4091 }
4092
4093 /* Handle a .CALL pseudo-op. This involves storing away information
4094 about where arguments are to be found so the linker can detect
4095 (and correct) argument location mismatches between caller and callee. */
4096
4097 static void
4098 pa_call (unused)
4099 int unused;
4100 {
4101 pa_call_args (&last_call_desc);
4102 demand_empty_rest_of_line ();
4103 return;
4104 }
4105
4106 /* Do the dirty work of building a call descriptor which describes
4107 where the caller placed arguments to a function call. */
4108
4109 static void
4110 pa_call_args (call_desc)
4111 struct call_desc *call_desc;
4112 {
4113 char *name, c, *p;
4114 unsigned int temp, arg_reloc;
4115
4116 while (!is_end_of_statement ())
4117 {
4118 name = input_line_pointer;
4119 c = get_symbol_end ();
4120 /* Process a source argument. */
4121 if ((strncasecmp (name, "argw", 4) == 0))
4122 {
4123 temp = atoi (name + 4);
4124 p = input_line_pointer;
4125 *p = c;
4126 input_line_pointer++;
4127 name = input_line_pointer;
4128 c = get_symbol_end ();
4129 arg_reloc = pa_build_arg_reloc (name);
4130 call_desc->arg_reloc |= pa_align_arg_reloc (temp, arg_reloc);
4131 }
4132 /* Process a return value. */
4133 else if ((strncasecmp (name, "rtnval", 6) == 0))
4134 {
4135 p = input_line_pointer;
4136 *p = c;
4137 input_line_pointer++;
4138 name = input_line_pointer;
4139 c = get_symbol_end ();
4140 arg_reloc = pa_build_arg_reloc (name);
4141 call_desc->arg_reloc |= (arg_reloc & 0x3);
4142 }
4143 else
4144 {
4145 as_bad ("Invalid .CALL argument: %s", name);
4146 }
4147 p = input_line_pointer;
4148 *p = c;
4149 if (!is_end_of_statement ())
4150 input_line_pointer++;
4151 }
4152 }
4153
4154 /* Return TRUE if FRAG1 and FRAG2 are the same. */
4155
4156 static int
4157 is_same_frag (frag1, frag2)
4158 fragS *frag1;
4159 fragS *frag2;
4160 {
4161
4162 if (frag1 == NULL)
4163 return (FALSE);
4164 else if (frag2 == NULL)
4165 return (FALSE);
4166 else if (frag1 == frag2)
4167 return (TRUE);
4168 else if (frag2->fr_type == rs_fill && frag2->fr_fix == 0)
4169 return (is_same_frag (frag1, frag2->fr_next));
4170 else
4171 return (FALSE);
4172 }
4173
4174 #ifdef OBJ_ELF
4175 /* Build an entry in the UNWIND subspace from the given function
4176 attributes in CALL_INFO. This is not needed for SOM as using
4177 R_ENTRY and R_EXIT relocations allow the linker to handle building
4178 of the unwind spaces. */
4179
4180 static void
4181 pa_build_unwind_subspace (call_info)
4182 struct call_info *call_info;
4183 {
4184 char *unwind;
4185 asection *seg, *save_seg;
4186 subsegT subseg, save_subseg;
4187 int i;
4188 char c, *p;
4189
4190 /* Get into the right seg/subseg. This may involve creating
4191 the seg the first time through. Make sure to have the
4192 old seg/subseg so that we can reset things when we are done. */
4193 subseg = SUBSEG_UNWIND;
4194 seg = bfd_get_section_by_name (stdoutput, UNWIND_SECTION_NAME);
4195 if (seg == ASEC_NULL)
4196 {
4197 seg = bfd_make_section_old_way (stdoutput, UNWIND_SECTION_NAME);
4198 bfd_set_section_flags (stdoutput, seg,
4199 SEC_READONLY | SEC_HAS_CONTENTS
4200 | SEC_LOAD | SEC_RELOC);
4201 }
4202
4203 save_seg = now_seg;
4204 save_subseg = now_subseg;
4205 subseg_set (seg, subseg);
4206
4207
4208 /* Get some space to hold relocation information for the unwind
4209 descriptor. */
4210 p = frag_more (4);
4211 call_info->start_offset_frag = frag_now;
4212 call_info->start_frag_where = p - frag_now->fr_literal;
4213
4214 /* Relocation info. for start offset of the function. */
4215 fix_new_hppa (frag_now, p - frag_now->fr_literal, 4,
4216 call_info->start_symbol, (offsetT) 0,
4217 (expressionS *) NULL, 0, R_HPPA_UNWIND, e_fsel, 32, 0,
4218 (char *) 0);
4219
4220 /* We need to search for the first relocation involving the start_symbol of
4221 this call_info descriptor. */
4222 {
4223 fixS *fixP;
4224
4225 call_info->start_fix = seg_info (now_seg)->fix_root;
4226 for (fixP = call_info->start_fix; fixP; fixP = fixP->fx_next)
4227 {
4228 if (fixP->fx_addsy == call_info->start_symbol
4229 || fixP->fx_subsy == call_info->start_symbol)
4230 {
4231 call_info->start_fix = fixP;
4232 break;
4233 }
4234 }
4235 }
4236
4237 p = frag_more (4);
4238 call_info->end_offset_frag = frag_now;
4239 call_info->end_frag_where = p - frag_now->fr_literal;
4240
4241 /* Relocation info. for end offset of the function. */
4242 fix_new_hppa (frag_now, p - frag_now->fr_literal, 4,
4243 call_info->end_symbol, (offsetT) 0,
4244 (expressionS *) NULL, 0, R_HPPA_UNWIND, e_fsel, 32, 0,
4245 (char *) 0);
4246
4247 /* We need to search for the first relocation involving the end_symbol of
4248 this call_info descriptor. */
4249 {
4250 fixS *fixP;
4251
4252 call_info->end_fix = seg_info (now_seg)->fix_root; /* the default */
4253 for (fixP = call_info->end_fix; fixP; fixP = fixP->fx_next)
4254 {
4255 if (fixP->fx_addsy == call_info->end_symbol
4256 || fixP->fx_subsy == call_info->end_symbol)
4257 {
4258 call_info->end_fix = fixP;
4259 break;
4260 }
4261 }
4262 }
4263
4264 /* Dump it. */
4265 unwind = (char *) &call_info->ci_unwind;
4266 for (i = 8; i < sizeof (struct unwind_table); i++)
4267 {
4268 c = *(unwind + i);
4269 {
4270 FRAG_APPEND_1_CHAR (c);
4271 }
4272 }
4273
4274 /* Return back to the original segment/subsegment. */
4275 subseg_set (save_seg, save_subseg);
4276 }
4277 #endif
4278
4279 /* Process a .CALLINFO pseudo-op. This information is used later
4280 to build unwind descriptors and maybe one day to support
4281 .ENTER and .LEAVE. */
4282
4283 static void
4284 pa_callinfo (unused)
4285 int unused;
4286 {
4287 char *name, c, *p;
4288 int temp;
4289
4290 /* .CALLINFO must appear within a procedure definition. */
4291 if (!within_procedure)
4292 as_bad (".callinfo is not within a procedure definition");
4293
4294 /* Mark the fact that we found the .CALLINFO for the
4295 current procedure. */
4296 callinfo_found = TRUE;
4297
4298 /* Iterate over the .CALLINFO arguments. */
4299 while (!is_end_of_statement ())
4300 {
4301 name = input_line_pointer;
4302 c = get_symbol_end ();
4303 /* Frame size specification. */
4304 if ((strncasecmp (name, "frame", 5) == 0))
4305 {
4306 p = input_line_pointer;
4307 *p = c;
4308 input_line_pointer++;
4309 temp = get_absolute_expression ();
4310 if ((temp & 0x3) != 0)
4311 {
4312 as_bad ("FRAME parameter must be a multiple of 8: %d\n", temp);
4313 temp = 0;
4314 }
4315
4316 /* callinfo is in bytes and unwind_desc is in 8 byte units. */
4317 last_call_info->ci_unwind.descriptor.frame_size = temp / 8;
4318
4319 }
4320 /* Entry register (GR, GR and SR) specifications. */
4321 else if ((strncasecmp (name, "entry_gr", 8) == 0))
4322 {
4323 p = input_line_pointer;
4324 *p = c;
4325 input_line_pointer++;
4326 temp = get_absolute_expression ();
4327 /* The HP assembler accepts 19 as the high bound for ENTRY_GR
4328 even though %r19 is caller saved. I think this is a bug in
4329 the HP assembler, and we are not going to emulate it. */
4330 if (temp < 3 || temp > 18)
4331 as_bad ("Value for ENTRY_GR must be in the range 3..18\n");
4332 last_call_info->ci_unwind.descriptor.entry_gr = temp - 2;
4333 }
4334 else if ((strncasecmp (name, "entry_fr", 8) == 0))
4335 {
4336 p = input_line_pointer;
4337 *p = c;
4338 input_line_pointer++;
4339 temp = get_absolute_expression ();
4340 /* Similarly the HP assembler takes 31 as the high bound even
4341 though %fr21 is the last callee saved floating point register. */
4342 if (temp < 12 || temp > 21)
4343 as_bad ("Value for ENTRY_FR must be in the range 12..21\n");
4344 last_call_info->ci_unwind.descriptor.entry_fr = temp - 11;
4345 }
4346 else if ((strncasecmp (name, "entry_sr", 8) == 0))
4347 {
4348 p = input_line_pointer;
4349 *p = c;
4350 input_line_pointer++;
4351 temp = get_absolute_expression ();
4352 if (temp != 3)
4353 as_bad ("Value for ENTRY_SR must be 3\n");
4354 last_call_info->entry_sr = temp - 2;
4355 }
4356 /* Note whether or not this function performs any calls. */
4357 else if ((strncasecmp (name, "calls", 5) == 0) ||
4358 (strncasecmp (name, "caller", 6) == 0))
4359 {
4360 p = input_line_pointer;
4361 *p = c;
4362 last_call_info->makes_calls = 1;
4363 }
4364 else if ((strncasecmp (name, "no_calls", 8) == 0))
4365 {
4366 p = input_line_pointer;
4367 *p = c;
4368 last_call_info->makes_calls = 0;
4369 }
4370 /* Should RP be saved into the stack. */
4371 else if ((strncasecmp (name, "save_rp", 7) == 0))
4372 {
4373 p = input_line_pointer;
4374 *p = c;
4375 last_call_info->ci_unwind.descriptor.save_rp = 1;
4376 }
4377 /* Likewise for SP. */
4378 else if ((strncasecmp (name, "save_sp", 7) == 0))
4379 {
4380 p = input_line_pointer;
4381 *p = c;
4382 last_call_info->ci_unwind.descriptor.save_sp = 1;
4383 }
4384 /* Is this an unwindable procedure. If so mark it so
4385 in the unwind descriptor. */
4386 else if ((strncasecmp (name, "no_unwind", 9) == 0))
4387 {
4388 p = input_line_pointer;
4389 *p = c;
4390 last_call_info->ci_unwind.descriptor.cannot_unwind = 1;
4391 }
4392 /* Is this an interrupt routine. If so mark it in the
4393 unwind descriptor. */
4394 else if ((strncasecmp (name, "hpux_int", 7) == 0))
4395 {
4396 p = input_line_pointer;
4397 *p = c;
4398 last_call_info->ci_unwind.descriptor.hpux_interrupt_marker = 1;
4399 }
4400 else
4401 {
4402 as_bad ("Invalid .CALLINFO argument: %s", name);
4403 }
4404 if (!is_end_of_statement ())
4405 input_line_pointer++;
4406 }
4407
4408 demand_empty_rest_of_line ();
4409 return;
4410 }
4411
4412 /* Switch into the code subspace. */
4413
4414 static void
4415 pa_code (unused)
4416 int unused;
4417 {
4418 sd_chain_struct *sdchain;
4419
4420 /* First time through it might be necessary to create the
4421 $TEXT$ space. */
4422 if ((sdchain = is_defined_space ("$TEXT$")) == NULL)
4423 {
4424 sdchain = create_new_space (pa_def_spaces[0].name,
4425 pa_def_spaces[0].spnum,
4426 pa_def_spaces[0].loadable,
4427 pa_def_spaces[0].defined,
4428 pa_def_spaces[0].private,
4429 pa_def_spaces[0].sort,
4430 pa_def_spaces[0].segment, 0);
4431 }
4432
4433 SPACE_DEFINED (sdchain) = 1;
4434 subseg_set (text_section, SUBSEG_CODE);
4435 demand_empty_rest_of_line ();
4436 return;
4437 }
4438
4439 /* This is different than the standard GAS s_comm(). On HP9000/800 machines,
4440 the .comm pseudo-op has the following symtax:
4441
4442 <label> .comm <length>
4443
4444 where <label> is optional and is a symbol whose address will be the start of
4445 a block of memory <length> bytes long. <length> must be an absolute
4446 expression. <length> bytes will be allocated in the current space
4447 and subspace. */
4448
4449 static void
4450 pa_comm (unused)
4451 int unused;
4452 {
4453 unsigned int size;
4454 symbolS *symbol;
4455 label_symbol_struct *label_symbol = pa_get_label ();
4456
4457 if (label_symbol)
4458 symbol = label_symbol->lss_label;
4459 else
4460 symbol = NULL;
4461
4462 SKIP_WHITESPACE ();
4463 size = get_absolute_expression ();
4464
4465 if (symbol)
4466 {
4467 /* It is incorrect to check S_IS_DEFINED at this point as
4468 the symbol will *always* be defined. FIXME. How to
4469 correctly determine when this label really as been
4470 defined before. */
4471 if (S_GET_VALUE (symbol))
4472 {
4473 if (S_GET_VALUE (symbol) != size)
4474 {
4475 as_warn ("Length of .comm \"%s\" is already %d. Not changed.",
4476 S_GET_NAME (symbol), S_GET_VALUE (symbol));
4477 return;
4478 }
4479 }
4480 else
4481 {
4482 S_SET_VALUE (symbol, size);
4483 S_SET_SEGMENT (symbol, &bfd_und_section);
4484 S_SET_EXTERNAL (symbol);
4485 }
4486 }
4487 demand_empty_rest_of_line ();
4488 }
4489
4490 /* Process a .COPYRIGHT pseudo-op. */
4491
4492 static void
4493 pa_copyright (unused)
4494 int unused;
4495 {
4496 char *name;
4497 char c;
4498
4499 SKIP_WHITESPACE ();
4500 if (*input_line_pointer == '\"')
4501 {
4502 ++input_line_pointer;
4503 name = input_line_pointer;
4504 while ((c = next_char_of_string ()) >= 0)
4505 ;
4506 c = *input_line_pointer;
4507 *input_line_pointer = '\0';
4508 *(input_line_pointer - 1) = '\0';
4509 {
4510 /* FIXME. Not supported */
4511 abort ();
4512 }
4513 *input_line_pointer = c;
4514 }
4515 else
4516 {
4517 as_bad ("Expected \"-ed string");
4518 }
4519 pa_undefine_label ();
4520 demand_empty_rest_of_line ();
4521 }
4522
4523 /* Process a .END pseudo-op. */
4524
4525 static void
4526 pa_end (unused)
4527 int unused;
4528 {
4529 demand_empty_rest_of_line ();
4530 return;
4531 }
4532
4533 /* Process a .ENTER pseudo-op. This is not supported. */
4534 static void
4535 pa_enter (unused)
4536 int unused;
4537 {
4538 abort ();
4539 return;
4540 }
4541
4542 /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the
4543 procesure. */
4544 static void
4545 pa_entry (unused)
4546 int unused;
4547 {
4548 if (!within_procedure)
4549 as_bad ("Misplaced .entry. Ignored.");
4550 else
4551 {
4552 if (!callinfo_found)
4553 as_bad ("Missing .callinfo.");
4554
4555 last_call_info->start_frag = frag_now;
4556 }
4557 demand_empty_rest_of_line ();
4558 within_entry_exit = TRUE;
4559
4560 /* Go back to the last symbol and turn on the BSF_FUNCTION flag.
4561 It will not be on if no .EXPORT pseudo-op exists (static function). */
4562 last_call_info->start_symbol->bsym->flags |= BSF_FUNCTION;
4563
4564 #ifdef OBJ_SOM
4565 /* SOM defers building of unwind descriptors until the link phase.
4566 The assembler is responsible for creating an R_ENTRY relocation
4567 to mark the beginning of a region and hold the unwind bits, and
4568 for creating an R_EXIT relocation to mark the end of the region.
4569
4570 FIXME. ELF should be using the same conventions! The problem
4571 is an unwind requires too much relocation space. Hmmm. Maybe
4572 if we split the unwind bits up between the relocations which
4573 denote the entry and exit points. */
4574 {
4575 char *where = frag_more (0);
4576
4577 fix_new_hppa (frag_now, where - frag_now->fr_literal, 0,
4578 last_call_info->start_symbol, (offsetT) 0, NULL,
4579 0, R_HPPA_ENTRY, e_fsel, 0, 0,
4580 (char *) &last_call_info->ci_unwind.descriptor);
4581 }
4582 #endif
4583
4584 return;
4585 }
4586
4587 /* Handle a .EQU pseudo-op. */
4588
4589 static void
4590 pa_equ (reg)
4591 int reg;
4592 {
4593 label_symbol_struct *label_symbol = pa_get_label ();
4594 symbolS *symbol;
4595
4596 if (label_symbol)
4597 {
4598 symbol = label_symbol->lss_label;
4599 S_SET_VALUE (symbol, (unsigned int) get_absolute_expression ());
4600 S_SET_SEGMENT (symbol, &bfd_abs_section);
4601 }
4602 else
4603 {
4604 if (reg)
4605 as_bad (".REG must use a label");
4606 else
4607 as_bad (".EQU must use a label");
4608 }
4609
4610 pa_undefine_label ();
4611 demand_empty_rest_of_line ();
4612 return;
4613 }
4614
4615 /* Helper function. Does processing for the end of a function. This
4616 usually involves creating some relocations or building special
4617 symbols to mark the end of the function. */
4618
4619 static void
4620 process_exit ()
4621 {
4622 char *where;
4623
4624 where = frag_more (0);
4625
4626 #ifdef OBJ_ELF
4627 /* Mark the end of the function, stuff away the location of the frag
4628 for the end of the function, and finally call pa_build_unwind_subspace
4629 to add an entry in the unwind table. */
4630 hppa_elf_mark_end_of_function ();
4631 last_call_info->end_frag = frag_now;
4632 pa_build_unwind_subspace (last_call_info);
4633 #else
4634 /* SOM defers building of unwind descriptors until the link phase.
4635 The assembler is responsible for creating an R_ENTRY relocation
4636 to mark the beginning of a region and hold the unwind bits, and
4637 for creating an R_EXIT relocation to mark the end of the region.
4638
4639 FIXME. ELF should be using the same conventions! The problem
4640 is an unwind requires too much relocation space. Hmmm. Maybe
4641 if we split the unwind bits up between the relocations which
4642 denote the entry and exit points. */
4643 fix_new_hppa (frag_now, where - frag_now->fr_literal, 0,
4644 last_call_info->start_symbol, (offsetT) 0,
4645 NULL, 0, R_HPPA_EXIT, e_fsel, 0, 0, NULL);
4646 #endif
4647
4648 }
4649
4650 /* Process a .EXIT pseudo-op. */
4651
4652 static void
4653 pa_exit (unused)
4654 int unused;
4655 {
4656 if (!within_procedure)
4657 as_bad (".EXIT must appear within a procedure");
4658 else
4659 {
4660 if (!callinfo_found)
4661 as_bad ("Missing .callinfo");
4662 else
4663 {
4664 if (!within_entry_exit)
4665 as_bad ("No .ENTRY for this .EXIT");
4666 else
4667 {
4668 within_entry_exit = FALSE;
4669 process_exit ();
4670 }
4671 }
4672 }
4673 demand_empty_rest_of_line ();
4674 return;
4675 }
4676
4677 /* Process a .EXPORT directive. This makes functions external
4678 and provides information such as argument relocation entries
4679 to callers. */
4680
4681 static void
4682 pa_export (unused)
4683 int unused;
4684 {
4685 char *name, c, *p;
4686 symbolS *symbol;
4687
4688 name = input_line_pointer;
4689 c = get_symbol_end ();
4690 /* Make sure the given symbol exists. */
4691 if ((symbol = symbol_find_or_make (name)) == NULL)
4692 {
4693 as_bad ("Cannot define export symbol: %s\n", name);
4694 p = input_line_pointer;
4695 *p = c;
4696 input_line_pointer++;
4697 }
4698 else
4699 {
4700 /* OK. Set the external bits and process argument relocations. */
4701 S_SET_EXTERNAL (symbol);
4702 p = input_line_pointer;
4703 *p = c;
4704 if (!is_end_of_statement ())
4705 {
4706 input_line_pointer++;
4707 pa_type_args (symbol, 1);
4708 #ifdef OBJ_ELF
4709 pa_build_symextn_section ();
4710 #endif
4711 }
4712 }
4713
4714 demand_empty_rest_of_line ();
4715 return;
4716 }
4717
4718 /* Helper function to process arguments to a .EXPORT pseudo-op. */
4719
4720 static void
4721 pa_type_args (symbolP, is_export)
4722 symbolS *symbolP;
4723 int is_export;
4724 {
4725 char *name, c, *p;
4726 unsigned int temp, arg_reloc;
4727 pa_symbol_type type = SYMBOL_TYPE_UNKNOWN;
4728 obj_symbol_type *symbol = (obj_symbol_type *) symbolP->bsym;
4729
4730 if (strncasecmp (input_line_pointer, "absolute", 8) == 0)
4731
4732 {
4733 input_line_pointer += 8;
4734 symbolP->bsym->flags &= ~BSF_FUNCTION;
4735 S_SET_SEGMENT (symbolP, &bfd_abs_section);
4736 type = SYMBOL_TYPE_ABSOLUTE;
4737 }
4738 else if (strncasecmp (input_line_pointer, "code", 4) == 0)
4739 {
4740 input_line_pointer += 4;
4741 /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM,
4742 instead one should be IMPORTing/EXPORTing ENTRY types.
4743
4744 Complain if one tries to EXPORT a CODE type since that's never
4745 done. Both GCC and HP C still try to IMPORT CODE types, so
4746 silently fix them to be ENTRY types. */
4747 if (symbolP->bsym->flags & BSF_FUNCTION)
4748 {
4749 if (is_export)
4750 as_tsktsk ("Using ENTRY rather than CODE in export directive for %s", symbolP->bsym->name);
4751
4752 symbolP->bsym->flags |= BSF_FUNCTION;
4753 type = SYMBOL_TYPE_ENTRY;
4754 }
4755 else
4756 {
4757 symbolP->bsym->flags &= ~BSF_FUNCTION;
4758 type = SYMBOL_TYPE_CODE;
4759 }
4760 }
4761 else if (strncasecmp (input_line_pointer, "data", 4) == 0)
4762 {
4763 input_line_pointer += 4;
4764 symbolP->bsym->flags &= ~BSF_FUNCTION;
4765 type = SYMBOL_TYPE_DATA;
4766 }
4767 else if ((strncasecmp (input_line_pointer, "entry", 5) == 0))
4768 {
4769 input_line_pointer += 5;
4770 symbolP->bsym->flags |= BSF_FUNCTION;
4771 type = SYMBOL_TYPE_ENTRY;
4772 }
4773 else if (strncasecmp (input_line_pointer, "millicode", 9) == 0)
4774 {
4775 input_line_pointer += 9;
4776 symbolP->bsym->flags |= BSF_FUNCTION;
4777 type = SYMBOL_TYPE_MILLICODE;
4778 }
4779 else if (strncasecmp (input_line_pointer, "plabel", 6) == 0)
4780 {
4781 input_line_pointer += 6;
4782 symbolP->bsym->flags &= ~BSF_FUNCTION;
4783 type = SYMBOL_TYPE_PLABEL;
4784 }
4785 else if (strncasecmp (input_line_pointer, "pri_prog", 8) == 0)
4786 {
4787 input_line_pointer += 8;
4788 symbolP->bsym->flags |= BSF_FUNCTION;
4789 type = SYMBOL_TYPE_PRI_PROG;
4790 }
4791 else if (strncasecmp (input_line_pointer, "sec_prog", 8) == 0)
4792 {
4793 input_line_pointer += 8;
4794 symbolP->bsym->flags |= BSF_FUNCTION;
4795 type = SYMBOL_TYPE_SEC_PROG;
4796 }
4797
4798 /* SOM requires much more information about symbol types
4799 than BFD understands. This is how we get this information
4800 to the SOM BFD backend. */
4801 #ifdef obj_set_symbol_type
4802 obj_set_symbol_type (symbolP->bsym, (int) type);
4803 #endif
4804
4805 /* Now that the type of the exported symbol has been handled,
4806 handle any argument relocation information. */
4807 while (!is_end_of_statement ())
4808 {
4809 if (*input_line_pointer == ',')
4810 input_line_pointer++;
4811 name = input_line_pointer;
4812 c = get_symbol_end ();
4813 /* Argument sources. */
4814 if ((strncasecmp (name, "argw", 4) == 0))
4815 {
4816 p = input_line_pointer;
4817 *p = c;
4818 input_line_pointer++;
4819 temp = atoi (name + 4);
4820 name = input_line_pointer;
4821 c = get_symbol_end ();
4822 arg_reloc = pa_align_arg_reloc (temp, pa_build_arg_reloc (name));
4823 symbol->tc_data.hppa_arg_reloc |= arg_reloc;
4824 *input_line_pointer = c;
4825 }
4826 /* The return value. */
4827 else if ((strncasecmp (name, "rtnval", 6)) == 0)
4828 {
4829 p = input_line_pointer;
4830 *p = c;
4831 input_line_pointer++;
4832 name = input_line_pointer;
4833 c = get_symbol_end ();
4834 arg_reloc = pa_build_arg_reloc (name);
4835 symbol->tc_data.hppa_arg_reloc |= arg_reloc;
4836 *input_line_pointer = c;
4837 }
4838 /* Privelege level. */
4839 else if ((strncasecmp (name, "priv_lev", 8)) == 0)
4840 {
4841 p = input_line_pointer;
4842 *p = c;
4843 input_line_pointer++;
4844 temp = atoi (input_line_pointer);
4845 c = get_symbol_end ();
4846 *input_line_pointer = c;
4847 }
4848 else
4849 {
4850 as_bad ("Undefined .EXPORT/.IMPORT argument (ignored): %s", name);
4851 p = input_line_pointer;
4852 *p = c;
4853 }
4854 if (!is_end_of_statement ())
4855 input_line_pointer++;
4856 }
4857 }
4858
4859 /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given
4860 assembly file must either be defined in the assembly file, or
4861 explicitly IMPORTED from another. */
4862
4863 static void
4864 pa_import (unused)
4865 int unused;
4866 {
4867 char *name, c, *p;
4868 symbolS *symbol;
4869
4870 name = input_line_pointer;
4871 c = get_symbol_end ();
4872
4873 symbol = symbol_find_or_make (name);
4874 p = input_line_pointer;
4875 *p = c;
4876
4877 if (!is_end_of_statement ())
4878 {
4879 input_line_pointer++;
4880 pa_type_args (symbol, 0);
4881 }
4882 else
4883 {
4884 /* Sigh. To be compatable with the HP assembler and to help
4885 poorly written assembly code, we assign a type based on
4886 the the current segment. Note only BSF_FUNCTION really
4887 matters, we do not need to set the full SYMBOL_TYPE_* info here. */
4888 if (now_seg == text_section)
4889 symbol->bsym->flags |= BSF_FUNCTION;
4890
4891 /* If the section is undefined, then the symbol is undefined
4892 Since this is an import, leave the section undefined. */
4893 S_SET_SEGMENT (symbol, &bfd_und_section);
4894 }
4895
4896 demand_empty_rest_of_line ();
4897 return;
4898 }
4899
4900 /* Handle a .LABEL pseudo-op. */
4901
4902 static void
4903 pa_label (unused)
4904 int unused;
4905 {
4906 char *name, c, *p;
4907
4908 name = input_line_pointer;
4909 c = get_symbol_end ();
4910
4911 if (strlen (name) > 0)
4912 {
4913 colon (name);
4914 p = input_line_pointer;
4915 *p = c;
4916 }
4917 else
4918 {
4919 as_warn ("Missing label name on .LABEL");
4920 }
4921
4922 if (!is_end_of_statement ())
4923 {
4924 as_warn ("extra .LABEL arguments ignored.");
4925 ignore_rest_of_line ();
4926 }
4927 demand_empty_rest_of_line ();
4928 return;
4929 }
4930
4931 /* Handle a .LEAVE pseudo-op. This is not supported yet. */
4932
4933 static void
4934 pa_leave (unused)
4935 int unused;
4936 {
4937 abort ();
4938 }
4939
4940 /* Handle a .ORIGIN pseudo-op. */
4941
4942 static void
4943 pa_origin (unused)
4944 int unused;
4945 {
4946 s_org (0);
4947 pa_undefine_label ();
4948 return;
4949 }
4950
4951 /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it
4952 is for static functions. FIXME. Should share more code with .EXPORT. */
4953
4954 static void
4955 pa_param (unused)
4956 int unused;
4957 {
4958 char *name, c, *p;
4959 symbolS *symbol;
4960
4961 name = input_line_pointer;
4962 c = get_symbol_end ();
4963
4964 if ((symbol = symbol_find_or_make (name)) == NULL)
4965 {
4966 as_bad ("Cannot define static symbol: %s\n", name);
4967 p = input_line_pointer;
4968 *p = c;
4969 input_line_pointer++;
4970 }
4971 else
4972 {
4973 S_CLEAR_EXTERNAL (symbol);
4974 p = input_line_pointer;
4975 *p = c;
4976 if (!is_end_of_statement ())
4977 {
4978 input_line_pointer++;
4979 pa_type_args (symbol, 0);
4980 }
4981 }
4982
4983 demand_empty_rest_of_line ();
4984 return;
4985 }
4986
4987 /* Handle a .PROC pseudo-op. It is used to mark the beginning
4988 of a procedure from a syntatical point of view. */
4989
4990 static void
4991 pa_proc (unused)
4992 int unused;
4993 {
4994 struct call_info *call_info;
4995
4996 if (within_procedure)
4997 as_fatal ("Nested procedures");
4998
4999 /* Reset global variables for new procedure. */
5000 callinfo_found = FALSE;
5001 within_procedure = TRUE;
5002
5003 /* Create another call_info structure. */
5004 call_info = (struct call_info *) xmalloc (sizeof (struct call_info));
5005
5006 if (!call_info)
5007 as_fatal ("Cannot allocate unwind descriptor\n");
5008
5009 bzero (call_info, sizeof (struct call_info));
5010
5011 call_info->ci_next = NULL;
5012
5013 if (call_info_root == NULL)
5014 {
5015 call_info_root = call_info;
5016 last_call_info = call_info;
5017 }
5018 else
5019 {
5020 last_call_info->ci_next = call_info;
5021 last_call_info = call_info;
5022 }
5023
5024 /* set up defaults on call_info structure */
5025
5026 call_info->ci_unwind.descriptor.cannot_unwind = 0;
5027 call_info->ci_unwind.descriptor.region_desc = 1;
5028 call_info->ci_unwind.descriptor.hpux_interrupt_marker = 0;
5029 call_info->entry_sr = ~0;
5030 call_info->makes_calls = 1;
5031
5032 /* If we got a .PROC pseudo-op, we know that the function is defined
5033 locally. Make sure it gets into the symbol table. */
5034 {
5035 label_symbol_struct *label_symbol = pa_get_label ();
5036
5037 if (label_symbol)
5038 {
5039 if (label_symbol->lss_label)
5040 {
5041 last_call_info->start_symbol = label_symbol->lss_label;
5042 label_symbol->lss_label->bsym->flags |= BSF_FUNCTION;
5043 }
5044 else
5045 as_bad ("Missing function name for .PROC (corrupted label)");
5046 }
5047 else
5048 as_bad ("Missing function name for .PROC");
5049 }
5050
5051 demand_empty_rest_of_line ();
5052 return;
5053 }
5054
5055 /* Process the syntatical end of a procedure. Make sure all the
5056 appropriate pseudo-ops were found within the procedure. */
5057
5058 static void
5059 pa_procend (unused)
5060 int unused;
5061 {
5062
5063 if (!within_procedure)
5064 as_bad ("misplaced .procend");
5065
5066 if (!callinfo_found)
5067 as_bad ("Missing .callinfo for this procedure");
5068
5069 if (within_entry_exit)
5070 as_bad ("Missing .EXIT for a .ENTRY");
5071
5072 #ifdef OBJ_ELF
5073 /* ELF needs to mark the end of each function so that it can compute
5074 the size of the function (apparently its needed in the symbol table. */
5075 hppa_elf_mark_end_of_function ();
5076 #endif
5077
5078 within_procedure = FALSE;
5079 demand_empty_rest_of_line ();
5080 return;
5081 }
5082
5083 /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero,
5084 then create a new space entry to hold the information specified
5085 by the parameters to the .SPACE directive. */
5086
5087 static sd_chain_struct *
5088 pa_parse_space_stmt (space_name, create_flag)
5089 char *space_name;
5090 int create_flag;
5091 {
5092 char *name, *ptemp, c;
5093 char loadable, defined, private, sort;
5094 int spnum;
5095 asection *seg = NULL;
5096 sd_chain_struct *space;
5097
5098 /* load default values */
5099 spnum = 0;
5100 sort = 0;
5101 loadable = TRUE;
5102 defined = TRUE;
5103 private = FALSE;
5104 if (strcasecmp (space_name, "$TEXT$") == 0)
5105 {
5106 seg = pa_def_spaces[0].segment;
5107 sort = pa_def_spaces[0].sort;
5108 }
5109 else if (strcasecmp (space_name, "$PRIVATE$") == 0)
5110 {
5111 seg = pa_def_spaces[1].segment;
5112 sort = pa_def_spaces[1].sort;
5113 }
5114
5115 if (!is_end_of_statement ())
5116 {
5117 print_errors = FALSE;
5118 ptemp = input_line_pointer + 1;
5119 /* First see if the space was specified as a number rather than
5120 as a name. According to the PA assembly manual the rest of
5121 the line should be ignored. */
5122 if ((spnum = pa_parse_number (&ptemp, 0)) >= 0)
5123 input_line_pointer = ptemp;
5124 else
5125 {
5126 while (!is_end_of_statement ())
5127 {
5128 input_line_pointer++;
5129 name = input_line_pointer;
5130 c = get_symbol_end ();
5131 if ((strncasecmp (name, "SPNUM", 5) == 0))
5132 {
5133 *input_line_pointer = c;
5134 input_line_pointer++;
5135 spnum = get_absolute_expression ();
5136 }
5137 else if ((strncasecmp (name, "SORT", 4) == 0))
5138 {
5139 *input_line_pointer = c;
5140 input_line_pointer++;
5141 sort = get_absolute_expression ();
5142 }
5143 else if ((strncasecmp (name, "UNLOADABLE", 10) == 0))
5144 {
5145 *input_line_pointer = c;
5146 loadable = FALSE;
5147 }
5148 else if ((strncasecmp (name, "NOTDEFINED", 10) == 0))
5149 {
5150 *input_line_pointer = c;
5151 defined = FALSE;
5152 }
5153 else if ((strncasecmp (name, "PRIVATE", 7) == 0))
5154 {
5155 *input_line_pointer = c;
5156 private = TRUE;
5157 }
5158 else
5159 {
5160 as_bad ("Invalid .SPACE argument");
5161 *input_line_pointer = c;
5162 if (!is_end_of_statement ())
5163 input_line_pointer++;
5164 }
5165 }
5166 }
5167 print_errors = TRUE;
5168 }
5169
5170 if (create_flag && seg == NULL)
5171 seg = subseg_new (space_name, 0);
5172
5173 /* If create_flag is nonzero, then create the new space with
5174 the attributes computed above. Else set the values in
5175 an already existing space -- this can only happen for
5176 the first occurence of a built-in space. */
5177 if (create_flag)
5178 space = create_new_space (space_name, spnum, loadable, defined,
5179 private, sort, seg, 1);
5180 else
5181 {
5182 space = is_defined_space (space_name);
5183 SPACE_SPNUM (space) = spnum;
5184 SPACE_LOADABLE (space) = loadable & 1;
5185 SPACE_DEFINED (space) = defined & 1;
5186 SPACE_USER_DEFINED (space) = 1;
5187 SPACE_PRIVATE (space) = private & 1;
5188 SPACE_SORT (space) = sort & 0xff;
5189 space->sd_seg = seg;
5190 }
5191
5192 #ifdef obj_set_section_attributes
5193 obj_set_section_attributes (seg, defined, private, sort, spnum);
5194 #endif
5195
5196 return space;
5197 }
5198
5199 /* Handle a .SPACE pseudo-op; this switches the current space to the
5200 given space, creating the new space if necessary. */
5201
5202 static void
5203 pa_space (unused)
5204 int unused;
5205 {
5206 char *name, c, *space_name, *save_s;
5207 int temp;
5208 sd_chain_struct *sd_chain;
5209
5210 if (within_procedure)
5211 {
5212 as_bad ("Can\'t change spaces within a procedure definition. Ignored");
5213 ignore_rest_of_line ();
5214 }
5215 else
5216 {
5217 /* Check for some of the predefined spaces. FIXME: most of the code
5218 below is repeated several times, can we extract the common parts
5219 and place them into a subroutine or something similar? */
5220 if (strncasecmp (input_line_pointer, "$text$", 6) == 0)
5221 {
5222 input_line_pointer += 6;
5223 sd_chain = is_defined_space ("$TEXT$");
5224 if (sd_chain == NULL)
5225 sd_chain = pa_parse_space_stmt ("$TEXT$", 1);
5226 else if (SPACE_USER_DEFINED (sd_chain) == 0)
5227 sd_chain = pa_parse_space_stmt ("$TEXT$", 0);
5228
5229 current_space = sd_chain;
5230 subseg_set (text_section, sd_chain->sd_last_subseg);
5231 current_subspace
5232 = pa_subsegment_to_subspace (text_section,
5233 sd_chain->sd_last_subseg);
5234 demand_empty_rest_of_line ();
5235 return;
5236 }
5237 if (strncasecmp (input_line_pointer, "$private$", 9) == 0)
5238 {
5239 input_line_pointer += 9;
5240 sd_chain = is_defined_space ("$PRIVATE$");
5241 if (sd_chain == NULL)
5242 sd_chain = pa_parse_space_stmt ("$PRIVATE$", 1);
5243 else if (SPACE_USER_DEFINED (sd_chain) == 0)
5244 sd_chain = pa_parse_space_stmt ("$PRIVATE$", 0);
5245
5246 current_space = sd_chain;
5247 subseg_set (data_section, sd_chain->sd_last_subseg);
5248 current_subspace
5249 = pa_subsegment_to_subspace (data_section,
5250 sd_chain->sd_last_subseg);
5251 demand_empty_rest_of_line ();
5252 return;
5253 }
5254 if (!strncasecmp (input_line_pointer,
5255 GDB_DEBUG_SPACE_NAME,
5256 strlen (GDB_DEBUG_SPACE_NAME)))
5257 {
5258 input_line_pointer += strlen (GDB_DEBUG_SPACE_NAME);
5259 sd_chain = is_defined_space (GDB_DEBUG_SPACE_NAME);
5260 if (sd_chain == NULL)
5261 sd_chain = pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME, 1);
5262 else if (SPACE_USER_DEFINED (sd_chain) == 0)
5263 sd_chain = pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME, 0);
5264
5265 current_space = sd_chain;
5266
5267 {
5268 asection *gdb_section
5269 = bfd_make_section_old_way (stdoutput, GDB_DEBUG_SPACE_NAME);
5270
5271 subseg_set (gdb_section, sd_chain->sd_last_subseg);
5272 current_subspace
5273 = pa_subsegment_to_subspace (gdb_section,
5274 sd_chain->sd_last_subseg);
5275 }
5276 demand_empty_rest_of_line ();
5277 return;
5278 }
5279
5280 /* It could be a space specified by number. */
5281 print_errors = 0;
5282 save_s = input_line_pointer;
5283 if ((temp = pa_parse_number (&input_line_pointer, 0)) >= 0)
5284 {
5285 if (sd_chain = pa_find_space_by_number (temp))
5286 {
5287 current_space = sd_chain;
5288
5289 subseg_set (sd_chain->sd_seg, sd_chain->sd_last_subseg);
5290 current_subspace
5291 = pa_subsegment_to_subspace (sd_chain->sd_seg,
5292 sd_chain->sd_last_subseg);
5293 demand_empty_rest_of_line ();
5294 return;
5295 }
5296 }
5297
5298 /* Not a number, attempt to create a new space. */
5299 print_errors = 1;
5300 input_line_pointer = save_s;
5301 name = input_line_pointer;
5302 c = get_symbol_end ();
5303 space_name = xmalloc (strlen (name) + 1);
5304 strcpy (space_name, name);
5305 *input_line_pointer = c;
5306
5307 sd_chain = pa_parse_space_stmt (space_name, 1);
5308 current_space = sd_chain;
5309
5310 subseg_set (sd_chain->sd_seg, sd_chain->sd_last_subseg);
5311 current_subspace = pa_subsegment_to_subspace (sd_chain->sd_seg,
5312 sd_chain->sd_last_subseg);
5313 demand_empty_rest_of_line ();
5314 }
5315 return;
5316 }
5317
5318 /* Switch to a new space. (I think). FIXME. */
5319
5320 static void
5321 pa_spnum (unused)
5322 int unused;
5323 {
5324 char *name;
5325 char c;
5326 char *p;
5327 sd_chain_struct *space;
5328
5329 name = input_line_pointer;
5330 c = get_symbol_end ();
5331 space = is_defined_space (name);
5332 if (space)
5333 {
5334 p = frag_more (4);
5335 md_number_to_chars (p, SPACE_SPNUM (space), 4);
5336 }
5337 else
5338 as_warn ("Undefined space: '%s' Assuming space number = 0.", name);
5339
5340 *input_line_pointer = c;
5341 demand_empty_rest_of_line ();
5342 return;
5343 }
5344
5345 /* If VALUE is an exact power of two between zero and 2^31, then
5346 return log2 (VALUE). Else return -1. */
5347
5348 static int
5349 log2 (value)
5350 int value;
5351 {
5352 int shift = 0;
5353
5354 while ((1 << shift) != value && shift < 32)
5355 shift++;
5356
5357 if (shift >= 32)
5358 return -1;
5359 else
5360 return shift;
5361 }
5362
5363 /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the
5364 given subspace, creating the new subspace if necessary.
5365
5366 FIXME. Should mirror pa_space more closely, in particular how
5367 they're broken up into subroutines. */
5368
5369 static void
5370 pa_subspace (unused)
5371 int unused;
5372 {
5373 char *name, *ss_name, *alias, c;
5374 char loadable, code_only, common, dup_common, zero, sort;
5375 int i, access, space_index, alignment, quadrant, applicable, flags;
5376 sd_chain_struct *space;
5377 ssd_chain_struct *ssd;
5378 asection *section;
5379
5380 if (within_procedure)
5381 {
5382 as_bad ("Can\'t change subspaces within a procedure definition. Ignored");
5383 ignore_rest_of_line ();
5384 }
5385 else
5386 {
5387 name = input_line_pointer;
5388 c = get_symbol_end ();
5389 ss_name = xmalloc (strlen (name) + 1);
5390 strcpy (ss_name, name);
5391 *input_line_pointer = c;
5392
5393 /* Load default values. */
5394 sort = 0;
5395 access = 0x7f;
5396 loadable = 1;
5397 common = 0;
5398 dup_common = 0;
5399 code_only = 0;
5400 zero = 0;
5401 space_index = ~0;
5402 alignment = 0;
5403 quadrant = 0;
5404 alias = NULL;
5405
5406 space = current_space;
5407 ssd = is_defined_subspace (ss_name);
5408 /* Allow user to override the builtin attributes of subspaces. But
5409 only allow the attributes to be changed once! */
5410 if (ssd && SUBSPACE_DEFINED (ssd))
5411 {
5412 subseg_set (ssd->ssd_seg, ssd->ssd_subseg);
5413 if (!is_end_of_statement ())
5414 as_warn ("Parameters of an existing subspace can\'t be modified");
5415 demand_empty_rest_of_line ();
5416 return;
5417 }
5418 else
5419 {
5420 /* A new subspace. Load default values if it matches one of
5421 the builtin subspaces. */
5422 i = 0;
5423 while (pa_def_subspaces[i].name)
5424 {
5425 if (strcasecmp (pa_def_subspaces[i].name, ss_name) == 0)
5426 {
5427 loadable = pa_def_subspaces[i].loadable;
5428 common = pa_def_subspaces[i].common;
5429 dup_common = pa_def_subspaces[i].dup_common;
5430 code_only = pa_def_subspaces[i].code_only;
5431 zero = pa_def_subspaces[i].zero;
5432 space_index = pa_def_subspaces[i].space_index;
5433 alignment = pa_def_subspaces[i].alignment;
5434 quadrant = pa_def_subspaces[i].quadrant;
5435 access = pa_def_subspaces[i].access;
5436 sort = pa_def_subspaces[i].sort;
5437 if (USE_ALIASES && pa_def_subspaces[i].alias)
5438 alias = pa_def_subspaces[i].alias;
5439 break;
5440 }
5441 i++;
5442 }
5443 }
5444
5445 /* We should be working with a new subspace now. Fill in
5446 any information as specified by the user. */
5447 if (!is_end_of_statement ())
5448 {
5449 input_line_pointer++;
5450 while (!is_end_of_statement ())
5451 {
5452 name = input_line_pointer;
5453 c = get_symbol_end ();
5454 if ((strncasecmp (name, "QUAD", 4) == 0))
5455 {
5456 *input_line_pointer = c;
5457 input_line_pointer++;
5458 quadrant = get_absolute_expression ();
5459 }
5460 else if ((strncasecmp (name, "ALIGN", 5) == 0))
5461 {
5462 *input_line_pointer = c;
5463 input_line_pointer++;
5464 alignment = get_absolute_expression ();
5465 if (log2 (alignment) == -1)
5466 {
5467 as_bad ("Alignment must be a power of 2");
5468 alignment = 1;
5469 }
5470 }
5471 else if ((strncasecmp (name, "ACCESS", 6) == 0))
5472 {
5473 *input_line_pointer = c;
5474 input_line_pointer++;
5475 access = get_absolute_expression ();
5476 }
5477 else if ((strncasecmp (name, "SORT", 4) == 0))
5478 {
5479 *input_line_pointer = c;
5480 input_line_pointer++;
5481 sort = get_absolute_expression ();
5482 }
5483 else if ((strncasecmp (name, "CODE_ONLY", 9) == 0))
5484 {
5485 *input_line_pointer = c;
5486 code_only = 1;
5487 }
5488 else if ((strncasecmp (name, "UNLOADABLE", 10) == 0))
5489 {
5490 *input_line_pointer = c;
5491 loadable = 0;
5492 }
5493 else if ((strncasecmp (name, "COMMON", 6) == 0))
5494 {
5495 *input_line_pointer = c;
5496 common = 1;
5497 }
5498 else if ((strncasecmp (name, "DUP_COMM", 8) == 0))
5499 {
5500 *input_line_pointer = c;
5501 dup_common = 1;
5502 }
5503 else if ((strncasecmp (name, "ZERO", 4) == 0))
5504 {
5505 *input_line_pointer = c;
5506 zero = 1;
5507 }
5508 else if ((strncasecmp (name, "FIRST", 5) == 0))
5509 as_bad ("FIRST not supported as a .SUBSPACE argument");
5510 else
5511 as_bad ("Invalid .SUBSPACE argument");
5512 if (!is_end_of_statement ())
5513 input_line_pointer++;
5514 }
5515 }
5516
5517 /* Compute a reasonable set of BFD flags based on the information
5518 in the .subspace directive. */
5519 applicable = bfd_applicable_section_flags (stdoutput);
5520 flags = 0;
5521 if (loadable)
5522 flags |= (SEC_ALLOC | SEC_LOAD);
5523 if (code_only)
5524 flags |= SEC_CODE;
5525 if (common || dup_common)
5526 flags |= SEC_IS_COMMON;
5527
5528 /* This is a zero-filled subspace (eg BSS). */
5529 if (zero)
5530 flags &= ~SEC_LOAD;
5531
5532 flags |= SEC_RELOC | SEC_HAS_CONTENTS;
5533 applicable &= flags;
5534
5535 /* If this is an existing subspace, then we want to use the
5536 segment already associated with the subspace.
5537
5538 FIXME NOW! ELF BFD doesn't appear to be ready to deal with
5539 lots of sections. It might be a problem in the PA ELF
5540 code, I do not know yet. For now avoid creating anything
5541 but the "standard" sections for ELF. */
5542 if (ssd)
5543 section = ssd->ssd_seg;
5544 else if (alias)
5545 section = subseg_new (alias, 0);
5546 else if (!alias && USE_ALIASES)
5547 {
5548 as_warn ("Ignoring subspace decl due to ELF BFD bugs.");
5549 demand_empty_rest_of_line ();
5550 return;
5551 }
5552 else
5553 section = subseg_new (ss_name, 0);
5554
5555 /* Now set the flags. */
5556 bfd_set_section_flags (stdoutput, section, applicable);
5557
5558 /* Record any alignment request for this section. */
5559 record_alignment (section, log2 (alignment));
5560
5561 /* Set the starting offset for this section. */
5562 bfd_set_section_vma (stdoutput, section,
5563 pa_subspace_start (space, quadrant));
5564
5565 /* Now that all the flags are set, update an existing subspace,
5566 or create a new one. */
5567 if (ssd)
5568
5569 current_subspace = update_subspace (space, ss_name, loadable,
5570 code_only, common, dup_common,
5571 sort, zero, access, space_index,
5572 alignment, quadrant,
5573 section);
5574 else
5575 current_subspace = create_new_subspace (space, ss_name, loadable,
5576 code_only, common,
5577 dup_common, zero, sort,
5578 access, space_index,
5579 alignment, quadrant, section);
5580
5581 demand_empty_rest_of_line ();
5582 current_subspace->ssd_seg = section;
5583 subseg_set (current_subspace->ssd_seg, current_subspace->ssd_subseg);
5584 }
5585 SUBSPACE_DEFINED (current_subspace) = 1;
5586 return;
5587 }
5588
5589
5590 /* Create default space and subspace dictionaries. */
5591
5592 static void
5593 pa_spaces_begin ()
5594 {
5595 int i;
5596
5597 space_dict_root = NULL;
5598 space_dict_last = NULL;
5599
5600 i = 0;
5601 while (pa_def_spaces[i].name)
5602 {
5603 char *name;
5604
5605 /* Pick the right name to use for the new section. */
5606 if (pa_def_spaces[i].alias && USE_ALIASES)
5607 name = pa_def_spaces[i].alias;
5608 else
5609 name = pa_def_spaces[i].name;
5610
5611 pa_def_spaces[i].segment = subseg_new (name, 0);
5612 create_new_space (pa_def_spaces[i].name, pa_def_spaces[i].spnum,
5613 pa_def_spaces[i].loadable, pa_def_spaces[i].defined,
5614 pa_def_spaces[i].private, pa_def_spaces[i].sort,
5615 pa_def_spaces[i].segment, 0);
5616 i++;
5617 }
5618
5619 i = 0;
5620 while (pa_def_subspaces[i].name)
5621 {
5622 char *name;
5623 int applicable, subsegment;
5624 asection *segment = NULL;
5625 sd_chain_struct *space;
5626
5627 /* Pick the right name for the new section and pick the right
5628 subsegment number. */
5629 if (pa_def_subspaces[i].alias && USE_ALIASES)
5630 {
5631 name = pa_def_subspaces[i].alias;
5632 subsegment = pa_def_subspaces[i].subsegment;
5633 }
5634 else
5635 {
5636 name = pa_def_subspaces[i].name;
5637 subsegment = 0;
5638 }
5639
5640 /* Create the new section. */
5641 segment = subseg_new (name, subsegment);
5642
5643
5644 /* For SOM we want to replace the standard .text, .data, and .bss
5645 sections with our own. */
5646 if (!strcmp (pa_def_subspaces[i].name, "$CODE$") && !USE_ALIASES)
5647 {
5648 text_section = segment;
5649 applicable = bfd_applicable_section_flags (stdoutput);
5650 bfd_set_section_flags (stdoutput, text_section,
5651 applicable & (SEC_ALLOC | SEC_LOAD
5652 | SEC_RELOC | SEC_CODE
5653 | SEC_READONLY
5654 | SEC_HAS_CONTENTS));
5655 }
5656 else if (!strcmp (pa_def_subspaces[i].name, "$DATA$") && !USE_ALIASES)
5657 {
5658 data_section = segment;
5659 applicable = bfd_applicable_section_flags (stdoutput);
5660 bfd_set_section_flags (stdoutput, data_section,
5661 applicable & (SEC_ALLOC | SEC_LOAD
5662 | SEC_RELOC
5663 | SEC_HAS_CONTENTS));
5664
5665
5666 }
5667 else if (!strcmp (pa_def_subspaces[i].name, "$BSS$") && !USE_ALIASES)
5668 {
5669 bss_section = segment;
5670 applicable = bfd_applicable_section_flags (stdoutput);
5671 bfd_set_section_flags (stdoutput, bss_section,
5672 applicable & SEC_ALLOC);
5673 }
5674
5675 /* Find the space associated with this subspace. */
5676 space = pa_segment_to_space (pa_def_spaces[pa_def_subspaces[i].
5677 def_space_index].segment);
5678 if (space == NULL)
5679 {
5680 as_fatal ("Internal error: Unable to find containing space for %s.",
5681 pa_def_subspaces[i].name);
5682 }
5683
5684 create_new_subspace (space, name,
5685 pa_def_subspaces[i].loadable,
5686 pa_def_subspaces[i].code_only,
5687 pa_def_subspaces[i].common,
5688 pa_def_subspaces[i].dup_common,
5689 pa_def_subspaces[i].zero,
5690 pa_def_subspaces[i].sort,
5691 pa_def_subspaces[i].access,
5692 pa_def_subspaces[i].space_index,
5693 pa_def_subspaces[i].alignment,
5694 pa_def_subspaces[i].quadrant,
5695 segment);
5696 i++;
5697 }
5698 }
5699
5700
5701
5702 /* Create a new space NAME, with the appropriate flags as defined
5703 by the given parameters.
5704
5705 Add the new space to the space dictionary chain in numerical
5706 order as defined by the SORT entries. */
5707
5708 static sd_chain_struct *
5709 create_new_space (name, spnum, loadable, defined, private,
5710 sort, seg, user_defined)
5711 char *name;
5712 int spnum;
5713 char loadable;
5714 char defined;
5715 char private;
5716 char sort;
5717 asection *seg;
5718 int user_defined;
5719 {
5720 sd_chain_struct *chain_entry;
5721
5722 chain_entry = (sd_chain_struct *) xmalloc (sizeof (sd_chain_struct));
5723 if (!chain_entry)
5724 as_fatal ("Out of memory: could not allocate new space chain entry: %s\n",
5725 name);
5726
5727 SPACE_NAME (chain_entry) = (char *) xmalloc (strlen (name) + 1);
5728 strcpy (SPACE_NAME (chain_entry), name);
5729 SPACE_NAME_INDEX (chain_entry) = 0;
5730 SPACE_LOADABLE (chain_entry) = loadable;
5731 SPACE_DEFINED (chain_entry) = defined;
5732 SPACE_USER_DEFINED (chain_entry) = user_defined;
5733 SPACE_PRIVATE (chain_entry) = private;
5734 SPACE_SPNUM (chain_entry) = spnum;
5735 SPACE_SORT (chain_entry) = sort;
5736
5737 chain_entry->sd_seg = seg;
5738 chain_entry->sd_last_subseg = -1;
5739 chain_entry->sd_next = NULL;
5740
5741 /* Find spot for the new space based on its sort key. */
5742 if (!space_dict_last)
5743 space_dict_last = chain_entry;
5744
5745 if (space_dict_root == NULL)
5746 space_dict_root = chain_entry;
5747 else
5748 {
5749 sd_chain_struct *chain_pointer;
5750 sd_chain_struct *prev_chain_pointer;
5751
5752 chain_pointer = space_dict_root;
5753 prev_chain_pointer = NULL;
5754
5755 while (chain_pointer)
5756 {
5757 if (SPACE_SORT (chain_pointer) <= SPACE_SORT (chain_entry))
5758 {
5759 prev_chain_pointer = chain_pointer;
5760 chain_pointer = chain_pointer->sd_next;
5761 }
5762 else
5763 break;
5764 }
5765
5766 /* At this point we've found the correct place to add the new
5767 entry. So add it and update the linked lists as appropriate. */
5768 if (prev_chain_pointer)
5769 {
5770 chain_entry->sd_next = chain_pointer;
5771 prev_chain_pointer->sd_next = chain_entry;
5772 }
5773 else
5774 {
5775 space_dict_root = chain_entry;
5776 chain_entry->sd_next = chain_pointer;
5777 }
5778
5779 if (chain_entry->sd_next == NULL)
5780 space_dict_last = chain_entry;
5781 }
5782
5783 /* This is here to catch predefined spaces which do not get
5784 modified by the user's input. Another call is found at
5785 the bottom of pa_parse_space_stmt to handle cases where
5786 the user modifies a predefined space. */
5787 #ifdef obj_set_section_attributes
5788 obj_set_section_attributes (seg, defined, private, sort, spnum);
5789 #endif
5790
5791 return chain_entry;
5792 }
5793
5794 /* Create a new subspace NAME, with the appropriate flags as defined
5795 by the given parameters.
5796
5797 Add the new subspace to the subspace dictionary chain in numerical
5798 order as defined by the SORT entries. */
5799
5800 static ssd_chain_struct *
5801 create_new_subspace (space, name, loadable, code_only, common,
5802 dup_common, is_zero, sort, access, space_index,
5803 alignment, quadrant, seg)
5804 sd_chain_struct *space;
5805 char *name;
5806 char loadable, code_only, common, dup_common, is_zero;
5807 char sort;
5808 int access;
5809 int space_index;
5810 int alignment;
5811 int quadrant;
5812 asection *seg;
5813 {
5814 ssd_chain_struct *chain_entry;
5815
5816 chain_entry = (ssd_chain_struct *) xmalloc (sizeof (ssd_chain_struct));
5817 if (!chain_entry)
5818 as_fatal ("Out of memory: could not allocate new subspace chain entry: %s\n", name);
5819
5820 SUBSPACE_NAME (chain_entry) = (char *) xmalloc (strlen (name) + 1);
5821 strcpy (SUBSPACE_NAME (chain_entry), name);
5822
5823 SUBSPACE_ACCESS (chain_entry) = access;
5824 SUBSPACE_LOADABLE (chain_entry) = loadable;
5825 SUBSPACE_COMMON (chain_entry) = common;
5826 SUBSPACE_DUP_COMM (chain_entry) = dup_common;
5827 SUBSPACE_SORT (chain_entry) = sort;
5828 SUBSPACE_CODE_ONLY (chain_entry) = code_only;
5829 SUBSPACE_ALIGN (chain_entry) = alignment;
5830 SUBSPACE_QUADRANT (chain_entry) = quadrant;
5831 SUBSPACE_SUBSPACE_START (chain_entry) = pa_subspace_start (space, quadrant);
5832 SUBSPACE_SPACE_INDEX (chain_entry) = space_index;
5833 SUBSPACE_ZERO (chain_entry) = is_zero;
5834
5835 /* Initialize subspace_defined. When we hit a .subspace directive
5836 we'll set it to 1 which "locks-in" the subspace attributes. */
5837 SUBSPACE_DEFINED (chain_entry) = 0;
5838
5839 chain_entry->ssd_subseg = USE_ALIASES ? pa_next_subseg (space) : 0;
5840 chain_entry->ssd_seg = seg;
5841 chain_entry->ssd_last_align = 1;
5842 chain_entry->ssd_next = NULL;
5843
5844 /* Find spot for the new subspace based on its sort key. */
5845 if (space->sd_subspaces == NULL)
5846 space->sd_subspaces = chain_entry;
5847 else
5848 {
5849 ssd_chain_struct *chain_pointer;
5850 ssd_chain_struct *prev_chain_pointer;
5851
5852 chain_pointer = space->sd_subspaces;
5853 prev_chain_pointer = NULL;
5854
5855 while (chain_pointer)
5856 {
5857 if (SUBSPACE_SORT (chain_pointer) <= SUBSPACE_SORT (chain_entry))
5858 {
5859 prev_chain_pointer = chain_pointer;
5860 chain_pointer = chain_pointer->ssd_next;
5861 }
5862 else
5863 break;
5864
5865 }
5866
5867 /* Now we have somewhere to put the new entry. Insert it and update
5868 the links. */
5869 if (prev_chain_pointer)
5870 {
5871 chain_entry->ssd_next = chain_pointer;
5872 prev_chain_pointer->ssd_next = chain_entry;
5873 }
5874 else
5875 {
5876 space->sd_subspaces = chain_entry;
5877 chain_entry->ssd_next = chain_pointer;
5878 }
5879 }
5880
5881 #ifdef obj_set_subsection_attributes
5882 obj_set_subsection_attributes (seg, space->sd_seg, access,
5883 sort, quadrant);
5884 #endif
5885
5886 return chain_entry;
5887
5888 }
5889
5890 /* Update the information for the given subspace based upon the
5891 various arguments. Return the modified subspace chain entry. */
5892
5893 static ssd_chain_struct *
5894 update_subspace (space, name, loadable, code_only, common, dup_common, sort,
5895 zero, access, space_index, alignment, quadrant, section)
5896 sd_chain_struct *space;
5897 char *name;
5898 char loadable;
5899 char code_only;
5900 char common;
5901 char dup_common;
5902 char zero;
5903 char sort;
5904 int access;
5905 int space_index;
5906 int alignment;
5907 int quadrant;
5908 asection *section;
5909 {
5910 ssd_chain_struct *chain_entry;
5911
5912 if ((chain_entry = is_defined_subspace (name)))
5913 {
5914 SUBSPACE_ACCESS (chain_entry) = access;
5915 SUBSPACE_LOADABLE (chain_entry) = loadable;
5916 SUBSPACE_COMMON (chain_entry) = common;
5917 SUBSPACE_DUP_COMM (chain_entry) = dup_common;
5918 SUBSPACE_CODE_ONLY (chain_entry) = 1;
5919 SUBSPACE_SORT (chain_entry) = sort;
5920 SUBSPACE_ALIGN (chain_entry) = alignment;
5921 SUBSPACE_QUADRANT (chain_entry) = quadrant;
5922 SUBSPACE_SPACE_INDEX (chain_entry) = space_index;
5923 SUBSPACE_ZERO (chain_entry) = zero;
5924 }
5925 else
5926 chain_entry = NULL;
5927
5928 #ifdef obj_set_subsection_attributes
5929 obj_set_subsection_attributes (section, space->sd_seg, access,
5930 sort, quadrant);
5931 #endif
5932
5933 return chain_entry;
5934
5935 }
5936
5937 /* Return the space chain entry for the space with the name NAME or
5938 NULL if no such space exists. */
5939
5940 static sd_chain_struct *
5941 is_defined_space (name)
5942 char *name;
5943 {
5944 sd_chain_struct *chain_pointer;
5945
5946 for (chain_pointer = space_dict_root;
5947 chain_pointer;
5948 chain_pointer = chain_pointer->sd_next)
5949 {
5950 if (strcmp (SPACE_NAME (chain_pointer), name) == 0)
5951 return chain_pointer;
5952 }
5953
5954 /* No mapping from segment to space was found. Return NULL. */
5955 return NULL;
5956 }
5957
5958 /* Find and return the space associated with the given seg. If no mapping
5959 from the given seg to a space is found, then return NULL.
5960
5961 Unlike subspaces, the number of spaces is not expected to grow much,
5962 so a linear exhaustive search is OK here. */
5963
5964 static sd_chain_struct *
5965 pa_segment_to_space (seg)
5966 asection *seg;
5967 {
5968 sd_chain_struct *space_chain;
5969
5970 /* Walk through each space looking for the correct mapping. */
5971 for (space_chain = space_dict_root;
5972 space_chain;
5973 space_chain = space_chain->sd_next)
5974 {
5975 if (space_chain->sd_seg == seg)
5976 return space_chain;
5977 }
5978
5979 /* Mapping was not found. Return NULL. */
5980 return NULL;
5981 }
5982
5983 /* Return the space chain entry for the subspace with the name NAME or
5984 NULL if no such subspace exists.
5985
5986 Uses a linear search through all the spaces and subspaces, this may
5987 not be appropriate if we ever being placing each function in its
5988 own subspace. */
5989
5990 static ssd_chain_struct *
5991 is_defined_subspace (name)
5992 char *name;
5993 {
5994 sd_chain_struct *space_chain;
5995 ssd_chain_struct *subspace_chain;
5996
5997 /* Walk through each space. */
5998 for (space_chain = space_dict_root;
5999 space_chain;
6000 space_chain = space_chain->sd_next)
6001 {
6002 /* Walk through each subspace looking for a name which matches. */
6003 for (subspace_chain = space_chain->sd_subspaces;
6004 subspace_chain;
6005 subspace_chain = subspace_chain->ssd_next)
6006 if (strcmp (SUBSPACE_NAME (subspace_chain), name) == 0)
6007 return subspace_chain;
6008 }
6009
6010 /* Subspace wasn't found. Return NULL. */
6011 return NULL;
6012 }
6013
6014 /* Find and return the subspace associated with the given seg. If no
6015 mapping from the given seg to a subspace is found, then return NULL.
6016
6017 If we ever put each procedure/function within its own subspace
6018 (to make life easier on the compiler and linker), then this will have
6019 to become more efficient. */
6020
6021 static ssd_chain_struct *
6022 pa_subsegment_to_subspace (seg, subseg)
6023 asection *seg;
6024 subsegT subseg;
6025 {
6026 sd_chain_struct *space_chain;
6027 ssd_chain_struct *subspace_chain;
6028
6029 /* Walk through each space. */
6030 for (space_chain = space_dict_root;
6031 space_chain;
6032 space_chain = space_chain->sd_next)
6033 {
6034 if (space_chain->sd_seg == seg)
6035 {
6036 /* Walk through each subspace within each space looking for
6037 the correct mapping. */
6038 for (subspace_chain = space_chain->sd_subspaces;
6039 subspace_chain;
6040 subspace_chain = subspace_chain->ssd_next)
6041 if (subspace_chain->ssd_subseg == (int) subseg)
6042 return subspace_chain;
6043 }
6044 }
6045
6046 /* No mapping from subsegment to subspace found. Return NULL. */
6047 return NULL;
6048 }
6049
6050 /* Given a number, try and find a space with the name number.
6051
6052 Return a pointer to a space dictionary chain entry for the space
6053 that was found or NULL on failure. */
6054
6055 static sd_chain_struct *
6056 pa_find_space_by_number (number)
6057 int number;
6058 {
6059 sd_chain_struct *space_chain;
6060
6061 for (space_chain = space_dict_root;
6062 space_chain;
6063 space_chain = space_chain->sd_next)
6064 {
6065 if (SPACE_SPNUM (space_chain) == number)
6066 return space_chain;
6067 }
6068
6069 /* No appropriate space found. Return NULL. */
6070 return NULL;
6071 }
6072
6073 /* Return the starting address for the given subspace. If the starting
6074 address is unknown then return zero. */
6075
6076 static unsigned int
6077 pa_subspace_start (space, quadrant)
6078 sd_chain_struct *space;
6079 int quadrant;
6080 {
6081 /* FIXME. Assumes everyone puts read/write data at 0x4000000, this
6082 is not correct for the PA OSF1 port. */
6083 if ((strcasecmp (SPACE_NAME (space), "$PRIVATE$") == 0) && quadrant == 1)
6084 return 0x40000000;
6085 else if (space->sd_seg == data_section && quadrant == 1)
6086 return 0x40000000;
6087 else
6088 return 0;
6089 }
6090
6091 /* FIXME. Needs documentation. */
6092 static int
6093 pa_next_subseg (space)
6094 sd_chain_struct *space;
6095 {
6096
6097 space->sd_last_subseg++;
6098 return space->sd_last_subseg;
6099 }
6100
6101 /* Helper function for pa_stringer. Used to find the end of
6102 a string. */
6103
6104 static unsigned int
6105 pa_stringer_aux (s)
6106 char *s;
6107 {
6108 unsigned int c = *s & CHAR_MASK;
6109 switch (c)
6110 {
6111 case '\"':
6112 c = NOT_A_CHAR;
6113 break;
6114 default:
6115 break;
6116 }
6117 return c;
6118 }
6119
6120 /* Handle a .STRING type pseudo-op. */
6121
6122 static void
6123 pa_stringer (append_zero)
6124 int append_zero;
6125 {
6126 char *s, num_buf[4];
6127 unsigned int c;
6128 int i;
6129
6130 /* Preprocess the string to handle PA-specific escape sequences.
6131 For example, \xDD where DD is a hexidecimal number should be
6132 changed to \OOO where OOO is an octal number. */
6133
6134 /* Skip the opening quote. */
6135 s = input_line_pointer + 1;
6136
6137 while (is_a_char (c = pa_stringer_aux (s++)))
6138 {
6139 if (c == '\\')
6140 {
6141 c = *s;
6142 switch (c)
6143 {
6144 /* Handle \x<num>. */
6145 case 'x':
6146 {
6147 unsigned int number;
6148 int num_digit;
6149 char dg;
6150 char *s_start = s;
6151
6152 /* Get pas the 'x'. */
6153 s++;
6154 for (num_digit = 0, number = 0, dg = *s;
6155 num_digit < 2
6156 && (isdigit (dg) || (dg >= 'a' && dg <= 'f')
6157 || (dg >= 'A' && dg <= 'F'));
6158 num_digit++)
6159 {
6160 if (isdigit (dg))
6161 number = number * 16 + dg - '0';
6162 else if (dg >= 'a' && dg <= 'f')
6163 number = number * 16 + dg - 'a' + 10;
6164 else
6165 number = number * 16 + dg - 'A' + 10;
6166
6167 s++;
6168 dg = *s;
6169 }
6170 if (num_digit > 0)
6171 {
6172 switch (num_digit)
6173 {
6174 case 1:
6175 sprintf (num_buf, "%02o", number);
6176 break;
6177 case 2:
6178 sprintf (num_buf, "%03o", number);
6179 break;
6180 }
6181 for (i = 0; i <= num_digit; i++)
6182 s_start[i] = num_buf[i];
6183 }
6184 break;
6185 }
6186 /* This might be a "\"", skip over the escaped char. */
6187 default:
6188 s++;
6189 break;
6190 }
6191 }
6192 }
6193 stringer (append_zero);
6194 pa_undefine_label ();
6195 }
6196
6197 /* Handle a .VERSION pseudo-op. */
6198
6199 static void
6200 pa_version (unused)
6201 int unused;
6202 {
6203 obj_version (0);
6204 pa_undefine_label ();
6205 }
6206
6207 /* Just like a normal cons, but when finished we have to undefine
6208 the latest space label. */
6209
6210 static void
6211 pa_cons (nbytes)
6212 int nbytes;
6213 {
6214 cons (nbytes);
6215 pa_undefine_label ();
6216 }
6217
6218 /* Switch to the data space. As usual delete our label. */
6219
6220 static void
6221 pa_data (unused)
6222 int unused;
6223 {
6224 s_data (0);
6225 pa_undefine_label ();
6226 }
6227
6228 /* FIXME. What's the purpose of this pseudo-op? */
6229
6230 static void
6231 pa_desc (unused)
6232 int unused;
6233 {
6234 pa_undefine_label ();
6235 }
6236
6237 /* Like float_cons, but we need to undefine our label. */
6238
6239 static void
6240 pa_float_cons (float_type)
6241 int float_type;
6242 {
6243 float_cons (float_type);
6244 pa_undefine_label ();
6245 }
6246
6247 /* Like s_fill, but delete our label when finished. */
6248
6249 static void
6250 pa_fill (unused)
6251 int unused;
6252 {
6253 s_fill (0);
6254 pa_undefine_label ();
6255 }
6256
6257 /* Like lcomm, but delete our label when finished. */
6258
6259 static void
6260 pa_lcomm (needs_align)
6261 int needs_align;
6262 {
6263 s_lcomm (needs_align);
6264 pa_undefine_label ();
6265 }
6266
6267 /* Like lsym, but delete our label when finished. */
6268
6269 static void
6270 pa_lsym (unused)
6271 int unused;
6272 {
6273 s_lsym (0);
6274 pa_undefine_label ();
6275 }
6276
6277 /* Switch to the text space. Like s_text, but delete our
6278 label when finished. */
6279 static void
6280 pa_text (unused)
6281 int unused;
6282 {
6283 s_text (0);
6284 pa_undefine_label ();
6285 }
6286
6287 /* On the PA relocations which involve function symbols must not be
6288 adjusted. This so that the linker can know when/how to create argument
6289 relocation stubs for indirect calls and calls to static functions.
6290
6291 FIXME. Also reject R_HPPA relocations which are 32 bits
6292 wide. Helps with code lables in arrays for SOM. (SOM BFD code
6293 needs to generate relocations to push the addend and symbol value
6294 onto the stack, add them, then pop the value off the stack and
6295 use it in a relocation -- yuk. */
6296
6297 int
6298 hppa_fix_adjustable (fixp)
6299 fixS *fixp;
6300 {
6301 struct hppa_fix_struct *hppa_fix;
6302
6303 hppa_fix = fixp->tc_fix_data;
6304
6305 if (fixp->fx_r_type == R_HPPA && hppa_fix->fx_r_format == 32)
6306 return 0;
6307
6308 if (fixp->fx_addsy == 0
6309 || (fixp->fx_addsy->bsym->flags & BSF_FUNCTION) == 0)
6310 return 1;
6311
6312 return 0;
6313 }
6314
6315 /* Return nonzero if the fixup in FIXP will require a relocation,
6316 even it if appears that the fixup could be completely handled
6317 within GAS. */
6318
6319 int
6320 hppa_force_relocation (fixp)
6321 fixS *fixp;
6322 {
6323 struct hppa_fix_struct *hppa_fixp = fixp->tc_fix_data;
6324
6325 #ifdef OBJ_SOM
6326 if (fixp->fx_r_type == R_HPPA_ENTRY || fixp->fx_r_type == R_HPPA_EXIT)
6327 return 1;
6328 #endif
6329
6330 #define stub_needed(CALLER, CALLEE) \
6331 ((CALLEE) && (CALLER) && ((CALLEE) != (CALLER)))
6332
6333 /* It is necessary to force PC-relative calls/jumps to have a relocation
6334 entry if they're going to need either a argument relocation or long
6335 call stub. FIXME. Can't we need the same for absolute calls? */
6336 if (fixp->fx_pcrel
6337 && (stub_needed (((obj_symbol_type *)
6338 fixp->fx_addsy->bsym)->tc_data.hppa_arg_reloc,
6339 hppa_fixp->fx_arg_reloc)))
6340 return 1;
6341
6342 #undef stub_needed
6343
6344 /* No need (yet) to force another relocations to be emitted. */
6345 return 0;
6346 }
6347
6348 /* Now for some ELF specific code. FIXME. */
6349 #ifdef OBJ_ELF
6350 static symext_chainS *symext_rootP;
6351 static symext_chainS *symext_lastP;
6352
6353 /* Mark the end of a function so that it's possible to compute
6354 the size of the function in hppa_elf_final_processing. */
6355
6356 static void
6357 hppa_elf_mark_end_of_function ()
6358 {
6359 /* ELF does not have EXIT relocations. All we do is create a
6360 temporary symbol marking the end of the function. */
6361 char *name = (char *)
6362 xmalloc (strlen ("L$\001end_") +
6363 strlen (S_GET_NAME (last_call_info->start_symbol)) + 1);
6364
6365 if (name)
6366 {
6367 symbolS *symbolP;
6368
6369 strcpy (name, "L$\001end_");
6370 strcat (name, S_GET_NAME (last_call_info->start_symbol));
6371
6372 /* If we have a .exit followed by a .procend, then the
6373 symbol will have already been defined. */
6374 symbolP = symbol_find (name);
6375 if (symbolP)
6376 {
6377 /* The symbol has already been defined! This can
6378 happen if we have a .exit followed by a .procend.
6379
6380 This is *not* an error. All we want to do is free
6381 the memory we just allocated for the name and continue. */
6382 xfree (name);
6383 }
6384 else
6385 {
6386 /* symbol value should be the offset of the
6387 last instruction of the function */
6388 symbolP = symbol_new (name, now_seg,
6389 (valueT) (obstack_next_free (&frags)
6390 - frag_now->fr_literal - 4),
6391 frag_now);
6392
6393 assert (symbolP);
6394 symbolP->bsym->flags = BSF_LOCAL;
6395 symbol_table_insert (symbolP);
6396 }
6397
6398 if (symbolP)
6399 last_call_info->end_symbol = symbolP;
6400 else
6401 as_bad ("Symbol '%s' could not be created.", name);
6402
6403 }
6404 else
6405 as_bad ("No memory for symbol name.");
6406
6407 /* Stuff away the location of the frag for the end of the function,
6408 and call pa_build_unwind_subspace to add an entry in the unwind
6409 table. */
6410 last_call_info->end_frag = frag_now;
6411 }
6412
6413 /* Do any symbol processing requested by the target-cpu or target-format. */
6414
6415 void
6416 hppa_tc_symbol (abfd, symbolP, sym_idx)
6417 bfd *abfd;
6418 elf_symbol_type *symbolP;
6419 int sym_idx;
6420 {
6421 symext_chainS *symextP;
6422 unsigned int arg_reloc;
6423
6424 /* Only functions can have argument relocations. */
6425 if (!(symbolP->symbol.flags & BSF_FUNCTION))
6426 return;
6427
6428 arg_reloc = symbolP->tc_data.hppa_arg_reloc;
6429
6430 /* If there are no argument relocation bits, then no relocation is
6431 necessary. Do not add this to the symextn section. */
6432 if (arg_reloc == 0)
6433 return;
6434
6435 symextP = (symext_chainS *) bfd_alloc (abfd, sizeof (symext_chainS) * 2);
6436
6437 symextP[0].entry = ELF32_HPPA_SX_WORD (HPPA_SXT_SYMNDX, sym_idx);
6438 symextP[0].next = &symextP[1];
6439
6440 symextP[1].entry = ELF32_HPPA_SX_WORD (HPPA_SXT_ARG_RELOC, arg_reloc);
6441 symextP[1].next = NULL;
6442
6443 if (symext_rootP == NULL)
6444 {
6445 symext_rootP = &symextP[0];
6446 symext_lastP = &symextP[1];
6447 }
6448 else
6449 {
6450 symext_lastP->next = &symextP[0];
6451 symext_lastP = &symextP[1];
6452 }
6453 }
6454
6455 /* Make sections needed by the target cpu and/or target format. */
6456 void
6457 hppa_tc_make_sections (abfd)
6458 bfd *abfd;
6459 {
6460 symext_chainS *symextP;
6461 int size, n;
6462 asection *symextn_sec;
6463 segT save_seg = now_seg;
6464 subsegT save_subseg = now_subseg;
6465
6466 /* Build the symbol extension section. */
6467 hppa_tc_make_symextn_section ();
6468
6469 /* Force some calculation to occur. */
6470 bfd_set_section_contents (stdoutput, stdoutput->sections, "", 0, 0);
6471
6472 hppa_elf_stub_finish (abfd);
6473
6474 /* If no symbols for the symbol extension section, then stop now. */
6475 if (symext_rootP == NULL)
6476 return;
6477
6478 /* Count the number of symbols for the symbol extension section. */
6479 for (n = 0, symextP = symext_rootP; symextP; symextP = symextP->next, ++n)
6480 ;
6481
6482 size = sizeof (symext_entryS) * n;
6483
6484 /* Switch to the symbol extension section. */
6485 symextn_sec = subseg_new (SYMEXTN_SECTION_NAME, 0);
6486
6487 frag_wane (frag_now);
6488 frag_new (0);
6489
6490 for (symextP = symext_rootP; symextP; symextP = symextP->next)
6491 {
6492 char *ptr;
6493 int *symtab_map = elf_sym_extra (abfd);
6494 int idx;
6495
6496 /* First, patch the symbol extension record to reflect the true
6497 symbol table index. */
6498
6499 if (ELF32_HPPA_SX_TYPE (symextP->entry) == HPPA_SXT_SYMNDX)
6500 {
6501 idx = ELF32_HPPA_SX_VAL (symextP->entry) - 1;
6502 symextP->entry = ELF32_HPPA_SX_WORD (HPPA_SXT_SYMNDX,
6503 symtab_map[idx]);
6504 }
6505
6506 ptr = frag_more (sizeof (symextP->entry));
6507 md_number_to_chars (ptr, symextP->entry, sizeof (symextP->entry));
6508 }
6509
6510 frag_now->fr_fix = obstack_next_free (&frags) - frag_now->fr_literal;
6511 frag_wane (frag_now);
6512
6513 /* Switch back to the original segment. */
6514 subseg_set (save_seg, save_subseg);
6515
6516 return;
6517 }
6518
6519 /* Make the symbol extension section. */
6520
6521 static void
6522 hppa_tc_make_symextn_section ()
6523 {
6524 if (symext_rootP)
6525 {
6526 symext_chainS *symextP;
6527 int n;
6528 unsigned int size;
6529 segT symextn_sec;
6530 segT save_seg = now_seg;
6531 subsegT save_subseg = now_subseg;
6532
6533 for (n = 0, symextP = symext_rootP; symextP; symextP = symextP->next, ++n)
6534 ;
6535
6536 size = sizeof (symext_entryS) * n;
6537
6538 symextn_sec = subseg_new (SYMEXTN_SECTION_NAME, 0);
6539
6540 bfd_set_section_flags (stdoutput, symextn_sec,
6541 SEC_LOAD | SEC_HAS_CONTENTS | SEC_DATA);
6542 bfd_set_section_size (stdoutput, symextn_sec, size);
6543
6544 /* Now, switch back to the original segment. */
6545 subseg_set (save_seg, save_subseg);
6546 }
6547 }
6548
6549 /* Build the symbol extension section. */
6550
6551 static void
6552 pa_build_symextn_section ()
6553 {
6554 segT seg;
6555 asection *save_seg = now_seg;
6556 subsegT subseg = (subsegT) 0;
6557 subsegT save_subseg = now_subseg;
6558
6559 seg = subseg_new (".hppa_symextn", subseg);
6560 bfd_set_section_flags (stdoutput,
6561 seg,
6562 SEC_HAS_CONTENTS | SEC_READONLY
6563 | SEC_ALLOC | SEC_LOAD);
6564
6565 subseg_set (save_seg, save_subseg);
6566
6567 }
6568
6569 /* For ELF, this function serves one purpose: to setup the st_size
6570 field of STT_FUNC symbols. To do this, we need to scan the
6571 call_info structure list, determining st_size in one of two possible
6572 ways:
6573
6574 1. call_info->start_frag->fr_fix has the size of the fragment.
6575 This approach assumes that the function was built into a
6576 single fragment. This works for most cases, but might fail.
6577 For example, if there was a segment change in the middle of
6578 the function.
6579
6580 2. The st_size field is the difference in the addresses of the
6581 call_info->start_frag->fr_address field and the fr_address
6582 field of the next fragment with fr_type == rs_fill and
6583 fr_fix != 0. */
6584
6585 void
6586 elf_hppa_final_processing ()
6587 {
6588 struct call_info *call_info_pointer;
6589
6590 for (call_info_pointer = call_info_root;
6591 call_info_pointer;
6592 call_info_pointer = call_info_pointer->ci_next)
6593 {
6594 elf_symbol_type *esym
6595 = (elf_symbol_type *) call_info_pointer->start_symbol->bsym;
6596 esym->internal_elf_sym.st_size =
6597 S_GET_VALUE (call_info_pointer->end_symbol)
6598 - S_GET_VALUE (call_info_pointer->start_symbol) + 4;
6599 }
6600 }
6601 #endif
This page took 0.174903 seconds and 5 git commands to generate.