1 /* tc-mcore.c -- Assemble code for M*Core
2 Copyright (C) 1999 Free Software Foundation.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 #include "../opcodes/mcore-opc.h"
31 #include "elf/mcore.h"
35 #define streq(a,b) (strcmp (a, b) == 0)
38 /* Forward declarations for dumb compilers. */
39 static void mcore_s_literals PARAMS ((int));
40 static void mcore_cons PARAMS ((int));
41 static void mcore_float_cons PARAMS ((int));
42 static void mcore_stringer PARAMS ((int));
43 static int log2 PARAMS ((unsigned int));
44 static char * parse_reg PARAMS ((char *, unsigned *));
45 static char * parse_creg PARAMS ((char *, unsigned *));
46 static char * parse_exp PARAMS ((char *, expressionS *));
47 static void make_name PARAMS ((char *, char *, int));
48 static int enter_literal PARAMS ((expressionS *, int));
49 static char * parse_rt PARAMS ((char *, char **, int, expressionS *));
50 static char * parse_imm PARAMS ((char *, unsigned *, unsigned, unsigned));
51 static char * parse_mem PARAMS ((char *, unsigned *, unsigned *, unsigned));
52 static void dump_literals PARAMS ((int));
53 static void check_literals PARAMS ((int, int));
54 static void mcore_s_text PARAMS ((int));
55 static void mcore_s_data PARAMS ((int));
56 static void mcore_s_section PARAMS ((int));
57 static void mcore_s_bss PARAMS ((int));
59 static void mcore_s_comm PARAMS ((int));
63 /* Several places in this file insert raw instructions into the
64 object. They should use MCORE_INST_XXX macros to get the opcodes
65 and then use these two macros to crack the MCORE_INST value into
66 the appropriate byte values. */
67 #define INST_BYTE0(x) (((x) >> 8) & 0xFF)
68 #define INST_BYTE1(x) ((x) & 0xFF)
70 const char comment_chars[] = "#/";
71 const char line_separator_chars[] = ";";
72 const char line_comment_chars[] = "#/";
74 const int md_reloc_size = 8;
76 static int do_jsri2bsr = 0; /* change here from 1 by Cruess 19 August 97 */
77 static int sifilter_mode = 0;
79 const char EXP_CHARS[] = "eE";
81 /* Chars that mean this number is a floating point constant */
84 const char FLT_CHARS[] = "rRsSfFdDxXpP";
86 #define C(what,length) (((what) << 2) + (length))
87 #define GET_WHAT(x) ((x >> 2))
89 /* These are the two types of relaxable instruction */
98 #define UNDEF_WORD_DISP 4
102 #define C32_LEN 10 /* allow for align */
104 #define U32_LEN 8 /* allow for align */
107 /* Initialize the relax table */
108 const relax_typeS md_relax_table[] =
110 { 1, 1, 0, 0 }, /* 0: unused */
111 { 1, 1, 0, 0 }, /* 1: unused */
112 { 1, 1, 0, 0 }, /* 2: unused */
113 { 1, 1, 0, 0 }, /* 3: unused */
114 { 1, 1, 0, 0 }, /* 4: unused */
115 { 2048, -2046, C12_LEN, C(COND_JUMP, COND32) }, /* 5: C(COND_JUMP, COND12) */
116 { 0, 0, C32_LEN, 0 }, /* 6: C(COND_JUMP, COND32) */
117 { 1, 1, 0, 0 }, /* 7: unused */
118 { 1, 1, 0, 0 }, /* 8: unused */
119 { 2048, -2046, U12_LEN, C(UNCD_JUMP, UNCD32) }, /* 9: C(UNCD_JUMP, UNCD12) */
120 { 0, 0, U32_LEN, 0 }, /*10: C(UNCD_JUMP, UNCD32) */
121 { 1, 1, 0, 0 }, /*11: unused */
122 { 0, 0, 0, 0 } /*12: unused */
125 /* LITERAL POOL DATA STRUCTURES */
128 unsigned short refcnt;
129 unsigned char ispcrel;
130 unsigned char unused;
134 #define MAX_POOL_SIZE (1024/4)
135 static struct literal litpool [MAX_POOL_SIZE];
136 static unsigned poolsize;
137 static unsigned poolnumber;
138 static unsigned long poolspan;
140 /* SPANPANIC: the point at which we get too scared and force a dump
141 of the literal pool, and perhaps put a branch in place.
143 1024 span of lrw/jmpi/jsri insn (actually span+1)
144 -2 possible alignment at the insn.
145 -2 possible alignment to get the table aligned.
146 -2 an inserted branch around the table.
148 at 1018, we might be in trouble.
149 -- so we have to be smaller than 1018 and since we deal with 2-byte
150 instructions, the next good choice is 1016.
151 -- Note we have a test case that fails when we've got 1018 here. */
152 #define SPANPANIC (1016) /* 1024 - 1 entry - 2 byte rounding */
153 #define SPANCLOSE (900)
154 #define SPANEXIT (600)
155 static symbolS * poolsym; /* label for current pool */
156 static char poolname[8];
157 static struct hash_control * opcode_hash_control; /* Opcode mnemonics */
159 /* This table describes all the machine specific pseudo-ops the assembler
160 has to support. The fields are:
161 Pseudo-op name without dot
162 Function to call to execute this pseudo-op
163 Integer arg to pass to the function */
164 const pseudo_typeS md_pseudo_table[] =
166 { "export", s_globl, 0 },
167 { "import", s_ignore, 0 },
168 { "literals", mcore_s_literals, 0 },
169 { "page", listing_eject, 0 },
171 /* The following are to intercept the placement of data into the text
172 section (eg addresses for a switch table), so that the space they
173 occupy can be taken into account when deciding whether or not to
174 dump the current literal pool.
175 XXX - currently we do not cope with the .space and .dcb.d directives. */
176 { "ascii", mcore_stringer, 0 },
177 { "asciz", mcore_stringer, 1 },
178 { "byte", mcore_cons, 1 },
179 { "dc", mcore_cons, 2 },
180 { "dc.b", mcore_cons, 1 },
181 { "dc.d", mcore_float_cons, 'd' },
182 { "dc.l", mcore_cons, 4 },
183 { "dc.s", mcore_float_cons, 'f' },
184 { "dc.w", mcore_cons, 2 },
185 { "dc.x", mcore_float_cons, 'x' },
186 { "double", mcore_float_cons, 'd'},
187 { "float", mcore_float_cons, 'f'},
188 { "hword", mcore_cons, 2 },
189 { "int", mcore_cons, 4 },
190 { "long", mcore_cons, 4 },
191 { "octa", mcore_cons, 16 },
192 { "quad", mcore_cons, 8 },
193 { "short", mcore_cons, 2 },
194 { "single", mcore_float_cons, 'f'},
195 { "string", mcore_stringer, 1 },
196 { "word", mcore_cons, 2 },
198 /* Allow for the effect of section changes. */
199 { "text", mcore_s_text, 0 },
200 { "data", mcore_s_data, 0 },
201 { "bss", mcore_s_bss, 1 },
203 { "comm", mcore_s_comm, 0 },
205 { "section", mcore_s_section, 0 },
206 { "section.s", mcore_s_section, 0 },
207 { "sect", mcore_s_section, 0 },
208 { "sect.s", mcore_s_section, 0 },
214 mcore_s_literals (ignore)
218 demand_empty_rest_of_line ();
226 if (now_seg == text_section)
228 char * ptr = input_line_pointer;
231 /* Count the number of commas on the line. */
232 while (! is_end_of_line [* ptr])
233 commas += * ptr ++ == ',';
235 poolspan += nbytes * commas;
240 /* In theory we ought to call check_literals (2,0) here in case
241 we need to dump the literal table. We cannot do this however,
242 as the directives that we are intercepting may be being used
243 to build a switch table, and we must not interfere with its
244 contents. Instead we cross our fingers and pray... */
248 mcore_float_cons (float_type)
251 if (now_seg == text_section)
253 char * ptr = input_line_pointer;
256 #ifdef REPEAT_CONS_EXPRESSIONS
257 #error REPEAT_CONS_EXPRESSIONS not handled
260 /* Count the number of commas on the line. */
261 while (! is_end_of_line [* ptr])
262 commas += * ptr ++ == ',';
264 /* We would like to compute "hex_float (float_type) * commas"
265 but hex_float is not exported from read.c */
266 float_type == 'f' ? 4 : (float_type == 'd' ? 8 : 12);
267 poolspan += float_type * commas;
270 float_cons (float_type);
272 /* See the comment in mcore_cons () about calling check_literals.
273 It is unlikely that a switch table will be constructed using
274 floating point values, but it is still likely that an indexed
275 table of floating point constants is being created by these
276 directives, so again we must not interfere with their placement. */
280 mcore_stringer (append_zero)
283 if (now_seg == text_section)
285 char * ptr = input_line_pointer;
287 /* In theory we should compute how many bytes are going to
288 be occupied by the string(s) and add this to the poolspan.
289 To keep things simple however, we just add the number of
290 bytes left on the current line. This will be an over-
291 estimate, which is OK, and automatically allows for the
292 appending a zero byte, since the real string(s) is/are
293 required to be enclosed in double quotes. */
294 while (! is_end_of_line [* ptr])
297 poolspan += ptr - input_line_pointer;
300 stringer (append_zero);
302 /* We call check_literals here in case a large number of strings are
303 being placed into the text section with a sequence of stringer
304 directives. In theory we could be upsetting something if these
305 strings are actually in an indexed table instead of referenced by
306 individual labels. Let us hope that that never happens. */
307 check_literals (2, 0);
310 /* Handle the section changing pseudo-ops. These call through to the
311 normal implementations, but they dump the literal pool first. */
314 mcore_s_text (ignore)
320 obj_elf_text (ignore);
327 mcore_s_data (ignore)
333 obj_elf_data (ignore);
340 mcore_s_section (ignore)
346 obj_elf_section (ignore);
349 obj_coff_section (ignore);
354 mcore_s_bss (needs_align)
359 s_lcomm_bytes (needs_align);
364 mcore_s_comm (needs_align)
369 obj_elf_common (needs_align);
373 /* This function is called once, at assembler startup time. This should
374 set up all the tables, etc that the MD part of the assembler needs. */
378 mcore_opcode_info * opcode;
379 char * prev_name = "";
381 opcode_hash_control = hash_new ();
383 /* Insert unique names into hash table */
384 for (opcode = mcore_table; opcode->name; opcode ++)
386 if (streq (prev_name, opcode->name))
388 /* Make all the opcodes with the same name point to the same
390 opcode->name = prev_name;
394 prev_name = opcode->name;
395 hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
402 static expressionS immediate; /* absolute expression */
404 /* Get a log2(val). */
419 /* Try to parse a reg name. */
425 /* Strip leading whitespace. */
426 while (isspace (* s))
429 if (tolower (s[0]) == 'r')
431 if (s[1] == '1' && s[2] >= '0' && s[2] <= '5')
433 *reg = 10 + s[2] - '0';
437 if (s[1] >= '0' && s[1] <= '9')
443 else if ( tolower (s[0]) == 's'
444 && tolower (s[1]) == 'p'
451 as_bad (_("register expected, but saw '%.6s'"), s);
485 /* Strip leading whitespace. */
486 while (isspace (* s))
489 if ((tolower (s[0]) == 'c' && tolower (s[1]) == 'r'))
491 if (s[2] == '3' && s[3] >= '0' && s[3] <= '1')
493 *reg = 30 + s[3] - '0';
497 if (s[2] == '2' && s[3] >= '0' && s[3] <= '9')
499 *reg = 20 + s[3] - '0';
503 if (s[2] == '1' && s[3] >= '0' && s[3] <= '9')
505 *reg = 10 + s[3] - '0';
509 if (s[2] >= '0' && s[2] <= '9')
516 /* Look at alternate creg names before giving error. */
517 for (i = 0; cregs[i].name[0] != '\0'; i++)
523 length = strlen (cregs[i].name);
525 for (j = 0; j < length; j++)
526 buf[j] = tolower (s[j]);
528 if (strncmp (cregs[i].name, buf, length) == 0)
530 *reg = cregs[i].crnum;
535 as_bad (_("control register expected, but saw '%.6s'"), s);
548 /* Skip whitespace. */
549 while (isspace (* s))
552 save = input_line_pointer;
553 input_line_pointer = s;
557 if (e->X_op == O_absent)
558 as_bad (_("missing operand"));
560 new = input_line_pointer;
561 input_line_pointer = save;
572 static const char hex[] = "0123456789ABCDEF";
577 s[3] = hex[(n >> 12) & 0xF];
578 s[4] = hex[(n >> 8) & 0xF];
579 s[5] = hex[(n >> 4) & 0xF];
580 s[6] = hex[(n) & 0xF];
584 #define POOL_END_LABEL ".LE"
585 #define POOL_START_LABEL ".LS"
588 dump_literals (isforce)
598 /* Must we branch around the literal table? */
604 make_name (brarname, POOL_END_LABEL, poolnumber);
606 brarsym = symbol_make (brarname);
608 symbol_table_insert (brarsym);
610 output = frag_var (rs_machine_dependent,
611 md_relax_table[C (UNCD_JUMP, UNCD32)].rlx_length,
612 md_relax_table[C (UNCD_JUMP, UNCD12)].rlx_length,
613 C (UNCD_JUMP, 0), brarsym, 0, 0);
614 output[0] = INST_BYTE0 (MCORE_INST_BR); /* br .+xxx */
615 output[1] = INST_BYTE1 (MCORE_INST_BR);
618 /* Make sure that the section is sufficiently aligned and that
619 the literal table is aligned within it. */
620 record_alignment (now_seg, 2);
621 frag_align (2, 0, 0);
623 colon (S_GET_NAME (poolsym));
625 for (i = 0, p = litpool; i < poolsize; i++, p++)
626 emit_expr (& p->e, 4);
629 colon (S_GET_NAME (brarsym));
635 check_literals (kind, offset)
641 /* SPANCLOSE and SPANEXIT are smaller numbers than SPANPANIC.
642 SPANPANIC means that we must dump now.
643 kind == 0 is any old instruction.
644 kind > 0 means we just had a control transfer instruction.
645 kind == 1 means within a function
646 kind == 2 means we just left a function
648 The dump_literals (1) call inserts a branch around the table, so
649 we first look to see if its a situation where we won't have to
650 insert a branch (e.g., the previous instruction was an unconditional
653 SPANPANIC is the point where we must dump a single-entry pool.
654 it accounts for alignments and an inserted branch.
655 the 'poolsize*2' accounts for the scenario where we do:
656 lrw r1,lit1; lrw r2,lit2; lrw r3,lit3
657 Note that the 'lit2' reference is 2 bytes further along
658 but the literal it references will be 4 bytes further along,
659 so we must consider the poolsize into this equation.
660 This is slightly over-cautious, but guarantees that we won't
661 panic because a relocation is too distant. */
663 if (poolspan > SPANCLOSE && kind > 0)
665 else if (poolspan > SPANEXIT && kind > 1)
667 else if (poolspan >= (SPANPANIC - poolsize * 2))
672 enter_literal (e, ispcrel)
679 if (poolsize >= MAX_POOL_SIZE - 2)
681 /* The literal pool is as full as we can handle. We have
682 to be 2 entries shy of the 1024/4=256 entries because we
683 have to allow for the branch (2 bytes) and the alignment
684 (2 bytes before the first insn referencing the pool and
685 2 bytes before the pool itself) == 6 bytes, rounds up
692 /* Create new literal pool. */
693 if (++ poolnumber > 0xFFFF)
694 as_fatal (_("more than 65K literal pools"));
696 make_name (poolname, POOL_START_LABEL, poolnumber);
697 poolsym = symbol_make (poolname);
698 symbol_table_insert (poolsym);
702 /* Search pool for value so we don't have duplicates. */
703 for (p = litpool, i = 0; i < poolsize; i++, p++)
705 if (e->X_op == p->e.X_op
706 && e->X_add_symbol == p->e.X_add_symbol
707 && e->X_add_number == p->e.X_add_number
708 && ispcrel == p->ispcrel)
716 p->ispcrel = ispcrel;
724 /* Parse a literal specification. -- either new or old syntax.
725 old syntax: the user supplies the label and places the literal.
726 new syntax: we put it into the literal pool. */
728 parse_rt (s, outputp, ispcrel, ep)
738 /* Indicate nothing there. */
743 s = parse_exp (s + 1, & e);
748 as_bad (_("missing ']'"));
752 s = parse_exp (s, & e);
754 n = enter_literal (& e, ispcrel);
759 /* Create a reference to pool entry. */
761 e.X_add_symbol = poolsym;
762 e.X_add_number = n << 2;
765 * outputp = frag_more (2);
767 fix_new_exp (frag_now, (*outputp) - frag_now->fr_literal, 2, & e, 1,
768 BFD_RELOC_MCORE_PCREL_IMM8BY4);
774 parse_imm (s, val, min, max)
783 new = parse_exp (s, & e);
785 if (e.X_op == O_absent)
786 ; /* An error message has already been emitted. */
787 else if (e.X_op != O_constant)
788 as_bad (_("operand must be a constant"));
789 else if (e.X_add_number < min || e.X_add_number > max)
790 as_bad (_("operand must be absolute in range %d..%d, not %d"),
791 min, max, e.X_add_number);
793 * val = e.X_add_number;
799 parse_mem (s, reg, off, siz)
809 while (isspace (* s))
814 s = parse_reg (s + 1, reg);
816 while (isspace (* s))
821 s = parse_imm (s + 1, off, 0, 63);
828 as_bad (_("operand must be a multiple of 4"));
835 as_bad (_("operand must be a multiple of 2"));
842 while (isspace (* s))
849 as_bad (_("base register expected"));
854 /* This is the guts of the machine-dependent assembler. STR points to a
855 machine dependent instruction. This function is supposed to emit
856 the frags/bytes it assembles to. */
864 mcore_opcode_info * opcode;
874 /* Drop leading whitespace. */
875 while (isspace (* str))
878 /* Find the op code end. */
879 for (op_start = op_end = str;
880 * op_end && nlen < 20 && !is_end_of_line [*op_end] && *op_end != ' ';
883 name[nlen] = op_start[nlen];
891 as_bad (_("can't find opcode "));
895 opcode = (mcore_opcode_info *) hash_find (opcode_hash_control, name);
898 as_bad (_("unknown opcode \"%s\""), name);
905 switch (opcode->opclass)
908 output = frag_more (2);
912 op_end = parse_imm (op_end + 1, & reg, 0, 3);
914 output = frag_more (2);
918 op_end = parse_reg (op_end + 1, & reg);
920 output = frag_more (2);
924 op_end = parse_reg (op_end + 1, & reg);
926 output = frag_more (2);
927 /* In a sifilter mode, we emit this insn 2 times,
928 fixes problem of an interrupt during a jmp.. */
931 output[0] = INST_BYTE0 (inst);
932 output[1] = INST_BYTE1 (inst);
933 output = frag_more (2);
938 op_end = parse_reg (op_end + 1, & reg);
941 as_bad (_("invalid register: r15 illegal"));
944 output = frag_more (2);
948 /* Replace with: bsr .+2 ; addi r15,6; jmp rx ; jmp rx */
949 inst = MCORE_INST_BSR; /* with 0 displacement */
950 output[0] = INST_BYTE0 (inst);
951 output[1] = INST_BYTE1 (inst);
953 output = frag_more (2);
954 inst = MCORE_INST_ADDI;
955 inst |= 15; /* addi r15,6 */
956 inst |= (6 - 1) << 4; /* over the jmp's */
957 output[0] = INST_BYTE0 (inst);
958 output[1] = INST_BYTE1 (inst);
960 output = frag_more (2);
961 inst = MCORE_INST_JMP | reg;
962 output[0] = INST_BYTE0 (inst);
963 output[1] = INST_BYTE1 (inst);
965 output = frag_more (2); /* 2nd emitted in fallthru */
970 op_end = parse_reg (op_end + 1, & reg);
973 /* Skip whitespace. */
974 while (isspace (* op_end))
979 op_end = parse_creg (op_end + 1, & reg);
983 output = frag_more (2);
987 op_end = parse_reg (op_end + 1, & reg);
990 /* Skip whitespace. */
991 while (isspace (* op_end))
996 op_end = parse_reg (op_end + 1, & reg);
1000 as_bad (_("second operand missing"));
1002 output = frag_more (2);
1005 case X1: /* Handle both syntax-> xtrb- r1,rx OR xtrb- rx */
1006 op_end = parse_reg (op_end + 1, & reg);
1008 /* Skip whitespace. */
1009 while (isspace (* op_end))
1012 if (* op_end == ',') /* xtrb- r1,rx */
1015 as_bad (_("destination register must be r1"));
1017 op_end = parse_reg (op_end + 1, & reg);
1021 output = frag_more (2);
1024 case O1R1: /* div- rx,r1 */
1025 op_end = parse_reg (op_end + 1, & reg);
1028 /* Skip whitespace. */
1029 while (isspace (* op_end))
1032 if (* op_end == ',')
1034 op_end = parse_reg (op_end + 1, & reg);
1036 as_bad (_("source register must be r1"));
1039 as_bad (_("second operand missing"));
1041 output = frag_more (2);
1045 op_end = parse_reg (op_end + 1, & reg);
1048 /* Skip whitespace. */
1049 while (isspace (* op_end))
1052 if (* op_end == ',')
1054 op_end = parse_imm (op_end + 1, & reg, 1, 32);
1055 inst |= (reg - 1) << 4;
1058 as_bad (_("second operand missing"));
1060 output = frag_more (2);
1064 op_end = parse_reg (op_end + 1, & reg);
1067 /* Skip whitespace. */
1068 while (isspace (* op_end))
1071 if (* op_end == ',')
1073 op_end = parse_imm (op_end + 1, & reg, 0, 31);
1077 as_bad (_("second operand missing"));
1079 output = frag_more (2);
1082 case OB2: /* like OB, but arg is 2^n instead of n */
1083 op_end = parse_reg (op_end + 1, & reg);
1086 /* Skip whitespace. */
1087 while (isspace (* op_end))
1090 if (* op_end == ',')
1092 op_end = parse_imm (op_end + 1, & reg, 1, 1 << 31);
1093 /* Further restrict the immediate to a power of two. */
1094 if ((reg & (reg - 1)) == 0)
1099 as_bad (_("immediate is not a power of two"));
1104 as_bad (_("second operand missing"));
1106 output = frag_more (2);
1109 case OBRa: /* Specific for bgeni: imm of 0->6 translate to movi. */
1112 op_end = parse_reg (op_end + 1, & reg);
1115 /* Skip whitespace. */
1116 while (isspace (* op_end))
1119 if (* op_end == ',')
1121 op_end = parse_imm (op_end + 1, & reg, 0, 31);
1122 /* immediate values of 0 -> 6 translate to movi */
1125 inst = (inst & 0xF) | MCORE_INST_BGENI_ALT;
1127 as_warn (_("translating bgeni to movi"));
1133 as_bad (_("second operand missing"));
1135 output = frag_more (2);
1138 case OBR2: /* like OBR, but arg is 2^n instead of n */
1139 op_end = parse_reg (op_end + 1, & reg);
1142 /* Skip whitespace. */
1143 while (isspace (* op_end))
1146 if (* op_end == ',')
1148 op_end = parse_imm (op_end + 1, & reg, 1, 1 << 31);
1150 /* Further restrict the immediate to a power of two. */
1151 if ((reg & (reg - 1)) == 0)
1156 as_bad (_("immediate is not a power of two"));
1159 /* Immediate values of 0 -> 6 translate to movi. */
1162 inst = (inst & 0xF) | MCORE_INST_BGENI_ALT;
1164 as_warn (_("translating mgeni to movi"));
1170 as_bad (_("second operand missing"));
1172 output = frag_more (2);
1175 case OMa: /* Specific for bmaski: imm 1->7 translate to movi. */
1178 op_end = parse_reg (op_end + 1, & reg);
1181 /* Skip whitespace. */
1182 while (isspace (* op_end))
1185 if (* op_end == ',')
1187 op_end = parse_imm (op_end + 1, & reg, 1, 32);
1189 /* Immediate values of 1 -> 7 translate to movi. */
1192 inst = (inst & 0xF) | MCORE_INST_BMASKI_ALT;
1193 reg = (0x1 << reg) - 1;
1196 as_warn (_("translating bmaski to movi"));
1201 inst |= (reg & 0x1F) << 4;
1205 as_bad (_("second operand missing"));
1207 output = frag_more (2);
1211 op_end = parse_reg (op_end + 1, & reg);
1214 /* Skip whitespace. */
1215 while (isspace (* op_end))
1218 if (* op_end == ',')
1220 op_end = parse_imm (op_end + 1, & reg, 1, 31);
1224 as_bad (_("second operand missing"));
1226 output = frag_more (2);
1230 op_end = parse_reg (op_end + 1, & reg);
1233 /* Skip whitespace. */
1234 while (isspace (* op_end))
1237 if (* op_end == ',')
1239 op_end = parse_imm (op_end + 1, & reg, 0, 0x7F);
1243 as_bad (_("second operand missing"));
1245 output = frag_more (2);
1249 op_end = parse_reg (op_end + 1, & reg);
1252 /* Skip whitespace. */
1253 while (isspace (* op_end))
1256 if (* op_end == ',')
1260 if ((inst & 0x6000) == 0)
1262 else if ((inst & 0x6000) == 0x4000)
1264 else if ((inst & 0x6000) == 0x2000)
1267 op_end = parse_mem (op_end + 1, & reg, & off, size);
1270 as_bad (_("displacement too large (%d)"), off);
1272 inst |= (reg) | (off << 4);
1275 as_bad (_("second operand missing"));
1277 output = frag_more (2);
1281 op_end = parse_reg (op_end + 1, & reg);
1283 if (reg == 0 || reg == 15)
1284 as_bad (_("Invalid register: r0 and r15 illegal"));
1288 /* Skip whitespace. */
1289 while (isspace (* op_end))
1292 if (* op_end == ',')
1293 /* parse_rt calls frag_more() for us. */
1294 input_line_pointer = parse_rt (op_end + 1, & output, 0, 0);
1297 as_bad (_("second operand missing"));
1298 output = frag_more (2); /* save its space */
1303 input_line_pointer = parse_rt (op_end + 1, & output, 1, 0);
1304 /* parse_rt() calls frag_more() for us. */
1308 op_end = parse_reg (op_end + 1, & reg);
1310 if (reg == 0 || reg == 15)
1311 as_bad (_("bad starting register: r0 and r15 invalid"));
1315 /* Skip whitespace. */
1316 while (isspace (* op_end))
1319 if (* op_end == '-')
1321 op_end = parse_reg (op_end + 1, & reg);
1324 as_bad (_("ending register must be r15"));
1326 /* Skip whitespace. */
1327 while (isspace (* op_end))
1331 if (* op_end == ',')
1335 /* Skip whitespace. */
1336 while (isspace (* op_end))
1339 if (* op_end == '(')
1341 op_end = parse_reg (op_end + 1, & reg);
1344 as_bad (_("bad base register: must be r0"));
1346 if (* op_end == ')')
1350 as_bad (_("base register expected"));
1353 as_bad (_("second operand missing"));
1355 output = frag_more (2);
1359 op_end = parse_reg (op_end + 1, & reg);
1362 as_fatal (_("first register must be r4"));
1364 /* Skip whitespace. */
1365 while (isspace (* op_end))
1368 if (* op_end == '-')
1370 op_end = parse_reg (op_end + 1, & reg);
1373 as_fatal (_("last register must be r7"));
1375 /* Skip whitespace. */
1376 while (isspace (* op_end))
1379 if (* op_end == ',')
1383 /* Skip whitespace. */
1384 while (isspace (* op_end))
1387 if (* op_end == '(')
1389 op_end = parse_reg (op_end + 1, & reg);
1391 if (reg >= 4 && reg <= 7)
1392 as_fatal ("base register cannot be r4, r5, r6, or r7");
1396 /* Skip whitespace. */
1397 while (isspace (* op_end))
1400 if (* op_end == ')')
1404 as_bad (_("base register expected"));
1407 as_bad (_("second operand missing"));
1410 as_bad (_("reg-reg expected"));
1412 output = frag_more (2);
1416 input_line_pointer = parse_exp (op_end + 1, & e);
1418 output = frag_more (2);
1420 fix_new_exp (frag_now, output-frag_now->fr_literal,
1421 2, & e, 1, BFD_RELOC_MCORE_PCREL_IMM11BY2);
1425 op_end = parse_reg (op_end + 1, & reg);
1428 /* Skip whitespace. */
1429 while (isspace (* op_end))
1432 if (* op_end == ',')
1434 op_end = parse_exp (op_end + 1, & e);
1435 output = frag_more (2);
1437 fix_new_exp (frag_now, output-frag_now->fr_literal,
1438 2, & e, 1, BFD_RELOC_MCORE_PCREL_IMM4BY2);
1442 as_bad (_("second operand missing"));
1443 output = frag_more (2);
1448 input_line_pointer = parse_exp (op_end + 1, & e);
1450 output = frag_var (rs_machine_dependent,
1451 md_relax_table[C (COND_JUMP, COND32)].rlx_length,
1452 md_relax_table[C (COND_JUMP, COND12)].rlx_length,
1453 C (COND_JUMP, 0), e.X_add_symbol, e.X_add_number, 0);
1458 input_line_pointer = parse_exp (op_end + 1, & e);
1459 output = frag_var (rs_machine_dependent,
1460 md_relax_table[C (UNCD_JUMP, UNCD32)].rlx_length,
1461 md_relax_table[C (UNCD_JUMP, UNCD12)].rlx_length,
1462 C (UNCD_JUMP, 0), e.X_add_symbol, e.X_add_number, 0);
1467 inst = MCORE_INST_JSRI; /* jsri */
1468 input_line_pointer = parse_rt (op_end + 1, & output, 1, & e);
1469 /* parse_rt() calls frag_more for us */
1471 /* Only do this if we know how to do it ... */
1472 if (e.X_op != O_absent && do_jsri2bsr)
1474 /* Look at adding the R_PCREL_JSRIMM11BY2. */
1475 fix_new_exp (frag_now, output-frag_now->fr_literal,
1476 2, & e, 1, BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2);
1480 case RSI: /* SI, but imm becomes 32-imm */
1481 op_end = parse_reg (op_end + 1, & reg);
1484 /* Skip whitespace. */
1485 while (isspace (* op_end))
1488 if (* op_end == ',')
1490 op_end = parse_imm (op_end + 1, & reg, 1, 31);
1496 as_bad (_("second operand missing"));
1498 output = frag_more (2);
1501 case DO21: /* O2, dup rd, lit must be 1 */
1502 op_end = parse_reg (op_end + 1, & reg);
1506 /* Skip whitespace. */
1507 while (isspace (* op_end))
1510 if (* op_end == ',')
1512 op_end = parse_imm (op_end + 1, & reg, 1, 31);
1515 as_bad (_("second operand must be 1"));
1518 as_bad (_("second operand missing"));
1520 output = frag_more (2);
1524 op_end = parse_reg (op_end + 1, & reg);
1527 /* Skip whitespace. */
1528 while (isspace (* op_end))
1531 if (* op_end == ',')
1533 op_end = parse_imm (op_end + 1, & reg, 1, 31);
1536 as_bad (_("zero used as immediate value"));
1541 as_bad (_("second operand missing"));
1543 output = frag_more (2);
1547 as_bad (_("unimplemented opcode \"%s\""), name);
1550 output[0] = INST_BYTE0 (inst);
1551 output[1] = INST_BYTE1 (inst);
1553 check_literals (opcode->transfer, isize);
1557 md_undefined_symbol (name)
1567 subseg_set (text_section, 0);
1570 /* Various routines to kill one day. */
1571 /* Equal to MAX_PRECISION in atof-ieee.c */
1572 #define MAX_LITTLENUMS 6
1574 /* Turn a string in input_line_pointer into a floating point constant of type
1575 type, and store the appropriate bytes in *litP. The number of LITTLENUMS
1576 emitted is stored in *sizeP. An error message is returned, or NULL on OK.*/
1578 md_atof (type, litP, sizeP)
1584 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1587 char * atof_ieee ();
1617 return _("Bad call to MD_NTOF()");
1620 t = atof_ieee (input_line_pointer, type, words);
1623 input_line_pointer = t;
1625 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1627 for (i = 0; i < prec; i++)
1629 md_number_to_chars (litP, (valueT) words[i],
1630 sizeof (LITTLENUM_TYPE));
1631 litP += sizeof (LITTLENUM_TYPE);
1637 CONST char * md_shortopts = "";
1639 #define OPTION_JSRI2BSR_ON (OPTION_MD_BASE + 0)
1640 #define OPTION_JSRI2BSR_OFF (OPTION_MD_BASE + 1)
1641 #define OPTION_SIFILTER_ON (OPTION_MD_BASE + 2)
1642 #define OPTION_SIFILTER_OFF (OPTION_MD_BASE + 3)
1644 struct option md_longopts[] =
1646 { "no-jsri2bsr", no_argument, NULL, OPTION_JSRI2BSR_OFF},
1647 { "jsri2bsr", no_argument, NULL, OPTION_JSRI2BSR_ON},
1648 { "sifilter", no_argument, NULL, OPTION_SIFILTER_ON},
1649 { "no-sifilter", no_argument, NULL, OPTION_SIFILTER_OFF},
1650 { NULL, no_argument, NULL, 0}
1653 size_t md_longopts_size = sizeof (md_longopts);
1656 md_parse_option (c, arg)
1666 case OPTION_JSRI2BSR_ON: do_jsri2bsr = 1; break;
1667 case OPTION_JSRI2BSR_OFF: do_jsri2bsr = 0; break;
1668 case OPTION_SIFILTER_ON: sifilter_mode = 1; break;
1669 case OPTION_SIFILTER_OFF: sifilter_mode = 0; break;
1677 md_show_usage (stream)
1680 fprintf (stream, _("\
1681 MCORE specific options:\n\
1682 -{no-}jsri2bsr {dis}able jsri to bsr transformation (def: dis)\n\
1683 -{no-}sifilter {dis}able silicon filter behavior (def: dis)"));
1686 int md_short_jump_size;
1689 md_create_short_jump (ptr, from_Nddr, to_Nddr, frag, to_symbol)
1694 symbolS * to_symbol;
1696 as_fatal (_("failed sanity check: short_jump"));
1700 md_create_long_jump (ptr, from_Nddr, to_Nddr, frag, to_symbol)
1705 symbolS * to_symbol;
1707 as_fatal (_("failed sanity check: long_jump"));
1710 /* Called after relaxing, change the frags so they know how big they are. */
1712 md_convert_frag (abfd, sec, fragP)
1715 register fragS * fragP;
1717 unsigned char * buffer;
1718 int targ_addr = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset;
1720 buffer = (unsigned char *) (fragP->fr_fix + fragP->fr_literal);
1721 targ_addr += symbol_get_frag (fragP->fr_symbol)->fr_address;
1723 switch (fragP->fr_subtype)
1725 case C (COND_JUMP, COND12):
1726 case C (UNCD_JUMP, UNCD12):
1728 /* Get the address of the end of the instruction */
1729 int next_inst = fragP->fr_fix + fragP->fr_address + 2;
1731 int disp = targ_addr - next_inst;
1734 as_bad (_("odd displacement at %x"), next_inst - 2);
1738 t0 = buffer[0] & 0xF8;
1740 md_number_to_chars (buffer, disp, 2);
1742 buffer[0] = (buffer[0] & 0x07) | t0;
1750 case C (COND_JUMP, COND32):
1751 case C (COND_JUMP, UNDEF_WORD_DISP):
1753 /* A conditional branch wont fit into 12 bits so:
1760 * if the b!cond is 4 byte aligned, the literal which would
1761 * go at x+4 will also be aligned.
1763 int first_inst = fragP->fr_fix + fragP->fr_address;
1764 int needpad = (first_inst & 3);
1766 buffer[0] ^= 0x08; /* Toggle T/F bit */
1768 buffer[2] = INST_BYTE0 (MCORE_INST_JMPI); /* Build jmpi */
1769 buffer[3] = INST_BYTE1 (MCORE_INST_JMPI);
1774 buffer[1] = 4; /* branch over jmpi, pad, and ptr */
1775 buffer[3] = 1; /* jmpi offset of 1 gets the pointer */
1778 buffer[4] = 0; /* alignment/pad */
1780 buffer[6] = 0; /* space for 32 bit address */
1785 /* Make reloc for the long disp */
1786 fix_new (fragP, fragP->fr_fix + 6, 4,
1787 fragP->fr_symbol, fragP->fr_offset, 0, BFD_RELOC_32);
1789 fragP->fr_fix += C32_LEN;
1793 /* See comment below about this given gas' limitations for
1794 shrinking the fragment. '3' is the amount of code that
1795 we inserted here, but '4' is right for the space we reserved
1796 for this fragment. */
1798 buffer[1] = 3; /* branch over jmpi, and ptr */
1799 buffer[3] = 0; /* jmpi offset of 0 gets the pointer */
1802 buffer[4] = 0; /* space for 32 bit address */
1807 /* Make reloc for the long disp. */
1808 fix_new (fragP, fragP->fr_fix + 4, 4,
1809 fragP->fr_symbol, fragP->fr_offset, 0, BFD_RELOC_32);
1810 fragP->fr_fix += C32_LEN;
1812 /* Frag is actually shorter (see the other side of this ifdef)
1813 but gas isn't prepared for that. We have to re-adjust
1814 the branch displacement so that it goes beyond the
1815 full length of the fragment, not just what we actually
1817 buffer[1] = 4; /* jmpi, ptr, and the 'tail pad' */
1824 case C (UNCD_JUMP, UNCD32):
1825 case C (UNCD_JUMP, UNDEF_WORD_DISP):
1827 /* An unconditional branch will not fit in 12 bits, make code which
1832 we need a pad if "first_inst" is 4 byte aligned.
1833 [because the natural literal place is x + 2] */
1834 int first_inst = fragP->fr_fix + fragP->fr_address;
1835 int needpad = !(first_inst & 3);
1837 buffer[0] = INST_BYTE0 (MCORE_INST_JMPI); /* Build jmpi */
1838 buffer[1] = INST_BYTE1 (MCORE_INST_JMPI);
1842 buffer[1] = 1; /* jmpi offset of 1 since padded */
1843 buffer[2] = 0; /* alignment */
1845 buffer[4] = 0; /* space for 32 bit address */
1850 /* Make reloc for the long disp */
1851 fix_new (fragP, fragP->fr_fix + 4, 4,
1852 fragP->fr_symbol, fragP->fr_offset, 0, BFD_RELOC_32);
1854 fragP->fr_fix += U32_LEN;
1858 buffer[1] = 0; /* jmpi offset of 0 if no pad */
1859 buffer[2] = 0; /* space for 32 bit address */
1864 /* Make reloc for the long disp */
1865 fix_new (fragP, fragP->fr_fix + 2, 4,
1866 fragP->fr_symbol, fragP->fr_offset, 0, BFD_RELOC_32);
1867 fragP->fr_fix += U32_LEN;
1879 /* Applies the desired value to the specified location.
1880 Also sets up addends for 'rela' type relocations. */
1882 md_apply_fix3 (fixP, valp, segment)
1887 char * buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1888 char * file = fixP->fx_file ? fixP->fx_file : _("unknown");
1889 const char * symname;
1890 /* Note: use offsetT because it is signed, valueT is unsigned. */
1891 offsetT val = (offsetT) * valp;
1893 symname = fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : _("<unknown>");
1894 /* Save this for the addend in the relocation record. */
1895 fixP->fx_addnumber = val;
1897 /* If the fix is relative to a symbol which is not defined, or not
1898 in the same segment as the fix, we cannot resolve it here. */
1899 if (fixP->fx_addsy != NULL
1900 && ( ! S_IS_DEFINED (fixP->fx_addsy)
1901 || (S_GET_SEGMENT (fixP->fx_addsy) != segment)))
1905 /* For ELF we can just return and let the reloc that will be generated
1906 take care of everything. For COFF we still have to insert 'val'
1907 into the insn since the addend field will be ignored. */
1914 switch (fixP->fx_r_type)
1916 case BFD_RELOC_MCORE_PCREL_IMM11BY2: /* second byte of 2 byte opcode */
1918 as_bad_where (file, fixP->fx_line,
1919 _("odd distance branch (0x%x bytes)"), val);
1921 if (((val & ~0x3ff) != 0) && ((val | 0x3ff) != -1))
1922 as_bad_where (file, fixP->fx_line,
1923 _("pcrel for branch to %s too far (0x%x)"),
1925 buf[0] |= ((val >> 8) & 0x7);
1926 buf[1] |= (val & 0xff);
1929 case BFD_RELOC_MCORE_PCREL_IMM8BY4: /* lower 8 bits of 2 byte opcode */
1933 as_bad_where (file, fixP->fx_line,
1934 _("pcrel for lrw/jmpi/jsri to %s too far (0x%x)"),
1937 buf[1] |= (val & 0xff);
1940 case BFD_RELOC_MCORE_PCREL_IMM4BY2: /* loopt instruction */
1941 if ((val < -32) || (val > -2))
1942 as_bad_where (file, fixP->fx_line,
1943 _("pcrel for loopt too far (0x%x)"), val);
1945 buf[1] |= (val & 0xf);
1948 case BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2:
1949 /* Conditional linker map jsri to bsr. */
1950 /* If its a local target and close enough, fix it.
1951 NB: >= -2k for backwards bsr; < 2k for forwards... */
1952 if (fixP->fx_addsy == 0 && val >= -2048 && val < 2048)
1954 long nval = (val / 2) & 0x7ff;
1955 nval |= MCORE_INST_BSR;
1957 /* REPLACE the instruction, don't just modify it. */
1958 buf[0] = INST_BYTE0 (nval);
1959 buf[1] = INST_BYTE1 (nval);
1965 case BFD_RELOC_MCORE_PCREL_32:
1966 case BFD_RELOC_VTABLE_INHERIT:
1967 case BFD_RELOC_VTABLE_ENTRY:
1972 if (fixP->fx_addsy != NULL)
1974 /* If the fix is an absolute reloc based on a symbol's
1975 address, then it cannot be resolved until the final link. */
1982 if (fixP->fx_size == 4)
1984 else if (fixP->fx_size == 2 && val >= -32768 && val <= 32767)
1986 else if (fixP->fx_size == 1 && val >= -256 && val <= 255)
1990 md_number_to_chars (buf, val, fixP->fx_size);
1995 return 0; /* Return value is ignored. */
1999 md_operand (expressionP)
2000 expressionS * expressionP;
2002 /* Ignore leading hash symbol, if poresent. */
2003 if (* input_line_pointer == '#')
2005 input_line_pointer ++;
2006 expression (expressionP);
2010 int md_long_jump_size;
2012 /* Called just before address relaxation, return the length
2013 by which a fragment must grow to reach it's destination. */
2015 md_estimate_size_before_relax (fragP, segment_type)
2016 register fragS * fragP;
2017 register segT segment_type;
2019 switch (fragP->fr_subtype)
2021 case C (UNCD_JUMP, UNDEF_DISP):
2022 /* Used to be a branch to somewhere which was unknown. */
2023 if (!fragP->fr_symbol)
2025 fragP->fr_subtype = C (UNCD_JUMP, UNCD12);
2026 fragP->fr_var = md_relax_table[C (UNCD_JUMP, UNCD12)].rlx_length;
2028 else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
2030 fragP->fr_subtype = C (UNCD_JUMP, UNCD12);
2031 fragP->fr_var = md_relax_table[C (UNCD_JUMP, UNCD12)].rlx_length;
2035 fragP->fr_subtype = C (UNCD_JUMP, UNDEF_WORD_DISP);
2036 fragP->fr_var = md_relax_table[C (UNCD_JUMP, UNCD32)].rlx_length;
2037 return md_relax_table[C (UNCD_JUMP, UNCD32)].rlx_length;
2044 case C (COND_JUMP, UNDEF_DISP):
2045 /* Used to be a branch to somewhere which was unknown. */
2046 if (fragP->fr_symbol
2047 && S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
2049 /* Got a symbol and it's defined in this segment, become byte
2050 sized - maybe it will fix up */
2051 fragP->fr_subtype = C (COND_JUMP, COND12);
2052 fragP->fr_var = md_relax_table[C (COND_JUMP, COND12)].rlx_length;
2054 else if (fragP->fr_symbol)
2056 /* Its got a segment, but its not ours, so it will always be long. */
2057 fragP->fr_subtype = C (COND_JUMP, UNDEF_WORD_DISP);
2058 fragP->fr_var = md_relax_table[C (COND_JUMP, COND32)].rlx_length;
2059 return md_relax_table[C (COND_JUMP, COND32)].rlx_length;
2063 /* We know the abs value. */
2064 fragP->fr_subtype = C (COND_JUMP, COND12);
2065 fragP->fr_var = md_relax_table[C (COND_JUMP, COND12)].rlx_length;
2071 return fragP->fr_var;
2074 /* Put number into target byte order */
2076 md_number_to_chars (ptr, use, nbytes)
2083 case 4: *ptr++ = (use >> 24) & 0xff; /* fall through */
2084 case 3: *ptr++ = (use >> 16) & 0xff; /* fall through */
2085 case 2: *ptr++ = (use >> 8) & 0xff; /* fall through */
2086 case 1: *ptr++ = (use >> 0) & 0xff; break;
2091 /* Round up a section size to the appropriate boundary. */
2093 md_section_align (segment, size)
2097 return size; /* Byte alignment is fine */
2101 /* The location from which a PC relative jump should be calculated,
2102 given a PC relative reloc. */
2104 md_pcrel_from_section (fixp, sec)
2109 /* If the symbol is undefined or defined in another section
2110 we leave the add number alone for the linker to fix it later.
2111 Only account for the PC pre-bump (which is 2 bytes on the MCore). */
2112 if (fixp->fx_addsy != (symbolS *) NULL
2113 && (! S_IS_DEFINED (fixp->fx_addsy)
2114 || (S_GET_SEGMENT (fixp->fx_addsy) != sec)))
2117 assert (fixp->fx_size == 2); /* must be an insn */
2118 return fixp->fx_size;
2122 /* The case where we are going to resolve things... */
2123 return fixp->fx_size + fixp->fx_where + fixp->fx_frag->fr_address;
2126 #define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
2127 #define MAP(SZ,PCREL,TYPE) case F (SZ, PCREL): code = (TYPE); break
2130 tc_gen_reloc (section, fixp)
2135 bfd_reloc_code_real_type code;
2138 switch (fixp->fx_r_type)
2140 /* These confuse the size/pcrel macro approach. */
2141 case BFD_RELOC_VTABLE_INHERIT:
2142 case BFD_RELOC_VTABLE_ENTRY:
2143 case BFD_RELOC_MCORE_PCREL_IMM4BY2:
2144 case BFD_RELOC_MCORE_PCREL_IMM8BY4:
2145 case BFD_RELOC_MCORE_PCREL_IMM11BY2:
2146 case BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2:
2147 code = fixp->fx_r_type;
2151 switch (F (fixp->fx_size, fixp->fx_pcrel))
2153 MAP (1, 0, BFD_RELOC_8);
2154 MAP (2, 0, BFD_RELOC_16);
2155 MAP (4, 0, BFD_RELOC_32);
2156 MAP (1, 1, BFD_RELOC_8_PCREL);
2157 MAP (2, 1, BFD_RELOC_16_PCREL);
2158 MAP (4, 1, BFD_RELOC_32_PCREL);
2160 code = fixp->fx_r_type;
2161 as_bad (_("Can not do %d byte %srelocation"),
2163 fixp->fx_pcrel ? _("pc-relative") : "");
2168 rel = (arelent *) xmalloc (sizeof (arelent));
2169 rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
2170 *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
2171 rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
2172 /* Always pass the addend along! */
2173 rel->addend = fixp->fx_addnumber;
2175 rel->howto = bfd_reloc_type_lookup (stdoutput, code);
2177 if (rel->howto == NULL)
2179 as_bad_where (fixp->fx_file, fixp->fx_line,
2180 _("Cannot represent relocation type %s"),
2181 bfd_get_reloc_code_name (code));
2183 /* Set howto to a garbage value so that we can keep going. */
2184 rel->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32);
2185 assert (rel->howto != NULL);
2192 /* See whether we need to force a relocation into the output file.
2193 This is used to force out switch and PC relative relocations when
2196 mcore_force_relocation (fix)
2199 if ( fix->fx_r_type == BFD_RELOC_VTABLE_INHERIT
2200 || fix->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
2206 /* Return true if the fix can be handled by GAS, false if it must
2207 be passed through to the linker. */
2209 mcore_fix_adjustable (fixP)
2212 if (fixP->fx_addsy == NULL)
2215 /* We need the symbol name for the VTABLE entries. */
2216 if ( fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
2217 || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
2222 #endif /* OBJ_ELF */