* config/tc-rl78.c (rl78_cons_fix_new): Handle user-specified
[deliverable/binutils-gdb.git] / gas / config / tc-rl78.c
1 /* tc-rl78.c -- Assembler for the Renesas RL78
2 Copyright 2011
3 Free Software Foundation, Inc.
4
5 This file is part of GAS, the GNU Assembler.
6
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
11
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.
16
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, 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
21
22 #include "as.h"
23 #include "struc-symbol.h"
24 #include "obstack.h"
25 #include "safe-ctype.h"
26 #include "dwarf2dbg.h"
27 #include "libbfd.h"
28 #include "elf/common.h"
29 #include "elf/rl78.h"
30 #include "rl78-defs.h"
31 #include "filenames.h"
32 #include "listing.h"
33 #include "sb.h"
34 #include "macro.h"
35
36 const char comment_chars[] = ";";
37 /* Note that input_file.c hand checks for '#' at the beginning of the
38 first line of the input file. This is because the compiler outputs
39 #NO_APP at the beginning of its output. */
40 const char line_comment_chars[] = "#";
41 /* Use something that isn't going to be needed by any expressions or
42 other syntax. */
43 const char line_separator_chars[] = "@";
44
45 const char EXP_CHARS[] = "eE";
46 const char FLT_CHARS[] = "dD";
47
48 /*------------------------------------------------------------------*/
49
50 char * rl78_lex_start;
51 char * rl78_lex_end;
52
53 typedef struct rl78_bytesT
54 {
55 char prefix[1];
56 int n_prefix;
57 char base[4];
58 int n_base;
59 char ops[8];
60 int n_ops;
61 struct
62 {
63 expressionS exp;
64 char offset;
65 char nbits;
66 char type; /* RL78REL_*. */
67 int reloc;
68 fixS * fixP;
69 } fixups[2];
70 int n_fixups;
71 struct
72 {
73 char type;
74 char field_pos;
75 char val_ofs;
76 } relax[2];
77 int n_relax;
78 int link_relax;
79 fixS *link_relax_fixP;
80 char times_grown;
81 char times_shrank;
82 } rl78_bytesT;
83
84 static rl78_bytesT rl78_bytes;
85
86 void
87 rl78_linkrelax_addr16 (void)
88 {
89 rl78_bytes.link_relax |= RL78_RELAXA_ADDR16;
90 }
91
92 void
93 rl78_linkrelax_branch (void)
94 {
95 rl78_bytes.link_relax |= RL78_RELAXA_BRA;
96 }
97
98 static void
99 rl78_fixup (expressionS exp, int offsetbits, int nbits, int type)
100 {
101 rl78_bytes.fixups[rl78_bytes.n_fixups].exp = exp;
102 rl78_bytes.fixups[rl78_bytes.n_fixups].offset = offsetbits;
103 rl78_bytes.fixups[rl78_bytes.n_fixups].nbits = nbits;
104 rl78_bytes.fixups[rl78_bytes.n_fixups].type = type;
105 rl78_bytes.fixups[rl78_bytes.n_fixups].reloc = exp.X_md;
106 rl78_bytes.n_fixups ++;
107 }
108
109 #define rl78_field_fixup(exp, offset, nbits, type) \
110 rl78_fixup (exp, offset + 8 * rl78_bytes.n_prefix), nbits, type)
111
112 #define rl78_op_fixup(exp, offset, nbits, type) \
113 rl78_fixup (exp, offset + 8 * (rl78_bytes.n_prefix + rl78_bytes.n_base), nbits, type)
114
115 void
116 rl78_prefix (int p)
117 {
118 rl78_bytes.prefix[0] = p;
119 rl78_bytes.n_prefix = 1;
120 }
121
122 int
123 rl78_has_prefix ()
124 {
125 return rl78_bytes.n_prefix;
126 }
127
128 void
129 rl78_base1 (int b1)
130 {
131 rl78_bytes.base[0] = b1;
132 rl78_bytes.n_base = 1;
133 }
134
135 void
136 rl78_base2 (int b1, int b2)
137 {
138 rl78_bytes.base[0] = b1;
139 rl78_bytes.base[1] = b2;
140 rl78_bytes.n_base = 2;
141 }
142
143 void
144 rl78_base3 (int b1, int b2, int b3)
145 {
146 rl78_bytes.base[0] = b1;
147 rl78_bytes.base[1] = b2;
148 rl78_bytes.base[2] = b3;
149 rl78_bytes.n_base = 3;
150 }
151
152 void
153 rl78_base4 (int b1, int b2, int b3, int b4)
154 {
155 rl78_bytes.base[0] = b1;
156 rl78_bytes.base[1] = b2;
157 rl78_bytes.base[2] = b3;
158 rl78_bytes.base[3] = b4;
159 rl78_bytes.n_base = 4;
160 }
161
162 #define F_PRECISION 2
163
164 void
165 rl78_op (expressionS exp, int nbytes, int type)
166 {
167 int v = 0;
168
169 if ((exp.X_op == O_constant || exp.X_op == O_big)
170 && type != RL78REL_PCREL)
171 {
172 if (exp.X_op == O_big && exp.X_add_number <= 0)
173 {
174 LITTLENUM_TYPE w[2];
175 char * ip = rl78_bytes.ops + rl78_bytes.n_ops;
176
177 gen_to_words (w, F_PRECISION, 8);
178 ip[3] = w[0] >> 8;
179 ip[2] = w[0];
180 ip[1] = w[1] >> 8;
181 ip[0] = w[1];
182 rl78_bytes.n_ops += 4;
183 }
184 else
185 {
186 v = exp.X_add_number;
187 while (nbytes)
188 {
189 rl78_bytes.ops[rl78_bytes.n_ops++] =v & 0xff;
190 v >>= 8;
191 nbytes --;
192 }
193 }
194 }
195 else
196 {
197 rl78_op_fixup (exp, rl78_bytes.n_ops * 8, nbytes * 8, type);
198 memset (rl78_bytes.ops + rl78_bytes.n_ops, 0, nbytes);
199 rl78_bytes.n_ops += nbytes;
200 }
201 }
202
203 /* This gets complicated when the field spans bytes, because fields
204 are numbered from the MSB of the first byte as zero, and bits are
205 stored LSB towards the LSB of the byte. Thus, a simple four-bit
206 insertion of 12 at position 4 of 0x00 yields: 0x0b. A three-bit
207 insertion of b'MXL at position 7 is like this:
208
209 - - - - - - - - - - - - - - - -
210 M X L */
211
212 void
213 rl78_field (int val, int pos, int sz)
214 {
215 int valm;
216 int bytep, bitp;
217
218 if (sz > 0)
219 {
220 if (val < 0 || val >= (1 << sz))
221 as_bad (_("Value %d doesn't fit in unsigned %d-bit field"), val, sz);
222 }
223 else
224 {
225 sz = - sz;
226 if (val < -(1 << (sz - 1)) || val >= (1 << (sz - 1)))
227 as_bad (_("Value %d doesn't fit in signed %d-bit field"), val, sz);
228 }
229
230 /* This code points at 'M' in the above example. */
231 bytep = pos / 8;
232 bitp = pos % 8;
233
234 while (bitp + sz > 8)
235 {
236 int ssz = 8 - bitp;
237 int svalm;
238
239 svalm = val >> (sz - ssz);
240 svalm = svalm & ((1 << ssz) - 1);
241 svalm = svalm << (8 - bitp - ssz);
242 gas_assert (bytep < rl78_bytes.n_base);
243 rl78_bytes.base[bytep] |= svalm;
244
245 bitp = 0;
246 sz -= ssz;
247 bytep ++;
248 }
249 valm = val & ((1 << sz) - 1);
250 valm = valm << (8 - bitp - sz);
251 gas_assert (bytep < rl78_bytes.n_base);
252 rl78_bytes.base[bytep] |= valm;
253 }
254
255 /*------------------------------------------------------------------*/
256
257 enum options
258 {
259 OPTION_RELAX = OPTION_MD_BASE,
260 };
261
262 #define RL78_SHORTOPTS ""
263 const char * md_shortopts = RL78_SHORTOPTS;
264
265 /* Assembler options. */
266 struct option md_longopts[] =
267 {
268 {"relax", no_argument, NULL, OPTION_RELAX},
269 {NULL, no_argument, NULL, 0}
270 };
271 size_t md_longopts_size = sizeof (md_longopts);
272
273 int
274 md_parse_option (int c, char * arg ATTRIBUTE_UNUSED)
275 {
276 switch (c)
277 {
278 case OPTION_RELAX:
279 linkrelax = 1;
280 return 1;
281
282 }
283 return 0;
284 }
285
286 void
287 md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
288 {
289 }
290
291
292 static void
293 s_bss (int ignore ATTRIBUTE_UNUSED)
294 {
295 int temp;
296
297 temp = get_absolute_expression ();
298 subseg_set (bss_section, (subsegT) temp);
299 demand_empty_rest_of_line ();
300 }
301
302 /* The target specific pseudo-ops which we support. */
303 const pseudo_typeS md_pseudo_table[] =
304 {
305 /* Our "standard" pseudos. */
306 { "double", float_cons, 'd' },
307 { "bss", s_bss, 0 },
308 { "3byte", cons, 3 },
309 { "int", cons, 4 },
310 { "word", cons, 4 },
311
312 /* End of list marker. */
313 { NULL, NULL, 0 }
314 };
315
316 void
317 md_begin (void)
318 {
319 }
320
321 void
322 rl78_md_end (void)
323 {
324 }
325
326 /* Write a value out to the object file, using the appropriate endianness. */
327 void
328 md_number_to_chars (char * buf, valueT val, int n)
329 {
330 number_to_chars_littleendian (buf, val, n);
331 }
332
333 static struct
334 {
335 char * fname;
336 int reloc;
337 }
338 reloc_functions[] =
339 {
340 { "lo16", BFD_RELOC_RL78_LO16 },
341 { "hi16", BFD_RELOC_RL78_HI16 },
342 { "hi8", BFD_RELOC_RL78_HI8 },
343 { 0, 0 }
344 };
345
346 void
347 md_operand (expressionS * exp ATTRIBUTE_UNUSED)
348 {
349 int reloc = 0;
350 int i;
351
352 for (i = 0; reloc_functions[i].fname; i++)
353 {
354 int flen = strlen (reloc_functions[i].fname);
355
356 if (input_line_pointer[0] == '%'
357 && strncasecmp (input_line_pointer + 1, reloc_functions[i].fname, flen) == 0
358 && input_line_pointer[flen + 1] == '(')
359 {
360 reloc = reloc_functions[i].reloc;
361 input_line_pointer += flen + 2;
362 break;
363 }
364 }
365 if (reloc == 0)
366 return;
367
368 expression (exp);
369 if (* input_line_pointer == ')')
370 input_line_pointer ++;
371
372 exp->X_md = reloc;
373 }
374
375 void
376 rl78_frag_init (fragS * fragP)
377 {
378 if (rl78_bytes.n_relax || rl78_bytes.link_relax)
379 {
380 fragP->tc_frag_data = malloc (sizeof (rl78_bytesT));
381 memcpy (fragP->tc_frag_data, & rl78_bytes, sizeof (rl78_bytesT));
382 }
383 else
384 fragP->tc_frag_data = 0;
385 }
386
387 /* When relaxing, we need to output a reloc for any .align directive
388 so that we can retain this alignment as we adjust opcode sizes. */
389 void
390 rl78_handle_align (fragS * frag)
391 {
392 if (linkrelax
393 && (frag->fr_type == rs_align
394 || frag->fr_type == rs_align_code)
395 && frag->fr_address + frag->fr_fix > 0
396 && frag->fr_offset > 0
397 && now_seg != bss_section)
398 {
399 fix_new (frag, frag->fr_fix, 0,
400 &abs_symbol, RL78_RELAXA_ALIGN + frag->fr_offset,
401 0, BFD_RELOC_RL78_RELAX);
402 /* For the purposes of relaxation, this relocation is attached
403 to the byte *after* the alignment - i.e. the byte that must
404 remain aligned. */
405 fix_new (frag->fr_next, 0, 0,
406 &abs_symbol, RL78_RELAXA_ELIGN + frag->fr_offset,
407 0, BFD_RELOC_RL78_RELAX);
408 }
409 }
410
411 char *
412 md_atof (int type, char * litP, int * sizeP)
413 {
414 return ieee_md_atof (type, litP, sizeP, target_big_endian);
415 }
416
417 symbolS *
418 md_undefined_symbol (char * name ATTRIBUTE_UNUSED)
419 {
420 return NULL;
421 }
422
423 #define APPEND(B, N_B) \
424 if (rl78_bytes.N_B) \
425 { \
426 memcpy (bytes + idx, rl78_bytes.B, rl78_bytes.N_B); \
427 idx += rl78_bytes.N_B; \
428 }
429
430
431 void
432 md_assemble (char * str)
433 {
434 char * bytes;
435 fragS * frag_then = frag_now;
436 int idx = 0;
437 int i;
438 int rel;
439 expressionS *exp;
440
441 /*printf("\033[32mASM: %s\033[0m\n", str);*/
442
443 dwarf2_emit_insn (0);
444
445 memset (& rl78_bytes, 0, sizeof (rl78_bytes));
446
447 rl78_lex_init (str, str + strlen (str));
448
449 rl78_parse ();
450
451 /* This simplifies the relaxation code. */
452 if (rl78_bytes.link_relax)
453 {
454 int olen = rl78_bytes.n_prefix + rl78_bytes.n_base + rl78_bytes.n_ops;
455 /* We do it this way because we want the frag to have the
456 rl78_bytes in it, which we initialize above. */
457 bytes = frag_more (olen);
458 frag_then = frag_now;
459 frag_variant (rs_machine_dependent,
460 olen /* max_chars */,
461 0 /* var */,
462 olen /* subtype */,
463 0 /* symbol */,
464 0 /* offset */,
465 0 /* opcode */);
466 frag_then->fr_opcode = bytes;
467 frag_then->fr_fix = olen + (bytes - frag_then->fr_literal);
468 frag_then->fr_subtype = olen;
469 frag_then->fr_var = 0;
470 }
471 else
472 {
473 bytes = frag_more (rl78_bytes.n_prefix + rl78_bytes.n_base + rl78_bytes.n_ops);
474 frag_then = frag_now;
475 }
476
477 APPEND (prefix, n_prefix);
478 APPEND (base, n_base);
479 APPEND (ops, n_ops);
480
481 if (rl78_bytes.link_relax)
482 {
483 fixS * f;
484
485 f = fix_new (frag_then,
486 (char *) bytes - frag_then->fr_literal,
487 0,
488 abs_section_sym,
489 rl78_bytes.link_relax | rl78_bytes.n_fixups,
490 0,
491 BFD_RELOC_RL78_RELAX);
492 frag_then->tc_frag_data->link_relax_fixP = f;
493 }
494
495 for (i = 0; i < rl78_bytes.n_fixups; i ++)
496 {
497 /* index: [nbytes][type] */
498 static int reloc_map[5][4] =
499 {
500 { 0, 0 },
501 { BFD_RELOC_8, BFD_RELOC_8_PCREL },
502 { BFD_RELOC_16, BFD_RELOC_16_PCREL },
503 { BFD_RELOC_24, BFD_RELOC_24_PCREL },
504 { BFD_RELOC_32, BFD_RELOC_32_PCREL },
505 };
506 fixS * f;
507
508 idx = rl78_bytes.fixups[i].offset / 8;
509 rel = reloc_map [rl78_bytes.fixups[i].nbits / 8][(int) rl78_bytes.fixups[i].type];
510
511 if (rl78_bytes.fixups[i].reloc)
512 rel = rl78_bytes.fixups[i].reloc;
513
514 if (frag_then->tc_frag_data)
515 exp = & frag_then->tc_frag_data->fixups[i].exp;
516 else
517 exp = & rl78_bytes.fixups[i].exp;
518
519 f = fix_new_exp (frag_then,
520 (char *) bytes + idx - frag_then->fr_literal,
521 rl78_bytes.fixups[i].nbits / 8,
522 exp,
523 rl78_bytes.fixups[i].type == RL78REL_PCREL ? 1 : 0,
524 rel);
525 if (frag_then->tc_frag_data)
526 frag_then->tc_frag_data->fixups[i].fixP = f;
527 }
528 }
529
530 void
531 rl78_cons_fix_new (fragS * frag,
532 int where,
533 int size,
534 expressionS * exp)
535 {
536 bfd_reloc_code_real_type type;
537
538 switch (size)
539 {
540 case 1:
541 type = BFD_RELOC_8;
542 break;
543 case 2:
544 type = BFD_RELOC_16;
545 break;
546 case 3:
547 type = BFD_RELOC_24;
548 break;
549 case 4:
550 type = BFD_RELOC_32;
551 break;
552 default:
553 as_bad (_("unsupported constant size %d\n"), size);
554 return;
555 }
556
557 switch (exp->X_md)
558 {
559 case BFD_RELOC_RL78_LO16:
560 case BFD_RELOC_RL78_HI16:
561 if (size != 2)
562 as_bad (_("%%hi16/%%lo16 only applies to .short or .hword"));
563 type = exp->X_md;
564 break;
565 case BFD_RELOC_RL78_HI8:
566 if (size != 1)
567 as_bad (_("%%hi8 only applies to .byte"));
568 type = exp->X_md;
569 break;
570 default:
571 break;
572 }
573
574 if (exp->X_op == O_subtract && exp->X_op_symbol)
575 {
576 if (size != 4 && size != 2 && size != 1)
577 as_bad (_("difference of two symbols only supported with .long, .short, or .byte"));
578 else
579 type = BFD_RELOC_RL78_DIFF;
580 }
581
582 fix_new_exp (frag, where, (int) size, exp, 0, type);
583 }
584
585 /* No relaxation just yet */
586 int
587 md_estimate_size_before_relax (fragS * fragP ATTRIBUTE_UNUSED, segT segment ATTRIBUTE_UNUSED)
588 {
589 return 0;
590 }
591
592 arelent **
593 tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
594 {
595 static arelent * reloc[8];
596 int rp;
597
598 if (fixp->fx_r_type == BFD_RELOC_NONE)
599 {
600 reloc[0] = NULL;
601 return reloc;
602 }
603
604 if (fixp->fx_subsy
605 && S_GET_SEGMENT (fixp->fx_subsy) == absolute_section)
606 {
607 fixp->fx_offset -= S_GET_VALUE (fixp->fx_subsy);
608 fixp->fx_subsy = NULL;
609 }
610
611 reloc[0] = (arelent *) xmalloc (sizeof (arelent));
612 reloc[0]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
613 * reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
614 reloc[0]->address = fixp->fx_frag->fr_address + fixp->fx_where;
615 reloc[0]->addend = fixp->fx_offset;
616
617 if (fixp->fx_r_type == BFD_RELOC_RL78_32_OP
618 && fixp->fx_subsy)
619 {
620 fixp->fx_r_type = BFD_RELOC_RL78_DIFF;
621 }
622
623 #define OPX(REL,SYM,ADD) \
624 reloc[rp] = (arelent *) xmalloc (sizeof (arelent)); \
625 reloc[rp]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); \
626 reloc[rp]->howto = bfd_reloc_type_lookup (stdoutput, REL); \
627 reloc[rp]->addend = ADD; \
628 * reloc[rp]->sym_ptr_ptr = SYM; \
629 reloc[rp]->address = fixp->fx_frag->fr_address + fixp->fx_where; \
630 reloc[++rp] = NULL
631 #define OPSYM(SYM) OPX(BFD_RELOC_RL78_SYM, SYM, 0)
632 #define OPIMM(IMM) OPX(BFD_RELOC_RL78_SYM, abs_symbol.bsym, IMM)
633 #define OP(OP) OPX(BFD_RELOC_RL78_##OP, *reloc[0]->sym_ptr_ptr, 0)
634 #define SYM0() reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RL78_SYM)
635
636 rp = 1;
637
638 /* Certain BFD relocations cannot be translated directly into
639 a single (non-Red Hat) RL78 relocation, but instead need
640 multiple RL78 relocations - handle them here. */
641 switch (fixp->fx_r_type)
642 {
643 case BFD_RELOC_RL78_DIFF:
644 SYM0 ();
645 OPSYM (symbol_get_bfdsym (fixp->fx_subsy));
646 OP(OP_SUBTRACT);
647
648 switch (fixp->fx_size)
649 {
650 case 1:
651 OP(ABS8);
652 break;
653 case 2:
654 OP (ABS16);
655 break;
656 case 4:
657 OP (ABS32);
658 break;
659 }
660 break;
661
662 case BFD_RELOC_RL78_NEG32:
663 SYM0 ();
664 OP (OP_NEG);
665 OP (ABS32);
666 break;
667
668 case BFD_RELOC_RL78_LO16:
669 SYM0 ();
670 OPIMM (0xffff);
671 OP (OP_AND);
672 OP (ABS16);
673 break;
674
675 case BFD_RELOC_RL78_HI16:
676 SYM0 ();
677 OPIMM (16);
678 OP (OP_SHRA);
679 OP (ABS16);
680 break;
681
682 case BFD_RELOC_RL78_HI8:
683 SYM0 ();
684 OPIMM (16);
685 OP (OP_SHRA);
686 OPIMM (0xff);
687 OP (OP_AND);
688 OP (ABS8);
689 break;
690
691 default:
692 reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
693 reloc[1] = NULL;
694 break;
695 }
696
697 return reloc;
698 }
699
700 int
701 rl78_validate_fix_sub (struct fix * f)
702 {
703 /* We permit the subtraction of two symbols in a few cases. */
704 /* mov #sym1-sym2, R3 */
705 if (f->fx_r_type == BFD_RELOC_RL78_32_OP)
706 return 1;
707 /* .long sym1-sym2 */
708 if (f->fx_r_type == BFD_RELOC_RL78_DIFF
709 && ! f->fx_pcrel
710 && (f->fx_size == 4 || f->fx_size == 2 || f->fx_size == 1))
711 return 1;
712 return 0;
713 }
714
715 long
716 md_pcrel_from_section (fixS * fixP, segT sec)
717 {
718 long rv;
719
720 if (fixP->fx_addsy != NULL
721 && (! S_IS_DEFINED (fixP->fx_addsy)
722 || S_GET_SEGMENT (fixP->fx_addsy) != sec))
723 /* The symbol is undefined (or is defined but not in this section).
724 Let the linker figure it out. */
725 return 0;
726
727 rv = fixP->fx_frag->fr_address + fixP->fx_where;
728 switch (fixP->fx_r_type)
729 {
730 case BFD_RELOC_8_PCREL:
731 rv += 1;
732 break;
733 case BFD_RELOC_16_PCREL:
734 rv += 2;
735 break;
736 default:
737 break;
738 }
739 return rv;
740 }
741
742 void
743 md_apply_fix (struct fix * f ATTRIBUTE_UNUSED,
744 valueT * t ATTRIBUTE_UNUSED,
745 segT s ATTRIBUTE_UNUSED)
746 {
747 char * op;
748 unsigned long val;
749
750 if (f->fx_addsy && S_FORCE_RELOC (f->fx_addsy, 1))
751 return;
752 if (f->fx_subsy && S_FORCE_RELOC (f->fx_subsy, 1))
753 return;
754
755 op = f->fx_frag->fr_literal + f->fx_where;
756 val = (unsigned long) * t;
757
758 switch (f->fx_r_type)
759 {
760 case BFD_RELOC_NONE:
761 break;
762
763 case BFD_RELOC_RL78_RELAX:
764 f->fx_done = 1;
765 break;
766
767 case BFD_RELOC_8:
768 case BFD_RELOC_8_PCREL:
769 op[0] = val;
770 break;
771
772 case BFD_RELOC_16:
773 case BFD_RELOC_16_PCREL:
774 op[0] = val;
775 op[1] = val >> 8;
776 break;
777
778 case BFD_RELOC_24:
779 op[0] = val;
780 op[1] = val >> 8;
781 op[2] = val >> 16;
782 break;
783
784 case BFD_RELOC_32:
785 case BFD_RELOC_RL78_DIFF:
786 op[0] = val;
787 op[1] = val >> 8;
788 op[2] = val >> 16;
789 op[3] = val >> 24;
790 break;
791
792 default:
793 as_bad (_("Unknown reloc in md_apply_fix: %s"),
794 bfd_get_reloc_code_name (f->fx_r_type));
795 break;
796 }
797
798 if (f->fx_addsy == NULL)
799 f->fx_done = 1;
800 }
801
802 valueT
803 md_section_align (segT segment, valueT size)
804 {
805 int align = bfd_get_section_alignment (stdoutput, segment);
806 return ((size + (1 << align) - 1) & (-1 << align));
807 }
808
809 void
810 md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
811 segT segment ATTRIBUTE_UNUSED,
812 fragS * fragP ATTRIBUTE_UNUSED)
813 {
814 /* No relaxation yet */
815 fragP->fr_var = 0;
816 }
This page took 0.04688 seconds and 5 git commands to generate.