1 /* tc-ppc.c -- Assemble for the PowerPC or POWER (RS/6000)
2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support.
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #include "safe-ctype.h"
28 #include "opcode/ppc.h"
32 #include "dwarf2dbg.h"
39 /* This is the assembler for the PowerPC or POWER (RS/6000) chips. */
41 /* Tell the main code what the endianness is. */
42 extern int target_big_endian;
44 /* Whether or not, we've set target_big_endian. */
45 static int set_target_endian = 0;
47 /* Whether to use user friendly register names. */
48 #ifndef TARGET_REG_NAMES_P
50 #define TARGET_REG_NAMES_P true
52 #define TARGET_REG_NAMES_P false
56 /* Macros for calculating LO, HI, HA, HIGHER, HIGHERA, HIGHEST,
59 /* #lo(value) denotes the least significant 16 bits of the indicated. */
60 #define PPC_LO(v) ((v) & 0xffff)
62 /* #hi(value) denotes bits 16 through 31 of the indicated value. */
63 #define PPC_HI(v) (((v) >> 16) & 0xffff)
65 /* #ha(value) denotes the high adjusted value: bits 16 through 31 of
66 the indicated value, compensating for #lo() being treated as a
68 #define PPC_HA(v) PPC_HI ((v) + 0x8000)
70 /* #higher(value) denotes bits 32 through 47 of the indicated value. */
71 #define PPC_HIGHER(v) (((v) >> 16 >> 16) & 0xffff)
73 /* #highera(value) denotes bits 32 through 47 of the indicated value,
74 compensating for #lo() being treated as a signed number. */
75 #define PPC_HIGHERA(v) PPC_HIGHER ((v) + 0x8000)
77 /* #highest(value) denotes bits 48 through 63 of the indicated value. */
78 #define PPC_HIGHEST(v) (((v) >> 24 >> 24) & 0xffff)
80 /* #highesta(value) denotes bits 48 through 63 of the indicated value,
81 compensating for #lo being treated as a signed number. */
82 #define PPC_HIGHESTA(v) PPC_HIGHEST ((v) + 0x8000)
84 #define SEX16(val) ((((val) & 0xffff) ^ 0x8000) - 0x8000)
86 static boolean reg_names_p = TARGET_REG_NAMES_P;
88 static boolean register_name PARAMS ((expressionS *));
89 static void ppc_set_cpu PARAMS ((void));
90 static unsigned long ppc_insert_operand
91 PARAMS ((unsigned long insn, const struct powerpc_operand *operand,
92 offsetT val, char *file, unsigned int line));
93 static void ppc_macro PARAMS ((char *str, const struct powerpc_macro *macro));
94 static void ppc_byte PARAMS ((int));
96 #if defined (OBJ_XCOFF) || defined (OBJ_ELF)
97 static int ppc_is_toc_sym PARAMS ((symbolS *sym));
98 static void ppc_tc PARAMS ((int));
99 static void ppc_machine PARAMS ((int));
103 static void ppc_comm PARAMS ((int));
104 static void ppc_bb PARAMS ((int));
105 static void ppc_bc PARAMS ((int));
106 static void ppc_bf PARAMS ((int));
107 static void ppc_biei PARAMS ((int));
108 static void ppc_bs PARAMS ((int));
109 static void ppc_eb PARAMS ((int));
110 static void ppc_ec PARAMS ((int));
111 static void ppc_ef PARAMS ((int));
112 static void ppc_es PARAMS ((int));
113 static void ppc_csect PARAMS ((int));
114 static void ppc_change_csect PARAMS ((symbolS *));
115 static void ppc_function PARAMS ((int));
116 static void ppc_extern PARAMS ((int));
117 static void ppc_lglobl PARAMS ((int));
118 static void ppc_section PARAMS ((int));
119 static void ppc_named_section PARAMS ((int));
120 static void ppc_stabx PARAMS ((int));
121 static void ppc_rename PARAMS ((int));
122 static void ppc_toc PARAMS ((int));
123 static void ppc_xcoff_cons PARAMS ((int));
124 static void ppc_vbyte PARAMS ((int));
128 static bfd_reloc_code_real_type ppc_elf_suffix PARAMS ((char **, expressionS *));
129 static void ppc_elf_cons PARAMS ((int));
130 static void ppc_elf_rdata PARAMS ((int));
131 static void ppc_elf_lcomm PARAMS ((int));
132 static void ppc_elf_validate_fix PARAMS ((fixS *, segT));
136 static void ppc_set_current_section PARAMS ((segT));
137 static void ppc_previous PARAMS ((int));
138 static void ppc_pdata PARAMS ((int));
139 static void ppc_ydata PARAMS ((int));
140 static void ppc_reldata PARAMS ((int));
141 static void ppc_rdata PARAMS ((int));
142 static void ppc_ualong PARAMS ((int));
143 static void ppc_znop PARAMS ((int));
144 static void ppc_pe_comm PARAMS ((int));
145 static void ppc_pe_section PARAMS ((int));
146 static void ppc_pe_function PARAMS ((int));
147 static void ppc_pe_tocd PARAMS ((int));
150 /* Generic assembler global variables which must be defined by all
154 /* This string holds the chars that always start a comment. If the
155 pre-processor is disabled, these aren't very useful. The macro
156 tc_comment_chars points to this. We use this, rather than the
157 usual comment_chars, so that we can switch for Solaris conventions. */
158 static const char ppc_solaris_comment_chars[] = "#!";
159 static const char ppc_eabi_comment_chars[] = "#";
161 #ifdef TARGET_SOLARIS_COMMENT
162 const char *ppc_comment_chars = ppc_solaris_comment_chars;
164 const char *ppc_comment_chars = ppc_eabi_comment_chars;
167 const char comment_chars[] = "#";
170 /* Characters which start a comment at the beginning of a line. */
171 const char line_comment_chars[] = "#";
173 /* Characters which may be used to separate multiple commands on a
175 const char line_separator_chars[] = ";";
177 /* Characters which are used to indicate an exponent in a floating
179 const char EXP_CHARS[] = "eE";
181 /* Characters which mean that a number is a floating point constant,
183 const char FLT_CHARS[] = "dD";
185 /* The target specific pseudo-ops which we support. */
187 const pseudo_typeS md_pseudo_table[] =
189 /* Pseudo-ops which must be overridden. */
190 { "byte", ppc_byte, 0 },
193 /* Pseudo-ops specific to the RS/6000 XCOFF format. Some of these
194 legitimately belong in the obj-*.c file. However, XCOFF is based
195 on COFF, and is only implemented for the RS/6000. We just use
196 obj-coff.c, and add what we need here. */
197 { "comm", ppc_comm, 0 },
198 { "lcomm", ppc_comm, 1 },
202 { "bi", ppc_biei, 0 },
204 { "csect", ppc_csect, 0 },
205 { "data", ppc_section, 'd' },
209 { "ei", ppc_biei, 1 },
211 { "extern", ppc_extern, 0 },
212 { "function", ppc_function, 0 },
213 { "lglobl", ppc_lglobl, 0 },
214 { "rename", ppc_rename, 0 },
215 { "section", ppc_named_section, 0 },
216 { "stabx", ppc_stabx, 0 },
217 { "text", ppc_section, 't' },
218 { "toc", ppc_toc, 0 },
219 { "long", ppc_xcoff_cons, 2 },
220 { "llong", ppc_xcoff_cons, 3 },
221 { "word", ppc_xcoff_cons, 1 },
222 { "short", ppc_xcoff_cons, 1 },
223 { "vbyte", ppc_vbyte, 0 },
227 { "llong", ppc_elf_cons, 8 },
228 { "quad", ppc_elf_cons, 8 },
229 { "long", ppc_elf_cons, 4 },
230 { "word", ppc_elf_cons, 2 },
231 { "short", ppc_elf_cons, 2 },
232 { "rdata", ppc_elf_rdata, 0 },
233 { "rodata", ppc_elf_rdata, 0 },
234 { "lcomm", ppc_elf_lcomm, 0 },
235 { "file", (void (*) PARAMS ((int))) dwarf2_directive_file, 0 },
236 { "loc", dwarf2_directive_loc, 0 },
240 /* Pseudo-ops specific to the Windows NT PowerPC PE (coff) format. */
241 { "previous", ppc_previous, 0 },
242 { "pdata", ppc_pdata, 0 },
243 { "ydata", ppc_ydata, 0 },
244 { "reldata", ppc_reldata, 0 },
245 { "rdata", ppc_rdata, 0 },
246 { "ualong", ppc_ualong, 0 },
247 { "znop", ppc_znop, 0 },
248 { "comm", ppc_pe_comm, 0 },
249 { "lcomm", ppc_pe_comm, 1 },
250 { "section", ppc_pe_section, 0 },
251 { "function", ppc_pe_function,0 },
252 { "tocd", ppc_pe_tocd, 0 },
255 #if defined (OBJ_XCOFF) || defined (OBJ_ELF)
257 { "machine", ppc_machine, 0 },
264 /* Predefined register names if -mregnames (or default for Windows NT).
265 In general, there are lots of them, in an attempt to be compatible
266 with a number of other Windows NT assemblers. */
268 /* Structure to hold information about predefined registers. */
275 /* List of registers that are pre-defined:
277 Each general register has predefined names of the form:
278 1. r<reg_num> which has the value <reg_num>.
279 2. r.<reg_num> which has the value <reg_num>.
281 Each floating point register has predefined names of the form:
282 1. f<reg_num> which has the value <reg_num>.
283 2. f.<reg_num> which has the value <reg_num>.
285 Each vector unit register has predefined names of the form:
286 1. v<reg_num> which has the value <reg_num>.
287 2. v.<reg_num> which has the value <reg_num>.
289 Each condition register has predefined names of the form:
290 1. cr<reg_num> which has the value <reg_num>.
291 2. cr.<reg_num> which has the value <reg_num>.
293 There are individual registers as well:
294 sp or r.sp has the value 1
295 rtoc or r.toc has the value 2
296 fpscr has the value 0
302 dsisr has the value 18
304 sdr1 has the value 25
305 srr0 has the value 26
306 srr1 has the value 27
308 The table is sorted. Suitable for searching by a binary search. */
310 static const struct pd_reg pre_defined_registers[] =
312 { "cr.0", 0 }, /* Condition Registers */
332 { "dar", 19 }, /* Data Access Register */
333 { "dec", 22 }, /* Decrementer */
334 { "dsisr", 18 }, /* Data Storage Interrupt Status Register */
336 { "f.0", 0 }, /* Floating point registers */
404 { "lr", 8 }, /* Link Register */
408 { "r.0", 0 }, /* General Purpose Registers */
441 { "r.sp", 1 }, /* Stack Pointer */
443 { "r.toc", 2 }, /* Pointer to the table of contents */
445 { "r0", 0 }, /* More general purpose registers */
478 { "rtoc", 2 }, /* Table of contents */
480 { "sdr1", 25 }, /* Storage Description Register 1 */
484 { "srr0", 26 }, /* Machine Status Save/Restore Register 0 */
485 { "srr1", 27 }, /* Machine Status Save/Restore Register 1 */
487 { "v.0", 0 }, /* Vector registers */
557 #define REG_NAME_CNT (sizeof (pre_defined_registers) / sizeof (struct pd_reg))
559 /* Given NAME, find the register number associated with that name, return
560 the integer value associated with the given name or -1 on failure. */
562 static int reg_name_search
563 PARAMS ((const struct pd_reg *, int, const char * name));
566 reg_name_search (regs, regcount, name)
567 const struct pd_reg *regs;
571 int middle, low, high;
579 middle = (low + high) / 2;
580 cmp = strcasecmp (name, regs[middle].name);
586 return regs[middle].value;
594 * Summary of register_name.
596 * in: Input_line_pointer points to 1st char of operand.
598 * out: A expressionS.
599 * The operand may have been a register: in this case, X_op == O_register,
600 * X_add_number is set to the register number, and truth is returned.
601 * Input_line_pointer->(next non-blank) char after operand, or is in its
606 register_name (expressionP)
607 expressionS *expressionP;
614 /* Find the spelling of the operand. */
615 start = name = input_line_pointer;
616 if (name[0] == '%' && ISALPHA (name[1]))
617 name = ++input_line_pointer;
619 else if (!reg_names_p || !ISALPHA (name[0]))
622 c = get_symbol_end ();
623 reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT, name);
625 /* Put back the delimiting char. */
626 *input_line_pointer = c;
628 /* Look to see if it's in the register table. */
631 expressionP->X_op = O_register;
632 expressionP->X_add_number = reg_number;
634 /* Make the rest nice. */
635 expressionP->X_add_symbol = NULL;
636 expressionP->X_op_symbol = NULL;
640 /* Reset the line as if we had not done anything. */
641 input_line_pointer = start;
645 /* This function is called for each symbol seen in an expression. It
646 handles the special parsing which PowerPC assemblers are supposed
647 to use for condition codes. */
649 /* Whether to do the special parsing. */
650 static boolean cr_operand;
652 /* Names to recognize in a condition code. This table is sorted. */
653 static const struct pd_reg cr_names[] =
670 /* Parsing function. This returns non-zero if it recognized an
674 ppc_parse_name (name, expr)
683 val = reg_name_search (cr_names, sizeof cr_names / sizeof cr_names[0],
688 expr->X_op = O_constant;
689 expr->X_add_number = val;
694 /* Local variables. */
696 /* The type of processor we are assembling for. This is one or more
697 of the PPC_OPCODE flags defined in opcode/ppc.h. */
698 static unsigned long ppc_cpu = 0;
700 /* Whether to target xcoff64/elf64. */
701 static unsigned int ppc_obj64 = BFD_DEFAULT_TARGET_SIZE == 64;
703 /* Opcode hash table. */
704 static struct hash_control *ppc_hash;
706 /* Macro hash table. */
707 static struct hash_control *ppc_macro_hash;
710 /* What type of shared library support to use. */
711 static enum { SHLIB_NONE, SHLIB_PIC, SHLIB_MRELOCATABLE } shlib = SHLIB_NONE;
713 /* Flags to set in the elf header. */
714 static flagword ppc_flags = 0;
716 /* Whether this is Solaris or not. */
717 #ifdef TARGET_SOLARIS_COMMENT
718 #define SOLARIS_P true
720 #define SOLARIS_P false
723 static boolean msolaris = SOLARIS_P;
728 /* The RS/6000 assembler uses the .csect pseudo-op to generate code
729 using a bunch of different sections. These assembler sections,
730 however, are all encompassed within the .text or .data sections of
731 the final output file. We handle this by using different
732 subsegments within these main segments. */
734 /* Next subsegment to allocate within the .text segment. */
735 static subsegT ppc_text_subsegment = 2;
737 /* Linked list of csects in the text section. */
738 static symbolS *ppc_text_csects;
740 /* Next subsegment to allocate within the .data segment. */
741 static subsegT ppc_data_subsegment = 2;
743 /* Linked list of csects in the data section. */
744 static symbolS *ppc_data_csects;
746 /* The current csect. */
747 static symbolS *ppc_current_csect;
749 /* The RS/6000 assembler uses a TOC which holds addresses of functions
750 and variables. Symbols are put in the TOC with the .tc pseudo-op.
751 A special relocation is used when accessing TOC entries. We handle
752 the TOC as a subsegment within the .data segment. We set it up if
753 we see a .toc pseudo-op, and save the csect symbol here. */
754 static symbolS *ppc_toc_csect;
756 /* The first frag in the TOC subsegment. */
757 static fragS *ppc_toc_frag;
759 /* The first frag in the first subsegment after the TOC in the .data
760 segment. NULL if there are no subsegments after the TOC. */
761 static fragS *ppc_after_toc_frag;
763 /* The current static block. */
764 static symbolS *ppc_current_block;
766 /* The COFF debugging section; set by md_begin. This is not the
767 .debug section, but is instead the secret BFD section which will
768 cause BFD to set the section number of a symbol to N_DEBUG. */
769 static asection *ppc_coff_debug_section;
771 #endif /* OBJ_XCOFF */
775 /* Various sections that we need for PE coff support. */
776 static segT ydata_section;
777 static segT pdata_section;
778 static segT reldata_section;
779 static segT rdata_section;
780 static segT tocdata_section;
782 /* The current section and the previous section. See ppc_previous. */
783 static segT ppc_previous_section;
784 static segT ppc_current_section;
789 symbolS *GOT_symbol; /* Pre-defined "_GLOBAL_OFFSET_TABLE" */
793 const char *const md_shortopts = "b:l:usm:K:VQ:";
795 const char *const md_shortopts = "um:";
797 const struct option md_longopts[] = {
798 {NULL, no_argument, NULL, 0}
800 const size_t md_longopts_size = sizeof (md_longopts);
803 md_parse_option (c, arg)
810 /* -u means that any undefined symbols should be treated as
811 external, which is the default for gas anyhow. */
816 /* Solaris as takes -le (presumably for little endian). For completeness
817 sake, recognize -be also. */
818 if (strcmp (arg, "e") == 0)
820 target_big_endian = 0;
821 set_target_endian = 1;
829 if (strcmp (arg, "e") == 0)
831 target_big_endian = 1;
832 set_target_endian = 1;
840 /* Recognize -K PIC. */
841 if (strcmp (arg, "PIC") == 0 || strcmp (arg, "pic") == 0)
844 ppc_flags |= EF_PPC_RELOCATABLE_LIB;
852 /* a64 and a32 determine whether to use XCOFF64 or XCOFF32. */
854 if (strcmp (arg, "64") == 0)
859 as_fatal (_("%s unsupported"), "-a64");
862 else if (strcmp (arg, "32") == 0)
869 /* -mpwrx and -mpwr2 mean to assemble for the IBM POWER/2
871 if (strcmp (arg, "pwrx") == 0 || strcmp (arg, "pwr2") == 0)
872 ppc_cpu = PPC_OPCODE_POWER | PPC_OPCODE_POWER2 | PPC_OPCODE_32;
873 /* -mpwr means to assemble for the IBM POWER (RIOS1). */
874 else if (strcmp (arg, "pwr") == 0)
875 ppc_cpu = PPC_OPCODE_POWER | PPC_OPCODE_32;
876 /* -m601 means to assemble for the PowerPC 601, which includes
877 instructions that are holdovers from the Power. */
878 else if (strcmp (arg, "601") == 0)
879 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_601 | PPC_OPCODE_32;
880 /* -mppc, -mppc32, -m603, and -m604 mean to assemble for the
882 else if (strcmp (arg, "ppc") == 0
883 || strcmp (arg, "ppc32") == 0
884 || strcmp (arg, "603") == 0
885 || strcmp (arg, "604") == 0)
886 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_32;
887 /* -m403 and -m405 mean to assemble for the PowerPC 403/405. */
888 else if (strcmp (arg, "403") == 0
889 || strcmp (arg, "405") == 0)
890 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_403 | PPC_OPCODE_32;
891 else if (strcmp (arg, "7400") == 0
892 || strcmp (arg, "7410") == 0
893 || strcmp (arg, "7450") == 0
894 || strcmp (arg, "7455") == 0)
895 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_ALTIVEC | PPC_OPCODE_32;
896 else if (strcmp (arg, "altivec") == 0)
899 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_ALTIVEC;
901 ppc_cpu |= PPC_OPCODE_ALTIVEC;
903 /* -mppc64 and -m620 mean to assemble for the 64-bit PowerPC
905 else if (strcmp (arg, "ppc64") == 0 || strcmp (arg, "620") == 0)
907 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_64;
909 else if (strcmp (arg, "ppc64bridge") == 0)
911 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_64_BRIDGE | PPC_OPCODE_64;
913 /* -mbooke/-mbooke32 mean enable 32-bit BookE support. */
914 else if (strcmp (arg, "booke") == 0 || strcmp (arg, "booke32") == 0)
915 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_BOOKE | PPC_OPCODE_32;
916 /* -mbooke64 means enable 64-bit BookE support. */
917 else if (strcmp (arg, "booke64") == 0)
919 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_BOOKE |
920 PPC_OPCODE_BOOKE64 | PPC_OPCODE_64;
922 else if (strcmp (arg, "power4") == 0)
924 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_64 | PPC_OPCODE_POWER4;
926 /* -mcom means assemble for the common intersection between Power
927 and PowerPC. At present, we just allow the union, rather
928 than the intersection. */
929 else if (strcmp (arg, "com") == 0)
930 ppc_cpu = PPC_OPCODE_COMMON | PPC_OPCODE_32;
931 /* -many means to assemble for any architecture (PWR/PWRX/PPC). */
932 else if (strcmp (arg, "any") == 0)
933 ppc_cpu = PPC_OPCODE_ANY | PPC_OPCODE_32;
935 else if (strcmp (arg, "regnames") == 0)
938 else if (strcmp (arg, "no-regnames") == 0)
942 /* -mrelocatable/-mrelocatable-lib -- warn about initializations
943 that require relocation. */
944 else if (strcmp (arg, "relocatable") == 0)
946 shlib = SHLIB_MRELOCATABLE;
947 ppc_flags |= EF_PPC_RELOCATABLE;
950 else if (strcmp (arg, "relocatable-lib") == 0)
952 shlib = SHLIB_MRELOCATABLE;
953 ppc_flags |= EF_PPC_RELOCATABLE_LIB;
956 /* -memb, set embedded bit. */
957 else if (strcmp (arg, "emb") == 0)
958 ppc_flags |= EF_PPC_EMB;
960 /* -mlittle/-mbig set the endianess. */
961 else if (strcmp (arg, "little") == 0
962 || strcmp (arg, "little-endian") == 0)
964 target_big_endian = 0;
965 set_target_endian = 1;
968 else if (strcmp (arg, "big") == 0 || strcmp (arg, "big-endian") == 0)
970 target_big_endian = 1;
971 set_target_endian = 1;
974 else if (strcmp (arg, "solaris") == 0)
977 ppc_comment_chars = ppc_solaris_comment_chars;
980 else if (strcmp (arg, "no-solaris") == 0)
983 ppc_comment_chars = ppc_eabi_comment_chars;
988 as_bad (_("invalid switch -m%s"), arg);
994 /* -V: SVR4 argument to print version ID. */
999 /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section
1000 should be emitted or not. FIXME: Not implemented. */
1004 /* Solaris takes -s to specify that .stabs go in a .stabs section,
1005 rather than .stabs.excl, which is ignored by the linker.
1006 FIXME: Not implemented. */
1022 md_show_usage (stream)
1025 fprintf (stream, _("\
1028 -mpwrx, -mpwr2 generate code for POWER/2 (RIOS2)\n\
1029 -mpwr generate code for POWER (RIOS1)\n\
1030 -m601 generate code for PowerPC 601\n\
1031 -mppc, -mppc32, -m603, -m604\n\
1032 generate code for PowerPC 603/604\n\
1033 -m403, -m405 generate code for PowerPC 403/405\n\
1034 -m7400, -m7410, -m7450, -m7455\n\
1035 generate code For PowerPC 7400/7410/7450/7455\n\
1036 -mppc64, -m620 generate code for PowerPC 620/625/630\n\
1037 -mppc64bridge generate code for PowerPC 64, including bridge insns\n\
1038 -mbooke64 generate code for 64-bit PowerPC BookE\n\
1039 -mbooke, mbooke32 generate code for 32-bit PowerPC BookE\n\
1040 -mpower4 generate code for Power4 architecture\n\
1041 -maltivec generate code for AltiVec\n\
1042 -mcom generate code Power/PowerPC common instructions\n\
1043 -many generate code for any architecture (PWR/PWRX/PPC)\n\
1044 -mregnames Allow symbolic names for registers\n\
1045 -mno-regnames Do not allow symbolic names for registers\n"));
1047 fprintf (stream, _("\
1048 -mrelocatable support for GCC's -mrelocatble option\n\
1049 -mrelocatable-lib support for GCC's -mrelocatble-lib option\n\
1050 -memb set PPC_EMB bit in ELF flags\n\
1051 -mlittle, -mlittle-endian\n\
1052 generate code for a little endian machine\n\
1053 -mbig, -mbig-endian generate code for a big endian machine\n\
1054 -msolaris generate code for Solaris\n\
1055 -mno-solaris do not generate code for Solaris\n\
1056 -V print assembler version number\n\
1057 -Qy, -Qn ignored\n"));
1061 /* Set ppc_cpu if it is not already set. */
1066 const char *default_os = TARGET_OS;
1067 const char *default_cpu = TARGET_CPU;
1072 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_64;
1073 else if (strncmp (default_os, "aix", 3) == 0
1074 && default_os[3] >= '4' && default_os[3] <= '9')
1075 ppc_cpu = PPC_OPCODE_COMMON | PPC_OPCODE_32;
1076 else if (strncmp (default_os, "aix3", 4) == 0)
1077 ppc_cpu = PPC_OPCODE_POWER | PPC_OPCODE_32;
1078 else if (strcmp (default_cpu, "rs6000") == 0)
1079 ppc_cpu = PPC_OPCODE_POWER | PPC_OPCODE_32;
1080 else if (strncmp (default_cpu, "powerpc", 7) == 0)
1082 if (default_cpu[7] == '6' && default_cpu[8] == '4')
1083 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_64;
1085 ppc_cpu = PPC_OPCODE_PPC | PPC_OPCODE_32;
1088 as_fatal (_("Unknown default cpu = %s, os = %s"),
1089 default_cpu, default_os);
1093 /* Figure out the BFD architecture to use. */
1095 enum bfd_architecture
1098 const char *default_cpu = TARGET_CPU;
1101 if ((ppc_cpu & PPC_OPCODE_PPC) != 0)
1102 return bfd_arch_powerpc;
1103 else if ((ppc_cpu & PPC_OPCODE_POWER) != 0)
1104 return bfd_arch_rs6000;
1105 else if ((ppc_cpu & (PPC_OPCODE_COMMON | PPC_OPCODE_ANY)) != 0)
1107 if (strcmp (default_cpu, "rs6000") == 0)
1108 return bfd_arch_rs6000;
1109 else if (strncmp (default_cpu, "powerpc", 7) == 0)
1110 return bfd_arch_powerpc;
1113 as_fatal (_("Neither Power nor PowerPC opcodes were selected."));
1114 return bfd_arch_unknown;
1121 return bfd_mach_ppc64;
1122 else if (ppc_arch () == bfd_arch_rs6000)
1123 return bfd_mach_rs6k;
1125 return bfd_mach_ppc;
1129 ppc_target_format ()
1133 return target_big_endian ? "pe-powerpc" : "pe-powerpcle";
1135 return "xcoff-powermac";
1138 return (ppc_obj64 ? "aix5coff64-rs6000" : "aixcoff-rs6000");
1140 return (ppc_obj64 ? "aixcoff64-rs6000" : "aixcoff-rs6000");
1145 return (target_big_endian
1146 ? (ppc_obj64 ? "elf64-powerpc" : "elf32-powerpc")
1147 : (ppc_obj64 ? "elf64-powerpcle" : "elf32-powerpcle"));
1151 /* This function is called when the assembler starts up. It is called
1152 after the options have been parsed and the output file has been
1158 register const struct powerpc_opcode *op;
1159 const struct powerpc_opcode *op_end;
1160 const struct powerpc_macro *macro;
1161 const struct powerpc_macro *macro_end;
1162 boolean dup_insn = false;
1167 /* Set the ELF flags if desired. */
1168 if (ppc_flags && !msolaris)
1169 bfd_set_private_flags (stdoutput, ppc_flags);
1172 /* Insert the opcodes into a hash table. */
1173 ppc_hash = hash_new ();
1175 op_end = powerpc_opcodes + powerpc_num_opcodes;
1176 for (op = powerpc_opcodes; op < op_end; op++)
1178 know ((op->opcode & op->mask) == op->opcode);
1180 if ((op->flags & ppc_cpu & ~(PPC_OPCODE_32 | PPC_OPCODE_64)) != 0
1181 && ((op->flags & (PPC_OPCODE_32 | PPC_OPCODE_64)) == 0
1182 || ((op->flags & (PPC_OPCODE_32 | PPC_OPCODE_64))
1183 == (ppc_cpu & (PPC_OPCODE_32 | PPC_OPCODE_64)))
1184 || (ppc_cpu & PPC_OPCODE_64_BRIDGE) != 0)
1185 /* Certain instructions (eg: extsw) do not exist in the
1186 32-bit BookE instruction set, but they do exist in the
1187 64-bit BookE instruction set, and other PPC instruction
1188 sets. Check to see if the opcode has the BOOKE64 flag set.
1189 If it does make sure that the target CPU is not the BookE32. */
1190 && ((op->flags & PPC_OPCODE_BOOKE64) == 0
1191 || (ppc_cpu & PPC_OPCODE_BOOKE64) == PPC_OPCODE_BOOKE64
1192 || (ppc_cpu & PPC_OPCODE_BOOKE) == 0)
1193 && ((op->flags & (PPC_OPCODE_POWER4 | PPC_OPCODE_NOPOWER4)) == 0
1194 || ((op->flags & PPC_OPCODE_POWER4)
1195 == (ppc_cpu & PPC_OPCODE_POWER4))))
1199 retval = hash_insert (ppc_hash, op->name, (PTR) op);
1200 if (retval != (const char *) NULL)
1202 /* Ignore Power duplicates for -m601. */
1203 if ((ppc_cpu & PPC_OPCODE_601) != 0
1204 && (op->flags & PPC_OPCODE_POWER) != 0)
1207 as_bad (_("Internal assembler error for instruction %s"),
1214 /* Insert the macros into a hash table. */
1215 ppc_macro_hash = hash_new ();
1217 macro_end = powerpc_macros + powerpc_num_macros;
1218 for (macro = powerpc_macros; macro < macro_end; macro++)
1220 if ((macro->flags & ppc_cpu) != 0)
1224 retval = hash_insert (ppc_macro_hash, macro->name, (PTR) macro);
1225 if (retval != (const char *) NULL)
1227 as_bad (_("Internal assembler error for macro %s"), macro->name);
1236 /* Tell the main code what the endianness is if it is not overidden
1238 if (!set_target_endian)
1240 set_target_endian = 1;
1241 target_big_endian = PPC_BIG_ENDIAN;
1245 ppc_coff_debug_section = coff_section_from_bfd_index (stdoutput, N_DEBUG);
1247 /* Create dummy symbols to serve as initial csects. This forces the
1248 text csects to precede the data csects. These symbols will not
1250 ppc_text_csects = symbol_make ("dummy\001");
1251 symbol_get_tc (ppc_text_csects)->within = ppc_text_csects;
1252 ppc_data_csects = symbol_make ("dummy\001");
1253 symbol_get_tc (ppc_data_csects)->within = ppc_data_csects;
1258 ppc_current_section = text_section;
1259 ppc_previous_section = 0;
1264 /* Insert an operand value into an instruction. */
1266 static unsigned long
1267 ppc_insert_operand (insn, operand, val, file, line)
1269 const struct powerpc_operand *operand;
1274 if (operand->bits != 32)
1279 if ((operand->flags & PPC_OPERAND_SIGNED) != 0)
1281 if ((operand->flags & PPC_OPERAND_SIGNOPT) != 0)
1282 max = (1 << operand->bits) - 1;
1284 max = (1 << (operand->bits - 1)) - 1;
1285 min = - (1 << (operand->bits - 1));
1289 /* Some people write 32 bit hex constants with the sign
1290 extension done by hand. This shouldn't really be
1291 valid, but, to permit this code to assemble on a 64
1292 bit host, we sign extend the 32 bit value. */
1294 && (val & (offsetT) 0x80000000) != 0
1295 && (val & (offsetT) 0xffffffff) == val)
1304 max = (1 << operand->bits) - 1;
1308 if ((operand->flags & PPC_OPERAND_NEGATIVE) != 0)
1313 if (test < (offsetT) min || test > (offsetT) max)
1316 _("operand out of range (%s not between %ld and %ld)");
1319 sprint_value (buf, test);
1320 as_bad_where (file, line, err, buf, min, max);
1324 if (operand->insert)
1329 insn = (*operand->insert) (insn, (long) val, ppc_cpu, &errmsg);
1330 if (errmsg != (const char *) NULL)
1331 as_bad_where (file, line, errmsg);
1334 insn |= (((long) val & ((1 << operand->bits) - 1))
1342 /* Parse @got, etc. and return the desired relocation. */
1343 static bfd_reloc_code_real_type
1344 ppc_elf_suffix (str_p, exp_p)
1359 const struct map_bfd *ptr;
1361 #define MAP(str,reloc) { str, sizeof (str)-1, reloc }
1363 static const struct map_bfd mapping[] = {
1364 MAP ("l", (int) BFD_RELOC_LO16),
1365 MAP ("h", (int) BFD_RELOC_HI16),
1366 MAP ("ha", (int) BFD_RELOC_HI16_S),
1367 MAP ("brtaken", (int) BFD_RELOC_PPC_B16_BRTAKEN),
1368 MAP ("brntaken", (int) BFD_RELOC_PPC_B16_BRNTAKEN),
1369 MAP ("got", (int) BFD_RELOC_16_GOTOFF),
1370 MAP ("got@l", (int) BFD_RELOC_LO16_GOTOFF),
1371 MAP ("got@h", (int) BFD_RELOC_HI16_GOTOFF),
1372 MAP ("got@ha", (int) BFD_RELOC_HI16_S_GOTOFF),
1373 MAP ("fixup", (int) BFD_RELOC_CTOR), /* warning with -mrelocatable */
1374 MAP ("plt", (int) BFD_RELOC_24_PLT_PCREL),
1375 MAP ("pltrel24", (int) BFD_RELOC_24_PLT_PCREL),
1376 MAP ("copy", (int) BFD_RELOC_PPC_COPY),
1377 MAP ("globdat", (int) BFD_RELOC_PPC_GLOB_DAT),
1378 MAP ("local24pc", (int) BFD_RELOC_PPC_LOCAL24PC),
1379 MAP ("local", (int) BFD_RELOC_PPC_LOCAL24PC),
1380 MAP ("pltrel", (int) BFD_RELOC_32_PLT_PCREL),
1381 MAP ("plt@l", (int) BFD_RELOC_LO16_PLTOFF),
1382 MAP ("plt@h", (int) BFD_RELOC_HI16_PLTOFF),
1383 MAP ("plt@ha", (int) BFD_RELOC_HI16_S_PLTOFF),
1384 MAP ("sdarel", (int) BFD_RELOC_GPREL16),
1385 MAP ("sectoff", (int) BFD_RELOC_16_BASEREL),
1386 MAP ("sectoff@l", (int) BFD_RELOC_LO16_BASEREL),
1387 MAP ("sectoff@h", (int) BFD_RELOC_HI16_BASEREL),
1388 MAP ("sectoff@ha", (int) BFD_RELOC_HI16_S_BASEREL),
1389 MAP ("naddr", (int) BFD_RELOC_PPC_EMB_NADDR32),
1390 MAP ("naddr16", (int) BFD_RELOC_PPC_EMB_NADDR16),
1391 MAP ("naddr@l", (int) BFD_RELOC_PPC_EMB_NADDR16_LO),
1392 MAP ("naddr@h", (int) BFD_RELOC_PPC_EMB_NADDR16_HI),
1393 MAP ("naddr@ha", (int) BFD_RELOC_PPC_EMB_NADDR16_HA),
1394 MAP ("sdai16", (int) BFD_RELOC_PPC_EMB_SDAI16),
1395 MAP ("sda2rel", (int) BFD_RELOC_PPC_EMB_SDA2REL),
1396 MAP ("sda2i16", (int) BFD_RELOC_PPC_EMB_SDA2I16),
1397 MAP ("sda21", (int) BFD_RELOC_PPC_EMB_SDA21),
1398 MAP ("mrkref", (int) BFD_RELOC_PPC_EMB_MRKREF),
1399 MAP ("relsect", (int) BFD_RELOC_PPC_EMB_RELSEC16),
1400 MAP ("relsect@l", (int) BFD_RELOC_PPC_EMB_RELST_LO),
1401 MAP ("relsect@h", (int) BFD_RELOC_PPC_EMB_RELST_HI),
1402 MAP ("relsect@ha", (int) BFD_RELOC_PPC_EMB_RELST_HA),
1403 MAP ("bitfld", (int) BFD_RELOC_PPC_EMB_BIT_FLD),
1404 MAP ("relsda", (int) BFD_RELOC_PPC_EMB_RELSDA),
1405 MAP ("xgot", (int) BFD_RELOC_PPC_TOC16),
1406 /* The following are only valid for ppc64. Negative values are
1407 used instead of a flag. */
1408 MAP ("higher", - (int) BFD_RELOC_PPC64_HIGHER),
1409 MAP ("highera", - (int) BFD_RELOC_PPC64_HIGHER_S),
1410 MAP ("highest", - (int) BFD_RELOC_PPC64_HIGHEST),
1411 MAP ("highesta", - (int) BFD_RELOC_PPC64_HIGHEST_S),
1412 MAP ("tocbase", - (int) BFD_RELOC_PPC64_TOC),
1413 MAP ("toc", - (int) BFD_RELOC_PPC_TOC16),
1414 MAP ("toc@l", - (int) BFD_RELOC_PPC64_TOC16_LO),
1415 MAP ("toc@h", - (int) BFD_RELOC_PPC64_TOC16_HI),
1416 MAP ("toc@ha", - (int) BFD_RELOC_PPC64_TOC16_HA),
1417 { (char *) 0, 0, (int) BFD_RELOC_UNUSED }
1421 return BFD_RELOC_UNUSED;
1423 for (ch = *str, str2 = ident;
1424 (str2 < ident + sizeof (ident) - 1
1425 && (ISALNUM (ch) || ch == '@'));
1428 *str2++ = TOLOWER (ch);
1435 for (ptr = &mapping[0]; ptr->length > 0; ptr++)
1436 if (ch == ptr->string[0]
1437 && len == ptr->length
1438 && memcmp (ident, ptr->string, ptr->length) == 0)
1440 int reloc = ptr->reloc;
1445 return BFD_RELOC_UNUSED;
1449 if (exp_p->X_add_number != 0
1450 && (reloc == (int) BFD_RELOC_16_GOTOFF
1451 || reloc == (int) BFD_RELOC_LO16_GOTOFF
1452 || reloc == (int) BFD_RELOC_HI16_GOTOFF
1453 || reloc == (int) BFD_RELOC_HI16_S_GOTOFF))
1454 as_warn (_("identifier+constant@got means identifier@got+constant"));
1456 /* Now check for identifier@suffix+constant. */
1457 if (*str == '-' || *str == '+')
1459 char *orig_line = input_line_pointer;
1460 expressionS new_exp;
1462 input_line_pointer = str;
1463 expression (&new_exp);
1464 if (new_exp.X_op == O_constant)
1466 exp_p->X_add_number += new_exp.X_add_number;
1467 str = input_line_pointer;
1470 if (&input_line_pointer != str_p)
1471 input_line_pointer = orig_line;
1475 if (reloc == (int) BFD_RELOC_PPC64_TOC
1476 && exp_p->X_op == O_symbol)
1478 /* This reloc type ignores the symbol. Change the symbol
1479 so that the dummy .TOC. symbol can be omitted from the
1481 exp_p->X_add_symbol = &abs_symbol;
1484 return (bfd_reloc_code_real_type) reloc;
1487 return BFD_RELOC_UNUSED;
1490 /* Like normal .long/.short/.word, except support @got, etc.
1491 Clobbers input_line_pointer, checks end-of-line. */
1493 ppc_elf_cons (nbytes)
1494 register int nbytes; /* 1=.byte, 2=.word, 4=.long, 8=.llong. */
1497 bfd_reloc_code_real_type reloc;
1499 if (is_it_end_of_statement ())
1501 demand_empty_rest_of_line ();
1508 if (exp.X_op == O_symbol
1509 && *input_line_pointer == '@'
1510 && (reloc = ppc_elf_suffix (&input_line_pointer,
1511 &exp)) != BFD_RELOC_UNUSED)
1513 reloc_howto_type *reloc_howto;
1516 reloc_howto = bfd_reloc_type_lookup (stdoutput, reloc);
1517 size = bfd_get_reloc_size (reloc_howto);
1521 as_bad (_("%s relocations do not fit in %d bytes\n"),
1522 reloc_howto->name, nbytes);
1529 p = frag_more (nbytes);
1531 if (target_big_endian)
1532 offset = nbytes - size;
1533 fix_new_exp (frag_now, p - frag_now->fr_literal + offset, size,
1538 emit_expr (&exp, (unsigned int) nbytes);
1540 while (*input_line_pointer++ == ',');
1542 /* Put terminator back into stream. */
1543 input_line_pointer--;
1544 demand_empty_rest_of_line ();
1547 /* Solaris pseduo op to change to the .rodata section. */
1552 char *save_line = input_line_pointer;
1553 static char section[] = ".rodata\n";
1555 /* Just pretend this is .section .rodata */
1556 input_line_pointer = section;
1557 obj_elf_section (xxx);
1559 input_line_pointer = save_line;
1562 /* Pseudo op to make file scope bss items. */
1565 int xxx ATTRIBUTE_UNUSED;
1567 register char *name;
1571 register symbolS *symbolP;
1578 name = input_line_pointer;
1579 c = get_symbol_end ();
1581 /* just after name is now '\0'. */
1582 p = input_line_pointer;
1585 if (*input_line_pointer != ',')
1587 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1588 ignore_rest_of_line ();
1592 input_line_pointer++; /* skip ',' */
1593 if ((size = get_absolute_expression ()) < 0)
1595 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) size);
1596 ignore_rest_of_line ();
1600 /* The third argument to .lcomm is the alignment. */
1601 if (*input_line_pointer != ',')
1605 ++input_line_pointer;
1606 align = get_absolute_expression ();
1609 as_warn (_("ignoring bad alignment"));
1615 symbolP = symbol_find_or_make (name);
1618 if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
1620 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1621 S_GET_NAME (symbolP));
1622 ignore_rest_of_line ();
1626 if (S_GET_VALUE (symbolP) && S_GET_VALUE (symbolP) != (valueT) size)
1628 as_bad (_("Length of .lcomm \"%s\" is already %ld. Not changed to %ld."),
1629 S_GET_NAME (symbolP),
1630 (long) S_GET_VALUE (symbolP),
1633 ignore_rest_of_line ();
1639 old_subsec = now_subseg;
1642 /* Convert to a power of 2 alignment. */
1643 for (align2 = 0; (align & 1) == 0; align >>= 1, ++align2);
1646 as_bad (_("Common alignment not a power of 2"));
1647 ignore_rest_of_line ();
1654 record_alignment (bss_section, align2);
1655 subseg_set (bss_section, 0);
1657 frag_align (align2, 0, 0);
1658 if (S_GET_SEGMENT (symbolP) == bss_section)
1659 symbol_get_frag (symbolP)->fr_symbol = 0;
1660 symbol_set_frag (symbolP, frag_now);
1661 pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size,
1664 S_SET_SIZE (symbolP, size);
1665 S_SET_SEGMENT (symbolP, bss_section);
1666 subseg_set (old_sec, old_subsec);
1667 demand_empty_rest_of_line ();
1670 /* Validate any relocations emitted for -mrelocatable, possibly adding
1671 fixups for word relocations in writable segments, so we can adjust
1674 ppc_elf_validate_fix (fixp, seg)
1678 if (fixp->fx_done || fixp->fx_pcrel)
1687 case SHLIB_MRELOCATABLE:
1688 if (fixp->fx_r_type <= BFD_RELOC_UNUSED
1689 && fixp->fx_r_type != BFD_RELOC_16_GOTOFF
1690 && fixp->fx_r_type != BFD_RELOC_HI16_GOTOFF
1691 && fixp->fx_r_type != BFD_RELOC_LO16_GOTOFF
1692 && fixp->fx_r_type != BFD_RELOC_HI16_S_GOTOFF
1693 && fixp->fx_r_type != BFD_RELOC_16_BASEREL
1694 && fixp->fx_r_type != BFD_RELOC_LO16_BASEREL
1695 && fixp->fx_r_type != BFD_RELOC_HI16_BASEREL
1696 && fixp->fx_r_type != BFD_RELOC_HI16_S_BASEREL
1697 && (seg->flags & SEC_LOAD) != 0
1698 && strcmp (segment_name (seg), ".got2") != 0
1699 && strcmp (segment_name (seg), ".dtors") != 0
1700 && strcmp (segment_name (seg), ".ctors") != 0
1701 && strcmp (segment_name (seg), ".fixup") != 0
1702 && strcmp (segment_name (seg), ".gcc_except_table") != 0
1703 && strcmp (segment_name (seg), ".eh_frame") != 0
1704 && strcmp (segment_name (seg), ".ex_shared") != 0)
1706 if ((seg->flags & (SEC_READONLY | SEC_CODE)) != 0
1707 || fixp->fx_r_type != BFD_RELOC_CTOR)
1709 as_bad_where (fixp->fx_file, fixp->fx_line,
1710 _("Relocation cannot be done when using -mrelocatable"));
1717 /* Prevent elf_frob_file_before_adjust removing a weak undefined
1718 function descriptor sym if the corresponding code sym is used. */
1721 ppc_frob_file_before_adjust ()
1728 for (symp = symbol_rootP; symp; symp = symbol_next (symp))
1735 name = S_GET_NAME (symp);
1739 if (! S_IS_WEAK (symp)
1740 || S_IS_DEFINED (symp))
1743 len = strlen (name) + 1;
1744 dotname = xmalloc (len + 1);
1746 memcpy (dotname + 1, name, len);
1747 dotsym = symbol_find (dotname);
1749 if (dotsym != NULL && (symbol_used_p (dotsym)
1750 || symbol_used_in_reloc_p (dotsym)))
1752 symbol_mark_used (symp);
1756 /* Don't emit .TOC. symbol. */
1757 symp = symbol_find (".TOC.");
1759 symbol_remove (symp, &symbol_rootP, &symbol_lastP);
1761 #endif /* OBJ_ELF */
1766 * Summary of parse_toc_entry.
1768 * in: Input_line_pointer points to the '[' in one of:
1770 * [toc] [tocv] [toc32] [toc64]
1772 * Anything else is an error of one kind or another.
1775 * return value: success or failure
1776 * toc_kind: kind of toc reference
1777 * input_line_pointer:
1778 * success: first char after the ']'
1779 * failure: unchanged
1783 * [toc] - rv == success, toc_kind = default_toc
1784 * [tocv] - rv == success, toc_kind = data_in_toc
1785 * [toc32] - rv == success, toc_kind = must_be_32
1786 * [toc64] - rv == success, toc_kind = must_be_64
1790 enum toc_size_qualifier
1792 default_toc, /* The toc cell constructed should be the system default size */
1793 data_in_toc, /* This is a direct reference to a toc cell */
1794 must_be_32, /* The toc cell constructed must be 32 bits wide */
1795 must_be_64 /* The toc cell constructed must be 64 bits wide */
1799 parse_toc_entry (toc_kind)
1800 enum toc_size_qualifier *toc_kind;
1805 enum toc_size_qualifier t;
1807 /* Save the input_line_pointer. */
1808 start = input_line_pointer;
1810 /* Skip over the '[' , and whitespace. */
1811 ++input_line_pointer;
1814 /* Find the spelling of the operand. */
1815 toc_spec = input_line_pointer;
1816 c = get_symbol_end ();
1818 if (strcmp (toc_spec, "toc") == 0)
1822 else if (strcmp (toc_spec, "tocv") == 0)
1826 else if (strcmp (toc_spec, "toc32") == 0)
1830 else if (strcmp (toc_spec, "toc64") == 0)
1836 as_bad (_("syntax error: invalid toc specifier `%s'"), toc_spec);
1837 *input_line_pointer = c;
1838 input_line_pointer = start;
1842 /* Now find the ']'. */
1843 *input_line_pointer = c;
1845 SKIP_WHITESPACE (); /* leading whitespace could be there. */
1846 c = *input_line_pointer++; /* input_line_pointer->past char in c. */
1850 as_bad (_("syntax error: expected `]', found `%c'"), c);
1851 input_line_pointer = start;
1861 /* We need to keep a list of fixups. We can't simply generate them as
1862 we go, because that would require us to first create the frag, and
1863 that would screw up references to ``.''. */
1869 bfd_reloc_code_real_type reloc;
1872 #define MAX_INSN_FIXUPS (5)
1874 /* This routine is called for each instruction to be assembled. */
1881 const struct powerpc_opcode *opcode;
1883 const unsigned char *opindex_ptr;
1887 struct ppc_fixup fixups[MAX_INSN_FIXUPS];
1892 bfd_reloc_code_real_type reloc;
1895 /* Get the opcode. */
1896 for (s = str; *s != '\0' && ! ISSPACE (*s); s++)
1901 /* Look up the opcode in the hash table. */
1902 opcode = (const struct powerpc_opcode *) hash_find (ppc_hash, str);
1903 if (opcode == (const struct powerpc_opcode *) NULL)
1905 const struct powerpc_macro *macro;
1907 macro = (const struct powerpc_macro *) hash_find (ppc_macro_hash, str);
1908 if (macro == (const struct powerpc_macro *) NULL)
1909 as_bad (_("Unrecognized opcode: `%s'"), str);
1911 ppc_macro (s, macro);
1916 insn = opcode->opcode;
1919 while (ISSPACE (*str))
1922 /* PowerPC operands are just expressions. The only real issue is
1923 that a few operand types are optional. All cases which might use
1924 an optional operand separate the operands only with commas (in
1925 some cases parentheses are used, as in ``lwz 1,0(1)'' but such
1926 cases never have optional operands). There is never more than
1927 one optional operand for an instruction. So, before we start
1928 seriously parsing the operands, we check to see if we have an
1929 optional operand, and, if we do, we count the number of commas to
1930 see whether the operand should be omitted. */
1932 for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++)
1934 const struct powerpc_operand *operand;
1936 operand = &powerpc_operands[*opindex_ptr];
1937 if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0)
1939 unsigned int opcount;
1940 unsigned int num_operands_expected;
1943 /* There is an optional operand. Count the number of
1944 commas in the input line. */
1951 while ((s = strchr (s, ',')) != (char *) NULL)
1958 /* Compute the number of expected operands.
1959 Do not count fake operands. */
1960 for (num_operands_expected = 0, i = 0; opcode->operands[i]; i ++)
1961 if ((powerpc_operands [opcode->operands[i]].flags & PPC_OPERAND_FAKE) == 0)
1962 ++ num_operands_expected;
1964 /* If there are fewer operands in the line then are called
1965 for by the instruction, we want to skip the optional
1967 if (opcount < num_operands_expected)
1974 /* Gather the operands. */
1978 for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++)
1980 const struct powerpc_operand *operand;
1986 if (next_opindex == 0)
1987 operand = &powerpc_operands[*opindex_ptr];
1990 operand = &powerpc_operands[next_opindex];
1996 /* If this is a fake operand, then we do not expect anything
1998 if ((operand->flags & PPC_OPERAND_FAKE) != 0)
2000 insn = (*operand->insert) (insn, 0L, ppc_cpu, &errmsg);
2001 if (errmsg != (const char *) NULL)
2006 /* If this is an optional operand, and we are skipping it, just
2008 if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0
2011 if (operand->insert)
2013 insn = (*operand->insert) (insn, 0L, ppc_cpu, &errmsg);
2014 if (errmsg != (const char *) NULL)
2017 if ((operand->flags & PPC_OPERAND_NEXT) != 0)
2018 next_opindex = *opindex_ptr + 1;
2022 /* Gather the operand. */
2023 hold = input_line_pointer;
2024 input_line_pointer = str;
2027 if (*input_line_pointer == '[')
2029 /* We are expecting something like the second argument here:
2031 * lwz r4,[toc].GS.0.static_int(rtoc)
2032 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2033 * The argument following the `]' must be a symbol name, and the
2034 * register must be the toc register: 'rtoc' or '2'
2036 * The effect is to 0 as the displacement field
2037 * in the instruction, and issue an IMAGE_REL_PPC_TOCREL16 (or
2038 * the appropriate variation) reloc against it based on the symbol.
2039 * The linker will build the toc, and insert the resolved toc offset.
2042 * o The size of the toc entry is currently assumed to be
2043 * 32 bits. This should not be assumed to be a hard coded
2045 * o In an effort to cope with a change from 32 to 64 bits,
2046 * there are also toc entries that are specified to be
2047 * either 32 or 64 bits:
2048 * lwz r4,[toc32].GS.0.static_int(rtoc)
2049 * lwz r4,[toc64].GS.0.static_int(rtoc)
2050 * These demand toc entries of the specified size, and the
2051 * instruction probably requires it.
2055 enum toc_size_qualifier toc_kind;
2056 bfd_reloc_code_real_type toc_reloc;
2058 /* Go parse off the [tocXX] part. */
2059 valid_toc = parse_toc_entry (&toc_kind);
2063 /* Note: message has already been issued.
2064 FIXME: what sort of recovery should we do?
2065 demand_rest_of_line (); return; ? */
2068 /* Now get the symbol following the ']'. */
2074 /* In this case, we may not have seen the symbol yet,
2075 since it is allowed to appear on a .extern or .globl
2076 or just be a label in the .data section. */
2077 toc_reloc = BFD_RELOC_PPC_TOC16;
2080 /* 1. The symbol must be defined and either in the toc
2081 section, or a global.
2082 2. The reloc generated must have the TOCDEFN flag set
2083 in upper bit mess of the reloc type.
2084 FIXME: It's a little confusing what the tocv
2085 qualifier can be used for. At the very least, I've
2086 seen three uses, only one of which I'm sure I can
2088 if (ex.X_op == O_symbol)
2090 assert (ex.X_add_symbol != NULL);
2091 if (symbol_get_bfdsym (ex.X_add_symbol)->section
2094 as_bad (_("[tocv] symbol is not a toc symbol"));
2098 toc_reloc = BFD_RELOC_PPC_TOC16;
2101 /* FIXME: these next two specifically specify 32/64 bit
2102 toc entries. We don't support them today. Is this
2103 the right way to say that? */
2104 toc_reloc = BFD_RELOC_UNUSED;
2105 as_bad (_("Unimplemented toc32 expression modifier"));
2108 /* FIXME: see above. */
2109 toc_reloc = BFD_RELOC_UNUSED;
2110 as_bad (_("Unimplemented toc64 expression modifier"));
2114 _("Unexpected return value [%d] from parse_toc_entry!\n"),
2120 /* We need to generate a fixup for this expression. */
2121 if (fc >= MAX_INSN_FIXUPS)
2122 as_fatal (_("too many fixups"));
2124 fixups[fc].reloc = toc_reloc;
2125 fixups[fc].exp = ex;
2126 fixups[fc].opindex = *opindex_ptr;
2129 /* Ok. We've set up the fixup for the instruction. Now make it
2130 look like the constant 0 was found here. */
2132 ex.X_op = O_constant;
2133 ex.X_add_number = 0;
2134 ex.X_add_symbol = NULL;
2135 ex.X_op_symbol = NULL;
2141 if (! register_name (&ex))
2143 if ((operand->flags & PPC_OPERAND_CR) != 0)
2150 str = input_line_pointer;
2151 input_line_pointer = hold;
2153 if (ex.X_op == O_illegal)
2154 as_bad (_("illegal operand"));
2155 else if (ex.X_op == O_absent)
2156 as_bad (_("missing operand"));
2157 else if (ex.X_op == O_register)
2159 insn = ppc_insert_operand (insn, operand, ex.X_add_number,
2162 else if (ex.X_op == O_constant)
2165 /* Allow @HA, @L, @H on constants. */
2166 char *orig_str = str;
2168 if ((reloc = ppc_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED)
2175 case BFD_RELOC_LO16:
2176 /* X_unsigned is the default, so if the user has done
2177 something which cleared it, we always produce a
2179 if (ex.X_unsigned && ! (operand->flags & PPC_OPERAND_SIGNED))
2180 ex.X_add_number &= 0xffff;
2182 ex.X_add_number = SEX16 (ex.X_add_number);
2185 case BFD_RELOC_HI16:
2186 if (ex.X_unsigned && ! (operand->flags & PPC_OPERAND_SIGNED))
2187 ex.X_add_number = PPC_HI (ex.X_add_number);
2189 ex.X_add_number = SEX16 (PPC_HI (ex.X_add_number));
2192 case BFD_RELOC_HI16_S:
2193 if (ex.X_unsigned && ! (operand->flags & PPC_OPERAND_SIGNED))
2194 ex.X_add_number = PPC_HA (ex.X_add_number);
2196 ex.X_add_number = SEX16 (PPC_HA (ex.X_add_number));
2199 case BFD_RELOC_PPC64_HIGHER:
2200 if (ex.X_unsigned && ! (operand->flags & PPC_OPERAND_SIGNED))
2201 ex.X_add_number = PPC_HIGHER (ex.X_add_number);
2203 ex.X_add_number = SEX16 (PPC_HIGHER (ex.X_add_number));
2206 case BFD_RELOC_PPC64_HIGHER_S:
2207 if (ex.X_unsigned && ! (operand->flags & PPC_OPERAND_SIGNED))
2208 ex.X_add_number = PPC_HIGHERA (ex.X_add_number);
2210 ex.X_add_number = SEX16 (PPC_HIGHERA (ex.X_add_number));
2213 case BFD_RELOC_PPC64_HIGHEST:
2214 if (ex.X_unsigned && ! (operand->flags & PPC_OPERAND_SIGNED))
2215 ex.X_add_number = PPC_HIGHEST (ex.X_add_number);
2217 ex.X_add_number = SEX16 (PPC_HIGHEST (ex.X_add_number));
2220 case BFD_RELOC_PPC64_HIGHEST_S:
2221 if (ex.X_unsigned && ! (operand->flags & PPC_OPERAND_SIGNED))
2222 ex.X_add_number = PPC_HIGHESTA (ex.X_add_number);
2224 ex.X_add_number = SEX16 (PPC_HIGHESTA (ex.X_add_number));
2227 #endif /* OBJ_ELF */
2228 insn = ppc_insert_operand (insn, operand, ex.X_add_number,
2232 else if ((reloc = ppc_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED)
2234 /* For the absolute forms of branches, convert the PC
2235 relative form back into the absolute. */
2236 if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0)
2240 case BFD_RELOC_PPC_B26:
2241 reloc = BFD_RELOC_PPC_BA26;
2243 case BFD_RELOC_PPC_B16:
2244 reloc = BFD_RELOC_PPC_BA16;
2246 case BFD_RELOC_PPC_B16_BRTAKEN:
2247 reloc = BFD_RELOC_PPC_BA16_BRTAKEN;
2249 case BFD_RELOC_PPC_B16_BRNTAKEN:
2250 reloc = BFD_RELOC_PPC_BA16_BRNTAKEN;
2258 && (operand->flags & PPC_OPERAND_DS) != 0)
2263 reloc = BFD_RELOC_PPC64_ADDR16_DS;
2265 case BFD_RELOC_LO16:
2266 reloc = BFD_RELOC_PPC64_ADDR16_LO_DS;
2268 case BFD_RELOC_16_GOTOFF:
2269 reloc = BFD_RELOC_PPC64_GOT16_DS;
2271 case BFD_RELOC_LO16_GOTOFF:
2272 reloc = BFD_RELOC_PPC64_GOT16_LO_DS;
2274 case BFD_RELOC_LO16_PLTOFF:
2275 reloc = BFD_RELOC_PPC64_PLT16_LO_DS;
2277 case BFD_RELOC_16_BASEREL:
2278 reloc = BFD_RELOC_PPC64_SECTOFF_DS;
2280 case BFD_RELOC_LO16_BASEREL:
2281 reloc = BFD_RELOC_PPC64_SECTOFF_LO_DS;
2283 case BFD_RELOC_PPC_TOC16:
2284 reloc = BFD_RELOC_PPC64_TOC16_DS;
2286 case BFD_RELOC_PPC64_TOC16_LO:
2287 reloc = BFD_RELOC_PPC64_TOC16_LO_DS;
2289 case BFD_RELOC_PPC64_PLTGOT16:
2290 reloc = BFD_RELOC_PPC64_PLTGOT16_DS;
2292 case BFD_RELOC_PPC64_PLTGOT16_LO:
2293 reloc = BFD_RELOC_PPC64_PLTGOT16_LO_DS;
2296 as_bad (_("unsupported relocation for DS offset field"));
2301 /* We need to generate a fixup for this expression. */
2302 if (fc >= MAX_INSN_FIXUPS)
2303 as_fatal (_("too many fixups"));
2304 fixups[fc].exp = ex;
2305 fixups[fc].opindex = 0;
2306 fixups[fc].reloc = reloc;
2309 #endif /* OBJ_ELF */
2313 /* We need to generate a fixup for this expression. */
2314 if (fc >= MAX_INSN_FIXUPS)
2315 as_fatal (_("too many fixups"));
2316 fixups[fc].exp = ex;
2317 fixups[fc].opindex = *opindex_ptr;
2318 fixups[fc].reloc = BFD_RELOC_UNUSED;
2327 else if ((operand->flags & PPC_OPERAND_PARENS) != 0)
2335 /* The call to expression should have advanced str past any
2338 && (endc != ',' || *str != '\0'))
2340 as_bad (_("syntax error; found `%c' but expected `%c'"), *str, endc);
2348 while (ISSPACE (*str))
2352 as_bad (_("junk at end of line: `%s'"), str);
2354 /* Write out the instruction. */
2356 md_number_to_chars (f, insn, 4);
2359 dwarf2_emit_insn (4);
2362 /* Create any fixups. At this point we do not use a
2363 bfd_reloc_code_real_type, but instead just use the
2364 BFD_RELOC_UNUSED plus the operand index. This lets us easily
2365 handle fixups for any operand type, although that is admittedly
2366 not a very exciting feature. We pick a BFD reloc type in
2368 for (i = 0; i < fc; i++)
2370 const struct powerpc_operand *operand;
2372 operand = &powerpc_operands[fixups[i].opindex];
2373 if (fixups[i].reloc != BFD_RELOC_UNUSED)
2375 reloc_howto_type *reloc_howto;
2380 reloc_howto = bfd_reloc_type_lookup (stdoutput, fixups[i].reloc);
2384 size = bfd_get_reloc_size (reloc_howto);
2385 offset = target_big_endian ? (4 - size) : 0;
2387 if (size < 1 || size > 4)
2390 fixP = fix_new_exp (frag_now,
2391 f - frag_now->fr_literal + offset,
2394 reloc_howto->pc_relative,
2397 /* Turn off complaints that the addend is too large for things like
2399 switch (fixups[i].reloc)
2401 case BFD_RELOC_16_GOTOFF:
2402 case BFD_RELOC_PPC_TOC16:
2403 case BFD_RELOC_LO16:
2404 case BFD_RELOC_HI16:
2405 case BFD_RELOC_HI16_S:
2407 case BFD_RELOC_PPC64_HIGHER:
2408 case BFD_RELOC_PPC64_HIGHER_S:
2409 case BFD_RELOC_PPC64_HIGHEST:
2410 case BFD_RELOC_PPC64_HIGHEST_S:
2412 fixP->fx_no_overflow = 1;
2419 fix_new_exp (frag_now,
2420 f - frag_now->fr_literal,
2423 (operand->flags & PPC_OPERAND_RELATIVE) != 0,
2424 ((bfd_reloc_code_real_type)
2425 (fixups[i].opindex + (int) BFD_RELOC_UNUSED)));
2429 /* Handle a macro. Gather all the operands, transform them as
2430 described by the macro, and call md_assemble recursively. All the
2431 operands are separated by commas; we don't accept parentheses
2432 around operands here. */
2435 ppc_macro (str, macro)
2437 const struct powerpc_macro *macro;
2448 /* Gather the users operands into the operands array. */
2453 if (count >= sizeof operands / sizeof operands[0])
2455 operands[count++] = s;
2456 s = strchr (s, ',');
2457 if (s == (char *) NULL)
2462 if (count != macro->operands)
2464 as_bad (_("wrong number of operands"));
2468 /* Work out how large the string must be (the size is unbounded
2469 because it includes user input). */
2471 format = macro->format;
2472 while (*format != '\0')
2481 arg = strtol (format + 1, &send, 10);
2482 know (send != format && arg >= 0 && arg < count);
2483 len += strlen (operands[arg]);
2488 /* Put the string together. */
2489 complete = s = (char *) alloca (len + 1);
2490 format = macro->format;
2491 while (*format != '\0')
2497 arg = strtol (format + 1, &send, 10);
2498 strcpy (s, operands[arg]);
2505 /* Assemble the constructed instruction. */
2506 md_assemble (complete);
2510 /* For ELF, add support for SHF_EXCLUDE and SHT_ORDERED. */
2513 ppc_section_letter (letter, ptr_msg)
2520 *ptr_msg = _("Bad .section directive: want a,e,w,x,M,S,G,T in string");
2525 ppc_section_word (str, len)
2529 if (len == 7 && strncmp (str, "exclude", 7) == 0)
2536 ppc_section_type (str, len)
2540 if (len == 7 && strncmp (str, "ordered", 7) == 0)
2547 ppc_section_flags (flags, attr, type)
2552 if (type == SHT_ORDERED)
2553 flags |= SEC_ALLOC | SEC_LOAD | SEC_SORT_ENTRIES;
2555 if (attr & SHF_EXCLUDE)
2556 flags |= SEC_EXCLUDE;
2560 #endif /* OBJ_ELF */
2563 /* Pseudo-op handling. */
2565 /* The .byte pseudo-op. This is similar to the normal .byte
2566 pseudo-op, but it can also take a single ASCII string. */
2570 int ignore ATTRIBUTE_UNUSED;
2572 if (*input_line_pointer != '\"')
2578 /* Gather characters. A real double quote is doubled. Unusual
2579 characters are not permitted. */
2580 ++input_line_pointer;
2585 c = *input_line_pointer++;
2589 if (*input_line_pointer != '\"')
2591 ++input_line_pointer;
2594 FRAG_APPEND_1_CHAR (c);
2597 demand_empty_rest_of_line ();
2602 /* XCOFF specific pseudo-op handling. */
2604 /* This is set if we are creating a .stabx symbol, since we don't want
2605 to handle symbol suffixes for such symbols. */
2606 static boolean ppc_stab_symbol;
2608 /* The .comm and .lcomm pseudo-ops for XCOFF. XCOFF puts common
2609 symbols in the .bss segment as though they were local common
2610 symbols, and uses a different smclas. The native Aix 4.3.3 assember
2611 aligns .comm and .lcomm to 4 bytes. */
2617 asection *current_seg = now_seg;
2618 subsegT current_subseg = now_subseg;
2624 symbolS *lcomm_sym = NULL;
2628 name = input_line_pointer;
2629 endc = get_symbol_end ();
2630 end_name = input_line_pointer;
2633 if (*input_line_pointer != ',')
2635 as_bad (_("missing size"));
2636 ignore_rest_of_line ();
2639 ++input_line_pointer;
2641 size = get_absolute_expression ();
2644 as_bad (_("negative size"));
2645 ignore_rest_of_line ();
2651 /* The third argument to .comm is the alignment. */
2652 if (*input_line_pointer != ',')
2656 ++input_line_pointer;
2657 align = get_absolute_expression ();
2660 as_warn (_("ignoring bad alignment"));
2675 /* The third argument to .lcomm appears to be the real local
2676 common symbol to create. References to the symbol named in
2677 the first argument are turned into references to the third
2679 if (*input_line_pointer != ',')
2681 as_bad (_("missing real symbol name"));
2682 ignore_rest_of_line ();
2685 ++input_line_pointer;
2687 lcomm_name = input_line_pointer;
2688 lcomm_endc = get_symbol_end ();
2690 lcomm_sym = symbol_find_or_make (lcomm_name);
2692 *input_line_pointer = lcomm_endc;
2696 sym = symbol_find_or_make (name);
2699 if (S_IS_DEFINED (sym)
2700 || S_GET_VALUE (sym) != 0)
2702 as_bad (_("attempt to redefine symbol"));
2703 ignore_rest_of_line ();
2707 record_alignment (bss_section, align);
2710 || ! S_IS_DEFINED (lcomm_sym))
2719 S_SET_EXTERNAL (sym);
2723 symbol_get_tc (lcomm_sym)->output = 1;
2724 def_sym = lcomm_sym;
2728 subseg_set (bss_section, 1);
2729 frag_align (align, 0, 0);
2731 symbol_set_frag (def_sym, frag_now);
2732 pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, def_sym,
2733 def_size, (char *) NULL);
2735 S_SET_SEGMENT (def_sym, bss_section);
2736 symbol_get_tc (def_sym)->align = align;
2740 /* Align the size of lcomm_sym. */
2741 symbol_get_frag (lcomm_sym)->fr_offset =
2742 ((symbol_get_frag (lcomm_sym)->fr_offset + (1 << align) - 1)
2743 &~ ((1 << align) - 1));
2744 if (align > symbol_get_tc (lcomm_sym)->align)
2745 symbol_get_tc (lcomm_sym)->align = align;
2750 /* Make sym an offset from lcomm_sym. */
2751 S_SET_SEGMENT (sym, bss_section);
2752 symbol_set_frag (sym, symbol_get_frag (lcomm_sym));
2753 S_SET_VALUE (sym, symbol_get_frag (lcomm_sym)->fr_offset);
2754 symbol_get_frag (lcomm_sym)->fr_offset += size;
2757 subseg_set (current_seg, current_subseg);
2759 demand_empty_rest_of_line ();
2762 /* The .csect pseudo-op. This switches us into a different
2763 subsegment. The first argument is a symbol whose value is the
2764 start of the .csect. In COFF, csect symbols get special aux
2765 entries defined by the x_csect field of union internal_auxent. The
2766 optional second argument is the alignment (the default is 2). */
2770 int ignore ATTRIBUTE_UNUSED;
2776 name = input_line_pointer;
2777 endc = get_symbol_end ();
2779 sym = symbol_find_or_make (name);
2781 *input_line_pointer = endc;
2783 if (S_GET_NAME (sym)[0] == '\0')
2785 /* An unnamed csect is assumed to be [PR]. */
2786 symbol_get_tc (sym)->class = XMC_PR;
2789 ppc_change_csect (sym);
2791 if (*input_line_pointer == ',')
2793 ++input_line_pointer;
2794 symbol_get_tc (sym)->align = get_absolute_expression ();
2797 demand_empty_rest_of_line ();
2800 /* Change to a different csect. */
2803 ppc_change_csect (sym)
2806 if (S_IS_DEFINED (sym))
2807 subseg_set (S_GET_SEGMENT (sym), symbol_get_tc (sym)->subseg);
2815 /* This is a new csect. We need to look at the symbol class to
2816 figure out whether it should go in the text section or the
2819 switch (symbol_get_tc (sym)->class)
2829 S_SET_SEGMENT (sym, text_section);
2830 symbol_get_tc (sym)->subseg = ppc_text_subsegment;
2831 ++ppc_text_subsegment;
2832 list_ptr = &ppc_text_csects;
2841 if (ppc_toc_csect != NULL
2842 && (symbol_get_tc (ppc_toc_csect)->subseg + 1
2843 == ppc_data_subsegment))
2845 S_SET_SEGMENT (sym, data_section);
2846 symbol_get_tc (sym)->subseg = ppc_data_subsegment;
2847 ++ppc_data_subsegment;
2848 list_ptr = &ppc_data_csects;
2854 /* We set the obstack chunk size to a small value before
2855 changing subsegments, so that we don't use a lot of memory
2856 space for what may be a small section. */
2857 hold_chunksize = chunksize;
2860 subseg_new (segment_name (S_GET_SEGMENT (sym)),
2861 symbol_get_tc (sym)->subseg);
2863 chunksize = hold_chunksize;
2866 ppc_after_toc_frag = frag_now;
2868 symbol_set_frag (sym, frag_now);
2869 S_SET_VALUE (sym, (valueT) frag_now_fix ());
2871 symbol_get_tc (sym)->align = 2;
2872 symbol_get_tc (sym)->output = 1;
2873 symbol_get_tc (sym)->within = sym;
2875 for (list = *list_ptr;
2876 symbol_get_tc (list)->next != (symbolS *) NULL;
2877 list = symbol_get_tc (list)->next)
2879 symbol_get_tc (list)->next = sym;
2881 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
2882 symbol_append (sym, symbol_get_tc (list)->within, &symbol_rootP,
2886 ppc_current_csect = sym;
2889 /* This function handles the .text and .data pseudo-ops. These
2890 pseudo-ops aren't really used by XCOFF; we implement them for the
2891 convenience of people who aren't used to XCOFF. */
2902 else if (type == 'd')
2907 sym = symbol_find_or_make (name);
2909 ppc_change_csect (sym);
2911 demand_empty_rest_of_line ();
2914 /* This function handles the .section pseudo-op. This is mostly to
2915 give an error, since XCOFF only supports .text, .data and .bss, but
2916 we do permit the user to name the text or data section. */
2919 ppc_named_section (ignore)
2920 int ignore ATTRIBUTE_UNUSED;
2923 const char *real_name;
2927 user_name = input_line_pointer;
2928 c = get_symbol_end ();
2930 if (strcmp (user_name, ".text") == 0)
2931 real_name = ".text[PR]";
2932 else if (strcmp (user_name, ".data") == 0)
2933 real_name = ".data[RW]";
2936 as_bad (_("The XCOFF file format does not support arbitrary sections"));
2937 *input_line_pointer = c;
2938 ignore_rest_of_line ();
2942 *input_line_pointer = c;
2944 sym = symbol_find_or_make (real_name);
2946 ppc_change_csect (sym);
2948 demand_empty_rest_of_line ();
2951 /* The .extern pseudo-op. We create an undefined symbol. */
2955 int ignore ATTRIBUTE_UNUSED;
2960 name = input_line_pointer;
2961 endc = get_symbol_end ();
2963 (void) symbol_find_or_make (name);
2965 *input_line_pointer = endc;
2967 demand_empty_rest_of_line ();
2970 /* The .lglobl pseudo-op. Keep the symbol in the symbol table. */
2974 int ignore ATTRIBUTE_UNUSED;
2980 name = input_line_pointer;
2981 endc = get_symbol_end ();
2983 sym = symbol_find_or_make (name);
2985 *input_line_pointer = endc;
2987 symbol_get_tc (sym)->output = 1;
2989 demand_empty_rest_of_line ();
2992 /* The .rename pseudo-op. The RS/6000 assembler can rename symbols,
2993 although I don't know why it bothers. */
2997 int ignore ATTRIBUTE_UNUSED;
3004 name = input_line_pointer;
3005 endc = get_symbol_end ();
3007 sym = symbol_find_or_make (name);
3009 *input_line_pointer = endc;
3011 if (*input_line_pointer != ',')
3013 as_bad (_("missing rename string"));
3014 ignore_rest_of_line ();
3017 ++input_line_pointer;
3019 symbol_get_tc (sym)->real_name = demand_copy_C_string (&len);
3021 demand_empty_rest_of_line ();
3024 /* The .stabx pseudo-op. This is similar to a normal .stabs
3025 pseudo-op, but slightly different. A sample is
3026 .stabx "main:F-1",.main,142,0
3027 The first argument is the symbol name to create. The second is the
3028 value, and the third is the storage class. The fourth seems to be
3029 always zero, and I am assuming it is the type. */
3033 int ignore ATTRIBUTE_UNUSED;
3040 name = demand_copy_C_string (&len);
3042 if (*input_line_pointer != ',')
3044 as_bad (_("missing value"));
3047 ++input_line_pointer;
3049 ppc_stab_symbol = true;
3050 sym = symbol_make (name);
3051 ppc_stab_symbol = false;
3053 symbol_get_tc (sym)->real_name = name;
3055 (void) expression (&exp);
3062 as_bad (_("illegal .stabx expression; zero assumed"));
3063 exp.X_add_number = 0;
3066 S_SET_VALUE (sym, (valueT) exp.X_add_number);
3067 symbol_set_frag (sym, &zero_address_frag);
3071 if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section)
3072 symbol_set_value_expression (sym, &exp);
3076 exp.X_add_number + S_GET_VALUE (exp.X_add_symbol));
3077 symbol_set_frag (sym, symbol_get_frag (exp.X_add_symbol));
3082 /* The value is some complex expression. This will probably
3083 fail at some later point, but this is probably the right
3084 thing to do here. */
3085 symbol_set_value_expression (sym, &exp);
3089 S_SET_SEGMENT (sym, ppc_coff_debug_section);
3090 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
3092 if (*input_line_pointer != ',')
3094 as_bad (_("missing class"));
3097 ++input_line_pointer;
3099 S_SET_STORAGE_CLASS (sym, get_absolute_expression ());
3101 if (*input_line_pointer != ',')
3103 as_bad (_("missing type"));
3106 ++input_line_pointer;
3108 S_SET_DATA_TYPE (sym, get_absolute_expression ());
3110 symbol_get_tc (sym)->output = 1;
3112 if (S_GET_STORAGE_CLASS (sym) == C_STSYM) {
3114 symbol_get_tc (sym)->within = ppc_current_block;
3119 .stabx "z",arrays_,133,0
3122 .comm arrays_,13768,3
3124 resolve_symbol_value will copy the exp's "within" into sym's when the
3125 offset is 0. Since this seems to be corner case problem,
3126 only do the correction for storage class C_STSYM. A better solution
3127 would be to have the tc field updated in ppc_symbol_new_hook. */
3129 if (exp.X_op == O_symbol)
3131 symbol_get_tc (exp.X_add_symbol)->within = ppc_current_block;
3135 if (exp.X_op != O_symbol
3136 || ! S_IS_EXTERNAL (exp.X_add_symbol)
3137 || S_GET_SEGMENT (exp.X_add_symbol) != bss_section)
3138 ppc_frob_label (sym);
3141 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
3142 symbol_append (sym, exp.X_add_symbol, &symbol_rootP, &symbol_lastP);
3143 if (symbol_get_tc (ppc_current_csect)->within == exp.X_add_symbol)
3144 symbol_get_tc (ppc_current_csect)->within = sym;
3147 demand_empty_rest_of_line ();
3150 /* The .function pseudo-op. This takes several arguments. The first
3151 argument seems to be the external name of the symbol. The second
3152 argment seems to be the label for the start of the function. gcc
3153 uses the same name for both. I have no idea what the third and
3154 fourth arguments are meant to be. The optional fifth argument is
3155 an expression for the size of the function. In COFF this symbol
3156 gets an aux entry like that used for a csect. */
3159 ppc_function (ignore)
3160 int ignore ATTRIBUTE_UNUSED;
3168 name = input_line_pointer;
3169 endc = get_symbol_end ();
3171 /* Ignore any [PR] suffix. */
3172 name = ppc_canonicalize_symbol_name (name);
3173 s = strchr (name, '[');
3174 if (s != (char *) NULL
3175 && strcmp (s + 1, "PR]") == 0)
3178 ext_sym = symbol_find_or_make (name);
3180 *input_line_pointer = endc;
3182 if (*input_line_pointer != ',')
3184 as_bad (_("missing symbol name"));
3185 ignore_rest_of_line ();
3188 ++input_line_pointer;
3190 name = input_line_pointer;
3191 endc = get_symbol_end ();
3193 lab_sym = symbol_find_or_make (name);
3195 *input_line_pointer = endc;
3197 if (ext_sym != lab_sym)
3201 exp.X_op = O_symbol;
3202 exp.X_add_symbol = lab_sym;
3203 exp.X_op_symbol = NULL;
3204 exp.X_add_number = 0;
3206 symbol_set_value_expression (ext_sym, &exp);
3209 if (symbol_get_tc (ext_sym)->class == -1)
3210 symbol_get_tc (ext_sym)->class = XMC_PR;
3211 symbol_get_tc (ext_sym)->output = 1;
3213 if (*input_line_pointer == ',')
3217 /* Ignore the third argument. */
3218 ++input_line_pointer;
3219 expression (&ignore);
3220 if (*input_line_pointer == ',')
3222 /* Ignore the fourth argument. */
3223 ++input_line_pointer;
3224 expression (&ignore);
3225 if (*input_line_pointer == ',')
3227 /* The fifth argument is the function size. */
3228 ++input_line_pointer;
3229 symbol_get_tc (ext_sym)->size = symbol_new ("L0\001",
3232 &zero_address_frag);
3233 pseudo_set (symbol_get_tc (ext_sym)->size);
3238 S_SET_DATA_TYPE (ext_sym, DT_FCN << N_BTSHFT);
3239 SF_SET_FUNCTION (ext_sym);
3240 SF_SET_PROCESS (ext_sym);
3241 coff_add_linesym (ext_sym);
3243 demand_empty_rest_of_line ();
3246 /* The .bf pseudo-op. This is just like a COFF C_FCN symbol named
3247 ".bf". If the pseudo op .bi was seen before .bf, patch the .bi sym
3248 with the correct line number */
3250 static symbolS *saved_bi_sym = 0;
3254 int ignore ATTRIBUTE_UNUSED;
3258 sym = symbol_make (".bf");
3259 S_SET_SEGMENT (sym, text_section);
3260 symbol_set_frag (sym, frag_now);
3261 S_SET_VALUE (sym, frag_now_fix ());
3262 S_SET_STORAGE_CLASS (sym, C_FCN);
3264 coff_line_base = get_absolute_expression ();
3266 S_SET_NUMBER_AUXILIARY (sym, 1);
3267 SA_SET_SYM_LNNO (sym, coff_line_base);
3269 /* Line number for bi. */
3272 S_SET_VALUE (saved_bi_sym, coff_n_line_nos);
3277 symbol_get_tc (sym)->output = 1;
3279 ppc_frob_label (sym);
3281 demand_empty_rest_of_line ();
3284 /* The .ef pseudo-op. This is just like a COFF C_FCN symbol named
3285 ".ef", except that the line number is absolute, not relative to the
3286 most recent ".bf" symbol. */
3290 int ignore ATTRIBUTE_UNUSED;
3294 sym = symbol_make (".ef");
3295 S_SET_SEGMENT (sym, text_section);
3296 symbol_set_frag (sym, frag_now);
3297 S_SET_VALUE (sym, frag_now_fix ());
3298 S_SET_STORAGE_CLASS (sym, C_FCN);
3299 S_SET_NUMBER_AUXILIARY (sym, 1);
3300 SA_SET_SYM_LNNO (sym, get_absolute_expression ());
3301 symbol_get_tc (sym)->output = 1;
3303 ppc_frob_label (sym);
3305 demand_empty_rest_of_line ();
3308 /* The .bi and .ei pseudo-ops. These take a string argument and
3309 generates a C_BINCL or C_EINCL symbol, which goes at the start of
3310 the symbol list. The value of .bi will be know when the next .bf
3317 static symbolS *last_biei;
3324 name = demand_copy_C_string (&len);
3326 /* The value of these symbols is actually file offset. Here we set
3327 the value to the index into the line number entries. In
3328 ppc_frob_symbols we set the fix_line field, which will cause BFD
3329 to do the right thing. */
3331 sym = symbol_make (name);
3332 /* obj-coff.c currently only handles line numbers correctly in the
3334 S_SET_SEGMENT (sym, text_section);
3335 S_SET_VALUE (sym, coff_n_line_nos);
3336 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
3338 S_SET_STORAGE_CLASS (sym, ei ? C_EINCL : C_BINCL);
3339 symbol_get_tc (sym)->output = 1;
3347 for (look = last_biei ? last_biei : symbol_rootP;
3348 (look != (symbolS *) NULL
3349 && (S_GET_STORAGE_CLASS (look) == C_FILE
3350 || S_GET_STORAGE_CLASS (look) == C_BINCL
3351 || S_GET_STORAGE_CLASS (look) == C_EINCL));
3352 look = symbol_next (look))
3354 if (look != (symbolS *) NULL)
3356 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
3357 symbol_insert (sym, look, &symbol_rootP, &symbol_lastP);
3361 demand_empty_rest_of_line ();
3364 /* The .bs pseudo-op. This generates a C_BSTAT symbol named ".bs".
3365 There is one argument, which is a csect symbol. The value of the
3366 .bs symbol is the index of this csect symbol. */
3370 int ignore ATTRIBUTE_UNUSED;
3377 if (ppc_current_block != NULL)
3378 as_bad (_("nested .bs blocks"));
3380 name = input_line_pointer;
3381 endc = get_symbol_end ();
3383 csect = symbol_find_or_make (name);
3385 *input_line_pointer = endc;
3387 sym = symbol_make (".bs");
3388 S_SET_SEGMENT (sym, now_seg);
3389 S_SET_STORAGE_CLASS (sym, C_BSTAT);
3390 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
3391 symbol_get_tc (sym)->output = 1;
3393 symbol_get_tc (sym)->within = csect;
3395 ppc_frob_label (sym);
3397 ppc_current_block = sym;
3399 demand_empty_rest_of_line ();
3402 /* The .es pseudo-op. Generate a C_ESTART symbol named .es. */
3406 int ignore ATTRIBUTE_UNUSED;
3410 if (ppc_current_block == NULL)
3411 as_bad (_(".es without preceding .bs"));
3413 sym = symbol_make (".es");
3414 S_SET_SEGMENT (sym, now_seg);
3415 S_SET_STORAGE_CLASS (sym, C_ESTAT);
3416 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
3417 symbol_get_tc (sym)->output = 1;
3419 ppc_frob_label (sym);
3421 ppc_current_block = NULL;
3423 demand_empty_rest_of_line ();
3426 /* The .bb pseudo-op. Generate a C_BLOCK symbol named .bb, with a
3431 int ignore ATTRIBUTE_UNUSED;
3435 sym = symbol_make (".bb");
3436 S_SET_SEGMENT (sym, text_section);
3437 symbol_set_frag (sym, frag_now);
3438 S_SET_VALUE (sym, frag_now_fix ());
3439 S_SET_STORAGE_CLASS (sym, C_BLOCK);
3441 S_SET_NUMBER_AUXILIARY (sym, 1);
3442 SA_SET_SYM_LNNO (sym, get_absolute_expression ());
3444 symbol_get_tc (sym)->output = 1;
3446 SF_SET_PROCESS (sym);
3448 ppc_frob_label (sym);
3450 demand_empty_rest_of_line ();
3453 /* The .eb pseudo-op. Generate a C_BLOCK symbol named .eb, with a
3458 int ignore ATTRIBUTE_UNUSED;
3462 sym = symbol_make (".eb");
3463 S_SET_SEGMENT (sym, text_section);
3464 symbol_set_frag (sym, frag_now);
3465 S_SET_VALUE (sym, frag_now_fix ());
3466 S_SET_STORAGE_CLASS (sym, C_BLOCK);
3467 S_SET_NUMBER_AUXILIARY (sym, 1);
3468 SA_SET_SYM_LNNO (sym, get_absolute_expression ());
3469 symbol_get_tc (sym)->output = 1;
3471 SF_SET_PROCESS (sym);
3473 ppc_frob_label (sym);
3475 demand_empty_rest_of_line ();
3478 /* The .bc pseudo-op. This just creates a C_BCOMM symbol with a
3483 int ignore ATTRIBUTE_UNUSED;
3489 name = demand_copy_C_string (&len);
3490 sym = symbol_make (name);
3491 S_SET_SEGMENT (sym, ppc_coff_debug_section);
3492 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
3493 S_SET_STORAGE_CLASS (sym, C_BCOMM);
3494 S_SET_VALUE (sym, 0);
3495 symbol_get_tc (sym)->output = 1;
3497 ppc_frob_label (sym);
3499 demand_empty_rest_of_line ();
3502 /* The .ec pseudo-op. This just creates a C_ECOMM symbol. */
3506 int ignore ATTRIBUTE_UNUSED;
3510 sym = symbol_make (".ec");
3511 S_SET_SEGMENT (sym, ppc_coff_debug_section);
3512 symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
3513 S_SET_STORAGE_CLASS (sym, C_ECOMM);
3514 S_SET_VALUE (sym, 0);
3515 symbol_get_tc (sym)->output = 1;
3517 ppc_frob_label (sym);
3519 demand_empty_rest_of_line ();
3522 /* The .toc pseudo-op. Switch to the .toc subsegment. */
3526 int ignore ATTRIBUTE_UNUSED;
3528 if (ppc_toc_csect != (symbolS *) NULL)
3529 subseg_set (data_section, symbol_get_tc (ppc_toc_csect)->subseg);
3536 subseg = ppc_data_subsegment;
3537 ++ppc_data_subsegment;
3539 subseg_new (segment_name (data_section), subseg);
3540 ppc_toc_frag = frag_now;
3542 sym = symbol_find_or_make ("TOC[TC0]");
3543 symbol_set_frag (sym, frag_now);
3544 S_SET_SEGMENT (sym, data_section);
3545 S_SET_VALUE (sym, (valueT) frag_now_fix ());
3546 symbol_get_tc (sym)->subseg = subseg;
3547 symbol_get_tc (sym)->output = 1;
3548 symbol_get_tc (sym)->within = sym;
3550 ppc_toc_csect = sym;
3552 for (list = ppc_data_csects;
3553 symbol_get_tc (list)->next != (symbolS *) NULL;
3554 list = symbol_get_tc (list)->next)
3556 symbol_get_tc (list)->next = sym;
3558 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
3559 symbol_append (sym, symbol_get_tc (list)->within, &symbol_rootP,
3563 ppc_current_csect = ppc_toc_csect;
3565 demand_empty_rest_of_line ();
3568 /* The AIX assembler automatically aligns the operands of a .long or
3569 .short pseudo-op, and we want to be compatible. */
3572 ppc_xcoff_cons (log_size)
3575 frag_align (log_size, 0, 0);
3576 record_alignment (now_seg, log_size);
3577 cons (1 << log_size);
3582 int dummy ATTRIBUTE_UNUSED;
3587 (void) expression (&exp);
3589 if (exp.X_op != O_constant)
3591 as_bad (_("non-constant byte count"));
3595 byte_count = exp.X_add_number;
3597 if (*input_line_pointer != ',')
3599 as_bad (_("missing value"));
3603 ++input_line_pointer;
3607 #endif /* OBJ_XCOFF */
3608 #if defined (OBJ_XCOFF) || defined (OBJ_ELF)
3610 /* The .tc pseudo-op. This is used when generating either XCOFF or
3611 ELF. This takes two or more arguments.
3613 When generating XCOFF output, the first argument is the name to
3614 give to this location in the toc; this will be a symbol with class
3615 TC. The rest of the arguments are N-byte values to actually put at
3616 this location in the TOC; often there is just one more argument, a
3617 relocateable symbol reference. The size of the value to store
3618 depends on target word size. A 32-bit target uses 4-byte values, a
3619 64-bit target uses 8-byte values.
3621 When not generating XCOFF output, the arguments are the same, but
3622 the first argument is simply ignored. */
3626 int ignore ATTRIBUTE_UNUSED;
3630 /* Define the TOC symbol name. */
3636 if (ppc_toc_csect == (symbolS *) NULL
3637 || ppc_toc_csect != ppc_current_csect)
3639 as_bad (_(".tc not in .toc section"));
3640 ignore_rest_of_line ();
3644 name = input_line_pointer;
3645 endc = get_symbol_end ();
3647 sym = symbol_find_or_make (name);
3649 *input_line_pointer = endc;
3651 if (S_IS_DEFINED (sym))
3655 label = symbol_get_tc (ppc_current_csect)->within;
3656 if (symbol_get_tc (label)->class != XMC_TC0)
3658 as_bad (_(".tc with no label"));
3659 ignore_rest_of_line ();
3663 S_SET_SEGMENT (label, S_GET_SEGMENT (sym));
3664 symbol_set_frag (label, symbol_get_frag (sym));
3665 S_SET_VALUE (label, S_GET_VALUE (sym));
3667 while (! is_end_of_line[(unsigned char) *input_line_pointer])
3668 ++input_line_pointer;
3673 S_SET_SEGMENT (sym, now_seg);
3674 symbol_set_frag (sym, frag_now);
3675 S_SET_VALUE (sym, (valueT) frag_now_fix ());
3676 symbol_get_tc (sym)->class = XMC_TC;
3677 symbol_get_tc (sym)->output = 1;
3679 ppc_frob_label (sym);
3682 #endif /* OBJ_XCOFF */
3686 /* Skip the TOC symbol name. */
3687 while (is_part_of_name (*input_line_pointer)
3688 || *input_line_pointer == '['
3689 || *input_line_pointer == ']'
3690 || *input_line_pointer == '{'
3691 || *input_line_pointer == '}')
3692 ++input_line_pointer;
3694 /* Align to a four/eight byte boundary. */
3695 align = ppc_obj64 ? 3 : 2;
3696 frag_align (align, 0, 0);
3697 record_alignment (now_seg, align);
3698 #endif /* OBJ_ELF */
3700 if (*input_line_pointer != ',')
3701 demand_empty_rest_of_line ();
3704 ++input_line_pointer;
3705 cons (ppc_obj64 ? 8 : 4);
3709 /* Pseudo-op .machine. */
3710 /* FIXME: `.machine' is a nop for the moment. It would be nice to
3711 accept this directive on the first line of input and set ppc_obj64
3712 and the target format accordingly. Unfortunately, the target
3713 format is selected in output-file.c:output_file_create before we
3714 even get to md_begin, so it's not possible without changing
3718 ppc_machine (ignore)
3719 int ignore ATTRIBUTE_UNUSED;
3721 discard_rest_of_line ();
3724 /* See whether a symbol is in the TOC section. */
3727 ppc_is_toc_sym (sym)
3731 return symbol_get_tc (sym)->class == XMC_TC;
3734 const char *sname = segment_name (S_GET_SEGMENT (sym));
3736 return strcmp (sname, ".toc") == 0;
3738 return strcmp (sname, ".got") == 0;
3741 #endif /* defined (OBJ_XCOFF) || defined (OBJ_ELF) */
3745 /* Pseudo-ops specific to the Windows NT PowerPC PE (coff) format. */
3747 /* Set the current section. */
3749 ppc_set_current_section (new)
3752 ppc_previous_section = ppc_current_section;
3753 ppc_current_section = new;
3756 /* pseudo-op: .previous
3757 behaviour: toggles the current section with the previous section.
3759 warnings: "No previous section" */
3762 ppc_previous (ignore)
3763 int ignore ATTRIBUTE_UNUSED;
3767 if (ppc_previous_section == NULL)
3769 as_warn (_("No previous section to return to. Directive ignored."));
3773 subseg_set (ppc_previous_section, 0);
3775 ppc_set_current_section (ppc_previous_section);
3778 /* pseudo-op: .pdata
3779 behaviour: predefined read only data section
3783 initial: .section .pdata "adr3"
3784 a - don't know -- maybe a misprint
3785 d - initialized data
3787 3 - double word aligned (that would be 4 byte boundary)
3790 Tag index tables (also known as the function table) for exception
3791 handling, debugging, etc. */
3795 int ignore ATTRIBUTE_UNUSED;
3797 if (pdata_section == 0)
3799 pdata_section = subseg_new (".pdata", 0);
3801 bfd_set_section_flags (stdoutput, pdata_section,
3802 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
3803 | SEC_READONLY | SEC_DATA ));
3805 bfd_set_section_alignment (stdoutput, pdata_section, 2);
3809 pdata_section = subseg_new (".pdata", 0);
3811 ppc_set_current_section (pdata_section);
3814 /* pseudo-op: .ydata
3815 behaviour: predefined read only data section
3819 initial: .section .ydata "drw3"
3820 a - don't know -- maybe a misprint
3821 d - initialized data
3823 3 - double word aligned (that would be 4 byte boundary)
3825 Tag tables (also known as the scope table) for exception handling,
3830 int ignore ATTRIBUTE_UNUSED;
3832 if (ydata_section == 0)
3834 ydata_section = subseg_new (".ydata", 0);
3835 bfd_set_section_flags (stdoutput, ydata_section,
3836 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
3837 | SEC_READONLY | SEC_DATA ));
3839 bfd_set_section_alignment (stdoutput, ydata_section, 3);
3843 ydata_section = subseg_new (".ydata", 0);
3845 ppc_set_current_section (ydata_section);
3848 /* pseudo-op: .reldata
3849 behaviour: predefined read write data section
3850 double word aligned (4-byte)
3851 FIXME: relocation is applied to it
3852 FIXME: what's the difference between this and .data?
3855 initial: .section .reldata "drw3"
3856 d - initialized data
3859 3 - double word aligned (that would be 8 byte boundary)
3862 Like .data, but intended to hold data subject to relocation, such as
3863 function descriptors, etc. */
3866 ppc_reldata (ignore)
3867 int ignore ATTRIBUTE_UNUSED;
3869 if (reldata_section == 0)
3871 reldata_section = subseg_new (".reldata", 0);
3873 bfd_set_section_flags (stdoutput, reldata_section,
3874 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
3877 bfd_set_section_alignment (stdoutput, reldata_section, 2);
3881 reldata_section = subseg_new (".reldata", 0);
3883 ppc_set_current_section (reldata_section);
3886 /* pseudo-op: .rdata
3887 behaviour: predefined read only data section
3891 initial: .section .rdata "dr3"
3892 d - initialized data
3894 3 - double word aligned (that would be 4 byte boundary) */
3898 int ignore ATTRIBUTE_UNUSED;
3900 if (rdata_section == 0)
3902 rdata_section = subseg_new (".rdata", 0);
3903 bfd_set_section_flags (stdoutput, rdata_section,
3904 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
3905 | SEC_READONLY | SEC_DATA ));
3907 bfd_set_section_alignment (stdoutput, rdata_section, 2);
3911 rdata_section = subseg_new (".rdata", 0);
3913 ppc_set_current_section (rdata_section);
3916 /* pseudo-op: .ualong
3917 behaviour: much like .int, with the exception that no alignment is
3919 FIXME: test the alignment statement
3925 int ignore ATTRIBUTE_UNUSED;
3931 /* pseudo-op: .znop <symbol name>
3932 behaviour: Issue a nop instruction
3933 Issue a IMAGE_REL_PPC_IFGLUE relocation against it, using
3934 the supplied symbol name.
3936 warnings: Missing symbol name */
3940 int ignore ATTRIBUTE_UNUSED;
3943 const struct powerpc_opcode *opcode;
3954 /* Strip out the symbol name. */
3955 symbol_name = input_line_pointer;
3956 c = get_symbol_end ();
3958 name = xmalloc (input_line_pointer - symbol_name + 1);
3959 strcpy (name, symbol_name);
3961 sym = symbol_find_or_make (name);
3963 *input_line_pointer = c;
3967 /* Look up the opcode in the hash table. */
3968 opcode = (const struct powerpc_opcode *) hash_find (ppc_hash, "nop");
3970 /* Stick in the nop. */
3971 insn = opcode->opcode;
3973 /* Write out the instruction. */
3975 md_number_to_chars (f, insn, 4);
3977 f - frag_now->fr_literal,
3982 BFD_RELOC_16_GOT_PCREL);
3995 register char *name;
3999 register symbolS *symbolP;
4002 name = input_line_pointer;
4003 c = get_symbol_end ();
4005 /* just after name is now '\0'. */
4006 p = input_line_pointer;
4009 if (*input_line_pointer != ',')
4011 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
4012 ignore_rest_of_line ();
4016 input_line_pointer++; /* skip ',' */
4017 if ((temp = get_absolute_expression ()) < 0)
4019 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp);
4020 ignore_rest_of_line ();
4026 /* The third argument to .comm is the alignment. */
4027 if (*input_line_pointer != ',')
4031 ++input_line_pointer;
4032 align = get_absolute_expression ();
4035 as_warn (_("ignoring bad alignment"));
4042 symbolP = symbol_find_or_make (name);
4045 if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
4047 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
4048 S_GET_NAME (symbolP));
4049 ignore_rest_of_line ();
4053 if (S_GET_VALUE (symbolP))
4055 if (S_GET_VALUE (symbolP) != (valueT) temp)
4056 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
4057 S_GET_NAME (symbolP),
4058 (long) S_GET_VALUE (symbolP),
4063 S_SET_VALUE (symbolP, (valueT) temp);
4064 S_SET_EXTERNAL (symbolP);
4067 demand_empty_rest_of_line ();
4071 * implement the .section pseudo op:
4072 * .section name {, "flags"}
4074 * | +--- optional flags: 'b' for bss
4076 * +-- section name 'l' for lib
4080 * 'd' (apparently m88k for data)
4082 * But if the argument is not a quoted string, treat it as a
4083 * subsegment number.
4085 * FIXME: this is a copy of the section processing from obj-coff.c, with
4086 * additions/changes for the moto-pas assembler support. There are three
4089 * FIXME: I just noticed this. This doesn't work at all really. It it
4090 * setting bits that bfd probably neither understands or uses. The
4091 * correct approach (?) will have to incorporate extra fields attached
4092 * to the section to hold the system specific stuff. (krk)
4095 * 'a' - unknown - referred to in documentation, but no definition supplied
4096 * 'c' - section has code
4097 * 'd' - section has initialized data
4098 * 'u' - section has uninitialized data
4099 * 'i' - section contains directives (info)
4100 * 'n' - section can be discarded
4101 * 'R' - remove section at link time
4103 * Section Protection:
4104 * 'r' - section is readable
4105 * 'w' - section is writeable
4106 * 'x' - section is executable
4107 * 's' - section is sharable
4109 * Section Alignment:
4110 * '0' - align to byte boundary
4111 * '1' - align to halfword undary
4112 * '2' - align to word boundary
4113 * '3' - align to doubleword boundary
4114 * '4' - align to quadword boundary
4115 * '5' - align to 32 byte boundary
4116 * '6' - align to 64 byte boundary
4121 ppc_pe_section (ignore)
4122 int ignore ATTRIBUTE_UNUSED;
4124 /* Strip out the section name. */
4133 section_name = input_line_pointer;
4134 c = get_symbol_end ();
4136 name = xmalloc (input_line_pointer - section_name + 1);
4137 strcpy (name, section_name);
4139 *input_line_pointer = c;
4144 flags = SEC_NO_FLAGS;
4146 if (strcmp (name, ".idata$2") == 0)
4150 else if (strcmp (name, ".idata$3") == 0)
4154 else if (strcmp (name, ".idata$4") == 0)
4158 else if (strcmp (name, ".idata$5") == 0)
4162 else if (strcmp (name, ".idata$6") == 0)
4167 /* Default alignment to 16 byte boundary. */
4170 if (*input_line_pointer == ',')
4172 ++input_line_pointer;
4174 if (*input_line_pointer != '"')
4175 exp = get_absolute_expression ();
4178 ++input_line_pointer;
4179 while (*input_line_pointer != '"'
4180 && ! is_end_of_line[(unsigned char) *input_line_pointer])
4182 switch (*input_line_pointer)
4184 /* Section Contents */
4185 case 'a': /* unknown */
4186 as_bad (_("Unsupported section attribute -- 'a'"));
4188 case 'c': /* code section */
4191 case 'd': /* section has initialized data */
4194 case 'u': /* section has uninitialized data */
4195 /* FIXME: This is IMAGE_SCN_CNT_UNINITIALIZED_DATA
4199 case 'i': /* section contains directives (info) */
4200 /* FIXME: This is IMAGE_SCN_LNK_INFO
4202 flags |= SEC_HAS_CONTENTS;
4204 case 'n': /* section can be discarded */
4207 case 'R': /* Remove section at link time */
4208 flags |= SEC_NEVER_LOAD;
4211 /* Section Protection */
4212 case 'r': /* section is readable */
4213 flags |= IMAGE_SCN_MEM_READ;
4215 case 'w': /* section is writeable */
4216 flags |= IMAGE_SCN_MEM_WRITE;
4218 case 'x': /* section is executable */
4219 flags |= IMAGE_SCN_MEM_EXECUTE;
4221 case 's': /* section is sharable */
4222 flags |= IMAGE_SCN_MEM_SHARED;
4225 /* Section Alignment */
4226 case '0': /* align to byte boundary */
4227 flags |= IMAGE_SCN_ALIGN_1BYTES;
4230 case '1': /* align to halfword boundary */
4231 flags |= IMAGE_SCN_ALIGN_2BYTES;
4234 case '2': /* align to word boundary */
4235 flags |= IMAGE_SCN_ALIGN_4BYTES;
4238 case '3': /* align to doubleword boundary */
4239 flags |= IMAGE_SCN_ALIGN_8BYTES;
4242 case '4': /* align to quadword boundary */
4243 flags |= IMAGE_SCN_ALIGN_16BYTES;
4246 case '5': /* align to 32 byte boundary */
4247 flags |= IMAGE_SCN_ALIGN_32BYTES;
4250 case '6': /* align to 64 byte boundary */
4251 flags |= IMAGE_SCN_ALIGN_64BYTES;
4256 as_bad (_("unknown section attribute '%c'"),
4257 *input_line_pointer);
4260 ++input_line_pointer;
4262 if (*input_line_pointer == '"')
4263 ++input_line_pointer;
4267 sec = subseg_new (name, (subsegT) exp);
4269 ppc_set_current_section (sec);
4271 if (flags != SEC_NO_FLAGS)
4273 if (! bfd_set_section_flags (stdoutput, sec, flags))
4274 as_bad (_("error setting flags for \"%s\": %s"),
4275 bfd_section_name (stdoutput, sec),
4276 bfd_errmsg (bfd_get_error ()));
4279 bfd_set_section_alignment (stdoutput, sec, align);
4284 ppc_pe_function (ignore)
4285 int ignore ATTRIBUTE_UNUSED;
4291 name = input_line_pointer;
4292 endc = get_symbol_end ();
4294 ext_sym = symbol_find_or_make (name);
4296 *input_line_pointer = endc;
4298 S_SET_DATA_TYPE (ext_sym, DT_FCN << N_BTSHFT);
4299 SF_SET_FUNCTION (ext_sym);
4300 SF_SET_PROCESS (ext_sym);
4301 coff_add_linesym (ext_sym);
4303 demand_empty_rest_of_line ();
4307 ppc_pe_tocd (ignore)
4308 int ignore ATTRIBUTE_UNUSED;
4310 if (tocdata_section == 0)
4312 tocdata_section = subseg_new (".tocd", 0);
4313 /* FIXME: section flags won't work. */
4314 bfd_set_section_flags (stdoutput, tocdata_section,
4315 (SEC_ALLOC | SEC_LOAD | SEC_RELOC
4316 | SEC_READONLY | SEC_DATA));
4318 bfd_set_section_alignment (stdoutput, tocdata_section, 2);
4322 rdata_section = subseg_new (".tocd", 0);
4325 ppc_set_current_section (tocdata_section);
4327 demand_empty_rest_of_line ();
4330 /* Don't adjust TOC relocs to use the section symbol. */
4333 ppc_pe_fix_adjustable (fix)
4336 return fix->fx_r_type != BFD_RELOC_PPC_TOC16;
4343 /* XCOFF specific symbol and file handling. */
4345 /* Canonicalize the symbol name. We use the to force the suffix, if
4346 any, to use square brackets, and to be in upper case. */
4349 ppc_canonicalize_symbol_name (name)
4354 if (ppc_stab_symbol)
4357 for (s = name; *s != '\0' && *s != '{' && *s != '['; s++)
4371 for (s++; *s != '\0' && *s != brac; s++)
4374 if (*s == '\0' || s[1] != '\0')
4375 as_bad (_("bad symbol suffix"));
4383 /* Set the class of a symbol based on the suffix, if any. This is
4384 called whenever a new symbol is created. */
4387 ppc_symbol_new_hook (sym)
4390 struct ppc_tc_sy *tc;
4393 tc = symbol_get_tc (sym);
4397 tc->real_name = NULL;
4403 if (ppc_stab_symbol)
4406 s = strchr (S_GET_NAME (sym), '[');
4407 if (s == (const char *) NULL)
4409 /* There is no suffix. */
4418 if (strcmp (s, "BS]") == 0)
4422 if (strcmp (s, "DB]") == 0)
4424 else if (strcmp (s, "DS]") == 0)
4428 if (strcmp (s, "GL]") == 0)
4432 if (strcmp (s, "PR]") == 0)
4436 if (strcmp (s, "RO]") == 0)
4438 else if (strcmp (s, "RW]") == 0)
4442 if (strcmp (s, "SV]") == 0)
4446 if (strcmp (s, "TC]") == 0)
4448 else if (strcmp (s, "TI]") == 0)
4450 else if (strcmp (s, "TB]") == 0)
4452 else if (strcmp (s, "TC0]") == 0 || strcmp (s, "T0]") == 0)
4453 tc->class = XMC_TC0;
4456 if (strcmp (s, "UA]") == 0)
4458 else if (strcmp (s, "UC]") == 0)
4462 if (strcmp (s, "XO]") == 0)
4467 if (tc->class == -1)
4468 as_bad (_("Unrecognized symbol suffix"));
4471 /* Set the class of a label based on where it is defined. This
4472 handles symbols without suffixes. Also, move the symbol so that it
4473 follows the csect symbol. */
4476 ppc_frob_label (sym)
4479 if (ppc_current_csect != (symbolS *) NULL)
4481 if (symbol_get_tc (sym)->class == -1)
4482 symbol_get_tc (sym)->class = symbol_get_tc (ppc_current_csect)->class;
4484 symbol_remove (sym, &symbol_rootP, &symbol_lastP);
4485 symbol_append (sym, symbol_get_tc (ppc_current_csect)->within,
4486 &symbol_rootP, &symbol_lastP);
4487 symbol_get_tc (ppc_current_csect)->within = sym;
4491 /* This variable is set by ppc_frob_symbol if any absolute symbols are
4492 seen. It tells ppc_adjust_symtab whether it needs to look through
4495 static boolean ppc_saw_abs;
4497 /* Change the name of a symbol just before writing it out. Set the
4498 real name if the .rename pseudo-op was used. Otherwise, remove any
4499 class suffix. Return 1 if the symbol should not be included in the
4503 ppc_frob_symbol (sym)
4506 static symbolS *ppc_last_function;
4507 static symbolS *set_end;
4509 /* Discard symbols that should not be included in the output symbol
4511 if (! symbol_used_in_reloc_p (sym)
4512 && ((symbol_get_bfdsym (sym)->flags & BSF_SECTION_SYM) != 0
4513 || (! S_IS_EXTERNAL (sym)
4514 && ! symbol_get_tc (sym)->output
4515 && S_GET_STORAGE_CLASS (sym) != C_FILE)))
4518 if (symbol_get_tc (sym)->real_name != (char *) NULL)
4519 S_SET_NAME (sym, symbol_get_tc (sym)->real_name);
4525 name = S_GET_NAME (sym);
4526 s = strchr (name, '[');
4527 if (s != (char *) NULL)
4533 snew = xmalloc (len + 1);
4534 memcpy (snew, name, len);
4537 S_SET_NAME (sym, snew);
4541 if (set_end != (symbolS *) NULL)
4543 SA_SET_SYM_ENDNDX (set_end, sym);
4547 if (SF_GET_FUNCTION (sym))
4549 if (ppc_last_function != (symbolS *) NULL)
4550 as_bad (_("two .function pseudo-ops with no intervening .ef"));
4551 ppc_last_function = sym;
4552 if (symbol_get_tc (sym)->size != (symbolS *) NULL)
4554 resolve_symbol_value (symbol_get_tc (sym)->size);
4555 SA_SET_SYM_FSIZE (sym,
4556 (long) S_GET_VALUE (symbol_get_tc (sym)->size));
4559 else if (S_GET_STORAGE_CLASS (sym) == C_FCN
4560 && strcmp (S_GET_NAME (sym), ".ef") == 0)
4562 if (ppc_last_function == (symbolS *) NULL)
4563 as_bad (_(".ef with no preceding .function"));
4566 set_end = ppc_last_function;
4567 ppc_last_function = NULL;
4569 /* We don't have a C_EFCN symbol, but we need to force the
4570 COFF backend to believe that it has seen one. */
4571 coff_last_function = NULL;
4575 if (! S_IS_EXTERNAL (sym)
4576 && (symbol_get_bfdsym (sym)->flags & BSF_SECTION_SYM) == 0
4577 && S_GET_STORAGE_CLASS (sym) != C_FILE
4578 && S_GET_STORAGE_CLASS (sym) != C_FCN
4579 && S_GET_STORAGE_CLASS (sym) != C_BLOCK
4580 && S_GET_STORAGE_CLASS (sym) != C_BSTAT
4581 && S_GET_STORAGE_CLASS (sym) != C_ESTAT
4582 && S_GET_STORAGE_CLASS (sym) != C_BINCL
4583 && S_GET_STORAGE_CLASS (sym) != C_EINCL
4584 && S_GET_SEGMENT (sym) != ppc_coff_debug_section)
4585 S_SET_STORAGE_CLASS (sym, C_HIDEXT);
4587 if (S_GET_STORAGE_CLASS (sym) == C_EXT
4588 || S_GET_STORAGE_CLASS (sym) == C_HIDEXT)
4591 union internal_auxent *a;
4593 /* Create a csect aux. */
4594 i = S_GET_NUMBER_AUXILIARY (sym);
4595 S_SET_NUMBER_AUXILIARY (sym, i + 1);
4596 a = &coffsymbol (symbol_get_bfdsym (sym))->native[i + 1].u.auxent;
4597 if (symbol_get_tc (sym)->class == XMC_TC0)
4599 /* This is the TOC table. */
4600 know (strcmp (S_GET_NAME (sym), "TOC") == 0);
4601 a->x_csect.x_scnlen.l = 0;
4602 a->x_csect.x_smtyp = (2 << 3) | XTY_SD;
4604 else if (symbol_get_tc (sym)->subseg != 0)
4606 /* This is a csect symbol. x_scnlen is the size of the
4608 if (symbol_get_tc (sym)->next == (symbolS *) NULL)
4609 a->x_csect.x_scnlen.l = (bfd_section_size (stdoutput,
4610 S_GET_SEGMENT (sym))
4611 - S_GET_VALUE (sym));
4614 resolve_symbol_value (symbol_get_tc (sym)->next);
4615 a->x_csect.x_scnlen.l = (S_GET_VALUE (symbol_get_tc (sym)->next)
4616 - S_GET_VALUE (sym));
4618 a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_SD;
4620 else if (S_GET_SEGMENT (sym) == bss_section)
4622 /* This is a common symbol. */
4623 a->x_csect.x_scnlen.l = symbol_get_frag (sym)->fr_offset;
4624 a->x_csect.x_smtyp = (symbol_get_tc (sym)->align << 3) | XTY_CM;
4625 if (S_IS_EXTERNAL (sym))
4626 symbol_get_tc (sym)->class = XMC_RW;
4628 symbol_get_tc (sym)->class = XMC_BS;
4630 else if (S_GET_SEGMENT (sym) == absolute_section)
4632 /* This is an absolute symbol. The csect will be created by
4633 ppc_adjust_symtab. */
4635 a->x_csect.x_smtyp = XTY_LD;
4636 if (symbol_get_tc (sym)->class == -1)
4637 symbol_get_tc (sym)->class = XMC_XO;
4639 else if (! S_IS_DEFINED (sym))
4641 /* This is an external symbol. */
4642 a->x_csect.x_scnlen.l = 0;
4643 a->x_csect.x_smtyp = XTY_ER;
4645 else if (symbol_get_tc (sym)->class == XMC_TC)
4649 /* This is a TOC definition. x_scnlen is the size of the
4651 next = symbol_next (sym);
4652 while (symbol_get_tc (next)->class == XMC_TC0)
4653 next = symbol_next (next);
4654 if (next == (symbolS *) NULL
4655 || symbol_get_tc (next)->class != XMC_TC)
4657 if (ppc_after_toc_frag == (fragS *) NULL)
4658 a->x_csect.x_scnlen.l = (bfd_section_size (stdoutput,
4660 - S_GET_VALUE (sym));
4662 a->x_csect.x_scnlen.l = (ppc_after_toc_frag->fr_address
4663 - S_GET_VALUE (sym));
4667 resolve_symbol_value (next);
4668 a->x_csect.x_scnlen.l = (S_GET_VALUE (next)
4669 - S_GET_VALUE (sym));
4671 a->x_csect.x_smtyp = (2 << 3) | XTY_SD;
4677 /* This is a normal symbol definition. x_scnlen is the
4678 symbol index of the containing csect. */
4679 if (S_GET_SEGMENT (sym) == text_section)
4680 csect = ppc_text_csects;
4681 else if (S_GET_SEGMENT (sym) == data_section)
4682 csect = ppc_data_csects;
4686 /* Skip the initial dummy symbol. */
4687 csect = symbol_get_tc (csect)->next;
4689 if (csect == (symbolS *) NULL)
4691 as_warn (_("warning: symbol %s has no csect"), S_GET_NAME (sym));
4692 a->x_csect.x_scnlen.l = 0;
4696 while (symbol_get_tc (csect)->next != (symbolS *) NULL)
4698 resolve_symbol_value (symbol_get_tc (csect)->next);
4699 if (S_GET_VALUE (symbol_get_tc (csect)->next)
4700 > S_GET_VALUE (sym))
4702 csect = symbol_get_tc (csect)->next;
4705 a->x_csect.x_scnlen.p =
4706 coffsymbol (symbol_get_bfdsym (csect))->native;
4707 coffsymbol (symbol_get_bfdsym (sym))->native[i + 1].fix_scnlen =
4710 a->x_csect.x_smtyp = XTY_LD;
4713 a->x_csect.x_parmhash = 0;
4714 a->x_csect.x_snhash = 0;
4715 if (symbol_get_tc (sym)->class == -1)
4716 a->x_csect.x_smclas = XMC_PR;
4718 a->x_csect.x_smclas = symbol_get_tc (sym)->class;
4719 a->x_csect.x_stab = 0;
4720 a->x_csect.x_snstab = 0;
4722 /* Don't let the COFF backend resort these symbols. */
4723 symbol_get_bfdsym (sym)->flags |= BSF_NOT_AT_END;
4725 else if (S_GET_STORAGE_CLASS (sym) == C_BSTAT)
4727 /* We want the value to be the symbol index of the referenced
4728 csect symbol. BFD will do that for us if we set the right
4732 coffsymbol (symbol_get_bfdsym
4733 (symbol_get_tc (sym)->within))->native));
4734 coffsymbol (symbol_get_bfdsym (sym))->native->fix_value = 1;
4736 else if (S_GET_STORAGE_CLASS (sym) == C_STSYM)
4741 /* The value is the offset from the enclosing csect. */
4742 block = symbol_get_tc (sym)->within;
4743 csect = symbol_get_tc (block)->within;
4744 resolve_symbol_value (csect);
4745 S_SET_VALUE (sym, S_GET_VALUE (sym) - S_GET_VALUE (csect));
4747 else if (S_GET_STORAGE_CLASS (sym) == C_BINCL
4748 || S_GET_STORAGE_CLASS (sym) == C_EINCL)
4750 /* We want the value to be a file offset into the line numbers.
4751 BFD will do that for us if we set the right flags. We have
4752 already set the value correctly. */
4753 coffsymbol (symbol_get_bfdsym (sym))->native->fix_line = 1;
4759 /* Adjust the symbol table. This creates csect symbols for all
4760 absolute symbols. */
4763 ppc_adjust_symtab ()
4770 for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
4774 union internal_auxent *a;
4776 if (S_GET_SEGMENT (sym) != absolute_section)
4779 csect = symbol_create (".abs[XO]", absolute_section,
4780 S_GET_VALUE (sym), &zero_address_frag);
4781 symbol_get_bfdsym (csect)->value = S_GET_VALUE (sym);
4782 S_SET_STORAGE_CLASS (csect, C_HIDEXT);
4783 i = S_GET_NUMBER_AUXILIARY (csect);
4784 S_SET_NUMBER_AUXILIARY (csect, i + 1);
4785 a = &coffsymbol (symbol_get_bfdsym (csect))->native[i + 1].u.auxent;
4786 a->x_csect.x_scnlen.l = 0;
4787 a->x_csect.x_smtyp = XTY_SD;
4788 a->x_csect.x_parmhash = 0;
4789 a->x_csect.x_snhash = 0;
4790 a->x_csect.x_smclas = XMC_XO;
4791 a->x_csect.x_stab = 0;
4792 a->x_csect.x_snstab = 0;
4794 symbol_insert (csect, sym, &symbol_rootP, &symbol_lastP);
4796 i = S_GET_NUMBER_AUXILIARY (sym);
4797 a = &coffsymbol (symbol_get_bfdsym (sym))->native[i].u.auxent;
4798 a->x_csect.x_scnlen.p = coffsymbol (symbol_get_bfdsym (csect))->native;
4799 coffsymbol (symbol_get_bfdsym (sym))->native[i].fix_scnlen = 1;
4802 ppc_saw_abs = false;
4805 /* Set the VMA for a section. This is called on all the sections in
4809 ppc_frob_section (sec)
4812 static bfd_size_type vma = 0;
4814 bfd_set_section_vma (stdoutput, sec, vma);
4815 vma += bfd_section_size (stdoutput, sec);
4818 #endif /* OBJ_XCOFF */
4820 /* Turn a string in input_line_pointer into a floating point constant
4821 of type TYPE, and store the appropriate bytes in *LITP. The number
4822 of LITTLENUMS emitted is stored in *SIZEP. An error message is
4823 returned, or NULL on OK. */
4826 md_atof (type, litp, sizep)
4832 LITTLENUM_TYPE words[4];
4848 return _("bad call to md_atof");
4851 t = atof_ieee (input_line_pointer, type, words);
4853 input_line_pointer = t;
4857 if (target_big_endian)
4859 for (i = 0; i < prec; i++)
4861 md_number_to_chars (litp, (valueT) words[i], 2);
4867 for (i = prec - 1; i >= 0; i--)
4869 md_number_to_chars (litp, (valueT) words[i], 2);
4877 /* Write a value out to the object file, using the appropriate
4881 md_number_to_chars (buf, val, n)
4886 if (target_big_endian)
4887 number_to_chars_bigendian (buf, val, n);
4889 number_to_chars_littleendian (buf, val, n);
4892 /* Align a section (I don't know why this is machine dependent). */
4895 md_section_align (seg, addr)
4899 int align = bfd_get_section_alignment (stdoutput, seg);
4901 return ((addr + (1 << align) - 1) & (-1 << align));
4904 /* We don't have any form of relaxing. */
4907 md_estimate_size_before_relax (fragp, seg)
4908 fragS *fragp ATTRIBUTE_UNUSED;
4909 asection *seg ATTRIBUTE_UNUSED;
4915 /* Convert a machine dependent frag. We never generate these. */
4918 md_convert_frag (abfd, sec, fragp)
4919 bfd *abfd ATTRIBUTE_UNUSED;
4920 asection *sec ATTRIBUTE_UNUSED;
4921 fragS *fragp ATTRIBUTE_UNUSED;
4926 /* We have no need to default values of symbols. */
4929 md_undefined_symbol (name)
4930 char *name ATTRIBUTE_UNUSED;
4935 /* Functions concerning relocs. */
4937 /* The location from which a PC relative jump should be calculated,
4938 given a PC relative reloc. */
4941 md_pcrel_from_section (fixp, sec)
4943 segT sec ATTRIBUTE_UNUSED;
4945 return fixp->fx_frag->fr_address + fixp->fx_where;
4950 /* This is called to see whether a fixup should be adjusted to use a
4951 section symbol. We take the opportunity to change a fixup against
4952 a symbol in the TOC subsegment into a reloc against the
4953 corresponding .tc symbol. */
4956 ppc_fix_adjustable (fix)
4961 resolve_symbol_value (fix->fx_addsy);
4962 val = S_GET_VALUE (fix->fx_addsy);
4963 if (ppc_toc_csect != (symbolS *) NULL
4964 && fix->fx_addsy != (symbolS *) NULL
4965 && fix->fx_addsy != ppc_toc_csect
4966 && S_GET_SEGMENT (fix->fx_addsy) == data_section
4967 && val >= ppc_toc_frag->fr_address
4968 && (ppc_after_toc_frag == (fragS *) NULL
4969 || val < ppc_after_toc_frag->fr_address))
4973 for (sy = symbol_next (ppc_toc_csect);
4974 sy != (symbolS *) NULL;
4975 sy = symbol_next (sy))
4977 if (symbol_get_tc (sy)->class == XMC_TC0)
4979 if (symbol_get_tc (sy)->class != XMC_TC)
4981 resolve_symbol_value (sy);
4982 if (val == S_GET_VALUE (sy))
4985 fix->fx_addnumber = val - ppc_toc_frag->fr_address;
4990 as_bad_where (fix->fx_file, fix->fx_line,
4991 _("symbol in .toc does not match any .tc"));
4994 /* Possibly adjust the reloc to be against the csect. */
4995 if (fix->fx_addsy != (symbolS *) NULL
4996 && symbol_get_tc (fix->fx_addsy)->subseg == 0
4997 && symbol_get_tc (fix->fx_addsy)->class != XMC_TC0
4998 && symbol_get_tc (fix->fx_addsy)->class != XMC_TC
4999 && S_GET_SEGMENT (fix->fx_addsy) != bss_section
5000 /* Don't adjust if this is a reloc in the toc section. */
5001 && (S_GET_SEGMENT (fix->fx_addsy) != data_section
5002 || ppc_toc_csect == NULL
5003 || val < ppc_toc_frag->fr_address
5004 || (ppc_after_toc_frag != NULL
5005 && val >= ppc_after_toc_frag->fr_address)))
5009 if (S_GET_SEGMENT (fix->fx_addsy) == text_section)
5010 csect = ppc_text_csects;
5011 else if (S_GET_SEGMENT (fix->fx_addsy) == data_section)
5012 csect = ppc_data_csects;
5016 /* Skip the initial dummy symbol. */
5017 csect = symbol_get_tc (csect)->next;
5019 if (csect != (symbolS *) NULL)
5021 while (symbol_get_tc (csect)->next != (symbolS *) NULL
5022 && (symbol_get_frag (symbol_get_tc (csect)->next)->fr_address
5025 /* If the csect address equals the symbol value, then we
5026 have to look through the full symbol table to see
5027 whether this is the csect we want. Note that we will
5028 only get here if the csect has zero length. */
5029 if ((symbol_get_frag (csect)->fr_address == val)
5030 && S_GET_VALUE (csect) == S_GET_VALUE (fix->fx_addsy))
5034 for (scan = symbol_next (csect);
5036 scan = symbol_next (scan))
5038 if (symbol_get_tc (scan)->subseg != 0)
5040 if (scan == fix->fx_addsy)
5044 /* If we found the symbol before the next csect
5045 symbol, then this is the csect we want. */
5046 if (scan == fix->fx_addsy)
5050 csect = symbol_get_tc (csect)->next;
5053 fix->fx_offset += (S_GET_VALUE (fix->fx_addsy)
5054 - symbol_get_frag (csect)->fr_address);
5055 fix->fx_addsy = csect;
5059 /* Adjust a reloc against a .lcomm symbol to be against the base
5061 if (fix->fx_addsy != (symbolS *) NULL
5062 && S_GET_SEGMENT (fix->fx_addsy) == bss_section
5063 && ! S_IS_EXTERNAL (fix->fx_addsy))
5065 resolve_symbol_value (symbol_get_frag (fix->fx_addsy)->fr_symbol);
5067 (S_GET_VALUE (fix->fx_addsy)
5068 - S_GET_VALUE (symbol_get_frag (fix->fx_addsy)->fr_symbol));
5069 fix->fx_addsy = symbol_get_frag (fix->fx_addsy)->fr_symbol;
5075 /* A reloc from one csect to another must be kept. The assembler
5076 will, of course, keep relocs between sections, and it will keep
5077 absolute relocs, but we need to force it to keep PC relative relocs
5078 between two csects in the same section. */
5081 ppc_force_relocation (fix)
5084 /* At this point fix->fx_addsy should already have been converted to
5085 a csect symbol. If the csect does not include the fragment, then
5086 we need to force the relocation. */
5088 && fix->fx_addsy != NULL
5089 && symbol_get_tc (fix->fx_addsy)->subseg != 0
5090 && ((symbol_get_frag (fix->fx_addsy)->fr_address
5091 > fix->fx_frag->fr_address)
5092 || (symbol_get_tc (fix->fx_addsy)->next != NULL
5093 && (symbol_get_frag (symbol_get_tc (fix->fx_addsy)->next)->fr_address
5094 <= fix->fx_frag->fr_address))))
5100 #endif /* OBJ_XCOFF */
5104 ppc_fix_adjustable (fix)
5107 return (fix->fx_r_type != BFD_RELOC_16_GOTOFF
5108 && fix->fx_r_type != BFD_RELOC_LO16_GOTOFF
5109 && fix->fx_r_type != BFD_RELOC_HI16_GOTOFF
5110 && fix->fx_r_type != BFD_RELOC_HI16_S_GOTOFF
5111 && fix->fx_r_type != BFD_RELOC_GPREL16
5112 && fix->fx_r_type != BFD_RELOC_VTABLE_INHERIT
5113 && fix->fx_r_type != BFD_RELOC_VTABLE_ENTRY
5114 && ! S_IS_EXTERNAL (fix->fx_addsy)
5115 && ! S_IS_WEAK (fix->fx_addsy)
5117 || (fix->fx_subsy != NULL
5118 && (S_GET_SEGMENT (fix->fx_subsy)
5119 == S_GET_SEGMENT (fix->fx_addsy)))
5120 || S_IS_LOCAL (fix->fx_addsy)));
5124 /* Apply a fixup to the object code. This is called for all the
5125 fixups we generated by the call to fix_new_exp, above. In the call
5126 above we used a reloc code which was the largest legal reloc code
5127 plus the operand index. Here we undo that to recover the operand
5128 index. At this point all symbol values should be fully resolved,
5129 and we attempt to completely resolve the reloc. If we can not do
5130 that, we determine the correct reloc code and put it back in the
5134 md_apply_fix3 (fixP, valP, seg)
5137 segT seg ATTRIBUTE_UNUSED;
5139 valueT value = * valP;
5142 if (fixP->fx_addsy != NULL)
5144 /* `*valuep' may contain the value of the symbol on which the reloc
5145 will be based; we have to remove it. */
5146 if (symbol_used_in_reloc_p (fixP->fx_addsy)
5147 && S_GET_SEGMENT (fixP->fx_addsy) != absolute_section
5148 && S_GET_SEGMENT (fixP->fx_addsy) != undefined_section
5149 && ! bfd_is_com_section (S_GET_SEGMENT (fixP->fx_addsy)))
5150 value -= S_GET_VALUE (fixP->fx_addsy);
5152 /* FIXME: Why '+'? Better yet, what exactly is '*valuep'
5153 supposed to be? I think this is related to various similar
5154 FIXMEs in tc-i386.c and tc-sparc.c. */
5156 value += fixP->fx_frag->fr_address + fixP->fx_where;
5161 /* FIXME FIXME FIXME: The value we are passed in *valuep includes
5162 the symbol values. Since we are using BFD_ASSEMBLER, if we are
5163 doing this relocation the code in write.c is going to call
5164 bfd_install_relocation, which is also going to use the symbol
5165 value. That means that if the reloc is fully resolved we want to
5166 use *valuep since bfd_install_relocation is not being used.
5167 However, if the reloc is not fully resolved we do not want to use
5168 *valuep, and must use fx_offset instead. However, if the reloc
5169 is PC relative, we do want to use *valuep since it includes the
5170 result of md_pcrel_from. This is confusing. */
5171 if (fixP->fx_addsy == (symbolS *) NULL)
5174 else if (fixP->fx_pcrel)
5179 value = fixP->fx_offset;
5180 if (fixP->fx_subsy != (symbolS *) NULL)
5182 if (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)
5183 value -= S_GET_VALUE (fixP->fx_subsy);
5186 /* We can't actually support subtracting a symbol. */
5187 as_bad_where (fixP->fx_file, fixP->fx_line,
5188 _("expression too complex"));
5194 if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
5197 const struct powerpc_operand *operand;
5201 opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED;
5203 operand = &powerpc_operands[opindex];
5206 /* An instruction like `lwz 9,sym(30)' when `sym' is not a TOC symbol
5207 does not generate a reloc. It uses the offset of `sym' within its
5208 csect. Other usages, such as `.long sym', generate relocs. This
5209 is the documented behaviour of non-TOC symbols. */
5210 if ((operand->flags & PPC_OPERAND_PARENS) != 0
5211 && operand->bits == 16
5212 && operand->shift == 0
5213 && (operand->insert == NULL || ppc_obj64)
5214 && fixP->fx_addsy != NULL
5215 && symbol_get_tc (fixP->fx_addsy)->subseg != 0
5216 && symbol_get_tc (fixP->fx_addsy)->class != XMC_TC
5217 && symbol_get_tc (fixP->fx_addsy)->class != XMC_TC0
5218 && S_GET_SEGMENT (fixP->fx_addsy) != bss_section)
5220 value = fixP->fx_offset;
5225 /* Fetch the instruction, insert the fully resolved operand
5226 value, and stuff the instruction back again. */
5227 where = fixP->fx_frag->fr_literal + fixP->fx_where;
5228 if (target_big_endian)
5229 insn = bfd_getb32 ((unsigned char *) where);
5231 insn = bfd_getl32 ((unsigned char *) where);
5232 insn = ppc_insert_operand (insn, operand, (offsetT) value,
5233 fixP->fx_file, fixP->fx_line);
5234 if (target_big_endian)
5235 bfd_putb32 ((bfd_vma) insn, (unsigned char *) where);
5237 bfd_putl32 ((bfd_vma) insn, (unsigned char *) where);
5240 /* Nothing else to do here. */
5243 assert (fixP->fx_addsy != NULL);
5245 /* Determine a BFD reloc value based on the operand information.
5246 We are only prepared to turn a few of the operands into
5248 if ((operand->flags & PPC_OPERAND_RELATIVE) != 0
5249 && operand->bits == 26
5250 && operand->shift == 0)
5251 fixP->fx_r_type = BFD_RELOC_PPC_B26;
5252 else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0
5253 && operand->bits == 16
5254 && operand->shift == 0)
5256 fixP->fx_r_type = BFD_RELOC_PPC_B16;
5259 if (target_big_endian)
5260 fixP->fx_where += 2;
5263 else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0
5264 && operand->bits == 26
5265 && operand->shift == 0)
5266 fixP->fx_r_type = BFD_RELOC_PPC_BA26;
5267 else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0
5268 && operand->bits == 16
5269 && operand->shift == 0)
5271 fixP->fx_r_type = BFD_RELOC_PPC_BA16;
5274 if (target_big_endian)
5275 fixP->fx_where += 2;
5278 #if defined (OBJ_XCOFF) || defined (OBJ_ELF)
5279 else if ((operand->flags & PPC_OPERAND_PARENS) != 0
5280 && operand->bits == 16
5281 && operand->shift == 0
5282 && ppc_is_toc_sym (fixP->fx_addsy))
5284 fixP->fx_r_type = BFD_RELOC_PPC_TOC16;
5287 && (operand->flags & PPC_OPERAND_DS) != 0)
5288 fixP->fx_r_type = BFD_RELOC_PPC64_TOC16_DS;
5291 if (target_big_endian)
5292 fixP->fx_where += 2;
5294 #endif /* defined (OBJ_XCOFF) || defined (OBJ_ELF) */
5300 /* Use expr_symbol_where to see if this is an expression
5302 if (expr_symbol_where (fixP->fx_addsy, &sfile, &sline))
5303 as_bad_where (fixP->fx_file, fixP->fx_line,
5304 _("unresolved expression that must be resolved"));
5306 as_bad_where (fixP->fx_file, fixP->fx_line,
5307 _("unsupported relocation against %s"),
5308 S_GET_NAME (fixP->fx_addsy));
5316 ppc_elf_validate_fix (fixP, seg);
5318 switch (fixP->fx_r_type)
5320 case BFD_RELOC_CTOR:
5327 fixP->fx_r_type = BFD_RELOC_32_PCREL;
5331 case BFD_RELOC_32_PCREL:
5332 case BFD_RELOC_PPC_EMB_NADDR32:
5333 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5340 fixP->fx_r_type = BFD_RELOC_64_PCREL;
5343 case BFD_RELOC_64_PCREL:
5344 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5348 case BFD_RELOC_LO16:
5350 case BFD_RELOC_GPREL16:
5351 case BFD_RELOC_16_GOT_PCREL:
5352 case BFD_RELOC_16_GOTOFF:
5353 case BFD_RELOC_LO16_GOTOFF:
5354 case BFD_RELOC_HI16_GOTOFF:
5355 case BFD_RELOC_HI16_S_GOTOFF:
5356 case BFD_RELOC_16_BASEREL:
5357 case BFD_RELOC_LO16_BASEREL:
5358 case BFD_RELOC_HI16_BASEREL:
5359 case BFD_RELOC_HI16_S_BASEREL:
5360 case BFD_RELOC_PPC_EMB_NADDR16:
5361 case BFD_RELOC_PPC_EMB_NADDR16_LO:
5362 case BFD_RELOC_PPC_EMB_NADDR16_HI:
5363 case BFD_RELOC_PPC_EMB_NADDR16_HA:
5364 case BFD_RELOC_PPC_EMB_SDAI16:
5365 case BFD_RELOC_PPC_EMB_SDA2REL:
5366 case BFD_RELOC_PPC_EMB_SDA2I16:
5367 case BFD_RELOC_PPC_EMB_RELSEC16:
5368 case BFD_RELOC_PPC_EMB_RELST_LO:
5369 case BFD_RELOC_PPC_EMB_RELST_HI:
5370 case BFD_RELOC_PPC_EMB_RELST_HA:
5371 case BFD_RELOC_PPC_EMB_RELSDA:
5372 case BFD_RELOC_PPC_TOC16:
5374 case BFD_RELOC_PPC64_TOC16_LO:
5375 case BFD_RELOC_PPC64_TOC16_HI:
5376 case BFD_RELOC_PPC64_TOC16_HA:
5380 if (fixP->fx_addsy != NULL)
5381 as_bad_where (fixP->fx_file, fixP->fx_line,
5382 _("cannot emit PC relative %s relocation against %s"),
5383 bfd_get_reloc_code_name (fixP->fx_r_type),
5384 S_GET_NAME (fixP->fx_addsy));
5386 as_bad_where (fixP->fx_file, fixP->fx_line,
5387 _("cannot emit PC relative %s relocation"),
5388 bfd_get_reloc_code_name (fixP->fx_r_type));
5391 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5395 /* This case happens when you write, for example,
5397 where L1 and L2 are defined later. */
5398 case BFD_RELOC_HI16:
5401 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5405 case BFD_RELOC_HI16_S:
5408 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5413 case BFD_RELOC_PPC64_HIGHER:
5416 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5417 PPC_HIGHER (value), 2);
5420 case BFD_RELOC_PPC64_HIGHER_S:
5423 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5424 PPC_HIGHERA (value), 2);
5427 case BFD_RELOC_PPC64_HIGHEST:
5430 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5431 PPC_HIGHEST (value), 2);
5434 case BFD_RELOC_PPC64_HIGHEST_S:
5437 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5438 PPC_HIGHESTA (value), 2);
5441 case BFD_RELOC_PPC64_ADDR16_DS:
5442 case BFD_RELOC_PPC64_ADDR16_LO_DS:
5443 case BFD_RELOC_PPC64_GOT16_DS:
5444 case BFD_RELOC_PPC64_GOT16_LO_DS:
5445 case BFD_RELOC_PPC64_PLT16_LO_DS:
5446 case BFD_RELOC_PPC64_SECTOFF_DS:
5447 case BFD_RELOC_PPC64_SECTOFF_LO_DS:
5448 case BFD_RELOC_PPC64_TOC16_DS:
5449 case BFD_RELOC_PPC64_TOC16_LO_DS:
5450 case BFD_RELOC_PPC64_PLTGOT16_DS:
5451 case BFD_RELOC_PPC64_PLTGOT16_LO_DS:
5455 unsigned char *where = fixP->fx_frag->fr_literal + fixP->fx_where;
5458 if (target_big_endian)
5459 val = bfd_getb16 (where);
5461 val = bfd_getl16 (where);
5462 val |= (value & 0xfffc);
5463 if (target_big_endian)
5464 bfd_putb16 ((bfd_vma) val, where);
5466 bfd_putl16 ((bfd_vma) val, where);
5470 /* Because SDA21 modifies the register field, the size is set to 4
5471 bytes, rather than 2, so offset it here appropriately. */
5472 case BFD_RELOC_PPC_EMB_SDA21:
5476 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where
5477 + ((target_big_endian) ? 2 : 0),
5485 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
5489 case BFD_RELOC_24_PLT_PCREL:
5490 case BFD_RELOC_PPC_LOCAL24PC:
5491 if (!fixP->fx_pcrel && !fixP->fx_done)
5499 /* Fetch the instruction, insert the fully resolved operand
5500 value, and stuff the instruction back again. */
5501 where = fixP->fx_frag->fr_literal + fixP->fx_where;
5502 if (target_big_endian)
5503 insn = bfd_getb32 ((unsigned char *) where);
5505 insn = bfd_getl32 ((unsigned char *) where);
5506 if ((value & 3) != 0)
5507 as_bad_where (fixP->fx_file, fixP->fx_line,
5508 _("must branch to an address a multiple of 4"));
5509 if ((offsetT) value < -0x40000000
5510 || (offsetT) value >= 0x40000000)
5511 as_bad_where (fixP->fx_file, fixP->fx_line,
5512 _("@local or @plt branch destination is too far away, %ld bytes"),
5514 insn = insn | (value & 0x03fffffc);
5515 if (target_big_endian)
5516 bfd_putb32 ((bfd_vma) insn, (unsigned char *) where);
5518 bfd_putl32 ((bfd_vma) insn, (unsigned char *) where);
5522 case BFD_RELOC_VTABLE_INHERIT:
5525 && !S_IS_DEFINED (fixP->fx_addsy)
5526 && !S_IS_WEAK (fixP->fx_addsy))
5527 S_SET_WEAK (fixP->fx_addsy);
5530 case BFD_RELOC_VTABLE_ENTRY:
5535 /* Generated by reference to `sym@tocbase'. The sym is
5536 ignored by the linker. */
5537 case BFD_RELOC_PPC64_TOC:
5543 _("Gas failure, reloc value %d\n"), fixP->fx_r_type);
5550 fixP->fx_addnumber = value;
5552 if (fixP->fx_r_type != BFD_RELOC_PPC_TOC16)
5553 fixP->fx_addnumber = 0;
5557 fixP->fx_addnumber = 0;
5559 /* We want to use the offset within the data segment of the
5560 symbol, not the actual VMA of the symbol. */
5561 fixP->fx_addnumber =
5562 - bfd_get_section_vma (stdoutput, S_GET_SEGMENT (fixP->fx_addsy));
5568 /* Generate a reloc for a fixup. */
5571 tc_gen_reloc (seg, fixp)
5572 asection *seg ATTRIBUTE_UNUSED;
5577 reloc = (arelent *) xmalloc (sizeof (arelent));
5579 reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
5580 *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
5581 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
5582 reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
5583 if (reloc->howto == (reloc_howto_type *) NULL)
5585 as_bad_where (fixp->fx_file, fixp->fx_line,
5586 _("reloc %d not supported by object file format"),
5587 (int) fixp->fx_r_type);
5590 reloc->addend = fixp->fx_addnumber;