1 /* tc-arc.c -- Assembler for the ARC
2 Copyright (C) 1994, 1995, 1997, 2000 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 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include "libiberty.h"
27 #include "opcode/arc.h"
28 #include "../opcodes/arc-ext.h"
31 extern int arc_get_mach PARAMS ((char *));
32 extern int arc_operand_type PARAMS ((int));
33 extern int arc_insn_not_jl PARAMS ((arc_insn));
34 extern int arc_limm_fixup_adjust PARAMS ((arc_insn));
35 extern int arc_get_noshortcut_flag PARAMS ((void));
36 extern int arc_set_ext_seg PARAMS ((void));
37 extern void arc_code_symbol PARAMS ((expressionS *));
39 static arc_insn arc_insert_operand PARAMS ((arc_insn,
40 const struct arc_operand *, int,
41 const struct arc_operand_value *,
42 offsetT, char *, unsigned int));
43 static void arc_common PARAMS ((int));
44 static void arc_extinst PARAMS ((int));
45 static void arc_extoper PARAMS ((int));
46 static void arc_option PARAMS ((int));
47 static int get_arc_exp_reloc_type PARAMS ((int, int, expressionS *,
50 const struct suffix_classes {
54 { "SUFFIX_COND|SUFFIX_FLAG",23 },
55 { "SUFFIX_FLAG", 11 },
56 { "SUFFIX_COND", 11 },
60 #define MAXSUFFIXCLASS (sizeof (suffixclass) / sizeof (struct suffix_classes))
62 const struct syntax_classes {
67 { "SYNTAX_3OP|OP1_MUST_BE_IMM", 26, SYNTAX_3OP|OP1_MUST_BE_IMM|SYNTAX_VALID },
68 { "OP1_MUST_BE_IMM|SYNTAX_3OP", 26, OP1_MUST_BE_IMM|SYNTAX_3OP|SYNTAX_VALID },
69 { "SYNTAX_2OP|OP1_IMM_IMPLIED", 26, SYNTAX_2OP|OP1_IMM_IMPLIED|SYNTAX_VALID },
70 { "OP1_IMM_IMPLIED|SYNTAX_2OP", 26, OP1_IMM_IMPLIED|SYNTAX_2OP|SYNTAX_VALID },
71 { "SYNTAX_3OP", 10, SYNTAX_3OP|SYNTAX_VALID },
72 { "SYNTAX_2OP", 10, SYNTAX_2OP|SYNTAX_VALID }
75 #define MAXSYNTAXCLASS (sizeof (syntaxclass) / sizeof (struct syntax_classes))
77 const pseudo_typeS md_pseudo_table[] = {
78 { "align", s_align_bytes, 0 }, /* Defaulting is invalid (0) */
79 { "comm", arc_common, 0 },
80 { "common", arc_common, 0 },
81 { "lcomm", arc_common, 1 },
82 { "lcommon", arc_common, 1 },
89 { "option", arc_option, 0 },
90 { "block", s_space, 0 },
91 { "extcondcode", arc_extoper, 0 },
92 { "extcoreregister", arc_extoper, 1 },
93 { "extauxregister", arc_extoper, 2 },
94 { "extinstruction", arc_extinst, 0 },
98 /* This array holds the chars that always start a comment. If the
99 pre-processor is disabled, these aren't very useful */
100 const char comment_chars[] = "#;";
102 /* This array holds the chars that only start a comment at the beginning of
103 a line. If the line seems to have the form '# 123 filename'
104 .line and .file directives will appear in the pre-processed output */
105 /* Note that input_file.c hand checks for '#' at the beginning of the
106 first line of the input file. This is because the compiler outputs
107 #NO_APP at the beginning of its output. */
108 /* Also note that comments started like this one will always
109 work if '/' isn't otherwise defined. */
110 const char line_comment_chars[] = "#";
112 const char line_separator_chars[] = "";
114 /* Chars that can be used to separate mant from exp in floating point nums */
115 const char EXP_CHARS[] = "eE";
117 /* Chars that mean this number is a floating point constant */
120 const char FLT_CHARS[] = "rRsSfFdD";
123 extern int target_big_endian;
124 const char *arc_target_format = DEFAULT_TARGET_FORMAT;
125 static int byte_order = DEFAULT_BYTE_ORDER;
127 static segT arcext_section;
129 /* One of bfd_mach_arc_n. */
130 static int arc_mach_type = bfd_mach_arc_5;
132 /* Non-zero if the cpu type has been explicitly specified. */
133 static int mach_type_specified_p = 0;
135 /* Non-zero if opcode tables have been initialized.
136 A .cpu command must appear before any instructions. */
137 static int cpu_tables_init_p = 0;
139 static struct hash_control *arc_suffix_hash = NULL;
141 const char *md_shortopts = "";
142 struct option md_longopts[] = {
143 #define OPTION_EB (OPTION_MD_BASE + 0)
144 {"EB", no_argument, NULL, OPTION_EB},
145 #define OPTION_EL (OPTION_MD_BASE + 1)
146 {"EL", no_argument, NULL, OPTION_EL},
147 #define OPTION_ARC5 (OPTION_MD_BASE + 2)
148 {"marc5", no_argument, NULL, OPTION_ARC5},
149 #define OPTION_ARC6 (OPTION_MD_BASE + 3)
150 {"marc6", no_argument, NULL, OPTION_ARC6},
151 #define OPTION_ARC7 (OPTION_MD_BASE + 4)
152 {"marc7", no_argument, NULL, OPTION_ARC7},
153 #define OPTION_ARC8 (OPTION_MD_BASE + 5)
154 {"marc8", no_argument, NULL, OPTION_ARC8},
155 #define OPTION_ARC (OPTION_MD_BASE + 6)
156 {"marc", no_argument, NULL, OPTION_ARC},
157 { NULL, no_argument, NULL, 0 }
159 size_t md_longopts_size = sizeof (md_longopts);
161 #define IS_SYMBOL_OPERAND(o) \
162 ((o) == 'b' || (o) == 'c' || (o) == 's' || (o) == 'o' || (o) == 'O')
164 struct arc_operand_value *get_ext_suffix (char *s);
166 /* Invocation line includes a switch not recognized by the base assembler.
167 See if it's a processor-specific option. */
170 md_parse_option (c, arg)
172 char *arg ATTRIBUTE_UNUSED;
178 arc_mach_type = bfd_mach_arc_5;
181 arc_mach_type = bfd_mach_arc_6;
184 arc_mach_type = bfd_mach_arc_7;
187 arc_mach_type = bfd_mach_arc_8;
190 byte_order = BIG_ENDIAN;
191 arc_target_format = "elf32-bigarc";
194 byte_order = LITTLE_ENDIAN;
195 arc_target_format = "elf32-littlearc";
204 md_show_usage (stream)
209 -marc[5|6|7|8] select processor variant (default arc%d)\n\
210 -EB assemble code for a big endian cpu\n\
211 -EL assemble code for a little endian cpu\n", arc_mach_type + 5);
214 /* This function is called once, at assembler startup time. It should
215 set up all the tables, etc. that the MD part of the assembler will need.
216 Opcode selection is defered until later because we might see a .cpu
222 /* The endianness can be chosen "at the factory". */
223 target_big_endian = byte_order == BIG_ENDIAN;
225 if (!bfd_set_arch_mach (stdoutput, bfd_arch_arc, arc_mach_type))
226 as_warn ("could not set architecture and machine");
228 /* This call is necessary because we need to
229 initialize `arc_operand_map' which may be needed before we see the
231 arc_opcode_init_tables (arc_get_opcode_mach (arc_mach_type,
235 /* Initialize the various opcode and operand tables.
236 MACH is one of bfd_mach_arc_xxx. */
239 init_opcode_tables (mach)
245 if ((arc_suffix_hash = hash_new ()) == NULL)
246 as_fatal ("virtual memory exhausted");
248 if (!bfd_set_arch_mach (stdoutput, bfd_arch_arc, mach))
249 as_warn ("could not set architecture and machine");
251 /* This initializes a few things in arc-opc.c that we need.
252 This must be called before the various arc_xxx_supported fns. */
253 arc_opcode_init_tables (arc_get_opcode_mach (mach, target_big_endian));
255 /* Only put the first entry of each equivalently named suffix in the
258 for (i = 0; i < arc_suffixes_count; i++)
260 if (strcmp (arc_suffixes[i].name, last) != 0)
261 hash_insert (arc_suffix_hash, arc_suffixes[i].name, (PTR) (arc_suffixes + i));
262 last = arc_suffixes[i].name;
265 /* Since registers don't have a prefix, we put them in the symbol table so
266 they can't be used as symbols. This also simplifies argument parsing as
267 we can let gas parse registers for us. The recorded register number is
268 the address of the register's entry in arc_reg_names.
270 If the register name is already in the table, then the existing
271 definition is assumed to be from an .ExtCoreRegister pseudo-op. */
273 for (i = 0; i < arc_reg_names_count; i++)
275 if (symbol_find (arc_reg_names[i].name))
277 /* Use symbol_create here instead of symbol_new so we don't try to
278 output registers into the object file's symbol table. */
279 symbol_table_insert (symbol_create (arc_reg_names[i].name, reg_section,
280 (int) &arc_reg_names[i], &zero_address_frag));
283 /* Tell `.option' it's too late. */
284 cpu_tables_init_p = 1;
287 /* Insert an operand value into an instruction.
288 If REG is non-NULL, it is a register number and ignore VAL. */
291 arc_insert_operand (insn, operand, mods, reg, val, file, line)
293 const struct arc_operand *operand;
295 const struct arc_operand_value *reg;
300 if (operand->bits != 32)
305 if ((operand->flags & ARC_OPERAND_SIGNED) != 0)
307 if ((operand->flags & ARC_OPERAND_SIGNOPT) != 0)
308 max = (1 << operand->bits) - 1;
310 max = (1 << (operand->bits - 1)) - 1;
311 min = - (1 << (operand->bits - 1));
315 max = (1 << operand->bits) - 1;
319 if ((operand->flags & ARC_OPERAND_NEGATIVE) != 0)
324 if (test < (offsetT) min || test > (offsetT) max)
327 "operand out of range (%s not between %ld and %ld)";
330 sprint_value (buf, test);
331 if (file == (char *) NULL)
332 as_warn (err, buf, min, max);
334 as_warn_where (file, line, err, buf, min, max);
343 insn = (*operand->insert) (insn, operand, mods, reg, (long) val, &errmsg);
344 if (errmsg != (const char *) NULL)
348 insn |= (((long) val & ((1 << operand->bits) - 1))
354 /* We need to keep a list of fixups. We can't simply generate them as
355 we go, because that would require us to first create the frag, and
356 that would screw up references to ``.''. */
359 /* index into `arc_operands' */
366 #define MAX_SUFFIXES 5
368 /* This routine is called for each instruction to be assembled. */
374 const struct arc_opcode *opcode;
375 const struct arc_opcode *std_opcode;
376 struct arc_opcode *ext_opcode;
378 const char *last_errmsg = 0;
380 static int init_tables_p = 0;
382 /* Opcode table initialization is deferred until here because we have to
383 wait for a possible .cpu command. */
386 init_opcode_tables (arc_mach_type);
390 /* Skip leading white space. */
391 while (isspace (*str))
394 /* The instructions are stored in lists hashed by the first letter (though
395 we needn't care how they're hashed). Get the first in the list. */
397 ext_opcode = arc_ext_opcodes;
398 std_opcode = arc_opcode_lookup_asm (str);
400 /* Keep looking until we find a match. */
403 for (opcode = (ext_opcode ? ext_opcode : std_opcode);
405 opcode = (ARC_OPCODE_NEXT_ASM (opcode)
406 ? ARC_OPCODE_NEXT_ASM (opcode)
407 : (ext_opcode ? ext_opcode = NULL, std_opcode : NULL)))
409 int past_opcode_p, fc, num_suffixes;
412 struct arc_fixup fixups[MAX_FIXUPS];
413 /* Used as a sanity check. If we need a limm reloc, make sure we ask
414 for an extra 4 bytes from frag_more. */
417 const struct arc_operand_value *insn_suffixes[MAX_SUFFIXES];
419 /* Is this opcode supported by the selected cpu? */
420 if (! arc_opcode_supported (opcode))
423 /* Scan the syntax string. If it doesn't match, try the next one. */
425 arc_opcode_init_insert ();
426 insn = opcode->value;
433 /* We don't check for (*str != '\0') here because we want to parse
434 any trailing fake arguments in the syntax string. */
435 for (str = start, syn = opcode->syntax; *syn != '\0';)
438 const struct arc_operand *operand;
440 /* Non operand chars must match exactly. */
441 if (*syn != '%' || *++syn == '%')
443 /* Handle '+' specially as we want to allow "ld r0,[sp-4]". */
444 /* ??? The syntax has changed to [sp,-4]. */
445 if (0 && *syn == '+' && *str == '-')
447 /* Skip over syn's +, but leave str's - alone.
448 That makes the case identical to "ld r0,[sp+-4]". */
451 else if (*str == *syn)
463 /* We have an operand. Pick out any modifiers. */
465 while (ARC_MOD_P (arc_operands[arc_operand_map[(int) *syn]].flags))
467 mods |= arc_operands[arc_operand_map[(int) *syn]].flags & ARC_MOD_BITS;
470 operand = arc_operands + arc_operand_map[(int) *syn];
471 if (operand->fmt == 0)
472 as_fatal ("unknown syntax format character `%c'", *syn);
474 if (operand->flags & ARC_OPERAND_FAKE)
476 const char *errmsg = NULL;
479 insn = (*operand->insert) (insn, operand, mods, NULL, 0, &errmsg);
480 if (errmsg != (const char *) NULL)
482 last_errmsg = errmsg;
483 if (operand->flags & ARC_OPERAND_ERROR)
488 else if (operand->flags & ARC_OPERAND_WARN)
493 && (operand->flags && operand->flags & ARC_OPERAND_LIMM)
495 (ARC_OPERAND_ABSOLUTE_BRANCH | ARC_OPERAND_ADDRESS)))
497 fixups[fix_up_at].opindex = arc_operand_map[operand->fmt];
502 /* Are we finished with suffixes? */
503 else if (!past_opcode_p)
508 const struct arc_operand_value *suf, *suffix_end;
509 const struct arc_operand_value *suffix = NULL;
511 if (!(operand->flags & ARC_OPERAND_SUFFIX))
514 /* If we're at a space in the input string, we want to skip the
515 remaining suffixes. There may be some fake ones though, so
516 just go on to try the next one. */
524 if (mods & ARC_MOD_DOT)
532 /* This can happen in "b.nd foo" and we're currently looking
533 for "%q" (ie: a condition code suffix). */
541 /* Pick the suffix out and look it up via the hash table. */
542 for (t = s; *t && isalnum (*t); ++t)
546 if ((suf = get_ext_suffix (s)))
549 suf = hash_find (arc_suffix_hash, s);
552 /* This can happen in "blle foo" and we're currently using
553 the template "b%q%.n %j". The "bl" insn occurs later in
554 the table so "lle" isn't an illegal suffix. */
559 /* Is it the right type? Note that the same character is used
560 several times, so we have to examine all of them. This is
561 relatively efficient as equivalent entries are kept
562 together. If it's not the right type, don't increment `str'
563 so we try the next one in the series. */
565 if (ext_suffix_p && arc_operands[suf->type].fmt == *syn)
567 /* Insert the suffix's value into the insn. */
570 insn = (*operand->insert) (insn, operand,
571 mods, NULL, suf->value,
574 insn |= suf->value << operand->shift;
582 suffix_end = arc_suffixes + arc_suffixes_count;
584 suffix < suffix_end && strcmp (suffix->name, suf->name) == 0;
587 if (arc_operands[suffix->type].fmt == *syn)
589 /* Insert the suffix's value into the insn. */
591 insn = (*operand->insert) (insn, operand,
592 mods, NULL, suffix->value,
595 insn |= suffix->value << operand->shift;
605 /* Wrong type. Just go on to try next insn entry. */
609 if (num_suffixes == MAX_SUFFIXES)
610 as_bad ("too many suffixes");
612 insn_suffixes[num_suffixes++] = suffix;
616 /* This is either a register or an expression of some kind. */
619 const struct arc_operand_value *reg = NULL;
623 if (operand->flags & ARC_OPERAND_SUFFIX)
626 /* Is there anything left to parse?
627 We don't check for this at the top because we want to parse
628 any trailing fake arguments in the syntax string. */
632 /* Parse the operand. */
633 hold = input_line_pointer;
634 input_line_pointer = str;
636 str = input_line_pointer;
637 input_line_pointer = hold;
639 if (exp.X_op == O_illegal)
640 as_bad ("illegal operand");
641 else if (exp.X_op == O_absent)
642 as_bad ("missing operand");
643 else if (exp.X_op == O_constant)
645 value = exp.X_add_number;
647 else if (exp.X_op == O_register)
649 reg = (struct arc_operand_value *) exp.X_add_number;
651 #define IS_REG_DEST_OPERAND(o) ((o) == 'a')
652 else if (IS_REG_DEST_OPERAND (*syn))
653 as_bad ("symbol as destination register");
656 if (!strncmp (str, "@h30", 4))
658 arc_code_symbol (&exp);
661 /* We need to generate a fixup for this expression. */
662 if (fc >= MAX_FIXUPS)
663 as_fatal ("too many fixups");
664 fixups[fc].exp = exp;
665 /* We don't support shimm relocs. break here to force
666 the assembler to output a limm. */
667 #define IS_REG_SHIMM_OFFSET(o) ((o) == 'd')
668 if (IS_REG_SHIMM_OFFSET (*syn))
670 /* If this is a register constant (IE: one whose
671 register value gets stored as 61-63) then this
673 /* ??? This bit could use some cleaning up.
674 Referencing the format chars like this goes
676 if (IS_SYMBOL_OPERAND (*syn))
680 /* Save this, we don't yet know what reloc to use. */
682 /* Tell insert_reg we need a limm. This is
683 needed because the value at this point is
685 /* ??? We need a cleaner interface than this. */
686 (*arc_operands[arc_operand_map['Q']].insert)
687 (insn, operand, mods, reg, 0L, &junk);
690 fixups[fc].opindex = arc_operand_map[(int) *syn];
695 /* Insert the register or expression into the instruction. */
698 const char *errmsg = NULL;
699 insn = (*operand->insert) (insn, operand, mods,
700 reg, (long) value, &errmsg);
701 if (errmsg != (const char *) NULL)
703 last_errmsg = errmsg;
704 if (operand->flags & ARC_OPERAND_ERROR)
709 else if (operand->flags & ARC_OPERAND_WARN)
715 insn |= (value & ((1 << operand->bits) - 1)) << operand->shift;
721 /* If we're at the end of the syntax string, we're done. */
722 /* FIXME: try to move this to a separate function. */
729 /* For the moment we assume a valid `str' can only contain blanks
730 now. IE: We needn't try again with a longer version of the
731 insn and it is assumed that longer versions of insns appear
732 before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
734 while (isspace (*str))
738 as_bad ("junk at end of line: `%s'", str);
740 /* Is there a limm value? */
741 limm_p = arc_opcode_limm_p (&limm);
743 /* Perform various error and warning tests. */
746 static int in_delay_slot_p = 0;
747 static int prev_insn_needs_cc_nop_p = 0;
748 /* delay slot type seen */
749 int delay_slot_type = ARC_DELAY_NONE;
750 /* conditional execution flag seen */
752 /* 1 if condition codes are being set */
754 /* 1 if conditional branch, including `b' "branch always" */
755 int cond_branch_p = opcode->flags & ARC_OPCODE_COND_BRANCH;
757 for (i = 0; i < num_suffixes; ++i)
759 switch (arc_operands[insn_suffixes[i]->type].fmt)
762 delay_slot_type = insn_suffixes[i]->value;
765 conditional = insn_suffixes[i]->value;
773 /* Putting an insn with a limm value in a delay slot is supposed to
774 be legal, but let's warn the user anyway. Ditto for 8 byte
775 jumps with delay slots. */
776 if (in_delay_slot_p && limm_p)
777 as_warn ("8 byte instruction in delay slot");
778 if (delay_slot_type != ARC_DELAY_NONE
779 && limm_p && arc_insn_not_jl (insn)) /* except for jl addr */
780 as_warn ("8 byte jump instruction with delay slot");
781 in_delay_slot_p = (delay_slot_type != ARC_DELAY_NONE) && !limm_p;
783 /* Warn when a conditional branch immediately follows a set of
784 the condition codes. Note that this needn't be done if the
785 insn that sets the condition codes uses a limm. */
786 if (cond_branch_p && conditional != 0 /* 0 = "always" */
787 && prev_insn_needs_cc_nop_p && arc_mach_type == bfd_mach_arc_5)
788 as_warn ("conditional branch follows set of flags");
789 prev_insn_needs_cc_nop_p =
790 /* FIXME: ??? not required:
791 (delay_slot_type != ARC_DELAY_NONE) && */
795 /* Write out the instruction.
796 It is important to fetch enough space in one call to `frag_more'.
797 We use (f - frag_now->fr_literal) to compute where we are and we
798 don't want frag_now to change between calls. */
802 md_number_to_chars (f, insn, 4);
803 md_number_to_chars (f + 4, limm, 4);
805 else if (limm_reloc_p)
807 /* We need a limm reloc, but the tables think we don't. */
813 md_number_to_chars (f, insn, 4);
816 /* Create any fixups. */
817 for (i = 0; i < fc; ++i)
819 int op_type, reloc_type;
821 const struct arc_operand *operand;
823 /* Create a fixup for this operand.
824 At this point we do not use a bfd_reloc_code_real_type for
825 operands residing in the insn, but instead just use the
826 operand index. This lets us easily handle fixups for any
827 operand type, although that is admittedly not a very exciting
828 feature. We pick a BFD reloc type in md_apply_fix.
830 Limm values (4 byte immediate "constants") must be treated
831 normally because they're not part of the actual insn word
832 and thus the insertion routines don't handle them. */
834 if (arc_operands[fixups[i].opindex].flags & ARC_OPERAND_LIMM)
836 /* Modify the fixup addend as required by the cpu. */
837 fixups[i].exp.X_add_number += arc_limm_fixup_adjust (insn);
838 op_type = fixups[i].opindex;
839 /* FIXME: can we add this data to the operand table? */
840 if (op_type == arc_operand_map['L']
841 || op_type == arc_operand_map['s']
842 || op_type == arc_operand_map['o']
843 || op_type == arc_operand_map['O'])
844 reloc_type = BFD_RELOC_32;
845 else if (op_type == arc_operand_map['J'])
846 reloc_type = BFD_RELOC_ARC_B26;
849 reloc_type = get_arc_exp_reloc_type (1, reloc_type,
855 op_type = get_arc_exp_reloc_type (0, fixups[i].opindex,
856 &fixups[i].exp, &exptmp);
857 reloc_type = op_type + (int) BFD_RELOC_UNUSED;
859 operand = &arc_operands[op_type];
860 fix_new_exp (frag_now,
861 ((f - frag_now->fr_literal)
862 + (operand->flags & ARC_OPERAND_LIMM ? 4 : 0)), 4,
864 (operand->flags & ARC_OPERAND_RELATIVE_BRANCH) != 0,
865 (bfd_reloc_code_real_type) reloc_type);
872 /* Try the next entry. */
875 if (NULL == last_errmsg)
876 as_bad ("bad instruction `%s'", start);
878 as_bad (last_errmsg);
882 arc_extoper (opertype)
891 struct arc_ext_operand_value *ext_oper;
897 name = input_line_pointer;
898 c = get_symbol_end ();
899 name = xstrdup (name);
902 ignore_rest_of_line ();
914 /* just after name is now '\0' */
915 p = input_line_pointer;
919 if (*input_line_pointer != ',')
921 as_bad ("expected comma after operand name");
922 ignore_rest_of_line ();
927 input_line_pointer++; /* skip ',' */
928 number = get_absolute_expression ();
932 as_bad ("negative operand number %d", number);
933 ignore_rest_of_line ();
942 if (*input_line_pointer != ',')
944 as_bad ("expected comma after register-number");
945 ignore_rest_of_line ();
950 input_line_pointer++; /* skip ',' */
951 mode = input_line_pointer;
953 if (!strncmp (mode, "r|w", 3))
956 input_line_pointer += 3;
960 if (!strncmp (mode, "r", 1))
962 imode = ARC_REGISTER_READONLY;
963 input_line_pointer += 1;
967 if (strncmp (mode, "w", 1))
969 as_bad ("invalid mode");
970 ignore_rest_of_line ();
976 imode = ARC_REGISTER_WRITEONLY;
977 input_line_pointer += 1;
984 if (*input_line_pointer != ',')
986 as_bad ("expected comma after register-mode");
987 ignore_rest_of_line ();
992 input_line_pointer++; /* skip ',' */
994 if (!strncmp (input_line_pointer, "cannot_shortcut", 15))
996 imode |= arc_get_noshortcut_flag ();
997 input_line_pointer += 15;
1001 if (strncmp (input_line_pointer, "can_shortcut", 12))
1003 as_bad ("shortcut designator invalid");
1004 ignore_rest_of_line ();
1010 input_line_pointer += 12;
1016 if ((opertype == 1) && number > 60)
1018 as_bad ("core register value (%d) too large", number);
1019 ignore_rest_of_line ();
1024 if ((opertype == 0) && number > 31)
1026 as_bad ("condition code value (%d) too large", number);
1027 ignore_rest_of_line ();
1032 ext_oper = (struct arc_ext_operand_value *) \
1033 xmalloc (sizeof (struct arc_ext_operand_value));
1037 /* If the symbol already exists, point it at the new definition. */
1038 if ((symbolP = symbol_find (name)))
1040 if (S_GET_SEGMENT (symbolP) == reg_section)
1041 S_SET_VALUE (symbolP, (int) &ext_oper->operand);
1044 as_bad ("attempt to override symbol: %s", name);
1045 ignore_rest_of_line ();
1053 /* If its not there, add it. */
1054 symbol_table_insert (symbol_create (name, reg_section,
1055 (int) &ext_oper->operand, &zero_address_frag));
1059 ext_oper->operand.name = name;
1060 ext_oper->operand.value = number;
1061 ext_oper->operand.type = arc_operand_type (opertype);
1062 ext_oper->operand.flags = imode;
1064 ext_oper->next = arc_ext_operands;
1065 arc_ext_operands = ext_oper;
1067 /* OK, now that we know what this operand is, put a description in
1068 the arc extension section of the output file. */
1071 old_subsec = now_subseg;
1079 *p = 3 + strlen (name) + 1;
1084 p = frag_more (strlen (name) + 1);
1089 *p = 3 + strlen (name) + 1;
1091 *p = EXT_CORE_REGISTER;
1094 p = frag_more (strlen (name) + 1);
1099 *p = 6 + strlen (name) + 1;
1101 *p = EXT_AUX_REGISTER;
1103 *p = number >> 24 & 0xff;
1105 *p = number >> 16 & 0xff;
1107 *p = number >> 8 & 0xff;
1110 p = frag_more (strlen (name) + 1);
1114 as_bad ("invalid opertype");
1115 ignore_rest_of_line ();
1121 subseg_set (old_sec, old_subsec);
1123 /* Enter all registers into the symbol table. */
1125 demand_empty_rest_of_line ();
1129 arc_extinst (ignore)
1130 int ignore ATTRIBUTE_UNUSED;
1132 unsigned char syntax[129];
1136 int suffixcode = -1;
1137 int opcode, subopcode;
1141 struct arc_opcode *ext_op;
1146 name = input_line_pointer;
1147 c = get_symbol_end ();
1148 name = xstrdup (name);
1151 ignore_rest_of_line ();
1154 strcpy (syntax, name);
1155 name_len = strlen (name);
1157 /* just after name is now '\0' */
1158 p = input_line_pointer;
1163 if (*input_line_pointer != ',')
1165 as_bad ("expected comma after operand name");
1166 ignore_rest_of_line ();
1170 input_line_pointer++; /* skip ',' */
1171 opcode = get_absolute_expression ();
1175 if (*input_line_pointer != ',')
1177 as_bad ("expected comma after opcode");
1178 ignore_rest_of_line ();
1182 input_line_pointer++; /* skip ',' */
1183 subopcode = get_absolute_expression ();
1187 as_bad ("negative subopcode %d", subopcode);
1188 ignore_rest_of_line ();
1196 as_bad ("subcode value found when opcode not equal 0x03");
1197 ignore_rest_of_line ();
1202 if (subopcode < 0x09 || subopcode == 0x3f)
1204 as_bad ("invalid subopcode %d", subopcode);
1205 ignore_rest_of_line ();
1213 if (*input_line_pointer != ',')
1215 as_bad ("expected comma after subopcode");
1216 ignore_rest_of_line ();
1220 input_line_pointer++; /* skip ',' */
1222 for (i = 0; i < (int) MAXSUFFIXCLASS; i++)
1224 if (!strncmp (suffixclass[i].name,input_line_pointer, suffixclass[i].len))
1227 input_line_pointer += suffixclass[i].len;
1232 if (-1 == suffixcode)
1234 as_bad ("invalid suffix class");
1235 ignore_rest_of_line ();
1241 if (*input_line_pointer != ',')
1243 as_bad ("expected comma after suffix class");
1244 ignore_rest_of_line ();
1248 input_line_pointer++; /* skip ',' */
1250 for (i = 0; i < (int) MAXSYNTAXCLASS; i++)
1252 if (!strncmp (syntaxclass[i].name,input_line_pointer, syntaxclass[i].len))
1254 class = syntaxclass[i].class;
1255 input_line_pointer += syntaxclass[i].len;
1260 if (0 == (SYNTAX_VALID & class))
1262 as_bad ("invalid syntax class");
1263 ignore_rest_of_line ();
1267 if ((0x3 == opcode) & (class & SYNTAX_3OP))
1269 as_bad ("opcode 0x3 and SYNTAX_3OP invalid");
1270 ignore_rest_of_line ();
1277 strcat (syntax, "%.q%.f ");
1280 strcat (syntax, "%.f ");
1283 strcat (syntax, "%.q ");
1286 strcat (syntax, " ");
1289 as_bad ("unknown suffix class");
1290 ignore_rest_of_line ();
1295 strcat (syntax, ((opcode == 0x3) ? "%a,%b" : ((class & SYNTAX_3OP) ? "%a,%b,%c" : "%b,%c")));
1297 strcat (syntax, "%F");
1298 strcat (syntax, "%S%L");
1300 ext_op = (struct arc_opcode *) xmalloc (sizeof (struct arc_opcode));
1303 ignore_rest_of_line ();
1307 ext_op->syntax = xstrdup (syntax);
1308 if (NULL == ext_op->syntax)
1310 ignore_rest_of_line ();
1314 ext_op->mask = I (-1) | ((0x3 == opcode) ? C (-1) : 0);
1315 ext_op->value = I (opcode) | ((0x3 == opcode) ? C (subopcode) : 0);
1316 ext_op->flags = class;
1317 ext_op->next_asm = arc_ext_opcodes;
1318 ext_op->next_dis = arc_ext_opcodes;
1319 arc_ext_opcodes = ext_op;
1321 /* OK, now that we know what this inst is, put a description in the
1322 arc extension section of the output file. */
1325 old_subsec = now_subseg;
1330 *p = 5 + name_len + 1;
1332 *p = EXT_INSTRUCTION;
1338 *p = (class & (OP1_MUST_BE_IMM | OP1_IMM_IMPLIED) ? IGNORE_FIRST_OPD : 0);
1339 p = frag_more (name_len);
1340 strncpy (p, syntax, name_len);
1344 subseg_set (old_sec, old_subsec);
1346 demand_empty_rest_of_line ();
1352 if (!arcext_section)
1354 arcext_section = subseg_new (".arcextmap", 0);
1355 bfd_set_section_flags (stdoutput, arcext_section,
1356 SEC_READONLY | SEC_HAS_CONTENTS);
1359 subseg_set (arcext_section, 0);
1364 arc_common (localScope)
1373 name = input_line_pointer;
1374 c = get_symbol_end ();
1375 /* just after name is now '\0' */
1376 p = input_line_pointer;
1380 if (*input_line_pointer != ',')
1382 as_bad ("expected comma after symbol name");
1383 ignore_rest_of_line ();
1387 input_line_pointer++; /* skip ',' */
1388 size = get_absolute_expression ();
1392 as_bad ("negative symbol length");
1393 ignore_rest_of_line ();
1398 symbolP = symbol_find_or_make (name);
1401 if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
1403 as_bad ("ignoring attempt to re-define symbol");
1404 ignore_rest_of_line ();
1407 if (((int) S_GET_VALUE (symbolP) != 0) \
1408 && ((int) S_GET_VALUE (symbolP) != size))
1410 as_warn ("length of symbol \"%s\" already %ld, ignoring %d",
1411 S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP), size);
1413 assert (symbolP->sy_frag == &zero_address_frag);
1415 /* Now parse the alignment field. This field is optional for
1416 local and global symbols. Default alignment is zero. */
1417 if (*input_line_pointer == ',')
1419 input_line_pointer++;
1420 align = get_absolute_expression ();
1424 as_warn ("assuming symbol alignment of zero");
1430 if (localScope != 0)
1437 old_subsec = now_subseg;
1438 record_alignment (bss_section, align);
1439 subseg_set (bss_section, 0); /* ??? subseg_set (bss_section, 1); ??? */
1443 frag_align (align, 0, 0);
1445 /* Detach from old frag. */
1446 if (S_GET_SEGMENT (symbolP) == bss_section)
1447 symbolP->sy_frag->fr_symbol = NULL;
1449 symbolP->sy_frag = frag_now;
1450 pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP,
1451 (offsetT) size, (char *) 0);
1454 S_SET_SIZE (symbolP, size);
1455 S_SET_SEGMENT (symbolP, bss_section);
1456 S_CLEAR_EXTERNAL (symbolP);
1458 subseg_set (old_sec, old_subsec);
1462 S_SET_VALUE (symbolP, (valueT) size);
1463 S_SET_ALIGN (symbolP, align);
1464 S_SET_EXTERNAL (symbolP);
1465 S_SET_SEGMENT (symbolP, bfd_com_section_ptr);
1468 symbolP->bsym->flags |= BSF_OBJECT;
1470 demand_empty_rest_of_line ();
1474 /* Select the cpu we're assembling for. */
1478 int ignore ATTRIBUTE_UNUSED;
1484 cpu = input_line_pointer;
1485 c = get_symbol_end ();
1486 mach = arc_get_mach (cpu);
1487 *input_line_pointer = c;
1489 /* If an instruction has already been seen, it's too late. */
1490 if (cpu_tables_init_p)
1492 as_bad ("\".option\" directive must appear before any instructions");
1493 ignore_rest_of_line ();
1500 if (mach_type_specified_p && mach != arc_mach_type)
1502 as_bad ("\".option\" directive conflicts with initial definition");
1503 ignore_rest_of_line ();
1508 /* The cpu may have been selected on the command line. */
1509 if (mach != arc_mach_type)
1510 as_warn ("\".option\" directive overrides command-line (default) value");
1511 arc_mach_type = mach;
1512 if (!bfd_set_arch_mach (stdoutput, bfd_arch_arc, mach))
1513 as_fatal ("could not set architecture and machine");
1514 mach_type_specified_p = 1;
1516 demand_empty_rest_of_line ();
1520 as_bad ("invalid identifier for \".option\"");
1521 ignore_rest_of_line ();
1524 /* Turn a string in input_line_pointer into a floating point constant
1525 of type TYPE, and store the appropriate bytes in *LITP. The number
1526 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1527 returned, or NULL on OK. */
1529 /* Equal to MAX_PRECISION in atof-ieee.c */
1530 #define MAX_LITTLENUMS 6
1533 md_atof (type, litP, sizeP)
1539 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1540 LITTLENUM_TYPE *wordP;
1558 return "bad call to md_atof";
1561 t = atof_ieee (input_line_pointer, type, words);
1563 input_line_pointer = t;
1564 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1565 for (wordP = words; prec--;)
1567 md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE));
1568 litP += sizeof (LITTLENUM_TYPE);
1574 /* Write a value out to the object file, using the appropriate
1578 md_number_to_chars (buf, val, n)
1583 if (target_big_endian)
1584 number_to_chars_bigendian (buf, val, n);
1586 number_to_chars_littleendian (buf, val, n);
1589 /* Round up a section size to the appropriate boundary. */
1592 md_section_align (segment, size)
1596 int align = bfd_get_section_alignment (stdoutput, segment);
1598 return ((size + (1 << align) - 1) & (-1 << align));
1601 /* We don't have any form of relaxing. */
1604 md_estimate_size_before_relax (fragp, seg)
1605 fragS *fragp ATTRIBUTE_UNUSED;
1606 asection *seg ATTRIBUTE_UNUSED;
1608 as_fatal (_("md_estimate_size_before_relax\n"));
1612 /* Convert a machine dependent frag. We never generate these. */
1615 md_convert_frag (abfd, sec, fragp)
1616 bfd *abfd ATTRIBUTE_UNUSED;
1617 asection *sec ATTRIBUTE_UNUSED;
1618 fragS *fragp ATTRIBUTE_UNUSED;
1620 as_fatal (_("md_convert_frag\n"));
1624 arc_code_symbol (expressionP)
1625 expressionS *expressionP;
1627 if (expressionP->X_op == O_symbol && expressionP->X_add_number == 0
1628 /* I think this test is unnecessary but just as a sanity check... */
1629 && expressionP->X_op_symbol == NULL)
1632 expressionP->X_op = O_right_shift;
1633 two.X_op = O_constant;
1634 two.X_add_symbol = two.X_op_symbol = NULL;
1635 two.X_add_number = 2;
1636 expressionP->X_op_symbol = make_expr_symbol (&two);
1638 /* Allow %st(sym1-sym2) */
1639 else if (expressionP->X_op == O_subtract
1640 && expressionP->X_add_symbol != NULL
1641 && expressionP->X_op_symbol != NULL
1642 && expressionP->X_add_number == 0)
1645 expressionP->X_add_symbol = make_expr_symbol (expressionP);
1646 expressionP->X_op = O_right_shift;
1647 two.X_op = O_constant;
1648 two.X_add_symbol = two.X_op_symbol = NULL;
1649 two.X_add_number = 2;
1650 expressionP->X_op_symbol = make_expr_symbol (&two);
1654 as_bad ("expression too complex code symbol");
1659 /* Parse an operand that is machine-specific.
1661 The ARC has a special %-op to adjust addresses so they're usable in
1662 branches. The "st" is short for the STatus register.
1663 ??? Later expand this to take a flags value too.
1665 ??? We can't create new expression types so we map the %-op's onto the
1666 existing syntax. This means that the user could use the chosen syntax
1667 to achieve the same effect. */
1670 md_operand (expressionP)
1671 expressionS *expressionP;
1673 char *p = input_line_pointer;
1676 if (strncmp (p, "%st(", 4) == 0)
1678 input_line_pointer += 4;
1679 expression (expressionP);
1680 if (*input_line_pointer != ')')
1682 as_bad ("missing ')' in %%-op");
1685 ++input_line_pointer;
1686 arc_code_symbol (expressionP);
1689 { /* It could be a register. */
1691 struct arc_ext_operand_value *ext_oper = arc_ext_operands;
1696 l = strlen (ext_oper->operand.name);
1697 if (!strncmp (p, ext_oper->operand.name, l) && !isalnum(*(p + l)))
1699 input_line_pointer += l + 1;
1700 expressionP->X_op = O_register;
1701 expressionP->X_add_number = (int) &ext_oper->operand;
1704 ext_oper = ext_oper->next;
1706 for (i = 0; i < arc_reg_names_count; i++)
1708 l = strlen (arc_reg_names[i].name);
1709 if (!strncmp (p, arc_reg_names[i].name, l) && !isalnum (*(p + l)))
1711 input_line_pointer += l + 1;
1712 expressionP->X_op = O_register;
1713 expressionP->X_add_number = (int) &arc_reg_names[i];
1720 /* We have no need to default values of symbols.
1721 We could catch register names here, but that is handled by inserting
1722 them all in the symbol table to begin with. */
1725 md_undefined_symbol (name)
1726 char *name ATTRIBUTE_UNUSED;
1731 /* Functions concerning expressions. */
1733 /* Parse a .byte, .word, etc. expression.
1735 Values for the status register are specified with %st(label).
1736 `label' will be right shifted by 2. */
1739 arc_parse_cons_expression (exp, nbytes)
1741 unsigned int nbytes ATTRIBUTE_UNUSED;
1743 char *p = input_line_pointer;
1744 int code_symbol_fix = 0;
1746 for (; ! is_end_of_line[(unsigned char) *p]; p++)
1747 if (*p == '@' && !strncmp (p, "@h30", 4))
1749 code_symbol_fix = 1;
1753 if (code_symbol_fix)
1755 arc_code_symbol (exp);
1756 input_line_pointer = p;
1760 /* Record a fixup for a cons expression. */
1763 arc_cons_fix_new (frag, where, nbytes, exp)
1774 /* This may be a special ARC reloc (eg: %st()). */
1775 reloc_type = get_arc_exp_reloc_type (1, BFD_RELOC_32, exp, &exptmp);
1776 fix_new_exp (frag, where, nbytes, &exptmp, 0, reloc_type);
1780 fix_new_exp (frag, where, nbytes, exp, 0,
1781 nbytes == 2 ? BFD_RELOC_16
1782 : nbytes == 8 ? BFD_RELOC_64
1787 /* Functions concerning relocs. */
1789 /* The location from which a PC relative jump should be calculated,
1790 given a PC relative reloc. */
1793 md_pcrel_from (fixP)
1796 if (fixP->fx_addsy != (symbolS *) NULL
1797 && ! S_IS_DEFINED (fixP->fx_addsy))
1799 /* The symbol is undefined. Let the linker figure it out. */
1803 /* Return the address of the delay slot. */
1804 return fixP->fx_frag->fr_address + fixP->fx_where + fixP->fx_size;
1807 /* Compute the reloc type of an expression.
1808 The possibly modified expression is stored in EXPNEW.
1810 This is used to convert the expressions generated by the %-op's into
1811 the appropriate operand type. It is called for both data in instructions
1812 (operands) and data outside instructions (variables, debugging info, etc.).
1814 Currently supported %-ops:
1816 %st(symbol): represented as "symbol >> 2"
1817 "st" is short for STatus as in the status register (pc)
1819 DEFAULT_TYPE is the type to use if no special processing is required.
1821 DATA_P is non-zero for data or limm values, zero for insn operands.
1822 Remember that the opcode "insertion fns" cannot be used on data, they're
1823 only for inserting operands into insns. They also can't be used for limm
1824 values as the insertion routines don't handle limm values. When called for
1825 insns we return fudged reloc types (real_value - BFD_RELOC_UNUSED). When
1826 called for data or limm values we use real reloc types. */
1829 get_arc_exp_reloc_type (data_p, default_type, exp, expnew)
1833 expressionS *expnew;
1835 /* If the expression is "symbol >> 2" we must change it to just "symbol",
1836 as fix_new_exp can't handle it. Similarily for (symbol - symbol) >> 2.
1837 That's ok though. What's really going on here is that we're using
1838 ">> 2" as a special syntax for specifying BFD_RELOC_ARC_B26. */
1840 if (exp->X_op == O_right_shift
1841 && exp->X_op_symbol != NULL
1842 && exp->X_op_symbol->sy_value.X_op == O_constant
1843 && exp->X_op_symbol->sy_value.X_add_number == 2
1844 && exp->X_add_number == 0)
1846 if (exp->X_add_symbol != NULL
1847 && (exp->X_add_symbol->sy_value.X_op == O_constant
1848 || exp->X_add_symbol->sy_value.X_op == O_symbol))
1851 expnew->X_op = O_symbol;
1852 expnew->X_op_symbol = NULL;
1853 return data_p ? BFD_RELOC_ARC_B26 : arc_operand_map['J'];
1855 else if (exp->X_add_symbol != NULL
1856 && exp->X_add_symbol->sy_value.X_op == O_subtract)
1858 *expnew = exp->X_add_symbol->sy_value;
1859 return data_p ? BFD_RELOC_ARC_B26 : arc_operand_map['J'];
1864 return default_type;
1867 /* Apply a fixup to the object code. This is called for all the
1868 fixups we generated by the call to fix_new_exp, above. In the call
1869 above we used a reloc code which was the largest legal reloc code
1870 plus the operand index. Here we undo that to recover the operand
1871 index. At this point all symbol values should be fully resolved,
1872 and we attempt to completely resolve the reloc. If we can not do
1873 that, we determine the correct reloc code and put it back in the fixup. */
1876 md_apply_fix3 (fixP, valueP, seg)
1882 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1886 /* FIXME FIXME FIXME: The value we are passed in *valueP includes
1887 the symbol values. Since we are using BFD_ASSEMBLER, if we are
1888 doing this relocation the code in write.c is going to call
1889 bfd_perform_relocation, which is also going to use the symbol
1890 value. That means that if the reloc is fully resolved we want to
1891 use *valueP since bfd_perform_relocation is not being used.
1892 However, if the reloc is not fully resolved we do not want to use
1893 *valueP, and must use fx_offset instead. However, if the reloc
1894 is PC relative, we do want to use *valueP since it includes the
1895 result of md_pcrel_from. This is confusing. */
1897 if (fixP->fx_addsy == (symbolS *) NULL)
1902 else if (fixP->fx_pcrel)
1905 /* ELF relocations are against symbols.
1906 If this symbol is in a different section then we need to leave it for
1907 the linker to deal with. Unfortunately, md_pcrel_from can't tell,
1908 so we have to undo it's effects here. */
1909 if (S_IS_DEFINED (fixP->fx_addsy)
1910 && S_GET_SEGMENT (fixP->fx_addsy) != seg)
1911 value += md_pcrel_from (fixP);
1915 value = fixP->fx_offset;
1916 if (fixP->fx_subsy != (symbolS *) NULL)
1918 if (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)
1919 value -= S_GET_VALUE (fixP->fx_subsy);
1922 /* We can't actually support subtracting a symbol. */
1923 as_bad_where (fixP->fx_file, fixP->fx_line,
1924 "expression too complex");
1929 if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
1932 const struct arc_operand *operand;
1936 opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED;
1938 operand = &arc_operands[opindex];
1940 /* Fetch the instruction, insert the fully resolved operand
1941 value, and stuff the instruction back again. */
1942 where = fixP->fx_frag->fr_literal + fixP->fx_where;
1943 if (target_big_endian)
1944 insn = bfd_getb32 ((unsigned char *) where);
1946 insn = bfd_getl32 ((unsigned char *) where);
1947 insn = arc_insert_operand (insn, operand, -1, NULL, (offsetT) value,
1948 fixP->fx_file, fixP->fx_line);
1949 if (target_big_endian)
1950 bfd_putb32 ((bfd_vma) insn, (unsigned char *) where);
1952 bfd_putl32 ((bfd_vma) insn, (unsigned char *) where);
1956 /* Nothing else to do here. */
1960 /* Determine a BFD reloc value based on the operand information.
1961 We are only prepared to turn a few of the operands into relocs.
1962 !!! Note that we can't handle limm values here. Since we're using
1963 implicit addends the addend must be inserted into the instruction,
1964 however, the opcode insertion routines currently do nothing with
1966 if (operand->fmt == 'B')
1968 assert ((operand->flags & ARC_OPERAND_RELATIVE_BRANCH) != 0
1969 && operand->bits == 20
1970 && operand->shift == 7);
1971 fixP->fx_r_type = BFD_RELOC_ARC_B22_PCREL;
1973 else if (operand->fmt == 'J')
1975 assert ((operand->flags & ARC_OPERAND_ABSOLUTE_BRANCH) != 0
1976 && operand->bits == 24
1977 && operand->shift == 32);
1978 fixP->fx_r_type = BFD_RELOC_ARC_B26;
1980 else if (operand->fmt == 'L')
1982 assert ((operand->flags & ARC_OPERAND_LIMM) != 0
1983 && operand->bits == 32
1984 && operand->shift == 32);
1985 fixP->fx_r_type = BFD_RELOC_32;
1989 as_bad_where (fixP->fx_file, fixP->fx_line,
1990 "unresolved expression that must be resolved");
1997 switch (fixP->fx_r_type)
2000 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2004 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2008 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2013 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2017 case BFD_RELOC_ARC_B26:
2018 /* If !fixP->fx_done then `value' is an implicit addend.
2019 We must shift it right by 2 in this case as well because the
2020 linker performs the relocation and then adds this in (as opposed
2021 to adding this in and then shifting right by 2). */
2023 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2031 fixP->fx_addnumber = value;
2036 /* Translate internal representation of relocation info to BFD target
2040 tc_gen_reloc (section, fixP)
2041 asection *section ATTRIBUTE_UNUSED;
2046 reloc = (arelent *) xmalloc (sizeof (arelent));
2048 reloc->sym_ptr_ptr = &fixP->fx_addsy->bsym;
2049 reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
2050 reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
2051 if (reloc->howto == (reloc_howto_type *) NULL)
2053 as_bad_where (fixP->fx_file, fixP->fx_line,
2054 "internal error: can't export reloc type %d (`%s')",
2056 bfd_get_reloc_code_name (fixP->fx_r_type));
2060 assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
2062 /* Set addend to account for PC being advanced one insn before the
2063 target address is computed, drop fx_addnumber as it is handled
2066 reloc->addend = (fixP->fx_pcrel ? -4 : 0);