* hppa.h (pa_opcodes): Replace 'f' by 'v'. Prefix float register args
[deliverable/binutils-gdb.git] / gas / config / tc-ppc.c
1 /* tc-ppc.c -- Assemble for the PowerPC or POWER (RS/6000)
2 Copyright (C) 1994, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
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
22 #include <stdio.h>
23 #include <ctype.h>
24 #include "as.h"
25 #include "subsegs.h"
26
27 #include "opcode/ppc.h"
28
29 #ifdef OBJ_ELF
30 #include "elf/ppc.h"
31 #endif
32
33 #ifdef TE_PE
34 #include "coff/pe.h"
35 #endif
36
37 /* This is the assembler for the PowerPC or POWER (RS/6000) chips. */
38
39 /* Tell the main code what the endianness is. */
40 extern int target_big_endian;
41
42 /* Whether or not, we've set target_big_endian. */
43 static int set_target_endian = 0;
44
45 /* Whether to use user friendly register names. */
46 #ifndef TARGET_REG_NAMES_P
47 #ifdef TE_PE
48 #define TARGET_REG_NAMES_P true
49 #else
50 #define TARGET_REG_NAMES_P false
51 #endif
52 #endif
53
54 static boolean reg_names_p = TARGET_REG_NAMES_P;
55
56 static boolean register_name PARAMS ((expressionS *));
57 static void ppc_set_cpu PARAMS ((void));
58 static unsigned long ppc_insert_operand
59 PARAMS ((unsigned long insn, const struct powerpc_operand *operand,
60 offsetT val, char *file, unsigned int line));
61 static void ppc_macro PARAMS ((char *str, const struct powerpc_macro *macro));
62 static void ppc_byte PARAMS ((int));
63 static int ppc_is_toc_sym PARAMS ((symbolS *sym));
64 static void ppc_tc PARAMS ((int));
65
66 #ifdef OBJ_XCOFF
67 static void ppc_comm PARAMS ((int));
68 static void ppc_bb PARAMS ((int));
69 static void ppc_bc PARAMS ((int));
70 static void ppc_bf PARAMS ((int));
71 static void ppc_biei PARAMS ((int));
72 static void ppc_bs PARAMS ((int));
73 static void ppc_eb PARAMS ((int));
74 static void ppc_ec PARAMS ((int));
75 static void ppc_ef PARAMS ((int));
76 static void ppc_es PARAMS ((int));
77 static void ppc_csect PARAMS ((int));
78 static void ppc_change_csect PARAMS ((symbolS *));
79 static void ppc_function PARAMS ((int));
80 static void ppc_extern PARAMS ((int));
81 static void ppc_lglobl PARAMS ((int));
82 static void ppc_section PARAMS ((int));
83 static void ppc_named_section PARAMS ((int));
84 static void ppc_stabx PARAMS ((int));
85 static void ppc_rename PARAMS ((int));
86 static void ppc_toc PARAMS ((int));
87 static void ppc_xcoff_cons PARAMS ((int));
88 static void ppc_vbyte PARAMS ((int));
89 #endif
90
91 #ifdef OBJ_ELF
92 static bfd_reloc_code_real_type ppc_elf_suffix PARAMS ((char **, expressionS *));
93 static void ppc_elf_cons PARAMS ((int));
94 static void ppc_elf_rdata PARAMS ((int));
95 static void ppc_elf_lcomm PARAMS ((int));
96 static void ppc_elf_validate_fix PARAMS ((fixS *, segT));
97 #endif
98
99 #ifdef TE_PE
100 static void ppc_set_current_section PARAMS ((segT));
101 static void ppc_previous PARAMS ((int));
102 static void ppc_pdata PARAMS ((int));
103 static void ppc_ydata PARAMS ((int));
104 static void ppc_reldata PARAMS ((int));
105 static void ppc_rdata PARAMS ((int));
106 static void ppc_ualong PARAMS ((int));
107 static void ppc_znop PARAMS ((int));
108 static void ppc_pe_comm PARAMS ((int));
109 static void ppc_pe_section PARAMS ((int));
110 static void ppc_pe_function PARAMS ((int));
111 static void ppc_pe_tocd PARAMS ((int));
112 #endif
113 \f
114 /* Generic assembler global variables which must be defined by all
115 targets. */
116
117 #ifdef OBJ_ELF
118 /* This string holds the chars that always start a comment. If the
119 pre-processor is disabled, these aren't very useful. The macro
120 tc_comment_chars points to this. We use this, rather than the
121 usual comment_chars, so that we can switch for Solaris conventions. */
122 static const char ppc_solaris_comment_chars[] = "#!";
123 static const char ppc_eabi_comment_chars[] = "#";
124
125 #ifdef TARGET_SOLARIS_COMMENT
126 const char *ppc_comment_chars = ppc_solaris_comment_chars;
127 #else
128 const char *ppc_comment_chars = ppc_eabi_comment_chars;
129 #endif
130 #else
131 const char comment_chars[] = "#";
132 #endif
133
134 /* Characters which start a comment at the beginning of a line. */
135 const char line_comment_chars[] = "#";
136
137 /* Characters which may be used to separate multiple commands on a
138 single line. */
139 const char line_separator_chars[] = ";";
140
141 /* Characters which are used to indicate an exponent in a floating
142 point number. */
143 const char EXP_CHARS[] = "eE";
144
145 /* Characters which mean that a number is a floating point constant,
146 as in 0d1.0. */
147 const char FLT_CHARS[] = "dD";
148 \f
149 /* The target specific pseudo-ops which we support. */
150
151 const pseudo_typeS md_pseudo_table[] =
152 {
153 /* Pseudo-ops which must be overridden. */
154 { "byte", ppc_byte, 0 },
155
156 #ifdef OBJ_XCOFF
157 /* Pseudo-ops specific to the RS/6000 XCOFF format. Some of these
158 legitimately belong in the obj-*.c file. However, XCOFF is based
159 on COFF, and is only implemented for the RS/6000. We just use
160 obj-coff.c, and add what we need here. */
161 { "comm", ppc_comm, 0 },
162 { "lcomm", ppc_comm, 1 },
163 { "bb", ppc_bb, 0 },
164 { "bc", ppc_bc, 0 },
165 { "bf", ppc_bf, 0 },
166 { "bi", ppc_biei, 0 },
167 { "bs", ppc_bs, 0 },
168 { "csect", ppc_csect, 0 },
169 { "data", ppc_section, 'd' },
170 { "eb", ppc_eb, 0 },
171 { "ec", ppc_ec, 0 },
172 { "ef", ppc_ef, 0 },
173 { "ei", ppc_biei, 1 },
174 { "es", ppc_es, 0 },
175 { "extern", ppc_extern, 0 },
176 { "function", ppc_function, 0 },
177 { "lglobl", ppc_lglobl, 0 },
178 { "rename", ppc_rename, 0 },
179 { "section", ppc_named_section, 0 },
180 { "stabx", ppc_stabx, 0 },
181 { "text", ppc_section, 't' },
182 { "toc", ppc_toc, 0 },
183 { "long", ppc_xcoff_cons, 2 },
184 { "word", ppc_xcoff_cons, 1 },
185 { "short", ppc_xcoff_cons, 1 },
186 { "vbyte", ppc_vbyte, 0 },
187 #endif
188
189 #ifdef OBJ_ELF
190 { "long", ppc_elf_cons, 4 },
191 { "word", ppc_elf_cons, 2 },
192 { "short", ppc_elf_cons, 2 },
193 { "rdata", ppc_elf_rdata, 0 },
194 { "rodata", ppc_elf_rdata, 0 },
195 { "lcomm", ppc_elf_lcomm, 0 },
196 #endif
197
198 #ifdef TE_PE
199 /* Pseudo-ops specific to the Windows NT PowerPC PE (coff) format */
200 { "previous", ppc_previous, 0 },
201 { "pdata", ppc_pdata, 0 },
202 { "ydata", ppc_ydata, 0 },
203 { "reldata", ppc_reldata, 0 },
204 { "rdata", ppc_rdata, 0 },
205 { "ualong", ppc_ualong, 0 },
206 { "znop", ppc_znop, 0 },
207 { "comm", ppc_pe_comm, 0 },
208 { "lcomm", ppc_pe_comm, 1 },
209 { "section", ppc_pe_section, 0 },
210 { "function", ppc_pe_function,0 },
211 { "tocd", ppc_pe_tocd, 0 },
212 #endif
213
214 /* This pseudo-op is used even when not generating XCOFF output. */
215 { "tc", ppc_tc, 0 },
216
217 { NULL, NULL, 0 }
218 };
219
220 \f
221 /* Predefined register names if -mregnames (or default for Windows NT). */
222 /* In general, there are lots of them, in an attempt to be compatible */
223 /* with a number of other Windows NT assemblers. */
224
225 /* Structure to hold information about predefined registers. */
226 struct pd_reg
227 {
228 char *name;
229 int value;
230 };
231
232 /* List of registers that are pre-defined:
233
234 Each general register has predefined names of the form:
235 1. r<reg_num> which has the value <reg_num>.
236 2. r.<reg_num> which has the value <reg_num>.
237
238
239 Each floating point register has predefined names of the form:
240 1. f<reg_num> which has the value <reg_num>.
241 2. f.<reg_num> which has the value <reg_num>.
242
243 Each condition register has predefined names of the form:
244 1. cr<reg_num> which has the value <reg_num>.
245 2. cr.<reg_num> which has the value <reg_num>.
246
247 There are individual registers as well:
248 sp or r.sp has the value 1
249 rtoc or r.toc has the value 2
250 fpscr has the value 0
251 xer has the value 1
252 lr has the value 8
253 ctr has the value 9
254 pmr has the value 0
255 dar has the value 19
256 dsisr has the value 18
257 dec has the value 22
258 sdr1 has the value 25
259 srr0 has the value 26
260 srr1 has the value 27
261
262 The table is sorted. Suitable for searching by a binary search. */
263
264 static const struct pd_reg pre_defined_registers[] =
265 {
266 { "cr.0", 0 }, /* Condition Registers */
267 { "cr.1", 1 },
268 { "cr.2", 2 },
269 { "cr.3", 3 },
270 { "cr.4", 4 },
271 { "cr.5", 5 },
272 { "cr.6", 6 },
273 { "cr.7", 7 },
274
275 { "cr0", 0 },
276 { "cr1", 1 },
277 { "cr2", 2 },
278 { "cr3", 3 },
279 { "cr4", 4 },
280 { "cr5", 5 },
281 { "cr6", 6 },
282 { "cr7", 7 },
283
284 { "ctr", 9 },
285
286 { "dar", 19 }, /* Data Access Register */
287 { "dec", 22 }, /* Decrementer */
288 { "dsisr", 18 }, /* Data Storage Interrupt Status Register */
289
290 { "f.0", 0 }, /* Floating point registers */
291 { "f.1", 1 },
292 { "f.10", 10 },
293 { "f.11", 11 },
294 { "f.12", 12 },
295 { "f.13", 13 },
296 { "f.14", 14 },
297 { "f.15", 15 },
298 { "f.16", 16 },
299 { "f.17", 17 },
300 { "f.18", 18 },
301 { "f.19", 19 },
302 { "f.2", 2 },
303 { "f.20", 20 },
304 { "f.21", 21 },
305 { "f.22", 22 },
306 { "f.23", 23 },
307 { "f.24", 24 },
308 { "f.25", 25 },
309 { "f.26", 26 },
310 { "f.27", 27 },
311 { "f.28", 28 },
312 { "f.29", 29 },
313 { "f.3", 3 },
314 { "f.30", 30 },
315 { "f.31", 31 },
316 { "f.4", 4 },
317 { "f.5", 5 },
318 { "f.6", 6 },
319 { "f.7", 7 },
320 { "f.8", 8 },
321 { "f.9", 9 },
322
323 { "f0", 0 },
324 { "f1", 1 },
325 { "f10", 10 },
326 { "f11", 11 },
327 { "f12", 12 },
328 { "f13", 13 },
329 { "f14", 14 },
330 { "f15", 15 },
331 { "f16", 16 },
332 { "f17", 17 },
333 { "f18", 18 },
334 { "f19", 19 },
335 { "f2", 2 },
336 { "f20", 20 },
337 { "f21", 21 },
338 { "f22", 22 },
339 { "f23", 23 },
340 { "f24", 24 },
341 { "f25", 25 },
342 { "f26", 26 },
343 { "f27", 27 },
344 { "f28", 28 },
345 { "f29", 29 },
346 { "f3", 3 },
347 { "f30", 30 },
348 { "f31", 31 },
349 { "f4", 4 },
350 { "f5", 5 },
351 { "f6", 6 },
352 { "f7", 7 },
353 { "f8", 8 },
354 { "f9", 9 },
355
356 { "fpscr", 0 },
357
358 { "lr", 8 }, /* Link Register */
359
360 { "pmr", 0 },
361
362 { "r.0", 0 }, /* General Purpose Registers */
363 { "r.1", 1 },
364 { "r.10", 10 },
365 { "r.11", 11 },
366 { "r.12", 12 },
367 { "r.13", 13 },
368 { "r.14", 14 },
369 { "r.15", 15 },
370 { "r.16", 16 },
371 { "r.17", 17 },
372 { "r.18", 18 },
373 { "r.19", 19 },
374 { "r.2", 2 },
375 { "r.20", 20 },
376 { "r.21", 21 },
377 { "r.22", 22 },
378 { "r.23", 23 },
379 { "r.24", 24 },
380 { "r.25", 25 },
381 { "r.26", 26 },
382 { "r.27", 27 },
383 { "r.28", 28 },
384 { "r.29", 29 },
385 { "r.3", 3 },
386 { "r.30", 30 },
387 { "r.31", 31 },
388 { "r.4", 4 },
389 { "r.5", 5 },
390 { "r.6", 6 },
391 { "r.7", 7 },
392 { "r.8", 8 },
393 { "r.9", 9 },
394
395 { "r.sp", 1 }, /* Stack Pointer */
396
397 { "r.toc", 2 }, /* Pointer to the table of contents */
398
399 { "r0", 0 }, /* More general purpose registers */
400 { "r1", 1 },
401 { "r10", 10 },
402 { "r11", 11 },
403 { "r12", 12 },
404 { "r13", 13 },
405 { "r14", 14 },
406 { "r15", 15 },
407 { "r16", 16 },
408 { "r17", 17 },
409 { "r18", 18 },
410 { "r19", 19 },
411 { "r2", 2 },
412 { "r20", 20 },
413 { "r21", 21 },
414 { "r22", 22 },
415 { "r23", 23 },
416 { "r24", 24 },
417 { "r25", 25 },
418 { "r26", 26 },
419 { "r27", 27 },
420 { "r28", 28 },
421 { "r29", 29 },
422 { "r3", 3 },
423 { "r30", 30 },
424 { "r31", 31 },
425 { "r4", 4 },
426 { "r5", 5 },
427 { "r6", 6 },
428 { "r7", 7 },
429 { "r8", 8 },
430 { "r9", 9 },
431
432 { "rtoc", 2 }, /* Table of contents */
433
434 { "sdr1", 25 }, /* Storage Description Register 1 */
435
436 { "sp", 1 },
437
438 { "srr0", 26 }, /* Machine Status Save/Restore Register 0 */
439 { "srr1", 27 }, /* Machine Status Save/Restore Register 1 */
440
441 { "xer", 1 },
442
443 };
444
445 #define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct pd_reg))
446
447 /* Given NAME, find the register number associated with that name, return
448 the integer value associated with the given name or -1 on failure. */
449
450 static int reg_name_search
451 PARAMS ((const struct pd_reg *, int, const char * name));
452
453 static int
454 reg_name_search (regs, regcount, name)
455 const struct pd_reg *regs;
456 int regcount;
457 const char *name;
458 {
459 int middle, low, high;
460 int cmp;
461
462 low = 0;
463 high = regcount - 1;
464
465 do
466 {
467 middle = (low + high) / 2;
468 cmp = strcasecmp (name, regs[middle].name);
469 if (cmp < 0)
470 high = middle - 1;
471 else if (cmp > 0)
472 low = middle + 1;
473 else
474 return regs[middle].value;
475 }
476 while (low <= high);
477
478 return -1;
479 }
480
481 /*
482 * Summary of register_name().
483 *
484 * in: Input_line_pointer points to 1st char of operand.
485 *
486 * out: A expressionS.
487 * The operand may have been a register: in this case, X_op == O_register,
488 * X_add_number is set to the register number, and truth is returned.
489 * Input_line_pointer->(next non-blank) char after operand, or is in its
490 * original state.
491 */
492
493 static boolean
494 register_name (expressionP)
495 expressionS *expressionP;
496 {
497 int reg_number;
498 char *name;
499 char *start;
500 char c;
501
502 /* Find the spelling of the operand */
503 start = name = input_line_pointer;
504 if (name[0] == '%' && isalpha (name[1]))
505 name = ++input_line_pointer;
506
507 else if (!reg_names_p || !isalpha (name[0]))
508 return false;
509
510 c = get_symbol_end ();
511 reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT, name);
512
513 /* look to see if it's in the register table */
514 if (reg_number >= 0)
515 {
516 expressionP->X_op = O_register;
517 expressionP->X_add_number = reg_number;
518
519 /* make the rest nice */
520 expressionP->X_add_symbol = NULL;
521 expressionP->X_op_symbol = NULL;
522 *input_line_pointer = c; /* put back the delimiting char */
523 return true;
524 }
525 else
526 {
527 /* reset the line as if we had not done anything */
528 *input_line_pointer = c; /* put back the delimiting char */
529 input_line_pointer = start; /* reset input_line pointer */
530 return false;
531 }
532 }
533 \f
534 /* This function is called for each symbol seen in an expression. It
535 handles the special parsing which PowerPC assemblers are supposed
536 to use for condition codes. */
537
538 /* Whether to do the special parsing. */
539 static boolean cr_operand;
540
541 /* Names to recognize in a condition code. This table is sorted. */
542 static const struct pd_reg cr_names[] =
543 {
544 { "cr0", 0 },
545 { "cr1", 1 },
546 { "cr2", 2 },
547 { "cr3", 3 },
548 { "cr4", 4 },
549 { "cr5", 5 },
550 { "cr6", 6 },
551 { "cr7", 7 },
552 { "eq", 2 },
553 { "gt", 1 },
554 { "lt", 0 },
555 { "so", 3 },
556 { "un", 3 }
557 };
558
559 /* Parsing function. This returns non-zero if it recognized an
560 expression. */
561
562 int
563 ppc_parse_name (name, expr)
564 const char *name;
565 expressionS *expr;
566 {
567 int val;
568
569 if (! cr_operand)
570 return 0;
571
572 val = reg_name_search (cr_names, sizeof cr_names / sizeof cr_names[0],
573 name);
574 if (val < 0)
575 return 0;
576
577 expr->X_op = O_constant;
578 expr->X_add_number = val;
579
580 return 1;
581 }
582 \f
583 /* Local variables. */
584
585 /* The type of processor we are assembling for. This is one or more
586 of the PPC_OPCODE flags defined in opcode/ppc.h. */
587 static int ppc_cpu = 0;
588
589 /* The size of the processor we are assembling for. This is either
590 PPC_OPCODE_32 or PPC_OPCODE_64. */
591 static int ppc_size = PPC_OPCODE_32;
592
593 /* Opcode hash table. */
594 static struct hash_control *ppc_hash;
595
596 /* Macro hash table. */
597 static struct hash_control *ppc_macro_hash;
598
599 #ifdef OBJ_ELF
600 /* What type of shared library support to use */
601 static enum { SHLIB_NONE, SHLIB_PIC, SHILB_MRELOCATABLE } shlib = SHLIB_NONE;
602
603 /* Flags to set in the elf header */
604 static flagword ppc_flags = 0;
605
606 /* Whether this is Solaris or not. */
607 #ifdef TARGET_SOLARIS_COMMENT
608 #define SOLARIS_P true
609 #else
610 #define SOLARIS_P false
611 #endif
612
613 static boolean msolaris = SOLARIS_P;
614 #endif
615
616 #ifdef OBJ_XCOFF
617
618 /* The RS/6000 assembler uses the .csect pseudo-op to generate code
619 using a bunch of different sections. These assembler sections,
620 however, are all encompassed within the .text or .data sections of
621 the final output file. We handle this by using different
622 subsegments within these main segments. */
623
624 /* Next subsegment to allocate within the .text segment. */
625 static subsegT ppc_text_subsegment = 2;
626
627 /* Linked list of csects in the text section. */
628 static symbolS *ppc_text_csects;
629
630 /* Next subsegment to allocate within the .data segment. */
631 static subsegT ppc_data_subsegment = 2;
632
633 /* Linked list of csects in the data section. */
634 static symbolS *ppc_data_csects;
635
636 /* The current csect. */
637 static symbolS *ppc_current_csect;
638
639 /* The RS/6000 assembler uses a TOC which holds addresses of functions
640 and variables. Symbols are put in the TOC with the .tc pseudo-op.
641 A special relocation is used when accessing TOC entries. We handle
642 the TOC as a subsegment within the .data segment. We set it up if
643 we see a .toc pseudo-op, and save the csect symbol here. */
644 static symbolS *ppc_toc_csect;
645
646 /* The first frag in the TOC subsegment. */
647 static fragS *ppc_toc_frag;
648
649 /* The first frag in the first subsegment after the TOC in the .data
650 segment. NULL if there are no subsegments after the TOC. */
651 static fragS *ppc_after_toc_frag;
652
653 /* The current static block. */
654 static symbolS *ppc_current_block;
655
656 /* The COFF debugging section; set by md_begin. This is not the
657 .debug section, but is instead the secret BFD section which will
658 cause BFD to set the section number of a symbol to N_DEBUG. */
659 static asection *ppc_coff_debug_section;
660
661 #endif /* OBJ_XCOFF */
662
663 #ifdef TE_PE
664
665 /* Various sections that we need for PE coff support. */
666 static segT ydata_section;
667 static segT pdata_section;
668 static segT reldata_section;
669 static segT rdata_section;
670 static segT tocdata_section;
671
672 /* The current section and the previous section. See ppc_previous. */
673 static segT ppc_previous_section;
674 static segT ppc_current_section;
675
676 #endif /* TE_PE */
677
678 #ifdef OBJ_ELF
679 symbolS *GOT_symbol; /* Pre-defined "_GLOBAL_OFFSET_TABLE" */
680 #endif /* OBJ_ELF */
681 \f
682 #ifdef OBJ_ELF
683 CONST char *md_shortopts = "b:l:usm:K:VQ:";
684 #else
685 CONST char *md_shortopts = "um:";
686 #endif
687 struct option md_longopts[] = {
688 {NULL, no_argument, NULL, 0}
689 };
690 size_t md_longopts_size = sizeof(md_longopts);
691
692 int
693 md_parse_option (c, arg)
694 int c;
695 char *arg;
696 {
697 switch (c)
698 {
699 case 'u':
700 /* -u means that any undefined symbols should be treated as
701 external, which is the default for gas anyhow. */
702 break;
703
704 #ifdef OBJ_ELF
705 case 'l':
706 /* Solaris as takes -le (presumably for little endian). For completeness
707 sake, recognize -be also. */
708 if (strcmp (arg, "e") == 0)
709 {
710 target_big_endian = 0;
711 set_target_endian = 1;
712 }
713 else
714 return 0;
715
716 break;
717
718 case 'b':
719 if (strcmp (arg, "e") == 0)
720 {
721 target_big_endian = 1;
722 set_target_endian = 1;
723 }
724 else
725 return 0;
726
727 break;
728
729 case 'K':
730 /* Recognize -K PIC */
731 if (strcmp (arg, "PIC") == 0 || strcmp (arg, "pic") == 0)
732 {
733 shlib = SHLIB_PIC;
734 ppc_flags |= EF_PPC_RELOCATABLE_LIB;
735 }
736 else
737 return 0;
738
739 break;
740 #endif
741
742 case 'm':
743 /* -mpwrx and -mpwr2 mean to assemble for the IBM POWER/2
744 (RIOS2). */
745 if (strcmp (arg, "pwrx") == 0 || strcmp (arg, "pwr2") == 0)
746 ppc_cpu = PPC_OPCODE_POWER | PPC_OPCODE_POWER2;
747 /* -mpwr means to assemble for the IBM POWER (RIOS1). */
748 else if (strcmp (arg, "pwr") == 0)
749 ppc_cpu = PPC_OPCODE_POWER;
750 /* -m601 means to assemble for the Motorola PowerPC 601, which includes
751 instructions that are holdovers from the Power. */
752 else if (strcmp (arg, "601") == 0)
753 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_601;
754 /* -mppc, -mppc32, -m603, and -m604 mean to assemble for the
755 Motorola PowerPC 603/604. */
756 else if (strcmp (arg, "ppc") == 0
757 || strcmp (arg, "ppc32") == 0
758 || strcmp (arg, "403") == 0
759 || strcmp (arg, "603") == 0
760 || strcmp (arg, "604") == 0)
761 ppc_cpu = PPC_OPCODE_PPC;
762 /* -mppc64 and -m620 mean to assemble for the 64-bit PowerPC
763 620. */
764 else if (strcmp (arg, "ppc64") == 0 || strcmp (arg, "620") == 0)
765 {
766 ppc_cpu = PPC_OPCODE_PPC;
767 ppc_size = PPC_OPCODE_64;
768 }
769 else if (strcmp (arg, "ppc64bridge") == 0)
770 {
771 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_64_BRIDGE;
772 ppc_size = PPC_OPCODE_64;
773 }
774 /* -mcom means assemble for the common intersection between Power
775 and PowerPC. At present, we just allow the union, rather
776 than the intersection. */
777 else if (strcmp (arg, "com") == 0)
778 ppc_cpu = PPC_OPCODE_COMMON;
779 /* -many means to assemble for any architecture (PWR/PWRX/PPC). */
780 else if (strcmp (arg, "any") == 0)
781 ppc_cpu = PPC_OPCODE_ANY;
782
783 else if (strcmp (arg, "regnames") == 0)
784 reg_names_p = true;
785
786 else if (strcmp (arg, "no-regnames") == 0)
787 reg_names_p = false;
788
789 #ifdef OBJ_ELF
790 /* -mrelocatable/-mrelocatable-lib -- warn about initializations that require relocation */
791 else if (strcmp (arg, "relocatable") == 0)
792 {
793 shlib = SHILB_MRELOCATABLE;
794 ppc_flags |= EF_PPC_RELOCATABLE;
795 }
796
797 else if (strcmp (arg, "relocatable-lib") == 0)
798 {
799 shlib = SHILB_MRELOCATABLE;
800 ppc_flags |= EF_PPC_RELOCATABLE_LIB;
801 }
802
803 /* -memb, set embedded bit */
804 else if (strcmp (arg, "emb") == 0)
805 ppc_flags |= EF_PPC_EMB;
806
807 /* -mlittle/-mbig set the endianess */
808 else if (strcmp (arg, "little") == 0 || strcmp (arg, "little-endian") == 0)
809 {
810 target_big_endian = 0;
811 set_target_endian = 1;
812 }
813
814 else if (strcmp (arg, "big") == 0 || strcmp (arg, "big-endian") == 0)
815 {
816 target_big_endian = 1;
817 set_target_endian = 1;
818 }
819
820 else if (strcmp (arg, "solaris") == 0)
821 {
822 msolaris = true;
823 ppc_comment_chars = ppc_solaris_comment_chars;
824 }
825
826 else if (strcmp (arg, "no-solaris") == 0)
827 {
828 msolaris = false;
829 ppc_comment_chars = ppc_eabi_comment_chars;
830 }
831 #endif
832 else
833 {
834 as_bad (_("invalid switch -m%s"), arg);
835 return 0;
836 }
837 break;
838
839 #ifdef OBJ_ELF
840 /* -V: SVR4 argument to print version ID. */
841 case 'V':
842 print_version_id ();
843 break;
844
845 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
846 should be emitted or not. FIXME: Not implemented. */
847 case 'Q':
848 break;
849
850 /* Solaris takes -s to specify that .stabs go in a .stabs section,
851 rather than .stabs.excl, which is ignored by the linker.
852 FIXME: Not implemented. */
853 case 's':
854 if (arg)
855 return 0;
856
857 break;
858 #endif
859
860 default:
861 return 0;
862 }
863
864 return 1;
865 }
866
867 void
868 md_show_usage (stream)
869 FILE *stream;
870 {
871 fprintf(stream, _("\
872 PowerPC options:\n\
873 -u ignored\n\
874 -mpwrx, -mpwr2 generate code for IBM POWER/2 (RIOS2)\n\
875 -mpwr generate code for IBM POWER (RIOS1)\n\
876 -m601 generate code for Motorola PowerPC 601\n\
877 -mppc, -mppc32, -m403, -m603, -m604\n\
878 generate code for Motorola PowerPC 603/604\n\
879 -mppc64, -m620 generate code for Motorola PowerPC 620\n\
880 -mppc64bridge generate code for PowerPC 64, including bridge insns\n\
881 -mcom generate code Power/PowerPC common instructions\n\
882 -many generate code for any architecture (PWR/PWRX/PPC)\n\
883 -mregnames Allow symbolic names for registers\n\
884 -mno-regnames Do not allow symbolic names for registers\n"));
885 #ifdef OBJ_ELF
886 fprintf(stream, _("\
887 -mrelocatable support for GCC's -mrelocatble option\n\
888 -mrelocatable-lib support for GCC's -mrelocatble-lib option\n\
889 -memb set PPC_EMB bit in ELF flags\n\
890 -mlittle, -mlittle-endian\n\
891 generate code for a little endian machine\n\
892 -mbig, -mbig-endian generate code for a big endian machine\n\
893 -msolaris generate code for Solaris\n\
894 -mno-solaris do not generate code for Solaris\n\
895 -V print assembler version number\n\
896 -Qy, -Qn ignored\n"));
897 #endif
898 }
899 \f
900 /* Set ppc_cpu if it is not already set. */
901
902 static void
903 ppc_set_cpu ()
904 {
905 const char *default_os = TARGET_OS;
906 const char *default_cpu = TARGET_CPU;
907
908 if (ppc_cpu == 0)
909 {
910 if (strncmp (default_os, "aix", 3) == 0
911 && default_os[3] >= '4' && default_os[3] <= '9')
912 ppc_cpu = PPC_OPCODE_COMMON;
913 else if (strncmp (default_os, "aix3", 4) == 0)
914 ppc_cpu = PPC_OPCODE_POWER;
915 else if (strcmp (default_cpu, "rs6000") == 0)
916 ppc_cpu = PPC_OPCODE_POWER;
917 else if (strcmp (default_cpu, "powerpc") == 0
918 || strcmp (default_cpu, "powerpcle") == 0)
919 ppc_cpu = PPC_OPCODE_PPC;
920 else
921 as_fatal (_("Unknown default cpu = %s, os = %s"), default_cpu, default_os);
922 }
923 }
924
925 /* Figure out the BFD architecture to use. */
926
927 enum bfd_architecture
928 ppc_arch ()
929 {
930 const char *default_cpu = TARGET_CPU;
931 ppc_set_cpu ();
932
933 if ((ppc_cpu & PPC_OPCODE_PPC) != 0)
934 return bfd_arch_powerpc;
935 else if ((ppc_cpu & PPC_OPCODE_POWER) != 0)
936 return bfd_arch_rs6000;
937 else if ((ppc_cpu & (PPC_OPCODE_COMMON | PPC_OPCODE_ANY)) != 0)
938 {
939 if (strcmp (default_cpu, "rs6000") == 0)
940 return bfd_arch_rs6000;
941 else if (strcmp (default_cpu, "powerpc") == 0
942 || strcmp (default_cpu, "powerpcle") == 0)
943 return bfd_arch_powerpc;
944 }
945
946 as_fatal (_("Neither Power nor PowerPC opcodes were selected."));
947 return bfd_arch_unknown;
948 }
949
950 /* This function is called when the assembler starts up. It is called
951 after the options have been parsed and the output file has been
952 opened. */
953
954 void
955 md_begin ()
956 {
957 register const struct powerpc_opcode *op;
958 const struct powerpc_opcode *op_end;
959 const struct powerpc_macro *macro;
960 const struct powerpc_macro *macro_end;
961 boolean dup_insn = false;
962
963 ppc_set_cpu ();
964
965 #ifdef OBJ_ELF
966 /* Set the ELF flags if desired. */
967 if (ppc_flags && !msolaris)
968 bfd_set_private_flags (stdoutput, ppc_flags);
969 #endif
970
971 /* Insert the opcodes into a hash table. */
972 ppc_hash = hash_new ();
973
974 op_end = powerpc_opcodes + powerpc_num_opcodes;
975 for (op = powerpc_opcodes; op < op_end; op++)
976 {
977 know ((op->opcode & op->mask) == op->opcode);
978
979 if ((op->flags & ppc_cpu) != 0
980 && ((op->flags & (PPC_OPCODE_32 | PPC_OPCODE_64)) == 0
981 || (op->flags & (PPC_OPCODE_32 | PPC_OPCODE_64)) == ppc_size
982 || (ppc_cpu & PPC_OPCODE_64_BRIDGE) != 0))
983 {
984 const char *retval;
985
986 retval = hash_insert (ppc_hash, op->name, (PTR) op);
987 if (retval != (const char *) NULL)
988 {
989 /* Ignore Power duplicates for -m601 */
990 if ((ppc_cpu & PPC_OPCODE_601) != 0
991 && (op->flags & PPC_OPCODE_POWER) != 0)
992 continue;
993
994 as_bad (_("Internal assembler error for instruction %s"), op->name);
995 dup_insn = true;
996 }
997 }
998 }
999
1000 /* Insert the macros into a hash table. */
1001 ppc_macro_hash = hash_new ();
1002
1003 macro_end = powerpc_macros + powerpc_num_macros;
1004 for (macro = powerpc_macros; macro < macro_end; macro++)
1005 {
1006 if ((macro->flags & ppc_cpu) != 0)
1007 {
1008 const char *retval;
1009
1010 retval = hash_insert (ppc_macro_hash, macro->name, (PTR) macro);
1011 if (retval != (const char *) NULL)
1012 {
1013 as_bad (_("Internal assembler error for macro %s"), macro->name);
1014 dup_insn = true;
1015 }
1016 }
1017 }
1018
1019 if (dup_insn)
1020 abort ();
1021
1022 /* Tell the main code what the endianness is if it is not overidden by the user. */
1023 if (!set_target_endian)
1024 {
1025 set_target_endian = 1;
1026 target_big_endian = PPC_BIG_ENDIAN;
1027 }
1028
1029 #ifdef OBJ_XCOFF
1030 ppc_coff_debug_section = coff_section_from_bfd_index (stdoutput, N_DEBUG);
1031
1032 /* Create dummy symbols to serve as initial csects. This forces the
1033 text csects to precede the data csects. These symbols will not
1034 be output. */
1035 ppc_text_csects = symbol_make ("dummy\001");
1036 symbol_get_tc (ppc_text_csects)->within = ppc_text_csects;
1037 ppc_data_csects = symbol_make ("dummy\001");
1038 symbol_get_tc (ppc_data_csects)->within = ppc_data_csects;
1039 #endif
1040
1041 #ifdef TE_PE
1042
1043 ppc_current_section = text_section;
1044 ppc_previous_section = 0;
1045
1046 #endif
1047 }
1048
1049 /* Insert an operand value into an instruction. */
1050
1051 static unsigned long
1052 ppc_insert_operand (insn, operand, val, file, line)
1053 unsigned long insn;
1054 const struct powerpc_operand *operand;
1055 offsetT val;
1056 char *file;
1057 unsigned int line;
1058 {
1059 if (operand->bits != 32)
1060 {
1061 long min, max;
1062 offsetT test;
1063
1064 if ((operand->flags & PPC_OPERAND_SIGNED) != 0)
1065 {
1066 if ((operand->flags & PPC_OPERAND_SIGNOPT) != 0)
1067 max = (1 << operand->bits) - 1;
1068 else
1069 max = (1 << (operand->bits - 1)) - 1;
1070 min = - (1 << (operand->bits - 1));
1071
1072 if (ppc_size == PPC_OPCODE_32)
1073 {
1074 /* Some people write 32 bit hex constants with the sign
1075 extension done by hand. This shouldn't really be
1076 valid, but, to permit this code to assemble on a 64
1077 bit host, we sign extend the 32 bit value. */
1078 if (val > 0
1079 && (val & 0x80000000) != 0
1080 && (val & 0xffffffff) == val)
1081 {
1082 val -= 0x80000000;
1083 val -= 0x80000000;
1084 }
1085 }
1086 }
1087 else
1088 {
1089 max = (1 << operand->bits) - 1;
1090 min = 0;
1091 }
1092
1093 if ((operand->flags & PPC_OPERAND_NEGATIVE) != 0)
1094 test = - val;
1095 else
1096 test = val;
1097
1098 if (test < (offsetT) min || test > (offsetT) max)
1099 {
1100 const char *err =
1101 _("operand out of range (%s not between %ld and %ld)");
1102 char buf[100];
1103
1104 sprint_value (buf, test);
1105 if (file == (char *) NULL)
1106 as_bad (err, buf, min, max);
1107 else
1108 as_bad_where (file, line, err, buf, min, max);
1109 }
1110 }
1111
1112 if (operand->insert)
1113 {
1114 const char *errmsg;
1115
1116 errmsg = NULL;
1117 insn = (*operand->insert) (insn, (long) val, &errmsg);
1118 if (errmsg != (const char *) NULL)
1119 as_bad (errmsg);
1120 }
1121 else
1122 insn |= (((long) val & ((1 << operand->bits) - 1))
1123 << operand->shift);
1124
1125 return insn;
1126 }
1127
1128 \f
1129 #ifdef OBJ_ELF
1130 /* Parse @got, etc. and return the desired relocation. */
1131 static bfd_reloc_code_real_type
1132 ppc_elf_suffix (str_p, exp_p)
1133 char **str_p;
1134 expressionS *exp_p;
1135 {
1136 struct map_bfd {
1137 char *string;
1138 int length;
1139 bfd_reloc_code_real_type reloc;
1140 };
1141
1142 char ident[20];
1143 char *str = *str_p;
1144 char *str2;
1145 int ch;
1146 int len;
1147 struct map_bfd *ptr;
1148
1149 #define MAP(str,reloc) { str, sizeof(str)-1, reloc }
1150
1151 static struct map_bfd mapping[] = {
1152 MAP ("l", BFD_RELOC_LO16),
1153 MAP ("h", BFD_RELOC_HI16),
1154 MAP ("ha", BFD_RELOC_HI16_S),
1155 MAP ("brtaken", BFD_RELOC_PPC_B16_BRTAKEN),
1156 MAP ("brntaken", BFD_RELOC_PPC_B16_BRNTAKEN),
1157 MAP ("got", BFD_RELOC_16_GOTOFF),
1158 MAP ("got@l", BFD_RELOC_LO16_GOTOFF),
1159 MAP ("got@h", BFD_RELOC_HI16_GOTOFF),
1160 MAP ("got@ha", BFD_RELOC_HI16_S_GOTOFF),
1161 MAP ("fixup", BFD_RELOC_CTOR), /* warnings with -mrelocatable */
1162 MAP ("plt", BFD_RELOC_24_PLT_PCREL),
1163 MAP ("pltrel24", BFD_RELOC_24_PLT_PCREL),
1164 MAP ("copy", BFD_RELOC_PPC_COPY),
1165 MAP ("globdat", BFD_RELOC_PPC_GLOB_DAT),
1166 MAP ("local24pc", BFD_RELOC_PPC_LOCAL24PC),
1167 MAP ("local", BFD_RELOC_PPC_LOCAL24PC),
1168 MAP ("pltrel", BFD_RELOC_32_PLT_PCREL),
1169 MAP ("plt@l", BFD_RELOC_LO16_PLTOFF),
1170 MAP ("plt@h", BFD_RELOC_HI16_PLTOFF),
1171 MAP ("plt@ha", BFD_RELOC_HI16_S_PLTOFF),
1172 MAP ("sdarel", BFD_RELOC_GPREL16),
1173 MAP ("sectoff", BFD_RELOC_32_BASEREL),
1174 MAP ("sectoff@l", BFD_RELOC_LO16_BASEREL),
1175 MAP ("sectoff@h", BFD_RELOC_HI16_BASEREL),
1176 MAP ("sectoff@ha", BFD_RELOC_HI16_S_BASEREL),
1177 MAP ("naddr", BFD_RELOC_PPC_EMB_NADDR32),
1178 MAP ("naddr16", BFD_RELOC_PPC_EMB_NADDR16),
1179 MAP ("naddr@l", BFD_RELOC_PPC_EMB_NADDR16_LO),
1180 MAP ("naddr@h", BFD_RELOC_PPC_EMB_NADDR16_HI),
1181 MAP ("naddr@ha", BFD_RELOC_PPC_EMB_NADDR16_HA),
1182 MAP ("sdai16", BFD_RELOC_PPC_EMB_SDAI16),
1183 MAP ("sda2rel", BFD_RELOC_PPC_EMB_SDA2REL),
1184 MAP ("sda2i16", BFD_RELOC_PPC_EMB_SDA2I16),
1185 MAP ("sda21", BFD_RELOC_PPC_EMB_SDA21),
1186 MAP ("mrkref", BFD_RELOC_PPC_EMB_MRKREF),
1187 MAP ("relsect", BFD_RELOC_PPC_EMB_RELSEC16),
1188 MAP ("relsect@l", BFD_RELOC_PPC_EMB_RELST_LO),
1189 MAP ("relsect@h", BFD_RELOC_PPC_EMB_RELST_HI),
1190 MAP ("relsect@ha", BFD_RELOC_PPC_EMB_RELST_HA),
1191 MAP ("bitfld", BFD_RELOC_PPC_EMB_BIT_FLD),
1192 MAP ("relsda", BFD_RELOC_PPC_EMB_RELSDA),
1193 MAP ("xgot", BFD_RELOC_PPC_TOC16),
1194
1195 { (char *)0, 0, BFD_RELOC_UNUSED }
1196 };
1197
1198 if (*str++ != '@')
1199 return BFD_RELOC_UNUSED;
1200
1201 for (ch = *str, str2 = ident;
1202 (str2 < ident + sizeof (ident) - 1
1203 && (isalnum (ch) || ch == '@'));
1204 ch = *++str)
1205 {
1206 *str2++ = (islower (ch)) ? ch : tolower (ch);
1207 }
1208
1209 *str2 = '\0';
1210 len = str2 - ident;
1211
1212 ch = ident[0];
1213 for (ptr = &mapping[0]; ptr->length > 0; ptr++)
1214 if (ch == ptr->string[0]
1215 && len == ptr->length
1216 && memcmp (ident, ptr->string, ptr->length) == 0)
1217 {
1218 if (exp_p->X_add_number != 0
1219 && (ptr->reloc == BFD_RELOC_16_GOTOFF
1220 || ptr->reloc == BFD_RELOC_LO16_GOTOFF
1221 || ptr->reloc == BFD_RELOC_HI16_GOTOFF
1222 || ptr->reloc == BFD_RELOC_HI16_S_GOTOFF))
1223 as_warn (_("identifier+constant@got means identifier@got+constant"));
1224
1225 /* Now check for identifier@suffix+constant */
1226 if (*str == '-' || *str == '+')
1227 {
1228 char *orig_line = input_line_pointer;
1229 expressionS new_exp;
1230
1231 input_line_pointer = str;
1232 expression (&new_exp);
1233 if (new_exp.X_op == O_constant)
1234 {
1235 exp_p->X_add_number += new_exp.X_add_number;
1236 str = input_line_pointer;
1237 }
1238
1239 if (&input_line_pointer != str_p)
1240 input_line_pointer = orig_line;
1241 }
1242
1243 *str_p = str;
1244 return ptr->reloc;
1245 }
1246
1247 return BFD_RELOC_UNUSED;
1248 }
1249
1250 /* Like normal .long/.short/.word, except support @got, etc. */
1251 /* clobbers input_line_pointer, checks */
1252 /* end-of-line. */
1253 static void
1254 ppc_elf_cons (nbytes)
1255 register int nbytes; /* 1=.byte, 2=.word, 4=.long */
1256 {
1257 expressionS exp;
1258 bfd_reloc_code_real_type reloc;
1259
1260 if (is_it_end_of_statement ())
1261 {
1262 demand_empty_rest_of_line ();
1263 return;
1264 }
1265
1266 do
1267 {
1268 expression (&exp);
1269 if (exp.X_op == O_symbol
1270 && *input_line_pointer == '@'
1271 && (reloc = ppc_elf_suffix (&input_line_pointer, &exp)) != BFD_RELOC_UNUSED)
1272 {
1273 reloc_howto_type *reloc_howto = bfd_reloc_type_lookup (stdoutput, reloc);
1274 int size = bfd_get_reloc_size (reloc_howto);
1275
1276 if (size > nbytes)
1277 as_bad (_("%s relocations do not fit in %d bytes\n"), reloc_howto->name, nbytes);
1278
1279 else
1280 {
1281 register char *p = frag_more ((int) nbytes);
1282 int offset = nbytes - size;
1283
1284 fix_new_exp (frag_now, p - frag_now->fr_literal + offset, size, &exp, 0, reloc);
1285 }
1286 }
1287 else
1288 emit_expr (&exp, (unsigned int) nbytes);
1289 }
1290 while (*input_line_pointer++ == ',');
1291
1292 input_line_pointer--; /* Put terminator back into stream. */
1293 demand_empty_rest_of_line ();
1294 }
1295
1296 /* Solaris pseduo op to change to the .rodata section. */
1297 static void
1298 ppc_elf_rdata (xxx)
1299 int xxx;
1300 {
1301 char *save_line = input_line_pointer;
1302 static char section[] = ".rodata\n";
1303
1304 /* Just pretend this is .section .rodata */
1305 input_line_pointer = section;
1306 obj_elf_section (xxx);
1307
1308 input_line_pointer = save_line;
1309 }
1310
1311 /* Pseudo op to make file scope bss items */
1312 static void
1313 ppc_elf_lcomm(xxx)
1314 int xxx;
1315 {
1316 register char *name;
1317 register char c;
1318 register char *p;
1319 offsetT size;
1320 register symbolS *symbolP;
1321 offsetT align;
1322 segT old_sec;
1323 int old_subsec;
1324 char *pfrag;
1325 int align2;
1326
1327 name = input_line_pointer;
1328 c = get_symbol_end ();
1329
1330 /* just after name is now '\0' */
1331 p = input_line_pointer;
1332 *p = c;
1333 SKIP_WHITESPACE ();
1334 if (*input_line_pointer != ',')
1335 {
1336 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1337 ignore_rest_of_line ();
1338 return;
1339 }
1340
1341 input_line_pointer++; /* skip ',' */
1342 if ((size = get_absolute_expression ()) < 0)
1343 {
1344 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) size);
1345 ignore_rest_of_line ();
1346 return;
1347 }
1348
1349 /* The third argument to .lcomm is the alignment. */
1350 if (*input_line_pointer != ',')
1351 align = 8;
1352 else
1353 {
1354 ++input_line_pointer;
1355 align = get_absolute_expression ();
1356 if (align <= 0)
1357 {
1358 as_warn (_("ignoring bad alignment"));
1359 align = 8;
1360 }
1361 }
1362
1363 *p = 0;
1364 symbolP = symbol_find_or_make (name);
1365 *p = c;
1366
1367 if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
1368 {
1369 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1370 S_GET_NAME (symbolP));
1371 ignore_rest_of_line ();
1372 return;
1373 }
1374
1375 if (S_GET_VALUE (symbolP) && S_GET_VALUE (symbolP) != (valueT) size)
1376 {
1377 as_bad (_("Length of .lcomm \"%s\" is already %ld. Not changed to %ld."),
1378 S_GET_NAME (symbolP),
1379 (long) S_GET_VALUE (symbolP),
1380 (long) size);
1381
1382 ignore_rest_of_line ();
1383 return;
1384 }
1385
1386 /* allocate_bss: */
1387 old_sec = now_seg;
1388 old_subsec = now_subseg;
1389 if (align)
1390 {
1391 /* convert to a power of 2 alignment */
1392 for (align2 = 0; (align & 1) == 0; align >>= 1, ++align2);
1393 if (align != 1)
1394 {
1395 as_bad (_("Common alignment not a power of 2"));
1396 ignore_rest_of_line ();
1397 return;
1398 }
1399 }
1400 else
1401 align2 = 0;
1402
1403 record_alignment (bss_section, align2);
1404 subseg_set (bss_section, 0);
1405 if (align2)
1406 frag_align (align2, 0, 0);
1407 if (S_GET_SEGMENT (symbolP) == bss_section)
1408 symbol_get_frag (symbolP)->fr_symbol = 0;
1409 symbol_set_frag (symbolP, frag_now);
1410 pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size,
1411 (char *) 0);
1412 *pfrag = 0;
1413 S_SET_SIZE (symbolP, size);
1414 S_SET_SEGMENT (symbolP, bss_section);
1415 subseg_set (old_sec, old_subsec);
1416 demand_empty_rest_of_line ();
1417 }
1418
1419 /* Validate any relocations emitted for -mrelocatable, possibly adding
1420 fixups for word relocations in writable segments, so we can adjust
1421 them at runtime. */
1422 static void
1423 ppc_elf_validate_fix (fixp, seg)
1424 fixS *fixp;
1425 segT seg;
1426 {
1427 if (fixp->fx_done || fixp->fx_pcrel)
1428 return;
1429
1430 switch (shlib)
1431 {
1432 case SHLIB_NONE:
1433 case SHLIB_PIC:
1434 return;
1435
1436 case SHILB_MRELOCATABLE:
1437 if (fixp->fx_r_type <= BFD_RELOC_UNUSED
1438 && fixp->fx_r_type != BFD_RELOC_16_GOTOFF
1439 && fixp->fx_r_type != BFD_RELOC_HI16_GOTOFF
1440 && fixp->fx_r_type != BFD_RELOC_LO16_GOTOFF
1441 && fixp->fx_r_type != BFD_RELOC_HI16_S_GOTOFF
1442 && fixp->fx_r_type != BFD_RELOC_32_BASEREL
1443 && fixp->fx_r_type != BFD_RELOC_LO16_BASEREL
1444 && fixp->fx_r_type != BFD_RELOC_HI16_BASEREL
1445 && fixp->fx_r_type != BFD_RELOC_HI16_S_BASEREL
1446 && strcmp (segment_name (seg), ".got2") != 0
1447 && strcmp (segment_name (seg), ".dtors") != 0
1448 && strcmp (segment_name (seg), ".ctors") != 0
1449 && strcmp (segment_name (seg), ".fixup") != 0
1450 && strcmp (segment_name (seg), ".stab") != 0
1451 && strcmp (segment_name (seg), ".gcc_except_table") != 0
1452 && strcmp (segment_name (seg), ".eh_frame") != 0
1453 && strcmp (segment_name (seg), ".ex_shared") != 0)
1454 {
1455 if ((seg->flags & (SEC_READONLY | SEC_CODE)) != 0
1456 || fixp->fx_r_type != BFD_RELOC_CTOR)
1457 {
1458 as_bad_where (fixp->fx_file, fixp->fx_line,
1459 _("Relocation cannot be done when using -mrelocatable"));
1460 }
1461 }
1462 return;
1463 }
1464 }
1465 #endif /* OBJ_ELF */
1466 \f
1467 #ifdef TE_PE
1468
1469 /*
1470 * Summary of parse_toc_entry().
1471 *
1472 * in: Input_line_pointer points to the '[' in one of:
1473 *
1474 * [toc] [tocv] [toc32] [toc64]
1475 *
1476 * Anything else is an error of one kind or another.
1477 *
1478 * out:
1479 * return value: success or failure
1480 * toc_kind: kind of toc reference
1481 * input_line_pointer:
1482 * success: first char after the ']'
1483 * failure: unchanged
1484 *
1485 * settings:
1486 *
1487 * [toc] - rv == success, toc_kind = default_toc
1488 * [tocv] - rv == success, toc_kind = data_in_toc
1489 * [toc32] - rv == success, toc_kind = must_be_32
1490 * [toc64] - rv == success, toc_kind = must_be_64
1491 *
1492 */
1493
1494 enum toc_size_qualifier
1495 {
1496 default_toc, /* The toc cell constructed should be the system default size */
1497 data_in_toc, /* This is a direct reference to a toc cell */
1498 must_be_32, /* The toc cell constructed must be 32 bits wide */
1499 must_be_64 /* The toc cell constructed must be 64 bits wide */
1500 };
1501
1502 static int
1503 parse_toc_entry(toc_kind)
1504 enum toc_size_qualifier *toc_kind;
1505 {
1506 char *start;
1507 char *toc_spec;
1508 char c;
1509 enum toc_size_qualifier t;
1510
1511 /* save the input_line_pointer */
1512 start = input_line_pointer;
1513
1514 /* skip over the '[' , and whitespace */
1515 ++input_line_pointer;
1516 SKIP_WHITESPACE ();
1517
1518 /* find the spelling of the operand */
1519 toc_spec = input_line_pointer;
1520 c = get_symbol_end ();
1521
1522 if (strcmp(toc_spec, "toc") == 0)
1523 {
1524 t = default_toc;
1525 }
1526 else if (strcmp(toc_spec, "tocv") == 0)
1527 {
1528 t = data_in_toc;
1529 }
1530 else if (strcmp(toc_spec, "toc32") == 0)
1531 {
1532 t = must_be_32;
1533 }
1534 else if (strcmp(toc_spec, "toc64") == 0)
1535 {
1536 t = must_be_64;
1537 }
1538 else
1539 {
1540 as_bad (_("syntax error: invalid toc specifier `%s'"), toc_spec);
1541 *input_line_pointer = c; /* put back the delimiting char */
1542 input_line_pointer = start; /* reset input_line pointer */
1543 return 0;
1544 }
1545
1546 /* now find the ']' */
1547 *input_line_pointer = c; /* put back the delimiting char */
1548
1549 SKIP_WHITESPACE (); /* leading whitespace could be there. */
1550 c = *input_line_pointer++; /* input_line_pointer->past char in c. */
1551
1552 if (c != ']')
1553 {
1554 as_bad (_("syntax error: expected `]', found `%c'"), c);
1555 input_line_pointer = start; /* reset input_line pointer */
1556 return 0;
1557 }
1558
1559 *toc_kind = t; /* set return value */
1560 return 1;
1561 }
1562 #endif
1563 \f
1564
1565 /* We need to keep a list of fixups. We can't simply generate them as
1566 we go, because that would require us to first create the frag, and
1567 that would screw up references to ``.''. */
1568
1569 struct ppc_fixup
1570 {
1571 expressionS exp;
1572 int opindex;
1573 bfd_reloc_code_real_type reloc;
1574 };
1575
1576 #define MAX_INSN_FIXUPS (5)
1577
1578 /* This routine is called for each instruction to be assembled. */
1579
1580 void
1581 md_assemble (str)
1582 char *str;
1583 {
1584 char *s;
1585 const struct powerpc_opcode *opcode;
1586 unsigned long insn;
1587 const unsigned char *opindex_ptr;
1588 int skip_optional;
1589 int need_paren;
1590 int next_opindex;
1591 struct ppc_fixup fixups[MAX_INSN_FIXUPS];
1592 int fc;
1593 char *f;
1594 int i;
1595 #ifdef OBJ_ELF
1596 bfd_reloc_code_real_type reloc;
1597 #endif
1598
1599 /* Get the opcode. */
1600 for (s = str; *s != '\0' && ! isspace (*s); s++)
1601 ;
1602 if (*s != '\0')
1603 *s++ = '\0';
1604
1605 /* Look up the opcode in the hash table. */
1606 opcode = (const struct powerpc_opcode *) hash_find (ppc_hash, str);
1607 if (opcode == (const struct powerpc_opcode *) NULL)
1608 {
1609 const struct powerpc_macro *macro;
1610
1611 macro = (const struct powerpc_macro *) hash_find (ppc_macro_hash, str);
1612 if (macro == (const struct powerpc_macro *) NULL)
1613 as_bad (_("Unrecognized opcode: `%s'"), str);
1614 else
1615 ppc_macro (s, macro);
1616
1617 return;
1618 }
1619
1620 insn = opcode->opcode;
1621
1622 str = s;
1623 while (isspace (*str))
1624 ++str;
1625
1626 /* PowerPC operands are just expressions. The only real issue is
1627 that a few operand types are optional. All cases which might use
1628 an optional operand separate the operands only with commas (in
1629 some cases parentheses are used, as in ``lwz 1,0(1)'' but such
1630 cases never have optional operands). There is never more than
1631 one optional operand for an instruction. So, before we start
1632 seriously parsing the operands, we check to see if we have an
1633 optional operand, and, if we do, we count the number of commas to
1634 see whether the operand should be omitted. */
1635 skip_optional = 0;
1636 for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++)
1637 {
1638 const struct powerpc_operand *operand;
1639
1640 operand = &powerpc_operands[*opindex_ptr];
1641 if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0)
1642 {
1643 unsigned int opcount;
1644
1645 /* There is an optional operand. Count the number of
1646 commas in the input line. */
1647 if (*str == '\0')
1648 opcount = 0;
1649 else
1650 {
1651 opcount = 1;
1652 s = str;
1653 while ((s = strchr (s, ',')) != (char *) NULL)
1654 {
1655 ++opcount;
1656 ++s;
1657 }
1658 }
1659
1660 /* If there are fewer operands in the line then are called
1661 for by the instruction, we want to skip the optional
1662 operand. */
1663 if (opcount < strlen (opcode->operands))
1664 skip_optional = 1;
1665
1666 break;
1667 }
1668 }
1669
1670 /* Gather the operands. */
1671 need_paren = 0;
1672 next_opindex = 0;
1673 fc = 0;
1674 for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++)
1675 {
1676 const struct powerpc_operand *operand;
1677 const char *errmsg;
1678 char *hold;
1679 expressionS ex;
1680 char endc;
1681
1682 if (next_opindex == 0)
1683 operand = &powerpc_operands[*opindex_ptr];
1684 else
1685 {
1686 operand = &powerpc_operands[next_opindex];
1687 next_opindex = 0;
1688 }
1689
1690 errmsg = NULL;
1691
1692 /* If this is a fake operand, then we do not expect anything
1693 from the input. */
1694 if ((operand->flags & PPC_OPERAND_FAKE) != 0)
1695 {
1696 insn = (*operand->insert) (insn, 0L, &errmsg);
1697 if (errmsg != (const char *) NULL)
1698 as_bad (errmsg);
1699 continue;
1700 }
1701
1702 /* If this is an optional operand, and we are skipping it, just
1703 insert a zero. */
1704 if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0
1705 && skip_optional)
1706 {
1707 if (operand->insert)
1708 {
1709 insn = (*operand->insert) (insn, 0L, &errmsg);
1710 if (errmsg != (const char *) NULL)
1711 as_bad (errmsg);
1712 }
1713 if ((operand->flags & PPC_OPERAND_NEXT) != 0)
1714 next_opindex = *opindex_ptr + 1;
1715 continue;
1716 }
1717
1718 /* Gather the operand. */
1719 hold = input_line_pointer;
1720 input_line_pointer = str;
1721
1722 #ifdef TE_PE
1723 if (*input_line_pointer == '[')
1724 {
1725 /* We are expecting something like the second argument here:
1726
1727 lwz r4,[toc].GS.0.static_int(rtoc)
1728 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1729 The argument following the `]' must be a symbol name, and the
1730 register must be the toc register: 'rtoc' or '2'
1731
1732 The effect is to 0 as the displacement field
1733 in the instruction, and issue an IMAGE_REL_PPC_TOCREL16 (or
1734 the appropriate variation) reloc against it based on the symbol.
1735 The linker will build the toc, and insert the resolved toc offset.
1736
1737 Note:
1738 o The size of the toc entry is currently assumed to be
1739 32 bits. This should not be assumed to be a hard coded
1740 number.
1741 o In an effort to cope with a change from 32 to 64 bits,
1742 there are also toc entries that are specified to be
1743 either 32 or 64 bits:
1744 lwz r4,[toc32].GS.0.static_int(rtoc)
1745 lwz r4,[toc64].GS.0.static_int(rtoc)
1746 These demand toc entries of the specified size, and the
1747 instruction probably requires it.
1748 */
1749
1750 int valid_toc;
1751 enum toc_size_qualifier toc_kind;
1752 bfd_reloc_code_real_type toc_reloc;
1753
1754 /* go parse off the [tocXX] part */
1755 valid_toc = parse_toc_entry(&toc_kind);
1756
1757 if (!valid_toc)
1758 {
1759 /* Note: message has already been issued. */
1760 /* FIXME: what sort of recovery should we do? */
1761 /* demand_rest_of_line(); return; ? */
1762 }
1763
1764 /* Now get the symbol following the ']' */
1765 expression(&ex);
1766
1767 switch (toc_kind)
1768 {
1769 case default_toc:
1770 /* In this case, we may not have seen the symbol yet, since */
1771 /* it is allowed to appear on a .extern or .globl or just be */
1772 /* a label in the .data section. */
1773 toc_reloc = BFD_RELOC_PPC_TOC16;
1774 break;
1775 case data_in_toc:
1776 /* 1. The symbol must be defined and either in the toc */
1777 /* section, or a global. */
1778 /* 2. The reloc generated must have the TOCDEFN flag set in */
1779 /* upper bit mess of the reloc type. */
1780 /* FIXME: It's a little confusing what the tocv qualifier can */
1781 /* be used for. At the very least, I've seen three */
1782 /* uses, only one of which I'm sure I can explain. */
1783 if (ex.X_op == O_symbol)
1784 {
1785 assert (ex.X_add_symbol != NULL);
1786 if (symbol_get_bfdsym (ex.X_add_symbol)->section
1787 != tocdata_section)
1788 {
1789 as_bad(_("[tocv] symbol is not a toc symbol"));
1790 }
1791 }
1792
1793 toc_reloc = BFD_RELOC_PPC_TOC16;
1794 break;
1795 case must_be_32:
1796 /* FIXME: these next two specifically specify 32/64 bit toc */
1797 /* entries. We don't support them today. Is this the */
1798 /* right way to say that? */
1799 toc_reloc = BFD_RELOC_UNUSED;
1800 as_bad (_("Unimplemented toc32 expression modifier"));
1801 break;
1802 case must_be_64:
1803 /* FIXME: see above */
1804 toc_reloc = BFD_RELOC_UNUSED;
1805 as_bad (_("Unimplemented toc64 expression modifier"));
1806 break;
1807 default:
1808 fprintf(stderr,
1809 _("Unexpected return value [%d] from parse_toc_entry!\n"),
1810 toc_kind);
1811 abort();
1812 break;
1813 }
1814
1815 /* We need to generate a fixup for this expression. */
1816 if (fc >= MAX_INSN_FIXUPS)
1817 as_fatal (_("too many fixups"));
1818
1819 fixups[fc].reloc = toc_reloc;
1820 fixups[fc].exp = ex;
1821 fixups[fc].opindex = *opindex_ptr;
1822 ++fc;
1823
1824 /* Ok. We've set up the fixup for the instruction. Now make it
1825 look like the constant 0 was found here */
1826 ex.X_unsigned = 1;
1827 ex.X_op = O_constant;
1828 ex.X_add_number = 0;
1829 ex.X_add_symbol = NULL;
1830 ex.X_op_symbol = NULL;
1831 }
1832
1833 else
1834 #endif /* TE_PE */
1835 {
1836 if (! register_name (&ex))
1837 {
1838 if ((operand->flags & PPC_OPERAND_CR) != 0)
1839 cr_operand = true;
1840 expression (&ex);
1841 cr_operand = false;
1842 }
1843 }
1844
1845 str = input_line_pointer;
1846 input_line_pointer = hold;
1847
1848 if (ex.X_op == O_illegal)
1849 as_bad (_("illegal operand"));
1850 else if (ex.X_op == O_absent)
1851 as_bad (_("missing operand"));
1852 else if (ex.X_op == O_register)
1853 {
1854 insn = ppc_insert_operand (insn, operand, ex.X_add_number,
1855 (char *) NULL, 0);
1856 }
1857 else if (ex.X_op == O_constant)
1858 {
1859 #ifdef OBJ_ELF
1860 /* Allow @HA, @L, @H on constants. */
1861 char *orig_str = str;
1862
1863 if ((reloc = ppc_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED)
1864 switch (reloc)
1865 {
1866 default:
1867 str = orig_str;
1868 break;
1869
1870 case BFD_RELOC_LO16:
1871 /* X_unsigned is the default, so if the user has done
1872 something which cleared it, we always produce a
1873 signed value. */
1874 if (ex.X_unsigned
1875 && (operand->flags & PPC_OPERAND_SIGNED) == 0)
1876 ex.X_add_number &= 0xffff;
1877 else
1878 ex.X_add_number = (((ex.X_add_number & 0xffff)
1879 ^ 0x8000)
1880 - 0x8000);
1881 break;
1882
1883 case BFD_RELOC_HI16:
1884 ex.X_add_number = (ex.X_add_number >> 16) & 0xffff;
1885 break;
1886
1887 case BFD_RELOC_HI16_S:
1888 ex.X_add_number = ((((ex.X_add_number >> 16) & 0xffff)
1889 + ((ex.X_add_number >> 15) & 1))
1890 & 0xffff);
1891 break;
1892 }
1893 #endif
1894 insn = ppc_insert_operand (insn, operand, ex.X_add_number,
1895 (char *) NULL, 0);
1896 }
1897 #ifdef OBJ_ELF
1898 else if ((reloc = ppc_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED)
1899 {
1900 /* For the absoulte forms of branchs, convert the PC relative form back into
1901 the absolute. */
1902 if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0)
1903 {
1904 switch (reloc)
1905 {
1906 case BFD_RELOC_PPC_B26:
1907 reloc = BFD_RELOC_PPC_BA26;
1908 break;
1909 case BFD_RELOC_PPC_B16:
1910 reloc = BFD_RELOC_PPC_BA16;
1911 break;
1912 case BFD_RELOC_PPC_B16_BRTAKEN:
1913 reloc = BFD_RELOC_PPC_BA16_BRTAKEN;
1914 break;
1915 case BFD_RELOC_PPC_B16_BRNTAKEN:
1916 reloc = BFD_RELOC_PPC_BA16_BRNTAKEN;
1917 break;
1918 default:
1919 break;
1920 }
1921 }
1922
1923 /* We need to generate a fixup for this expression. */
1924 if (fc >= MAX_INSN_FIXUPS)
1925 as_fatal (_("too many fixups"));
1926 fixups[fc].exp = ex;
1927 fixups[fc].opindex = 0;
1928 fixups[fc].reloc = reloc;
1929 ++fc;
1930 }
1931 #endif /* OBJ_ELF */
1932
1933 else
1934 {
1935 /* We need to generate a fixup for this expression. */
1936 if (fc >= MAX_INSN_FIXUPS)
1937 as_fatal (_("too many fixups"));
1938 fixups[fc].exp = ex;
1939 fixups[fc].opindex = *opindex_ptr;
1940 fixups[fc].reloc = BFD_RELOC_UNUSED;
1941 ++fc;
1942 }
1943
1944 if (need_paren)
1945 {
1946 endc = ')';
1947 need_paren = 0;
1948 }
1949 else if ((operand->flags & PPC_OPERAND_PARENS) != 0)
1950 {
1951 endc = '(';
1952 need_paren = 1;
1953 }
1954 else
1955 endc = ',';
1956
1957 /* The call to expression should have advanced str past any
1958 whitespace. */
1959 if (*str != endc
1960 && (endc != ',' || *str != '\0'))
1961 {
1962 as_bad (_("syntax error; found `%c' but expected `%c'"), *str, endc);
1963 break;
1964 }
1965
1966 if (*str != '\0')
1967 ++str;
1968 }
1969
1970 while (isspace (*str))
1971 ++str;
1972
1973 if (*str != '\0')
1974 as_bad (_("junk at end of line: `%s'"), str);
1975
1976 /* Write out the instruction. */
1977 f = frag_more (4);
1978 md_number_to_chars (f, insn, 4);
1979
1980 /* Create any fixups. At this point we do not use a
1981 bfd_reloc_code_real_type, but instead just use the
1982 BFD_RELOC_UNUSED plus the operand index. This lets us easily
1983 handle fixups for any operand type, although that is admittedly
1984 not a very exciting feature. We pick a BFD reloc type in
1985 md_apply_fix. */
1986 for (i = 0; i < fc; i++)
1987 {
1988 const struct powerpc_operand *operand;
1989
1990 operand = &powerpc_operands[fixups[i].opindex];
1991 if (fixups[i].reloc != BFD_RELOC_UNUSED)
1992 {
1993 reloc_howto_type *reloc_howto = bfd_reloc_type_lookup (stdoutput, fixups[i].reloc);
1994 int size;
1995 int offset;
1996 fixS *fixP;
1997
1998 if (!reloc_howto)
1999 abort ();
2000
2001 size = bfd_get_reloc_size (reloc_howto);
2002 offset = target_big_endian ? (4 - size) : 0;
2003
2004 if (size < 1 || size > 4)
2005 abort();
2006
2007 fixP = fix_new_exp (frag_now, f - frag_now->fr_literal + offset, size,
2008 &fixups[i].exp, reloc_howto->pc_relative,
2009 fixups[i].reloc);
2010
2011 /* Turn off complaints that the addend is too large for things like
2012 foo+100000@ha. */
2013 switch (fixups[i].reloc)
2014 {
2015 case BFD_RELOC_16_GOTOFF:
2016 case BFD_RELOC_PPC_TOC16:
2017 case BFD_RELOC_LO16:
2018 case BFD_RELOC_HI16:
2019 case BFD_RELOC_HI16_S:
2020 fixP->fx_no_overflow = 1;
2021 break;
2022 default:
2023 break;
2024 }
2025 }
2026 else
2027 fix_new_exp (frag_now, f - frag_now->fr_literal, 4,
2028 &fixups[i].exp,
2029 (operand->flags & PPC_OPERAND_RELATIVE) != 0,
2030 ((bfd_reloc_code_real_type)
2031 (fixups[i].opindex + (int) BFD_RELOC_UNUSED)));
2032 }
2033 }
2034
2035 /* Handle a macro. Gather all the operands, transform them as
2036 described by the macro, and call md_assemble recursively. All the
2037 operands are separated by commas; we don't accept parentheses
2038 around operands here. */
2039
2040 static void
2041 ppc_macro (str, macro)
2042 char *str;
2043 const struct powerpc_macro *macro;
2044 {
2045 char *operands[10];
2046 unsigned int count;
2047 char *s;
2048 unsigned int len;
2049 const char *format;
2050 int arg;
2051 char *send;
2052 char *complete;
2053
2054 /* Gather the users operands into the operands array. */
2055 count = 0;
2056 s = str;
2057 while (1)
2058 {
2059 if (count >= sizeof operands / sizeof operands[0])
2060 break;
2061 operands[count++] = s;
2062 s = strchr (s, ',');
2063 if (s == (char *) NULL)
2064 break;
2065 *s++ = '\0';
2066 }
2067
2068 if (count != macro->operands)
2069 {
2070 as_bad (_("wrong number of operands"));
2071 return;
2072 }
2073
2074 /* Work out how large the string must be (the size is unbounded
2075 because it includes user input). */
2076 len = 0;
2077 format = macro->format;
2078 while (*format != '\0')
2079 {
2080 if (*format != '%')
2081 {
2082 ++len;
2083 ++format;
2084 }
2085 else
2086 {
2087 arg = strtol (format + 1, &send, 10);
2088 know (send != format && arg >= 0 && arg < count);
2089 len += strlen (operands[arg]);
2090 format = send;
2091 }
2092 }
2093
2094 /* Put the string together. */
2095 complete = s = (char *) alloca (len + 1);
2096 format = macro->format;
2097 while (*format != '\0')
2098 {
2099 if (*format != '%')
2100 *s++ = *format++;
2101 else
2102 {
2103 arg = strtol (format + 1, &send, 10);
2104 strcpy (s, operands[arg]);
2105 s += strlen (s);
2106 format = send;
2107 }
2108 }
2109 *s = '\0';
2110
2111 /* Assemble the constructed instruction. */
2112 md_assemble (complete);
2113 }
2114 \f
2115 #ifdef OBJ_ELF
2116 /* For ELF, add support for SHF_EXCLUDE and SHT_ORDERED */
2117
2118 int
2119 ppc_section_letter (letter, ptr_msg)
2120 int letter;
2121 char **ptr_msg;
2122 {
2123 if (letter == 'e')
2124 return SHF_EXCLUDE;
2125
2126 *ptr_msg = _("Bad .section directive: want a,w,x,e in string");
2127 return 0;
2128 }
2129
2130 int
2131 ppc_section_word (str, len)
2132 char *str;
2133 size_t len;
2134 {
2135 if (len == 7 && strncmp (str, "exclude", 7) == 0)
2136 return SHF_EXCLUDE;
2137
2138 return -1;
2139 }
2140
2141 int
2142 ppc_section_type (str, len)
2143 char *str;
2144 size_t len;
2145 {
2146 if (len == 7 && strncmp (str, "ordered", 7) == 0)
2147 return SHT_ORDERED;
2148
2149 return -1;
2150 }
2151
2152 int
2153 ppc_section_flags (flags, attr, type)
2154 int flags;
2155 int attr;
2156 int type;
2157 {
2158 if (type == SHT_ORDERED)
2159 flags |= SEC_ALLOC | SEC_LOAD | SEC_SORT_ENTRIES;
2160
2161 if (attr & SHF_EXCLUDE)
2162 flags |= SEC_EXCLUDE;
2163
2164 return flags;
2165 }
2166 #endif /* OBJ_ELF */
2167
2168 \f
2169 /* Pseudo-op handling. */
2170
2171 /* The .byte pseudo-op. This is similar to the normal .byte
2172 pseudo-op, but it can also take a single ASCII string. */
2173
2174 static void
2175 ppc_byte (ignore)
2176 int ignore;
2177 {
2178 if (*input_line_pointer != '\"')
2179 {
2180 cons (1);
2181 return;
2182 }
2183
2184 /* Gather characters. A real double quote is doubled. Unusual
2185 characters are not permitted. */
2186 ++input_line_pointer;
2187 while (1)
2188 {
2189 char c;
2190
2191 c = *input_line_pointer++;
2192
2193 if (c == '\"')
2194 {
2195 if (*input_line_pointer != '\"')
2196 break;
2197 ++input_line_pointer;
2198 }
2199
2200 FRAG_APPEND_1_CHAR (c);
2201 }
2202
2203 demand_empty_rest_of_line ();
2204 }
2205 \f
2206 #ifdef OBJ_XCOFF
2207
2208 /* XCOFF specific pseudo-op handling. */
2209
2210 /* This is set if we are creating a .stabx symbol, since we don't want
2211 to handle symbol suffixes for such symbols. */
2212 static boolean ppc_stab_symbol;
2213
2214 /* The .comm and .lcomm pseudo-ops for XCOFF. XCOFF puts common
2215 symbols in the .bss segment as though they were local common
2216 symbols, and uses a different smclas. */
2217
2218 static void
2219 ppc_comm (lcomm)
2220 int lcomm;
2221 {
2222 asection *current_seg = now_seg;
2223 subsegT current_subseg = now_subseg;
2224 char *name;
2225 char endc;
2226 char *end_name;
2227 offsetT size;
2228 offsetT align;
2229 symbolS *lcomm_sym = NULL;
2230 symbolS *sym;
2231 char *pfrag;
2232
2233 name = input_line_pointer;
2234 endc = get_symbol_end ();
2235 end_name = input_line_pointer;
2236 *end_name = endc;
2237
2238 if (*input_line_pointer != ',')
2239 {
2240 as_bad (_("missing size"));
2241 ignore_rest_of_line ();
2242 return;
2243 }
2244 ++input_line_pointer;
2245
2246 size = get_absolute_expression ();
2247 if (size < 0)
2248 {
2249 as_bad (_("negative size"));
2250 ignore_rest_of_line ();
2251 return;
2252 }
2253
2254 if (! lcomm)
2255 {
2256 /* The third argument to .comm is the alignment. */
2257 if (*input_line_pointer != ',')
2258 align = 3;
2259 else
2260 {
2261 ++input_line_pointer;
2262 align = get_absolute_expression ();
2263 if (align <= 0)
2264 {
2265 as_warn (_("ignoring bad alignment"));
2266 align = 3;
2267 }
2268 }
2269 }
2270 else
2271 {
2272 char *lcomm_name;
2273 char lcomm_endc;
2274
2275 if (size <= 1)
2276 align = 0;
2277 else if (size <= 2)
2278 align = 1;
2279 else if (size <= 4)
2280 align = 2;
2281 else
2282 align = 3;
2283
2284 /* The third argument to .lcomm appears to be the real local
2285 common symbol to create. References to the symbol named in
2286 the first argument are turned into references to the third
2287 argument. */
2288 if (*input_line_pointer != ',')
2289 {
2290 as_bad (_("missing real symbol name"));
2291 ignore_rest_of_line ();
2292 return;
2293 }
2294 ++input_line_pointer;
2295
2296 lcomm_name = input_line_pointer;
2297 lcomm_endc = get_symbol_end ();
2298
2299 lcomm_sym = symbol_find_or_make (lcomm_name);
2300
2301 *input_line_pointer = lcomm_endc;
2302 }
2303
2304 *end_name = '\0';
2305 sym = symbol_find_or_make (name);
2306 *end_name = endc;
2307
2308 if (S_IS_DEFINED (sym)
2309 || S_GET_VALUE (sym) != 0)
2310 {
2311 as_bad (_("attempt to redefine symbol"));
2312 ignore_rest_of_line ();
2313 return;
2314 }
2315
2316 record_alignment (bss_section, align);
2317
2318 if (! lcomm
2319 || ! S_IS_DEFINED (lcomm_sym))
2320 {
2321 symbolS *def_sym;
2322 offsetT def_size;
2323
2324 if (! lcomm)
2325 {
2326 def_sym = sym;
2327 def_size = size;
2328 S_SET_EXTERNAL (sym);
2329 }
2330 else
2331 {
2332 symbol_get_tc (lcomm_sym)->output = 1;
2333 def_sym = lcomm_sym;
2334 def_size = 0;
2335 }
2336
2337 subseg_set (bss_section, 1);
2338 frag_align (align, 0, 0);
2339
2340 symbol_set_frag (def_sym, frag_now);
2341 pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, def_sym,
2342 def_size, (char *) NULL);
2343 *pfrag = 0;
2344 S_SET_SEGMENT (def_sym, bss_section);
2345 symbol_get_tc (def_sym)->align = align;
2346 }
2347 else if (lcomm)
2348 {
2349 /* Align the size of lcomm_sym. */
2350 symbol_get_frag (lcomm_sym)->fr_offset =
2351 ((symbol_get_frag (lcomm_sym)->fr_offset + (1 << align) - 1)
2352 &~ ((1 << align) - 1));
2353 if (align > symbol_get_tc (lcomm_sym)->align)
2354 symbol_get_tc (lcomm_sym)->align = align;
2355 }
2356
2357 if (lcomm)
2358 {
2359 /* Make sym an offset from lcomm_sym. */
2360 S_SET_SEGMENT (sym, bss_section);
2361 symbol_set_frag (sym, symbol_get_frag (lcomm_sym));
2362 S_SET_VALUE (sym, symbol_get_frag (lcomm_sym)->fr_offset);
2363 symbol_get_frag (lcomm_sym)->fr_offset += size;
2364 }
2365
2366 subseg_set (current_seg, current_subseg);
2367
2368 demand_empty_rest_of_line ();
2369 }
2370
2371 /* The .csect pseudo-op. This switches us into a different
2372 subsegment. The first argument is a symbol whose value is the
2373 start of the .csect. In COFF, csect symbols get special aux
2374 entries defined by the x_csect field of union internal_auxent. The
2375 optional second argument is the alignment (the default is 2). */
2376
2377 static void
2378 ppc_csect (ignore)
2379 int ignore;
2380 {
2381 char *name;
2382 char endc;
2383 symbolS *sym;
2384
2385 name = input_line_pointer;
2386 endc = get_symbol_end ();
2387
2388 sym = symbol_find_or_make (name);
2389
2390 *input_line_pointer = endc;
2391
2392 if (S_GET_NAME (sym)[0] == '\0')
2393 {
2394 /* An unnamed csect is assumed to be [PR]. */
2395 symbol_get_tc (sym)->class = XMC_PR;
2396 }
2397
2398 ppc_change_csect (sym);
2399
2400 if (*input_line_pointer == ',')
2401 {
2402 ++input_line_pointer;
2403 symbol_get_tc (sym)->align = get_absolute_expression ();
2404 }
2405
2406 demand_empty_rest_of_line ();
2407 }
2408
2409 /* Change to a different csect. */
2410
2411 static void
2412 ppc_change_csect (sym)
2413 symbolS *sym;
2414 {
2415 if (S_IS_DEFINED (sym))
2416 subseg_set (S_GET_SEGMENT (sym), symbol_get_tc (sym)->subseg);
2417 else
2418 {
2419 symbolS **list_ptr;
2420 int after_toc;
2421 int hold_chunksize;
2422 symbolS *list;
2423
2424 /* This is a new csect. We need to look at the symbol class to
2425 figure out whether it should go in the text section or the
2426 data section. */
2427 after_toc = 0;
2428 switch (symbol_get_tc (sym)->class)
2429 {
2430 case XMC_PR:
2431 case XMC_RO:
2432 case XMC_DB:
2433 case XMC_GL:
2434 case XMC_XO:
2435 case XMC_SV:
2436 case XMC_TI:
2437 case XMC_TB:
2438 S_SET_SEGMENT (sym, text_section);
2439 symbol_get_tc (sym)->subseg = ppc_text_subsegment;
2440 ++ppc_text_subsegment;
2441 list_ptr = &ppc_text_csects;
2442 break;
2443 case XMC_RW:
2444 case XMC_TC0:
2445 case XMC_TC:
2446 case XMC_DS:
2447 case XMC_UA:
2448 case XMC_BS:
2449 case XMC_UC:
2450 if (ppc_toc_csect != NULL
2451 && (symbol_get_tc (ppc_toc_csect)->subseg + 1
2452 == ppc_data_subsegment))
2453 after_toc = 1;
2454 S_SET_SEGMENT (sym, data_section);
2455 symbol_get_tc (sym)->subseg = ppc_data_subsegment;
2456 ++ppc_data_subsegment;
2457 list_ptr = &ppc_data_csects;
2458 break;
2459 default:
2460 abort ();
2461 }
2462
2463 /* We set the obstack chunk size to a small value before
2464 changing subsegments, so that we don't use a lot of memory
2465 space for what may be a small section. */
2466 hold_chunksize = chunksize;
2467 chunksize = 64;
2468
2469 subseg_new (segment_name (S_GET_SEGMENT (sym)),
2470 symbol_get_tc (sym)->subseg);
2471
2472 chunksize = hold_chunksize;
2473
2474 if (after_toc)
2475 ppc_after_toc_frag = frag_now;
2476
2477 symbol_set_frag (sym, frag_now);
2478 S_SET_VALUE (sym, (valueT) frag_now_fix ());
2479
2480 symbol_get_tc (sym)->align = 2;
2481 symbol_get_tc (sym)->output = 1;
2482 symbol_get_tc (sym)->within = sym;
2483
2484 for (list = *list_ptr;
2485 symbol_get_tc (list)->next != (symbolS *) NULL;
2486 list = symbol_get_tc (list)->next)
2487 ;
2488 symbol_get_tc (list)->next = sym;
2489
2490 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
2491 symbol_append (sym, symbol_get_tc (list)->within, &symbol_rootP,
2492 &symbol_lastP);
2493 }
2494
2495 ppc_current_csect = sym;
2496 }
2497
2498 /* This function handles the .text and .data pseudo-ops. These
2499 pseudo-ops aren't really used by XCOFF; we implement them for the
2500 convenience of people who aren't used to XCOFF. */
2501
2502 static void
2503 ppc_section (type)
2504 int type;
2505 {
2506 const char *name;
2507 symbolS *sym;
2508
2509 if (type == 't')
2510 name = ".text[PR]";
2511 else if (type == 'd')
2512 name = ".data[RW]";
2513 else
2514 abort ();
2515
2516 sym = symbol_find_or_make (name);
2517
2518 ppc_change_csect (sym);
2519
2520 demand_empty_rest_of_line ();
2521 }
2522
2523 /* This function handles the .section pseudo-op. This is mostly to
2524 give an error, since XCOFF only supports .text, .data and .bss, but
2525 we do permit the user to name the text or data section. */
2526
2527 static void
2528 ppc_named_section (ignore)
2529 int ignore;
2530 {
2531 char *user_name;
2532 const char *real_name;
2533 char c;
2534 symbolS *sym;
2535
2536 user_name = input_line_pointer;
2537 c = get_symbol_end ();
2538
2539 if (strcmp (user_name, ".text") == 0)
2540 real_name = ".text[PR]";
2541 else if (strcmp (user_name, ".data") == 0)
2542 real_name = ".data[RW]";
2543 else
2544 {
2545 as_bad (_("The XCOFF file format does not support arbitrary sections"));
2546 *input_line_pointer = c;
2547 ignore_rest_of_line ();
2548 return;
2549 }
2550
2551 *input_line_pointer = c;
2552
2553 sym = symbol_find_or_make (real_name);
2554
2555 ppc_change_csect (sym);
2556
2557 demand_empty_rest_of_line ();
2558 }
2559
2560 /* The .extern pseudo-op. We create an undefined symbol. */
2561
2562 static void
2563 ppc_extern (ignore)
2564 int ignore;
2565 {
2566 char *name;
2567 char endc;
2568
2569 name = input_line_pointer;
2570 endc = get_symbol_end ();
2571
2572 (void) symbol_find_or_make (name);
2573
2574 *input_line_pointer = endc;
2575
2576 demand_empty_rest_of_line ();
2577 }
2578
2579 /* The .lglobl pseudo-op. Keep the symbol in the symbol table. */
2580
2581 static void
2582 ppc_lglobl (ignore)
2583 int ignore;
2584 {
2585 char *name;
2586 char endc;
2587 symbolS *sym;
2588
2589 name = input_line_pointer;
2590 endc = get_symbol_end ();
2591
2592 sym = symbol_find_or_make (name);
2593
2594 *input_line_pointer = endc;
2595
2596 symbol_get_tc (sym)->output = 1;
2597
2598 demand_empty_rest_of_line ();
2599 }
2600
2601 /* The .rename pseudo-op. The RS/6000 assembler can rename symbols,
2602 although I don't know why it bothers. */
2603
2604 static void
2605 ppc_rename (ignore)
2606 int ignore;
2607 {
2608 char *name;
2609 char endc;
2610 symbolS *sym;
2611 int len;
2612
2613 name = input_line_pointer;
2614 endc = get_symbol_end ();
2615
2616 sym = symbol_find_or_make (name);
2617
2618 *input_line_pointer = endc;
2619
2620 if (*input_line_pointer != ',')
2621 {
2622 as_bad (_("missing rename string"));
2623 ignore_rest_of_line ();
2624 return;
2625 }
2626 ++input_line_pointer;
2627
2628 symbol_get_tc (sym)->real_name = demand_copy_C_string (&len);
2629
2630 demand_empty_rest_of_line ();
2631 }
2632
2633 /* The .stabx pseudo-op. This is similar to a normal .stabs
2634 pseudo-op, but slightly different. A sample is
2635 .stabx "main:F-1",.main,142,0
2636 The first argument is the symbol name to create. The second is the
2637 value, and the third is the storage class. The fourth seems to be
2638 always zero, and I am assuming it is the type. */
2639
2640 static void
2641 ppc_stabx (ignore)
2642 int ignore;
2643 {
2644 char *name;
2645 int len;
2646 symbolS *sym;
2647 expressionS exp;
2648
2649 name = demand_copy_C_string (&len);
2650
2651 if (*input_line_pointer != ',')
2652 {
2653 as_bad (_("missing value"));
2654 return;
2655 }
2656 ++input_line_pointer;
2657
2658 ppc_stab_symbol = true;
2659 sym = symbol_make (name);
2660 ppc_stab_symbol = false;
2661
2662 symbol_get_tc (sym)->real_name = name;
2663
2664 (void) expression (&exp);
2665
2666 switch (exp.X_op)
2667 {
2668 case O_illegal:
2669 case O_absent:
2670 case O_big:
2671 as_bad (_("illegal .stabx expression; zero assumed"));
2672 exp.X_add_number = 0;
2673 /* Fall through. */
2674 case O_constant:
2675 S_SET_VALUE (sym, (valueT) exp.X_add_number);
2676 symbol_set_frag (sym, &zero_address_frag);
2677 break;
2678
2679 case O_symbol:
2680 if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section)
2681 symbol_set_value_expression (sym, &exp);
2682 else
2683 {
2684 S_SET_VALUE (sym,
2685 exp.X_add_number + S_GET_VALUE (exp.X_add_symbol));
2686 symbol_set_frag (sym, symbol_get_frag (exp.X_add_symbol));
2687 }
2688 break;
2689
2690 default:
2691 /* The value is some complex expression. This will probably
2692 fail at some later point, but this is probably the right
2693 thing to do here. */
2694 symbol_set_value_expression (sym, &exp);
2695 break;
2696 }
2697
2698 S_SET_SEGMENT (sym, ppc_coff_debug_section);
2699 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
2700
2701 if (*input_line_pointer != ',')
2702 {
2703 as_bad (_("missing class"));
2704 return;
2705 }
2706 ++input_line_pointer;
2707
2708 S_SET_STORAGE_CLASS (sym, get_absolute_expression ());
2709
2710 if (*input_line_pointer != ',')
2711 {
2712 as_bad (_("missing type"));
2713 return;
2714 }
2715 ++input_line_pointer;
2716
2717 S_SET_DATA_TYPE (sym, get_absolute_expression ());
2718
2719 symbol_get_tc (sym)->output = 1;
2720
2721 if (S_GET_STORAGE_CLASS (sym) == C_STSYM)
2722 symbol_get_tc (sym)->within = ppc_current_block;
2723
2724 if (exp.X_op != O_symbol
2725 || ! S_IS_EXTERNAL (exp.X_add_symbol)
2726 || S_GET_SEGMENT (exp.X_add_symbol) != bss_section)
2727 ppc_frob_label (sym);
2728 else
2729 {
2730 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
2731 symbol_append (sym, exp.X_add_symbol, &symbol_rootP, &symbol_lastP);
2732 if (symbol_get_tc (ppc_current_csect)->within == exp.X_add_symbol)
2733 symbol_get_tc (ppc_current_csect)->within = sym;
2734 }
2735
2736 demand_empty_rest_of_line ();
2737 }
2738
2739 /* The .function pseudo-op. This takes several arguments. The first
2740 argument seems to be the external name of the symbol. The second
2741 argment seems to be the label for the start of the function. gcc
2742 uses the same name for both. I have no idea what the third and
2743 fourth arguments are meant to be. The optional fifth argument is
2744 an expression for the size of the function. In COFF this symbol
2745 gets an aux entry like that used for a csect. */
2746
2747 static void
2748 ppc_function (ignore)
2749 int ignore;
2750 {
2751 char *name;
2752 char endc;
2753 char *s;
2754 symbolS *ext_sym;
2755 symbolS *lab_sym;
2756
2757 name = input_line_pointer;
2758 endc = get_symbol_end ();
2759
2760 /* Ignore any [PR] suffix. */
2761 name = ppc_canonicalize_symbol_name (name);
2762 s = strchr (name, '[');
2763 if (s != (char *) NULL
2764 && strcmp (s + 1, "PR]") == 0)
2765 *s = '\0';
2766
2767 ext_sym = symbol_find_or_make (name);
2768
2769 *input_line_pointer = endc;
2770
2771 if (*input_line_pointer != ',')
2772 {
2773 as_bad (_("missing symbol name"));
2774 ignore_rest_of_line ();
2775 return;
2776 }
2777 ++input_line_pointer;
2778
2779 name = input_line_pointer;
2780 endc = get_symbol_end ();
2781
2782 lab_sym = symbol_find_or_make (name);
2783
2784 *input_line_pointer = endc;
2785
2786 if (ext_sym != lab_sym)
2787 {
2788 expressionS exp;
2789
2790 exp.X_op = O_symbol;
2791 exp.X_add_symbol = lab_sym;
2792 exp.X_op_symbol = NULL;
2793 exp.X_add_number = 0;
2794 exp.X_unsigned = 0;
2795 symbol_set_value_expression (ext_sym, &exp);
2796 }
2797
2798 if (symbol_get_tc (ext_sym)->class == -1)
2799 symbol_get_tc (ext_sym)->class = XMC_PR;
2800 symbol_get_tc (ext_sym)->output = 1;
2801
2802 if (*input_line_pointer == ',')
2803 {
2804 expressionS ignore;
2805
2806 /* Ignore the third argument. */
2807 ++input_line_pointer;
2808 expression (&ignore);
2809 if (*input_line_pointer == ',')
2810 {
2811 /* Ignore the fourth argument. */
2812 ++input_line_pointer;
2813 expression (&ignore);
2814 if (*input_line_pointer == ',')
2815 {
2816 /* The fifth argument is the function size. */
2817 ++input_line_pointer;
2818 symbol_get_tc (ext_sym)->size = symbol_new ("L0\001",
2819 absolute_section,
2820 (valueT) 0,
2821 &zero_address_frag);
2822 pseudo_set (symbol_get_tc (ext_sym)->size);
2823 }
2824 }
2825 }
2826
2827 S_SET_DATA_TYPE (ext_sym, DT_FCN << N_BTSHFT);
2828 SF_SET_FUNCTION (ext_sym);
2829 SF_SET_PROCESS (ext_sym);
2830 coff_add_linesym (ext_sym);
2831
2832 demand_empty_rest_of_line ();
2833 }
2834
2835 /* The .bf pseudo-op. This is just like a COFF C_FCN symbol named
2836 ".bf". */
2837
2838 static void
2839 ppc_bf (ignore)
2840 int ignore;
2841 {
2842 symbolS *sym;
2843
2844 sym = symbol_make (".bf");
2845 S_SET_SEGMENT (sym, text_section);
2846 symbol_set_frag (sym, frag_now);
2847 S_SET_VALUE (sym, frag_now_fix ());
2848 S_SET_STORAGE_CLASS (sym, C_FCN);
2849
2850 coff_line_base = get_absolute_expression ();
2851
2852 S_SET_NUMBER_AUXILIARY (sym, 1);
2853 SA_SET_SYM_LNNO (sym, coff_line_base);
2854
2855 symbol_get_tc (sym)->output = 1;
2856
2857 ppc_frob_label (sym);
2858
2859 demand_empty_rest_of_line ();
2860 }
2861
2862 /* The .ef pseudo-op. This is just like a COFF C_FCN symbol named
2863 ".ef", except that the line number is absolute, not relative to the
2864 most recent ".bf" symbol. */
2865
2866 static void
2867 ppc_ef (ignore)
2868 int ignore;
2869 {
2870 symbolS *sym;
2871
2872 sym = symbol_make (".ef");
2873 S_SET_SEGMENT (sym, text_section);
2874 symbol_set_frag (sym, frag_now);
2875 S_SET_VALUE (sym, frag_now_fix ());
2876 S_SET_STORAGE_CLASS (sym, C_FCN);
2877 S_SET_NUMBER_AUXILIARY (sym, 1);
2878 SA_SET_SYM_LNNO (sym, get_absolute_expression ());
2879 symbol_get_tc (sym)->output = 1;
2880
2881 ppc_frob_label (sym);
2882
2883 demand_empty_rest_of_line ();
2884 }
2885
2886 /* The .bi and .ei pseudo-ops. These take a string argument and
2887 generates a C_BINCL or C_EINCL symbol, which goes at the start of
2888 the symbol list. */
2889
2890 static void
2891 ppc_biei (ei)
2892 int ei;
2893 {
2894 static symbolS *last_biei;
2895
2896 char *name;
2897 int len;
2898 symbolS *sym;
2899 symbolS *look;
2900
2901 name = demand_copy_C_string (&len);
2902
2903 /* The value of these symbols is actually file offset. Here we set
2904 the value to the index into the line number entries. In
2905 ppc_frob_symbols we set the fix_line field, which will cause BFD
2906 to do the right thing. */
2907
2908 sym = symbol_make (name);
2909 /* obj-coff.c currently only handles line numbers correctly in the
2910 .text section. */
2911 S_SET_SEGMENT (sym, text_section);
2912 S_SET_VALUE (sym, coff_n_line_nos);
2913 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
2914
2915 S_SET_STORAGE_CLASS (sym, ei ? C_EINCL : C_BINCL);
2916 symbol_get_tc (sym)->output = 1;
2917
2918 for (look = last_biei ? last_biei : symbol_rootP;
2919 (look != (symbolS *) NULL
2920 && (S_GET_STORAGE_CLASS (look) == C_FILE
2921 || S_GET_STORAGE_CLASS (look) == C_BINCL
2922 || S_GET_STORAGE_CLASS (look) == C_EINCL));
2923 look = symbol_next (look))
2924 ;
2925 if (look != (symbolS *) NULL)
2926 {
2927 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
2928 symbol_insert (sym, look, &symbol_rootP, &symbol_lastP);
2929 last_biei = sym;
2930 }
2931
2932 demand_empty_rest_of_line ();
2933 }
2934
2935 /* The .bs pseudo-op. This generates a C_BSTAT symbol named ".bs".
2936 There is one argument, which is a csect symbol. The value of the
2937 .bs symbol is the index of this csect symbol. */
2938
2939 static void
2940 ppc_bs (ignore)
2941 int ignore;
2942 {
2943 char *name;
2944 char endc;
2945 symbolS *csect;
2946 symbolS *sym;
2947
2948 if (ppc_current_block != NULL)
2949 as_bad (_("nested .bs blocks"));
2950
2951 name = input_line_pointer;
2952 endc = get_symbol_end ();
2953
2954 csect = symbol_find_or_make (name);
2955
2956 *input_line_pointer = endc;
2957
2958 sym = symbol_make (".bs");
2959 S_SET_SEGMENT (sym, now_seg);
2960 S_SET_STORAGE_CLASS (sym, C_BSTAT);
2961 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
2962 symbol_get_tc (sym)->output = 1;
2963
2964 symbol_get_tc (sym)->within = csect;
2965
2966 ppc_frob_label (sym);
2967
2968 ppc_current_block = sym;
2969
2970 demand_empty_rest_of_line ();
2971 }
2972
2973 /* The .es pseudo-op. Generate a C_ESTART symbol named .es. */
2974
2975 static void
2976 ppc_es (ignore)
2977 int ignore;
2978 {
2979 symbolS *sym;
2980
2981 if (ppc_current_block == NULL)
2982 as_bad (_(".es without preceding .bs"));
2983
2984 sym = symbol_make (".es");
2985 S_SET_SEGMENT (sym, now_seg);
2986 S_SET_STORAGE_CLASS (sym, C_ESTAT);
2987 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
2988 symbol_get_tc (sym)->output = 1;
2989
2990 ppc_frob_label (sym);
2991
2992 ppc_current_block = NULL;
2993
2994 demand_empty_rest_of_line ();
2995 }
2996
2997 /* The .bb pseudo-op. Generate a C_BLOCK symbol named .bb, with a
2998 line number. */
2999
3000 static void
3001 ppc_bb (ignore)
3002 int ignore;
3003 {
3004 symbolS *sym;
3005
3006 sym = symbol_make (".bb");
3007 S_SET_SEGMENT (sym, text_section);
3008 symbol_set_frag (sym, frag_now);
3009 S_SET_VALUE (sym, frag_now_fix ());
3010 S_SET_STORAGE_CLASS (sym, C_BLOCK);
3011
3012 S_SET_NUMBER_AUXILIARY (sym, 1);
3013 SA_SET_SYM_LNNO (sym, get_absolute_expression ());
3014
3015 symbol_get_tc (sym)->output = 1;
3016
3017 SF_SET_PROCESS (sym);
3018
3019 ppc_frob_label (sym);
3020
3021 demand_empty_rest_of_line ();
3022 }
3023
3024 /* The .eb pseudo-op. Generate a C_BLOCK symbol named .eb, with a
3025 line number. */
3026
3027 static void
3028 ppc_eb (ignore)
3029 int ignore;
3030 {
3031 symbolS *sym;
3032
3033 sym = symbol_make (".eb");
3034 S_SET_SEGMENT (sym, text_section);
3035 symbol_set_frag (sym, frag_now);
3036 S_SET_VALUE (sym, frag_now_fix ());
3037 S_SET_STORAGE_CLASS (sym, C_BLOCK);
3038 S_SET_NUMBER_AUXILIARY (sym, 1);
3039 SA_SET_SYM_LNNO (sym, get_absolute_expression ());
3040 symbol_get_tc (sym)->output = 1;
3041
3042 SF_SET_PROCESS (sym);
3043
3044 ppc_frob_label (sym);
3045
3046 demand_empty_rest_of_line ();
3047 }
3048
3049 /* The .bc pseudo-op. This just creates a C_BCOMM symbol with a
3050 specified name. */
3051
3052 static void
3053 ppc_bc (ignore)
3054 int ignore;
3055 {
3056 char *name;
3057 int len;
3058 symbolS *sym;
3059
3060 name = demand_copy_C_string (&len);
3061 sym = symbol_make (name);
3062 S_SET_SEGMENT (sym, ppc_coff_debug_section);
3063 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
3064 S_SET_STORAGE_CLASS (sym, C_BCOMM);
3065 S_SET_VALUE (sym, 0);
3066 symbol_get_tc (sym)->output = 1;
3067
3068 ppc_frob_label (sym);
3069
3070 demand_empty_rest_of_line ();
3071 }
3072
3073 /* The .ec pseudo-op. This just creates a C_ECOMM symbol. */
3074
3075 static void
3076 ppc_ec (ignore)
3077 int ignore;
3078 {
3079 symbolS *sym;
3080
3081 sym = symbol_make (".ec");
3082 S_SET_SEGMENT (sym, ppc_coff_debug_section);
3083 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
3084 S_SET_STORAGE_CLASS (sym, C_ECOMM);
3085 S_SET_VALUE (sym, 0);
3086 symbol_get_tc (sym)->output = 1;
3087
3088 ppc_frob_label (sym);
3089
3090 demand_empty_rest_of_line ();
3091 }
3092
3093 /* The .toc pseudo-op. Switch to the .toc subsegment. */
3094
3095 static void
3096 ppc_toc (ignore)
3097 int ignore;
3098 {
3099 if (ppc_toc_csect != (symbolS *) NULL)
3100 subseg_set (data_section, symbol_get_tc (ppc_toc_csect)->subseg);
3101 else
3102 {
3103 subsegT subseg;
3104 symbolS *sym;
3105 symbolS *list;
3106
3107 subseg = ppc_data_subsegment;
3108 ++ppc_data_subsegment;
3109
3110 subseg_new (segment_name (data_section), subseg);
3111 ppc_toc_frag = frag_now;
3112
3113 sym = symbol_find_or_make ("TOC[TC0]");
3114 symbol_set_frag (sym, frag_now);
3115 S_SET_SEGMENT (sym, data_section);
3116 S_SET_VALUE (sym, (valueT) frag_now_fix ());
3117 symbol_get_tc (sym)->subseg = subseg;
3118 symbol_get_tc (sym)->output = 1;
3119 symbol_get_tc (sym)->within = sym;
3120
3121 ppc_toc_csect = sym;
3122
3123 for (list = ppc_data_csects;
3124 symbol_get_tc (list)->next != (symbolS *) NULL;
3125 list = symbol_get_tc (list)->next)
3126 ;
3127 symbol_get_tc (list)->next = sym;
3128
3129 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
3130 symbol_append (sym, symbol_get_tc (list)->within, &symbol_rootP,
3131 &symbol_lastP);
3132 }
3133
3134 ppc_current_csect = ppc_toc_csect;
3135
3136 demand_empty_rest_of_line ();
3137 }
3138
3139 /* The AIX assembler automatically aligns the operands of a .long or
3140 .short pseudo-op, and we want to be compatible. */
3141
3142 static void
3143 ppc_xcoff_cons (log_size)
3144 int log_size;
3145 {
3146 frag_align (log_size, 0, 0);
3147 record_alignment (now_seg, log_size);
3148 cons (1 << log_size);
3149 }
3150
3151 static void
3152 ppc_vbyte (dummy)
3153 int dummy;
3154 {
3155 expressionS exp;
3156 int byte_count;
3157
3158 (void) expression (&exp);
3159
3160 if (exp.X_op != O_constant)
3161 {
3162 as_bad (_("non-constant byte count"));
3163 return;
3164 }
3165
3166 byte_count = exp.X_add_number;
3167
3168 if (*input_line_pointer != ',')
3169 {
3170 as_bad (_("missing value"));
3171 return;
3172 }
3173
3174 ++input_line_pointer;
3175 cons (byte_count);
3176 }
3177
3178 #endif /* OBJ_XCOFF */
3179 \f
3180 /* The .tc pseudo-op. This is used when generating either XCOFF or
3181 ELF. This takes two or more arguments.
3182
3183 When generating XCOFF output, the first argument is the name to
3184 give to this location in the toc; this will be a symbol with class
3185 TC. The rest of the arguments are 4 byte values to actually put at
3186 this location in the TOC; often there is just one more argument, a
3187 relocateable symbol reference.
3188
3189 When not generating XCOFF output, the arguments are the same, but
3190 the first argument is simply ignored. */
3191
3192 static void
3193 ppc_tc (ignore)
3194 int ignore;
3195 {
3196 #ifdef OBJ_XCOFF
3197
3198 /* Define the TOC symbol name. */
3199 {
3200 char *name;
3201 char endc;
3202 symbolS *sym;
3203
3204 if (ppc_toc_csect == (symbolS *) NULL
3205 || ppc_toc_csect != ppc_current_csect)
3206 {
3207 as_bad (_(".tc not in .toc section"));
3208 ignore_rest_of_line ();
3209 return;
3210 }
3211
3212 name = input_line_pointer;
3213 endc = get_symbol_end ();
3214
3215 sym = symbol_find_or_make (name);
3216
3217 *input_line_pointer = endc;
3218
3219 if (S_IS_DEFINED (sym))
3220 {
3221 symbolS *label;
3222
3223 label = symbol_get_tc (ppc_current_csect)->within;
3224 if (symbol_get_tc (label)->class != XMC_TC0)
3225 {
3226 as_bad (_(".tc with no label"));
3227 ignore_rest_of_line ();
3228 return;
3229 }
3230
3231 S_SET_SEGMENT (label, S_GET_SEGMENT (sym));
3232 symbol_set_frag (label, symbol_get_frag (sym));
3233 S_SET_VALUE (label, S_GET_VALUE (sym));
3234
3235 while (! is_end_of_line[(unsigned char) *input_line_pointer])
3236 ++input_line_pointer;
3237
3238 return;
3239 }
3240
3241 S_SET_SEGMENT (sym, now_seg);
3242 symbol_set_frag (sym, frag_now);
3243 S_SET_VALUE (sym, (valueT) frag_now_fix ());
3244 symbol_get_tc (sym)->class = XMC_TC;
3245 symbol_get_tc (sym)->output = 1;
3246
3247 ppc_frob_label (sym);
3248 }
3249
3250 #else /* ! defined (OBJ_XCOFF) */
3251
3252 /* Skip the TOC symbol name. */
3253 while (is_part_of_name (*input_line_pointer)
3254 || *input_line_pointer == '['
3255 || *input_line_pointer == ']'
3256 || *input_line_pointer == '{'
3257 || *input_line_pointer == '}')
3258 ++input_line_pointer;
3259
3260 /* Align to a four byte boundary. */
3261 frag_align (2, 0, 0);
3262 record_alignment (now_seg, 2);
3263
3264 #endif /* ! defined (OBJ_XCOFF) */
3265
3266 if (*input_line_pointer != ',')
3267 demand_empty_rest_of_line ();
3268 else
3269 {
3270 ++input_line_pointer;
3271 cons (4);
3272 }
3273 }
3274 \f
3275 #ifdef TE_PE
3276
3277 /* Pseudo-ops specific to the Windows NT PowerPC PE (coff) format */
3278
3279 /* Set the current section. */
3280 static void
3281 ppc_set_current_section (new)
3282 segT new;
3283 {
3284 ppc_previous_section = ppc_current_section;
3285 ppc_current_section = new;
3286 }
3287
3288 /* pseudo-op: .previous
3289 behaviour: toggles the current section with the previous section.
3290 errors: None
3291 warnings: "No previous section"
3292 */
3293 static void
3294 ppc_previous(ignore)
3295 int ignore;
3296 {
3297 symbolS *tmp;
3298
3299 if (ppc_previous_section == NULL)
3300 {
3301 as_warn(_("No previous section to return to. Directive ignored."));
3302 return;
3303 }
3304
3305 subseg_set(ppc_previous_section, 0);
3306
3307 ppc_set_current_section(ppc_previous_section);
3308 }
3309
3310 /* pseudo-op: .pdata
3311 behaviour: predefined read only data section
3312 double word aligned
3313 errors: None
3314 warnings: None
3315 initial: .section .pdata "adr3"
3316 a - don't know -- maybe a misprint
3317 d - initialized data
3318 r - readable
3319 3 - double word aligned (that would be 4 byte boundary)
3320
3321 commentary:
3322 Tag index tables (also known as the function table) for exception
3323 handling, debugging, etc.
3324
3325 */
3326 static void
3327 ppc_pdata(ignore)
3328 int ignore;
3329 {
3330 if (pdata_section == 0)
3331 {
3332 pdata_section = subseg_new (".pdata", 0);
3333
3334 bfd_set_section_flags (stdoutput, pdata_section,
3335 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
3336 | SEC_READONLY | SEC_DATA ));
3337
3338 bfd_set_section_alignment (stdoutput, pdata_section, 2);
3339 }
3340 else
3341 {
3342 pdata_section = subseg_new(".pdata", 0);
3343 }
3344 ppc_set_current_section(pdata_section);
3345 }
3346
3347 /* pseudo-op: .ydata
3348 behaviour: predefined read only data section
3349 double word aligned
3350 errors: None
3351 warnings: None
3352 initial: .section .ydata "drw3"
3353 a - don't know -- maybe a misprint
3354 d - initialized data
3355 r - readable
3356 3 - double word aligned (that would be 4 byte boundary)
3357 commentary:
3358 Tag tables (also known as the scope table) for exception handling,
3359 debugging, etc.
3360 */
3361 static void
3362 ppc_ydata(ignore)
3363 int ignore;
3364 {
3365 if (ydata_section == 0)
3366 {
3367 ydata_section = subseg_new (".ydata", 0);
3368 bfd_set_section_flags (stdoutput, ydata_section,
3369 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
3370 | SEC_READONLY | SEC_DATA ));
3371
3372 bfd_set_section_alignment (stdoutput, ydata_section, 3);
3373 }
3374 else
3375 {
3376 ydata_section = subseg_new (".ydata", 0);
3377 }
3378 ppc_set_current_section(ydata_section);
3379 }
3380
3381 /* pseudo-op: .reldata
3382 behaviour: predefined read write data section
3383 double word aligned (4-byte)
3384 FIXME: relocation is applied to it
3385 FIXME: what's the difference between this and .data?
3386 errors: None
3387 warnings: None
3388 initial: .section .reldata "drw3"
3389 d - initialized data
3390 r - readable
3391 w - writeable
3392 3 - double word aligned (that would be 8 byte boundary)
3393
3394 commentary:
3395 Like .data, but intended to hold data subject to relocation, such as
3396 function descriptors, etc.
3397 */
3398 static void
3399 ppc_reldata(ignore)
3400 int ignore;
3401 {
3402 if (reldata_section == 0)
3403 {
3404 reldata_section = subseg_new (".reldata", 0);
3405
3406 bfd_set_section_flags (stdoutput, reldata_section,
3407 ( SEC_ALLOC | SEC_LOAD | SEC_RELOC
3408 | SEC_DATA ));
3409
3410 bfd_set_section_alignment (stdoutput, reldata_section, 2);
3411 }
3412 else
3413 {
3414 reldata_section = subseg_new (".reldata", 0);
3415 }
3416 ppc_set_current_section(reldata_section);
3417 }
3418
3419 /* pseudo-op: .rdata
3420 behaviour: predefined read only data section
3421 double word aligned
3422 errors: None
3423 warnings: None
3424 initial: .section .rdata "dr3"
3425 d - initialized data
3426 r - readable
3427 3 - double word aligned (that would be 4 byte boundary)
3428 */
3429 static void
3430 ppc_rdata(ignore)
3431 int ignore;
3432 {
3433 if (rdata_section == 0)
3434 {
3435 rdata_section = subseg_new (".rdata", 0);
3436 bfd_set_section_flags (stdoutput, rdata_section,
3437 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
3438 | SEC_READONLY | SEC_DATA ));
3439
3440 bfd_set_section_alignment (stdoutput, rdata_section, 2);
3441 }
3442 else
3443 {
3444 rdata_section = subseg_new (".rdata", 0);
3445 }
3446 ppc_set_current_section(rdata_section);
3447 }
3448
3449 /* pseudo-op: .ualong
3450 behaviour: much like .int, with the exception that no alignment is
3451 performed.
3452 FIXME: test the alignment statement
3453 errors: None
3454 warnings: None
3455 */
3456 static void
3457 ppc_ualong(ignore)
3458 int ignore;
3459 {
3460 /* try for long */
3461 cons ( 4 );
3462 }
3463
3464 /* pseudo-op: .znop <symbol name>
3465 behaviour: Issue a nop instruction
3466 Issue a IMAGE_REL_PPC_IFGLUE relocation against it, using
3467 the supplied symbol name.
3468 errors: None
3469 warnings: Missing symbol name
3470 */
3471 static void
3472 ppc_znop(ignore)
3473 int ignore;
3474 {
3475 unsigned long insn;
3476 const struct powerpc_opcode *opcode;
3477 expressionS ex;
3478 char *f;
3479
3480 symbolS *sym;
3481
3482 /* Strip out the symbol name */
3483 char *symbol_name;
3484 char c;
3485 char *name;
3486 unsigned int exp;
3487 flagword flags;
3488 asection *sec;
3489
3490 symbol_name = input_line_pointer;
3491 c = get_symbol_end ();
3492
3493 name = xmalloc (input_line_pointer - symbol_name + 1);
3494 strcpy (name, symbol_name);
3495
3496 sym = symbol_find_or_make (name);
3497
3498 *input_line_pointer = c;
3499
3500 SKIP_WHITESPACE ();
3501
3502 /* Look up the opcode in the hash table. */
3503 opcode = (const struct powerpc_opcode *) hash_find (ppc_hash, "nop");
3504
3505 /* stick in the nop */
3506 insn = opcode->opcode;
3507
3508 /* Write out the instruction. */
3509 f = frag_more (4);
3510 md_number_to_chars (f, insn, 4);
3511 fix_new (frag_now,
3512 f - frag_now->fr_literal,
3513 4,
3514 sym,
3515 0,
3516 0,
3517 BFD_RELOC_16_GOT_PCREL);
3518
3519 }
3520
3521 /* pseudo-op:
3522 behaviour:
3523 errors:
3524 warnings:
3525 */
3526 static void
3527 ppc_pe_comm(lcomm)
3528 int lcomm;
3529 {
3530 register char *name;
3531 register char c;
3532 register char *p;
3533 offsetT temp;
3534 register symbolS *symbolP;
3535 offsetT align;
3536
3537 name = input_line_pointer;
3538 c = get_symbol_end ();
3539
3540 /* just after name is now '\0' */
3541 p = input_line_pointer;
3542 *p = c;
3543 SKIP_WHITESPACE ();
3544 if (*input_line_pointer != ',')
3545 {
3546 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
3547 ignore_rest_of_line ();
3548 return;
3549 }
3550
3551 input_line_pointer++; /* skip ',' */
3552 if ((temp = get_absolute_expression ()) < 0)
3553 {
3554 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp);
3555 ignore_rest_of_line ();
3556 return;
3557 }
3558
3559 if (! lcomm)
3560 {
3561 /* The third argument to .comm is the alignment. */
3562 if (*input_line_pointer != ',')
3563 align = 3;
3564 else
3565 {
3566 ++input_line_pointer;
3567 align = get_absolute_expression ();
3568 if (align <= 0)
3569 {
3570 as_warn (_("ignoring bad alignment"));
3571 align = 3;
3572 }
3573 }
3574 }
3575
3576 *p = 0;
3577 symbolP = symbol_find_or_make (name);
3578
3579 *p = c;
3580 if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
3581 {
3582 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
3583 S_GET_NAME (symbolP));
3584 ignore_rest_of_line ();
3585 return;
3586 }
3587
3588 if (S_GET_VALUE (symbolP))
3589 {
3590 if (S_GET_VALUE (symbolP) != (valueT) temp)
3591 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
3592 S_GET_NAME (symbolP),
3593 (long) S_GET_VALUE (symbolP),
3594 (long) temp);
3595 }
3596 else
3597 {
3598 S_SET_VALUE (symbolP, (valueT) temp);
3599 S_SET_EXTERNAL (symbolP);
3600 }
3601
3602 demand_empty_rest_of_line ();
3603 }
3604
3605 /*
3606 * implement the .section pseudo op:
3607 * .section name {, "flags"}
3608 * ^ ^
3609 * | +--- optional flags: 'b' for bss
3610 * | 'i' for info
3611 * +-- section name 'l' for lib
3612 * 'n' for noload
3613 * 'o' for over
3614 * 'w' for data
3615 * 'd' (apparently m88k for data)
3616 * 'x' for text
3617 * But if the argument is not a quoted string, treat it as a
3618 * subsegment number.
3619 *
3620 * FIXME: this is a copy of the section processing from obj-coff.c, with
3621 * additions/changes for the moto-pas assembler support. There are three
3622 * categories:
3623 *
3624 * FIXME: I just noticed this. This doesn't work at all really. It it
3625 * setting bits that bfd probably neither understands or uses. The
3626 * correct approach (?) will have to incorporate extra fields attached
3627 * to the section to hold the system specific stuff. (krk)
3628 *
3629 * Section Contents:
3630 * 'a' - unknown - referred to in documentation, but no definition supplied
3631 * 'c' - section has code
3632 * 'd' - section has initialized data
3633 * 'u' - section has uninitialized data
3634 * 'i' - section contains directives (info)
3635 * 'n' - section can be discarded
3636 * 'R' - remove section at link time
3637 *
3638 * Section Protection:
3639 * 'r' - section is readable
3640 * 'w' - section is writeable
3641 * 'x' - section is executable
3642 * 's' - section is sharable
3643 *
3644 * Section Alignment:
3645 * '0' - align to byte boundary
3646 * '1' - align to halfword undary
3647 * '2' - align to word boundary
3648 * '3' - align to doubleword boundary
3649 * '4' - align to quadword boundary
3650 * '5' - align to 32 byte boundary
3651 * '6' - align to 64 byte boundary
3652 *
3653 */
3654
3655 void
3656 ppc_pe_section (ignore)
3657 int ignore;
3658 {
3659 /* Strip out the section name */
3660 char *section_name;
3661 char c;
3662 char *name;
3663 unsigned int exp;
3664 flagword flags;
3665 segT sec;
3666 int align;
3667
3668 section_name = input_line_pointer;
3669 c = get_symbol_end ();
3670
3671 name = xmalloc (input_line_pointer - section_name + 1);
3672 strcpy (name, section_name);
3673
3674 *input_line_pointer = c;
3675
3676 SKIP_WHITESPACE ();
3677
3678 exp = 0;
3679 flags = SEC_NO_FLAGS;
3680
3681 if (strcmp (name, ".idata$2") == 0)
3682 {
3683 align = 0;
3684 }
3685 else if (strcmp (name, ".idata$3") == 0)
3686 {
3687 align = 0;
3688 }
3689 else if (strcmp (name, ".idata$4") == 0)
3690 {
3691 align = 2;
3692 }
3693 else if (strcmp (name, ".idata$5") == 0)
3694 {
3695 align = 2;
3696 }
3697 else if (strcmp (name, ".idata$6") == 0)
3698 {
3699 align = 1;
3700 }
3701 else
3702 align = 4; /* default alignment to 16 byte boundary */
3703
3704 if (*input_line_pointer == ',')
3705 {
3706 ++input_line_pointer;
3707 SKIP_WHITESPACE ();
3708 if (*input_line_pointer != '"')
3709 exp = get_absolute_expression ();
3710 else
3711 {
3712 ++input_line_pointer;
3713 while (*input_line_pointer != '"'
3714 && ! is_end_of_line[(unsigned char) *input_line_pointer])
3715 {
3716 switch (*input_line_pointer)
3717 {
3718 /* Section Contents */
3719 case 'a': /* unknown */
3720 as_bad (_("Unsupported section attribute -- 'a'"));
3721 break;
3722 case 'c': /* code section */
3723 flags |= SEC_CODE;
3724 break;
3725 case 'd': /* section has initialized data */
3726 flags |= SEC_DATA;
3727 break;
3728 case 'u': /* section has uninitialized data */
3729 /* FIXME: This is IMAGE_SCN_CNT_UNINITIALIZED_DATA
3730 in winnt.h */
3731 flags |= SEC_ROM;
3732 break;
3733 case 'i': /* section contains directives (info) */
3734 /* FIXME: This is IMAGE_SCN_LNK_INFO
3735 in winnt.h */
3736 flags |= SEC_HAS_CONTENTS;
3737 break;
3738 case 'n': /* section can be discarded */
3739 flags &=~ SEC_LOAD;
3740 break;
3741 case 'R': /* Remove section at link time */
3742 flags |= SEC_NEVER_LOAD;
3743 break;
3744
3745 /* Section Protection */
3746 case 'r': /* section is readable */
3747 flags |= IMAGE_SCN_MEM_READ;
3748 break;
3749 case 'w': /* section is writeable */
3750 flags |= IMAGE_SCN_MEM_WRITE;
3751 break;
3752 case 'x': /* section is executable */
3753 flags |= IMAGE_SCN_MEM_EXECUTE;
3754 break;
3755 case 's': /* section is sharable */
3756 flags |= IMAGE_SCN_MEM_SHARED;
3757 break;
3758
3759 /* Section Alignment */
3760 case '0': /* align to byte boundary */
3761 flags |= IMAGE_SCN_ALIGN_1BYTES;
3762 align = 0;
3763 break;
3764 case '1': /* align to halfword boundary */
3765 flags |= IMAGE_SCN_ALIGN_2BYTES;
3766 align = 1;
3767 break;
3768 case '2': /* align to word boundary */
3769 flags |= IMAGE_SCN_ALIGN_4BYTES;
3770 align = 2;
3771 break;
3772 case '3': /* align to doubleword boundary */
3773 flags |= IMAGE_SCN_ALIGN_8BYTES;
3774 align = 3;
3775 break;
3776 case '4': /* align to quadword boundary */
3777 flags |= IMAGE_SCN_ALIGN_16BYTES;
3778 align = 4;
3779 break;
3780 case '5': /* align to 32 byte boundary */
3781 flags |= IMAGE_SCN_ALIGN_32BYTES;
3782 align = 5;
3783 break;
3784 case '6': /* align to 64 byte boundary */
3785 flags |= IMAGE_SCN_ALIGN_64BYTES;
3786 align = 6;
3787 break;
3788
3789 default:
3790 as_bad(_("unknown section attribute '%c'"),
3791 *input_line_pointer);
3792 break;
3793 }
3794 ++input_line_pointer;
3795 }
3796 if (*input_line_pointer == '"')
3797 ++input_line_pointer;
3798 }
3799 }
3800
3801 sec = subseg_new (name, (subsegT) exp);
3802
3803 ppc_set_current_section(sec);
3804
3805 if (flags != SEC_NO_FLAGS)
3806 {
3807 if (! bfd_set_section_flags (stdoutput, sec, flags))
3808 as_bad (_("error setting flags for \"%s\": %s"),
3809 bfd_section_name (stdoutput, sec),
3810 bfd_errmsg (bfd_get_error ()));
3811 }
3812
3813 bfd_set_section_alignment(stdoutput, sec, align);
3814
3815 }
3816
3817 static void
3818 ppc_pe_function (ignore)
3819 int ignore;
3820 {
3821 char *name;
3822 char endc;
3823 symbolS *ext_sym;
3824
3825 name = input_line_pointer;
3826 endc = get_symbol_end ();
3827
3828 ext_sym = symbol_find_or_make (name);
3829
3830 *input_line_pointer = endc;
3831
3832 S_SET_DATA_TYPE (ext_sym, DT_FCN << N_BTSHFT);
3833 SF_SET_FUNCTION (ext_sym);
3834 SF_SET_PROCESS (ext_sym);
3835 coff_add_linesym (ext_sym);
3836
3837 demand_empty_rest_of_line ();
3838 }
3839
3840 static void
3841 ppc_pe_tocd (ignore)
3842 int ignore;
3843 {
3844 if (tocdata_section == 0)
3845 {
3846 tocdata_section = subseg_new (".tocd", 0);
3847 /* FIXME: section flags won't work */
3848 bfd_set_section_flags (stdoutput, tocdata_section,
3849 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
3850 | SEC_READONLY | SEC_DATA ));
3851
3852 bfd_set_section_alignment (stdoutput, tocdata_section, 2);
3853 }
3854 else
3855 {
3856 rdata_section = subseg_new (".tocd", 0);
3857 }
3858
3859 ppc_set_current_section(tocdata_section);
3860
3861 demand_empty_rest_of_line ();
3862 }
3863
3864 /* Don't adjust TOC relocs to use the section symbol. */
3865
3866 int
3867 ppc_pe_fix_adjustable (fix)
3868 fixS *fix;
3869 {
3870 return fix->fx_r_type != BFD_RELOC_PPC_TOC16;
3871 }
3872
3873 #endif
3874 \f
3875 #ifdef OBJ_XCOFF
3876
3877 /* XCOFF specific symbol and file handling. */
3878
3879 /* Canonicalize the symbol name. We use the to force the suffix, if
3880 any, to use square brackets, and to be in upper case. */
3881
3882 char *
3883 ppc_canonicalize_symbol_name (name)
3884 char *name;
3885 {
3886 char *s;
3887
3888 if (ppc_stab_symbol)
3889 return name;
3890
3891 for (s = name; *s != '\0' && *s != '{' && *s != '['; s++)
3892 ;
3893 if (*s != '\0')
3894 {
3895 char brac;
3896
3897 if (*s == '[')
3898 brac = ']';
3899 else
3900 {
3901 *s = '[';
3902 brac = '}';
3903 }
3904
3905 for (s++; *s != '\0' && *s != brac; s++)
3906 if (islower (*s))
3907 *s = toupper (*s);
3908
3909 if (*s == '\0' || s[1] != '\0')
3910 as_bad (_("bad symbol suffix"));
3911
3912 *s = ']';
3913 }
3914
3915 return name;
3916 }
3917
3918 /* Set the class of a symbol based on the suffix, if any. This is
3919 called whenever a new symbol is created. */
3920
3921 void
3922 ppc_symbol_new_hook (sym)
3923 symbolS *sym;
3924 {
3925 struct ppc_tc_sy *tc;
3926 const char *s;
3927
3928 tc = symbol_get_tc (sym);
3929 tc->next = NULL;
3930 tc->output = 0;
3931 tc->class = -1;
3932 tc->real_name = NULL;
3933 tc->subseg = 0;
3934 tc->align = 0;
3935 tc->size = NULL;
3936 tc->within = NULL;
3937
3938 if (ppc_stab_symbol)
3939 return;
3940
3941 s = strchr (S_GET_NAME (sym), '[');
3942 if (s == (const char *) NULL)
3943 {
3944 /* There is no suffix. */
3945 return;
3946 }
3947
3948 ++s;
3949
3950 switch (s[0])
3951 {
3952 case 'B':
3953 if (strcmp (s, "BS]") == 0)
3954 tc->class = XMC_BS;
3955 break;
3956 case 'D':
3957 if (strcmp (s, "DB]") == 0)
3958 tc->class = XMC_DB;
3959 else if (strcmp (s, "DS]") == 0)
3960 tc->class = XMC_DS;
3961 break;
3962 case 'G':
3963 if (strcmp (s, "GL]") == 0)
3964 tc->class = XMC_GL;
3965 break;
3966 case 'P':
3967 if (strcmp (s, "PR]") == 0)
3968 tc->class = XMC_PR;
3969 break;
3970 case 'R':
3971 if (strcmp (s, "RO]") == 0)
3972 tc->class = XMC_RO;
3973 else if (strcmp (s, "RW]") == 0)
3974 tc->class = XMC_RW;
3975 break;
3976 case 'S':
3977 if (strcmp (s, "SV]") == 0)
3978 tc->class = XMC_SV;
3979 break;
3980 case 'T':
3981 if (strcmp (s, "TC]") == 0)
3982 tc->class = XMC_TC;
3983 else if (strcmp (s, "TI]") == 0)
3984 tc->class = XMC_TI;
3985 else if (strcmp (s, "TB]") == 0)
3986 tc->class = XMC_TB;
3987 else if (strcmp (s, "TC0]") == 0 || strcmp (s, "T0]") == 0)
3988 tc->class = XMC_TC0;
3989 break;
3990 case 'U':
3991 if (strcmp (s, "UA]") == 0)
3992 tc->class = XMC_UA;
3993 else if (strcmp (s, "UC]") == 0)
3994 tc->class = XMC_UC;
3995 break;
3996 case 'X':
3997 if (strcmp (s, "XO]") == 0)
3998 tc->class = XMC_XO;
3999 break;
4000 }
4001
4002 if (tc->class == -1)
4003 as_bad (_("Unrecognized symbol suffix"));
4004 }
4005
4006 /* Set the class of a label based on where it is defined. This
4007 handles symbols without suffixes. Also, move the symbol so that it
4008 follows the csect symbol. */
4009
4010 void
4011 ppc_frob_label (sym)
4012 symbolS *sym;
4013 {
4014 if (ppc_current_csect != (symbolS *) NULL)
4015 {
4016 if (symbol_get_tc (sym)->class == -1)
4017 symbol_get_tc (sym)->class = symbol_get_tc (ppc_current_csect)->class;
4018
4019 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
4020 symbol_append (sym, symbol_get_tc (ppc_current_csect)->within,
4021 &symbol_rootP, &symbol_lastP);
4022 symbol_get_tc (ppc_current_csect)->within = sym;
4023 }
4024 }
4025
4026 /* This variable is set by ppc_frob_symbol if any absolute symbols are
4027 seen. It tells ppc_adjust_symtab whether it needs to look through
4028 the symbols. */
4029
4030 static boolean ppc_saw_abs;
4031
4032 /* Change the name of a symbol just before writing it out. Set the
4033 real name if the .rename pseudo-op was used. Otherwise, remove any
4034 class suffix. Return 1 if the symbol should not be included in the
4035 symbol table. */
4036
4037 int
4038 ppc_frob_symbol (sym)
4039 symbolS *sym;
4040 {
4041 static symbolS *ppc_last_function;
4042 static symbolS *set_end;
4043
4044 /* Discard symbols that should not be included in the output symbol
4045 table. */
4046 if (! symbol_used_in_reloc_p (sym)
4047 && ((symbol_get_bfdsym (sym)->flags & BSF_SECTION_SYM) != 0
4048 || (! S_IS_EXTERNAL (sym)
4049 && ! symbol_get_tc (sym)->output
4050 && S_GET_STORAGE_CLASS (sym) != C_FILE)))
4051 return 1;
4052
4053 if (symbol_get_tc (sym)->real_name != (char *) NULL)
4054 S_SET_NAME (sym, symbol_get_tc (sym)->real_name);
4055 else
4056 {
4057 const char *name;
4058 const char *s;
4059
4060 name = S_GET_NAME (sym);
4061 s = strchr (name, '[');
4062 if (s != (char *) NULL)
4063 {
4064 unsigned int len;
4065 char *snew;
4066
4067 len = s - name;
4068 snew = xmalloc (len + 1);
4069 memcpy (snew, name, len);
4070 snew[len] = '\0';
4071
4072 S_SET_NAME (sym, snew);
4073 }
4074 }
4075
4076 if (set_end != (symbolS *) NULL)
4077 {
4078 SA_SET_SYM_ENDNDX (set_end, sym);
4079 set_end = NULL;
4080 }
4081
4082 if (SF_GET_FUNCTION (sym))
4083 {
4084 if (ppc_last_function != (symbolS *) NULL)
4085 as_bad (_("two .function pseudo-ops with no intervening .ef"));
4086 ppc_last_function = sym;
4087 if (symbol_get_tc (sym)->size != (symbolS *) NULL)
4088 {
4089 resolve_symbol_value (symbol_get_tc (sym)->size, 1);
4090 SA_SET_SYM_FSIZE (sym,
4091 (long) S_GET_VALUE (symbol_get_tc (sym)->size));
4092 }
4093 }
4094 else if (S_GET_STORAGE_CLASS (sym) == C_FCN
4095 && strcmp (S_GET_NAME (sym), ".ef") == 0)
4096 {
4097 if (ppc_last_function == (symbolS *) NULL)
4098 as_bad (_(".ef with no preceding .function"));
4099 else
4100 {
4101 set_end = ppc_last_function;
4102 ppc_last_function = NULL;
4103
4104 /* We don't have a C_EFCN symbol, but we need to force the
4105 COFF backend to believe that it has seen one. */
4106 coff_last_function = NULL;
4107 }
4108 }
4109
4110 if (! S_IS_EXTERNAL (sym)
4111 && (symbol_get_bfdsym (sym)->flags & BSF_SECTION_SYM) == 0
4112 && S_GET_STORAGE_CLASS (sym) != C_FILE
4113 && S_GET_STORAGE_CLASS (sym) != C_FCN
4114 && S_GET_STORAGE_CLASS (sym) != C_BLOCK
4115 && S_GET_STORAGE_CLASS (sym) != C_BSTAT
4116 && S_GET_STORAGE_CLASS (sym) != C_ESTAT
4117 && S_GET_STORAGE_CLASS (sym) != C_BINCL
4118 && S_GET_STORAGE_CLASS (sym) != C_EINCL
4119 && S_GET_SEGMENT (sym) != ppc_coff_debug_section)
4120 S_SET_STORAGE_CLASS (sym, C_HIDEXT);
4121
4122 if (S_GET_STORAGE_CLASS (sym) == C_EXT
4123 || S_GET_STORAGE_CLASS (sym) == C_HIDEXT)
4124 {
4125 int i;
4126 union internal_auxent *a;
4127
4128 /* Create a csect aux. */
4129 i = S_GET_NUMBER_AUXILIARY (sym);
4130 S_SET_NUMBER_AUXILIARY (sym, i + 1);
4131 a = &coffsymbol (symbol_get_bfdsym (sym))->native[i + 1].u.auxent;
4132 if (symbol_get_tc (sym)->class == XMC_TC0)
4133 {
4134 /* This is the TOC table. */
4135 know (strcmp (S_GET_NAME (sym), "TOC") == 0);
4136 a->x_csect.x_scnlen.l = 0;
4137 a->x_csect.x_smtyp = (2 << 3) | XTY_SD;
4138 }
4139 else if (symbol_get_tc (sym)->subseg != 0)
4140 {
4141 /* This is a csect symbol. x_scnlen is the size of the
4142 csect. */
4143 if (symbol_get_tc (sym)->next == (symbolS *) NULL)
4144 a->x_csect.x_scnlen.l = (bfd_section_size (stdoutput,
4145 S_GET_SEGMENT (sym))
4146 - S_GET_VALUE (sym));
4147 else
4148 {
4149 resolve_symbol_value (symbol_get_tc (sym)->next, 1);
4150 a->x_csect.x_scnlen.l = (S_GET_VALUE (symbol_get_tc (sym)->next)
4151 - S_GET_VALUE (sym));
4152 }
4153 a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_SD;
4154 }
4155 else if (S_GET_SEGMENT (sym) == bss_section)
4156 {
4157 /* This is a common symbol. */
4158 a->x_csect.x_scnlen.l = symbol_get_frag (sym)->fr_offset;
4159 a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_CM;
4160 if (S_IS_EXTERNAL (sym))
4161 symbol_get_tc (sym)->class = XMC_RW;
4162 else
4163 symbol_get_tc (sym)->class = XMC_BS;
4164 }
4165 else if (S_GET_SEGMENT (sym) == absolute_section)
4166 {
4167 /* This is an absolute symbol. The csect will be created by
4168 ppc_adjust_symtab. */
4169 ppc_saw_abs = true;
4170 a->x_csect.x_smtyp = XTY_LD;
4171 if (symbol_get_tc (sym)->class == -1)
4172 symbol_get_tc (sym)->class = XMC_XO;
4173 }
4174 else if (! S_IS_DEFINED (sym))
4175 {
4176 /* This is an external symbol. */
4177 a->x_csect.x_scnlen.l = 0;
4178 a->x_csect.x_smtyp = XTY_ER;
4179 }
4180 else if (symbol_get_tc (sym)->class == XMC_TC)
4181 {
4182 symbolS *next;
4183
4184 /* This is a TOC definition. x_scnlen is the size of the
4185 TOC entry. */
4186 next = symbol_next (sym);
4187 while (symbol_get_tc (next)->class == XMC_TC0)
4188 next = symbol_next (next);
4189 if (next == (symbolS *) NULL
4190 || symbol_get_tc (next)->class != XMC_TC)
4191 {
4192 if (ppc_after_toc_frag == (fragS *) NULL)
4193 a->x_csect.x_scnlen.l = (bfd_section_size (stdoutput,
4194 data_section)
4195 - S_GET_VALUE (sym));
4196 else
4197 a->x_csect.x_scnlen.l = (ppc_after_toc_frag->fr_address
4198 - S_GET_VALUE (sym));
4199 }
4200 else
4201 {
4202 resolve_symbol_value (next, 1);
4203 a->x_csect.x_scnlen.l = (S_GET_VALUE (next)
4204 - S_GET_VALUE (sym));
4205 }
4206 a->x_csect.x_smtyp = (2 << 3) | XTY_SD;
4207 }
4208 else
4209 {
4210 symbolS *csect;
4211
4212 /* This is a normal symbol definition. x_scnlen is the
4213 symbol index of the containing csect. */
4214 if (S_GET_SEGMENT (sym) == text_section)
4215 csect = ppc_text_csects;
4216 else if (S_GET_SEGMENT (sym) == data_section)
4217 csect = ppc_data_csects;
4218 else
4219 abort ();
4220
4221 /* Skip the initial dummy symbol. */
4222 csect = symbol_get_tc (csect)->next;
4223
4224 if (csect == (symbolS *) NULL)
4225 {
4226 as_warn (_("warning: symbol %s has no csect"), S_GET_NAME (sym));
4227 a->x_csect.x_scnlen.l = 0;
4228 }
4229 else
4230 {
4231 while (symbol_get_tc (csect)->next != (symbolS *) NULL)
4232 {
4233 resolve_symbol_value (symbol_get_tc (csect)->next, 1);
4234 if (S_GET_VALUE (symbol_get_tc (csect)->next)
4235 > S_GET_VALUE (sym))
4236 break;
4237 csect = symbol_get_tc (csect)->next;
4238 }
4239
4240 a->x_csect.x_scnlen.p =
4241 coffsymbol (symbol_get_bfdsym (csect))->native;
4242 coffsymbol (symbol_get_bfdsym (sym))->native[i + 1].fix_scnlen =
4243 1;
4244 }
4245 a->x_csect.x_smtyp = XTY_LD;
4246 }
4247
4248 a->x_csect.x_parmhash = 0;
4249 a->x_csect.x_snhash = 0;
4250 if (symbol_get_tc (sym)->class == -1)
4251 a->x_csect.x_smclas = XMC_PR;
4252 else
4253 a->x_csect.x_smclas = symbol_get_tc (sym)->class;
4254 a->x_csect.x_stab = 0;
4255 a->x_csect.x_snstab = 0;
4256
4257 /* Don't let the COFF backend resort these symbols. */
4258 symbol_get_bfdsym (sym)->flags |= BSF_NOT_AT_END;
4259 }
4260 else if (S_GET_STORAGE_CLASS (sym) == C_BSTAT)
4261 {
4262 /* We want the value to be the symbol index of the referenced
4263 csect symbol. BFD will do that for us if we set the right
4264 flags. */
4265 S_SET_VALUE (sym,
4266 ((valueT)
4267 coffsymbol (symbol_get_bfdsym
4268 (symbol_get_tc (sym)->within))->native));
4269 coffsymbol (symbol_get_bfdsym (sym))->native->fix_value = 1;
4270 }
4271 else if (S_GET_STORAGE_CLASS (sym) == C_STSYM)
4272 {
4273 symbolS *block;
4274 symbolS *csect;
4275
4276 /* The value is the offset from the enclosing csect. */
4277 block = symbol_get_tc (sym)->within;
4278 csect = symbol_get_tc (block)->within;
4279 resolve_symbol_value (csect, 1);
4280 S_SET_VALUE (sym, S_GET_VALUE (sym) - S_GET_VALUE (csect));
4281 }
4282 else if (S_GET_STORAGE_CLASS (sym) == C_BINCL
4283 || S_GET_STORAGE_CLASS (sym) == C_EINCL)
4284 {
4285 /* We want the value to be a file offset into the line numbers.
4286 BFD will do that for us if we set the right flags. We have
4287 already set the value correctly. */
4288 coffsymbol (symbol_get_bfdsym (sym))->native->fix_line = 1;
4289 }
4290
4291 return 0;
4292 }
4293
4294 /* Adjust the symbol table. This creates csect symbols for all
4295 absolute symbols. */
4296
4297 void
4298 ppc_adjust_symtab ()
4299 {
4300 symbolS *sym;
4301
4302 if (! ppc_saw_abs)
4303 return;
4304
4305 for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
4306 {
4307 symbolS *csect;
4308 int i;
4309 union internal_auxent *a;
4310
4311 if (S_GET_SEGMENT (sym) != absolute_section)
4312 continue;
4313
4314 csect = symbol_create (".abs[XO]", absolute_section,
4315 S_GET_VALUE (sym), &zero_address_frag);
4316 symbol_get_bfdsym (csect)->value = S_GET_VALUE (sym);
4317 S_SET_STORAGE_CLASS (csect, C_HIDEXT);
4318 i = S_GET_NUMBER_AUXILIARY (csect);
4319 S_SET_NUMBER_AUXILIARY (csect, i + 1);
4320 a = &coffsymbol (symbol_get_bfdsym (csect))->native[i + 1].u.auxent;
4321 a->x_csect.x_scnlen.l = 0;
4322 a->x_csect.x_smtyp = XTY_SD;
4323 a->x_csect.x_parmhash = 0;
4324 a->x_csect.x_snhash = 0;
4325 a->x_csect.x_smclas = XMC_XO;
4326 a->x_csect.x_stab = 0;
4327 a->x_csect.x_snstab = 0;
4328
4329 symbol_insert (csect, sym, &symbol_rootP, &symbol_lastP);
4330
4331 i = S_GET_NUMBER_AUXILIARY (sym);
4332 a = &coffsymbol (symbol_get_bfdsym (sym))->native[i].u.auxent;
4333 a->x_csect.x_scnlen.p = coffsymbol (symbol_get_bfdsym (csect))->native;
4334 coffsymbol (symbol_get_bfdsym (sym))->native[i].fix_scnlen = 1;
4335 }
4336
4337 ppc_saw_abs = false;
4338 }
4339
4340 /* Set the VMA for a section. This is called on all the sections in
4341 turn. */
4342
4343 void
4344 ppc_frob_section (sec)
4345 asection *sec;
4346 {
4347 static bfd_size_type vma = 0;
4348
4349 bfd_set_section_vma (stdoutput, sec, vma);
4350 vma += bfd_section_size (stdoutput, sec);
4351 }
4352
4353 #endif /* OBJ_XCOFF */
4354 \f
4355 /* Turn a string in input_line_pointer into a floating point constant
4356 of type type, and store the appropriate bytes in *litp. The number
4357 of LITTLENUMS emitted is stored in *sizep . An error message is
4358 returned, or NULL on OK. */
4359
4360 char *
4361 md_atof (type, litp, sizep)
4362 int type;
4363 char *litp;
4364 int *sizep;
4365 {
4366 int prec;
4367 LITTLENUM_TYPE words[4];
4368 char *t;
4369 int i;
4370
4371 switch (type)
4372 {
4373 case 'f':
4374 prec = 2;
4375 break;
4376
4377 case 'd':
4378 prec = 4;
4379 break;
4380
4381 default:
4382 *sizep = 0;
4383 return _("bad call to md_atof");
4384 }
4385
4386 t = atof_ieee (input_line_pointer, type, words);
4387 if (t)
4388 input_line_pointer = t;
4389
4390 *sizep = prec * 2;
4391
4392 if (target_big_endian)
4393 {
4394 for (i = 0; i < prec; i++)
4395 {
4396 md_number_to_chars (litp, (valueT) words[i], 2);
4397 litp += 2;
4398 }
4399 }
4400 else
4401 {
4402 for (i = prec - 1; i >= 0; i--)
4403 {
4404 md_number_to_chars (litp, (valueT) words[i], 2);
4405 litp += 2;
4406 }
4407 }
4408
4409 return NULL;
4410 }
4411
4412 /* Write a value out to the object file, using the appropriate
4413 endianness. */
4414
4415 void
4416 md_number_to_chars (buf, val, n)
4417 char *buf;
4418 valueT val;
4419 int n;
4420 {
4421 if (target_big_endian)
4422 number_to_chars_bigendian (buf, val, n);
4423 else
4424 number_to_chars_littleendian (buf, val, n);
4425 }
4426
4427 /* Align a section (I don't know why this is machine dependent). */
4428
4429 valueT
4430 md_section_align (seg, addr)
4431 asection *seg;
4432 valueT addr;
4433 {
4434 int align = bfd_get_section_alignment (stdoutput, seg);
4435
4436 return ((addr + (1 << align) - 1) & (-1 << align));
4437 }
4438
4439 /* We don't have any form of relaxing. */
4440
4441 int
4442 md_estimate_size_before_relax (fragp, seg)
4443 fragS *fragp;
4444 asection *seg;
4445 {
4446 abort ();
4447 return 0;
4448 }
4449
4450 /* Convert a machine dependent frag. We never generate these. */
4451
4452 void
4453 md_convert_frag (abfd, sec, fragp)
4454 bfd *abfd;
4455 asection *sec;
4456 fragS *fragp;
4457 {
4458 abort ();
4459 }
4460
4461 /* We have no need to default values of symbols. */
4462
4463 /*ARGSUSED*/
4464 symbolS *
4465 md_undefined_symbol (name)
4466 char *name;
4467 {
4468 return 0;
4469 }
4470 \f
4471 /* Functions concerning relocs. */
4472
4473 /* The location from which a PC relative jump should be calculated,
4474 given a PC relative reloc. */
4475
4476 long
4477 md_pcrel_from_section (fixp, sec)
4478 fixS *fixp;
4479 segT sec;
4480 {
4481 return fixp->fx_frag->fr_address + fixp->fx_where;
4482 }
4483
4484 #ifdef OBJ_XCOFF
4485
4486 /* This is called to see whether a fixup should be adjusted to use a
4487 section symbol. We take the opportunity to change a fixup against
4488 a symbol in the TOC subsegment into a reloc against the
4489 corresponding .tc symbol. */
4490
4491 int
4492 ppc_fix_adjustable (fix)
4493 fixS *fix;
4494 {
4495 valueT val;
4496
4497 resolve_symbol_value (fix->fx_addsy, 1);
4498 val = S_GET_VALUE (fix->fx_addsy);
4499 if (ppc_toc_csect != (symbolS *) NULL
4500 && fix->fx_addsy != (symbolS *) NULL
4501 && fix->fx_addsy != ppc_toc_csect
4502 && S_GET_SEGMENT (fix->fx_addsy) == data_section
4503 && val >= ppc_toc_frag->fr_address
4504 && (ppc_after_toc_frag == (fragS *) NULL
4505 || val < ppc_after_toc_frag->fr_address))
4506 {
4507 symbolS *sy;
4508
4509 for (sy = symbol_next (ppc_toc_csect);
4510 sy != (symbolS *) NULL;
4511 sy = symbol_next (sy))
4512 {
4513 if (symbol_get_tc (sy)->class == XMC_TC0)
4514 continue;
4515 if (symbol_get_tc (sy)->class != XMC_TC)
4516 break;
4517 resolve_symbol_value (sy, 1);
4518 if (val == S_GET_VALUE (sy))
4519 {
4520 fix->fx_addsy = sy;
4521 fix->fx_addnumber = val - ppc_toc_frag->fr_address;
4522 return 0;
4523 }
4524 }
4525
4526 as_bad_where (fix->fx_file, fix->fx_line,
4527 _("symbol in .toc does not match any .tc"));
4528 }
4529
4530 /* Possibly adjust the reloc to be against the csect. */
4531 if (fix->fx_addsy != (symbolS *) NULL
4532 && symbol_get_tc (fix->fx_addsy)->subseg == 0
4533 && symbol_get_tc (fix->fx_addsy)->class != XMC_TC0
4534 && symbol_get_tc (fix->fx_addsy)->class != XMC_TC
4535 && S_GET_SEGMENT (fix->fx_addsy) != bss_section
4536 /* Don't adjust if this is a reloc in the toc section. */
4537 && (S_GET_SEGMENT (fix->fx_addsy) != data_section
4538 || ppc_toc_csect == NULL
4539 || val < ppc_toc_frag->fr_address
4540 || (ppc_after_toc_frag != NULL
4541 && val >= ppc_after_toc_frag->fr_address)))
4542 {
4543 symbolS *csect;
4544
4545 if (S_GET_SEGMENT (fix->fx_addsy) == text_section)
4546 csect = ppc_text_csects;
4547 else if (S_GET_SEGMENT (fix->fx_addsy) == data_section)
4548 csect = ppc_data_csects;
4549 else
4550 abort ();
4551
4552 /* Skip the initial dummy symbol. */
4553 csect = symbol_get_tc (csect)->next;
4554
4555 if (csect != (symbolS *) NULL)
4556 {
4557 while (symbol_get_tc (csect)->next != (symbolS *) NULL
4558 && (symbol_get_frag (symbol_get_tc (csect)->next)->fr_address
4559 <= symbol_get_frag (fix->fx_addsy)->fr_address))
4560 {
4561 /* If the csect address equals the symbol value, then we
4562 have to look through the full symbol table to see
4563 whether this is the csect we want. Note that we will
4564 only get here if the csect has zero length. */
4565 if ((symbol_get_frag (csect)->fr_address
4566 == symbol_get_frag (fix->fx_addsy)->fr_address)
4567 && S_GET_VALUE (csect) == S_GET_VALUE (fix->fx_addsy))
4568 {
4569 symbolS *scan;
4570
4571 for (scan = symbol_next (csect);
4572 scan != NULL;
4573 scan = symbol_next (scan))
4574 {
4575 if (symbol_get_tc (scan)->subseg != 0)
4576 break;
4577 if (scan == fix->fx_addsy)
4578 break;
4579 }
4580
4581 /* If we found the symbol before the next csect
4582 symbol, then this is the csect we want. */
4583 if (scan == fix->fx_addsy)
4584 break;
4585 }
4586
4587 csect = symbol_get_tc (csect)->next;
4588 }
4589
4590 fix->fx_offset += (S_GET_VALUE (fix->fx_addsy)
4591 - symbol_get_frag (csect)->fr_address);
4592 fix->fx_addsy = csect;
4593 }
4594 }
4595
4596 /* Adjust a reloc against a .lcomm symbol to be against the base
4597 .lcomm. */
4598 if (fix->fx_addsy != (symbolS *) NULL
4599 && S_GET_SEGMENT (fix->fx_addsy) == bss_section
4600 && ! S_IS_EXTERNAL (fix->fx_addsy))
4601 {
4602 resolve_symbol_value (symbol_get_frag (fix->fx_addsy)->fr_symbol, 1);
4603 fix->fx_offset +=
4604 (S_GET_VALUE (fix->fx_addsy)
4605 - S_GET_VALUE (symbol_get_frag (fix->fx_addsy)->fr_symbol));
4606 fix->fx_addsy = symbol_get_frag (fix->fx_addsy)->fr_symbol;
4607 }
4608
4609 return 0;
4610 }
4611
4612 /* A reloc from one csect to another must be kept. The assembler
4613 will, of course, keep relocs between sections, and it will keep
4614 absolute relocs, but we need to force it to keep PC relative relocs
4615 between two csects in the same section. */
4616
4617 int
4618 ppc_force_relocation (fix)
4619 fixS *fix;
4620 {
4621 /* At this point fix->fx_addsy should already have been converted to
4622 a csect symbol. If the csect does not include the fragment, then
4623 we need to force the relocation. */
4624 if (fix->fx_pcrel
4625 && fix->fx_addsy != NULL
4626 && symbol_get_tc (fix->fx_addsy)->subseg != 0
4627 && ((symbol_get_frag (fix->fx_addsy)->fr_address
4628 > fix->fx_frag->fr_address)
4629 || (symbol_get_tc (fix->fx_addsy)->next != NULL
4630 && (symbol_get_frag (symbol_get_tc (fix->fx_addsy)->next)->fr_address
4631 <= fix->fx_frag->fr_address))))
4632 return 1;
4633
4634 return 0;
4635 }
4636
4637 #endif /* OBJ_XCOFF */
4638
4639 /* See whether a symbol is in the TOC section. */
4640
4641 static int
4642 ppc_is_toc_sym (sym)
4643 symbolS *sym;
4644 {
4645 #ifdef OBJ_XCOFF
4646 return symbol_get_tc (sym)->class == XMC_TC;
4647 #else
4648 return strcmp (segment_name (S_GET_SEGMENT (sym)), ".got") == 0;
4649 #endif
4650 }
4651
4652 /* Apply a fixup to the object code. This is called for all the
4653 fixups we generated by the call to fix_new_exp, above. In the call
4654 above we used a reloc code which was the largest legal reloc code
4655 plus the operand index. Here we undo that to recover the operand
4656 index. At this point all symbol values should be fully resolved,
4657 and we attempt to completely resolve the reloc. If we can not do
4658 that, we determine the correct reloc code and put it back in the
4659 fixup. */
4660
4661 int
4662 md_apply_fix3 (fixp, valuep, seg)
4663 fixS *fixp;
4664 valueT *valuep;
4665 segT seg;
4666 {
4667 valueT value;
4668
4669 #ifdef OBJ_ELF
4670 value = *valuep;
4671 if (fixp->fx_addsy != NULL)
4672 {
4673 /* `*valuep' may contain the value of the symbol on which the reloc
4674 will be based; we have to remove it. */
4675 if (symbol_used_in_reloc_p (fixp->fx_addsy)
4676 && S_GET_SEGMENT (fixp->fx_addsy) != absolute_section
4677 && S_GET_SEGMENT (fixp->fx_addsy) != undefined_section
4678 && ! bfd_is_com_section (S_GET_SEGMENT (fixp->fx_addsy)))
4679 value -= S_GET_VALUE (fixp->fx_addsy);
4680
4681 /* FIXME: Why '+'? Better yet, what exactly is '*valuep'
4682 supposed to be? I think this is related to various similar
4683 FIXMEs in tc-i386.c and tc-sparc.c. */
4684 if (fixp->fx_pcrel)
4685 value += fixp->fx_frag->fr_address + fixp->fx_where;
4686 }
4687 else
4688 {
4689 fixp->fx_done = 1;
4690 }
4691 #else
4692 /* FIXME FIXME FIXME: The value we are passed in *valuep includes
4693 the symbol values. Since we are using BFD_ASSEMBLER, if we are
4694 doing this relocation the code in write.c is going to call
4695 bfd_install_relocation, which is also going to use the symbol
4696 value. That means that if the reloc is fully resolved we want to
4697 use *valuep since bfd_install_relocation is not being used.
4698 However, if the reloc is not fully resolved we do not want to use
4699 *valuep, and must use fx_offset instead. However, if the reloc
4700 is PC relative, we do want to use *valuep since it includes the
4701 result of md_pcrel_from. This is confusing. */
4702 if (fixp->fx_addsy == (symbolS *) NULL)
4703 {
4704 value = *valuep;
4705 fixp->fx_done = 1;
4706 }
4707 else if (fixp->fx_pcrel)
4708 value = *valuep;
4709 else
4710 {
4711 value = fixp->fx_offset;
4712 if (fixp->fx_subsy != (symbolS *) NULL)
4713 {
4714 if (S_GET_SEGMENT (fixp->fx_subsy) == absolute_section)
4715 value -= S_GET_VALUE (fixp->fx_subsy);
4716 else
4717 {
4718 /* We can't actually support subtracting a symbol. */
4719 as_bad_where (fixp->fx_file, fixp->fx_line,
4720 _("expression too complex"));
4721 }
4722 }
4723 }
4724 #endif
4725
4726 if ((int) fixp->fx_r_type >= (int) BFD_RELOC_UNUSED)
4727 {
4728 int opindex;
4729 const struct powerpc_operand *operand;
4730 char *where;
4731 unsigned long insn;
4732
4733 opindex = (int) fixp->fx_r_type - (int) BFD_RELOC_UNUSED;
4734
4735 operand = &powerpc_operands[opindex];
4736
4737 #ifdef OBJ_XCOFF
4738 /* It appears that an instruction like
4739 l 9,LC..1(30)
4740 when LC..1 is not a TOC symbol does not generate a reloc. It
4741 uses the offset of LC..1 within its csect. However, .long
4742 LC..1 will generate a reloc. I can't find any documentation
4743 on how these cases are to be distinguished, so this is a wild
4744 guess. These cases are generated by gcc -mminimal-toc. */
4745 if ((operand->flags & PPC_OPERAND_PARENS) != 0
4746 && operand->bits == 16
4747 && operand->shift == 0
4748 && operand->insert == NULL
4749 && fixp->fx_addsy != NULL
4750 && symbol_get_tc (fixp->fx_addsy)->subseg != 0
4751 && symbol_get_tc (fixp->fx_addsy)->class != XMC_TC
4752 && symbol_get_tc (fixp->fx_addsy)->class != XMC_TC0
4753 && S_GET_SEGMENT (fixp->fx_addsy) != bss_section)
4754 {
4755 value = fixp->fx_offset;
4756 fixp->fx_done = 1;
4757 }
4758 #endif
4759
4760 /* Fetch the instruction, insert the fully resolved operand
4761 value, and stuff the instruction back again. */
4762 where = fixp->fx_frag->fr_literal + fixp->fx_where;
4763 if (target_big_endian)
4764 insn = bfd_getb32 ((unsigned char *) where);
4765 else
4766 insn = bfd_getl32 ((unsigned char *) where);
4767 insn = ppc_insert_operand (insn, operand, (offsetT) value,
4768 fixp->fx_file, fixp->fx_line);
4769 if (target_big_endian)
4770 bfd_putb32 ((bfd_vma) insn, (unsigned char *) where);
4771 else
4772 bfd_putl32 ((bfd_vma) insn, (unsigned char *) where);
4773
4774 if (fixp->fx_done)
4775 {
4776 /* Nothing else to do here. */
4777 return 1;
4778 }
4779
4780 /* Determine a BFD reloc value based on the operand information.
4781 We are only prepared to turn a few of the operands into
4782 relocs.
4783 FIXME: We need to handle the DS field at the very least.
4784 FIXME: Selecting the reloc type is a bit haphazard; perhaps
4785 there should be a new field in the operand table. */
4786 if ((operand->flags & PPC_OPERAND_RELATIVE) != 0
4787 && operand->bits == 26
4788 && operand->shift == 0)
4789 fixp->fx_r_type = BFD_RELOC_PPC_B26;
4790 else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0
4791 && operand->bits == 16
4792 && operand->shift == 0)
4793 fixp->fx_r_type = BFD_RELOC_PPC_B16;
4794 else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0
4795 && operand->bits == 26
4796 && operand->shift == 0)
4797 fixp->fx_r_type = BFD_RELOC_PPC_BA26;
4798 else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0
4799 && operand->bits == 16
4800 && operand->shift == 0)
4801 fixp->fx_r_type = BFD_RELOC_PPC_BA16;
4802 else if ((operand->flags & PPC_OPERAND_PARENS) != 0
4803 && operand->bits == 16
4804 && operand->shift == 0
4805 && operand->insert == NULL
4806 && fixp->fx_addsy != NULL
4807 && ppc_is_toc_sym (fixp->fx_addsy))
4808 {
4809 fixp->fx_size = 2;
4810 if (target_big_endian)
4811 fixp->fx_where += 2;
4812 fixp->fx_r_type = BFD_RELOC_PPC_TOC16;
4813 }
4814 else
4815 {
4816 char *sfile;
4817 unsigned int sline;
4818
4819 /* Use expr_symbol_where to see if this is an expression
4820 symbol. */
4821 if (expr_symbol_where (fixp->fx_addsy, &sfile, &sline))
4822 as_bad_where (fixp->fx_file, fixp->fx_line,
4823 _("unresolved expression that must be resolved"));
4824 else
4825 as_bad_where (fixp->fx_file, fixp->fx_line,
4826 _("unsupported relocation type"));
4827 fixp->fx_done = 1;
4828 return 1;
4829 }
4830 }
4831 else
4832 {
4833 #ifdef OBJ_ELF
4834 ppc_elf_validate_fix (fixp, seg);
4835 #endif
4836 switch (fixp->fx_r_type)
4837 {
4838 case BFD_RELOC_32:
4839 case BFD_RELOC_CTOR:
4840 if (fixp->fx_pcrel)
4841 fixp->fx_r_type = BFD_RELOC_32_PCREL;
4842 /* fall through */
4843
4844 case BFD_RELOC_RVA:
4845 case BFD_RELOC_32_PCREL:
4846 case BFD_RELOC_32_BASEREL:
4847 case BFD_RELOC_PPC_EMB_NADDR32:
4848 md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where,
4849 value, 4);
4850 break;
4851
4852 case BFD_RELOC_LO16:
4853 case BFD_RELOC_16:
4854 case BFD_RELOC_GPREL16:
4855 case BFD_RELOC_16_GOT_PCREL:
4856 case BFD_RELOC_16_GOTOFF:
4857 case BFD_RELOC_LO16_GOTOFF:
4858 case BFD_RELOC_HI16_GOTOFF:
4859 case BFD_RELOC_HI16_S_GOTOFF:
4860 case BFD_RELOC_LO16_BASEREL:
4861 case BFD_RELOC_HI16_BASEREL:
4862 case BFD_RELOC_HI16_S_BASEREL:
4863 case BFD_RELOC_PPC_EMB_NADDR16:
4864 case BFD_RELOC_PPC_EMB_NADDR16_LO:
4865 case BFD_RELOC_PPC_EMB_NADDR16_HI:
4866 case BFD_RELOC_PPC_EMB_NADDR16_HA:
4867 case BFD_RELOC_PPC_EMB_SDAI16:
4868 case BFD_RELOC_PPC_EMB_SDA2REL:
4869 case BFD_RELOC_PPC_EMB_SDA2I16:
4870 case BFD_RELOC_PPC_EMB_RELSEC16:
4871 case BFD_RELOC_PPC_EMB_RELST_LO:
4872 case BFD_RELOC_PPC_EMB_RELST_HI:
4873 case BFD_RELOC_PPC_EMB_RELST_HA:
4874 case BFD_RELOC_PPC_EMB_RELSDA:
4875 case BFD_RELOC_PPC_TOC16:
4876 if (fixp->fx_pcrel)
4877 {
4878 if (fixp->fx_addsy != NULL)
4879 as_bad_where (fixp->fx_file, fixp->fx_line,
4880 _("cannot emit PC relative %s relocation against %s"),
4881 bfd_get_reloc_code_name (fixp->fx_r_type),
4882 S_GET_NAME (fixp->fx_addsy));
4883 else
4884 as_bad_where (fixp->fx_file, fixp->fx_line,
4885 _("cannot emit PC relative %s relocation"),
4886 bfd_get_reloc_code_name (fixp->fx_r_type));
4887 }
4888
4889 md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where,
4890 value, 2);
4891 break;
4892
4893 /* This case happens when you write, for example,
4894 lis %r3,(L1-L2)@ha
4895 where L1 and L2 are defined later. */
4896 case BFD_RELOC_HI16:
4897 if (fixp->fx_pcrel)
4898 abort ();
4899 md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where,
4900 value >> 16, 2);
4901 break;
4902 case BFD_RELOC_HI16_S:
4903 if (fixp->fx_pcrel)
4904 abort ();
4905 md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where,
4906 (value + 0x8000) >> 16, 2);
4907 break;
4908
4909 /* Because SDA21 modifies the register field, the size is set to 4
4910 bytes, rather than 2, so offset it here appropriately */
4911 case BFD_RELOC_PPC_EMB_SDA21:
4912 if (fixp->fx_pcrel)
4913 abort ();
4914
4915 md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where
4916 + ((target_big_endian) ? 2 : 0),
4917 value, 2);
4918 break;
4919
4920 case BFD_RELOC_8:
4921 if (fixp->fx_pcrel)
4922 abort ();
4923
4924 md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where,
4925 value, 1);
4926 break;
4927
4928 case BFD_RELOC_24_PLT_PCREL:
4929 case BFD_RELOC_PPC_LOCAL24PC:
4930 if (!fixp->fx_pcrel && !fixp->fx_done)
4931 abort ();
4932
4933 if (fixp->fx_done)
4934 {
4935 char *where;
4936 unsigned long insn;
4937
4938 /* Fetch the instruction, insert the fully resolved operand
4939 value, and stuff the instruction back again. */
4940 where = fixp->fx_frag->fr_literal + fixp->fx_where;
4941 if (target_big_endian)
4942 insn = bfd_getb32 ((unsigned char *) where);
4943 else
4944 insn = bfd_getl32 ((unsigned char *) where);
4945 if ((value & 3) != 0)
4946 as_bad_where (fixp->fx_file, fixp->fx_line,
4947 _("must branch to an address a multiple of 4"));
4948 if ((offsetT) value < -0x40000000
4949 || (offsetT) value >= 0x40000000)
4950 as_bad_where (fixp->fx_file, fixp->fx_line,
4951 _("@local or @plt branch destination is too far away, %ld bytes"),
4952 value);
4953 insn = insn | (value & 0x03fffffc);
4954 if (target_big_endian)
4955 bfd_putb32 ((bfd_vma) insn, (unsigned char *) where);
4956 else
4957 bfd_putl32 ((bfd_vma) insn, (unsigned char *) where);
4958 }
4959 break;
4960
4961 case BFD_RELOC_VTABLE_INHERIT:
4962 fixp->fx_done = 0;
4963 if (fixp->fx_addsy
4964 && !S_IS_DEFINED (fixp->fx_addsy)
4965 && !S_IS_WEAK (fixp->fx_addsy))
4966 S_SET_WEAK (fixp->fx_addsy);
4967 break;
4968
4969 case BFD_RELOC_VTABLE_ENTRY:
4970 fixp->fx_done = 0;
4971 break;
4972
4973 default:
4974 fprintf(stderr,
4975 _("Gas failure, reloc value %d\n"), fixp->fx_r_type);
4976 fflush(stderr);
4977 abort ();
4978 }
4979 }
4980
4981 #ifdef OBJ_ELF
4982 fixp->fx_addnumber = value;
4983 #else
4984 if (fixp->fx_r_type != BFD_RELOC_PPC_TOC16)
4985 fixp->fx_addnumber = 0;
4986 else
4987 {
4988 #ifdef TE_PE
4989 fixp->fx_addnumber = 0;
4990 #else
4991 /* We want to use the offset within the data segment of the
4992 symbol, not the actual VMA of the symbol. */
4993 fixp->fx_addnumber =
4994 - bfd_get_section_vma (stdoutput, S_GET_SEGMENT (fixp->fx_addsy));
4995 #endif
4996 }
4997 #endif
4998
4999 return 1;
5000 }
5001
5002 /* Generate a reloc for a fixup. */
5003
5004 arelent *
5005 tc_gen_reloc (seg, fixp)
5006 asection *seg;
5007 fixS *fixp;
5008 {
5009 arelent *reloc;
5010
5011 reloc = (arelent *) xmalloc (sizeof (arelent));
5012
5013 reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
5014 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
5015 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
5016 reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
5017 if (reloc->howto == (reloc_howto_type *) NULL)
5018 {
5019 as_bad_where (fixp->fx_file, fixp->fx_line,
5020 _("reloc %d not supported by object file format"), (int)fixp->fx_r_type);
5021 return NULL;
5022 }
5023 reloc->addend = fixp->fx_addnumber;
5024
5025 return reloc;
5026 }
This page took 0.145842 seconds and 4 git commands to generate.