1 /* tc-rx.c -- Assembler for the Renesas RX
2 Copyright 2008, 2009, 2010, 2011
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public 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
23 #include "struc-symbol.h"
25 #include "safe-ctype.h"
26 #include "dwarf2dbg.h"
28 #include "elf/common.h"
31 #include "filenames.h"
36 #define RX_OPCODE_BIG_ENDIAN 0
38 const char comment_chars
[] = ";";
39 /* Note that input_file.c hand checks for '#' at the beginning of the
40 first line of the input file. This is because the compiler outputs
41 #NO_APP at the beginning of its output. */
42 const char line_comment_chars
[] = "#";
43 const char line_separator_chars
[] = "!";
45 const char EXP_CHARS
[] = "eE";
46 const char FLT_CHARS
[] = "dD";
48 /* ELF flags to set in the output file header. */
49 static int elf_flags
= 0;
51 bfd_boolean rx_use_conventional_section_names
= FALSE
;
52 static bfd_boolean rx_use_small_data_limit
= FALSE
;
54 static bfd_boolean rx_pid_mode
= FALSE
;
55 static int rx_num_int_regs
= 0;
59 static void rx_fetchalign (int ignore ATTRIBUTE_UNUSED
);
63 OPTION_BIG
= OPTION_MD_BASE
,
67 OPTION_CONVENTIONAL_SECTION_NAMES
,
68 OPTION_RENESAS_SECTION_NAMES
,
69 OPTION_SMALL_DATA_LIMIT
,
75 #define RX_SHORTOPTS ""
76 const char * md_shortopts
= RX_SHORTOPTS
;
78 /* Assembler options. */
79 struct option md_longopts
[] =
81 {"mbig-endian-data", no_argument
, NULL
, OPTION_BIG
},
82 {"mlittle-endian-data", no_argument
, NULL
, OPTION_LITTLE
},
83 /* The next two switches are here because the
84 generic parts of the linker testsuite uses them. */
85 {"EB", no_argument
, NULL
, OPTION_BIG
},
86 {"EL", no_argument
, NULL
, OPTION_LITTLE
},
87 {"m32bit-doubles", no_argument
, NULL
, OPTION_32BIT_DOUBLES
},
88 {"m64bit-doubles", no_argument
, NULL
, OPTION_64BIT_DOUBLES
},
89 /* This option is here mainly for the binutils testsuites,
90 as many of their tests assume conventional section naming. */
91 {"muse-conventional-section-names", no_argument
, NULL
, OPTION_CONVENTIONAL_SECTION_NAMES
},
92 {"muse-renesas-section-names", no_argument
, NULL
, OPTION_RENESAS_SECTION_NAMES
},
93 {"msmall-data-limit", no_argument
, NULL
, OPTION_SMALL_DATA_LIMIT
},
94 {"relax", no_argument
, NULL
, OPTION_RELAX
},
95 {"mpid", no_argument
, NULL
, OPTION_PID
},
96 {"mint-register", required_argument
, NULL
, OPTION_INT_REGS
},
97 {NULL
, no_argument
, NULL
, 0}
99 size_t md_longopts_size
= sizeof (md_longopts
);
102 md_parse_option (int c ATTRIBUTE_UNUSED
, char * arg ATTRIBUTE_UNUSED
)
107 target_big_endian
= 1;
111 target_big_endian
= 0;
114 case OPTION_32BIT_DOUBLES
:
115 elf_flags
&= ~ E_FLAG_RX_64BIT_DOUBLES
;
118 case OPTION_64BIT_DOUBLES
:
119 elf_flags
|= E_FLAG_RX_64BIT_DOUBLES
;
122 case OPTION_CONVENTIONAL_SECTION_NAMES
:
123 rx_use_conventional_section_names
= TRUE
;
126 case OPTION_RENESAS_SECTION_NAMES
:
127 rx_use_conventional_section_names
= FALSE
;
130 case OPTION_SMALL_DATA_LIMIT
:
131 rx_use_small_data_limit
= TRUE
;
140 elf_flags
|= E_FLAG_RX_PID
;
143 case OPTION_INT_REGS
:
144 rx_num_int_regs
= atoi (optarg
);
151 md_show_usage (FILE * stream
)
153 fprintf (stream
, _(" RX specific command line options:\n"));
154 fprintf (stream
, _(" --mbig-endian-data\n"));
155 fprintf (stream
, _(" --mlittle-endian-data [default]\n"));
156 fprintf (stream
, _(" --m32bit-doubles [default]\n"));
157 fprintf (stream
, _(" --m64bit-doubles\n"));
158 fprintf (stream
, _(" --muse-conventional-section-names\n"));
159 fprintf (stream
, _(" --muse-renesas-section-names [default]\n"));
160 fprintf (stream
, _(" --msmall-data-limit\n"));
161 fprintf (stream
, _(" --mrelax\n"));
162 fprintf (stream
, _(" --mpid\n"));
163 fprintf (stream
, _(" --mint-register=<value>\n"));
167 s_bss (int ignore ATTRIBUTE_UNUSED
)
171 temp
= get_absolute_expression ();
172 subseg_set (bss_section
, (subsegT
) temp
);
173 demand_empty_rest_of_line ();
177 rx_float_cons (int ignore ATTRIBUTE_UNUSED
)
179 if (elf_flags
& E_FLAG_RX_64BIT_DOUBLES
)
180 return float_cons ('d');
181 return float_cons ('f');
185 rx_strcasestr (const char *string
, const char *sub
)
191 return (char *)string
;
194 strl
= strlen (string
);
198 /* strncasecmp is in libiberty. */
199 if (strncasecmp (string
, sub
, subl
) == 0)
200 return (char *)string
;
209 rx_include (int ignore
)
214 char * current_filename
;
222 /* The RX version of the .INCLUDE pseudo-op does not
223 have to have the filename inside double quotes. */
225 if (*input_line_pointer
== '"')
227 /* Treat as the normal GAS .include pseudo-op. */
232 /* Get the filename. Spaces are allowed, NUL characters are not. */
233 filename
= input_line_pointer
;
234 eof
= find_end_of_line (filename
, FALSE
);
235 input_line_pointer
= eof
;
237 while (eof
>= filename
&& (* eof
== ' ' || * eof
== '\n'))
239 end_char
= *(++ eof
);
243 as_bad (_("no filename following .INCLUDE pseudo-op"));
248 as_where (& current_filename
, NULL
);
249 f
= (char *) xmalloc (strlen (current_filename
) + strlen (filename
) + 1);
251 /* Check the filename. If [@]..FILE[@] is found then replace
252 this with the current assembler source filename, stripped
253 of any directory prefixes or extensions. */
254 if ((p
= rx_strcasestr (filename
, "..file")) != NULL
)
258 len
= 6; /* strlen ("..file"); */
260 if (p
> filename
&& p
[-1] == '@')
266 for (d
= c
= current_filename
; *c
; c
++)
267 if (IS_DIR_SEPARATOR (* c
))
273 sprintf (f
, "%.*s%.*s%.*s", (int) (p
- filename
), filename
,
275 (int) (strlen (filename
) - ((p
+ len
) - filename
)),
279 strcpy (f
, filename
);
281 /* RX .INCLUDE semantics say that 'filename' is located by:
283 1. If filename is absolute, just try that. Otherwise...
285 2. If the current source file includes a directory component
286 then prepend that to the filename and try. Otherwise...
288 3. Try any directories specified by the -I command line
291 4 .Try a directory specifed by the INC100 environment variable. */
293 if (IS_ABSOLUTE_PATH (f
))
294 try = fopen (path
= f
, FOPEN_RT
);
297 char * env
= getenv ("INC100");
301 len
= strlen (current_filename
);
302 if ((size_t) include_dir_maxlen
> len
)
303 len
= include_dir_maxlen
;
304 if (env
&& strlen (env
) > len
)
307 path
= (char *) xmalloc (strlen (f
) + len
+ 5);
309 if (current_filename
!= NULL
)
311 for (d
= NULL
, p
= current_filename
; *p
; p
++)
312 if (IS_DIR_SEPARATOR (* p
))
317 sprintf (path
, "%.*s/%s", (int) (d
- current_filename
), current_filename
,
319 try = fopen (path
, FOPEN_RT
);
327 for (i
= 0; i
< include_dir_count
; i
++)
329 sprintf (path
, "%s/%s", include_dirs
[i
], f
);
330 if ((try = fopen (path
, FOPEN_RT
)) != NULL
)
335 if (try == NULL
&& env
!= NULL
)
337 sprintf (path
, "%s/%s", env
, f
);
338 try = fopen (path
, FOPEN_RT
);
346 as_bad (_("unable to locate include file: %s"), filename
);
352 register_dependency (path
);
353 input_scrub_insert_file (path
);
360 parse_rx_section (char * name
)
364 int attr
= SHF_ALLOC
| SHF_EXECINSTR
;
373 for (p
= input_line_pointer
; *p
&& strchr ("\n\t, =", *p
) == NULL
; p
++)
378 if (strcasecmp (input_line_pointer
, "ALIGN") == 0)
393 case '2': align
= 2; break;
394 case '4': align
= 4; break;
395 case '8': align
= 8; break;
397 as_bad (_("unrecognised alignment value in .SECTION directive: %s"), p
);
398 ignore_rest_of_line ();
406 else if (strcasecmp (input_line_pointer
, "CODE") == 0)
407 attr
= SHF_ALLOC
| SHF_EXECINSTR
;
408 else if (strcasecmp (input_line_pointer
, "DATA") == 0)
409 attr
= SHF_ALLOC
| SHF_WRITE
;
410 else if (strcasecmp (input_line_pointer
, "ROMDATA") == 0)
414 as_bad (_("unknown parameter following .SECTION directive: %s"),
418 input_line_pointer
= p
+ 1;
419 ignore_rest_of_line ();
424 input_line_pointer
= p
+ 1;
426 while (end_char
!= '\n' && end_char
!= 0);
428 if ((sec
= bfd_get_section_by_name (stdoutput
, name
)) == NULL
)
430 if (strcmp (name
, "B") && strcmp (name
, "B_1") && strcmp (name
, "B_2"))
435 obj_elf_change_section (name
, type
, attr
, 0, NULL
, FALSE
, FALSE
);
437 else /* Try not to redefine a section, especially B_1. */
439 int flags
= sec
->flags
;
441 type
= elf_section_type (sec
);
443 attr
= ((flags
& SEC_READONLY
) ? 0 : SHF_WRITE
)
444 | ((flags
& SEC_ALLOC
) ? SHF_ALLOC
: 0)
445 | ((flags
& SEC_CODE
) ? SHF_EXECINSTR
: 0)
446 | ((flags
& SEC_MERGE
) ? SHF_MERGE
: 0)
447 | ((flags
& SEC_STRINGS
) ? SHF_STRINGS
: 0)
448 | ((flags
& SEC_THREAD_LOCAL
) ? SHF_TLS
: 0);
450 obj_elf_change_section (name
, type
, attr
, 0, NULL
, FALSE
, FALSE
);
453 bfd_set_section_alignment (stdoutput
, now_seg
, align
);
457 rx_section (int ignore
)
461 /* The as100 assembler supports a different syntax for the .section
462 pseudo-op. So check for it and handle it here if necessary. */
465 /* Peek past the section name to see if arguments follow. */
466 for (p
= input_line_pointer
; *p
; p
++)
467 if (*p
== ',' || *p
== '\n')
472 int len
= p
- input_line_pointer
;
474 while (ISSPACE (*++p
))
477 if (*p
!= '"' && *p
!= '#')
479 char * name
= (char *) xmalloc (len
+ 1);
481 strncpy (name
, input_line_pointer
, len
);
484 input_line_pointer
= p
;
485 parse_rx_section (name
);
490 obj_elf_section (ignore
);
494 rx_list (int ignore ATTRIBUTE_UNUSED
)
498 if (strncasecmp (input_line_pointer
, "OFF", 3))
500 else if (strncasecmp (input_line_pointer
, "ON", 2))
503 as_warn (_("expecting either ON or OFF after .list"));
506 /* Like the .rept pseudo op, but supports the
507 use of ..MACREP inside the repeated region. */
510 rx_rept (int ignore ATTRIBUTE_UNUSED
)
512 int count
= get_absolute_expression ();
514 do_repeat_with_expander (count
, "MREPEAT", "ENDR", "..MACREP");
517 /* Like cons() accept that strings are allowed. */
524 if (* input_line_pointer
== '"')
531 rx_nop (int ignore ATTRIBUTE_UNUSED
)
533 ignore_rest_of_line ();
539 as_warn (_("The \".%s\" pseudo-op is not implemented\n"),
540 md_pseudo_table
[idx
].poc_name
);
541 ignore_rest_of_line ();
544 /* The target specific pseudo-ops which we support. */
545 const pseudo_typeS md_pseudo_table
[] =
547 /* These are unimplemented. They're listed first so that we can use
548 the poc_value as the index into this array, to get the name of
549 the pseudo. So, keep these (1) first, and (2) in order, with (3)
550 the poc_value's in sequence. */
551 { "btglb", rx_unimp
, 0 },
552 { "call", rx_unimp
, 1 },
553 { "einsf", rx_unimp
, 2 },
554 { "fb", rx_unimp
, 3 },
555 { "fbsym", rx_unimp
, 4 },
556 { "id", rx_unimp
, 5 },
557 { "initsct", rx_unimp
, 6 },
558 { "insf", rx_unimp
, 7 },
559 { "instr", rx_unimp
, 8 },
560 { "lbba", rx_unimp
, 9 },
561 { "len", rx_unimp
, 10 },
562 { "optj", rx_unimp
, 11 },
563 { "rvector", rx_unimp
, 12 },
564 { "sb", rx_unimp
, 13 },
565 { "sbbit", rx_unimp
, 14 },
566 { "sbsym", rx_unimp
, 15 },
567 { "sbsym16", rx_unimp
, 16 },
569 /* These are the do-nothing pseudos. */
570 { "stk", rx_nop
, 0 },
571 /* The manual documents ".stk" but the compiler emits ".stack". */
572 { "stack", rx_nop
, 0 },
574 /* These are Renesas as100 assembler pseudo-ops that we do support. */
575 { "addr", rx_cons
, 3 },
576 { "align", s_align_bytes
, 2 },
577 { "byte", rx_cons
, 1 },
578 { "fixed", float_cons
, 'f' },
579 { "form", listing_psize
, 0 },
580 { "glb", s_globl
, 0 },
581 { "include", rx_include
, 0 },
582 { "list", rx_list
, 0 },
583 { "lword", rx_cons
, 4 },
584 { "mrepeat", rx_rept
, 0 },
585 { "section", rx_section
, 0 },
587 /* FIXME: The following pseudo-ops place their values (and associated
588 label if present) in the data section, regardless of whatever
589 section we are currently in. At the moment this code does not
590 implement that part of the semantics. */
591 { "blka", s_space
, 3 },
592 { "blkb", s_space
, 1 },
593 { "blkd", s_space
, 8 },
594 { "blkf", s_space
, 4 },
595 { "blkl", s_space
, 4 },
596 { "blkw", s_space
, 2 },
598 /* Our "standard" pseudos. */
599 { "double", rx_float_cons
, 0 },
601 { "3byte", cons
, 3 },
605 { "fetchalign", rx_fetchalign
, 0 },
607 /* End of list marker. */
611 static asymbol
* gp_symbol
;
612 static asymbol
* rx_pid_symbol
;
614 static symbolS
* rx_pidreg_symbol
;
615 static symbolS
* rx_gpreg_symbol
;
620 /* Make the __gp and __pid_base symbols now rather
621 than after the symbol table is frozen. We only do this
622 when supporting small data limits because otherwise we
623 pollute the symbol table. */
625 /* The meta-registers %pidreg and %gpreg depend on what other
626 options are specified. The __rx_*_defined symbols exist so we
627 can .ifdef asm code based on what options were passed to gas,
628 without needing a preprocessor */
632 rx_pid_register
= 13 - rx_num_int_regs
;
633 rx_pid_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__pid_base"));
634 rx_pidreg_symbol
= symbol_find_or_make ("__rx_pidreg_defined");
635 S_SET_VALUE (rx_pidreg_symbol
, rx_pid_register
);
636 S_SET_SEGMENT (rx_pidreg_symbol
, absolute_section
);
639 if (rx_use_small_data_limit
)
642 rx_gp_register
= rx_pid_register
- 1;
644 rx_gp_register
= 13 - rx_num_int_regs
;
645 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
646 rx_gpreg_symbol
= symbol_find_or_make ("__rx_gpreg_defined");
647 S_SET_VALUE (rx_gpreg_symbol
, rx_gp_register
);
648 S_SET_SEGMENT (rx_gpreg_symbol
, absolute_section
);
655 /* These negative numbers are found in rx_bytesT.n_base for non-opcode
657 #define RX_NBASE_FETCHALIGN -1
659 typedef struct rx_bytesT
662 /* If this is negative, it's a special-purpose frag as per the defines above. */
671 char type
; /* RXREL_*. */
684 fixS
*link_relax_fixP
;
689 static rx_bytesT rx_bytes
;
690 /* We set n_ops to be "size of next opcode" if the next opcode doesn't relax. */
691 static rx_bytesT
*fetchalign_bytes
= NULL
;
694 rx_fetchalign (int ignore ATTRIBUTE_UNUSED
)
699 memset (& rx_bytes
, 0, sizeof (rx_bytes
));
700 rx_bytes
.n_base
= RX_NBASE_FETCHALIGN
;
702 bytes
= frag_more (8);
703 frag_then
= frag_now
;
704 frag_variant (rs_machine_dependent
,
711 frag_then
->fr_opcode
= bytes
;
712 frag_then
->fr_subtype
= 0;
713 fetchalign_bytes
= frag_then
->tc_frag_data
;
717 rx_relax (int type
, int pos
)
719 rx_bytes
.relax
[rx_bytes
.n_relax
].type
= type
;
720 rx_bytes
.relax
[rx_bytes
.n_relax
].field_pos
= pos
;
721 rx_bytes
.relax
[rx_bytes
.n_relax
].val_ofs
= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
726 rx_linkrelax_dsp (int pos
)
731 rx_bytes
.link_relax
|= RX_RELAXA_DSP4
;
734 rx_bytes
.link_relax
|= RX_RELAXA_DSP6
;
737 rx_bytes
.link_relax
|= RX_RELAXA_DSP14
;
743 rx_linkrelax_imm (int pos
)
748 rx_bytes
.link_relax
|= RX_RELAXA_IMM6
;
751 rx_bytes
.link_relax
|= RX_RELAXA_IMM12
;
757 rx_linkrelax_branch (void)
759 rx_bytes
.link_relax
|= RX_RELAXA_BRA
;
763 rx_fixup (expressionS exp
, int offsetbits
, int nbits
, int type
)
765 rx_bytes
.fixups
[rx_bytes
.n_fixups
].exp
= exp
;
766 rx_bytes
.fixups
[rx_bytes
.n_fixups
].offset
= offsetbits
;
767 rx_bytes
.fixups
[rx_bytes
.n_fixups
].nbits
= nbits
;
768 rx_bytes
.fixups
[rx_bytes
.n_fixups
].type
= type
;
769 rx_bytes
.fixups
[rx_bytes
.n_fixups
].reloc
= exp
.X_md
;
770 rx_bytes
.n_fixups
++;
773 #define rx_field_fixup(exp, offset, nbits, type) \
774 rx_fixup (exp, offset, nbits, type)
776 #define rx_op_fixup(exp, offset, nbits, type) \
777 rx_fixup (exp, offset + 8 * rx_bytes.n_base, nbits, type)
782 rx_bytes
.base
[0] = b1
;
787 rx_base2 (int b1
, int b2
)
789 rx_bytes
.base
[0] = b1
;
790 rx_bytes
.base
[1] = b2
;
795 rx_base3 (int b1
, int b2
, int b3
)
797 rx_bytes
.base
[0] = b1
;
798 rx_bytes
.base
[1] = b2
;
799 rx_bytes
.base
[2] = b3
;
804 rx_base4 (int b1
, int b2
, int b3
, int b4
)
806 rx_bytes
.base
[0] = b1
;
807 rx_bytes
.base
[1] = b2
;
808 rx_bytes
.base
[2] = b3
;
809 rx_bytes
.base
[3] = b4
;
813 /* This gets complicated when the field spans bytes, because fields
814 are numbered from the MSB of the first byte as zero, and bits are
815 stored LSB towards the LSB of the byte. Thus, a simple four-bit
816 insertion of 12 at position 4 of 0x00 yields: 0x0b. A three-bit
817 insertion of b'MXL at position 7 is like this:
819 - - - - - - - - - - - - - - - -
823 rx_field (int val
, int pos
, int sz
)
830 if (val
< 0 || val
>= (1 << sz
))
831 as_bad (_("Value %d doesn't fit in unsigned %d-bit field"), val
, sz
);
836 if (val
< -(1 << (sz
- 1)) || val
>= (1 << (sz
- 1)))
837 as_bad (_("Value %d doesn't fit in signed %d-bit field"), val
, sz
);
840 /* This code points at 'M' in the above example. */
844 while (bitp
+ sz
> 8)
849 svalm
= val
>> (sz
- ssz
);
850 svalm
= svalm
& ((1 << ssz
) - 1);
851 svalm
= svalm
<< (8 - bitp
- ssz
);
852 gas_assert (bytep
< rx_bytes
.n_base
);
853 rx_bytes
.base
[bytep
] |= svalm
;
859 valm
= val
& ((1 << sz
) - 1);
860 valm
= valm
<< (8 - bitp
- sz
);
861 gas_assert (bytep
< rx_bytes
.n_base
);
862 rx_bytes
.base
[bytep
] |= valm
;
865 /* Special case of the above, for 3-bit displacements of 2..9. */
868 rx_disp3 (expressionS exp
, int pos
)
870 rx_field_fixup (exp
, pos
, 3, RXREL_PCREL
);
873 /* Special case of the above, for split 5-bit displacements. Assumes
874 the displacement has been checked with rx_disp5op. */
875 /* ---- -432 1--- 0--- */
878 rx_field5s (expressionS exp
)
882 val
= exp
.X_add_number
;
883 rx_bytes
.base
[0] |= val
>> 2;
884 rx_bytes
.base
[1] |= (val
<< 6) & 0x80;
885 rx_bytes
.base
[1] |= (val
<< 3) & 0x08;
888 /* ---- ---- 4--- 3210 */
891 rx_field5s2 (expressionS exp
)
895 val
= exp
.X_add_number
;
896 rx_bytes
.base
[1] |= (val
<< 3) & 0x80;
897 rx_bytes
.base
[1] |= (val
) & 0x0f;
900 #define OP(x) rx_bytes.ops[rx_bytes.n_ops++] = (x)
902 #define F_PRECISION 2
905 rx_op (expressionS exp
, int nbytes
, int type
)
909 if ((exp
.X_op
== O_constant
|| exp
.X_op
== O_big
)
910 && type
!= RXREL_PCREL
)
912 if (exp
.X_op
== O_big
&& exp
.X_add_number
<= 0)
915 char * ip
= rx_bytes
.ops
+ rx_bytes
.n_ops
;
917 gen_to_words (w
, F_PRECISION
, 8);
918 #if RX_OPCODE_BIG_ENDIAN
933 v
= exp
.X_add_number
;
936 #if RX_OPCODE_BIG_ENDIAN
937 OP ((v
>> (8 * (nbytes
- 1))) & 0xff);
948 rx_op_fixup (exp
, rx_bytes
.n_ops
* 8, nbytes
* 8, type
);
949 memset (rx_bytes
.ops
+ rx_bytes
.n_ops
, 0, nbytes
);
950 rx_bytes
.n_ops
+= nbytes
;
960 #define APPEND(B, N_B) \
963 memcpy (bytes + idx, rx_bytes.B, rx_bytes.N_B); \
964 idx += rx_bytes.N_B; \
968 rx_frag_init (fragS
* fragP
)
970 if (rx_bytes
.n_relax
|| rx_bytes
.link_relax
|| rx_bytes
.n_base
< 0)
972 fragP
->tc_frag_data
= malloc (sizeof (rx_bytesT
));
973 memcpy (fragP
->tc_frag_data
, & rx_bytes
, sizeof (rx_bytesT
));
976 fragP
->tc_frag_data
= 0;
979 /* Handle the as100's version of the .equ pseudo-op. It has the syntax:
980 <symbol_name> .equ <expression> */
983 rx_equ (char * name
, char * expression
)
985 char saved_name_end_char
;
989 while (ISSPACE (* name
))
992 for (name_end
= name
+ 1; *name_end
; name_end
++)
993 if (! ISALNUM (* name_end
))
996 saved_name_end_char
= * name_end
;
999 saved_ilp
= input_line_pointer
;
1000 input_line_pointer
= expression
;
1004 input_line_pointer
= saved_ilp
;
1005 * name_end
= saved_name_end_char
;
1008 /* Look for Renesas as100 pseudo-ops that occur after a symbol name
1009 rather than at the start of a line. (eg .EQU or .DEFINE). If one
1010 is found, process it and return TRUE otherwise return FALSE. */
1013 scan_for_infix_rx_pseudo_ops (char * str
)
1017 char * dot
= strchr (str
, '.');
1019 if (dot
== NULL
|| dot
== str
)
1022 /* A real pseudo-op must be preceeded by whitespace. */
1023 if (dot
[-1] != ' ' && dot
[-1] != '\t')
1026 pseudo_op
= dot
+ 1;
1028 if (!ISALNUM (* pseudo_op
))
1031 for (p
= pseudo_op
+ 1; ISALNUM (* p
); p
++)
1034 if (strncasecmp ("EQU", pseudo_op
, p
- pseudo_op
) == 0)
1036 else if (strncasecmp ("DEFINE", pseudo_op
, p
- pseudo_op
) == 0)
1037 as_warn (_("The .DEFINE pseudo-op is not implemented"));
1038 else if (strncasecmp ("MACRO", pseudo_op
, p
- pseudo_op
) == 0)
1039 as_warn (_("The .MACRO pseudo-op is not implemented"));
1040 else if (strncasecmp ("BTEQU", pseudo_op
, p
- pseudo_op
) == 0)
1041 as_warn (_("The .BTEQU pseudo-op is not implemented."));
1049 md_assemble (char * str
)
1054 fragS
* frag_then
= frag_now
;
1057 memset (& rx_bytes
, 0, sizeof (rx_bytes
));
1059 rx_lex_init (str
, str
+ strlen (str
));
1060 if (scan_for_infix_rx_pseudo_ops (str
))
1064 /* This simplifies the relaxation code. */
1065 if (rx_bytes
.n_relax
|| rx_bytes
.link_relax
)
1067 /* We do it this way because we want the frag to have the
1068 rx_bytes in it, which we initialize above. */
1069 bytes
= frag_more (12);
1070 frag_then
= frag_now
;
1071 frag_variant (rs_machine_dependent
,
1078 frag_then
->fr_opcode
= bytes
;
1079 frag_then
->fr_fix
+= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
1080 frag_then
->fr_subtype
= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
1084 bytes
= frag_more (rx_bytes
.n_base
+ rx_bytes
.n_ops
);
1085 frag_then
= frag_now
;
1086 if (fetchalign_bytes
)
1087 fetchalign_bytes
->n_ops
= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
1090 fetchalign_bytes
= NULL
;
1092 APPEND (base
, n_base
);
1093 APPEND (ops
, n_ops
);
1095 if (rx_bytes
.link_relax
&& rx_bytes
.n_fixups
)
1099 f
= fix_new (frag_then
,
1100 (char *) bytes
- frag_then
->fr_literal
,
1103 rx_bytes
.link_relax
| rx_bytes
.n_fixups
,
1105 BFD_RELOC_RX_RELAX
);
1106 frag_then
->tc_frag_data
->link_relax_fixP
= f
;
1109 for (i
= 0; i
< rx_bytes
.n_fixups
; i
++)
1111 /* index: [nbytes][type] */
1112 static int reloc_map
[5][4] =
1114 { 0, 0, 0, BFD_RELOC_RX_DIR3U_PCREL
},
1115 { BFD_RELOC_8
, BFD_RELOC_RX_8U
, BFD_RELOC_RX_NEG8
, BFD_RELOC_8_PCREL
},
1116 { BFD_RELOC_RX_16_OP
, BFD_RELOC_RX_16U
, BFD_RELOC_RX_NEG16
, BFD_RELOC_16_PCREL
},
1117 { BFD_RELOC_RX_24_OP
, BFD_RELOC_RX_24U
, BFD_RELOC_RX_NEG24
, BFD_RELOC_24_PCREL
},
1118 { BFD_RELOC_RX_32_OP
, BFD_RELOC_32
, BFD_RELOC_RX_NEG32
, BFD_RELOC_32_PCREL
},
1122 idx
= rx_bytes
.fixups
[i
].offset
/ 8;
1123 rel
= reloc_map
[rx_bytes
.fixups
[i
].nbits
/ 8][(int) rx_bytes
.fixups
[i
].type
];
1125 if (rx_bytes
.fixups
[i
].reloc
)
1126 rel
= rx_bytes
.fixups
[i
].reloc
;
1128 if (frag_then
->tc_frag_data
)
1129 exp
= & frag_then
->tc_frag_data
->fixups
[i
].exp
;
1131 exp
= & rx_bytes
.fixups
[i
].exp
;
1133 f
= fix_new_exp (frag_then
,
1134 (char *) bytes
+ idx
- frag_then
->fr_literal
,
1135 rx_bytes
.fixups
[i
].nbits
/ 8,
1137 rx_bytes
.fixups
[i
].type
== RXREL_PCREL
? 1 : 0,
1139 if (frag_then
->tc_frag_data
)
1140 frag_then
->tc_frag_data
->fixups
[i
].fixP
= f
;
1143 dwarf2_emit_insn (idx
);
1151 /* Write a value out to the object file, using the appropriate endianness. */
1154 md_number_to_chars (char * buf
, valueT val
, int n
)
1156 if (target_big_endian
)
1157 number_to_chars_bigendian (buf
, val
, n
);
1159 number_to_chars_littleendian (buf
, val
, n
);
1169 { "gp", BFD_RELOC_GPREL16
},
1174 md_operand (expressionS
* exp ATTRIBUTE_UNUSED
)
1179 for (i
= 0; reloc_functions
[i
].fname
; i
++)
1181 int flen
= strlen (reloc_functions
[i
].fname
);
1183 if (input_line_pointer
[0] == '%'
1184 && strncasecmp (input_line_pointer
+ 1, reloc_functions
[i
].fname
, flen
) == 0
1185 && input_line_pointer
[flen
+ 1] == '(')
1187 reloc
= reloc_functions
[i
].reloc
;
1188 input_line_pointer
+= flen
+ 2;
1196 if (* input_line_pointer
== ')')
1197 input_line_pointer
++;
1203 md_section_align (segT segment
, valueT size
)
1205 int align
= bfd_get_section_alignment (stdoutput
, segment
);
1206 return ((size
+ (1 << align
) - 1) & (-1 << align
));
1210 static unsigned char nop_1
[] = { 0x03};
1211 /* MOV.L R0,R0 - 1 cycle */
1212 static unsigned char nop_2
[] = { 0xef, 0x00};
1213 /* MAX R0,R0 - 1 cycle */
1214 static unsigned char nop_3
[] = { 0xfc, 0x13, 0x00 };
1215 /* MUL #1,R0 - 1 cycle */
1216 static unsigned char nop_4
[] = { 0x76, 0x10, 0x01, 0x00 };
1217 /* MUL #1,R0 - 1 cycle */
1218 static unsigned char nop_5
[] = { 0x77, 0x10, 0x01, 0x00, 0x00 };
1219 /* MUL #1,R0 - 1 cycle */
1220 static unsigned char nop_6
[] = { 0x74, 0x10, 0x01, 0x00, 0x00, 0x00 };
1221 /* BRA.S .+7 - 1 cycle */
1222 static unsigned char nop_7
[] = { 0x0F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };
1224 static unsigned char *nops
[] = { NULL
, nop_1
, nop_2
, nop_3
, nop_4
, nop_5
, nop_6
, nop_7
};
1225 #define BIGGEST_NOP 7
1227 /* When relaxing, we need to output a reloc for any .align directive
1228 so that we can retain this alignment as we adjust opcode sizes. */
1230 rx_handle_align (fragS
* frag
)
1232 /* If handling an alignment frag, use an optimal NOP pattern.
1233 Only do this if a fill value has not already been provided.
1234 FIXME: This test fails if the provided fill value is zero. */
1235 if ((frag
->fr_type
== rs_align
1236 || frag
->fr_type
== rs_align_code
)
1237 && subseg_text_p (now_seg
))
1239 int count
= (frag
->fr_next
->fr_address
1242 unsigned char *base
= (unsigned char *)frag
->fr_literal
+ frag
->fr_fix
;
1246 if (count
> BIGGEST_NOP
)
1254 memcpy (base
, nops
[count
], count
);
1255 frag
->fr_var
= count
;
1261 && (frag
->fr_type
== rs_align
1262 || frag
->fr_type
== rs_align_code
)
1263 && frag
->fr_address
+ frag
->fr_fix
> 0
1264 && frag
->fr_offset
> 0
1265 && now_seg
!= bss_section
)
1267 fix_new (frag
, frag
->fr_fix
, 0,
1268 &abs_symbol
, RX_RELAXA_ALIGN
+ frag
->fr_offset
,
1269 0, BFD_RELOC_RX_RELAX
);
1270 /* For the purposes of relaxation, this relocation is attached
1271 to the byte *after* the alignment - i.e. the byte that must
1273 fix_new (frag
->fr_next
, 0, 0,
1274 &abs_symbol
, RX_RELAXA_ELIGN
+ frag
->fr_offset
,
1275 0, BFD_RELOC_RX_RELAX
);
1280 md_atof (int type
, char * litP
, int * sizeP
)
1282 return ieee_md_atof (type
, litP
, sizeP
, target_big_endian
);
1286 md_undefined_symbol (char * name ATTRIBUTE_UNUSED
)
1291 /*----------------------------------------------------------------------*/
1292 /* To recap: we estimate everything based on md_estimate_size, then
1293 adjust based on rx_relax_frag. When it all settles, we call
1294 md_convert frag to update the bytes. The relaxation types and
1295 relocations are in fragP->tc_frag_data, which is a copy of that
1298 Our scheme is as follows: fr_fix has the size of the smallest
1299 opcode (like BRA.S). We store the number of total bytes we need in
1300 fr_subtype. When we're done relaxing, we use fr_subtype and the
1301 existing opcode bytes to figure out what actual opcode we need to
1302 put in there. If the fixup isn't resolvable now, we use the
1305 #define TRACE_RELAX 0
1306 #define tprintf if (TRACE_RELAX) printf
1318 /* We're looking for these types of relaxations:
1321 BRA.B 00101110 dspppppp
1322 BRA.W 00111000 dspppppp pppppppp
1323 BRA.A 00000100 dspppppp pppppppp pppppppp
1326 BEQ.B 00100000 dspppppp
1327 BEQ.W 00111010 dspppppp pppppppp
1330 BNE.B 00100001 dspppppp
1331 BNE.W 00111011 dspppppp pppppppp
1333 BSR.W 00111001 dspppppp pppppppp
1334 BSR.A 00000101 dspppppp pppppppp pppppppp
1336 Bcc.B 0010cond dspppppp
1338 Additionally, we can synthesize longer conditional branches using
1339 pairs of opcodes, one with an inverted conditional (flip LSB):
1341 Bcc.W 0010ncnd 00000110 00111000 dspppppp pppppppp
1342 Bcc.A 0010ncnd 00000111 00000100 dspppppp pppppppp pppppppp
1343 BEQ.A 00011100 00000100 dspppppp pppppppp pppppppp
1344 BNE.A 00010100 00000100 dspppppp pppppppp pppppppp */
1346 /* Given the opcode bytes at OP, figure out which opcode it is and
1347 return the type of opcode. We use this to re-encode the opcode as
1348 a different size later. */
1351 rx_opcode_type (char * op
)
1353 unsigned char b
= (unsigned char) op
[0];
1357 case 0x08: return OT_bra
;
1358 case 0x10: return OT_beq
;
1359 case 0x18: return OT_bne
;
1364 case 0x2e: return OT_bra
;
1365 case 0x38: return OT_bra
;
1366 case 0x04: return OT_bra
;
1368 case 0x20: return OT_beq
;
1369 case 0x3a: return OT_beq
;
1371 case 0x21: return OT_bne
;
1372 case 0x3b: return OT_bne
;
1374 case 0x39: return OT_bsr
;
1375 case 0x05: return OT_bsr
;
1378 if ((b
& 0xf0) == 0x20)
1384 /* Returns zero if *addrP has the target address. Else returns nonzero
1385 if we cannot compute the target address yet. */
1388 rx_frag_fix_value (fragS
* fragP
,
1393 addressT
* sym_addr
)
1396 rx_bytesT
* b
= fragP
->tc_frag_data
;
1397 expressionS
* exp
= & b
->fixups
[which
].exp
;
1399 if (need_diff
&& exp
->X_op
!= O_subtract
)
1402 if (exp
->X_add_symbol
)
1404 if (S_FORCE_RELOC (exp
->X_add_symbol
, 1))
1406 if (S_GET_SEGMENT (exp
->X_add_symbol
) != segment
)
1408 addr
+= S_GET_VALUE (exp
->X_add_symbol
);
1411 if (exp
->X_op_symbol
)
1413 if (exp
->X_op
!= O_subtract
)
1415 if (S_FORCE_RELOC (exp
->X_op_symbol
, 1))
1417 if (S_GET_SEGMENT (exp
->X_op_symbol
) != segment
)
1419 addr
-= S_GET_VALUE (exp
->X_op_symbol
);
1423 addr
+= exp
->X_add_number
;
1428 /* Estimate how big the opcode is after this relax pass. The return
1429 value is the difference between fr_fix and the actual size. We
1430 compute the total size in rx_relax_frag and store it in fr_subtype,
1431 sowe only need to subtract fx_fix and return it. */
1434 md_estimate_size_before_relax (fragS
* fragP ATTRIBUTE_UNUSED
, segT segment ATTRIBUTE_UNUSED
)
1439 tprintf ("\033[32m est frag: addr %08lx fix %ld var %ld ofs %ld lit %p opc %p type %d sub %d\033[0m\n",
1440 (unsigned long) (fragP
->fr_address
1441 + (fragP
->fr_opcode
- fragP
->fr_literal
)),
1442 (long) fragP
->fr_fix
, (long) fragP
->fr_var
, (long) fragP
->fr_offset
,
1443 fragP
->fr_literal
, fragP
->fr_opcode
, fragP
->fr_type
, fragP
->fr_subtype
);
1445 /* This is the size of the opcode that's accounted for in fr_fix. */
1446 opfixsize
= fragP
->fr_fix
- (fragP
->fr_opcode
- fragP
->fr_literal
);
1447 /* This is the size of the opcode that isn't. */
1448 delta
= (fragP
->fr_subtype
- opfixsize
);
1450 tprintf (" -> opfixsize %d delta %d\n", opfixsize
, delta
);
1454 /* Given a frag FRAGP, return the "next" frag that contains an
1455 opcode. Assumes the next opcode is relaxable, and thus rs_machine_dependent. */
1458 rx_next_opcode (fragS
*fragP
)
1461 fragP
= fragP
->fr_next
;
1462 } while (fragP
&& fragP
->fr_type
!= rs_machine_dependent
);
1466 /* Given the new addresses for this relax pass, figure out how big
1467 each opcode must be. We store the total number of bytes needed in
1468 fr_subtype. The return value is the difference between the size
1469 after the last pass and the size after this pass, so we use the old
1470 fr_subtype to calculate the difference. */
1473 rx_relax_frag (segT segment ATTRIBUTE_UNUSED
, fragS
* fragP
, long stretch
)
1475 addressT addr0
, sym_addr
;
1478 int oldsize
= fragP
->fr_subtype
;
1479 int newsize
= oldsize
;
1481 /* Index of relaxation we care about. */
1484 tprintf ("\033[36mrelax frag: addr %08lx fix %ld var %ld ofs %ld lit %p opc %p type %d sub %d str %ld\033[0m\n",
1485 (unsigned long) (fragP
->fr_address
1486 + (fragP
->fr_opcode
- fragP
->fr_literal
)),
1487 (long) fragP
->fr_fix
, (long) fragP
->fr_var
, (long) fragP
->fr_offset
,
1488 fragP
->fr_literal
, fragP
->fr_opcode
, fragP
->fr_type
, fragP
->fr_subtype
, stretch
);
1490 mypc
= fragP
->fr_address
+ (fragP
->fr_opcode
- fragP
->fr_literal
);
1492 if (fragP
->tc_frag_data
->n_base
== RX_NBASE_FETCHALIGN
)
1494 unsigned int next_size
;
1495 if (fragP
->fr_next
== NULL
)
1498 next_size
= fragP
->tc_frag_data
->n_ops
;
1501 fragS
*n
= rx_next_opcode (fragP
);
1502 next_size
= n
->fr_subtype
;
1505 fragP
->fr_subtype
= (8-(mypc
& 7)) & 7;
1506 tprintf("subtype %u\n", fragP
->fr_subtype
);
1507 if (fragP
->fr_subtype
>= next_size
)
1508 fragP
->fr_subtype
= 0;
1509 tprintf ("\033[34m -> mypc %lu next_size %u new %d old %d delta %d (fetchalign)\033[0m\n",
1511 next_size
, fragP
->fr_subtype
, oldsize
, fragP
->fr_subtype
-oldsize
);
1513 newsize
= fragP
->fr_subtype
;
1515 return newsize
- oldsize
;
1518 optype
= rx_opcode_type (fragP
->fr_opcode
);
1520 /* In the one case where we have both a disp and imm relaxation, we want
1521 the imm relaxation here. */
1523 if (fragP
->tc_frag_data
->n_relax
> 1
1524 && fragP
->tc_frag_data
->relax
[0].type
== RX_RELAX_DISP
)
1527 /* Try to get the target address. */
1528 if (rx_frag_fix_value (fragP
, segment
, ri
, & addr0
,
1529 fragP
->tc_frag_data
->relax
[ri
].type
!= RX_RELAX_BRANCH
,
1532 /* If we don't, we must use the maximum size for the linker.
1533 Note that we don't use synthetically expanded conditionals
1535 switch (fragP
->tc_frag_data
->relax
[ri
].type
)
1537 case RX_RELAX_BRANCH
:
1558 newsize
= fragP
->tc_frag_data
->relax
[ri
].val_ofs
+ 4;
1561 fragP
->fr_subtype
= newsize
;
1562 tprintf (" -> new %d old %d delta %d (external)\n", newsize
, oldsize
, newsize
-oldsize
);
1563 return newsize
- oldsize
;
1566 if (sym_addr
> mypc
)
1569 switch (fragP
->tc_frag_data
->relax
[ri
].type
)
1571 case RX_RELAX_BRANCH
:
1572 tprintf ("branch, addr %08lx pc %08lx disp %ld\n",
1573 (unsigned long) addr0
, (unsigned long) mypc
,
1574 (long) (addr0
- mypc
));
1575 disp
= (int) addr0
- (int) mypc
;
1580 if (disp
>= -128 && (disp
- (oldsize
-2)) <= 127)
1583 else if (disp
>= -32768 && (disp
- (oldsize
-5)) <= 32767)
1593 if ((disp
- (oldsize
-1)) >= 3 && (disp
- (oldsize
-1)) <= 10 && !linkrelax
)
1596 else if (disp
>= -128 && (disp
- (oldsize
-2)) <= 127)
1599 else if (disp
>= -32768 && (disp
- (oldsize
-3)) <= 32767)
1609 if ((disp
- (oldsize
-1)) >= 3 && (disp
- (oldsize
-1)) <= 10 && !linkrelax
)
1612 else if (disp
>= -128 && (disp
- (oldsize
-2)) <= 127)
1615 else if (disp
>= -32768 && (disp
- (oldsize
-3)) <= 32767)
1626 tprintf (" - newsize %d\n", newsize
);
1630 tprintf ("other, addr %08lx pc %08lx LI %d OF %d\n",
1631 (unsigned long) addr0
, (unsigned long) mypc
,
1632 fragP
->tc_frag_data
->relax
[ri
].field_pos
,
1633 fragP
->tc_frag_data
->relax
[ri
].val_ofs
);
1635 newsize
= fragP
->tc_frag_data
->relax
[ri
].val_ofs
;
1637 if ((long) addr0
>= -128 && (long) addr0
<= 127)
1639 else if ((long) addr0
>= -32768 && (long) addr0
<= 32767)
1641 else if ((long) addr0
>= -8388608 && (long) addr0
<= 8388607)
1651 if (fragP
->tc_frag_data
->relax
[ri
].type
== RX_RELAX_BRANCH
)
1667 /* This prevents infinite loops in align-heavy sources. */
1668 if (newsize
< oldsize
)
1670 if (fragP
->tc_frag_data
->times_shrank
> 10
1671 && fragP
->tc_frag_data
->times_grown
> 10)
1673 if (fragP
->tc_frag_data
->times_shrank
< 20)
1674 fragP
->tc_frag_data
->times_shrank
++;
1676 else if (newsize
> oldsize
)
1678 if (fragP
->tc_frag_data
->times_grown
< 20)
1679 fragP
->tc_frag_data
->times_grown
++;
1682 fragP
->fr_subtype
= newsize
;
1683 tprintf (" -> new %d old %d delta %d\n", newsize
, oldsize
, newsize
-oldsize
);
1684 return newsize
- oldsize
;
1687 /* This lets us test for the opcode type and the desired size in a
1688 switch statement. */
1689 #define OPCODE(type,size) ((type) * 16 + (size))
1691 /* Given the opcode stored in fr_opcode and the number of bytes we
1692 think we need, encode a new opcode. We stored a pointer to the
1693 fixup for this opcode in the tc_frag_data structure. If we can do
1694 the fixup here, we change the relocation type to "none" (we test
1695 for that in tc_gen_reloc) else we change it to the right type for
1696 the new (biggest) opcode. */
1699 md_convert_frag (bfd
* abfd ATTRIBUTE_UNUSED
,
1700 segT segment ATTRIBUTE_UNUSED
,
1701 fragS
* fragP ATTRIBUTE_UNUSED
)
1703 rx_bytesT
* rxb
= fragP
->tc_frag_data
;
1704 addressT addr0
, mypc
;
1706 int reloc_type
, reloc_adjust
;
1707 char * op
= fragP
->fr_opcode
;
1710 int fi
= (rxb
->n_fixups
> 1) ? 1 : 0;
1711 fixS
* fix
= rxb
->fixups
[fi
].fixP
;
1713 tprintf ("\033[31mconvrt frag: addr %08lx fix %ld var %ld ofs %ld lit %p opc %p type %d sub %d\033[0m\n",
1714 (unsigned long) (fragP
->fr_address
1715 + (fragP
->fr_opcode
- fragP
->fr_literal
)),
1716 (long) fragP
->fr_fix
, (long) fragP
->fr_var
, (long) fragP
->fr_offset
,
1717 fragP
->fr_literal
, fragP
->fr_opcode
, fragP
->fr_type
,
1724 printf ("lit 0x%p opc 0x%p", fragP
->fr_literal
, fragP
->fr_opcode
);
1725 for (i
= 0; i
< 10; i
++)
1726 printf (" %02x", (unsigned char) (fragP
->fr_opcode
[i
]));
1731 if (fragP
->tc_frag_data
->n_base
== RX_NBASE_FETCHALIGN
)
1733 int count
= fragP
->fr_subtype
;
1736 else if (count
> BIGGEST_NOP
)
1743 memcpy (op
, nops
[count
], count
);
1747 /* In the one case where we have both a disp and imm relaxation, we want
1748 the imm relaxation here. */
1750 if (fragP
->tc_frag_data
->n_relax
> 1
1751 && fragP
->tc_frag_data
->relax
[0].type
== RX_RELAX_DISP
)
1754 /* We used a new frag for this opcode, so the opcode address should
1755 be the frag address. */
1756 mypc
= fragP
->fr_address
+ (fragP
->fr_opcode
- fragP
->fr_literal
);
1758 /* Try to get the target address. If we fail here, we just use the
1760 if (rx_frag_fix_value (fragP
, segment
, 0, & addr0
,
1761 fragP
->tc_frag_data
->relax
[ri
].type
!= RX_RELAX_BRANCH
, 0))
1763 /* We don't know the target address. */
1770 /* We know the target address, and it's in addr0. */
1771 disp
= (int) addr0
- (int) mypc
;
1777 reloc_type
= BFD_RELOC_NONE
;
1780 tprintf ("convert, op is %d, disp %d (%lx-%lx)\n",
1781 rx_opcode_type (fragP
->fr_opcode
), disp
,
1782 (unsigned long) addr0
, (unsigned long) mypc
);
1783 switch (fragP
->tc_frag_data
->relax
[ri
].type
)
1785 case RX_RELAX_BRANCH
:
1786 switch (OPCODE (rx_opcode_type (fragP
->fr_opcode
), fragP
->fr_subtype
))
1788 case OPCODE (OT_bra
, 1): /* BRA.S - no change. */
1789 op
[0] = 0x08 + (disp
& 7);
1791 case OPCODE (OT_bra
, 2): /* BRA.B - 8 bit. */
1794 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1797 case OPCODE (OT_bra
, 3): /* BRA.W - 16 bit. */
1799 #if RX_OPCODE_BIG_ENDIAN
1800 op
[1] = (disp
>> 8) & 0xff;
1803 op
[2] = (disp
>> 8) & 0xff;
1807 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1809 case OPCODE (OT_bra
, 4): /* BRA.A - 24 bit. */
1811 #if RX_OPCODE_BIG_ENDIAN
1812 op
[1] = (disp
>> 16) & 0xff;
1813 op
[2] = (disp
>> 8) & 0xff;
1816 op
[3] = (disp
>> 16) & 0xff;
1817 op
[2] = (disp
>> 8) & 0xff;
1820 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1824 case OPCODE (OT_beq
, 1): /* BEQ.S - no change. */
1825 op
[0] = 0x10 + (disp
& 7);
1827 case OPCODE (OT_beq
, 2): /* BEQ.B - 8 bit. */
1831 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1833 case OPCODE (OT_beq
, 3): /* BEQ.W - 16 bit. */
1835 #if RX_OPCODE_BIG_ENDIAN
1836 op
[1] = (disp
>> 8) & 0xff;
1839 op
[2] = (disp
>> 8) & 0xff;
1842 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1845 case OPCODE (OT_beq
, 5): /* BEQ.A - synthetic. */
1846 op
[0] = 0x1d; /* bne.s .+5. */
1847 op
[1] = 0x04; /* bra.a dsp:24. */
1849 #if RX_OPCODE_BIG_ENDIAN
1850 op
[2] = (disp
>> 16) & 0xff;
1851 op
[3] = (disp
>> 8) & 0xff;
1854 op
[4] = (disp
>> 16) & 0xff;
1855 op
[3] = (disp
>> 8) & 0xff;
1858 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1862 case OPCODE (OT_bne
, 1): /* BNE.S - no change. */
1863 op
[0] = 0x18 + (disp
& 7);
1865 case OPCODE (OT_bne
, 2): /* BNE.B - 8 bit. */
1869 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1871 case OPCODE (OT_bne
, 3): /* BNE.W - 16 bit. */
1873 #if RX_OPCODE_BIG_ENDIAN
1874 op
[1] = (disp
>> 8) & 0xff;
1877 op
[2] = (disp
>> 8) & 0xff;
1880 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1883 case OPCODE (OT_bne
, 5): /* BNE.A - synthetic. */
1884 op
[0] = 0x15; /* beq.s .+5. */
1885 op
[1] = 0x04; /* bra.a dsp:24. */
1887 #if RX_OPCODE_BIG_ENDIAN
1888 op
[2] = (disp
>> 16) & 0xff;
1889 op
[3] = (disp
>> 8) & 0xff;
1892 op
[4] = (disp
>> 16) & 0xff;
1893 op
[3] = (disp
>> 8) & 0xff;
1896 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1900 case OPCODE (OT_bsr
, 3): /* BSR.W - 16 bit. */
1902 #if RX_OPCODE_BIG_ENDIAN
1903 op
[1] = (disp
>> 8) & 0xff;
1906 op
[2] = (disp
>> 8) & 0xff;
1909 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1912 case OPCODE (OT_bsr
, 4): /* BSR.A - 24 bit. */
1914 #if RX_OPCODE_BIG_ENDIAN
1915 op
[1] = (disp
>> 16) & 0xff;
1916 op
[2] = (disp
>> 8) & 0xff;
1919 op
[3] = (disp
>> 16) & 0xff;
1920 op
[2] = (disp
>> 8) & 0xff;
1923 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1927 case OPCODE (OT_bcc
, 2): /* Bcond.B - 8 bit. */
1929 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1931 case OPCODE (OT_bcc
, 5): /* Bcond.W - synthetic. */
1932 op
[0] ^= 1; /* Invert condition. */
1933 op
[1] = 5; /* Displacement. */
1936 #if RX_OPCODE_BIG_ENDIAN
1937 op
[3] = (disp
>> 8) & 0xff;
1940 op
[4] = (disp
>> 8) & 0xff;
1943 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1946 case OPCODE (OT_bcc
, 6): /* Bcond.S - synthetic. */
1947 op
[0] ^= 1; /* Invert condition. */
1948 op
[1] = 6; /* Displacement. */
1951 #if RX_OPCODE_BIG_ENDIAN
1952 op
[3] = (disp
>> 16) & 0xff;
1953 op
[4] = (disp
>> 8) & 0xff;
1956 op
[5] = (disp
>> 16) & 0xff;
1957 op
[4] = (disp
>> 8) & 0xff;
1960 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1965 /* These are opcodes we'll relax in th linker, later. */
1967 reloc_type
= rxb
->fixups
[ri
].fixP
->fx_r_type
;
1974 int nbytes
= fragP
->fr_subtype
- fragP
->tc_frag_data
->relax
[ri
].val_ofs
;
1976 char * imm
= op
+ fragP
->tc_frag_data
->relax
[ri
].val_ofs
;
1983 reloc_type
= BFD_RELOC_8
;
1987 #if RX_OPCODE_BIG_ENDIAN
1989 imm
[0] = addr0
>> 8;
1992 imm
[1] = addr0
>> 8;
1994 reloc_type
= BFD_RELOC_RX_16_OP
;
1998 #if RX_OPCODE_BIG_ENDIAN
2000 imm
[1] = addr0
>> 8;
2001 imm
[0] = addr0
>> 16;
2004 imm
[1] = addr0
>> 8;
2005 imm
[2] = addr0
>> 16;
2007 reloc_type
= BFD_RELOC_RX_24_OP
;
2011 #if RX_OPCODE_BIG_ENDIAN
2013 imm
[2] = addr0
>> 8;
2014 imm
[1] = addr0
>> 16;
2015 imm
[0] = addr0
>> 24;
2018 imm
[1] = addr0
>> 8;
2019 imm
[2] = addr0
>> 16;
2020 imm
[3] = addr0
>> 24;
2022 reloc_type
= BFD_RELOC_RX_32_OP
;
2025 as_bad (_("invalid immediate size"));
2029 switch (fragP
->tc_frag_data
->relax
[ri
].field_pos
)
2044 as_bad (_("invalid immediate field position"));
2052 reloc_type
= fix
->fx_r_type
;
2061 fix
->fx_r_type
= reloc_type
;
2062 fix
->fx_where
+= reloc_adjust
;
2065 case BFD_RELOC_NONE
:
2071 case BFD_RELOC_16_PCREL
:
2072 case BFD_RELOC_RX_16_OP
:
2075 case BFD_RELOC_24_PCREL
:
2076 case BFD_RELOC_RX_24_OP
:
2079 case BFD_RELOC_RX_32_OP
:
2085 fragP
->fr_fix
= fragP
->fr_subtype
+ (fragP
->fr_opcode
- fragP
->fr_literal
);
2086 tprintf ("fragP->fr_fix now %ld (%d + (%p - %p)\n", (long) fragP
->fr_fix
,
2087 fragP
->fr_subtype
, fragP
->fr_opcode
, fragP
->fr_literal
);
2090 if (fragP
->fr_next
!= NULL
2091 && ((offsetT
) (fragP
->fr_next
->fr_address
- fragP
->fr_address
)
2093 as_bad (_("bad frag at %p : fix %ld addr %ld %ld \n"), fragP
,
2094 (long) fragP
->fr_fix
,
2095 (long) fragP
->fr_address
, (long) fragP
->fr_next
->fr_address
);
2101 rx_validate_fix_sub (struct fix
* f
)
2103 /* We permit the subtraction of two symbols in a few cases. */
2104 /* mov #sym1-sym2, R3 */
2105 if (f
->fx_r_type
== BFD_RELOC_RX_32_OP
)
2107 /* .long sym1-sym2 */
2108 if (f
->fx_r_type
== BFD_RELOC_RX_DIFF
2110 && (f
->fx_size
== 4 || f
->fx_size
== 2 || f
->fx_size
== 1))
2116 md_pcrel_from_section (fixS
* fixP
, segT sec
)
2120 if (fixP
->fx_addsy
!= NULL
2121 && (! S_IS_DEFINED (fixP
->fx_addsy
)
2122 || S_GET_SEGMENT (fixP
->fx_addsy
) != sec
))
2123 /* The symbol is undefined (or is defined but not in this section).
2124 Let the linker figure it out. */
2127 rv
= fixP
->fx_frag
->fr_address
+ fixP
->fx_where
;
2128 switch (fixP
->fx_r_type
)
2130 case BFD_RELOC_RX_DIR3U_PCREL
:
2138 rx_cons_fix_new (fragS
* frag
,
2143 bfd_reloc_code_real_type type
;
2151 type
= BFD_RELOC_16
;
2154 type
= BFD_RELOC_24
;
2157 type
= BFD_RELOC_32
;
2160 as_bad (_("unsupported constant size %d\n"), size
);
2164 if (exp
->X_op
== O_subtract
&& exp
->X_op_symbol
)
2166 if (size
!= 4 && size
!= 2 && size
!= 1)
2167 as_bad (_("difference of two symbols only supported with .long, .short, or .byte"));
2169 type
= BFD_RELOC_RX_DIFF
;
2172 fix_new_exp (frag
, where
, (int) size
, exp
, 0, type
);
2176 md_apply_fix (struct fix
* f ATTRIBUTE_UNUSED
,
2177 valueT
* t ATTRIBUTE_UNUSED
,
2178 segT s ATTRIBUTE_UNUSED
)
2180 /* Instruction bytes are always little endian. */
2184 if (f
->fx_addsy
&& S_FORCE_RELOC (f
->fx_addsy
, 1))
2186 if (f
->fx_subsy
&& S_FORCE_RELOC (f
->fx_subsy
, 1))
2189 #define OP2(x) op[target_big_endian ? 1-x : x]
2190 #define OP3(x) op[target_big_endian ? 2-x : x]
2191 #define OP4(x) op[target_big_endian ? 3-x : x]
2193 op
= f
->fx_frag
->fr_literal
+ f
->fx_where
;
2194 val
= (unsigned long) * t
;
2196 /* Opcode words are always the same endian. Data words are either
2197 big or little endian. */
2199 switch (f
->fx_r_type
)
2201 case BFD_RELOC_NONE
:
2204 case BFD_RELOC_RX_RELAX
:
2208 case BFD_RELOC_RX_DIR3U_PCREL
:
2209 if (val
< 3 || val
> 10)
2210 as_bad_where (f
->fx_file
, f
->fx_line
,
2211 _("jump not 3..10 bytes away (is %d)"), (int) val
);
2213 op
[0] |= val
& 0x07;
2217 case BFD_RELOC_8_PCREL
:
2218 case BFD_RELOC_RX_8U
:
2223 OP2(1) = val
& 0xff;
2224 OP2(0) = (val
>> 8) & 0xff;
2227 case BFD_RELOC_16_PCREL
:
2228 case BFD_RELOC_RX_16_OP
:
2229 case BFD_RELOC_RX_16U
:
2230 #if RX_OPCODE_BIG_ENDIAN
2232 op
[0] = (val
>> 8) & 0xff;
2235 op
[1] = (val
>> 8) & 0xff;
2240 OP3(0) = val
& 0xff;
2241 OP3(1) = (val
>> 8) & 0xff;
2242 OP3(2) = (val
>> 16) & 0xff;
2245 case BFD_RELOC_24_PCREL
:
2246 case BFD_RELOC_RX_24_OP
:
2247 case BFD_RELOC_RX_24U
:
2248 #if RX_OPCODE_BIG_ENDIAN
2250 op
[1] = (val
>> 8) & 0xff;
2251 op
[0] = (val
>> 16) & 0xff;
2254 op
[1] = (val
>> 8) & 0xff;
2255 op
[2] = (val
>> 16) & 0xff;
2259 case BFD_RELOC_RX_DIFF
:
2266 OP2(0) = val
& 0xff;
2267 OP2(1) = (val
>> 8) & 0xff;
2270 OP4(0) = val
& 0xff;
2271 OP4(1) = (val
>> 8) & 0xff;
2272 OP4(2) = (val
>> 16) & 0xff;
2273 OP4(3) = (val
>> 24) & 0xff;
2279 OP4(0) = val
& 0xff;
2280 OP4(1) = (val
>> 8) & 0xff;
2281 OP4(2) = (val
>> 16) & 0xff;
2282 OP4(3) = (val
>> 24) & 0xff;
2285 case BFD_RELOC_RX_32_OP
:
2286 #if RX_OPCODE_BIG_ENDIAN
2288 op
[2] = (val
>> 8) & 0xff;
2289 op
[1] = (val
>> 16) & 0xff;
2290 op
[0] = (val
>> 24) & 0xff;
2293 op
[1] = (val
>> 8) & 0xff;
2294 op
[2] = (val
>> 16) & 0xff;
2295 op
[3] = (val
>> 24) & 0xff;
2299 case BFD_RELOC_RX_NEG8
:
2303 case BFD_RELOC_RX_NEG16
:
2305 #if RX_OPCODE_BIG_ENDIAN
2307 op
[0] = (val
>> 8) & 0xff;
2310 op
[1] = (val
>> 8) & 0xff;
2314 case BFD_RELOC_RX_NEG24
:
2316 #if RX_OPCODE_BIG_ENDIAN
2318 op
[1] = (val
>> 8) & 0xff;
2319 op
[0] = (val
>> 16) & 0xff;
2322 op
[1] = (val
>> 8) & 0xff;
2323 op
[2] = (val
>> 16) & 0xff;
2327 case BFD_RELOC_RX_NEG32
:
2329 #if RX_OPCODE_BIG_ENDIAN
2331 op
[2] = (val
>> 8) & 0xff;
2332 op
[1] = (val
>> 16) & 0xff;
2333 op
[0] = (val
>> 24) & 0xff;
2336 op
[1] = (val
>> 8) & 0xff;
2337 op
[2] = (val
>> 16) & 0xff;
2338 op
[3] = (val
>> 24) & 0xff;
2342 case BFD_RELOC_RX_GPRELL
:
2344 case BFD_RELOC_RX_GPRELW
:
2346 case BFD_RELOC_RX_GPRELB
:
2347 #if RX_OPCODE_BIG_ENDIAN
2349 op
[0] = (val
>> 8) & 0xff;
2352 op
[1] = (val
>> 8) & 0xff;
2357 as_bad (_("Unknown reloc in md_apply_fix: %s"),
2358 bfd_get_reloc_code_name (f
->fx_r_type
));
2362 if (f
->fx_addsy
== NULL
)
2367 tc_gen_reloc (asection
* sec ATTRIBUTE_UNUSED
, fixS
* fixp
)
2369 static arelent
* reloc
[5];
2370 bfd_boolean is_opcode
= FALSE
;
2372 if (fixp
->fx_r_type
== BFD_RELOC_NONE
)
2379 && S_GET_SEGMENT (fixp
->fx_subsy
) == absolute_section
)
2381 fixp
->fx_offset
-= S_GET_VALUE (fixp
->fx_subsy
);
2382 fixp
->fx_subsy
= NULL
;
2385 reloc
[0] = (arelent
*) xmalloc (sizeof (arelent
));
2386 reloc
[0]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2387 * reloc
[0]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2388 reloc
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2389 reloc
[0]->addend
= fixp
->fx_offset
;
2391 if (fixp
->fx_r_type
== BFD_RELOC_RX_32_OP
2394 fixp
->fx_r_type
= BFD_RELOC_RX_DIFF
;
2398 is_opcode
= sec
->flags
& SEC_CODE
;
2400 /* Certain BFD relocations cannot be translated directly into
2401 a single (non-Red Hat) RX relocation, but instead need
2402 multiple RX relocations - handle them here. */
2403 switch (fixp
->fx_r_type
)
2405 case BFD_RELOC_RX_DIFF
:
2406 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2408 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2409 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2410 * reloc
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
2411 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2412 reloc
[1]->addend
= 0;
2413 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2415 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2416 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2417 reloc
[2]->addend
= 0;
2418 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2419 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2421 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2422 switch (fixp
->fx_size
)
2425 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS8
);
2428 if (!is_opcode
&& target_big_endian
)
2429 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16_REV
);
2431 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16UL
);
2433 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16
);
2436 if (!is_opcode
&& target_big_endian
)
2437 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS32_REV
);
2439 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS32
);
2442 reloc
[3]->addend
= 0;
2443 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2444 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2449 case BFD_RELOC_RX_GPRELL
:
2450 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2452 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2453 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2454 if (gp_symbol
== NULL
)
2456 if (symbol_table_frozen
)
2460 gp
= symbol_find ("__gp");
2462 as_bad (("unable to create __gp symbol: please re-assemble with the -msmall-data-limit option specified"));
2464 gp_symbol
= symbol_get_bfdsym (gp
);
2467 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
2469 * reloc
[1]->sym_ptr_ptr
= gp_symbol
;
2470 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2471 reloc
[1]->addend
= 0;
2472 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2474 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2475 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2476 reloc
[2]->addend
= 0;
2477 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2478 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2480 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2481 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16UL
);
2482 reloc
[3]->addend
= 0;
2483 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2484 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2489 case BFD_RELOC_RX_GPRELW
:
2490 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2492 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2493 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2494 if (gp_symbol
== NULL
)
2496 if (symbol_table_frozen
)
2500 gp
= symbol_find ("__gp");
2502 as_bad (("unable to create __gp symbol: please re-assemble with the -msmall-data-limit option specified"));
2504 gp_symbol
= symbol_get_bfdsym (gp
);
2507 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
2509 * reloc
[1]->sym_ptr_ptr
= gp_symbol
;
2510 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2511 reloc
[1]->addend
= 0;
2512 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2514 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2515 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2516 reloc
[2]->addend
= 0;
2517 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2518 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2520 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2521 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16UW
);
2522 reloc
[3]->addend
= 0;
2523 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2524 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2529 case BFD_RELOC_RX_GPRELB
:
2530 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2532 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2533 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2534 if (gp_symbol
== NULL
)
2536 if (symbol_table_frozen
)
2540 gp
= symbol_find ("__gp");
2542 as_bad (("unable to create __gp symbol: please re-assemble with the -msmall-data-limit option specified"));
2544 gp_symbol
= symbol_get_bfdsym (gp
);
2547 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
2549 * reloc
[1]->sym_ptr_ptr
= gp_symbol
;
2550 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2551 reloc
[1]->addend
= 0;
2552 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2554 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2555 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2556 reloc
[2]->addend
= 0;
2557 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2558 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2560 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2561 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16U
);
2562 reloc
[3]->addend
= 0;
2563 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2564 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2569 case BFD_RELOC_RX_NEG32
:
2570 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2572 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2573 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_NEG
);
2574 reloc
[1]->addend
= 0;
2575 reloc
[1]->sym_ptr_ptr
= reloc
[0]->sym_ptr_ptr
;
2576 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2578 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2579 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS32
);
2580 reloc
[2]->addend
= 0;
2581 reloc
[2]->sym_ptr_ptr
= reloc
[0]->sym_ptr_ptr
;
2582 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2588 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
2596 /* Set the ELF specific flags. */
2599 rx_elf_final_processing (void)
2601 elf_elfheader (stdoutput
)->e_flags
|= elf_flags
;
2604 /* Scan the current input line for occurances of Renesas
2605 local labels and replace them with the GAS version. */
2608 rx_start_line (void)
2610 int in_double_quote
= 0;
2611 int in_single_quote
= 0;
2613 char * p
= input_line_pointer
;
2615 /* Scan the line looking for question marks. Skip past quote enclosed regions. */
2626 in_double_quote
= ! in_double_quote
;
2630 in_single_quote
= ! in_single_quote
;
2634 if (in_double_quote
|| in_single_quote
)
2639 else if (p
[1] == '+')
2644 else if (p
[1] == '-')