1 /* tc-sparc.c -- Assemble for the SPARC
2 Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public
18 License along with GAS; see the file COPYING. If not, write
19 to the Free Software Foundation, 51 Franklin Street - Fifth Floor,
20 Boston, MA 02110-1301, USA. */
23 #include "safe-ctype.h"
26 #include "opcode/sparc.h"
27 #include "dw2gencfi.h"
30 #include "elf/sparc.h"
31 #include "dwarf2dbg.h"
34 /* Some ancient Sun C compilers would not take such hex constants as
35 unsigned, and would end up sign-extending them to form an offsetT,
36 so use these constants instead. */
37 #define U0xffffffff ((((unsigned long) 1 << 16) << 16) - 1)
38 #define U0x80000000 ((((unsigned long) 1 << 16) << 15))
40 static int sparc_ip (char *, const struct sparc_opcode
**);
41 static int parse_keyword_arg (int (*) (const char *), char **, int *);
42 static int parse_const_expr_arg (char **, int *);
43 static int get_expression (char *);
45 /* Default architecture. */
46 /* ??? The default value should be V8, but sparclite support was added
47 by making it the default. GCC now passes -Asparclite, so maybe sometime in
48 the future we can set this to V8. */
50 #define DEFAULT_ARCH "sparclite"
52 static char *default_arch
= DEFAULT_ARCH
;
54 /* Non-zero if the initial values of `max_architecture' and `sparc_arch_size'
56 static int default_init_p
;
58 /* Current architecture. We don't bump up unless necessary. */
59 static enum sparc_opcode_arch_val current_architecture
= SPARC_OPCODE_ARCH_V6
;
61 /* The maximum architecture level we can bump up to.
62 In a 32 bit environment, don't allow bumping up to v9 by default.
63 The native assembler works this way. The user is required to pass
64 an explicit argument before we'll create v9 object files. However, if
65 we don't see any v9 insns, a v8plus object file is not created. */
66 static enum sparc_opcode_arch_val max_architecture
;
68 /* Either 32 or 64, selects file format. */
69 static int sparc_arch_size
;
70 /* Initial (default) value, recorded separately in case a user option
71 changes the value before md_show_usage is called. */
72 static int default_arch_size
;
75 /* The currently selected v9 memory model. Currently only used for
77 static enum { MM_TSO
, MM_PSO
, MM_RMO
} sparc_memory_model
= MM_RMO
;
80 static int architecture_requested
;
81 static int warn_on_bump
;
83 /* If warn_on_bump and the needed architecture is higher than this
84 architecture, issue a warning. */
85 static enum sparc_opcode_arch_val warn_after_architecture
;
87 /* Non-zero if as should generate error if an undeclared g[23] register
88 has been used in -64. */
89 static int no_undeclared_regs
;
91 /* Non-zero if we should try to relax jumps and calls. */
92 static int sparc_relax
;
94 /* Non-zero if we are generating PIC code. */
97 /* Non-zero if we should give an error when misaligned data is seen. */
98 static int enforce_aligned_data
;
100 extern int target_big_endian
;
102 static int target_little_endian_data
;
104 /* Symbols for global registers on v9. */
105 static symbolS
*globals
[8];
107 /* The dwarf2 data alignment, adjusted for 32 or 64 bit. */
108 int sparc_cie_data_alignment
;
110 /* V9 and 86x have big and little endian data, but instructions are always big
111 endian. The sparclet has bi-endian support but both data and insns have
112 the same endianness. Global `target_big_endian' is used for data.
113 The following macro is used for instructions. */
114 #ifndef INSN_BIG_ENDIAN
115 #define INSN_BIG_ENDIAN (target_big_endian \
116 || default_arch_type == sparc86x \
117 || SPARC_OPCODE_ARCH_V9_P (max_architecture))
120 /* Handle of the OPCODE hash table. */
121 static struct hash_control
*op_hash
;
123 static void s_data1 (void);
124 static void s_seg (int);
125 static void s_proc (int);
126 static void s_reserve (int);
127 static void s_common (int);
128 static void s_empty (int);
129 static void s_uacons (int);
130 static void s_ncons (int);
132 static void s_register (int);
135 const pseudo_typeS md_pseudo_table
[] =
137 {"align", s_align_bytes
, 0}, /* Defaulting is invalid (0). */
138 {"common", s_common
, 0},
139 {"empty", s_empty
, 0},
140 {"global", s_globl
, 0},
142 {"nword", s_ncons
, 0},
143 {"optim", s_ignore
, 0},
145 {"reserve", s_reserve
, 0},
147 {"skip", s_space
, 0},
150 {"uahalf", s_uacons
, 2},
151 {"uaword", s_uacons
, 4},
152 {"uaxword", s_uacons
, 8},
154 /* These are specific to sparc/svr4. */
155 {"2byte", s_uacons
, 2},
156 {"4byte", s_uacons
, 4},
157 {"8byte", s_uacons
, 8},
158 {"register", s_register
, 0},
163 /* This array holds the chars that always start a comment. If the
164 pre-processor is disabled, these aren't very useful. */
165 const char comment_chars
[] = "!"; /* JF removed '|' from
168 /* This array holds the chars that only start a comment at the beginning of
169 a line. If the line seems to have the form '# 123 filename'
170 .line and .file directives will appear in the pre-processed output. */
171 /* Note that input_file.c hand checks for '#' at the beginning of the
172 first line of the input file. This is because the compiler outputs
173 #NO_APP at the beginning of its output. */
174 /* Also note that comments started like this one will always
175 work if '/' isn't otherwise defined. */
176 const char line_comment_chars
[] = "#";
178 const char line_separator_chars
[] = ";";
180 /* Chars that can be used to separate mant from exp in floating point
182 const char EXP_CHARS
[] = "eE";
184 /* Chars that mean this number is a floating point constant.
187 const char FLT_CHARS
[] = "rRsSfFdDxXpP";
189 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
190 changed in read.c. Ideally it shouldn't have to know about it at all,
191 but nothing is ideal around here. */
193 #define isoctal(c) ((unsigned) ((c) - '0') < 8)
198 unsigned long opcode
;
199 struct nlist
*nlistp
;
203 bfd_reloc_code_real_type reloc
;
206 struct sparc_it the_insn
, set_insn
;
208 static void output_insn (const struct sparc_opcode
*, struct sparc_it
*);
210 /* Table of arguments to -A.
211 The sparc_opcode_arch table in sparc-opc.c is insufficient and incorrect
212 for this use. That table is for opcodes only. This table is for opcodes
215 enum sparc_arch_types
{v6
, v7
, v8
, sparclet
, sparclite
, sparc86x
, v8plus
,
216 v8plusa
, v9
, v9a
, v9b
, v9_64
};
218 static struct sparc_arch
{
221 enum sparc_arch_types arch_type
;
222 /* Default word size, as specified during configuration.
223 A value of zero means can't be used to specify default architecture. */
224 int default_arch_size
;
225 /* Allowable arg to -A? */
227 } sparc_arch_table
[] = {
228 { "v6", "v6", v6
, 0, 1 },
229 { "v7", "v7", v7
, 0, 1 },
230 { "v8", "v8", v8
, 32, 1 },
231 { "sparclet", "sparclet", sparclet
, 32, 1 },
232 { "sparclite", "sparclite", sparclite
, 32, 1 },
233 { "sparc86x", "sparclite", sparc86x
, 32, 1 },
234 { "v8plus", "v9", v9
, 0, 1 },
235 { "v8plusa", "v9a", v9
, 0, 1 },
236 { "v8plusb", "v9b", v9
, 0, 1 },
237 { "v9", "v9", v9
, 0, 1 },
238 { "v9a", "v9a", v9
, 0, 1 },
239 { "v9b", "v9b", v9
, 0, 1 },
240 /* This exists to allow configure.in/Makefile.in to pass one
241 value to specify both the default machine and default word size. */
242 { "v9-64", "v9", v9
, 64, 0 },
243 { NULL
, NULL
, v8
, 0, 0 }
246 /* Variant of default_arch */
247 static enum sparc_arch_types default_arch_type
;
249 static struct sparc_arch
*
250 lookup_arch (char *name
)
252 struct sparc_arch
*sa
;
254 for (sa
= &sparc_arch_table
[0]; sa
->name
!= NULL
; sa
++)
255 if (strcmp (sa
->name
, name
) == 0)
257 if (sa
->name
== NULL
)
262 /* Initialize the default opcode arch and word size from the default
263 architecture name. */
266 init_default_arch (void)
268 struct sparc_arch
*sa
= lookup_arch (default_arch
);
271 || sa
->default_arch_size
== 0)
272 as_fatal (_("Invalid default architecture, broken assembler."));
274 max_architecture
= sparc_opcode_lookup_arch (sa
->opcode_arch
);
275 if (max_architecture
== SPARC_OPCODE_ARCH_BAD
)
276 as_fatal (_("Bad opcode table, broken assembler."));
277 default_arch_size
= sparc_arch_size
= sa
->default_arch_size
;
279 default_arch_type
= sa
->arch_type
;
282 /* Called by TARGET_FORMAT. */
285 sparc_target_format (void)
287 /* We don't get a chance to initialize anything before we're called,
288 so handle that now. */
289 if (! default_init_p
)
290 init_default_arch ();
294 return "a.out-sparc-netbsd";
297 if (target_big_endian
)
298 return "a.out-sunos-big";
299 else if (default_arch_type
== sparc86x
&& target_little_endian_data
)
300 return "a.out-sunos-big";
302 return "a.out-sparc-little";
304 return "a.out-sunos-big";
315 return "coff-sparc-lynx";
322 return "elf32-sparc-vxworks";
326 return sparc_arch_size
== 64 ? ELF64_TARGET_FORMAT
: ELF_TARGET_FORMAT
;
333 * Invocation line includes a switch not recognized by the base assembler.
334 * See if it's a processor-specific option. These are:
337 * Warn on architecture bumps. See also -A.
339 * -Av6, -Av7, -Av8, -Asparclite, -Asparclet
340 * Standard 32 bit architectures.
342 * Sparc64 in either a 32 or 64 bit world (-32/-64 says which).
343 * This used to only mean 64 bits, but properly specifying it
344 * complicated gcc's ASM_SPECs, so now opcode selection is
345 * specified orthogonally to word size (except when specifying
346 * the default, but that is an internal implementation detail).
347 * -Av8plus, -Av8plusa, -Av8plusb
348 * Same as -Av9{,a,b}.
349 * -xarch=v8plus, -xarch=v8plusa, -xarch=v8plusb
350 * Same as -Av8plus{,a,b} -32, for compatibility with Sun's
352 * -xarch=v9, -xarch=v9a, -xarch=v9b
353 * Same as -Av9{,a,b} -64, for compatibility with Sun's
356 * Select the architecture and possibly the file format.
357 * Instructions or features not supported by the selected
358 * architecture cause fatal errors.
360 * The default is to start at v6, and bump the architecture up
361 * whenever an instruction is seen at a higher level. In 32 bit
362 * environments, v9 is not bumped up to, the user must pass
365 * If -bump is specified, a warning is printing when bumping to
368 * If an architecture is specified, all instructions must match
369 * that architecture. Any higher level instructions are flagged
370 * as errors. Note that in the 32 bit environment specifying
371 * -Av8plus does not automatically create a v8plus object file, a
372 * v9 insn must be seen.
374 * If both an architecture and -bump are specified, the
375 * architecture starts at the specified level, but bumps are
376 * warnings. Note that we can't set `current_architecture' to
377 * the requested level in this case: in the 32 bit environment,
378 * we still must avoid creating v8plus object files unless v9
382 * Bumping between incompatible architectures is always an
383 * error. For example, from sparclite to v9.
387 const char *md_shortopts
= "A:K:VQ:sq";
390 const char *md_shortopts
= "A:k";
392 const char *md_shortopts
= "A:";
395 struct option md_longopts
[] = {
396 #define OPTION_BUMP (OPTION_MD_BASE)
397 {"bump", no_argument
, NULL
, OPTION_BUMP
},
398 #define OPTION_SPARC (OPTION_MD_BASE + 1)
399 {"sparc", no_argument
, NULL
, OPTION_SPARC
},
400 #define OPTION_XARCH (OPTION_MD_BASE + 2)
401 {"xarch", required_argument
, NULL
, OPTION_XARCH
},
403 #define OPTION_32 (OPTION_MD_BASE + 3)
404 {"32", no_argument
, NULL
, OPTION_32
},
405 #define OPTION_64 (OPTION_MD_BASE + 4)
406 {"64", no_argument
, NULL
, OPTION_64
},
407 #define OPTION_TSO (OPTION_MD_BASE + 5)
408 {"TSO", no_argument
, NULL
, OPTION_TSO
},
409 #define OPTION_PSO (OPTION_MD_BASE + 6)
410 {"PSO", no_argument
, NULL
, OPTION_PSO
},
411 #define OPTION_RMO (OPTION_MD_BASE + 7)
412 {"RMO", no_argument
, NULL
, OPTION_RMO
},
414 #ifdef SPARC_BIENDIAN
415 #define OPTION_LITTLE_ENDIAN (OPTION_MD_BASE + 8)
416 {"EL", no_argument
, NULL
, OPTION_LITTLE_ENDIAN
},
417 #define OPTION_BIG_ENDIAN (OPTION_MD_BASE + 9)
418 {"EB", no_argument
, NULL
, OPTION_BIG_ENDIAN
},
420 #define OPTION_ENFORCE_ALIGNED_DATA (OPTION_MD_BASE + 10)
421 {"enforce-aligned-data", no_argument
, NULL
, OPTION_ENFORCE_ALIGNED_DATA
},
422 #define OPTION_LITTLE_ENDIAN_DATA (OPTION_MD_BASE + 11)
423 {"little-endian-data", no_argument
, NULL
, OPTION_LITTLE_ENDIAN_DATA
},
425 #define OPTION_NO_UNDECLARED_REGS (OPTION_MD_BASE + 12)
426 {"no-undeclared-regs", no_argument
, NULL
, OPTION_NO_UNDECLARED_REGS
},
427 #define OPTION_UNDECLARED_REGS (OPTION_MD_BASE + 13)
428 {"undeclared-regs", no_argument
, NULL
, OPTION_UNDECLARED_REGS
},
430 #define OPTION_RELAX (OPTION_MD_BASE + 14)
431 {"relax", no_argument
, NULL
, OPTION_RELAX
},
432 #define OPTION_NO_RELAX (OPTION_MD_BASE + 15)
433 {"no-relax", no_argument
, NULL
, OPTION_NO_RELAX
},
434 {NULL
, no_argument
, NULL
, 0}
437 size_t md_longopts_size
= sizeof (md_longopts
);
440 md_parse_option (int c
, char *arg
)
442 /* We don't get a chance to initialize anything before we're called,
443 so handle that now. */
444 if (! default_init_p
)
445 init_default_arch ();
451 warn_after_architecture
= SPARC_OPCODE_ARCH_V6
;
456 if (strncmp (arg
, "v9", 2) != 0)
457 md_parse_option (OPTION_32
, NULL
);
459 md_parse_option (OPTION_64
, NULL
);
465 struct sparc_arch
*sa
;
466 enum sparc_opcode_arch_val opcode_arch
;
468 sa
= lookup_arch (arg
);
470 || ! sa
->user_option_p
)
472 if (c
== OPTION_XARCH
)
473 as_bad (_("invalid architecture -xarch=%s"), arg
);
475 as_bad (_("invalid architecture -A%s"), arg
);
479 opcode_arch
= sparc_opcode_lookup_arch (sa
->opcode_arch
);
480 if (opcode_arch
== SPARC_OPCODE_ARCH_BAD
)
481 as_fatal (_("Bad opcode table, broken assembler."));
483 max_architecture
= opcode_arch
;
484 architecture_requested
= 1;
489 /* Ignore -sparc, used by SunOS make default .s.o rule. */
492 case OPTION_ENFORCE_ALIGNED_DATA
:
493 enforce_aligned_data
= 1;
496 #ifdef SPARC_BIENDIAN
497 case OPTION_LITTLE_ENDIAN
:
498 target_big_endian
= 0;
499 if (default_arch_type
!= sparclet
)
500 as_fatal ("This target does not support -EL");
502 case OPTION_LITTLE_ENDIAN_DATA
:
503 target_little_endian_data
= 1;
504 target_big_endian
= 0;
505 if (default_arch_type
!= sparc86x
506 && default_arch_type
!= v9
)
507 as_fatal ("This target does not support --little-endian-data");
509 case OPTION_BIG_ENDIAN
:
510 target_big_endian
= 1;
524 const char **list
, **l
;
526 sparc_arch_size
= c
== OPTION_32
? 32 : 64;
527 list
= bfd_target_list ();
528 for (l
= list
; *l
!= NULL
; l
++)
530 if (sparc_arch_size
== 32)
532 if (CONST_STRNEQ (*l
, "elf32-sparc"))
537 if (CONST_STRNEQ (*l
, "elf64-sparc"))
542 as_fatal (_("No compiled in support for %d bit object file format"),
549 sparc_memory_model
= MM_TSO
;
553 sparc_memory_model
= MM_PSO
;
557 sparc_memory_model
= MM_RMO
;
565 /* Qy - do emit .comment
566 Qn - do not emit .comment. */
570 /* Use .stab instead of .stab.excl. */
574 /* quick -- Native assembler does fewer checks. */
578 if (strcmp (arg
, "PIC") != 0)
579 as_warn (_("Unrecognized option following -K"));
584 case OPTION_NO_UNDECLARED_REGS
:
585 no_undeclared_regs
= 1;
588 case OPTION_UNDECLARED_REGS
:
589 no_undeclared_regs
= 0;
597 case OPTION_NO_RELAX
:
609 md_show_usage (FILE *stream
)
611 const struct sparc_arch
*arch
;
614 /* We don't get a chance to initialize anything before we're called,
615 so handle that now. */
616 if (! default_init_p
)
617 init_default_arch ();
619 fprintf (stream
, _("SPARC options:\n"));
621 for (arch
= &sparc_arch_table
[0]; arch
->name
; arch
++)
623 if (!arch
->user_option_p
)
625 if (arch
!= &sparc_arch_table
[0])
626 fprintf (stream
, " | ");
627 if (column
+ strlen (arch
->name
) > 70)
630 fputc ('\n', stream
);
632 column
+= 5 + 2 + strlen (arch
->name
);
633 fprintf (stream
, "-A%s", arch
->name
);
635 for (arch
= &sparc_arch_table
[0]; arch
->name
; arch
++)
637 if (!arch
->user_option_p
)
639 fprintf (stream
, " | ");
640 if (column
+ strlen (arch
->name
) > 65)
643 fputc ('\n', stream
);
645 column
+= 5 + 7 + strlen (arch
->name
);
646 fprintf (stream
, "-xarch=%s", arch
->name
);
648 fprintf (stream
, _("\n\
649 specify variant of SPARC architecture\n\
650 -bump warn when assembler switches architectures\n\
652 --enforce-aligned-data force .long, etc., to be aligned correctly\n\
653 -relax relax jumps and branches (default)\n\
654 -no-relax avoid changing any jumps and branches\n"));
656 fprintf (stream
, _("\
657 -k generate PIC\n"));
660 fprintf (stream
, _("\
661 -32 create 32 bit object file\n\
662 -64 create 64 bit object file\n"));
663 fprintf (stream
, _("\
664 [default is %d]\n"), default_arch_size
);
665 fprintf (stream
, _("\
666 -TSO use Total Store Ordering\n\
667 -PSO use Partial Store Ordering\n\
668 -RMO use Relaxed Memory Ordering\n"));
669 fprintf (stream
, _("\
670 [default is %s]\n"), (default_arch_size
== 64) ? "RMO" : "TSO");
671 fprintf (stream
, _("\
672 -KPIC generate PIC\n\
673 -V print assembler version number\n\
674 -undeclared-regs ignore application global register usage without\n\
675 appropriate .register directive (default)\n\
676 -no-undeclared-regs force error on application global register usage\n\
677 without appropriate .register directive\n\
682 #ifdef SPARC_BIENDIAN
683 fprintf (stream
, _("\
684 -EL generate code for a little endian machine\n\
685 -EB generate code for a big endian machine\n\
686 --little-endian-data generate code for a machine having big endian\n\
687 instructions and little endian data.\n"));
691 /* Native operand size opcode translation. */
697 } native_op_table
[] =
699 {"ldn", "ld", "ldx"},
700 {"ldna", "lda", "ldxa"},
701 {"stn", "st", "stx"},
702 {"stna", "sta", "stxa"},
703 {"slln", "sll", "sllx"},
704 {"srln", "srl", "srlx"},
705 {"sran", "sra", "srax"},
706 {"casn", "cas", "casx"},
707 {"casna", "casa", "casxa"},
708 {"clrn", "clr", "clrx"},
712 /* sparc64 privileged and hyperprivileged registers. */
714 struct priv_reg_entry
720 struct priv_reg_entry priv_reg_table
[] =
740 {"", -1}, /* End marker. */
743 struct priv_reg_entry hpriv_reg_table
[] =
751 {"", -1}, /* End marker. */
754 /* v9a specific asrs. This table is ordered by initial
755 letter, in reverse. */
757 struct priv_reg_entry v9a_asr_table
[] =
760 {"sys_tick_cmpr", 25},
764 {"softint_clear", 21},
772 {"clear_softint", 21},
773 {"", -1}, /* End marker. */
777 cmp_reg_entry (const void *parg
, const void *qarg
)
779 const struct priv_reg_entry
*p
= (const struct priv_reg_entry
*) parg
;
780 const struct priv_reg_entry
*q
= (const struct priv_reg_entry
*) qarg
;
782 return strcmp (q
->name
, p
->name
);
785 /* This function is called once, at assembler startup time. It should
786 set up all the tables, etc. that the MD part of the assembler will
792 register const char *retval
= NULL
;
794 register unsigned int i
= 0;
796 /* We don't get a chance to initialize anything before md_parse_option
797 is called, and it may not be called, so handle default initialization
798 now if not already done. */
799 if (! default_init_p
)
800 init_default_arch ();
802 sparc_cie_data_alignment
= sparc_arch_size
== 64 ? -8 : -4;
803 op_hash
= hash_new ();
805 while (i
< (unsigned int) sparc_num_opcodes
)
807 const char *name
= sparc_opcodes
[i
].name
;
808 retval
= hash_insert (op_hash
, name
, (void *) &sparc_opcodes
[i
]);
811 as_bad (_("Internal error: can't hash `%s': %s\n"),
812 sparc_opcodes
[i
].name
, retval
);
817 if (sparc_opcodes
[i
].match
& sparc_opcodes
[i
].lose
)
819 as_bad (_("Internal error: losing opcode: `%s' \"%s\"\n"),
820 sparc_opcodes
[i
].name
, sparc_opcodes
[i
].args
);
825 while (i
< (unsigned int) sparc_num_opcodes
826 && !strcmp (sparc_opcodes
[i
].name
, name
));
829 for (i
= 0; native_op_table
[i
].name
; i
++)
831 const struct sparc_opcode
*insn
;
832 char *name
= ((sparc_arch_size
== 32)
833 ? native_op_table
[i
].name32
834 : native_op_table
[i
].name64
);
835 insn
= (struct sparc_opcode
*) hash_find (op_hash
, name
);
838 as_bad (_("Internal error: can't find opcode `%s' for `%s'\n"),
839 name
, native_op_table
[i
].name
);
844 retval
= hash_insert (op_hash
, native_op_table
[i
].name
,
848 as_bad (_("Internal error: can't hash `%s': %s\n"),
849 sparc_opcodes
[i
].name
, retval
);
856 as_fatal (_("Broken assembler. No assembly attempted."));
858 qsort (priv_reg_table
, sizeof (priv_reg_table
) / sizeof (priv_reg_table
[0]),
859 sizeof (priv_reg_table
[0]), cmp_reg_entry
);
861 /* If -bump, record the architecture level at which we start issuing
862 warnings. The behaviour is different depending upon whether an
863 architecture was explicitly specified. If it wasn't, we issue warnings
864 for all upwards bumps. If it was, we don't start issuing warnings until
865 we need to bump beyond the requested architecture or when we bump between
866 conflicting architectures. */
869 && architecture_requested
)
871 /* `max_architecture' records the requested architecture.
872 Issue warnings if we go above it. */
873 warn_after_architecture
= max_architecture
;
875 /* Find the highest architecture level that doesn't conflict with
876 the requested one. */
877 for (max_architecture
= SPARC_OPCODE_ARCH_MAX
;
878 max_architecture
> warn_after_architecture
;
880 if (! SPARC_OPCODE_CONFLICT_P (max_architecture
,
881 warn_after_architecture
))
886 /* Called after all assembly has been done. */
891 unsigned long mach
= bfd_mach_sparc
;
893 if (sparc_arch_size
== 64)
894 switch (current_architecture
)
896 case SPARC_OPCODE_ARCH_V9A
: mach
= bfd_mach_sparc_v9a
; break;
897 case SPARC_OPCODE_ARCH_V9B
: mach
= bfd_mach_sparc_v9b
; break;
898 default: mach
= bfd_mach_sparc_v9
; break;
901 switch (current_architecture
)
903 case SPARC_OPCODE_ARCH_SPARCLET
: mach
= bfd_mach_sparc_sparclet
; break;
904 case SPARC_OPCODE_ARCH_V9
: mach
= bfd_mach_sparc_v8plus
; break;
905 case SPARC_OPCODE_ARCH_V9A
: mach
= bfd_mach_sparc_v8plusa
; break;
906 case SPARC_OPCODE_ARCH_V9B
: mach
= bfd_mach_sparc_v8plusb
; break;
907 /* The sparclite is treated like a normal sparc. Perhaps it shouldn't
908 be but for now it is (since that's the way it's always been
912 bfd_set_arch_mach (stdoutput
, bfd_arch_sparc
, mach
);
915 /* Return non-zero if VAL is in the range -(MAX+1) to MAX. */
918 in_signed_range (bfd_signed_vma val
, bfd_signed_vma max
)
922 /* Sign-extend the value from the architecture word size, so that
923 0xffffffff is always considered -1 on sparc32. */
924 if (sparc_arch_size
== 32)
926 bfd_signed_vma sign
= (bfd_signed_vma
) 1 << 31;
927 val
= ((val
& U0xffffffff
) ^ sign
) - sign
;
936 /* Return non-zero if VAL is in the range 0 to MAX. */
939 in_unsigned_range (bfd_vma val
, bfd_vma max
)
946 /* Return non-zero if VAL is in the range -(MAX/2+1) to MAX.
947 (e.g. -15 to +31). */
950 in_bitfield_range (bfd_signed_vma val
, bfd_signed_vma max
)
956 if (val
< ~(max
>> 1))
962 sparc_ffs (unsigned int mask
)
969 for (i
= 0; (mask
& 1) == 0; ++i
)
974 /* Implement big shift right. */
976 BSR (bfd_vma val
, int amount
)
978 if (sizeof (bfd_vma
) <= 4 && amount
>= 32)
979 as_fatal (_("Support for 64-bit arithmetic not compiled in."));
980 return val
>> amount
;
983 /* For communication between sparc_ip and get_expression. */
984 static char *expr_end
;
986 /* Values for `special_case'.
987 Instructions that require wierd handling because they're longer than
989 #define SPECIAL_CASE_NONE 0
990 #define SPECIAL_CASE_SET 1
991 #define SPECIAL_CASE_SETSW 2
992 #define SPECIAL_CASE_SETX 3
993 /* FIXME: sparc-opc.c doesn't have necessary "S" trigger to enable this. */
994 #define SPECIAL_CASE_FDIV 4
996 /* Bit masks of various insns. */
997 #define NOP_INSN 0x01000000
998 #define OR_INSN 0x80100000
999 #define XOR_INSN 0x80180000
1000 #define FMOVS_INSN 0x81A00020
1001 #define SETHI_INSN 0x01000000
1002 #define SLLX_INSN 0x81281000
1003 #define SRA_INSN 0x81380000
1005 /* The last instruction to be assembled. */
1006 static const struct sparc_opcode
*last_insn
;
1007 /* The assembled opcode of `last_insn'. */
1008 static unsigned long last_opcode
;
1010 /* Handle the set and setuw synthetic instructions. */
1013 synthetize_setuw (const struct sparc_opcode
*insn
)
1015 int need_hi22_p
= 0;
1016 int rd
= (the_insn
.opcode
& RD (~0)) >> 25;
1018 if (the_insn
.exp
.X_op
== O_constant
)
1020 if (SPARC_OPCODE_ARCH_V9_P (max_architecture
))
1022 if (sizeof (offsetT
) > 4
1023 && (the_insn
.exp
.X_add_number
< 0
1024 || the_insn
.exp
.X_add_number
> (offsetT
) U0xffffffff
))
1025 as_warn (_("set: number not in 0..4294967295 range"));
1029 if (sizeof (offsetT
) > 4
1030 && (the_insn
.exp
.X_add_number
< -(offsetT
) U0x80000000
1031 || the_insn
.exp
.X_add_number
> (offsetT
) U0xffffffff
))
1032 as_warn (_("set: number not in -2147483648..4294967295 range"));
1033 the_insn
.exp
.X_add_number
= (int) the_insn
.exp
.X_add_number
;
1037 /* See if operand is absolute and small; skip sethi if so. */
1038 if (the_insn
.exp
.X_op
!= O_constant
1039 || the_insn
.exp
.X_add_number
>= (1 << 12)
1040 || the_insn
.exp
.X_add_number
< -(1 << 12))
1042 the_insn
.opcode
= (SETHI_INSN
| RD (rd
)
1043 | ((the_insn
.exp
.X_add_number
>> 10)
1044 & (the_insn
.exp
.X_op
== O_constant
1046 the_insn
.reloc
= (the_insn
.exp
.X_op
!= O_constant
1047 ? BFD_RELOC_HI22
: BFD_RELOC_NONE
);
1048 output_insn (insn
, &the_insn
);
1052 /* See if operand has no low-order bits; skip OR if so. */
1053 if (the_insn
.exp
.X_op
!= O_constant
1054 || (need_hi22_p
&& (the_insn
.exp
.X_add_number
& 0x3FF) != 0)
1057 the_insn
.opcode
= (OR_INSN
| (need_hi22_p
? RS1 (rd
) : 0)
1059 | (the_insn
.exp
.X_add_number
1060 & (the_insn
.exp
.X_op
!= O_constant
1061 ? 0 : need_hi22_p
? 0x3ff : 0x1fff)));
1062 the_insn
.reloc
= (the_insn
.exp
.X_op
!= O_constant
1063 ? BFD_RELOC_LO10
: BFD_RELOC_NONE
);
1064 output_insn (insn
, &the_insn
);
1068 /* Handle the setsw synthetic instruction. */
1071 synthetize_setsw (const struct sparc_opcode
*insn
)
1075 rd
= (the_insn
.opcode
& RD (~0)) >> 25;
1077 if (the_insn
.exp
.X_op
!= O_constant
)
1079 synthetize_setuw (insn
);
1081 /* Need to sign extend it. */
1082 the_insn
.opcode
= (SRA_INSN
| RS1 (rd
) | RD (rd
));
1083 the_insn
.reloc
= BFD_RELOC_NONE
;
1084 output_insn (insn
, &the_insn
);
1088 if (sizeof (offsetT
) > 4
1089 && (the_insn
.exp
.X_add_number
< -(offsetT
) U0x80000000
1090 || the_insn
.exp
.X_add_number
> (offsetT
) U0xffffffff
))
1091 as_warn (_("setsw: number not in -2147483648..4294967295 range"));
1093 low32
= the_insn
.exp
.X_add_number
;
1097 synthetize_setuw (insn
);
1103 the_insn
.reloc
= BFD_RELOC_NONE
;
1104 /* See if operand is absolute and small; skip sethi if so. */
1105 if (low32
< -(1 << 12))
1107 the_insn
.opcode
= (SETHI_INSN
| RD (rd
)
1108 | (((~the_insn
.exp
.X_add_number
) >> 10) & 0x3fffff));
1109 output_insn (insn
, &the_insn
);
1110 low32
= 0x1c00 | (low32
& 0x3ff);
1111 opc
= RS1 (rd
) | XOR_INSN
;
1114 the_insn
.opcode
= (opc
| RD (rd
) | IMMED
1115 | (low32
& 0x1fff));
1116 output_insn (insn
, &the_insn
);
1119 /* Handle the setsw synthetic instruction. */
1122 synthetize_setx (const struct sparc_opcode
*insn
)
1124 int upper32
, lower32
;
1125 int tmpreg
= (the_insn
.opcode
& RS1 (~0)) >> 14;
1126 int dstreg
= (the_insn
.opcode
& RD (~0)) >> 25;
1128 int need_hh22_p
= 0, need_hm10_p
= 0, need_hi22_p
= 0, need_lo10_p
= 0;
1129 int need_xor10_p
= 0;
1131 #define SIGNEXT32(x) ((((x) & U0xffffffff) ^ U0x80000000) - U0x80000000)
1132 lower32
= SIGNEXT32 (the_insn
.exp
.X_add_number
);
1133 upper32
= SIGNEXT32 (BSR (the_insn
.exp
.X_add_number
, 32));
1136 upper_dstreg
= tmpreg
;
1137 /* The tmp reg should not be the dst reg. */
1138 if (tmpreg
== dstreg
)
1139 as_warn (_("setx: temporary register same as destination register"));
1141 /* ??? Obviously there are other optimizations we can do
1142 (e.g. sethi+shift for 0x1f0000000) and perhaps we shouldn't be
1143 doing some of these. Later. If you do change things, try to
1144 change all of this to be table driven as well. */
1145 /* What to output depends on the number if it's constant.
1146 Compute that first, then output what we've decided upon. */
1147 if (the_insn
.exp
.X_op
!= O_constant
)
1149 if (sparc_arch_size
== 32)
1151 /* When arch size is 32, we want setx to be equivalent
1152 to setuw for anything but constants. */
1153 the_insn
.exp
.X_add_number
&= 0xffffffff;
1154 synthetize_setuw (insn
);
1157 need_hh22_p
= need_hm10_p
= need_hi22_p
= need_lo10_p
= 1;
1163 /* Reset X_add_number, we've extracted it as upper32/lower32.
1164 Otherwise fixup_segment will complain about not being able to
1165 write an 8 byte number in a 4 byte field. */
1166 the_insn
.exp
.X_add_number
= 0;
1168 /* Only need hh22 if `or' insn can't handle constant. */
1169 if (upper32
< -(1 << 12) || upper32
>= (1 << 12))
1172 /* Does bottom part (after sethi) have bits? */
1173 if ((need_hh22_p
&& (upper32
& 0x3ff) != 0)
1174 /* No hh22, but does upper32 still have bits we can't set
1176 || (! need_hh22_p
&& upper32
!= 0 && upper32
!= -1))
1179 /* If the lower half is all zero, we build the upper half directly
1180 into the dst reg. */
1182 /* Need lower half if number is zero or 0xffffffff00000000. */
1183 || (! need_hh22_p
&& ! need_hm10_p
))
1185 /* No need for sethi if `or' insn can handle constant. */
1186 if (lower32
< -(1 << 12) || lower32
>= (1 << 12)
1187 /* Note that we can't use a negative constant in the `or'
1188 insn unless the upper 32 bits are all ones. */
1189 || (lower32
< 0 && upper32
!= -1)
1190 || (lower32
>= 0 && upper32
== -1))
1193 if (need_hi22_p
&& upper32
== -1)
1196 /* Does bottom part (after sethi) have bits? */
1197 else if ((need_hi22_p
&& (lower32
& 0x3ff) != 0)
1199 || (! need_hi22_p
&& (lower32
& 0x1fff) != 0)
1200 /* Need `or' if we didn't set anything else. */
1201 || (! need_hi22_p
&& ! need_hh22_p
&& ! need_hm10_p
))
1205 /* Output directly to dst reg if lower 32 bits are all zero. */
1206 upper_dstreg
= dstreg
;
1209 if (!upper_dstreg
&& dstreg
)
1210 as_warn (_("setx: illegal temporary register g0"));
1214 the_insn
.opcode
= (SETHI_INSN
| RD (upper_dstreg
)
1215 | ((upper32
>> 10) & 0x3fffff));
1216 the_insn
.reloc
= (the_insn
.exp
.X_op
!= O_constant
1217 ? BFD_RELOC_SPARC_HH22
: BFD_RELOC_NONE
);
1218 output_insn (insn
, &the_insn
);
1223 the_insn
.opcode
= (SETHI_INSN
| RD (dstreg
)
1224 | (((need_xor10_p
? ~lower32
: lower32
)
1225 >> 10) & 0x3fffff));
1226 the_insn
.reloc
= (the_insn
.exp
.X_op
!= O_constant
1227 ? BFD_RELOC_SPARC_LM22
: BFD_RELOC_NONE
);
1228 output_insn (insn
, &the_insn
);
1233 the_insn
.opcode
= (OR_INSN
1234 | (need_hh22_p
? RS1 (upper_dstreg
) : 0)
1237 | (upper32
& (need_hh22_p
? 0x3ff : 0x1fff)));
1238 the_insn
.reloc
= (the_insn
.exp
.X_op
!= O_constant
1239 ? BFD_RELOC_SPARC_HM10
: BFD_RELOC_NONE
);
1240 output_insn (insn
, &the_insn
);
1245 /* FIXME: One nice optimization to do here is to OR the low part
1246 with the highpart if hi22 isn't needed and the low part is
1248 the_insn
.opcode
= (OR_INSN
| (need_hi22_p
? RS1 (dstreg
) : 0)
1251 | (lower32
& (need_hi22_p
? 0x3ff : 0x1fff)));
1252 the_insn
.reloc
= (the_insn
.exp
.X_op
!= O_constant
1253 ? BFD_RELOC_LO10
: BFD_RELOC_NONE
);
1254 output_insn (insn
, &the_insn
);
1257 /* If we needed to build the upper part, shift it into place. */
1258 if (need_hh22_p
|| need_hm10_p
)
1260 the_insn
.opcode
= (SLLX_INSN
| RS1 (upper_dstreg
) | RD (upper_dstreg
)
1262 the_insn
.reloc
= BFD_RELOC_NONE
;
1263 output_insn (insn
, &the_insn
);
1266 /* To get -1 in upper32, we do sethi %hi(~x), r; xor r, -0x400 | x, r. */
1269 the_insn
.opcode
= (XOR_INSN
| RS1 (dstreg
) | RD (dstreg
) | IMMED
1270 | 0x1c00 | (lower32
& 0x3ff));
1271 the_insn
.reloc
= BFD_RELOC_NONE
;
1272 output_insn (insn
, &the_insn
);
1275 /* If we needed to build both upper and lower parts, OR them together. */
1276 else if ((need_hh22_p
|| need_hm10_p
) && (need_hi22_p
|| need_lo10_p
))
1278 the_insn
.opcode
= (OR_INSN
| RS1 (dstreg
) | RS2 (upper_dstreg
)
1280 the_insn
.reloc
= BFD_RELOC_NONE
;
1281 output_insn (insn
, &the_insn
);
1285 /* Main entry point to assemble one instruction. */
1288 md_assemble (char *str
)
1290 const struct sparc_opcode
*insn
;
1294 special_case
= sparc_ip (str
, &insn
);
1298 /* We warn about attempts to put a floating point branch in a delay slot,
1299 unless the delay slot has been annulled. */
1300 if (last_insn
!= NULL
1301 && (insn
->flags
& F_FBR
) != 0
1302 && (last_insn
->flags
& F_DELAYED
) != 0
1303 /* ??? This test isn't completely accurate. We assume anything with
1304 F_{UNBR,CONDBR,FBR} set is annullable. */
1305 && ((last_insn
->flags
& (F_UNBR
| F_CONDBR
| F_FBR
)) == 0
1306 || (last_opcode
& ANNUL
) == 0))
1307 as_warn (_("FP branch in delay slot"));
1309 /* SPARC before v9 requires a nop instruction between a floating
1310 point instruction and a floating point branch. We insert one
1311 automatically, with a warning. */
1312 if (max_architecture
< SPARC_OPCODE_ARCH_V9
1313 && last_insn
!= NULL
1314 && (insn
->flags
& F_FBR
) != 0
1315 && (last_insn
->flags
& F_FLOAT
) != 0)
1317 struct sparc_it nop_insn
;
1319 nop_insn
.opcode
= NOP_INSN
;
1320 nop_insn
.reloc
= BFD_RELOC_NONE
;
1321 output_insn (insn
, &nop_insn
);
1322 as_warn (_("FP branch preceded by FP instruction; NOP inserted"));
1325 switch (special_case
)
1327 case SPECIAL_CASE_NONE
:
1329 output_insn (insn
, &the_insn
);
1332 case SPECIAL_CASE_SETSW
:
1333 synthetize_setsw (insn
);
1336 case SPECIAL_CASE_SET
:
1337 synthetize_setuw (insn
);
1340 case SPECIAL_CASE_SETX
:
1341 synthetize_setx (insn
);
1344 case SPECIAL_CASE_FDIV
:
1346 int rd
= (the_insn
.opcode
>> 25) & 0x1f;
1348 output_insn (insn
, &the_insn
);
1350 /* According to information leaked from Sun, the "fdiv" instructions
1351 on early SPARC machines would produce incorrect results sometimes.
1352 The workaround is to add an fmovs of the destination register to
1353 itself just after the instruction. This was true on machines
1354 with Weitek 1165 float chips, such as the Sun-4/260 and /280. */
1355 assert (the_insn
.reloc
== BFD_RELOC_NONE
);
1356 the_insn
.opcode
= FMOVS_INSN
| rd
| RD (rd
);
1357 output_insn (insn
, &the_insn
);
1362 as_fatal (_("failed special case insn sanity check"));
1366 /* Subroutine of md_assemble to do the actual parsing. */
1369 sparc_ip (char *str
, const struct sparc_opcode
**pinsn
)
1371 char *error_message
= "";
1375 const struct sparc_opcode
*insn
;
1377 unsigned long opcode
;
1378 unsigned int mask
= 0;
1382 int special_case
= SPECIAL_CASE_NONE
;
1389 while (ISLOWER (*s
) || ISDIGIT (*s
));
1406 as_bad (_("Unknown opcode: `%s'"), str
);
1408 return special_case
;
1410 insn
= (struct sparc_opcode
*) hash_find (op_hash
, str
);
1414 as_bad (_("Unknown opcode: `%s'"), str
);
1415 return special_case
;
1425 opcode
= insn
->match
;
1426 memset (&the_insn
, '\0', sizeof (the_insn
));
1427 the_insn
.reloc
= BFD_RELOC_NONE
;
1430 /* Build the opcode, checking as we go to make sure that the
1432 for (args
= insn
->args
;; ++args
)
1440 /* Parse a series of masks. */
1447 if (! parse_keyword_arg (sparc_encode_membar
, &s
,
1450 error_message
= _(": invalid membar mask name");
1456 if (*s
== '|' || *s
== '+')
1464 if (! parse_const_expr_arg (&s
, &kmask
))
1466 error_message
= _(": invalid membar mask expression");
1469 if (kmask
< 0 || kmask
> 127)
1471 error_message
= _(": invalid membar mask number");
1476 opcode
|= MEMBAR (kmask
);
1484 if (! parse_const_expr_arg (&s
, &smask
))
1486 error_message
= _(": invalid siam mode expression");
1489 if (smask
< 0 || smask
> 7)
1491 error_message
= _(": invalid siam mode number");
1502 /* Parse a prefetch function. */
1505 if (! parse_keyword_arg (sparc_encode_prefetch
, &s
, &fcn
))
1507 error_message
= _(": invalid prefetch function name");
1513 if (! parse_const_expr_arg (&s
, &fcn
))
1515 error_message
= _(": invalid prefetch function expression");
1518 if (fcn
< 0 || fcn
> 31)
1520 error_message
= _(": invalid prefetch function number");
1530 /* Parse a sparc64 privileged register. */
1533 struct priv_reg_entry
*p
= priv_reg_table
;
1534 unsigned int len
= 9999999; /* Init to make gcc happy. */
1537 while (p
->name
[0] > s
[0])
1539 while (p
->name
[0] == s
[0])
1541 len
= strlen (p
->name
);
1542 if (strncmp (p
->name
, s
, len
) == 0)
1546 if (p
->name
[0] != s
[0])
1548 error_message
= _(": unrecognizable privileged register");
1552 opcode
|= (p
->regnum
<< 14);
1554 opcode
|= (p
->regnum
<< 25);
1560 error_message
= _(": unrecognizable privileged register");
1566 /* Parse a sparc64 hyperprivileged register. */
1569 struct priv_reg_entry
*p
= hpriv_reg_table
;
1570 unsigned int len
= 9999999; /* Init to make gcc happy. */
1573 while (p
->name
[0] > s
[0])
1575 while (p
->name
[0] == s
[0])
1577 len
= strlen (p
->name
);
1578 if (strncmp (p
->name
, s
, len
) == 0)
1582 if (p
->name
[0] != s
[0])
1584 error_message
= _(": unrecognizable hyperprivileged register");
1588 opcode
|= (p
->regnum
<< 14);
1590 opcode
|= (p
->regnum
<< 25);
1596 error_message
= _(": unrecognizable hyperprivileged register");
1602 /* Parse a v9a/v9b ancillary state register. */
1605 struct priv_reg_entry
*p
= v9a_asr_table
;
1606 unsigned int len
= 9999999; /* Init to make gcc happy. */
1609 while (p
->name
[0] > s
[0])
1611 while (p
->name
[0] == s
[0])
1613 len
= strlen (p
->name
);
1614 if (strncmp (p
->name
, s
, len
) == 0)
1618 if (p
->name
[0] != s
[0])
1620 error_message
= _(": unrecognizable v9a or v9b ancillary state register");
1623 if (*args
== '/' && (p
->regnum
== 20 || p
->regnum
== 21))
1625 error_message
= _(": rd on write only ancillary state register");
1629 && (insn
->architecture
1630 & SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9A
)))
1632 /* %sys_tick and %sys_tick_cmpr are v9bnotv9a */
1633 error_message
= _(": unrecognizable v9a ancillary state register");
1637 opcode
|= (p
->regnum
<< 14);
1639 opcode
|= (p
->regnum
<< 25);
1645 error_message
= _(": unrecognizable v9a or v9b ancillary state register");
1651 if (strncmp (s
, "%asr", 4) == 0)
1659 while (ISDIGIT (*s
))
1661 num
= num
* 10 + *s
- '0';
1665 if (current_architecture
>= SPARC_OPCODE_ARCH_V9
)
1667 if (num
< 16 || 31 < num
)
1669 error_message
= _(": asr number must be between 16 and 31");
1675 if (num
< 0 || 31 < num
)
1677 error_message
= _(": asr number must be between 0 and 31");
1682 opcode
|= (*args
== 'M' ? RS1 (num
) : RD (num
));
1687 error_message
= _(": expecting %asrN");
1694 the_insn
.reloc
= BFD_RELOC_SPARC_11
;
1698 the_insn
.reloc
= BFD_RELOC_SPARC_10
;
1702 /* V8 systems don't understand BFD_RELOC_SPARC_5. */
1703 if (SPARC_OPCODE_ARCH_V9_P (max_architecture
))
1704 the_insn
.reloc
= BFD_RELOC_SPARC_5
;
1706 the_insn
.reloc
= BFD_RELOC_SPARC13
;
1707 /* These fields are unsigned, but for upward compatibility,
1708 allow negative values as well. */
1712 /* V8 systems don't understand BFD_RELOC_SPARC_6. */
1713 if (SPARC_OPCODE_ARCH_V9_P (max_architecture
))
1714 the_insn
.reloc
= BFD_RELOC_SPARC_6
;
1716 the_insn
.reloc
= BFD_RELOC_SPARC13
;
1717 /* These fields are unsigned, but for upward compatibility,
1718 allow negative values as well. */
1722 the_insn
.reloc
= /* RELOC_WDISP2_14 */ BFD_RELOC_SPARC_WDISP16
;
1727 the_insn
.reloc
= BFD_RELOC_SPARC_WDISP19
;
1732 if (*s
== 'p' && s
[1] == 'n')
1740 if (*s
== 'p' && s
[1] == 't')
1752 if (strncmp (s
, "%icc", 4) == 0)
1764 if (strncmp (s
, "%xcc", 4) == 0)
1776 if (strncmp (s
, "%fcc0", 5) == 0)
1788 if (strncmp (s
, "%fcc1", 5) == 0)
1800 if (strncmp (s
, "%fcc2", 5) == 0)
1812 if (strncmp (s
, "%fcc3", 5) == 0)
1820 if (strncmp (s
, "%pc", 3) == 0)
1828 if (strncmp (s
, "%tick", 5) == 0)
1835 case '\0': /* End of args. */
1836 if (s
[0] == ',' && s
[1] == '%')
1838 static const struct ops
1840 /* The name as it appears in assembler. */
1842 /* strlen (name), precomputed for speed */
1844 /* The reloc this pseudo-op translates to. */
1846 /* 1 if tls call. */
1851 { "tgd_add", 7, BFD_RELOC_SPARC_TLS_GD_ADD
, 0 },
1852 { "tgd_call", 8, BFD_RELOC_SPARC_TLS_GD_CALL
, 1 },
1853 { "tldm_add", 8, BFD_RELOC_SPARC_TLS_LDM_ADD
, 0 },
1854 { "tldm_call", 9, BFD_RELOC_SPARC_TLS_LDM_CALL
, 1 },
1855 { "tldo_add", 8, BFD_RELOC_SPARC_TLS_LDO_ADD
, 0 },
1856 { "tie_ldx", 7, BFD_RELOC_SPARC_TLS_IE_LDX
, 0 },
1857 { "tie_ld", 6, BFD_RELOC_SPARC_TLS_IE_LD
, 0 },
1858 { "tie_add", 7, BFD_RELOC_SPARC_TLS_IE_ADD
, 0 },
1859 { "gdop", 4, BFD_RELOC_SPARC_GOTDATA_OP
, 0 },
1862 const struct ops
*o
;
1866 for (o
= ops
; o
->name
; o
++)
1867 if (strncmp (s
+ 2, o
->name
, o
->len
) == 0)
1869 if (o
->name
== NULL
)
1872 if (s
[o
->len
+ 2] != '(')
1874 as_bad (_("Illegal operands: %%%s requires arguments in ()"), o
->name
);
1875 return special_case
;
1878 if (! o
->tls_call
&& the_insn
.reloc
!= BFD_RELOC_NONE
)
1880 as_bad (_("Illegal operands: %%%s cannot be used together with other relocs in the insn ()"),
1882 return special_case
;
1886 && (the_insn
.reloc
!= BFD_RELOC_32_PCREL_S2
1887 || the_insn
.exp
.X_add_number
!= 0
1888 || the_insn
.exp
.X_add_symbol
1889 != symbol_find_or_make ("__tls_get_addr")))
1891 as_bad (_("Illegal operands: %%%s can be only used with call __tls_get_addr"),
1893 return special_case
;
1896 the_insn
.reloc
= o
->reloc
;
1897 memset (&the_insn
.exp
, 0, sizeof (the_insn
.exp
));
1900 for (s1
= s
; *s1
&& *s1
!= ',' && *s1
!= ']'; s1
++)
1903 else if (*s1
== ')')
1912 as_bad (_("Illegal operands: %%%s requires arguments in ()"), o
->name
);
1913 return special_case
;
1917 (void) get_expression (s
);
1937 case '[': /* These must match exactly. */
1945 case '#': /* Must be at least one digit. */
1948 while (ISDIGIT (*s
))
1956 case 'C': /* Coprocessor state register. */
1957 if (strncmp (s
, "%csr", 4) == 0)
1964 case 'b': /* Next operand is a coprocessor register. */
1967 if (*s
++ == '%' && *s
++ == 'c' && ISDIGIT (*s
))
1972 mask
= 10 * (mask
- '0') + (*s
++ - '0');
1986 opcode
|= mask
<< 14;
1994 opcode
|= mask
<< 25;
2000 case 'r': /* next operand must be a register */
2010 case 'f': /* frame pointer */
2018 case 'g': /* global register */
2027 case 'i': /* in register */
2031 mask
= c
- '0' + 24;
2036 case 'l': /* local register */
2040 mask
= (c
- '0' + 16);
2045 case 'o': /* out register */
2049 mask
= (c
- '0' + 8);
2054 case 's': /* stack pointer */
2062 case 'r': /* any register */
2063 if (!ISDIGIT ((c
= *s
++)))
2080 if ((c
= 10 * (c
- '0') + (*s
++ - '0')) >= 32)
2096 if ((mask
& ~1) == 2 && sparc_arch_size
== 64
2097 && no_undeclared_regs
&& ! globals
[mask
])
2098 as_bad (_("detected global register use not covered by .register pseudo-op"));
2100 /* Got the register, now figure out where
2101 it goes in the opcode. */
2105 opcode
|= mask
<< 14;
2113 opcode
|= mask
<< 25;
2117 opcode
|= (mask
<< 25) | (mask
<< 14);
2121 opcode
|= (mask
<< 25) | (mask
<< 0);
2127 case 'e': /* next operand is a floating point register */
2142 && ((format
= *s
) == 'f')
2145 for (mask
= 0; ISDIGIT (*s
); ++s
)
2147 mask
= 10 * mask
+ (*s
- '0');
2148 } /* read the number */
2156 } /* register must be even numbered */
2164 } /* register must be multiple of 4 */
2168 if (SPARC_OPCODE_ARCH_V9_P (max_architecture
))
2169 error_message
= _(": There are only 64 f registers; [0-63]");
2171 error_message
= _(": There are only 32 f registers; [0-31]");
2174 else if (mask
>= 32)
2176 if (SPARC_OPCODE_ARCH_V9_P (max_architecture
))
2178 if (*args
== 'e' || *args
== 'f' || *args
== 'g')
2181 = _(": There are only 32 single precision f registers; [0-31]");
2185 mask
-= 31; /* wrap high bit */
2189 error_message
= _(": There are only 32 f registers; [0-31]");
2197 } /* if not an 'f' register. */
2204 opcode
|= RS1 (mask
);
2210 opcode
|= RS2 (mask
);
2216 opcode
|= RD (mask
);
2225 if (strncmp (s
, "%fsr", 4) == 0)
2232 case '0': /* 64 bit immediate (set, setsw, setx insn) */
2233 the_insn
.reloc
= BFD_RELOC_NONE
; /* reloc handled elsewhere */
2236 case 'l': /* 22 bit PC relative immediate */
2237 the_insn
.reloc
= BFD_RELOC_SPARC_WDISP22
;
2241 case 'L': /* 30 bit immediate */
2242 the_insn
.reloc
= BFD_RELOC_32_PCREL_S2
;
2247 case 'n': /* 22 bit immediate */
2248 the_insn
.reloc
= BFD_RELOC_SPARC22
;
2251 case 'i': /* 13 bit immediate */
2252 the_insn
.reloc
= BFD_RELOC_SPARC13
;
2262 char *op_arg
= NULL
;
2263 static expressionS op_exp
;
2264 bfd_reloc_code_real_type old_reloc
= the_insn
.reloc
;
2266 /* Check for %hi, etc. */
2269 static const struct ops
{
2270 /* The name as it appears in assembler. */
2272 /* strlen (name), precomputed for speed */
2274 /* The reloc this pseudo-op translates to. */
2276 /* Non-zero if for v9 only. */
2278 /* Non-zero if can be used in pc-relative contexts. */
2279 int pcrel_p
;/*FIXME:wip*/
2281 /* hix/lox must appear before hi/lo so %hix won't be
2282 mistaken for %hi. */
2283 { "hix", 3, BFD_RELOC_SPARC_HIX22
, 1, 0 },
2284 { "lox", 3, BFD_RELOC_SPARC_LOX10
, 1, 0 },
2285 { "hi", 2, BFD_RELOC_HI22
, 0, 1 },
2286 { "lo", 2, BFD_RELOC_LO10
, 0, 1 },
2287 { "pc22", 4, BFD_RELOC_SPARC_PC22
, 0, 1 },
2288 { "pc10", 4, BFD_RELOC_SPARC_PC10
, 0, 1 },
2289 { "hh", 2, BFD_RELOC_SPARC_HH22
, 1, 1 },
2290 { "hm", 2, BFD_RELOC_SPARC_HM10
, 1, 1 },
2291 { "lm", 2, BFD_RELOC_SPARC_LM22
, 1, 1 },
2292 { "h44", 3, BFD_RELOC_SPARC_H44
, 1, 0 },
2293 { "m44", 3, BFD_RELOC_SPARC_M44
, 1, 0 },
2294 { "l44", 3, BFD_RELOC_SPARC_L44
, 1, 0 },
2295 { "uhi", 3, BFD_RELOC_SPARC_HH22
, 1, 0 },
2296 { "ulo", 3, BFD_RELOC_SPARC_HM10
, 1, 0 },
2297 { "tgd_hi22", 8, BFD_RELOC_SPARC_TLS_GD_HI22
, 0, 0 },
2298 { "tgd_lo10", 8, BFD_RELOC_SPARC_TLS_GD_LO10
, 0, 0 },
2299 { "tldm_hi22", 9, BFD_RELOC_SPARC_TLS_LDM_HI22
, 0, 0 },
2300 { "tldm_lo10", 9, BFD_RELOC_SPARC_TLS_LDM_LO10
, 0, 0 },
2301 { "tldo_hix22", 10, BFD_RELOC_SPARC_TLS_LDO_HIX22
, 0,
2303 { "tldo_lox10", 10, BFD_RELOC_SPARC_TLS_LDO_LOX10
, 0,
2305 { "tie_hi22", 8, BFD_RELOC_SPARC_TLS_IE_HI22
, 0, 0 },
2306 { "tie_lo10", 8, BFD_RELOC_SPARC_TLS_IE_LO10
, 0, 0 },
2307 { "tle_hix22", 9, BFD_RELOC_SPARC_TLS_LE_HIX22
, 0, 0 },
2308 { "tle_lox10", 9, BFD_RELOC_SPARC_TLS_LE_LOX10
, 0, 0 },
2309 { "gdop_hix22", 10, BFD_RELOC_SPARC_GOTDATA_OP_HIX22
,
2311 { "gdop_lox10", 10, BFD_RELOC_SPARC_GOTDATA_OP_LOX10
,
2313 { NULL
, 0, 0, 0, 0 }
2315 const struct ops
*o
;
2317 for (o
= ops
; o
->name
; o
++)
2318 if (strncmp (s
+ 1, o
->name
, o
->len
) == 0)
2320 if (o
->name
== NULL
)
2323 if (s
[o
->len
+ 1] != '(')
2325 as_bad (_("Illegal operands: %%%s requires arguments in ()"), o
->name
);
2326 return special_case
;
2330 the_insn
.reloc
= o
->reloc
;
2335 /* Note that if the get_expression() fails, we will still
2336 have created U entries in the symbol table for the
2337 'symbols' in the input string. Try not to create U
2338 symbols for registers, etc. */
2340 /* This stuff checks to see if the expression ends in
2341 +%reg. If it does, it removes the register from
2342 the expression, and re-sets 's' to point to the
2349 for (s1
= s
; *s1
&& *s1
!= ',' && *s1
!= ']'; s1
++)
2352 else if (*s1
== ')')
2361 as_bad (_("Illegal operands: %%%s requires arguments in ()"), op_arg
);
2362 return special_case
;
2366 (void) get_expression (s
);
2369 if (*s
== ',' || *s
== ']' || !*s
)
2371 if (*s
!= '+' && *s
!= '-')
2373 as_bad (_("Illegal operands: Can't do arithmetics other than + and - involving %%%s()"), op_arg
);
2374 return special_case
;
2378 op_exp
= the_insn
.exp
;
2379 memset (&the_insn
.exp
, 0, sizeof (the_insn
.exp
));
2382 for (s1
= s
; *s1
&& *s1
!= ',' && *s1
!= ']'; s1
++)
2385 if (s1
!= s
&& ISDIGIT (s1
[-1]))
2387 if (s1
[-2] == '%' && s1
[-3] == '+')
2389 else if (strchr ("goli0123456789", s1
[-2]) && s1
[-3] == '%' && s1
[-4] == '+')
2396 if (op_arg
&& s1
== s
+ 1)
2397 the_insn
.exp
.X_op
= O_absent
;
2399 (void) get_expression (s
);
2411 (void) get_expression (s
);
2419 the_insn
.exp2
= the_insn
.exp
;
2420 the_insn
.exp
= op_exp
;
2421 if (the_insn
.exp2
.X_op
== O_absent
)
2422 the_insn
.exp2
.X_op
= O_illegal
;
2423 else if (the_insn
.exp
.X_op
== O_absent
)
2425 the_insn
.exp
= the_insn
.exp2
;
2426 the_insn
.exp2
.X_op
= O_illegal
;
2428 else if (the_insn
.exp
.X_op
== O_constant
)
2430 valueT val
= the_insn
.exp
.X_add_number
;
2431 switch (the_insn
.reloc
)
2436 case BFD_RELOC_SPARC_HH22
:
2437 val
= BSR (val
, 32);
2440 case BFD_RELOC_SPARC_LM22
:
2441 case BFD_RELOC_HI22
:
2442 val
= (val
>> 10) & 0x3fffff;
2445 case BFD_RELOC_SPARC_HM10
:
2446 val
= BSR (val
, 32);
2449 case BFD_RELOC_LO10
:
2453 case BFD_RELOC_SPARC_H44
:
2458 case BFD_RELOC_SPARC_M44
:
2463 case BFD_RELOC_SPARC_L44
:
2467 case BFD_RELOC_SPARC_HIX22
:
2469 val
= (val
>> 10) & 0x3fffff;
2472 case BFD_RELOC_SPARC_LOX10
:
2473 val
= (val
& 0x3ff) | 0x1c00;
2476 the_insn
.exp
= the_insn
.exp2
;
2477 the_insn
.exp
.X_add_number
+= val
;
2478 the_insn
.exp2
.X_op
= O_illegal
;
2479 the_insn
.reloc
= old_reloc
;
2481 else if (the_insn
.exp2
.X_op
!= O_constant
)
2483 as_bad (_("Illegal operands: Can't add non-constant expression to %%%s()"), op_arg
);
2484 return special_case
;
2488 if (old_reloc
!= BFD_RELOC_SPARC13
2489 || the_insn
.reloc
!= BFD_RELOC_LO10
2490 || sparc_arch_size
!= 64
2493 as_bad (_("Illegal operands: Can't do arithmetics involving %%%s() of a relocatable symbol"), op_arg
);
2494 return special_case
;
2496 the_insn
.reloc
= BFD_RELOC_SPARC_OLO10
;
2500 /* Check for constants that don't require emitting a reloc. */
2501 if (the_insn
.exp
.X_op
== O_constant
2502 && the_insn
.exp
.X_add_symbol
== 0
2503 && the_insn
.exp
.X_op_symbol
== 0)
2505 /* For pc-relative call instructions, we reject
2506 constants to get better code. */
2508 && the_insn
.reloc
== BFD_RELOC_32_PCREL_S2
2509 && in_signed_range (the_insn
.exp
.X_add_number
, 0x3fff))
2511 error_message
= _(": PC-relative operand can't be a constant");
2515 if (the_insn
.reloc
>= BFD_RELOC_SPARC_TLS_GD_HI22
2516 && the_insn
.reloc
<= BFD_RELOC_SPARC_TLS_TPOFF64
)
2518 error_message
= _(": TLS operand can't be a constant");
2522 /* Constants that won't fit are checked in md_apply_fix
2523 and bfd_install_relocation.
2524 ??? It would be preferable to install the constants
2525 into the insn here and save having to create a fixS
2526 for each one. There already exists code to handle
2527 all the various cases (e.g. in md_apply_fix and
2528 bfd_install_relocation) so duplicating all that code
2529 here isn't right. */
2549 if (! parse_keyword_arg (sparc_encode_asi
, &s
, &asi
))
2551 error_message
= _(": invalid ASI name");
2557 if (! parse_const_expr_arg (&s
, &asi
))
2559 error_message
= _(": invalid ASI expression");
2562 if (asi
< 0 || asi
> 255)
2564 error_message
= _(": invalid ASI number");
2568 opcode
|= ASI (asi
);
2570 } /* Alternate space. */
2573 if (strncmp (s
, "%psr", 4) == 0)
2580 case 'q': /* Floating point queue. */
2581 if (strncmp (s
, "%fq", 3) == 0)
2588 case 'Q': /* Coprocessor queue. */
2589 if (strncmp (s
, "%cq", 3) == 0)
2597 if (strcmp (str
, "set") == 0
2598 || strcmp (str
, "setuw") == 0)
2600 special_case
= SPECIAL_CASE_SET
;
2603 else if (strcmp (str
, "setsw") == 0)
2605 special_case
= SPECIAL_CASE_SETSW
;
2608 else if (strcmp (str
, "setx") == 0)
2610 special_case
= SPECIAL_CASE_SETX
;
2613 else if (strncmp (str
, "fdiv", 4) == 0)
2615 special_case
= SPECIAL_CASE_FDIV
;
2621 if (strncmp (s
, "%asi", 4) != 0)
2627 if (strncmp (s
, "%fprs", 5) != 0)
2633 if (strncmp (s
, "%ccr", 4) != 0)
2639 if (strncmp (s
, "%tbr", 4) != 0)
2645 if (strncmp (s
, "%wim", 4) != 0)
2652 char *push
= input_line_pointer
;
2655 input_line_pointer
= s
;
2657 if (e
.X_op
== O_constant
)
2659 int n
= e
.X_add_number
;
2660 if (n
!= e
.X_add_number
|| (n
& ~0x1ff) != 0)
2661 as_bad (_("OPF immediate operand out of range (0-0x1ff)"));
2663 opcode
|= e
.X_add_number
<< 5;
2666 as_bad (_("non-immediate OPF operand, ignored"));
2667 s
= input_line_pointer
;
2668 input_line_pointer
= push
;
2673 if (strncmp (s
, "%y", 2) != 0)
2681 /* Parse a sparclet cpreg. */
2683 if (! parse_keyword_arg (sparc_encode_sparclet_cpreg
, &s
, &cpreg
))
2685 error_message
= _(": invalid cpreg name");
2688 opcode
|= (*args
== 'U' ? RS1 (cpreg
) : RD (cpreg
));
2693 as_fatal (_("failed sanity check."));
2694 } /* switch on arg code. */
2696 /* Break out of for() loop. */
2698 } /* For each arg that we expect. */
2703 /* Args don't match. */
2704 if (&insn
[1] - sparc_opcodes
< sparc_num_opcodes
2705 && (insn
->name
== insn
[1].name
2706 || !strcmp (insn
->name
, insn
[1].name
)))
2714 as_bad (_("Illegal operands%s"), error_message
);
2715 return special_case
;
2720 /* We have a match. Now see if the architecture is OK. */
2721 int needed_arch_mask
= insn
->architecture
;
2726 ~(SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9
) - 1);
2727 if (! needed_arch_mask
)
2729 SPARC_OPCODE_ARCH_MASK (SPARC_OPCODE_ARCH_V9
);
2732 if (needed_arch_mask
2733 & SPARC_OPCODE_SUPPORTED (current_architecture
))
2736 /* Can we bump up the architecture? */
2737 else if (needed_arch_mask
2738 & SPARC_OPCODE_SUPPORTED (max_architecture
))
2740 enum sparc_opcode_arch_val needed_architecture
=
2741 sparc_ffs (SPARC_OPCODE_SUPPORTED (max_architecture
)
2742 & needed_arch_mask
);
2744 assert (needed_architecture
<= SPARC_OPCODE_ARCH_MAX
);
2746 && needed_architecture
> warn_after_architecture
)
2748 as_warn (_("architecture bumped from \"%s\" to \"%s\" on \"%s\""),
2749 sparc_opcode_archs
[current_architecture
].name
,
2750 sparc_opcode_archs
[needed_architecture
].name
,
2752 warn_after_architecture
= needed_architecture
;
2754 current_architecture
= needed_architecture
;
2757 /* ??? This seems to be a bit fragile. What if the next entry in
2758 the opcode table is the one we want and it is supported?
2759 It is possible to arrange the table today so that this can't
2760 happen but what about tomorrow? */
2763 int arch
, printed_one_p
= 0;
2765 char required_archs
[SPARC_OPCODE_ARCH_MAX
* 16];
2767 /* Create a list of the architectures that support the insn. */
2768 needed_arch_mask
&= ~SPARC_OPCODE_SUPPORTED (max_architecture
);
2770 arch
= sparc_ffs (needed_arch_mask
);
2771 while ((1 << arch
) <= needed_arch_mask
)
2773 if ((1 << arch
) & needed_arch_mask
)
2777 strcpy (p
, sparc_opcode_archs
[arch
].name
);
2784 as_bad (_("Architecture mismatch on \"%s\"."), str
);
2785 as_tsktsk (_(" (Requires %s; requested architecture is %s.)"),
2787 sparc_opcode_archs
[max_architecture
].name
);
2788 return special_case
;
2790 } /* If no match. */
2793 } /* Forever looking for a match. */
2795 the_insn
.opcode
= opcode
;
2796 return special_case
;
2799 /* Parse an argument that can be expressed as a keyword.
2800 (eg: #StoreStore or %ccfr).
2801 The result is a boolean indicating success.
2802 If successful, INPUT_POINTER is updated. */
2805 parse_keyword_arg (int (*lookup_fn
) (const char *),
2806 char **input_pointerP
,
2812 p
= *input_pointerP
;
2813 for (q
= p
+ (*p
== '#' || *p
== '%');
2814 ISALNUM (*q
) || *q
== '_';
2819 value
= (*lookup_fn
) (p
);
2824 *input_pointerP
= q
;
2828 /* Parse an argument that is a constant expression.
2829 The result is a boolean indicating success. */
2832 parse_const_expr_arg (char **input_pointerP
, int *valueP
)
2834 char *save
= input_line_pointer
;
2837 input_line_pointer
= *input_pointerP
;
2838 /* The next expression may be something other than a constant
2839 (say if we're not processing the right variant of the insn).
2840 Don't call expression unless we're sure it will succeed as it will
2841 signal an error (which we want to defer until later). */
2842 /* FIXME: It might be better to define md_operand and have it recognize
2843 things like %asi, etc. but continuing that route through to the end
2844 is a lot of work. */
2845 if (*input_line_pointer
== '%')
2847 input_line_pointer
= save
;
2851 *input_pointerP
= input_line_pointer
;
2852 input_line_pointer
= save
;
2853 if (exp
.X_op
!= O_constant
)
2855 *valueP
= exp
.X_add_number
;
2859 /* Subroutine of sparc_ip to parse an expression. */
2862 get_expression (char *str
)
2867 save_in
= input_line_pointer
;
2868 input_line_pointer
= str
;
2869 seg
= expression (&the_insn
.exp
);
2870 if (seg
!= absolute_section
2871 && seg
!= text_section
2872 && seg
!= data_section
2873 && seg
!= bss_section
2874 && seg
!= undefined_section
)
2876 the_insn
.error
= _("bad segment");
2877 expr_end
= input_line_pointer
;
2878 input_line_pointer
= save_in
;
2881 expr_end
= input_line_pointer
;
2882 input_line_pointer
= save_in
;
2886 /* Subroutine of md_assemble to output one insn. */
2889 output_insn (const struct sparc_opcode
*insn
, struct sparc_it
*the_insn
)
2891 char *toP
= frag_more (4);
2893 /* Put out the opcode. */
2894 if (INSN_BIG_ENDIAN
)
2895 number_to_chars_bigendian (toP
, (valueT
) the_insn
->opcode
, 4);
2897 number_to_chars_littleendian (toP
, (valueT
) the_insn
->opcode
, 4);
2899 /* Put out the symbol-dependent stuff. */
2900 if (the_insn
->reloc
!= BFD_RELOC_NONE
)
2902 fixS
*fixP
= fix_new_exp (frag_now
, /* Which frag. */
2903 (toP
- frag_now
->fr_literal
), /* Where. */
2908 /* Turn off overflow checking in fixup_segment. We'll do our
2909 own overflow checking in md_apply_fix. This is necessary because
2910 the insn size is 4 and fixup_segment will signal an overflow for
2911 large 8 byte quantities. */
2912 fixP
->fx_no_overflow
= 1;
2913 if (the_insn
->reloc
== BFD_RELOC_SPARC_OLO10
)
2914 fixP
->tc_fix_data
= the_insn
->exp2
.X_add_number
;
2918 last_opcode
= the_insn
->opcode
;
2921 dwarf2_emit_insn (4);
2926 md_atof (int type
, char *litP
, int *sizeP
)
2928 return ieee_md_atof (type
, litP
, sizeP
, target_big_endian
);
2931 /* Write a value out to the object file, using the appropriate
2935 md_number_to_chars (char *buf
, valueT val
, int n
)
2937 if (target_big_endian
)
2938 number_to_chars_bigendian (buf
, val
, n
);
2939 else if (target_little_endian_data
2940 && ((n
== 4 || n
== 2) && ~now_seg
->flags
& SEC_ALLOC
))
2941 /* Output debug words, which are not in allocated sections, as big
2943 number_to_chars_bigendian (buf
, val
, n
);
2944 else if (target_little_endian_data
|| ! target_big_endian
)
2945 number_to_chars_littleendian (buf
, val
, n
);
2948 /* Apply a fixS to the frags, now that we know the value it ought to
2952 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT segment ATTRIBUTE_UNUSED
)
2954 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
2955 offsetT val
= * (offsetT
*) valP
;
2958 assert (fixP
->fx_r_type
< BFD_RELOC_UNUSED
);
2960 fixP
->fx_addnumber
= val
; /* Remember value for emit_reloc. */
2963 /* SPARC ELF relocations don't use an addend in the data field. */
2964 if (fixP
->fx_addsy
!= NULL
)
2966 switch (fixP
->fx_r_type
)
2968 case BFD_RELOC_SPARC_TLS_GD_HI22
:
2969 case BFD_RELOC_SPARC_TLS_GD_LO10
:
2970 case BFD_RELOC_SPARC_TLS_GD_ADD
:
2971 case BFD_RELOC_SPARC_TLS_GD_CALL
:
2972 case BFD_RELOC_SPARC_TLS_LDM_HI22
:
2973 case BFD_RELOC_SPARC_TLS_LDM_LO10
:
2974 case BFD_RELOC_SPARC_TLS_LDM_ADD
:
2975 case BFD_RELOC_SPARC_TLS_LDM_CALL
:
2976 case BFD_RELOC_SPARC_TLS_LDO_HIX22
:
2977 case BFD_RELOC_SPARC_TLS_LDO_LOX10
:
2978 case BFD_RELOC_SPARC_TLS_LDO_ADD
:
2979 case BFD_RELOC_SPARC_TLS_IE_HI22
:
2980 case BFD_RELOC_SPARC_TLS_IE_LO10
:
2981 case BFD_RELOC_SPARC_TLS_IE_LD
:
2982 case BFD_RELOC_SPARC_TLS_IE_LDX
:
2983 case BFD_RELOC_SPARC_TLS_IE_ADD
:
2984 case BFD_RELOC_SPARC_TLS_LE_HIX22
:
2985 case BFD_RELOC_SPARC_TLS_LE_LOX10
:
2986 case BFD_RELOC_SPARC_TLS_DTPMOD32
:
2987 case BFD_RELOC_SPARC_TLS_DTPMOD64
:
2988 case BFD_RELOC_SPARC_TLS_DTPOFF32
:
2989 case BFD_RELOC_SPARC_TLS_DTPOFF64
:
2990 case BFD_RELOC_SPARC_TLS_TPOFF32
:
2991 case BFD_RELOC_SPARC_TLS_TPOFF64
:
2992 S_SET_THREAD_LOCAL (fixP
->fx_addsy
);
3002 /* This is a hack. There should be a better way to
3003 handle this. Probably in terms of howto fields, once
3004 we can look at these fixups in terms of howtos. */
3005 if (fixP
->fx_r_type
== BFD_RELOC_32_PCREL_S2
&& fixP
->fx_addsy
)
3006 val
+= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
3009 /* FIXME: More ridiculous gas reloc hacking. If we are going to
3010 generate a reloc, then we just want to let the reloc addend set
3011 the value. We do not want to also stuff the addend into the
3012 object file. Including the addend in the object file works when
3013 doing a static link, because the linker will ignore the object
3014 file contents. However, the dynamic linker does not ignore the
3015 object file contents. */
3016 if (fixP
->fx_addsy
!= NULL
3017 && fixP
->fx_r_type
!= BFD_RELOC_32_PCREL_S2
)
3020 /* When generating PIC code, we do not want an addend for a reloc
3021 against a local symbol. We adjust fx_addnumber to cancel out the
3022 value already included in val, and to also cancel out the
3023 adjustment which bfd_install_relocation will create. */
3025 && fixP
->fx_r_type
!= BFD_RELOC_32_PCREL_S2
3026 && fixP
->fx_addsy
!= NULL
3027 && ! S_IS_COMMON (fixP
->fx_addsy
)
3028 && symbol_section_p (fixP
->fx_addsy
))
3029 fixP
->fx_addnumber
-= 2 * S_GET_VALUE (fixP
->fx_addsy
);
3031 /* When generating PIC code, we need to fiddle to get
3032 bfd_install_relocation to do the right thing for a PC relative
3033 reloc against a local symbol which we are going to keep. */
3035 && fixP
->fx_r_type
== BFD_RELOC_32_PCREL_S2
3036 && fixP
->fx_addsy
!= NULL
3037 && (S_IS_EXTERNAL (fixP
->fx_addsy
)
3038 || S_IS_WEAK (fixP
->fx_addsy
))
3039 && S_IS_DEFINED (fixP
->fx_addsy
)
3040 && ! S_IS_COMMON (fixP
->fx_addsy
))
3043 fixP
->fx_addnumber
-= 2 * S_GET_VALUE (fixP
->fx_addsy
);
3047 /* If this is a data relocation, just output VAL. */
3049 if (fixP
->fx_r_type
== BFD_RELOC_16
3050 || fixP
->fx_r_type
== BFD_RELOC_SPARC_UA16
)
3052 md_number_to_chars (buf
, val
, 2);
3054 else if (fixP
->fx_r_type
== BFD_RELOC_32
3055 || fixP
->fx_r_type
== BFD_RELOC_SPARC_UA32
3056 || fixP
->fx_r_type
== BFD_RELOC_SPARC_REV32
)
3058 md_number_to_chars (buf
, val
, 4);
3060 else if (fixP
->fx_r_type
== BFD_RELOC_64
3061 || fixP
->fx_r_type
== BFD_RELOC_SPARC_UA64
)
3063 md_number_to_chars (buf
, val
, 8);
3065 else if (fixP
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
3066 || fixP
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
3073 /* It's a relocation against an instruction. */
3075 if (INSN_BIG_ENDIAN
)
3076 insn
= bfd_getb32 ((unsigned char *) buf
);
3078 insn
= bfd_getl32 ((unsigned char *) buf
);
3080 switch (fixP
->fx_r_type
)
3082 case BFD_RELOC_32_PCREL_S2
:
3084 /* FIXME: This increment-by-one deserves a comment of why it's
3086 if (! sparc_pic_code
3087 || fixP
->fx_addsy
== NULL
3088 || symbol_section_p (fixP
->fx_addsy
))
3091 insn
|= val
& 0x3fffffff;
3093 /* See if we have a delay slot. */
3094 if (sparc_relax
&& fixP
->fx_where
+ 8 <= fixP
->fx_frag
->fr_fix
)
3098 #define XCC (2 << 20)
3099 #define COND(x) (((x)&0xf)<<25)
3100 #define CONDA COND(0x8)
3101 #define INSN_BPA (F2(0,1) | CONDA | BPRED | XCC)
3102 #define INSN_BA (F2(0,2) | CONDA)
3103 #define INSN_OR F3(2, 0x2, 0)
3104 #define INSN_NOP F2(0,4)
3108 /* If the instruction is a call with either:
3110 arithmetic instruction with rd == %o7
3111 where rs1 != %o7 and rs2 if it is register != %o7
3112 then we can optimize if the call destination is near
3113 by changing the call into a branch always. */
3114 if (INSN_BIG_ENDIAN
)
3115 delay
= bfd_getb32 ((unsigned char *) buf
+ 4);
3117 delay
= bfd_getl32 ((unsigned char *) buf
+ 4);
3118 if ((insn
& OP (~0)) != OP (1) || (delay
& OP (~0)) != OP (2))
3120 if ((delay
& OP3 (~0)) != OP3 (0x3d) /* Restore. */
3121 && ((delay
& OP3 (0x28)) != 0 /* Arithmetic. */
3122 || ((delay
& RD (~0)) != RD (O7
))))
3124 if ((delay
& RS1 (~0)) == RS1 (O7
)
3125 || ((delay
& F3I (~0)) == 0
3126 && (delay
& RS2 (~0)) == RS2 (O7
)))
3128 /* Ensure the branch will fit into simm22. */
3129 if ((val
& 0x3fe00000)
3130 && (val
& 0x3fe00000) != 0x3fe00000)
3132 /* Check if the arch is v9 and branch will fit
3134 if (((val
& 0x3c0000) == 0
3135 || (val
& 0x3c0000) == 0x3c0000)
3136 && (sparc_arch_size
== 64
3137 || current_architecture
>= SPARC_OPCODE_ARCH_V9
))
3139 insn
= INSN_BPA
| (val
& 0x7ffff);
3142 insn
= INSN_BA
| (val
& 0x3fffff);
3143 if (fixP
->fx_where
>= 4
3144 && ((delay
& (0xffffffff ^ RS1 (~0)))
3145 == (INSN_OR
| RD (O7
) | RS2 (G0
))))
3150 if (INSN_BIG_ENDIAN
)
3151 setter
= bfd_getb32 ((unsigned char *) buf
- 4);
3153 setter
= bfd_getl32 ((unsigned char *) buf
- 4);
3154 if ((setter
& (0xffffffff ^ RD (~0)))
3155 != (INSN_OR
| RS1 (O7
) | RS2 (G0
)))
3162 If call foo was replaced with ba, replace
3163 or %rN, %g0, %o7 with nop. */
3164 reg
= (delay
& RS1 (~0)) >> 14;
3165 if (reg
!= ((setter
& RD (~0)) >> 25)
3166 || reg
== G0
|| reg
== O7
)
3169 if (INSN_BIG_ENDIAN
)
3170 bfd_putb32 (INSN_NOP
, (unsigned char *) buf
+ 4);
3172 bfd_putl32 (INSN_NOP
, (unsigned char *) buf
+ 4);
3177 case BFD_RELOC_SPARC_11
:
3178 if (! in_signed_range (val
, 0x7ff))
3179 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3180 _("relocation overflow"));
3181 insn
|= val
& 0x7ff;
3184 case BFD_RELOC_SPARC_10
:
3185 if (! in_signed_range (val
, 0x3ff))
3186 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3187 _("relocation overflow"));
3188 insn
|= val
& 0x3ff;
3191 case BFD_RELOC_SPARC_7
:
3192 if (! in_bitfield_range (val
, 0x7f))
3193 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3194 _("relocation overflow"));
3198 case BFD_RELOC_SPARC_6
:
3199 if (! in_bitfield_range (val
, 0x3f))
3200 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3201 _("relocation overflow"));
3205 case BFD_RELOC_SPARC_5
:
3206 if (! in_bitfield_range (val
, 0x1f))
3207 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3208 _("relocation overflow"));
3212 case BFD_RELOC_SPARC_WDISP16
:
3215 || val
<= -(offsetT
) 0x20008)
3216 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3217 _("relocation overflow"));
3218 /* FIXME: The +1 deserves a comment. */
3219 val
= (val
>> 2) + 1;
3220 insn
|= ((val
& 0xc000) << 6) | (val
& 0x3fff);
3223 case BFD_RELOC_SPARC_WDISP19
:
3226 || val
<= -(offsetT
) 0x100008)
3227 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3228 _("relocation overflow"));
3229 /* FIXME: The +1 deserves a comment. */
3230 val
= (val
>> 2) + 1;
3231 insn
|= val
& 0x7ffff;
3234 case BFD_RELOC_SPARC_HH22
:
3235 val
= BSR (val
, 32);
3238 case BFD_RELOC_SPARC_LM22
:
3239 case BFD_RELOC_HI22
:
3240 if (!fixP
->fx_addsy
)
3241 insn
|= (val
>> 10) & 0x3fffff;
3243 /* FIXME: Need comment explaining why we do this. */
3247 case BFD_RELOC_SPARC22
:
3248 if (val
& ~0x003fffff)
3249 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3250 _("relocation overflow"));
3251 insn
|= (val
& 0x3fffff);
3254 case BFD_RELOC_SPARC_HM10
:
3255 val
= BSR (val
, 32);
3258 case BFD_RELOC_LO10
:
3259 if (!fixP
->fx_addsy
)
3260 insn
|= val
& 0x3ff;
3262 /* FIXME: Need comment explaining why we do this. */
3266 case BFD_RELOC_SPARC_OLO10
:
3268 val
+= fixP
->tc_fix_data
;
3271 case BFD_RELOC_SPARC13
:
3272 if (! in_signed_range (val
, 0x1fff))
3273 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3274 _("relocation overflow"));
3275 insn
|= val
& 0x1fff;
3278 case BFD_RELOC_SPARC_WDISP22
:
3279 val
= (val
>> 2) + 1;
3281 case BFD_RELOC_SPARC_BASE22
:
3282 insn
|= val
& 0x3fffff;
3285 case BFD_RELOC_SPARC_H44
:
3286 if (!fixP
->fx_addsy
)
3290 insn
|= tval
& 0x3fffff;
3294 case BFD_RELOC_SPARC_M44
:
3295 if (!fixP
->fx_addsy
)
3296 insn
|= (val
>> 12) & 0x3ff;
3299 case BFD_RELOC_SPARC_L44
:
3300 if (!fixP
->fx_addsy
)
3301 insn
|= val
& 0xfff;
3304 case BFD_RELOC_SPARC_HIX22
:
3305 if (!fixP
->fx_addsy
)
3307 val
^= ~(offsetT
) 0;
3308 insn
|= (val
>> 10) & 0x3fffff;
3312 case BFD_RELOC_SPARC_LOX10
:
3313 if (!fixP
->fx_addsy
)
3314 insn
|= 0x1c00 | (val
& 0x3ff);
3317 case BFD_RELOC_NONE
:
3319 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
3320 _("bad or unhandled relocation type: 0x%02x"),
3325 if (INSN_BIG_ENDIAN
)
3326 bfd_putb32 (insn
, (unsigned char *) buf
);
3328 bfd_putl32 (insn
, (unsigned char *) buf
);
3331 /* Are we finished with this relocation now? */
3332 if (fixP
->fx_addsy
== 0 && !fixP
->fx_pcrel
)
3336 /* Translate internal representation of relocation info to BFD target
3340 tc_gen_reloc (asection
*section
, fixS
*fixp
)
3342 static arelent
*relocs
[3];
3344 bfd_reloc_code_real_type code
;
3346 relocs
[0] = reloc
= (arelent
*) xmalloc (sizeof (arelent
));
3349 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3350 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
3351 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3353 switch (fixp
->fx_r_type
)
3357 case BFD_RELOC_HI22
:
3358 case BFD_RELOC_LO10
:
3359 case BFD_RELOC_32_PCREL_S2
:
3360 case BFD_RELOC_SPARC13
:
3361 case BFD_RELOC_SPARC22
:
3362 case BFD_RELOC_SPARC_PC22
:
3363 case BFD_RELOC_SPARC_PC10
:
3364 case BFD_RELOC_SPARC_BASE13
:
3365 case BFD_RELOC_SPARC_WDISP16
:
3366 case BFD_RELOC_SPARC_WDISP19
:
3367 case BFD_RELOC_SPARC_WDISP22
:
3369 case BFD_RELOC_SPARC_5
:
3370 case BFD_RELOC_SPARC_6
:
3371 case BFD_RELOC_SPARC_7
:
3372 case BFD_RELOC_SPARC_10
:
3373 case BFD_RELOC_SPARC_11
:
3374 case BFD_RELOC_SPARC_HH22
:
3375 case BFD_RELOC_SPARC_HM10
:
3376 case BFD_RELOC_SPARC_LM22
:
3377 case BFD_RELOC_SPARC_PC_HH22
:
3378 case BFD_RELOC_SPARC_PC_HM10
:
3379 case BFD_RELOC_SPARC_PC_LM22
:
3380 case BFD_RELOC_SPARC_H44
:
3381 case BFD_RELOC_SPARC_M44
:
3382 case BFD_RELOC_SPARC_L44
:
3383 case BFD_RELOC_SPARC_HIX22
:
3384 case BFD_RELOC_SPARC_LOX10
:
3385 case BFD_RELOC_SPARC_REV32
:
3386 case BFD_RELOC_SPARC_OLO10
:
3387 case BFD_RELOC_SPARC_UA16
:
3388 case BFD_RELOC_SPARC_UA32
:
3389 case BFD_RELOC_SPARC_UA64
:
3390 case BFD_RELOC_8_PCREL
:
3391 case BFD_RELOC_16_PCREL
:
3392 case BFD_RELOC_32_PCREL
:
3393 case BFD_RELOC_64_PCREL
:
3394 case BFD_RELOC_SPARC_PLT32
:
3395 case BFD_RELOC_SPARC_PLT64
:
3396 case BFD_RELOC_VTABLE_ENTRY
:
3397 case BFD_RELOC_VTABLE_INHERIT
:
3398 case BFD_RELOC_SPARC_TLS_GD_HI22
:
3399 case BFD_RELOC_SPARC_TLS_GD_LO10
:
3400 case BFD_RELOC_SPARC_TLS_GD_ADD
:
3401 case BFD_RELOC_SPARC_TLS_GD_CALL
:
3402 case BFD_RELOC_SPARC_TLS_LDM_HI22
:
3403 case BFD_RELOC_SPARC_TLS_LDM_LO10
:
3404 case BFD_RELOC_SPARC_TLS_LDM_ADD
:
3405 case BFD_RELOC_SPARC_TLS_LDM_CALL
:
3406 case BFD_RELOC_SPARC_TLS_LDO_HIX22
:
3407 case BFD_RELOC_SPARC_TLS_LDO_LOX10
:
3408 case BFD_RELOC_SPARC_TLS_LDO_ADD
:
3409 case BFD_RELOC_SPARC_TLS_IE_HI22
:
3410 case BFD_RELOC_SPARC_TLS_IE_LO10
:
3411 case BFD_RELOC_SPARC_TLS_IE_LD
:
3412 case BFD_RELOC_SPARC_TLS_IE_LDX
:
3413 case BFD_RELOC_SPARC_TLS_IE_ADD
:
3414 case BFD_RELOC_SPARC_TLS_LE_HIX22
:
3415 case BFD_RELOC_SPARC_TLS_LE_LOX10
:
3416 case BFD_RELOC_SPARC_TLS_DTPOFF32
:
3417 case BFD_RELOC_SPARC_TLS_DTPOFF64
:
3418 case BFD_RELOC_SPARC_GOTDATA_OP_HIX22
:
3419 case BFD_RELOC_SPARC_GOTDATA_OP_LOX10
:
3420 case BFD_RELOC_SPARC_GOTDATA_OP
:
3421 code
= fixp
->fx_r_type
;
3428 #if defined (OBJ_ELF) || defined (OBJ_AOUT)
3429 /* If we are generating PIC code, we need to generate a different
3433 #define GOT_NAME "_GLOBAL_OFFSET_TABLE_"
3435 #define GOT_NAME "__GLOBAL_OFFSET_TABLE_"
3438 #define GOTT_BASE "__GOTT_BASE__"
3439 #define GOTT_INDEX "__GOTT_INDEX__"
3442 /* This code must be parallel to the OBJ_ELF tc_fix_adjustable. */
3448 case BFD_RELOC_32_PCREL_S2
:
3449 if (generic_force_reloc (fixp
))
3450 code
= BFD_RELOC_SPARC_WPLT30
;
3452 case BFD_RELOC_HI22
:
3453 code
= BFD_RELOC_SPARC_GOT22
;
3454 if (fixp
->fx_addsy
!= NULL
)
3456 if (strcmp (S_GET_NAME (fixp
->fx_addsy
), GOT_NAME
) == 0)
3457 code
= BFD_RELOC_SPARC_PC22
;
3459 if (strcmp (S_GET_NAME (fixp
->fx_addsy
), GOTT_BASE
) == 0
3460 || strcmp (S_GET_NAME (fixp
->fx_addsy
), GOTT_INDEX
) == 0)
3461 code
= BFD_RELOC_HI22
; /* Unchanged. */
3465 case BFD_RELOC_LO10
:
3466 code
= BFD_RELOC_SPARC_GOT10
;
3467 if (fixp
->fx_addsy
!= NULL
)
3469 if (strcmp (S_GET_NAME (fixp
->fx_addsy
), GOT_NAME
) == 0)
3470 code
= BFD_RELOC_SPARC_PC10
;
3472 if (strcmp (S_GET_NAME (fixp
->fx_addsy
), GOTT_BASE
) == 0
3473 || strcmp (S_GET_NAME (fixp
->fx_addsy
), GOTT_INDEX
) == 0)
3474 code
= BFD_RELOC_LO10
; /* Unchanged. */
3478 case BFD_RELOC_SPARC13
:
3479 code
= BFD_RELOC_SPARC_GOT13
;
3485 #endif /* defined (OBJ_ELF) || defined (OBJ_AOUT) */
3487 /* Nothing is aligned in DWARF debugging sections. */
3488 if (bfd_get_section_flags (stdoutput
, section
) & SEC_DEBUGGING
)
3491 case BFD_RELOC_16
: code
= BFD_RELOC_SPARC_UA16
; break;
3492 case BFD_RELOC_32
: code
= BFD_RELOC_SPARC_UA32
; break;
3493 case BFD_RELOC_64
: code
= BFD_RELOC_SPARC_UA64
; break;
3497 if (code
== BFD_RELOC_SPARC_OLO10
)
3498 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_LO10
);
3500 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, code
);
3501 if (reloc
->howto
== 0)
3503 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
3504 _("internal error: can't export reloc type %d (`%s')"),
3505 fixp
->fx_r_type
, bfd_get_reloc_code_name (code
));
3511 /* @@ Why fx_addnumber sometimes and fx_offset other times? */
3514 if (reloc
->howto
->pc_relative
== 0
3515 || code
== BFD_RELOC_SPARC_PC10
3516 || code
== BFD_RELOC_SPARC_PC22
)
3517 reloc
->addend
= fixp
->fx_addnumber
;
3518 else if (sparc_pic_code
3519 && fixp
->fx_r_type
== BFD_RELOC_32_PCREL_S2
3520 && fixp
->fx_addsy
!= NULL
3521 && (S_IS_EXTERNAL (fixp
->fx_addsy
)
3522 || S_IS_WEAK (fixp
->fx_addsy
))
3523 && S_IS_DEFINED (fixp
->fx_addsy
)
3524 && ! S_IS_COMMON (fixp
->fx_addsy
))
3525 reloc
->addend
= fixp
->fx_addnumber
;
3527 reloc
->addend
= fixp
->fx_offset
- reloc
->address
;
3529 #else /* elf or coff */
3531 if (code
!= BFD_RELOC_32_PCREL_S2
3532 && code
!= BFD_RELOC_SPARC_WDISP22
3533 && code
!= BFD_RELOC_SPARC_WDISP16
3534 && code
!= BFD_RELOC_SPARC_WDISP19
3535 && code
!= BFD_RELOC_SPARC_WPLT30
3536 && code
!= BFD_RELOC_SPARC_TLS_GD_CALL
3537 && code
!= BFD_RELOC_SPARC_TLS_LDM_CALL
)
3538 reloc
->addend
= fixp
->fx_addnumber
;
3539 else if (symbol_section_p (fixp
->fx_addsy
))
3540 reloc
->addend
= (section
->vma
3541 + fixp
->fx_addnumber
3542 + md_pcrel_from (fixp
));
3544 reloc
->addend
= fixp
->fx_offset
;
3547 /* We expand R_SPARC_OLO10 to R_SPARC_LO10 and R_SPARC_13
3548 on the same location. */
3549 if (code
== BFD_RELOC_SPARC_OLO10
)
3551 relocs
[1] = reloc
= (arelent
*) xmalloc (sizeof (arelent
));
3554 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
3556 = symbol_get_bfdsym (section_symbol (absolute_section
));
3557 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
3558 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_SPARC13
);
3559 reloc
->addend
= fixp
->tc_fix_data
;
3565 /* We have no need to default values of symbols. */
3568 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
3573 /* Round up a section size to the appropriate boundary. */
3576 md_section_align (segT segment ATTRIBUTE_UNUSED
, valueT size
)
3579 /* This is not right for ELF; a.out wants it, and COFF will force
3580 the alignment anyways. */
3581 valueT align
= ((valueT
) 1
3582 << (valueT
) bfd_get_section_alignment (stdoutput
, segment
));
3585 /* Turn alignment value into a mask. */
3587 newsize
= (size
+ align
) & ~align
;
3594 /* Exactly what point is a PC-relative offset relative TO?
3595 On the sparc, they're relative to the address of the offset, plus
3596 its size. This gets us to the following instruction.
3597 (??? Is this right? FIXME-SOON) */
3599 md_pcrel_from (fixS
*fixP
)
3603 ret
= fixP
->fx_where
+ fixP
->fx_frag
->fr_address
;
3604 if (! sparc_pic_code
3605 || fixP
->fx_addsy
== NULL
3606 || symbol_section_p (fixP
->fx_addsy
))
3607 ret
+= fixP
->fx_size
;
3611 /* Return log2 (VALUE), or -1 if VALUE is not an exact positive power
3622 for (shift
= 0; (value
& 1) == 0; value
>>= 1)
3625 return (value
== 1) ? shift
: -1;
3628 /* Sort of like s_lcomm. */
3631 static int max_alignment
= 15;
3635 s_reserve (int ignore ATTRIBUTE_UNUSED
)
3645 name
= input_line_pointer
;
3646 c
= get_symbol_end ();
3647 p
= input_line_pointer
;
3651 if (*input_line_pointer
!= ',')
3653 as_bad (_("Expected comma after name"));
3654 ignore_rest_of_line ();
3658 ++input_line_pointer
;
3660 if ((size
= get_absolute_expression ()) < 0)
3662 as_bad (_("BSS length (%d.) <0! Ignored."), size
);
3663 ignore_rest_of_line ();
3668 symbolP
= symbol_find_or_make (name
);
3671 if (strncmp (input_line_pointer
, ",\"bss\"", 6) != 0
3672 && strncmp (input_line_pointer
, ",\".bss\"", 7) != 0)
3674 as_bad (_("bad .reserve segment -- expected BSS segment"));
3678 if (input_line_pointer
[2] == '.')
3679 input_line_pointer
+= 7;
3681 input_line_pointer
+= 6;
3684 if (*input_line_pointer
== ',')
3686 ++input_line_pointer
;
3689 if (*input_line_pointer
== '\n')
3691 as_bad (_("missing alignment"));
3692 ignore_rest_of_line ();
3696 align
= (int) get_absolute_expression ();
3699 if (align
> max_alignment
)
3701 align
= max_alignment
;
3702 as_warn (_("alignment too large; assuming %d"), align
);
3708 as_bad (_("negative alignment"));
3709 ignore_rest_of_line ();
3715 temp
= mylog2 (align
);
3718 as_bad (_("alignment not a power of 2"));
3719 ignore_rest_of_line ();
3726 record_alignment (bss_section
, align
);
3731 if (!S_IS_DEFINED (symbolP
)
3733 && S_GET_OTHER (symbolP
) == 0
3734 && S_GET_DESC (symbolP
) == 0
3741 segT current_seg
= now_seg
;
3742 subsegT current_subseg
= now_subseg
;
3744 /* Switch to bss. */
3745 subseg_set (bss_section
, 1);
3749 frag_align (align
, 0, 0);
3751 /* Detach from old frag. */
3752 if (S_GET_SEGMENT (symbolP
) == bss_section
)
3753 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
3755 symbol_set_frag (symbolP
, frag_now
);
3756 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
3757 (offsetT
) size
, (char *) 0);
3760 S_SET_SEGMENT (symbolP
, bss_section
);
3762 subseg_set (current_seg
, current_subseg
);
3765 S_SET_SIZE (symbolP
, size
);
3771 as_warn ("Ignoring attempt to re-define symbol %s",
3772 S_GET_NAME (symbolP
));
3773 } /* if not redefining. */
3775 demand_empty_rest_of_line ();
3779 s_common (int ignore ATTRIBUTE_UNUSED
)
3787 name
= input_line_pointer
;
3788 c
= get_symbol_end ();
3789 /* Just after name is now '\0'. */
3790 p
= input_line_pointer
;
3793 if (*input_line_pointer
!= ',')
3795 as_bad (_("Expected comma after symbol-name"));
3796 ignore_rest_of_line ();
3801 input_line_pointer
++;
3803 if ((temp
= get_absolute_expression ()) < 0)
3805 as_bad (_(".COMMon length (%lu) out of range ignored"),
3806 (unsigned long) temp
);
3807 ignore_rest_of_line ();
3812 symbolP
= symbol_find_or_make (name
);
3814 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
3816 as_bad (_("Ignoring attempt to re-define symbol"));
3817 ignore_rest_of_line ();
3820 if (S_GET_VALUE (symbolP
) != 0)
3822 if (S_GET_VALUE (symbolP
) != (valueT
) size
)
3824 as_warn (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
3825 S_GET_NAME (symbolP
), (long) S_GET_VALUE (symbolP
), (long) size
);
3831 S_SET_VALUE (symbolP
, (valueT
) size
);
3832 S_SET_EXTERNAL (symbolP
);
3835 know (symbol_get_frag (symbolP
) == &zero_address_frag
);
3836 if (*input_line_pointer
!= ',')
3838 as_bad (_("Expected comma after common length"));
3839 ignore_rest_of_line ();
3842 input_line_pointer
++;
3844 if (*input_line_pointer
!= '"')
3846 temp
= get_absolute_expression ();
3849 if (temp
> max_alignment
)
3851 temp
= max_alignment
;
3852 as_warn (_("alignment too large; assuming %ld"), (long) temp
);
3858 as_bad (_("negative alignment"));
3859 ignore_rest_of_line ();
3864 if (symbol_get_obj (symbolP
)->local
)
3872 old_subsec
= now_subseg
;
3877 align
= mylog2 (temp
);
3881 as_bad (_("alignment not a power of 2"));
3882 ignore_rest_of_line ();
3886 record_alignment (bss_section
, align
);
3887 subseg_set (bss_section
, 0);
3889 frag_align (align
, 0, 0);
3890 if (S_GET_SEGMENT (symbolP
) == bss_section
)
3891 symbol_get_frag (symbolP
)->fr_symbol
= 0;
3892 symbol_set_frag (symbolP
, frag_now
);
3893 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
3894 (offsetT
) size
, (char *) 0);
3896 S_SET_SEGMENT (symbolP
, bss_section
);
3897 S_CLEAR_EXTERNAL (symbolP
);
3898 S_SET_SIZE (symbolP
, size
);
3899 subseg_set (old_sec
, old_subsec
);
3902 #endif /* OBJ_ELF */
3905 S_SET_VALUE (symbolP
, (valueT
) size
);
3907 S_SET_ALIGN (symbolP
, temp
);
3908 S_SET_SIZE (symbolP
, size
);
3910 S_SET_EXTERNAL (symbolP
);
3911 S_SET_SEGMENT (symbolP
, bfd_com_section_ptr
);
3916 input_line_pointer
++;
3917 /* @@ Some use the dot, some don't. Can we get some consistency?? */
3918 if (*input_line_pointer
== '.')
3919 input_line_pointer
++;
3920 /* @@ Some say data, some say bss. */
3921 if (strncmp (input_line_pointer
, "bss\"", 4)
3922 && strncmp (input_line_pointer
, "data\"", 5))
3924 while (*--input_line_pointer
!= '"')
3926 input_line_pointer
--;
3927 goto bad_common_segment
;
3929 while (*input_line_pointer
++ != '"')
3931 goto allocate_common
;
3934 symbol_get_bfdsym (symbolP
)->flags
|= BSF_OBJECT
;
3936 demand_empty_rest_of_line ();
3941 p
= input_line_pointer
;
3942 while (*p
&& *p
!= '\n')
3946 as_bad (_("bad .common segment %s"), input_line_pointer
+ 1);
3948 input_line_pointer
= p
;
3949 ignore_rest_of_line ();
3954 /* Handle the .empty pseudo-op. This suppresses the warnings about
3955 invalid delay slot usage. */
3958 s_empty (int ignore ATTRIBUTE_UNUSED
)
3960 /* The easy way to implement is to just forget about the last
3966 s_seg (int ignore ATTRIBUTE_UNUSED
)
3969 if (strncmp (input_line_pointer
, "\"text\"", 6) == 0)
3971 input_line_pointer
+= 6;
3975 if (strncmp (input_line_pointer
, "\"data\"", 6) == 0)
3977 input_line_pointer
+= 6;
3981 if (strncmp (input_line_pointer
, "\"data1\"", 7) == 0)
3983 input_line_pointer
+= 7;
3987 if (strncmp (input_line_pointer
, "\"bss\"", 5) == 0)
3989 input_line_pointer
+= 5;
3990 /* We only support 2 segments -- text and data -- for now, so
3991 things in the "bss segment" will have to go into data for now.
3992 You can still allocate SEG_BSS stuff with .lcomm or .reserve. */
3993 subseg_set (data_section
, 255); /* FIXME-SOMEDAY. */
3996 as_bad (_("Unknown segment type"));
3997 demand_empty_rest_of_line ();
4003 subseg_set (data_section
, 1);
4004 demand_empty_rest_of_line ();
4008 s_proc (int ignore ATTRIBUTE_UNUSED
)
4010 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
4012 ++input_line_pointer
;
4014 ++input_line_pointer
;
4017 /* This static variable is set by s_uacons to tell sparc_cons_align
4018 that the expression does not need to be aligned. */
4020 static int sparc_no_align_cons
= 0;
4022 /* This static variable is set by sparc_cons to emit requested types
4023 of relocations in cons_fix_new_sparc. */
4025 static const char *sparc_cons_special_reloc
;
4027 /* This handles the unaligned space allocation pseudo-ops, such as
4028 .uaword. .uaword is just like .word, but the value does not need
4032 s_uacons (int bytes
)
4034 /* Tell sparc_cons_align not to align this value. */
4035 sparc_no_align_cons
= 1;
4037 sparc_no_align_cons
= 0;
4040 /* This handles the native word allocation pseudo-op .nword.
4041 For sparc_arch_size 32 it is equivalent to .word, for
4042 sparc_arch_size 64 it is equivalent to .xword. */
4045 s_ncons (int bytes ATTRIBUTE_UNUSED
)
4047 cons (sparc_arch_size
== 32 ? 4 : 8);
4051 /* Handle the SPARC ELF .register pseudo-op. This sets the binding of a
4055 .register %g[2367],{#scratch|symbolname|#ignore}
4059 s_register (int ignore ATTRIBUTE_UNUSED
)
4064 const char *regname
;
4066 if (input_line_pointer
[0] != '%'
4067 || input_line_pointer
[1] != 'g'
4068 || ((input_line_pointer
[2] & ~1) != '2'
4069 && (input_line_pointer
[2] & ~1) != '6')
4070 || input_line_pointer
[3] != ',')
4071 as_bad (_("register syntax is .register %%g[2367],{#scratch|symbolname|#ignore}"));
4072 reg
= input_line_pointer
[2] - '0';
4073 input_line_pointer
+= 4;
4075 if (*input_line_pointer
== '#')
4077 ++input_line_pointer
;
4078 regname
= input_line_pointer
;
4079 c
= get_symbol_end ();
4080 if (strcmp (regname
, "scratch") && strcmp (regname
, "ignore"))
4081 as_bad (_("register syntax is .register %%g[2367],{#scratch|symbolname|#ignore}"));
4082 if (regname
[0] == 'i')
4089 regname
= input_line_pointer
;
4090 c
= get_symbol_end ();
4092 if (sparc_arch_size
== 64)
4096 if ((regname
&& globals
[reg
] != (symbolS
*) 1
4097 && strcmp (S_GET_NAME (globals
[reg
]), regname
))
4098 || ((regname
!= NULL
) ^ (globals
[reg
] != (symbolS
*) 1)))
4099 as_bad (_("redefinition of global register"));
4103 if (regname
== NULL
)
4104 globals
[reg
] = (symbolS
*) 1;
4109 if (symbol_find (regname
))
4110 as_bad (_("Register symbol %s already defined."),
4113 globals
[reg
] = symbol_make (regname
);
4114 flags
= symbol_get_bfdsym (globals
[reg
])->flags
;
4116 flags
= flags
& ~(BSF_GLOBAL
|BSF_LOCAL
|BSF_WEAK
);
4117 if (! (flags
& (BSF_GLOBAL
|BSF_LOCAL
|BSF_WEAK
)))
4118 flags
|= BSF_GLOBAL
;
4119 symbol_get_bfdsym (globals
[reg
])->flags
= flags
;
4120 S_SET_VALUE (globals
[reg
], (valueT
) reg
);
4121 S_SET_ALIGN (globals
[reg
], reg
);
4122 S_SET_SIZE (globals
[reg
], 0);
4123 /* Although we actually want undefined_section here,
4124 we have to use absolute_section, because otherwise
4125 generic as code will make it a COM section.
4126 We fix this up in sparc_adjust_symtab. */
4127 S_SET_SEGMENT (globals
[reg
], absolute_section
);
4128 S_SET_OTHER (globals
[reg
], 0);
4129 elf_symbol (symbol_get_bfdsym (globals
[reg
]))
4130 ->internal_elf_sym
.st_info
=
4131 ELF_ST_INFO(STB_GLOBAL
, STT_REGISTER
);
4132 elf_symbol (symbol_get_bfdsym (globals
[reg
]))
4133 ->internal_elf_sym
.st_shndx
= SHN_UNDEF
;
4138 *input_line_pointer
= c
;
4140 demand_empty_rest_of_line ();
4143 /* Adjust the symbol table. We set undefined sections for STT_REGISTER
4144 symbols which need it. */
4147 sparc_adjust_symtab (void)
4151 for (sym
= symbol_rootP
; sym
!= NULL
; sym
= symbol_next (sym
))
4153 if (ELF_ST_TYPE (elf_symbol (symbol_get_bfdsym (sym
))
4154 ->internal_elf_sym
.st_info
) != STT_REGISTER
)
4157 if (ELF_ST_TYPE (elf_symbol (symbol_get_bfdsym (sym
))
4158 ->internal_elf_sym
.st_shndx
!= SHN_UNDEF
))
4161 S_SET_SEGMENT (sym
, undefined_section
);
4166 /* If the --enforce-aligned-data option is used, we require .word,
4167 et. al., to be aligned correctly. We do it by setting up an
4168 rs_align_code frag, and checking in HANDLE_ALIGN to make sure that
4169 no unexpected alignment was introduced.
4171 The SunOS and Solaris native assemblers enforce aligned data by
4172 default. We don't want to do that, because gcc can deliberately
4173 generate misaligned data if the packed attribute is used. Instead,
4174 we permit misaligned data by default, and permit the user to set an
4175 option to check for it. */
4178 sparc_cons_align (int nbytes
)
4183 /* Only do this if we are enforcing aligned data. */
4184 if (! enforce_aligned_data
)
4187 /* Don't align if this is an unaligned pseudo-op. */
4188 if (sparc_no_align_cons
)
4191 nalign
= mylog2 (nbytes
);
4195 assert (nalign
> 0);
4197 if (now_seg
== absolute_section
)
4199 if ((abs_section_offset
& ((1 << nalign
) - 1)) != 0)
4200 as_bad (_("misaligned data"));
4204 p
= frag_var (rs_align_test
, 1, 1, (relax_substateT
) 0,
4205 (symbolS
*) NULL
, (offsetT
) nalign
, (char *) NULL
);
4207 record_alignment (now_seg
, nalign
);
4210 /* This is called from HANDLE_ALIGN in tc-sparc.h. */
4213 sparc_handle_align (fragS
*fragp
)
4218 count
= fragp
->fr_next
->fr_address
- fragp
->fr_address
- fragp
->fr_fix
;
4220 switch (fragp
->fr_type
)
4224 as_bad_where (fragp
->fr_file
, fragp
->fr_line
, _("misaligned data"));
4228 p
= fragp
->fr_literal
+ fragp
->fr_fix
;
4239 if (SPARC_OPCODE_ARCH_V9_P (max_architecture
) && count
> 8)
4241 unsigned wval
= (0x30680000 | count
>> 2); /* ba,a,pt %xcc, 1f */
4242 if (INSN_BIG_ENDIAN
)
4243 number_to_chars_bigendian (p
, wval
, 4);
4245 number_to_chars_littleendian (p
, wval
, 4);
4251 if (INSN_BIG_ENDIAN
)
4252 number_to_chars_bigendian (p
, 0x01000000, 4);
4254 number_to_chars_littleendian (p
, 0x01000000, 4);
4256 fragp
->fr_fix
+= fix
;
4266 /* Some special processing for a Sparc ELF file. */
4269 sparc_elf_final_processing (void)
4271 /* Set the Sparc ELF flag bits. FIXME: There should probably be some
4272 sort of BFD interface for this. */
4273 if (sparc_arch_size
== 64)
4275 switch (sparc_memory_model
)
4278 elf_elfheader (stdoutput
)->e_flags
|= EF_SPARCV9_RMO
;
4281 elf_elfheader (stdoutput
)->e_flags
|= EF_SPARCV9_PSO
;
4287 else if (current_architecture
>= SPARC_OPCODE_ARCH_V9
)
4288 elf_elfheader (stdoutput
)->e_flags
|= EF_SPARC_32PLUS
;
4289 if (current_architecture
== SPARC_OPCODE_ARCH_V9A
)
4290 elf_elfheader (stdoutput
)->e_flags
|= EF_SPARC_SUN_US1
;
4291 else if (current_architecture
== SPARC_OPCODE_ARCH_V9B
)
4292 elf_elfheader (stdoutput
)->e_flags
|= EF_SPARC_SUN_US1
|EF_SPARC_SUN_US3
;
4296 sparc_cons (expressionS
*exp
, int size
)
4301 sparc_cons_special_reloc
= NULL
;
4302 save
= input_line_pointer
;
4303 if (input_line_pointer
[0] == '%'
4304 && input_line_pointer
[1] == 'r'
4305 && input_line_pointer
[2] == '_')
4307 if (strncmp (input_line_pointer
+ 3, "disp", 4) == 0)
4309 input_line_pointer
+= 7;
4310 sparc_cons_special_reloc
= "disp";
4312 else if (strncmp (input_line_pointer
+ 3, "plt", 3) == 0)
4314 if (size
!= 4 && size
!= 8)
4315 as_bad (_("Illegal operands: %%r_plt in %d-byte data field"), size
);
4318 input_line_pointer
+= 6;
4319 sparc_cons_special_reloc
= "plt";
4322 else if (strncmp (input_line_pointer
+ 3, "tls_dtpoff", 10) == 0)
4324 if (size
!= 4 && size
!= 8)
4325 as_bad (_("Illegal operands: %%r_tls_dtpoff in %d-byte data field"), size
);
4328 input_line_pointer
+= 13;
4329 sparc_cons_special_reloc
= "tls_dtpoff";
4332 if (sparc_cons_special_reloc
)
4339 if (*input_line_pointer
!= '8')
4341 input_line_pointer
--;
4344 if (input_line_pointer
[0] != '1' || input_line_pointer
[1] != '6')
4348 if (input_line_pointer
[0] != '3' || input_line_pointer
[1] != '2')
4352 if (input_line_pointer
[0] != '6' || input_line_pointer
[1] != '4')
4362 as_bad (_("Illegal operands: Only %%r_%s%d allowed in %d-byte data fields"),
4363 sparc_cons_special_reloc
, size
* 8, size
);
4367 input_line_pointer
+= 2;
4368 if (*input_line_pointer
!= '(')
4370 as_bad (_("Illegal operands: %%r_%s%d requires arguments in ()"),
4371 sparc_cons_special_reloc
, size
* 8);
4378 input_line_pointer
= save
;
4379 sparc_cons_special_reloc
= NULL
;
4384 char *end
= ++input_line_pointer
;
4387 while (! is_end_of_line
[(c
= *end
)])
4401 as_bad (_("Illegal operands: %%r_%s%d requires arguments in ()"),
4402 sparc_cons_special_reloc
, size
* 8);
4408 if (input_line_pointer
!= end
)
4410 as_bad (_("Illegal operands: %%r_%s%d requires arguments in ()"),
4411 sparc_cons_special_reloc
, size
* 8);
4415 input_line_pointer
++;
4417 c
= *input_line_pointer
;
4418 if (! is_end_of_line
[c
] && c
!= ',')
4419 as_bad (_("Illegal operands: garbage after %%r_%s%d()"),
4420 sparc_cons_special_reloc
, size
* 8);
4426 if (sparc_cons_special_reloc
== NULL
)
4432 /* This is called by emit_expr via TC_CONS_FIX_NEW when creating a
4433 reloc for a cons. We could use the definition there, except that
4434 we want to handle little endian relocs specially. */
4437 cons_fix_new_sparc (fragS
*frag
,
4439 unsigned int nbytes
,
4442 bfd_reloc_code_real_type r
;
4444 r
= (nbytes
== 1 ? BFD_RELOC_8
:
4445 (nbytes
== 2 ? BFD_RELOC_16
:
4446 (nbytes
== 4 ? BFD_RELOC_32
: BFD_RELOC_64
)));
4448 if (target_little_endian_data
4450 && now_seg
->flags
& SEC_ALLOC
)
4451 r
= BFD_RELOC_SPARC_REV32
;
4453 if (sparc_cons_special_reloc
)
4455 if (*sparc_cons_special_reloc
== 'd')
4458 case 1: r
= BFD_RELOC_8_PCREL
; break;
4459 case 2: r
= BFD_RELOC_16_PCREL
; break;
4460 case 4: r
= BFD_RELOC_32_PCREL
; break;
4461 case 8: r
= BFD_RELOC_64_PCREL
; break;
4464 else if (*sparc_cons_special_reloc
== 'p')
4467 case 4: r
= BFD_RELOC_SPARC_PLT32
; break;
4468 case 8: r
= BFD_RELOC_SPARC_PLT64
; break;
4473 case 4: r
= BFD_RELOC_SPARC_TLS_DTPOFF32
; break;
4474 case 8: r
= BFD_RELOC_SPARC_TLS_DTPOFF64
; break;
4477 else if (sparc_no_align_cons
)
4481 case 2: r
= BFD_RELOC_SPARC_UA16
; break;
4482 case 4: r
= BFD_RELOC_SPARC_UA32
; break;
4483 case 8: r
= BFD_RELOC_SPARC_UA64
; break;
4488 fix_new_exp (frag
, where
, (int) nbytes
, exp
, 0, r
);
4489 sparc_cons_special_reloc
= NULL
;
4493 sparc_cfi_frame_initial_instructions (void)
4495 cfi_add_CFA_def_cfa (14, sparc_arch_size
== 64 ? 0x7ff : 0);
4499 sparc_regname_to_dw2regnum (char *regname
)
4507 p
= strchr (q
, regname
[0]);
4510 if (regname
[1] < '0' || regname
[1] > '8' || regname
[2])
4512 return (p
- q
) * 8 + regname
[1] - '0';
4514 if (regname
[0] == 's' && regname
[1] == 'p' && !regname
[2])
4516 if (regname
[0] == 'f' && regname
[1] == 'p' && !regname
[2])
4518 if (regname
[0] == 'f' || regname
[0] == 'r')
4520 unsigned int regnum
;
4522 regnum
= strtoul (regname
+ 1, &q
, 10);
4525 if (regnum
>= ((regname
[0] == 'f'
4526 && SPARC_OPCODE_ARCH_V9_P (max_architecture
))
4529 if (regname
[0] == 'f')
4532 if (regnum
>= 64 && (regnum
& 1))
4541 sparc_cfi_emit_pcrel_expr (expressionS
*exp
, unsigned int nbytes
)
4543 sparc_cons_special_reloc
= "disp";
4544 sparc_no_align_cons
= 1;
4545 emit_expr (exp
, nbytes
);
4546 sparc_no_align_cons
= 0;
4547 sparc_cons_special_reloc
= NULL
;