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
= E_FLAG_RX_ABI
;
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
,
77 #define RX_SHORTOPTS ""
78 const char * md_shortopts
= RX_SHORTOPTS
;
80 /* Assembler options. */
81 struct option md_longopts
[] =
83 {"mbig-endian-data", no_argument
, NULL
, OPTION_BIG
},
84 {"mlittle-endian-data", no_argument
, NULL
, OPTION_LITTLE
},
85 /* The next two switches are here because the
86 generic parts of the linker testsuite uses them. */
87 {"EB", no_argument
, NULL
, OPTION_BIG
},
88 {"EL", no_argument
, NULL
, OPTION_LITTLE
},
89 {"m32bit-doubles", no_argument
, NULL
, OPTION_32BIT_DOUBLES
},
90 {"m64bit-doubles", no_argument
, NULL
, OPTION_64BIT_DOUBLES
},
91 /* This option is here mainly for the binutils testsuites,
92 as many of their tests assume conventional section naming. */
93 {"muse-conventional-section-names", no_argument
, NULL
, OPTION_CONVENTIONAL_SECTION_NAMES
},
94 {"muse-renesas-section-names", no_argument
, NULL
, OPTION_RENESAS_SECTION_NAMES
},
95 {"msmall-data-limit", no_argument
, NULL
, OPTION_SMALL_DATA_LIMIT
},
96 {"relax", no_argument
, NULL
, OPTION_RELAX
},
97 {"mpid", no_argument
, NULL
, OPTION_PID
},
98 {"mint-register", required_argument
, NULL
, OPTION_INT_REGS
},
99 {"mgcc-abi", no_argument
, NULL
, OPTION_USES_GCC_ABI
},
100 {"mrx-abi", no_argument
, NULL
, OPTION_USES_RX_ABI
},
101 {NULL
, no_argument
, NULL
, 0}
103 size_t md_longopts_size
= sizeof (md_longopts
);
106 md_parse_option (int c ATTRIBUTE_UNUSED
, char * arg ATTRIBUTE_UNUSED
)
111 target_big_endian
= 1;
115 target_big_endian
= 0;
118 case OPTION_32BIT_DOUBLES
:
119 elf_flags
&= ~ E_FLAG_RX_64BIT_DOUBLES
;
122 case OPTION_64BIT_DOUBLES
:
123 elf_flags
|= E_FLAG_RX_64BIT_DOUBLES
;
126 case OPTION_CONVENTIONAL_SECTION_NAMES
:
127 rx_use_conventional_section_names
= TRUE
;
130 case OPTION_RENESAS_SECTION_NAMES
:
131 rx_use_conventional_section_names
= FALSE
;
134 case OPTION_SMALL_DATA_LIMIT
:
135 rx_use_small_data_limit
= TRUE
;
144 elf_flags
|= E_FLAG_RX_PID
;
147 case OPTION_INT_REGS
:
148 rx_num_int_regs
= atoi (optarg
);
151 case OPTION_USES_GCC_ABI
:
152 elf_flags
&= ~ E_FLAG_RX_ABI
;
155 case OPTION_USES_RX_ABI
:
156 elf_flags
|= E_FLAG_RX_ABI
;
163 md_show_usage (FILE * stream
)
165 fprintf (stream
, _(" RX specific command line options:\n"));
166 fprintf (stream
, _(" --mbig-endian-data\n"));
167 fprintf (stream
, _(" --mlittle-endian-data [default]\n"));
168 fprintf (stream
, _(" --m32bit-doubles [default]\n"));
169 fprintf (stream
, _(" --m64bit-doubles\n"));
170 fprintf (stream
, _(" --muse-conventional-section-names\n"));
171 fprintf (stream
, _(" --muse-renesas-section-names [default]\n"));
172 fprintf (stream
, _(" --msmall-data-limit\n"));
173 fprintf (stream
, _(" --mrelax\n"));
174 fprintf (stream
, _(" --mpid\n"));
175 fprintf (stream
, _(" --mint-register=<value>\n"));
179 s_bss (int ignore ATTRIBUTE_UNUSED
)
183 temp
= get_absolute_expression ();
184 subseg_set (bss_section
, (subsegT
) temp
);
185 demand_empty_rest_of_line ();
189 rx_float_cons (int ignore ATTRIBUTE_UNUSED
)
191 if (elf_flags
& E_FLAG_RX_64BIT_DOUBLES
)
192 return float_cons ('d');
193 return float_cons ('f');
197 rx_strcasestr (const char *string
, const char *sub
)
203 return (char *)string
;
206 strl
= strlen (string
);
210 /* strncasecmp is in libiberty. */
211 if (strncasecmp (string
, sub
, subl
) == 0)
212 return (char *)string
;
221 rx_include (int ignore
)
226 char * current_filename
;
234 /* The RX version of the .INCLUDE pseudo-op does not
235 have to have the filename inside double quotes. */
237 if (*input_line_pointer
== '"')
239 /* Treat as the normal GAS .include pseudo-op. */
244 /* Get the filename. Spaces are allowed, NUL characters are not. */
245 filename
= input_line_pointer
;
246 eof
= find_end_of_line (filename
, FALSE
);
247 input_line_pointer
= eof
;
249 while (eof
>= filename
&& (* eof
== ' ' || * eof
== '\n'))
251 end_char
= *(++ eof
);
255 as_bad (_("no filename following .INCLUDE pseudo-op"));
260 as_where (& current_filename
, NULL
);
261 f
= (char *) xmalloc (strlen (current_filename
) + strlen (filename
) + 1);
263 /* Check the filename. If [@]..FILE[@] is found then replace
264 this with the current assembler source filename, stripped
265 of any directory prefixes or extensions. */
266 if ((p
= rx_strcasestr (filename
, "..file")) != NULL
)
270 len
= 6; /* strlen ("..file"); */
272 if (p
> filename
&& p
[-1] == '@')
278 for (d
= c
= current_filename
; *c
; c
++)
279 if (IS_DIR_SEPARATOR (* c
))
285 sprintf (f
, "%.*s%.*s%.*s", (int) (p
- filename
), filename
,
287 (int) (strlen (filename
) - ((p
+ len
) - filename
)),
291 strcpy (f
, filename
);
293 /* RX .INCLUDE semantics say that 'filename' is located by:
295 1. If filename is absolute, just try that. Otherwise...
297 2. If the current source file includes a directory component
298 then prepend that to the filename and try. Otherwise...
300 3. Try any directories specified by the -I command line
303 4 .Try a directory specifed by the INC100 environment variable. */
305 if (IS_ABSOLUTE_PATH (f
))
306 try = fopen (path
= f
, FOPEN_RT
);
309 char * env
= getenv ("INC100");
313 len
= strlen (current_filename
);
314 if ((size_t) include_dir_maxlen
> len
)
315 len
= include_dir_maxlen
;
316 if (env
&& strlen (env
) > len
)
319 path
= (char *) xmalloc (strlen (f
) + len
+ 5);
321 if (current_filename
!= NULL
)
323 for (d
= NULL
, p
= current_filename
; *p
; p
++)
324 if (IS_DIR_SEPARATOR (* p
))
329 sprintf (path
, "%.*s/%s", (int) (d
- current_filename
), current_filename
,
331 try = fopen (path
, FOPEN_RT
);
339 for (i
= 0; i
< include_dir_count
; i
++)
341 sprintf (path
, "%s/%s", include_dirs
[i
], f
);
342 if ((try = fopen (path
, FOPEN_RT
)) != NULL
)
347 if (try == NULL
&& env
!= NULL
)
349 sprintf (path
, "%s/%s", env
, f
);
350 try = fopen (path
, FOPEN_RT
);
358 as_bad (_("unable to locate include file: %s"), filename
);
364 register_dependency (path
);
365 input_scrub_insert_file (path
);
372 parse_rx_section (char * name
)
376 int attr
= SHF_ALLOC
| SHF_EXECINSTR
;
385 for (p
= input_line_pointer
; *p
&& strchr ("\n\t, =", *p
) == NULL
; p
++)
390 if (strcasecmp (input_line_pointer
, "ALIGN") == 0)
405 case '2': align
= 2; break;
406 case '4': align
= 4; break;
407 case '8': align
= 8; break;
409 as_bad (_("unrecognised alignment value in .SECTION directive: %s"), p
);
410 ignore_rest_of_line ();
418 else if (strcasecmp (input_line_pointer
, "CODE") == 0)
419 attr
= SHF_ALLOC
| SHF_EXECINSTR
;
420 else if (strcasecmp (input_line_pointer
, "DATA") == 0)
421 attr
= SHF_ALLOC
| SHF_WRITE
;
422 else if (strcasecmp (input_line_pointer
, "ROMDATA") == 0)
426 as_bad (_("unknown parameter following .SECTION directive: %s"),
430 input_line_pointer
= p
+ 1;
431 ignore_rest_of_line ();
436 input_line_pointer
= p
+ 1;
438 while (end_char
!= '\n' && end_char
!= 0);
440 if ((sec
= bfd_get_section_by_name (stdoutput
, name
)) == NULL
)
442 if (strcmp (name
, "B") && strcmp (name
, "B_1") && strcmp (name
, "B_2"))
447 obj_elf_change_section (name
, type
, attr
, 0, NULL
, FALSE
, FALSE
);
449 else /* Try not to redefine a section, especially B_1. */
451 int flags
= sec
->flags
;
453 type
= elf_section_type (sec
);
455 attr
= ((flags
& SEC_READONLY
) ? 0 : SHF_WRITE
)
456 | ((flags
& SEC_ALLOC
) ? SHF_ALLOC
: 0)
457 | ((flags
& SEC_CODE
) ? SHF_EXECINSTR
: 0)
458 | ((flags
& SEC_MERGE
) ? SHF_MERGE
: 0)
459 | ((flags
& SEC_STRINGS
) ? SHF_STRINGS
: 0)
460 | ((flags
& SEC_THREAD_LOCAL
) ? SHF_TLS
: 0);
462 obj_elf_change_section (name
, type
, attr
, 0, NULL
, FALSE
, FALSE
);
465 bfd_set_section_alignment (stdoutput
, now_seg
, align
);
469 rx_section (int ignore
)
473 /* The as100 assembler supports a different syntax for the .section
474 pseudo-op. So check for it and handle it here if necessary. */
477 /* Peek past the section name to see if arguments follow. */
478 for (p
= input_line_pointer
; *p
; p
++)
479 if (*p
== ',' || *p
== '\n')
484 int len
= p
- input_line_pointer
;
486 while (ISSPACE (*++p
))
489 if (*p
!= '"' && *p
!= '#')
491 char * name
= (char *) xmalloc (len
+ 1);
493 strncpy (name
, input_line_pointer
, len
);
496 input_line_pointer
= p
;
497 parse_rx_section (name
);
502 obj_elf_section (ignore
);
506 rx_list (int ignore ATTRIBUTE_UNUSED
)
510 if (strncasecmp (input_line_pointer
, "OFF", 3))
512 else if (strncasecmp (input_line_pointer
, "ON", 2))
515 as_warn (_("expecting either ON or OFF after .list"));
518 /* Like the .rept pseudo op, but supports the
519 use of ..MACREP inside the repeated region. */
522 rx_rept (int ignore ATTRIBUTE_UNUSED
)
524 int count
= get_absolute_expression ();
526 do_repeat_with_expander (count
, "MREPEAT", "ENDR", "..MACREP");
529 /* Like cons() accept that strings are allowed. */
536 if (* input_line_pointer
== '"')
543 rx_nop (int ignore ATTRIBUTE_UNUSED
)
545 ignore_rest_of_line ();
551 as_warn (_("The \".%s\" pseudo-op is not implemented\n"),
552 md_pseudo_table
[idx
].poc_name
);
553 ignore_rest_of_line ();
556 /* The target specific pseudo-ops which we support. */
557 const pseudo_typeS md_pseudo_table
[] =
559 /* These are unimplemented. They're listed first so that we can use
560 the poc_value as the index into this array, to get the name of
561 the pseudo. So, keep these (1) first, and (2) in order, with (3)
562 the poc_value's in sequence. */
563 { "btglb", rx_unimp
, 0 },
564 { "call", rx_unimp
, 1 },
565 { "einsf", rx_unimp
, 2 },
566 { "fb", rx_unimp
, 3 },
567 { "fbsym", rx_unimp
, 4 },
568 { "id", rx_unimp
, 5 },
569 { "initsct", rx_unimp
, 6 },
570 { "insf", rx_unimp
, 7 },
571 { "instr", rx_unimp
, 8 },
572 { "lbba", rx_unimp
, 9 },
573 { "len", rx_unimp
, 10 },
574 { "optj", rx_unimp
, 11 },
575 { "rvector", rx_unimp
, 12 },
576 { "sb", rx_unimp
, 13 },
577 { "sbbit", rx_unimp
, 14 },
578 { "sbsym", rx_unimp
, 15 },
579 { "sbsym16", rx_unimp
, 16 },
581 /* These are the do-nothing pseudos. */
582 { "stk", rx_nop
, 0 },
583 /* The manual documents ".stk" but the compiler emits ".stack". */
584 { "stack", rx_nop
, 0 },
586 /* These are Renesas as100 assembler pseudo-ops that we do support. */
587 { "addr", rx_cons
, 3 },
588 { "align", s_align_bytes
, 2 },
589 { "byte", rx_cons
, 1 },
590 { "fixed", float_cons
, 'f' },
591 { "form", listing_psize
, 0 },
592 { "glb", s_globl
, 0 },
593 { "include", rx_include
, 0 },
594 { "list", rx_list
, 0 },
595 { "lword", rx_cons
, 4 },
596 { "mrepeat", rx_rept
, 0 },
597 { "section", rx_section
, 0 },
599 /* FIXME: The following pseudo-ops place their values (and associated
600 label if present) in the data section, regardless of whatever
601 section we are currently in. At the moment this code does not
602 implement that part of the semantics. */
603 { "blka", s_space
, 3 },
604 { "blkb", s_space
, 1 },
605 { "blkd", s_space
, 8 },
606 { "blkf", s_space
, 4 },
607 { "blkl", s_space
, 4 },
608 { "blkw", s_space
, 2 },
610 /* Our "standard" pseudos. */
611 { "double", rx_float_cons
, 0 },
613 { "3byte", cons
, 3 },
617 { "fetchalign", rx_fetchalign
, 0 },
619 /* End of list marker. */
623 static asymbol
* gp_symbol
;
624 static asymbol
* rx_pid_symbol
;
626 static symbolS
* rx_pidreg_symbol
;
627 static symbolS
* rx_gpreg_symbol
;
632 /* Make the __gp and __pid_base symbols now rather
633 than after the symbol table is frozen. We only do this
634 when supporting small data limits because otherwise we
635 pollute the symbol table. */
637 /* The meta-registers %pidreg and %gpreg depend on what other
638 options are specified. The __rx_*_defined symbols exist so we
639 can .ifdef asm code based on what options were passed to gas,
640 without needing a preprocessor */
644 rx_pid_register
= 13 - rx_num_int_regs
;
645 rx_pid_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__pid_base"));
646 rx_pidreg_symbol
= symbol_find_or_make ("__rx_pidreg_defined");
647 S_SET_VALUE (rx_pidreg_symbol
, rx_pid_register
);
648 S_SET_SEGMENT (rx_pidreg_symbol
, absolute_section
);
651 if (rx_use_small_data_limit
)
654 rx_gp_register
= rx_pid_register
- 1;
656 rx_gp_register
= 13 - rx_num_int_regs
;
657 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
658 rx_gpreg_symbol
= symbol_find_or_make ("__rx_gpreg_defined");
659 S_SET_VALUE (rx_gpreg_symbol
, rx_gp_register
);
660 S_SET_SEGMENT (rx_gpreg_symbol
, absolute_section
);
667 /* These negative numbers are found in rx_bytesT.n_base for non-opcode
669 #define RX_NBASE_FETCHALIGN -1
671 typedef struct rx_bytesT
674 /* If this is negative, it's a special-purpose frag as per the defines above. */
683 char type
; /* RXREL_*. */
696 fixS
*link_relax_fixP
;
701 static rx_bytesT rx_bytes
;
702 /* We set n_ops to be "size of next opcode" if the next opcode doesn't relax. */
703 static rx_bytesT
*fetchalign_bytes
= NULL
;
706 rx_fetchalign (int ignore ATTRIBUTE_UNUSED
)
711 memset (& rx_bytes
, 0, sizeof (rx_bytes
));
712 rx_bytes
.n_base
= RX_NBASE_FETCHALIGN
;
714 bytes
= frag_more (8);
715 frag_then
= frag_now
;
716 frag_variant (rs_machine_dependent
,
723 frag_then
->fr_opcode
= bytes
;
724 frag_then
->fr_subtype
= 0;
725 fetchalign_bytes
= frag_then
->tc_frag_data
;
729 rx_relax (int type
, int pos
)
731 rx_bytes
.relax
[rx_bytes
.n_relax
].type
= type
;
732 rx_bytes
.relax
[rx_bytes
.n_relax
].field_pos
= pos
;
733 rx_bytes
.relax
[rx_bytes
.n_relax
].val_ofs
= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
738 rx_linkrelax_dsp (int pos
)
743 rx_bytes
.link_relax
|= RX_RELAXA_DSP4
;
746 rx_bytes
.link_relax
|= RX_RELAXA_DSP6
;
749 rx_bytes
.link_relax
|= RX_RELAXA_DSP14
;
755 rx_linkrelax_imm (int pos
)
760 rx_bytes
.link_relax
|= RX_RELAXA_IMM6
;
763 rx_bytes
.link_relax
|= RX_RELAXA_IMM12
;
769 rx_linkrelax_branch (void)
771 rx_bytes
.link_relax
|= RX_RELAXA_BRA
;
775 rx_fixup (expressionS exp
, int offsetbits
, int nbits
, int type
)
777 rx_bytes
.fixups
[rx_bytes
.n_fixups
].exp
= exp
;
778 rx_bytes
.fixups
[rx_bytes
.n_fixups
].offset
= offsetbits
;
779 rx_bytes
.fixups
[rx_bytes
.n_fixups
].nbits
= nbits
;
780 rx_bytes
.fixups
[rx_bytes
.n_fixups
].type
= type
;
781 rx_bytes
.fixups
[rx_bytes
.n_fixups
].reloc
= exp
.X_md
;
782 rx_bytes
.n_fixups
++;
785 #define rx_field_fixup(exp, offset, nbits, type) \
786 rx_fixup (exp, offset, nbits, type)
788 #define rx_op_fixup(exp, offset, nbits, type) \
789 rx_fixup (exp, offset + 8 * rx_bytes.n_base, nbits, type)
794 rx_bytes
.base
[0] = b1
;
799 rx_base2 (int b1
, int b2
)
801 rx_bytes
.base
[0] = b1
;
802 rx_bytes
.base
[1] = b2
;
807 rx_base3 (int b1
, int b2
, int b3
)
809 rx_bytes
.base
[0] = b1
;
810 rx_bytes
.base
[1] = b2
;
811 rx_bytes
.base
[2] = b3
;
816 rx_base4 (int b1
, int b2
, int b3
, int b4
)
818 rx_bytes
.base
[0] = b1
;
819 rx_bytes
.base
[1] = b2
;
820 rx_bytes
.base
[2] = b3
;
821 rx_bytes
.base
[3] = b4
;
825 /* This gets complicated when the field spans bytes, because fields
826 are numbered from the MSB of the first byte as zero, and bits are
827 stored LSB towards the LSB of the byte. Thus, a simple four-bit
828 insertion of 12 at position 4 of 0x00 yields: 0x0b. A three-bit
829 insertion of b'MXL at position 7 is like this:
831 - - - - - - - - - - - - - - - -
835 rx_field (int val
, int pos
, int sz
)
842 if (val
< 0 || val
>= (1 << sz
))
843 as_bad (_("Value %d doesn't fit in unsigned %d-bit field"), val
, sz
);
848 if (val
< -(1 << (sz
- 1)) || val
>= (1 << (sz
- 1)))
849 as_bad (_("Value %d doesn't fit in signed %d-bit field"), val
, sz
);
852 /* This code points at 'M' in the above example. */
856 while (bitp
+ sz
> 8)
861 svalm
= val
>> (sz
- ssz
);
862 svalm
= svalm
& ((1 << ssz
) - 1);
863 svalm
= svalm
<< (8 - bitp
- ssz
);
864 gas_assert (bytep
< rx_bytes
.n_base
);
865 rx_bytes
.base
[bytep
] |= svalm
;
871 valm
= val
& ((1 << sz
) - 1);
872 valm
= valm
<< (8 - bitp
- sz
);
873 gas_assert (bytep
< rx_bytes
.n_base
);
874 rx_bytes
.base
[bytep
] |= valm
;
877 /* Special case of the above, for 3-bit displacements of 2..9. */
880 rx_disp3 (expressionS exp
, int pos
)
882 rx_field_fixup (exp
, pos
, 3, RXREL_PCREL
);
885 /* Special case of the above, for split 5-bit displacements. Assumes
886 the displacement has been checked with rx_disp5op. */
887 /* ---- -432 1--- 0--- */
890 rx_field5s (expressionS exp
)
894 val
= exp
.X_add_number
;
895 rx_bytes
.base
[0] |= val
>> 2;
896 rx_bytes
.base
[1] |= (val
<< 6) & 0x80;
897 rx_bytes
.base
[1] |= (val
<< 3) & 0x08;
900 /* ---- ---- 4--- 3210 */
903 rx_field5s2 (expressionS exp
)
907 val
= exp
.X_add_number
;
908 rx_bytes
.base
[1] |= (val
<< 3) & 0x80;
909 rx_bytes
.base
[1] |= (val
) & 0x0f;
912 #define OP(x) rx_bytes.ops[rx_bytes.n_ops++] = (x)
914 #define F_PRECISION 2
917 rx_op (expressionS exp
, int nbytes
, int type
)
921 if ((exp
.X_op
== O_constant
|| exp
.X_op
== O_big
)
922 && type
!= RXREL_PCREL
)
924 if (exp
.X_op
== O_big
&& exp
.X_add_number
<= 0)
927 char * ip
= rx_bytes
.ops
+ rx_bytes
.n_ops
;
929 gen_to_words (w
, F_PRECISION
, 8);
930 #if RX_OPCODE_BIG_ENDIAN
945 v
= exp
.X_add_number
;
948 #if RX_OPCODE_BIG_ENDIAN
949 OP ((v
>> (8 * (nbytes
- 1))) & 0xff);
960 rx_op_fixup (exp
, rx_bytes
.n_ops
* 8, nbytes
* 8, type
);
961 memset (rx_bytes
.ops
+ rx_bytes
.n_ops
, 0, nbytes
);
962 rx_bytes
.n_ops
+= nbytes
;
972 #define APPEND(B, N_B) \
975 memcpy (bytes + idx, rx_bytes.B, rx_bytes.N_B); \
976 idx += rx_bytes.N_B; \
980 rx_frag_init (fragS
* fragP
)
982 if (rx_bytes
.n_relax
|| rx_bytes
.link_relax
|| rx_bytes
.n_base
< 0)
984 fragP
->tc_frag_data
= malloc (sizeof (rx_bytesT
));
985 memcpy (fragP
->tc_frag_data
, & rx_bytes
, sizeof (rx_bytesT
));
988 fragP
->tc_frag_data
= 0;
991 /* Handle the as100's version of the .equ pseudo-op. It has the syntax:
992 <symbol_name> .equ <expression> */
995 rx_equ (char * name
, char * expression
)
997 char saved_name_end_char
;
1001 while (ISSPACE (* name
))
1004 for (name_end
= name
+ 1; *name_end
; name_end
++)
1005 if (! ISALNUM (* name_end
))
1008 saved_name_end_char
= * name_end
;
1011 saved_ilp
= input_line_pointer
;
1012 input_line_pointer
= expression
;
1016 input_line_pointer
= saved_ilp
;
1017 * name_end
= saved_name_end_char
;
1020 /* Look for Renesas as100 pseudo-ops that occur after a symbol name
1021 rather than at the start of a line. (eg .EQU or .DEFINE). If one
1022 is found, process it and return TRUE otherwise return FALSE. */
1025 scan_for_infix_rx_pseudo_ops (char * str
)
1029 char * dot
= strchr (str
, '.');
1031 if (dot
== NULL
|| dot
== str
)
1034 /* A real pseudo-op must be preceeded by whitespace. */
1035 if (dot
[-1] != ' ' && dot
[-1] != '\t')
1038 pseudo_op
= dot
+ 1;
1040 if (!ISALNUM (* pseudo_op
))
1043 for (p
= pseudo_op
+ 1; ISALNUM (* p
); p
++)
1046 if (strncasecmp ("EQU", pseudo_op
, p
- pseudo_op
) == 0)
1048 else if (strncasecmp ("DEFINE", pseudo_op
, p
- pseudo_op
) == 0)
1049 as_warn (_("The .DEFINE pseudo-op is not implemented"));
1050 else if (strncasecmp ("MACRO", pseudo_op
, p
- pseudo_op
) == 0)
1051 as_warn (_("The .MACRO pseudo-op is not implemented"));
1052 else if (strncasecmp ("BTEQU", pseudo_op
, p
- pseudo_op
) == 0)
1053 as_warn (_("The .BTEQU pseudo-op is not implemented."));
1061 md_assemble (char * str
)
1066 fragS
* frag_then
= frag_now
;
1069 memset (& rx_bytes
, 0, sizeof (rx_bytes
));
1071 rx_lex_init (str
, str
+ strlen (str
));
1072 if (scan_for_infix_rx_pseudo_ops (str
))
1076 /* This simplifies the relaxation code. */
1077 if (rx_bytes
.n_relax
|| rx_bytes
.link_relax
)
1079 /* We do it this way because we want the frag to have the
1080 rx_bytes in it, which we initialize above. */
1081 bytes
= frag_more (12);
1082 frag_then
= frag_now
;
1083 frag_variant (rs_machine_dependent
,
1090 frag_then
->fr_opcode
= bytes
;
1091 frag_then
->fr_fix
+= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
1092 frag_then
->fr_subtype
= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
1096 bytes
= frag_more (rx_bytes
.n_base
+ rx_bytes
.n_ops
);
1097 frag_then
= frag_now
;
1098 if (fetchalign_bytes
)
1099 fetchalign_bytes
->n_ops
= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
1102 fetchalign_bytes
= NULL
;
1104 APPEND (base
, n_base
);
1105 APPEND (ops
, n_ops
);
1107 if (rx_bytes
.link_relax
&& rx_bytes
.n_fixups
)
1111 f
= fix_new (frag_then
,
1112 (char *) bytes
- frag_then
->fr_literal
,
1115 rx_bytes
.link_relax
| rx_bytes
.n_fixups
,
1117 BFD_RELOC_RX_RELAX
);
1118 frag_then
->tc_frag_data
->link_relax_fixP
= f
;
1121 for (i
= 0; i
< rx_bytes
.n_fixups
; i
++)
1123 /* index: [nbytes][type] */
1124 static int reloc_map
[5][4] =
1126 { 0, 0, 0, BFD_RELOC_RX_DIR3U_PCREL
},
1127 { BFD_RELOC_8
, BFD_RELOC_RX_8U
, BFD_RELOC_RX_NEG8
, BFD_RELOC_8_PCREL
},
1128 { BFD_RELOC_RX_16_OP
, BFD_RELOC_RX_16U
, BFD_RELOC_RX_NEG16
, BFD_RELOC_16_PCREL
},
1129 { BFD_RELOC_RX_24_OP
, BFD_RELOC_RX_24U
, BFD_RELOC_RX_NEG24
, BFD_RELOC_24_PCREL
},
1130 { BFD_RELOC_RX_32_OP
, BFD_RELOC_32
, BFD_RELOC_RX_NEG32
, BFD_RELOC_32_PCREL
},
1134 idx
= rx_bytes
.fixups
[i
].offset
/ 8;
1135 rel
= reloc_map
[rx_bytes
.fixups
[i
].nbits
/ 8][(int) rx_bytes
.fixups
[i
].type
];
1137 if (rx_bytes
.fixups
[i
].reloc
)
1138 rel
= rx_bytes
.fixups
[i
].reloc
;
1140 if (frag_then
->tc_frag_data
)
1141 exp
= & frag_then
->tc_frag_data
->fixups
[i
].exp
;
1143 exp
= & rx_bytes
.fixups
[i
].exp
;
1145 f
= fix_new_exp (frag_then
,
1146 (char *) bytes
+ idx
- frag_then
->fr_literal
,
1147 rx_bytes
.fixups
[i
].nbits
/ 8,
1149 rx_bytes
.fixups
[i
].type
== RXREL_PCREL
? 1 : 0,
1151 if (frag_then
->tc_frag_data
)
1152 frag_then
->tc_frag_data
->fixups
[i
].fixP
= f
;
1155 dwarf2_emit_insn (idx
);
1163 /* Write a value out to the object file, using the appropriate endianness. */
1166 md_number_to_chars (char * buf
, valueT val
, int n
)
1168 if (target_big_endian
)
1169 number_to_chars_bigendian (buf
, val
, n
);
1171 number_to_chars_littleendian (buf
, val
, n
);
1181 { "gp", BFD_RELOC_GPREL16
},
1186 md_operand (expressionS
* exp ATTRIBUTE_UNUSED
)
1191 for (i
= 0; reloc_functions
[i
].fname
; i
++)
1193 int flen
= strlen (reloc_functions
[i
].fname
);
1195 if (input_line_pointer
[0] == '%'
1196 && strncasecmp (input_line_pointer
+ 1, reloc_functions
[i
].fname
, flen
) == 0
1197 && input_line_pointer
[flen
+ 1] == '(')
1199 reloc
= reloc_functions
[i
].reloc
;
1200 input_line_pointer
+= flen
+ 2;
1208 if (* input_line_pointer
== ')')
1209 input_line_pointer
++;
1215 md_section_align (segT segment
, valueT size
)
1217 int align
= bfd_get_section_alignment (stdoutput
, segment
);
1218 return ((size
+ (1 << align
) - 1) & (-1 << align
));
1222 static unsigned char nop_1
[] = { 0x03};
1223 /* MOV.L R0,R0 - 1 cycle */
1224 static unsigned char nop_2
[] = { 0xef, 0x00};
1225 /* MAX R0,R0 - 1 cycle */
1226 static unsigned char nop_3
[] = { 0xfc, 0x13, 0x00 };
1227 /* MUL #1,R0 - 1 cycle */
1228 static unsigned char nop_4
[] = { 0x76, 0x10, 0x01, 0x00 };
1229 /* MUL #1,R0 - 1 cycle */
1230 static unsigned char nop_5
[] = { 0x77, 0x10, 0x01, 0x00, 0x00 };
1231 /* MUL #1,R0 - 1 cycle */
1232 static unsigned char nop_6
[] = { 0x74, 0x10, 0x01, 0x00, 0x00, 0x00 };
1233 /* BRA.S .+7 - 1 cycle */
1234 static unsigned char nop_7
[] = { 0x0F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };
1236 static unsigned char *nops
[] = { NULL
, nop_1
, nop_2
, nop_3
, nop_4
, nop_5
, nop_6
, nop_7
};
1237 #define BIGGEST_NOP 7
1239 /* When relaxing, we need to output a reloc for any .align directive
1240 so that we can retain this alignment as we adjust opcode sizes. */
1242 rx_handle_align (fragS
* frag
)
1244 /* If handling an alignment frag, use an optimal NOP pattern.
1245 Only do this if a fill value has not already been provided.
1246 FIXME: This test fails if the provided fill value is zero. */
1247 if ((frag
->fr_type
== rs_align
1248 || frag
->fr_type
== rs_align_code
)
1249 && subseg_text_p (now_seg
))
1251 int count
= (frag
->fr_next
->fr_address
1254 unsigned char *base
= (unsigned char *)frag
->fr_literal
+ frag
->fr_fix
;
1258 if (count
> BIGGEST_NOP
)
1266 memcpy (base
, nops
[count
], count
);
1267 frag
->fr_var
= count
;
1273 && (frag
->fr_type
== rs_align
1274 || frag
->fr_type
== rs_align_code
)
1275 && frag
->fr_address
+ frag
->fr_fix
> 0
1276 && frag
->fr_offset
> 0
1277 && now_seg
!= bss_section
)
1279 fix_new (frag
, frag
->fr_fix
, 0,
1280 &abs_symbol
, RX_RELAXA_ALIGN
+ frag
->fr_offset
,
1281 0, BFD_RELOC_RX_RELAX
);
1282 /* For the purposes of relaxation, this relocation is attached
1283 to the byte *after* the alignment - i.e. the byte that must
1285 fix_new (frag
->fr_next
, 0, 0,
1286 &abs_symbol
, RX_RELAXA_ELIGN
+ frag
->fr_offset
,
1287 0, BFD_RELOC_RX_RELAX
);
1292 md_atof (int type
, char * litP
, int * sizeP
)
1294 return ieee_md_atof (type
, litP
, sizeP
, target_big_endian
);
1298 md_undefined_symbol (char * name ATTRIBUTE_UNUSED
)
1303 /*----------------------------------------------------------------------*/
1304 /* To recap: we estimate everything based on md_estimate_size, then
1305 adjust based on rx_relax_frag. When it all settles, we call
1306 md_convert frag to update the bytes. The relaxation types and
1307 relocations are in fragP->tc_frag_data, which is a copy of that
1310 Our scheme is as follows: fr_fix has the size of the smallest
1311 opcode (like BRA.S). We store the number of total bytes we need in
1312 fr_subtype. When we're done relaxing, we use fr_subtype and the
1313 existing opcode bytes to figure out what actual opcode we need to
1314 put in there. If the fixup isn't resolvable now, we use the
1317 #define TRACE_RELAX 0
1318 #define tprintf if (TRACE_RELAX) printf
1330 /* We're looking for these types of relaxations:
1333 BRA.B 00101110 dspppppp
1334 BRA.W 00111000 dspppppp pppppppp
1335 BRA.A 00000100 dspppppp pppppppp pppppppp
1338 BEQ.B 00100000 dspppppp
1339 BEQ.W 00111010 dspppppp pppppppp
1342 BNE.B 00100001 dspppppp
1343 BNE.W 00111011 dspppppp pppppppp
1345 BSR.W 00111001 dspppppp pppppppp
1346 BSR.A 00000101 dspppppp pppppppp pppppppp
1348 Bcc.B 0010cond dspppppp
1350 Additionally, we can synthesize longer conditional branches using
1351 pairs of opcodes, one with an inverted conditional (flip LSB):
1353 Bcc.W 0010ncnd 00000110 00111000 dspppppp pppppppp
1354 Bcc.A 0010ncnd 00000111 00000100 dspppppp pppppppp pppppppp
1355 BEQ.A 00011100 00000100 dspppppp pppppppp pppppppp
1356 BNE.A 00010100 00000100 dspppppp pppppppp pppppppp */
1358 /* Given the opcode bytes at OP, figure out which opcode it is and
1359 return the type of opcode. We use this to re-encode the opcode as
1360 a different size later. */
1363 rx_opcode_type (char * op
)
1365 unsigned char b
= (unsigned char) op
[0];
1369 case 0x08: return OT_bra
;
1370 case 0x10: return OT_beq
;
1371 case 0x18: return OT_bne
;
1376 case 0x2e: return OT_bra
;
1377 case 0x38: return OT_bra
;
1378 case 0x04: return OT_bra
;
1380 case 0x20: return OT_beq
;
1381 case 0x3a: return OT_beq
;
1383 case 0x21: return OT_bne
;
1384 case 0x3b: return OT_bne
;
1386 case 0x39: return OT_bsr
;
1387 case 0x05: return OT_bsr
;
1390 if ((b
& 0xf0) == 0x20)
1396 /* Returns zero if *addrP has the target address. Else returns nonzero
1397 if we cannot compute the target address yet. */
1400 rx_frag_fix_value (fragS
* fragP
,
1405 addressT
* sym_addr
)
1408 rx_bytesT
* b
= fragP
->tc_frag_data
;
1409 expressionS
* exp
= & b
->fixups
[which
].exp
;
1411 if (need_diff
&& exp
->X_op
!= O_subtract
)
1414 if (exp
->X_add_symbol
)
1416 if (S_FORCE_RELOC (exp
->X_add_symbol
, 1))
1418 if (S_GET_SEGMENT (exp
->X_add_symbol
) != segment
)
1420 addr
+= S_GET_VALUE (exp
->X_add_symbol
);
1423 if (exp
->X_op_symbol
)
1425 if (exp
->X_op
!= O_subtract
)
1427 if (S_FORCE_RELOC (exp
->X_op_symbol
, 1))
1429 if (S_GET_SEGMENT (exp
->X_op_symbol
) != segment
)
1431 addr
-= S_GET_VALUE (exp
->X_op_symbol
);
1435 addr
+= exp
->X_add_number
;
1440 /* Estimate how big the opcode is after this relax pass. The return
1441 value is the difference between fr_fix and the actual size. We
1442 compute the total size in rx_relax_frag and store it in fr_subtype,
1443 sowe only need to subtract fx_fix and return it. */
1446 md_estimate_size_before_relax (fragS
* fragP ATTRIBUTE_UNUSED
, segT segment ATTRIBUTE_UNUSED
)
1451 tprintf ("\033[32m est frag: addr %08lx fix %ld var %ld ofs %ld lit %p opc %p type %d sub %d\033[0m\n",
1452 (unsigned long) (fragP
->fr_address
1453 + (fragP
->fr_opcode
- fragP
->fr_literal
)),
1454 (long) fragP
->fr_fix
, (long) fragP
->fr_var
, (long) fragP
->fr_offset
,
1455 fragP
->fr_literal
, fragP
->fr_opcode
, fragP
->fr_type
, fragP
->fr_subtype
);
1457 /* This is the size of the opcode that's accounted for in fr_fix. */
1458 opfixsize
= fragP
->fr_fix
- (fragP
->fr_opcode
- fragP
->fr_literal
);
1459 /* This is the size of the opcode that isn't. */
1460 delta
= (fragP
->fr_subtype
- opfixsize
);
1462 tprintf (" -> opfixsize %d delta %d\n", opfixsize
, delta
);
1466 /* Given a frag FRAGP, return the "next" frag that contains an
1467 opcode. Assumes the next opcode is relaxable, and thus rs_machine_dependent. */
1470 rx_next_opcode (fragS
*fragP
)
1473 fragP
= fragP
->fr_next
;
1474 } while (fragP
&& fragP
->fr_type
!= rs_machine_dependent
);
1478 /* Given the new addresses for this relax pass, figure out how big
1479 each opcode must be. We store the total number of bytes needed in
1480 fr_subtype. The return value is the difference between the size
1481 after the last pass and the size after this pass, so we use the old
1482 fr_subtype to calculate the difference. */
1485 rx_relax_frag (segT segment ATTRIBUTE_UNUSED
, fragS
* fragP
, long stretch
)
1487 addressT addr0
, sym_addr
;
1490 int oldsize
= fragP
->fr_subtype
;
1491 int newsize
= oldsize
;
1493 /* Index of relaxation we care about. */
1496 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",
1497 (unsigned long) (fragP
->fr_address
1498 + (fragP
->fr_opcode
- fragP
->fr_literal
)),
1499 (long) fragP
->fr_fix
, (long) fragP
->fr_var
, (long) fragP
->fr_offset
,
1500 fragP
->fr_literal
, fragP
->fr_opcode
, fragP
->fr_type
, fragP
->fr_subtype
, stretch
);
1502 mypc
= fragP
->fr_address
+ (fragP
->fr_opcode
- fragP
->fr_literal
);
1504 if (fragP
->tc_frag_data
->n_base
== RX_NBASE_FETCHALIGN
)
1506 unsigned int next_size
;
1507 if (fragP
->fr_next
== NULL
)
1510 next_size
= fragP
->tc_frag_data
->n_ops
;
1513 fragS
*n
= rx_next_opcode (fragP
);
1514 next_size
= n
->fr_subtype
;
1517 fragP
->fr_subtype
= (8-(mypc
& 7)) & 7;
1518 tprintf("subtype %u\n", fragP
->fr_subtype
);
1519 if (fragP
->fr_subtype
>= next_size
)
1520 fragP
->fr_subtype
= 0;
1521 tprintf ("\033[34m -> mypc %lu next_size %u new %d old %d delta %d (fetchalign)\033[0m\n",
1523 next_size
, fragP
->fr_subtype
, oldsize
, fragP
->fr_subtype
-oldsize
);
1525 newsize
= fragP
->fr_subtype
;
1527 return newsize
- oldsize
;
1530 optype
= rx_opcode_type (fragP
->fr_opcode
);
1532 /* In the one case where we have both a disp and imm relaxation, we want
1533 the imm relaxation here. */
1535 if (fragP
->tc_frag_data
->n_relax
> 1
1536 && fragP
->tc_frag_data
->relax
[0].type
== RX_RELAX_DISP
)
1539 /* Try to get the target address. */
1540 if (rx_frag_fix_value (fragP
, segment
, ri
, & addr0
,
1541 fragP
->tc_frag_data
->relax
[ri
].type
!= RX_RELAX_BRANCH
,
1544 /* If we don't, we must use the maximum size for the linker.
1545 Note that we don't use synthetically expanded conditionals
1547 switch (fragP
->tc_frag_data
->relax
[ri
].type
)
1549 case RX_RELAX_BRANCH
:
1570 newsize
= fragP
->tc_frag_data
->relax
[ri
].val_ofs
+ 4;
1573 fragP
->fr_subtype
= newsize
;
1574 tprintf (" -> new %d old %d delta %d (external)\n", newsize
, oldsize
, newsize
-oldsize
);
1575 return newsize
- oldsize
;
1578 if (sym_addr
> mypc
)
1581 switch (fragP
->tc_frag_data
->relax
[ri
].type
)
1583 case RX_RELAX_BRANCH
:
1584 tprintf ("branch, addr %08lx pc %08lx disp %ld\n",
1585 (unsigned long) addr0
, (unsigned long) mypc
,
1586 (long) (addr0
- mypc
));
1587 disp
= (int) addr0
- (int) mypc
;
1592 if (disp
>= -128 && (disp
- (oldsize
-2)) <= 127)
1595 else if (disp
>= -32768 && (disp
- (oldsize
-5)) <= 32767)
1605 if ((disp
- (oldsize
-1)) >= 3 && (disp
- (oldsize
-1)) <= 10 && !linkrelax
)
1608 else if (disp
>= -128 && (disp
- (oldsize
-2)) <= 127)
1611 else if (disp
>= -32768 && (disp
- (oldsize
-3)) <= 32767)
1621 if ((disp
- (oldsize
-1)) >= 3 && (disp
- (oldsize
-1)) <= 10 && !linkrelax
)
1624 else if (disp
>= -128 && (disp
- (oldsize
-2)) <= 127)
1627 else if (disp
>= -32768 && (disp
- (oldsize
-3)) <= 32767)
1638 tprintf (" - newsize %d\n", newsize
);
1642 tprintf ("other, addr %08lx pc %08lx LI %d OF %d\n",
1643 (unsigned long) addr0
, (unsigned long) mypc
,
1644 fragP
->tc_frag_data
->relax
[ri
].field_pos
,
1645 fragP
->tc_frag_data
->relax
[ri
].val_ofs
);
1647 newsize
= fragP
->tc_frag_data
->relax
[ri
].val_ofs
;
1649 if ((long) addr0
>= -128 && (long) addr0
<= 127)
1651 else if ((long) addr0
>= -32768 && (long) addr0
<= 32767)
1653 else if ((long) addr0
>= -8388608 && (long) addr0
<= 8388607)
1663 if (fragP
->tc_frag_data
->relax
[ri
].type
== RX_RELAX_BRANCH
)
1679 /* This prevents infinite loops in align-heavy sources. */
1680 if (newsize
< oldsize
)
1682 if (fragP
->tc_frag_data
->times_shrank
> 10
1683 && fragP
->tc_frag_data
->times_grown
> 10)
1685 if (fragP
->tc_frag_data
->times_shrank
< 20)
1686 fragP
->tc_frag_data
->times_shrank
++;
1688 else if (newsize
> oldsize
)
1690 if (fragP
->tc_frag_data
->times_grown
< 20)
1691 fragP
->tc_frag_data
->times_grown
++;
1694 fragP
->fr_subtype
= newsize
;
1695 tprintf (" -> new %d old %d delta %d\n", newsize
, oldsize
, newsize
-oldsize
);
1696 return newsize
- oldsize
;
1699 /* This lets us test for the opcode type and the desired size in a
1700 switch statement. */
1701 #define OPCODE(type,size) ((type) * 16 + (size))
1703 /* Given the opcode stored in fr_opcode and the number of bytes we
1704 think we need, encode a new opcode. We stored a pointer to the
1705 fixup for this opcode in the tc_frag_data structure. If we can do
1706 the fixup here, we change the relocation type to "none" (we test
1707 for that in tc_gen_reloc) else we change it to the right type for
1708 the new (biggest) opcode. */
1711 md_convert_frag (bfd
* abfd ATTRIBUTE_UNUSED
,
1712 segT segment ATTRIBUTE_UNUSED
,
1713 fragS
* fragP ATTRIBUTE_UNUSED
)
1715 rx_bytesT
* rxb
= fragP
->tc_frag_data
;
1716 addressT addr0
, mypc
;
1718 int reloc_type
, reloc_adjust
;
1719 char * op
= fragP
->fr_opcode
;
1722 int fi
= (rxb
->n_fixups
> 1) ? 1 : 0;
1723 fixS
* fix
= rxb
->fixups
[fi
].fixP
;
1725 tprintf ("\033[31mconvrt frag: addr %08lx fix %ld var %ld ofs %ld lit %p opc %p type %d sub %d\033[0m\n",
1726 (unsigned long) (fragP
->fr_address
1727 + (fragP
->fr_opcode
- fragP
->fr_literal
)),
1728 (long) fragP
->fr_fix
, (long) fragP
->fr_var
, (long) fragP
->fr_offset
,
1729 fragP
->fr_literal
, fragP
->fr_opcode
, fragP
->fr_type
,
1736 printf ("lit 0x%p opc 0x%p", fragP
->fr_literal
, fragP
->fr_opcode
);
1737 for (i
= 0; i
< 10; i
++)
1738 printf (" %02x", (unsigned char) (fragP
->fr_opcode
[i
]));
1743 if (fragP
->tc_frag_data
->n_base
== RX_NBASE_FETCHALIGN
)
1745 int count
= fragP
->fr_subtype
;
1748 else if (count
> BIGGEST_NOP
)
1755 memcpy (op
, nops
[count
], count
);
1759 /* In the one case where we have both a disp and imm relaxation, we want
1760 the imm relaxation here. */
1762 if (fragP
->tc_frag_data
->n_relax
> 1
1763 && fragP
->tc_frag_data
->relax
[0].type
== RX_RELAX_DISP
)
1766 /* We used a new frag for this opcode, so the opcode address should
1767 be the frag address. */
1768 mypc
= fragP
->fr_address
+ (fragP
->fr_opcode
- fragP
->fr_literal
);
1770 /* Try to get the target address. If we fail here, we just use the
1772 if (rx_frag_fix_value (fragP
, segment
, 0, & addr0
,
1773 fragP
->tc_frag_data
->relax
[ri
].type
!= RX_RELAX_BRANCH
, 0))
1775 /* We don't know the target address. */
1782 /* We know the target address, and it's in addr0. */
1783 disp
= (int) addr0
- (int) mypc
;
1789 reloc_type
= BFD_RELOC_NONE
;
1792 tprintf ("convert, op is %d, disp %d (%lx-%lx)\n",
1793 rx_opcode_type (fragP
->fr_opcode
), disp
,
1794 (unsigned long) addr0
, (unsigned long) mypc
);
1795 switch (fragP
->tc_frag_data
->relax
[ri
].type
)
1797 case RX_RELAX_BRANCH
:
1798 switch (OPCODE (rx_opcode_type (fragP
->fr_opcode
), fragP
->fr_subtype
))
1800 case OPCODE (OT_bra
, 1): /* BRA.S - no change. */
1801 op
[0] = 0x08 + (disp
& 7);
1803 case OPCODE (OT_bra
, 2): /* BRA.B - 8 bit. */
1806 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1809 case OPCODE (OT_bra
, 3): /* BRA.W - 16 bit. */
1811 #if RX_OPCODE_BIG_ENDIAN
1812 op
[1] = (disp
>> 8) & 0xff;
1815 op
[2] = (disp
>> 8) & 0xff;
1819 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1821 case OPCODE (OT_bra
, 4): /* BRA.A - 24 bit. */
1823 #if RX_OPCODE_BIG_ENDIAN
1824 op
[1] = (disp
>> 16) & 0xff;
1825 op
[2] = (disp
>> 8) & 0xff;
1828 op
[3] = (disp
>> 16) & 0xff;
1829 op
[2] = (disp
>> 8) & 0xff;
1832 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1836 case OPCODE (OT_beq
, 1): /* BEQ.S - no change. */
1837 op
[0] = 0x10 + (disp
& 7);
1839 case OPCODE (OT_beq
, 2): /* BEQ.B - 8 bit. */
1843 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1845 case OPCODE (OT_beq
, 3): /* BEQ.W - 16 bit. */
1847 #if RX_OPCODE_BIG_ENDIAN
1848 op
[1] = (disp
>> 8) & 0xff;
1851 op
[2] = (disp
>> 8) & 0xff;
1854 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1857 case OPCODE (OT_beq
, 5): /* BEQ.A - synthetic. */
1858 op
[0] = 0x1d; /* bne.s .+5. */
1859 op
[1] = 0x04; /* bra.a dsp:24. */
1861 #if RX_OPCODE_BIG_ENDIAN
1862 op
[2] = (disp
>> 16) & 0xff;
1863 op
[3] = (disp
>> 8) & 0xff;
1866 op
[4] = (disp
>> 16) & 0xff;
1867 op
[3] = (disp
>> 8) & 0xff;
1870 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1874 case OPCODE (OT_bne
, 1): /* BNE.S - no change. */
1875 op
[0] = 0x18 + (disp
& 7);
1877 case OPCODE (OT_bne
, 2): /* BNE.B - 8 bit. */
1881 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1883 case OPCODE (OT_bne
, 3): /* BNE.W - 16 bit. */
1885 #if RX_OPCODE_BIG_ENDIAN
1886 op
[1] = (disp
>> 8) & 0xff;
1889 op
[2] = (disp
>> 8) & 0xff;
1892 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1895 case OPCODE (OT_bne
, 5): /* BNE.A - synthetic. */
1896 op
[0] = 0x15; /* beq.s .+5. */
1897 op
[1] = 0x04; /* bra.a dsp:24. */
1899 #if RX_OPCODE_BIG_ENDIAN
1900 op
[2] = (disp
>> 16) & 0xff;
1901 op
[3] = (disp
>> 8) & 0xff;
1904 op
[4] = (disp
>> 16) & 0xff;
1905 op
[3] = (disp
>> 8) & 0xff;
1908 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1912 case OPCODE (OT_bsr
, 3): /* BSR.W - 16 bit. */
1914 #if RX_OPCODE_BIG_ENDIAN
1915 op
[1] = (disp
>> 8) & 0xff;
1918 op
[2] = (disp
>> 8) & 0xff;
1921 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1924 case OPCODE (OT_bsr
, 4): /* BSR.A - 24 bit. */
1926 #if RX_OPCODE_BIG_ENDIAN
1927 op
[1] = (disp
>> 16) & 0xff;
1928 op
[2] = (disp
>> 8) & 0xff;
1931 op
[3] = (disp
>> 16) & 0xff;
1932 op
[2] = (disp
>> 8) & 0xff;
1935 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1939 case OPCODE (OT_bcc
, 2): /* Bcond.B - 8 bit. */
1941 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1943 case OPCODE (OT_bcc
, 5): /* Bcond.W - synthetic. */
1944 op
[0] ^= 1; /* Invert condition. */
1945 op
[1] = 5; /* Displacement. */
1948 #if RX_OPCODE_BIG_ENDIAN
1949 op
[3] = (disp
>> 8) & 0xff;
1952 op
[4] = (disp
>> 8) & 0xff;
1955 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1958 case OPCODE (OT_bcc
, 6): /* Bcond.S - synthetic. */
1959 op
[0] ^= 1; /* Invert condition. */
1960 op
[1] = 6; /* Displacement. */
1963 #if RX_OPCODE_BIG_ENDIAN
1964 op
[3] = (disp
>> 16) & 0xff;
1965 op
[4] = (disp
>> 8) & 0xff;
1968 op
[5] = (disp
>> 16) & 0xff;
1969 op
[4] = (disp
>> 8) & 0xff;
1972 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1977 /* These are opcodes we'll relax in th linker, later. */
1979 reloc_type
= rxb
->fixups
[ri
].fixP
->fx_r_type
;
1986 int nbytes
= fragP
->fr_subtype
- fragP
->tc_frag_data
->relax
[ri
].val_ofs
;
1988 char * imm
= op
+ fragP
->tc_frag_data
->relax
[ri
].val_ofs
;
1995 reloc_type
= BFD_RELOC_8
;
1999 #if RX_OPCODE_BIG_ENDIAN
2001 imm
[0] = addr0
>> 8;
2004 imm
[1] = addr0
>> 8;
2006 reloc_type
= BFD_RELOC_RX_16_OP
;
2010 #if RX_OPCODE_BIG_ENDIAN
2012 imm
[1] = addr0
>> 8;
2013 imm
[0] = addr0
>> 16;
2016 imm
[1] = addr0
>> 8;
2017 imm
[2] = addr0
>> 16;
2019 reloc_type
= BFD_RELOC_RX_24_OP
;
2023 #if RX_OPCODE_BIG_ENDIAN
2025 imm
[2] = addr0
>> 8;
2026 imm
[1] = addr0
>> 16;
2027 imm
[0] = addr0
>> 24;
2030 imm
[1] = addr0
>> 8;
2031 imm
[2] = addr0
>> 16;
2032 imm
[3] = addr0
>> 24;
2034 reloc_type
= BFD_RELOC_RX_32_OP
;
2037 as_bad (_("invalid immediate size"));
2041 switch (fragP
->tc_frag_data
->relax
[ri
].field_pos
)
2056 as_bad (_("invalid immediate field position"));
2064 reloc_type
= fix
->fx_r_type
;
2073 fix
->fx_r_type
= reloc_type
;
2074 fix
->fx_where
+= reloc_adjust
;
2077 case BFD_RELOC_NONE
:
2083 case BFD_RELOC_16_PCREL
:
2084 case BFD_RELOC_RX_16_OP
:
2087 case BFD_RELOC_24_PCREL
:
2088 case BFD_RELOC_RX_24_OP
:
2091 case BFD_RELOC_RX_32_OP
:
2097 fragP
->fr_fix
= fragP
->fr_subtype
+ (fragP
->fr_opcode
- fragP
->fr_literal
);
2098 tprintf ("fragP->fr_fix now %ld (%d + (%p - %p)\n", (long) fragP
->fr_fix
,
2099 fragP
->fr_subtype
, fragP
->fr_opcode
, fragP
->fr_literal
);
2102 if (fragP
->fr_next
!= NULL
2103 && ((offsetT
) (fragP
->fr_next
->fr_address
- fragP
->fr_address
)
2105 as_bad (_("bad frag at %p : fix %ld addr %ld %ld \n"), fragP
,
2106 (long) fragP
->fr_fix
,
2107 (long) fragP
->fr_address
, (long) fragP
->fr_next
->fr_address
);
2113 rx_validate_fix_sub (struct fix
* f
)
2115 /* We permit the subtraction of two symbols in a few cases. */
2116 /* mov #sym1-sym2, R3 */
2117 if (f
->fx_r_type
== BFD_RELOC_RX_32_OP
)
2119 /* .long sym1-sym2 */
2120 if (f
->fx_r_type
== BFD_RELOC_RX_DIFF
2122 && (f
->fx_size
== 4 || f
->fx_size
== 2 || f
->fx_size
== 1))
2128 md_pcrel_from_section (fixS
* fixP
, segT sec
)
2132 if (fixP
->fx_addsy
!= NULL
2133 && (! S_IS_DEFINED (fixP
->fx_addsy
)
2134 || S_GET_SEGMENT (fixP
->fx_addsy
) != sec
))
2135 /* The symbol is undefined (or is defined but not in this section).
2136 Let the linker figure it out. */
2139 rv
= fixP
->fx_frag
->fr_address
+ fixP
->fx_where
;
2140 switch (fixP
->fx_r_type
)
2142 case BFD_RELOC_RX_DIR3U_PCREL
:
2150 rx_cons_fix_new (fragS
* frag
,
2155 bfd_reloc_code_real_type type
;
2163 type
= BFD_RELOC_16
;
2166 type
= BFD_RELOC_24
;
2169 type
= BFD_RELOC_32
;
2172 as_bad (_("unsupported constant size %d\n"), size
);
2176 if (exp
->X_op
== O_subtract
&& exp
->X_op_symbol
)
2178 if (size
!= 4 && size
!= 2 && size
!= 1)
2179 as_bad (_("difference of two symbols only supported with .long, .short, or .byte"));
2181 type
= BFD_RELOC_RX_DIFF
;
2184 fix_new_exp (frag
, where
, (int) size
, exp
, 0, type
);
2188 md_apply_fix (struct fix
* f ATTRIBUTE_UNUSED
,
2189 valueT
* t ATTRIBUTE_UNUSED
,
2190 segT s ATTRIBUTE_UNUSED
)
2192 /* Instruction bytes are always little endian. */
2196 if (f
->fx_addsy
&& S_FORCE_RELOC (f
->fx_addsy
, 1))
2198 if (f
->fx_subsy
&& S_FORCE_RELOC (f
->fx_subsy
, 1))
2201 #define OP2(x) op[target_big_endian ? 1-x : x]
2202 #define OP3(x) op[target_big_endian ? 2-x : x]
2203 #define OP4(x) op[target_big_endian ? 3-x : x]
2205 op
= f
->fx_frag
->fr_literal
+ f
->fx_where
;
2206 val
= (unsigned long) * t
;
2208 /* Opcode words are always the same endian. Data words are either
2209 big or little endian. */
2211 switch (f
->fx_r_type
)
2213 case BFD_RELOC_NONE
:
2216 case BFD_RELOC_RX_RELAX
:
2220 case BFD_RELOC_RX_DIR3U_PCREL
:
2221 if (val
< 3 || val
> 10)
2222 as_bad_where (f
->fx_file
, f
->fx_line
,
2223 _("jump not 3..10 bytes away (is %d)"), (int) val
);
2225 op
[0] |= val
& 0x07;
2229 case BFD_RELOC_8_PCREL
:
2230 case BFD_RELOC_RX_8U
:
2235 OP2(1) = val
& 0xff;
2236 OP2(0) = (val
>> 8) & 0xff;
2239 case BFD_RELOC_16_PCREL
:
2240 case BFD_RELOC_RX_16_OP
:
2241 case BFD_RELOC_RX_16U
:
2242 #if RX_OPCODE_BIG_ENDIAN
2244 op
[0] = (val
>> 8) & 0xff;
2247 op
[1] = (val
>> 8) & 0xff;
2252 OP3(0) = val
& 0xff;
2253 OP3(1) = (val
>> 8) & 0xff;
2254 OP3(2) = (val
>> 16) & 0xff;
2257 case BFD_RELOC_24_PCREL
:
2258 case BFD_RELOC_RX_24_OP
:
2259 case BFD_RELOC_RX_24U
:
2260 #if RX_OPCODE_BIG_ENDIAN
2262 op
[1] = (val
>> 8) & 0xff;
2263 op
[0] = (val
>> 16) & 0xff;
2266 op
[1] = (val
>> 8) & 0xff;
2267 op
[2] = (val
>> 16) & 0xff;
2271 case BFD_RELOC_RX_DIFF
:
2278 OP2(0) = val
& 0xff;
2279 OP2(1) = (val
>> 8) & 0xff;
2282 OP4(0) = val
& 0xff;
2283 OP4(1) = (val
>> 8) & 0xff;
2284 OP4(2) = (val
>> 16) & 0xff;
2285 OP4(3) = (val
>> 24) & 0xff;
2291 OP4(0) = val
& 0xff;
2292 OP4(1) = (val
>> 8) & 0xff;
2293 OP4(2) = (val
>> 16) & 0xff;
2294 OP4(3) = (val
>> 24) & 0xff;
2297 case BFD_RELOC_RX_32_OP
:
2298 #if RX_OPCODE_BIG_ENDIAN
2300 op
[2] = (val
>> 8) & 0xff;
2301 op
[1] = (val
>> 16) & 0xff;
2302 op
[0] = (val
>> 24) & 0xff;
2305 op
[1] = (val
>> 8) & 0xff;
2306 op
[2] = (val
>> 16) & 0xff;
2307 op
[3] = (val
>> 24) & 0xff;
2311 case BFD_RELOC_RX_NEG8
:
2315 case BFD_RELOC_RX_NEG16
:
2317 #if RX_OPCODE_BIG_ENDIAN
2319 op
[0] = (val
>> 8) & 0xff;
2322 op
[1] = (val
>> 8) & 0xff;
2326 case BFD_RELOC_RX_NEG24
:
2328 #if RX_OPCODE_BIG_ENDIAN
2330 op
[1] = (val
>> 8) & 0xff;
2331 op
[0] = (val
>> 16) & 0xff;
2334 op
[1] = (val
>> 8) & 0xff;
2335 op
[2] = (val
>> 16) & 0xff;
2339 case BFD_RELOC_RX_NEG32
:
2341 #if RX_OPCODE_BIG_ENDIAN
2343 op
[2] = (val
>> 8) & 0xff;
2344 op
[1] = (val
>> 16) & 0xff;
2345 op
[0] = (val
>> 24) & 0xff;
2348 op
[1] = (val
>> 8) & 0xff;
2349 op
[2] = (val
>> 16) & 0xff;
2350 op
[3] = (val
>> 24) & 0xff;
2354 case BFD_RELOC_RX_GPRELL
:
2356 case BFD_RELOC_RX_GPRELW
:
2358 case BFD_RELOC_RX_GPRELB
:
2359 #if RX_OPCODE_BIG_ENDIAN
2361 op
[0] = (val
>> 8) & 0xff;
2364 op
[1] = (val
>> 8) & 0xff;
2369 as_bad (_("Unknown reloc in md_apply_fix: %s"),
2370 bfd_get_reloc_code_name (f
->fx_r_type
));
2374 if (f
->fx_addsy
== NULL
)
2379 tc_gen_reloc (asection
* sec ATTRIBUTE_UNUSED
, fixS
* fixp
)
2381 static arelent
* reloc
[5];
2382 bfd_boolean is_opcode
= FALSE
;
2384 if (fixp
->fx_r_type
== BFD_RELOC_NONE
)
2391 && S_GET_SEGMENT (fixp
->fx_subsy
) == absolute_section
)
2393 fixp
->fx_offset
-= S_GET_VALUE (fixp
->fx_subsy
);
2394 fixp
->fx_subsy
= NULL
;
2397 reloc
[0] = (arelent
*) xmalloc (sizeof (arelent
));
2398 reloc
[0]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2399 * reloc
[0]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2400 reloc
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2401 reloc
[0]->addend
= fixp
->fx_offset
;
2403 if (fixp
->fx_r_type
== BFD_RELOC_RX_32_OP
2406 fixp
->fx_r_type
= BFD_RELOC_RX_DIFF
;
2410 is_opcode
= sec
->flags
& SEC_CODE
;
2412 /* Certain BFD relocations cannot be translated directly into
2413 a single (non-Red Hat) RX relocation, but instead need
2414 multiple RX relocations - handle them here. */
2415 switch (fixp
->fx_r_type
)
2417 case BFD_RELOC_RX_DIFF
:
2418 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2420 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2421 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2422 * reloc
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
2423 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2424 reloc
[1]->addend
= 0;
2425 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2427 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2428 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2429 reloc
[2]->addend
= 0;
2430 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2431 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2433 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2434 switch (fixp
->fx_size
)
2437 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS8
);
2440 if (!is_opcode
&& target_big_endian
)
2441 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16_REV
);
2443 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16UL
);
2445 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16
);
2448 if (!is_opcode
&& target_big_endian
)
2449 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS32_REV
);
2451 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS32
);
2454 reloc
[3]->addend
= 0;
2455 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2456 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2461 case BFD_RELOC_RX_GPRELL
:
2462 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2464 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2465 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2466 if (gp_symbol
== NULL
)
2468 if (symbol_table_frozen
)
2472 gp
= symbol_find ("__gp");
2474 as_bad (("unable to create __gp symbol: please re-assemble with the -msmall-data-limit option specified"));
2476 gp_symbol
= symbol_get_bfdsym (gp
);
2479 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
2481 * reloc
[1]->sym_ptr_ptr
= gp_symbol
;
2482 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2483 reloc
[1]->addend
= 0;
2484 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2486 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2487 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2488 reloc
[2]->addend
= 0;
2489 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2490 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2492 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2493 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16UL
);
2494 reloc
[3]->addend
= 0;
2495 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2496 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2501 case BFD_RELOC_RX_GPRELW
:
2502 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2504 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2505 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2506 if (gp_symbol
== NULL
)
2508 if (symbol_table_frozen
)
2512 gp
= symbol_find ("__gp");
2514 as_bad (("unable to create __gp symbol: please re-assemble with the -msmall-data-limit option specified"));
2516 gp_symbol
= symbol_get_bfdsym (gp
);
2519 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
2521 * reloc
[1]->sym_ptr_ptr
= gp_symbol
;
2522 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2523 reloc
[1]->addend
= 0;
2524 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2526 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2527 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2528 reloc
[2]->addend
= 0;
2529 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2530 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2532 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2533 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16UW
);
2534 reloc
[3]->addend
= 0;
2535 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2536 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2541 case BFD_RELOC_RX_GPRELB
:
2542 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2544 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2545 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2546 if (gp_symbol
== NULL
)
2548 if (symbol_table_frozen
)
2552 gp
= symbol_find ("__gp");
2554 as_bad (("unable to create __gp symbol: please re-assemble with the -msmall-data-limit option specified"));
2556 gp_symbol
= symbol_get_bfdsym (gp
);
2559 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
2561 * reloc
[1]->sym_ptr_ptr
= gp_symbol
;
2562 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2563 reloc
[1]->addend
= 0;
2564 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2566 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2567 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2568 reloc
[2]->addend
= 0;
2569 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2570 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2572 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2573 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16U
);
2574 reloc
[3]->addend
= 0;
2575 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2576 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2581 case BFD_RELOC_RX_NEG32
:
2582 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2584 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2585 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_NEG
);
2586 reloc
[1]->addend
= 0;
2587 reloc
[1]->sym_ptr_ptr
= reloc
[0]->sym_ptr_ptr
;
2588 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2590 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2591 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS32
);
2592 reloc
[2]->addend
= 0;
2593 reloc
[2]->sym_ptr_ptr
= reloc
[0]->sym_ptr_ptr
;
2594 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2600 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
2608 /* Set the ELF specific flags. */
2611 rx_elf_final_processing (void)
2613 elf_elfheader (stdoutput
)->e_flags
|= elf_flags
;
2616 /* Scan the current input line for occurances of Renesas
2617 local labels and replace them with the GAS version. */
2620 rx_start_line (void)
2622 int in_double_quote
= 0;
2623 int in_single_quote
= 0;
2625 char * p
= input_line_pointer
;
2627 /* Scan the line looking for question marks. Skip past quote enclosed regions. */
2638 in_double_quote
= ! in_double_quote
;
2642 in_single_quote
= ! in_single_quote
;
2646 if (in_double_quote
|| in_single_quote
)
2651 else if (p
[1] == '+')
2656 else if (p
[1] == '-')