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)
586 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
587 "Relocation cannot be done when using -mrelocatable");
593 /* We need to keep a list of fixups. We can't simply generate them as
594 we go, because that would require us to first create the frag, and
595 that would screw up references to ``.''. */
601 bfd_reloc_code_real_type reloc
;
604 #define MAX_INSN_FIXUPS (5)
606 /* This routine is called for each instruction to be assembled. */
613 const struct powerpc_opcode
*opcode
;
615 const unsigned char *opindex_ptr
;
619 struct ppc_fixup fixups
[MAX_INSN_FIXUPS
];
623 bfd_reloc_code_real_type reloc
;
625 /* Get the opcode. */
626 for (s
= str
; *s
!= '\0' && ! isspace (*s
); s
++)
631 /* Look up the opcode in the hash table. */
632 opcode
= (const struct powerpc_opcode
*) hash_find (ppc_hash
, str
);
633 if (opcode
== (const struct powerpc_opcode
*) NULL
)
635 const struct powerpc_macro
*macro
;
637 macro
= (const struct powerpc_macro
*) hash_find (ppc_macro_hash
, str
);
638 if (macro
== (const struct powerpc_macro
*) NULL
)
639 as_bad ("Unrecognized opcode: `%s'", str
);
641 ppc_macro (s
, macro
);
646 insn
= opcode
->opcode
;
649 while (isspace (*str
))
652 /* PowerPC operands are just expressions. The only real issue is
653 that a few operand types are optional. All cases which might use
654 an optional operand separate the operands only with commas (in
655 some cases parentheses are used, as in ``lwz 1,0(1)'' but such
656 cases never have optional operands). There is never more than
657 one optional operand for an instruction. So, before we start
658 seriously parsing the operands, we check to see if we have an
659 optional operand, and, if we do, we count the number of commas to
660 see whether the operand should be omitted. */
662 for (opindex_ptr
= opcode
->operands
; *opindex_ptr
!= 0; opindex_ptr
++)
664 const struct powerpc_operand
*operand
;
666 operand
= &powerpc_operands
[*opindex_ptr
];
667 if ((operand
->flags
& PPC_OPERAND_OPTIONAL
) != 0)
669 unsigned int opcount
;
671 /* There is an optional operand. Count the number of
672 commas in the input line. */
679 while ((s
= strchr (s
, ',')) != (char *) NULL
)
686 /* If there are fewer operands in the line then are called
687 for by the instruction, we want to skip the optional
689 if (opcount
< strlen (opcode
->operands
))
696 /* Gather the operands. */
700 for (opindex_ptr
= opcode
->operands
; *opindex_ptr
!= 0; opindex_ptr
++)
702 const struct powerpc_operand
*operand
;
708 if (next_opindex
== 0)
709 operand
= &powerpc_operands
[*opindex_ptr
];
712 operand
= &powerpc_operands
[next_opindex
];
718 /* If this is a fake operand, then we do not expect anything
720 if ((operand
->flags
& PPC_OPERAND_FAKE
) != 0)
722 insn
= (*operand
->insert
) (insn
, 0L, &errmsg
);
723 if (errmsg
!= (const char *) NULL
)
728 /* If this is an optional operand, and we are skipping it, just
730 if ((operand
->flags
& PPC_OPERAND_OPTIONAL
) != 0
735 insn
= (*operand
->insert
) (insn
, 0L, &errmsg
);
736 if (errmsg
!= (const char *) NULL
)
739 if ((operand
->flags
& PPC_OPERAND_NEXT
) != 0)
740 next_opindex
= *opindex_ptr
+ 1;
744 /* Gather the operand. */
745 hold
= input_line_pointer
;
746 input_line_pointer
= str
;
748 str
= input_line_pointer
;
749 input_line_pointer
= hold
;
751 if (ex
.X_op
== O_illegal
)
752 as_bad ("illegal operand");
753 else if (ex
.X_op
== O_absent
)
754 as_bad ("missing operand");
755 else if (ex
.X_op
== O_constant
)
756 insn
= ppc_insert_operand (insn
, operand
, ex
.X_add_number
,
760 else if ((reloc
= ppc_elf_suffix (&str
)) != BFD_RELOC_UNUSED
)
762 /* We need to generate a fixup for this expression. */
763 if (fc
>= MAX_INSN_FIXUPS
)
764 as_fatal ("too many fixups");
766 fixups
[fc
].opindex
= 0;
767 fixups
[fc
].reloc
= reloc
;
774 /* We need to generate a fixup for this expression. */
775 if (fc
>= MAX_INSN_FIXUPS
)
776 as_fatal ("too many fixups");
778 fixups
[fc
].opindex
= *opindex_ptr
;
779 fixups
[fc
].reloc
= BFD_RELOC_UNUSED
;
788 else if ((operand
->flags
& PPC_OPERAND_PARENS
) != 0)
796 /* The call to expression should have advanced str past any
799 && (endc
!= ',' || *str
!= '\0'))
801 as_bad ("syntax error; found `%c' but expected `%c'", *str
, endc
);
809 while (isspace (*str
))
813 as_bad ("junk at end of line: `%s'", str
);
815 /* Write out the instruction. */
817 md_number_to_chars (f
, insn
, 4);
819 /* Create any fixups. At this point we do not use a
820 bfd_reloc_code_real_type, but instead just use the operand index.
821 This lets us easily handle fixups for any operand type, although
822 that is admittedly not a very exciting feature. We pick a BFD
823 reloc type in md_apply_fix. */
824 for (i
= 0; i
< fc
; i
++)
826 const struct powerpc_operand
*operand
;
828 operand
= &powerpc_operands
[fixups
[i
].opindex
];
829 if (fixups
[i
].reloc
!= BFD_RELOC_UNUSED
)
831 reloc_howto_type
*reloc_howto
= bfd_reloc_type_lookup (stdoutput
, fixups
[i
].reloc
);
832 int offset
= (!reloc_howto
) ? 0 : (4 - bfd_get_reloc_size (reloc_howto
));
837 fix_new_exp (frag_now
, f
- frag_now
->fr_literal
+ offset
, 4 - offset
,
838 &fixups
[i
].exp
, (reloc_howto
&& reloc_howto
->pc_relative
),
842 fix_new_exp (frag_now
, f
- frag_now
->fr_literal
, 4,
844 (operand
->flags
& PPC_OPERAND_RELATIVE
) != 0,
845 ((bfd_reloc_code_real_type
)
846 (fixups
[i
].opindex
+ (int) BFD_RELOC_UNUSED
)));
850 #ifndef WORKING_DOT_WORD
851 /* Handle long and short jumps */
853 md_create_short_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
855 addressT from_addr
, to_addr
;
863 md_create_long_jump (ptr
, from_addr
, to_addr
, frag
, to_symbol
)
865 addressT from_addr
, to_addr
;
873 /* Handle a macro. Gather all the operands, transform them as
874 described by the macro, and call md_assemble recursively. All the
875 operands are separated by commas; we don't accept parentheses
876 around operands here. */
879 ppc_macro (str
, macro
)
881 const struct powerpc_macro
*macro
;
892 /* Gather the users operands into the operands array. */
897 if (count
>= sizeof operands
/ sizeof operands
[0])
899 operands
[count
++] = s
;
901 if (s
== (char *) NULL
)
906 if (count
!= macro
->operands
)
908 as_bad ("wrong number of operands");
912 /* Work out how large the string must be (the size is unbounded
913 because it includes user input). */
915 format
= macro
->format
;
916 while (*format
!= '\0')
925 arg
= strtol (format
+ 1, &send
, 10);
926 know (send
!= format
&& arg
>= 0 && arg
< count
);
927 len
+= strlen (operands
[arg
]);
932 /* Put the string together. */
933 complete
= s
= (char *) alloca (len
+ 1);
934 format
= macro
->format
;
935 while (*format
!= '\0')
941 arg
= strtol (format
+ 1, &send
, 10);
942 strcpy (s
, operands
[arg
]);
949 /* Assemble the constructed instruction. */
950 md_assemble (complete
);
953 /* Pseudo-op handling. */
955 /* The .byte pseudo-op. This is similar to the normal .byte
956 pseudo-op, but it can also take a single ASCII string. */
962 if (*input_line_pointer
!= '\"')
968 /* Gather characters. A real double quote is doubled. Unusual
969 characters are not permitted. */
970 ++input_line_pointer
;
975 c
= *input_line_pointer
++;
979 if (*input_line_pointer
!= '\"')
981 ++input_line_pointer
;
984 FRAG_APPEND_1_CHAR (c
);
987 demand_empty_rest_of_line ();
992 /* XCOFF specific pseudo-op handling. */
994 /* The .comm and .lcomm pseudo-ops for XCOFF. XCOFF puts common
995 symbols in the .bss segment as though they were local common
996 symbols, and uses a different smclas. */
1002 asection
*current_seg
= now_seg
;
1003 subsegT current_subseg
= now_subseg
;
1009 symbolS
*lcomm_sym
= NULL
;
1013 name
= input_line_pointer
;
1014 endc
= get_symbol_end ();
1015 end_name
= input_line_pointer
;
1018 if (*input_line_pointer
!= ',')
1020 as_bad ("missing size");
1021 ignore_rest_of_line ();
1024 ++input_line_pointer
;
1026 size
= get_absolute_expression ();
1029 as_bad ("negative size");
1030 ignore_rest_of_line ();
1036 /* The third argument to .comm is the alignment. */
1037 if (*input_line_pointer
!= ',')
1041 ++input_line_pointer
;
1042 align
= get_absolute_expression ();
1045 as_warn ("ignoring bad alignment");
1064 /* The third argument to .lcomm appears to be the real local
1065 common symbol to create. References to the symbol named in
1066 the first argument are turned into references to the third
1068 if (*input_line_pointer
!= ',')
1070 as_bad ("missing real symbol name");
1071 ignore_rest_of_line ();
1074 ++input_line_pointer
;
1076 lcomm_name
= input_line_pointer
;
1077 lcomm_endc
= get_symbol_end ();
1079 lcomm_sym
= symbol_find_or_make (lcomm_name
);
1081 *input_line_pointer
= lcomm_endc
;
1085 sym
= symbol_find_or_make (name
);
1088 if (S_IS_DEFINED (sym
)
1089 || S_GET_VALUE (sym
) != 0)
1091 as_bad ("attempt to redefine symbol");
1092 ignore_rest_of_line ();
1096 record_alignment (bss_section
, align
);
1099 || ! S_IS_DEFINED (lcomm_sym
))
1108 S_SET_EXTERNAL (sym
);
1112 lcomm_sym
->sy_tc
.output
= 1;
1113 def_sym
= lcomm_sym
;
1117 subseg_set (bss_section
, 1);
1118 frag_align (align
, 0);
1120 def_sym
->sy_frag
= frag_now
;
1121 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, def_sym
,
1122 def_size
, (char *) NULL
);
1124 S_SET_SEGMENT (def_sym
, bss_section
);
1125 def_sym
->sy_tc
.align
= align
;
1129 /* Align the size of lcomm_sym. */
1130 lcomm_sym
->sy_frag
->fr_offset
=
1131 ((lcomm_sym
->sy_frag
->fr_offset
+ (1 << align
) - 1)
1132 &~ ((1 << align
) - 1));
1133 if (align
> lcomm_sym
->sy_tc
.align
)
1134 lcomm_sym
->sy_tc
.align
= align
;
1139 /* Make sym an offset from lcomm_sym. */
1140 S_SET_SEGMENT (sym
, bss_section
);
1141 sym
->sy_frag
= lcomm_sym
->sy_frag
;
1142 S_SET_VALUE (sym
, lcomm_sym
->sy_frag
->fr_offset
);
1143 lcomm_sym
->sy_frag
->fr_offset
+= size
;
1146 subseg_set (current_seg
, current_subseg
);
1148 demand_empty_rest_of_line ();
1151 /* The .csect pseudo-op. This switches us into a different
1152 subsegment. The first argument is a symbol whose value is the
1153 start of the .csect. In COFF, csect symbols get special aux
1154 entries defined by the x_csect field of union internal_auxent. The
1155 optional second argument is the alignment (the default is 2). */
1165 name
= input_line_pointer
;
1166 endc
= get_symbol_end ();
1168 sym
= symbol_find_or_make (name
);
1170 *input_line_pointer
= endc
;
1172 if (S_IS_DEFINED (sym
))
1173 subseg_set (S_GET_SEGMENT (sym
), sym
->sy_tc
.subseg
);
1180 /* This is a new csect. We need to look at the symbol class to
1181 figure out whether it should go in the text section or the
1184 switch (sym
->sy_tc
.class)
1194 S_SET_SEGMENT (sym
, text_section
);
1195 sym
->sy_tc
.subseg
= ppc_text_subsegment
;
1196 ++ppc_text_subsegment
;
1197 list_ptr
= &ppc_text_csects
;
1206 if (ppc_toc_csect
->sy_tc
.subseg
+ 1 == ppc_data_subsegment
)
1208 S_SET_SEGMENT (sym
, data_section
);
1209 sym
->sy_tc
.subseg
= ppc_data_subsegment
;
1210 ++ppc_data_subsegment
;
1211 list_ptr
= &ppc_data_csects
;
1217 subseg_new (segment_name (S_GET_SEGMENT (sym
)), sym
->sy_tc
.subseg
);
1219 ppc_after_toc_frag
= frag_now
;
1221 sym
->sy_frag
= frag_now
;
1222 S_SET_VALUE (sym
, (valueT
) frag_now_fix ());
1224 sym
->sy_tc
.align
= 2;
1225 sym
->sy_tc
.output
= 1;
1226 sym
->sy_tc
.within
= sym
;
1228 for (list
= *list_ptr
;
1229 list
->sy_tc
.next
!= (symbolS
*) NULL
;
1230 list
= list
->sy_tc
.next
)
1232 list
->sy_tc
.next
= sym
;
1234 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
1235 symbol_append (sym
, list
->sy_tc
.within
, &symbol_rootP
, &symbol_lastP
);
1238 if (*input_line_pointer
== ',')
1240 ++input_line_pointer
;
1241 sym
->sy_tc
.align
= get_absolute_expression ();
1244 ppc_current_csect
= sym
;
1246 demand_empty_rest_of_line ();
1249 /* The .extern pseudo-op. We create an undefined symbol. */
1258 name
= input_line_pointer
;
1259 endc
= get_symbol_end ();
1261 (void) symbol_find_or_make (name
);
1263 *input_line_pointer
= endc
;
1265 demand_empty_rest_of_line ();
1268 /* The .lglobl pseudo-op. I think the RS/6000 assembler only needs
1269 this because it can't handle undefined symbols. I think we can
1279 /* The .rename pseudo-op. The RS/6000 assembler can rename symbols,
1280 although I don't know why it bothers. */
1291 name
= input_line_pointer
;
1292 endc
= get_symbol_end ();
1294 sym
= symbol_find_or_make (name
);
1296 *input_line_pointer
= endc
;
1298 if (*input_line_pointer
!= ',')
1300 as_bad ("missing rename string");
1301 ignore_rest_of_line ();
1304 ++input_line_pointer
;
1306 sym
->sy_tc
.real_name
= demand_copy_C_string (&len
);
1308 demand_empty_rest_of_line ();
1311 /* The .stabx pseudo-op. This is similar to a normal .stabs
1312 pseudo-op, but slightly different. A sample is
1313 .stabx "main:F-1",.main,142,0
1314 The first argument is the symbol name to create. The second is the
1315 value, and the third is the storage class. The fourth seems to be
1316 always zero, and I am assuming it is the type. */
1327 name
= demand_copy_C_string (&len
);
1329 if (*input_line_pointer
!= ',')
1331 as_bad ("missing value");
1334 ++input_line_pointer
;
1336 sym
= symbol_make (name
);
1338 (void) expression (&exp
);
1345 as_bad ("illegal .stabx expression; zero assumed");
1346 exp
.X_add_number
= 0;
1349 S_SET_VALUE (sym
, (valueT
) exp
.X_add_number
);
1350 sym
->sy_frag
= &zero_address_frag
;
1354 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
)
1355 sym
->sy_value
= exp
;
1359 exp
.X_add_number
+ S_GET_VALUE (exp
.X_add_symbol
));
1360 sym
->sy_frag
= exp
.X_add_symbol
->sy_frag
;
1365 /* The value is some complex expression. This will probably
1366 fail at some later point, but this is probably the right
1367 thing to do here. */
1368 sym
->sy_value
= exp
;
1372 S_SET_SEGMENT (sym
, ppc_coff_debug_section
);
1373 sym
->bsym
->flags
|= BSF_DEBUGGING
;
1375 if (*input_line_pointer
!= ',')
1377 as_bad ("missing class");
1380 ++input_line_pointer
;
1382 S_SET_STORAGE_CLASS (sym
, get_absolute_expression ());
1384 if (*input_line_pointer
!= ',')
1386 as_bad ("missing type");
1389 ++input_line_pointer
;
1391 S_SET_DATA_TYPE (sym
, get_absolute_expression ());
1393 sym
->sy_tc
.output
= 1;
1395 if (S_GET_STORAGE_CLASS (sym
) == C_STSYM
)
1396 sym
->sy_tc
.within
= ppc_current_block
;
1398 if (exp
.X_op
!= O_symbol
1399 || ! S_IS_EXTERNAL (exp
.X_add_symbol
)
1400 || S_GET_SEGMENT (exp
.X_add_symbol
) != bss_section
)
1401 ppc_frob_label (sym
);
1404 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
1405 symbol_append (sym
, exp
.X_add_symbol
, &symbol_rootP
, &symbol_lastP
);
1406 if (ppc_current_csect
->sy_tc
.within
== exp
.X_add_symbol
)
1407 ppc_current_csect
->sy_tc
.within
= sym
;
1410 if (strlen (name
) > SYMNMLEN
)
1412 /* For some reason, each name is preceded by a two byte length
1413 and followed by a null byte. */
1414 ppc_debug_name_section_size
+= strlen (name
) + 3;
1417 demand_empty_rest_of_line ();
1420 /* The .function pseudo-op. This takes several arguments. The first
1421 argument seems to be the external name of the symbol. The second
1422 argment seems to be the label for the start of the function. gcc
1423 uses the same name for both. I have no idea what the third and
1424 fourth arguments are meant to be. The optional fifth argument is
1425 an expression for the size of the function. In COFF this symbol
1426 gets an aux entry like that used for a csect. */
1429 ppc_function (ignore
)
1438 name
= input_line_pointer
;
1439 endc
= get_symbol_end ();
1441 /* Ignore any [PR] suffix. */
1442 name
= ppc_canonicalize_symbol_name (name
);
1443 s
= strchr (name
, '[');
1444 if (s
!= (char *) NULL
1445 && strcmp (s
+ 1, "PR]") == 0)
1448 ext_sym
= symbol_find_or_make (name
);
1450 *input_line_pointer
= endc
;
1452 if (*input_line_pointer
!= ',')
1454 as_bad ("missing symbol name");
1455 ignore_rest_of_line ();
1458 ++input_line_pointer
;
1460 name
= input_line_pointer
;
1461 endc
= get_symbol_end ();
1463 lab_sym
= symbol_find_or_make (name
);
1465 *input_line_pointer
= endc
;
1467 if (ext_sym
!= lab_sym
)
1469 ext_sym
->sy_value
.X_op
= O_symbol
;
1470 ext_sym
->sy_value
.X_add_symbol
= lab_sym
;
1471 ext_sym
->sy_value
.X_op_symbol
= NULL
;
1472 ext_sym
->sy_value
.X_add_number
= 0;
1475 if (ext_sym
->sy_tc
.class == -1)
1476 ext_sym
->sy_tc
.class = XMC_PR
;
1477 ext_sym
->sy_tc
.output
= 1;
1479 if (*input_line_pointer
== ',')
1483 /* Ignore the third argument. */
1484 ++input_line_pointer
;
1485 expression (&ignore
);
1486 if (*input_line_pointer
== ',')
1488 /* Ignore the fourth argument. */
1489 ++input_line_pointer
;
1490 expression (&ignore
);
1491 if (*input_line_pointer
== ',')
1493 /* The fifth argument is the function size. */
1494 ++input_line_pointer
;
1495 ext_sym
->sy_tc
.size
= symbol_new ("L0\001",
1498 &zero_address_frag
);
1499 pseudo_set (ext_sym
->sy_tc
.size
);
1504 S_SET_DATA_TYPE (ext_sym
, DT_FCN
<< N_BTSHFT
);
1505 SF_SET_FUNCTION (ext_sym
);
1506 SF_SET_PROCESS (ext_sym
);
1507 coff_add_linesym (ext_sym
);
1509 demand_empty_rest_of_line ();
1512 /* The .bf pseudo-op. This is just like a COFF C_FCN symbol named
1521 sym
= symbol_make (".bf");
1522 S_SET_SEGMENT (sym
, text_section
);
1523 sym
->sy_frag
= frag_now
;
1524 S_SET_VALUE (sym
, frag_now_fix ());
1525 S_SET_STORAGE_CLASS (sym
, C_FCN
);
1527 coff_line_base
= get_absolute_expression ();
1529 S_SET_NUMBER_AUXILIARY (sym
, 1);
1530 SA_SET_SYM_LNNO (sym
, coff_line_base
);
1532 sym
->sy_tc
.output
= 1;
1534 ppc_frob_label (sym
);
1536 demand_empty_rest_of_line ();
1539 /* The .ef pseudo-op. This is just like a COFF C_FCN symbol named
1540 ".ef", except that the line number is absolute, not relative to the
1541 most recent ".bf" symbol. */
1549 sym
= symbol_make (".ef");
1550 S_SET_SEGMENT (sym
, text_section
);
1551 sym
->sy_frag
= frag_now
;
1552 S_SET_VALUE (sym
, frag_now_fix ());
1553 S_SET_STORAGE_CLASS (sym
, C_FCN
);
1554 S_SET_NUMBER_AUXILIARY (sym
, 1);
1555 SA_SET_SYM_LNNO (sym
, get_absolute_expression ());
1556 sym
->sy_tc
.output
= 1;
1558 ppc_frob_label (sym
);
1560 demand_empty_rest_of_line ();
1563 /* The .bi and .ei pseudo-ops. These take a string argument and
1564 generates a C_BINCL or C_EINCL symbol, which goes at the start of
1576 name
= demand_copy_C_string (&len
);
1578 sym
= symbol_make (name
);
1579 S_SET_SEGMENT (sym
, ppc_coff_debug_section
);
1580 sym
->bsym
->flags
|= BSF_DEBUGGING
;
1582 /* FIXME: The value of the .bi or .ei symbol is supposed to be the
1583 offset in the file to the line number entry to use. That is
1584 quite difficult to implement using BFD, so I'm just not doing it.
1585 Sorry. Please add it if you can figure out how. Note that this
1586 approach is the only way to support multiple files in COFF, since
1587 line numbers are associated with function symbols. Note further
1588 that it still doesn't work, since the line numbers are stored as
1589 offsets from a base line number. */
1591 S_SET_STORAGE_CLASS (sym
, ei
? C_EINCL
: C_BINCL
);
1592 sym
->sy_tc
.output
= 1;
1594 for (look
= symbol_rootP
;
1595 (look
!= (symbolS
*) NULL
1596 && (S_GET_STORAGE_CLASS (look
) == C_FILE
1597 || S_GET_STORAGE_CLASS (look
) == C_BINCL
1598 || S_GET_STORAGE_CLASS (look
) == C_EINCL
));
1599 look
= symbol_next (look
))
1601 if (look
!= (symbolS
*) NULL
)
1603 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
1604 symbol_insert (sym
, look
, &symbol_rootP
, &symbol_lastP
);
1607 demand_empty_rest_of_line ();
1610 /* The .bs pseudo-op. This generates a C_BSTAT symbol named ".bs".
1611 There is one argument, which is a csect symbol. The value of the
1612 .bs symbol is the index of this csect symbol. */
1623 if (ppc_current_block
!= NULL
)
1624 as_bad ("nested .bs blocks");
1626 name
= input_line_pointer
;
1627 endc
= get_symbol_end ();
1629 csect
= symbol_find_or_make (name
);
1631 *input_line_pointer
= endc
;
1633 sym
= symbol_make (".bs");
1634 S_SET_SEGMENT (sym
, now_seg
);
1635 S_SET_STORAGE_CLASS (sym
, C_BSTAT
);
1636 sym
->bsym
->flags
|= BSF_DEBUGGING
;
1637 sym
->sy_tc
.output
= 1;
1639 sym
->sy_tc
.within
= csect
;
1641 ppc_frob_label (sym
);
1643 ppc_current_block
= sym
;
1645 demand_empty_rest_of_line ();
1648 /* The .es pseudo-op. Generate a C_ESTART symbol named .es. */
1656 if (ppc_current_block
== NULL
)
1657 as_bad (".es without preceding .bs");
1659 sym
= symbol_make (".es");
1660 S_SET_SEGMENT (sym
, now_seg
);
1661 S_SET_STORAGE_CLASS (sym
, C_ESTAT
);
1662 sym
->bsym
->flags
|= BSF_DEBUGGING
;
1663 sym
->sy_tc
.output
= 1;
1665 ppc_frob_label (sym
);
1667 ppc_current_block
= NULL
;
1669 demand_empty_rest_of_line ();
1672 /* The .bb pseudo-op. Generate a C_BLOCK symbol named .bb, with a
1681 sym
= symbol_make (".bb");
1682 S_SET_SEGMENT (sym
, text_section
);
1683 sym
->sy_frag
= frag_now
;
1684 S_SET_VALUE (sym
, frag_now_fix ());
1685 S_SET_STORAGE_CLASS (sym
, C_BLOCK
);
1687 S_SET_NUMBER_AUXILIARY (sym
, 1);
1688 SA_SET_SYM_LNNO (sym
, get_absolute_expression ());
1690 sym
->sy_tc
.output
= 1;
1692 ppc_frob_label (sym
);
1694 demand_empty_rest_of_line ();
1697 /* The .eb pseudo-op. Generate a C_BLOCK symbol named .eb, with a
1706 sym
= symbol_make (".eb");
1707 S_SET_SEGMENT (sym
, text_section
);
1708 sym
->sy_frag
= frag_now
;
1709 S_SET_VALUE (sym
, frag_now_fix ());
1710 S_SET_STORAGE_CLASS (sym
, C_FCN
);
1711 S_SET_NUMBER_AUXILIARY (sym
, 1);
1712 SA_SET_SYM_LNNO (sym
, get_absolute_expression ());
1713 sym
->sy_tc
.output
= 1;
1715 ppc_frob_label (sym
);
1717 demand_empty_rest_of_line ();
1720 /* The .toc pseudo-op. Switch to the .toc subsegment. */
1726 if (ppc_toc_csect
!= (symbolS
*) NULL
)
1727 subseg_set (data_section
, ppc_toc_csect
->sy_tc
.subseg
);
1734 subseg
= ppc_data_subsegment
;
1735 ++ppc_data_subsegment
;
1737 subseg_new (segment_name (data_section
), subseg
);
1738 ppc_toc_frag
= frag_now
;
1740 sym
= symbol_find_or_make ("TOC[TC0]");
1741 sym
->sy_frag
= frag_now
;
1742 S_SET_SEGMENT (sym
, data_section
);
1743 S_SET_VALUE (sym
, (valueT
) frag_now_fix ());
1744 sym
->sy_tc
.subseg
= subseg
;
1745 sym
->sy_tc
.output
= 1;
1746 sym
->sy_tc
.within
= sym
;
1748 ppc_toc_csect
= sym
;
1750 for (list
= ppc_data_csects
;
1751 list
->sy_tc
.next
!= (symbolS
*) NULL
;
1752 list
= list
->sy_tc
.next
)
1754 list
->sy_tc
.next
= sym
;
1756 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
1757 symbol_append (sym
, list
->sy_tc
.within
, &symbol_rootP
, &symbol_lastP
);
1760 ppc_current_csect
= ppc_toc_csect
;
1762 demand_empty_rest_of_line ();
1765 #endif /* OBJ_COFF */
1767 /* The .tc pseudo-op. This is used when generating either XCOFF or
1768 ELF. This takes two or more arguments.
1770 When generating XCOFF output, the first argument is the name to
1771 give to this location in the toc; this will be a symbol with class
1772 TC. The rest of the arguments are 4 byte values to actually put at
1773 this location in the TOC; often there is just one more argument, a
1774 relocateable symbol reference.
1776 When not generating XCOFF output, the arguments are the same, but
1777 the first argument is simply ignored. */
1785 /* Define the TOC symbol name. */
1791 if (ppc_toc_csect
== (symbolS
*) NULL
1792 || ppc_toc_csect
!= ppc_current_csect
)
1794 as_bad (".tc not in .toc section");
1795 ignore_rest_of_line ();
1799 name
= input_line_pointer
;
1800 endc
= get_symbol_end ();
1802 sym
= symbol_find_or_make (name
);
1804 *input_line_pointer
= endc
;
1806 if (S_IS_DEFINED (sym
))
1810 label
= ppc_current_csect
->sy_tc
.within
;
1811 if (label
->sy_tc
.class != XMC_TC0
)
1813 as_warn (".tc with no label");
1814 ignore_rest_of_line ();
1818 S_SET_SEGMENT (label
, S_GET_SEGMENT (sym
));
1819 label
->sy_frag
= sym
->sy_frag
;
1820 S_SET_VALUE (label
, S_GET_VALUE (sym
));
1822 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1823 ++input_line_pointer
;
1828 S_SET_SEGMENT (sym
, now_seg
);
1829 sym
->sy_frag
= frag_now
;
1830 S_SET_VALUE (sym
, (valueT
) frag_now_fix ());
1831 sym
->sy_tc
.class = XMC_TC
;
1832 sym
->sy_tc
.output
= 1;
1834 ppc_frob_label (sym
);
1837 #else /* ! defined (OBJ_COFF) */
1839 /* Skip the TOC symbol name. */
1840 while (is_part_of_name (*input_line_pointer
)
1841 || *input_line_pointer
== '['
1842 || *input_line_pointer
== ']'
1843 || *input_line_pointer
== '{'
1844 || *input_line_pointer
== '}')
1845 ++input_line_pointer
;
1847 /* Align to a four byte boundary. */
1849 record_alignment (now_seg
, 2);
1851 #endif /* ! defined (OBJ_COFF) */
1853 if (*input_line_pointer
!= ',')
1854 demand_empty_rest_of_line ();
1857 ++input_line_pointer
;
1864 /* XCOFF specific symbol and file handling. */
1866 /* Canonicalize the symbol name. We use the to force the suffix, if
1867 any, to use square brackets, and to be in upper case. */
1870 ppc_canonicalize_symbol_name (name
)
1875 for (s
= name
; *s
!= '\0' && *s
!= '{' && *s
!= '['; s
++)
1889 for (s
++; *s
!= '\0' && *s
!= brac
; s
++)
1893 if (*s
== '\0' || s
[1] != '\0')
1894 as_bad ("bad symbol suffix");
1902 /* Set the class of a symbol based on the suffix, if any. This is
1903 called whenever a new symbol is created. */
1906 ppc_symbol_new_hook (sym
)
1911 sym
->sy_tc
.next
= NULL
;
1912 sym
->sy_tc
.output
= 0;
1913 sym
->sy_tc
.class = -1;
1914 sym
->sy_tc
.real_name
= NULL
;
1915 sym
->sy_tc
.subseg
= 0;
1916 sym
->sy_tc
.align
= 0;
1917 sym
->sy_tc
.size
= NULL
;
1918 sym
->sy_tc
.within
= NULL
;
1920 s
= strchr (S_GET_NAME (sym
), '[');
1921 if (s
== (const char *) NULL
)
1923 /* There is no suffix. */
1932 if (strcmp (s
, "BS]") == 0)
1933 sym
->sy_tc
.class = XMC_BS
;
1936 if (strcmp (s
, "DB]") == 0)
1937 sym
->sy_tc
.class = XMC_DB
;
1938 else if (strcmp (s
, "DS]") == 0)
1939 sym
->sy_tc
.class = XMC_DS
;
1942 if (strcmp (s
, "GL]") == 0)
1943 sym
->sy_tc
.class = XMC_GL
;
1946 if (strcmp (s
, "PR]") == 0)
1947 sym
->sy_tc
.class = XMC_PR
;
1950 if (strcmp (s
, "RO]") == 0)
1951 sym
->sy_tc
.class = XMC_RO
;
1952 else if (strcmp (s
, "RW]") == 0)
1953 sym
->sy_tc
.class = XMC_RW
;
1956 if (strcmp (s
, "SV]") == 0)
1957 sym
->sy_tc
.class = XMC_SV
;
1960 if (strcmp (s
, "TC]") == 0)
1961 sym
->sy_tc
.class = XMC_TC
;
1962 else if (strcmp (s
, "TI]") == 0)
1963 sym
->sy_tc
.class = XMC_TI
;
1964 else if (strcmp (s
, "TB]") == 0)
1965 sym
->sy_tc
.class = XMC_TB
;
1966 else if (strcmp (s
, "TC0]") == 0 || strcmp (s
, "T0]") == 0)
1967 sym
->sy_tc
.class = XMC_TC0
;
1970 if (strcmp (s
, "UA]") == 0)
1971 sym
->sy_tc
.class = XMC_UA
;
1972 else if (strcmp (s
, "UC]") == 0)
1973 sym
->sy_tc
.class = XMC_UC
;
1976 if (strcmp (s
, "XO]") == 0)
1977 sym
->sy_tc
.class = XMC_XO
;
1981 if (sym
->sy_tc
.class == -1)
1982 as_bad ("Unrecognized symbol suffix");
1985 /* Set the class of a label based on where it is defined. This
1986 handles symbols without suffixes. Also, move the symbol so that it
1987 follows the csect symbol. */
1990 ppc_frob_label (sym
)
1993 if (ppc_current_csect
!= (symbolS
*) NULL
)
1995 if (sym
->sy_tc
.class == -1)
1996 sym
->sy_tc
.class = ppc_current_csect
->sy_tc
.class;
1998 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
1999 symbol_append (sym
, ppc_current_csect
->sy_tc
.within
, &symbol_rootP
,
2001 ppc_current_csect
->sy_tc
.within
= sym
;
2005 /* Change the name of a symbol just before writing it out. Set the
2006 real name if the .rename pseudo-op was used. Otherwise, remove any
2007 class suffix. Return 1 if the symbol should not be included in the
2011 ppc_frob_symbol (sym
)
2014 static symbolS
*ppc_last_function
;
2015 static symbolS
*set_end
;
2017 /* Discard symbols that should not be included in the output symbol
2019 if (! sym
->sy_used_in_reloc
2020 && ((sym
->bsym
->flags
& BSF_SECTION_SYM
) != 0
2021 || (! S_IS_EXTERNAL (sym
)
2022 && ! sym
->sy_tc
.output
2023 && S_GET_STORAGE_CLASS (sym
) != C_FILE
)))
2026 if (sym
->sy_tc
.real_name
!= (char *) NULL
)
2027 S_SET_NAME (sym
, sym
->sy_tc
.real_name
);
2033 name
= S_GET_NAME (sym
);
2034 s
= strchr (name
, '[');
2035 if (s
!= (char *) NULL
)
2041 snew
= xmalloc (len
+ 1);
2042 memcpy (snew
, name
, len
);
2045 S_SET_NAME (sym
, snew
);
2049 if (set_end
!= (symbolS
*) NULL
)
2051 SA_SET_SYM_ENDNDX (set_end
, sym
);
2055 if (SF_GET_FUNCTION (sym
))
2057 if (ppc_last_function
!= (symbolS
*) NULL
)
2058 as_warn ("two .function pseudo-ops with no intervening .ef");
2059 ppc_last_function
= sym
;
2060 if (sym
->sy_tc
.size
!= (symbolS
*) NULL
)
2062 resolve_symbol_value (sym
->sy_tc
.size
);
2063 SA_SET_SYM_FSIZE (sym
, (long) S_GET_VALUE (sym
->sy_tc
.size
));
2066 else if (S_GET_STORAGE_CLASS (sym
) == C_FCN
2067 && strcmp (S_GET_NAME (sym
), ".ef") == 0)
2069 if (ppc_last_function
== (symbolS
*) NULL
)
2070 as_warn (".ef with no preceding .function");
2073 set_end
= ppc_last_function
;
2074 ppc_last_function
= NULL
;
2076 /* We don't have a C_EFCN symbol, but we need to force the
2077 COFF backend to believe that it has seen one. */
2078 coff_last_function
= NULL
;
2082 if (! S_IS_EXTERNAL (sym
)
2083 && (sym
->bsym
->flags
& BSF_SECTION_SYM
) == 0
2084 && S_GET_STORAGE_CLASS (sym
) != C_FILE
2085 && S_GET_STORAGE_CLASS (sym
) != C_FCN
2086 && S_GET_STORAGE_CLASS (sym
) != C_BSTAT
2087 && S_GET_STORAGE_CLASS (sym
) != C_ESTAT
2088 && S_GET_SEGMENT (sym
) != ppc_coff_debug_section
)
2089 S_SET_STORAGE_CLASS (sym
, C_HIDEXT
);
2091 if (S_GET_STORAGE_CLASS (sym
) == C_EXT
2092 || S_GET_STORAGE_CLASS (sym
) == C_HIDEXT
)
2095 union internal_auxent
*a
;
2097 /* Create a csect aux. */
2098 i
= S_GET_NUMBER_AUXILIARY (sym
);
2099 S_SET_NUMBER_AUXILIARY (sym
, i
+ 1);
2100 a
= &coffsymbol (sym
->bsym
)->native
[i
+ 1].u
.auxent
;
2101 if (sym
->sy_tc
.class == XMC_TC0
)
2103 /* This is the TOC table. */
2104 know (strcmp (S_GET_NAME (sym
), "TOC") == 0);
2105 a
->x_csect
.x_scnlen
.l
= 0;
2106 a
->x_csect
.x_smtyp
= (2 << 3) | XTY_SD
;
2108 else if (sym
->sy_tc
.subseg
!= 0)
2110 /* This is a csect symbol. x_scnlen is the size of the
2112 if (sym
->sy_tc
.next
== (symbolS
*) NULL
)
2113 a
->x_csect
.x_scnlen
.l
= (bfd_section_size (stdoutput
,
2114 S_GET_SEGMENT (sym
))
2115 - S_GET_VALUE (sym
));
2118 resolve_symbol_value (sym
->sy_tc
.next
);
2119 a
->x_csect
.x_scnlen
.l
= (S_GET_VALUE (sym
->sy_tc
.next
)
2120 - S_GET_VALUE (sym
));
2122 a
->x_csect
.x_smtyp
= (sym
->sy_tc
.align
<< 3) | XTY_SD
;
2124 else if (S_GET_SEGMENT (sym
) == bss_section
)
2126 /* This is a common symbol. */
2127 a
->x_csect
.x_scnlen
.l
= sym
->sy_frag
->fr_offset
;
2128 a
->x_csect
.x_smtyp
= (sym
->sy_tc
.align
<< 3) | XTY_CM
;
2129 if (S_IS_EXTERNAL (sym
))
2130 sym
->sy_tc
.class = XMC_RW
;
2132 sym
->sy_tc
.class = XMC_BS
;
2134 else if (! S_IS_DEFINED (sym
))
2136 /* This is an external symbol. */
2137 a
->x_csect
.x_scnlen
.l
= 0;
2138 a
->x_csect
.x_smtyp
= XTY_ER
;
2140 else if (sym
->sy_tc
.class == XMC_TC
)
2144 /* This is a TOC definition. x_scnlen is the size of the
2146 next
= symbol_next (sym
);
2147 while (next
->sy_tc
.class == XMC_TC0
)
2148 next
= symbol_next (next
);
2149 if (next
== (symbolS
*) NULL
2150 || next
->sy_tc
.class != XMC_TC
)
2152 if (ppc_after_toc_frag
== (fragS
*) NULL
)
2153 a
->x_csect
.x_scnlen
.l
= (bfd_section_size (stdoutput
,
2155 - S_GET_VALUE (sym
));
2157 a
->x_csect
.x_scnlen
.l
= (ppc_after_toc_frag
->fr_address
2158 - S_GET_VALUE (sym
));
2162 resolve_symbol_value (next
);
2163 a
->x_csect
.x_scnlen
.l
= (S_GET_VALUE (next
)
2164 - S_GET_VALUE (sym
));
2166 a
->x_csect
.x_smtyp
= (2 << 3) | XTY_SD
;
2172 /* This is a normal symbol definition. x_scnlen is the
2173 symbol index of the containing csect. */
2174 if (S_GET_SEGMENT (sym
) == text_section
)
2175 csect
= ppc_text_csects
;
2176 else if (S_GET_SEGMENT (sym
) == data_section
)
2177 csect
= ppc_data_csects
;
2181 /* Skip the initial dummy symbol. */
2182 csect
= csect
->sy_tc
.next
;
2184 if (csect
== (symbolS
*) NULL
)
2185 a
->x_csect
.x_scnlen
.l
= 0;
2188 while (csect
->sy_tc
.next
!= (symbolS
*) NULL
)
2190 resolve_symbol_value (csect
->sy_tc
.next
);
2191 if (S_GET_VALUE (csect
->sy_tc
.next
) > S_GET_VALUE (sym
))
2193 csect
= csect
->sy_tc
.next
;
2196 a
->x_csect
.x_scnlen
.p
= coffsymbol (csect
->bsym
)->native
;
2197 coffsymbol (sym
->bsym
)->native
[i
+ 1].fix_scnlen
= 1;
2199 a
->x_csect
.x_smtyp
= XTY_LD
;
2202 a
->x_csect
.x_parmhash
= 0;
2203 a
->x_csect
.x_snhash
= 0;
2204 if (sym
->sy_tc
.class == -1)
2205 a
->x_csect
.x_smclas
= XMC_PR
;
2207 a
->x_csect
.x_smclas
= sym
->sy_tc
.class;
2208 a
->x_csect
.x_stab
= 0;
2209 a
->x_csect
.x_snstab
= 0;
2211 else if (S_GET_STORAGE_CLASS (sym
) == C_BSTAT
)
2213 /* We want the value to be the symbol index of the referenced
2214 csect symbol. BFD will do that for us if we set the right
2217 (valueT
) coffsymbol (sym
->sy_tc
.within
->bsym
)->native
);
2218 coffsymbol (sym
->bsym
)->native
->fix_value
= 1;
2220 else if (S_GET_STORAGE_CLASS (sym
) == C_STSYM
)
2225 /* The value is the offset from the enclosing csect. */
2226 block
= sym
->sy_tc
.within
;
2227 csect
= block
->sy_tc
.within
;
2228 resolve_symbol_value (csect
);
2229 S_SET_VALUE (sym
, S_GET_VALUE (sym
) - S_GET_VALUE (csect
));
2235 /* Set the VMA for a section. This is called on all the sections in
2239 ppc_frob_section (sec
)
2242 static bfd_size_type vma
= 0;
2244 bfd_set_section_vma (stdoutput
, sec
, vma
);
2245 vma
+= bfd_section_size (stdoutput
, sec
);
2248 /* Adjust the file by adding a .debug section if needed. */
2253 if (ppc_debug_name_section_size
> 0)
2257 sec
= bfd_make_section (stdoutput
, ".debug");
2258 if (sec
== (asection
*) NULL
2259 || ! bfd_set_section_size (stdoutput
, sec
,
2260 ppc_debug_name_section_size
)
2261 || ! bfd_set_section_flags (stdoutput
, sec
,
2262 SEC_HAS_CONTENTS
| SEC_LOAD
))
2263 as_fatal ("can't make .debug section");
2267 #endif /* OBJ_COFF */
2269 /* Turn a string in input_line_pointer into a floating point constant
2270 of type type, and store the appropriate bytes in *litp. The number
2271 of LITTLENUMS emitted is stored in *sizep . An error message is
2272 returned, or NULL on OK. */
2275 md_atof (type
, litp
, sizep
)
2281 LITTLENUM_TYPE words
[4];
2297 return "bad call to md_atof";
2300 t
= atof_ieee (input_line_pointer
, type
, words
);
2302 input_line_pointer
= t
;
2308 for (i
= 0; i
< prec
; i
++)
2310 md_number_to_chars (litp
, (valueT
) words
[i
], 2);
2316 for (i
= prec
- 1; i
>= 0; i
--)
2318 md_number_to_chars (litp
, (valueT
) words
[i
], 2);
2326 /* Write a value out to the object file, using the appropriate
2330 md_number_to_chars (buf
, val
, n
)
2336 number_to_chars_bigendian (buf
, val
, n
);
2338 number_to_chars_littleendian (buf
, val
, n
);
2341 /* Align a section (I don't know why this is machine dependent). */
2344 md_section_align (seg
, addr
)
2348 int align
= bfd_get_section_alignment (stdoutput
, seg
);
2350 return ((addr
+ (1 << align
) - 1) & (-1 << align
));
2353 /* We don't have any form of relaxing. */
2356 md_estimate_size_before_relax (fragp
, seg
)
2363 const relax_typeS md_relax_table
[] =
2368 /* Convert a machine dependent frag. We never generate these. */
2371 md_convert_frag (abfd
, sec
, fragp
)
2379 /* We have no need to default values of symbols. */
2383 md_undefined_symbol (name
)
2389 /* Functions concerning relocs. */
2391 /* The location from which a PC relative jump should be calculated,
2392 given a PC relative reloc. */
2395 md_pcrel_from (fixp
)
2399 if (fixp
->fx_addsy
!= (symbolS
*) NULL
2400 && ! S_IS_DEFINED (fixp
->fx_addsy
))
2404 return fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2409 /* This is called to see whether a fixup should be adjusted to use a
2410 section symbol. We take the opportunity to change a fixup against
2411 a symbol in the TOC subsegment into a reloc against the
2412 corresponding .tc symbol. */
2415 ppc_fix_adjustable (fix
)
2420 resolve_symbol_value (fix
->fx_addsy
);
2421 val
= S_GET_VALUE (fix
->fx_addsy
);
2422 if (ppc_toc_csect
!= (symbolS
*) NULL
2423 && fix
->fx_addsy
!= (symbolS
*) NULL
2424 && fix
->fx_addsy
!= ppc_toc_csect
2425 && S_GET_SEGMENT (fix
->fx_addsy
) == data_section
2426 && val
>= ppc_toc_frag
->fr_address
2427 && (ppc_after_toc_frag
== (fragS
*) NULL
2428 || val
< ppc_after_toc_frag
->fr_address
))
2432 for (sy
= symbol_next (ppc_toc_csect
);
2433 sy
!= (symbolS
*) NULL
;
2434 sy
= symbol_next (sy
))
2436 if (sy
->sy_tc
.class == XMC_TC0
)
2438 if (sy
->sy_tc
.class != XMC_TC
)
2440 resolve_symbol_value (sy
);
2441 if (val
== S_GET_VALUE (sy
))
2444 fix
->fx_addnumber
= val
- ppc_toc_frag
->fr_address
;
2449 as_bad_where (fix
->fx_file
, fix
->fx_line
,
2450 "symbol in .toc does not match any .tc");
2453 /* Possibly adjust the reloc to be against the csect. */
2454 if (fix
->fx_addsy
!= (symbolS
*) NULL
2455 && fix
->fx_addsy
->sy_tc
.subseg
== 0
2456 && fix
->fx_addsy
->sy_tc
.class != XMC_TC0
2457 && fix
->fx_addsy
->sy_tc
.class != XMC_TC
2458 && S_GET_SEGMENT (fix
->fx_addsy
) != bss_section
)
2462 if (S_GET_SEGMENT (fix
->fx_addsy
) == text_section
)
2463 csect
= ppc_text_csects
;
2464 else if (S_GET_SEGMENT (fix
->fx_addsy
) == data_section
)
2465 csect
= ppc_data_csects
;
2469 /* Skip the initial dummy symbol. */
2470 csect
= csect
->sy_tc
.next
;
2472 if (csect
!= (symbolS
*) NULL
)
2474 while (csect
->sy_tc
.next
!= (symbolS
*) NULL
2475 && (csect
->sy_tc
.next
->sy_frag
->fr_address
2476 <= fix
->fx_addsy
->sy_frag
->fr_address
))
2477 csect
= csect
->sy_tc
.next
;
2479 fix
->fx_offset
+= (S_GET_VALUE (fix
->fx_addsy
)
2480 - csect
->sy_frag
->fr_address
);
2481 fix
->fx_addsy
= csect
;
2485 /* Adjust a reloc against a .lcomm symbol to be against the base
2487 if (fix
->fx_addsy
!= (symbolS
*) NULL
2488 && S_GET_SEGMENT (fix
->fx_addsy
) == bss_section
2489 && ! S_IS_EXTERNAL (fix
->fx_addsy
))
2491 resolve_symbol_value (fix
->fx_addsy
->sy_frag
->fr_symbol
);
2492 fix
->fx_offset
+= (S_GET_VALUE (fix
->fx_addsy
)
2493 - S_GET_VALUE (fix
->fx_addsy
->sy_frag
->fr_symbol
));
2494 fix
->fx_addsy
= fix
->fx_addsy
->sy_frag
->fr_symbol
;
2502 /* See whether a symbol is in the TOC section. */
2505 ppc_is_toc_sym (sym
)
2509 return sym
->sy_tc
.class == XMC_TC
;
2511 return strcmp (segment_name (S_GET_SEGMENT (sym
)), ".got") == 0;
2515 /* Apply a fixup to the object code. This is called for all the
2516 fixups we generated by the call to fix_new_exp, above. In the call
2517 above we used a reloc code which was the largest legal reloc code
2518 plus the operand index. Here we undo that to recover the operand
2519 index. At this point all symbol values should be fully resolved,
2520 and we attempt to completely resolve the reloc. If we can not do
2521 that, we determine the correct reloc code and put it back in the
2525 md_apply_fix3 (fixp
, valuep
, seg
)
2532 /* FIXME FIXME FIXME: The value we are passed in *valuep includes
2533 the symbol values. Since we are using BFD_ASSEMBLER, if we are
2534 doing this relocation the code in write.c is going to call
2535 bfd_perform_relocation, which is also going to use the symbol
2536 value. That means that if the reloc is fully resolved we want to
2537 use *valuep since bfd_perform_relocation is not being used.
2538 However, if the reloc is not fully resolved we do not want to use
2539 *valuep, and must use fx_offset instead. However, if the reloc
2540 is PC relative, we do want to use *valuep since it includes the
2541 result of md_pcrel_from. This is confusing. */
2543 if (fixp
->fx_addsy
== (symbolS
*) NULL
)
2548 else if (fixp
->fx_pcrel
)
2552 value
= fixp
->fx_offset
;
2553 if (fixp
->fx_subsy
!= (symbolS
*) NULL
)
2555 if (S_GET_SEGMENT (fixp
->fx_subsy
) == absolute_section
)
2556 value
-= S_GET_VALUE (fixp
->fx_subsy
);
2559 /* We can't actually support subtracting a symbol. */
2560 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2561 "expression too complex");
2566 if ((int) fixp
->fx_r_type
>= (int) BFD_RELOC_UNUSED
)
2569 const struct powerpc_operand
*operand
;
2573 opindex
= (int) fixp
->fx_r_type
- (int) BFD_RELOC_UNUSED
;
2575 operand
= &powerpc_operands
[opindex
];
2578 /* It appears that an instruction like
2580 when LC..1 is not a TOC symbol does not generate a reloc. It
2581 uses the offset of LC..1 within its csect. However, .long
2582 LC..1 will generate a reloc. I can't find any documentation
2583 on how these cases are to be distinguished, so this is a wild
2584 guess. These cases are generated by gcc -mminimal-toc. */
2585 if ((operand
->flags
& PPC_OPERAND_PARENS
) != 0
2586 && operand
->bits
== 16
2587 && operand
->shift
== 0
2588 && operand
->insert
== NULL
2589 && fixp
->fx_addsy
!= NULL
2590 && fixp
->fx_addsy
->sy_tc
.subseg
!= 0
2591 && fixp
->fx_addsy
->sy_tc
.class != XMC_TC
2592 && fixp
->fx_addsy
->sy_tc
.class != XMC_TC0
2593 && S_GET_SEGMENT (fixp
->fx_addsy
) != bss_section
)
2595 value
= fixp
->fx_offset
;
2600 /* Fetch the instruction, insert the fully resolved operand
2601 value, and stuff the instruction back again. */
2602 where
= fixp
->fx_frag
->fr_literal
+ fixp
->fx_where
;
2604 insn
= bfd_getb32 ((unsigned char *) where
);
2606 insn
= bfd_getl32 ((unsigned char *) where
);
2607 insn
= ppc_insert_operand (insn
, operand
, (offsetT
) value
,
2608 fixp
->fx_file
, fixp
->fx_line
);
2610 bfd_putb32 ((bfd_vma
) insn
, (unsigned char *) where
);
2612 bfd_putl32 ((bfd_vma
) insn
, (unsigned char *) where
);
2616 /* Nothing else to do here. */
2620 /* Determine a BFD reloc value based on the operand information.
2621 We are only prepared to turn a few of the operands into
2623 FIXME: We need to handle the DS field at the very least.
2624 FIXME: Handling 16 bit branches would also be reasonable.
2625 FIXME: Selecting the reloc type is a bit haphazard; perhaps
2626 there should be a new field in the operand table. */
2627 if ((operand
->flags
& PPC_OPERAND_RELATIVE
) != 0
2628 && operand
->bits
== 26
2629 && operand
->shift
== 0)
2630 fixp
->fx_r_type
= BFD_RELOC_PPC_B26
;
2631 else if ((operand
->flags
& PPC_OPERAND_ABSOLUTE
) != 0
2632 && operand
->bits
== 26
2633 && operand
->shift
== 0)
2634 fixp
->fx_r_type
= BFD_RELOC_PPC_BA26
;
2635 else if ((operand
->flags
& PPC_OPERAND_PARENS
) != 0
2636 && operand
->bits
== 16
2637 && operand
->shift
== 0
2638 && operand
->insert
== NULL
2639 && fixp
->fx_addsy
!= NULL
2640 && ppc_is_toc_sym (fixp
->fx_addsy
))
2644 fixp
->fx_where
+= 2;
2645 fixp
->fx_r_type
= BFD_RELOC_PPC_TOC16
;
2649 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2650 "unresolved expression that must be resolved");
2658 ppc_elf_validate_fix (fixp
, seg
);
2660 switch (fixp
->fx_r_type
)
2665 fixp
->fx_r_type
= BFD_RELOC_32_PCREL
;
2666 value
+= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2667 } /* fall through */
2669 case BFD_RELOC_32_PCREL
:
2670 md_number_to_chars (fixp
->fx_frag
->fr_literal
+ fixp
->fx_where
,
2673 case BFD_RELOC_LO16
:
2674 case BFD_RELOC_HI16
:
2675 case BFD_RELOC_HI16_S
:
2676 case BFD_RELOC_PPC_TOC16
:
2681 md_number_to_chars (fixp
->fx_frag
->fr_literal
+ fixp
->fx_where
,
2689 md_number_to_chars (fixp
->fx_frag
->fr_literal
+ fixp
->fx_where
,
2698 fixp
->fx_addnumber
= value
;
2700 if (fixp
->fx_r_type
!= BFD_RELOC_PPC_TOC16
)
2701 fixp
->fx_addnumber
= 0;
2704 /* We want to use the offset within the data segment of the
2705 symbol, not the actual VMA of the symbol. */
2706 fixp
->fx_addnumber
=
2707 - bfd_get_section_vma (stdoutput
, S_GET_SEGMENT (fixp
->fx_addsy
));
2714 /* Generate a reloc for a fixup. */
2717 tc_gen_reloc (seg
, fixp
)
2723 reloc
= (arelent
*) bfd_alloc_by_size_t (stdoutput
, sizeof (arelent
));
2725 reloc
->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
2726 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2727 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
2728 if (reloc
->howto
== (reloc_howto_type
*) NULL
)
2730 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
2731 "reloc %d not supported by object file format", (int)fixp
->fx_r_type
);
2734 reloc
->addend
= fixp
->fx_addnumber
;