1 /* tc-ppc.c -- Assemble for the PowerPC or POWER (RS/6000)
2 Copyright (C) 1994 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 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "opcode/ppc.h"
28 /* This is the assembler for the PowerPC or POWER (RS/6000) chips. */
30 /* FIXME: This should be handled in a different way. */
31 extern int target_big_endian
;
33 static void ppc_set_cpu
PARAMS ((void));
34 static unsigned long ppc_insert_operand
35 PARAMS ((unsigned long insn
, const struct powerpc_operand
*operand
,
36 offsetT val
, char *file
, unsigned int line
));
37 static void ppc_macro
PARAMS ((char *str
, const struct powerpc_macro
*macro
));
38 static void ppc_byte
PARAMS ((int));
39 static int ppc_is_toc_sym
PARAMS ((symbolS
*sym
));
40 static void ppc_tc
PARAMS ((int));
42 static void ppc_comm
PARAMS ((int));
43 static void ppc_bb
PARAMS ((int));
44 static void ppc_bf
PARAMS ((int));
45 static void ppc_biei
PARAMS ((int));
46 static void ppc_bs
PARAMS ((int));
47 static void ppc_eb
PARAMS ((int));
48 static void ppc_ef
PARAMS ((int));
49 static void ppc_es
PARAMS ((int));
50 static void ppc_csect
PARAMS ((int));
51 static void ppc_function
PARAMS ((int));
52 static void ppc_extern
PARAMS ((int));
53 static void ppc_lglobl
PARAMS ((int));
54 static void ppc_stabx
PARAMS ((int));
55 static void ppc_rename
PARAMS ((int));
56 static void ppc_toc
PARAMS ((int));
59 static bfd_reloc_code_real_type ppc_elf_suffix
PARAMS ((char **));
60 static void ppc_elf_cons
PARAMS ((int));
61 static void ppc_elf_validate_fix (fixS
*, segT
);
64 /* Generic assembler global variables which must be defined by all
67 /* Characters which always start a comment. */
68 const char comment_chars
[] = "#";
70 /* Characters which start a comment at the beginning of a line. */
71 const char line_comment_chars
[] = "#";
73 /* Characters which may be used to separate multiple commands on a
75 const char line_separator_chars
[] = ";";
77 /* Characters which are used to indicate an exponent in a floating
79 const char EXP_CHARS
[] = "eE";
81 /* Characters which mean that a number is a floating point constant,
83 const char FLT_CHARS
[] = "dD";
85 /* The target specific pseudo-ops which we support. */
87 const pseudo_typeS md_pseudo_table
[] =
89 /* Pseudo-ops which must be overridden. */
90 { "byte", ppc_byte
, 0 },
93 /* Pseudo-ops specific to the RS/6000 XCOFF format. Some of these
94 legitimately belong in the obj-*.c file. However, XCOFF is based
95 on COFF, and is only implemented for the RS/6000. We just use
96 obj-coff.c, and add what we need here. */
97 { "comm", ppc_comm
, 0 },
98 { "lcomm", ppc_comm
, 1 },
101 { "bi", ppc_biei
, 0 },
103 { "csect", ppc_csect
, 0 },
106 { "ei", ppc_biei
, 1 },
108 { "extern", ppc_extern
, 0 },
109 { "function", ppc_function
, 0 },
110 { "lglobl", ppc_lglobl
, 0 },
111 { "rename", ppc_rename
, 0 },
112 { "stabx", ppc_stabx
, 0 },
113 { "toc", ppc_toc
, 0 },
116 { "long", ppc_elf_cons
, 4 },
117 { "word", ppc_elf_cons
, 2 },
118 { "short", ppc_elf_cons
, 2 },
121 /* This pseudo-op is used even when not generating XCOFF output. */
127 /* Local variables. */
129 /* The type of processor we are assembling for. This is one or more
130 of the PPC_OPCODE flags defined in opcode/ppc.h. */
131 static int ppc_cpu
= 0;
133 /* The size of the processor we are assembling for. This is either
134 PPC_OPCODE_32 or PPC_OPCODE_64. */
135 static int ppc_size
= PPC_OPCODE_32
;
137 /* The endianness we are using. */
138 static int ppc_big_endian
= PPC_BIG_ENDIAN
;
140 /* Opcode hash table. */
141 static struct hash_control
*ppc_hash
;
143 /* Macro hash table. */
144 static struct hash_control
*ppc_macro_hash
;
147 /* Whether to warn about non PC relative relocations that aren't
148 in the .got2 section. */
149 static int mrelocatable
= 0;
154 /* The RS/6000 assembler uses the .csect pseudo-op to generate code
155 using a bunch of different sections. These assembler sections,
156 however, are all encompassed within the .text or .data sections of
157 the final output file. We handle this by using different
158 subsegments within these main segments. */
160 /* Next subsegment to allocate within the .text segment. */
161 static subsegT ppc_text_subsegment
= 2;
163 /* Linked list of csects in the text section. */
164 static symbolS
*ppc_text_csects
;
166 /* Next subsegment to allocate within the .data segment. */
167 static subsegT ppc_data_subsegment
= 2;
169 /* Linked list of csects in the data section. */
170 static symbolS
*ppc_data_csects
;
172 /* The current csect. */
173 static symbolS
*ppc_current_csect
;
175 /* The RS/6000 assembler uses a TOC which holds addresses of functions
176 and variables. Symbols are put in the TOC with the .tc pseudo-op.
177 A special relocation is used when accessing TOC entries. We handle
178 the TOC as a subsegment within the .data segment. We set it up if
179 we see a .toc pseudo-op, and save the csect symbol here. */
180 static symbolS
*ppc_toc_csect
;
182 /* The first frag in the TOC subsegment. */
183 static fragS
*ppc_toc_frag
;
185 /* The first frag in the first subsegment after the TOC in the .data
186 segment. NULL if there are no subsegments after the TOC. */
187 static fragS
*ppc_after_toc_frag
;
189 /* The current static block. */
190 static symbolS
*ppc_current_block
;
192 /* The COFF debugging section; set by md_begin. This is not the
193 .debug section, but is instead the secret BFD section which will
194 cause BFD to set the section number of a symbol to N_DEBUG. */
195 static asection
*ppc_coff_debug_section
;
197 /* The size of the .debug section. */
198 static bfd_size_type ppc_debug_name_section_size
;
200 #endif /* OBJ_COFF */
203 symbolS
*GOT_symbol
; /* Pre-defined "_GLOBAL_OFFSET_TABLE" */
206 #ifndef WORKING_DOT_WORD
207 const int md_short_jump_size
= 4;
208 const int md_long_jump_size
= 4;
212 CONST
char *md_shortopts
= "um:VQ:";
214 CONST
char *md_shortopts
= "um:";
216 struct option md_longopts
[] = {
217 {NULL
, no_argument
, NULL
, 0}
219 size_t md_longopts_size
= sizeof(md_longopts
);
222 md_parse_option (c
, arg
)
229 /* -u means that any undefined symbols should be treated as
230 external, which is the default for gas anyhow. */
234 /* -mpwrx and -mpwr2 mean to assemble for the IBM POWER/2
236 if (strcmp (arg
, "pwrx") == 0 || strcmp (arg
, "pwr2") == 0)
237 ppc_cpu
= PPC_OPCODE_POWER
| PPC_OPCODE_POWER2
;
238 /* -mpwr means to assemble for the IBM POWER (RIOS1). */
239 else if (strcmp (arg
, "pwr") == 0)
240 ppc_cpu
= PPC_OPCODE_POWER
;
241 /* -m601 means to assemble for the Motorola PowerPC 601. FIXME: We
242 ignore the option for now, but we should really use it to permit
243 instructions defined on the 601 that are not part of the standard
244 PowerPC architecture (mostly holdovers from the POWER). */
245 else if (strcmp (arg
, "601") == 0)
246 ppc_cpu
= PPC_OPCODE_PPC
| PPC_OPCODE_601
;
247 /* -mppc, -mppc32, -m603, and -m604 mean to assemble for the
248 Motorola PowerPC 603/604. */
249 else if (strcmp (arg
, "ppc") == 0
250 || strcmp (arg
, "ppc32") == 0
251 || strcmp (arg
, "603") == 0
252 || strcmp (arg
, "604") == 0)
253 ppc_cpu
= PPC_OPCODE_PPC
;
254 /* -mppc64 and -m620 mean to assemble for the 64-bit PowerPC
256 else if (strcmp (arg
, "ppc64") == 0 || strcmp (arg
, "620") == 0)
258 ppc_cpu
= PPC_OPCODE_PPC
;
259 ppc_size
= PPC_OPCODE_64
;
261 /* -many means to assemble for any architecture (PWR/PWRX/PPC). */
262 else if (strcmp (arg
, "any") == 0)
263 ppc_cpu
= PPC_OPCODE_POWER
| PPC_OPCODE_POWER2
| PPC_OPCODE_PPC
;
265 /* -mrelocatable -- warn about initializations that require relocation */
266 else if (strcmp (arg
, "relocatable") == 0)
271 as_bad ("invalid architecture -m%s", arg
);
277 /* -V: SVR4 argument to print version ID. */
282 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
283 should be emitted or not. FIXME: Not implemented. */
296 md_show_usage (stream
)
302 -mpwrx generate code for IBM POWER/2 (RIOS2)\n\
303 -mpwr generate code for IBM POWER (RIOS1)\n\
304 -m601 generate code for Motorola PowerPC 601\n\
305 -mppc, -mppc32, -m603, -m604\n\
306 generate code for Motorola PowerPC 603/604\n\
307 -many generate code for any architecture (PWR/PWRX/PPC)\n");
310 -mrelocatable warn incompatible with GCC's -mrelocatble option\n\
311 -V print assembler version number\n\
312 -Qy, -Qn ignored\n");
316 /* Set ppc_cpu if it is not already set. */
321 const char *default_cpu
= TARGET_CPU
;
325 if (strcmp (default_cpu
, "rs6000") == 0)
326 ppc_cpu
= PPC_OPCODE_POWER
;
327 else if (strcmp (default_cpu
, "powerpc") == 0)
328 ppc_cpu
= PPC_OPCODE_PPC
;
334 /* Figure out the BFD architecture to use. */
336 enum bfd_architecture
341 if ((ppc_cpu
& PPC_OPCODE_PPC
) != 0)
342 return bfd_arch_powerpc
;
343 else if ((ppc_cpu
& PPC_OPCODE_POWER
) != 0)
344 return bfd_arch_rs6000
;
349 /* This function is called when the assembler starts up. It is called
350 after the options have been parsed and the output file has been
356 register const struct powerpc_opcode
*op
;
357 const struct powerpc_opcode
*op_end
;
358 const struct powerpc_macro
*macro
;
359 const struct powerpc_macro
*macro_end
;
363 /* Insert the opcodes into a hash table. */
364 ppc_hash
= hash_new ();
366 op_end
= powerpc_opcodes
+ powerpc_num_opcodes
;
367 for (op
= powerpc_opcodes
; op
< op_end
; op
++)
369 know ((op
->opcode
& op
->mask
) == op
->opcode
);
371 if ((op
->flags
& ppc_cpu
) != 0
372 && ((op
->flags
& (PPC_OPCODE_32
| PPC_OPCODE_64
)) == 0
373 || (op
->flags
& (PPC_OPCODE_32
| PPC_OPCODE_64
)) == ppc_size
))
377 retval
= hash_insert (ppc_hash
, op
->name
, (PTR
) op
);
378 if (retval
!= (const char *) NULL
)
380 /* We permit a duplication of the mfdec instruction on
381 the 601, because it seems to have one value on the
382 601 and a different value on other PowerPC
383 processors. It's easier to permit a duplication than
384 to define a new instruction type flag. When using
385 -many, the comparison instructions are a harmless
387 if (strcmp (retval
, "exists") != 0
388 || (((ppc_cpu
& PPC_OPCODE_601
) == 0
389 || strcmp (op
->name
, "mfdec") != 0)
390 && (ppc_cpu
!= (PPC_OPCODE_POWER
393 || (strcmp (op
->name
, "cmpli") != 0
394 && strcmp (op
->name
, "cmpi") != 0
395 && strcmp (op
->name
, "cmp") != 0
396 && strcmp (op
->name
, "cmpl") != 0))))
402 /* Insert the macros into a hash table. */
403 ppc_macro_hash
= hash_new ();
405 macro_end
= powerpc_macros
+ powerpc_num_macros
;
406 for (macro
= powerpc_macros
; macro
< macro_end
; macro
++)
408 if ((macro
->flags
& ppc_cpu
) != 0)
412 retval
= hash_insert (ppc_macro_hash
, macro
->name
, (PTR
) macro
);
413 if (retval
!= (const char *) NULL
)
418 /* Tell the main code what the endianness is. */
419 target_big_endian
= ppc_big_endian
;
422 ppc_coff_debug_section
= coff_section_from_bfd_index (stdoutput
, N_DEBUG
);
424 /* Create dummy symbols to serve as initial csects. This forces the
425 text csects to precede the data csects. These symbols will not
427 ppc_text_csects
= symbol_make ("dummy\001");
428 ppc_text_csects
->sy_tc
.within
= ppc_text_csects
;
429 ppc_data_csects
= symbol_make ("dummy\001");
430 ppc_data_csects
->sy_tc
.within
= ppc_data_csects
;
434 /* Insert an operand value into an instruction. */
437 ppc_insert_operand (insn
, operand
, val
, file
, line
)
439 const struct powerpc_operand
*operand
;
444 if (operand
->bits
!= 32)
449 if ((operand
->flags
& PPC_OPERAND_SIGNED
) != 0)
451 if ((operand
->flags
& PPC_OPERAND_SIGNOPT
) != 0
452 && ppc_size
== PPC_OPCODE_32
)
453 max
= (1 << operand
->bits
) - 1;
455 max
= (1 << (operand
->bits
- 1)) - 1;
456 min
= - (1 << (operand
->bits
- 1));
460 max
= (1 << operand
->bits
) - 1;
464 if ((operand
->flags
& PPC_OPERAND_NEGATIVE
) != 0)
469 if (test
< (offsetT
) min
|| test
> (offsetT
) max
)
472 "operand out of range (%s not between %ld and %ld)";
475 sprint_value (buf
, test
);
476 if (file
== (char *) NULL
)
477 as_warn (err
, buf
, min
, max
);
479 as_warn_where (file
, line
, err
, buf
, min
, max
);
488 insn
= (*operand
->insert
) (insn
, (long) val
, &errmsg
);
489 if (errmsg
!= (const char *) NULL
)
493 insn
|= (((long) val
& ((1 << operand
->bits
) - 1))
500 /* Parse @got, etc. and return the desired relocation. */
501 static bfd_reloc_code_real_type
502 ppc_elf_suffix (str_p
)
508 return BFD_RELOC_UNUSED
;
510 if (strncmp (str
, "@GOT", 4) == 0 || strncmp (str
, "@got", 4) == 0)
513 return BFD_RELOC_PPC_TOC16
;
515 else if (strncmp (str
, "@L", 2) == 0 || strncmp (str
, "@l", 2) == 0)
518 return BFD_RELOC_LO16
;
520 else if (strncmp (str
, "@HA", 3) == 0 || strncmp (str
, "@ha", 3) == 0)
523 return BFD_RELOC_HI16_S
;
525 else if (strncmp (str
, "@H", 2) == 0 || strncmp (str
, "@h", 2) == 0)
528 return BFD_RELOC_HI16
;
531 return BFD_RELOC_UNUSED
;
534 /* Like normal .long/.short/.word, except support @got, etc. */
535 /* clobbers input_line_pointer, checks */
538 ppc_elf_cons (nbytes
)
539 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
542 bfd_reloc_code_real_type reloc
;
544 if (is_it_end_of_statement ())
546 demand_empty_rest_of_line ();
554 && exp
.X_op
== O_symbol
555 && *input_line_pointer
== '@'
556 && (reloc
= ppc_elf_suffix (&input_line_pointer
)) != BFD_RELOC_UNUSED
)
558 register char *p
= frag_more ((int) nbytes
);
559 reloc_howto_type
*reloc_howto
= bfd_reloc_type_lookup (stdoutput
, reloc
);
560 int offset
= (!reloc_howto
) ? 0 : (nbytes
- bfd_get_reloc_size (reloc_howto
));
565 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
+ offset
, (int) nbytes
- offset
, &exp
, 0, reloc
);
568 emit_expr (&exp
, (unsigned int) nbytes
);
570 while (*input_line_pointer
++ == ',');
572 input_line_pointer
--; /* Put terminator back into stream. */
573 demand_empty_rest_of_line ();
576 /* Validate any relocations emitted for -mrelocatable */
578 ppc_elf_validate_fix (fixS
*fixp
, segT seg
)
583 && fixp
->fx_r_type
<= BFD_RELOC_UNUSED
584 && strcmp (segment_name (seg
), ".got2") != 0
585 && strcmp (segment_name (seg
), ".stab") != 0)
587 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
588 "Relocation cannot be done when using -mrelocatable");
594 /* We need to keep a list of fixups. We can't simply generate them as
595 we go, because that would require us to first create the frag, and
596 that would screw up references to ``.''. */
602 bfd_reloc_code_real_type reloc
;
605 #define MAX_INSN_FIXUPS (5)
607 /* This routine is called for each instruction to be assembled. */
614 const struct powerpc_opcode
*opcode
;
616 const unsigned char *opindex_ptr
;
620 struct ppc_fixup fixups
[MAX_INSN_FIXUPS
];
624 bfd_reloc_code_real_type reloc
;
626 /* Get the opcode. */
627 for (s
= str
; *s
!= '\0' && ! isspace (*s
); s
++)
632 /* Look up the opcode in the hash table. */
633 opcode
= (const struct powerpc_opcode
*) hash_find (ppc_hash
, str
);
634 if (opcode
== (const struct powerpc_opcode
*) NULL
)
636 const struct powerpc_macro
*macro
;
638 macro
= (const struct powerpc_macro
*) hash_find (ppc_macro_hash
, str
);
639 if (macro
== (const struct powerpc_macro
*) NULL
)
640 as_bad ("Unrecognized opcode: `%s'", str
);
642 ppc_macro (s
, macro
);
647 insn
= opcode
->opcode
;
650 while (isspace (*str
))
653 /* PowerPC operands are just expressions. The only real issue is
654 that a few operand types are optional. All cases which might use
655 an optional operand separate the operands only with commas (in
656 some cases parentheses are used, as in ``lwz 1,0(1)'' but such
657 cases never have optional operands). There is never more than
658 one optional operand for an instruction. So, before we start
659 seriously parsing the operands, we check to see if we have an
660 optional operand, and, if we do, we count the number of commas to
661 see whether the operand should be omitted. */
663 for (opindex_ptr
= opcode
->operands
; *opindex_ptr
!= 0; opindex_ptr
++)
665 const struct powerpc_operand
*operand
;
667 operand
= &powerpc_operands
[*opindex_ptr
];
668 if ((operand
->flags
& PPC_OPERAND_OPTIONAL
) != 0)
670 unsigned int opcount
;
672 /* There is an optional operand. Count the number of
673 commas in the input line. */
680 while ((s
= strchr (s
, ',')) != (char *) NULL
)
687 /* If there are fewer operands in the line then are called
688 for by the instruction, we want to skip the optional
690 if (opcount
< strlen (opcode
->operands
))
697 /* Gather the operands. */
701 for (opindex_ptr
= opcode
->operands
; *opindex_ptr
!= 0; opindex_ptr
++)
703 const struct powerpc_operand
*operand
;
709 if (next_opindex
== 0)
710 operand
= &powerpc_operands
[*opindex_ptr
];
713 operand
= &powerpc_operands
[next_opindex
];
719 /* If this is a fake operand, then we do not expect anything
721 if ((operand
->flags
& PPC_OPERAND_FAKE
) != 0)
723 insn
= (*operand
->insert
) (insn
, 0L, &errmsg
);
724 if (errmsg
!= (const char *) NULL
)
729 /* If this is an optional operand, and we are skipping it, just
731 if ((operand
->flags
& PPC_OPERAND_OPTIONAL
) != 0
736 insn
= (*operand
->insert
) (insn
, 0L, &errmsg
);
737 if (errmsg
!= (const char *) NULL
)
740 if ((operand
->flags
& PPC_OPERAND_NEXT
) != 0)
741 next_opindex
= *opindex_ptr
+ 1;
745 /* Gather the operand. */
746 hold
= input_line_pointer
;
747 input_line_pointer
= str
;
749 str
= input_line_pointer
;
750 input_line_pointer
= hold
;
752 if (ex
.X_op
== O_illegal
)
753 as_bad ("illegal operand");
754 else if (ex
.X_op
== O_absent
)
755 as_bad ("missing operand");
756 else if (ex
.X_op
== O_constant
)
757 insn
= ppc_insert_operand (insn
, operand
, ex
.X_add_number
,
761 else if ((reloc
= ppc_elf_suffix (&str
)) != BFD_RELOC_UNUSED
)
763 /* We need to generate a fixup for this expression. */
764 if (fc
>= MAX_INSN_FIXUPS
)
765 as_fatal ("too many fixups");
767 fixups
[fc
].opindex
= 0;
768 fixups
[fc
].reloc
= reloc
;
775 /* We need to generate a fixup for this expression. */
776 if (fc
>= MAX_INSN_FIXUPS
)
777 as_fatal ("too many fixups");
779 fixups
[fc
].opindex
= *opindex_ptr
;
780 fixups
[fc
].reloc
= BFD_RELOC_UNUSED
;
789 else if ((operand
->flags
& PPC_OPERAND_PARENS
) != 0)
797 /* The call to expression should have advanced str past any
800 && (endc
!= ',' || *str
!= '\0'))
802 as_bad ("syntax error; found `%c' but expected `%c'", *str
, endc
);
810 while (isspace (*str
))
814 as_bad ("junk at end of line: `%s'", str
);
816 /* Write out the instruction. */
818 md_number_to_chars (f
, insn
, 4);
820 /* Create any fixups. At this point we do not use a
821 bfd_reloc_code_real_type, but instead just use the operand index.
822 This lets us easily handle fixups for any operand type, although
823 that is admittedly not a very exciting feature. We pick a BFD
824 reloc type in md_apply_fix. */
825 for (i
= 0; i
< fc
; i
++)
827 const struct powerpc_operand
*operand
;
829 operand
= &powerpc_operands
[fixups
[i
].opindex
];
830 if (fixups
[i
].reloc
!= BFD_RELOC_UNUSED
)
832 reloc_howto_type
*reloc_howto
= bfd_reloc_type_lookup (stdoutput
, fixups
[i
].reloc
);
833 int offset
= (!reloc_howto
) ? 0 : (4 - bfd_get_reloc_size (reloc_howto
));
838 fix_new_exp (frag_now
, f
- frag_now
->fr_literal
+ offset
, 4 - offset
,
839 &fixups
[i
].exp
, (reloc_howto
&& reloc_howto
->pc_relative
),
843 fix_new_exp (frag_now
, f
- frag_now
->fr_literal
, 4,
845 (operand
->flags
& PPC_OPERAND_RELATIVE
) != 0,
846 ((bfd_reloc_code_real_type
)
847 (fixups
[i
].opindex
+ (int) BFD_RELOC_UNUSED
)));
851 #ifndef WORKING_DOT_WORD
852 /* Handle long and short jumps */
854 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
856 addressT from_addr
, to_addr
;
864 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
866 addressT from_addr
, to_addr
;
874 /* Handle a macro. Gather all the operands, transform them as
875 described by the macro, and call md_assemble recursively. All the
876 operands are separated by commas; we don't accept parentheses
877 around operands here. */
880 ppc_macro (str
, macro
)
882 const struct powerpc_macro
*macro
;
893 /* Gather the users operands into the operands array. */
898 if (count
>= sizeof operands
/ sizeof operands
[0])
900 operands
[count
++] = s
;
902 if (s
== (char *) NULL
)
907 if (count
!= macro
->operands
)
909 as_bad ("wrong number of operands");
913 /* Work out how large the string must be (the size is unbounded
914 because it includes user input). */
916 format
= macro
->format
;
917 while (*format
!= '\0')
926 arg
= strtol (format
+ 1, &send
, 10);
927 know (send
!= format
&& arg
>= 0 && arg
< count
);
928 len
+= strlen (operands
[arg
]);
933 /* Put the string together. */
934 complete
= s
= (char *) alloca (len
+ 1);
935 format
= macro
->format
;
936 while (*format
!= '\0')
942 arg
= strtol (format
+ 1, &send
, 10);
943 strcpy (s
, operands
[arg
]);
950 /* Assemble the constructed instruction. */
951 md_assemble (complete
);
954 /* Pseudo-op handling. */
956 /* The .byte pseudo-op. This is similar to the normal .byte
957 pseudo-op, but it can also take a single ASCII string. */
963 if (*input_line_pointer
!= '\"')
969 /* Gather characters. A real double quote is doubled. Unusual
970 characters are not permitted. */
971 ++input_line_pointer
;
976 c
= *input_line_pointer
++;
980 if (*input_line_pointer
!= '\"')
982 ++input_line_pointer
;
985 FRAG_APPEND_1_CHAR (c
);
988 demand_empty_rest_of_line ();
993 /* XCOFF specific pseudo-op handling. */
995 /* The .comm and .lcomm pseudo-ops for XCOFF. XCOFF puts common
996 symbols in the .bss segment as though they were local common
997 symbols, and uses a different smclas. */
1003 asection
*current_seg
= now_seg
;
1004 subsegT current_subseg
= now_subseg
;
1010 symbolS
*lcomm_sym
= NULL
;
1014 name
= input_line_pointer
;
1015 endc
= get_symbol_end ();
1016 end_name
= input_line_pointer
;
1019 if (*input_line_pointer
!= ',')
1021 as_bad ("missing size");
1022 ignore_rest_of_line ();
1025 ++input_line_pointer
;
1027 size
= get_absolute_expression ();
1030 as_bad ("negative size");
1031 ignore_rest_of_line ();
1037 /* The third argument to .comm is the alignment. */
1038 if (*input_line_pointer
!= ',')
1042 ++input_line_pointer
;
1043 align
= get_absolute_expression ();
1046 as_warn ("ignoring bad alignment");
1065 /* The third argument to .lcomm appears to be the real local
1066 common symbol to create. References to the symbol named in
1067 the first argument are turned into references to the third
1069 if (*input_line_pointer
!= ',')
1071 as_bad ("missing real symbol name");
1072 ignore_rest_of_line ();
1075 ++input_line_pointer
;
1077 lcomm_name
= input_line_pointer
;
1078 lcomm_endc
= get_symbol_end ();
1080 lcomm_sym
= symbol_find_or_make (lcomm_name
);
1082 *input_line_pointer
= lcomm_endc
;
1086 sym
= symbol_find_or_make (name
);
1089 if (S_IS_DEFINED (sym
)
1090 || S_GET_VALUE (sym
) != 0)
1092 as_bad ("attempt to redefine symbol");
1093 ignore_rest_of_line ();
1097 record_alignment (bss_section
, align
);
1100 || ! S_IS_DEFINED (lcomm_sym
))
1109 S_SET_EXTERNAL (sym
);
1113 lcomm_sym
->sy_tc
.output
= 1;
1114 def_sym
= lcomm_sym
;
1118 subseg_set (bss_section
, 1);
1119 frag_align (align
, 0);
1121 def_sym
->sy_frag
= frag_now
;
1122 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, def_sym
,
1123 def_size
, (char *) NULL
);
1125 S_SET_SEGMENT (def_sym
, bss_section
);
1126 def_sym
->sy_tc
.align
= align
;
1130 /* Align the size of lcomm_sym. */
1131 lcomm_sym
->sy_frag
->fr_offset
=
1132 ((lcomm_sym
->sy_frag
->fr_offset
+ (1 << align
) - 1)
1133 &~ ((1 << align
) - 1));
1134 if (align
> lcomm_sym
->sy_tc
.align
)
1135 lcomm_sym
->sy_tc
.align
= align
;
1140 /* Make sym an offset from lcomm_sym. */
1141 S_SET_SEGMENT (sym
, bss_section
);
1142 sym
->sy_frag
= lcomm_sym
->sy_frag
;
1143 S_SET_VALUE (sym
, lcomm_sym
->sy_frag
->fr_offset
);
1144 lcomm_sym
->sy_frag
->fr_offset
+= size
;
1147 subseg_set (current_seg
, current_subseg
);
1149 demand_empty_rest_of_line ();
1152 /* The .csect pseudo-op. This switches us into a different
1153 subsegment. The first argument is a symbol whose value is the
1154 start of the .csect. In COFF, csect symbols get special aux
1155 entries defined by the x_csect field of union internal_auxent. The
1156 optional second argument is the alignment (the default is 2). */
1166 name
= input_line_pointer
;
1167 endc
= get_symbol_end ();
1169 sym
= symbol_find_or_make (name
);
1171 *input_line_pointer
= endc
;
1173 if (S_IS_DEFINED (sym
))
1174 subseg_set (S_GET_SEGMENT (sym
), sym
->sy_tc
.subseg
);
1181 /* This is a new csect. We need to look at the symbol class to
1182 figure out whether it should go in the text section or the
1185 switch (sym
->sy_tc
.class)
1195 S_SET_SEGMENT (sym
, text_section
);
1196 sym
->sy_tc
.subseg
= ppc_text_subsegment
;
1197 ++ppc_text_subsegment
;
1198 list_ptr
= &ppc_text_csects
;
1207 if (ppc_toc_csect
->sy_tc
.subseg
+ 1 == ppc_data_subsegment
)
1209 S_SET_SEGMENT (sym
, data_section
);
1210 sym
->sy_tc
.subseg
= ppc_data_subsegment
;
1211 ++ppc_data_subsegment
;
1212 list_ptr
= &ppc_data_csects
;
1218 subseg_new (segment_name (S_GET_SEGMENT (sym
)), sym
->sy_tc
.subseg
);
1220 ppc_after_toc_frag
= frag_now
;
1222 sym
->sy_frag
= frag_now
;
1223 S_SET_VALUE (sym
, (valueT
) frag_now_fix ());
1225 sym
->sy_tc
.align
= 2;
1226 sym
->sy_tc
.output
= 1;
1227 sym
->sy_tc
.within
= sym
;
1229 for (list
= *list_ptr
;
1230 list
->sy_tc
.next
!= (symbolS
*) NULL
;
1231 list
= list
->sy_tc
.next
)
1233 list
->sy_tc
.next
= sym
;
1235 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
1236 symbol_append (sym
, list
->sy_tc
.within
, &symbol_rootP
, &symbol_lastP
);
1239 if (*input_line_pointer
== ',')
1241 ++input_line_pointer
;
1242 sym
->sy_tc
.align
= get_absolute_expression ();
1245 ppc_current_csect
= sym
;
1247 demand_empty_rest_of_line ();
1250 /* The .extern pseudo-op. We create an undefined symbol. */
1259 name
= input_line_pointer
;
1260 endc
= get_symbol_end ();
1262 (void) symbol_find_or_make (name
);
1264 *input_line_pointer
= endc
;
1266 demand_empty_rest_of_line ();
1269 /* The .lglobl pseudo-op. I think the RS/6000 assembler only needs
1270 this because it can't handle undefined symbols. I think we can
1280 /* The .rename pseudo-op. The RS/6000 assembler can rename symbols,
1281 although I don't know why it bothers. */
1292 name
= input_line_pointer
;
1293 endc
= get_symbol_end ();
1295 sym
= symbol_find_or_make (name
);
1297 *input_line_pointer
= endc
;
1299 if (*input_line_pointer
!= ',')
1301 as_bad ("missing rename string");
1302 ignore_rest_of_line ();
1305 ++input_line_pointer
;
1307 sym
->sy_tc
.real_name
= demand_copy_C_string (&len
);
1309 demand_empty_rest_of_line ();
1312 /* The .stabx pseudo-op. This is similar to a normal .stabs
1313 pseudo-op, but slightly different. A sample is
1314 .stabx "main:F-1",.main,142,0
1315 The first argument is the symbol name to create. The second is the
1316 value, and the third is the storage class. The fourth seems to be
1317 always zero, and I am assuming it is the type. */
1328 name
= demand_copy_C_string (&len
);
1330 if (*input_line_pointer
!= ',')
1332 as_bad ("missing value");
1335 ++input_line_pointer
;
1337 sym
= symbol_make (name
);
1339 (void) expression (&exp
);
1346 as_bad ("illegal .stabx expression; zero assumed");
1347 exp
.X_add_number
= 0;
1350 S_SET_VALUE (sym
, (valueT
) exp
.X_add_number
);
1351 sym
->sy_frag
= &zero_address_frag
;
1355 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
)
1356 sym
->sy_value
= exp
;
1360 exp
.X_add_number
+ S_GET_VALUE (exp
.X_add_symbol
));
1361 sym
->sy_frag
= exp
.X_add_symbol
->sy_frag
;
1366 /* The value is some complex expression. This will probably
1367 fail at some later point, but this is probably the right
1368 thing to do here. */
1369 sym
->sy_value
= exp
;
1373 S_SET_SEGMENT (sym
, ppc_coff_debug_section
);
1374 sym
->bsym
->flags
|= BSF_DEBUGGING
;
1376 if (*input_line_pointer
!= ',')
1378 as_bad ("missing class");
1381 ++input_line_pointer
;
1383 S_SET_STORAGE_CLASS (sym
, get_absolute_expression ());
1385 if (*input_line_pointer
!= ',')
1387 as_bad ("missing type");
1390 ++input_line_pointer
;
1392 S_SET_DATA_TYPE (sym
, get_absolute_expression ());
1394 sym
->sy_tc
.output
= 1;
1396 if (S_GET_STORAGE_CLASS (sym
) == C_STSYM
)
1397 sym
->sy_tc
.within
= ppc_current_block
;
1399 if (exp
.X_op
!= O_symbol
1400 || ! S_IS_EXTERNAL (exp
.X_add_symbol
)
1401 || S_GET_SEGMENT (exp
.X_add_symbol
) != bss_section
)
1402 ppc_frob_label (sym
);
1405 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
1406 symbol_append (sym
, exp
.X_add_symbol
, &symbol_rootP
, &symbol_lastP
);
1407 if (ppc_current_csect
->sy_tc
.within
== exp
.X_add_symbol
)
1408 ppc_current_csect
->sy_tc
.within
= sym
;
1411 if (strlen (name
) > SYMNMLEN
)
1413 /* For some reason, each name is preceded by a two byte length
1414 and followed by a null byte. */
1415 ppc_debug_name_section_size
+= strlen (name
) + 3;
1418 demand_empty_rest_of_line ();
1421 /* The .function pseudo-op. This takes several arguments. The first
1422 argument seems to be the external name of the symbol. The second
1423 argment seems to be the label for the start of the function. gcc
1424 uses the same name for both. I have no idea what the third and
1425 fourth arguments are meant to be. The optional fifth argument is
1426 an expression for the size of the function. In COFF this symbol
1427 gets an aux entry like that used for a csect. */
1430 ppc_function (ignore
)
1439 name
= input_line_pointer
;
1440 endc
= get_symbol_end ();
1442 /* Ignore any [PR] suffix. */
1443 name
= ppc_canonicalize_symbol_name (name
);
1444 s
= strchr (name
, '[');
1445 if (s
!= (char *) NULL
1446 && strcmp (s
+ 1, "PR]") == 0)
1449 ext_sym
= symbol_find_or_make (name
);
1451 *input_line_pointer
= endc
;
1453 if (*input_line_pointer
!= ',')
1455 as_bad ("missing symbol name");
1456 ignore_rest_of_line ();
1459 ++input_line_pointer
;
1461 name
= input_line_pointer
;
1462 endc
= get_symbol_end ();
1464 lab_sym
= symbol_find_or_make (name
);
1466 *input_line_pointer
= endc
;
1468 if (ext_sym
!= lab_sym
)
1470 ext_sym
->sy_value
.X_op
= O_symbol
;
1471 ext_sym
->sy_value
.X_add_symbol
= lab_sym
;
1472 ext_sym
->sy_value
.X_op_symbol
= NULL
;
1473 ext_sym
->sy_value
.X_add_number
= 0;
1476 if (ext_sym
->sy_tc
.class == -1)
1477 ext_sym
->sy_tc
.class = XMC_PR
;
1478 ext_sym
->sy_tc
.output
= 1;
1480 if (*input_line_pointer
== ',')
1484 /* Ignore the third argument. */
1485 ++input_line_pointer
;
1486 expression (&ignore
);
1487 if (*input_line_pointer
== ',')
1489 /* Ignore the fourth argument. */
1490 ++input_line_pointer
;
1491 expression (&ignore
);
1492 if (*input_line_pointer
== ',')
1494 /* The fifth argument is the function size. */
1495 ++input_line_pointer
;
1496 ext_sym
->sy_tc
.size
= symbol_new ("L0\001",
1499 &zero_address_frag
);
1500 pseudo_set (ext_sym
->sy_tc
.size
);
1505 S_SET_DATA_TYPE (ext_sym
, DT_FCN
<< N_BTSHFT
);
1506 SF_SET_FUNCTION (ext_sym
);
1507 SF_SET_PROCESS (ext_sym
);
1508 coff_add_linesym (ext_sym
);
1510 demand_empty_rest_of_line ();
1513 /* The .bf pseudo-op. This is just like a COFF C_FCN symbol named
1522 sym
= symbol_make (".bf");
1523 S_SET_SEGMENT (sym
, text_section
);
1524 sym
->sy_frag
= frag_now
;
1525 S_SET_VALUE (sym
, frag_now_fix ());
1526 S_SET_STORAGE_CLASS (sym
, C_FCN
);
1528 coff_line_base
= get_absolute_expression ();
1530 S_SET_NUMBER_AUXILIARY (sym
, 1);
1531 SA_SET_SYM_LNNO (sym
, coff_line_base
);
1533 sym
->sy_tc
.output
= 1;
1535 ppc_frob_label (sym
);
1537 demand_empty_rest_of_line ();
1540 /* The .ef pseudo-op. This is just like a COFF C_FCN symbol named
1541 ".ef", except that the line number is absolute, not relative to the
1542 most recent ".bf" symbol. */
1550 sym
= symbol_make (".ef");
1551 S_SET_SEGMENT (sym
, text_section
);
1552 sym
->sy_frag
= frag_now
;
1553 S_SET_VALUE (sym
, frag_now_fix ());
1554 S_SET_STORAGE_CLASS (sym
, C_FCN
);
1555 S_SET_NUMBER_AUXILIARY (sym
, 1);
1556 SA_SET_SYM_LNNO (sym
, get_absolute_expression ());
1557 sym
->sy_tc
.output
= 1;
1559 ppc_frob_label (sym
);
1561 demand_empty_rest_of_line ();
1564 /* The .bi and .ei pseudo-ops. These take a string argument and
1565 generates a C_BINCL or C_EINCL symbol, which goes at the start of
1577 name
= demand_copy_C_string (&len
);
1579 sym
= symbol_make (name
);
1580 S_SET_SEGMENT (sym
, ppc_coff_debug_section
);
1581 sym
->bsym
->flags
|= BSF_DEBUGGING
;
1583 /* FIXME: The value of the .bi or .ei symbol is supposed to be the
1584 offset in the file to the line number entry to use. That is
1585 quite difficult to implement using BFD, so I'm just not doing it.
1586 Sorry. Please add it if you can figure out how. Note that this
1587 approach is the only way to support multiple files in COFF, since
1588 line numbers are associated with function symbols. Note further
1589 that it still doesn't work, since the line numbers are stored as
1590 offsets from a base line number. */
1592 S_SET_STORAGE_CLASS (sym
, ei
? C_EINCL
: C_BINCL
);
1593 sym
->sy_tc
.output
= 1;
1595 for (look
= symbol_rootP
;
1596 (look
!= (symbolS
*) NULL
1597 && (S_GET_STORAGE_CLASS (look
) == C_FILE
1598 || S_GET_STORAGE_CLASS (look
) == C_BINCL
1599 || S_GET_STORAGE_CLASS (look
) == C_EINCL
));
1600 look
= symbol_next (look
))
1602 if (look
!= (symbolS
*) NULL
)
1604 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
1605 symbol_insert (sym
, look
, &symbol_rootP
, &symbol_lastP
);
1608 demand_empty_rest_of_line ();
1611 /* The .bs pseudo-op. This generates a C_BSTAT symbol named ".bs".
1612 There is one argument, which is a csect symbol. The value of the
1613 .bs symbol is the index of this csect symbol. */
1624 if (ppc_current_block
!= NULL
)
1625 as_bad ("nested .bs blocks");
1627 name
= input_line_pointer
;
1628 endc
= get_symbol_end ();
1630 csect
= symbol_find_or_make (name
);
1632 *input_line_pointer
= endc
;
1634 sym
= symbol_make (".bs");
1635 S_SET_SEGMENT (sym
, now_seg
);
1636 S_SET_STORAGE_CLASS (sym
, C_BSTAT
);
1637 sym
->bsym
->flags
|= BSF_DEBUGGING
;
1638 sym
->sy_tc
.output
= 1;
1640 sym
->sy_tc
.within
= csect
;
1642 ppc_frob_label (sym
);
1644 ppc_current_block
= sym
;
1646 demand_empty_rest_of_line ();
1649 /* The .es pseudo-op. Generate a C_ESTART symbol named .es. */
1657 if (ppc_current_block
== NULL
)
1658 as_bad (".es without preceding .bs");
1660 sym
= symbol_make (".es");
1661 S_SET_SEGMENT (sym
, now_seg
);
1662 S_SET_STORAGE_CLASS (sym
, C_ESTAT
);
1663 sym
->bsym
->flags
|= BSF_DEBUGGING
;
1664 sym
->sy_tc
.output
= 1;
1666 ppc_frob_label (sym
);
1668 ppc_current_block
= NULL
;
1670 demand_empty_rest_of_line ();
1673 /* The .bb pseudo-op. Generate a C_BLOCK symbol named .bb, with a
1682 sym
= symbol_make (".bb");
1683 S_SET_SEGMENT (sym
, text_section
);
1684 sym
->sy_frag
= frag_now
;
1685 S_SET_VALUE (sym
, frag_now_fix ());
1686 S_SET_STORAGE_CLASS (sym
, C_BLOCK
);
1688 S_SET_NUMBER_AUXILIARY (sym
, 1);
1689 SA_SET_SYM_LNNO (sym
, get_absolute_expression ());
1691 sym
->sy_tc
.output
= 1;
1693 ppc_frob_label (sym
);
1695 demand_empty_rest_of_line ();
1698 /* The .eb pseudo-op. Generate a C_BLOCK symbol named .eb, with a
1707 sym
= symbol_make (".eb");
1708 S_SET_SEGMENT (sym
, text_section
);
1709 sym
->sy_frag
= frag_now
;
1710 S_SET_VALUE (sym
, frag_now_fix ());
1711 S_SET_STORAGE_CLASS (sym
, C_FCN
);
1712 S_SET_NUMBER_AUXILIARY (sym
, 1);
1713 SA_SET_SYM_LNNO (sym
, get_absolute_expression ());
1714 sym
->sy_tc
.output
= 1;
1716 ppc_frob_label (sym
);
1718 demand_empty_rest_of_line ();
1721 /* The .toc pseudo-op. Switch to the .toc subsegment. */
1727 if (ppc_toc_csect
!= (symbolS
*) NULL
)
1728 subseg_set (data_section
, ppc_toc_csect
->sy_tc
.subseg
);
1735 subseg
= ppc_data_subsegment
;
1736 ++ppc_data_subsegment
;
1738 subseg_new (segment_name (data_section
), subseg
);
1739 ppc_toc_frag
= frag_now
;
1741 sym
= symbol_find_or_make ("TOC[TC0]");
1742 sym
->sy_frag
= frag_now
;
1743 S_SET_SEGMENT (sym
, data_section
);
1744 S_SET_VALUE (sym
, (valueT
) frag_now_fix ());
1745 sym
->sy_tc
.subseg
= subseg
;
1746 sym
->sy_tc
.output
= 1;
1747 sym
->sy_tc
.within
= sym
;
1749 ppc_toc_csect
= sym
;
1751 for (list
= ppc_data_csects
;
1752 list
->sy_tc
.next
!= (symbolS
*) NULL
;
1753 list
= list
->sy_tc
.next
)
1755 list
->sy_tc
.next
= sym
;
1757 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
1758 symbol_append (sym
, list
->sy_tc
.within
, &symbol_rootP
, &symbol_lastP
);
1761 ppc_current_csect
= ppc_toc_csect
;
1763 demand_empty_rest_of_line ();
1766 #endif /* OBJ_COFF */
1768 /* The .tc pseudo-op. This is used when generating either XCOFF or
1769 ELF. This takes two or more arguments.
1771 When generating XCOFF output, the first argument is the name to
1772 give to this location in the toc; this will be a symbol with class
1773 TC. The rest of the arguments are 4 byte values to actually put at
1774 this location in the TOC; often there is just one more argument, a
1775 relocateable symbol reference.
1777 When not generating XCOFF output, the arguments are the same, but
1778 the first argument is simply ignored. */
1786 /* Define the TOC symbol name. */
1792 if (ppc_toc_csect
== (symbolS
*) NULL
1793 || ppc_toc_csect
!= ppc_current_csect
)
1795 as_bad (".tc not in .toc section");
1796 ignore_rest_of_line ();
1800 name
= input_line_pointer
;
1801 endc
= get_symbol_end ();
1803 sym
= symbol_find_or_make (name
);
1805 *input_line_pointer
= endc
;
1807 if (S_IS_DEFINED (sym
))
1811 label
= ppc_current_csect
->sy_tc
.within
;
1812 if (label
->sy_tc
.class != XMC_TC0
)
1814 as_warn (".tc with no label");
1815 ignore_rest_of_line ();
1819 S_SET_SEGMENT (label
, S_GET_SEGMENT (sym
));
1820 label
->sy_frag
= sym
->sy_frag
;
1821 S_SET_VALUE (label
, S_GET_VALUE (sym
));
1823 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1824 ++input_line_pointer
;
1829 S_SET_SEGMENT (sym
, now_seg
);
1830 sym
->sy_frag
= frag_now
;
1831 S_SET_VALUE (sym
, (valueT
) frag_now_fix ());
1832 sym
->sy_tc
.class = XMC_TC
;
1833 sym
->sy_tc
.output
= 1;
1835 ppc_frob_label (sym
);
1838 #else /* ! defined (OBJ_COFF) */
1840 /* Skip the TOC symbol name. */
1841 while (is_part_of_name (*input_line_pointer
)
1842 || *input_line_pointer
== '['
1843 || *input_line_pointer
== ']'
1844 || *input_line_pointer
== '{'
1845 || *input_line_pointer
== '}')
1846 ++input_line_pointer
;
1848 /* Align to a four byte boundary. */
1850 record_alignment (now_seg
, 2);
1852 #endif /* ! defined (OBJ_COFF) */
1854 if (*input_line_pointer
!= ',')
1855 demand_empty_rest_of_line ();
1858 ++input_line_pointer
;
1865 /* XCOFF specific symbol and file handling. */
1867 /* Canonicalize the symbol name. We use the to force the suffix, if
1868 any, to use square brackets, and to be in upper case. */
1871 ppc_canonicalize_symbol_name (name
)
1876 for (s
= name
; *s
!= '\0' && *s
!= '{' && *s
!= '['; s
++)
1890 for (s
++; *s
!= '\0' && *s
!= brac
; s
++)
1894 if (*s
== '\0' || s
[1] != '\0')
1895 as_bad ("bad symbol suffix");
1903 /* Set the class of a symbol based on the suffix, if any. This is
1904 called whenever a new symbol is created. */
1907 ppc_symbol_new_hook (sym
)
1912 sym
->sy_tc
.next
= NULL
;
1913 sym
->sy_tc
.output
= 0;
1914 sym
->sy_tc
.class = -1;
1915 sym
->sy_tc
.real_name
= NULL
;
1916 sym
->sy_tc
.subseg
= 0;
1917 sym
->sy_tc
.align
= 0;
1918 sym
->sy_tc
.size
= NULL
;
1919 sym
->sy_tc
.within
= NULL
;
1921 s
= strchr (S_GET_NAME (sym
), '[');
1922 if (s
== (const char *) NULL
)
1924 /* There is no suffix. */
1933 if (strcmp (s
, "BS]") == 0)
1934 sym
->sy_tc
.class = XMC_BS
;
1937 if (strcmp (s
, "DB]") == 0)
1938 sym
->sy_tc
.class = XMC_DB
;
1939 else if (strcmp (s
, "DS]") == 0)
1940 sym
->sy_tc
.class = XMC_DS
;
1943 if (strcmp (s
, "GL]") == 0)
1944 sym
->sy_tc
.class = XMC_GL
;
1947 if (strcmp (s
, "PR]") == 0)
1948 sym
->sy_tc
.class = XMC_PR
;
1951 if (strcmp (s
, "RO]") == 0)
1952 sym
->sy_tc
.class = XMC_RO
;
1953 else if (strcmp (s
, "RW]") == 0)
1954 sym
->sy_tc
.class = XMC_RW
;
1957 if (strcmp (s
, "SV]") == 0)
1958 sym
->sy_tc
.class = XMC_SV
;
1961 if (strcmp (s
, "TC]") == 0)
1962 sym
->sy_tc
.class = XMC_TC
;
1963 else if (strcmp (s
, "TI]") == 0)
1964 sym
->sy_tc
.class = XMC_TI
;
1965 else if (strcmp (s
, "TB]") == 0)
1966 sym
->sy_tc
.class = XMC_TB
;
1967 else if (strcmp (s
, "TC0]") == 0 || strcmp (s
, "T0]") == 0)
1968 sym
->sy_tc
.class = XMC_TC0
;
1971 if (strcmp (s
, "UA]") == 0)
1972 sym
->sy_tc
.class = XMC_UA
;
1973 else if (strcmp (s
, "UC]") == 0)
1974 sym
->sy_tc
.class = XMC_UC
;
1977 if (strcmp (s
, "XO]") == 0)
1978 sym
->sy_tc
.class = XMC_XO
;
1982 if (sym
->sy_tc
.class == -1)
1983 as_bad ("Unrecognized symbol suffix");
1986 /* Set the class of a label based on where it is defined. This
1987 handles symbols without suffixes. Also, move the symbol so that it
1988 follows the csect symbol. */
1991 ppc_frob_label (sym
)
1994 if (ppc_current_csect
!= (symbolS
*) NULL
)
1996 if (sym
->sy_tc
.class == -1)
1997 sym
->sy_tc
.class = ppc_current_csect
->sy_tc
.class;
1999 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
2000 symbol_append (sym
, ppc_current_csect
->sy_tc
.within
, &symbol_rootP
,
2002 ppc_current_csect
->sy_tc
.within
= sym
;
2006 /* Change the name of a symbol just before writing it out. Set the
2007 real name if the .rename pseudo-op was used. Otherwise, remove any
2008 class suffix. Return 1 if the symbol should not be included in the
2012 ppc_frob_symbol (sym
)
2015 static symbolS
*ppc_last_function
;
2016 static symbolS
*set_end
;
2018 /* Discard symbols that should not be included in the output symbol
2020 if (! sym
->sy_used_in_reloc
2021 && ((sym
->bsym
->flags
& BSF_SECTION_SYM
) != 0
2022 || (! S_IS_EXTERNAL (sym
)
2023 && ! sym
->sy_tc
.output
2024 && S_GET_STORAGE_CLASS (sym
) != C_FILE
)))
2027 if (sym
->sy_tc
.real_name
!= (char *) NULL
)
2028 S_SET_NAME (sym
, sym
->sy_tc
.real_name
);
2034 name
= S_GET_NAME (sym
);
2035 s
= strchr (name
, '[');
2036 if (s
!= (char *) NULL
)
2042 snew
= xmalloc (len
+ 1);
2043 memcpy (snew
, name
, len
);
2046 S_SET_NAME (sym
, snew
);
2050 if (set_end
!= (symbolS
*) NULL
)
2052 SA_SET_SYM_ENDNDX (set_end
, sym
);
2056 if (SF_GET_FUNCTION (sym
))
2058 if (ppc_last_function
!= (symbolS
*) NULL
)
2059 as_warn ("two .function pseudo-ops with no intervening .ef");
2060 ppc_last_function
= sym
;
2061 if (sym
->sy_tc
.size
!= (symbolS
*) NULL
)
2063 resolve_symbol_value (sym
->sy_tc
.size
);
2064 SA_SET_SYM_FSIZE (sym
, (long) S_GET_VALUE (sym
->sy_tc
.size
));
2067 else if (S_GET_STORAGE_CLASS (sym
) == C_FCN
2068 && strcmp (S_GET_NAME (sym
), ".ef") == 0)
2070 if (ppc_last_function
== (symbolS
*) NULL
)
2071 as_warn (".ef with no preceding .function");
2074 set_end
= ppc_last_function
;
2075 ppc_last_function
= NULL
;
2077 /* We don't have a C_EFCN symbol, but we need to force the
2078 COFF backend to believe that it has seen one. */
2079 coff_last_function
= NULL
;
2083 if (! S_IS_EXTERNAL (sym
)
2084 && (sym
->bsym
->flags
& BSF_SECTION_SYM
) == 0
2085 && S_GET_STORAGE_CLASS (sym
) != C_FILE
2086 && S_GET_STORAGE_CLASS (sym
) != C_FCN
2087 && S_GET_STORAGE_CLASS (sym
) != C_BSTAT
2088 && S_GET_STORAGE_CLASS (sym
) != C_ESTAT
2089 && S_GET_SEGMENT (sym
) != ppc_coff_debug_section
)
2090 S_SET_STORAGE_CLASS (sym
, C_HIDEXT
);
2092 if (S_GET_STORAGE_CLASS (sym
) == C_EXT
2093 || S_GET_STORAGE_CLASS (sym
) == C_HIDEXT
)
2096 union internal_auxent
*a
;
2098 /* Create a csect aux. */
2099 i
= S_GET_NUMBER_AUXILIARY (sym
);
2100 S_SET_NUMBER_AUXILIARY (sym
, i
+ 1);
2101 a
= &coffsymbol (sym
->bsym
)->native
[i
+ 1].u
.auxent
;
2102 if (sym
->sy_tc
.class == XMC_TC0
)
2104 /* This is the TOC table. */
2105 know (strcmp (S_GET_NAME (sym
), "TOC") == 0);
2106 a
->x_csect
.x_scnlen
.l
= 0;
2107 a
->x_csect
.x_smtyp
= (2 << 3) | XTY_SD
;
2109 else if (sym
->sy_tc
.subseg
!= 0)
2111 /* This is a csect symbol. x_scnlen is the size of the
2113 if (sym
->sy_tc
.next
== (symbolS
*) NULL
)
2114 a
->x_csect
.x_scnlen
.l
= (bfd_section_size (stdoutput
,
2115 S_GET_SEGMENT (sym
))
2116 - S_GET_VALUE (sym
));
2119 resolve_symbol_value (sym
->sy_tc
.next
);
2120 a
->x_csect
.x_scnlen
.l
= (S_GET_VALUE (sym
->sy_tc
.next
)
2121 - S_GET_VALUE (sym
));
2123 a
->x_csect
.x_smtyp
= (sym
->sy_tc
.align
<< 3) | XTY_SD
;
2125 else if (S_GET_SEGMENT (sym
) == bss_section
)
2127 /* This is a common symbol. */
2128 a
->x_csect
.x_scnlen
.l
= sym
->sy_frag
->fr_offset
;
2129 a
->x_csect
.x_smtyp
= (sym
->sy_tc
.align
<< 3) | XTY_CM
;
2130 if (S_IS_EXTERNAL (sym
))
2131 sym
->sy_tc
.class = XMC_RW
;
2133 sym
->sy_tc
.class = XMC_BS
;
2135 else if (! S_IS_DEFINED (sym
))
2137 /* This is an external symbol. */
2138 a
->x_csect
.x_scnlen
.l
= 0;
2139 a
->x_csect
.x_smtyp
= XTY_ER
;
2141 else if (sym
->sy_tc
.class == XMC_TC
)
2145 /* This is a TOC definition. x_scnlen is the size of the
2147 next
= symbol_next (sym
);
2148 while (next
->sy_tc
.class == XMC_TC0
)
2149 next
= symbol_next (next
);
2150 if (next
== (symbolS
*) NULL
2151 || next
->sy_tc
.class != XMC_TC
)
2153 if (ppc_after_toc_frag
== (fragS
*) NULL
)
2154 a
->x_csect
.x_scnlen
.l
= (bfd_section_size (stdoutput
,
2156 - S_GET_VALUE (sym
));
2158 a
->x_csect
.x_scnlen
.l
= (ppc_after_toc_frag
->fr_address
2159 - S_GET_VALUE (sym
));
2163 resolve_symbol_value (next
);
2164 a
->x_csect
.x_scnlen
.l
= (S_GET_VALUE (next
)
2165 - S_GET_VALUE (sym
));
2167 a
->x_csect
.x_smtyp
= (2 << 3) | XTY_SD
;
2173 /* This is a normal symbol definition. x_scnlen is the
2174 symbol index of the containing csect. */
2175 if (S_GET_SEGMENT (sym
) == text_section
)
2176 csect
= ppc_text_csects
;
2177 else if (S_GET_SEGMENT (sym
) == data_section
)
2178 csect
= ppc_data_csects
;
2182 /* Skip the initial dummy symbol. */
2183 csect
= csect
->sy_tc
.next
;
2185 if (csect
== (symbolS
*) NULL
)
2186 a
->x_csect
.x_scnlen
.l
= 0;
2189 while (csect
->sy_tc
.next
!= (symbolS
*) NULL
)
2191 resolve_symbol_value (csect
->sy_tc
.next
);
2192 if (S_GET_VALUE (csect
->sy_tc
.next
) > S_GET_VALUE (sym
))
2194 csect
= csect
->sy_tc
.next
;
2197 a
->x_csect
.x_scnlen
.p
= coffsymbol (csect
->bsym
)->native
;
2198 coffsymbol (sym
->bsym
)->native
[i
+ 1].fix_scnlen
= 1;
2200 a
->x_csect
.x_smtyp
= XTY_LD
;
2203 a
->x_csect
.x_parmhash
= 0;
2204 a
->x_csect
.x_snhash
= 0;
2205 if (sym
->sy_tc
.class == -1)
2206 a
->x_csect
.x_smclas
= XMC_PR
;
2208 a
->x_csect
.x_smclas
= sym
->sy_tc
.class;
2209 a
->x_csect
.x_stab
= 0;
2210 a
->x_csect
.x_snstab
= 0;
2212 else if (S_GET_STORAGE_CLASS (sym
) == C_BSTAT
)
2214 /* We want the value to be the symbol index of the referenced
2215 csect symbol. BFD will do that for us if we set the right
2218 (valueT
) coffsymbol (sym
->sy_tc
.within
->bsym
)->native
);
2219 coffsymbol (sym
->bsym
)->native
->fix_value
= 1;
2221 else if (S_GET_STORAGE_CLASS (sym
) == C_STSYM
)
2226 /* The value is the offset from the enclosing csect. */
2227 block
= sym
->sy_tc
.within
;
2228 csect
= block
->sy_tc
.within
;
2229 resolve_symbol_value (csect
);
2230 S_SET_VALUE (sym
, S_GET_VALUE (sym
) - S_GET_VALUE (csect
));
2236 /* Set the VMA for a section. This is called on all the sections in
2240 ppc_frob_section (sec
)
2243 static bfd_size_type vma
= 0;
2245 bfd_set_section_vma (stdoutput
, sec
, vma
);
2246 vma
+= bfd_section_size (stdoutput
, sec
);
2249 /* Adjust the file by adding a .debug section if needed. */
2254 if (ppc_debug_name_section_size
> 0)
2258 sec
= bfd_make_section (stdoutput
, ".debug");
2259 if (sec
== (asection
*) NULL
2260 || ! bfd_set_section_size (stdoutput
, sec
,
2261 ppc_debug_name_section_size
)
2262 || ! bfd_set_section_flags (stdoutput
, sec
,
2263 SEC_HAS_CONTENTS
| SEC_LOAD
))
2264 as_fatal ("can't make .debug section");
2268 #endif /* OBJ_COFF */
2270 /* Turn a string in input_line_pointer into a floating point constant
2271 of type type, and store the appropriate bytes in *litp. The number
2272 of LITTLENUMS emitted is stored in *sizep . An error message is
2273 returned, or NULL on OK. */
2276 md_atof (type
, litp
, sizep
)
2282 LITTLENUM_TYPE words
[4];
2298 return "bad call to md_atof";
2301 t
= atof_ieee (input_line_pointer
, type
, words
);
2303 input_line_pointer
= t
;
2309 for (i
= 0; i
< prec
; i
++)
2311 md_number_to_chars (litp
, (valueT
) words
[i
], 2);
2317 for (i
= prec
- 1; i
>= 0; i
--)
2319 md_number_to_chars (litp
, (valueT
) words
[i
], 2);
2327 /* Write a value out to the object file, using the appropriate
2331 md_number_to_chars (buf
, val
, n
)
2337 number_to_chars_bigendian (buf
, val
, n
);
2339 number_to_chars_littleendian (buf
, val
, n
);
2342 /* Align a section (I don't know why this is machine dependent). */
2345 md_section_align (seg
, addr
)
2349 int align
= bfd_get_section_alignment (stdoutput
, seg
);
2351 return ((addr
+ (1 << align
) - 1) & (-1 << align
));
2354 /* We don't have any form of relaxing. */
2357 md_estimate_size_before_relax (fragp
, seg
)
2364 const relax_typeS md_relax_table
[] =
2369 /* Convert a machine dependent frag. We never generate these. */
2372 md_convert_frag (abfd
, sec
, fragp
)
2380 /* We have no need to default values of symbols. */
2384 md_undefined_symbol (name
)
2390 /* Functions concerning relocs. */
2392 /* The location from which a PC relative jump should be calculated,
2393 given a PC relative reloc. */
2396 md_pcrel_from (fixp
)
2400 if (fixp
->fx_addsy
!= (symbolS
*) NULL
2401 && ! S_IS_DEFINED (fixp
->fx_addsy
))
2405 return fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2410 /* This is called to see whether a fixup should be adjusted to use a
2411 section symbol. We take the opportunity to change a fixup against
2412 a symbol in the TOC subsegment into a reloc against the
2413 corresponding .tc symbol. */
2416 ppc_fix_adjustable (fix
)
2421 resolve_symbol_value (fix
->fx_addsy
);
2422 val
= S_GET_VALUE (fix
->fx_addsy
);
2423 if (ppc_toc_csect
!= (symbolS
*) NULL
2424 && fix
->fx_addsy
!= (symbolS
*) NULL
2425 && fix
->fx_addsy
!= ppc_toc_csect
2426 && S_GET_SEGMENT (fix
->fx_addsy
) == data_section
2427 && val
>= ppc_toc_frag
->fr_address
2428 && (ppc_after_toc_frag
== (fragS
*) NULL
2429 || val
< ppc_after_toc_frag
->fr_address
))
2433 for (sy
= symbol_next (ppc_toc_csect
);
2434 sy
!= (symbolS
*) NULL
;
2435 sy
= symbol_next (sy
))
2437 if (sy
->sy_tc
.class == XMC_TC0
)
2439 if (sy
->sy_tc
.class != XMC_TC
)
2441 resolve_symbol_value (sy
);
2442 if (val
== S_GET_VALUE (sy
))
2445 fix
->fx_addnumber
= val
- ppc_toc_frag
->fr_address
;
2450 as_bad_where (fix
->fx_file
, fix
->fx_line
,
2451 "symbol in .toc does not match any .tc");
2454 /* Possibly adjust the reloc to be against the csect. */
2455 if (fix
->fx_addsy
!= (symbolS
*) NULL
2456 && fix
->fx_addsy
->sy_tc
.subseg
== 0
2457 && fix
->fx_addsy
->sy_tc
.class != XMC_TC0
2458 && fix
->fx_addsy
->sy_tc
.class != XMC_TC
2459 && S_GET_SEGMENT (fix
->fx_addsy
) != bss_section
)
2463 if (S_GET_SEGMENT (fix
->fx_addsy
) == text_section
)
2464 csect
= ppc_text_csects
;
2465 else if (S_GET_SEGMENT (fix
->fx_addsy
) == data_section
)
2466 csect
= ppc_data_csects
;
2470 /* Skip the initial dummy symbol. */
2471 csect
= csect
->sy_tc
.next
;
2473 if (csect
!= (symbolS
*) NULL
)
2475 while (csect
->sy_tc
.next
!= (symbolS
*) NULL
2476 && (csect
->sy_tc
.next
->sy_frag
->fr_address
2477 <= fix
->fx_addsy
->sy_frag
->fr_address
))
2478 csect
= csect
->sy_tc
.next
;
2480 fix
->fx_offset
+= (S_GET_VALUE (fix
->fx_addsy
)
2481 - csect
->sy_frag
->fr_address
);
2482 fix
->fx_addsy
= csect
;
2486 /* Adjust a reloc against a .lcomm symbol to be against the base
2488 if (fix
->fx_addsy
!= (symbolS
*) NULL
2489 && S_GET_SEGMENT (fix
->fx_addsy
) == bss_section
2490 && ! S_IS_EXTERNAL (fix
->fx_addsy
))
2492 resolve_symbol_value (fix
->fx_addsy
->sy_frag
->fr_symbol
);
2493 fix
->fx_offset
+= (S_GET_VALUE (fix
->fx_addsy
)
2494 - S_GET_VALUE (fix
->fx_addsy
->sy_frag
->fr_symbol
));
2495 fix
->fx_addsy
= fix
->fx_addsy
->sy_frag
->fr_symbol
;
2503 /* See whether a symbol is in the TOC section. */
2506 ppc_is_toc_sym (sym
)
2510 return sym
->sy_tc
.class == XMC_TC
;
2512 return strcmp (segment_name (S_GET_SEGMENT (sym
)), ".got") == 0;
2516 /* Apply a fixup to the object code. This is called for all the
2517 fixups we generated by the call to fix_new_exp, above. In the call
2518 above we used a reloc code which was the largest legal reloc code
2519 plus the operand index. Here we undo that to recover the operand
2520 index. At this point all symbol values should be fully resolved,
2521 and we attempt to completely resolve the reloc. If we can not do
2522 that, we determine the correct reloc code and put it back in the
2526 md_apply_fix3 (fixp
, valuep
, seg
)
2533 /* FIXME FIXME FIXME: The value we are passed in *valuep includes
2534 the symbol values. Since we are using BFD_ASSEMBLER, if we are
2535 doing this relocation the code in write.c is going to call
2536 bfd_perform_relocation, which is also going to use the symbol
2537 value. That means that if the reloc is fully resolved we want to
2538 use *valuep since bfd_perform_relocation is not being used.
2539 However, if the reloc is not fully resolved we do not want to use
2540 *valuep, and must use fx_offset instead. However, if the reloc
2541 is PC relative, we do want to use *valuep since it includes the
2542 result of md_pcrel_from. This is confusing. */
2544 if (fixp
->fx_addsy
== (symbolS
*) NULL
)
2549 else if (fixp
->fx_pcrel
)
2553 value
= fixp
->fx_offset
;
2554 if (fixp
->fx_subsy
!= (symbolS
*) NULL
)
2556 if (S_GET_SEGMENT (fixp
->fx_subsy
) == absolute_section
)
2557 value
-= S_GET_VALUE (fixp
->fx_subsy
);
2560 /* We can't actually support subtracting a symbol. */
2561 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2562 "expression too complex");
2567 if ((int) fixp
->fx_r_type
>= (int) BFD_RELOC_UNUSED
)
2570 const struct powerpc_operand
*operand
;
2574 opindex
= (int) fixp
->fx_r_type
- (int) BFD_RELOC_UNUSED
;
2576 operand
= &powerpc_operands
[opindex
];
2579 /* It appears that an instruction like
2581 when LC..1 is not a TOC symbol does not generate a reloc. It
2582 uses the offset of LC..1 within its csect. However, .long
2583 LC..1 will generate a reloc. I can't find any documentation
2584 on how these cases are to be distinguished, so this is a wild
2585 guess. These cases are generated by gcc -mminimal-toc. */
2586 if ((operand
->flags
& PPC_OPERAND_PARENS
) != 0
2587 && operand
->bits
== 16
2588 && operand
->shift
== 0
2589 && operand
->insert
== NULL
2590 && fixp
->fx_addsy
!= NULL
2591 && fixp
->fx_addsy
->sy_tc
.subseg
!= 0
2592 && fixp
->fx_addsy
->sy_tc
.class != XMC_TC
2593 && fixp
->fx_addsy
->sy_tc
.class != XMC_TC0
2594 && S_GET_SEGMENT (fixp
->fx_addsy
) != bss_section
)
2596 value
= fixp
->fx_offset
;
2601 /* Fetch the instruction, insert the fully resolved operand
2602 value, and stuff the instruction back again. */
2603 where
= fixp
->fx_frag
->fr_literal
+ fixp
->fx_where
;
2605 insn
= bfd_getb32 ((unsigned char *) where
);
2607 insn
= bfd_getl32 ((unsigned char *) where
);
2608 insn
= ppc_insert_operand (insn
, operand
, (offsetT
) value
,
2609 fixp
->fx_file
, fixp
->fx_line
);
2611 bfd_putb32 ((bfd_vma
) insn
, (unsigned char *) where
);
2613 bfd_putl32 ((bfd_vma
) insn
, (unsigned char *) where
);
2617 /* Nothing else to do here. */
2621 /* Determine a BFD reloc value based on the operand information.
2622 We are only prepared to turn a few of the operands into
2624 FIXME: We need to handle the DS field at the very least.
2625 FIXME: Handling 16 bit branches would also be reasonable.
2626 FIXME: Selecting the reloc type is a bit haphazard; perhaps
2627 there should be a new field in the operand table. */
2628 if ((operand
->flags
& PPC_OPERAND_RELATIVE
) != 0
2629 && operand
->bits
== 26
2630 && operand
->shift
== 0)
2631 fixp
->fx_r_type
= BFD_RELOC_PPC_B26
;
2632 else if ((operand
->flags
& PPC_OPERAND_ABSOLUTE
) != 0
2633 && operand
->bits
== 26
2634 && operand
->shift
== 0)
2635 fixp
->fx_r_type
= BFD_RELOC_PPC_BA26
;
2636 else if ((operand
->flags
& PPC_OPERAND_PARENS
) != 0
2637 && operand
->bits
== 16
2638 && operand
->shift
== 0
2639 && operand
->insert
== NULL
2640 && fixp
->fx_addsy
!= NULL
2641 && ppc_is_toc_sym (fixp
->fx_addsy
))
2645 fixp
->fx_where
+= 2;
2646 fixp
->fx_r_type
= BFD_RELOC_PPC_TOC16
;
2650 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2651 "unresolved expression that must be resolved");
2659 ppc_elf_validate_fix (fixp
, seg
);
2661 switch (fixp
->fx_r_type
)
2666 fixp
->fx_r_type
= BFD_RELOC_32_PCREL
;
2667 value
+= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2668 } /* fall through */
2670 case BFD_RELOC_32_PCREL
:
2671 md_number_to_chars (fixp
->fx_frag
->fr_literal
+ fixp
->fx_where
,
2674 case BFD_RELOC_LO16
:
2675 case BFD_RELOC_HI16
:
2676 case BFD_RELOC_HI16_S
:
2677 case BFD_RELOC_PPC_TOC16
:
2682 md_number_to_chars (fixp
->fx_frag
->fr_literal
+ fixp
->fx_where
,
2690 md_number_to_chars (fixp
->fx_frag
->fr_literal
+ fixp
->fx_where
,
2699 fixp
->fx_addnumber
= value
;
2701 if (fixp
->fx_r_type
!= BFD_RELOC_PPC_TOC16
)
2702 fixp
->fx_addnumber
= 0;
2705 /* We want to use the offset within the data segment of the
2706 symbol, not the actual VMA of the symbol. */
2707 fixp
->fx_addnumber
=
2708 - bfd_get_section_vma (stdoutput
, S_GET_SEGMENT (fixp
->fx_addsy
));
2715 /* Generate a reloc for a fixup. */
2718 tc_gen_reloc (seg
, fixp
)
2724 reloc
= (arelent
*) bfd_alloc_by_size_t (stdoutput
, sizeof (arelent
));
2726 reloc
->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
2727 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2728 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
2729 if (reloc
->howto
== (reloc_howto_type
*) NULL
)
2731 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2732 "reloc %d not supported by object file format", (int)fixp
->fx_r_type
);
2735 reloc
->addend
= fixp
->fx_addnumber
;