Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* tc-hppa.c -- Assemble for the PA |
c7d004c5 | 2 | Copyright 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
ae6063d4 | 3 | 2002, 2003 Free Software Foundation, Inc. |
252b5132 RH |
4 | |
5 | This file is part of GAS, the GNU Assembler. | |
6 | ||
7 | GAS is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GAS is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GAS; see the file COPYING. If not, write to the Free | |
19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
20 | 02111-1307, USA. */ | |
21 | ||
252b5132 RH |
22 | /* HP PA-RISC support was contributed by the Center for Software Science |
23 | at the University of Utah. */ | |
24 | ||
25 | #include <stdio.h> | |
252b5132 RH |
26 | |
27 | #include "as.h" | |
3882b010 | 28 | #include "safe-ctype.h" |
252b5132 RH |
29 | #include "subsegs.h" |
30 | ||
31 | #include "bfd/libhppa.h" | |
252b5132 RH |
32 | |
33 | /* Be careful, this file includes data *declarations*. */ | |
34 | #include "opcode/hppa.h" | |
35 | ||
49863f82 JL |
36 | #if defined (OBJ_ELF) && defined (OBJ_SOM) |
37 | error only one of OBJ_ELF and OBJ_SOM can be defined | |
38 | #endif | |
39 | ||
2d93dcc4 JL |
40 | /* If we are using ELF, then we probably can support dwarf2 debug |
41 | records. Furthermore, if we are supporting dwarf2 debug records, | |
42 | then we want to use the assembler support for compact line numbers. */ | |
43 | #ifdef OBJ_ELF | |
44 | #include "dwarf2dbg.h" | |
2d93dcc4 | 45 | |
252b5132 RH |
46 | /* A "convient" place to put object file dependencies which do |
47 | not need to be seen outside of tc-hppa.c. */ | |
ad1079af | 48 | |
252b5132 | 49 | /* Object file formats specify relocation types. */ |
ad1079af | 50 | typedef enum elf_hppa_reloc_type reloc_type; |
252b5132 RH |
51 | |
52 | /* Object file formats specify BFD symbol types. */ | |
53 | typedef elf_symbol_type obj_symbol_type; | |
ad1079af AM |
54 | #define symbol_arg_reloc_info(sym)\ |
55 | (((obj_symbol_type *) symbol_get_bfdsym (sym))->tc_data.hppa_arg_reloc) | |
252b5132 | 56 | |
ad1079af | 57 | #if TARGET_ARCH_SIZE == 64 |
252b5132 | 58 | /* How to generate a relocation. */ |
b388df87 | 59 | #define hppa_gen_reloc_type _bfd_elf64_hppa_gen_reloc_type |
3dcfe21d | 60 | #define elf_hppa_reloc_final_type elf64_hppa_reloc_final_type |
b388df87 JL |
61 | #else |
62 | #define hppa_gen_reloc_type _bfd_elf32_hppa_gen_reloc_type | |
3dcfe21d | 63 | #define elf_hppa_reloc_final_type elf32_hppa_reloc_final_type |
b388df87 | 64 | #endif |
252b5132 RH |
65 | |
66 | /* ELF objects can have versions, but apparently do not have anywhere | |
67 | to store a copyright string. */ | |
68 | #define obj_version obj_elf_version | |
69 | #define obj_copyright obj_elf_version | |
46031ca9 JL |
70 | |
71 | #define UNWIND_SECTION_NAME ".PARISC.unwind" | |
ad1079af | 72 | #endif /* OBJ_ELF */ |
252b5132 RH |
73 | |
74 | #ifdef OBJ_SOM | |
75 | /* Names of various debugging spaces/subspaces. */ | |
76 | #define GDB_DEBUG_SPACE_NAME "$GDB_DEBUG$" | |
77 | #define GDB_STRINGS_SUBSPACE_NAME "$GDB_STRINGS$" | |
78 | #define GDB_SYMBOLS_SUBSPACE_NAME "$GDB_SYMBOLS$" | |
79 | #define UNWIND_SECTION_NAME "$UNWIND$" | |
80 | ||
81 | /* Object file formats specify relocation types. */ | |
82 | typedef int reloc_type; | |
83 | ||
84 | /* SOM objects can have both a version string and a copyright string. */ | |
85 | #define obj_version obj_som_version | |
86 | #define obj_copyright obj_som_copyright | |
87 | ||
252b5132 RH |
88 | /* How to generate a relocation. */ |
89 | #define hppa_gen_reloc_type hppa_som_gen_reloc_type | |
90 | ||
91 | /* Object file formats specify BFD symbol types. */ | |
92 | typedef som_symbol_type obj_symbol_type; | |
ad1079af AM |
93 | #define symbol_arg_reloc_info(sym)\ |
94 | (((obj_symbol_type *) symbol_get_bfdsym (sym))->tc_data.ap.hppa_arg_reloc) | |
252b5132 RH |
95 | |
96 | /* This apparently isn't in older versions of hpux reloc.h. */ | |
97 | #ifndef R_DLT_REL | |
98 | #define R_DLT_REL 0x78 | |
99 | #endif | |
252b5132 RH |
100 | |
101 | #ifndef R_N0SEL | |
102 | #define R_N0SEL 0xd8 | |
103 | #endif | |
104 | ||
105 | #ifndef R_N1SEL | |
106 | #define R_N1SEL 0xd9 | |
107 | #endif | |
ad1079af | 108 | #endif /* OBJ_SOM */ |
252b5132 | 109 | |
8a238888 AM |
110 | #if TARGET_ARCH_SIZE == 64 |
111 | #define DEFAULT_LEVEL 25 | |
112 | #else | |
113 | #define DEFAULT_LEVEL 10 | |
114 | #endif | |
115 | ||
252b5132 RH |
116 | /* Various structures and types used internally in tc-hppa.c. */ |
117 | ||
118 | /* Unwind table and descriptor. FIXME: Sync this with GDB version. */ | |
119 | ||
120 | struct unwind_desc | |
121 | { | |
122 | unsigned int cannot_unwind:1; | |
123 | unsigned int millicode:1; | |
124 | unsigned int millicode_save_rest:1; | |
125 | unsigned int region_desc:2; | |
126 | unsigned int save_sr:2; | |
127 | unsigned int entry_fr:4; | |
128 | unsigned int entry_gr:5; | |
129 | unsigned int args_stored:1; | |
130 | unsigned int call_fr:5; | |
131 | unsigned int call_gr:5; | |
132 | unsigned int save_sp:1; | |
133 | unsigned int save_rp:1; | |
134 | unsigned int save_rp_in_frame:1; | |
135 | unsigned int extn_ptr_defined:1; | |
136 | unsigned int cleanup_defined:1; | |
137 | ||
138 | unsigned int hpe_interrupt_marker:1; | |
139 | unsigned int hpux_interrupt_marker:1; | |
140 | unsigned int reserved:3; | |
141 | unsigned int frame_size:27; | |
142 | }; | |
143 | ||
da6c73e0 AM |
144 | /* We can't rely on compilers placing bitfields in any particular |
145 | place, so use these macros when dumping unwind descriptors to | |
146 | object files. */ | |
147 | #define UNWIND_LOW32(U) \ | |
148 | (((U)->cannot_unwind << 31) \ | |
149 | | ((U)->millicode << 30) \ | |
150 | | ((U)->millicode_save_rest << 29) \ | |
151 | | ((U)->region_desc << 27) \ | |
152 | | ((U)->save_sr << 25) \ | |
153 | | ((U)->entry_fr << 21) \ | |
154 | | ((U)->entry_gr << 16) \ | |
155 | | ((U)->args_stored << 15) \ | |
156 | | ((U)->call_fr << 10) \ | |
157 | | ((U)->call_gr << 5) \ | |
158 | | ((U)->save_sp << 4) \ | |
159 | | ((U)->save_rp << 3) \ | |
160 | | ((U)->save_rp_in_frame << 2) \ | |
161 | | ((U)->extn_ptr_defined << 1) \ | |
162 | | ((U)->cleanup_defined << 0)) | |
163 | ||
164 | #define UNWIND_HIGH32(U) \ | |
165 | (((U)->hpe_interrupt_marker << 31) \ | |
166 | | ((U)->hpux_interrupt_marker << 30) \ | |
167 | | ((U)->frame_size << 0)) | |
168 | ||
252b5132 RH |
169 | struct unwind_table |
170 | { | |
171 | /* Starting and ending offsets of the region described by | |
172 | descriptor. */ | |
173 | unsigned int start_offset; | |
174 | unsigned int end_offset; | |
175 | struct unwind_desc descriptor; | |
176 | }; | |
177 | ||
178 | /* This structure is used by the .callinfo, .enter, .leave pseudo-ops to | |
179 | control the entry and exit code they generate. It is also used in | |
180 | creation of the correct stack unwind descriptors. | |
181 | ||
182 | NOTE: GAS does not support .enter and .leave for the generation of | |
183 | prologues and epilogues. FIXME. | |
184 | ||
185 | The fields in structure roughly correspond to the arguments available on the | |
186 | .callinfo pseudo-op. */ | |
187 | ||
188 | struct call_info | |
189 | { | |
190 | /* The unwind descriptor being built. */ | |
191 | struct unwind_table ci_unwind; | |
192 | ||
193 | /* Name of this function. */ | |
194 | symbolS *start_symbol; | |
195 | ||
196 | /* (temporary) symbol used to mark the end of this function. */ | |
197 | symbolS *end_symbol; | |
198 | ||
199 | /* Next entry in the chain. */ | |
200 | struct call_info *ci_next; | |
201 | }; | |
202 | ||
203 | /* Operand formats for FP instructions. Note not all FP instructions | |
204 | allow all four formats to be used (for example fmpysub only allows | |
205 | SGL and DBL). */ | |
206 | typedef enum | |
207 | { | |
208 | SGL, DBL, ILLEGAL_FMT, QUAD, W, UW, DW, UDW, QW, UQW | |
209 | } | |
210 | fp_operand_format; | |
211 | ||
212 | /* This fully describes the symbol types which may be attached to | |
213 | an EXPORT or IMPORT directive. Only SOM uses this formation | |
214 | (ELF has no need for it). */ | |
215 | typedef enum | |
216 | { | |
217 | SYMBOL_TYPE_UNKNOWN, | |
218 | SYMBOL_TYPE_ABSOLUTE, | |
219 | SYMBOL_TYPE_CODE, | |
220 | SYMBOL_TYPE_DATA, | |
221 | SYMBOL_TYPE_ENTRY, | |
222 | SYMBOL_TYPE_MILLICODE, | |
223 | SYMBOL_TYPE_PLABEL, | |
224 | SYMBOL_TYPE_PRI_PROG, | |
225 | SYMBOL_TYPE_SEC_PROG, | |
226 | } | |
227 | pa_symbol_type; | |
228 | ||
229 | /* This structure contains information needed to assemble | |
230 | individual instructions. */ | |
231 | struct pa_it | |
232 | { | |
233 | /* Holds the opcode after parsing by pa_ip. */ | |
234 | unsigned long opcode; | |
235 | ||
236 | /* Holds an expression associated with the current instruction. */ | |
237 | expressionS exp; | |
238 | ||
239 | /* Does this instruction use PC-relative addressing. */ | |
240 | int pcrel; | |
241 | ||
242 | /* Floating point formats for operand1 and operand2. */ | |
243 | fp_operand_format fpof1; | |
244 | fp_operand_format fpof2; | |
245 | ||
1cf6ae67 JL |
246 | /* Whether or not we saw a truncation request on an fcnv insn. */ |
247 | int trunc; | |
252b5132 RH |
248 | |
249 | /* Holds the field selector for this instruction | |
250 | (for example L%, LR%, etc). */ | |
251 | long field_selector; | |
252 | ||
253 | /* Holds any argument relocation bits associated with this | |
254 | instruction. (instruction should be some sort of call). */ | |
ad1079af | 255 | unsigned int arg_reloc; |
252b5132 RH |
256 | |
257 | /* The format specification for this instruction. */ | |
258 | int format; | |
259 | ||
260 | /* The relocation (if any) associated with this instruction. */ | |
261 | reloc_type reloc; | |
262 | }; | |
263 | ||
264 | /* PA-89 floating point registers are arranged like this: | |
265 | ||
252b5132 RH |
266 | +--------------+--------------+ |
267 | | 0 or 16L | 16 or 16R | | |
268 | +--------------+--------------+ | |
269 | | 1 or 17L | 17 or 17R | | |
270 | +--------------+--------------+ | |
271 | | | | | |
272 | ||
273 | . . . | |
274 | . . . | |
275 | . . . | |
276 | ||
277 | | | | | |
278 | +--------------+--------------+ | |
279 | | 14 or 30L | 30 or 30R | | |
280 | +--------------+--------------+ | |
281 | | 15 or 31L | 31 or 31R | | |
ecacdc7a | 282 | +--------------+--------------+ */ |
252b5132 RH |
283 | |
284 | /* Additional information needed to build argument relocation stubs. */ | |
285 | struct call_desc | |
286 | { | |
287 | /* The argument relocation specification. */ | |
288 | unsigned int arg_reloc; | |
289 | ||
290 | /* Number of arguments. */ | |
291 | unsigned int arg_count; | |
292 | }; | |
293 | ||
49863f82 | 294 | #ifdef OBJ_SOM |
252b5132 RH |
295 | /* This structure defines an entry in the subspace dictionary |
296 | chain. */ | |
297 | ||
298 | struct subspace_dictionary_chain | |
299 | { | |
300 | /* Nonzero if this space has been defined by the user code. */ | |
301 | unsigned int ssd_defined; | |
302 | ||
303 | /* Name of this subspace. */ | |
304 | char *ssd_name; | |
305 | ||
306 | /* GAS segment and subsegment associated with this subspace. */ | |
307 | asection *ssd_seg; | |
308 | int ssd_subseg; | |
309 | ||
310 | /* Next space in the subspace dictionary chain. */ | |
311 | struct subspace_dictionary_chain *ssd_next; | |
312 | }; | |
313 | ||
314 | typedef struct subspace_dictionary_chain ssd_chain_struct; | |
315 | ||
316 | /* This structure defines an entry in the subspace dictionary | |
317 | chain. */ | |
318 | ||
319 | struct space_dictionary_chain | |
320 | { | |
321 | /* Nonzero if this space has been defined by the user code or | |
322 | as a default space. */ | |
323 | unsigned int sd_defined; | |
324 | ||
325 | /* Nonzero if this spaces has been defined by the user code. */ | |
326 | unsigned int sd_user_defined; | |
327 | ||
328 | /* The space number (or index). */ | |
329 | unsigned int sd_spnum; | |
330 | ||
331 | /* The name of this subspace. */ | |
332 | char *sd_name; | |
333 | ||
334 | /* GAS segment to which this subspace corresponds. */ | |
335 | asection *sd_seg; | |
336 | ||
337 | /* Current subsegment number being used. */ | |
338 | int sd_last_subseg; | |
339 | ||
340 | /* The chain of subspaces contained within this space. */ | |
341 | ssd_chain_struct *sd_subspaces; | |
342 | ||
343 | /* The next entry in the space dictionary chain. */ | |
344 | struct space_dictionary_chain *sd_next; | |
345 | }; | |
346 | ||
347 | typedef struct space_dictionary_chain sd_chain_struct; | |
348 | ||
252b5132 RH |
349 | /* This structure defines attributes of the default subspace |
350 | dictionary entries. */ | |
351 | ||
352 | struct default_subspace_dict | |
353 | { | |
354 | /* Name of the subspace. */ | |
355 | char *name; | |
356 | ||
357 | /* FIXME. Is this still needed? */ | |
358 | char defined; | |
359 | ||
360 | /* Nonzero if this subspace is loadable. */ | |
361 | char loadable; | |
362 | ||
363 | /* Nonzero if this subspace contains only code. */ | |
364 | char code_only; | |
365 | ||
366 | /* Nonzero if this is a common subspace. */ | |
367 | char common; | |
368 | ||
369 | /* Nonzero if this is a common subspace which allows symbols | |
370 | to be multiply defined. */ | |
371 | char dup_common; | |
372 | ||
373 | /* Nonzero if this subspace should be zero filled. */ | |
374 | char zero; | |
375 | ||
376 | /* Sort key for this subspace. */ | |
377 | unsigned char sort; | |
378 | ||
379 | /* Access control bits for this subspace. Can represent RWX access | |
380 | as well as privilege level changes for gateways. */ | |
381 | int access; | |
382 | ||
383 | /* Index of containing space. */ | |
384 | int space_index; | |
385 | ||
386 | /* Alignment (in bytes) of this subspace. */ | |
387 | int alignment; | |
388 | ||
389 | /* Quadrant within space where this subspace should be loaded. */ | |
390 | int quadrant; | |
391 | ||
392 | /* An index into the default spaces array. */ | |
393 | int def_space_index; | |
394 | ||
252b5132 RH |
395 | /* Subsegment associated with this subspace. */ |
396 | subsegT subsegment; | |
397 | }; | |
398 | ||
399 | /* This structure defines attributes of the default space | |
400 | dictionary entries. */ | |
401 | ||
402 | struct default_space_dict | |
403 | { | |
404 | /* Name of the space. */ | |
405 | char *name; | |
406 | ||
407 | /* Space number. It is possible to identify spaces within | |
408 | assembly code numerically! */ | |
409 | int spnum; | |
410 | ||
411 | /* Nonzero if this space is loadable. */ | |
412 | char loadable; | |
413 | ||
414 | /* Nonzero if this space is "defined". FIXME is still needed */ | |
415 | char defined; | |
416 | ||
417 | /* Nonzero if this space can not be shared. */ | |
418 | char private; | |
419 | ||
420 | /* Sort key for this space. */ | |
421 | unsigned char sort; | |
422 | ||
423 | /* Segment associated with this space. */ | |
424 | asection *segment; | |
252b5132 | 425 | }; |
49863f82 JL |
426 | #endif |
427 | ||
428 | /* Structure for previous label tracking. Needed so that alignments, | |
429 | callinfo declarations, etc can be easily attached to a particular | |
430 | label. */ | |
431 | typedef struct label_symbol_struct | |
432 | { | |
433 | struct symbol *lss_label; | |
434 | #ifdef OBJ_SOM | |
435 | sd_chain_struct *lss_space; | |
436 | #endif | |
437 | #ifdef OBJ_ELF | |
438 | segT lss_segment; | |
439 | #endif | |
440 | struct label_symbol_struct *lss_next; | |
441 | } | |
442 | label_symbol_struct; | |
252b5132 RH |
443 | |
444 | /* Extra information needed to perform fixups (relocations) on the PA. */ | |
445 | struct hppa_fix_struct | |
446 | { | |
447 | /* The field selector. */ | |
448 | enum hppa_reloc_field_selector_type_alt fx_r_field; | |
449 | ||
450 | /* Type of fixup. */ | |
451 | int fx_r_type; | |
452 | ||
453 | /* Format of fixup. */ | |
454 | int fx_r_format; | |
455 | ||
456 | /* Argument relocation bits. */ | |
ad1079af | 457 | unsigned int fx_arg_reloc; |
252b5132 RH |
458 | |
459 | /* The segment this fixup appears in. */ | |
460 | segT segment; | |
461 | }; | |
462 | ||
463 | /* Structure to hold information about predefined registers. */ | |
464 | ||
465 | struct pd_reg | |
466 | { | |
467 | char *name; | |
468 | int value; | |
469 | }; | |
470 | ||
471 | /* This structure defines the mapping from a FP condition string | |
472 | to a condition number which can be recorded in an instruction. */ | |
473 | struct fp_cond_map | |
474 | { | |
475 | char *string; | |
476 | int cond; | |
477 | }; | |
478 | ||
479 | /* This structure defines a mapping from a field selector | |
480 | string to a field selector type. */ | |
481 | struct selector_entry | |
482 | { | |
483 | char *prefix; | |
484 | int field_selector; | |
485 | }; | |
486 | ||
487 | /* Prototypes for functions local to tc-hppa.c. */ | |
488 | ||
49863f82 | 489 | #ifdef OBJ_SOM |
252b5132 | 490 | static void pa_check_current_space_and_subspace PARAMS ((void)); |
49863f82 JL |
491 | #endif |
492 | ||
ad1079af AM |
493 | #if !(defined (OBJ_ELF) && defined (TE_LINUX)) |
494 | static void pa_text PARAMS ((int)); | |
495 | static void pa_data PARAMS ((int)); | |
496 | static void pa_comm PARAMS ((int)); | |
497 | #endif | |
252b5132 RH |
498 | static fp_operand_format pa_parse_fp_format PARAMS ((char **s)); |
499 | static void pa_cons PARAMS ((int)); | |
252b5132 RH |
500 | static void pa_float_cons PARAMS ((int)); |
501 | static void pa_fill PARAMS ((int)); | |
502 | static void pa_lcomm PARAMS ((int)); | |
503 | static void pa_lsym PARAMS ((int)); | |
504 | static void pa_stringer PARAMS ((int)); | |
252b5132 RH |
505 | static void pa_version PARAMS ((int)); |
506 | static int pa_parse_fp_cmp_cond PARAMS ((char **)); | |
507 | static int get_expression PARAMS ((char *)); | |
508 | static int pa_get_absolute_expression PARAMS ((struct pa_it *, char **)); | |
509 | static int evaluate_absolute PARAMS ((struct pa_it *)); | |
510 | static unsigned int pa_build_arg_reloc PARAMS ((char *)); | |
511 | static unsigned int pa_align_arg_reloc PARAMS ((unsigned int, unsigned int)); | |
512 | static int pa_parse_nullif PARAMS ((char **)); | |
677537c1 AM |
513 | static int pa_parse_nonneg_cmpsub_cmpltr PARAMS ((char **)); |
514 | static int pa_parse_neg_cmpsub_cmpltr PARAMS ((char **)); | |
515 | static int pa_parse_neg_add_cmpltr PARAMS ((char **)); | |
516 | static int pa_parse_nonneg_add_cmpltr PARAMS ((char **)); | |
d53d2751 JL |
517 | static int pa_parse_cmpb_64_cmpltr PARAMS ((char **)); |
518 | static int pa_parse_cmpib_64_cmpltr PARAMS ((char **)); | |
519 | static int pa_parse_addb_64_cmpltr PARAMS ((char **)); | |
252b5132 RH |
520 | static void pa_block PARAMS ((int)); |
521 | static void pa_brtab PARAMS ((int)); | |
522 | static void pa_try PARAMS ((int)); | |
523 | static void pa_call PARAMS ((int)); | |
524 | static void pa_call_args PARAMS ((struct call_desc *)); | |
525 | static void pa_callinfo PARAMS ((int)); | |
252b5132 RH |
526 | static void pa_copyright PARAMS ((int)); |
527 | static void pa_end PARAMS ((int)); | |
528 | static void pa_enter PARAMS ((int)); | |
529 | static void pa_entry PARAMS ((int)); | |
530 | static void pa_equ PARAMS ((int)); | |
531 | static void pa_exit PARAMS ((int)); | |
532 | static void pa_export PARAMS ((int)); | |
533 | static void pa_type_args PARAMS ((symbolS *, int)); | |
534 | static void pa_import PARAMS ((int)); | |
535 | static void pa_label PARAMS ((int)); | |
536 | static void pa_leave PARAMS ((int)); | |
537 | static void pa_level PARAMS ((int)); | |
538 | static void pa_origin PARAMS ((int)); | |
539 | static void pa_proc PARAMS ((int)); | |
540 | static void pa_procend PARAMS ((int)); | |
252b5132 RH |
541 | static void pa_param PARAMS ((int)); |
542 | static void pa_undefine_label PARAMS ((void)); | |
ecacdc7a AM |
543 | static int need_pa11_opcode PARAMS ((void)); |
544 | static int pa_parse_number PARAMS ((char **, int)); | |
252b5132 | 545 | static label_symbol_struct *pa_get_label PARAMS ((void)); |
49863f82 | 546 | #ifdef OBJ_SOM |
3f9b03b5 | 547 | static int log2 PARAMS ((int)); |
49863f82 JL |
548 | static void pa_compiler PARAMS ((int)); |
549 | static void pa_align PARAMS ((int)); | |
550 | static void pa_space PARAMS ((int)); | |
551 | static void pa_spnum PARAMS ((int)); | |
552 | static void pa_subspace PARAMS ((int)); | |
252b5132 RH |
553 | static sd_chain_struct *create_new_space PARAMS ((char *, int, int, |
554 | int, int, int, | |
555 | asection *, int)); | |
556 | static ssd_chain_struct *create_new_subspace PARAMS ((sd_chain_struct *, | |
557 | char *, int, int, | |
558 | int, int, int, | |
559 | int, int, int, int, | |
560 | int, asection *)); | |
561 | static ssd_chain_struct *update_subspace PARAMS ((sd_chain_struct *, | |
562 | char *, int, int, int, | |
563 | int, int, int, int, | |
564 | int, int, int, | |
565 | asection *)); | |
566 | static sd_chain_struct *is_defined_space PARAMS ((char *)); | |
567 | static ssd_chain_struct *is_defined_subspace PARAMS ((char *)); | |
568 | static sd_chain_struct *pa_segment_to_space PARAMS ((asection *)); | |
569 | static ssd_chain_struct *pa_subsegment_to_subspace PARAMS ((asection *, | |
570 | subsegT)); | |
571 | static sd_chain_struct *pa_find_space_by_number PARAMS ((int)); | |
572 | static unsigned int pa_subspace_start PARAMS ((sd_chain_struct *, int)); | |
49863f82 JL |
573 | static sd_chain_struct *pa_parse_space_stmt PARAMS ((char *, int)); |
574 | static int pa_next_subseg PARAMS ((sd_chain_struct *)); | |
575 | static void pa_spaces_begin PARAMS ((void)); | |
576 | #endif | |
252b5132 RH |
577 | static void pa_ip PARAMS ((char *)); |
578 | static void fix_new_hppa PARAMS ((fragS *, int, int, symbolS *, | |
ad1079af | 579 | offsetT, expressionS *, int, |
252b5132 RH |
580 | bfd_reloc_code_real_type, |
581 | enum hppa_reloc_field_selector_type_alt, | |
da6c73e0 | 582 | int, unsigned int, int)); |
252b5132 RH |
583 | static int is_end_of_statement PARAMS ((void)); |
584 | static int reg_name_search PARAMS ((char *)); | |
585 | static int pa_chk_field_selector PARAMS ((char **)); | |
586 | static int is_same_frag PARAMS ((fragS *, fragS *)); | |
587 | static void process_exit PARAMS ((void)); | |
252b5132 | 588 | static unsigned int pa_stringer_aux PARAMS ((char *)); |
1cf6ae67 JL |
589 | static fp_operand_format pa_parse_fp_cnv_format PARAMS ((char **s)); |
590 | static int pa_parse_ftest_gfx_completer PARAMS ((char **)); | |
252b5132 RH |
591 | |
592 | #ifdef OBJ_ELF | |
593 | static void hppa_elf_mark_end_of_function PARAMS ((void)); | |
594 | static void pa_build_unwind_subspace PARAMS ((struct call_info *)); | |
904a31bf AM |
595 | static void pa_vtable_entry PARAMS ((int)); |
596 | static void pa_vtable_inherit PARAMS ((int)); | |
252b5132 RH |
597 | #endif |
598 | ||
599 | /* File and gloally scoped variable declarations. */ | |
600 | ||
49863f82 | 601 | #ifdef OBJ_SOM |
252b5132 RH |
602 | /* Root and final entry in the space chain. */ |
603 | static sd_chain_struct *space_dict_root; | |
604 | static sd_chain_struct *space_dict_last; | |
605 | ||
606 | /* The current space and subspace. */ | |
607 | static sd_chain_struct *current_space; | |
608 | static ssd_chain_struct *current_subspace; | |
49863f82 | 609 | #endif |
252b5132 RH |
610 | |
611 | /* Root of the call_info chain. */ | |
612 | static struct call_info *call_info_root; | |
613 | ||
614 | /* The last call_info (for functions) structure | |
615 | seen so it can be associated with fixups and | |
616 | function labels. */ | |
617 | static struct call_info *last_call_info; | |
618 | ||
619 | /* The last call description (for actual calls). */ | |
620 | static struct call_desc last_call_desc; | |
621 | ||
622 | /* handle of the OPCODE hash table */ | |
623 | static struct hash_control *op_hash = NULL; | |
624 | ||
f0d7d5f9 NC |
625 | /* Those characters can be suffixes of opcode names. */ |
626 | const char hppa_symbol_chars[] = ",*!?=<>"; | |
627 | ||
252b5132 RH |
628 | /* Table of pseudo ops for the PA. FIXME -- how many of these |
629 | are now redundant with the overall GAS and the object file | |
630 | dependent tables? */ | |
631 | const pseudo_typeS md_pseudo_table[] = | |
632 | { | |
633 | /* align pseudo-ops on the PA specify the actual alignment requested, | |
634 | not the log2 of the requested alignment. */ | |
49863f82 | 635 | #ifdef OBJ_SOM |
252b5132 | 636 | {"align", pa_align, 8}, |
49863f82 JL |
637 | #endif |
638 | #ifdef OBJ_ELF | |
639 | {"align", s_align_bytes, 8}, | |
640 | #endif | |
252b5132 RH |
641 | {"begin_brtab", pa_brtab, 1}, |
642 | {"begin_try", pa_try, 1}, | |
643 | {"block", pa_block, 1}, | |
644 | {"blockz", pa_block, 0}, | |
645 | {"byte", pa_cons, 1}, | |
646 | {"call", pa_call, 0}, | |
647 | {"callinfo", pa_callinfo, 0}, | |
ad1079af AM |
648 | #if defined (OBJ_ELF) && defined (TE_LINUX) |
649 | {"code", obj_elf_text, 0}, | |
650 | #else | |
651 | {"code", pa_text, 0}, | |
252b5132 | 652 | {"comm", pa_comm, 0}, |
ad1079af | 653 | #endif |
252b5132 RH |
654 | #ifdef OBJ_SOM |
655 | {"compiler", pa_compiler, 0}, | |
656 | #endif | |
657 | {"copyright", pa_copyright, 0}, | |
ad1079af | 658 | #if !(defined (OBJ_ELF) && defined (TE_LINUX)) |
252b5132 | 659 | {"data", pa_data, 0}, |
ad1079af | 660 | #endif |
252b5132 | 661 | {"double", pa_float_cons, 'd'}, |
077db52a | 662 | {"dword", pa_cons, 8}, |
252b5132 RH |
663 | {"end", pa_end, 0}, |
664 | {"end_brtab", pa_brtab, 0}, | |
ad1079af | 665 | #if !(defined (OBJ_ELF) && defined (TE_LINUX)) |
252b5132 | 666 | {"end_try", pa_try, 0}, |
ad1079af | 667 | #endif |
252b5132 RH |
668 | {"enter", pa_enter, 0}, |
669 | {"entry", pa_entry, 0}, | |
670 | {"equ", pa_equ, 0}, | |
671 | {"exit", pa_exit, 0}, | |
672 | {"export", pa_export, 0}, | |
2d93dcc4 | 673 | #ifdef OBJ_ELF |
9f1838ed | 674 | {"file", (void (*) PARAMS ((int))) dwarf2_directive_file, 0 }, |
2d93dcc4 | 675 | #endif |
252b5132 RH |
676 | {"fill", pa_fill, 0}, |
677 | {"float", pa_float_cons, 'f'}, | |
678 | {"half", pa_cons, 2}, | |
679 | {"import", pa_import, 0}, | |
680 | {"int", pa_cons, 4}, | |
681 | {"label", pa_label, 0}, | |
682 | {"lcomm", pa_lcomm, 0}, | |
683 | {"leave", pa_leave, 0}, | |
684 | {"level", pa_level, 0}, | |
2d93dcc4 | 685 | #ifdef OBJ_ELF |
ad1079af | 686 | {"loc", dwarf2_directive_loc, 0 }, |
2d93dcc4 | 687 | #endif |
252b5132 RH |
688 | {"long", pa_cons, 4}, |
689 | {"lsym", pa_lsym, 0}, | |
49863f82 | 690 | #ifdef OBJ_SOM |
252b5132 | 691 | {"nsubspa", pa_subspace, 1}, |
49863f82 | 692 | #endif |
252b5132 RH |
693 | {"octa", pa_cons, 16}, |
694 | {"org", pa_origin, 0}, | |
695 | {"origin", pa_origin, 0}, | |
696 | {"param", pa_param, 0}, | |
697 | {"proc", pa_proc, 0}, | |
698 | {"procend", pa_procend, 0}, | |
699 | {"quad", pa_cons, 8}, | |
700 | {"reg", pa_equ, 1}, | |
701 | {"short", pa_cons, 2}, | |
702 | {"single", pa_float_cons, 'f'}, | |
49863f82 | 703 | #ifdef OBJ_SOM |
252b5132 RH |
704 | {"space", pa_space, 0}, |
705 | {"spnum", pa_spnum, 0}, | |
49863f82 | 706 | #endif |
252b5132 RH |
707 | {"string", pa_stringer, 0}, |
708 | {"stringz", pa_stringer, 1}, | |
49863f82 | 709 | #ifdef OBJ_SOM |
252b5132 | 710 | {"subspa", pa_subspace, 0}, |
49863f82 | 711 | #endif |
ad1079af | 712 | #if !(defined (OBJ_ELF) && defined (TE_LINUX)) |
252b5132 | 713 | {"text", pa_text, 0}, |
ad1079af | 714 | #endif |
252b5132 | 715 | {"version", pa_version, 0}, |
904a31bf AM |
716 | #ifdef OBJ_ELF |
717 | {"vtable_entry", pa_vtable_entry, 0}, | |
718 | {"vtable_inherit", pa_vtable_inherit, 0}, | |
719 | #endif | |
252b5132 RH |
720 | {"word", pa_cons, 4}, |
721 | {NULL, 0, 0} | |
722 | }; | |
723 | ||
724 | /* This array holds the chars that only start a comment at the beginning of | |
725 | a line. If the line seems to have the form '# 123 filename' | |
726 | .line and .file directives will appear in the pre-processed output. | |
727 | ||
728 | Note that input_file.c hand checks for '#' at the beginning of the | |
729 | first line of the input file. This is because the compiler outputs | |
730 | #NO_APP at the beginning of its output. | |
731 | ||
a28a3ccf | 732 | Also note that C style comments will always work. */ |
252b5132 RH |
733 | const char line_comment_chars[] = "#"; |
734 | ||
ad1079af AM |
735 | /* This array holds the chars that always start a comment. If the |
736 | pre-processor is disabled, these aren't very useful. */ | |
737 | const char comment_chars[] = ";"; | |
738 | ||
252b5132 RH |
739 | /* This array holds the characters which act as line separators. */ |
740 | const char line_separator_chars[] = "!"; | |
741 | ||
742 | /* Chars that can be used to separate mant from exp in floating point nums. */ | |
743 | const char EXP_CHARS[] = "eE"; | |
744 | ||
745 | /* Chars that mean this number is a floating point constant. | |
746 | As in 0f12.456 or 0d1.2345e12. | |
747 | ||
748 | Be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be | |
749 | changed in read.c. Ideally it shouldn't hae to know abou it at | |
750 | all, but nothing is ideal around here. */ | |
751 | const char FLT_CHARS[] = "rRsSfFdDxXpP"; | |
752 | ||
753 | static struct pa_it the_insn; | |
754 | ||
755 | /* Points to the end of an expression just parsed by get_expressoin | |
756 | and friends. FIXME. This shouldn't be handled with a file-global | |
757 | variable. */ | |
758 | static char *expr_end; | |
759 | ||
760 | /* Nonzero if a .callinfo appeared within the current procedure. */ | |
761 | static int callinfo_found; | |
762 | ||
763 | /* Nonzero if the assembler is currently within a .entry/.exit pair. */ | |
764 | static int within_entry_exit; | |
765 | ||
766 | /* Nonzero if the assembler is currently within a procedure definition. */ | |
767 | static int within_procedure; | |
768 | ||
ad1079af | 769 | /* Handle on structure which keep track of the last symbol |
252b5132 RH |
770 | seen in each subspace. */ |
771 | static label_symbol_struct *label_symbols_rootp = NULL; | |
772 | ||
773 | /* Holds the last field selector. */ | |
774 | static int hppa_field_selector; | |
775 | ||
0f4f8b56 JL |
776 | /* Nonzero when strict syntax checking is enabled. Zero otherwise. |
777 | ||
778 | Each opcode in the table has a flag which indicates whether or not | |
779 | strict syntax checking should be enabled for that instruction. */ | |
780 | static int strict = 0; | |
781 | ||
ecacdc7a AM |
782 | /* pa_parse_number returns values in `pa_number'. Mostly |
783 | pa_parse_number is used to return a register number, with floating | |
784 | point registers being numbered from FP_REG_BASE upwards. | |
785 | The bit specified with FP_REG_RSEL is set if the floating point | |
786 | register has a `r' suffix. */ | |
787 | #define FP_REG_BASE 64 | |
788 | #define FP_REG_RSEL 128 | |
789 | static int pa_number; | |
790 | ||
993142d5 | 791 | #ifdef OBJ_SOM |
252b5132 RH |
792 | /* A dummy bfd symbol so that all relocations have symbols of some kind. */ |
793 | static symbolS *dummy_symbol; | |
993142d5 | 794 | #endif |
252b5132 RH |
795 | |
796 | /* Nonzero if errors are to be printed. */ | |
797 | static int print_errors = 1; | |
798 | ||
799 | /* List of registers that are pre-defined: | |
800 | ||
801 | Each general register has one predefined name of the form | |
802 | %r<REGNUM> which has the value <REGNUM>. | |
803 | ||
804 | Space and control registers are handled in a similar manner, | |
805 | but use %sr<REGNUM> and %cr<REGNUM> as their predefined names. | |
806 | ||
807 | Likewise for the floating point registers, but of the form | |
808 | %fr<REGNUM>. Floating point registers have additional predefined | |
809 | names with 'L' and 'R' suffixes (e.g. %fr19L, %fr19R) which | |
810 | again have the value <REGNUM>. | |
811 | ||
812 | Many registers also have synonyms: | |
813 | ||
814 | %r26 - %r23 have %arg0 - %arg3 as synonyms | |
815 | %r28 - %r29 have %ret0 - %ret1 as synonyms | |
816 | %r30 has %sp as a synonym | |
817 | %r27 has %dp as a synonym | |
818 | %r2 has %rp as a synonym | |
819 | ||
820 | Almost every control register has a synonym; they are not listed | |
821 | here for brevity. | |
822 | ||
a28a3ccf | 823 | The table is sorted. Suitable for searching by a binary search. */ |
252b5132 RH |
824 | |
825 | static const struct pd_reg pre_defined_registers[] = | |
826 | { | |
ecacdc7a AM |
827 | {"%arg0", 26}, |
828 | {"%arg1", 25}, | |
829 | {"%arg2", 24}, | |
830 | {"%arg3", 23}, | |
831 | {"%cr0", 0}, | |
832 | {"%cr10", 10}, | |
833 | {"%cr11", 11}, | |
834 | {"%cr12", 12}, | |
835 | {"%cr13", 13}, | |
836 | {"%cr14", 14}, | |
837 | {"%cr15", 15}, | |
838 | {"%cr16", 16}, | |
839 | {"%cr17", 17}, | |
840 | {"%cr18", 18}, | |
841 | {"%cr19", 19}, | |
842 | {"%cr20", 20}, | |
843 | {"%cr21", 21}, | |
844 | {"%cr22", 22}, | |
845 | {"%cr23", 23}, | |
846 | {"%cr24", 24}, | |
847 | {"%cr25", 25}, | |
848 | {"%cr26", 26}, | |
849 | {"%cr27", 27}, | |
850 | {"%cr28", 28}, | |
851 | {"%cr29", 29}, | |
852 | {"%cr30", 30}, | |
853 | {"%cr31", 31}, | |
854 | {"%cr8", 8}, | |
855 | {"%cr9", 9}, | |
856 | {"%dp", 27}, | |
857 | {"%eiem", 15}, | |
858 | {"%eirr", 23}, | |
859 | {"%fr0", 0 + FP_REG_BASE}, | |
860 | {"%fr0l", 0 + FP_REG_BASE}, | |
861 | {"%fr0r", 0 + FP_REG_BASE + FP_REG_RSEL}, | |
862 | {"%fr1", 1 + FP_REG_BASE}, | |
863 | {"%fr10", 10 + FP_REG_BASE}, | |
864 | {"%fr10l", 10 + FP_REG_BASE}, | |
865 | {"%fr10r", 10 + FP_REG_BASE + FP_REG_RSEL}, | |
866 | {"%fr11", 11 + FP_REG_BASE}, | |
867 | {"%fr11l", 11 + FP_REG_BASE}, | |
868 | {"%fr11r", 11 + FP_REG_BASE + FP_REG_RSEL}, | |
869 | {"%fr12", 12 + FP_REG_BASE}, | |
870 | {"%fr12l", 12 + FP_REG_BASE}, | |
871 | {"%fr12r", 12 + FP_REG_BASE + FP_REG_RSEL}, | |
872 | {"%fr13", 13 + FP_REG_BASE}, | |
873 | {"%fr13l", 13 + FP_REG_BASE}, | |
874 | {"%fr13r", 13 + FP_REG_BASE + FP_REG_RSEL}, | |
875 | {"%fr14", 14 + FP_REG_BASE}, | |
876 | {"%fr14l", 14 + FP_REG_BASE}, | |
877 | {"%fr14r", 14 + FP_REG_BASE + FP_REG_RSEL}, | |
878 | {"%fr15", 15 + FP_REG_BASE}, | |
879 | {"%fr15l", 15 + FP_REG_BASE}, | |
880 | {"%fr15r", 15 + FP_REG_BASE + FP_REG_RSEL}, | |
881 | {"%fr16", 16 + FP_REG_BASE}, | |
882 | {"%fr16l", 16 + FP_REG_BASE}, | |
883 | {"%fr16r", 16 + FP_REG_BASE + FP_REG_RSEL}, | |
884 | {"%fr17", 17 + FP_REG_BASE}, | |
885 | {"%fr17l", 17 + FP_REG_BASE}, | |
886 | {"%fr17r", 17 + FP_REG_BASE + FP_REG_RSEL}, | |
887 | {"%fr18", 18 + FP_REG_BASE}, | |
888 | {"%fr18l", 18 + FP_REG_BASE}, | |
889 | {"%fr18r", 18 + FP_REG_BASE + FP_REG_RSEL}, | |
890 | {"%fr19", 19 + FP_REG_BASE}, | |
891 | {"%fr19l", 19 + FP_REG_BASE}, | |
892 | {"%fr19r", 19 + FP_REG_BASE + FP_REG_RSEL}, | |
893 | {"%fr1l", 1 + FP_REG_BASE}, | |
894 | {"%fr1r", 1 + FP_REG_BASE + FP_REG_RSEL}, | |
895 | {"%fr2", 2 + FP_REG_BASE}, | |
896 | {"%fr20", 20 + FP_REG_BASE}, | |
897 | {"%fr20l", 20 + FP_REG_BASE}, | |
898 | {"%fr20r", 20 + FP_REG_BASE + FP_REG_RSEL}, | |
899 | {"%fr21", 21 + FP_REG_BASE}, | |
900 | {"%fr21l", 21 + FP_REG_BASE}, | |
901 | {"%fr21r", 21 + FP_REG_BASE + FP_REG_RSEL}, | |
902 | {"%fr22", 22 + FP_REG_BASE}, | |
903 | {"%fr22l", 22 + FP_REG_BASE}, | |
904 | {"%fr22r", 22 + FP_REG_BASE + FP_REG_RSEL}, | |
905 | {"%fr23", 23 + FP_REG_BASE}, | |
906 | {"%fr23l", 23 + FP_REG_BASE}, | |
907 | {"%fr23r", 23 + FP_REG_BASE + FP_REG_RSEL}, | |
908 | {"%fr24", 24 + FP_REG_BASE}, | |
909 | {"%fr24l", 24 + FP_REG_BASE}, | |
910 | {"%fr24r", 24 + FP_REG_BASE + FP_REG_RSEL}, | |
911 | {"%fr25", 25 + FP_REG_BASE}, | |
912 | {"%fr25l", 25 + FP_REG_BASE}, | |
913 | {"%fr25r", 25 + FP_REG_BASE + FP_REG_RSEL}, | |
914 | {"%fr26", 26 + FP_REG_BASE}, | |
915 | {"%fr26l", 26 + FP_REG_BASE}, | |
916 | {"%fr26r", 26 + FP_REG_BASE + FP_REG_RSEL}, | |
917 | {"%fr27", 27 + FP_REG_BASE}, | |
918 | {"%fr27l", 27 + FP_REG_BASE}, | |
919 | {"%fr27r", 27 + FP_REG_BASE + FP_REG_RSEL}, | |
920 | {"%fr28", 28 + FP_REG_BASE}, | |
921 | {"%fr28l", 28 + FP_REG_BASE}, | |
922 | {"%fr28r", 28 + FP_REG_BASE + FP_REG_RSEL}, | |
923 | {"%fr29", 29 + FP_REG_BASE}, | |
924 | {"%fr29l", 29 + FP_REG_BASE}, | |
925 | {"%fr29r", 29 + FP_REG_BASE + FP_REG_RSEL}, | |
926 | {"%fr2l", 2 + FP_REG_BASE}, | |
927 | {"%fr2r", 2 + FP_REG_BASE + FP_REG_RSEL}, | |
928 | {"%fr3", 3 + FP_REG_BASE}, | |
929 | {"%fr30", 30 + FP_REG_BASE}, | |
930 | {"%fr30l", 30 + FP_REG_BASE}, | |
931 | {"%fr30r", 30 + FP_REG_BASE + FP_REG_RSEL}, | |
932 | {"%fr31", 31 + FP_REG_BASE}, | |
933 | {"%fr31l", 31 + FP_REG_BASE}, | |
934 | {"%fr31r", 31 + FP_REG_BASE + FP_REG_RSEL}, | |
935 | {"%fr3l", 3 + FP_REG_BASE}, | |
936 | {"%fr3r", 3 + FP_REG_BASE + FP_REG_RSEL}, | |
937 | {"%fr4", 4 + FP_REG_BASE}, | |
938 | {"%fr4l", 4 + FP_REG_BASE}, | |
939 | {"%fr4r", 4 + FP_REG_BASE + FP_REG_RSEL}, | |
940 | {"%fr5", 5 + FP_REG_BASE}, | |
941 | {"%fr5l", 5 + FP_REG_BASE}, | |
942 | {"%fr5r", 5 + FP_REG_BASE + FP_REG_RSEL}, | |
943 | {"%fr6", 6 + FP_REG_BASE}, | |
944 | {"%fr6l", 6 + FP_REG_BASE}, | |
945 | {"%fr6r", 6 + FP_REG_BASE + FP_REG_RSEL}, | |
946 | {"%fr7", 7 + FP_REG_BASE}, | |
947 | {"%fr7l", 7 + FP_REG_BASE}, | |
948 | {"%fr7r", 7 + FP_REG_BASE + FP_REG_RSEL}, | |
949 | {"%fr8", 8 + FP_REG_BASE}, | |
950 | {"%fr8l", 8 + FP_REG_BASE}, | |
951 | {"%fr8r", 8 + FP_REG_BASE + FP_REG_RSEL}, | |
952 | {"%fr9", 9 + FP_REG_BASE}, | |
953 | {"%fr9l", 9 + FP_REG_BASE}, | |
954 | {"%fr9r", 9 + FP_REG_BASE + FP_REG_RSEL}, | |
955 | {"%hta", 25}, | |
956 | {"%iir", 19}, | |
957 | {"%ior", 21}, | |
958 | {"%ipsw", 22}, | |
959 | {"%isr", 20}, | |
960 | {"%itmr", 16}, | |
961 | {"%iva", 14}, | |
8be31359 NC |
962 | #if TARGET_ARCH_SIZE == 64 |
963 | {"%mrp", 2}, | |
964 | #else | |
965 | {"%mrp", 31}, | |
966 | #endif | |
ecacdc7a AM |
967 | {"%pcoq", 18}, |
968 | {"%pcsq", 17}, | |
969 | {"%pidr1", 8}, | |
970 | {"%pidr2", 9}, | |
252b5132 RH |
971 | {"%pidr3", 12}, |
972 | {"%pidr4", 13}, | |
ecacdc7a AM |
973 | {"%ppda", 24}, |
974 | {"%r0", 0}, | |
975 | {"%r1", 1}, | |
976 | {"%r10", 10}, | |
977 | {"%r11", 11}, | |
978 | {"%r12", 12}, | |
979 | {"%r13", 13}, | |
980 | {"%r14", 14}, | |
981 | {"%r15", 15}, | |
982 | {"%r16", 16}, | |
983 | {"%r17", 17}, | |
984 | {"%r18", 18}, | |
985 | {"%r19", 19}, | |
986 | {"%r2", 2}, | |
987 | {"%r20", 20}, | |
988 | {"%r21", 21}, | |
989 | {"%r22", 22}, | |
990 | {"%r23", 23}, | |
991 | {"%r24", 24}, | |
992 | {"%r25", 25}, | |
993 | {"%r26", 26}, | |
994 | {"%r27", 27}, | |
995 | {"%r28", 28}, | |
996 | {"%r29", 29}, | |
997 | {"%r3", 3}, | |
998 | {"%r30", 30}, | |
999 | {"%r31", 31}, | |
1000 | {"%r4", 4}, | |
1001 | {"%r5", 5}, | |
1002 | {"%r6", 6}, | |
1003 | {"%r7", 7}, | |
1004 | {"%r8", 8}, | |
1005 | {"%r9", 9}, | |
1006 | {"%rctr", 0}, | |
1007 | {"%ret0", 28}, | |
1008 | {"%ret1", 29}, | |
1009 | {"%rp", 2}, | |
1010 | {"%sar", 11}, | |
1011 | {"%sp", 30}, | |
1012 | {"%sr0", 0}, | |
1013 | {"%sr1", 1}, | |
1014 | {"%sr2", 2}, | |
1015 | {"%sr3", 3}, | |
1016 | {"%sr4", 4}, | |
1017 | {"%sr5", 5}, | |
1018 | {"%sr6", 6}, | |
1019 | {"%sr7", 7}, | |
1020 | {"%tr0", 24}, | |
1021 | {"%tr1", 25}, | |
1022 | {"%tr2", 26}, | |
1023 | {"%tr3", 27}, | |
1024 | {"%tr4", 28}, | |
1025 | {"%tr5", 29}, | |
1026 | {"%tr6", 30}, | |
1027 | {"%tr7", 31} | |
252b5132 RH |
1028 | }; |
1029 | ||
1030 | /* This table is sorted by order of the length of the string. This is | |
1031 | so we check for <> before we check for <. If we had a <> and checked | |
1032 | for < first, we would get a false match. */ | |
1033 | static const struct fp_cond_map fp_cond_map[] = | |
1034 | { | |
1035 | {"false?", 0}, | |
1036 | {"false", 1}, | |
1037 | {"true?", 30}, | |
1038 | {"true", 31}, | |
1039 | {"!<=>", 3}, | |
1040 | {"!?>=", 8}, | |
1041 | {"!?<=", 16}, | |
1042 | {"!<>", 7}, | |
1043 | {"!>=", 11}, | |
1044 | {"!?>", 12}, | |
1045 | {"?<=", 14}, | |
1046 | {"!<=", 19}, | |
1047 | {"!?<", 20}, | |
1048 | {"?>=", 22}, | |
1049 | {"!?=", 24}, | |
1050 | {"!=t", 27}, | |
1051 | {"<=>", 29}, | |
1052 | {"=t", 5}, | |
1053 | {"?=", 6}, | |
1054 | {"?<", 10}, | |
1055 | {"<=", 13}, | |
1056 | {"!>", 15}, | |
1057 | {"?>", 18}, | |
1058 | {">=", 21}, | |
1059 | {"!<", 23}, | |
1060 | {"<>", 25}, | |
1061 | {"!=", 26}, | |
1062 | {"!?", 28}, | |
1063 | {"?", 2}, | |
1064 | {"=", 4}, | |
1065 | {"<", 9}, | |
1066 | {">", 17} | |
1067 | }; | |
1068 | ||
1069 | static const struct selector_entry selector_table[] = | |
1070 | { | |
1071 | {"f", e_fsel}, | |
1072 | {"l", e_lsel}, | |
1073 | {"ld", e_ldsel}, | |
1074 | {"lp", e_lpsel}, | |
1075 | {"lr", e_lrsel}, | |
1076 | {"ls", e_lssel}, | |
1077 | {"lt", e_ltsel}, | |
39ba5561 | 1078 | {"ltp", e_ltpsel}, |
252b5132 RH |
1079 | {"n", e_nsel}, |
1080 | {"nl", e_nlsel}, | |
1081 | {"nlr", e_nlrsel}, | |
1082 | {"p", e_psel}, | |
1083 | {"r", e_rsel}, | |
1084 | {"rd", e_rdsel}, | |
1085 | {"rp", e_rpsel}, | |
1086 | {"rr", e_rrsel}, | |
1087 | {"rs", e_rssel}, | |
1088 | {"rt", e_rtsel}, | |
39ba5561 | 1089 | {"rtp", e_rtpsel}, |
252b5132 RH |
1090 | {"t", e_tsel}, |
1091 | }; | |
1092 | ||
49863f82 | 1093 | #ifdef OBJ_SOM |
252b5132 RH |
1094 | /* default space and subspace dictionaries */ |
1095 | ||
1096 | #define GDB_SYMBOLS GDB_SYMBOLS_SUBSPACE_NAME | |
1097 | #define GDB_STRINGS GDB_STRINGS_SUBSPACE_NAME | |
1098 | ||
1099 | /* pre-defined subsegments (subspaces) for the HPPA. */ | |
1100 | #define SUBSEG_CODE 0 | |
1101 | #define SUBSEG_LIT 1 | |
1102 | #define SUBSEG_MILLI 2 | |
1103 | #define SUBSEG_DATA 0 | |
1104 | #define SUBSEG_BSS 2 | |
1105 | #define SUBSEG_UNWIND 3 | |
1106 | #define SUBSEG_GDB_STRINGS 0 | |
1107 | #define SUBSEG_GDB_SYMBOLS 1 | |
1108 | ||
1109 | static struct default_subspace_dict pa_def_subspaces[] = | |
1110 | { | |
49863f82 JL |
1111 | {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE}, |
1112 | {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA}, | |
1113 | {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT}, | |
1114 | {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI}, | |
1115 | {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS}, | |
252b5132 RH |
1116 | {NULL, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0} |
1117 | }; | |
1118 | ||
1119 | static struct default_space_dict pa_def_spaces[] = | |
1120 | { | |
49863f82 JL |
1121 | {"$TEXT$", 0, 1, 1, 0, 8, ASEC_NULL}, |
1122 | {"$PRIVATE$", 1, 1, 1, 1, 16, ASEC_NULL}, | |
1123 | {NULL, 0, 0, 0, 0, 0, ASEC_NULL} | |
252b5132 RH |
1124 | }; |
1125 | ||
1126 | /* Misc local definitions used by the assembler. */ | |
1127 | ||
252b5132 RH |
1128 | /* These macros are used to maintain spaces/subspaces. */ |
1129 | #define SPACE_DEFINED(space_chain) (space_chain)->sd_defined | |
1130 | #define SPACE_USER_DEFINED(space_chain) (space_chain)->sd_user_defined | |
1131 | #define SPACE_SPNUM(space_chain) (space_chain)->sd_spnum | |
1132 | #define SPACE_NAME(space_chain) (space_chain)->sd_name | |
1133 | ||
1134 | #define SUBSPACE_DEFINED(ss_chain) (ss_chain)->ssd_defined | |
1135 | #define SUBSPACE_NAME(ss_chain) (ss_chain)->ssd_name | |
49863f82 JL |
1136 | #endif |
1137 | ||
1138 | /* Return nonzero if the string pointed to by S potentially represents | |
1139 | a right or left half of a FP register */ | |
1140 | #define IS_R_SELECT(S) (*(S) == 'R' || *(S) == 'r') | |
1141 | #define IS_L_SELECT(S) (*(S) == 'L' || *(S) == 'l') | |
252b5132 RH |
1142 | |
1143 | /* Insert FIELD into OPCODE starting at bit START. Continue pa_ip | |
1144 | main loop after insertion. */ | |
1145 | ||
1146 | #define INSERT_FIELD_AND_CONTINUE(OPCODE, FIELD, START) \ | |
1147 | { \ | |
1148 | ((OPCODE) |= (FIELD) << (START)); \ | |
1149 | continue; \ | |
1150 | } | |
1151 | ||
1152 | /* Simple range checking for FIELD againt HIGH and LOW bounds. | |
1153 | IGNORE is used to suppress the error message. */ | |
1154 | ||
1155 | #define CHECK_FIELD(FIELD, HIGH, LOW, IGNORE) \ | |
1156 | { \ | |
1157 | if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \ | |
1158 | { \ | |
1159 | if (! IGNORE) \ | |
1160 | as_bad (_("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \ | |
1161 | (int) (FIELD));\ | |
1162 | break; \ | |
1163 | } \ | |
1164 | } | |
1165 | ||
94f592af | 1166 | /* Variant of CHECK_FIELD for use in md_apply_fix3 and other places where |
b091f402 AM |
1167 | the current file and line number are not valid. */ |
1168 | ||
1169 | #define CHECK_FIELD_WHERE(FIELD, HIGH, LOW, FILENAME, LINE) \ | |
1170 | { \ | |
1171 | if ((FIELD) > (HIGH) || (FIELD) < (LOW)) \ | |
1172 | { \ | |
1173 | as_bad_where ((FILENAME), (LINE), \ | |
1174 | _("Field out of range [%d..%d] (%d)."), (LOW), (HIGH), \ | |
1175 | (int) (FIELD));\ | |
1176 | break; \ | |
1177 | } \ | |
1178 | } | |
1179 | ||
a02fab7e JL |
1180 | /* Simple alignment checking for FIELD againt ALIGN (a power of two). |
1181 | IGNORE is used to suppress the error message. */ | |
1182 | ||
1183 | #define CHECK_ALIGN(FIELD, ALIGN, IGNORE) \ | |
1184 | { \ | |
1185 | if ((FIELD) & ((ALIGN) - 1)) \ | |
1186 | { \ | |
1187 | if (! IGNORE) \ | |
1188 | as_bad (_("Field not properly aligned [%d] (%d)."), (ALIGN), \ | |
1189 | (int) (FIELD));\ | |
1190 | break; \ | |
1191 | } \ | |
1192 | } | |
1193 | ||
252b5132 RH |
1194 | #define is_DP_relative(exp) \ |
1195 | ((exp).X_op == O_subtract \ | |
a0f75b47 | 1196 | && strcmp (S_GET_NAME ((exp).X_op_symbol), "$global$") == 0) |
252b5132 RH |
1197 | |
1198 | #define is_PC_relative(exp) \ | |
1199 | ((exp).X_op == O_subtract \ | |
a0f75b47 | 1200 | && strcmp (S_GET_NAME ((exp).X_op_symbol), "$PIC_pcrel$0") == 0) |
252b5132 RH |
1201 | |
1202 | /* We need some complex handling for stabs (sym1 - sym2). Luckily, we'll | |
1203 | always be able to reduce the expression to a constant, so we don't | |
1204 | need real complex handling yet. */ | |
1205 | #define is_complex(exp) \ | |
1206 | ((exp).X_op != O_constant && (exp).X_op != O_symbol) | |
1207 | ||
1208 | /* Actual functions to implement the PA specific code for the assembler. */ | |
1209 | ||
1210 | /* Called before writing the object file. Make sure entry/exit and | |
1211 | proc/procend pairs match. */ | |
1212 | ||
1213 | void | |
1214 | pa_check_eof () | |
1215 | { | |
1216 | if (within_entry_exit) | |
1217 | as_fatal (_("Missing .exit\n")); | |
1218 | ||
1219 | if (within_procedure) | |
1220 | as_fatal (_("Missing .procend\n")); | |
1221 | } | |
1222 | ||
252b5132 RH |
1223 | /* Returns a pointer to the label_symbol_struct for the current space. |
1224 | or NULL if no label_symbol_struct exists for the current space. */ | |
1225 | ||
1226 | static label_symbol_struct * | |
1227 | pa_get_label () | |
1228 | { | |
1229 | label_symbol_struct *label_chain; | |
252b5132 RH |
1230 | |
1231 | for (label_chain = label_symbols_rootp; | |
1232 | label_chain; | |
1233 | label_chain = label_chain->lss_next) | |
49863f82 JL |
1234 | { |
1235 | #ifdef OBJ_SOM | |
1236 | if (current_space == label_chain->lss_space && label_chain->lss_label) | |
1237 | return label_chain; | |
1238 | #endif | |
1239 | #ifdef OBJ_ELF | |
1240 | if (now_seg == label_chain->lss_segment && label_chain->lss_label) | |
252b5132 | 1241 | return label_chain; |
49863f82 JL |
1242 | #endif |
1243 | } | |
252b5132 RH |
1244 | |
1245 | return NULL; | |
1246 | } | |
1247 | ||
1248 | /* Defines a label for the current space. If one is already defined, | |
1249 | this function will replace it with the new label. */ | |
1250 | ||
1251 | void | |
1252 | pa_define_label (symbol) | |
1253 | symbolS *symbol; | |
1254 | { | |
1255 | label_symbol_struct *label_chain = pa_get_label (); | |
252b5132 RH |
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; | |
49863f82 JL |
1265 | #ifdef OBJ_SOM |
1266 | label_chain->lss_space = current_space; | |
1267 | #endif | |
1268 | #ifdef OBJ_ELF | |
1269 | label_chain->lss_segment = now_seg; | |
1270 | #endif | |
252b5132 RH |
1271 | label_chain->lss_next = NULL; |
1272 | ||
1273 | if (label_symbols_rootp) | |
1274 | label_chain->lss_next = label_symbols_rootp; | |
1275 | ||
1276 | label_symbols_rootp = label_chain; | |
1277 | } | |
1278 | } | |
1279 | ||
1280 | /* Removes a label definition for the current space. | |
1281 | If there is no label_symbol_struct entry, then no action is taken. */ | |
1282 | ||
1283 | static void | |
1284 | pa_undefine_label () | |
1285 | { | |
1286 | label_symbol_struct *label_chain; | |
1287 | label_symbol_struct *prev_label_chain = NULL; | |
252b5132 RH |
1288 | |
1289 | for (label_chain = label_symbols_rootp; | |
1290 | label_chain; | |
1291 | label_chain = label_chain->lss_next) | |
1292 | { | |
49863f82 JL |
1293 | if (1 |
1294 | #ifdef OBJ_SOM | |
cc8a6dd0 | 1295 | && current_space == label_chain->lss_space && label_chain->lss_label |
49863f82 JL |
1296 | #endif |
1297 | #ifdef OBJ_ELF | |
cc8a6dd0 | 1298 | && now_seg == label_chain->lss_segment && label_chain->lss_label |
49863f82 JL |
1299 | #endif |
1300 | ) | |
252b5132 RH |
1301 | { |
1302 | /* Remove the label from the chain and free its memory. */ | |
1303 | if (prev_label_chain) | |
1304 | prev_label_chain->lss_next = label_chain->lss_next; | |
1305 | else | |
1306 | label_symbols_rootp = label_chain->lss_next; | |
1307 | ||
1308 | free (label_chain); | |
1309 | break; | |
1310 | } | |
1311 | prev_label_chain = label_chain; | |
1312 | } | |
1313 | } | |
1314 | ||
252b5132 RH |
1315 | /* An HPPA-specific version of fix_new. This is required because the HPPA |
1316 | code needs to keep track of some extra stuff. Each call to fix_new_hppa | |
1317 | results in the creation of an instance of an hppa_fix_struct. An | |
1318 | hppa_fix_struct stores the extra information along with a pointer to the | |
1319 | original fixS. This is attached to the original fixup via the | |
1320 | tc_fix_data field. */ | |
1321 | ||
1322 | static void | |
1323 | fix_new_hppa (frag, where, size, add_symbol, offset, exp, pcrel, | |
1324 | r_type, r_field, r_format, arg_reloc, unwind_bits) | |
1325 | fragS *frag; | |
1326 | int where; | |
1327 | int size; | |
1328 | symbolS *add_symbol; | |
ad1079af | 1329 | offsetT offset; |
252b5132 RH |
1330 | expressionS *exp; |
1331 | int pcrel; | |
1332 | bfd_reloc_code_real_type r_type; | |
1333 | enum hppa_reloc_field_selector_type_alt r_field; | |
1334 | int r_format; | |
ad1079af | 1335 | unsigned int arg_reloc; |
da6c73e0 | 1336 | int unwind_bits ATTRIBUTE_UNUSED; |
252b5132 RH |
1337 | { |
1338 | fixS *new_fix; | |
1339 | ||
1340 | struct hppa_fix_struct *hppa_fix = (struct hppa_fix_struct *) | |
1341 | obstack_alloc (¬es, sizeof (struct hppa_fix_struct)); | |
1342 | ||
1343 | if (exp != NULL) | |
1344 | new_fix = fix_new_exp (frag, where, size, exp, pcrel, r_type); | |
1345 | else | |
1346 | new_fix = fix_new (frag, where, size, add_symbol, offset, pcrel, r_type); | |
1347 | new_fix->tc_fix_data = (void *) hppa_fix; | |
1348 | hppa_fix->fx_r_type = r_type; | |
1349 | hppa_fix->fx_r_field = r_field; | |
1350 | hppa_fix->fx_r_format = r_format; | |
1351 | hppa_fix->fx_arg_reloc = arg_reloc; | |
1352 | hppa_fix->segment = now_seg; | |
1353 | #ifdef OBJ_SOM | |
1354 | if (r_type == R_ENTRY || r_type == R_EXIT) | |
da6c73e0 | 1355 | new_fix->fx_offset = unwind_bits; |
252b5132 RH |
1356 | #endif |
1357 | ||
1358 | /* foo-$global$ is used to access non-automatic storage. $global$ | |
1359 | is really just a marker and has served its purpose, so eliminate | |
904a31bf | 1360 | it now so as not to confuse write.c. Ditto for $PIC_pcrel$0. */ |
252b5132 | 1361 | if (new_fix->fx_subsy |
904a31bf AM |
1362 | && (strcmp (S_GET_NAME (new_fix->fx_subsy), "$global$") == 0 |
1363 | || strcmp (S_GET_NAME (new_fix->fx_subsy), "$PIC_pcrel$0") == 0)) | |
252b5132 RH |
1364 | new_fix->fx_subsy = NULL; |
1365 | } | |
1366 | ||
1367 | /* Parse a .byte, .word, .long expression for the HPPA. Called by | |
1368 | cons via the TC_PARSE_CONS_EXPRESSION macro. */ | |
1369 | ||
1370 | void | |
1371 | parse_cons_expression_hppa (exp) | |
1372 | expressionS *exp; | |
1373 | { | |
1374 | hppa_field_selector = pa_chk_field_selector (&input_line_pointer); | |
1375 | expression (exp); | |
1376 | } | |
1377 | ||
1378 | /* This fix_new is called by cons via TC_CONS_FIX_NEW. | |
1379 | hppa_field_selector is set by the parse_cons_expression_hppa. */ | |
1380 | ||
1381 | void | |
1382 | cons_fix_new_hppa (frag, where, size, exp) | |
1383 | fragS *frag; | |
1384 | int where; | |
1385 | int size; | |
1386 | expressionS *exp; | |
1387 | { | |
1388 | unsigned int rel_type; | |
1389 | ||
1390 | /* Get a base relocation type. */ | |
1391 | if (is_DP_relative (*exp)) | |
1392 | rel_type = R_HPPA_GOTOFF; | |
1393 | else if (is_complex (*exp)) | |
1394 | rel_type = R_HPPA_COMPLEX; | |
1395 | else | |
1396 | rel_type = R_HPPA; | |
1397 | ||
1398 | if (hppa_field_selector != e_psel && hppa_field_selector != e_fsel) | |
ad1079af AM |
1399 | { |
1400 | as_warn (_("Invalid field selector. Assuming F%%.")); | |
1401 | hppa_field_selector = e_fsel; | |
1402 | } | |
252b5132 RH |
1403 | |
1404 | fix_new_hppa (frag, where, size, | |
1405 | (symbolS *) NULL, (offsetT) 0, exp, 0, rel_type, | |
da6c73e0 | 1406 | hppa_field_selector, size * 8, 0, 0); |
252b5132 RH |
1407 | |
1408 | /* Reset field selector to its default state. */ | |
1409 | hppa_field_selector = 0; | |
1410 | } | |
1411 | ||
1412 | /* This function is called once, at assembler startup time. It should | |
1413 | set up all the tables, etc. that the MD part of the assembler will need. */ | |
1414 | ||
1415 | void | |
1416 | md_begin () | |
1417 | { | |
1418 | const char *retval = NULL; | |
1419 | int lose = 0; | |
1420 | unsigned int i = 0; | |
1421 | ||
1422 | last_call_info = NULL; | |
1423 | call_info_root = NULL; | |
1424 | ||
1425 | /* Set the default machine type. */ | |
8a238888 | 1426 | if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, DEFAULT_LEVEL)) |
252b5132 RH |
1427 | as_warn (_("could not set architecture and machine")); |
1428 | ||
1429 | /* Folding of text and data segments fails miserably on the PA. | |
1430 | Warn user and disable "-R" option. */ | |
1431 | if (flag_readonly_data_in_text) | |
1432 | { | |
1433 | as_warn (_("-R option not supported on this target.")); | |
1434 | flag_readonly_data_in_text = 0; | |
1435 | } | |
1436 | ||
49863f82 | 1437 | #ifdef OBJ_SOM |
252b5132 | 1438 | pa_spaces_begin (); |
49863f82 | 1439 | #endif |
252b5132 RH |
1440 | |
1441 | op_hash = hash_new (); | |
1442 | ||
1443 | while (i < NUMOPCODES) | |
1444 | { | |
1445 | const char *name = pa_opcodes[i].name; | |
1446 | retval = hash_insert (op_hash, name, (struct pa_opcode *) &pa_opcodes[i]); | |
1447 | if (retval != NULL && *retval != '\0') | |
1448 | { | |
1449 | as_fatal (_("Internal error: can't hash `%s': %s\n"), name, retval); | |
1450 | lose = 1; | |
1451 | } | |
1452 | do | |
1453 | { | |
1454 | if ((pa_opcodes[i].match & pa_opcodes[i].mask) | |
1455 | != pa_opcodes[i].match) | |
1456 | { | |
1457 | fprintf (stderr, _("internal error: losing opcode: `%s' \"%s\"\n"), | |
1458 | pa_opcodes[i].name, pa_opcodes[i].args); | |
1459 | lose = 1; | |
1460 | } | |
1461 | ++i; | |
1462 | } | |
1463 | while (i < NUMOPCODES && !strcmp (pa_opcodes[i].name, name)); | |
1464 | } | |
1465 | ||
1466 | if (lose) | |
1467 | as_fatal (_("Broken assembler. No assembly attempted.")); | |
1468 | ||
49863f82 | 1469 | #ifdef OBJ_SOM |
252b5132 RH |
1470 | /* SOM will change text_section. To make sure we never put |
1471 | anything into the old one switch to the new one now. */ | |
1472 | subseg_set (text_section, 0); | |
49863f82 | 1473 | #endif |
252b5132 | 1474 | |
993142d5 | 1475 | #ifdef OBJ_SOM |
252b5132 RH |
1476 | dummy_symbol = symbol_find_or_make ("L$dummy"); |
1477 | S_SET_SEGMENT (dummy_symbol, text_section); | |
a28a3ccf | 1478 | /* Force the symbol to be converted to a real symbol. */ |
d53d2751 | 1479 | (void) symbol_get_bfdsym (dummy_symbol); |
993142d5 | 1480 | #endif |
252b5132 RH |
1481 | } |
1482 | ||
1483 | /* Assemble a single instruction storing it into a frag. */ | |
1484 | void | |
1485 | md_assemble (str) | |
1486 | char *str; | |
1487 | { | |
1488 | char *to; | |
1489 | ||
1490 | /* The had better be something to assemble. */ | |
1491 | assert (str); | |
1492 | ||
1493 | /* If we are within a procedure definition, make sure we've | |
1494 | defined a label for the procedure; handle case where the | |
1495 | label was defined after the .PROC directive. | |
1496 | ||
1497 | Note there's not need to diddle with the segment or fragment | |
1498 | for the label symbol in this case. We have already switched | |
1499 | into the new $CODE$ subspace at this point. */ | |
1500 | if (within_procedure && last_call_info->start_symbol == NULL) | |
1501 | { | |
1502 | label_symbol_struct *label_symbol = pa_get_label (); | |
1503 | ||
1504 | if (label_symbol) | |
1505 | { | |
1506 | if (label_symbol->lss_label) | |
1507 | { | |
1508 | last_call_info->start_symbol = label_symbol->lss_label; | |
a0f75b47 ILT |
1509 | symbol_get_bfdsym (label_symbol->lss_label)->flags |
1510 | |= BSF_FUNCTION; | |
252b5132 RH |
1511 | #ifdef OBJ_SOM |
1512 | /* Also handle allocation of a fixup to hold the unwind | |
1513 | information when the label appears after the proc/procend. */ | |
1514 | if (within_entry_exit) | |
1515 | { | |
da6c73e0 AM |
1516 | char *where; |
1517 | unsigned int u; | |
252b5132 | 1518 | |
da6c73e0 AM |
1519 | where = frag_more (0); |
1520 | u = UNWIND_LOW32 (&last_call_info->ci_unwind.descriptor); | |
252b5132 RH |
1521 | fix_new_hppa (frag_now, where - frag_now->fr_literal, 0, |
1522 | NULL, (offsetT) 0, NULL, | |
da6c73e0 | 1523 | 0, R_HPPA_ENTRY, e_fsel, 0, 0, u); |
252b5132 RH |
1524 | } |
1525 | #endif | |
1526 | } | |
1527 | else | |
1528 | as_bad (_("Missing function name for .PROC (corrupted label chain)")); | |
1529 | } | |
1530 | else | |
1531 | as_bad (_("Missing function name for .PROC")); | |
1532 | } | |
1533 | ||
1534 | /* Assemble the instruction. Results are saved into "the_insn". */ | |
1535 | pa_ip (str); | |
1536 | ||
1537 | /* Get somewhere to put the assembled instrution. */ | |
1538 | to = frag_more (4); | |
1539 | ||
a28a3ccf | 1540 | /* Output the opcode. */ |
252b5132 RH |
1541 | md_number_to_chars (to, the_insn.opcode, 4); |
1542 | ||
1543 | /* If necessary output more stuff. */ | |
1544 | if (the_insn.reloc != R_HPPA_NONE) | |
1545 | fix_new_hppa (frag_now, (to - frag_now->fr_literal), 4, NULL, | |
1546 | (offsetT) 0, &the_insn.exp, the_insn.pcrel, | |
1547 | the_insn.reloc, the_insn.field_selector, | |
da6c73e0 | 1548 | the_insn.format, the_insn.arg_reloc, 0); |
2d93dcc4 JL |
1549 | |
1550 | #ifdef OBJ_ELF | |
4dc7ead9 | 1551 | dwarf2_emit_insn (4); |
b52c78b8 | 1552 | #endif |
252b5132 RH |
1553 | } |
1554 | ||
1555 | /* Do the real work for assembling a single instruction. Store results | |
1556 | into the global "the_insn" variable. */ | |
1557 | ||
1558 | static void | |
1559 | pa_ip (str) | |
1560 | char *str; | |
1561 | { | |
1562 | char *error_message = ""; | |
1563 | char *s, c, *argstart, *name, *save_s; | |
1564 | const char *args; | |
1565 | int match = FALSE; | |
1566 | int comma = 0; | |
1567 | int cmpltr, nullif, flag, cond, num; | |
1568 | unsigned long opcode; | |
1569 | struct pa_opcode *insn; | |
1570 | ||
49863f82 | 1571 | #ifdef OBJ_SOM |
252b5132 RH |
1572 | /* We must have a valid space and subspace. */ |
1573 | pa_check_current_space_and_subspace (); | |
49863f82 | 1574 | #endif |
252b5132 | 1575 | |
b1c5e0ee JL |
1576 | /* Convert everything up to the first whitespace character into lower |
1577 | case. */ | |
1578 | for (s = str; *s != ' ' && *s != '\t' && *s != '\n' && *s != '\0'; s++) | |
3882b010 | 1579 | *s = TOLOWER (*s); |
b1c5e0ee | 1580 | |
252b5132 | 1581 | /* Skip to something interesting. */ |
3882b010 L |
1582 | for (s = str; |
1583 | ISUPPER (*s) || ISLOWER (*s) || (*s >= '0' && *s <= '3'); | |
1584 | ++s) | |
252b5132 RH |
1585 | ; |
1586 | ||
1587 | switch (*s) | |
1588 | { | |
1589 | ||
1590 | case '\0': | |
1591 | break; | |
1592 | ||
1593 | case ',': | |
1594 | comma = 1; | |
1595 | ||
1596 | /*FALLTHROUGH */ | |
1597 | ||
1598 | case ' ': | |
1599 | *s++ = '\0'; | |
1600 | break; | |
1601 | ||
1602 | default: | |
1603 | as_fatal (_("Unknown opcode: `%s'"), str); | |
1604 | } | |
1605 | ||
252b5132 RH |
1606 | /* Look up the opcode in the has table. */ |
1607 | if ((insn = (struct pa_opcode *) hash_find (op_hash, str)) == NULL) | |
1608 | { | |
1609 | as_bad ("Unknown opcode: `%s'", str); | |
1610 | return; | |
1611 | } | |
1612 | ||
1613 | if (comma) | |
1614 | { | |
1615 | *--s = ','; | |
1616 | } | |
1617 | ||
1618 | /* Mark the location where arguments for the instruction start, then | |
1619 | start processing them. */ | |
1620 | argstart = s; | |
1621 | for (;;) | |
1622 | { | |
1623 | /* Do some initialization. */ | |
1624 | opcode = insn->match; | |
0f4f8b56 | 1625 | strict = (insn->flags & FLAG_STRICT); |
252b5132 RH |
1626 | memset (&the_insn, 0, sizeof (the_insn)); |
1627 | ||
1628 | the_insn.reloc = R_HPPA_NONE; | |
1629 | ||
1630 | /* If this instruction is specific to a particular architecture, | |
1631 | then set a new architecture. */ | |
1632 | /* But do not automatically promote to pa2.0. The automatic promotion | |
1633 | crud is for compatability with HP's old assemblers only. */ | |
1634 | if (insn->arch < 20 | |
1635 | && bfd_get_mach (stdoutput) < insn->arch) | |
1636 | { | |
1637 | if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, insn->arch)) | |
1638 | as_warn (_("could not update architecture and machine")); | |
1639 | } | |
1640 | else if (bfd_get_mach (stdoutput) < insn->arch) | |
1641 | { | |
1642 | match = FALSE; | |
1643 | goto failed; | |
1644 | } | |
1645 | ||
1646 | /* Build the opcode, checking as we go to make | |
1647 | sure that the operands match. */ | |
1648 | for (args = insn->args;; ++args) | |
1649 | { | |
680ef6de JL |
1650 | /* Absorb white space in instruction. */ |
1651 | while (*s == ' ' || *s == '\t') | |
1652 | s++; | |
1653 | ||
252b5132 RH |
1654 | switch (*args) |
1655 | { | |
1656 | ||
1657 | /* End of arguments. */ | |
1658 | case '\0': | |
1659 | if (*s == '\0') | |
1660 | match = TRUE; | |
1661 | break; | |
1662 | ||
1663 | case '+': | |
1664 | if (*s == '+') | |
1665 | { | |
1666 | ++s; | |
1667 | continue; | |
1668 | } | |
1669 | if (*s == '-') | |
1670 | continue; | |
1671 | break; | |
1672 | ||
1673 | /* These must match exactly. */ | |
1674 | case '(': | |
1675 | case ')': | |
1676 | case ',': | |
1677 | case ' ': | |
1678 | if (*s++ == *args) | |
1679 | continue; | |
1680 | break; | |
1681 | ||
1682 | /* Handle a 5 bit register or control register field at 10. */ | |
1683 | case 'b': | |
1684 | case '^': | |
ecacdc7a | 1685 | if (!pa_parse_number (&s, 0)) |
0f4f8b56 | 1686 | break; |
ecacdc7a | 1687 | num = pa_number; |
252b5132 RH |
1688 | CHECK_FIELD (num, 31, 0, 0); |
1689 | INSERT_FIELD_AND_CONTINUE (opcode, num, 21); | |
1690 | ||
a97685e9 JL |
1691 | /* Handle %sar or %cr11. No bits get set, we just verify that it |
1692 | is there. */ | |
1693 | case '!': | |
1694 | /* Skip whitespace before register. */ | |
1695 | while (*s == ' ' || *s == '\t') | |
1696 | s = s + 1; | |
1697 | ||
07726851 | 1698 | if (!strncasecmp (s, "%sar", 4)) |
a97685e9 JL |
1699 | { |
1700 | s += 4; | |
1701 | continue; | |
1702 | } | |
07726851 | 1703 | else if (!strncasecmp (s, "%cr11", 5)) |
a97685e9 JL |
1704 | { |
1705 | s += 5; | |
1706 | continue; | |
1707 | } | |
1708 | break; | |
1709 | ||
252b5132 RH |
1710 | /* Handle a 5 bit register field at 15. */ |
1711 | case 'x': | |
ecacdc7a | 1712 | if (!pa_parse_number (&s, 0)) |
0f4f8b56 | 1713 | break; |
ecacdc7a | 1714 | num = pa_number; |
252b5132 RH |
1715 | CHECK_FIELD (num, 31, 0, 0); |
1716 | INSERT_FIELD_AND_CONTINUE (opcode, num, 16); | |
1717 | ||
1718 | /* Handle a 5 bit register field at 31. */ | |
252b5132 | 1719 | case 't': |
ecacdc7a | 1720 | if (!pa_parse_number (&s, 0)) |
0f4f8b56 | 1721 | break; |
ecacdc7a | 1722 | num = pa_number; |
252b5132 RH |
1723 | CHECK_FIELD (num, 31, 0, 0); |
1724 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
1725 | ||
413c94ba JL |
1726 | /* Handle a 5 bit register field at 10 and 15. */ |
1727 | case 'a': | |
ecacdc7a | 1728 | if (!pa_parse_number (&s, 0)) |
0f4f8b56 | 1729 | break; |
ecacdc7a | 1730 | num = pa_number; |
413c94ba JL |
1731 | CHECK_FIELD (num, 31, 0, 0); |
1732 | opcode |= num << 16; | |
1733 | INSERT_FIELD_AND_CONTINUE (opcode, num, 21); | |
1734 | ||
252b5132 RH |
1735 | /* Handle a 5 bit field length at 31. */ |
1736 | case 'T': | |
1737 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
1738 | if (strict && the_insn.exp.X_op != O_constant) |
1739 | break; | |
252b5132 RH |
1740 | s = expr_end; |
1741 | CHECK_FIELD (num, 32, 1, 0); | |
1742 | INSERT_FIELD_AND_CONTINUE (opcode, 32 - num, 0); | |
1743 | ||
1744 | /* Handle a 5 bit immediate at 15. */ | |
1745 | case '5': | |
1746 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
1747 | if (strict && the_insn.exp.X_op != O_constant) |
1748 | break; | |
252b5132 | 1749 | s = expr_end; |
0f4f8b56 JL |
1750 | /* When in strict mode, we want to just reject this |
1751 | match instead of giving an out of range error. */ | |
1752 | CHECK_FIELD (num, 15, -16, strict); | |
3f9b03b5 | 1753 | num = low_sign_unext (num, 5); |
252b5132 RH |
1754 | INSERT_FIELD_AND_CONTINUE (opcode, num, 16); |
1755 | ||
1756 | /* Handle a 5 bit immediate at 31. */ | |
1757 | case 'V': | |
1758 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
1759 | if (strict && the_insn.exp.X_op != O_constant) |
1760 | break; | |
252b5132 | 1761 | s = expr_end; |
0f4f8b56 JL |
1762 | /* When in strict mode, we want to just reject this |
1763 | match instead of giving an out of range error. */ | |
ad1079af | 1764 | CHECK_FIELD (num, 15, -16, strict); |
3f9b03b5 | 1765 | num = low_sign_unext (num, 5); |
252b5132 RH |
1766 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); |
1767 | ||
1768 | /* Handle an unsigned 5 bit immediate at 31. */ | |
1769 | case 'r': | |
1770 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
1771 | if (strict && the_insn.exp.X_op != O_constant) |
1772 | break; | |
252b5132 | 1773 | s = expr_end; |
ad1079af AM |
1774 | CHECK_FIELD (num, 31, 0, strict); |
1775 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
252b5132 RH |
1776 | |
1777 | /* Handle an unsigned 5 bit immediate at 15. */ | |
1778 | case 'R': | |
1779 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
1780 | if (strict && the_insn.exp.X_op != O_constant) |
1781 | break; | |
252b5132 | 1782 | s = expr_end; |
0f4f8b56 | 1783 | CHECK_FIELD (num, 31, 0, strict); |
252b5132 RH |
1784 | INSERT_FIELD_AND_CONTINUE (opcode, num, 16); |
1785 | ||
680ef6de JL |
1786 | /* Handle an unsigned 10 bit immediate at 15. */ |
1787 | case 'U': | |
1788 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
1789 | if (strict && the_insn.exp.X_op != O_constant) |
1790 | break; | |
680ef6de | 1791 | s = expr_end; |
0f4f8b56 | 1792 | CHECK_FIELD (num, 1023, 0, strict); |
680ef6de JL |
1793 | INSERT_FIELD_AND_CONTINUE (opcode, num, 16); |
1794 | ||
252b5132 RH |
1795 | /* Handle a 2 bit space identifier at 17. */ |
1796 | case 's': | |
ecacdc7a | 1797 | if (!pa_parse_number (&s, 0)) |
0f4f8b56 | 1798 | break; |
ecacdc7a | 1799 | num = pa_number; |
252b5132 RH |
1800 | CHECK_FIELD (num, 3, 0, 1); |
1801 | INSERT_FIELD_AND_CONTINUE (opcode, num, 14); | |
1802 | ||
1803 | /* Handle a 3 bit space identifier at 18. */ | |
1804 | case 'S': | |
ecacdc7a | 1805 | if (!pa_parse_number (&s, 0)) |
0f4f8b56 | 1806 | break; |
ecacdc7a | 1807 | num = pa_number; |
252b5132 | 1808 | CHECK_FIELD (num, 7, 0, 1); |
ad1079af | 1809 | opcode |= re_assemble_3 (num); |
3f9b03b5 | 1810 | continue; |
252b5132 | 1811 | |
28252e61 | 1812 | /* Handle all completers. */ |
252b5132 | 1813 | case 'c': |
28252e61 JL |
1814 | switch (*++args) |
1815 | { | |
1816 | ||
1817 | /* Handle a completer for an indexing load or store. */ | |
1d358ee0 | 1818 | case 'X': |
28252e61 | 1819 | case 'x': |
252b5132 | 1820 | { |
28252e61 JL |
1821 | int uu = 0; |
1822 | int m = 0; | |
1823 | int i = 0; | |
1824 | while (*s == ',' && i < 2) | |
252b5132 | 1825 | { |
28252e61 JL |
1826 | s++; |
1827 | if (strncasecmp (s, "sm", 2) == 0) | |
1828 | { | |
1829 | uu = 1; | |
1830 | m = 1; | |
1831 | s++; | |
1832 | i++; | |
1833 | } | |
1834 | else if (strncasecmp (s, "m", 1) == 0) | |
1835 | m = 1; | |
d53d2751 JL |
1836 | else if ((strncasecmp (s, "s ", 2) == 0) |
1837 | || (strncasecmp (s, "s,", 2) == 0)) | |
28252e61 | 1838 | uu = 1; |
0f4f8b56 JL |
1839 | /* When in strict mode this is a match failure. */ |
1840 | else if (strict) | |
d53d2751 JL |
1841 | { |
1842 | s--; | |
1843 | break; | |
1844 | } | |
28252e61 JL |
1845 | else |
1846 | as_bad (_("Invalid Indexed Load Completer.")); | |
252b5132 RH |
1847 | s++; |
1848 | i++; | |
1849 | } | |
28252e61 JL |
1850 | if (i > 2) |
1851 | as_bad (_("Invalid Indexed Load Completer Syntax.")); | |
1852 | opcode |= m << 5; | |
1853 | INSERT_FIELD_AND_CONTINUE (opcode, uu, 13); | |
252b5132 | 1854 | } |
252b5132 | 1855 | |
28252e61 | 1856 | /* Handle a short load/store completer. */ |
1d358ee0 | 1857 | case 'M': |
28252e61 | 1858 | case 'm': |
61dd1d31 | 1859 | case 'q': |
71823da4 | 1860 | case 'J': |
d53d2751 | 1861 | case 'e': |
252b5132 | 1862 | { |
28252e61 JL |
1863 | int a = 0; |
1864 | int m = 0; | |
1865 | if (*s == ',') | |
252b5132 | 1866 | { |
d53d2751 | 1867 | int found = 0; |
28252e61 JL |
1868 | s++; |
1869 | if (strncasecmp (s, "ma", 2) == 0) | |
1870 | { | |
1871 | a = 0; | |
1872 | m = 1; | |
d53d2751 | 1873 | found = 1; |
28252e61 JL |
1874 | } |
1875 | else if (strncasecmp (s, "mb", 2) == 0) | |
1876 | { | |
1877 | a = 1; | |
1878 | m = 1; | |
d53d2751 | 1879 | found = 1; |
28252e61 | 1880 | } |
d53d2751 JL |
1881 | |
1882 | /* When in strict mode, pass through for cache op. */ | |
1883 | if (!found && strict) | |
1884 | s--; | |
28252e61 | 1885 | else |
d53d2751 JL |
1886 | { |
1887 | if (!found) | |
1888 | as_bad (_("Invalid Short Load/Store Completer.")); | |
1889 | s += 2; | |
1890 | } | |
252b5132 | 1891 | } |
65fab780 | 1892 | /* If we did not get a ma/mb completer, then we do not |
d53d2751 JL |
1893 | consider this a positive match for 'ce'. */ |
1894 | else if (*args == 'e') | |
65fab780 | 1895 | break; |
252b5132 | 1896 | |
1d358ee0 | 1897 | /* 'J', 'm', 'M' and 'q' are the same, except for where they |
71823da4 | 1898 | encode the before/after field. */ |
1d358ee0 | 1899 | if (*args == 'm' || *args == 'M') |
61dd1d31 JL |
1900 | { |
1901 | opcode |= m << 5; | |
1902 | INSERT_FIELD_AND_CONTINUE (opcode, a, 13); | |
1903 | } | |
1904 | else if (*args == 'q') | |
1905 | { | |
1906 | opcode |= m << 3; | |
1907 | INSERT_FIELD_AND_CONTINUE (opcode, a, 2); | |
1908 | } | |
71823da4 JL |
1909 | else if (*args == 'J') |
1910 | { | |
1911 | /* M bit is explicit in the major opcode. */ | |
1912 | INSERT_FIELD_AND_CONTINUE (opcode, a, 2); | |
1913 | } | |
d53d2751 | 1914 | else if (*args == 'e') |
65fab780 | 1915 | { |
1328dc98 AM |
1916 | /* Stash the ma/mb flag temporarily in the |
1917 | instruction. We will use (and remove it) | |
1918 | later when handling 'J', 'K', '<' & '>'. */ | |
1919 | opcode |= a; | |
65fab780 JL |
1920 | continue; |
1921 | } | |
252b5132 | 1922 | } |
252b5132 | 1923 | |
28252e61 | 1924 | /* Handle a stbys completer. */ |
1d358ee0 | 1925 | case 'A': |
28252e61 | 1926 | case 's': |
252b5132 | 1927 | { |
28252e61 JL |
1928 | int a = 0; |
1929 | int m = 0; | |
1930 | int i = 0; | |
1931 | while (*s == ',' && i < 2) | |
1932 | { | |
1933 | s++; | |
1934 | if (strncasecmp (s, "m", 1) == 0) | |
1935 | m = 1; | |
d53d2751 JL |
1936 | else if ((strncasecmp (s, "b ", 2) == 0) |
1937 | || (strncasecmp (s, "b,", 2) == 0)) | |
28252e61 JL |
1938 | a = 0; |
1939 | else if (strncasecmp (s, "e", 1) == 0) | |
1940 | a = 1; | |
0f4f8b56 JL |
1941 | /* When in strict mode this is a match failure. */ |
1942 | else if (strict) | |
d53d2751 JL |
1943 | { |
1944 | s--; | |
1945 | break; | |
1946 | } | |
28252e61 JL |
1947 | else |
1948 | as_bad (_("Invalid Store Bytes Short Completer")); | |
1949 | s++; | |
1950 | i++; | |
1951 | } | |
1952 | if (i > 2) | |
252b5132 | 1953 | as_bad (_("Invalid Store Bytes Short Completer")); |
28252e61 JL |
1954 | opcode |= m << 5; |
1955 | INSERT_FIELD_AND_CONTINUE (opcode, a, 13); | |
252b5132 | 1956 | } |
28252e61 | 1957 | |
d53d2751 JL |
1958 | /* Handle load cache hint completer. */ |
1959 | case 'c': | |
1960 | cmpltr = 0; | |
07726851 | 1961 | if (!strncmp (s, ",sl", 3)) |
d53d2751 JL |
1962 | { |
1963 | s += 3; | |
1964 | cmpltr = 2; | |
1965 | } | |
1966 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 10); | |
1967 | ||
1968 | /* Handle store cache hint completer. */ | |
1969 | case 'C': | |
1970 | cmpltr = 0; | |
07726851 | 1971 | if (!strncmp (s, ",sl", 3)) |
d53d2751 JL |
1972 | { |
1973 | s += 3; | |
1974 | cmpltr = 2; | |
1975 | } | |
07726851 | 1976 | else if (!strncmp (s, ",bc", 3)) |
d53d2751 JL |
1977 | { |
1978 | s += 3; | |
1979 | cmpltr = 1; | |
1980 | } | |
1981 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 10); | |
1982 | ||
1983 | /* Handle load and clear cache hint completer. */ | |
1984 | case 'd': | |
1985 | cmpltr = 0; | |
07726851 | 1986 | if (!strncmp (s, ",co", 3)) |
d53d2751 JL |
1987 | { |
1988 | s += 3; | |
1989 | cmpltr = 1; | |
1990 | } | |
1991 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 10); | |
1992 | ||
a28a3ccf | 1993 | /* Handle load ordering completer. */ |
d53d2751 | 1994 | case 'o': |
07726851 | 1995 | if (strncmp (s, ",o", 2) != 0) |
d53d2751 JL |
1996 | break; |
1997 | s += 2; | |
1998 | continue; | |
1999 | ||
ce674324 JL |
2000 | /* Handle a branch gate completer. */ |
2001 | case 'g': | |
2002 | if (strncasecmp (s, ",gate", 5) != 0) | |
2003 | break; | |
2004 | s += 5; | |
2005 | continue; | |
2006 | ||
2007 | /* Handle a branch link and push completer. */ | |
2008 | case 'p': | |
2009 | if (strncasecmp (s, ",l,push", 7) != 0) | |
2010 | break; | |
2011 | s += 7; | |
2012 | continue; | |
2013 | ||
2014 | /* Handle a branch link completer. */ | |
2015 | case 'l': | |
2016 | if (strncasecmp (s, ",l", 2) != 0) | |
2017 | break; | |
2018 | s += 2; | |
2019 | continue; | |
2020 | ||
2021 | /* Handle a branch pop completer. */ | |
2022 | case 'P': | |
2023 | if (strncasecmp (s, ",pop", 4) != 0) | |
2024 | break; | |
2025 | s += 4; | |
2026 | continue; | |
2027 | ||
680ef6de JL |
2028 | /* Handle a local processor completer. */ |
2029 | case 'L': | |
2030 | if (strncasecmp (s, ",l", 2) != 0) | |
2031 | break; | |
2032 | s += 2; | |
2033 | continue; | |
2034 | ||
2035 | /* Handle a PROBE read/write completer. */ | |
2036 | case 'w': | |
2037 | flag = 0; | |
2038 | if (!strncasecmp (s, ",w", 2)) | |
2039 | { | |
2040 | flag = 1; | |
2041 | s += 2; | |
2042 | } | |
2043 | else if (!strncasecmp (s, ",r", 2)) | |
2044 | { | |
2045 | flag = 0; | |
2046 | s += 2; | |
2047 | } | |
2048 | ||
2049 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 6); | |
2050 | ||
2051 | /* Handle MFCTL wide completer. */ | |
d53d2751 | 2052 | case 'W': |
680ef6de JL |
2053 | if (strncasecmp (s, ",w", 2) != 0) |
2054 | break; | |
2055 | s += 2; | |
2056 | continue; | |
2057 | ||
2058 | /* Handle an RFI restore completer. */ | |
2059 | case 'r': | |
2060 | flag = 0; | |
2061 | if (!strncasecmp (s, ",r", 2)) | |
2062 | { | |
2063 | flag = 5; | |
2064 | s += 2; | |
2065 | } | |
2066 | ||
2067 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 5); | |
2068 | ||
28252e61 JL |
2069 | /* Handle a system control completer. */ |
2070 | case 'Z': | |
2071 | if (*s == ',' && (*(s + 1) == 'm' || *(s + 1) == 'M')) | |
2072 | { | |
2073 | flag = 1; | |
2074 | s += 2; | |
2075 | } | |
2076 | else | |
2077 | flag = 0; | |
2078 | ||
2079 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 5); | |
2080 | ||
680ef6de JL |
2081 | /* Handle intermediate/final completer for DCOR. */ |
2082 | case 'i': | |
2083 | flag = 0; | |
2084 | if (!strncasecmp (s, ",i", 2)) | |
2085 | { | |
2086 | flag = 1; | |
2087 | s += 2; | |
2088 | } | |
2089 | ||
2090 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 6); | |
2091 | ||
9e4f2d3a JL |
2092 | /* Handle zero/sign extension completer. */ |
2093 | case 'z': | |
2094 | flag = 1; | |
2095 | if (!strncasecmp (s, ",z", 2)) | |
2096 | { | |
2097 | flag = 0; | |
2098 | s += 2; | |
2099 | } | |
2100 | ||
2101 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 10); | |
2102 | ||
680ef6de JL |
2103 | /* Handle add completer. */ |
2104 | case 'a': | |
2105 | flag = 1; | |
2106 | if (!strncasecmp (s, ",l", 2)) | |
2107 | { | |
2108 | flag = 2; | |
2109 | s += 2; | |
2110 | } | |
2111 | else if (!strncasecmp (s, ",tsv", 4)) | |
2112 | { | |
2113 | flag = 3; | |
2114 | s += 4; | |
2115 | } | |
d53d2751 | 2116 | |
680ef6de JL |
2117 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 10); |
2118 | ||
2119 | /* Handle 64 bit carry for ADD. */ | |
2120 | case 'Y': | |
2121 | flag = 0; | |
2122 | if (!strncasecmp (s, ",dc,tsv", 7) || | |
2123 | !strncasecmp (s, ",tsv,dc", 7)) | |
2124 | { | |
2125 | flag = 1; | |
2126 | s += 7; | |
2127 | } | |
2128 | else if (!strncasecmp (s, ",dc", 3)) | |
2129 | { | |
2130 | flag = 0; | |
2131 | s += 3; | |
2132 | } | |
2133 | else | |
2134 | break; | |
2135 | ||
2136 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); | |
2137 | ||
2138 | /* Handle 32 bit carry for ADD. */ | |
2139 | case 'y': | |
2140 | flag = 0; | |
2141 | if (!strncasecmp (s, ",c,tsv", 6) || | |
2142 | !strncasecmp (s, ",tsv,c", 6)) | |
2143 | { | |
2144 | flag = 1; | |
2145 | s += 6; | |
2146 | } | |
2147 | else if (!strncasecmp (s, ",c", 2)) | |
2148 | { | |
2149 | flag = 0; | |
2150 | s += 2; | |
2151 | } | |
2152 | else | |
2153 | break; | |
2154 | ||
2155 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); | |
2156 | ||
2157 | /* Handle trap on signed overflow. */ | |
2158 | case 'v': | |
2159 | flag = 0; | |
2160 | if (!strncasecmp (s, ",tsv", 4)) | |
2161 | { | |
2162 | flag = 1; | |
2163 | s += 4; | |
2164 | } | |
2165 | ||
2166 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); | |
2167 | ||
2168 | /* Handle trap on condition and overflow. */ | |
2169 | case 't': | |
2170 | flag = 0; | |
2171 | if (!strncasecmp (s, ",tc,tsv", 7) || | |
2172 | !strncasecmp (s, ",tsv,tc", 7)) | |
2173 | { | |
2174 | flag = 1; | |
2175 | s += 7; | |
2176 | } | |
2177 | else if (!strncasecmp (s, ",tc", 3)) | |
2178 | { | |
2179 | flag = 0; | |
2180 | s += 3; | |
2181 | } | |
2182 | else | |
2183 | break; | |
2184 | ||
2185 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); | |
2186 | ||
2187 | /* Handle 64 bit borrow for SUB. */ | |
2188 | case 'B': | |
2189 | flag = 0; | |
2190 | if (!strncasecmp (s, ",db,tsv", 7) || | |
2191 | !strncasecmp (s, ",tsv,db", 7)) | |
2192 | { | |
2193 | flag = 1; | |
2194 | s += 7; | |
2195 | } | |
2196 | else if (!strncasecmp (s, ",db", 3)) | |
2197 | { | |
2198 | flag = 0; | |
2199 | s += 3; | |
2200 | } | |
2201 | else | |
2202 | break; | |
2203 | ||
2204 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); | |
2205 | ||
2206 | /* Handle 32 bit borrow for SUB. */ | |
2207 | case 'b': | |
2208 | flag = 0; | |
2209 | if (!strncasecmp (s, ",b,tsv", 6) || | |
2210 | !strncasecmp (s, ",tsv,b", 6)) | |
2211 | { | |
2212 | flag = 1; | |
2213 | s += 6; | |
2214 | } | |
2215 | else if (!strncasecmp (s, ",b", 2)) | |
2216 | { | |
2217 | flag = 0; | |
2218 | s += 2; | |
2219 | } | |
2220 | else | |
2221 | break; | |
2222 | ||
2223 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); | |
2224 | ||
2225 | /* Handle trap condition completer for UADDCM. */ | |
2226 | case 'T': | |
2227 | flag = 0; | |
2228 | if (!strncasecmp (s, ",tc", 3)) | |
2229 | { | |
2230 | flag = 1; | |
2231 | s += 3; | |
2232 | } | |
2233 | ||
2234 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 6); | |
2235 | ||
413c94ba JL |
2236 | /* Handle signed/unsigned at 21. */ |
2237 | case 'S': | |
2238 | { | |
2239 | int sign = 1; | |
2240 | if (strncasecmp (s, ",s", 2) == 0) | |
2241 | { | |
2242 | sign = 1; | |
2243 | s += 2; | |
2244 | } | |
2245 | else if (strncasecmp (s, ",u", 2) == 0) | |
2246 | { | |
2247 | sign = 0; | |
2248 | s += 2; | |
2249 | } | |
2250 | ||
2251 | INSERT_FIELD_AND_CONTINUE (opcode, sign, 10); | |
2252 | } | |
2253 | ||
2254 | /* Handle left/right combination at 17:18. */ | |
2255 | case 'h': | |
2256 | if (*s++ == ',') | |
2257 | { | |
2258 | int lr = 0; | |
2259 | if (*s == 'r') | |
2260 | lr = 2; | |
2261 | else if (*s == 'l') | |
2262 | lr = 0; | |
2263 | else | |
07726851 | 2264 | as_bad (_("Invalid left/right combination completer")); |
413c94ba JL |
2265 | |
2266 | s++; | |
2267 | INSERT_FIELD_AND_CONTINUE (opcode, lr, 13); | |
2268 | } | |
2269 | else | |
07726851 | 2270 | as_bad (_("Invalid left/right combination completer")); |
413c94ba JL |
2271 | break; |
2272 | ||
2273 | /* Handle saturation at 24:25. */ | |
2274 | case 'H': | |
2275 | { | |
2276 | int sat = 3; | |
2277 | if (strncasecmp (s, ",ss", 3) == 0) | |
2278 | { | |
2279 | sat = 1; | |
2280 | s += 3; | |
2281 | } | |
2282 | else if (strncasecmp (s, ",us", 3) == 0) | |
2283 | { | |
2284 | sat = 0; | |
2285 | s += 3; | |
2286 | } | |
2287 | ||
2288 | INSERT_FIELD_AND_CONTINUE (opcode, sat, 6); | |
2289 | } | |
2290 | ||
2291 | /* Handle permutation completer. */ | |
2292 | case '*': | |
2293 | if (*s++ == ',') | |
2294 | { | |
b1039fc4 | 2295 | int permloc[4]; |
413c94ba JL |
2296 | int perm = 0; |
2297 | int i = 0; | |
b1039fc4 JL |
2298 | permloc[0] = 13; |
2299 | permloc[1] = 10; | |
2300 | permloc[2] = 8; | |
2301 | permloc[3] = 6; | |
413c94ba JL |
2302 | for (; i < 4; i++) |
2303 | { | |
2304 | switch (*s++) | |
2305 | { | |
2306 | case '0': | |
2307 | perm = 0; | |
2308 | break; | |
2309 | case '1': | |
2310 | perm = 1; | |
2311 | break; | |
2312 | case '2': | |
2313 | perm = 2; | |
2314 | break; | |
2315 | case '3': | |
2316 | perm = 3; | |
2317 | break; | |
2318 | default: | |
07726851 | 2319 | as_bad (_("Invalid permutation completer")); |
413c94ba JL |
2320 | } |
2321 | opcode |= perm << permloc[i]; | |
2322 | } | |
2323 | continue; | |
2324 | } | |
2325 | else | |
07726851 | 2326 | as_bad (_("Invalid permutation completer")); |
413c94ba JL |
2327 | break; |
2328 | ||
28252e61 JL |
2329 | default: |
2330 | abort (); | |
2331 | } | |
2332 | break; | |
252b5132 | 2333 | |
55a914bc | 2334 | /* Handle all conditions. */ |
252b5132 | 2335 | case '?': |
55a914bc JL |
2336 | { |
2337 | args++; | |
2338 | switch (*args) | |
2339 | { | |
cc8a6dd0 KH |
2340 | /* Handle FP compare conditions. */ |
2341 | case 'f': | |
2342 | cond = pa_parse_fp_cmp_cond (&s); | |
2343 | INSERT_FIELD_AND_CONTINUE (opcode, cond, 0); | |
55a914bc JL |
2344 | |
2345 | /* Handle an add condition. */ | |
9a913dfb | 2346 | case 'A': |
55a914bc | 2347 | case 'a': |
cc8a6dd0 KH |
2348 | cmpltr = 0; |
2349 | flag = 0; | |
55a914bc JL |
2350 | if (*s == ',') |
2351 | { | |
2352 | s++; | |
9a913dfb JL |
2353 | |
2354 | /* 64 bit conditions. */ | |
2355 | if (*args == 'A') | |
2356 | { | |
2357 | if (*s == '*') | |
2358 | s++; | |
2359 | else | |
2360 | break; | |
2361 | } | |
17d9105c JL |
2362 | else if (*s == '*') |
2363 | break; | |
55a914bc | 2364 | name = s; |
9a913dfb | 2365 | |
680ef6de | 2366 | name = s; |
55a914bc JL |
2367 | while (*s != ',' && *s != ' ' && *s != '\t') |
2368 | s += 1; | |
2369 | c = *s; | |
2370 | *s = 0x00; | |
2371 | if (strcmp (name, "=") == 0) | |
2372 | cmpltr = 1; | |
2373 | else if (strcmp (name, "<") == 0) | |
2374 | cmpltr = 2; | |
2375 | else if (strcmp (name, "<=") == 0) | |
2376 | cmpltr = 3; | |
2377 | else if (strcasecmp (name, "nuv") == 0) | |
2378 | cmpltr = 4; | |
2379 | else if (strcasecmp (name, "znv") == 0) | |
2380 | cmpltr = 5; | |
2381 | else if (strcasecmp (name, "sv") == 0) | |
2382 | cmpltr = 6; | |
2383 | else if (strcasecmp (name, "od") == 0) | |
2384 | cmpltr = 7; | |
2385 | else if (strcasecmp (name, "tr") == 0) | |
2386 | { | |
2387 | cmpltr = 0; | |
2388 | flag = 1; | |
2389 | } | |
2390 | else if (strcmp (name, "<>") == 0) | |
2391 | { | |
2392 | cmpltr = 1; | |
2393 | flag = 1; | |
2394 | } | |
2395 | else if (strcmp (name, ">=") == 0) | |
2396 | { | |
2397 | cmpltr = 2; | |
2398 | flag = 1; | |
2399 | } | |
2400 | else if (strcmp (name, ">") == 0) | |
2401 | { | |
2402 | cmpltr = 3; | |
2403 | flag = 1; | |
2404 | } | |
2405 | else if (strcasecmp (name, "uv") == 0) | |
2406 | { | |
2407 | cmpltr = 4; | |
2408 | flag = 1; | |
2409 | } | |
2410 | else if (strcasecmp (name, "vnz") == 0) | |
2411 | { | |
2412 | cmpltr = 5; | |
2413 | flag = 1; | |
2414 | } | |
2415 | else if (strcasecmp (name, "nsv") == 0) | |
2416 | { | |
2417 | cmpltr = 6; | |
2418 | flag = 1; | |
2419 | } | |
2420 | else if (strcasecmp (name, "ev") == 0) | |
2421 | { | |
2422 | cmpltr = 7; | |
2423 | flag = 1; | |
2424 | } | |
9a913dfb JL |
2425 | /* ",*" is a valid condition. */ |
2426 | else if (*args == 'a') | |
55a914bc JL |
2427 | as_bad (_("Invalid Add Condition: %s"), name); |
2428 | *s = c; | |
2429 | } | |
2430 | opcode |= cmpltr << 13; | |
2431 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); | |
252b5132 | 2432 | |
55a914bc JL |
2433 | /* Handle non-negated add and branch condition. */ |
2434 | case 'd': | |
677537c1 | 2435 | cmpltr = pa_parse_nonneg_add_cmpltr (&s); |
55a914bc JL |
2436 | if (cmpltr < 0) |
2437 | { | |
677537c1 | 2438 | as_bad (_("Invalid Add and Branch Condition")); |
55a914bc JL |
2439 | cmpltr = 0; |
2440 | } | |
2441 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); | |
2442 | ||
d53d2751 | 2443 | /* Handle 64 bit wide-mode add and branch condition. */ |
9a913dfb | 2444 | case 'W': |
d53d2751 JL |
2445 | cmpltr = pa_parse_addb_64_cmpltr (&s); |
2446 | if (cmpltr < 0) | |
2447 | { | |
677537c1 | 2448 | as_bad (_("Invalid Add and Branch Condition")); |
d53d2751 JL |
2449 | cmpltr = 0; |
2450 | } | |
2451 | else | |
2452 | { | |
a28a3ccf | 2453 | /* Negated condition requires an opcode change. */ |
d53d2751 JL |
2454 | opcode |= (cmpltr & 8) << 24; |
2455 | } | |
2456 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr & 7, 13); | |
9a913dfb | 2457 | |
d53d2751 | 2458 | /* Handle a negated or non-negated add and branch |
55a914bc JL |
2459 | condition. */ |
2460 | case '@': | |
2461 | save_s = s; | |
677537c1 | 2462 | cmpltr = pa_parse_nonneg_add_cmpltr (&s); |
55a914bc JL |
2463 | if (cmpltr < 0) |
2464 | { | |
2465 | s = save_s; | |
677537c1 | 2466 | cmpltr = pa_parse_neg_add_cmpltr (&s); |
55a914bc JL |
2467 | if (cmpltr < 0) |
2468 | { | |
2469 | as_bad (_("Invalid Compare/Subtract Condition")); | |
2470 | cmpltr = 0; | |
2471 | } | |
2472 | else | |
2473 | { | |
a28a3ccf | 2474 | /* Negated condition requires an opcode change. */ |
55a914bc JL |
2475 | opcode |= 1 << 27; |
2476 | } | |
2477 | } | |
2478 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); | |
252b5132 | 2479 | |
55a914bc | 2480 | /* Handle branch on bit conditions. */ |
9a913dfb | 2481 | case 'B': |
55a914bc JL |
2482 | case 'b': |
2483 | cmpltr = 0; | |
2484 | if (*s == ',') | |
2485 | { | |
2486 | s++; | |
9a913dfb JL |
2487 | |
2488 | if (*args == 'B') | |
2489 | { | |
2490 | if (*s == '*') | |
2491 | s++; | |
2492 | else | |
2493 | break; | |
2494 | } | |
17d9105c JL |
2495 | else if (*s == '*') |
2496 | break; | |
9a913dfb | 2497 | |
55a914bc JL |
2498 | if (strncmp (s, "<", 1) == 0) |
2499 | { | |
2500 | cmpltr = 0; | |
2501 | s++; | |
2502 | } | |
2503 | else if (strncmp (s, ">=", 2) == 0) | |
2504 | { | |
2505 | cmpltr = 1; | |
2506 | s += 2; | |
2507 | } | |
2508 | else | |
2509 | as_bad (_("Invalid Bit Branch Condition: %c"), *s); | |
2510 | } | |
2511 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 15); | |
252b5132 | 2512 | |
55a914bc | 2513 | /* Handle a compare/subtract condition. */ |
9a913dfb | 2514 | case 'S': |
55a914bc JL |
2515 | case 's': |
2516 | cmpltr = 0; | |
2517 | flag = 0; | |
2518 | if (*s == ',') | |
2519 | { | |
2520 | s++; | |
9a913dfb JL |
2521 | |
2522 | /* 64 bit conditions. */ | |
2523 | if (*args == 'S') | |
d53d2751 | 2524 | { |
9a913dfb JL |
2525 | if (*s == '*') |
2526 | s++; | |
2527 | else | |
2528 | break; | |
d53d2751 | 2529 | } |
17d9105c JL |
2530 | else if (*s == '*') |
2531 | break; | |
55a914bc | 2532 | name = s; |
d53d2751 | 2533 | |
680ef6de | 2534 | name = s; |
55a914bc JL |
2535 | while (*s != ',' && *s != ' ' && *s != '\t') |
2536 | s += 1; | |
2537 | c = *s; | |
2538 | *s = 0x00; | |
2539 | if (strcmp (name, "=") == 0) | |
2540 | cmpltr = 1; | |
2541 | else if (strcmp (name, "<") == 0) | |
2542 | cmpltr = 2; | |
2543 | else if (strcmp (name, "<=") == 0) | |
2544 | cmpltr = 3; | |
2545 | else if (strcasecmp (name, "<<") == 0) | |
2546 | cmpltr = 4; | |
2547 | else if (strcasecmp (name, "<<=") == 0) | |
2548 | cmpltr = 5; | |
2549 | else if (strcasecmp (name, "sv") == 0) | |
2550 | cmpltr = 6; | |
2551 | else if (strcasecmp (name, "od") == 0) | |
2552 | cmpltr = 7; | |
2553 | else if (strcasecmp (name, "tr") == 0) | |
2554 | { | |
2555 | cmpltr = 0; | |
2556 | flag = 1; | |
2557 | } | |
2558 | else if (strcmp (name, "<>") == 0) | |
2559 | { | |
2560 | cmpltr = 1; | |
2561 | flag = 1; | |
2562 | } | |
2563 | else if (strcmp (name, ">=") == 0) | |
2564 | { | |
2565 | cmpltr = 2; | |
2566 | flag = 1; | |
2567 | } | |
2568 | else if (strcmp (name, ">") == 0) | |
2569 | { | |
2570 | cmpltr = 3; | |
2571 | flag = 1; | |
2572 | } | |
2573 | else if (strcasecmp (name, ">>=") == 0) | |
2574 | { | |
2575 | cmpltr = 4; | |
2576 | flag = 1; | |
2577 | } | |
2578 | else if (strcasecmp (name, ">>") == 0) | |
2579 | { | |
2580 | cmpltr = 5; | |
2581 | flag = 1; | |
2582 | } | |
2583 | else if (strcasecmp (name, "nsv") == 0) | |
2584 | { | |
2585 | cmpltr = 6; | |
2586 | flag = 1; | |
2587 | } | |
2588 | else if (strcasecmp (name, "ev") == 0) | |
2589 | { | |
2590 | cmpltr = 7; | |
2591 | flag = 1; | |
2592 | } | |
9a913dfb JL |
2593 | /* ",*" is a valid condition. */ |
2594 | else if (*args != 'S') | |
55a914bc JL |
2595 | as_bad (_("Invalid Compare/Subtract Condition: %s"), |
2596 | name); | |
2597 | *s = c; | |
2598 | } | |
2599 | opcode |= cmpltr << 13; | |
2600 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); | |
252b5132 | 2601 | |
55a914bc JL |
2602 | /* Handle a non-negated compare condition. */ |
2603 | case 't': | |
677537c1 | 2604 | cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s); |
55a914bc JL |
2605 | if (cmpltr < 0) |
2606 | { | |
677537c1 | 2607 | as_bad (_("Invalid Compare/Subtract Condition")); |
55a914bc JL |
2608 | cmpltr = 0; |
2609 | } | |
2610 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); | |
9a913dfb | 2611 | |
d53d2751 | 2612 | /* Handle a 32 bit compare and branch condition. */ |
55a914bc JL |
2613 | case 'n': |
2614 | save_s = s; | |
677537c1 | 2615 | cmpltr = pa_parse_nonneg_cmpsub_cmpltr (&s); |
55a914bc JL |
2616 | if (cmpltr < 0) |
2617 | { | |
2618 | s = save_s; | |
677537c1 | 2619 | cmpltr = pa_parse_neg_cmpsub_cmpltr (&s); |
55a914bc JL |
2620 | if (cmpltr < 0) |
2621 | { | |
677537c1 | 2622 | as_bad (_("Invalid Compare and Branch Condition")); |
55a914bc JL |
2623 | cmpltr = 0; |
2624 | } | |
2625 | else | |
2626 | { | |
a28a3ccf | 2627 | /* Negated condition requires an opcode change. */ |
55a914bc JL |
2628 | opcode |= 1 << 27; |
2629 | } | |
2630 | } | |
d53d2751 JL |
2631 | |
2632 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); | |
2633 | ||
2634 | /* Handle a 64 bit compare and branch condition. */ | |
2635 | case 'N': | |
2636 | cmpltr = pa_parse_cmpb_64_cmpltr (&s); | |
2637 | if (cmpltr >= 0) | |
2638 | { | |
a28a3ccf | 2639 | /* Negated condition requires an opcode change. */ |
d53d2751 JL |
2640 | opcode |= (cmpltr & 8) << 26; |
2641 | } | |
2642 | else | |
a28a3ccf | 2643 | /* Not a 64 bit cond. Give 32 bit a chance. */ |
d53d2751 JL |
2644 | break; |
2645 | ||
2646 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr & 7, 13); | |
2647 | ||
2648 | /* Handle a 64 bit cmpib condition. */ | |
2649 | case 'Q': | |
2650 | cmpltr = pa_parse_cmpib_64_cmpltr (&s); | |
2651 | if (cmpltr < 0) | |
a28a3ccf | 2652 | /* Not a 64 bit cond. Give 32 bit a chance. */ |
d53d2751 JL |
2653 | break; |
2654 | ||
55a914bc JL |
2655 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); |
2656 | ||
2657 | /* Handle a logical instruction condition. */ | |
9a913dfb | 2658 | case 'L': |
55a914bc JL |
2659 | case 'l': |
2660 | cmpltr = 0; | |
2661 | flag = 0; | |
2662 | if (*s == ',') | |
2663 | { | |
2664 | s++; | |
9a913dfb JL |
2665 | |
2666 | /* 64 bit conditions. */ | |
2667 | if (*args == 'L') | |
2668 | { | |
2669 | if (*s == '*') | |
2670 | s++; | |
2671 | else | |
2672 | break; | |
2673 | } | |
17d9105c JL |
2674 | else if (*s == '*') |
2675 | break; | |
d53d2751 | 2676 | |
680ef6de | 2677 | name = s; |
55a914bc JL |
2678 | while (*s != ',' && *s != ' ' && *s != '\t') |
2679 | s += 1; | |
2680 | c = *s; | |
2681 | *s = 0x00; | |
d53d2751 | 2682 | |
55a914bc JL |
2683 | if (strcmp (name, "=") == 0) |
2684 | cmpltr = 1; | |
2685 | else if (strcmp (name, "<") == 0) | |
2686 | cmpltr = 2; | |
2687 | else if (strcmp (name, "<=") == 0) | |
2688 | cmpltr = 3; | |
2689 | else if (strcasecmp (name, "od") == 0) | |
2690 | cmpltr = 7; | |
2691 | else if (strcasecmp (name, "tr") == 0) | |
2692 | { | |
2693 | cmpltr = 0; | |
2694 | flag = 1; | |
2695 | } | |
2696 | else if (strcmp (name, "<>") == 0) | |
2697 | { | |
2698 | cmpltr = 1; | |
2699 | flag = 1; | |
2700 | } | |
2701 | else if (strcmp (name, ">=") == 0) | |
2702 | { | |
2703 | cmpltr = 2; | |
2704 | flag = 1; | |
2705 | } | |
2706 | else if (strcmp (name, ">") == 0) | |
2707 | { | |
2708 | cmpltr = 3; | |
2709 | flag = 1; | |
2710 | } | |
2711 | else if (strcasecmp (name, "ev") == 0) | |
2712 | { | |
2713 | cmpltr = 7; | |
2714 | flag = 1; | |
2715 | } | |
9a913dfb JL |
2716 | /* ",*" is a valid condition. */ |
2717 | else if (*args != 'L') | |
55a914bc JL |
2718 | as_bad (_("Invalid Logical Instruction Condition.")); |
2719 | *s = c; | |
2720 | } | |
2721 | opcode |= cmpltr << 13; | |
2722 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); | |
2723 | ||
2724 | /* Handle a shift/extract/deposit condition. */ | |
9a913dfb | 2725 | case 'X': |
55a914bc JL |
2726 | case 'x': |
2727 | case 'y': | |
2728 | cmpltr = 0; | |
2729 | if (*s == ',') | |
2730 | { | |
2731 | save_s = s++; | |
2732 | ||
9a913dfb JL |
2733 | /* 64 bit conditions. */ |
2734 | if (*args == 'X') | |
2735 | { | |
2736 | if (*s == '*') | |
2737 | s++; | |
2738 | else | |
2739 | break; | |
2740 | } | |
17d9105c JL |
2741 | else if (*s == '*') |
2742 | break; | |
d53d2751 | 2743 | |
680ef6de | 2744 | name = s; |
55a914bc JL |
2745 | while (*s != ',' && *s != ' ' && *s != '\t') |
2746 | s += 1; | |
2747 | c = *s; | |
2748 | *s = 0x00; | |
2749 | if (strcmp (name, "=") == 0) | |
2750 | cmpltr = 1; | |
2751 | else if (strcmp (name, "<") == 0) | |
2752 | cmpltr = 2; | |
2753 | else if (strcasecmp (name, "od") == 0) | |
2754 | cmpltr = 3; | |
2755 | else if (strcasecmp (name, "tr") == 0) | |
2756 | cmpltr = 4; | |
2757 | else if (strcmp (name, "<>") == 0) | |
2758 | cmpltr = 5; | |
2759 | else if (strcmp (name, ">=") == 0) | |
2760 | cmpltr = 6; | |
2761 | else if (strcasecmp (name, "ev") == 0) | |
2762 | cmpltr = 7; | |
2763 | /* Handle movb,n. Put things back the way they were. | |
2764 | This includes moving s back to where it started. */ | |
2765 | else if (strcasecmp (name, "n") == 0 && *args == 'y') | |
2766 | { | |
2767 | *s = c; | |
2768 | s = save_s; | |
2769 | continue; | |
2770 | } | |
9a913dfb JL |
2771 | /* ",*" is a valid condition. */ |
2772 | else if (*args != 'X') | |
55a914bc JL |
2773 | as_bad (_("Invalid Shift/Extract/Deposit Condition.")); |
2774 | *s = c; | |
2775 | } | |
2776 | INSERT_FIELD_AND_CONTINUE (opcode, cmpltr, 13); | |
252b5132 | 2777 | |
55a914bc | 2778 | /* Handle a unit instruction condition. */ |
9a913dfb JL |
2779 | case 'U': |
2780 | case 'u': | |
55a914bc JL |
2781 | cmpltr = 0; |
2782 | flag = 0; | |
2783 | if (*s == ',') | |
2784 | { | |
2785 | s++; | |
d53d2751 | 2786 | |
9a913dfb JL |
2787 | /* 64 bit conditions. */ |
2788 | if (*args == 'U') | |
2789 | { | |
2790 | if (*s == '*') | |
2791 | s++; | |
2792 | else | |
2793 | break; | |
2794 | } | |
17d9105c JL |
2795 | else if (*s == '*') |
2796 | break; | |
d53d2751 | 2797 | |
55a914bc JL |
2798 | if (strncasecmp (s, "sbz", 3) == 0) |
2799 | { | |
2800 | cmpltr = 2; | |
2801 | s += 3; | |
2802 | } | |
2803 | else if (strncasecmp (s, "shz", 3) == 0) | |
2804 | { | |
2805 | cmpltr = 3; | |
2806 | s += 3; | |
2807 | } | |
2808 | else if (strncasecmp (s, "sdc", 3) == 0) | |
2809 | { | |
2810 | cmpltr = 4; | |
2811 | s += 3; | |
2812 | } | |
2813 | else if (strncasecmp (s, "sbc", 3) == 0) | |
2814 | { | |
2815 | cmpltr = 6; | |
2816 | s += 3; | |
2817 | } | |
2818 | else if (strncasecmp (s, "shc", 3) == 0) | |
2819 | { | |
2820 | cmpltr = 7; | |
2821 | s += 3; | |
2822 | } | |
2823 | else if (strncasecmp (s, "tr", 2) == 0) | |
2824 | { | |
2825 | cmpltr = 0; | |
2826 | flag = 1; | |
2827 | s += 2; | |
2828 | } | |
2829 | else if (strncasecmp (s, "nbz", 3) == 0) | |
2830 | { | |
2831 | cmpltr = 2; | |
2832 | flag = 1; | |
2833 | s += 3; | |
2834 | } | |
2835 | else if (strncasecmp (s, "nhz", 3) == 0) | |
2836 | { | |
2837 | cmpltr = 3; | |
2838 | flag = 1; | |
2839 | s += 3; | |
2840 | } | |
2841 | else if (strncasecmp (s, "ndc", 3) == 0) | |
2842 | { | |
2843 | cmpltr = 4; | |
2844 | flag = 1; | |
2845 | s += 3; | |
2846 | } | |
2847 | else if (strncasecmp (s, "nbc", 3) == 0) | |
2848 | { | |
2849 | cmpltr = 6; | |
2850 | flag = 1; | |
2851 | s += 3; | |
2852 | } | |
2853 | else if (strncasecmp (s, "nhc", 3) == 0) | |
2854 | { | |
2855 | cmpltr = 7; | |
2856 | flag = 1; | |
2857 | s += 3; | |
2858 | } | |
afbf211f JL |
2859 | else if (strncasecmp (s, "swz", 3) == 0) |
2860 | { | |
2861 | cmpltr = 1; | |
2862 | flag = 0; | |
2863 | s += 3; | |
2864 | } | |
2865 | else if (strncasecmp (s, "swc", 3) == 0) | |
2866 | { | |
2867 | cmpltr = 5; | |
2868 | flag = 0; | |
2869 | s += 3; | |
2870 | } | |
2871 | else if (strncasecmp (s, "nwz", 3) == 0) | |
2872 | { | |
2873 | cmpltr = 1; | |
2874 | flag = 1; | |
2875 | s += 3; | |
2876 | } | |
2877 | else if (strncasecmp (s, "nwc", 3) == 0) | |
2878 | { | |
2879 | cmpltr = 5; | |
2880 | flag = 1; | |
2881 | s += 3; | |
2882 | } | |
9a913dfb JL |
2883 | /* ",*" is a valid condition. */ |
2884 | else if (*args != 'U') | |
55a914bc JL |
2885 | as_bad (_("Invalid Unit Instruction Condition.")); |
2886 | } | |
2887 | opcode |= cmpltr << 13; | |
2888 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 12); | |
252b5132 | 2889 | |
55a914bc JL |
2890 | default: |
2891 | abort (); | |
2892 | } | |
0741736b | 2893 | break; |
55a914bc | 2894 | } |
252b5132 | 2895 | |
252b5132 RH |
2896 | /* Handle a nullification completer for branch instructions. */ |
2897 | case 'n': | |
2898 | nullif = pa_parse_nullif (&s); | |
2899 | INSERT_FIELD_AND_CONTINUE (opcode, nullif, 1); | |
2900 | ||
2901 | /* Handle a nullification completer for copr and spop insns. */ | |
2902 | case 'N': | |
2903 | nullif = pa_parse_nullif (&s); | |
2904 | INSERT_FIELD_AND_CONTINUE (opcode, nullif, 5); | |
2905 | ||
dbe2f9ee JL |
2906 | /* Handle ,%r2 completer for new syntax branches. */ |
2907 | case 'L': | |
54af6ff6 | 2908 | if (*s == ',' && strncasecmp (s + 1, "%r2", 3) == 0) |
dbe2f9ee | 2909 | s += 4; |
54af6ff6 | 2910 | else if (*s == ',' && strncasecmp (s + 1, "%rp", 3) == 0) |
dbe2f9ee JL |
2911 | s += 4; |
2912 | else | |
2913 | break; | |
2914 | continue; | |
2915 | ||
1cf6ae67 JL |
2916 | /* Handle 3 bit entry into the fp compare array. Valid values |
2917 | are 0..6 inclusive. */ | |
2918 | case 'h': | |
2919 | get_expression (s); | |
2920 | s = expr_end; | |
2921 | if (the_insn.exp.X_op == O_constant) | |
2922 | { | |
2923 | num = evaluate_absolute (&the_insn); | |
2924 | CHECK_FIELD (num, 6, 0, 0); | |
2925 | num++; | |
2926 | INSERT_FIELD_AND_CONTINUE (opcode, num, 13); | |
2927 | } | |
2928 | else | |
2929 | break; | |
2930 | ||
2931 | /* Handle 3 bit entry into the fp compare array. Valid values | |
2932 | are 0..6 inclusive. */ | |
2933 | case 'm': | |
2934 | get_expression (s); | |
1cf6ae67 JL |
2935 | if (the_insn.exp.X_op == O_constant) |
2936 | { | |
b1039fc4 | 2937 | s = expr_end; |
1cf6ae67 JL |
2938 | num = evaluate_absolute (&the_insn); |
2939 | CHECK_FIELD (num, 6, 0, 0); | |
2940 | num = (num + 1) ^ 1; | |
2941 | INSERT_FIELD_AND_CONTINUE (opcode, num, 13); | |
2942 | } | |
2943 | else | |
b1039fc4 | 2944 | break; |
1cf6ae67 JL |
2945 | |
2946 | /* Handle graphics test completers for ftest */ | |
2947 | case '=': | |
2948 | { | |
2949 | num = pa_parse_ftest_gfx_completer (&s); | |
2950 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
2951 | } | |
2952 | ||
252b5132 RH |
2953 | /* Handle a 11 bit immediate at 31. */ |
2954 | case 'i': | |
2955 | the_insn.field_selector = pa_chk_field_selector (&s); | |
2956 | get_expression (s); | |
2957 | s = expr_end; | |
2958 | if (the_insn.exp.X_op == O_constant) | |
2959 | { | |
2960 | num = evaluate_absolute (&the_insn); | |
2961 | CHECK_FIELD (num, 1023, -1024, 0); | |
3f9b03b5 | 2962 | num = low_sign_unext (num, 11); |
252b5132 RH |
2963 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); |
2964 | } | |
2965 | else | |
2966 | { | |
2967 | if (is_DP_relative (the_insn.exp)) | |
2968 | the_insn.reloc = R_HPPA_GOTOFF; | |
2969 | else if (is_PC_relative (the_insn.exp)) | |
2970 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
2971 | else | |
2972 | the_insn.reloc = R_HPPA; | |
2973 | the_insn.format = 11; | |
2974 | continue; | |
2975 | } | |
2976 | ||
65fab780 JL |
2977 | /* Handle a 14 bit immediate at 31. */ |
2978 | case 'J': | |
2979 | the_insn.field_selector = pa_chk_field_selector (&s); | |
2980 | get_expression (s); | |
2981 | s = expr_end; | |
2982 | if (the_insn.exp.X_op == O_constant) | |
2983 | { | |
1328dc98 | 2984 | int mb; |
65fab780 | 2985 | |
1328dc98 | 2986 | /* XXX the completer stored away tidbits of information |
65fab780 JL |
2987 | for us to extract. We need a cleaner way to do this. |
2988 | Now that we have lots of letters again, it would be | |
2989 | good to rethink this. */ | |
1328dc98 AM |
2990 | mb = opcode & 1; |
2991 | opcode -= mb; | |
65fab780 | 2992 | num = evaluate_absolute (&the_insn); |
1328dc98 | 2993 | if (mb != (num < 0)) |
65fab780 JL |
2994 | break; |
2995 | CHECK_FIELD (num, 8191, -8192, 0); | |
3f9b03b5 | 2996 | num = low_sign_unext (num, 14); |
65fab780 JL |
2997 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); |
2998 | } | |
1328dc98 | 2999 | break; |
65fab780 JL |
3000 | |
3001 | /* Handle a 14 bit immediate at 31. */ | |
3002 | case 'K': | |
3003 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3004 | get_expression (s); | |
3005 | s = expr_end; | |
3006 | if (the_insn.exp.X_op == O_constant) | |
3007 | { | |
1328dc98 | 3008 | int mb; |
65fab780 | 3009 | |
1328dc98 AM |
3010 | mb = opcode & 1; |
3011 | opcode -= mb; | |
65fab780 | 3012 | num = evaluate_absolute (&the_insn); |
1328dc98 | 3013 | if (mb == (num < 0)) |
65fab780 JL |
3014 | break; |
3015 | if (num % 4) | |
3016 | break; | |
3017 | CHECK_FIELD (num, 8191, -8192, 0); | |
1328dc98 AM |
3018 | num = low_sign_unext (num, 14); |
3019 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
65fab780 | 3020 | } |
1328dc98 AM |
3021 | break; |
3022 | ||
3023 | /* Handle a 16 bit immediate at 31. */ | |
3024 | case '<': | |
3025 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3026 | get_expression (s); | |
3027 | s = expr_end; | |
3028 | if (the_insn.exp.X_op == O_constant) | |
65fab780 | 3029 | { |
1328dc98 AM |
3030 | int mb; |
3031 | ||
3032 | mb = opcode & 1; | |
3033 | opcode -= mb; | |
3034 | num = evaluate_absolute (&the_insn); | |
3035 | if (mb != (num < 0)) | |
3036 | break; | |
3037 | CHECK_FIELD (num, 32767, -32768, 0); | |
3038 | num = re_assemble_16 (num); | |
3039 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
65fab780 | 3040 | } |
1328dc98 AM |
3041 | break; |
3042 | ||
3043 | /* Handle a 16 bit immediate at 31. */ | |
3044 | case '>': | |
3045 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3046 | get_expression (s); | |
3047 | s = expr_end; | |
3048 | if (the_insn.exp.X_op == O_constant) | |
3049 | { | |
3050 | int mb; | |
3051 | ||
3052 | mb = opcode & 1; | |
3053 | opcode -= mb; | |
3054 | num = evaluate_absolute (&the_insn); | |
3055 | if (mb == (num < 0)) | |
3056 | break; | |
3057 | if (num % 4) | |
3058 | break; | |
3059 | CHECK_FIELD (num, 32767, -32768, 0); | |
3060 | num = re_assemble_16 (num); | |
3061 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
3062 | } | |
3063 | break; | |
65fab780 | 3064 | |
ad1079af | 3065 | /* Handle 14 bit immediate, shifted left three times. */ |
61dd1d31 JL |
3066 | case '#': |
3067 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3068 | get_expression (s); | |
3069 | s = expr_end; | |
3070 | if (the_insn.exp.X_op == O_constant) | |
3071 | { | |
3072 | num = evaluate_absolute (&the_insn); | |
3073 | if (num & 0x7) | |
3074 | break; | |
3075 | CHECK_FIELD (num, 8191, -8192, 0); | |
3076 | if (num < 0) | |
3077 | opcode |= 1; | |
3078 | num &= 0x1fff; | |
3079 | num >>= 3; | |
3080 | INSERT_FIELD_AND_CONTINUE (opcode, num, 4); | |
3081 | } | |
3082 | else | |
3083 | { | |
3084 | if (is_DP_relative (the_insn.exp)) | |
3085 | the_insn.reloc = R_HPPA_GOTOFF; | |
3086 | else if (is_PC_relative (the_insn.exp)) | |
3087 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3088 | else | |
3089 | the_insn.reloc = R_HPPA; | |
3090 | the_insn.format = 14; | |
3091 | continue; | |
3092 | } | |
3093 | break; | |
3094 | ||
3095 | /* Handle 14 bit immediate, shifted left twice. */ | |
3096 | case 'd': | |
3097 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3098 | get_expression (s); | |
3099 | s = expr_end; | |
3100 | if (the_insn.exp.X_op == O_constant) | |
3101 | { | |
3102 | num = evaluate_absolute (&the_insn); | |
3103 | if (num & 0x3) | |
3104 | break; | |
3105 | CHECK_FIELD (num, 8191, -8192, 0); | |
3106 | if (num < 0) | |
3107 | opcode |= 1; | |
3108 | num &= 0x1fff; | |
3109 | num >>= 2; | |
3110 | INSERT_FIELD_AND_CONTINUE (opcode, num, 3); | |
3111 | } | |
3112 | else | |
3113 | { | |
3114 | if (is_DP_relative (the_insn.exp)) | |
3115 | the_insn.reloc = R_HPPA_GOTOFF; | |
3116 | else if (is_PC_relative (the_insn.exp)) | |
3117 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3118 | else | |
3119 | the_insn.reloc = R_HPPA; | |
3120 | the_insn.format = 14; | |
3121 | continue; | |
3122 | } | |
252b5132 RH |
3123 | |
3124 | /* Handle a 14 bit immediate at 31. */ | |
3125 | case 'j': | |
3126 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3127 | get_expression (s); | |
3128 | s = expr_end; | |
3129 | if (the_insn.exp.X_op == O_constant) | |
3130 | { | |
3131 | num = evaluate_absolute (&the_insn); | |
3132 | CHECK_FIELD (num, 8191, -8192, 0); | |
3f9b03b5 | 3133 | num = low_sign_unext (num, 14); |
252b5132 RH |
3134 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); |
3135 | } | |
3136 | else | |
3137 | { | |
3138 | if (is_DP_relative (the_insn.exp)) | |
3139 | the_insn.reloc = R_HPPA_GOTOFF; | |
3140 | else if (is_PC_relative (the_insn.exp)) | |
3141 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3142 | else | |
3143 | the_insn.reloc = R_HPPA; | |
3144 | the_insn.format = 14; | |
3145 | continue; | |
3146 | } | |
3147 | ||
3148 | /* Handle a 21 bit immediate at 31. */ | |
3149 | case 'k': | |
3150 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3151 | get_expression (s); | |
3152 | s = expr_end; | |
3153 | if (the_insn.exp.X_op == O_constant) | |
3154 | { | |
3155 | num = evaluate_absolute (&the_insn); | |
3156 | CHECK_FIELD (num >> 11, 1048575, -1048576, 0); | |
ad1079af | 3157 | opcode |= re_assemble_21 (num); |
3f9b03b5 | 3158 | continue; |
252b5132 RH |
3159 | } |
3160 | else | |
3161 | { | |
3162 | if (is_DP_relative (the_insn.exp)) | |
3163 | the_insn.reloc = R_HPPA_GOTOFF; | |
3164 | else if (is_PC_relative (the_insn.exp)) | |
3165 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3166 | else | |
3167 | the_insn.reloc = R_HPPA; | |
3168 | the_insn.format = 21; | |
3169 | continue; | |
3170 | } | |
3171 | ||
a02fab7e JL |
3172 | /* Handle a 16 bit immediate at 31 (PA 2.0 wide mode only). */ |
3173 | case 'l': | |
3174 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3175 | get_expression (s); | |
3176 | s = expr_end; | |
3177 | if (the_insn.exp.X_op == O_constant) | |
3178 | { | |
a02fab7e JL |
3179 | num = evaluate_absolute (&the_insn); |
3180 | CHECK_FIELD (num, 32767, -32768, 0); | |
ad1079af | 3181 | opcode |= re_assemble_16 (num); |
3f9b03b5 | 3182 | continue; |
a02fab7e JL |
3183 | } |
3184 | else | |
3185 | { | |
3186 | /* ??? Is this valid for wide mode? */ | |
3187 | if (is_DP_relative (the_insn.exp)) | |
3188 | the_insn.reloc = R_HPPA_GOTOFF; | |
3189 | else if (is_PC_relative (the_insn.exp)) | |
3190 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3191 | else | |
3192 | the_insn.reloc = R_HPPA; | |
3193 | the_insn.format = 14; | |
3194 | continue; | |
3195 | } | |
3196 | ||
3197 | /* Handle a word-aligned 16-bit imm. at 31 (PA2.0 wide). */ | |
3198 | case 'y': | |
3199 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3200 | get_expression (s); | |
3201 | s = expr_end; | |
3202 | if (the_insn.exp.X_op == O_constant) | |
3203 | { | |
a02fab7e JL |
3204 | num = evaluate_absolute (&the_insn); |
3205 | CHECK_FIELD (num, 32767, -32768, 0); | |
3206 | CHECK_ALIGN (num, 4, 0); | |
ad1079af | 3207 | opcode |= re_assemble_16 (num); |
3f9b03b5 | 3208 | continue; |
a02fab7e JL |
3209 | } |
3210 | else | |
3211 | { | |
3212 | /* ??? Is this valid for wide mode? */ | |
3213 | if (is_DP_relative (the_insn.exp)) | |
3214 | the_insn.reloc = R_HPPA_GOTOFF; | |
3215 | else if (is_PC_relative (the_insn.exp)) | |
3216 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3217 | else | |
3218 | the_insn.reloc = R_HPPA; | |
3219 | the_insn.format = 14; | |
3220 | continue; | |
3221 | } | |
3222 | ||
3223 | /* Handle a dword-aligned 16-bit imm. at 31 (PA2.0 wide). */ | |
3224 | case '&': | |
3225 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3226 | get_expression (s); | |
3227 | s = expr_end; | |
3228 | if (the_insn.exp.X_op == O_constant) | |
3229 | { | |
a02fab7e JL |
3230 | num = evaluate_absolute (&the_insn); |
3231 | CHECK_FIELD (num, 32767, -32768, 0); | |
3232 | CHECK_ALIGN (num, 8, 0); | |
ad1079af | 3233 | opcode |= re_assemble_16 (num); |
3f9b03b5 | 3234 | continue; |
a02fab7e JL |
3235 | } |
3236 | else | |
3237 | { | |
3238 | /* ??? Is this valid for wide mode? */ | |
3239 | if (is_DP_relative (the_insn.exp)) | |
3240 | the_insn.reloc = R_HPPA_GOTOFF; | |
3241 | else if (is_PC_relative (the_insn.exp)) | |
3242 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3243 | else | |
3244 | the_insn.reloc = R_HPPA; | |
3245 | the_insn.format = 14; | |
3246 | continue; | |
3247 | } | |
3248 | ||
252b5132 RH |
3249 | /* Handle a 12 bit branch displacement. */ |
3250 | case 'w': | |
3251 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3252 | get_expression (s); | |
3253 | s = expr_end; | |
3254 | the_insn.pcrel = 1; | |
22862cde AM |
3255 | if (!the_insn.exp.X_add_symbol |
3256 | || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), | |
ec8b3afd | 3257 | FAKE_LABEL_NAME)) |
252b5132 | 3258 | { |
252b5132 RH |
3259 | num = evaluate_absolute (&the_insn); |
3260 | if (num % 4) | |
3261 | { | |
3262 | as_bad (_("Branch to unaligned address")); | |
3263 | break; | |
3264 | } | |
22862cde AM |
3265 | if (the_insn.exp.X_add_symbol) |
3266 | num -= 8; | |
3267 | CHECK_FIELD (num, 8191, -8192, 0); | |
3268 | opcode |= re_assemble_12 (num >> 2); | |
3f9b03b5 | 3269 | continue; |
252b5132 RH |
3270 | } |
3271 | else | |
3272 | { | |
3273 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3274 | the_insn.format = 12; | |
3275 | the_insn.arg_reloc = last_call_desc.arg_reloc; | |
3276 | memset (&last_call_desc, 0, sizeof (struct call_desc)); | |
3277 | s = expr_end; | |
3278 | continue; | |
3279 | } | |
3280 | ||
3281 | /* Handle a 17 bit branch displacement. */ | |
3282 | case 'W': | |
3283 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3284 | get_expression (s); | |
3285 | s = expr_end; | |
3286 | the_insn.pcrel = 1; | |
3287 | if (!the_insn.exp.X_add_symbol | |
3288 | || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), | |
ec8b3afd | 3289 | FAKE_LABEL_NAME)) |
252b5132 | 3290 | { |
252b5132 RH |
3291 | num = evaluate_absolute (&the_insn); |
3292 | if (num % 4) | |
3293 | { | |
3294 | as_bad (_("Branch to unaligned address")); | |
3295 | break; | |
3296 | } | |
252b5132 RH |
3297 | if (the_insn.exp.X_add_symbol) |
3298 | num -= 8; | |
22862cde | 3299 | CHECK_FIELD (num, 262143, -262144, 0); |
ad1079af | 3300 | opcode |= re_assemble_17 (num >> 2); |
3f9b03b5 | 3301 | continue; |
252b5132 RH |
3302 | } |
3303 | else | |
3304 | { | |
3305 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3306 | the_insn.format = 17; | |
3307 | the_insn.arg_reloc = last_call_desc.arg_reloc; | |
3308 | memset (&last_call_desc, 0, sizeof (struct call_desc)); | |
3309 | continue; | |
3310 | } | |
3311 | ||
77c02e18 JL |
3312 | /* Handle a 22 bit branch displacement. */ |
3313 | case 'X': | |
3314 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3315 | get_expression (s); | |
3316 | s = expr_end; | |
3317 | the_insn.pcrel = 1; | |
3318 | if (!the_insn.exp.X_add_symbol | |
3319 | || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), | |
ec8b3afd | 3320 | FAKE_LABEL_NAME)) |
77c02e18 | 3321 | { |
77c02e18 JL |
3322 | num = evaluate_absolute (&the_insn); |
3323 | if (num % 4) | |
3324 | { | |
3325 | as_bad (_("Branch to unaligned address")); | |
3326 | break; | |
3327 | } | |
77c02e18 JL |
3328 | if (the_insn.exp.X_add_symbol) |
3329 | num -= 8; | |
22862cde | 3330 | CHECK_FIELD (num, 8388607, -8388608, 0); |
ad1079af | 3331 | opcode |= re_assemble_22 (num >> 2); |
77c02e18 JL |
3332 | } |
3333 | else | |
3334 | { | |
3335 | the_insn.reloc = R_HPPA_PCREL_CALL; | |
3336 | the_insn.format = 22; | |
3337 | the_insn.arg_reloc = last_call_desc.arg_reloc; | |
3338 | memset (&last_call_desc, 0, sizeof (struct call_desc)); | |
3339 | continue; | |
3340 | } | |
3341 | ||
252b5132 RH |
3342 | /* Handle an absolute 17 bit branch target. */ |
3343 | case 'z': | |
3344 | the_insn.field_selector = pa_chk_field_selector (&s); | |
3345 | get_expression (s); | |
3346 | s = expr_end; | |
3347 | the_insn.pcrel = 0; | |
3348 | if (!the_insn.exp.X_add_symbol | |
3349 | || !strcmp (S_GET_NAME (the_insn.exp.X_add_symbol), | |
ec8b3afd | 3350 | FAKE_LABEL_NAME)) |
252b5132 | 3351 | { |
252b5132 RH |
3352 | num = evaluate_absolute (&the_insn); |
3353 | if (num % 4) | |
3354 | { | |
3355 | as_bad (_("Branch to unaligned address")); | |
3356 | break; | |
3357 | } | |
252b5132 RH |
3358 | if (the_insn.exp.X_add_symbol) |
3359 | num -= 8; | |
22862cde | 3360 | CHECK_FIELD (num, 262143, -262144, 0); |
ad1079af | 3361 | opcode |= re_assemble_17 (num >> 2); |
3f9b03b5 | 3362 | continue; |
252b5132 RH |
3363 | } |
3364 | else | |
3365 | { | |
3366 | the_insn.reloc = R_HPPA_ABS_CALL; | |
3367 | the_insn.format = 17; | |
3368 | the_insn.arg_reloc = last_call_desc.arg_reloc; | |
3369 | memset (&last_call_desc, 0, sizeof (struct call_desc)); | |
3370 | continue; | |
3371 | } | |
3372 | ||
4964086a JL |
3373 | /* Handle '%r1' implicit operand of addil instruction. */ |
3374 | case 'Z': | |
3375 | if (*s == ',' && *(s + 1) == '%' && *(s + 3) == '1' | |
3376 | && (*(s + 2) == 'r' || *(s + 2) == 'R')) | |
3377 | { | |
3378 | s += 4; | |
3379 | continue; | |
3380 | } | |
3381 | else | |
3382 | break; | |
3383 | ||
ce674324 JL |
3384 | /* Handle '%sr0,%r31' implicit operand of be,l instruction. */ |
3385 | case 'Y': | |
3386 | if (strncasecmp (s, "%sr0,%r31", 9) != 0) | |
3387 | break; | |
3388 | s += 9; | |
3389 | continue; | |
3390 | ||
d53d2751 JL |
3391 | /* Handle immediate value of 0 for ordered load/store instructions. */ |
3392 | case '@': | |
3393 | if (*s != '0') | |
3394 | break; | |
3395 | s++; | |
3396 | continue; | |
3397 | ||
a97685e9 JL |
3398 | /* Handle a 2 bit shift count at 25. */ |
3399 | case '.': | |
3400 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3401 | if (strict && the_insn.exp.X_op != O_constant) |
3402 | break; | |
a97685e9 | 3403 | s = expr_end; |
0f4f8b56 | 3404 | CHECK_FIELD (num, 3, 1, strict); |
a97685e9 JL |
3405 | INSERT_FIELD_AND_CONTINUE (opcode, num, 6); |
3406 | ||
413c94ba JL |
3407 | /* Handle a 4 bit shift count at 25. */ |
3408 | case '*': | |
3409 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3410 | if (strict && the_insn.exp.X_op != O_constant) |
3411 | break; | |
413c94ba | 3412 | s = expr_end; |
0f4f8b56 | 3413 | CHECK_FIELD (num, 15, 0, strict); |
413c94ba JL |
3414 | INSERT_FIELD_AND_CONTINUE (opcode, num, 6); |
3415 | ||
252b5132 RH |
3416 | /* Handle a 5 bit shift count at 26. */ |
3417 | case 'p': | |
3418 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3419 | if (strict && the_insn.exp.X_op != O_constant) |
3420 | break; | |
252b5132 | 3421 | s = expr_end; |
0f4f8b56 | 3422 | CHECK_FIELD (num, 31, 0, strict); |
252b5132 RH |
3423 | INSERT_FIELD_AND_CONTINUE (opcode, 31 - num, 5); |
3424 | ||
a97685e9 JL |
3425 | /* Handle a 6 bit shift count at 20,22:26. */ |
3426 | case '~': | |
3427 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3428 | if (strict && the_insn.exp.X_op != O_constant) |
3429 | break; | |
a97685e9 | 3430 | s = expr_end; |
0f4f8b56 | 3431 | CHECK_FIELD (num, 63, 0, strict); |
a97685e9 JL |
3432 | num = 63 - num; |
3433 | opcode |= (num & 0x20) << 6; | |
3434 | INSERT_FIELD_AND_CONTINUE (opcode, num & 0x1f, 5); | |
3435 | ||
9e4f2d3a JL |
3436 | /* Handle a 6 bit field length at 23,27:31. */ |
3437 | case '%': | |
3438 | flag = 0; | |
3439 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3440 | if (strict && the_insn.exp.X_op != O_constant) |
3441 | break; | |
9e4f2d3a | 3442 | s = expr_end; |
0f4f8b56 | 3443 | CHECK_FIELD (num, 64, 1, strict); |
9e4f2d3a JL |
3444 | num--; |
3445 | opcode |= (num & 0x20) << 3; | |
3446 | num = 31 - (num & 0x1f); | |
3447 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
3448 | ||
3449 | /* Handle a 6 bit field length at 19,27:31. */ | |
3450 | case '|': | |
3451 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3452 | if (strict && the_insn.exp.X_op != O_constant) |
3453 | break; | |
9e4f2d3a | 3454 | s = expr_end; |
0f4f8b56 | 3455 | CHECK_FIELD (num, 64, 1, strict); |
9e4f2d3a JL |
3456 | num--; |
3457 | opcode |= (num & 0x20) << 7; | |
3458 | num = 31 - (num & 0x1f); | |
3459 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
3460 | ||
252b5132 RH |
3461 | /* Handle a 5 bit bit position at 26. */ |
3462 | case 'P': | |
3463 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3464 | if (strict && the_insn.exp.X_op != O_constant) |
3465 | break; | |
252b5132 | 3466 | s = expr_end; |
0f4f8b56 | 3467 | CHECK_FIELD (num, 31, 0, strict); |
252b5132 RH |
3468 | INSERT_FIELD_AND_CONTINUE (opcode, num, 5); |
3469 | ||
9e4f2d3a JL |
3470 | /* Handle a 6 bit bit position at 20,22:26. */ |
3471 | case 'q': | |
3472 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3473 | if (strict && the_insn.exp.X_op != O_constant) |
3474 | break; | |
9e4f2d3a | 3475 | s = expr_end; |
0f4f8b56 | 3476 | CHECK_FIELD (num, 63, 0, strict); |
9e4f2d3a JL |
3477 | opcode |= (num & 0x20) << 6; |
3478 | INSERT_FIELD_AND_CONTINUE (opcode, num & 0x1f, 5); | |
3479 | ||
afbf211f JL |
3480 | /* Handle a 5 bit immediate at 10 with 'd' as the complement |
3481 | of the high bit of the immediate. */ | |
3482 | case 'B': | |
3483 | num = pa_get_absolute_expression (&the_insn, &s); | |
3484 | if (strict && the_insn.exp.X_op != O_constant) | |
3485 | break; | |
3486 | s = expr_end; | |
3487 | CHECK_FIELD (num, 63, 0, strict); | |
3488 | if (num & 0x20) | |
3489 | ; | |
3490 | else | |
3491 | opcode |= (1 << 13); | |
3492 | INSERT_FIELD_AND_CONTINUE (opcode, num & 0x1f, 21); | |
3493 | ||
252b5132 RH |
3494 | /* Handle a 5 bit immediate at 10. */ |
3495 | case 'Q': | |
252b5132 | 3496 | num = pa_get_absolute_expression (&the_insn, &s); |
0f4f8b56 JL |
3497 | if (strict && the_insn.exp.X_op != O_constant) |
3498 | break; | |
252b5132 | 3499 | s = expr_end; |
0f4f8b56 | 3500 | CHECK_FIELD (num, 31, 0, strict); |
252b5132 RH |
3501 | INSERT_FIELD_AND_CONTINUE (opcode, num, 21); |
3502 | ||
a97685e9 JL |
3503 | /* Handle a 9 bit immediate at 28. */ |
3504 | case '$': | |
3505 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3506 | if (strict && the_insn.exp.X_op != O_constant) |
3507 | break; | |
a97685e9 | 3508 | s = expr_end; |
0f4f8b56 | 3509 | CHECK_FIELD (num, 511, 1, strict); |
a97685e9 | 3510 | INSERT_FIELD_AND_CONTINUE (opcode, num, 3); |
d53d2751 | 3511 | |
252b5132 RH |
3512 | /* Handle a 13 bit immediate at 18. */ |
3513 | case 'A': | |
3514 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3515 | if (strict && the_insn.exp.X_op != O_constant) |
3516 | break; | |
252b5132 | 3517 | s = expr_end; |
0f4f8b56 | 3518 | CHECK_FIELD (num, 8191, 0, strict); |
252b5132 RH |
3519 | INSERT_FIELD_AND_CONTINUE (opcode, num, 13); |
3520 | ||
3521 | /* Handle a 26 bit immediate at 31. */ | |
3522 | case 'D': | |
3523 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3524 | if (strict && the_insn.exp.X_op != O_constant) |
3525 | break; | |
252b5132 | 3526 | s = expr_end; |
0485cba3 | 3527 | CHECK_FIELD (num, 67108863, 0, strict); |
252b5132 RH |
3528 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); |
3529 | ||
3530 | /* Handle a 3 bit SFU identifier at 25. */ | |
97e1581b | 3531 | case 'v': |
252b5132 RH |
3532 | if (*s++ != ',') |
3533 | as_bad (_("Invalid SFU identifier")); | |
3534 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3535 | if (strict && the_insn.exp.X_op != O_constant) |
3536 | break; | |
252b5132 | 3537 | s = expr_end; |
0f4f8b56 | 3538 | CHECK_FIELD (num, 7, 0, strict); |
252b5132 RH |
3539 | INSERT_FIELD_AND_CONTINUE (opcode, num, 6); |
3540 | ||
3541 | /* Handle a 20 bit SOP field for spop0. */ | |
3542 | case 'O': | |
3543 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3544 | if (strict && the_insn.exp.X_op != O_constant) |
3545 | break; | |
252b5132 | 3546 | s = expr_end; |
0f4f8b56 | 3547 | CHECK_FIELD (num, 1048575, 0, strict); |
252b5132 RH |
3548 | num = (num & 0x1f) | ((num & 0x000fffe0) << 6); |
3549 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
3550 | ||
3551 | /* Handle a 15bit SOP field for spop1. */ | |
3552 | case 'o': | |
3553 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3554 | if (strict && the_insn.exp.X_op != O_constant) |
3555 | break; | |
252b5132 | 3556 | s = expr_end; |
0f4f8b56 | 3557 | CHECK_FIELD (num, 32767, 0, strict); |
252b5132 RH |
3558 | INSERT_FIELD_AND_CONTINUE (opcode, num, 11); |
3559 | ||
3560 | /* Handle a 10bit SOP field for spop3. */ | |
3561 | case '0': | |
3562 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3563 | if (strict && the_insn.exp.X_op != O_constant) |
3564 | break; | |
252b5132 | 3565 | s = expr_end; |
0f4f8b56 | 3566 | CHECK_FIELD (num, 1023, 0, strict); |
252b5132 RH |
3567 | num = (num & 0x1f) | ((num & 0x000003e0) << 6); |
3568 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
3569 | ||
3570 | /* Handle a 15 bit SOP field for spop2. */ | |
3571 | case '1': | |
3572 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3573 | if (strict && the_insn.exp.X_op != O_constant) |
3574 | break; | |
252b5132 | 3575 | s = expr_end; |
0f4f8b56 | 3576 | CHECK_FIELD (num, 32767, 0, strict); |
252b5132 RH |
3577 | num = (num & 0x1f) | ((num & 0x00007fe0) << 6); |
3578 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
3579 | ||
3580 | /* Handle a 3-bit co-processor ID field. */ | |
3581 | case 'u': | |
3582 | if (*s++ != ',') | |
3583 | as_bad (_("Invalid COPR identifier")); | |
3584 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3585 | if (strict && the_insn.exp.X_op != O_constant) |
3586 | break; | |
252b5132 | 3587 | s = expr_end; |
0f4f8b56 | 3588 | CHECK_FIELD (num, 7, 0, strict); |
252b5132 RH |
3589 | INSERT_FIELD_AND_CONTINUE (opcode, num, 6); |
3590 | ||
3591 | /* Handle a 22bit SOP field for copr. */ | |
3592 | case '2': | |
3593 | num = pa_get_absolute_expression (&the_insn, &s); | |
0f4f8b56 JL |
3594 | if (strict && the_insn.exp.X_op != O_constant) |
3595 | break; | |
252b5132 | 3596 | s = expr_end; |
0f4f8b56 | 3597 | CHECK_FIELD (num, 4194303, 0, strict); |
252b5132 RH |
3598 | num = (num & 0x1f) | ((num & 0x003fffe0) << 4); |
3599 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
3600 | ||
1cf6ae67 JL |
3601 | /* Handle a source FP operand format completer. */ |
3602 | case '{': | |
3603 | if (*s == ',' && *(s+1) == 't') | |
3604 | { | |
3605 | the_insn.trunc = 1; | |
3606 | s += 2; | |
3607 | } | |
3608 | else | |
3609 | the_insn.trunc = 0; | |
3610 | flag = pa_parse_fp_cnv_format (&s); | |
3611 | the_insn.fpof1 = flag; | |
3612 | if (flag == W || flag == UW) | |
3613 | flag = SGL; | |
3614 | if (flag == DW || flag == UDW) | |
3615 | flag = DBL; | |
3616 | if (flag == QW || flag == UQW) | |
3617 | flag = QUAD; | |
3618 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); | |
3619 | ||
3620 | /* Handle a destination FP operand format completer. */ | |
3621 | case '_': | |
3622 | /* pa_parse_format needs the ',' prefix. */ | |
3623 | s--; | |
3624 | flag = pa_parse_fp_cnv_format (&s); | |
3625 | the_insn.fpof2 = flag; | |
3626 | if (flag == W || flag == UW) | |
3627 | flag = SGL; | |
3628 | if (flag == DW || flag == UDW) | |
3629 | flag = DBL; | |
3630 | if (flag == QW || flag == UQW) | |
3631 | flag = QUAD; | |
3632 | opcode |= flag << 13; | |
3633 | if (the_insn.fpof1 == SGL | |
d53d2751 | 3634 | || the_insn.fpof1 == DBL |
1cf6ae67 JL |
3635 | || the_insn.fpof1 == QUAD) |
3636 | { | |
3637 | if (the_insn.fpof2 == SGL | |
3638 | || the_insn.fpof2 == DBL | |
3639 | || the_insn.fpof2 == QUAD) | |
3640 | flag = 0; | |
3641 | else if (the_insn.fpof2 == W | |
3642 | || the_insn.fpof2 == DW | |
3643 | || the_insn.fpof2 == QW) | |
3644 | flag = 2; | |
3645 | else if (the_insn.fpof2 == UW | |
3646 | || the_insn.fpof2 == UDW | |
3647 | || the_insn.fpof2 == UQW) | |
3648 | flag = 6; | |
3649 | else | |
3650 | abort (); | |
3651 | } | |
3652 | else if (the_insn.fpof1 == W | |
d53d2751 | 3653 | || the_insn.fpof1 == DW |
1cf6ae67 JL |
3654 | || the_insn.fpof1 == QW) |
3655 | { | |
3656 | if (the_insn.fpof2 == SGL | |
3657 | || the_insn.fpof2 == DBL | |
3658 | || the_insn.fpof2 == QUAD) | |
3659 | flag = 1; | |
3660 | else | |
3661 | abort (); | |
3662 | } | |
3663 | else if (the_insn.fpof1 == UW | |
d53d2751 | 3664 | || the_insn.fpof1 == UDW |
1cf6ae67 JL |
3665 | || the_insn.fpof1 == UQW) |
3666 | { | |
3667 | if (the_insn.fpof2 == SGL | |
3668 | || the_insn.fpof2 == DBL | |
3669 | || the_insn.fpof2 == QUAD) | |
3670 | flag = 5; | |
3671 | else | |
3672 | abort (); | |
3673 | } | |
3674 | flag |= the_insn.trunc; | |
3675 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 15); | |
252b5132 RH |
3676 | |
3677 | /* Handle a source FP operand format completer. */ | |
3678 | case 'F': | |
3679 | flag = pa_parse_fp_format (&s); | |
3680 | the_insn.fpof1 = flag; | |
3681 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); | |
3682 | ||
3683 | /* Handle a destination FP operand format completer. */ | |
3684 | case 'G': | |
3685 | /* pa_parse_format needs the ',' prefix. */ | |
3686 | s--; | |
3687 | flag = pa_parse_fp_format (&s); | |
3688 | the_insn.fpof2 = flag; | |
3689 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 13); | |
3690 | ||
9ecc05f0 JL |
3691 | /* Handle a source FP operand format completer at 20. */ |
3692 | case 'I': | |
3693 | flag = pa_parse_fp_format (&s); | |
3694 | the_insn.fpof1 = flag; | |
3695 | INSERT_FIELD_AND_CONTINUE (opcode, flag, 11); | |
3696 | ||
97e1581b JL |
3697 | /* Handle a floating point operand format at 26. |
3698 | Only allows single and double precision. */ | |
3699 | case 'H': | |
3700 | flag = pa_parse_fp_format (&s); | |
3701 | switch (flag) | |
3702 | { | |
3703 | case SGL: | |
3704 | opcode |= 0x20; | |
3705 | case DBL: | |
3706 | the_insn.fpof1 = flag; | |
3707 | continue; | |
252b5132 | 3708 | |
97e1581b JL |
3709 | case QUAD: |
3710 | case ILLEGAL_FMT: | |
3711 | default: | |
3712 | as_bad (_("Invalid Floating Point Operand Format.")); | |
3713 | } | |
3714 | break; | |
252b5132 | 3715 | |
97e1581b JL |
3716 | /* Handle all floating point registers. */ |
3717 | case 'f': | |
3718 | switch (*++args) | |
3719 | { | |
3720 | /* Float target register. */ | |
3721 | case 't': | |
ecacdc7a | 3722 | if (!pa_parse_number (&s, 3)) |
0f4f8b56 | 3723 | break; |
ecacdc7a | 3724 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
97e1581b JL |
3725 | CHECK_FIELD (num, 31, 0, 0); |
3726 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); | |
252b5132 | 3727 | |
97e1581b JL |
3728 | /* Float target register with L/R selection. */ |
3729 | case 'T': | |
252b5132 | 3730 | { |
ecacdc7a | 3731 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3732 | break; |
ecacdc7a AM |
3733 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3734 | CHECK_FIELD (num, 31, 0, 0); | |
3735 | opcode |= num; | |
b53fcc20 | 3736 | |
97e1581b JL |
3737 | /* 0x30 opcodes are FP arithmetic operation opcodes |
3738 | and need to be turned into 0x38 opcodes. This | |
3739 | is not necessary for loads/stores. */ | |
ecacdc7a | 3740 | if (need_pa11_opcode () |
97e1581b JL |
3741 | && ((opcode & 0xfc000000) == 0x30000000)) |
3742 | opcode |= 1 << 27; | |
b53fcc20 | 3743 | |
ecacdc7a AM |
3744 | opcode |= (pa_number & FP_REG_RSEL ? 1 << 6 : 0); |
3745 | continue; | |
97e1581b | 3746 | } |
252b5132 | 3747 | |
97e1581b JL |
3748 | /* Float operand 1. */ |
3749 | case 'a': | |
3750 | { | |
ecacdc7a | 3751 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3752 | break; |
ecacdc7a AM |
3753 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3754 | CHECK_FIELD (num, 31, 0, 0); | |
3755 | opcode |= num << 21; | |
3756 | if (need_pa11_opcode ()) | |
97e1581b | 3757 | { |
ecacdc7a | 3758 | opcode |= (pa_number & FP_REG_RSEL ? 1 << 7 : 0); |
97e1581b JL |
3759 | opcode |= 1 << 27; |
3760 | } | |
3761 | continue; | |
3762 | } | |
252b5132 | 3763 | |
97e1581b | 3764 | /* Float operand 1 with L/R selection. */ |
e061d86f | 3765 | case 'X': |
97e1581b | 3766 | case 'A': |
252b5132 | 3767 | { |
ecacdc7a | 3768 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3769 | break; |
ecacdc7a AM |
3770 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3771 | CHECK_FIELD (num, 31, 0, 0); | |
3772 | opcode |= num << 21; | |
3773 | opcode |= (pa_number & FP_REG_RSEL ? 1 << 7 : 0); | |
97e1581b | 3774 | continue; |
252b5132 | 3775 | } |
252b5132 | 3776 | |
97e1581b JL |
3777 | /* Float operand 2. */ |
3778 | case 'b': | |
3779 | { | |
ecacdc7a | 3780 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3781 | break; |
ecacdc7a AM |
3782 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3783 | CHECK_FIELD (num, 31, 0, 0); | |
3784 | opcode |= num << 16; | |
3785 | if (need_pa11_opcode ()) | |
97e1581b | 3786 | { |
ecacdc7a | 3787 | opcode |= (pa_number & FP_REG_RSEL ? 1 << 12 : 0); |
97e1581b JL |
3788 | opcode |= 1 << 27; |
3789 | } | |
3790 | continue; | |
3791 | } | |
3792 | ||
3793 | /* Float operand 2 with L/R selection. */ | |
3794 | case 'B': | |
252b5132 | 3795 | { |
ecacdc7a | 3796 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3797 | break; |
ecacdc7a AM |
3798 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3799 | CHECK_FIELD (num, 31, 0, 0); | |
3800 | opcode |= num << 16; | |
3801 | opcode |= (pa_number & FP_REG_RSEL ? 1 << 12 : 0); | |
97e1581b | 3802 | continue; |
252b5132 | 3803 | } |
252b5132 | 3804 | |
97e1581b JL |
3805 | /* Float operand 3 for fmpyfadd, fmpynfadd. */ |
3806 | case 'C': | |
3807 | { | |
ecacdc7a | 3808 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3809 | break; |
ecacdc7a AM |
3810 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3811 | CHECK_FIELD (num, 31, 0, 0); | |
3812 | opcode |= (num & 0x1c) << 11; | |
3813 | opcode |= (num & 0x03) << 9; | |
3814 | opcode |= (pa_number & FP_REG_RSEL ? 1 << 8 : 0); | |
97e1581b JL |
3815 | continue; |
3816 | } | |
b53fcc20 | 3817 | |
97e1581b JL |
3818 | /* Float mult operand 1 for fmpyadd, fmpysub */ |
3819 | case 'i': | |
3820 | { | |
ecacdc7a | 3821 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3822 | break; |
ecacdc7a AM |
3823 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3824 | CHECK_FIELD (num, 31, 0, 0); | |
97e1581b JL |
3825 | if (the_insn.fpof1 == SGL) |
3826 | { | |
ecacdc7a | 3827 | if (num < 16) |
97e1581b JL |
3828 | { |
3829 | as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); | |
3830 | break; | |
3831 | } | |
ecacdc7a AM |
3832 | num &= 0xF; |
3833 | num |= (pa_number & FP_REG_RSEL ? 1 << 4 : 0); | |
97e1581b | 3834 | } |
ecacdc7a | 3835 | INSERT_FIELD_AND_CONTINUE (opcode, num, 21); |
97e1581b JL |
3836 | } |
3837 | ||
3838 | /* Float mult operand 2 for fmpyadd, fmpysub */ | |
3839 | case 'j': | |
252b5132 | 3840 | { |
ecacdc7a | 3841 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3842 | break; |
ecacdc7a AM |
3843 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3844 | CHECK_FIELD (num, 31, 0, 0); | |
97e1581b | 3845 | if (the_insn.fpof1 == SGL) |
252b5132 | 3846 | { |
ecacdc7a | 3847 | if (num < 16) |
97e1581b | 3848 | { |
ecacdc7a AM |
3849 | as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); |
3850 | break; | |
97e1581b | 3851 | } |
ecacdc7a AM |
3852 | num &= 0xF; |
3853 | num |= (pa_number & FP_REG_RSEL ? 1 << 4 : 0); | |
252b5132 | 3854 | } |
ecacdc7a | 3855 | INSERT_FIELD_AND_CONTINUE (opcode, num, 16); |
252b5132 | 3856 | } |
252b5132 | 3857 | |
97e1581b JL |
3858 | /* Float mult target for fmpyadd, fmpysub */ |
3859 | case 'k': | |
252b5132 | 3860 | { |
ecacdc7a | 3861 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3862 | break; |
ecacdc7a AM |
3863 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3864 | CHECK_FIELD (num, 31, 0, 0); | |
97e1581b | 3865 | if (the_insn.fpof1 == SGL) |
252b5132 | 3866 | { |
ecacdc7a | 3867 | if (num < 16) |
97e1581b | 3868 | { |
ecacdc7a AM |
3869 | as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); |
3870 | break; | |
97e1581b | 3871 | } |
ecacdc7a AM |
3872 | num &= 0xF; |
3873 | num |= (pa_number & FP_REG_RSEL ? 1 << 4 : 0); | |
252b5132 | 3874 | } |
ecacdc7a | 3875 | INSERT_FIELD_AND_CONTINUE (opcode, num, 0); |
252b5132 | 3876 | } |
252b5132 | 3877 | |
97e1581b JL |
3878 | /* Float add operand 1 for fmpyadd, fmpysub */ |
3879 | case 'l': | |
252b5132 | 3880 | { |
ecacdc7a | 3881 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3882 | break; |
ecacdc7a AM |
3883 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3884 | CHECK_FIELD (num, 31, 0, 0); | |
97e1581b | 3885 | if (the_insn.fpof1 == SGL) |
252b5132 | 3886 | { |
ecacdc7a | 3887 | if (num < 16) |
97e1581b | 3888 | { |
ecacdc7a AM |
3889 | as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); |
3890 | break; | |
97e1581b | 3891 | } |
ecacdc7a AM |
3892 | num &= 0xF; |
3893 | num |= (pa_number & FP_REG_RSEL ? 1 << 4 : 0); | |
252b5132 | 3894 | } |
ecacdc7a | 3895 | INSERT_FIELD_AND_CONTINUE (opcode, num, 6); |
252b5132 | 3896 | } |
252b5132 | 3897 | |
97e1581b JL |
3898 | /* Float add target for fmpyadd, fmpysub */ |
3899 | case 'm': | |
252b5132 | 3900 | { |
ecacdc7a | 3901 | if (!pa_parse_number (&s, 1)) |
0f4f8b56 | 3902 | break; |
ecacdc7a AM |
3903 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3904 | CHECK_FIELD (num, 31, 0, 0); | |
97e1581b | 3905 | if (the_insn.fpof1 == SGL) |
252b5132 | 3906 | { |
ecacdc7a | 3907 | if (num < 16) |
97e1581b | 3908 | { |
ecacdc7a AM |
3909 | as_bad (_("Invalid register for single precision fmpyadd or fmpysub")); |
3910 | break; | |
97e1581b | 3911 | } |
ecacdc7a AM |
3912 | num &= 0xF; |
3913 | num |= (pa_number & FP_REG_RSEL ? 1 << 4 : 0); | |
252b5132 | 3914 | } |
ecacdc7a | 3915 | INSERT_FIELD_AND_CONTINUE (opcode, num, 11); |
252b5132 | 3916 | } |
252b5132 | 3917 | |
71823da4 | 3918 | /* Handle L/R register halves like 'x'. */ |
a02fab7e | 3919 | case 'E': |
71823da4 JL |
3920 | case 'e': |
3921 | { | |
ecacdc7a | 3922 | if (!pa_parse_number (&s, 1)) |
71823da4 | 3923 | break; |
ecacdc7a AM |
3924 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
3925 | CHECK_FIELD (num, 31, 0, 0); | |
3926 | opcode |= num << 16; | |
3927 | if (need_pa11_opcode ()) | |
71823da4 | 3928 | { |
ecacdc7a | 3929 | opcode |= (pa_number & FP_REG_RSEL ? 1 << 1 : 0); |
71823da4 JL |
3930 | } |
3931 | continue; | |
d3426803 | 3932 | } |
a02fab7e JL |
3933 | |
3934 | /* Float target register (PA 2.0 wide). */ | |
3935 | case 'x': | |
ecacdc7a | 3936 | if (!pa_parse_number (&s, 3)) |
a02fab7e | 3937 | break; |
ecacdc7a | 3938 | num = (pa_number & ~FP_REG_RSEL) - FP_REG_BASE; |
a02fab7e JL |
3939 | CHECK_FIELD (num, 31, 0, 0); |
3940 | INSERT_FIELD_AND_CONTINUE (opcode, num, 16); | |
3941 | ||
97e1581b JL |
3942 | default: |
3943 | abort (); | |
3944 | } | |
3945 | break; | |
3946 | ||
252b5132 RH |
3947 | default: |
3948 | abort (); | |
3949 | } | |
3950 | break; | |
3951 | } | |
3952 | ||
3953 | failed: | |
3954 | /* Check if the args matched. */ | |
b34976b6 | 3955 | if (!match) |
252b5132 RH |
3956 | { |
3957 | if (&insn[1] - pa_opcodes < (int) NUMOPCODES | |
3958 | && !strcmp (insn->name, insn[1].name)) | |
3959 | { | |
3960 | ++insn; | |
3961 | s = argstart; | |
3962 | continue; | |
3963 | } | |
3964 | else | |
3965 | { | |
3966 | as_bad (_("Invalid operands %s"), error_message); | |
3967 | return; | |
3968 | } | |
3969 | } | |
3970 | break; | |
3971 | } | |
3972 | ||
3973 | the_insn.opcode = opcode; | |
3974 | } | |
3975 | ||
3976 | /* Turn a string in input_line_pointer into a floating point constant of type | |
3977 | type, and store the appropriate bytes in *litP. The number of LITTLENUMS | |
3978 | emitted is stored in *sizeP . An error message or NULL is returned. */ | |
3979 | ||
3980 | #define MAX_LITTLENUMS 6 | |
3981 | ||
3982 | char * | |
3983 | md_atof (type, litP, sizeP) | |
3984 | char type; | |
3985 | char *litP; | |
3986 | int *sizeP; | |
3987 | { | |
3988 | int prec; | |
3989 | LITTLENUM_TYPE words[MAX_LITTLENUMS]; | |
3990 | LITTLENUM_TYPE *wordP; | |
3991 | char *t; | |
3992 | ||
3993 | switch (type) | |
3994 | { | |
3995 | ||
3996 | case 'f': | |
3997 | case 'F': | |
3998 | case 's': | |
3999 | case 'S': | |
4000 | prec = 2; | |
4001 | break; | |
4002 | ||
4003 | case 'd': | |
4004 | case 'D': | |
4005 | case 'r': | |
4006 | case 'R': | |
4007 | prec = 4; | |
4008 | break; | |
4009 | ||
4010 | case 'x': | |
4011 | case 'X': | |
4012 | prec = 6; | |
4013 | break; | |
4014 | ||
4015 | case 'p': | |
4016 | case 'P': | |
4017 | prec = 6; | |
4018 | break; | |
4019 | ||
4020 | default: | |
4021 | *sizeP = 0; | |
4022 | return _("Bad call to MD_ATOF()"); | |
4023 | } | |
4024 | t = atof_ieee (input_line_pointer, type, words); | |
4025 | if (t) | |
4026 | input_line_pointer = t; | |
4027 | *sizeP = prec * sizeof (LITTLENUM_TYPE); | |
4028 | for (wordP = words; prec--;) | |
4029 | { | |
4030 | md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE)); | |
4031 | litP += sizeof (LITTLENUM_TYPE); | |
4032 | } | |
4033 | return NULL; | |
4034 | } | |
4035 | ||
4036 | /* Write out big-endian. */ | |
4037 | ||
4038 | void | |
4039 | md_number_to_chars (buf, val, n) | |
4040 | char *buf; | |
4041 | valueT val; | |
4042 | int n; | |
4043 | { | |
4044 | number_to_chars_bigendian (buf, val, n); | |
4045 | } | |
4046 | ||
4047 | /* Translate internal representation of relocation info to BFD target | |
4048 | format. */ | |
4049 | ||
4050 | arelent ** | |
4051 | tc_gen_reloc (section, fixp) | |
4052 | asection *section; | |
4053 | fixS *fixp; | |
4054 | { | |
4055 | arelent *reloc; | |
4056 | struct hppa_fix_struct *hppa_fixp; | |
252b5132 RH |
4057 | static arelent *no_relocs = NULL; |
4058 | arelent **relocs; | |
ad1079af AM |
4059 | reloc_type **codes; |
4060 | reloc_type code; | |
252b5132 RH |
4061 | int n_relocs; |
4062 | int i; | |
4063 | ||
4064 | hppa_fixp = (struct hppa_fix_struct *) fixp->tc_fix_data; | |
4065 | if (fixp->fx_addsy == 0) | |
4066 | return &no_relocs; | |
ad1079af | 4067 | |
252b5132 RH |
4068 | assert (hppa_fixp != 0); |
4069 | assert (section != 0); | |
4070 | ||
4071 | reloc = (arelent *) xmalloc (sizeof (arelent)); | |
4072 | ||
a0f75b47 ILT |
4073 | reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); |
4074 | *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); | |
ad1079af | 4075 | codes = hppa_gen_reloc_type (stdoutput, |
252b5132 RH |
4076 | fixp->fx_r_type, |
4077 | hppa_fixp->fx_r_format, | |
4078 | hppa_fixp->fx_r_field, | |
4079 | fixp->fx_subsy != NULL, | |
a0f75b47 | 4080 | symbol_get_bfdsym (fixp->fx_addsy)); |
252b5132 RH |
4081 | |
4082 | if (codes == NULL) | |
5506e1a5 | 4083 | { |
b091f402 | 4084 | as_bad_where (fixp->fx_file, fixp->fx_line, _("Cannot handle fixup")); |
5506e1a5 AM |
4085 | abort (); |
4086 | } | |
252b5132 RH |
4087 | |
4088 | for (n_relocs = 0; codes[n_relocs]; n_relocs++) | |
4089 | ; | |
4090 | ||
4091 | relocs = (arelent **) xmalloc (sizeof (arelent *) * n_relocs + 1); | |
4092 | reloc = (arelent *) xmalloc (sizeof (arelent) * n_relocs); | |
4093 | for (i = 0; i < n_relocs; i++) | |
4094 | relocs[i] = &reloc[i]; | |
4095 | ||
4096 | relocs[n_relocs] = NULL; | |
4097 | ||
4098 | #ifdef OBJ_ELF | |
4099 | switch (fixp->fx_r_type) | |
4100 | { | |
4101 | default: | |
4102 | assert (n_relocs == 1); | |
4103 | ||
4104 | code = *codes[0]; | |
4105 | ||
252b5132 RH |
4106 | /* Now, do any processing that is dependent on the relocation type. */ |
4107 | switch (code) | |
4108 | { | |
4109 | case R_PARISC_DLTREL21L: | |
4110 | case R_PARISC_DLTREL14R: | |
4111 | case R_PARISC_DLTREL14F: | |
4112 | case R_PARISC_PLABEL32: | |
4113 | case R_PARISC_PLABEL21L: | |
4114 | case R_PARISC_PLABEL14R: | |
4115 | /* For plabel relocations, the addend of the | |
4116 | relocation should be either 0 (no static link) or 2 | |
904a31bf AM |
4117 | (static link required). This adjustment is done in |
4118 | bfd/elf32-hppa.c:elf32_hppa_relocate_section. | |
252b5132 RH |
4119 | |
4120 | We also slam a zero addend into the DLT relative relocs; | |
4121 | it doesn't make a lot of sense to use any addend since | |
4122 | it gets you a different (eg unknown) DLT entry. */ | |
4123 | reloc->addend = 0; | |
4124 | break; | |
4125 | ||
ad1079af | 4126 | #ifdef ELF_ARG_RELOC |
252b5132 RH |
4127 | case R_PARISC_PCREL17R: |
4128 | case R_PARISC_PCREL17F: | |
4129 | case R_PARISC_PCREL17C: | |
ad1079af AM |
4130 | case R_PARISC_DIR17R: |
4131 | case R_PARISC_DIR17F: | |
ad1079af AM |
4132 | case R_PARISC_PCREL21L: |
4133 | case R_PARISC_DIR21L: | |
904a31bf AM |
4134 | reloc->addend = HPPA_R_ADDEND (hppa_fixp->fx_arg_reloc, |
4135 | fixp->fx_offset); | |
ad1079af AM |
4136 | break; |
4137 | #endif | |
4138 | ||
64afeba3 AM |
4139 | case R_PARISC_DIR32: |
4140 | /* Facilitate hand-crafted unwind info. */ | |
4141 | if (strcmp (section->name, UNWIND_SECTION_NAME) == 0) | |
4142 | code = R_PARISC_SEGREL32; | |
4143 | /* Fall thru */ | |
4144 | ||
252b5132 RH |
4145 | default: |
4146 | reloc->addend = fixp->fx_offset; | |
4147 | break; | |
4148 | } | |
64afeba3 AM |
4149 | |
4150 | reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); | |
4151 | *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); | |
4152 | reloc->howto = bfd_reloc_type_lookup (stdoutput, | |
4153 | (bfd_reloc_code_real_type) code); | |
4154 | reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; | |
4155 | ||
4156 | assert (reloc->howto && (unsigned int) code == reloc->howto->type); | |
252b5132 RH |
4157 | break; |
4158 | } | |
4159 | #else /* OBJ_SOM */ | |
4160 | ||
4161 | /* Walk over reach relocation returned by the BFD backend. */ | |
4162 | for (i = 0; i < n_relocs; i++) | |
4163 | { | |
4164 | code = *codes[i]; | |
4165 | ||
398e8c25 ILT |
4166 | relocs[i]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); |
4167 | *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); | |
ad1079af AM |
4168 | relocs[i]->howto = |
4169 | bfd_reloc_type_lookup (stdoutput, | |
4170 | (bfd_reloc_code_real_type) code); | |
252b5132 RH |
4171 | relocs[i]->address = fixp->fx_frag->fr_address + fixp->fx_where; |
4172 | ||
4173 | switch (code) | |
4174 | { | |
4175 | case R_COMP2: | |
4176 | /* The only time we ever use a R_COMP2 fixup is for the difference | |
4177 | of two symbols. With that in mind we fill in all four | |
4178 | relocs now and break out of the loop. */ | |
4179 | assert (i == 1); | |
993142d5 | 4180 | relocs[0]->sym_ptr_ptr = (asymbol **) &(bfd_abs_symbol); |
ad1079af AM |
4181 | relocs[0]->howto = |
4182 | bfd_reloc_type_lookup (stdoutput, | |
4183 | (bfd_reloc_code_real_type) *codes[0]); | |
252b5132 RH |
4184 | relocs[0]->address = fixp->fx_frag->fr_address + fixp->fx_where; |
4185 | relocs[0]->addend = 0; | |
993142d5 ILT |
4186 | relocs[1]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); |
4187 | *relocs[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); | |
ad1079af AM |
4188 | relocs[1]->howto = |
4189 | bfd_reloc_type_lookup (stdoutput, | |
4190 | (bfd_reloc_code_real_type) *codes[1]); | |
252b5132 RH |
4191 | relocs[1]->address = fixp->fx_frag->fr_address + fixp->fx_where; |
4192 | relocs[1]->addend = 0; | |
993142d5 ILT |
4193 | relocs[2]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); |
4194 | *relocs[2]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy); | |
ad1079af AM |
4195 | relocs[2]->howto = |
4196 | bfd_reloc_type_lookup (stdoutput, | |
4197 | (bfd_reloc_code_real_type) *codes[2]); | |
252b5132 RH |
4198 | relocs[2]->address = fixp->fx_frag->fr_address + fixp->fx_where; |
4199 | relocs[2]->addend = 0; | |
993142d5 | 4200 | relocs[3]->sym_ptr_ptr = (asymbol **) &(bfd_abs_symbol); |
ad1079af AM |
4201 | relocs[3]->howto = |
4202 | bfd_reloc_type_lookup (stdoutput, | |
4203 | (bfd_reloc_code_real_type) *codes[3]); | |
252b5132 RH |
4204 | relocs[3]->address = fixp->fx_frag->fr_address + fixp->fx_where; |
4205 | relocs[3]->addend = 0; | |
993142d5 | 4206 | relocs[4]->sym_ptr_ptr = (asymbol **) &(bfd_abs_symbol); |
ad1079af AM |
4207 | relocs[4]->howto = |
4208 | bfd_reloc_type_lookup (stdoutput, | |
4209 | (bfd_reloc_code_real_type) *codes[4]); | |
252b5132 RH |
4210 | relocs[4]->address = fixp->fx_frag->fr_address + fixp->fx_where; |
4211 | relocs[4]->addend = 0; | |
4212 | goto done; | |
4213 | case R_PCREL_CALL: | |
4214 | case R_ABS_CALL: | |
4215 | relocs[i]->addend = HPPA_R_ADDEND (hppa_fixp->fx_arg_reloc, 0); | |
4216 | break; | |
4217 | ||
4218 | case R_DLT_REL: | |
4219 | case R_DATA_PLABEL: | |
4220 | case R_CODE_PLABEL: | |
4221 | /* For plabel relocations, the addend of the | |
4222 | relocation should be either 0 (no static link) or 2 | |
4223 | (static link required). | |
4224 | ||
4225 | FIXME: We always assume no static link! | |
4226 | ||
4227 | We also slam a zero addend into the DLT relative relocs; | |
4228 | it doesn't make a lot of sense to use any addend since | |
4229 | it gets you a different (eg unknown) DLT entry. */ | |
4230 | relocs[i]->addend = 0; | |
4231 | break; | |
4232 | ||
4233 | case R_N_MODE: | |
4234 | case R_S_MODE: | |
4235 | case R_D_MODE: | |
4236 | case R_R_MODE: | |
4237 | case R_FSEL: | |
4238 | case R_LSEL: | |
4239 | case R_RSEL: | |
4240 | case R_BEGIN_BRTAB: | |
4241 | case R_END_BRTAB: | |
4242 | case R_BEGIN_TRY: | |
4243 | case R_N0SEL: | |
4244 | case R_N1SEL: | |
4245 | /* There is no symbol or addend associated with these fixups. */ | |
cc8a6dd0 KH |
4246 | relocs[i]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); |
4247 | *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol); | |
252b5132 RH |
4248 | relocs[i]->addend = 0; |
4249 | break; | |
4250 | ||
4251 | case R_END_TRY: | |
4252 | case R_ENTRY: | |
4253 | case R_EXIT: | |
4254 | /* There is no symbol associated with these fixups. */ | |
cc8a6dd0 KH |
4255 | relocs[i]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); |
4256 | *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol); | |
252b5132 RH |
4257 | relocs[i]->addend = fixp->fx_offset; |
4258 | break; | |
4259 | ||
4260 | default: | |
4261 | relocs[i]->addend = fixp->fx_offset; | |
4262 | } | |
4263 | } | |
4264 | ||
4265 | done: | |
4266 | #endif | |
4267 | ||
4268 | return relocs; | |
4269 | } | |
4270 | ||
4271 | /* Process any machine dependent frag types. */ | |
4272 | ||
4273 | void | |
4274 | md_convert_frag (abfd, sec, fragP) | |
3f9b03b5 AM |
4275 | register bfd *abfd ATTRIBUTE_UNUSED; |
4276 | register asection *sec ATTRIBUTE_UNUSED; | |
252b5132 RH |
4277 | register fragS *fragP; |
4278 | { | |
4279 | unsigned int address; | |
4280 | ||
4281 | if (fragP->fr_type == rs_machine_dependent) | |
4282 | { | |
4283 | switch ((int) fragP->fr_subtype) | |
4284 | { | |
4285 | case 0: | |
4286 | fragP->fr_type = rs_fill; | |
4287 | know (fragP->fr_var == 1); | |
4288 | know (fragP->fr_next); | |
4289 | address = fragP->fr_address + fragP->fr_fix; | |
4290 | if (address % fragP->fr_offset) | |
4291 | { | |
4292 | fragP->fr_offset = | |
4293 | fragP->fr_next->fr_address | |
4294 | - fragP->fr_address | |
4295 | - fragP->fr_fix; | |
4296 | } | |
4297 | else | |
4298 | fragP->fr_offset = 0; | |
4299 | break; | |
4300 | } | |
4301 | } | |
4302 | } | |
4303 | ||
a28a3ccf | 4304 | /* Round up a section size to the appropriate boundary. */ |
252b5132 RH |
4305 | |
4306 | valueT | |
4307 | md_section_align (segment, size) | |
4308 | asection *segment; | |
4309 | valueT size; | |
4310 | { | |
4311 | int align = bfd_get_section_alignment (stdoutput, segment); | |
4312 | int align2 = (1 << align) - 1; | |
4313 | ||
4314 | return (size + align2) & ~align2; | |
4315 | } | |
4316 | ||
4317 | /* Return the approximate size of a frag before relaxation has occurred. */ | |
4318 | int | |
4319 | md_estimate_size_before_relax (fragP, segment) | |
4320 | register fragS *fragP; | |
3f9b03b5 | 4321 | asection *segment ATTRIBUTE_UNUSED; |
252b5132 RH |
4322 | { |
4323 | int size; | |
4324 | ||
4325 | size = 0; | |
4326 | ||
4327 | while ((fragP->fr_fix + size) % fragP->fr_offset) | |
4328 | size++; | |
4329 | ||
4330 | return size; | |
4331 | } | |
4332 | \f | |
ad1079af | 4333 | #ifdef OBJ_ELF |
4c400d5e AM |
4334 | # ifdef WARN_COMMENTS |
4335 | const char *md_shortopts = "Vc"; | |
4336 | # else | |
ad1079af | 4337 | const char *md_shortopts = "V"; |
4c400d5e | 4338 | # endif |
ad1079af | 4339 | #else |
4c400d5e AM |
4340 | # ifdef WARN_COMMENTS |
4341 | const char *md_shortopts = "c"; | |
4342 | # else | |
ad1079af | 4343 | const char *md_shortopts = ""; |
4c400d5e | 4344 | # endif |
ad1079af AM |
4345 | #endif |
4346 | ||
252b5132 | 4347 | struct option md_longopts[] = { |
4c400d5e AM |
4348 | #ifdef WARN_COMMENTS |
4349 | {"warn-comment", no_argument, NULL, 'c'}, | |
4350 | #endif | |
252b5132 RH |
4351 | {NULL, no_argument, NULL, 0} |
4352 | }; | |
bc805888 | 4353 | size_t md_longopts_size = sizeof (md_longopts); |
252b5132 RH |
4354 | |
4355 | int | |
4356 | md_parse_option (c, arg) | |
3f9b03b5 AM |
4357 | int c ATTRIBUTE_UNUSED; |
4358 | char *arg ATTRIBUTE_UNUSED; | |
252b5132 | 4359 | { |
ad1079af AM |
4360 | switch (c) |
4361 | { | |
4362 | default: | |
4363 | return 0; | |
4364 | ||
4365 | #ifdef OBJ_ELF | |
4366 | case 'V': | |
4367 | print_version_id (); | |
4368 | break; | |
4c400d5e AM |
4369 | #endif |
4370 | #ifdef WARN_COMMENTS | |
4371 | case 'c': | |
4372 | warn_comment = 1; | |
4373 | break; | |
ad1079af AM |
4374 | #endif |
4375 | } | |
4376 | ||
4377 | return 1; | |
252b5132 RH |
4378 | } |
4379 | ||
4380 | void | |
4381 | md_show_usage (stream) | |
3f9b03b5 | 4382 | FILE *stream ATTRIBUTE_UNUSED; |
252b5132 | 4383 | { |
4c400d5e AM |
4384 | #ifdef OBJ_ELF |
4385 | fprintf (stream, _("\ | |
4386 | -Q ignored\n")); | |
4387 | #endif | |
4388 | #ifdef WARN_COMMENTS | |
4389 | fprintf (stream, _("\ | |
4390 | -c print a warning if a comment is found\n")); | |
4391 | #endif | |
252b5132 RH |
4392 | } |
4393 | \f | |
4394 | /* We have no need to default values of symbols. */ | |
4395 | ||
4396 | symbolS * | |
4397 | md_undefined_symbol (name) | |
3f9b03b5 | 4398 | char *name ATTRIBUTE_UNUSED; |
252b5132 RH |
4399 | { |
4400 | return 0; | |
4401 | } | |
4402 | ||
25a8b250 | 4403 | #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC) |
5506e1a5 AM |
4404 | #define nonzero_dibits(x) \ |
4405 | ((x) | (((x) & 0x55555555) << 1) | (((x) & 0xAAAAAAAA) >> 1)) | |
ad1079af | 4406 | #define arg_reloc_stub_needed(CALLER, CALLEE) \ |
5506e1a5 | 4407 | (((CALLER) ^ (CALLEE)) & nonzero_dibits (CALLER) & nonzero_dibits (CALLEE)) |
ad1079af AM |
4408 | #else |
4409 | #define arg_reloc_stub_needed(CALLER, CALLEE) 0 | |
4410 | #endif | |
4411 | ||
252b5132 RH |
4412 | /* Apply a fixup to an instruction. */ |
4413 | ||
94f592af NC |
4414 | void |
4415 | md_apply_fix3 (fixP, valP, seg) | |
252b5132 | 4416 | fixS *fixP; |
e0ac8af0 | 4417 | valueT *valP; |
94f592af | 4418 | segT seg ATTRIBUTE_UNUSED; |
252b5132 | 4419 | { |
dc1fc56b | 4420 | unsigned char *buf; |
252b5132 | 4421 | struct hppa_fix_struct *hppa_fixP; |
3f9b03b5 | 4422 | offsetT new_val; |
dc1fc56b | 4423 | int insn, val, fmt; |
252b5132 | 4424 | |
252b5132 RH |
4425 | /* SOM uses R_HPPA_ENTRY and R_HPPA_EXIT relocations which can |
4426 | never be "applied" (they are just markers). Likewise for | |
4427 | R_HPPA_BEGIN_BRTAB and R_HPPA_END_BRTAB. */ | |
4428 | #ifdef OBJ_SOM | |
4429 | if (fixP->fx_r_type == R_HPPA_ENTRY | |
4430 | || fixP->fx_r_type == R_HPPA_EXIT | |
4431 | || fixP->fx_r_type == R_HPPA_BEGIN_BRTAB | |
4432 | || fixP->fx_r_type == R_HPPA_END_BRTAB | |
4433 | || fixP->fx_r_type == R_HPPA_BEGIN_TRY) | |
94f592af | 4434 | return; |
252b5132 RH |
4435 | |
4436 | /* Disgusting. We must set fx_offset ourselves -- R_HPPA_END_TRY | |
4437 | fixups are considered not adjustable, which in turn causes | |
4438 | adjust_reloc_syms to not set fx_offset. Ugh. */ | |
4439 | if (fixP->fx_r_type == R_HPPA_END_TRY) | |
4440 | { | |
94f592af NC |
4441 | fixP->fx_offset = * valP; |
4442 | return; | |
252b5132 RH |
4443 | } |
4444 | #endif | |
904a31bf AM |
4445 | #ifdef OBJ_ELF |
4446 | if (fixP->fx_r_type == (int) R_PARISC_GNU_VTENTRY | |
4447 | || fixP->fx_r_type == (int) R_PARISC_GNU_VTINHERIT) | |
94f592af | 4448 | return; |
904a31bf | 4449 | #endif |
252b5132 | 4450 | |
502b19cb JL |
4451 | if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0) |
4452 | fixP->fx_done = 1; | |
4453 | ||
252b5132 RH |
4454 | /* There should have been an HPPA specific fixup associated |
4455 | with the GAS fixup. */ | |
dc1fc56b AM |
4456 | hppa_fixP = (struct hppa_fix_struct *) fixP->tc_fix_data; |
4457 | if (hppa_fixP == NULL) | |
252b5132 | 4458 | { |
b091f402 AM |
4459 | as_bad_where (fixP->fx_file, fixP->fx_line, |
4460 | _("no hppa_fixup entry for fixup type 0x%x"), | |
4461 | fixP->fx_r_type); | |
94f592af | 4462 | return; |
dc1fc56b | 4463 | } |
252b5132 | 4464 | |
40d74fb1 | 4465 | buf = (unsigned char *) (fixP->fx_frag->fr_literal + fixP->fx_where); |
dc1fc56b AM |
4466 | insn = bfd_get_32 (stdoutput, buf); |
4467 | fmt = bfd_hppa_insn2fmt (stdoutput, insn); | |
5506e1a5 | 4468 | |
dc1fc56b AM |
4469 | /* If there is a symbol associated with this fixup, then it's something |
4470 | which will need a SOM relocation (except for some PC-relative relocs). | |
4471 | In such cases we should treat the "val" or "addend" as zero since it | |
4472 | will be added in as needed from fx_offset in tc_gen_reloc. */ | |
4473 | if ((fixP->fx_addsy != NULL | |
4474 | || fixP->fx_r_type == (int) R_HPPA_NONE) | |
252b5132 | 4475 | #ifdef OBJ_SOM |
dc1fc56b | 4476 | && fmt != 32 |
252b5132 | 4477 | #endif |
dc1fc56b AM |
4478 | ) |
4479 | new_val = ((fmt == 12 || fmt == 17 || fmt == 22) ? 8 : 0); | |
252b5132 | 4480 | #ifdef OBJ_SOM |
dc1fc56b AM |
4481 | /* These field selectors imply that we do not want an addend. */ |
4482 | else if (hppa_fixP->fx_r_field == e_psel | |
4483 | || hppa_fixP->fx_r_field == e_rpsel | |
4484 | || hppa_fixP->fx_r_field == e_lpsel | |
4485 | || hppa_fixP->fx_r_field == e_tsel | |
4486 | || hppa_fixP->fx_r_field == e_rtsel | |
4487 | || hppa_fixP->fx_r_field == e_ltsel) | |
4488 | new_val = ((fmt == 12 || fmt == 17 || fmt == 22) ? 8 : 0); | |
252b5132 | 4489 | #endif |
dc1fc56b | 4490 | else |
94f592af | 4491 | new_val = hppa_field_adjust (* valP, 0, hppa_fixP->fx_r_field); |
dc1fc56b AM |
4492 | |
4493 | /* Handle pc-relative exceptions from above. */ | |
4494 | if ((fmt == 12 || fmt == 17 || fmt == 22) | |
4495 | && fixP->fx_addsy | |
4496 | && fixP->fx_pcrel | |
4497 | && !arg_reloc_stub_needed (symbol_arg_reloc_info (fixP->fx_addsy), | |
4498 | hppa_fixP->fx_arg_reloc) | |
27df9f40 | 4499 | #ifdef OBJ_ELF |
94f592af NC |
4500 | && (* valP - 8 + 8192 < 16384 |
4501 | || (fmt == 17 && * valP - 8 + 262144 < 524288) | |
4502 | || (fmt == 22 && * valP - 8 + 8388608 < 16777216)) | |
27df9f40 AM |
4503 | #endif |
4504 | #ifdef OBJ_SOM | |
94f592af NC |
4505 | && (* valP - 8 + 262144 < 524288 |
4506 | || (fmt == 22 && * valP - 8 + 8388608 < 16777216)) | |
27df9f40 | 4507 | #endif |
dc1fc56b AM |
4508 | && !S_IS_EXTERNAL (fixP->fx_addsy) |
4509 | && !S_IS_WEAK (fixP->fx_addsy) | |
4510 | && S_GET_SEGMENT (fixP->fx_addsy) == hppa_fixP->segment | |
4511 | && !(fixP->fx_subsy | |
4512 | && S_GET_SEGMENT (fixP->fx_subsy) != hppa_fixP->segment)) | |
4513 | { | |
94f592af | 4514 | new_val = hppa_field_adjust (* valP, 0, hppa_fixP->fx_r_field); |
dc1fc56b | 4515 | } |
3f9b03b5 | 4516 | |
dc1fc56b AM |
4517 | switch (fmt) |
4518 | { | |
4519 | case 10: | |
b091f402 AM |
4520 | CHECK_FIELD_WHERE (new_val, 8191, -8192, |
4521 | fixP->fx_file, fixP->fx_line); | |
dc1fc56b | 4522 | val = new_val; |
a02fab7e | 4523 | |
dc1fc56b AM |
4524 | insn = (insn & ~ 0x3ff1) | (((val & 0x1ff8) << 1) |
4525 | | ((val & 0x2000) >> 13)); | |
4526 | break; | |
4527 | case -11: | |
b091f402 AM |
4528 | CHECK_FIELD_WHERE (new_val, 8191, -8192, |
4529 | fixP->fx_file, fixP->fx_line); | |
dc1fc56b | 4530 | val = new_val; |
a02fab7e | 4531 | |
dc1fc56b AM |
4532 | insn = (insn & ~ 0x3ff9) | (((val & 0x1ffc) << 1) |
4533 | | ((val & 0x2000) >> 13)); | |
4534 | break; | |
4535 | /* Handle all opcodes with the 'j' operand type. */ | |
4536 | case 14: | |
b091f402 AM |
4537 | CHECK_FIELD_WHERE (new_val, 8191, -8192, |
4538 | fixP->fx_file, fixP->fx_line); | |
dc1fc56b | 4539 | val = new_val; |
252b5132 | 4540 | |
dc1fc56b AM |
4541 | insn = ((insn & ~ 0x3fff) | low_sign_unext (val, 14)); |
4542 | break; | |
252b5132 | 4543 | |
dc1fc56b AM |
4544 | /* Handle all opcodes with the 'k' operand type. */ |
4545 | case 21: | |
b091f402 AM |
4546 | CHECK_FIELD_WHERE (new_val, 1048575, -1048576, |
4547 | fixP->fx_file, fixP->fx_line); | |
dc1fc56b | 4548 | val = new_val; |
3f9b03b5 | 4549 | |
dc1fc56b AM |
4550 | insn = (insn & ~ 0x1fffff) | re_assemble_21 (val); |
4551 | break; | |
252b5132 | 4552 | |
dc1fc56b AM |
4553 | /* Handle all the opcodes with the 'i' operand type. */ |
4554 | case 11: | |
b091f402 AM |
4555 | CHECK_FIELD_WHERE (new_val, 1023, -1024, |
4556 | fixP->fx_file, fixP->fx_line); | |
dc1fc56b | 4557 | val = new_val; |
252b5132 | 4558 | |
dc1fc56b AM |
4559 | insn = (insn & ~ 0x7ff) | low_sign_unext (val, 11); |
4560 | break; | |
252b5132 | 4561 | |
dc1fc56b AM |
4562 | /* Handle all the opcodes with the 'w' operand type. */ |
4563 | case 12: | |
b091f402 AM |
4564 | CHECK_FIELD_WHERE (new_val - 8, 8191, -8192, |
4565 | fixP->fx_file, fixP->fx_line); | |
dc1fc56b | 4566 | val = new_val - 8; |
252b5132 | 4567 | |
dc1fc56b AM |
4568 | insn = (insn & ~ 0x1ffd) | re_assemble_12 (val >> 2); |
4569 | break; | |
252b5132 | 4570 | |
dc1fc56b AM |
4571 | /* Handle some of the opcodes with the 'W' operand type. */ |
4572 | case 17: | |
4573 | { | |
94f592af | 4574 | offsetT distance = * valP; |
252b5132 | 4575 | |
dc1fc56b AM |
4576 | /* If this is an absolute branch (ie no link) with an out of |
4577 | range target, then we want to complain. */ | |
4578 | if (fixP->fx_r_type == (int) R_HPPA_PCREL_CALL | |
4579 | && (insn & 0xffe00000) == 0xe8000000) | |
b091f402 AM |
4580 | CHECK_FIELD_WHERE (distance - 8, 262143, -262144, |
4581 | fixP->fx_file, fixP->fx_line); | |
3f9b03b5 | 4582 | |
b091f402 AM |
4583 | CHECK_FIELD_WHERE (new_val - 8, 262143, -262144, |
4584 | fixP->fx_file, fixP->fx_line); | |
dc1fc56b | 4585 | val = new_val - 8; |
252b5132 | 4586 | |
dc1fc56b AM |
4587 | insn = (insn & ~ 0x1f1ffd) | re_assemble_17 (val >> 2); |
4588 | break; | |
4589 | } | |
77c02e18 | 4590 | |
dc1fc56b AM |
4591 | case 22: |
4592 | { | |
94f592af | 4593 | offsetT distance = * valP; |
77c02e18 | 4594 | |
dc1fc56b AM |
4595 | /* If this is an absolute branch (ie no link) with an out of |
4596 | range target, then we want to complain. */ | |
4597 | if (fixP->fx_r_type == (int) R_HPPA_PCREL_CALL | |
4598 | && (insn & 0xffe00000) == 0xe8000000) | |
b091f402 AM |
4599 | CHECK_FIELD_WHERE (distance - 8, 8388607, -8388608, |
4600 | fixP->fx_file, fixP->fx_line); | |
3f9b03b5 | 4601 | |
b091f402 AM |
4602 | CHECK_FIELD_WHERE (new_val - 8, 8388607, -8388608, |
4603 | fixP->fx_file, fixP->fx_line); | |
dc1fc56b | 4604 | val = new_val - 8; |
77c02e18 | 4605 | |
dc1fc56b AM |
4606 | insn = (insn & ~ 0x3ff1ffd) | re_assemble_22 (val >> 2); |
4607 | break; | |
4608 | } | |
ad1079af | 4609 | |
dc1fc56b AM |
4610 | case -10: |
4611 | val = new_val; | |
4612 | insn = (insn & ~ 0xfff1) | re_assemble_16 (val & -8); | |
4613 | break; | |
ad1079af | 4614 | |
dc1fc56b AM |
4615 | case -16: |
4616 | val = new_val; | |
4617 | insn = (insn & ~ 0xfff9) | re_assemble_16 (val & -4); | |
4618 | break; | |
ad1079af | 4619 | |
dc1fc56b AM |
4620 | case 16: |
4621 | val = new_val; | |
4622 | insn = (insn & ~ 0xffff) | re_assemble_16 (val); | |
4623 | break; | |
252b5132 | 4624 | |
dc1fc56b AM |
4625 | case 32: |
4626 | insn = new_val; | |
4627 | break; | |
252b5132 | 4628 | |
dc1fc56b | 4629 | default: |
b091f402 AM |
4630 | as_bad_where (fixP->fx_file, fixP->fx_line, |
4631 | _("Unknown relocation encountered in md_apply_fix.")); | |
94f592af | 4632 | return; |
252b5132 | 4633 | } |
dc1fc56b AM |
4634 | |
4635 | /* Insert the relocation. */ | |
4636 | bfd_put_32 (stdoutput, insn, buf); | |
252b5132 RH |
4637 | } |
4638 | ||
4639 | /* Exactly what point is a PC-relative offset relative TO? | |
4640 | On the PA, they're relative to the address of the offset. */ | |
4641 | ||
4642 | long | |
4643 | md_pcrel_from (fixP) | |
4644 | fixS *fixP; | |
4645 | { | |
4646 | return fixP->fx_where + fixP->fx_frag->fr_address; | |
4647 | } | |
4648 | ||
4649 | /* Return nonzero if the input line pointer is at the end of | |
4650 | a statement. */ | |
4651 | ||
4652 | static int | |
4653 | is_end_of_statement () | |
4654 | { | |
4655 | return ((*input_line_pointer == '\n') | |
4656 | || (*input_line_pointer == ';') | |
4657 | || (*input_line_pointer == '!')); | |
4658 | } | |
4659 | ||
4660 | /* Read a number from S. The number might come in one of many forms, | |
4661 | the most common will be a hex or decimal constant, but it could be | |
4662 | a pre-defined register (Yuk!), or an absolute symbol. | |
4663 | ||
ecacdc7a AM |
4664 | Return 1 on success or 0 on failure. If STRICT, then a missing |
4665 | register prefix will cause a failure. The number itself is | |
4666 | returned in `pa_number'. | |
252b5132 | 4667 | |
ecacdc7a AM |
4668 | IS_FLOAT indicates that a PA-89 FP register number should be |
4669 | parsed; A `l' or `r' suffix is checked for if but 2 of IS_FLOAT is | |
4670 | not set. | |
252b5132 RH |
4671 | |
4672 | pa_parse_number can not handle negative constants and will fail | |
4673 | horribly if it is passed such a constant. */ | |
4674 | ||
4675 | static int | |
ecacdc7a | 4676 | pa_parse_number (s, is_float) |
252b5132 | 4677 | char **s; |
ecacdc7a | 4678 | int is_float; |
252b5132 RH |
4679 | { |
4680 | int num; | |
4681 | char *name; | |
4682 | char c; | |
4683 | symbolS *sym; | |
4684 | int status; | |
4685 | char *p = *s; | |
b34976b6 | 4686 | bfd_boolean have_prefix; |
252b5132 RH |
4687 | |
4688 | /* Skip whitespace before the number. */ | |
4689 | while (*p == ' ' || *p == '\t') | |
4690 | p = p + 1; | |
4691 | ||
ecacdc7a AM |
4692 | pa_number = -1; |
4693 | have_prefix = 0; | |
4694 | num = 0; | |
3882b010 | 4695 | if (!strict && ISDIGIT (*p)) |
252b5132 RH |
4696 | { |
4697 | /* Looks like a number. */ | |
252b5132 RH |
4698 | |
4699 | if (*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X')) | |
4700 | { | |
4701 | /* The number is specified in hex. */ | |
4702 | p += 2; | |
3882b010 | 4703 | while (ISDIGIT (*p) || ((*p >= 'a') && (*p <= 'f')) |
252b5132 RH |
4704 | || ((*p >= 'A') && (*p <= 'F'))) |
4705 | { | |
3882b010 | 4706 | if (ISDIGIT (*p)) |
252b5132 RH |
4707 | num = num * 16 + *p - '0'; |
4708 | else if (*p >= 'a' && *p <= 'f') | |
4709 | num = num * 16 + *p - 'a' + 10; | |
4710 | else | |
4711 | num = num * 16 + *p - 'A' + 10; | |
4712 | ++p; | |
4713 | } | |
4714 | } | |
4715 | else | |
4716 | { | |
4717 | /* The number is specified in decimal. */ | |
3882b010 | 4718 | while (ISDIGIT (*p)) |
252b5132 RH |
4719 | { |
4720 | num = num * 10 + *p - '0'; | |
4721 | ++p; | |
4722 | } | |
4723 | } | |
4724 | ||
ecacdc7a | 4725 | pa_number = num; |
252b5132 | 4726 | |
ecacdc7a AM |
4727 | /* Check for a `l' or `r' suffix. */ |
4728 | if (is_float) | |
4729 | { | |
4730 | pa_number += FP_REG_BASE; | |
4731 | if (! (is_float & 2)) | |
252b5132 | 4732 | { |
ecacdc7a AM |
4733 | if (IS_R_SELECT (p)) |
4734 | { | |
4735 | pa_number += FP_REG_RSEL; | |
4736 | ++p; | |
4737 | } | |
4738 | else if (IS_L_SELECT (p)) | |
4739 | { | |
4740 | ++p; | |
4741 | } | |
252b5132 | 4742 | } |
252b5132 RH |
4743 | } |
4744 | } | |
4745 | else if (*p == '%') | |
4746 | { | |
4747 | /* The number might be a predefined register. */ | |
ecacdc7a | 4748 | have_prefix = 1; |
252b5132 RH |
4749 | name = p; |
4750 | p++; | |
4751 | c = *p; | |
4752 | /* Tege hack: Special case for general registers as the general | |
4753 | code makes a binary search with case translation, and is VERY | |
a28a3ccf | 4754 | slow. */ |
252b5132 RH |
4755 | if (c == 'r') |
4756 | { | |
4757 | p++; | |
4758 | if (*p == 'e' && *(p + 1) == 't' | |
4759 | && (*(p + 2) == '0' || *(p + 2) == '1')) | |
4760 | { | |
4761 | p += 2; | |
4762 | num = *p - '0' + 28; | |
4763 | p++; | |
4764 | } | |
4765 | else if (*p == 'p') | |
4766 | { | |
4767 | num = 2; | |
4768 | p++; | |
4769 | } | |
3882b010 | 4770 | else if (!ISDIGIT (*p)) |
252b5132 RH |
4771 | { |
4772 | if (print_errors) | |
4773 | as_bad (_("Undefined register: '%s'."), name); | |
4774 | num = -1; | |
4775 | } | |
4776 | else | |
4777 | { | |
4778 | do | |
4779 | num = num * 10 + *p++ - '0'; | |
3882b010 | 4780 | while (ISDIGIT (*p)); |
252b5132 RH |
4781 | } |
4782 | } | |
4783 | else | |
4784 | { | |
4785 | /* Do a normal register search. */ | |
4786 | while (is_part_of_name (c)) | |
4787 | { | |
4788 | p = p + 1; | |
4789 | c = *p; | |
4790 | } | |
4791 | *p = 0; | |
4792 | status = reg_name_search (name); | |
4793 | if (status >= 0) | |
4794 | num = status; | |
4795 | else | |
4796 | { | |
4797 | if (print_errors) | |
4798 | as_bad (_("Undefined register: '%s'."), name); | |
4799 | num = -1; | |
4800 | } | |
4801 | *p = c; | |
4802 | } | |
4803 | ||
ecacdc7a | 4804 | pa_number = num; |
252b5132 RH |
4805 | } |
4806 | else | |
4807 | { | |
4808 | /* And finally, it could be a symbol in the absolute section which | |
ecacdc7a | 4809 | is effectively a constant, or a register alias symbol. */ |
252b5132 RH |
4810 | name = p; |
4811 | c = *p; | |
4812 | while (is_part_of_name (c)) | |
4813 | { | |
4814 | p = p + 1; | |
4815 | c = *p; | |
4816 | } | |
4817 | *p = 0; | |
4818 | if ((sym = symbol_find (name)) != NULL) | |
4819 | { | |
ecacdc7a AM |
4820 | if (S_GET_SEGMENT (sym) == reg_section) |
4821 | { | |
4822 | num = S_GET_VALUE (sym); | |
4823 | /* Well, we don't really have one, but we do have a | |
4824 | register, so... */ | |
b34976b6 | 4825 | have_prefix = TRUE; |
ecacdc7a AM |
4826 | } |
4827 | else if (S_GET_SEGMENT (sym) == &bfd_abs_section) | |
252b5132 | 4828 | num = S_GET_VALUE (sym); |
ecacdc7a | 4829 | else if (!strict) |
252b5132 RH |
4830 | { |
4831 | if (print_errors) | |
4832 | as_bad (_("Non-absolute symbol: '%s'."), name); | |
4833 | num = -1; | |
4834 | } | |
4835 | } | |
ecacdc7a | 4836 | else if (!strict) |
252b5132 RH |
4837 | { |
4838 | /* There is where we'd come for an undefined symbol | |
4839 | or for an empty string. For an empty string we | |
4840 | will return zero. That's a concession made for | |
4841 | compatability with the braindamaged HP assemblers. */ | |
4842 | if (*name == 0) | |
4843 | num = 0; | |
4844 | else | |
4845 | { | |
4846 | if (print_errors) | |
4847 | as_bad (_("Undefined absolute constant: '%s'."), name); | |
4848 | num = -1; | |
4849 | } | |
4850 | } | |
4851 | *p = c; | |
4852 | ||
ecacdc7a | 4853 | pa_number = num; |
252b5132 RH |
4854 | } |
4855 | ||
ecacdc7a AM |
4856 | if (!strict || have_prefix) |
4857 | { | |
4858 | *s = p; | |
4859 | return 1; | |
4860 | } | |
4861 | return 0; | |
252b5132 RH |
4862 | } |
4863 | ||
bc805888 | 4864 | #define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg)) |
252b5132 RH |
4865 | |
4866 | /* Given NAME, find the register number associated with that name, return | |
4867 | the integer value associated with the given name or -1 on failure. */ | |
4868 | ||
4869 | static int | |
4870 | reg_name_search (name) | |
4871 | char *name; | |
4872 | { | |
4873 | int middle, low, high; | |
4874 | int cmp; | |
4875 | ||
4876 | low = 0; | |
4877 | high = REG_NAME_CNT - 1; | |
4878 | ||
4879 | do | |
4880 | { | |
4881 | middle = (low + high) / 2; | |
4882 | cmp = strcasecmp (name, pre_defined_registers[middle].name); | |
4883 | if (cmp < 0) | |
4884 | high = middle - 1; | |
4885 | else if (cmp > 0) | |
4886 | low = middle + 1; | |
4887 | else | |
4888 | return pre_defined_registers[middle].value; | |
4889 | } | |
4890 | while (low <= high); | |
4891 | ||
4892 | return -1; | |
4893 | } | |
4894 | ||
252b5132 RH |
4895 | /* Return nonzero if the given INSN and L/R information will require |
4896 | a new PA-1.1 opcode. */ | |
4897 | ||
4898 | static int | |
ecacdc7a | 4899 | need_pa11_opcode () |
252b5132 | 4900 | { |
ecacdc7a AM |
4901 | if ((pa_number & FP_REG_RSEL) != 0 |
4902 | && !(the_insn.fpof1 == DBL && the_insn.fpof2 == DBL)) | |
252b5132 RH |
4903 | { |
4904 | /* If this instruction is specific to a particular architecture, | |
4905 | then set a new architecture. */ | |
4906 | if (bfd_get_mach (stdoutput) < pa11) | |
4907 | { | |
4908 | if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, pa11)) | |
4909 | as_warn (_("could not update architecture and machine")); | |
4910 | } | |
4911 | return TRUE; | |
4912 | } | |
4913 | else | |
4914 | return FALSE; | |
4915 | } | |
4916 | ||
4917 | /* Parse a condition for a fcmp instruction. Return the numerical | |
4918 | code associated with the condition. */ | |
4919 | ||
4920 | static int | |
4921 | pa_parse_fp_cmp_cond (s) | |
4922 | char **s; | |
4923 | { | |
4924 | int cond, i; | |
4925 | ||
4926 | cond = 0; | |
4927 | ||
4928 | for (i = 0; i < 32; i++) | |
4929 | { | |
4930 | if (strncasecmp (*s, fp_cond_map[i].string, | |
4931 | strlen (fp_cond_map[i].string)) == 0) | |
4932 | { | |
4933 | cond = fp_cond_map[i].cond; | |
4934 | *s += strlen (fp_cond_map[i].string); | |
4935 | /* If not a complete match, back up the input string and | |
4936 | report an error. */ | |
4937 | if (**s != ' ' && **s != '\t') | |
4938 | { | |
4939 | *s -= strlen (fp_cond_map[i].string); | |
4940 | break; | |
4941 | } | |
4942 | while (**s == ' ' || **s == '\t') | |
4943 | *s = *s + 1; | |
4944 | return cond; | |
4945 | } | |
4946 | } | |
4947 | ||
4948 | as_bad (_("Invalid FP Compare Condition: %s"), *s); | |
4949 | ||
4950 | /* Advance over the bogus completer. */ | |
4951 | while (**s != ',' && **s != ' ' && **s != '\t') | |
4952 | *s += 1; | |
4953 | ||
4954 | return 0; | |
4955 | } | |
4956 | ||
1cf6ae67 JL |
4957 | /* Parse a graphics test complete for ftest. */ |
4958 | ||
4959 | static int | |
4960 | pa_parse_ftest_gfx_completer (s) | |
4961 | char **s; | |
4962 | { | |
4963 | int value; | |
4964 | ||
4965 | value = 0; | |
4966 | if (strncasecmp (*s, "acc8", 4) == 0) | |
4967 | { | |
4968 | value = 5; | |
4969 | *s += 4; | |
4970 | } | |
4971 | else if (strncasecmp (*s, "acc6", 4) == 0) | |
4972 | { | |
4973 | value = 9; | |
4974 | *s += 4; | |
4975 | } | |
4976 | else if (strncasecmp (*s, "acc4", 4) == 0) | |
4977 | { | |
4978 | value = 13; | |
4979 | *s += 4; | |
4980 | } | |
4981 | else if (strncasecmp (*s, "acc2", 4) == 0) | |
4982 | { | |
4983 | value = 17; | |
4984 | *s += 4; | |
4985 | } | |
4986 | else if (strncasecmp (*s, "acc", 3) == 0) | |
4987 | { | |
4988 | value = 1; | |
4989 | *s += 3; | |
4990 | } | |
4991 | else if (strncasecmp (*s, "rej8", 4) == 0) | |
4992 | { | |
4993 | value = 6; | |
4994 | *s += 4; | |
4995 | } | |
4996 | else if (strncasecmp (*s, "rej", 3) == 0) | |
4997 | { | |
4998 | value = 2; | |
4999 | *s += 3; | |
5000 | } | |
5001 | else | |
5002 | { | |
5003 | value = 0; | |
5004 | as_bad (_("Invalid FTEST completer: %s"), *s); | |
5005 | } | |
5006 | ||
5007 | return value; | |
5008 | } | |
5009 | ||
5010 | /* Parse an FP operand format completer returning the completer | |
5011 | type. */ | |
5012 | ||
5013 | static fp_operand_format | |
5014 | pa_parse_fp_cnv_format (s) | |
5015 | char **s; | |
5016 | { | |
5017 | int format; | |
5018 | ||
5019 | format = SGL; | |
5020 | if (**s == ',') | |
5021 | { | |
5022 | *s += 1; | |
5023 | if (strncasecmp (*s, "sgl", 3) == 0) | |
5024 | { | |
5025 | format = SGL; | |
5026 | *s += 4; | |
5027 | } | |
5028 | else if (strncasecmp (*s, "dbl", 3) == 0) | |
5029 | { | |
5030 | format = DBL; | |
5031 | *s += 4; | |
5032 | } | |
5033 | else if (strncasecmp (*s, "quad", 4) == 0) | |
5034 | { | |
5035 | format = QUAD; | |
5036 | *s += 5; | |
5037 | } | |
5038 | else if (strncasecmp (*s, "w", 1) == 0) | |
5039 | { | |
5040 | format = W; | |
5041 | *s += 2; | |
5042 | } | |
5043 | else if (strncasecmp (*s, "uw", 2) == 0) | |
5044 | { | |
5045 | format = UW; | |
5046 | *s += 3; | |
5047 | } | |
5048 | else if (strncasecmp (*s, "dw", 2) == 0) | |
5049 | { | |
5050 | format = DW; | |
5051 | *s += 3; | |
5052 | } | |
5053 | else if (strncasecmp (*s, "udw", 3) == 0) | |
5054 | { | |
5055 | format = UDW; | |
5056 | *s += 4; | |
5057 | } | |
5058 | else if (strncasecmp (*s, "qw", 2) == 0) | |
5059 | { | |
5060 | format = QW; | |
5061 | *s += 3; | |
5062 | } | |
5063 | else if (strncasecmp (*s, "uqw", 3) == 0) | |
5064 | { | |
5065 | format = UQW; | |
5066 | *s += 4; | |
5067 | } | |
5068 | else | |
5069 | { | |
5070 | format = ILLEGAL_FMT; | |
5071 | as_bad (_("Invalid FP Operand Format: %3s"), *s); | |
5072 | } | |
5073 | } | |
5074 | ||
5075 | return format; | |
5076 | } | |
252b5132 RH |
5077 | |
5078 | /* Parse an FP operand format completer returning the completer | |
5079 | type. */ | |
5080 | ||
5081 | static fp_operand_format | |
5082 | pa_parse_fp_format (s) | |
5083 | char **s; | |
5084 | { | |
5085 | int format; | |
5086 | ||
5087 | format = SGL; | |
5088 | if (**s == ',') | |
5089 | { | |
5090 | *s += 1; | |
5091 | if (strncasecmp (*s, "sgl", 3) == 0) | |
5092 | { | |
5093 | format = SGL; | |
5094 | *s += 4; | |
5095 | } | |
5096 | else if (strncasecmp (*s, "dbl", 3) == 0) | |
5097 | { | |
5098 | format = DBL; | |
5099 | *s += 4; | |
5100 | } | |
5101 | else if (strncasecmp (*s, "quad", 4) == 0) | |
5102 | { | |
5103 | format = QUAD; | |
5104 | *s += 5; | |
5105 | } | |
5106 | else | |
5107 | { | |
5108 | format = ILLEGAL_FMT; | |
5109 | as_bad (_("Invalid FP Operand Format: %3s"), *s); | |
5110 | } | |
5111 | } | |
5112 | ||
5113 | return format; | |
5114 | } | |
5115 | ||
5116 | /* Convert from a selector string into a selector type. */ | |
5117 | ||
5118 | static int | |
5119 | pa_chk_field_selector (str) | |
5120 | char **str; | |
5121 | { | |
5122 | int middle, low, high; | |
5123 | int cmp; | |
5124 | char name[4]; | |
5125 | ||
5126 | /* Read past any whitespace. */ | |
5127 | /* FIXME: should we read past newlines and formfeeds??? */ | |
5128 | while (**str == ' ' || **str == '\t' || **str == '\n' || **str == '\f') | |
5129 | *str = *str + 1; | |
5130 | ||
5131 | if ((*str)[1] == '\'' || (*str)[1] == '%') | |
3882b010 | 5132 | name[0] = TOLOWER ((*str)[0]), |
252b5132 RH |
5133 | name[1] = 0; |
5134 | else if ((*str)[2] == '\'' || (*str)[2] == '%') | |
3882b010 L |
5135 | name[0] = TOLOWER ((*str)[0]), |
5136 | name[1] = TOLOWER ((*str)[1]), | |
252b5132 | 5137 | name[2] = 0; |
252b5132 | 5138 | else if ((*str)[3] == '\'' || (*str)[3] == '%') |
3882b010 L |
5139 | name[0] = TOLOWER ((*str)[0]), |
5140 | name[1] = TOLOWER ((*str)[1]), | |
5141 | name[2] = TOLOWER ((*str)[2]), | |
252b5132 | 5142 | name[3] = 0; |
252b5132 RH |
5143 | else |
5144 | return e_fsel; | |
5145 | ||
5146 | low = 0; | |
5147 | high = sizeof (selector_table) / sizeof (struct selector_entry) - 1; | |
5148 | ||
5149 | do | |
5150 | { | |
5151 | middle = (low + high) / 2; | |
5152 | cmp = strcmp (name, selector_table[middle].prefix); | |
5153 | if (cmp < 0) | |
5154 | high = middle - 1; | |
5155 | else if (cmp > 0) | |
5156 | low = middle + 1; | |
5157 | else | |
5158 | { | |
5159 | *str += strlen (name) + 1; | |
5160 | #ifndef OBJ_SOM | |
5161 | if (selector_table[middle].field_selector == e_nsel) | |
5162 | return e_fsel; | |
5163 | #endif | |
5164 | return selector_table[middle].field_selector; | |
5165 | } | |
5166 | } | |
5167 | while (low <= high); | |
5168 | ||
5169 | return e_fsel; | |
5170 | } | |
5171 | ||
5172 | /* Mark (via expr_end) the end of an expression (I think). FIXME. */ | |
5173 | ||
5174 | static int | |
5175 | get_expression (str) | |
5176 | char *str; | |
5177 | { | |
5178 | char *save_in; | |
5179 | asection *seg; | |
5180 | ||
5181 | save_in = input_line_pointer; | |
5182 | input_line_pointer = str; | |
5183 | seg = expression (&the_insn.exp); | |
5184 | if (!(seg == absolute_section | |
5185 | || seg == undefined_section | |
5186 | || SEG_NORMAL (seg))) | |
5187 | { | |
5188 | as_warn (_("Bad segment in expression.")); | |
5189 | expr_end = input_line_pointer; | |
5190 | input_line_pointer = save_in; | |
5191 | return 1; | |
5192 | } | |
5193 | expr_end = input_line_pointer; | |
5194 | input_line_pointer = save_in; | |
5195 | return 0; | |
5196 | } | |
5197 | ||
a28a3ccf | 5198 | /* Mark (via expr_end) the end of an absolute expression. FIXME. */ |
252b5132 RH |
5199 | static int |
5200 | pa_get_absolute_expression (insn, strp) | |
5201 | struct pa_it *insn; | |
5202 | char **strp; | |
5203 | { | |
5204 | char *save_in; | |
5205 | ||
5206 | insn->field_selector = pa_chk_field_selector (strp); | |
5207 | save_in = input_line_pointer; | |
5208 | input_line_pointer = *strp; | |
5209 | expression (&insn->exp); | |
5210 | /* This is not perfect, but is a huge improvement over doing nothing. | |
5211 | ||
5212 | The PA assembly syntax is ambigious in a variety of ways. Consider | |
5213 | this string "4 %r5" Is that the number 4 followed by the register | |
ecacdc7a | 5214 | r5, or is that 4 MOD r5? |
252b5132 RH |
5215 | |
5216 | If we get a modulo expresion When looking for an absolute, we try | |
5217 | again cutting off the input string at the first whitespace character. */ | |
5218 | if (insn->exp.X_op == O_modulus) | |
5219 | { | |
5220 | char *s, c; | |
5221 | int retval; | |
5222 | ||
5223 | input_line_pointer = *strp; | |
5224 | s = *strp; | |
5225 | while (*s != ',' && *s != ' ' && *s != '\t') | |
cc8a6dd0 | 5226 | s++; |
252b5132 RH |
5227 | |
5228 | c = *s; | |
5229 | *s = 0; | |
5230 | ||
5231 | retval = pa_get_absolute_expression (insn, strp); | |
5232 | ||
5233 | input_line_pointer = save_in; | |
5234 | *s = c; | |
5235 | return evaluate_absolute (insn); | |
5236 | } | |
0f4f8b56 JL |
5237 | /* When in strict mode we have a non-match, fix up the pointers |
5238 | and return to our caller. */ | |
5239 | if (insn->exp.X_op != O_constant && strict) | |
5240 | { | |
5241 | expr_end = input_line_pointer; | |
5242 | input_line_pointer = save_in; | |
5243 | return 0; | |
5244 | } | |
252b5132 RH |
5245 | if (insn->exp.X_op != O_constant) |
5246 | { | |
5247 | as_bad (_("Bad segment (should be absolute).")); | |
5248 | expr_end = input_line_pointer; | |
5249 | input_line_pointer = save_in; | |
5250 | return 0; | |
5251 | } | |
5252 | expr_end = input_line_pointer; | |
5253 | input_line_pointer = save_in; | |
5254 | return evaluate_absolute (insn); | |
5255 | } | |
5256 | ||
5257 | /* Evaluate an absolute expression EXP which may be modified by | |
5258 | the selector FIELD_SELECTOR. Return the value of the expression. */ | |
5259 | static int | |
5260 | evaluate_absolute (insn) | |
5261 | struct pa_it *insn; | |
5262 | { | |
3f9b03b5 | 5263 | offsetT value; |
252b5132 RH |
5264 | expressionS exp; |
5265 | int field_selector = insn->field_selector; | |
5266 | ||
5267 | exp = insn->exp; | |
5268 | value = exp.X_add_number; | |
5269 | ||
3f9b03b5 | 5270 | return hppa_field_adjust (0, value, field_selector); |
252b5132 RH |
5271 | } |
5272 | ||
5273 | /* Given an argument location specification return the associated | |
5274 | argument location number. */ | |
5275 | ||
5276 | static unsigned int | |
5277 | pa_build_arg_reloc (type_name) | |
5278 | char *type_name; | |
5279 | { | |
5280 | ||
5281 | if (strncasecmp (type_name, "no", 2) == 0) | |
5282 | return 0; | |
5283 | if (strncasecmp (type_name, "gr", 2) == 0) | |
5284 | return 1; | |
5285 | else if (strncasecmp (type_name, "fr", 2) == 0) | |
5286 | return 2; | |
5287 | else if (strncasecmp (type_name, "fu", 2) == 0) | |
5288 | return 3; | |
5289 | else | |
5290 | as_bad (_("Invalid argument location: %s\n"), type_name); | |
5291 | ||
5292 | return 0; | |
5293 | } | |
5294 | ||
5295 | /* Encode and return an argument relocation specification for | |
5296 | the given register in the location specified by arg_reloc. */ | |
5297 | ||
5298 | static unsigned int | |
5299 | pa_align_arg_reloc (reg, arg_reloc) | |
5300 | unsigned int reg; | |
5301 | unsigned int arg_reloc; | |
5302 | { | |
5303 | unsigned int new_reloc; | |
5304 | ||
5305 | new_reloc = arg_reloc; | |
5306 | switch (reg) | |
5307 | { | |
5308 | case 0: | |
5309 | new_reloc <<= 8; | |
5310 | break; | |
5311 | case 1: | |
5312 | new_reloc <<= 6; | |
5313 | break; | |
5314 | case 2: | |
5315 | new_reloc <<= 4; | |
5316 | break; | |
5317 | case 3: | |
5318 | new_reloc <<= 2; | |
5319 | break; | |
5320 | default: | |
5321 | as_bad (_("Invalid argument description: %d"), reg); | |
5322 | } | |
5323 | ||
5324 | return new_reloc; | |
5325 | } | |
5326 | ||
5327 | /* Parse a PA nullification completer (,n). Return nonzero if the | |
5328 | completer was found; return zero if no completer was found. */ | |
5329 | ||
5330 | static int | |
5331 | pa_parse_nullif (s) | |
5332 | char **s; | |
5333 | { | |
5334 | int nullif; | |
5335 | ||
5336 | nullif = 0; | |
5337 | if (**s == ',') | |
5338 | { | |
5339 | *s = *s + 1; | |
5340 | if (strncasecmp (*s, "n", 1) == 0) | |
5341 | nullif = 1; | |
5342 | else | |
5343 | { | |
5344 | as_bad (_("Invalid Nullification: (%c)"), **s); | |
5345 | nullif = 0; | |
5346 | } | |
5347 | *s = *s + 1; | |
5348 | } | |
5349 | ||
5350 | return nullif; | |
5351 | } | |
5352 | ||
5353 | /* Parse a non-negated compare/subtract completer returning the | |
677537c1 | 5354 | number (for encoding in instrutions) of the given completer. */ |
252b5132 RH |
5355 | |
5356 | static int | |
677537c1 | 5357 | pa_parse_nonneg_cmpsub_cmpltr (s) |
252b5132 | 5358 | char **s; |
252b5132 RH |
5359 | { |
5360 | int cmpltr; | |
5361 | char *name = *s + 1; | |
5362 | char c; | |
5363 | char *save_s = *s; | |
5364 | int nullify = 0; | |
5365 | ||
5366 | cmpltr = 0; | |
5367 | if (**s == ',') | |
5368 | { | |
5369 | *s += 1; | |
5370 | while (**s != ',' && **s != ' ' && **s != '\t') | |
5371 | *s += 1; | |
5372 | c = **s; | |
5373 | **s = 0x00; | |
5374 | ||
252b5132 RH |
5375 | if (strcmp (name, "=") == 0) |
5376 | { | |
5377 | cmpltr = 1; | |
5378 | } | |
5379 | else if (strcmp (name, "<") == 0) | |
5380 | { | |
5381 | cmpltr = 2; | |
5382 | } | |
5383 | else if (strcmp (name, "<=") == 0) | |
5384 | { | |
5385 | cmpltr = 3; | |
5386 | } | |
5387 | else if (strcmp (name, "<<") == 0) | |
5388 | { | |
5389 | cmpltr = 4; | |
5390 | } | |
5391 | else if (strcmp (name, "<<=") == 0) | |
5392 | { | |
5393 | cmpltr = 5; | |
5394 | } | |
5395 | else if (strcasecmp (name, "sv") == 0) | |
5396 | { | |
5397 | cmpltr = 6; | |
5398 | } | |
5399 | else if (strcasecmp (name, "od") == 0) | |
5400 | { | |
5401 | cmpltr = 7; | |
5402 | } | |
5403 | /* If we have something like addb,n then there is no condition | |
5404 | completer. */ | |
677537c1 | 5405 | else if (strcasecmp (name, "n") == 0) |
252b5132 RH |
5406 | { |
5407 | cmpltr = 0; | |
5408 | nullify = 1; | |
5409 | } | |
5410 | else | |
5411 | { | |
5412 | cmpltr = -1; | |
5413 | } | |
5414 | **s = c; | |
5415 | } | |
5416 | ||
5417 | /* Reset pointers if this was really a ,n for a branch instruction. */ | |
5418 | if (nullify) | |
5419 | *s = save_s; | |
5420 | ||
252b5132 RH |
5421 | return cmpltr; |
5422 | } | |
5423 | ||
5424 | /* Parse a negated compare/subtract completer returning the | |
677537c1 | 5425 | number (for encoding in instrutions) of the given completer. */ |
252b5132 RH |
5426 | |
5427 | static int | |
677537c1 | 5428 | pa_parse_neg_cmpsub_cmpltr (s) |
252b5132 | 5429 | char **s; |
252b5132 RH |
5430 | { |
5431 | int cmpltr; | |
5432 | char *name = *s + 1; | |
5433 | char c; | |
5434 | char *save_s = *s; | |
5435 | int nullify = 0; | |
5436 | ||
5437 | cmpltr = 0; | |
5438 | if (**s == ',') | |
5439 | { | |
5440 | *s += 1; | |
5441 | while (**s != ',' && **s != ' ' && **s != '\t') | |
5442 | *s += 1; | |
5443 | c = **s; | |
5444 | **s = 0x00; | |
5445 | ||
252b5132 RH |
5446 | if (strcasecmp (name, "tr") == 0) |
5447 | { | |
5448 | cmpltr = 0; | |
5449 | } | |
5450 | else if (strcmp (name, "<>") == 0) | |
5451 | { | |
5452 | cmpltr = 1; | |
5453 | } | |
5454 | else if (strcmp (name, ">=") == 0) | |
5455 | { | |
5456 | cmpltr = 2; | |
5457 | } | |
5458 | else if (strcmp (name, ">") == 0) | |
5459 | { | |
5460 | cmpltr = 3; | |
5461 | } | |
5462 | else if (strcmp (name, ">>=") == 0) | |
5463 | { | |
5464 | cmpltr = 4; | |
5465 | } | |
5466 | else if (strcmp (name, ">>") == 0) | |
5467 | { | |
5468 | cmpltr = 5; | |
5469 | } | |
5470 | else if (strcasecmp (name, "nsv") == 0) | |
5471 | { | |
5472 | cmpltr = 6; | |
5473 | } | |
5474 | else if (strcasecmp (name, "ev") == 0) | |
5475 | { | |
5476 | cmpltr = 7; | |
5477 | } | |
5478 | /* If we have something like addb,n then there is no condition | |
5479 | completer. */ | |
677537c1 | 5480 | else if (strcasecmp (name, "n") == 0) |
252b5132 RH |
5481 | { |
5482 | cmpltr = 0; | |
5483 | nullify = 1; | |
5484 | } | |
5485 | else | |
5486 | { | |
5487 | cmpltr = -1; | |
5488 | } | |
5489 | **s = c; | |
5490 | } | |
5491 | ||
5492 | /* Reset pointers if this was really a ,n for a branch instruction. */ | |
5493 | if (nullify) | |
5494 | *s = save_s; | |
5495 | ||
252b5132 RH |
5496 | return cmpltr; |
5497 | } | |
5498 | ||
d53d2751 JL |
5499 | /* Parse a 64 bit compare and branch completer returning the number (for |
5500 | encoding in instrutions) of the given completer. | |
5501 | ||
5502 | Nonnegated comparisons are returned as 0-7, negated comparisons are | |
5503 | returned as 8-15. */ | |
5504 | ||
5505 | static int | |
5506 | pa_parse_cmpb_64_cmpltr (s) | |
5507 | char **s; | |
5508 | { | |
5509 | int cmpltr; | |
5510 | char *name = *s + 1; | |
5511 | char c; | |
d53d2751 JL |
5512 | |
5513 | cmpltr = -1; | |
5514 | if (**s == ',') | |
5515 | { | |
5516 | *s += 1; | |
5517 | while (**s != ',' && **s != ' ' && **s != '\t') | |
5518 | *s += 1; | |
5519 | c = **s; | |
5520 | **s = 0x00; | |
5521 | ||
5522 | if (strcmp (name, "*") == 0) | |
5523 | { | |
5524 | cmpltr = 0; | |
5525 | } | |
5526 | else if (strcmp (name, "*=") == 0) | |
5527 | { | |
5528 | cmpltr = 1; | |
5529 | } | |
5530 | else if (strcmp (name, "*<") == 0) | |
5531 | { | |
5532 | cmpltr = 2; | |
5533 | } | |
5534 | else if (strcmp (name, "*<=") == 0) | |
5535 | { | |
5536 | cmpltr = 3; | |
5537 | } | |
5538 | else if (strcmp (name, "*<<") == 0) | |
5539 | { | |
5540 | cmpltr = 4; | |
5541 | } | |
5542 | else if (strcmp (name, "*<<=") == 0) | |
5543 | { | |
5544 | cmpltr = 5; | |
5545 | } | |
5546 | else if (strcasecmp (name, "*sv") == 0) | |
5547 | { | |
5548 | cmpltr = 6; | |
5549 | } | |
5550 | else if (strcasecmp (name, "*od") == 0) | |
5551 | { | |
5552 | cmpltr = 7; | |
5553 | } | |
5554 | else if (strcasecmp (name, "*tr") == 0) | |
5555 | { | |
5556 | cmpltr = 8; | |
5557 | } | |
5558 | else if (strcmp (name, "*<>") == 0) | |
5559 | { | |
5560 | cmpltr = 9; | |
5561 | } | |
5562 | else if (strcmp (name, "*>=") == 0) | |
5563 | { | |
5564 | cmpltr = 10; | |
5565 | } | |
5566 | else if (strcmp (name, "*>") == 0) | |
5567 | { | |
5568 | cmpltr = 11; | |
5569 | } | |
5570 | else if (strcmp (name, "*>>=") == 0) | |
5571 | { | |
5572 | cmpltr = 12; | |
5573 | } | |
5574 | else if (strcmp (name, "*>>") == 0) | |
5575 | { | |
5576 | cmpltr = 13; | |
5577 | } | |
5578 | else if (strcasecmp (name, "*nsv") == 0) | |
5579 | { | |
5580 | cmpltr = 14; | |
5581 | } | |
5582 | else if (strcasecmp (name, "*ev") == 0) | |
5583 | { | |
5584 | cmpltr = 15; | |
5585 | } | |
5586 | else | |
5587 | { | |
5588 | cmpltr = -1; | |
5589 | } | |
5590 | **s = c; | |
5591 | } | |
5592 | ||
d53d2751 JL |
5593 | return cmpltr; |
5594 | } | |
5595 | ||
5596 | /* Parse a 64 bit compare immediate and branch completer returning the number | |
5597 | (for encoding in instrutions) of the given completer. */ | |
5598 | ||
5599 | static int | |
5600 | pa_parse_cmpib_64_cmpltr (s) | |
5601 | char **s; | |
5602 | { | |
5603 | int cmpltr; | |
5604 | char *name = *s + 1; | |
5605 | char c; | |
d53d2751 JL |
5606 | |
5607 | cmpltr = -1; | |
5608 | if (**s == ',') | |
5609 | { | |
5610 | *s += 1; | |
5611 | while (**s != ',' && **s != ' ' && **s != '\t') | |
5612 | *s += 1; | |
5613 | c = **s; | |
5614 | **s = 0x00; | |
5615 | ||
5616 | if (strcmp (name, "*<<") == 0) | |
5617 | { | |
5618 | cmpltr = 0; | |
5619 | } | |
5620 | else if (strcmp (name, "*=") == 0) | |
5621 | { | |
5622 | cmpltr = 1; | |
5623 | } | |
5624 | else if (strcmp (name, "*<") == 0) | |
5625 | { | |
5626 | cmpltr = 2; | |
5627 | } | |
5628 | else if (strcmp (name, "*<=") == 0) | |
5629 | { | |
5630 | cmpltr = 3; | |
5631 | } | |
5632 | else if (strcmp (name, "*>>=") == 0) | |
5633 | { | |
5634 | cmpltr = 4; | |
5635 | } | |
5636 | else if (strcmp (name, "*<>") == 0) | |
5637 | { | |
5638 | cmpltr = 5; | |
5639 | } | |
5640 | else if (strcasecmp (name, "*>=") == 0) | |
5641 | { | |
5642 | cmpltr = 6; | |
5643 | } | |
5644 | else if (strcasecmp (name, "*>") == 0) | |
5645 | { | |
5646 | cmpltr = 7; | |
5647 | } | |
5648 | else | |
5649 | { | |
5650 | cmpltr = -1; | |
5651 | } | |
5652 | **s = c; | |
5653 | } | |
5654 | ||
d53d2751 JL |
5655 | return cmpltr; |
5656 | } | |
5657 | ||
252b5132 | 5658 | /* Parse a non-negated addition completer returning the number |
677537c1 | 5659 | (for encoding in instrutions) of the given completer. */ |
252b5132 RH |
5660 | |
5661 | static int | |
677537c1 | 5662 | pa_parse_nonneg_add_cmpltr (s) |
252b5132 | 5663 | char **s; |
252b5132 RH |
5664 | { |
5665 | int cmpltr; | |
5666 | char *name = *s + 1; | |
5667 | char c; | |
5668 | char *save_s = *s; | |
677537c1 | 5669 | int nullify = 0; |
252b5132 RH |
5670 | |
5671 | cmpltr = 0; | |
5672 | if (**s == ',') | |
5673 | { | |
5674 | *s += 1; | |
5675 | while (**s != ',' && **s != ' ' && **s != '\t') | |
5676 | *s += 1; | |
5677 | c = **s; | |
5678 | **s = 0x00; | |
5679 | if (strcmp (name, "=") == 0) | |
5680 | { | |
5681 | cmpltr = 1; | |
5682 | } | |
5683 | else if (strcmp (name, "<") == 0) | |
5684 | { | |
5685 | cmpltr = 2; | |
5686 | } | |
5687 | else if (strcmp (name, "<=") == 0) | |
5688 | { | |
5689 | cmpltr = 3; | |
5690 | } | |
5691 | else if (strcasecmp (name, "nuv") == 0) | |
5692 | { | |
5693 | cmpltr = 4; | |
5694 | } | |
5695 | else if (strcasecmp (name, "znv") == 0) | |
5696 | { | |
5697 | cmpltr = 5; | |
5698 | } | |
5699 | else if (strcasecmp (name, "sv") == 0) | |
5700 | { | |
5701 | cmpltr = 6; | |
5702 | } | |
5703 | else if (strcasecmp (name, "od") == 0) | |
5704 | { | |
5705 | cmpltr = 7; | |
5706 | } | |
5707 | /* If we have something like addb,n then there is no condition | |
5708 | completer. */ | |
677537c1 | 5709 | else if (strcasecmp (name, "n") == 0) |
252b5132 RH |
5710 | { |
5711 | cmpltr = 0; | |
677537c1 | 5712 | nullify = 1; |
252b5132 RH |
5713 | } |
5714 | else | |
5715 | { | |
5716 | cmpltr = -1; | |
5717 | } | |
5718 | **s = c; | |
5719 | } | |
5720 | ||
5721 | /* Reset pointers if this was really a ,n for a branch instruction. */ | |
677537c1 | 5722 | if (nullify) |
252b5132 RH |
5723 | *s = save_s; |
5724 | ||
5725 | return cmpltr; | |
5726 | } | |
5727 | ||
5728 | /* Parse a negated addition completer returning the number | |
677537c1 | 5729 | (for encoding in instrutions) of the given completer. */ |
252b5132 RH |
5730 | |
5731 | static int | |
677537c1 | 5732 | pa_parse_neg_add_cmpltr (s) |
252b5132 | 5733 | char **s; |
252b5132 RH |
5734 | { |
5735 | int cmpltr; | |
5736 | char *name = *s + 1; | |
5737 | char c; | |
5738 | char *save_s = *s; | |
677537c1 | 5739 | int nullify = 0; |
252b5132 RH |
5740 | |
5741 | cmpltr = 0; | |
5742 | if (**s == ',') | |
5743 | { | |
5744 | *s += 1; | |
5745 | while (**s != ',' && **s != ' ' && **s != '\t') | |
5746 | *s += 1; | |
5747 | c = **s; | |
5748 | **s = 0x00; | |
5749 | if (strcasecmp (name, "tr") == 0) | |
5750 | { | |
5751 | cmpltr = 0; | |
5752 | } | |
5753 | else if (strcmp (name, "<>") == 0) | |
5754 | { | |
5755 | cmpltr = 1; | |
5756 | } | |
5757 | else if (strcmp (name, ">=") == 0) | |
5758 | { | |
5759 | cmpltr = 2; | |
5760 | } | |
5761 | else if (strcmp (name, ">") == 0) | |
5762 | { | |
5763 | cmpltr = 3; | |
5764 | } | |
5765 | else if (strcasecmp (name, "uv") == 0) | |
5766 | { | |
5767 | cmpltr = 4; | |
5768 | } | |
5769 | else if (strcasecmp (name, "vnz") == 0) | |
5770 | { | |
5771 | cmpltr = 5; | |
5772 | } | |
5773 | else if (strcasecmp (name, "nsv") == 0) | |
5774 | { | |
5775 | cmpltr = 6; | |
5776 | } | |
5777 | else if (strcasecmp (name, "ev") == 0) | |
5778 | { | |
5779 | cmpltr = 7; | |
5780 | } | |
5781 | /* If we have something like addb,n then there is no condition | |
5782 | completer. */ | |
677537c1 | 5783 | else if (strcasecmp (name, "n") == 0) |
252b5132 RH |
5784 | { |
5785 | cmpltr = 0; | |
677537c1 | 5786 | nullify = 1; |
252b5132 RH |
5787 | } |
5788 | else | |
5789 | { | |
5790 | cmpltr = -1; | |
5791 | } | |
5792 | **s = c; | |
5793 | } | |
5794 | ||
5795 | /* Reset pointers if this was really a ,n for a branch instruction. */ | |
677537c1 | 5796 | if (nullify) |
252b5132 RH |
5797 | *s = save_s; |
5798 | ||
5799 | return cmpltr; | |
5800 | } | |
5801 | ||
d53d2751 JL |
5802 | /* Parse a 64 bit wide mode add and branch completer returning the number (for |
5803 | encoding in instrutions) of the given completer. */ | |
5804 | ||
5805 | static int | |
5806 | pa_parse_addb_64_cmpltr (s) | |
5807 | char **s; | |
5808 | { | |
5809 | int cmpltr; | |
5810 | char *name = *s + 1; | |
5811 | char c; | |
5812 | char *save_s = *s; | |
5813 | int nullify = 0; | |
5814 | ||
5815 | cmpltr = 0; | |
5816 | if (**s == ',') | |
5817 | { | |
5818 | *s += 1; | |
5819 | while (**s != ',' && **s != ' ' && **s != '\t') | |
5820 | *s += 1; | |
5821 | c = **s; | |
5822 | **s = 0x00; | |
5823 | if (strcmp (name, "=") == 0) | |
5824 | { | |
5825 | cmpltr = 1; | |
5826 | } | |
5827 | else if (strcmp (name, "<") == 0) | |
5828 | { | |
5829 | cmpltr = 2; | |
5830 | } | |
5831 | else if (strcmp (name, "<=") == 0) | |
5832 | { | |
5833 | cmpltr = 3; | |
5834 | } | |
5835 | else if (strcasecmp (name, "nuv") == 0) | |
5836 | { | |
5837 | cmpltr = 4; | |
5838 | } | |
5839 | else if (strcasecmp (name, "*=") == 0) | |
5840 | { | |
5841 | cmpltr = 5; | |
5842 | } | |
5843 | else if (strcasecmp (name, "*<") == 0) | |
5844 | { | |
5845 | cmpltr = 6; | |
5846 | } | |
5847 | else if (strcasecmp (name, "*<=") == 0) | |
5848 | { | |
5849 | cmpltr = 7; | |
5850 | } | |
5851 | else if (strcmp (name, "tr") == 0) | |
5852 | { | |
5853 | cmpltr = 8; | |
5854 | } | |
5855 | else if (strcmp (name, "<>") == 0) | |
5856 | { | |
5857 | cmpltr = 9; | |
5858 | } | |
5859 | else if (strcmp (name, ">=") == 0) | |
5860 | { | |
5861 | cmpltr = 10; | |
5862 | } | |
5863 | else if (strcmp (name, ">") == 0) | |
5864 | { | |
5865 | cmpltr = 11; | |
5866 | } | |
5867 | else if (strcasecmp (name, "uv") == 0) | |
5868 | { | |
5869 | cmpltr = 12; | |
5870 | } | |
5871 | else if (strcasecmp (name, "*<>") == 0) | |
5872 | { | |
5873 | cmpltr = 13; | |
5874 | } | |
5875 | else if (strcasecmp (name, "*>=") == 0) | |
5876 | { | |
5877 | cmpltr = 14; | |
5878 | } | |
5879 | else if (strcasecmp (name, "*>") == 0) | |
5880 | { | |
5881 | cmpltr = 15; | |
5882 | } | |
5883 | /* If we have something like addb,n then there is no condition | |
5884 | completer. */ | |
5885 | else if (strcasecmp (name, "n") == 0) | |
5886 | { | |
5887 | cmpltr = 0; | |
5888 | nullify = 1; | |
5889 | } | |
5890 | else | |
5891 | { | |
5892 | cmpltr = -1; | |
5893 | } | |
5894 | **s = c; | |
5895 | } | |
5896 | ||
5897 | /* Reset pointers if this was really a ,n for a branch instruction. */ | |
5898 | if (nullify) | |
5899 | *s = save_s; | |
5900 | ||
5901 | return cmpltr; | |
5902 | } | |
5903 | ||
49863f82 | 5904 | #ifdef OBJ_SOM |
252b5132 RH |
5905 | /* Handle an alignment directive. Special so that we can update the |
5906 | alignment of the subspace if necessary. */ | |
5907 | static void | |
5908 | pa_align (bytes) | |
5506e1a5 | 5909 | int bytes; |
252b5132 RH |
5910 | { |
5911 | /* We must have a valid space and subspace. */ | |
5912 | pa_check_current_space_and_subspace (); | |
5913 | ||
5914 | /* Let the generic gas code do most of the work. */ | |
5915 | s_align_bytes (bytes); | |
5916 | ||
5917 | /* If bytes is a power of 2, then update the current subspace's | |
5918 | alignment if necessary. */ | |
5919 | if (log2 (bytes) != -1) | |
5920 | record_alignment (current_subspace->ssd_seg, log2 (bytes)); | |
5921 | } | |
49863f82 | 5922 | #endif |
252b5132 RH |
5923 | |
5924 | /* Handle a .BLOCK type pseudo-op. */ | |
5925 | ||
5926 | static void | |
5927 | pa_block (z) | |
3f9b03b5 | 5928 | int z ATTRIBUTE_UNUSED; |
252b5132 RH |
5929 | { |
5930 | char *p; | |
5931 | long int temp_fill; | |
5932 | unsigned int temp_size; | |
5933 | unsigned int i; | |
5934 | ||
49863f82 | 5935 | #ifdef OBJ_SOM |
252b5132 RH |
5936 | /* We must have a valid space and subspace. */ |
5937 | pa_check_current_space_and_subspace (); | |
49863f82 | 5938 | #endif |
252b5132 RH |
5939 | |
5940 | temp_size = get_absolute_expression (); | |
5941 | ||
5942 | /* Always fill with zeros, that's what the HP assembler does. */ | |
5943 | temp_fill = 0; | |
5944 | ||
5945 | p = frag_var (rs_fill, (int) temp_size, (int) temp_size, | |
5946 | (relax_substateT) 0, (symbolS *) 0, (offsetT) 1, NULL); | |
5947 | memset (p, 0, temp_size); | |
5948 | ||
5949 | /* Convert 2 bytes at a time. */ | |
5950 | ||
5951 | for (i = 0; i < temp_size; i += 2) | |
5952 | { | |
5953 | md_number_to_chars (p + i, | |
5954 | (valueT) temp_fill, | |
5955 | (int) ((temp_size - i) > 2 ? 2 : (temp_size - i))); | |
5956 | } | |
5957 | ||
5958 | pa_undefine_label (); | |
5959 | demand_empty_rest_of_line (); | |
5960 | } | |
5961 | ||
5962 | /* Handle a .begin_brtab and .end_brtab pseudo-op. */ | |
5963 | ||
5964 | static void | |
5965 | pa_brtab (begin) | |
3f9b03b5 | 5966 | int begin ATTRIBUTE_UNUSED; |
252b5132 RH |
5967 | { |
5968 | ||
5969 | #ifdef OBJ_SOM | |
5970 | /* The BRTAB relocations are only availble in SOM (to denote | |
5971 | the beginning and end of branch tables). */ | |
5972 | char *where = frag_more (0); | |
5973 | ||
5974 | fix_new_hppa (frag_now, where - frag_now->fr_literal, 0, | |
5975 | NULL, (offsetT) 0, NULL, | |
5976 | 0, begin ? R_HPPA_BEGIN_BRTAB : R_HPPA_END_BRTAB, | |
da6c73e0 | 5977 | e_fsel, 0, 0, 0); |
252b5132 RH |
5978 | #endif |
5979 | ||
5980 | demand_empty_rest_of_line (); | |
5981 | } | |
5982 | ||
5983 | /* Handle a .begin_try and .end_try pseudo-op. */ | |
5984 | ||
5985 | static void | |
5986 | pa_try (begin) | |
3f9b03b5 | 5987 | int begin ATTRIBUTE_UNUSED; |
252b5132 RH |
5988 | { |
5989 | #ifdef OBJ_SOM | |
5990 | expressionS exp; | |
5991 | char *where = frag_more (0); | |
5992 | ||
5993 | if (! begin) | |
5994 | expression (&exp); | |
5995 | ||
5996 | /* The TRY relocations are only availble in SOM (to denote | |
5997 | the beginning and end of exception handling regions). */ | |
5998 | ||
5999 | fix_new_hppa (frag_now, where - frag_now->fr_literal, 0, | |
6000 | NULL, (offsetT) 0, begin ? NULL : &exp, | |
6001 | 0, begin ? R_HPPA_BEGIN_TRY : R_HPPA_END_TRY, | |
da6c73e0 | 6002 | e_fsel, 0, 0, 0); |
252b5132 RH |
6003 | #endif |
6004 | ||
6005 | demand_empty_rest_of_line (); | |
6006 | } | |
6007 | ||
6008 | /* Handle a .CALL pseudo-op. This involves storing away information | |
6009 | about where arguments are to be found so the linker can detect | |
6010 | (and correct) argument location mismatches between caller and callee. */ | |
6011 | ||
6012 | static void | |
6013 | pa_call (unused) | |
3f9b03b5 | 6014 | int unused ATTRIBUTE_UNUSED; |
252b5132 | 6015 | { |
49863f82 | 6016 | #ifdef OBJ_SOM |
252b5132 RH |
6017 | /* We must have a valid space and subspace. */ |
6018 | pa_check_current_space_and_subspace (); | |
49863f82 | 6019 | #endif |
252b5132 RH |
6020 | |
6021 | pa_call_args (&last_call_desc); | |
6022 | demand_empty_rest_of_line (); | |
6023 | } | |
6024 | ||
6025 | /* Do the dirty work of building a call descriptor which describes | |
6026 | where the caller placed arguments to a function call. */ | |
6027 | ||
6028 | static void | |
6029 | pa_call_args (call_desc) | |
6030 | struct call_desc *call_desc; | |
6031 | { | |
6032 | char *name, c, *p; | |
6033 | unsigned int temp, arg_reloc; | |
6034 | ||
6035 | while (!is_end_of_statement ()) | |
6036 | { | |
6037 | name = input_line_pointer; | |
6038 | c = get_symbol_end (); | |
6039 | /* Process a source argument. */ | |
6040 | if ((strncasecmp (name, "argw", 4) == 0)) | |
6041 | { | |
6042 | temp = atoi (name + 4); | |
6043 | p = input_line_pointer; | |
6044 | *p = c; | |
6045 | input_line_pointer++; | |
6046 | name = input_line_pointer; | |
6047 | c = get_symbol_end (); | |
6048 | arg_reloc = pa_build_arg_reloc (name); | |
6049 | call_desc->arg_reloc |= pa_align_arg_reloc (temp, arg_reloc); | |
6050 | } | |
6051 | /* Process a return value. */ | |
6052 | else if ((strncasecmp (name, "rtnval", 6) == 0)) | |
6053 | { | |
6054 | p = input_line_pointer; | |
6055 | *p = c; | |
6056 | input_line_pointer++; | |
6057 | name = input_line_pointer; | |
6058 | c = get_symbol_end (); | |
6059 | arg_reloc = pa_build_arg_reloc (name); | |
6060 | call_desc->arg_reloc |= (arg_reloc & 0x3); | |
6061 | } | |
6062 | else | |
6063 | { | |
6064 | as_bad (_("Invalid .CALL argument: %s"), name); | |
6065 | } | |
6066 | p = input_line_pointer; | |
6067 | *p = c; | |
6068 | if (!is_end_of_statement ()) | |
6069 | input_line_pointer++; | |
6070 | } | |
6071 | } | |
6072 | ||
6073 | /* Return TRUE if FRAG1 and FRAG2 are the same. */ | |
6074 | ||
6075 | static int | |
6076 | is_same_frag (frag1, frag2) | |
6077 | fragS *frag1; | |
6078 | fragS *frag2; | |
6079 | { | |
6080 | ||
6081 | if (frag1 == NULL) | |
6082 | return (FALSE); | |
6083 | else if (frag2 == NULL) | |
6084 | return (FALSE); | |
6085 | else if (frag1 == frag2) | |
6086 | return (TRUE); | |
6087 | else if (frag2->fr_type == rs_fill && frag2->fr_fix == 0) | |
6088 | return (is_same_frag (frag1, frag2->fr_next)); | |
6089 | else | |
6090 | return (FALSE); | |
6091 | } | |
6092 | ||
6093 | #ifdef OBJ_ELF | |
6094 | /* Build an entry in the UNWIND subspace from the given function | |
6095 | attributes in CALL_INFO. This is not needed for SOM as using | |
6096 | R_ENTRY and R_EXIT relocations allow the linker to handle building | |
6097 | of the unwind spaces. */ | |
6098 | ||
6099 | static void | |
6100 | pa_build_unwind_subspace (call_info) | |
6101 | struct call_info *call_info; | |
6102 | { | |
252b5132 | 6103 | asection *seg, *save_seg; |
3f9b03b5 | 6104 | subsegT save_subseg; |
da6c73e0 | 6105 | unsigned int unwind; |
3f9b03b5 | 6106 | int reloc; |
da6c73e0 | 6107 | char *p; |
252b5132 | 6108 | |
1d3d5051 AM |
6109 | if ((bfd_get_section_flags (stdoutput, now_seg) |
6110 | & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) | |
6111 | != (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) | |
7acbfc6b JL |
6112 | return; |
6113 | ||
c46b7515 | 6114 | reloc = R_PARISC_SEGREL32; |
c97305a1 JL |
6115 | save_seg = now_seg; |
6116 | save_subseg = now_subseg; | |
252b5132 RH |
6117 | /* Get into the right seg/subseg. This may involve creating |
6118 | the seg the first time through. Make sure to have the | |
6119 | old seg/subseg so that we can reset things when we are done. */ | |
252b5132 RH |
6120 | seg = bfd_get_section_by_name (stdoutput, UNWIND_SECTION_NAME); |
6121 | if (seg == ASEC_NULL) | |
6122 | { | |
c97305a1 | 6123 | seg = subseg_new (UNWIND_SECTION_NAME, 0); |
252b5132 RH |
6124 | bfd_set_section_flags (stdoutput, seg, |
6125 | SEC_READONLY | SEC_HAS_CONTENTS | |
b100be66 JL |
6126 | | SEC_LOAD | SEC_RELOC | SEC_ALLOC | SEC_DATA); |
6127 | bfd_set_section_alignment (stdoutput, seg, 2); | |
252b5132 RH |
6128 | } |
6129 | ||
46031ca9 | 6130 | subseg_set (seg, 0); |
252b5132 | 6131 | |
252b5132 RH |
6132 | /* Get some space to hold relocation information for the unwind |
6133 | descriptor. */ | |
da6c73e0 | 6134 | p = frag_more (16); |
252b5132 RH |
6135 | |
6136 | /* Relocation info. for start offset of the function. */ | |
8ea46bbd | 6137 | md_number_to_chars (p, 0, 4); |
252b5132 RH |
6138 | fix_new_hppa (frag_now, p - frag_now->fr_literal, 4, |
6139 | call_info->start_symbol, (offsetT) 0, | |
46031ca9 | 6140 | (expressionS *) NULL, 0, reloc, |
da6c73e0 | 6141 | e_fsel, 32, 0, 0); |
252b5132 RH |
6142 | |
6143 | /* Relocation info. for end offset of the function. | |
6144 | ||
6145 | Because we allow reductions of 32bit relocations for ELF, this will be | |
6146 | reduced to section_sym + offset which avoids putting the temporary | |
6147 | symbol into the symbol table. It (should) end up giving the same | |
6148 | value as call_info->start_symbol + function size once the linker is | |
6149 | finished with its work. */ | |
8ea46bbd | 6150 | md_number_to_chars (p + 4, 0, 4); |
da6c73e0 | 6151 | fix_new_hppa (frag_now, p + 4 - frag_now->fr_literal, 4, |
252b5132 | 6152 | call_info->end_symbol, (offsetT) 0, |
46031ca9 | 6153 | (expressionS *) NULL, 0, reloc, |
da6c73e0 | 6154 | e_fsel, 32, 0, 0); |
252b5132 | 6155 | |
da6c73e0 AM |
6156 | /* Dump the descriptor. */ |
6157 | unwind = UNWIND_LOW32 (&call_info->ci_unwind.descriptor); | |
6158 | md_number_to_chars (p + 8, unwind, 4); | |
6159 | ||
6160 | unwind = UNWIND_HIGH32 (&call_info->ci_unwind.descriptor); | |
6161 | md_number_to_chars (p + 12, unwind, 4); | |
252b5132 RH |
6162 | |
6163 | /* Return back to the original segment/subsegment. */ | |
6164 | subseg_set (save_seg, save_subseg); | |
6165 | } | |
6166 | #endif | |
6167 | ||
6168 | /* Process a .CALLINFO pseudo-op. This information is used later | |
6169 | to build unwind descriptors and maybe one day to support | |
6170 | .ENTER and .LEAVE. */ | |
6171 | ||
6172 | static void | |
6173 | pa_callinfo (unused) | |
3f9b03b5 | 6174 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
6175 | { |
6176 | char *name, c, *p; | |
6177 | int temp; | |
6178 | ||
49863f82 | 6179 | #ifdef OBJ_SOM |
252b5132 RH |
6180 | /* We must have a valid space and subspace. */ |
6181 | pa_check_current_space_and_subspace (); | |
49863f82 | 6182 | #endif |
252b5132 RH |
6183 | |
6184 | /* .CALLINFO must appear within a procedure definition. */ | |
6185 | if (!within_procedure) | |
6186 | as_bad (_(".callinfo is not within a procedure definition")); | |
6187 | ||
6188 | /* Mark the fact that we found the .CALLINFO for the | |
6189 | current procedure. */ | |
6190 | callinfo_found = TRUE; | |
6191 | ||
6192 | /* Iterate over the .CALLINFO arguments. */ | |
6193 | while (!is_end_of_statement ()) | |
6194 | { | |
6195 | name = input_line_pointer; | |
6196 | c = get_symbol_end (); | |
6197 | /* Frame size specification. */ | |
6198 | if ((strncasecmp (name, "frame", 5) == 0)) | |
6199 | { | |
6200 | p = input_line_pointer; | |
6201 | *p = c; | |
6202 | input_line_pointer++; | |
6203 | temp = get_absolute_expression (); | |
6204 | if ((temp & 0x3) != 0) | |
6205 | { | |
6206 | as_bad (_("FRAME parameter must be a multiple of 8: %d\n"), temp); | |
6207 | temp = 0; | |
6208 | } | |
6209 | ||
6210 | /* callinfo is in bytes and unwind_desc is in 8 byte units. */ | |
6211 | last_call_info->ci_unwind.descriptor.frame_size = temp / 8; | |
6212 | ||
6213 | } | |
6214 | /* Entry register (GR, GR and SR) specifications. */ | |
6215 | else if ((strncasecmp (name, "entry_gr", 8) == 0)) | |
6216 | { | |
6217 | p = input_line_pointer; | |
6218 | *p = c; | |
6219 | input_line_pointer++; | |
6220 | temp = get_absolute_expression (); | |
6221 | /* The HP assembler accepts 19 as the high bound for ENTRY_GR | |
6222 | even though %r19 is caller saved. I think this is a bug in | |
6223 | the HP assembler, and we are not going to emulate it. */ | |
6224 | if (temp < 3 || temp > 18) | |
6225 | as_bad (_("Value for ENTRY_GR must be in the range 3..18\n")); | |
6226 | last_call_info->ci_unwind.descriptor.entry_gr = temp - 2; | |
6227 | } | |
6228 | else if ((strncasecmp (name, "entry_fr", 8) == 0)) | |
6229 | { | |
6230 | p = input_line_pointer; | |
6231 | *p = c; | |
6232 | input_line_pointer++; | |
6233 | temp = get_absolute_expression (); | |
6234 | /* Similarly the HP assembler takes 31 as the high bound even | |
6235 | though %fr21 is the last callee saved floating point register. */ | |
6236 | if (temp < 12 || temp > 21) | |
6237 | as_bad (_("Value for ENTRY_FR must be in the range 12..21\n")); | |
6238 | last_call_info->ci_unwind.descriptor.entry_fr = temp - 11; | |
6239 | } | |
6240 | else if ((strncasecmp (name, "entry_sr", 8) == 0)) | |
6241 | { | |
6242 | p = input_line_pointer; | |
6243 | *p = c; | |
6244 | input_line_pointer++; | |
6245 | temp = get_absolute_expression (); | |
6246 | if (temp != 3) | |
6247 | as_bad (_("Value for ENTRY_SR must be 3\n")); | |
6248 | } | |
6249 | /* Note whether or not this function performs any calls. */ | |
6250 | else if ((strncasecmp (name, "calls", 5) == 0) || | |
6251 | (strncasecmp (name, "caller", 6) == 0)) | |
6252 | { | |
6253 | p = input_line_pointer; | |
6254 | *p = c; | |
6255 | } | |
6256 | else if ((strncasecmp (name, "no_calls", 8) == 0)) | |
6257 | { | |
6258 | p = input_line_pointer; | |
6259 | *p = c; | |
6260 | } | |
6261 | /* Should RP be saved into the stack. */ | |
6262 | else if ((strncasecmp (name, "save_rp", 7) == 0)) | |
6263 | { | |
6264 | p = input_line_pointer; | |
6265 | *p = c; | |
6266 | last_call_info->ci_unwind.descriptor.save_rp = 1; | |
6267 | } | |
6268 | /* Likewise for SP. */ | |
6269 | else if ((strncasecmp (name, "save_sp", 7) == 0)) | |
6270 | { | |
6271 | p = input_line_pointer; | |
6272 | *p = c; | |
6273 | last_call_info->ci_unwind.descriptor.save_sp = 1; | |
6274 | } | |
6275 | /* Is this an unwindable procedure. If so mark it so | |
6276 | in the unwind descriptor. */ | |
6277 | else if ((strncasecmp (name, "no_unwind", 9) == 0)) | |
6278 | { | |
6279 | p = input_line_pointer; | |
6280 | *p = c; | |
6281 | last_call_info->ci_unwind.descriptor.cannot_unwind = 1; | |
6282 | } | |
6283 | /* Is this an interrupt routine. If so mark it in the | |
6284 | unwind descriptor. */ | |
6285 | else if ((strncasecmp (name, "hpux_int", 7) == 0)) | |
6286 | { | |
6287 | p = input_line_pointer; | |
6288 | *p = c; | |
6289 | last_call_info->ci_unwind.descriptor.hpux_interrupt_marker = 1; | |
6290 | } | |
6291 | /* Is this a millicode routine. "millicode" isn't in my | |
6292 | assembler manual, but my copy is old. The HP assembler | |
6293 | accepts it, and there's a place in the unwind descriptor | |
6294 | to drop the information, so we'll accept it too. */ | |
6295 | else if ((strncasecmp (name, "millicode", 9) == 0)) | |
6296 | { | |
6297 | p = input_line_pointer; | |
6298 | *p = c; | |
6299 | last_call_info->ci_unwind.descriptor.millicode = 1; | |
6300 | } | |
6301 | else | |
6302 | { | |
6303 | as_bad (_("Invalid .CALLINFO argument: %s"), name); | |
6304 | *input_line_pointer = c; | |
6305 | } | |
6306 | if (!is_end_of_statement ()) | |
6307 | input_line_pointer++; | |
6308 | } | |
6309 | ||
6310 | demand_empty_rest_of_line (); | |
6311 | } | |
6312 | ||
ad1079af AM |
6313 | #if !(defined (OBJ_ELF) && defined (TE_LINUX)) |
6314 | /* Switch to the text space. Like s_text, but delete our | |
6315 | label when finished. */ | |
252b5132 | 6316 | static void |
ad1079af | 6317 | pa_text (unused) |
3f9b03b5 | 6318 | int unused ATTRIBUTE_UNUSED; |
252b5132 | 6319 | { |
49863f82 | 6320 | #ifdef OBJ_SOM |
252b5132 RH |
6321 | current_space = is_defined_space ("$TEXT$"); |
6322 | current_subspace | |
6323 | = pa_subsegment_to_subspace (current_space->sd_seg, 0); | |
49863f82 | 6324 | #endif |
ad1079af | 6325 | |
252b5132 RH |
6326 | s_text (0); |
6327 | pa_undefine_label (); | |
6328 | } | |
6329 | ||
ad1079af AM |
6330 | /* Switch to the data space. As usual delete our label. */ |
6331 | static void | |
6332 | pa_data (unused) | |
6333 | int unused ATTRIBUTE_UNUSED; | |
6334 | { | |
6335 | #ifdef OBJ_SOM | |
6336 | current_space = is_defined_space ("$PRIVATE$"); | |
6337 | current_subspace | |
6338 | = pa_subsegment_to_subspace (current_space->sd_seg, 0); | |
6339 | #endif | |
6340 | s_data (0); | |
6341 | pa_undefine_label (); | |
6342 | } | |
6343 | ||
252b5132 RH |
6344 | /* This is different than the standard GAS s_comm(). On HP9000/800 machines, |
6345 | the .comm pseudo-op has the following symtax: | |
6346 | ||
6347 | <label> .comm <length> | |
6348 | ||
6349 | where <label> is optional and is a symbol whose address will be the start of | |
6350 | a block of memory <length> bytes long. <length> must be an absolute | |
6351 | expression. <length> bytes will be allocated in the current space | |
6352 | and subspace. | |
6353 | ||
6354 | Also note the label may not even be on the same line as the .comm. | |
6355 | ||
6356 | This difference in syntax means the colon function will be called | |
6357 | on the symbol before we arrive in pa_comm. colon will set a number | |
6358 | of attributes of the symbol that need to be fixed here. In particular | |
6359 | the value, section pointer, fragment pointer, flags, etc. What | |
6360 | a pain. | |
6361 | ||
6362 | This also makes error detection all but impossible. */ | |
6363 | ||
6364 | static void | |
6365 | pa_comm (unused) | |
3f9b03b5 | 6366 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
6367 | { |
6368 | unsigned int size; | |
6369 | symbolS *symbol; | |
6370 | label_symbol_struct *label_symbol = pa_get_label (); | |
6371 | ||
6372 | if (label_symbol) | |
6373 | symbol = label_symbol->lss_label; | |
6374 | else | |
6375 | symbol = NULL; | |
6376 | ||
6377 | SKIP_WHITESPACE (); | |
6378 | size = get_absolute_expression (); | |
6379 | ||
6380 | if (symbol) | |
6381 | { | |
6382 | S_SET_VALUE (symbol, size); | |
6383 | S_SET_SEGMENT (symbol, bfd_und_section_ptr); | |
6384 | S_SET_EXTERNAL (symbol); | |
6385 | ||
6386 | /* colon() has already set the frag to the current location in the | |
6387 | current subspace; we need to reset the fragment to the zero address | |
6388 | fragment. We also need to reset the segment pointer. */ | |
a0f75b47 | 6389 | symbol_set_frag (symbol, &zero_address_frag); |
252b5132 RH |
6390 | } |
6391 | demand_empty_rest_of_line (); | |
6392 | } | |
ad1079af | 6393 | #endif /* !(defined (OBJ_ELF) && defined (TE_LINUX)) */ |
252b5132 RH |
6394 | |
6395 | /* Process a .END pseudo-op. */ | |
6396 | ||
6397 | static void | |
6398 | pa_end (unused) | |
3f9b03b5 | 6399 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
6400 | { |
6401 | demand_empty_rest_of_line (); | |
6402 | } | |
6403 | ||
6404 | /* Process a .ENTER pseudo-op. This is not supported. */ | |
6405 | static void | |
6406 | pa_enter (unused) | |
3f9b03b5 | 6407 | int unused ATTRIBUTE_UNUSED; |
252b5132 | 6408 | { |
49863f82 | 6409 | #ifdef OBJ_SOM |
252b5132 RH |
6410 | /* We must have a valid space and subspace. */ |
6411 | pa_check_current_space_and_subspace (); | |
49863f82 | 6412 | #endif |
252b5132 RH |
6413 | |
6414 | as_bad (_("The .ENTER pseudo-op is not supported")); | |
6415 | demand_empty_rest_of_line (); | |
6416 | } | |
6417 | ||
6418 | /* Process a .ENTRY pseudo-op. .ENTRY marks the beginning of the | |
6419 | procesure. */ | |
6420 | static void | |
6421 | pa_entry (unused) | |
3f9b03b5 | 6422 | int unused ATTRIBUTE_UNUSED; |
252b5132 | 6423 | { |
49863f82 | 6424 | #ifdef OBJ_SOM |
252b5132 RH |
6425 | /* We must have a valid space and subspace. */ |
6426 | pa_check_current_space_and_subspace (); | |
49863f82 | 6427 | #endif |
252b5132 RH |
6428 | |
6429 | if (!within_procedure) | |
6430 | as_bad (_("Misplaced .entry. Ignored.")); | |
6431 | else | |
6432 | { | |
6433 | if (!callinfo_found) | |
6434 | as_bad (_("Missing .callinfo.")); | |
6435 | } | |
6436 | demand_empty_rest_of_line (); | |
6437 | within_entry_exit = TRUE; | |
6438 | ||
6439 | #ifdef OBJ_SOM | |
6440 | /* SOM defers building of unwind descriptors until the link phase. | |
6441 | The assembler is responsible for creating an R_ENTRY relocation | |
6442 | to mark the beginning of a region and hold the unwind bits, and | |
6443 | for creating an R_EXIT relocation to mark the end of the region. | |
6444 | ||
6445 | FIXME. ELF should be using the same conventions! The problem | |
6446 | is an unwind requires too much relocation space. Hmmm. Maybe | |
6447 | if we split the unwind bits up between the relocations which | |
6448 | denote the entry and exit points. */ | |
6449 | if (last_call_info->start_symbol != NULL) | |
6450 | { | |
da6c73e0 AM |
6451 | char *where; |
6452 | unsigned int u; | |
252b5132 | 6453 | |
da6c73e0 AM |
6454 | where = frag_more (0); |
6455 | u = UNWIND_LOW32 (&last_call_info->ci_unwind.descriptor); | |
252b5132 RH |
6456 | fix_new_hppa (frag_now, where - frag_now->fr_literal, 0, |
6457 | NULL, (offsetT) 0, NULL, | |
da6c73e0 | 6458 | 0, R_HPPA_ENTRY, e_fsel, 0, 0, u); |
252b5132 RH |
6459 | } |
6460 | #endif | |
6461 | } | |
6462 | ||
ecacdc7a AM |
6463 | /* Silly nonsense for pa_equ. The only half-sensible use for this is |
6464 | being able to subtract two register symbols that specify a range of | |
6465 | registers, to get the size of the range. */ | |
6466 | static int fudge_reg_expressions; | |
6467 | ||
6468 | int | |
6469 | hppa_force_reg_syms_absolute (resultP, op, rightP) | |
6470 | expressionS *resultP; | |
6471 | operatorT op ATTRIBUTE_UNUSED; | |
6472 | expressionS *rightP; | |
6473 | { | |
6474 | if (fudge_reg_expressions | |
6475 | && rightP->X_op == O_register | |
6476 | && resultP->X_op == O_register) | |
6477 | { | |
6478 | rightP->X_op = O_constant; | |
6479 | resultP->X_op = O_constant; | |
6480 | } | |
6481 | return 0; /* Continue normal expr handling. */ | |
6482 | } | |
6483 | ||
252b5132 RH |
6484 | /* Handle a .EQU pseudo-op. */ |
6485 | ||
6486 | static void | |
6487 | pa_equ (reg) | |
6488 | int reg; | |
6489 | { | |
6490 | label_symbol_struct *label_symbol = pa_get_label (); | |
6491 | symbolS *symbol; | |
6492 | ||
6493 | if (label_symbol) | |
6494 | { | |
6495 | symbol = label_symbol->lss_label; | |
6496 | if (reg) | |
ecacdc7a AM |
6497 | { |
6498 | strict = 1; | |
6499 | if (!pa_parse_number (&input_line_pointer, 0)) | |
6500 | as_bad (_(".REG expression must be a register")); | |
6501 | S_SET_VALUE (symbol, pa_number); | |
6502 | S_SET_SEGMENT (symbol, reg_section); | |
6503 | } | |
252b5132 | 6504 | else |
ecacdc7a AM |
6505 | { |
6506 | expressionS exp; | |
6507 | segT seg; | |
6508 | ||
6509 | fudge_reg_expressions = 1; | |
6510 | seg = expression (&exp); | |
6511 | fudge_reg_expressions = 0; | |
6512 | if (exp.X_op != O_constant | |
6513 | && exp.X_op != O_register) | |
6514 | { | |
6515 | if (exp.X_op != O_absent) | |
6516 | as_bad (_("bad or irreducible absolute expression; zero assumed")); | |
6517 | exp.X_add_number = 0; | |
6518 | seg = absolute_section; | |
6519 | } | |
6520 | S_SET_VALUE (symbol, (unsigned int) exp.X_add_number); | |
6521 | S_SET_SEGMENT (symbol, seg); | |
6522 | } | |
252b5132 RH |
6523 | } |
6524 | else | |
6525 | { | |
6526 | if (reg) | |
6527 | as_bad (_(".REG must use a label")); | |
6528 | else | |
6529 | as_bad (_(".EQU must use a label")); | |
6530 | } | |
6531 | ||
6532 | pa_undefine_label (); | |
6533 | demand_empty_rest_of_line (); | |
6534 | } | |
6535 | ||
6536 | /* Helper function. Does processing for the end of a function. This | |
6537 | usually involves creating some relocations or building special | |
6538 | symbols to mark the end of the function. */ | |
6539 | ||
6540 | static void | |
6541 | process_exit () | |
6542 | { | |
6543 | char *where; | |
6544 | ||
6545 | where = frag_more (0); | |
6546 | ||
6547 | #ifdef OBJ_ELF | |
6548 | /* Mark the end of the function, stuff away the location of the frag | |
6549 | for the end of the function, and finally call pa_build_unwind_subspace | |
6550 | to add an entry in the unwind table. */ | |
6551 | hppa_elf_mark_end_of_function (); | |
6552 | pa_build_unwind_subspace (last_call_info); | |
6553 | #else | |
6554 | /* SOM defers building of unwind descriptors until the link phase. | |
6555 | The assembler is responsible for creating an R_ENTRY relocation | |
6556 | to mark the beginning of a region and hold the unwind bits, and | |
6557 | for creating an R_EXIT relocation to mark the end of the region. | |
6558 | ||
6559 | FIXME. ELF should be using the same conventions! The problem | |
6560 | is an unwind requires too much relocation space. Hmmm. Maybe | |
6561 | if we split the unwind bits up between the relocations which | |
6562 | denote the entry and exit points. */ | |
6563 | fix_new_hppa (frag_now, where - frag_now->fr_literal, 0, | |
6564 | NULL, (offsetT) 0, | |
6565 | NULL, 0, R_HPPA_EXIT, e_fsel, 0, 0, | |
da6c73e0 | 6566 | UNWIND_HIGH32 (&last_call_info->ci_unwind.descriptor)); |
252b5132 RH |
6567 | #endif |
6568 | } | |
6569 | ||
6570 | /* Process a .EXIT pseudo-op. */ | |
6571 | ||
6572 | static void | |
6573 | pa_exit (unused) | |
3f9b03b5 | 6574 | int unused ATTRIBUTE_UNUSED; |
252b5132 | 6575 | { |
49863f82 | 6576 | #ifdef OBJ_SOM |
252b5132 RH |
6577 | /* We must have a valid space and subspace. */ |
6578 | pa_check_current_space_and_subspace (); | |
49863f82 | 6579 | #endif |
252b5132 RH |
6580 | |
6581 | if (!within_procedure) | |
6582 | as_bad (_(".EXIT must appear within a procedure")); | |
6583 | else | |
6584 | { | |
6585 | if (!callinfo_found) | |
6586 | as_bad (_("Missing .callinfo")); | |
6587 | else | |
6588 | { | |
6589 | if (!within_entry_exit) | |
6590 | as_bad (_("No .ENTRY for this .EXIT")); | |
6591 | else | |
6592 | { | |
6593 | within_entry_exit = FALSE; | |
6594 | process_exit (); | |
6595 | } | |
6596 | } | |
6597 | } | |
6598 | demand_empty_rest_of_line (); | |
6599 | } | |
6600 | ||
6601 | /* Process a .EXPORT directive. This makes functions external | |
6602 | and provides information such as argument relocation entries | |
6603 | to callers. */ | |
6604 | ||
6605 | static void | |
6606 | pa_export (unused) | |
3f9b03b5 | 6607 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
6608 | { |
6609 | char *name, c, *p; | |
6610 | symbolS *symbol; | |
6611 | ||
6612 | name = input_line_pointer; | |
6613 | c = get_symbol_end (); | |
6614 | /* Make sure the given symbol exists. */ | |
6615 | if ((symbol = symbol_find_or_make (name)) == NULL) | |
6616 | { | |
6617 | as_bad (_("Cannot define export symbol: %s\n"), name); | |
6618 | p = input_line_pointer; | |
6619 | *p = c; | |
6620 | input_line_pointer++; | |
6621 | } | |
6622 | else | |
6623 | { | |
20348649 | 6624 | /* OK. Set the external bits and process argument relocations. |
a28a3ccf | 6625 | For the HP, weak and global are not mutually exclusive. |
20348649 JL |
6626 | S_SET_EXTERNAL will not set BSF_GLOBAL if WEAK is set. |
6627 | Call S_SET_EXTERNAL to get the other processing. Manually | |
6628 | set BSF_GLOBAL when we get back. */ | |
252b5132 | 6629 | S_SET_EXTERNAL (symbol); |
20348649 | 6630 | symbol_get_bfdsym (symbol)->flags |= BSF_GLOBAL; |
252b5132 RH |
6631 | p = input_line_pointer; |
6632 | *p = c; | |
6633 | if (!is_end_of_statement ()) | |
6634 | { | |
6635 | input_line_pointer++; | |
6636 | pa_type_args (symbol, 1); | |
6637 | } | |
6638 | } | |
6639 | ||
6640 | demand_empty_rest_of_line (); | |
6641 | } | |
6642 | ||
6643 | /* Helper function to process arguments to a .EXPORT pseudo-op. */ | |
6644 | ||
6645 | static void | |
6646 | pa_type_args (symbolP, is_export) | |
6647 | symbolS *symbolP; | |
6648 | int is_export; | |
6649 | { | |
6650 | char *name, c, *p; | |
6651 | unsigned int temp, arg_reloc; | |
6652 | pa_symbol_type type = SYMBOL_TYPE_UNKNOWN; | |
904a31bf | 6653 | asymbol *bfdsym = symbol_get_bfdsym (symbolP); |
252b5132 RH |
6654 | |
6655 | if (strncasecmp (input_line_pointer, "absolute", 8) == 0) | |
6656 | ||
6657 | { | |
6658 | input_line_pointer += 8; | |
904a31bf | 6659 | bfdsym->flags &= ~BSF_FUNCTION; |
252b5132 RH |
6660 | S_SET_SEGMENT (symbolP, bfd_abs_section_ptr); |
6661 | type = SYMBOL_TYPE_ABSOLUTE; | |
6662 | } | |
6663 | else if (strncasecmp (input_line_pointer, "code", 4) == 0) | |
6664 | { | |
6665 | input_line_pointer += 4; | |
6666 | /* IMPORTing/EXPORTing CODE types for functions is meaningless for SOM, | |
6667 | instead one should be IMPORTing/EXPORTing ENTRY types. | |
6668 | ||
6669 | Complain if one tries to EXPORT a CODE type since that's never | |
6670 | done. Both GCC and HP C still try to IMPORT CODE types, so | |
6671 | silently fix them to be ENTRY types. */ | |
a0f75b47 | 6672 | if (S_IS_FUNCTION (symbolP)) |
252b5132 RH |
6673 | { |
6674 | if (is_export) | |
a0f75b47 ILT |
6675 | as_tsktsk (_("Using ENTRY rather than CODE in export directive for %s"), |
6676 | S_GET_NAME (symbolP)); | |
252b5132 | 6677 | |
904a31bf | 6678 | bfdsym->flags |= BSF_FUNCTION; |
252b5132 RH |
6679 | type = SYMBOL_TYPE_ENTRY; |
6680 | } | |
6681 | else | |
6682 | { | |
904a31bf | 6683 | bfdsym->flags &= ~BSF_FUNCTION; |
252b5132 RH |
6684 | type = SYMBOL_TYPE_CODE; |
6685 | } | |
6686 | } | |
6687 | else if (strncasecmp (input_line_pointer, "data", 4) == 0) | |
6688 | { | |
6689 | input_line_pointer += 4; | |
904a31bf AM |
6690 | bfdsym->flags &= ~BSF_FUNCTION; |
6691 | bfdsym->flags |= BSF_OBJECT; | |
252b5132 RH |
6692 | type = SYMBOL_TYPE_DATA; |
6693 | } | |
6694 | else if ((strncasecmp (input_line_pointer, "entry", 5) == 0)) | |
6695 | { | |
6696 | input_line_pointer += 5; | |
904a31bf | 6697 | bfdsym->flags |= BSF_FUNCTION; |
252b5132 RH |
6698 | type = SYMBOL_TYPE_ENTRY; |
6699 | } | |
6700 | else if (strncasecmp (input_line_pointer, "millicode", 9) == 0) | |
6701 | { | |
6702 | input_line_pointer += 9; | |
904a31bf AM |
6703 | bfdsym->flags |= BSF_FUNCTION; |
6704 | #ifdef OBJ_ELF | |
6705 | { | |
6706 | elf_symbol_type *elfsym = (elf_symbol_type *) bfdsym; | |
6707 | elfsym->internal_elf_sym.st_info = | |
6708 | ELF_ST_INFO (ELF_ST_BIND (elfsym->internal_elf_sym.st_info), | |
6709 | STT_PARISC_MILLI); | |
6710 | } | |
6711 | #endif | |
252b5132 RH |
6712 | type = SYMBOL_TYPE_MILLICODE; |
6713 | } | |
6714 | else if (strncasecmp (input_line_pointer, "plabel", 6) == 0) | |
6715 | { | |
6716 | input_line_pointer += 6; | |
904a31bf | 6717 | bfdsym->flags &= ~BSF_FUNCTION; |
252b5132 RH |
6718 | type = SYMBOL_TYPE_PLABEL; |
6719 | } | |
6720 | else if (strncasecmp (input_line_pointer, "pri_prog", 8) == 0) | |
6721 | { | |
6722 | input_line_pointer += 8; | |
904a31bf | 6723 | bfdsym->flags |= BSF_FUNCTION; |
252b5132 RH |
6724 | type = SYMBOL_TYPE_PRI_PROG; |
6725 | } | |
6726 | else if (strncasecmp (input_line_pointer, "sec_prog", 8) == 0) | |
6727 | { | |
6728 | input_line_pointer += 8; | |
904a31bf | 6729 | bfdsym->flags |= BSF_FUNCTION; |
252b5132 RH |
6730 | type = SYMBOL_TYPE_SEC_PROG; |
6731 | } | |
6732 | ||
6733 | /* SOM requires much more information about symbol types | |
6734 | than BFD understands. This is how we get this information | |
6735 | to the SOM BFD backend. */ | |
6736 | #ifdef obj_set_symbol_type | |
904a31bf | 6737 | obj_set_symbol_type (bfdsym, (int) type); |
252b5132 RH |
6738 | #endif |
6739 | ||
6740 | /* Now that the type of the exported symbol has been handled, | |
6741 | handle any argument relocation information. */ | |
6742 | while (!is_end_of_statement ()) | |
6743 | { | |
6744 | if (*input_line_pointer == ',') | |
6745 | input_line_pointer++; | |
6746 | name = input_line_pointer; | |
6747 | c = get_symbol_end (); | |
6748 | /* Argument sources. */ | |
6749 | if ((strncasecmp (name, "argw", 4) == 0)) | |
6750 | { | |
6751 | p = input_line_pointer; | |
6752 | *p = c; | |
6753 | input_line_pointer++; | |
6754 | temp = atoi (name + 4); | |
6755 | name = input_line_pointer; | |
6756 | c = get_symbol_end (); | |
6757 | arg_reloc = pa_align_arg_reloc (temp, pa_build_arg_reloc (name)); | |
25a8b250 | 6758 | #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC) |
ad1079af | 6759 | symbol_arg_reloc_info (symbolP) |= arg_reloc; |
49863f82 | 6760 | #endif |
252b5132 RH |
6761 | *input_line_pointer = c; |
6762 | } | |
6763 | /* The return value. */ | |
6764 | else if ((strncasecmp (name, "rtnval", 6)) == 0) | |
6765 | { | |
6766 | p = input_line_pointer; | |
6767 | *p = c; | |
6768 | input_line_pointer++; | |
6769 | name = input_line_pointer; | |
6770 | c = get_symbol_end (); | |
6771 | arg_reloc = pa_build_arg_reloc (name); | |
25a8b250 | 6772 | #if defined (OBJ_SOM) || defined (ELF_ARG_RELOC) |
ad1079af | 6773 | symbol_arg_reloc_info (symbolP) |= arg_reloc; |
49863f82 | 6774 | #endif |
252b5132 RH |
6775 | *input_line_pointer = c; |
6776 | } | |
6777 | /* Privelege level. */ | |
6778 | else if ((strncasecmp (name, "priv_lev", 8)) == 0) | |
6779 | { | |
6780 | p = input_line_pointer; | |
6781 | *p = c; | |
6782 | input_line_pointer++; | |
6783 | temp = atoi (input_line_pointer); | |
49863f82 | 6784 | #ifdef OBJ_SOM |
904a31bf | 6785 | ((obj_symbol_type *) bfdsym)->tc_data.ap.hppa_priv_level = temp; |
49863f82 | 6786 | #endif |
252b5132 RH |
6787 | c = get_symbol_end (); |
6788 | *input_line_pointer = c; | |
6789 | } | |
6790 | else | |
6791 | { | |
6792 | as_bad (_("Undefined .EXPORT/.IMPORT argument (ignored): %s"), name); | |
6793 | p = input_line_pointer; | |
6794 | *p = c; | |
6795 | } | |
6796 | if (!is_end_of_statement ()) | |
6797 | input_line_pointer++; | |
6798 | } | |
6799 | } | |
6800 | ||
6801 | /* Handle an .IMPORT pseudo-op. Any symbol referenced in a given | |
6802 | assembly file must either be defined in the assembly file, or | |
6803 | explicitly IMPORTED from another. */ | |
6804 | ||
6805 | static void | |
6806 | pa_import (unused) | |
3f9b03b5 | 6807 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
6808 | { |
6809 | char *name, c, *p; | |
6810 | symbolS *symbol; | |
6811 | ||
6812 | name = input_line_pointer; | |
6813 | c = get_symbol_end (); | |
6814 | ||
6815 | symbol = symbol_find (name); | |
6816 | /* Ugh. We might be importing a symbol defined earlier in the file, | |
6817 | in which case all the code below will really screw things up | |
6818 | (set the wrong segment, symbol flags & type, etc). */ | |
6819 | if (symbol == NULL || !S_IS_DEFINED (symbol)) | |
6820 | { | |
6821 | symbol = symbol_find_or_make (name); | |
6822 | p = input_line_pointer; | |
6823 | *p = c; | |
6824 | ||
6825 | if (!is_end_of_statement ()) | |
6826 | { | |
6827 | input_line_pointer++; | |
6828 | pa_type_args (symbol, 0); | |
6829 | } | |
6830 | else | |
6831 | { | |
6832 | /* Sigh. To be compatable with the HP assembler and to help | |
6833 | poorly written assembly code, we assign a type based on | |
b6ff326e | 6834 | the current segment. Note only BSF_FUNCTION really |
252b5132 RH |
6835 | matters, we do not need to set the full SYMBOL_TYPE_* info. */ |
6836 | if (now_seg == text_section) | |
a0f75b47 | 6837 | symbol_get_bfdsym (symbol)->flags |= BSF_FUNCTION; |
252b5132 RH |
6838 | |
6839 | /* If the section is undefined, then the symbol is undefined | |
6840 | Since this is an import, leave the section undefined. */ | |
6841 | S_SET_SEGMENT (symbol, bfd_und_section_ptr); | |
6842 | } | |
6843 | } | |
6844 | else | |
6845 | { | |
6846 | /* The symbol was already defined. Just eat everything up to | |
6847 | the end of the current statement. */ | |
6848 | while (!is_end_of_statement ()) | |
6849 | input_line_pointer++; | |
6850 | } | |
6851 | ||
6852 | demand_empty_rest_of_line (); | |
6853 | } | |
6854 | ||
6855 | /* Handle a .LABEL pseudo-op. */ | |
6856 | ||
6857 | static void | |
6858 | pa_label (unused) | |
3f9b03b5 | 6859 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
6860 | { |
6861 | char *name, c, *p; | |
6862 | ||
6863 | name = input_line_pointer; | |
6864 | c = get_symbol_end (); | |
6865 | ||
6866 | if (strlen (name) > 0) | |
6867 | { | |
6868 | colon (name); | |
6869 | p = input_line_pointer; | |
6870 | *p = c; | |
6871 | } | |
6872 | else | |
6873 | { | |
6874 | as_warn (_("Missing label name on .LABEL")); | |
6875 | } | |
6876 | ||
6877 | if (!is_end_of_statement ()) | |
6878 | { | |
6879 | as_warn (_("extra .LABEL arguments ignored.")); | |
6880 | ignore_rest_of_line (); | |
6881 | } | |
6882 | demand_empty_rest_of_line (); | |
6883 | } | |
6884 | ||
6885 | /* Handle a .LEAVE pseudo-op. This is not supported yet. */ | |
6886 | ||
6887 | static void | |
6888 | pa_leave (unused) | |
3f9b03b5 | 6889 | int unused ATTRIBUTE_UNUSED; |
252b5132 | 6890 | { |
49863f82 | 6891 | #ifdef OBJ_SOM |
252b5132 RH |
6892 | /* We must have a valid space and subspace. */ |
6893 | pa_check_current_space_and_subspace (); | |
49863f82 | 6894 | #endif |
252b5132 RH |
6895 | |
6896 | as_bad (_("The .LEAVE pseudo-op is not supported")); | |
6897 | demand_empty_rest_of_line (); | |
6898 | } | |
6899 | ||
6900 | /* Handle a .LEVEL pseudo-op. */ | |
6901 | ||
6902 | static void | |
6903 | pa_level (unused) | |
3f9b03b5 | 6904 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
6905 | { |
6906 | char *level; | |
6907 | ||
6908 | level = input_line_pointer; | |
6909 | if (strncmp (level, "1.0", 3) == 0) | |
6910 | { | |
6911 | input_line_pointer += 3; | |
6912 | if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 10)) | |
6913 | as_warn (_("could not set architecture and machine")); | |
6914 | } | |
6915 | else if (strncmp (level, "1.1", 3) == 0) | |
6916 | { | |
6917 | input_line_pointer += 3; | |
6918 | if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 11)) | |
6919 | as_warn (_("could not set architecture and machine")); | |
6920 | } | |
46031ca9 JL |
6921 | else if (strncmp (level, "2.0w", 4) == 0) |
6922 | { | |
6923 | input_line_pointer += 4; | |
6924 | if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 25)) | |
6925 | as_warn (_("could not set architecture and machine")); | |
6926 | } | |
252b5132 RH |
6927 | else if (strncmp (level, "2.0", 3) == 0) |
6928 | { | |
6929 | input_line_pointer += 3; | |
6930 | if (!bfd_set_arch_mach (stdoutput, bfd_arch_hppa, 20)) | |
6931 | as_warn (_("could not set architecture and machine")); | |
6932 | } | |
6933 | else | |
6934 | { | |
6935 | as_bad (_("Unrecognized .LEVEL argument\n")); | |
6936 | ignore_rest_of_line (); | |
6937 | } | |
6938 | demand_empty_rest_of_line (); | |
6939 | } | |
6940 | ||
6941 | /* Handle a .ORIGIN pseudo-op. */ | |
6942 | ||
6943 | static void | |
6944 | pa_origin (unused) | |
3f9b03b5 | 6945 | int unused ATTRIBUTE_UNUSED; |
252b5132 | 6946 | { |
49863f82 | 6947 | #ifdef OBJ_SOM |
252b5132 RH |
6948 | /* We must have a valid space and subspace. */ |
6949 | pa_check_current_space_and_subspace (); | |
49863f82 | 6950 | #endif |
252b5132 RH |
6951 | |
6952 | s_org (0); | |
6953 | pa_undefine_label (); | |
6954 | } | |
6955 | ||
6956 | /* Handle a .PARAM pseudo-op. This is much like a .EXPORT, except it | |
6957 | is for static functions. FIXME. Should share more code with .EXPORT. */ | |
6958 | ||
6959 | static void | |
6960 | pa_param (unused) | |
3f9b03b5 | 6961 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
6962 | { |
6963 | char *name, c, *p; | |
6964 | symbolS *symbol; | |
6965 | ||
6966 | name = input_line_pointer; | |
6967 | c = get_symbol_end (); | |
6968 | ||
6969 | if ((symbol = symbol_find_or_make (name)) == NULL) | |
6970 | { | |
6971 | as_bad (_("Cannot define static symbol: %s\n"), name); | |
6972 | p = input_line_pointer; | |
6973 | *p = c; | |
6974 | input_line_pointer++; | |
6975 | } | |
6976 | else | |
6977 | { | |
6978 | S_CLEAR_EXTERNAL (symbol); | |
6979 | p = input_line_pointer; | |
6980 | *p = c; | |
6981 | if (!is_end_of_statement ()) | |
6982 | { | |
6983 | input_line_pointer++; | |
6984 | pa_type_args (symbol, 0); | |
6985 | } | |
6986 | } | |
6987 | ||
6988 | demand_empty_rest_of_line (); | |
6989 | } | |
6990 | ||
6991 | /* Handle a .PROC pseudo-op. It is used to mark the beginning | |
ad1079af | 6992 | of a procedure from a syntactical point of view. */ |
252b5132 RH |
6993 | |
6994 | static void | |
6995 | pa_proc (unused) | |
3f9b03b5 | 6996 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
6997 | { |
6998 | struct call_info *call_info; | |
6999 | ||
49863f82 | 7000 | #ifdef OBJ_SOM |
252b5132 RH |
7001 | /* We must have a valid space and subspace. */ |
7002 | pa_check_current_space_and_subspace (); | |
49863f82 | 7003 | #endif |
252b5132 RH |
7004 | |
7005 | if (within_procedure) | |
7006 | as_fatal (_("Nested procedures")); | |
7007 | ||
7008 | /* Reset global variables for new procedure. */ | |
7009 | callinfo_found = FALSE; | |
7010 | within_procedure = TRUE; | |
7011 | ||
7012 | /* Create another call_info structure. */ | |
7013 | call_info = (struct call_info *) xmalloc (sizeof (struct call_info)); | |
7014 | ||
7015 | if (!call_info) | |
7016 | as_fatal (_("Cannot allocate unwind descriptor\n")); | |
7017 | ||
7018 | memset (call_info, 0, sizeof (struct call_info)); | |
7019 | ||
7020 | call_info->ci_next = NULL; | |
7021 | ||
7022 | if (call_info_root == NULL) | |
7023 | { | |
7024 | call_info_root = call_info; | |
7025 | last_call_info = call_info; | |
7026 | } | |
7027 | else | |
7028 | { | |
7029 | last_call_info->ci_next = call_info; | |
7030 | last_call_info = call_info; | |
7031 | } | |
7032 | ||
7033 | /* set up defaults on call_info structure */ | |
7034 | ||
7035 | call_info->ci_unwind.descriptor.cannot_unwind = 0; | |
7036 | call_info->ci_unwind.descriptor.region_desc = 1; | |
7037 | call_info->ci_unwind.descriptor.hpux_interrupt_marker = 0; | |
7038 | ||
7039 | /* If we got a .PROC pseudo-op, we know that the function is defined | |
7040 | locally. Make sure it gets into the symbol table. */ | |
7041 | { | |
7042 | label_symbol_struct *label_symbol = pa_get_label (); | |
7043 | ||
7044 | if (label_symbol) | |
7045 | { | |
7046 | if (label_symbol->lss_label) | |
7047 | { | |
7048 | last_call_info->start_symbol = label_symbol->lss_label; | |
a0f75b47 | 7049 | symbol_get_bfdsym (label_symbol->lss_label)->flags |= BSF_FUNCTION; |
252b5132 RH |
7050 | } |
7051 | else | |
7052 | as_bad (_("Missing function name for .PROC (corrupted label chain)")); | |
7053 | } | |
7054 | else | |
7055 | last_call_info->start_symbol = NULL; | |
7056 | } | |
7057 | ||
7058 | demand_empty_rest_of_line (); | |
7059 | } | |
7060 | ||
7061 | /* Process the syntatical end of a procedure. Make sure all the | |
7062 | appropriate pseudo-ops were found within the procedure. */ | |
7063 | ||
7064 | static void | |
7065 | pa_procend (unused) | |
3f9b03b5 | 7066 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
7067 | { |
7068 | ||
49863f82 | 7069 | #ifdef OBJ_SOM |
252b5132 RH |
7070 | /* We must have a valid space and subspace. */ |
7071 | pa_check_current_space_and_subspace (); | |
49863f82 | 7072 | #endif |
252b5132 RH |
7073 | |
7074 | /* If we are within a procedure definition, make sure we've | |
7075 | defined a label for the procedure; handle case where the | |
7076 | label was defined after the .PROC directive. | |
7077 | ||
7078 | Note there's not need to diddle with the segment or fragment | |
7079 | for the label symbol in this case. We have already switched | |
7080 | into the new $CODE$ subspace at this point. */ | |
7081 | if (within_procedure && last_call_info->start_symbol == NULL) | |
7082 | { | |
7083 | label_symbol_struct *label_symbol = pa_get_label (); | |
7084 | ||
7085 | if (label_symbol) | |
7086 | { | |
7087 | if (label_symbol->lss_label) | |
7088 | { | |
7089 | last_call_info->start_symbol = label_symbol->lss_label; | |
a0f75b47 ILT |
7090 | symbol_get_bfdsym (label_symbol->lss_label)->flags |
7091 | |= BSF_FUNCTION; | |
252b5132 RH |
7092 | #ifdef OBJ_SOM |
7093 | /* Also handle allocation of a fixup to hold the unwind | |
7094 | information when the label appears after the proc/procend. */ | |
7095 | if (within_entry_exit) | |
7096 | { | |
da6c73e0 AM |
7097 | char *where; |
7098 | unsigned int u; | |
252b5132 | 7099 | |
da6c73e0 AM |
7100 | where = frag_more (0); |
7101 | u = UNWIND_LOW32 (&last_call_info->ci_unwind.descriptor); | |
252b5132 RH |
7102 | fix_new_hppa (frag_now, where - frag_now->fr_literal, 0, |
7103 | NULL, (offsetT) 0, NULL, | |
da6c73e0 | 7104 | 0, R_HPPA_ENTRY, e_fsel, 0, 0, u); |
252b5132 RH |
7105 | } |
7106 | #endif | |
7107 | } | |
7108 | else | |
7109 | as_bad (_("Missing function name for .PROC (corrupted label chain)")); | |
7110 | } | |
7111 | else | |
7112 | as_bad (_("Missing function name for .PROC")); | |
7113 | } | |
7114 | ||
7115 | if (!within_procedure) | |
7116 | as_bad (_("misplaced .procend")); | |
7117 | ||
7118 | if (!callinfo_found) | |
7119 | as_bad (_("Missing .callinfo for this procedure")); | |
7120 | ||
7121 | if (within_entry_exit) | |
7122 | as_bad (_("Missing .EXIT for a .ENTRY")); | |
7123 | ||
7124 | #ifdef OBJ_ELF | |
7125 | /* ELF needs to mark the end of each function so that it can compute | |
7126 | the size of the function (apparently its needed in the symbol table). */ | |
7127 | hppa_elf_mark_end_of_function (); | |
7128 | #endif | |
7129 | ||
7130 | within_procedure = FALSE; | |
7131 | demand_empty_rest_of_line (); | |
7132 | pa_undefine_label (); | |
7133 | } | |
7134 | ||
3f9b03b5 | 7135 | #ifdef OBJ_SOM |
49863f82 JL |
7136 | /* If VALUE is an exact power of two between zero and 2^31, then |
7137 | return log2 (VALUE). Else return -1. */ | |
7138 | ||
7139 | static int | |
7140 | log2 (value) | |
7141 | int value; | |
7142 | { | |
7143 | int shift = 0; | |
7144 | ||
7145 | while ((1 << shift) != value && shift < 32) | |
7146 | shift++; | |
7147 | ||
7148 | if (shift >= 32) | |
7149 | return -1; | |
7150 | else | |
7151 | return shift; | |
7152 | } | |
7153 | ||
49863f82 JL |
7154 | /* Check to make sure we have a valid space and subspace. */ |
7155 | ||
7156 | static void | |
7157 | pa_check_current_space_and_subspace () | |
7158 | { | |
7159 | if (current_space == NULL) | |
7160 | as_fatal (_("Not in a space.\n")); | |
7161 | ||
7162 | if (current_subspace == NULL) | |
7163 | as_fatal (_("Not in a subspace.\n")); | |
7164 | } | |
7165 | ||
252b5132 RH |
7166 | /* Parse the parameters to a .SPACE directive; if CREATE_FLAG is nonzero, |
7167 | then create a new space entry to hold the information specified | |
7168 | by the parameters to the .SPACE directive. */ | |
7169 | ||
7170 | static sd_chain_struct * | |
7171 | pa_parse_space_stmt (space_name, create_flag) | |
7172 | char *space_name; | |
7173 | int create_flag; | |
7174 | { | |
7175 | char *name, *ptemp, c; | |
7176 | char loadable, defined, private, sort; | |
ecacdc7a | 7177 | int spnum; |
252b5132 RH |
7178 | asection *seg = NULL; |
7179 | sd_chain_struct *space; | |
7180 | ||
7181 | /* load default values */ | |
7182 | spnum = 0; | |
7183 | sort = 0; | |
7184 | loadable = TRUE; | |
7185 | defined = TRUE; | |
7186 | private = FALSE; | |
7187 | if (strcmp (space_name, "$TEXT$") == 0) | |
7188 | { | |
7189 | seg = pa_def_spaces[0].segment; | |
7190 | defined = pa_def_spaces[0].defined; | |
7191 | private = pa_def_spaces[0].private; | |
7192 | sort = pa_def_spaces[0].sort; | |
7193 | spnum = pa_def_spaces[0].spnum; | |
7194 | } | |
7195 | else if (strcmp (space_name, "$PRIVATE$") == 0) | |
7196 | { | |
7197 | seg = pa_def_spaces[1].segment; | |
7198 | defined = pa_def_spaces[1].defined; | |
7199 | private = pa_def_spaces[1].private; | |
7200 | sort = pa_def_spaces[1].sort; | |
7201 | spnum = pa_def_spaces[1].spnum; | |
7202 | } | |
7203 | ||
7204 | if (!is_end_of_statement ()) | |
7205 | { | |
7206 | print_errors = FALSE; | |
7207 | ptemp = input_line_pointer + 1; | |
7208 | /* First see if the space was specified as a number rather than | |
7209 | as a name. According to the PA assembly manual the rest of | |
7210 | the line should be ignored. */ | |
ecacdc7a AM |
7211 | strict = 0; |
7212 | pa_parse_number (&ptemp, 0); | |
7213 | if (pa_number >= 0) | |
252b5132 | 7214 | { |
ecacdc7a | 7215 | spnum = pa_number; |
252b5132 RH |
7216 | input_line_pointer = ptemp; |
7217 | } | |
7218 | else | |
7219 | { | |
7220 | while (!is_end_of_statement ()) | |
7221 | { | |
7222 | input_line_pointer++; | |
7223 | name = input_line_pointer; | |
7224 | c = get_symbol_end (); | |
7225 | if ((strncasecmp (name, "spnum", 5) == 0)) | |
7226 | { | |
7227 | *input_line_pointer = c; | |
7228 | input_line_pointer++; | |
7229 | spnum = get_absolute_expression (); | |
7230 | } | |
7231 | else if ((strncasecmp (name, "sort", 4) == 0)) | |
7232 | { | |
7233 | *input_line_pointer = c; | |
7234 | input_line_pointer++; | |
7235 | sort = get_absolute_expression (); | |
7236 | } | |
7237 | else if ((strncasecmp (name, "unloadable", 10) == 0)) | |
7238 | { | |
7239 | *input_line_pointer = c; | |
7240 | loadable = FALSE; | |
7241 | } | |
7242 | else if ((strncasecmp (name, "notdefined", 10) == 0)) | |
7243 | { | |
7244 | *input_line_pointer = c; | |
7245 | defined = FALSE; | |
7246 | } | |
7247 | else if ((strncasecmp (name, "private", 7) == 0)) | |
7248 | { | |
7249 | *input_line_pointer = c; | |
7250 | private = TRUE; | |
7251 | } | |
7252 | else | |
7253 | { | |
7254 | as_bad (_("Invalid .SPACE argument")); | |
7255 | *input_line_pointer = c; | |
7256 | if (!is_end_of_statement ()) | |
7257 | input_line_pointer++; | |
7258 | } | |
7259 | } | |
7260 | } | |
7261 | print_errors = TRUE; | |
7262 | } | |
7263 | ||
7264 | if (create_flag && seg == NULL) | |
7265 | seg = subseg_new (space_name, 0); | |
7266 | ||
7267 | /* If create_flag is nonzero, then create the new space with | |
7268 | the attributes computed above. Else set the values in | |
7269 | an already existing space -- this can only happen for | |
7270 | the first occurence of a built-in space. */ | |
7271 | if (create_flag) | |
7272 | space = create_new_space (space_name, spnum, loadable, defined, | |
7273 | private, sort, seg, 1); | |
7274 | else | |
7275 | { | |
7276 | space = is_defined_space (space_name); | |
7277 | SPACE_SPNUM (space) = spnum; | |
7278 | SPACE_DEFINED (space) = defined & 1; | |
7279 | SPACE_USER_DEFINED (space) = 1; | |
7280 | } | |
7281 | ||
7282 | #ifdef obj_set_section_attributes | |
7283 | obj_set_section_attributes (seg, defined, private, sort, spnum); | |
7284 | #endif | |
7285 | ||
7286 | return space; | |
7287 | } | |
7288 | ||
7289 | /* Handle a .SPACE pseudo-op; this switches the current space to the | |
7290 | given space, creating the new space if necessary. */ | |
7291 | ||
7292 | static void | |
7293 | pa_space (unused) | |
3f9b03b5 | 7294 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
7295 | { |
7296 | char *name, c, *space_name, *save_s; | |
252b5132 RH |
7297 | sd_chain_struct *sd_chain; |
7298 | ||
7299 | if (within_procedure) | |
7300 | { | |
7301 | as_bad (_("Can\'t change spaces within a procedure definition. Ignored")); | |
7302 | ignore_rest_of_line (); | |
7303 | } | |
7304 | else | |
7305 | { | |
7306 | /* Check for some of the predefined spaces. FIXME: most of the code | |
7307 | below is repeated several times, can we extract the common parts | |
7308 | and place them into a subroutine or something similar? */ | |
7309 | /* FIXME Is this (and the next IF stmt) really right? | |
7310 | What if INPUT_LINE_POINTER points to "$TEXT$FOO"? */ | |
7311 | if (strncmp (input_line_pointer, "$TEXT$", 6) == 0) | |
7312 | { | |
7313 | input_line_pointer += 6; | |
7314 | sd_chain = is_defined_space ("$TEXT$"); | |
7315 | if (sd_chain == NULL) | |
7316 | sd_chain = pa_parse_space_stmt ("$TEXT$", 1); | |
7317 | else if (SPACE_USER_DEFINED (sd_chain) == 0) | |
7318 | sd_chain = pa_parse_space_stmt ("$TEXT$", 0); | |
7319 | ||
7320 | current_space = sd_chain; | |
7321 | subseg_set (text_section, sd_chain->sd_last_subseg); | |
7322 | current_subspace | |
7323 | = pa_subsegment_to_subspace (text_section, | |
7324 | sd_chain->sd_last_subseg); | |
7325 | demand_empty_rest_of_line (); | |
7326 | return; | |
7327 | } | |
7328 | if (strncmp (input_line_pointer, "$PRIVATE$", 9) == 0) | |
7329 | { | |
7330 | input_line_pointer += 9; | |
7331 | sd_chain = is_defined_space ("$PRIVATE$"); | |
7332 | if (sd_chain == NULL) | |
7333 | sd_chain = pa_parse_space_stmt ("$PRIVATE$", 1); | |
7334 | else if (SPACE_USER_DEFINED (sd_chain) == 0) | |
7335 | sd_chain = pa_parse_space_stmt ("$PRIVATE$", 0); | |
7336 | ||
7337 | current_space = sd_chain; | |
7338 | subseg_set (data_section, sd_chain->sd_last_subseg); | |
7339 | current_subspace | |
7340 | = pa_subsegment_to_subspace (data_section, | |
7341 | sd_chain->sd_last_subseg); | |
7342 | demand_empty_rest_of_line (); | |
7343 | return; | |
7344 | } | |
7345 | if (!strncasecmp (input_line_pointer, | |
7346 | GDB_DEBUG_SPACE_NAME, | |
7347 | strlen (GDB_DEBUG_SPACE_NAME))) | |
7348 | { | |
7349 | input_line_pointer += strlen (GDB_DEBUG_SPACE_NAME); | |
7350 | sd_chain = is_defined_space (GDB_DEBUG_SPACE_NAME); | |
7351 | if (sd_chain == NULL) | |
7352 | sd_chain = pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME, 1); | |
7353 | else if (SPACE_USER_DEFINED (sd_chain) == 0) | |
7354 | sd_chain = pa_parse_space_stmt (GDB_DEBUG_SPACE_NAME, 0); | |
7355 | ||
7356 | current_space = sd_chain; | |
7357 | ||
7358 | { | |
7359 | asection *gdb_section | |
7360 | = bfd_make_section_old_way (stdoutput, GDB_DEBUG_SPACE_NAME); | |
7361 | ||
7362 | subseg_set (gdb_section, sd_chain->sd_last_subseg); | |
7363 | current_subspace | |
7364 | = pa_subsegment_to_subspace (gdb_section, | |
7365 | sd_chain->sd_last_subseg); | |
7366 | } | |
7367 | demand_empty_rest_of_line (); | |
7368 | return; | |
7369 | } | |
7370 | ||
7371 | /* It could be a space specified by number. */ | |
7372 | print_errors = 0; | |
7373 | save_s = input_line_pointer; | |
ecacdc7a AM |
7374 | strict = 0; |
7375 | pa_parse_number (&input_line_pointer, 0); | |
7376 | if (pa_number >= 0) | |
252b5132 | 7377 | { |
ecacdc7a | 7378 | if ((sd_chain = pa_find_space_by_number (pa_number))) |
252b5132 RH |
7379 | { |
7380 | current_space = sd_chain; | |
7381 | ||
7382 | subseg_set (sd_chain->sd_seg, sd_chain->sd_last_subseg); | |
7383 | current_subspace | |
7384 | = pa_subsegment_to_subspace (sd_chain->sd_seg, | |
7385 | sd_chain->sd_last_subseg); | |
7386 | demand_empty_rest_of_line (); | |
7387 | return; | |
7388 | } | |
7389 | } | |
7390 | ||
7391 | /* Not a number, attempt to create a new space. */ | |
7392 | print_errors = 1; | |
7393 | input_line_pointer = save_s; | |
7394 | name = input_line_pointer; | |
7395 | c = get_symbol_end (); | |
7396 | space_name = xmalloc (strlen (name) + 1); | |
7397 | strcpy (space_name, name); | |
7398 | *input_line_pointer = c; | |
7399 | ||
7400 | sd_chain = pa_parse_space_stmt (space_name, 1); | |
7401 | current_space = sd_chain; | |
7402 | ||
7403 | subseg_set (sd_chain->sd_seg, sd_chain->sd_last_subseg); | |
7404 | current_subspace = pa_subsegment_to_subspace (sd_chain->sd_seg, | |
7405 | sd_chain->sd_last_subseg); | |
7406 | demand_empty_rest_of_line (); | |
7407 | } | |
7408 | } | |
7409 | ||
7410 | /* Switch to a new space. (I think). FIXME. */ | |
7411 | ||
7412 | static void | |
7413 | pa_spnum (unused) | |
3f9b03b5 | 7414 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
7415 | { |
7416 | char *name; | |
7417 | char c; | |
7418 | char *p; | |
7419 | sd_chain_struct *space; | |
7420 | ||
7421 | name = input_line_pointer; | |
7422 | c = get_symbol_end (); | |
7423 | space = is_defined_space (name); | |
7424 | if (space) | |
7425 | { | |
7426 | p = frag_more (4); | |
7427 | md_number_to_chars (p, SPACE_SPNUM (space), 4); | |
7428 | } | |
7429 | else | |
7430 | as_warn (_("Undefined space: '%s' Assuming space number = 0."), name); | |
7431 | ||
7432 | *input_line_pointer = c; | |
7433 | demand_empty_rest_of_line (); | |
7434 | } | |
7435 | ||
252b5132 RH |
7436 | /* Handle a .SUBSPACE pseudo-op; this switches the current subspace to the |
7437 | given subspace, creating the new subspace if necessary. | |
7438 | ||
7439 | FIXME. Should mirror pa_space more closely, in particular how | |
7440 | they're broken up into subroutines. */ | |
7441 | ||
7442 | static void | |
7443 | pa_subspace (create_new) | |
7444 | int create_new; | |
7445 | { | |
49863f82 | 7446 | char *name, *ss_name, c; |
252b5132 RH |
7447 | char loadable, code_only, common, dup_common, zero, sort; |
7448 | int i, access, space_index, alignment, quadrant, applicable, flags; | |
7449 | sd_chain_struct *space; | |
7450 | ssd_chain_struct *ssd; | |
7451 | asection *section; | |
7452 | ||
7453 | if (current_space == NULL) | |
7454 | as_fatal (_("Must be in a space before changing or declaring subspaces.\n")); | |
7455 | ||
7456 | if (within_procedure) | |
7457 | { | |
7458 | as_bad (_("Can\'t change subspaces within a procedure definition. Ignored")); | |
7459 | ignore_rest_of_line (); | |
7460 | } | |
7461 | else | |
7462 | { | |
7463 | name = input_line_pointer; | |
7464 | c = get_symbol_end (); | |
7465 | ss_name = xmalloc (strlen (name) + 1); | |
7466 | strcpy (ss_name, name); | |
7467 | *input_line_pointer = c; | |
7468 | ||
7469 | /* Load default values. */ | |
7470 | sort = 0; | |
7471 | access = 0x7f; | |
7472 | loadable = 1; | |
7473 | common = 0; | |
7474 | dup_common = 0; | |
7475 | code_only = 0; | |
7476 | zero = 0; | |
7477 | space_index = ~0; | |
7478 | alignment = 1; | |
7479 | quadrant = 0; | |
252b5132 RH |
7480 | |
7481 | space = current_space; | |
7482 | if (create_new) | |
7483 | ssd = NULL; | |
7484 | else | |
7485 | ssd = is_defined_subspace (ss_name); | |
7486 | /* Allow user to override the builtin attributes of subspaces. But | |
7487 | only allow the attributes to be changed once! */ | |
7488 | if (ssd && SUBSPACE_DEFINED (ssd)) | |
7489 | { | |
7490 | subseg_set (ssd->ssd_seg, ssd->ssd_subseg); | |
7491 | current_subspace = ssd; | |
7492 | if (!is_end_of_statement ()) | |
7493 | as_warn (_("Parameters of an existing subspace can\'t be modified")); | |
7494 | demand_empty_rest_of_line (); | |
7495 | return; | |
7496 | } | |
7497 | else | |
7498 | { | |
7499 | /* A new subspace. Load default values if it matches one of | |
7500 | the builtin subspaces. */ | |
7501 | i = 0; | |
7502 | while (pa_def_subspaces[i].name) | |
7503 | { | |
7504 | if (strcasecmp (pa_def_subspaces[i].name, ss_name) == 0) | |
7505 | { | |
7506 | loadable = pa_def_subspaces[i].loadable; | |
7507 | common = pa_def_subspaces[i].common; | |
7508 | dup_common = pa_def_subspaces[i].dup_common; | |
7509 | code_only = pa_def_subspaces[i].code_only; | |
7510 | zero = pa_def_subspaces[i].zero; | |
7511 | space_index = pa_def_subspaces[i].space_index; | |
7512 | alignment = pa_def_subspaces[i].alignment; | |
7513 | quadrant = pa_def_subspaces[i].quadrant; | |
7514 | access = pa_def_subspaces[i].access; | |
7515 | sort = pa_def_subspaces[i].sort; | |
252b5132 RH |
7516 | break; |
7517 | } | |
7518 | i++; | |
7519 | } | |
7520 | } | |
7521 | ||
7522 | /* We should be working with a new subspace now. Fill in | |
7523 | any information as specified by the user. */ | |
7524 | if (!is_end_of_statement ()) | |
7525 | { | |
7526 | input_line_pointer++; | |
7527 | while (!is_end_of_statement ()) | |
7528 | { | |
7529 | name = input_line_pointer; | |
7530 | c = get_symbol_end (); | |
7531 | if ((strncasecmp (name, "quad", 4) == 0)) | |
7532 | { | |
7533 | *input_line_pointer = c; | |
7534 | input_line_pointer++; | |
7535 | quadrant = get_absolute_expression (); | |
7536 | } | |
7537 | else if ((strncasecmp (name, "align", 5) == 0)) | |
7538 | { | |
7539 | *input_line_pointer = c; | |
7540 | input_line_pointer++; | |
7541 | alignment = get_absolute_expression (); | |
7542 | if (log2 (alignment) == -1) | |
7543 | { | |
7544 | as_bad (_("Alignment must be a power of 2")); | |
7545 | alignment = 1; | |
7546 | } | |
7547 | } | |
7548 | else if ((strncasecmp (name, "access", 6) == 0)) | |
7549 | { | |
7550 | *input_line_pointer = c; | |
7551 | input_line_pointer++; | |
7552 | access = get_absolute_expression (); | |
7553 | } | |
7554 | else if ((strncasecmp (name, "sort", 4) == 0)) | |
7555 | { | |
7556 | *input_line_pointer = c; | |
7557 | input_line_pointer++; | |
7558 | sort = get_absolute_expression (); | |
7559 | } | |
7560 | else if ((strncasecmp (name, "code_only", 9) == 0)) | |
7561 | { | |
7562 | *input_line_pointer = c; | |
7563 | code_only = 1; | |
7564 | } | |
7565 | else if ((strncasecmp (name, "unloadable", 10) == 0)) | |
7566 | { | |
7567 | *input_line_pointer = c; | |
7568 | loadable = 0; | |
7569 | } | |
7570 | else if ((strncasecmp (name, "common", 6) == 0)) | |
7571 | { | |
7572 | *input_line_pointer = c; | |
7573 | common = 1; | |
7574 | } | |
7575 | else if ((strncasecmp (name, "dup_comm", 8) == 0)) | |
7576 | { | |
7577 | *input_line_pointer = c; | |
7578 | dup_common = 1; | |
7579 | } | |
7580 | else if ((strncasecmp (name, "zero", 4) == 0)) | |
7581 | { | |
7582 | *input_line_pointer = c; | |
7583 | zero = 1; | |
7584 | } | |
7585 | else if ((strncasecmp (name, "first", 5) == 0)) | |
7586 | as_bad (_("FIRST not supported as a .SUBSPACE argument")); | |
7587 | else | |
7588 | as_bad (_("Invalid .SUBSPACE argument")); | |
7589 | if (!is_end_of_statement ()) | |
7590 | input_line_pointer++; | |
7591 | } | |
7592 | } | |
7593 | ||
7594 | /* Compute a reasonable set of BFD flags based on the information | |
7595 | in the .subspace directive. */ | |
7596 | applicable = bfd_applicable_section_flags (stdoutput); | |
7597 | flags = 0; | |
7598 | if (loadable) | |
7599 | flags |= (SEC_ALLOC | SEC_LOAD); | |
7600 | if (code_only) | |
7601 | flags |= SEC_CODE; | |
7602 | if (common || dup_common) | |
7603 | flags |= SEC_IS_COMMON; | |
7604 | ||
7605 | flags |= SEC_RELOC | SEC_HAS_CONTENTS; | |
7606 | ||
7607 | /* This is a zero-filled subspace (eg BSS). */ | |
7608 | if (zero) | |
7609 | flags &= ~(SEC_LOAD | SEC_HAS_CONTENTS); | |
7610 | ||
7611 | applicable &= flags; | |
7612 | ||
7613 | /* If this is an existing subspace, then we want to use the | |
7614 | segment already associated with the subspace. | |
7615 | ||
7616 | FIXME NOW! ELF BFD doesn't appear to be ready to deal with | |
7617 | lots of sections. It might be a problem in the PA ELF | |
7618 | code, I do not know yet. For now avoid creating anything | |
7619 | but the "standard" sections for ELF. */ | |
7620 | if (create_new) | |
7621 | section = subseg_force_new (ss_name, 0); | |
7622 | else if (ssd) | |
7623 | section = ssd->ssd_seg; | |
252b5132 RH |
7624 | else |
7625 | section = subseg_new (ss_name, 0); | |
7626 | ||
7627 | if (zero) | |
7628 | seg_info (section)->bss = 1; | |
7629 | ||
7630 | /* Now set the flags. */ | |
7631 | bfd_set_section_flags (stdoutput, section, applicable); | |
7632 | ||
7633 | /* Record any alignment request for this section. */ | |
7634 | record_alignment (section, log2 (alignment)); | |
7635 | ||
7636 | /* Set the starting offset for this section. */ | |
7637 | bfd_set_section_vma (stdoutput, section, | |
7638 | pa_subspace_start (space, quadrant)); | |
7639 | ||
7640 | /* Now that all the flags are set, update an existing subspace, | |
7641 | or create a new one. */ | |
7642 | if (ssd) | |
7643 | ||
7644 | current_subspace = update_subspace (space, ss_name, loadable, | |
7645 | code_only, common, dup_common, | |
7646 | sort, zero, access, space_index, | |
7647 | alignment, quadrant, | |
7648 | section); | |
7649 | else | |
7650 | current_subspace = create_new_subspace (space, ss_name, loadable, | |
7651 | code_only, common, | |
7652 | dup_common, zero, sort, | |
7653 | access, space_index, | |
7654 | alignment, quadrant, section); | |
7655 | ||
7656 | demand_empty_rest_of_line (); | |
7657 | current_subspace->ssd_seg = section; | |
7658 | subseg_set (current_subspace->ssd_seg, current_subspace->ssd_subseg); | |
7659 | } | |
7660 | SUBSPACE_DEFINED (current_subspace) = 1; | |
7661 | } | |
7662 | ||
252b5132 RH |
7663 | /* Create default space and subspace dictionaries. */ |
7664 | ||
7665 | static void | |
7666 | pa_spaces_begin () | |
7667 | { | |
7668 | int i; | |
7669 | ||
7670 | space_dict_root = NULL; | |
7671 | space_dict_last = NULL; | |
7672 | ||
7673 | i = 0; | |
7674 | while (pa_def_spaces[i].name) | |
7675 | { | |
7676 | char *name; | |
7677 | ||
7678 | /* Pick the right name to use for the new section. */ | |
49863f82 | 7679 | name = pa_def_spaces[i].name; |
252b5132 RH |
7680 | |
7681 | pa_def_spaces[i].segment = subseg_new (name, 0); | |
7682 | create_new_space (pa_def_spaces[i].name, pa_def_spaces[i].spnum, | |
7683 | pa_def_spaces[i].loadable, pa_def_spaces[i].defined, | |
7684 | pa_def_spaces[i].private, pa_def_spaces[i].sort, | |
7685 | pa_def_spaces[i].segment, 0); | |
7686 | i++; | |
7687 | } | |
7688 | ||
7689 | i = 0; | |
7690 | while (pa_def_subspaces[i].name) | |
7691 | { | |
7692 | char *name; | |
7693 | int applicable, subsegment; | |
7694 | asection *segment = NULL; | |
7695 | sd_chain_struct *space; | |
7696 | ||
7697 | /* Pick the right name for the new section and pick the right | |
7698 | subsegment number. */ | |
49863f82 JL |
7699 | name = pa_def_subspaces[i].name; |
7700 | subsegment = 0; | |
252b5132 RH |
7701 | |
7702 | /* Create the new section. */ | |
7703 | segment = subseg_new (name, subsegment); | |
7704 | ||
252b5132 RH |
7705 | /* For SOM we want to replace the standard .text, .data, and .bss |
7706 | sections with our own. We also want to set BFD flags for | |
7707 | all the built-in subspaces. */ | |
49863f82 | 7708 | if (!strcmp (pa_def_subspaces[i].name, "$CODE$")) |
252b5132 RH |
7709 | { |
7710 | text_section = segment; | |
7711 | applicable = bfd_applicable_section_flags (stdoutput); | |
7712 | bfd_set_section_flags (stdoutput, segment, | |
7713 | applicable & (SEC_ALLOC | SEC_LOAD | |
7714 | | SEC_RELOC | SEC_CODE | |
7715 | | SEC_READONLY | |
7716 | | SEC_HAS_CONTENTS)); | |
7717 | } | |
49863f82 | 7718 | else if (!strcmp (pa_def_subspaces[i].name, "$DATA$")) |
252b5132 RH |
7719 | { |
7720 | data_section = segment; | |
7721 | applicable = bfd_applicable_section_flags (stdoutput); | |
7722 | bfd_set_section_flags (stdoutput, segment, | |
7723 | applicable & (SEC_ALLOC | SEC_LOAD | |
7724 | | SEC_RELOC | |
7725 | | SEC_HAS_CONTENTS)); | |
7726 | ||
252b5132 | 7727 | } |
49863f82 | 7728 | else if (!strcmp (pa_def_subspaces[i].name, "$BSS$")) |
252b5132 RH |
7729 | { |
7730 | bss_section = segment; | |
7731 | applicable = bfd_applicable_section_flags (stdoutput); | |
7732 | bfd_set_section_flags (stdoutput, segment, | |
7733 | applicable & SEC_ALLOC); | |
7734 | } | |
49863f82 | 7735 | else if (!strcmp (pa_def_subspaces[i].name, "$LIT$")) |
252b5132 RH |
7736 | { |
7737 | applicable = bfd_applicable_section_flags (stdoutput); | |
7738 | bfd_set_section_flags (stdoutput, segment, | |
7739 | applicable & (SEC_ALLOC | SEC_LOAD | |
7740 | | SEC_RELOC | |
7741 | | SEC_READONLY | |
7742 | | SEC_HAS_CONTENTS)); | |
7743 | } | |
49863f82 | 7744 | else if (!strcmp (pa_def_subspaces[i].name, "$MILLICODE$")) |
252b5132 RH |
7745 | { |
7746 | applicable = bfd_applicable_section_flags (stdoutput); | |
7747 | bfd_set_section_flags (stdoutput, segment, | |
7748 | applicable & (SEC_ALLOC | SEC_LOAD | |
7749 | | SEC_RELOC | |
7750 | | SEC_READONLY | |
7751 | | SEC_HAS_CONTENTS)); | |
7752 | } | |
49863f82 | 7753 | else if (!strcmp (pa_def_subspaces[i].name, "$UNWIND$")) |
252b5132 RH |
7754 | { |
7755 | applicable = bfd_applicable_section_flags (stdoutput); | |
7756 | bfd_set_section_flags (stdoutput, segment, | |
7757 | applicable & (SEC_ALLOC | SEC_LOAD | |
7758 | | SEC_RELOC | |
7759 | | SEC_READONLY | |
7760 | | SEC_HAS_CONTENTS)); | |
7761 | } | |
7762 | ||
7763 | /* Find the space associated with this subspace. */ | |
7764 | space = pa_segment_to_space (pa_def_spaces[pa_def_subspaces[i]. | |
7765 | def_space_index].segment); | |
7766 | if (space == NULL) | |
7767 | { | |
7768 | as_fatal (_("Internal error: Unable to find containing space for %s."), | |
7769 | pa_def_subspaces[i].name); | |
7770 | } | |
7771 | ||
7772 | create_new_subspace (space, name, | |
7773 | pa_def_subspaces[i].loadable, | |
7774 | pa_def_subspaces[i].code_only, | |
7775 | pa_def_subspaces[i].common, | |
7776 | pa_def_subspaces[i].dup_common, | |
7777 | pa_def_subspaces[i].zero, | |
7778 | pa_def_subspaces[i].sort, | |
7779 | pa_def_subspaces[i].access, | |
7780 | pa_def_subspaces[i].space_index, | |
7781 | pa_def_subspaces[i].alignment, | |
7782 | pa_def_subspaces[i].quadrant, | |
7783 | segment); | |
7784 | i++; | |
7785 | } | |
7786 | } | |
7787 | ||
252b5132 RH |
7788 | /* Create a new space NAME, with the appropriate flags as defined |
7789 | by the given parameters. */ | |
7790 | ||
7791 | static sd_chain_struct * | |
7792 | create_new_space (name, spnum, loadable, defined, private, | |
7793 | sort, seg, user_defined) | |
7794 | char *name; | |
7795 | int spnum; | |
7796 | int loadable; | |
7797 | int defined; | |
7798 | int private; | |
7799 | int sort; | |
7800 | asection *seg; | |
7801 | int user_defined; | |
7802 | { | |
7803 | sd_chain_struct *chain_entry; | |
7804 | ||
7805 | chain_entry = (sd_chain_struct *) xmalloc (sizeof (sd_chain_struct)); | |
7806 | if (!chain_entry) | |
7807 | as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"), | |
7808 | name); | |
7809 | ||
7810 | SPACE_NAME (chain_entry) = (char *) xmalloc (strlen (name) + 1); | |
7811 | strcpy (SPACE_NAME (chain_entry), name); | |
7812 | SPACE_DEFINED (chain_entry) = defined; | |
7813 | SPACE_USER_DEFINED (chain_entry) = user_defined; | |
7814 | SPACE_SPNUM (chain_entry) = spnum; | |
7815 | ||
7816 | chain_entry->sd_seg = seg; | |
7817 | chain_entry->sd_last_subseg = -1; | |
7818 | chain_entry->sd_subspaces = NULL; | |
7819 | chain_entry->sd_next = NULL; | |
7820 | ||
7821 | /* Find spot for the new space based on its sort key. */ | |
7822 | if (!space_dict_last) | |
7823 | space_dict_last = chain_entry; | |
7824 | ||
7825 | if (space_dict_root == NULL) | |
7826 | space_dict_root = chain_entry; | |
7827 | else | |
7828 | { | |
7829 | sd_chain_struct *chain_pointer; | |
7830 | sd_chain_struct *prev_chain_pointer; | |
7831 | ||
7832 | chain_pointer = space_dict_root; | |
7833 | prev_chain_pointer = NULL; | |
7834 | ||
7835 | while (chain_pointer) | |
7836 | { | |
7837 | prev_chain_pointer = chain_pointer; | |
7838 | chain_pointer = chain_pointer->sd_next; | |
7839 | } | |
7840 | ||
7841 | /* At this point we've found the correct place to add the new | |
7842 | entry. So add it and update the linked lists as appropriate. */ | |
7843 | if (prev_chain_pointer) | |
7844 | { | |
7845 | chain_entry->sd_next = chain_pointer; | |
7846 | prev_chain_pointer->sd_next = chain_entry; | |
7847 | } | |
7848 | else | |
7849 | { | |
7850 | space_dict_root = chain_entry; | |
7851 | chain_entry->sd_next = chain_pointer; | |
7852 | } | |
7853 | ||
7854 | if (chain_entry->sd_next == NULL) | |
7855 | space_dict_last = chain_entry; | |
7856 | } | |
7857 | ||
7858 | /* This is here to catch predefined spaces which do not get | |
7859 | modified by the user's input. Another call is found at | |
7860 | the bottom of pa_parse_space_stmt to handle cases where | |
7861 | the user modifies a predefined space. */ | |
7862 | #ifdef obj_set_section_attributes | |
7863 | obj_set_section_attributes (seg, defined, private, sort, spnum); | |
7864 | #endif | |
7865 | ||
7866 | return chain_entry; | |
7867 | } | |
7868 | ||
7869 | /* Create a new subspace NAME, with the appropriate flags as defined | |
7870 | by the given parameters. | |
7871 | ||
7872 | Add the new subspace to the subspace dictionary chain in numerical | |
7873 | order as defined by the SORT entries. */ | |
7874 | ||
7875 | static ssd_chain_struct * | |
7876 | create_new_subspace (space, name, loadable, code_only, common, | |
7877 | dup_common, is_zero, sort, access, space_index, | |
7878 | alignment, quadrant, seg) | |
7879 | sd_chain_struct *space; | |
7880 | char *name; | |
7881 | int loadable, code_only, common, dup_common, is_zero; | |
7882 | int sort; | |
7883 | int access; | |
7884 | int space_index; | |
7885 | int alignment; | |
7886 | int quadrant; | |
7887 | asection *seg; | |
7888 | { | |
7889 | ssd_chain_struct *chain_entry; | |
7890 | ||
7891 | chain_entry = (ssd_chain_struct *) xmalloc (sizeof (ssd_chain_struct)); | |
7892 | if (!chain_entry) | |
7893 | as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name); | |
7894 | ||
7895 | SUBSPACE_NAME (chain_entry) = (char *) xmalloc (strlen (name) + 1); | |
7896 | strcpy (SUBSPACE_NAME (chain_entry), name); | |
7897 | ||
7898 | /* Initialize subspace_defined. When we hit a .subspace directive | |
7899 | we'll set it to 1 which "locks-in" the subspace attributes. */ | |
7900 | SUBSPACE_DEFINED (chain_entry) = 0; | |
7901 | ||
49863f82 | 7902 | chain_entry->ssd_subseg = 0; |
252b5132 RH |
7903 | chain_entry->ssd_seg = seg; |
7904 | chain_entry->ssd_next = NULL; | |
7905 | ||
7906 | /* Find spot for the new subspace based on its sort key. */ | |
7907 | if (space->sd_subspaces == NULL) | |
7908 | space->sd_subspaces = chain_entry; | |
7909 | else | |
7910 | { | |
7911 | ssd_chain_struct *chain_pointer; | |
7912 | ssd_chain_struct *prev_chain_pointer; | |
7913 | ||
7914 | chain_pointer = space->sd_subspaces; | |
7915 | prev_chain_pointer = NULL; | |
7916 | ||
7917 | while (chain_pointer) | |
7918 | { | |
7919 | prev_chain_pointer = chain_pointer; | |
7920 | chain_pointer = chain_pointer->ssd_next; | |
7921 | } | |
7922 | ||
7923 | /* Now we have somewhere to put the new entry. Insert it and update | |
7924 | the links. */ | |
7925 | if (prev_chain_pointer) | |
7926 | { | |
7927 | chain_entry->ssd_next = chain_pointer; | |
7928 | prev_chain_pointer->ssd_next = chain_entry; | |
7929 | } | |
7930 | else | |
7931 | { | |
7932 | space->sd_subspaces = chain_entry; | |
7933 | chain_entry->ssd_next = chain_pointer; | |
7934 | } | |
7935 | } | |
7936 | ||
7937 | #ifdef obj_set_subsection_attributes | |
7938 | obj_set_subsection_attributes (seg, space->sd_seg, access, | |
7939 | sort, quadrant); | |
7940 | #endif | |
7941 | ||
7942 | return chain_entry; | |
7943 | } | |
7944 | ||
7945 | /* Update the information for the given subspace based upon the | |
7946 | various arguments. Return the modified subspace chain entry. */ | |
7947 | ||
7948 | static ssd_chain_struct * | |
7949 | update_subspace (space, name, loadable, code_only, common, dup_common, sort, | |
7950 | zero, access, space_index, alignment, quadrant, section) | |
7951 | sd_chain_struct *space; | |
7952 | char *name; | |
7953 | int loadable; | |
7954 | int code_only; | |
7955 | int common; | |
7956 | int dup_common; | |
7957 | int zero; | |
7958 | int sort; | |
7959 | int access; | |
7960 | int space_index; | |
7961 | int alignment; | |
7962 | int quadrant; | |
7963 | asection *section; | |
7964 | { | |
7965 | ssd_chain_struct *chain_entry; | |
7966 | ||
7967 | chain_entry = is_defined_subspace (name); | |
7968 | ||
7969 | #ifdef obj_set_subsection_attributes | |
7970 | obj_set_subsection_attributes (section, space->sd_seg, access, | |
7971 | sort, quadrant); | |
7972 | #endif | |
7973 | ||
7974 | return chain_entry; | |
7975 | } | |
7976 | ||
7977 | /* Return the space chain entry for the space with the name NAME or | |
7978 | NULL if no such space exists. */ | |
7979 | ||
7980 | static sd_chain_struct * | |
7981 | is_defined_space (name) | |
7982 | char *name; | |
7983 | { | |
7984 | sd_chain_struct *chain_pointer; | |
7985 | ||
7986 | for (chain_pointer = space_dict_root; | |
7987 | chain_pointer; | |
7988 | chain_pointer = chain_pointer->sd_next) | |
7989 | { | |
7990 | if (strcmp (SPACE_NAME (chain_pointer), name) == 0) | |
7991 | return chain_pointer; | |
7992 | } | |
7993 | ||
7994 | /* No mapping from segment to space was found. Return NULL. */ | |
7995 | return NULL; | |
7996 | } | |
7997 | ||
7998 | /* Find and return the space associated with the given seg. If no mapping | |
7999 | from the given seg to a space is found, then return NULL. | |
8000 | ||
8001 | Unlike subspaces, the number of spaces is not expected to grow much, | |
8002 | so a linear exhaustive search is OK here. */ | |
8003 | ||
8004 | static sd_chain_struct * | |
8005 | pa_segment_to_space (seg) | |
8006 | asection *seg; | |
8007 | { | |
8008 | sd_chain_struct *space_chain; | |
8009 | ||
8010 | /* Walk through each space looking for the correct mapping. */ | |
8011 | for (space_chain = space_dict_root; | |
8012 | space_chain; | |
8013 | space_chain = space_chain->sd_next) | |
8014 | { | |
8015 | if (space_chain->sd_seg == seg) | |
8016 | return space_chain; | |
8017 | } | |
8018 | ||
8019 | /* Mapping was not found. Return NULL. */ | |
8020 | return NULL; | |
8021 | } | |
8022 | ||
8023 | /* Return the space chain entry for the subspace with the name NAME or | |
8024 | NULL if no such subspace exists. | |
8025 | ||
8026 | Uses a linear search through all the spaces and subspaces, this may | |
8027 | not be appropriate if we ever being placing each function in its | |
8028 | own subspace. */ | |
8029 | ||
8030 | static ssd_chain_struct * | |
8031 | is_defined_subspace (name) | |
8032 | char *name; | |
8033 | { | |
8034 | sd_chain_struct *space_chain; | |
8035 | ssd_chain_struct *subspace_chain; | |
8036 | ||
8037 | /* Walk through each space. */ | |
8038 | for (space_chain = space_dict_root; | |
8039 | space_chain; | |
8040 | space_chain = space_chain->sd_next) | |
8041 | { | |
8042 | /* Walk through each subspace looking for a name which matches. */ | |
8043 | for (subspace_chain = space_chain->sd_subspaces; | |
8044 | subspace_chain; | |
8045 | subspace_chain = subspace_chain->ssd_next) | |
8046 | if (strcmp (SUBSPACE_NAME (subspace_chain), name) == 0) | |
8047 | return subspace_chain; | |
8048 | } | |
8049 | ||
8050 | /* Subspace wasn't found. Return NULL. */ | |
8051 | return NULL; | |
8052 | } | |
8053 | ||
8054 | /* Find and return the subspace associated with the given seg. If no | |
8055 | mapping from the given seg to a subspace is found, then return NULL. | |
8056 | ||
8057 | If we ever put each procedure/function within its own subspace | |
8058 | (to make life easier on the compiler and linker), then this will have | |
8059 | to become more efficient. */ | |
8060 | ||
8061 | static ssd_chain_struct * | |
8062 | pa_subsegment_to_subspace (seg, subseg) | |
8063 | asection *seg; | |
8064 | subsegT subseg; | |
8065 | { | |
8066 | sd_chain_struct *space_chain; | |
8067 | ssd_chain_struct *subspace_chain; | |
8068 | ||
8069 | /* Walk through each space. */ | |
8070 | for (space_chain = space_dict_root; | |
8071 | space_chain; | |
8072 | space_chain = space_chain->sd_next) | |
8073 | { | |
8074 | if (space_chain->sd_seg == seg) | |
8075 | { | |
8076 | /* Walk through each subspace within each space looking for | |
8077 | the correct mapping. */ | |
8078 | for (subspace_chain = space_chain->sd_subspaces; | |
8079 | subspace_chain; | |
8080 | subspace_chain = subspace_chain->ssd_next) | |
8081 | if (subspace_chain->ssd_subseg == (int) subseg) | |
8082 | return subspace_chain; | |
8083 | } | |
8084 | } | |
8085 | ||
8086 | /* No mapping from subsegment to subspace found. Return NULL. */ | |
8087 | return NULL; | |
8088 | } | |
8089 | ||
8090 | /* Given a number, try and find a space with the name number. | |
8091 | ||
8092 | Return a pointer to a space dictionary chain entry for the space | |
8093 | that was found or NULL on failure. */ | |
8094 | ||
8095 | static sd_chain_struct * | |
8096 | pa_find_space_by_number (number) | |
8097 | int number; | |
8098 | { | |
8099 | sd_chain_struct *space_chain; | |
8100 | ||
8101 | for (space_chain = space_dict_root; | |
8102 | space_chain; | |
8103 | space_chain = space_chain->sd_next) | |
8104 | { | |
8105 | if (SPACE_SPNUM (space_chain) == (unsigned int) number) | |
8106 | return space_chain; | |
8107 | } | |
8108 | ||
8109 | /* No appropriate space found. Return NULL. */ | |
8110 | return NULL; | |
8111 | } | |
8112 | ||
8113 | /* Return the starting address for the given subspace. If the starting | |
8114 | address is unknown then return zero. */ | |
8115 | ||
8116 | static unsigned int | |
8117 | pa_subspace_start (space, quadrant) | |
8118 | sd_chain_struct *space; | |
8119 | int quadrant; | |
8120 | { | |
252b5132 RH |
8121 | /* FIXME. Assumes everyone puts read/write data at 0x4000000, this |
8122 | is not correct for the PA OSF1 port. */ | |
8123 | if ((strcmp (SPACE_NAME (space), "$PRIVATE$") == 0) && quadrant == 1) | |
8124 | return 0x40000000; | |
8125 | else if (space->sd_seg == data_section && quadrant == 1) | |
8126 | return 0x40000000; | |
8127 | else | |
8128 | return 0; | |
252b5132 RH |
8129 | return 0; |
8130 | } | |
8131 | ||
8132 | /* FIXME. Needs documentation. */ | |
8133 | static int | |
8134 | pa_next_subseg (space) | |
8135 | sd_chain_struct *space; | |
8136 | { | |
8137 | ||
8138 | space->sd_last_subseg++; | |
8139 | return space->sd_last_subseg; | |
8140 | } | |
49863f82 | 8141 | #endif |
252b5132 RH |
8142 | |
8143 | /* Helper function for pa_stringer. Used to find the end of | |
8144 | a string. */ | |
8145 | ||
8146 | static unsigned int | |
8147 | pa_stringer_aux (s) | |
8148 | char *s; | |
8149 | { | |
8150 | unsigned int c = *s & CHAR_MASK; | |
8151 | ||
252b5132 RH |
8152 | switch (c) |
8153 | { | |
8154 | case '\"': | |
8155 | c = NOT_A_CHAR; | |
8156 | break; | |
8157 | default: | |
8158 | break; | |
8159 | } | |
8160 | return c; | |
8161 | } | |
8162 | ||
8163 | /* Handle a .STRING type pseudo-op. */ | |
8164 | ||
8165 | static void | |
8166 | pa_stringer (append_zero) | |
8167 | int append_zero; | |
8168 | { | |
8169 | char *s, num_buf[4]; | |
8170 | unsigned int c; | |
8171 | int i; | |
8172 | ||
8173 | /* Preprocess the string to handle PA-specific escape sequences. | |
ad1079af | 8174 | For example, \xDD where DD is a hexadecimal number should be |
252b5132 RH |
8175 | changed to \OOO where OOO is an octal number. */ |
8176 | ||
ad1079af AM |
8177 | #ifdef OBJ_SOM |
8178 | /* We must have a valid space and subspace. */ | |
8179 | pa_check_current_space_and_subspace (); | |
8180 | #endif | |
8181 | ||
252b5132 RH |
8182 | /* Skip the opening quote. */ |
8183 | s = input_line_pointer + 1; | |
8184 | ||
8185 | while (is_a_char (c = pa_stringer_aux (s++))) | |
8186 | { | |
8187 | if (c == '\\') | |
8188 | { | |
8189 | c = *s; | |
8190 | switch (c) | |
8191 | { | |
8192 | /* Handle \x<num>. */ | |
8193 | case 'x': | |
8194 | { | |
8195 | unsigned int number; | |
8196 | int num_digit; | |
8197 | char dg; | |
8198 | char *s_start = s; | |
8199 | ||
ad1079af | 8200 | /* Get past the 'x'. */ |
252b5132 RH |
8201 | s++; |
8202 | for (num_digit = 0, number = 0, dg = *s; | |
8203 | num_digit < 2 | |
3882b010 | 8204 | && (ISDIGIT (dg) || (dg >= 'a' && dg <= 'f') |
252b5132 RH |
8205 | || (dg >= 'A' && dg <= 'F')); |
8206 | num_digit++) | |
8207 | { | |
3882b010 | 8208 | if (ISDIGIT (dg)) |
252b5132 RH |
8209 | number = number * 16 + dg - '0'; |
8210 | else if (dg >= 'a' && dg <= 'f') | |
8211 | number = number * 16 + dg - 'a' + 10; | |
8212 | else | |
8213 | number = number * 16 + dg - 'A' + 10; | |
8214 | ||
8215 | s++; | |
8216 | dg = *s; | |
8217 | } | |
8218 | if (num_digit > 0) | |
8219 | { | |
8220 | switch (num_digit) | |
8221 | { | |
8222 | case 1: | |
8223 | sprintf (num_buf, "%02o", number); | |
8224 | break; | |
8225 | case 2: | |
8226 | sprintf (num_buf, "%03o", number); | |
8227 | break; | |
8228 | } | |
8229 | for (i = 0; i <= num_digit; i++) | |
8230 | s_start[i] = num_buf[i]; | |
8231 | } | |
8232 | break; | |
8233 | } | |
8234 | /* This might be a "\"", skip over the escaped char. */ | |
8235 | default: | |
8236 | s++; | |
8237 | break; | |
8238 | } | |
8239 | } | |
8240 | } | |
8241 | stringer (append_zero); | |
8242 | pa_undefine_label (); | |
8243 | } | |
8244 | ||
8245 | /* Handle a .VERSION pseudo-op. */ | |
8246 | ||
8247 | static void | |
8248 | pa_version (unused) | |
3f9b03b5 | 8249 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
8250 | { |
8251 | obj_version (0); | |
8252 | pa_undefine_label (); | |
8253 | } | |
8254 | ||
8255 | #ifdef OBJ_SOM | |
8256 | ||
8257 | /* Handle a .COMPILER pseudo-op. */ | |
8258 | ||
8259 | static void | |
8260 | pa_compiler (unused) | |
3f9b03b5 | 8261 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
8262 | { |
8263 | obj_som_compiler (0); | |
8264 | pa_undefine_label (); | |
8265 | } | |
8266 | ||
8267 | #endif | |
8268 | ||
8269 | /* Handle a .COPYRIGHT pseudo-op. */ | |
8270 | ||
8271 | static void | |
8272 | pa_copyright (unused) | |
3f9b03b5 | 8273 | int unused ATTRIBUTE_UNUSED; |
252b5132 RH |
8274 | { |
8275 | obj_copyright (0); | |
8276 | pa_undefine_label (); | |
8277 | } | |
8278 | ||
8279 | /* Just like a normal cons, but when finished we have to undefine | |
8280 | the latest space label. */ | |
8281 | ||
8282 | static void | |
8283 | pa_cons (nbytes) | |
8284 | int nbytes; | |
8285 | { | |
8286 | cons (nbytes); | |
8287 | pa_undefine_label (); | |
8288 | } | |
8289 | ||
252b5132 RH |
8290 | /* Like float_cons, but we need to undefine our label. */ |
8291 | ||
8292 | static void | |
8293 | pa_float_cons (float_type) | |
8294 | int float_type; | |
8295 | { | |
8296 | float_cons (float_type); | |
8297 | pa_undefine_label (); | |
8298 | } | |
8299 | ||
8300 | /* Like s_fill, but delete our label when finished. */ | |
8301 | ||
8302 | static void | |
8303 | pa_fill (unused) | |
3f9b03b5 | 8304 | int unused ATTRIBUTE_UNUSED; |
252b5132 | 8305 | { |
49863f82 | 8306 | #ifdef OBJ_SOM |
252b5132 RH |
8307 | /* We must have a valid space and subspace. */ |
8308 | pa_check_current_space_and_subspace (); | |
49863f82 | 8309 | #endif |
252b5132 RH |
8310 | |
8311 | s_fill (0); | |
8312 | pa_undefine_label (); | |
8313 | } | |
8314 | ||
8315 | /* Like lcomm, but delete our label when finished. */ | |
8316 | ||
8317 | static void | |
8318 | pa_lcomm (needs_align) | |
8319 | int needs_align; | |
8320 | { | |
49863f82 | 8321 | #ifdef OBJ_SOM |
252b5132 RH |
8322 | /* We must have a valid space and subspace. */ |
8323 | pa_check_current_space_and_subspace (); | |
49863f82 | 8324 | #endif |
252b5132 RH |
8325 | |
8326 | s_lcomm (needs_align); | |
8327 | pa_undefine_label (); | |
8328 | } | |
8329 | ||
8330 | /* Like lsym, but delete our label when finished. */ | |
8331 | ||
8332 | static void | |
8333 | pa_lsym (unused) | |
3f9b03b5 | 8334 | int unused ATTRIBUTE_UNUSED; |
252b5132 | 8335 | { |
49863f82 | 8336 | #ifdef OBJ_SOM |
252b5132 RH |
8337 | /* We must have a valid space and subspace. */ |
8338 | pa_check_current_space_and_subspace (); | |
49863f82 | 8339 | #endif |
252b5132 RH |
8340 | |
8341 | s_lsym (0); | |
8342 | pa_undefine_label (); | |
8343 | } | |
8344 | ||
252b5132 RH |
8345 | /* On the PA relocations which involve function symbols must not be |
8346 | adjusted. This so that the linker can know when/how to create argument | |
8347 | relocation stubs for indirect calls and calls to static functions. | |
8348 | ||
8349 | "T" field selectors create DLT relative fixups for accessing | |
8350 | globals and statics in PIC code; each DLT relative fixup creates | |
8351 | an entry in the DLT table. The entries contain the address of | |
8352 | the final target (eg accessing "foo" would create a DLT entry | |
8353 | with the address of "foo"). | |
8354 | ||
8355 | Unfortunately, the HP linker doesn't take into account any addend | |
8356 | when generating the DLT; so accessing $LIT$+8 puts the address of | |
8357 | $LIT$ into the DLT rather than the address of $LIT$+8. | |
8358 | ||
8359 | The end result is we can't perform relocation symbol reductions for | |
8360 | any fixup which creates entries in the DLT (eg they use "T" field | |
8361 | selectors). | |
8362 | ||
8363 | Reject reductions involving symbols with external scope; such | |
d53d2751 | 8364 | reductions make life a living hell for object file editors. |
252b5132 RH |
8365 | |
8366 | FIXME. Also reject R_HPPA relocations which are 32bits wide in | |
8367 | the code space. The SOM BFD backend doesn't know how to pull the | |
8368 | right bits out of an instruction. */ | |
8369 | ||
8370 | int | |
8371 | hppa_fix_adjustable (fixp) | |
8372 | fixS *fixp; | |
8373 | { | |
3dcfe21d | 8374 | reloc_type code; |
252b5132 RH |
8375 | struct hppa_fix_struct *hppa_fix; |
8376 | ||
8377 | hppa_fix = (struct hppa_fix_struct *) fixp->tc_fix_data; | |
8378 | ||
8379 | #ifdef OBJ_SOM | |
8380 | /* Reject reductions of symbols in 32bit relocs. */ | |
8381 | if (fixp->fx_r_type == R_HPPA && hppa_fix->fx_r_format == 32) | |
8382 | return 0; | |
1cd1c99b | 8383 | #endif |
252b5132 | 8384 | |
904a31bf | 8385 | #ifdef OBJ_ELF |
3dcfe21d AM |
8386 | /* LR/RR selectors are implicitly used for a number of different relocation |
8387 | types. We must ensure that none of these types are adjusted (see below) | |
8388 | even if they occur with a different selector. */ | |
8389 | code = elf_hppa_reloc_final_type (stdoutput, fixp->fx_r_type, | |
8390 | hppa_fix->fx_r_format, | |
8391 | hppa_fix->fx_r_field); | |
8392 | ||
8393 | switch (code) | |
8394 | { | |
8395 | /* Relocation types which use e_lrsel. */ | |
8396 | case R_PARISC_DIR21L: | |
3dcfe21d AM |
8397 | case R_PARISC_DLTREL21L: |
8398 | case R_PARISC_DPREL21L: | |
3dcfe21d AM |
8399 | case R_PARISC_PLTOFF21L: |
8400 | ||
8401 | /* Relocation types which use e_rrsel. */ | |
8402 | case R_PARISC_DIR14R: | |
8403 | case R_PARISC_DIR14DR: | |
8404 | case R_PARISC_DIR14WR: | |
8405 | case R_PARISC_DIR17R: | |
3dcfe21d AM |
8406 | case R_PARISC_DLTREL14R: |
8407 | case R_PARISC_DLTREL14DR: | |
8408 | case R_PARISC_DLTREL14WR: | |
8409 | case R_PARISC_DPREL14R: | |
8410 | case R_PARISC_DPREL14DR: | |
8411 | case R_PARISC_DPREL14WR: | |
40d74fb1 JL |
8412 | case R_PARISC_PLTOFF14R: |
8413 | case R_PARISC_PLTOFF14DR: | |
8414 | case R_PARISC_PLTOFF14WR: | |
3dcfe21d AM |
8415 | |
8416 | /* Other types that we reject for reduction. */ | |
8417 | case R_PARISC_GNU_VTENTRY: | |
8418 | case R_PARISC_GNU_VTINHERIT: | |
8419 | return 0; | |
8420 | default: | |
8421 | break; | |
8422 | } | |
5506e1a5 | 8423 | #endif |
959ee541 | 8424 | |
252b5132 | 8425 | /* Reject reductions of symbols in sym1-sym2 expressions when |
d53d2751 | 8426 | the fixup will occur in a CODE subspace. |
252b5132 RH |
8427 | |
8428 | XXX FIXME: Long term we probably want to reject all of these; | |
8429 | for example reducing in the debug section would lose if we ever | |
8430 | supported using the optimizing hp linker. */ | |
8431 | if (fixp->fx_addsy | |
8432 | && fixp->fx_subsy | |
8433 | && (hppa_fix->segment->flags & SEC_CODE)) | |
a161fe53 | 8434 | return 0; |
252b5132 RH |
8435 | |
8436 | /* We can't adjust any relocs that use LR% and RR% field selectors. | |
1cd1c99b AM |
8437 | |
8438 | If a symbol is reduced to a section symbol, the assembler will | |
8439 | adjust the addend unless the symbol happens to reside right at | |
8440 | the start of the section. Additionally, the linker has no choice | |
8441 | but to manipulate the addends when coalescing input sections for | |
8442 | "ld -r". Since an LR% field selector is defined to round the | |
8443 | addend, we can't change the addend without risking that a LR% and | |
8444 | it's corresponding (possible multiple) RR% field will no longer | |
8445 | sum to the right value. | |
8446 | ||
8447 | eg. Suppose we have | |
8448 | . ldil LR%foo+0,%r21 | |
8449 | . ldw RR%foo+0(%r21),%r26 | |
25a8b250 AM |
8450 | . ldw RR%foo+4(%r21),%r25 |
8451 | ||
8452 | If foo is at address 4092 (decimal) in section `sect', then after | |
8453 | reducing to the section symbol we get | |
8454 | . LR%sect+4092 == (L%sect)+0 | |
8455 | . RR%sect+4092 == (R%sect)+4092 | |
8456 | . RR%sect+4096 == (R%sect)-4096 | |
8457 | and the last address loses because rounding the addend to 8k | |
8458 | mutiples takes us up to 8192 with an offset of -4096. | |
8459 | ||
8460 | In cases where the LR% expression is identical to the RR% one we | |
8461 | will never have a problem, but is so happens that gcc rounds | |
8462 | addends involved in LR% field selectors to work around a HP | |
8463 | linker bug. ie. We often have addresses like the last case | |
1cd1c99b AM |
8464 | above where the LR% expression is offset from the RR% one. */ |
8465 | ||
252b5132 RH |
8466 | if (hppa_fix->fx_r_field == e_lrsel |
8467 | || hppa_fix->fx_r_field == e_rrsel | |
8468 | || hppa_fix->fx_r_field == e_nlrsel) | |
8469 | return 0; | |
252b5132 RH |
8470 | |
8471 | /* Reject reductions of symbols in DLT relative relocs, | |
8472 | relocations with plabels. */ | |
8473 | if (hppa_fix->fx_r_field == e_tsel | |
8474 | || hppa_fix->fx_r_field == e_ltsel | |
8475 | || hppa_fix->fx_r_field == e_rtsel | |
8476 | || hppa_fix->fx_r_field == e_psel | |
8477 | || hppa_fix->fx_r_field == e_rpsel | |
8478 | || hppa_fix->fx_r_field == e_lpsel) | |
8479 | return 0; | |
8480 | ||
252b5132 RH |
8481 | /* Reject absolute calls (jumps). */ |
8482 | if (hppa_fix->fx_r_type == R_HPPA_ABS_CALL) | |
8483 | return 0; | |
8484 | ||
8485 | /* Reject reductions of function symbols. */ | |
5506e1a5 AM |
8486 | if (fixp->fx_addsy != 0 && S_IS_FUNCTION (fixp->fx_addsy)) |
8487 | return 0; | |
252b5132 | 8488 | |
5506e1a5 | 8489 | return 1; |
252b5132 RH |
8490 | } |
8491 | ||
8492 | /* Return nonzero if the fixup in FIXP will require a relocation, | |
8493 | even it if appears that the fixup could be completely handled | |
8494 | within GAS. */ | |
8495 | ||
8496 | int | |
8497 | hppa_force_relocation (fixp) | |
ad1079af | 8498 | struct fix *fixp; |
252b5132 RH |
8499 | { |
8500 | struct hppa_fix_struct *hppa_fixp; | |
252b5132 RH |
8501 | |
8502 | hppa_fixp = (struct hppa_fix_struct *) fixp->tc_fix_data; | |
8503 | #ifdef OBJ_SOM | |
ad1079af AM |
8504 | if (fixp->fx_r_type == (int) R_HPPA_ENTRY |
8505 | || fixp->fx_r_type == (int) R_HPPA_EXIT | |
8506 | || fixp->fx_r_type == (int) R_HPPA_BEGIN_BRTAB | |
8507 | || fixp->fx_r_type == (int) R_HPPA_END_BRTAB | |
8508 | || fixp->fx_r_type == (int) R_HPPA_BEGIN_TRY | |
8509 | || fixp->fx_r_type == (int) R_HPPA_END_TRY | |
252b5132 RH |
8510 | || (fixp->fx_addsy != NULL && fixp->fx_subsy != NULL |
8511 | && (hppa_fixp->segment->flags & SEC_CODE) != 0)) | |
8512 | return 1; | |
8513 | #endif | |
904a31bf AM |
8514 | #ifdef OBJ_ELF |
8515 | if (fixp->fx_r_type == (int) R_PARISC_GNU_VTINHERIT | |
8516 | || fixp->fx_r_type == (int) R_PARISC_GNU_VTENTRY) | |
8517 | return 1; | |
5506e1a5 AM |
8518 | #endif |
8519 | ||
8520 | assert (fixp->fx_addsy != NULL); | |
252b5132 | 8521 | |
9e754211 AM |
8522 | /* Ensure we emit a relocation for global symbols so that dynamic |
8523 | linking works. */ | |
ae6063d4 | 8524 | if (S_FORCE_RELOC (fixp->fx_addsy, 1)) |
9e754211 AM |
8525 | return 1; |
8526 | ||
252b5132 | 8527 | /* It is necessary to force PC-relative calls/jumps to have a relocation |
b6ff326e | 8528 | entry if they're going to need either an argument relocation or long |
9e754211 | 8529 | call stub. */ |
5506e1a5 AM |
8530 | if (fixp->fx_pcrel |
8531 | && arg_reloc_stub_needed (symbol_arg_reloc_info (fixp->fx_addsy), | |
8532 | hppa_fixp->fx_arg_reloc)) | |
252b5132 | 8533 | return 1; |
ad1079af | 8534 | |
5506e1a5 AM |
8535 | /* Now check to see if we're going to need a long-branch stub. */ |
8536 | if (fixp->fx_r_type == (int) R_HPPA_PCREL_CALL) | |
8537 | { | |
ec8b3afd JL |
8538 | long pc = md_pcrel_from (fixp); |
8539 | valueT distance, min_stub_distance; | |
5506e1a5 | 8540 | |
ec8b3afd JL |
8541 | distance = fixp->fx_offset + S_GET_VALUE (fixp->fx_addsy) - pc - 8; |
8542 | ||
8543 | /* Distance to the closest possible stub. This will detect most | |
8544 | but not all circumstances where a stub will not work. */ | |
8545 | min_stub_distance = pc + 16; | |
8546 | #ifdef OBJ_SOM | |
8547 | if (last_call_info != NULL) | |
8548 | min_stub_distance -= S_GET_VALUE (last_call_info->start_symbol); | |
27df9f40 | 8549 | #endif |
ec8b3afd JL |
8550 | |
8551 | if ((distance + 8388608 >= 16777216 | |
8552 | && min_stub_distance <= 8388608) | |
8553 | || (hppa_fixp->fx_r_format == 17 | |
8554 | && distance + 262144 >= 524288 | |
8555 | && min_stub_distance <= 262144) | |
8556 | || (hppa_fixp->fx_r_format == 12 | |
8557 | && distance + 8192 >= 16384 | |
8558 | && min_stub_distance <= 8192) | |
27df9f40 | 8559 | ) |
5506e1a5 AM |
8560 | return 1; |
8561 | } | |
252b5132 | 8562 | |
ad1079af | 8563 | if (fixp->fx_r_type == (int) R_HPPA_ABS_CALL) |
252b5132 | 8564 | return 1; |
252b5132 RH |
8565 | |
8566 | /* No need (yet) to force another relocations to be emitted. */ | |
8567 | return 0; | |
8568 | } | |
8569 | ||
8570 | /* Now for some ELF specific code. FIXME. */ | |
8571 | #ifdef OBJ_ELF | |
8572 | /* Mark the end of a function so that it's possible to compute | |
ec8b3afd | 8573 | the size of the function in elf_hppa_final_processing. */ |
252b5132 RH |
8574 | |
8575 | static void | |
8576 | hppa_elf_mark_end_of_function () | |
8577 | { | |
8578 | /* ELF does not have EXIT relocations. All we do is create a | |
8579 | temporary symbol marking the end of the function. */ | |
ad1079af AM |
8580 | char *name; |
8581 | ||
8582 | if (last_call_info == NULL || last_call_info->start_symbol == NULL) | |
8583 | { | |
8584 | /* We have already warned about a missing label, | |
8585 | or other problems. */ | |
8586 | return; | |
8587 | } | |
252b5132 | 8588 | |
ad1079af AM |
8589 | name = (char *) xmalloc (strlen ("L$\001end_") |
8590 | + strlen (S_GET_NAME (last_call_info->start_symbol)) | |
8591 | + 1); | |
252b5132 RH |
8592 | if (name) |
8593 | { | |
8594 | symbolS *symbolP; | |
8595 | ||
8596 | strcpy (name, "L$\001end_"); | |
8597 | strcat (name, S_GET_NAME (last_call_info->start_symbol)); | |
8598 | ||
8599 | /* If we have a .exit followed by a .procend, then the | |
8600 | symbol will have already been defined. */ | |
8601 | symbolP = symbol_find (name); | |
8602 | if (symbolP) | |
8603 | { | |
8604 | /* The symbol has already been defined! This can | |
8605 | happen if we have a .exit followed by a .procend. | |
8606 | ||
8607 | This is *not* an error. All we want to do is free | |
8608 | the memory we just allocated for the name and continue. */ | |
8609 | xfree (name); | |
8610 | } | |
8611 | else | |
8612 | { | |
8613 | /* symbol value should be the offset of the | |
8614 | last instruction of the function */ | |
8615 | symbolP = symbol_new (name, now_seg, (valueT) (frag_now_fix () - 4), | |
8616 | frag_now); | |
8617 | ||
8618 | assert (symbolP); | |
a0f75b47 | 8619 | S_CLEAR_EXTERNAL (symbolP); |
252b5132 RH |
8620 | symbol_table_insert (symbolP); |
8621 | } | |
8622 | ||
8623 | if (symbolP) | |
8624 | last_call_info->end_symbol = symbolP; | |
8625 | else | |
8626 | as_bad (_("Symbol '%s' could not be created."), name); | |
8627 | ||
8628 | } | |
8629 | else | |
8630 | as_bad (_("No memory for symbol name.")); | |
8631 | ||
8632 | } | |
8633 | ||
8634 | /* For ELF, this function serves one purpose: to setup the st_size | |
8635 | field of STT_FUNC symbols. To do this, we need to scan the | |
8636 | call_info structure list, determining st_size in by taking the | |
8637 | difference in the address of the beginning/end marker symbols. */ | |
8638 | ||
8639 | void | |
8640 | elf_hppa_final_processing () | |
8641 | { | |
8642 | struct call_info *call_info_pointer; | |
8643 | ||
8644 | for (call_info_pointer = call_info_root; | |
8645 | call_info_pointer; | |
8646 | call_info_pointer = call_info_pointer->ci_next) | |
8647 | { | |
8648 | elf_symbol_type *esym | |
a0f75b47 ILT |
8649 | = ((elf_symbol_type *) |
8650 | symbol_get_bfdsym (call_info_pointer->start_symbol)); | |
252b5132 RH |
8651 | esym->internal_elf_sym.st_size = |
8652 | S_GET_VALUE (call_info_pointer->end_symbol) | |
8653 | - S_GET_VALUE (call_info_pointer->start_symbol) + 4; | |
8654 | } | |
8655 | } | |
2d93dcc4 | 8656 | |
904a31bf AM |
8657 | static void |
8658 | pa_vtable_entry (ignore) | |
8659 | int ignore ATTRIBUTE_UNUSED; | |
8660 | { | |
8661 | struct fix *new_fix; | |
8662 | ||
8663 | new_fix = obj_elf_vtable_entry (0); | |
8664 | ||
8665 | if (new_fix) | |
8666 | { | |
8667 | struct hppa_fix_struct *hppa_fix = (struct hppa_fix_struct *) | |
8668 | obstack_alloc (¬es, sizeof (struct hppa_fix_struct)); | |
8669 | hppa_fix->fx_r_type = R_HPPA; | |
8670 | hppa_fix->fx_r_field = e_fsel; | |
8671 | hppa_fix->fx_r_format = 32; | |
8672 | hppa_fix->fx_arg_reloc = 0; | |
8673 | hppa_fix->segment = now_seg; | |
8674 | new_fix->tc_fix_data = (void *) hppa_fix; | |
8675 | new_fix->fx_r_type = (int) R_PARISC_GNU_VTENTRY; | |
8676 | } | |
8677 | } | |
8678 | ||
8679 | static void | |
8680 | pa_vtable_inherit (ignore) | |
8681 | int ignore ATTRIBUTE_UNUSED; | |
8682 | { | |
8683 | struct fix *new_fix; | |
8684 | ||
8685 | new_fix = obj_elf_vtable_inherit (0); | |
8686 | ||
8687 | if (new_fix) | |
8688 | { | |
8689 | struct hppa_fix_struct *hppa_fix = (struct hppa_fix_struct *) | |
8690 | obstack_alloc (¬es, sizeof (struct hppa_fix_struct)); | |
8691 | hppa_fix->fx_r_type = R_HPPA; | |
8692 | hppa_fix->fx_r_field = e_fsel; | |
8693 | hppa_fix->fx_r_format = 32; | |
8694 | hppa_fix->fx_arg_reloc = 0; | |
8695 | hppa_fix->segment = now_seg; | |
8696 | new_fix->tc_fix_data = (void *) hppa_fix; | |
8697 | new_fix->fx_r_type = (int) R_PARISC_GNU_VTINHERIT; | |
8698 | } | |
8699 | } | |
2d93dcc4 | 8700 | #endif |