1 /* tc-ppc.c -- Assemble for the PowerPC or POWER (RS/6000)
2 Copyright (C) 1994-2021 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23 #include "safe-ctype.h"
25 #include "dw2gencfi.h"
26 #include "opcode/ppc.h"
30 #include "elf/ppc64.h"
31 #include "dwarf2dbg.h"
35 #include "coff/xcoff.h"
39 /* This is the assembler for the PowerPC or POWER (RS/6000) chips. */
41 /* Tell the main code what the endianness is. */
42 extern int target_big_endian
;
44 /* Whether or not, we've set target_big_endian. */
45 static int set_target_endian
= 0;
47 /* Whether to use user friendly register names. */
48 #ifndef TARGET_REG_NAMES_P
49 #define TARGET_REG_NAMES_P FALSE
52 /* Macros for calculating LO, HI, HA, HIGHER, HIGHERA, HIGHEST,
55 /* #lo(value) denotes the least significant 16 bits of the indicated. */
56 #define PPC_LO(v) ((v) & 0xffff)
58 /* #hi(value) denotes bits 16 through 31 of the indicated value. */
59 #define PPC_HI(v) (((v) >> 16) & 0xffff)
61 /* #ha(value) denotes the high adjusted value: bits 16 through 31 of
62 the indicated value, compensating for #lo() being treated as a
64 #define PPC_HA(v) PPC_HI ((v) + 0x8000)
66 /* #higher(value) denotes bits 32 through 47 of the indicated value. */
67 #define PPC_HIGHER(v) (((v) >> 16 >> 16) & 0xffff)
69 /* #highera(value) denotes bits 32 through 47 of the indicated value,
70 compensating for #lo() being treated as a signed number. */
71 #define PPC_HIGHERA(v) PPC_HIGHER ((v) + 0x8000)
73 /* #highest(value) denotes bits 48 through 63 of the indicated value. */
74 #define PPC_HIGHEST(v) (((v) >> 24 >> 24) & 0xffff)
76 /* #highesta(value) denotes bits 48 through 63 of the indicated value,
77 compensating for #lo being treated as a signed number. */
78 #define PPC_HIGHESTA(v) PPC_HIGHEST ((v) + 0x8000)
80 #define SEX16(val) (((val) ^ 0x8000) - 0x8000)
82 /* For the time being on ppc64, don't report overflow on @h and @ha
83 applied to constants. */
84 #define REPORT_OVERFLOW_HI 0
86 static bfd_boolean reg_names_p
= TARGET_REG_NAMES_P
;
88 static void ppc_macro (char *, const struct powerpc_macro
*);
89 static void ppc_byte (int);
91 #if defined (OBJ_XCOFF) || defined (OBJ_ELF)
92 static void ppc_tc (int);
93 static void ppc_machine (int);
97 static void ppc_comm (int);
98 static void ppc_bb (int);
99 static void ppc_bc (int);
100 static void ppc_bf (int);
101 static void ppc_biei (int);
102 static void ppc_bs (int);
103 static void ppc_eb (int);
104 static void ppc_ec (int);
105 static void ppc_ef (int);
106 static void ppc_es (int);
107 static void ppc_csect (int);
108 static void ppc_dwsect (int);
109 static void ppc_change_csect (symbolS
*, offsetT
);
110 static void ppc_function (int);
111 static void ppc_extern (int);
112 static void ppc_lglobl (int);
113 static void ppc_ref (int);
114 static void ppc_section (int);
115 static void ppc_named_section (int);
116 static void ppc_stabx (int);
117 static void ppc_rename (int);
118 static void ppc_toc (int);
119 static void ppc_xcoff_cons (int);
120 static void ppc_vbyte (int);
124 static void ppc_elf_rdata (int);
125 static void ppc_elf_lcomm (int);
126 static void ppc_elf_localentry (int);
127 static void ppc_elf_abiversion (int);
128 static void ppc_elf_gnu_attribute (int);
131 /* Generic assembler global variables which must be defined by all
135 /* This string holds the chars that always start a comment. If the
136 pre-processor is disabled, these aren't very useful. The macro
137 tc_comment_chars points to this. We use this, rather than the
138 usual comment_chars, so that we can switch for Solaris conventions. */
139 static const char ppc_solaris_comment_chars
[] = "#!";
140 static const char ppc_eabi_comment_chars
[] = "#";
142 #ifdef TARGET_SOLARIS_COMMENT
143 const char *ppc_comment_chars
= ppc_solaris_comment_chars
;
145 const char *ppc_comment_chars
= ppc_eabi_comment_chars
;
148 const char comment_chars
[] = "#";
151 /* Characters which start a comment at the beginning of a line. */
152 const char line_comment_chars
[] = "#";
154 /* Characters which may be used to separate multiple commands on a
156 const char line_separator_chars
[] = ";";
158 /* Characters which are used to indicate an exponent in a floating
160 const char EXP_CHARS
[] = "eE";
162 /* Characters which mean that a number is a floating point constant,
164 const char FLT_CHARS
[] = "dD";
166 /* Anything that can start an operand needs to be mentioned here,
167 to stop the input scrubber eating whitespace. */
168 const char ppc_symbol_chars
[] = "%[";
170 /* The dwarf2 data alignment, adjusted for 32 or 64 bit. */
171 int ppc_cie_data_alignment
;
173 /* The dwarf2 minimum instruction length. */
174 int ppc_dwarf2_line_min_insn_length
;
176 /* More than this number of nops in an alignment op gets a branch
178 unsigned long nop_limit
= 4;
180 /* The type of processor we are assembling for. This is one or more
181 of the PPC_OPCODE flags defined in opcode/ppc.h. */
182 ppc_cpu_t ppc_cpu
= 0;
183 ppc_cpu_t sticky
= 0;
185 /* Value for ELF e_flags EF_PPC64_ABI. */
186 unsigned int ppc_abiversion
= 0;
189 /* Flags set on encountering toc relocs. */
191 has_large_toc_reloc
= 1,
192 has_small_toc_reloc
= 2
196 /* Warn on emitting data to code sections. */
202 /* The target specific pseudo-ops which we support. */
204 const pseudo_typeS md_pseudo_table
[] =
206 /* Pseudo-ops which must be overridden. */
207 { "byte", ppc_byte
, 0 },
210 /* Pseudo-ops specific to the RS/6000 XCOFF format. Some of these
211 legitimately belong in the obj-*.c file. However, XCOFF is based
212 on COFF, and is only implemented for the RS/6000. We just use
213 obj-coff.c, and add what we need here. */
214 { "comm", ppc_comm
, 0 },
215 { "lcomm", ppc_comm
, 1 },
219 { "bi", ppc_biei
, 0 },
221 { "csect", ppc_csect
, 0 },
222 { "dwsect", ppc_dwsect
, 0 },
223 { "data", ppc_section
, 'd' },
227 { "ei", ppc_biei
, 1 },
229 { "extern", ppc_extern
, 0 },
230 { "function", ppc_function
, 0 },
231 { "lglobl", ppc_lglobl
, 0 },
232 { "ref", ppc_ref
, 0 },
233 { "rename", ppc_rename
, 0 },
234 { "section", ppc_named_section
, 0 },
235 { "stabx", ppc_stabx
, 0 },
236 { "text", ppc_section
, 't' },
237 { "toc", ppc_toc
, 0 },
238 { "long", ppc_xcoff_cons
, 2 },
239 { "llong", ppc_xcoff_cons
, 3 },
240 { "word", ppc_xcoff_cons
, 1 },
241 { "short", ppc_xcoff_cons
, 1 },
242 { "vbyte", ppc_vbyte
, 0 },
246 { "llong", cons
, 8 },
247 { "rdata", ppc_elf_rdata
, 0 },
248 { "rodata", ppc_elf_rdata
, 0 },
249 { "lcomm", ppc_elf_lcomm
, 0 },
250 { "localentry", ppc_elf_localentry
, 0 },
251 { "abiversion", ppc_elf_abiversion
, 0 },
252 { "gnu_attribute", ppc_elf_gnu_attribute
, 0},
255 #if defined (OBJ_XCOFF) || defined (OBJ_ELF)
257 { "machine", ppc_machine
, 0 },
264 /* Predefined register names if -mregnames (or default for Windows NT).
265 In general, there are lots of them, in an attempt to be compatible
266 with a number of other Windows NT assemblers. */
268 /* Structure to hold information about predefined registers. */
272 unsigned short value
;
273 unsigned short flags
;
276 /* List of registers that are pre-defined:
278 Each general register has predefined names of the form:
279 1. r<reg_num> which has the value <reg_num>.
280 2. r.<reg_num> which has the value <reg_num>.
282 Each floating point register has predefined names of the form:
283 1. f<reg_num> which has the value <reg_num>.
284 2. f.<reg_num> which has the value <reg_num>.
286 Each vector unit register has predefined names of the form:
287 1. v<reg_num> which has the value <reg_num>.
288 2. v.<reg_num> which has the value <reg_num>.
290 Each condition register has predefined names of the form:
291 1. cr<reg_num> which has the value <reg_num>.
292 2. cr.<reg_num> which has the value <reg_num>.
294 There are individual registers as well:
295 sp or r.sp has the value 1
296 rtoc or r.toc has the value 2
301 dsisr has the value 18
303 sdr1 has the value 25
304 srr0 has the value 26
305 srr1 has the value 27
307 The table is sorted. Suitable for searching by a binary search. */
309 static const struct pd_reg pre_defined_registers
[] =
311 /* VSX accumulators. */
312 { "a0", 0, PPC_OPERAND_ACC
},
313 { "a1", 1, PPC_OPERAND_ACC
},
314 { "a2", 2, PPC_OPERAND_ACC
},
315 { "a3", 3, PPC_OPERAND_ACC
},
316 { "a4", 4, PPC_OPERAND_ACC
},
317 { "a5", 5, PPC_OPERAND_ACC
},
318 { "a6", 6, PPC_OPERAND_ACC
},
319 { "a7", 7, PPC_OPERAND_ACC
},
321 /* Condition Registers */
322 { "cr.0", 0, PPC_OPERAND_CR_REG
},
323 { "cr.1", 1, PPC_OPERAND_CR_REG
},
324 { "cr.2", 2, PPC_OPERAND_CR_REG
},
325 { "cr.3", 3, PPC_OPERAND_CR_REG
},
326 { "cr.4", 4, PPC_OPERAND_CR_REG
},
327 { "cr.5", 5, PPC_OPERAND_CR_REG
},
328 { "cr.6", 6, PPC_OPERAND_CR_REG
},
329 { "cr.7", 7, PPC_OPERAND_CR_REG
},
331 { "cr0", 0, PPC_OPERAND_CR_REG
},
332 { "cr1", 1, PPC_OPERAND_CR_REG
},
333 { "cr2", 2, PPC_OPERAND_CR_REG
},
334 { "cr3", 3, PPC_OPERAND_CR_REG
},
335 { "cr4", 4, PPC_OPERAND_CR_REG
},
336 { "cr5", 5, PPC_OPERAND_CR_REG
},
337 { "cr6", 6, PPC_OPERAND_CR_REG
},
338 { "cr7", 7, PPC_OPERAND_CR_REG
},
340 { "ctr", 9, PPC_OPERAND_SPR
},
341 { "dar", 19, PPC_OPERAND_SPR
},
342 { "dec", 22, PPC_OPERAND_SPR
},
343 { "dsisr", 18, PPC_OPERAND_SPR
},
345 /* Floating point registers */
346 { "f.0", 0, PPC_OPERAND_FPR
},
347 { "f.1", 1, PPC_OPERAND_FPR
},
348 { "f.10", 10, PPC_OPERAND_FPR
},
349 { "f.11", 11, PPC_OPERAND_FPR
},
350 { "f.12", 12, PPC_OPERAND_FPR
},
351 { "f.13", 13, PPC_OPERAND_FPR
},
352 { "f.14", 14, PPC_OPERAND_FPR
},
353 { "f.15", 15, PPC_OPERAND_FPR
},
354 { "f.16", 16, PPC_OPERAND_FPR
},
355 { "f.17", 17, PPC_OPERAND_FPR
},
356 { "f.18", 18, PPC_OPERAND_FPR
},
357 { "f.19", 19, PPC_OPERAND_FPR
},
358 { "f.2", 2, PPC_OPERAND_FPR
},
359 { "f.20", 20, PPC_OPERAND_FPR
},
360 { "f.21", 21, PPC_OPERAND_FPR
},
361 { "f.22", 22, PPC_OPERAND_FPR
},
362 { "f.23", 23, PPC_OPERAND_FPR
},
363 { "f.24", 24, PPC_OPERAND_FPR
},
364 { "f.25", 25, PPC_OPERAND_FPR
},
365 { "f.26", 26, PPC_OPERAND_FPR
},
366 { "f.27", 27, PPC_OPERAND_FPR
},
367 { "f.28", 28, PPC_OPERAND_FPR
},
368 { "f.29", 29, PPC_OPERAND_FPR
},
369 { "f.3", 3, PPC_OPERAND_FPR
},
370 { "f.30", 30, PPC_OPERAND_FPR
},
371 { "f.31", 31, PPC_OPERAND_FPR
},
372 { "f.32", 32, PPC_OPERAND_VSR
},
373 { "f.33", 33, PPC_OPERAND_VSR
},
374 { "f.34", 34, PPC_OPERAND_VSR
},
375 { "f.35", 35, PPC_OPERAND_VSR
},
376 { "f.36", 36, PPC_OPERAND_VSR
},
377 { "f.37", 37, PPC_OPERAND_VSR
},
378 { "f.38", 38, PPC_OPERAND_VSR
},
379 { "f.39", 39, PPC_OPERAND_VSR
},
380 { "f.4", 4, PPC_OPERAND_FPR
},
381 { "f.40", 40, PPC_OPERAND_VSR
},
382 { "f.41", 41, PPC_OPERAND_VSR
},
383 { "f.42", 42, PPC_OPERAND_VSR
},
384 { "f.43", 43, PPC_OPERAND_VSR
},
385 { "f.44", 44, PPC_OPERAND_VSR
},
386 { "f.45", 45, PPC_OPERAND_VSR
},
387 { "f.46", 46, PPC_OPERAND_VSR
},
388 { "f.47", 47, PPC_OPERAND_VSR
},
389 { "f.48", 48, PPC_OPERAND_VSR
},
390 { "f.49", 49, PPC_OPERAND_VSR
},
391 { "f.5", 5, PPC_OPERAND_FPR
},
392 { "f.50", 50, PPC_OPERAND_VSR
},
393 { "f.51", 51, PPC_OPERAND_VSR
},
394 { "f.52", 52, PPC_OPERAND_VSR
},
395 { "f.53", 53, PPC_OPERAND_VSR
},
396 { "f.54", 54, PPC_OPERAND_VSR
},
397 { "f.55", 55, PPC_OPERAND_VSR
},
398 { "f.56", 56, PPC_OPERAND_VSR
},
399 { "f.57", 57, PPC_OPERAND_VSR
},
400 { "f.58", 58, PPC_OPERAND_VSR
},
401 { "f.59", 59, PPC_OPERAND_VSR
},
402 { "f.6", 6, PPC_OPERAND_FPR
},
403 { "f.60", 60, PPC_OPERAND_VSR
},
404 { "f.61", 61, PPC_OPERAND_VSR
},
405 { "f.62", 62, PPC_OPERAND_VSR
},
406 { "f.63", 63, PPC_OPERAND_VSR
},
407 { "f.7", 7, PPC_OPERAND_FPR
},
408 { "f.8", 8, PPC_OPERAND_FPR
},
409 { "f.9", 9, PPC_OPERAND_FPR
},
411 { "f0", 0, PPC_OPERAND_FPR
},
412 { "f1", 1, PPC_OPERAND_FPR
},
413 { "f10", 10, PPC_OPERAND_FPR
},
414 { "f11", 11, PPC_OPERAND_FPR
},
415 { "f12", 12, PPC_OPERAND_FPR
},
416 { "f13", 13, PPC_OPERAND_FPR
},
417 { "f14", 14, PPC_OPERAND_FPR
},
418 { "f15", 15, PPC_OPERAND_FPR
},
419 { "f16", 16, PPC_OPERAND_FPR
},
420 { "f17", 17, PPC_OPERAND_FPR
},
421 { "f18", 18, PPC_OPERAND_FPR
},
422 { "f19", 19, PPC_OPERAND_FPR
},
423 { "f2", 2, PPC_OPERAND_FPR
},
424 { "f20", 20, PPC_OPERAND_FPR
},
425 { "f21", 21, PPC_OPERAND_FPR
},
426 { "f22", 22, PPC_OPERAND_FPR
},
427 { "f23", 23, PPC_OPERAND_FPR
},
428 { "f24", 24, PPC_OPERAND_FPR
},
429 { "f25", 25, PPC_OPERAND_FPR
},
430 { "f26", 26, PPC_OPERAND_FPR
},
431 { "f27", 27, PPC_OPERAND_FPR
},
432 { "f28", 28, PPC_OPERAND_FPR
},
433 { "f29", 29, PPC_OPERAND_FPR
},
434 { "f3", 3, PPC_OPERAND_FPR
},
435 { "f30", 30, PPC_OPERAND_FPR
},
436 { "f31", 31, PPC_OPERAND_FPR
},
437 { "f32", 32, PPC_OPERAND_VSR
},
438 { "f33", 33, PPC_OPERAND_VSR
},
439 { "f34", 34, PPC_OPERAND_VSR
},
440 { "f35", 35, PPC_OPERAND_VSR
},
441 { "f36", 36, PPC_OPERAND_VSR
},
442 { "f37", 37, PPC_OPERAND_VSR
},
443 { "f38", 38, PPC_OPERAND_VSR
},
444 { "f39", 39, PPC_OPERAND_VSR
},
445 { "f4", 4, PPC_OPERAND_FPR
},
446 { "f40", 40, PPC_OPERAND_VSR
},
447 { "f41", 41, PPC_OPERAND_VSR
},
448 { "f42", 42, PPC_OPERAND_VSR
},
449 { "f43", 43, PPC_OPERAND_VSR
},
450 { "f44", 44, PPC_OPERAND_VSR
},
451 { "f45", 45, PPC_OPERAND_VSR
},
452 { "f46", 46, PPC_OPERAND_VSR
},
453 { "f47", 47, PPC_OPERAND_VSR
},
454 { "f48", 48, PPC_OPERAND_VSR
},
455 { "f49", 49, PPC_OPERAND_VSR
},
456 { "f5", 5, PPC_OPERAND_FPR
},
457 { "f50", 50, PPC_OPERAND_VSR
},
458 { "f51", 51, PPC_OPERAND_VSR
},
459 { "f52", 52, PPC_OPERAND_VSR
},
460 { "f53", 53, PPC_OPERAND_VSR
},
461 { "f54", 54, PPC_OPERAND_VSR
},
462 { "f55", 55, PPC_OPERAND_VSR
},
463 { "f56", 56, PPC_OPERAND_VSR
},
464 { "f57", 57, PPC_OPERAND_VSR
},
465 { "f58", 58, PPC_OPERAND_VSR
},
466 { "f59", 59, PPC_OPERAND_VSR
},
467 { "f6", 6, PPC_OPERAND_FPR
},
468 { "f60", 60, PPC_OPERAND_VSR
},
469 { "f61", 61, PPC_OPERAND_VSR
},
470 { "f62", 62, PPC_OPERAND_VSR
},
471 { "f63", 63, PPC_OPERAND_VSR
},
472 { "f7", 7, PPC_OPERAND_FPR
},
473 { "f8", 8, PPC_OPERAND_FPR
},
474 { "f9", 9, PPC_OPERAND_FPR
},
476 /* Quantization registers used with pair single instructions. */
477 { "gqr.0", 0, PPC_OPERAND_GQR
},
478 { "gqr.1", 1, PPC_OPERAND_GQR
},
479 { "gqr.2", 2, PPC_OPERAND_GQR
},
480 { "gqr.3", 3, PPC_OPERAND_GQR
},
481 { "gqr.4", 4, PPC_OPERAND_GQR
},
482 { "gqr.5", 5, PPC_OPERAND_GQR
},
483 { "gqr.6", 6, PPC_OPERAND_GQR
},
484 { "gqr.7", 7, PPC_OPERAND_GQR
},
485 { "gqr0", 0, PPC_OPERAND_GQR
},
486 { "gqr1", 1, PPC_OPERAND_GQR
},
487 { "gqr2", 2, PPC_OPERAND_GQR
},
488 { "gqr3", 3, PPC_OPERAND_GQR
},
489 { "gqr4", 4, PPC_OPERAND_GQR
},
490 { "gqr5", 5, PPC_OPERAND_GQR
},
491 { "gqr6", 6, PPC_OPERAND_GQR
},
492 { "gqr7", 7, PPC_OPERAND_GQR
},
494 { "lr", 8, PPC_OPERAND_SPR
},
496 /* General Purpose Registers */
497 { "r.0", 0, PPC_OPERAND_GPR
},
498 { "r.1", 1, PPC_OPERAND_GPR
},
499 { "r.10", 10, PPC_OPERAND_GPR
},
500 { "r.11", 11, PPC_OPERAND_GPR
},
501 { "r.12", 12, PPC_OPERAND_GPR
},
502 { "r.13", 13, PPC_OPERAND_GPR
},
503 { "r.14", 14, PPC_OPERAND_GPR
},
504 { "r.15", 15, PPC_OPERAND_GPR
},
505 { "r.16", 16, PPC_OPERAND_GPR
},
506 { "r.17", 17, PPC_OPERAND_GPR
},
507 { "r.18", 18, PPC_OPERAND_GPR
},
508 { "r.19", 19, PPC_OPERAND_GPR
},
509 { "r.2", 2, PPC_OPERAND_GPR
},
510 { "r.20", 20, PPC_OPERAND_GPR
},
511 { "r.21", 21, PPC_OPERAND_GPR
},
512 { "r.22", 22, PPC_OPERAND_GPR
},
513 { "r.23", 23, PPC_OPERAND_GPR
},
514 { "r.24", 24, PPC_OPERAND_GPR
},
515 { "r.25", 25, PPC_OPERAND_GPR
},
516 { "r.26", 26, PPC_OPERAND_GPR
},
517 { "r.27", 27, PPC_OPERAND_GPR
},
518 { "r.28", 28, PPC_OPERAND_GPR
},
519 { "r.29", 29, PPC_OPERAND_GPR
},
520 { "r.3", 3, PPC_OPERAND_GPR
},
521 { "r.30", 30, PPC_OPERAND_GPR
},
522 { "r.31", 31, PPC_OPERAND_GPR
},
523 { "r.4", 4, PPC_OPERAND_GPR
},
524 { "r.5", 5, PPC_OPERAND_GPR
},
525 { "r.6", 6, PPC_OPERAND_GPR
},
526 { "r.7", 7, PPC_OPERAND_GPR
},
527 { "r.8", 8, PPC_OPERAND_GPR
},
528 { "r.9", 9, PPC_OPERAND_GPR
},
530 { "r.sp", 1, PPC_OPERAND_GPR
},
532 { "r.toc", 2, PPC_OPERAND_GPR
},
534 { "r0", 0, PPC_OPERAND_GPR
},
535 { "r1", 1, PPC_OPERAND_GPR
},
536 { "r10", 10, PPC_OPERAND_GPR
},
537 { "r11", 11, PPC_OPERAND_GPR
},
538 { "r12", 12, PPC_OPERAND_GPR
},
539 { "r13", 13, PPC_OPERAND_GPR
},
540 { "r14", 14, PPC_OPERAND_GPR
},
541 { "r15", 15, PPC_OPERAND_GPR
},
542 { "r16", 16, PPC_OPERAND_GPR
},
543 { "r17", 17, PPC_OPERAND_GPR
},
544 { "r18", 18, PPC_OPERAND_GPR
},
545 { "r19", 19, PPC_OPERAND_GPR
},
546 { "r2", 2, PPC_OPERAND_GPR
},
547 { "r20", 20, PPC_OPERAND_GPR
},
548 { "r21", 21, PPC_OPERAND_GPR
},
549 { "r22", 22, PPC_OPERAND_GPR
},
550 { "r23", 23, PPC_OPERAND_GPR
},
551 { "r24", 24, PPC_OPERAND_GPR
},
552 { "r25", 25, PPC_OPERAND_GPR
},
553 { "r26", 26, PPC_OPERAND_GPR
},
554 { "r27", 27, PPC_OPERAND_GPR
},
555 { "r28", 28, PPC_OPERAND_GPR
},
556 { "r29", 29, PPC_OPERAND_GPR
},
557 { "r3", 3, PPC_OPERAND_GPR
},
558 { "r30", 30, PPC_OPERAND_GPR
},
559 { "r31", 31, PPC_OPERAND_GPR
},
560 { "r4", 4, PPC_OPERAND_GPR
},
561 { "r5", 5, PPC_OPERAND_GPR
},
562 { "r6", 6, PPC_OPERAND_GPR
},
563 { "r7", 7, PPC_OPERAND_GPR
},
564 { "r8", 8, PPC_OPERAND_GPR
},
565 { "r9", 9, PPC_OPERAND_GPR
},
567 { "rtoc", 2, PPC_OPERAND_GPR
},
569 { "sdr1", 25, PPC_OPERAND_SPR
},
571 { "sp", 1, PPC_OPERAND_GPR
},
573 { "srr0", 26, PPC_OPERAND_SPR
},
574 { "srr1", 27, PPC_OPERAND_SPR
},
576 /* Vector (Altivec/VMX) registers */
577 { "v.0", 0, PPC_OPERAND_VR
},
578 { "v.1", 1, PPC_OPERAND_VR
},
579 { "v.10", 10, PPC_OPERAND_VR
},
580 { "v.11", 11, PPC_OPERAND_VR
},
581 { "v.12", 12, PPC_OPERAND_VR
},
582 { "v.13", 13, PPC_OPERAND_VR
},
583 { "v.14", 14, PPC_OPERAND_VR
},
584 { "v.15", 15, PPC_OPERAND_VR
},
585 { "v.16", 16, PPC_OPERAND_VR
},
586 { "v.17", 17, PPC_OPERAND_VR
},
587 { "v.18", 18, PPC_OPERAND_VR
},
588 { "v.19", 19, PPC_OPERAND_VR
},
589 { "v.2", 2, PPC_OPERAND_VR
},
590 { "v.20", 20, PPC_OPERAND_VR
},
591 { "v.21", 21, PPC_OPERAND_VR
},
592 { "v.22", 22, PPC_OPERAND_VR
},
593 { "v.23", 23, PPC_OPERAND_VR
},
594 { "v.24", 24, PPC_OPERAND_VR
},
595 { "v.25", 25, PPC_OPERAND_VR
},
596 { "v.26", 26, PPC_OPERAND_VR
},
597 { "v.27", 27, PPC_OPERAND_VR
},
598 { "v.28", 28, PPC_OPERAND_VR
},
599 { "v.29", 29, PPC_OPERAND_VR
},
600 { "v.3", 3, PPC_OPERAND_VR
},
601 { "v.30", 30, PPC_OPERAND_VR
},
602 { "v.31", 31, PPC_OPERAND_VR
},
603 { "v.4", 4, PPC_OPERAND_VR
},
604 { "v.5", 5, PPC_OPERAND_VR
},
605 { "v.6", 6, PPC_OPERAND_VR
},
606 { "v.7", 7, PPC_OPERAND_VR
},
607 { "v.8", 8, PPC_OPERAND_VR
},
608 { "v.9", 9, PPC_OPERAND_VR
},
610 { "v0", 0, PPC_OPERAND_VR
},
611 { "v1", 1, PPC_OPERAND_VR
},
612 { "v10", 10, PPC_OPERAND_VR
},
613 { "v11", 11, PPC_OPERAND_VR
},
614 { "v12", 12, PPC_OPERAND_VR
},
615 { "v13", 13, PPC_OPERAND_VR
},
616 { "v14", 14, PPC_OPERAND_VR
},
617 { "v15", 15, PPC_OPERAND_VR
},
618 { "v16", 16, PPC_OPERAND_VR
},
619 { "v17", 17, PPC_OPERAND_VR
},
620 { "v18", 18, PPC_OPERAND_VR
},
621 { "v19", 19, PPC_OPERAND_VR
},
622 { "v2", 2, PPC_OPERAND_VR
},
623 { "v20", 20, PPC_OPERAND_VR
},
624 { "v21", 21, PPC_OPERAND_VR
},
625 { "v22", 22, PPC_OPERAND_VR
},
626 { "v23", 23, PPC_OPERAND_VR
},
627 { "v24", 24, PPC_OPERAND_VR
},
628 { "v25", 25, PPC_OPERAND_VR
},
629 { "v26", 26, PPC_OPERAND_VR
},
630 { "v27", 27, PPC_OPERAND_VR
},
631 { "v28", 28, PPC_OPERAND_VR
},
632 { "v29", 29, PPC_OPERAND_VR
},
633 { "v3", 3, PPC_OPERAND_VR
},
634 { "v30", 30, PPC_OPERAND_VR
},
635 { "v31", 31, PPC_OPERAND_VR
},
636 { "v4", 4, PPC_OPERAND_VR
},
637 { "v5", 5, PPC_OPERAND_VR
},
638 { "v6", 6, PPC_OPERAND_VR
},
639 { "v7", 7, PPC_OPERAND_VR
},
640 { "v8", 8, PPC_OPERAND_VR
},
641 { "v9", 9, PPC_OPERAND_VR
},
643 /* Vector Scalar (VSX) registers (ISA 2.06). */
644 { "vs.0", 0, PPC_OPERAND_VSR
},
645 { "vs.1", 1, PPC_OPERAND_VSR
},
646 { "vs.10", 10, PPC_OPERAND_VSR
},
647 { "vs.11", 11, PPC_OPERAND_VSR
},
648 { "vs.12", 12, PPC_OPERAND_VSR
},
649 { "vs.13", 13, PPC_OPERAND_VSR
},
650 { "vs.14", 14, PPC_OPERAND_VSR
},
651 { "vs.15", 15, PPC_OPERAND_VSR
},
652 { "vs.16", 16, PPC_OPERAND_VSR
},
653 { "vs.17", 17, PPC_OPERAND_VSR
},
654 { "vs.18", 18, PPC_OPERAND_VSR
},
655 { "vs.19", 19, PPC_OPERAND_VSR
},
656 { "vs.2", 2, PPC_OPERAND_VSR
},
657 { "vs.20", 20, PPC_OPERAND_VSR
},
658 { "vs.21", 21, PPC_OPERAND_VSR
},
659 { "vs.22", 22, PPC_OPERAND_VSR
},
660 { "vs.23", 23, PPC_OPERAND_VSR
},
661 { "vs.24", 24, PPC_OPERAND_VSR
},
662 { "vs.25", 25, PPC_OPERAND_VSR
},
663 { "vs.26", 26, PPC_OPERAND_VSR
},
664 { "vs.27", 27, PPC_OPERAND_VSR
},
665 { "vs.28", 28, PPC_OPERAND_VSR
},
666 { "vs.29", 29, PPC_OPERAND_VSR
},
667 { "vs.3", 3, PPC_OPERAND_VSR
},
668 { "vs.30", 30, PPC_OPERAND_VSR
},
669 { "vs.31", 31, PPC_OPERAND_VSR
},
670 { "vs.32", 32, PPC_OPERAND_VSR
},
671 { "vs.33", 33, PPC_OPERAND_VSR
},
672 { "vs.34", 34, PPC_OPERAND_VSR
},
673 { "vs.35", 35, PPC_OPERAND_VSR
},
674 { "vs.36", 36, PPC_OPERAND_VSR
},
675 { "vs.37", 37, PPC_OPERAND_VSR
},
676 { "vs.38", 38, PPC_OPERAND_VSR
},
677 { "vs.39", 39, PPC_OPERAND_VSR
},
678 { "vs.4", 4, PPC_OPERAND_VSR
},
679 { "vs.40", 40, PPC_OPERAND_VSR
},
680 { "vs.41", 41, PPC_OPERAND_VSR
},
681 { "vs.42", 42, PPC_OPERAND_VSR
},
682 { "vs.43", 43, PPC_OPERAND_VSR
},
683 { "vs.44", 44, PPC_OPERAND_VSR
},
684 { "vs.45", 45, PPC_OPERAND_VSR
},
685 { "vs.46", 46, PPC_OPERAND_VSR
},
686 { "vs.47", 47, PPC_OPERAND_VSR
},
687 { "vs.48", 48, PPC_OPERAND_VSR
},
688 { "vs.49", 49, PPC_OPERAND_VSR
},
689 { "vs.5", 5, PPC_OPERAND_VSR
},
690 { "vs.50", 50, PPC_OPERAND_VSR
},
691 { "vs.51", 51, PPC_OPERAND_VSR
},
692 { "vs.52", 52, PPC_OPERAND_VSR
},
693 { "vs.53", 53, PPC_OPERAND_VSR
},
694 { "vs.54", 54, PPC_OPERAND_VSR
},
695 { "vs.55", 55, PPC_OPERAND_VSR
},
696 { "vs.56", 56, PPC_OPERAND_VSR
},
697 { "vs.57", 57, PPC_OPERAND_VSR
},
698 { "vs.58", 58, PPC_OPERAND_VSR
},
699 { "vs.59", 59, PPC_OPERAND_VSR
},
700 { "vs.6", 6, PPC_OPERAND_VSR
},
701 { "vs.60", 60, PPC_OPERAND_VSR
},
702 { "vs.61", 61, PPC_OPERAND_VSR
},
703 { "vs.62", 62, PPC_OPERAND_VSR
},
704 { "vs.63", 63, PPC_OPERAND_VSR
},
705 { "vs.7", 7, PPC_OPERAND_VSR
},
706 { "vs.8", 8, PPC_OPERAND_VSR
},
707 { "vs.9", 9, PPC_OPERAND_VSR
},
709 { "vs0", 0, PPC_OPERAND_VSR
},
710 { "vs1", 1, PPC_OPERAND_VSR
},
711 { "vs10", 10, PPC_OPERAND_VSR
},
712 { "vs11", 11, PPC_OPERAND_VSR
},
713 { "vs12", 12, PPC_OPERAND_VSR
},
714 { "vs13", 13, PPC_OPERAND_VSR
},
715 { "vs14", 14, PPC_OPERAND_VSR
},
716 { "vs15", 15, PPC_OPERAND_VSR
},
717 { "vs16", 16, PPC_OPERAND_VSR
},
718 { "vs17", 17, PPC_OPERAND_VSR
},
719 { "vs18", 18, PPC_OPERAND_VSR
},
720 { "vs19", 19, PPC_OPERAND_VSR
},
721 { "vs2", 2, PPC_OPERAND_VSR
},
722 { "vs20", 20, PPC_OPERAND_VSR
},
723 { "vs21", 21, PPC_OPERAND_VSR
},
724 { "vs22", 22, PPC_OPERAND_VSR
},
725 { "vs23", 23, PPC_OPERAND_VSR
},
726 { "vs24", 24, PPC_OPERAND_VSR
},
727 { "vs25", 25, PPC_OPERAND_VSR
},
728 { "vs26", 26, PPC_OPERAND_VSR
},
729 { "vs27", 27, PPC_OPERAND_VSR
},
730 { "vs28", 28, PPC_OPERAND_VSR
},
731 { "vs29", 29, PPC_OPERAND_VSR
},
732 { "vs3", 3, PPC_OPERAND_VSR
},
733 { "vs30", 30, PPC_OPERAND_VSR
},
734 { "vs31", 31, PPC_OPERAND_VSR
},
735 { "vs32", 32, PPC_OPERAND_VSR
},
736 { "vs33", 33, PPC_OPERAND_VSR
},
737 { "vs34", 34, PPC_OPERAND_VSR
},
738 { "vs35", 35, PPC_OPERAND_VSR
},
739 { "vs36", 36, PPC_OPERAND_VSR
},
740 { "vs37", 37, PPC_OPERAND_VSR
},
741 { "vs38", 38, PPC_OPERAND_VSR
},
742 { "vs39", 39, PPC_OPERAND_VSR
},
743 { "vs4", 4, PPC_OPERAND_VSR
},
744 { "vs40", 40, PPC_OPERAND_VSR
},
745 { "vs41", 41, PPC_OPERAND_VSR
},
746 { "vs42", 42, PPC_OPERAND_VSR
},
747 { "vs43", 43, PPC_OPERAND_VSR
},
748 { "vs44", 44, PPC_OPERAND_VSR
},
749 { "vs45", 45, PPC_OPERAND_VSR
},
750 { "vs46", 46, PPC_OPERAND_VSR
},
751 { "vs47", 47, PPC_OPERAND_VSR
},
752 { "vs48", 48, PPC_OPERAND_VSR
},
753 { "vs49", 49, PPC_OPERAND_VSR
},
754 { "vs5", 5, PPC_OPERAND_VSR
},
755 { "vs50", 50, PPC_OPERAND_VSR
},
756 { "vs51", 51, PPC_OPERAND_VSR
},
757 { "vs52", 52, PPC_OPERAND_VSR
},
758 { "vs53", 53, PPC_OPERAND_VSR
},
759 { "vs54", 54, PPC_OPERAND_VSR
},
760 { "vs55", 55, PPC_OPERAND_VSR
},
761 { "vs56", 56, PPC_OPERAND_VSR
},
762 { "vs57", 57, PPC_OPERAND_VSR
},
763 { "vs58", 58, PPC_OPERAND_VSR
},
764 { "vs59", 59, PPC_OPERAND_VSR
},
765 { "vs6", 6, PPC_OPERAND_VSR
},
766 { "vs60", 60, PPC_OPERAND_VSR
},
767 { "vs61", 61, PPC_OPERAND_VSR
},
768 { "vs62", 62, PPC_OPERAND_VSR
},
769 { "vs63", 63, PPC_OPERAND_VSR
},
770 { "vs7", 7, PPC_OPERAND_VSR
},
771 { "vs8", 8, PPC_OPERAND_VSR
},
772 { "vs9", 9, PPC_OPERAND_VSR
},
774 { "xer", 1, PPC_OPERAND_SPR
}
777 #define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg))
779 /* Given NAME, find the register number associated with that name, return
780 the integer value associated with the given name or -1 on failure. */
782 static const struct pd_reg
*
783 reg_name_search (const struct pd_reg
*regs
, int regcount
, const char *name
)
785 int middle
, low
, high
;
793 middle
= (low
+ high
) / 2;
794 cmp
= strcasecmp (name
, regs
[middle
].name
);
800 return ®s
[middle
];
808 * Summary of register_name.
810 * in: Input_line_pointer points to 1st char of operand.
812 * out: A expressionS.
813 * The operand may have been a register: in this case, X_op == O_register,
814 * X_add_number is set to the register number, and truth is returned.
815 * Input_line_pointer->(next non-blank) char after operand, or is in its
820 register_name (expressionS
*expressionP
)
822 const struct pd_reg
*reg
;
827 /* Find the spelling of the operand. */
828 start
= name
= input_line_pointer
;
829 if (name
[0] == '%' && ISALPHA (name
[1]))
830 name
= ++input_line_pointer
;
832 else if (!reg_names_p
|| !ISALPHA (name
[0]))
835 c
= get_symbol_name (&name
);
836 reg
= reg_name_search (pre_defined_registers
, REG_NAME_CNT
, name
);
838 /* Put back the delimiting char. */
839 *input_line_pointer
= c
;
841 /* Look to see if it's in the register table. */
844 expressionP
->X_op
= O_register
;
845 expressionP
->X_add_number
= reg
->value
;
846 expressionP
->X_md
= reg
->flags
;
848 /* Make the rest nice. */
849 expressionP
->X_add_symbol
= NULL
;
850 expressionP
->X_op_symbol
= NULL
;
854 /* Reset the line as if we had not done anything. */
855 input_line_pointer
= start
;
859 /* This function is called for each symbol seen in an expression. It
860 handles the special parsing which PowerPC assemblers are supposed
861 to use for condition codes. */
863 /* Whether to do the special parsing. */
864 static bfd_boolean cr_operand
;
866 /* Names to recognize in a condition code. This table is sorted. */
867 static const struct pd_reg cr_names
[] =
869 { "cr0", 0, PPC_OPERAND_CR_REG
},
870 { "cr1", 1, PPC_OPERAND_CR_REG
},
871 { "cr2", 2, PPC_OPERAND_CR_REG
},
872 { "cr3", 3, PPC_OPERAND_CR_REG
},
873 { "cr4", 4, PPC_OPERAND_CR_REG
},
874 { "cr5", 5, PPC_OPERAND_CR_REG
},
875 { "cr6", 6, PPC_OPERAND_CR_REG
},
876 { "cr7", 7, PPC_OPERAND_CR_REG
},
877 { "eq", 2, PPC_OPERAND_CR_BIT
},
878 { "gt", 1, PPC_OPERAND_CR_BIT
},
879 { "lt", 0, PPC_OPERAND_CR_BIT
},
880 { "so", 3, PPC_OPERAND_CR_BIT
},
881 { "un", 3, PPC_OPERAND_CR_BIT
}
884 /* Parsing function. This returns non-zero if it recognized an
888 ppc_parse_name (const char *name
, expressionS
*exp
)
890 const struct pd_reg
*reg
;
897 reg
= reg_name_search (cr_names
, sizeof cr_names
/ sizeof cr_names
[0],
902 exp
->X_op
= O_register
;
903 exp
->X_add_number
= reg
->value
;
904 exp
->X_md
= reg
->flags
;
909 /* Propagate X_md and check register expressions. This is to support
910 condition codes like 4*cr5+eq. */
913 ppc_optimize_expr (expressionS
*left
, operatorT op
, expressionS
*right
)
915 /* Accept 4*cr<n> and cr<n>*4. */
917 && ((right
->X_op
== O_register
918 && right
->X_md
== PPC_OPERAND_CR_REG
919 && left
->X_op
== O_constant
920 && left
->X_add_number
== 4)
921 || (left
->X_op
== O_register
922 && left
->X_md
== PPC_OPERAND_CR_REG
923 && right
->X_op
== O_constant
924 && right
->X_add_number
== 4)))
926 left
->X_op
= O_register
;
927 left
->X_md
= PPC_OPERAND_CR_REG
| PPC_OPERAND_CR_BIT
;
928 left
->X_add_number
*= right
->X_add_number
;
932 /* Accept the above plus <cr bit>, and <cr bit> plus the above. */
933 if (right
->X_op
== O_register
934 && left
->X_op
== O_register
936 && ((right
->X_md
== PPC_OPERAND_CR_BIT
937 && left
->X_md
== (PPC_OPERAND_CR_REG
| PPC_OPERAND_CR_BIT
))
938 || (right
->X_md
== (PPC_OPERAND_CR_REG
| PPC_OPERAND_CR_BIT
)
939 && left
->X_md
== PPC_OPERAND_CR_BIT
)))
941 left
->X_md
= PPC_OPERAND_CR_BIT
;
942 right
->X_op
= O_constant
;
946 /* Accept reg +/- constant. */
947 if (left
->X_op
== O_register
948 && !((op
== O_add
|| op
== O_subtract
) && right
->X_op
== O_constant
))
949 as_warn (_("invalid register expression"));
951 /* Accept constant + reg. */
952 if (right
->X_op
== O_register
)
954 if (op
== O_add
&& left
->X_op
== O_constant
)
955 left
->X_md
= right
->X_md
;
957 as_warn (_("invalid register expression"));
963 /* Local variables. */
965 /* Whether to target xcoff64/elf64. */
966 static unsigned int ppc_obj64
= BFD_DEFAULT_TARGET_SIZE
== 64;
968 /* Opcode hash table. */
969 static htab_t ppc_hash
;
971 /* Macro hash table. */
972 static htab_t ppc_macro_hash
;
975 /* What type of shared library support to use. */
976 static enum { SHLIB_NONE
, SHLIB_PIC
, SHLIB_MRELOCATABLE
} shlib
= SHLIB_NONE
;
978 /* Flags to set in the elf header. */
979 static flagword ppc_flags
= 0;
981 /* Whether this is Solaris or not. */
982 #ifdef TARGET_SOLARIS_COMMENT
983 #define SOLARIS_P TRUE
985 #define SOLARIS_P FALSE
988 static bfd_boolean msolaris
= SOLARIS_P
;
993 /* The RS/6000 assembler uses the .csect pseudo-op to generate code
994 using a bunch of different sections. These assembler sections,
995 however, are all encompassed within the .text or .data sections of
996 the final output file. We handle this by using different
997 subsegments within these main segments. */
999 /* Next subsegment to allocate within the .text segment. */
1000 static subsegT ppc_text_subsegment
= 2;
1002 /* Linked list of csects in the text section. */
1003 static symbolS
*ppc_text_csects
;
1005 /* Next subsegment to allocate within the .data segment. */
1006 static subsegT ppc_data_subsegment
= 2;
1008 /* Linked list of csects in the data section. */
1009 static symbolS
*ppc_data_csects
;
1011 /* The current csect. */
1012 static symbolS
*ppc_current_csect
;
1014 /* The RS/6000 assembler uses a TOC which holds addresses of functions
1015 and variables. Symbols are put in the TOC with the .tc pseudo-op.
1016 A special relocation is used when accessing TOC entries. We handle
1017 the TOC as a subsegment within the .data segment. We set it up if
1018 we see a .toc pseudo-op, and save the csect symbol here. */
1019 static symbolS
*ppc_toc_csect
;
1021 /* The first frag in the TOC subsegment. */
1022 static fragS
*ppc_toc_frag
;
1024 /* The first frag in the first subsegment after the TOC in the .data
1025 segment. NULL if there are no subsegments after the TOC. */
1026 static fragS
*ppc_after_toc_frag
;
1028 /* The current static block. */
1029 static symbolS
*ppc_current_block
;
1031 /* The COFF debugging section; set by md_begin. This is not the
1032 .debug section, but is instead the secret BFD section which will
1033 cause BFD to set the section number of a symbol to N_DEBUG. */
1034 static asection
*ppc_coff_debug_section
;
1036 /* Structure to set the length field of the dwarf sections. */
1037 struct dw_subsection
{
1038 /* Subsections are simply linked. */
1039 struct dw_subsection
*link
;
1041 /* The subsection number. */
1044 /* Expression to compute the length of the section. */
1045 expressionS end_exp
;
1048 static struct dw_section
{
1049 /* Corresponding section. */
1052 /* Simply linked list of subsections with a label. */
1053 struct dw_subsection
*list_subseg
;
1055 /* The anonymous subsection. */
1056 struct dw_subsection
*anon_subseg
;
1057 } dw_sections
[XCOFF_DWSECT_NBR_NAMES
];
1058 #endif /* OBJ_XCOFF */
1061 symbolS
*GOT_symbol
; /* Pre-defined "_GLOBAL_OFFSET_TABLE" */
1062 unsigned long *ppc_apuinfo_list
;
1063 unsigned int ppc_apuinfo_num
;
1064 unsigned int ppc_apuinfo_num_alloc
;
1065 #endif /* OBJ_ELF */
1068 const char *const md_shortopts
= "b:l:usm:K:VQ:";
1070 const char *const md_shortopts
= "um:";
1072 #define OPTION_NOPS (OPTION_MD_BASE + 0)
1073 const struct option md_longopts
[] = {
1074 {"nops", required_argument
, NULL
, OPTION_NOPS
},
1075 {"ppc476-workaround", no_argument
, &warn_476
, 1},
1076 {"no-ppc476-workaround", no_argument
, &warn_476
, 0},
1077 {NULL
, no_argument
, NULL
, 0}
1079 const size_t md_longopts_size
= sizeof (md_longopts
);
1082 md_parse_option (int c
, const char *arg
)
1089 /* -u means that any undefined symbols should be treated as
1090 external, which is the default for gas anyhow. */
1095 /* Solaris as takes -le (presumably for little endian). For completeness
1096 sake, recognize -be also. */
1097 if (strcmp (arg
, "e") == 0)
1099 target_big_endian
= 0;
1100 set_target_endian
= 1;
1101 if (ppc_cpu
& PPC_OPCODE_VLE
)
1102 as_bad (_("the use of -mvle requires big endian."));
1110 if (strcmp (arg
, "e") == 0)
1112 target_big_endian
= 1;
1113 set_target_endian
= 1;
1121 /* Recognize -K PIC. */
1122 if (strcmp (arg
, "PIC") == 0 || strcmp (arg
, "pic") == 0)
1125 ppc_flags
|= EF_PPC_RELOCATABLE_LIB
;
1133 /* a64 and a32 determine whether to use XCOFF64 or XCOFF32. */
1135 if (strcmp (arg
, "64") == 0)
1139 if (ppc_cpu
& PPC_OPCODE_VLE
)
1140 as_bad (_("the use of -mvle requires -a32."));
1142 as_fatal (_("%s unsupported"), "-a64");
1145 else if (strcmp (arg
, "32") == 0)
1152 new_cpu
= ppc_parse_cpu (ppc_cpu
, &sticky
, arg
);
1153 /* "raw" is only valid for the disassembler. */
1154 if (new_cpu
!= 0 && (new_cpu
& PPC_OPCODE_RAW
) == 0)
1157 if (strcmp (arg
, "vle") == 0)
1159 if (set_target_endian
&& target_big_endian
== 0)
1160 as_bad (_("the use of -mvle requires big endian."));
1162 as_bad (_("the use of -mvle requires -a32."));
1166 else if (strcmp (arg
, "no-vle") == 0)
1168 sticky
&= ~PPC_OPCODE_VLE
;
1170 new_cpu
= ppc_parse_cpu (ppc_cpu
, &sticky
, "booke");
1171 new_cpu
&= ~PPC_OPCODE_VLE
;
1176 else if (strcmp (arg
, "regnames") == 0)
1179 else if (strcmp (arg
, "no-regnames") == 0)
1180 reg_names_p
= FALSE
;
1183 /* -mrelocatable/-mrelocatable-lib -- warn about initializations
1184 that require relocation. */
1185 else if (strcmp (arg
, "relocatable") == 0)
1187 shlib
= SHLIB_MRELOCATABLE
;
1188 ppc_flags
|= EF_PPC_RELOCATABLE
;
1191 else if (strcmp (arg
, "relocatable-lib") == 0)
1193 shlib
= SHLIB_MRELOCATABLE
;
1194 ppc_flags
|= EF_PPC_RELOCATABLE_LIB
;
1197 /* -memb, set embedded bit. */
1198 else if (strcmp (arg
, "emb") == 0)
1199 ppc_flags
|= EF_PPC_EMB
;
1201 /* -mlittle/-mbig set the endianness. */
1202 else if (strcmp (arg
, "little") == 0
1203 || strcmp (arg
, "little-endian") == 0)
1205 target_big_endian
= 0;
1206 set_target_endian
= 1;
1207 if (ppc_cpu
& PPC_OPCODE_VLE
)
1208 as_bad (_("the use of -mvle requires big endian."));
1211 else if (strcmp (arg
, "big") == 0 || strcmp (arg
, "big-endian") == 0)
1213 target_big_endian
= 1;
1214 set_target_endian
= 1;
1217 else if (strcmp (arg
, "solaris") == 0)
1220 ppc_comment_chars
= ppc_solaris_comment_chars
;
1223 else if (strcmp (arg
, "no-solaris") == 0)
1226 ppc_comment_chars
= ppc_eabi_comment_chars
;
1228 else if (strcmp (arg
, "spe2") == 0)
1230 ppc_cpu
|= PPC_OPCODE_SPE2
;
1235 as_bad (_("invalid switch -m%s"), arg
);
1241 /* -V: SVR4 argument to print version ID. */
1243 print_version_id ();
1246 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
1247 should be emitted or not. FIXME: Not implemented. */
1251 /* Solaris takes -s to specify that .stabs go in a .stabs section,
1252 rather than .stabs.excl, which is ignored by the linker.
1253 FIXME: Not implemented. */
1264 nop_limit
= strtoul (optarg
, &end
, 0);
1266 as_bad (_("--nops needs a numeric argument"));
1281 is_ppc64_target (const bfd_target
*targ
, void *data ATTRIBUTE_UNUSED
)
1283 switch (targ
->flavour
)
1286 case bfd_target_elf_flavour
:
1287 return strncmp (targ
->name
, "elf64-powerpc", 13) == 0;
1290 case bfd_target_xcoff_flavour
:
1291 return (strcmp (targ
->name
, "aixcoff64-rs6000") == 0
1292 || strcmp (targ
->name
, "aix5coff64-rs6000") == 0);
1300 md_show_usage (FILE *stream
)
1302 fprintf (stream
, _("\
1303 PowerPC options:\n"));
1304 fprintf (stream
, _("\
1305 -a32 generate ELF32/XCOFF32\n"));
1306 if (bfd_iterate_over_targets (is_ppc64_target
, NULL
))
1307 fprintf (stream
, _("\
1308 -a64 generate ELF64/XCOFF64\n"));
1309 fprintf (stream
, _("\
1311 fprintf (stream
, _("\
1312 -mpwrx, -mpwr2 generate code for POWER/2 (RIOS2)\n"));
1313 fprintf (stream
, _("\
1314 -mpwr generate code for POWER (RIOS1)\n"));
1315 fprintf (stream
, _("\
1316 -m601 generate code for PowerPC 601\n"));
1317 fprintf (stream
, _("\
1318 -mppc, -mppc32, -m603, -m604\n\
1319 generate code for PowerPC 603/604\n"));
1320 fprintf (stream
, _("\
1321 -m403 generate code for PowerPC 403\n"));
1322 fprintf (stream
, _("\
1323 -m405 generate code for PowerPC 405\n"));
1324 fprintf (stream
, _("\
1325 -m440 generate code for PowerPC 440\n"));
1326 fprintf (stream
, _("\
1327 -m464 generate code for PowerPC 464\n"));
1328 fprintf (stream
, _("\
1329 -m476 generate code for PowerPC 476\n"));
1330 fprintf (stream
, _("\
1331 -m7400, -m7410, -m7450, -m7455\n\
1332 generate code for PowerPC 7400/7410/7450/7455\n"));
1333 fprintf (stream
, _("\
1334 -m750cl, -mgekko, -mbroadway\n\
1335 generate code for PowerPC 750cl/Gekko/Broadway\n"));
1336 fprintf (stream
, _("\
1337 -m821, -m850, -m860 generate code for PowerPC 821/850/860\n"));
1338 fprintf (stream
, _("\
1339 -mppc64, -m620 generate code for PowerPC 620/625/630\n"));
1340 fprintf (stream
, _("\
1341 -mppc64bridge generate code for PowerPC 64, including bridge insns\n"));
1342 fprintf (stream
, _("\
1343 -mbooke generate code for 32-bit PowerPC BookE\n"));
1344 fprintf (stream
, _("\
1345 -ma2 generate code for A2 architecture\n"));
1346 fprintf (stream
, _("\
1347 -mpower4, -mpwr4 generate code for Power4 architecture\n"));
1348 fprintf (stream
, _("\
1349 -mpower5, -mpwr5, -mpwr5x\n\
1350 generate code for Power5 architecture\n"));
1351 fprintf (stream
, _("\
1352 -mpower6, -mpwr6 generate code for Power6 architecture\n"));
1353 fprintf (stream
, _("\
1354 -mpower7, -mpwr7 generate code for Power7 architecture\n"));
1355 fprintf (stream
, _("\
1356 -mpower8, -mpwr8 generate code for Power8 architecture\n"));
1357 fprintf (stream
, _("\
1358 -mpower9, -mpwr9 generate code for Power9 architecture\n"));
1359 fprintf (stream
, _("\
1360 -mpower10, -mpwr10 generate code for Power10 architecture\n"));
1361 fprintf (stream
, _("\
1362 -mcell generate code for Cell Broadband Engine architecture\n"));
1363 fprintf (stream
, _("\
1364 -mcom generate code for Power/PowerPC common instructions\n"));
1365 fprintf (stream
, _("\
1366 -many generate code for any architecture (PWR/PWRX/PPC)\n"));
1367 fprintf (stream
, _("\
1368 -maltivec generate code for AltiVec\n"));
1369 fprintf (stream
, _("\
1370 -mvsx generate code for Vector-Scalar (VSX) instructions\n"));
1371 fprintf (stream
, _("\
1372 -me300 generate code for PowerPC e300 family\n"));
1373 fprintf (stream
, _("\
1374 -me500, -me500x2 generate code for Motorola e500 core complex\n"));
1375 fprintf (stream
, _("\
1376 -me500mc, generate code for Freescale e500mc core complex\n"));
1377 fprintf (stream
, _("\
1378 -me500mc64, generate code for Freescale e500mc64 core complex\n"));
1379 fprintf (stream
, _("\
1380 -me5500, generate code for Freescale e5500 core complex\n"));
1381 fprintf (stream
, _("\
1382 -me6500, generate code for Freescale e6500 core complex\n"));
1383 fprintf (stream
, _("\
1384 -mspe generate code for Motorola SPE instructions\n"));
1385 fprintf (stream
, _("\
1386 -mspe2 generate code for Freescale SPE2 instructions\n"));
1387 fprintf (stream
, _("\
1388 -mvle generate code for Freescale VLE instructions\n"));
1389 fprintf (stream
, _("\
1390 -mtitan generate code for AppliedMicro Titan core complex\n"));
1391 fprintf (stream
, _("\
1392 -mregnames Allow symbolic names for registers\n"));
1393 fprintf (stream
, _("\
1394 -mno-regnames Do not allow symbolic names for registers\n"));
1396 fprintf (stream
, _("\
1397 -mrelocatable support for GCC's -mrelocatble option\n"));
1398 fprintf (stream
, _("\
1399 -mrelocatable-lib support for GCC's -mrelocatble-lib option\n"));
1400 fprintf (stream
, _("\
1401 -memb set PPC_EMB bit in ELF flags\n"));
1402 fprintf (stream
, _("\
1403 -mlittle, -mlittle-endian, -le\n\
1404 generate code for a little endian machine\n"));
1405 fprintf (stream
, _("\
1406 -mbig, -mbig-endian, -be\n\
1407 generate code for a big endian machine\n"));
1408 fprintf (stream
, _("\
1409 -msolaris generate code for Solaris\n"));
1410 fprintf (stream
, _("\
1411 -mno-solaris do not generate code for Solaris\n"));
1412 fprintf (stream
, _("\
1413 -K PIC set EF_PPC_RELOCATABLE_LIB in ELF flags\n"));
1414 fprintf (stream
, _("\
1415 -V print assembler version number\n"));
1416 fprintf (stream
, _("\
1417 -Qy, -Qn ignored\n"));
1419 fprintf (stream
, _("\
1420 -nops=count when aligning, more than COUNT nops uses a branch\n"));
1421 fprintf (stream
, _("\
1422 -ppc476-workaround warn if emitting data to code sections\n"));
1425 /* Set ppc_cpu if it is not already set. */
1430 const char *default_os
= TARGET_OS
;
1431 const char *default_cpu
= TARGET_CPU
;
1433 if ((ppc_cpu
& ~(ppc_cpu_t
) PPC_OPCODE_ANY
) == 0)
1436 if (target_big_endian
)
1437 ppc_cpu
|= PPC_OPCODE_PPC
| PPC_OPCODE_64
;
1439 /* The minimum supported cpu for 64-bit little-endian is power8. */
1440 ppc_cpu
|= ppc_parse_cpu (ppc_cpu
, &sticky
, "power8");
1441 else if (strncmp (default_os
, "aix", 3) == 0
1442 && default_os
[3] >= '4' && default_os
[3] <= '9')
1443 ppc_cpu
|= PPC_OPCODE_COMMON
;
1444 else if (strncmp (default_os
, "aix3", 4) == 0)
1445 ppc_cpu
|= PPC_OPCODE_POWER
;
1446 else if (strcmp (default_cpu
, "rs6000") == 0)
1447 ppc_cpu
|= PPC_OPCODE_POWER
;
1448 else if (strncmp (default_cpu
, "powerpc", 7) == 0)
1449 ppc_cpu
|= PPC_OPCODE_PPC
;
1451 as_fatal (_("unknown default cpu = %s, os = %s"),
1452 default_cpu
, default_os
);
1456 /* Figure out the BFD architecture to use. This function and ppc_mach
1457 are called well before md_begin, when the output file is opened. */
1459 enum bfd_architecture
1462 const char *default_cpu
= TARGET_CPU
;
1465 if ((ppc_cpu
& PPC_OPCODE_PPC
) != 0)
1466 return bfd_arch_powerpc
;
1467 if ((ppc_cpu
& PPC_OPCODE_VLE
) != 0)
1468 return bfd_arch_powerpc
;
1469 if ((ppc_cpu
& PPC_OPCODE_POWER
) != 0)
1470 return bfd_arch_rs6000
;
1471 if ((ppc_cpu
& (PPC_OPCODE_COMMON
| PPC_OPCODE_ANY
)) != 0)
1473 if (strcmp (default_cpu
, "rs6000") == 0)
1474 return bfd_arch_rs6000
;
1475 else if (strncmp (default_cpu
, "powerpc", 7) == 0)
1476 return bfd_arch_powerpc
;
1479 as_fatal (_("neither Power nor PowerPC opcodes were selected."));
1480 return bfd_arch_unknown
;
1487 return bfd_mach_ppc64
;
1488 else if (ppc_arch () == bfd_arch_rs6000
)
1489 return bfd_mach_rs6k
;
1490 else if (ppc_cpu
& PPC_OPCODE_TITAN
)
1491 return bfd_mach_ppc_titan
;
1492 else if (ppc_cpu
& PPC_OPCODE_VLE
)
1493 return bfd_mach_ppc_vle
;
1495 return bfd_mach_ppc
;
1499 ppc_target_format (void)
1503 return "xcoff-powermac";
1506 return (ppc_obj64
? "aix5coff64-rs6000" : "aixcoff-rs6000");
1508 return (ppc_obj64
? "aixcoff64-rs6000" : "aixcoff-rs6000");
1514 return (ppc_obj64
? "elf64-powerpc-freebsd" : "elf32-powerpc-freebsd");
1515 # elif defined (TE_VXWORKS)
1516 return "elf32-powerpc-vxworks";
1518 return (target_big_endian
1519 ? (ppc_obj64
? "elf64-powerpc" : "elf32-powerpc")
1520 : (ppc_obj64
? "elf64-powerpcle" : "elf32-powerpcle"));
1525 /* Validate one entry in powerpc_opcodes[] or vle_opcodes[].
1526 Return TRUE if there's a problem, otherwise FALSE. */
1529 insn_validate (const struct powerpc_opcode
*op
)
1531 const unsigned char *o
;
1532 uint64_t omask
= op
->mask
;
1534 /* The mask had better not trim off opcode bits. */
1535 if ((op
->opcode
& omask
) != op
->opcode
)
1537 as_bad (_("mask trims opcode bits for %s"), op
->name
);
1541 /* The operands must not overlap the opcode or each other. */
1542 for (o
= op
->operands
; *o
; ++o
)
1544 bfd_boolean optional
= FALSE
;
1545 if (*o
>= num_powerpc_operands
)
1547 as_bad (_("operand index error for %s"), op
->name
);
1553 const struct powerpc_operand
*operand
= &powerpc_operands
[*o
];
1554 if (operand
->shift
== (int) PPC_OPSHIFT_INV
)
1561 if ((operand
->flags
& PPC_OPERAND_NEGATIVE
) != 0)
1563 else if ((operand
->flags
& PPC_OPERAND_PLUS1
) != 0)
1565 mask
= (*operand
->insert
) (0, val
, ppc_cpu
, &errmsg
);
1567 else if (operand
->shift
>= 0)
1568 mask
= operand
->bitm
<< operand
->shift
;
1570 mask
= operand
->bitm
>> -operand
->shift
;
1573 as_bad (_("operand %d overlap in %s"),
1574 (int) (o
- op
->operands
), op
->name
);
1578 if ((operand
->flags
& PPC_OPERAND_OPTIONAL
) != 0)
1582 as_bad (_("non-optional operand %d follows optional operand in %s"),
1583 (int) (o
- op
->operands
), op
->name
);
1591 /* Insert opcodes and macros into hash tables. Called at startup and
1592 for .machine pseudo. */
1595 ppc_setup_opcodes (void)
1597 const struct powerpc_opcode
*op
;
1598 const struct powerpc_opcode
*op_end
;
1599 const struct powerpc_macro
*macro
;
1600 const struct powerpc_macro
*macro_end
;
1601 bfd_boolean bad_insn
= FALSE
;
1603 if (ppc_hash
!= NULL
)
1604 htab_delete (ppc_hash
);
1605 if (ppc_macro_hash
!= NULL
)
1606 htab_delete (ppc_macro_hash
);
1608 /* Insert the opcodes into a hash table. */
1609 ppc_hash
= str_htab_create ();
1611 if (ENABLE_CHECKING
)
1615 /* An index into powerpc_operands is stored in struct fix
1616 fx_pcrel_adjust which is 8 bits wide. */
1617 gas_assert (num_powerpc_operands
< 256);
1619 /* Check operand masks. Code here and in the disassembler assumes
1620 all the 1's in the mask are contiguous. */
1621 for (i
= 0; i
< num_powerpc_operands
; ++i
)
1623 uint64_t mask
= powerpc_operands
[i
].bitm
;
1627 right_bit
= mask
& -mask
;
1629 right_bit
= mask
& -mask
;
1630 if (mask
!= right_bit
)
1632 as_bad (_("powerpc_operands[%d].bitm invalid"), i
);
1635 for (j
= i
+ 1; j
< num_powerpc_operands
; ++j
)
1636 if (memcmp (&powerpc_operands
[i
], &powerpc_operands
[j
],
1637 sizeof (powerpc_operands
[0])) == 0)
1639 as_bad (_("powerpc_operands[%d] duplicates powerpc_operands[%d]"),
1646 op_end
= powerpc_opcodes
+ powerpc_num_opcodes
;
1647 for (op
= powerpc_opcodes
; op
< op_end
; op
++)
1649 if (ENABLE_CHECKING
)
1651 unsigned int new_opcode
= PPC_OP (op
[0].opcode
);
1653 #ifdef PRINT_OPCODE_TABLE
1654 printf ("%-14s\t#%04u\tmajor op: 0x%x\top: 0x%llx\tmask: 0x%llx\tflags: 0x%llx\n",
1655 op
->name
, (unsigned int) (op
- powerpc_opcodes
),
1656 new_opcode
, (unsigned long long) op
->opcode
,
1657 (unsigned long long) op
->mask
, (unsigned long long) op
->flags
);
1660 /* The major opcodes had better be sorted. Code in the disassembler
1661 assumes the insns are sorted according to major opcode. */
1662 if (op
!= powerpc_opcodes
1663 && new_opcode
< PPC_OP (op
[-1].opcode
))
1665 as_bad (_("major opcode is not sorted for %s"), op
->name
);
1669 if ((op
->flags
& PPC_OPCODE_VLE
) != 0)
1671 as_bad (_("%s is enabled by vle flag"), op
->name
);
1674 if (PPC_OP (op
->opcode
) != 4
1675 && PPC_OP (op
->opcode
) != 31
1676 && (op
->deprecated
& PPC_OPCODE_VLE
) == 0)
1678 as_bad (_("%s not disabled by vle flag"), op
->name
);
1681 bad_insn
|= insn_validate (op
);
1684 if ((ppc_cpu
& op
->flags
) != 0
1685 && !(ppc_cpu
& op
->deprecated
)
1686 && str_hash_insert (ppc_hash
, op
->name
, op
, 0) != NULL
)
1688 as_bad (_("duplicate %s"), op
->name
);
1693 if ((ppc_cpu
& PPC_OPCODE_ANY
) != 0)
1694 for (op
= powerpc_opcodes
; op
< op_end
; op
++)
1695 str_hash_insert (ppc_hash
, op
->name
, op
, 0);
1697 op_end
= prefix_opcodes
+ prefix_num_opcodes
;
1698 for (op
= prefix_opcodes
; op
< op_end
; op
++)
1700 if (ENABLE_CHECKING
)
1702 unsigned int new_opcode
= PPC_PREFIX_SEG (op
[0].opcode
);
1704 #ifdef PRINT_OPCODE_TABLE
1705 printf ("%-14s\t#%04u\tmajor op/2: 0x%x\top: 0x%llx\tmask: 0x%llx\tflags: 0x%llx\n",
1706 op
->name
, (unsigned int) (op
- prefix_opcodes
),
1707 new_opcode
, (unsigned long long) op
->opcode
,
1708 (unsigned long long) op
->mask
, (unsigned long long) op
->flags
);
1711 /* The major opcodes had better be sorted. Code in the disassembler
1712 assumes the insns are sorted according to major opcode. */
1713 if (op
!= prefix_opcodes
1714 && new_opcode
< PPC_PREFIX_SEG (op
[-1].opcode
))
1716 as_bad (_("major opcode is not sorted for %s"), op
->name
);
1719 bad_insn
|= insn_validate (op
);
1722 if ((ppc_cpu
& op
->flags
) != 0
1723 && !(ppc_cpu
& op
->deprecated
)
1724 && str_hash_insert (ppc_hash
, op
->name
, op
, 0) != NULL
)
1726 as_bad (_("duplicate %s"), op
->name
);
1731 if ((ppc_cpu
& PPC_OPCODE_ANY
) != 0)
1732 for (op
= prefix_opcodes
; op
< op_end
; op
++)
1733 str_hash_insert (ppc_hash
, op
->name
, op
, 0);
1735 op_end
= vle_opcodes
+ vle_num_opcodes
;
1736 for (op
= vle_opcodes
; op
< op_end
; op
++)
1738 if (ENABLE_CHECKING
)
1740 unsigned new_seg
= VLE_OP_TO_SEG (VLE_OP (op
[0].opcode
, op
[0].mask
));
1742 #ifdef PRINT_OPCODE_TABLE
1743 printf ("%-14s\t#%04u\tmajor op: 0x%x\top: 0x%llx\tmask: 0x%llx\tflags: 0x%llx\n",
1744 op
->name
, (unsigned int) (op
- vle_opcodes
),
1745 (unsigned int) new_seg
, (unsigned long long) op
->opcode
,
1746 (unsigned long long) op
->mask
, (unsigned long long) op
->flags
);
1749 /* The major opcodes had better be sorted. Code in the disassembler
1750 assumes the insns are sorted according to major opcode. */
1751 if (op
!= vle_opcodes
1752 && new_seg
< VLE_OP_TO_SEG (VLE_OP (op
[-1].opcode
, op
[-1].mask
)))
1754 as_bad (_("major opcode is not sorted for %s"), op
->name
);
1758 bad_insn
|= insn_validate (op
);
1761 if ((ppc_cpu
& op
->flags
) != 0
1762 && !(ppc_cpu
& op
->deprecated
)
1763 && str_hash_insert (ppc_hash
, op
->name
, op
, 0) != NULL
)
1765 as_bad (_("duplicate %s"), op
->name
);
1770 /* SPE2 instructions */
1771 if ((ppc_cpu
& PPC_OPCODE_SPE2
) == PPC_OPCODE_SPE2
)
1773 op_end
= spe2_opcodes
+ spe2_num_opcodes
;
1774 for (op
= spe2_opcodes
; op
< op_end
; op
++)
1776 if (ENABLE_CHECKING
)
1778 if (op
!= spe2_opcodes
)
1780 unsigned old_seg
, new_seg
;
1782 old_seg
= VLE_OP (op
[-1].opcode
, op
[-1].mask
);
1783 old_seg
= VLE_OP_TO_SEG (old_seg
);
1784 new_seg
= VLE_OP (op
[0].opcode
, op
[0].mask
);
1785 new_seg
= VLE_OP_TO_SEG (new_seg
);
1787 /* The major opcodes had better be sorted. Code in the
1788 disassembler assumes the insns are sorted according to
1790 if (new_seg
< old_seg
)
1792 as_bad (_("major opcode is not sorted for %s"), op
->name
);
1797 bad_insn
|= insn_validate (op
);
1800 if ((ppc_cpu
& op
->flags
) != 0
1801 && !(ppc_cpu
& op
->deprecated
)
1802 && str_hash_insert (ppc_hash
, op
->name
, op
, 0) != NULL
)
1804 as_bad (_("duplicate %s"), op
->name
);
1809 for (op
= spe2_opcodes
; op
< op_end
; op
++)
1810 str_hash_insert (ppc_hash
, op
->name
, op
, 0);
1813 /* Insert the macros into a hash table. */
1814 ppc_macro_hash
= str_htab_create ();
1816 macro_end
= powerpc_macros
+ powerpc_num_macros
;
1817 for (macro
= powerpc_macros
; macro
< macro_end
; macro
++)
1818 if (((macro
->flags
& ppc_cpu
) != 0
1819 || (ppc_cpu
& PPC_OPCODE_ANY
) != 0)
1820 && str_hash_insert (ppc_macro_hash
, macro
->name
, macro
, 0) != NULL
)
1822 as_bad (_("duplicate %s"), macro
->name
);
1830 /* This function is called when the assembler starts up. It is called
1831 after the options have been parsed and the output file has been
1839 ppc_cie_data_alignment
= ppc_obj64
? -8 : -4;
1840 ppc_dwarf2_line_min_insn_length
= (ppc_cpu
& PPC_OPCODE_VLE
) ? 2 : 4;
1843 /* Set the ELF flags if desired. */
1844 if (ppc_flags
&& !msolaris
)
1845 bfd_set_private_flags (stdoutput
, ppc_flags
);
1848 ppc_setup_opcodes ();
1850 /* Tell the main code what the endianness is if it is not overridden
1852 if (!set_target_endian
)
1854 set_target_endian
= 1;
1855 target_big_endian
= PPC_BIG_ENDIAN
;
1859 ppc_coff_debug_section
= coff_section_from_bfd_index (stdoutput
, N_DEBUG
);
1861 /* Create dummy symbols to serve as initial csects. This forces the
1862 text csects to precede the data csects. These symbols will not
1864 ppc_text_csects
= symbol_make ("dummy\001");
1865 symbol_get_tc (ppc_text_csects
)->within
= ppc_text_csects
;
1866 ppc_data_csects
= symbol_make ("dummy\001");
1867 symbol_get_tc (ppc_data_csects
)->within
= ppc_data_csects
;
1875 if (ppc_apuinfo_list
== NULL
)
1878 /* Ok, so write the section info out. We have this layout:
1882 0 8 length of "APUinfo\0"
1883 4 (n*4) number of APU's (4 bytes each)
1886 20 APU#1 first APU's info
1887 24 APU#2 second APU's info
1892 asection
*seg
= now_seg
;
1893 subsegT subseg
= now_subseg
;
1894 asection
*apuinfo_secp
= (asection
*) NULL
;
1897 /* Create the .PPC.EMB.apuinfo section. */
1898 apuinfo_secp
= subseg_new (APUINFO_SECTION_NAME
, 0);
1899 bfd_set_section_flags (apuinfo_secp
, SEC_HAS_CONTENTS
| SEC_READONLY
);
1902 md_number_to_chars (p
, (valueT
) 8, 4);
1905 md_number_to_chars (p
, (valueT
) ppc_apuinfo_num
* 4, 4);
1908 md_number_to_chars (p
, (valueT
) 2, 4);
1911 strcpy (p
, APUINFO_LABEL
);
1913 for (i
= 0; i
< ppc_apuinfo_num
; i
++)
1916 md_number_to_chars (p
, (valueT
) ppc_apuinfo_list
[i
], 4);
1919 frag_align (2, 0, 0);
1921 /* We probably can't restore the current segment, for there likely
1924 subseg_set (seg
, subseg
);
1929 /* Insert an operand value into an instruction. */
1932 ppc_insert_operand (uint64_t insn
,
1933 const struct powerpc_operand
*operand
,
1939 int64_t min
, max
, right
;
1941 max
= operand
->bitm
;
1945 if ((operand
->flags
& PPC_OPERAND_SIGNOPT
) != 0)
1947 /* Extend the allowed range for addis to [-32768, 65535].
1948 Similarly for cmpli and some VLE high part insns. For 64-bit
1949 it would be good to disable this for signed fields since the
1950 value is sign extended into the high 32 bits of the register.
1951 If the value is, say, an address, then we might care about
1952 the high bits. However, gcc as of 2014-06 uses unsigned
1953 values when loading the high part of 64-bit constants using
1955 min
= ~(max
>> 1) & -right
;
1957 else if ((operand
->flags
& PPC_OPERAND_SIGNED
) != 0)
1959 max
= (max
>> 1) & -right
;
1960 min
= ~max
& -right
;
1963 if ((operand
->flags
& PPC_OPERAND_PLUS1
) != 0)
1966 if ((operand
->flags
& PPC_OPERAND_NEGATIVE
) != 0)
1975 /* Some people write constants with the sign extension done by
1976 hand but only up to 32 bits. This shouldn't really be valid,
1977 but, to permit this code to assemble on a 64-bit host, we
1978 sign extend the 32-bit value to 64 bits if so doing makes the
1979 value valid. We only do this for operands that are 32-bits or
1982 && (operand
->bitm
& ~0xffffffffULL
) == 0
1983 && (val
- (1LL << 32)) >= min
1984 && (val
- (1LL << 32)) <= max
1985 && ((val
- (1LL << 32)) & (right
- 1)) == 0)
1986 val
= val
- (1LL << 32);
1988 /* Similarly, people write expressions like ~(1<<15), and expect
1989 this to be OK for a 32-bit unsigned value. */
1991 && (operand
->bitm
& ~0xffffffffULL
) == 0
1992 && (val
+ (1LL << 32)) >= min
1993 && (val
+ (1LL << 32)) <= max
1994 && ((val
+ (1LL << 32)) & (right
- 1)) == 0)
1995 val
= val
+ (1LL << 32);
1999 || (val
& (right
- 1)) != 0)
2000 as_bad_value_out_of_range (_("operand"), val
, min
, max
, file
, line
);
2003 if (operand
->insert
)
2008 insn
= (*operand
->insert
) (insn
, val
, cpu
, &errmsg
);
2009 if (errmsg
!= (const char *) NULL
)
2010 as_bad_where (file
, line
, "%s", errmsg
);
2012 else if (operand
->shift
>= 0)
2013 insn
|= (val
& operand
->bitm
) << operand
->shift
;
2015 insn
|= (val
& operand
->bitm
) >> -operand
->shift
;
2022 /* Parse @got, etc. and return the desired relocation. */
2023 static bfd_reloc_code_real_type
2024 ppc_elf_suffix (char **str_p
, expressionS
*exp_p
)
2028 unsigned int length
: 8;
2029 unsigned int valid32
: 1;
2030 unsigned int valid64
: 1;
2039 const struct map_bfd
*ptr
;
2041 #define MAP(str, reloc) { str, sizeof (str) - 1, 1, 1, reloc }
2042 #define MAP32(str, reloc) { str, sizeof (str) - 1, 1, 0, reloc }
2043 #define MAP64(str, reloc) { str, sizeof (str) - 1, 0, 1, reloc }
2045 static const struct map_bfd mapping
[] = {
2046 MAP ("l", BFD_RELOC_LO16
),
2047 MAP ("h", BFD_RELOC_HI16
),
2048 MAP ("ha", BFD_RELOC_HI16_S
),
2049 MAP ("brtaken", BFD_RELOC_PPC_B16_BRTAKEN
),
2050 MAP ("brntaken", BFD_RELOC_PPC_B16_BRNTAKEN
),
2051 MAP ("got", BFD_RELOC_16_GOTOFF
),
2052 MAP ("got@l", BFD_RELOC_LO16_GOTOFF
),
2053 MAP ("got@h", BFD_RELOC_HI16_GOTOFF
),
2054 MAP ("got@ha", BFD_RELOC_HI16_S_GOTOFF
),
2055 MAP ("plt@l", BFD_RELOC_LO16_PLTOFF
),
2056 MAP ("plt@h", BFD_RELOC_HI16_PLTOFF
),
2057 MAP ("plt@ha", BFD_RELOC_HI16_S_PLTOFF
),
2058 MAP ("copy", BFD_RELOC_PPC_COPY
),
2059 MAP ("globdat", BFD_RELOC_PPC_GLOB_DAT
),
2060 MAP ("sectoff", BFD_RELOC_16_BASEREL
),
2061 MAP ("sectoff@l", BFD_RELOC_LO16_BASEREL
),
2062 MAP ("sectoff@h", BFD_RELOC_HI16_BASEREL
),
2063 MAP ("sectoff@ha", BFD_RELOC_HI16_S_BASEREL
),
2064 MAP ("tls", BFD_RELOC_PPC_TLS
),
2065 MAP ("dtpmod", BFD_RELOC_PPC_DTPMOD
),
2066 MAP ("dtprel", BFD_RELOC_PPC_DTPREL
),
2067 MAP ("dtprel@l", BFD_RELOC_PPC_DTPREL16_LO
),
2068 MAP ("dtprel@h", BFD_RELOC_PPC_DTPREL16_HI
),
2069 MAP ("dtprel@ha", BFD_RELOC_PPC_DTPREL16_HA
),
2070 MAP ("tprel", BFD_RELOC_PPC_TPREL
),
2071 MAP ("tprel@l", BFD_RELOC_PPC_TPREL16_LO
),
2072 MAP ("tprel@h", BFD_RELOC_PPC_TPREL16_HI
),
2073 MAP ("tprel@ha", BFD_RELOC_PPC_TPREL16_HA
),
2074 MAP ("got@tlsgd", BFD_RELOC_PPC_GOT_TLSGD16
),
2075 MAP ("got@tlsgd@l", BFD_RELOC_PPC_GOT_TLSGD16_LO
),
2076 MAP ("got@tlsgd@h", BFD_RELOC_PPC_GOT_TLSGD16_HI
),
2077 MAP ("got@tlsgd@ha", BFD_RELOC_PPC_GOT_TLSGD16_HA
),
2078 MAP ("got@tlsld", BFD_RELOC_PPC_GOT_TLSLD16
),
2079 MAP ("got@tlsld@l", BFD_RELOC_PPC_GOT_TLSLD16_LO
),
2080 MAP ("got@tlsld@h", BFD_RELOC_PPC_GOT_TLSLD16_HI
),
2081 MAP ("got@tlsld@ha", BFD_RELOC_PPC_GOT_TLSLD16_HA
),
2082 MAP ("got@dtprel", BFD_RELOC_PPC_GOT_DTPREL16
),
2083 MAP ("got@dtprel@l", BFD_RELOC_PPC_GOT_DTPREL16_LO
),
2084 MAP ("got@dtprel@h", BFD_RELOC_PPC_GOT_DTPREL16_HI
),
2085 MAP ("got@dtprel@ha", BFD_RELOC_PPC_GOT_DTPREL16_HA
),
2086 MAP ("got@tprel", BFD_RELOC_PPC_GOT_TPREL16
),
2087 MAP ("got@tprel@l", BFD_RELOC_PPC_GOT_TPREL16_LO
),
2088 MAP ("got@tprel@h", BFD_RELOC_PPC_GOT_TPREL16_HI
),
2089 MAP ("got@tprel@ha", BFD_RELOC_PPC_GOT_TPREL16_HA
),
2090 MAP32 ("fixup", BFD_RELOC_CTOR
),
2091 MAP32 ("plt", BFD_RELOC_24_PLT_PCREL
),
2092 MAP32 ("pltrel24", BFD_RELOC_24_PLT_PCREL
),
2093 MAP32 ("local24pc", BFD_RELOC_PPC_LOCAL24PC
),
2094 MAP32 ("local", BFD_RELOC_PPC_LOCAL24PC
),
2095 MAP32 ("pltrel", BFD_RELOC_32_PLT_PCREL
),
2096 MAP32 ("sdarel", BFD_RELOC_GPREL16
),
2097 MAP32 ("sdarel@l", BFD_RELOC_PPC_VLE_SDAREL_LO16A
),
2098 MAP32 ("sdarel@h", BFD_RELOC_PPC_VLE_SDAREL_HI16A
),
2099 MAP32 ("sdarel@ha", BFD_RELOC_PPC_VLE_SDAREL_HA16A
),
2100 MAP32 ("naddr", BFD_RELOC_PPC_EMB_NADDR32
),
2101 MAP32 ("naddr16", BFD_RELOC_PPC_EMB_NADDR16
),
2102 MAP32 ("naddr@l", BFD_RELOC_PPC_EMB_NADDR16_LO
),
2103 MAP32 ("naddr@h", BFD_RELOC_PPC_EMB_NADDR16_HI
),
2104 MAP32 ("naddr@ha", BFD_RELOC_PPC_EMB_NADDR16_HA
),
2105 MAP32 ("sdai16", BFD_RELOC_PPC_EMB_SDAI16
),
2106 MAP32 ("sda2rel", BFD_RELOC_PPC_EMB_SDA2REL
),
2107 MAP32 ("sda2i16", BFD_RELOC_PPC_EMB_SDA2I16
),
2108 MAP32 ("sda21", BFD_RELOC_PPC_EMB_SDA21
),
2109 MAP32 ("sda21@l", BFD_RELOC_PPC_VLE_SDA21_LO
),
2110 MAP32 ("mrkref", BFD_RELOC_PPC_EMB_MRKREF
),
2111 MAP32 ("relsect", BFD_RELOC_PPC_EMB_RELSEC16
),
2112 MAP32 ("relsect@l", BFD_RELOC_PPC_EMB_RELST_LO
),
2113 MAP32 ("relsect@h", BFD_RELOC_PPC_EMB_RELST_HI
),
2114 MAP32 ("relsect@ha", BFD_RELOC_PPC_EMB_RELST_HA
),
2115 MAP32 ("bitfld", BFD_RELOC_PPC_EMB_BIT_FLD
),
2116 MAP32 ("relsda", BFD_RELOC_PPC_EMB_RELSDA
),
2117 MAP32 ("xgot", BFD_RELOC_PPC_TOC16
),
2118 MAP64 ("high", BFD_RELOC_PPC64_ADDR16_HIGH
),
2119 MAP64 ("higha", BFD_RELOC_PPC64_ADDR16_HIGHA
),
2120 MAP64 ("higher", BFD_RELOC_PPC64_HIGHER
),
2121 MAP64 ("highera", BFD_RELOC_PPC64_HIGHER_S
),
2122 MAP64 ("highest", BFD_RELOC_PPC64_HIGHEST
),
2123 MAP64 ("highesta", BFD_RELOC_PPC64_HIGHEST_S
),
2124 MAP64 ("tocbase", BFD_RELOC_PPC64_TOC
),
2125 MAP64 ("toc", BFD_RELOC_PPC_TOC16
),
2126 MAP64 ("toc@l", BFD_RELOC_PPC64_TOC16_LO
),
2127 MAP64 ("toc@h", BFD_RELOC_PPC64_TOC16_HI
),
2128 MAP64 ("toc@ha", BFD_RELOC_PPC64_TOC16_HA
),
2129 MAP64 ("dtprel@high", BFD_RELOC_PPC64_DTPREL16_HIGH
),
2130 MAP64 ("dtprel@higha", BFD_RELOC_PPC64_DTPREL16_HIGHA
),
2131 MAP64 ("dtprel@higher", BFD_RELOC_PPC64_DTPREL16_HIGHER
),
2132 MAP64 ("dtprel@highera", BFD_RELOC_PPC64_DTPREL16_HIGHERA
),
2133 MAP64 ("dtprel@highest", BFD_RELOC_PPC64_DTPREL16_HIGHEST
),
2134 MAP64 ("dtprel@highesta", BFD_RELOC_PPC64_DTPREL16_HIGHESTA
),
2135 MAP64 ("localentry", BFD_RELOC_PPC64_ADDR64_LOCAL
),
2136 MAP64 ("tprel@high", BFD_RELOC_PPC64_TPREL16_HIGH
),
2137 MAP64 ("tprel@higha", BFD_RELOC_PPC64_TPREL16_HIGHA
),
2138 MAP64 ("tprel@higher", BFD_RELOC_PPC64_TPREL16_HIGHER
),
2139 MAP64 ("tprel@highera", BFD_RELOC_PPC64_TPREL16_HIGHERA
),
2140 MAP64 ("tprel@highest", BFD_RELOC_PPC64_TPREL16_HIGHEST
),
2141 MAP64 ("tprel@highesta", BFD_RELOC_PPC64_TPREL16_HIGHESTA
),
2142 MAP64 ("notoc", BFD_RELOC_PPC64_REL24_NOTOC
),
2143 MAP64 ("pcrel", BFD_RELOC_PPC64_PCREL34
),
2144 MAP64 ("got@pcrel", BFD_RELOC_PPC64_GOT_PCREL34
),
2145 MAP64 ("plt@pcrel", BFD_RELOC_PPC64_PLT_PCREL34
),
2146 MAP64 ("tls@pcrel", BFD_RELOC_PPC64_TLS_PCREL
),
2147 MAP64 ("got@tlsgd@pcrel", BFD_RELOC_PPC64_GOT_TLSGD_PCREL34
),
2148 MAP64 ("got@tlsld@pcrel", BFD_RELOC_PPC64_GOT_TLSLD_PCREL34
),
2149 MAP64 ("got@tprel@pcrel", BFD_RELOC_PPC64_GOT_TPREL_PCREL34
),
2150 MAP64 ("got@dtprel@pcrel", BFD_RELOC_PPC64_GOT_DTPREL_PCREL34
),
2151 MAP64 ("higher34", BFD_RELOC_PPC64_ADDR16_HIGHER34
),
2152 MAP64 ("highera34", BFD_RELOC_PPC64_ADDR16_HIGHERA34
),
2153 MAP64 ("highest34", BFD_RELOC_PPC64_ADDR16_HIGHEST34
),
2154 MAP64 ("highesta34", BFD_RELOC_PPC64_ADDR16_HIGHESTA34
),
2155 { (char *) 0, 0, 0, 0, BFD_RELOC_NONE
}
2159 return BFD_RELOC_NONE
;
2161 for (ch
= *str
, str2
= ident
;
2162 (str2
< ident
+ sizeof (ident
) - 1
2163 && (ISALNUM (ch
) || ch
== '@'));
2166 *str2
++ = TOLOWER (ch
);
2173 for (ptr
= &mapping
[0]; ptr
->length
> 0; ptr
++)
2174 if (ch
== ptr
->string
[0]
2175 && len
== ptr
->length
2176 && memcmp (ident
, ptr
->string
, ptr
->length
) == 0
2177 && (ppc_obj64
? ptr
->valid64
: ptr
->valid32
))
2179 int reloc
= ptr
->reloc
;
2181 if (!ppc_obj64
&& exp_p
->X_add_number
!= 0)
2185 case BFD_RELOC_16_GOTOFF
:
2186 case BFD_RELOC_LO16_GOTOFF
:
2187 case BFD_RELOC_HI16_GOTOFF
:
2188 case BFD_RELOC_HI16_S_GOTOFF
:
2189 as_warn (_("symbol+offset@%s means symbol@%s+offset"),
2190 ptr
->string
, ptr
->string
);
2193 case BFD_RELOC_PPC_GOT_TLSGD16
:
2194 case BFD_RELOC_PPC_GOT_TLSGD16_LO
:
2195 case BFD_RELOC_PPC_GOT_TLSGD16_HI
:
2196 case BFD_RELOC_PPC_GOT_TLSGD16_HA
:
2197 case BFD_RELOC_PPC_GOT_TLSLD16
:
2198 case BFD_RELOC_PPC_GOT_TLSLD16_LO
:
2199 case BFD_RELOC_PPC_GOT_TLSLD16_HI
:
2200 case BFD_RELOC_PPC_GOT_TLSLD16_HA
:
2201 case BFD_RELOC_PPC_GOT_DTPREL16
:
2202 case BFD_RELOC_PPC_GOT_DTPREL16_LO
:
2203 case BFD_RELOC_PPC_GOT_DTPREL16_HI
:
2204 case BFD_RELOC_PPC_GOT_DTPREL16_HA
:
2205 case BFD_RELOC_PPC_GOT_TPREL16
:
2206 case BFD_RELOC_PPC_GOT_TPREL16_LO
:
2207 case BFD_RELOC_PPC_GOT_TPREL16_HI
:
2208 case BFD_RELOC_PPC_GOT_TPREL16_HA
:
2209 as_bad (_("symbol+offset@%s not supported"), ptr
->string
);
2214 /* Now check for identifier@suffix+constant. */
2215 if (*str
== '-' || *str
== '+')
2217 char *orig_line
= input_line_pointer
;
2218 expressionS new_exp
;
2220 input_line_pointer
= str
;
2221 expression (&new_exp
);
2222 if (new_exp
.X_op
== O_constant
)
2224 exp_p
->X_add_number
+= new_exp
.X_add_number
;
2225 str
= input_line_pointer
;
2228 if (&input_line_pointer
!= str_p
)
2229 input_line_pointer
= orig_line
;
2233 if (reloc
== (int) BFD_RELOC_PPC64_TOC
2234 && exp_p
->X_op
== O_symbol
2235 && strcmp (S_GET_NAME (exp_p
->X_add_symbol
), ".TOC.") == 0)
2237 /* Change the symbol so that the dummy .TOC. symbol can be
2238 omitted from the object file. */
2239 exp_p
->X_add_symbol
= &abs_symbol
;
2242 return (bfd_reloc_code_real_type
) reloc
;
2245 return BFD_RELOC_NONE
;
2248 /* Support @got, etc. on constants emitted via .short, .int etc. */
2250 bfd_reloc_code_real_type
2251 ppc_elf_parse_cons (expressionS
*exp
, unsigned int nbytes
)
2254 if (nbytes
>= 2 && *input_line_pointer
== '@')
2255 return ppc_elf_suffix (&input_line_pointer
, exp
);
2256 return BFD_RELOC_NONE
;
2259 /* Warn when emitting data to code sections, unless we are emitting
2260 a relocation that ld --ppc476-workaround uses to recognise data
2261 *and* there was an unconditional branch prior to the data. */
2264 ppc_elf_cons_fix_check (expressionS
*exp ATTRIBUTE_UNUSED
,
2265 unsigned int nbytes
, fixS
*fix
)
2268 && (now_seg
->flags
& SEC_CODE
) != 0
2271 || !(fix
->fx_r_type
== BFD_RELOC_32
2272 || fix
->fx_r_type
== BFD_RELOC_CTOR
2273 || fix
->fx_r_type
== BFD_RELOC_32_PCREL
)
2274 || !(last_seg
== now_seg
&& last_subseg
== now_subseg
)
2275 || !((last_insn
& (0x3f << 26)) == (18u << 26)
2276 || ((last_insn
& (0x3f << 26)) == (16u << 26)
2277 && (last_insn
& (0x14 << 21)) == (0x14 << 21))
2278 || ((last_insn
& (0x3f << 26)) == (19u << 26)
2279 && (last_insn
& (0x3ff << 1)) == (16u << 1)
2280 && (last_insn
& (0x14 << 21)) == (0x14 << 21)))))
2282 /* Flag that we've warned. */
2286 as_warn (_("data in executable section"));
2290 /* Solaris pseduo op to change to the .rodata section. */
2292 ppc_elf_rdata (int xxx
)
2294 char *save_line
= input_line_pointer
;
2295 static char section
[] = ".rodata\n";
2297 /* Just pretend this is .section .rodata */
2298 input_line_pointer
= section
;
2299 obj_elf_section (xxx
);
2301 input_line_pointer
= save_line
;
2304 /* Pseudo op to make file scope bss items. */
2306 ppc_elf_lcomm (int xxx ATTRIBUTE_UNUSED
)
2319 c
= get_symbol_name (&name
);
2321 /* Just after name is now '\0'. */
2322 p
= input_line_pointer
;
2324 SKIP_WHITESPACE_AFTER_NAME ();
2325 if (*input_line_pointer
!= ',')
2327 as_bad (_("expected comma after symbol-name: rest of line ignored."));
2328 ignore_rest_of_line ();
2332 input_line_pointer
++; /* skip ',' */
2333 if ((size
= get_absolute_expression ()) < 0)
2335 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) size
);
2336 ignore_rest_of_line ();
2340 /* The third argument to .lcomm is the alignment. */
2341 if (*input_line_pointer
!= ',')
2345 ++input_line_pointer
;
2346 align
= get_absolute_expression ();
2349 as_warn (_("ignoring bad alignment"));
2355 symbolP
= symbol_find_or_make (name
);
2358 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
2360 as_bad (_("ignoring attempt to re-define symbol `%s'."),
2361 S_GET_NAME (symbolP
));
2362 ignore_rest_of_line ();
2366 if (S_GET_VALUE (symbolP
) && S_GET_VALUE (symbolP
) != (valueT
) size
)
2368 as_bad (_("length of .lcomm \"%s\" is already %ld. Not changed to %ld."),
2369 S_GET_NAME (symbolP
),
2370 (long) S_GET_VALUE (symbolP
),
2373 ignore_rest_of_line ();
2379 old_subsec
= now_subseg
;
2382 /* Convert to a power of 2 alignment. */
2383 for (align2
= 0; (align
& 1) == 0; align
>>= 1, ++align2
);
2386 as_bad (_("common alignment not a power of 2"));
2387 ignore_rest_of_line ();
2394 record_alignment (bss_section
, align2
);
2395 subseg_set (bss_section
, 1);
2397 frag_align (align2
, 0, 0);
2398 if (S_GET_SEGMENT (symbolP
) == bss_section
)
2399 symbol_get_frag (symbolP
)->fr_symbol
= 0;
2400 symbol_set_frag (symbolP
, frag_now
);
2401 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
, size
,
2404 S_SET_SIZE (symbolP
, size
);
2405 S_SET_SEGMENT (symbolP
, bss_section
);
2406 subseg_set (old_sec
, old_subsec
);
2407 demand_empty_rest_of_line ();
2410 /* Pseudo op to set symbol local entry point. */
2412 ppc_elf_localentry (int ignore ATTRIBUTE_UNUSED
)
2415 char c
= get_symbol_name (&name
);
2420 elf_symbol_type
*elfsym
;
2422 p
= input_line_pointer
;
2424 SKIP_WHITESPACE_AFTER_NAME ();
2425 if (*input_line_pointer
!= ',')
2428 as_bad (_("expected comma after name `%s' in .localentry directive"),
2431 ignore_rest_of_line ();
2434 input_line_pointer
++;
2436 if (exp
.X_op
== O_absent
)
2438 as_bad (_("missing expression in .localentry directive"));
2439 exp
.X_op
= O_constant
;
2440 exp
.X_add_number
= 0;
2443 sym
= symbol_find_or_make (name
);
2446 if (resolve_expression (&exp
)
2447 && exp
.X_op
== O_constant
)
2449 unsigned int encoded
, ok
;
2452 if (exp
.X_add_number
== 1 || exp
.X_add_number
== 7)
2453 encoded
= exp
.X_add_number
<< STO_PPC64_LOCAL_BIT
;
2456 encoded
= PPC64_SET_LOCAL_ENTRY_OFFSET (exp
.X_add_number
);
2457 if (exp
.X_add_number
!= (offsetT
) PPC64_LOCAL_ENTRY_OFFSET (encoded
))
2459 as_bad (_(".localentry expression for `%s' "
2460 "is not a valid power of 2"), S_GET_NAME (sym
));
2466 bfdsym
= symbol_get_bfdsym (sym
);
2467 elfsym
= elf_symbol_from (bfdsym
);
2468 gas_assert (elfsym
);
2469 elfsym
->internal_elf_sym
.st_other
&= ~STO_PPC64_LOCAL_MASK
;
2470 elfsym
->internal_elf_sym
.st_other
|= encoded
;
2471 if (ppc_abiversion
== 0)
2476 as_bad (_(".localentry expression for `%s' "
2477 "does not evaluate to a constant"), S_GET_NAME (sym
));
2479 demand_empty_rest_of_line ();
2482 /* Pseudo op to set ABI version. */
2484 ppc_elf_abiversion (int ignore ATTRIBUTE_UNUSED
)
2489 if (exp
.X_op
== O_absent
)
2491 as_bad (_("missing expression in .abiversion directive"));
2492 exp
.X_op
= O_constant
;
2493 exp
.X_add_number
= 0;
2496 if (resolve_expression (&exp
)
2497 && exp
.X_op
== O_constant
)
2498 ppc_abiversion
= exp
.X_add_number
;
2500 as_bad (_(".abiversion expression does not evaluate to a constant"));
2501 demand_empty_rest_of_line ();
2504 /* Parse a .gnu_attribute directive. */
2506 ppc_elf_gnu_attribute (int ignored ATTRIBUTE_UNUSED
)
2508 int tag
= obj_elf_vendor_attribute (OBJ_ATTR_GNU
);
2510 /* Check validity of defined powerpc tags. */
2511 if (tag
== Tag_GNU_Power_ABI_FP
2512 || tag
== Tag_GNU_Power_ABI_Vector
2513 || tag
== Tag_GNU_Power_ABI_Struct_Return
)
2517 val
= bfd_elf_get_obj_attr_int (stdoutput
, OBJ_ATTR_GNU
, tag
);
2519 if ((tag
== Tag_GNU_Power_ABI_FP
&& val
> 15)
2520 || (tag
== Tag_GNU_Power_ABI_Vector
&& val
> 3)
2521 || (tag
== Tag_GNU_Power_ABI_Struct_Return
&& val
> 2))
2522 as_warn (_("unknown .gnu_attribute value"));
2526 /* Set ABI version in output file. */
2530 if (ppc_obj64
&& ppc_abiversion
!= 0)
2532 elf_elfheader (stdoutput
)->e_flags
&= ~EF_PPC64_ABI
;
2533 elf_elfheader (stdoutput
)->e_flags
|= ppc_abiversion
& EF_PPC64_ABI
;
2535 /* Any selection of opcodes based on ppc_cpu after gas has finished
2536 parsing the file is invalid. md_apply_fix and ppc_handle_align
2537 must select opcodes based on the machine in force at the point
2538 where the fixup or alignment frag was created, not the machine in
2539 force at the end of file. */
2543 /* Validate any relocations emitted for -mrelocatable, possibly adding
2544 fixups for word relocations in writable segments, so we can adjust
2547 ppc_elf_validate_fix (fixS
*fixp
, segT seg
)
2549 if (fixp
->fx_done
|| fixp
->fx_pcrel
)
2558 case SHLIB_MRELOCATABLE
:
2559 if (fixp
->fx_r_type
!= BFD_RELOC_16_GOTOFF
2560 && fixp
->fx_r_type
!= BFD_RELOC_HI16_GOTOFF
2561 && fixp
->fx_r_type
!= BFD_RELOC_LO16_GOTOFF
2562 && fixp
->fx_r_type
!= BFD_RELOC_HI16_S_GOTOFF
2563 && fixp
->fx_r_type
!= BFD_RELOC_16_BASEREL
2564 && fixp
->fx_r_type
!= BFD_RELOC_LO16_BASEREL
2565 && fixp
->fx_r_type
!= BFD_RELOC_HI16_BASEREL
2566 && fixp
->fx_r_type
!= BFD_RELOC_HI16_S_BASEREL
2567 && (seg
->flags
& SEC_LOAD
) != 0
2568 && strcmp (segment_name (seg
), ".got2") != 0
2569 && strcmp (segment_name (seg
), ".dtors") != 0
2570 && strcmp (segment_name (seg
), ".ctors") != 0
2571 && strcmp (segment_name (seg
), ".fixup") != 0
2572 && strcmp (segment_name (seg
), ".gcc_except_table") != 0
2573 && strcmp (segment_name (seg
), ".eh_frame") != 0
2574 && strcmp (segment_name (seg
), ".ex_shared") != 0)
2576 if ((seg
->flags
& (SEC_READONLY
| SEC_CODE
)) != 0
2577 || fixp
->fx_r_type
!= BFD_RELOC_CTOR
)
2579 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2580 _("relocation cannot be done when using -mrelocatable"));
2587 /* Prevent elf_frob_file_before_adjust removing a weak undefined
2588 function descriptor sym if the corresponding code sym is used. */
2591 ppc_frob_file_before_adjust (void)
2599 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
2605 name
= S_GET_NAME (symp
);
2609 if (! S_IS_WEAK (symp
)
2610 || S_IS_DEFINED (symp
))
2613 dotname
= concat (".", name
, (char *) NULL
);
2614 dotsym
= symbol_find_noref (dotname
, 1);
2616 if (dotsym
!= NULL
&& (symbol_used_p (dotsym
)
2617 || symbol_used_in_reloc_p (dotsym
)))
2618 symbol_mark_used (symp
);
2622 toc
= bfd_get_section_by_name (stdoutput
, ".toc");
2624 && toc_reloc_types
!= has_large_toc_reloc
2625 && bfd_section_size (toc
) > 0x10000)
2626 as_warn (_("TOC section size exceeds 64k"));
2629 /* .TOC. used in an opd entry as .TOC.@tocbase doesn't need to be
2630 emitted. Other uses of .TOC. will cause the symbol to be marked
2631 with BSF_KEEP in md_apply_fix. */
2634 ppc_elf_adjust_symtab (void)
2639 symp
= symbol_find (".TOC.");
2642 asymbol
*bsym
= symbol_get_bfdsym (symp
);
2643 if ((bsym
->flags
& BSF_KEEP
) == 0)
2644 symbol_remove (symp
, &symbol_rootP
, &symbol_lastP
);
2648 #endif /* OBJ_ELF */
2650 #if defined (OBJ_XCOFF) || defined (OBJ_ELF)
2651 /* See whether a symbol is in the TOC section. */
2654 ppc_is_toc_sym (symbolS
*sym
)
2657 return (symbol_get_tc (sym
)->symbol_class
== XMC_TC
2658 || symbol_get_tc (sym
)->symbol_class
== XMC_TC0
);
2661 const char *sname
= segment_name (S_GET_SEGMENT (sym
));
2663 return strcmp (sname
, ".toc") == 0;
2665 return strcmp (sname
, ".got") == 0;
2668 #endif /* defined (OBJ_XCOFF) || defined (OBJ_ELF) */
2672 #define APUID(a,v) ((((a) & 0xffff) << 16) | ((v) & 0xffff))
2674 ppc_apuinfo_section_add (unsigned int apu
, unsigned int version
)
2678 /* Check we don't already exist. */
2679 for (i
= 0; i
< ppc_apuinfo_num
; i
++)
2680 if (ppc_apuinfo_list
[i
] == APUID (apu
, version
))
2683 if (ppc_apuinfo_num
== ppc_apuinfo_num_alloc
)
2685 if (ppc_apuinfo_num_alloc
== 0)
2687 ppc_apuinfo_num_alloc
= 4;
2688 ppc_apuinfo_list
= XNEWVEC (unsigned long, ppc_apuinfo_num_alloc
);
2692 ppc_apuinfo_num_alloc
+= 4;
2693 ppc_apuinfo_list
= XRESIZEVEC (unsigned long, ppc_apuinfo_list
,
2694 ppc_apuinfo_num_alloc
);
2697 ppc_apuinfo_list
[ppc_apuinfo_num
++] = APUID (apu
, version
);
2702 /* Various frobbings of labels and their addresses. */
2704 /* Symbols labelling the current insn. */
2705 struct insn_label_list
2707 struct insn_label_list
*next
;
2711 static struct insn_label_list
*insn_labels
;
2712 static struct insn_label_list
*free_insn_labels
;
2715 ppc_record_label (symbolS
*sym
)
2717 struct insn_label_list
*l
;
2719 if (free_insn_labels
== NULL
)
2720 l
= XNEW (struct insn_label_list
);
2723 l
= free_insn_labels
;
2724 free_insn_labels
= l
->next
;
2728 l
->next
= insn_labels
;
2733 ppc_clear_labels (void)
2735 while (insn_labels
!= NULL
)
2737 struct insn_label_list
*l
= insn_labels
;
2738 insn_labels
= l
->next
;
2739 l
->next
= free_insn_labels
;
2740 free_insn_labels
= l
;
2745 ppc_start_line_hook (void)
2747 ppc_clear_labels ();
2751 ppc_new_dot_label (symbolS
*sym
)
2753 ppc_record_label (sym
);
2755 /* Anchor this label to the current csect for relocations. */
2756 symbol_get_tc (sym
)->within
= ppc_current_csect
;
2761 ppc_frob_label (symbolS
*sym
)
2763 ppc_record_label (sym
);
2766 /* Set the class of a label based on where it is defined. This handles
2767 symbols without suffixes. Also, move the symbol so that it follows
2768 the csect symbol. */
2769 if (ppc_current_csect
!= (symbolS
*) NULL
)
2771 if (symbol_get_tc (sym
)->symbol_class
== -1)
2772 symbol_get_tc (sym
)->symbol_class
= symbol_get_tc (ppc_current_csect
)->symbol_class
;
2774 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
2775 symbol_append (sym
, symbol_get_tc (ppc_current_csect
)->within
,
2776 &symbol_rootP
, &symbol_lastP
);
2777 symbol_get_tc (ppc_current_csect
)->within
= sym
;
2778 symbol_get_tc (sym
)->within
= ppc_current_csect
;
2783 dwarf2_emit_label (sym
);
2787 /* We need to keep a list of fixups. We can't simply generate them as
2788 we go, because that would require us to first create the frag, and
2789 that would screw up references to ``.''. */
2795 bfd_reloc_code_real_type reloc
;
2798 #define MAX_INSN_FIXUPS (5)
2800 /* Return the field size operated on by RELOC, and whether it is
2801 pc-relative in PC_RELATIVE. */
2804 fixup_size (bfd_reloc_code_real_type reloc
, bfd_boolean
*pc_relative
)
2806 unsigned int size
= 0;
2807 bfd_boolean pcrel
= FALSE
;
2811 /* This switch statement must handle all BFD_RELOC values
2812 possible in instruction fixups. As is, it handles all
2813 BFD_RELOC values used in bfd/elf64-ppc.c, bfd/elf32-ppc.c,
2814 bfd/coff-rs6000.c and bfd/coff64-rs6000.c.
2815 Overkill since data and marker relocs need not be handled
2816 here, but this way we can be sure a needed fixup reloc isn't
2817 accidentally omitted. */
2818 case BFD_RELOC_PPC_EMB_MRKREF
:
2819 case BFD_RELOC_VTABLE_ENTRY
:
2820 case BFD_RELOC_VTABLE_INHERIT
:
2828 case BFD_RELOC_16_BASEREL
:
2829 case BFD_RELOC_16_GOTOFF
:
2830 case BFD_RELOC_GPREL16
:
2831 case BFD_RELOC_HI16
:
2832 case BFD_RELOC_HI16_BASEREL
:
2833 case BFD_RELOC_HI16_GOTOFF
:
2834 case BFD_RELOC_HI16_PLTOFF
:
2835 case BFD_RELOC_HI16_S
:
2836 case BFD_RELOC_HI16_S_BASEREL
:
2837 case BFD_RELOC_HI16_S_GOTOFF
:
2838 case BFD_RELOC_HI16_S_PLTOFF
:
2839 case BFD_RELOC_LO16
:
2840 case BFD_RELOC_LO16_BASEREL
:
2841 case BFD_RELOC_LO16_GOTOFF
:
2842 case BFD_RELOC_LO16_PLTOFF
:
2843 case BFD_RELOC_PPC64_ADDR16_DS
:
2844 case BFD_RELOC_PPC64_ADDR16_HIGH
:
2845 case BFD_RELOC_PPC64_ADDR16_HIGHA
:
2846 case BFD_RELOC_PPC64_ADDR16_HIGHER34
:
2847 case BFD_RELOC_PPC64_ADDR16_HIGHERA34
:
2848 case BFD_RELOC_PPC64_ADDR16_HIGHEST34
:
2849 case BFD_RELOC_PPC64_ADDR16_HIGHESTA34
:
2850 case BFD_RELOC_PPC64_ADDR16_LO_DS
:
2851 case BFD_RELOC_PPC64_DTPREL16_DS
:
2852 case BFD_RELOC_PPC64_DTPREL16_HIGH
:
2853 case BFD_RELOC_PPC64_DTPREL16_HIGHA
:
2854 case BFD_RELOC_PPC64_DTPREL16_HIGHER
:
2855 case BFD_RELOC_PPC64_DTPREL16_HIGHERA
:
2856 case BFD_RELOC_PPC64_DTPREL16_HIGHEST
:
2857 case BFD_RELOC_PPC64_DTPREL16_HIGHESTA
:
2858 case BFD_RELOC_PPC64_DTPREL16_LO_DS
:
2859 case BFD_RELOC_PPC64_GOT16_DS
:
2860 case BFD_RELOC_PPC64_GOT16_LO_DS
:
2861 case BFD_RELOC_PPC64_HIGHER
:
2862 case BFD_RELOC_PPC64_HIGHER_S
:
2863 case BFD_RELOC_PPC64_HIGHEST
:
2864 case BFD_RELOC_PPC64_HIGHEST_S
:
2865 case BFD_RELOC_PPC64_PLT16_LO_DS
:
2866 case BFD_RELOC_PPC64_PLTGOT16
:
2867 case BFD_RELOC_PPC64_PLTGOT16_DS
:
2868 case BFD_RELOC_PPC64_PLTGOT16_HA
:
2869 case BFD_RELOC_PPC64_PLTGOT16_HI
:
2870 case BFD_RELOC_PPC64_PLTGOT16_LO
:
2871 case BFD_RELOC_PPC64_PLTGOT16_LO_DS
:
2872 case BFD_RELOC_PPC64_SECTOFF_DS
:
2873 case BFD_RELOC_PPC64_SECTOFF_LO_DS
:
2874 case BFD_RELOC_PPC64_TOC16_DS
:
2875 case BFD_RELOC_PPC64_TOC16_HA
:
2876 case BFD_RELOC_PPC64_TOC16_HI
:
2877 case BFD_RELOC_PPC64_TOC16_LO
:
2878 case BFD_RELOC_PPC64_TOC16_LO_DS
:
2879 case BFD_RELOC_PPC64_TPREL16_DS
:
2880 case BFD_RELOC_PPC64_TPREL16_HIGH
:
2881 case BFD_RELOC_PPC64_TPREL16_HIGHA
:
2882 case BFD_RELOC_PPC64_TPREL16_HIGHER
:
2883 case BFD_RELOC_PPC64_TPREL16_HIGHERA
:
2884 case BFD_RELOC_PPC64_TPREL16_HIGHEST
:
2885 case BFD_RELOC_PPC64_TPREL16_HIGHESTA
:
2886 case BFD_RELOC_PPC64_TPREL16_LO_DS
:
2888 case BFD_RELOC_PPC_BA16
:
2890 case BFD_RELOC_PPC_DTPREL16
:
2891 case BFD_RELOC_PPC_DTPREL16_HA
:
2892 case BFD_RELOC_PPC_DTPREL16_HI
:
2893 case BFD_RELOC_PPC_DTPREL16_LO
:
2894 case BFD_RELOC_PPC_EMB_NADDR16
:
2895 case BFD_RELOC_PPC_EMB_NADDR16_HA
:
2896 case BFD_RELOC_PPC_EMB_NADDR16_HI
:
2897 case BFD_RELOC_PPC_EMB_NADDR16_LO
:
2898 case BFD_RELOC_PPC_EMB_RELSDA
:
2899 case BFD_RELOC_PPC_EMB_RELSEC16
:
2900 case BFD_RELOC_PPC_EMB_RELST_LO
:
2901 case BFD_RELOC_PPC_EMB_RELST_HI
:
2902 case BFD_RELOC_PPC_EMB_RELST_HA
:
2903 case BFD_RELOC_PPC_EMB_SDA2I16
:
2904 case BFD_RELOC_PPC_EMB_SDA2REL
:
2905 case BFD_RELOC_PPC_EMB_SDAI16
:
2906 case BFD_RELOC_PPC_GOT_DTPREL16
:
2907 case BFD_RELOC_PPC_GOT_DTPREL16_HA
:
2908 case BFD_RELOC_PPC_GOT_DTPREL16_HI
:
2909 case BFD_RELOC_PPC_GOT_DTPREL16_LO
:
2910 case BFD_RELOC_PPC_GOT_TLSGD16
:
2911 case BFD_RELOC_PPC_GOT_TLSGD16_HA
:
2912 case BFD_RELOC_PPC_GOT_TLSGD16_HI
:
2913 case BFD_RELOC_PPC_GOT_TLSGD16_LO
:
2914 case BFD_RELOC_PPC_GOT_TLSLD16
:
2915 case BFD_RELOC_PPC_GOT_TLSLD16_HA
:
2916 case BFD_RELOC_PPC_GOT_TLSLD16_HI
:
2917 case BFD_RELOC_PPC_GOT_TLSLD16_LO
:
2918 case BFD_RELOC_PPC_GOT_TPREL16
:
2919 case BFD_RELOC_PPC_GOT_TPREL16_HA
:
2920 case BFD_RELOC_PPC_GOT_TPREL16_HI
:
2921 case BFD_RELOC_PPC_GOT_TPREL16_LO
:
2922 case BFD_RELOC_PPC_TOC16
:
2923 case BFD_RELOC_PPC_TPREL16
:
2924 case BFD_RELOC_PPC_TPREL16_HA
:
2925 case BFD_RELOC_PPC_TPREL16_HI
:
2926 case BFD_RELOC_PPC_TPREL16_LO
:
2930 case BFD_RELOC_16_PCREL
:
2931 case BFD_RELOC_HI16_PCREL
:
2932 case BFD_RELOC_HI16_S_PCREL
:
2933 case BFD_RELOC_LO16_PCREL
:
2934 case BFD_RELOC_PPC64_REL16_HIGH
:
2935 case BFD_RELOC_PPC64_REL16_HIGHA
:
2936 case BFD_RELOC_PPC64_REL16_HIGHER
:
2937 case BFD_RELOC_PPC64_REL16_HIGHER34
:
2938 case BFD_RELOC_PPC64_REL16_HIGHERA
:
2939 case BFD_RELOC_PPC64_REL16_HIGHERA34
:
2940 case BFD_RELOC_PPC64_REL16_HIGHEST
:
2941 case BFD_RELOC_PPC64_REL16_HIGHEST34
:
2942 case BFD_RELOC_PPC64_REL16_HIGHESTA
:
2943 case BFD_RELOC_PPC64_REL16_HIGHESTA34
:
2945 case BFD_RELOC_PPC_B16
:
2947 case BFD_RELOC_PPC_VLE_REL8
:
2953 case BFD_RELOC_32_PLTOFF
:
2955 case BFD_RELOC_CTOR
:
2957 case BFD_RELOC_PPC64_ENTRY
:
2958 case BFD_RELOC_PPC_16DX_HA
:
2960 case BFD_RELOC_PPC_BA16
:
2962 case BFD_RELOC_PPC_BA16_BRNTAKEN
:
2963 case BFD_RELOC_PPC_BA16_BRTAKEN
:
2964 case BFD_RELOC_PPC_BA26
:
2965 case BFD_RELOC_PPC_EMB_BIT_FLD
:
2966 case BFD_RELOC_PPC_EMB_NADDR32
:
2967 case BFD_RELOC_PPC_EMB_SDA21
:
2968 case BFD_RELOC_PPC_TLS
:
2969 case BFD_RELOC_PPC_TLSGD
:
2970 case BFD_RELOC_PPC_TLSLD
:
2971 case BFD_RELOC_PPC_VLE_HA16A
:
2972 case BFD_RELOC_PPC_VLE_HA16D
:
2973 case BFD_RELOC_PPC_VLE_HI16A
:
2974 case BFD_RELOC_PPC_VLE_HI16D
:
2975 case BFD_RELOC_PPC_VLE_LO16A
:
2976 case BFD_RELOC_PPC_VLE_LO16D
:
2977 case BFD_RELOC_PPC_VLE_SDA21
:
2978 case BFD_RELOC_PPC_VLE_SDA21_LO
:
2979 case BFD_RELOC_PPC_VLE_SDAREL_HA16A
:
2980 case BFD_RELOC_PPC_VLE_SDAREL_HA16D
:
2981 case BFD_RELOC_PPC_VLE_SDAREL_HI16A
:
2982 case BFD_RELOC_PPC_VLE_SDAREL_HI16D
:
2983 case BFD_RELOC_PPC_VLE_SDAREL_LO16A
:
2984 case BFD_RELOC_PPC_VLE_SDAREL_LO16D
:
2985 case BFD_RELOC_PPC64_TLS_PCREL
:
2990 case BFD_RELOC_24_PLT_PCREL
:
2991 case BFD_RELOC_32_PCREL
:
2992 case BFD_RELOC_32_PLT_PCREL
:
2993 case BFD_RELOC_PPC64_REL24_NOTOC
:
2995 case BFD_RELOC_PPC_B16
:
2997 case BFD_RELOC_PPC_B16_BRNTAKEN
:
2998 case BFD_RELOC_PPC_B16_BRTAKEN
:
2999 case BFD_RELOC_PPC_B26
:
3000 case BFD_RELOC_PPC_LOCAL24PC
:
3001 case BFD_RELOC_PPC_REL16DX_HA
:
3002 case BFD_RELOC_PPC_VLE_REL15
:
3003 case BFD_RELOC_PPC_VLE_REL24
:
3009 case BFD_RELOC_CTOR
:
3011 case BFD_RELOC_PPC_COPY
:
3012 case BFD_RELOC_PPC_DTPMOD
:
3013 case BFD_RELOC_PPC_DTPREL
:
3014 case BFD_RELOC_PPC_GLOB_DAT
:
3015 case BFD_RELOC_PPC_TPREL
:
3016 size
= ppc_obj64
? 8 : 4;
3020 case BFD_RELOC_64_PLTOFF
:
3021 case BFD_RELOC_PPC64_ADDR64_LOCAL
:
3022 case BFD_RELOC_PPC64_D28
:
3023 case BFD_RELOC_PPC64_D34
:
3024 case BFD_RELOC_PPC64_D34_LO
:
3025 case BFD_RELOC_PPC64_D34_HI30
:
3026 case BFD_RELOC_PPC64_D34_HA30
:
3027 case BFD_RELOC_PPC64_TPREL34
:
3028 case BFD_RELOC_PPC64_DTPREL34
:
3029 case BFD_RELOC_PPC64_TOC
:
3033 case BFD_RELOC_64_PCREL
:
3034 case BFD_RELOC_64_PLT_PCREL
:
3035 case BFD_RELOC_PPC64_GOT_PCREL34
:
3036 case BFD_RELOC_PPC64_GOT_TLSGD_PCREL34
:
3037 case BFD_RELOC_PPC64_GOT_TLSLD_PCREL34
:
3038 case BFD_RELOC_PPC64_GOT_TPREL_PCREL34
:
3039 case BFD_RELOC_PPC64_GOT_DTPREL_PCREL34
:
3040 case BFD_RELOC_PPC64_PCREL28
:
3041 case BFD_RELOC_PPC64_PCREL34
:
3042 case BFD_RELOC_PPC64_PLT_PCREL34
:
3051 if (ENABLE_CHECKING
)
3053 reloc_howto_type
*reloc_howto
= bfd_reloc_type_lookup (stdoutput
, reloc
);
3054 if (reloc_howto
!= NULL
3055 && (size
!= bfd_get_reloc_size (reloc_howto
)
3056 || pcrel
!= reloc_howto
->pc_relative
))
3058 as_bad (_("%s howto doesn't match size/pcrel in gas"),
3063 *pc_relative
= pcrel
;
3068 /* If we have parsed a call to __tls_get_addr, parse an argument like
3069 (gd0@tlsgd). *STR is the leading parenthesis on entry. If an arg
3070 is successfully parsed, *STR is updated past the trailing
3071 parenthesis and trailing white space, and *TLS_FIX contains the
3072 reloc and arg expression. */
3075 parse_tls_arg (char **str
, const expressionS
*exp
, struct ppc_fixup
*tls_fix
)
3077 const char *sym_name
= S_GET_NAME (exp
->X_add_symbol
);
3078 if (sym_name
[0] == '.')
3081 tls_fix
->reloc
= BFD_RELOC_NONE
;
3082 if (strncasecmp (sym_name
, "__tls_get_addr", 14) == 0
3083 && (sym_name
[14] == 0
3084 || strcasecmp (sym_name
+ 14, "_desc") == 0
3085 || strcasecmp (sym_name
+ 14, "_opt") == 0))
3087 char *hold
= input_line_pointer
;
3088 input_line_pointer
= *str
+ 1;
3089 expression (&tls_fix
->exp
);
3090 if (tls_fix
->exp
.X_op
== O_symbol
)
3092 if (strncasecmp (input_line_pointer
, "@tlsgd)", 7) == 0)
3093 tls_fix
->reloc
= BFD_RELOC_PPC_TLSGD
;
3094 else if (strncasecmp (input_line_pointer
, "@tlsld)", 7) == 0)
3095 tls_fix
->reloc
= BFD_RELOC_PPC_TLSLD
;
3096 if (tls_fix
->reloc
!= BFD_RELOC_NONE
)
3098 input_line_pointer
+= 7;
3100 *str
= input_line_pointer
;
3103 input_line_pointer
= hold
;
3105 return tls_fix
->reloc
!= BFD_RELOC_NONE
;
3109 /* Parse svp64 extra operands given to the MACRO opcode starting at S,
3110 then its operands, and assemble the svp64 macro. */
3113 parse_svp64_macro (char *s
, struct powerpc_macro
*macro
)
3115 as_bad (_("`sv.'-prefixed macros are not supported"));
3118 /* Parse extra operands at S, and initialize SVP64_PREFIX with them. */
3120 parse_svp64_operands (char **s
, uint32_t *svp64_prefix
, ppc_cpu_t flags
)
3122 *svp64_prefix
= (uint32_t)1 << 26;
3123 /* Do nothing for now. */
3126 /* This routine is called for each instruction to be assembled. */