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
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #include "libiberty.h"
26 #include "opcode/arc.h"
27 #include "../opcodes/arc-ext.h"
30 extern int arc_get_mach PARAMS ((char *));
31 extern int arc_operand_type PARAMS ((int));
32 extern int arc_insn_not_jl PARAMS ((arc_insn));
33 extern int arc_limm_fixup_adjust PARAMS ((arc_insn));
34 extern int arc_get_noshortcut_flag PARAMS ((void));
35 extern int arc_set_ext_seg PARAMS ((void));
36 extern void arc_code_symbol PARAMS((expressionS *));
38 static arc_insn arc_insert_operand PARAMS ((arc_insn,
39 const struct arc_operand *, int,
40 const struct arc_operand_value *,
41 offsetT, char *, unsigned int));
42 static void arc_common PARAMS ((int));
43 static void arc_extinst PARAMS ((int));
44 static void arc_extoper PARAMS ((int));
45 static void arc_option PARAMS ((int));
46 static int get_arc_exp_reloc_type PARAMS ((int, int, expressionS *,
49 const struct suffix_classes {
53 { "SUFFIX_COND|SUFFIX_FLAG",23 },
54 { "SUFFIX_FLAG", 11 },
55 { "SUFFIX_COND", 11 },
59 #define MAXSUFFIXCLASS (sizeof(suffixclass) / sizeof(struct suffix_classes))
61 const struct syntax_classes {
66 { "SYNTAX_3OP|OP1_MUST_BE_IMM", 26, SYNTAX_3OP|OP1_MUST_BE_IMM|SYNTAX_VALID },
67 { "OP1_MUST_BE_IMM|SYNTAX_3OP", 26, OP1_MUST_BE_IMM|SYNTAX_3OP|SYNTAX_VALID },
68 { "SYNTAX_2OP|OP1_IMM_IMPLIED", 26, SYNTAX_2OP|OP1_IMM_IMPLIED|SYNTAX_VALID },
69 { "OP1_IMM_IMPLIED|SYNTAX_2OP", 26, OP1_IMM_IMPLIED|SYNTAX_2OP|SYNTAX_VALID },
70 { "SYNTAX_3OP", 10, SYNTAX_3OP|SYNTAX_VALID },
71 { "SYNTAX_2OP", 10, SYNTAX_2OP|SYNTAX_VALID }
74 #define MAXSYNTAXCLASS (sizeof(syntaxclass) / sizeof(struct syntax_classes))
76 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[] =
144 #define OPTION_EB (OPTION_MD_BASE + 0)
145 {"EB", no_argument, NULL, OPTION_EB},
146 #define OPTION_EL (OPTION_MD_BASE + 1)
147 {"EL", no_argument, NULL, OPTION_EL},
148 #define OPTION_ARC5 (OPTION_MD_BASE + 2)
149 {"marc5", no_argument, NULL, OPTION_ARC5},
150 #define OPTION_ARC6 (OPTION_MD_BASE + 3)
151 {"marc6", no_argument, NULL, OPTION_ARC6},
152 #define OPTION_ARC7 (OPTION_MD_BASE + 4)
153 {"marc7", no_argument, NULL, OPTION_ARC7},
154 #define OPTION_ARC8 (OPTION_MD_BASE + 5)
155 {"marc8", no_argument, NULL, OPTION_ARC8},
156 #define OPTION_ARC (OPTION_MD_BASE + 6)
157 {"marc", no_argument, NULL, OPTION_ARC},
158 { NULL, no_argument, NULL, 0 }
160 size_t md_longopts_size = sizeof (md_longopts);
162 #define IS_SYMBOL_OPERAND(o) \
163 ((o) == 'b' || (o) == 'c' || (o) == 's' || (o) == 'o' || (o) == 'O')
165 struct arc_operand_value *get_ext_suffix(char *s);
170 * Invocation line includes a switch not recognized by the base assembler.
171 * See if it's a processor-specific option.
175 md_parse_option (c, arg)
177 char *arg ATTRIBUTE_UNUSED;
183 arc_mach_type = bfd_mach_arc_5;
186 arc_mach_type = bfd_mach_arc_6;
189 arc_mach_type = bfd_mach_arc_7;
192 arc_mach_type = bfd_mach_arc_8;
195 byte_order = BIG_ENDIAN;
196 arc_target_format = "elf32-bigarc";
199 byte_order = LITTLE_ENDIAN;
200 arc_target_format = "elf32-littlearc";
209 md_show_usage (stream)
214 -marc[5|6|7|8] select processor variant (default arc%d)\n\
215 -EB assemble code for a big endian cpu\n\
216 -EL assemble code for a little endian cpu\n", arc_mach_type + 5);
219 /* This function is called once, at assembler startup time. It should
220 set up all the tables, etc. that the MD part of the assembler will need.
221 Opcode selection is defered until later because we might see a .cpu
227 /* The endianness can be chosen "at the factory". */
228 target_big_endian = byte_order == BIG_ENDIAN;
230 if (!bfd_set_arch_mach (stdoutput, bfd_arch_arc, arc_mach_type))
231 as_warn ("could not set architecture and machine");
233 /* This call is necessary because we need to
234 initialize `arc_operand_map' which may be needed before we see the
236 arc_opcode_init_tables (arc_get_opcode_mach (arc_mach_type,
240 /* Initialize the various opcode and operand tables.
241 MACH is one of bfd_mach_arc_xxx. */
244 init_opcode_tables (mach)
250 if ((arc_suffix_hash = hash_new ()) == NULL)
251 as_fatal ("virtual memory exhausted");
253 if (!bfd_set_arch_mach (stdoutput, bfd_arch_arc, mach))
254 as_warn ("could not set architecture and machine");
256 /* This initializes a few things in arc-opc.c that we need.
257 This must be called before the various arc_xxx_supported fns. */
258 arc_opcode_init_tables (arc_get_opcode_mach (mach, target_big_endian));
260 /* Only put the first entry of each equivalently named suffix in the
263 for (i = 0; i < arc_suffixes_count; i++)
265 if (strcmp (arc_suffixes[i].name, last) != 0)
266 hash_insert (arc_suffix_hash, arc_suffixes[i].name, (PTR) (arc_suffixes + i));
267 last = arc_suffixes[i].name;
270 /* Since registers don't have a prefix, we put them in the symbol table so
271 they can't be used as symbols. This also simplifies argument parsing as
272 we can let gas parse registers for us. The recorded register number is
273 the address of the register's entry in arc_reg_names.
275 If the register name is already in the table, then the existing
276 definition is assumed to be from an .ExtCoreRegister pseudo-op. */
278 for (i = 0; i < arc_reg_names_count; i++)
280 if (symbol_find(arc_reg_names[i].name))
282 /* Use symbol_create here instead of symbol_new so we don't try to
283 output registers into the object file's symbol table. */
284 symbol_table_insert (symbol_create (arc_reg_names[i].name, reg_section,
285 (int) &arc_reg_names[i], &zero_address_frag));
288 /* Tell `.option' it's too late. */
289 cpu_tables_init_p = 1;
292 /* Insert an operand value into an instruction.
293 If REG is non-NULL, it is a register number and ignore VAL. */
296 arc_insert_operand (insn, operand, mods, reg, val, file, line)
298 const struct arc_operand *operand;
300 const struct arc_operand_value *reg;
305 if (operand->bits != 32)
310 if ((operand->flags & ARC_OPERAND_SIGNED) != 0)
312 if ((operand->flags & ARC_OPERAND_SIGNOPT) != 0)
313 max = (1 << operand->bits) - 1;
315 max = (1 << (operand->bits - 1)) - 1;
316 min = - (1 << (operand->bits - 1));
320 max = (1 << operand->bits) - 1;
324 if ((operand->flags & ARC_OPERAND_NEGATIVE) != 0)
329 if (test < (offsetT) min || test > (offsetT) max)
332 "operand out of range (%s not between %ld and %ld)";
335 sprint_value (buf, test);
336 if (file == (char *) NULL)
337 as_warn (err, buf, min, max);
339 as_warn_where (file, line, err, buf, min, max);
348 insn = (*operand->insert) (insn, operand, mods, reg, (long) val, &errmsg);
349 if (errmsg != (const char *) NULL)
353 insn |= (((long) val & ((1 << operand->bits) - 1))
359 /* We need to keep a list of fixups. We can't simply generate them as
360 we go, because that would require us to first create the frag, and
361 that would screw up references to ``.''. */
365 /* index into `arc_operands' */
372 #define MAX_SUFFIXES 5
374 /* This routine is called for each instruction to be assembled. */
380 const struct arc_opcode *opcode;
381 const struct arc_opcode *std_opcode;
382 struct arc_opcode *ext_opcode;
384 const char *last_errmsg = 0;
386 static int init_tables_p = 0;
388 /* Opcode table initialization is deferred until here because we have to
389 wait for a possible .cpu command. */
392 init_opcode_tables (arc_mach_type);
396 /* Skip leading white space. */
397 while (isspace (*str))
400 /* The instructions are stored in lists hashed by the first letter (though
401 we needn't care how they're hashed). Get the first in the list. */
403 ext_opcode = arc_ext_opcodes;
404 std_opcode = arc_opcode_lookup_asm (str);
406 /* Keep looking until we find a match. */
409 for (opcode = (ext_opcode ? ext_opcode : std_opcode) ;
411 opcode = (ARC_OPCODE_NEXT_ASM (opcode)
412 ? ARC_OPCODE_NEXT_ASM (opcode)
413 : (ext_opcode ? ext_opcode = NULL, std_opcode : NULL)))
415 int past_opcode_p, fc, num_suffixes;
418 struct arc_fixup fixups[MAX_FIXUPS];
419 /* Used as a sanity check. If we need a limm reloc, make sure we ask
420 for an extra 4 bytes from frag_more. */
423 const struct arc_operand_value *insn_suffixes[MAX_SUFFIXES];
425 /* Is this opcode supported by the selected cpu? */
426 if (! arc_opcode_supported (opcode))
429 /* Scan the syntax string. If it doesn't match, try the next one. */
431 arc_opcode_init_insert ();
432 insn = opcode->value;
439 /* We don't check for (*str != '\0') here because we want to parse
440 any trailing fake arguments in the syntax string. */
441 for (str = start, syn = opcode->syntax; *syn != '\0'; )
444 const struct arc_operand *operand;
446 /* Non operand chars must match exactly. */
447 if (*syn != '%' || *++syn == '%')
449 /* Handle '+' specially as we want to allow "ld r0,[sp-4]". */
450 /* ??? The syntax has changed to [sp,-4]. */
451 if (0 && *syn == '+' && *str == '-')
453 /* Skip over syn's +, but leave str's - alone.
454 That makes the case identical to "ld r0,[sp+-4]". */
457 else if (*str == *syn)
469 /* We have an operand. Pick out any modifiers. */
471 while (ARC_MOD_P (arc_operands[arc_operand_map[(int) *syn]].flags))
473 mods |= arc_operands[arc_operand_map[(int) *syn]].flags & ARC_MOD_BITS;
476 operand = arc_operands + arc_operand_map[(int) *syn];
477 if (operand->fmt == 0)
478 as_fatal ("unknown syntax format character `%c'", *syn);
480 if (operand->flags & ARC_OPERAND_FAKE)
482 const char *errmsg = NULL;
485 insn = (*operand->insert) (insn, operand, mods, NULL, 0, &errmsg);
486 if (errmsg != (const char *) NULL)
488 last_errmsg = errmsg;
489 if (operand->flags & ARC_OPERAND_ERROR)
494 else if (operand->flags & ARC_OPERAND_WARN)
499 && (operand->flags && operand->flags & ARC_OPERAND_LIMM)
501 (ARC_OPERAND_ABSOLUTE_BRANCH | ARC_OPERAND_ADDRESS)))
503 fixups[fix_up_at].opindex = arc_operand_map[operand->fmt];
508 /* Are we finished with suffixes? */
509 else if (!past_opcode_p)
514 const struct arc_operand_value *suf,*suffix_end;
515 const struct arc_operand_value *suffix = NULL;
517 if (!(operand->flags & ARC_OPERAND_SUFFIX))
520 /* If we're at a space in the input string, we want to skip the
521 remaining suffixes. There may be some fake ones though, so
522 just go on to try the next one. */
530 if (mods & ARC_MOD_DOT)
538 /* This can happen in "b.nd foo" and we're currently looking
539 for "%q" (ie: a condition code suffix). */
547 /* Pick the suffix out and look it up via the hash table. */
548 for (t = s; *t && isalnum (*t); ++t)
552 if ((suf = get_ext_suffix(s)))
555 suf = hash_find (arc_suffix_hash, s);
558 /* This can happen in "blle foo" and we're currently using
559 the template "b%q%.n %j". The "bl" insn occurs later in
560 the table so "lle" isn't an illegal suffix. */
565 /* Is it the right type? Note that the same character is used
566 several times, so we have to examine all of them. This is
567 relatively efficient as equivalent entries are kept
568 together. If it's not the right type, don't increment `str'
569 so we try the next one in the series. */
571 if (ext_suffix_p && arc_operands[suf->type].fmt == *syn)
573 /* Insert the suffix's value into the insn. */
576 insn = (*operand->insert) (insn, operand,
577 mods, NULL, suf->value,
580 insn |= suf->value << operand->shift;
588 suffix_end = arc_suffixes + arc_suffixes_count;
590 suffix < suffix_end && strcmp (suffix->name, suf->name) == 0;
593 if (arc_operands[suffix->type].fmt == *syn)
595 /* Insert the suffix's value into the insn. */
597 insn = (*operand->insert) (insn, operand,
598 mods, NULL, suffix->value,
601 insn |= suffix->value << operand->shift;
611 ; /* Wrong type. Just go on to try next insn entry. */
614 if (num_suffixes == MAX_SUFFIXES)
615 as_bad ("too many suffixes");
617 insn_suffixes[num_suffixes++] = suffix;
621 /* This is either a register or an expression of some kind. */
624 const struct arc_operand_value *reg = NULL;
628 if (operand->flags & ARC_OPERAND_SUFFIX)
631 /* Is there anything left to parse?
632 We don't check for this at the top because we want to parse
633 any trailing fake arguments in the syntax string. */
637 /* Parse the operand. */
638 hold = input_line_pointer;
639 input_line_pointer = str;
641 str = input_line_pointer;
642 input_line_pointer = hold;
644 if (exp.X_op == O_illegal)
645 as_bad ("illegal operand");
646 else if (exp.X_op == O_absent)
647 as_bad ("missing operand");
648 else if (exp.X_op == O_constant)
650 value = exp.X_add_number;
652 else if (exp.X_op == O_register)
654 reg = (struct arc_operand_value *) exp.X_add_number;
656 #define IS_REG_DEST_OPERAND(o) ((o) == 'a')
657 else if (IS_REG_DEST_OPERAND (*syn))
658 as_bad("symbol as destination register");
661 if(!strncmp(str,"@h30",4))
663 arc_code_symbol(&exp);
666 /* We need to generate a fixup for this expression. */
667 if (fc >= MAX_FIXUPS)
668 as_fatal ("too many fixups");
669 fixups[fc].exp = exp;
670 /* We don't support shimm relocs. break here to force
671 the assembler to output a limm */
672 #define IS_REG_SHIMM_OFFSET(o) ((o) == 'd')
673 if(IS_REG_SHIMM_OFFSET(*syn))
675 /* If this is a register constant (IE: one whose
676 register value gets stored as 61-63) then this
678 /* ??? This bit could use some cleaning up.
679 Referencing the format chars like this goes
681 if (IS_SYMBOL_OPERAND (*syn))
685 /* save this, we don't yet know what reloc to use */
687 /* Tell insert_reg we need a limm. This is
688 needed because the value at this point is
690 /* ??? We need a cleaner interface than this. */
691 (*arc_operands[arc_operand_map['Q']].insert)
692 (insn, operand, mods, reg, 0L, &junk);
695 fixups[fc].opindex = arc_operand_map[(int) *syn];
700 /* Insert the register or expression into the instruction. */
703 const char *errmsg = NULL;
704 insn = (*operand->insert) (insn, operand, mods,
705 reg, (long) value, &errmsg);
706 if (errmsg != (const char *) NULL)
708 last_errmsg = errmsg;
709 if (operand->flags & ARC_OPERAND_ERROR)
714 else if (operand->flags & ARC_OPERAND_WARN)
720 insn |= (value & ((1 << operand->bits) - 1)) << operand->shift;
726 /* If we're at the end of the syntax string, we're done. */
727 /* FIXME: try to move this to a separate function. */
734 /* For the moment we assume a valid `str' can only contain blanks
735 now. IE: We needn't try again with a longer version of the
736 insn and it is assumed that longer versions of insns appear
737 before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
739 while (isspace (*str))
743 as_bad ("junk at end of line: `%s'", str);
745 /* Is there a limm value? */
746 limm_p = arc_opcode_limm_p (&limm);
748 /* Perform various error and warning tests. */
751 static int in_delay_slot_p = 0;
752 static int prev_insn_needs_cc_nop_p = 0;
753 /* delay slot type seen */
754 int delay_slot_type = ARC_DELAY_NONE;
755 /* conditional execution flag seen */
757 /* 1 if condition codes are being set */
759 /* 1 if conditional branch, including `b' "branch always" */
760 int cond_branch_p = opcode->flags & ARC_OPCODE_COND_BRANCH;
762 for (i = 0; i < num_suffixes; ++i)
764 switch (arc_operands[insn_suffixes[i]->type].fmt)
767 delay_slot_type = insn_suffixes[i]->value;
770 conditional = insn_suffixes[i]->value;
778 /* Putting an insn with a limm value in a delay slot is supposed to
779 be legal, but let's warn the user anyway. Ditto for 8 byte
780 jumps with delay slots. */
781 if (in_delay_slot_p && limm_p)
782 as_warn ("8 byte instruction in delay slot");
783 if (delay_slot_type != ARC_DELAY_NONE
784 && limm_p && arc_insn_not_jl(insn)) /* except for jl addr */
785 as_warn ("8 byte jump instruction with delay slot");
786 in_delay_slot_p = (delay_slot_type != ARC_DELAY_NONE) && !limm_p;
788 /* Warn when a conditional branch immediately follows a set of
789 the condition codes. Note that this needn't be done if the
790 insn that sets the condition codes uses a limm. */
791 if (cond_branch_p && conditional != 0 /* 0 = "always" */
792 && prev_insn_needs_cc_nop_p && arc_mach_type == bfd_mach_arc_5)
793 as_warn ("conditional branch follows set of flags");
794 prev_insn_needs_cc_nop_p =
795 /* FIXME: ??? not required:
796 (delay_slot_type != ARC_DELAY_NONE) && */
800 /* Write out the instruction.
801 It is important to fetch enough space in one call to `frag_more'.
802 We use (f - frag_now->fr_literal) to compute where we are and we
803 don't want frag_now to change between calls. */
807 md_number_to_chars (f, insn, 4);
808 md_number_to_chars (f + 4, limm, 4);
810 else if (limm_reloc_p)
812 /* We need a limm reloc, but the tables think we don't. */
818 md_number_to_chars (f, insn, 4);
821 /* Create any fixups. */
822 for (i = 0; i < fc; ++i)
824 int op_type, reloc_type;
826 const struct arc_operand *operand;
828 /* Create a fixup for this operand.
829 At this point we do not use a bfd_reloc_code_real_type for
830 operands residing in the insn, but instead just use the
831 operand index. This lets us easily handle fixups for any
832 operand type, although that is admittedly not a very exciting
833 feature. We pick a BFD reloc type in md_apply_fix.
835 Limm values (4 byte immediate "constants") must be treated
836 normally because they're not part of the actual insn word
837 and thus the insertion routines don't handle them. */
839 if (arc_operands[fixups[i].opindex].flags & ARC_OPERAND_LIMM)
841 /* modify the fixup addend as required by the cpu */
842 fixups[i].exp.X_add_number += arc_limm_fixup_adjust(insn);
843 op_type = fixups[i].opindex;
844 /* FIXME: can we add this data to the operand table? */
845 if (op_type == arc_operand_map['L']
846 || op_type == arc_operand_map['s']
847 || op_type == arc_operand_map['o']
848 || op_type == arc_operand_map['O'])
849 reloc_type = BFD_RELOC_32;
850 else if (op_type == arc_operand_map['J'])
851 reloc_type = BFD_RELOC_ARC_B26;
854 reloc_type = get_arc_exp_reloc_type (1, reloc_type,
860 op_type = get_arc_exp_reloc_type (0, fixups[i].opindex,
861 &fixups[i].exp, &exptmp);
862 reloc_type = op_type + (int) BFD_RELOC_UNUSED;
864 operand = &arc_operands[op_type];
865 fix_new_exp (frag_now,
866 ((f - frag_now->fr_literal)
867 + (operand->flags & ARC_OPERAND_LIMM ? 4 : 0)), 4,
869 (operand->flags & ARC_OPERAND_RELATIVE_BRANCH) != 0,
870 (bfd_reloc_code_real_type) reloc_type);
877 /* Try the next entry. */
880 if(NULL == last_errmsg)
881 as_bad ("bad instruction `%s'", start);
883 as_bad (last_errmsg);
889 arc_extoper (opertype)
898 struct arc_ext_operand_value *ext_oper;
904 name = input_line_pointer;
905 c = get_symbol_end ();
906 name = xstrdup(name);
909 ignore_rest_of_line();
921 /* just after name is now '\0' */
922 p = input_line_pointer;
926 if (*input_line_pointer != ',')
928 as_bad ("expected comma after operand name");
929 ignore_rest_of_line ();
934 input_line_pointer++; /* skip ',' */
935 number = get_absolute_expression ();
939 as_bad ("negative operand number %d",number);
940 ignore_rest_of_line();
949 if (*input_line_pointer != ',')
951 as_bad ("expected comma after register-number");
952 ignore_rest_of_line ();
957 input_line_pointer++; /* skip ',' */
958 mode = input_line_pointer;
960 if (!strncmp(mode, "r|w",3))
963 input_line_pointer += 3;
967 if (!strncmp(mode,"r",1))
969 imode = ARC_REGISTER_READONLY;
970 input_line_pointer += 1;
974 if (strncmp(mode,"w",1))
976 as_bad ("invalid mode");
977 ignore_rest_of_line();
983 imode = ARC_REGISTER_WRITEONLY;
984 input_line_pointer += 1;
991 if (*input_line_pointer != ',')
993 as_bad ("expected comma after register-mode");
994 ignore_rest_of_line ();
999 input_line_pointer++; /* skip ',' */
1001 if(!strncmp(input_line_pointer,"cannot_shortcut",15))
1003 imode |= arc_get_noshortcut_flag();
1004 input_line_pointer += 15;
1008 if(strncmp(input_line_pointer,"can_shortcut",12))
1010 as_bad ("shortcut designator invalid");
1011 ignore_rest_of_line();
1017 input_line_pointer += 12;
1023 if ((opertype == 1) && number > 60)
1025 as_bad("core register value (%d) too large", number);
1026 ignore_rest_of_line();
1031 if ((opertype == 0) && number > 31)
1033 as_bad("condition code value (%d) too large", number);
1034 ignore_rest_of_line();
1039 ext_oper = (struct arc_ext_operand_value *) \
1040 xmalloc(sizeof(struct arc_ext_operand_value));
1044 /* if the symbol already exists, point it at the new definition */
1045 if ((symbolP = symbol_find (name)))
1047 if (S_GET_SEGMENT(symbolP) == reg_section)
1048 S_SET_VALUE(symbolP,(int)&ext_oper->operand);
1051 as_bad("attempt to override symbol: %s",name);
1052 ignore_rest_of_line();
1060 /* If its not there, add it */
1061 symbol_table_insert (symbol_create (name, reg_section,
1062 (int) &ext_oper->operand, &zero_address_frag));
1066 ext_oper->operand.name = name;
1067 ext_oper->operand.value = number;
1068 ext_oper->operand.type = arc_operand_type(opertype);
1069 ext_oper->operand.flags = imode;
1071 ext_oper->next = arc_ext_operands;
1072 arc_ext_operands = ext_oper;
1074 /* ok, now that we know what this operand is, put a description
1075 in the arc extension section of the output file */
1078 old_subsec = now_subseg;
1086 *p = 3 + strlen(name) + 1;
1091 p = frag_more(strlen(name) + 1);
1096 *p = 3 + strlen(name) + 1;
1098 *p = EXT_CORE_REGISTER;
1101 p = frag_more(strlen(name) + 1);
1106 *p = 6 + strlen(name) + 1;
1108 *p = EXT_AUX_REGISTER;
1110 *p = number >> 24 & 0xff;
1112 *p = number >> 16 & 0xff;
1114 *p = number >> 8 & 0xff;
1117 p = frag_more(strlen(name) + 1);
1121 as_bad("invalid opertype");
1122 ignore_rest_of_line();
1128 subseg_set (old_sec, old_subsec);
1130 /* enter all registers into the symbol table */
1132 demand_empty_rest_of_line();
1136 arc_extinst (ignore)
1137 int ignore ATTRIBUTE_UNUSED;
1139 unsigned char syntax[129];
1143 int suffixcode = -1;
1144 int opcode,subopcode;
1148 struct arc_opcode *ext_op;
1153 name = input_line_pointer;
1154 c = get_symbol_end ();
1155 name = xstrdup(name);
1158 ignore_rest_of_line();
1161 strcpy(syntax,name);
1162 name_len = strlen(name);
1164 /* just after name is now '\0' */
1165 p = input_line_pointer;
1170 if (*input_line_pointer != ',')
1172 as_bad ("expected comma after operand name");
1173 ignore_rest_of_line ();
1177 input_line_pointer++; /* skip ',' */
1178 opcode = get_absolute_expression ();
1182 if (*input_line_pointer != ',')
1184 as_bad ("expected comma after opcode");
1185 ignore_rest_of_line ();
1189 input_line_pointer++; /* skip ',' */
1190 subopcode = get_absolute_expression ();
1194 as_bad ("negative subopcode %d",subopcode);
1195 ignore_rest_of_line();
1203 as_bad ("subcode value found when opcode not equal 0x03");
1204 ignore_rest_of_line();
1209 if (subopcode < 0x09 || subopcode == 0x3f)
1211 as_bad ("invalid subopcode %d", subopcode);
1212 ignore_rest_of_line();
1220 if (*input_line_pointer != ',')
1222 as_bad ("expected comma after subopcode");
1223 ignore_rest_of_line ();
1227 input_line_pointer++; /* skip ',' */
1229 for(i = 0; i < (int) MAXSUFFIXCLASS; i++)
1231 if(!strncmp(suffixclass[i].name,input_line_pointer, suffixclass[i].len))
1234 input_line_pointer += suffixclass[i].len;
1239 if(-1 == suffixcode)
1241 as_bad ("invalid suffix class");
1242 ignore_rest_of_line ();
1248 if (*input_line_pointer != ',')
1250 as_bad ("expected comma after suffix class");
1251 ignore_rest_of_line ();
1255 input_line_pointer++; /* skip ',' */
1257 for(i = 0; i < (int) MAXSYNTAXCLASS; i++)
1259 if(!strncmp(syntaxclass[i].name,input_line_pointer, syntaxclass[i].len))
1261 class = syntaxclass[i].class;
1262 input_line_pointer += syntaxclass[i].len;
1267 if(0 == (SYNTAX_VALID & class))
1269 as_bad ("invalid syntax class");
1270 ignore_rest_of_line ();
1274 if ((0x3 == opcode) & (class & SYNTAX_3OP))
1276 as_bad ("opcode 0x3 and SYNTAX_3OP invalid");
1277 ignore_rest_of_line ();
1284 strcat(syntax,"%.q%.f ");
1287 strcat(syntax,"%.f ");
1290 strcat(syntax,"%.q ");
1296 as_bad("unknown suffix class");
1297 ignore_rest_of_line();
1302 strcat(syntax,((opcode == 0x3) ? "%a,%b" : ((class & SYNTAX_3OP) ? "%a,%b,%c" : "%b,%c")));
1304 strcat(syntax,"%F");
1305 strcat(syntax,"%S%L");
1307 ext_op = (struct arc_opcode *) xmalloc(sizeof(struct arc_opcode));
1310 ignore_rest_of_line ();
1314 ext_op->syntax = xstrdup(syntax);
1315 if (NULL == ext_op->syntax)
1317 ignore_rest_of_line ();
1321 ext_op->mask = I(-1) | ((0x3 == opcode) ? C(-1) : 0 );
1322 ext_op->value = I(opcode) | ((0x3 == opcode) ? C(subopcode) : 0 );
1323 ext_op->flags = class;
1324 ext_op->next_asm = arc_ext_opcodes;
1325 ext_op->next_dis = arc_ext_opcodes;
1326 arc_ext_opcodes = ext_op;
1328 /* ok, now that we know what this inst is, put a description in
1329 the arc extension section of the output file */
1332 old_subsec = now_subseg;
1337 *p = 5 + name_len +1;
1339 *p = EXT_INSTRUCTION;
1345 *p = (class & (OP1_MUST_BE_IMM | OP1_IMM_IMPLIED) ? IGNORE_FIRST_OPD : 0);
1346 p = frag_more(name_len);
1347 strncpy(p,syntax,name_len);
1351 subseg_set (old_sec, old_subsec);
1353 demand_empty_rest_of_line();
1359 if (!arcext_section)
1361 arcext_section = subseg_new (".arcextmap", 0);
1362 bfd_set_section_flags (stdoutput, arcext_section,
1363 SEC_READONLY | SEC_HAS_CONTENTS);
1366 subseg_set (arcext_section, 0);
1371 arc_common (localScope)
1380 name = input_line_pointer;
1381 c = get_symbol_end ();
1382 /* just after name is now '\0' */
1383 p = input_line_pointer;
1387 if (*input_line_pointer != ',')
1389 as_bad ("expected comma after symbol name");
1390 ignore_rest_of_line ();
1394 input_line_pointer++; /* skip ',' */
1395 size = get_absolute_expression ();
1399 as_bad ("negative symbol length");
1400 ignore_rest_of_line ();
1405 symbolP = symbol_find_or_make (name);
1408 if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
1410 as_bad ("ignoring attempt to re-define symbol");
1411 ignore_rest_of_line ();
1414 if ( ((int) S_GET_VALUE (symbolP) != 0) \
1415 && ((int) S_GET_VALUE (symbolP) != size) )
1417 as_warn ("length of symbol \"%s\" already %ld, ignoring %d",
1418 S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP), size);
1420 assert (symbolP->sy_frag == &zero_address_frag);
1423 /* Now parse the alignment field. This field is optional for
1424 local and global symbols. Default alignment is zero. */
1425 if (*input_line_pointer == ',')
1427 input_line_pointer++;
1428 align = get_absolute_expression ();
1432 as_warn ("assuming symbol alignment of zero");
1438 if (localScope != 0)
1445 old_subsec = now_subseg;
1446 record_alignment (bss_section, align);
1447 subseg_set (bss_section, 0); /* ??? subseg_set (bss_section, 1); ??? */
1450 frag_align (align, 0, 0); /* do alignment */
1452 /* detach from old frag */
1453 if (S_GET_SEGMENT (symbolP) == bss_section)
1454 symbolP->sy_frag->fr_symbol = NULL;
1456 symbolP->sy_frag = frag_now;
1457 pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP,
1458 (offsetT) size, (char *) 0);
1461 S_SET_SIZE (symbolP, size);
1462 S_SET_SEGMENT (symbolP, bss_section);
1463 S_CLEAR_EXTERNAL (symbolP);
1465 subseg_set (old_sec, old_subsec);
1469 S_SET_VALUE (symbolP, (valueT) size);
1470 S_SET_ALIGN (symbolP, align);
1471 S_SET_EXTERNAL (symbolP);
1472 S_SET_SEGMENT (symbolP, bfd_com_section_ptr);
1475 symbolP->bsym->flags |= BSF_OBJECT;
1477 demand_empty_rest_of_line ();
1483 /* Select the cpu we're assembling for. */
1487 int ignore ATTRIBUTE_UNUSED;
1493 cpu = input_line_pointer;
1494 c = get_symbol_end ();
1495 mach = arc_get_mach (cpu);
1496 *input_line_pointer = c;
1498 /* If an instruction has already been seen, it's too late. */
1499 if (cpu_tables_init_p)
1501 as_bad ("\".option\" directive must appear before any instructions");
1502 ignore_rest_of_line ();
1509 if (mach_type_specified_p && mach != arc_mach_type)
1511 as_bad ("\".option\" directive conflicts with initial definition");
1512 ignore_rest_of_line ();
1517 /* The cpu may have been selected on the command line. */
1518 if (mach != arc_mach_type)
1519 as_warn ("\".option\" directive overrides command-line (default) value");
1520 arc_mach_type = mach;
1521 if (!bfd_set_arch_mach (stdoutput, bfd_arch_arc, mach))
1522 as_fatal ("could not set architecture and machine");
1523 mach_type_specified_p = 1;
1525 demand_empty_rest_of_line ();
1529 as_bad ("invalid identifier for \".option\"");
1530 ignore_rest_of_line ();
1534 /* Turn a string in input_line_pointer into a floating point constant of type
1535 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
1536 emitted is stored in *sizeP.
1537 An error message is returned, or NULL on OK. */
1539 /* Equal to MAX_PRECISION in atof-ieee.c */
1540 #define MAX_LITTLENUMS 6
1543 md_atof (type, litP, sizeP)
1549 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1550 LITTLENUM_TYPE *wordP;
1568 return "bad call to md_atof";
1571 t = atof_ieee (input_line_pointer, type, words);
1573 input_line_pointer = t;
1574 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1575 for (wordP = words; prec--;)
1577 md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE));
1578 litP += sizeof (LITTLENUM_TYPE);
1584 /* Write a value out to the object file, using the appropriate
1588 md_number_to_chars (buf, val, n)
1593 if (target_big_endian)
1594 number_to_chars_bigendian (buf, val, n);
1596 number_to_chars_littleendian (buf, val, n);
1599 /* Round up a section size to the appropriate boundary. */
1602 md_section_align (segment, size)
1606 int align = bfd_get_section_alignment (stdoutput, segment);
1608 return ((size + (1 << align) - 1) & (-1 << align));
1611 /* We don't have any form of relaxing. */
1614 md_estimate_size_before_relax (fragp, seg)
1615 fragS *fragp ATTRIBUTE_UNUSED;
1616 asection *seg ATTRIBUTE_UNUSED;
1618 as_fatal (_("md_estimate_size_before_relax\n"));
1622 /* Convert a machine dependent frag. We never generate these. */
1625 md_convert_frag (abfd, sec, fragp)
1626 bfd *abfd ATTRIBUTE_UNUSED;
1627 asection *sec ATTRIBUTE_UNUSED;
1628 fragS *fragp ATTRIBUTE_UNUSED;
1630 as_fatal (_("md_convert_frag\n"));
1634 arc_code_symbol(expressionP)
1635 expressionS *expressionP;
1637 if (expressionP->X_op == O_symbol && expressionP->X_add_number == 0
1638 /* I think this test is unnecessary but just as a sanity check... */
1639 && expressionP->X_op_symbol == NULL)
1642 expressionP->X_op = O_right_shift;
1643 two.X_op = O_constant;
1644 two.X_add_symbol = two.X_op_symbol = NULL;
1645 two.X_add_number = 2;
1646 expressionP->X_op_symbol = make_expr_symbol (&two);
1648 /* allow %st(sym1-sym2) */
1649 else if (expressionP->X_op == O_subtract && expressionP->X_add_symbol != NULL
1650 && expressionP->X_op_symbol != NULL && expressionP->X_add_number == 0)
1653 expressionP->X_add_symbol = make_expr_symbol (expressionP);
1654 expressionP->X_op = O_right_shift;
1655 two.X_op = O_constant;
1656 two.X_add_symbol = two.X_op_symbol = NULL;
1657 two.X_add_number = 2;
1658 expressionP->X_op_symbol = make_expr_symbol (&two);
1662 as_bad ("expression too complex code symbol");
1667 /* Parse an operand that is machine-specific.
1669 The ARC has a special %-op to adjust addresses so they're usable in
1670 branches. The "st" is short for the STatus register.
1671 ??? Later expand this to take a flags value too.
1673 ??? We can't create new expression types so we map the %-op's onto the
1674 existing syntax. This means that the user could use the chosen syntax
1675 to achieve the same effect. */
1678 md_operand (expressionP)
1679 expressionS *expressionP;
1681 char *p = input_line_pointer;
1684 if(strncmp (p, "%st(", 4) == 0)
1686 input_line_pointer += 4;
1687 expression (expressionP);
1688 if (*input_line_pointer != ')')
1690 as_bad ("missing ')' in %%-op");
1693 ++input_line_pointer;
1694 arc_code_symbol(expressionP);
1697 { /* it could be a register */
1699 struct arc_ext_operand_value *ext_oper = arc_ext_operands;
1704 l = strlen(ext_oper->operand.name);
1705 if(!strncmp(p,ext_oper->operand.name,l) && !isalnum(*(p + l)))
1707 input_line_pointer += l + 1;
1708 expressionP->X_op = O_register;
1709 expressionP->X_add_number = (int) &ext_oper->operand;
1712 ext_oper = ext_oper->next;
1714 for (i = 0; i < arc_reg_names_count; i++)
1716 l = strlen(arc_reg_names[i].name);
1717 if(!strncmp(p,arc_reg_names[i].name,l) && !isalnum(*(p + l)))
1719 input_line_pointer += l + 1;
1720 expressionP->X_op = O_register;
1721 expressionP->X_add_number = (int) &arc_reg_names[i];
1728 /* We have no need to default values of symbols.
1729 We could catch register names here, but that is handled by inserting
1730 them all in the symbol table to begin with. */
1733 md_undefined_symbol (name)
1734 char *name ATTRIBUTE_UNUSED;
1739 /* Functions concerning expressions. */
1741 /* Parse a .byte, .word, etc. expression.
1743 Values for the status register are specified with %st(label).
1744 `label' will be right shifted by 2. */
1747 arc_parse_cons_expression (exp, nbytes)
1749 unsigned int nbytes ATTRIBUTE_UNUSED;
1751 char *p = input_line_pointer;
1752 int code_symbol_fix = 0;
1754 for (;! is_end_of_line[(unsigned char) *p]; p++)
1755 if (*p == '@' && !strncmp(p,"@h30",4))
1757 code_symbol_fix = 1;
1761 if (code_symbol_fix)
1763 arc_code_symbol(exp);
1764 input_line_pointer = p;
1768 /* Record a fixup for a cons expression. */
1771 arc_cons_fix_new (frag, where, nbytes, exp)
1782 /* This may be a special ARC reloc (eg: %st()). */
1783 reloc_type = get_arc_exp_reloc_type (1, BFD_RELOC_32, exp, &exptmp);
1784 fix_new_exp (frag, where, nbytes, &exptmp, 0, reloc_type);
1788 fix_new_exp (frag, where, nbytes, exp, 0,
1789 nbytes == 2 ? BFD_RELOC_16
1790 : nbytes == 8 ? BFD_RELOC_64
1795 /* Functions concerning relocs. */
1797 /* The location from which a PC relative jump should be calculated,
1798 given a PC relative reloc. */
1801 md_pcrel_from (fixP)
1804 if (fixP->fx_addsy != (symbolS *) NULL
1805 && ! S_IS_DEFINED (fixP->fx_addsy))
1807 /* The symbol is undefined. Let the linker figure it out. */
1811 /* Return the address of the delay slot. */
1812 return fixP->fx_frag->fr_address + fixP->fx_where + fixP->fx_size;
1815 /* Compute the reloc type of an expression.
1816 The possibly modified expression is stored in EXPNEW.
1818 This is used to convert the expressions generated by the %-op's into
1819 the appropriate operand type. It is called for both data in instructions
1820 (operands) and data outside instructions (variables, debugging info, etc.).
1822 Currently supported %-ops:
1824 %st(symbol): represented as "symbol >> 2"
1825 "st" is short for STatus as in the status register (pc)
1827 DEFAULT_TYPE is the type to use if no special processing is required.
1829 DATA_P is non-zero for data or limm values, zero for insn operands.
1830 Remember that the opcode "insertion fns" cannot be used on data, they're
1831 only for inserting operands into insns. They also can't be used for limm
1832 values as the insertion routines don't handle limm values. When called for
1833 insns we return fudged reloc types (real_value - BFD_RELOC_UNUSED). When
1834 called for data or limm values we use real reloc types. */
1837 get_arc_exp_reloc_type (data_p, default_type, exp, expnew)
1841 expressionS *expnew;
1843 /* If the expression is "symbol >> 2" we must change it to just "symbol",
1844 as fix_new_exp can't handle it. Similarily for (symbol - symbol) >> 2.
1845 That's ok though. What's really going on here is that we're using
1846 ">> 2" as a special syntax for specifying BFD_RELOC_ARC_B26. */
1848 if (exp->X_op == O_right_shift
1849 && exp->X_op_symbol != NULL
1850 && exp->X_op_symbol->sy_value.X_op == O_constant
1851 && exp->X_op_symbol->sy_value.X_add_number == 2
1852 && exp->X_add_number == 0)
1854 if (exp->X_add_symbol != NULL
1855 && (exp->X_add_symbol->sy_value.X_op == O_constant
1856 || exp->X_add_symbol->sy_value.X_op == O_symbol))
1859 expnew->X_op = O_symbol;
1860 expnew->X_op_symbol = NULL;
1861 return data_p ? BFD_RELOC_ARC_B26 : arc_operand_map['J'];
1863 else if (exp->X_add_symbol != NULL
1864 && exp->X_add_symbol->sy_value.X_op == O_subtract)
1866 *expnew = exp->X_add_symbol->sy_value;
1867 return data_p ? BFD_RELOC_ARC_B26 : arc_operand_map['J'];
1872 return default_type;
1875 /* Apply a fixup to the object code. This is called for all the
1876 fixups we generated by the call to fix_new_exp, above. In the call
1877 above we used a reloc code which was the largest legal reloc code
1878 plus the operand index. Here we undo that to recover the operand
1879 index. At this point all symbol values should be fully resolved,
1880 and we attempt to completely resolve the reloc. If we can not do
1881 that, we determine the correct reloc code and put it back in the fixup. */
1884 md_apply_fix3 (fixP, valueP, seg)
1889 /*char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;*/
1892 /* FIXME FIXME FIXME: The value we are passed in *valueP includes
1893 the symbol values. Since we are using BFD_ASSEMBLER, if we are
1894 doing this relocation the code in write.c is going to call
1895 bfd_perform_relocation, which is also going to use the symbol
1896 value. That means that if the reloc is fully resolved we want to
1897 use *valueP since bfd_perform_relocation is not being used.
1898 However, if the reloc is not fully resolved we do not want to use
1899 *valueP, and must use fx_offset instead. However, if the reloc
1900 is PC relative, we do want to use *valueP since it includes the
1901 result of md_pcrel_from. This is confusing. */
1903 if (fixP->fx_addsy == (symbolS *) NULL)
1908 else if (fixP->fx_pcrel)
1911 /* ELF relocations are against symbols.
1912 If this symbol is in a different section then we need to leave it for
1913 the linker to deal with. Unfortunately, md_pcrel_from can't tell,
1914 so we have to undo it's effects here. */
1915 if (S_IS_DEFINED (fixP->fx_addsy)
1916 && S_GET_SEGMENT (fixP->fx_addsy) != seg)
1917 value += md_pcrel_from (fixP);
1921 value = fixP->fx_offset;
1922 if (fixP->fx_subsy != (symbolS *) NULL)
1924 if (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)
1925 value -= S_GET_VALUE (fixP->fx_subsy);
1928 /* We can't actually support subtracting a symbol. */
1929 as_bad_where (fixP->fx_file, fixP->fx_line,
1930 "expression too complex");
1935 if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
1938 const struct arc_operand *operand;
1942 opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED;
1944 operand = &arc_operands[opindex];
1946 /* Fetch the instruction, insert the fully resolved operand
1947 value, and stuff the instruction back again. */
1948 where = fixP->fx_frag->fr_literal + fixP->fx_where;
1949 if (target_big_endian)
1950 insn = bfd_getb32 ((unsigned char *) where);
1952 insn = bfd_getl32 ((unsigned char *) where);
1953 insn = arc_insert_operand (insn, operand, -1, NULL, (offsetT) value,
1954 fixP->fx_file, fixP->fx_line);
1955 if (target_big_endian)
1956 bfd_putb32 ((bfd_vma) insn, (unsigned char *) where);
1958 bfd_putl32 ((bfd_vma) insn, (unsigned char *) where);
1962 /* Nothing else to do here. */
1966 /* Determine a BFD reloc value based on the operand information.
1967 We are only prepared to turn a few of the operands into relocs.
1968 !!! Note that we can't handle limm values here. Since we're using
1969 implicit addends the addend must be inserted into the instruction,
1970 however, the opcode insertion routines currently do nothing with
1972 if (operand->fmt == 'B')
1974 assert ((operand->flags & ARC_OPERAND_RELATIVE_BRANCH) != 0
1975 && operand->bits == 20
1976 && operand->shift == 7);
1977 fixP->fx_r_type = BFD_RELOC_ARC_B22_PCREL;
1979 else if (operand->fmt == 'J')
1981 assert ((operand->flags & ARC_OPERAND_ABSOLUTE_BRANCH) != 0
1982 && operand->bits == 24
1983 && operand->shift == 32);
1984 fixP->fx_r_type = BFD_RELOC_ARC_B26;
1986 else if (operand->fmt == 'L')
1988 assert ((operand->flags & ARC_OPERAND_LIMM) != 0
1989 && operand->bits == 32
1990 && operand->shift == 32);
1991 fixP->fx_r_type = BFD_RELOC_32;
1995 as_bad_where (fixP->fx_file, fixP->fx_line,
1996 "unresolved expression that must be resolved");
2003 switch (fixP->fx_r_type)
2006 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2010 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2014 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2019 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2023 case BFD_RELOC_ARC_B26:
2024 /* If !fixP->fx_done then `value' is an implicit addend.
2025 We must shift it right by 2 in this case as well because the
2026 linker performs the relocation and then adds this in (as opposed
2027 to adding this in and then shifting right by 2). */
2029 md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
2037 fixP->fx_addnumber = value;
2042 /* Translate internal representation of relocation info to BFD target
2046 tc_gen_reloc (section, fixP)
2047 asection *section ATTRIBUTE_UNUSED;
2052 reloc = (arelent *) xmalloc (sizeof (arelent));
2054 reloc->sym_ptr_ptr = &fixP->fx_addsy->bsym;
2055 reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
2056 reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
2057 if (reloc->howto == (reloc_howto_type *) NULL)
2059 as_bad_where (fixP->fx_file, fixP->fx_line,
2060 "internal error: can't export reloc type %d (`%s')",
2061 fixP->fx_r_type, bfd_get_reloc_code_name (fixP->fx_r_type));
2065 assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
2067 /* set addend to account for PC being advanced one insn before the target
2068 address is computed, drop fx_addnumber as it is handled elsewhere mlm */
2070 reloc->addend = ( fixP->fx_pcrel ? -4 : 0 );