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;
61 OPTION_BIG
= OPTION_MD_BASE
,
65 OPTION_CONVENTIONAL_SECTION_NAMES
,
66 OPTION_RENESAS_SECTION_NAMES
,
67 OPTION_SMALL_DATA_LIMIT
,
73 #define RX_SHORTOPTS ""
74 const char * md_shortopts
= RX_SHORTOPTS
;
76 /* Assembler options. */
77 struct option md_longopts
[] =
79 {"mbig-endian-data", no_argument
, NULL
, OPTION_BIG
},
80 {"mlittle-endian-data", no_argument
, NULL
, OPTION_LITTLE
},
81 /* The next two switches are here because the
82 generic parts of the linker testsuite uses them. */
83 {"EB", no_argument
, NULL
, OPTION_BIG
},
84 {"EL", no_argument
, NULL
, OPTION_LITTLE
},
85 {"m32bit-doubles", no_argument
, NULL
, OPTION_32BIT_DOUBLES
},
86 {"m64bit-doubles", no_argument
, NULL
, OPTION_64BIT_DOUBLES
},
87 /* This option is here mainly for the binutils testsuites,
88 as many of their tests assume conventional section naming. */
89 {"muse-conventional-section-names", no_argument
, NULL
, OPTION_CONVENTIONAL_SECTION_NAMES
},
90 {"muse-renesas-section-names", no_argument
, NULL
, OPTION_RENESAS_SECTION_NAMES
},
91 {"msmall-data-limit", no_argument
, NULL
, OPTION_SMALL_DATA_LIMIT
},
92 {"relax", no_argument
, NULL
, OPTION_RELAX
},
93 {"mpid", no_argument
, NULL
, OPTION_PID
},
94 {"mint-register", required_argument
, NULL
, OPTION_INT_REGS
},
95 {NULL
, no_argument
, NULL
, 0}
97 size_t md_longopts_size
= sizeof (md_longopts
);
100 md_parse_option (int c ATTRIBUTE_UNUSED
, char * arg ATTRIBUTE_UNUSED
)
105 target_big_endian
= 1;
109 target_big_endian
= 0;
112 case OPTION_32BIT_DOUBLES
:
113 elf_flags
&= ~ E_FLAG_RX_64BIT_DOUBLES
;
116 case OPTION_64BIT_DOUBLES
:
117 elf_flags
|= E_FLAG_RX_64BIT_DOUBLES
;
120 case OPTION_CONVENTIONAL_SECTION_NAMES
:
121 rx_use_conventional_section_names
= TRUE
;
124 case OPTION_RENESAS_SECTION_NAMES
:
125 rx_use_conventional_section_names
= FALSE
;
128 case OPTION_SMALL_DATA_LIMIT
:
129 rx_use_small_data_limit
= TRUE
;
138 elf_flags
|= E_FLAG_RX_PID
;
141 case OPTION_INT_REGS
:
142 rx_num_int_regs
= atoi (optarg
);
149 md_show_usage (FILE * stream
)
151 fprintf (stream
, _(" RX specific command line options:\n"));
152 fprintf (stream
, _(" --mbig-endian-data\n"));
153 fprintf (stream
, _(" --mlittle-endian-data [default]\n"));
154 fprintf (stream
, _(" --m32bit-doubles [default]\n"));
155 fprintf (stream
, _(" --m64bit-doubles\n"));
156 fprintf (stream
, _(" --muse-conventional-section-names\n"));
157 fprintf (stream
, _(" --muse-renesas-section-names [default]\n"));
158 fprintf (stream
, _(" --msmall-data-limit\n"));
159 fprintf (stream
, _(" --mrelax\n"));
160 fprintf (stream
, _(" --mpid\n"));
161 fprintf (stream
, _(" --mint-register=<value>\n"));
165 s_bss (int ignore ATTRIBUTE_UNUSED
)
169 temp
= get_absolute_expression ();
170 subseg_set (bss_section
, (subsegT
) temp
);
171 demand_empty_rest_of_line ();
175 rx_float_cons (int ignore ATTRIBUTE_UNUSED
)
177 if (elf_flags
& E_FLAG_RX_64BIT_DOUBLES
)
178 return float_cons ('d');
179 return float_cons ('f');
183 rx_strcasestr (const char *string
, const char *sub
)
189 return (char *)string
;
192 strl
= strlen (string
);
196 /* strncasecmp is in libiberty. */
197 if (strncasecmp (string
, sub
, subl
) == 0)
198 return (char *)string
;
207 rx_include (int ignore
)
212 char * current_filename
;
220 /* The RX version of the .INCLUDE pseudo-op does not
221 have to have the filename inside double quotes. */
223 if (*input_line_pointer
== '"')
225 /* Treat as the normal GAS .include pseudo-op. */
230 /* Get the filename. Spaces are allowed, NUL characters are not. */
231 filename
= input_line_pointer
;
232 eof
= find_end_of_line (filename
, FALSE
);
233 input_line_pointer
= eof
;
235 while (eof
>= filename
&& (* eof
== ' ' || * eof
== '\n'))
237 end_char
= *(++ eof
);
241 as_bad (_("no filename following .INCLUDE pseudo-op"));
246 as_where (& current_filename
, NULL
);
247 f
= (char *) xmalloc (strlen (current_filename
) + strlen (filename
) + 1);
249 /* Check the filename. If [@]..FILE[@] is found then replace
250 this with the current assembler source filename, stripped
251 of any directory prefixes or extensions. */
252 if ((p
= rx_strcasestr (filename
, "..file")) != NULL
)
256 len
= 6; /* strlen ("..file"); */
258 if (p
> filename
&& p
[-1] == '@')
264 for (d
= c
= current_filename
; *c
; c
++)
265 if (IS_DIR_SEPARATOR (* c
))
271 sprintf (f
, "%.*s%.*s%.*s", (int) (p
- filename
), filename
,
273 (int) (strlen (filename
) - ((p
+ len
) - filename
)),
277 strcpy (f
, filename
);
279 /* RX .INCLUDE semantics say that 'filename' is located by:
281 1. If filename is absolute, just try that. Otherwise...
283 2. If the current source file includes a directory component
284 then prepend that to the filename and try. Otherwise...
286 3. Try any directories specified by the -I command line
289 4 .Try a directory specifed by the INC100 environment variable. */
291 if (IS_ABSOLUTE_PATH (f
))
292 try = fopen (path
= f
, FOPEN_RT
);
295 char * env
= getenv ("INC100");
299 len
= strlen (current_filename
);
300 if ((size_t) include_dir_maxlen
> len
)
301 len
= include_dir_maxlen
;
302 if (env
&& strlen (env
) > len
)
305 path
= (char *) xmalloc (strlen (f
) + len
+ 5);
307 if (current_filename
!= NULL
)
309 for (d
= NULL
, p
= current_filename
; *p
; p
++)
310 if (IS_DIR_SEPARATOR (* p
))
315 sprintf (path
, "%.*s/%s", (int) (d
- current_filename
), current_filename
,
317 try = fopen (path
, FOPEN_RT
);
325 for (i
= 0; i
< include_dir_count
; i
++)
327 sprintf (path
, "%s/%s", include_dirs
[i
], f
);
328 if ((try = fopen (path
, FOPEN_RT
)) != NULL
)
333 if (try == NULL
&& env
!= NULL
)
335 sprintf (path
, "%s/%s", env
, f
);
336 try = fopen (path
, FOPEN_RT
);
344 as_bad (_("unable to locate include file: %s"), filename
);
350 register_dependency (path
);
351 input_scrub_insert_file (path
);
358 parse_rx_section (char * name
)
362 int attr
= SHF_ALLOC
| SHF_EXECINSTR
;
371 for (p
= input_line_pointer
; *p
&& strchr ("\n\t, =", *p
) == NULL
; p
++)
376 if (strcasecmp (input_line_pointer
, "ALIGN") == 0)
391 case '2': align
= 2; break;
392 case '4': align
= 4; break;
393 case '8': align
= 8; break;
395 as_bad (_("unrecognised alignment value in .SECTION directive: %s"), p
);
396 ignore_rest_of_line ();
404 else if (strcasecmp (input_line_pointer
, "CODE") == 0)
405 attr
= SHF_ALLOC
| SHF_EXECINSTR
;
406 else if (strcasecmp (input_line_pointer
, "DATA") == 0)
407 attr
= SHF_ALLOC
| SHF_WRITE
;
408 else if (strcasecmp (input_line_pointer
, "ROMDATA") == 0)
412 as_bad (_("unknown parameter following .SECTION directive: %s"),
416 input_line_pointer
= p
+ 1;
417 ignore_rest_of_line ();
422 input_line_pointer
= p
+ 1;
424 while (end_char
!= '\n' && end_char
!= 0);
426 if ((sec
= bfd_get_section_by_name (stdoutput
, name
)) == NULL
)
428 if (strcmp (name
, "B") && strcmp (name
, "B_1") && strcmp (name
, "B_2"))
433 obj_elf_change_section (name
, type
, attr
, 0, NULL
, FALSE
, FALSE
);
435 else /* Try not to redefine a section, especially B_1. */
437 int flags
= sec
->flags
;
439 type
= elf_section_type (sec
);
441 attr
= ((flags
& SEC_READONLY
) ? 0 : SHF_WRITE
)
442 | ((flags
& SEC_ALLOC
) ? SHF_ALLOC
: 0)
443 | ((flags
& SEC_CODE
) ? SHF_EXECINSTR
: 0)
444 | ((flags
& SEC_MERGE
) ? SHF_MERGE
: 0)
445 | ((flags
& SEC_STRINGS
) ? SHF_STRINGS
: 0)
446 | ((flags
& SEC_THREAD_LOCAL
) ? SHF_TLS
: 0);
448 obj_elf_change_section (name
, type
, attr
, 0, NULL
, FALSE
, FALSE
);
451 bfd_set_section_alignment (stdoutput
, now_seg
, align
);
455 rx_section (int ignore
)
459 /* The as100 assembler supports a different syntax for the .section
460 pseudo-op. So check for it and handle it here if necessary. */
463 /* Peek past the section name to see if arguments follow. */
464 for (p
= input_line_pointer
; *p
; p
++)
465 if (*p
== ',' || *p
== '\n')
470 int len
= p
- input_line_pointer
;
472 while (ISSPACE (*++p
))
475 if (*p
!= '"' && *p
!= '#')
477 char * name
= (char *) xmalloc (len
+ 1);
479 strncpy (name
, input_line_pointer
, len
);
482 input_line_pointer
= p
;
483 parse_rx_section (name
);
488 obj_elf_section (ignore
);
492 rx_list (int ignore ATTRIBUTE_UNUSED
)
496 if (strncasecmp (input_line_pointer
, "OFF", 3))
498 else if (strncasecmp (input_line_pointer
, "ON", 2))
501 as_warn (_("expecting either ON or OFF after .list"));
504 /* Like the .rept pseudo op, but supports the
505 use of ..MACREP inside the repeated region. */
508 rx_rept (int ignore ATTRIBUTE_UNUSED
)
510 int count
= get_absolute_expression ();
512 do_repeat_with_expander (count
, "MREPEAT", "ENDR", "..MACREP");
515 /* Like cons() accept that strings are allowed. */
522 if (* input_line_pointer
== '"')
529 rx_nop (int ignore ATTRIBUTE_UNUSED
)
531 ignore_rest_of_line ();
537 as_warn (_("The \".%s\" pseudo-op is not implemented\n"),
538 md_pseudo_table
[idx
].poc_name
);
539 ignore_rest_of_line ();
542 /* The target specific pseudo-ops which we support. */
543 const pseudo_typeS md_pseudo_table
[] =
545 /* These are unimplemented. They're listed first so that we can use
546 the poc_value as the index into this array, to get the name of
547 the pseudo. So, keep these (1) first, and (2) in order, with (3)
548 the poc_value's in sequence. */
549 { "btglb", rx_unimp
, 0 },
550 { "call", rx_unimp
, 1 },
551 { "einsf", rx_unimp
, 2 },
552 { "fb", rx_unimp
, 3 },
553 { "fbsym", rx_unimp
, 4 },
554 { "id", rx_unimp
, 5 },
555 { "initsct", rx_unimp
, 6 },
556 { "insf", rx_unimp
, 7 },
557 { "instr", rx_unimp
, 8 },
558 { "lbba", rx_unimp
, 9 },
559 { "len", rx_unimp
, 10 },
560 { "optj", rx_unimp
, 11 },
561 { "rvector", rx_unimp
, 12 },
562 { "sb", rx_unimp
, 13 },
563 { "sbbit", rx_unimp
, 14 },
564 { "sbsym", rx_unimp
, 15 },
565 { "sbsym16", rx_unimp
, 16 },
567 /* These are the do-nothing pseudos. */
568 { "stk", rx_nop
, 0 },
569 /* The manual documents ".stk" but the compiler emits ".stack". */
570 { "stack", rx_nop
, 0 },
572 /* These are Renesas as100 assembler pseudo-ops that we do support. */
573 { "addr", rx_cons
, 3 },
574 { "align", s_align_bytes
, 2 },
575 { "byte", rx_cons
, 1 },
576 { "fixed", float_cons
, 'f' },
577 { "form", listing_psize
, 0 },
578 { "glb", s_globl
, 0 },
579 { "include", rx_include
, 0 },
580 { "list", rx_list
, 0 },
581 { "lword", rx_cons
, 4 },
582 { "mrepeat", rx_rept
, 0 },
583 { "section", rx_section
, 0 },
585 /* FIXME: The following pseudo-ops place their values (and associated
586 label if present) in the data section, regardless of whatever
587 section we are currently in. At the moment this code does not
588 implement that part of the semantics. */
589 { "blka", s_space
, 3 },
590 { "blkb", s_space
, 1 },
591 { "blkd", s_space
, 8 },
592 { "blkf", s_space
, 4 },
593 { "blkl", s_space
, 4 },
594 { "blkw", s_space
, 2 },
596 /* Our "standard" pseudos. */
597 { "double", rx_float_cons
, 0 },
599 { "3byte", cons
, 3 },
603 /* End of list marker. */
607 static asymbol
* gp_symbol
;
608 static asymbol
* rx_pid_symbol
;
610 static symbolS
* rx_pidreg_symbol
;
611 static symbolS
* rx_gpreg_symbol
;
616 /* Make the __gp and __pid_base symbols now rather
617 than after the symbol table is frozen. We only do this
618 when supporting small data limits because otherwise we
619 pollute the symbol table. */
621 /* The meta-registers %pidreg and %gpreg depend on what other
622 options are specified. The __rx_*_defined symbols exist so we
623 can .ifdef asm code based on what options were passed to gas,
624 without needing a preprocessor */
628 rx_pid_register
= 13 - rx_num_int_regs
;
629 rx_pid_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__pid_base"));
630 rx_pidreg_symbol
= symbol_find_or_make ("__rx_pidreg_defined");
631 S_SET_VALUE (rx_pidreg_symbol
, rx_pid_register
);
632 S_SET_SEGMENT (rx_pidreg_symbol
, absolute_section
);
635 if (rx_use_small_data_limit
)
638 rx_gp_register
= rx_pid_register
- 1;
640 rx_gp_register
= 13 - rx_num_int_regs
;
641 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
642 rx_gpreg_symbol
= symbol_find_or_make ("__rx_gpreg_defined");
643 S_SET_VALUE (rx_gpreg_symbol
, rx_gp_register
);
644 S_SET_SEGMENT (rx_gpreg_symbol
, absolute_section
);
651 typedef struct rx_bytesT
662 char type
; /* RXREL_*. */
675 fixS
*link_relax_fixP
;
680 static rx_bytesT rx_bytes
;
683 rx_relax (int type
, int pos
)
685 rx_bytes
.relax
[rx_bytes
.n_relax
].type
= type
;
686 rx_bytes
.relax
[rx_bytes
.n_relax
].field_pos
= pos
;
687 rx_bytes
.relax
[rx_bytes
.n_relax
].val_ofs
= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
692 rx_linkrelax_dsp (int pos
)
697 rx_bytes
.link_relax
|= RX_RELAXA_DSP4
;
700 rx_bytes
.link_relax
|= RX_RELAXA_DSP6
;
703 rx_bytes
.link_relax
|= RX_RELAXA_DSP14
;
709 rx_linkrelax_imm (int pos
)
714 rx_bytes
.link_relax
|= RX_RELAXA_IMM6
;
717 rx_bytes
.link_relax
|= RX_RELAXA_IMM12
;
723 rx_linkrelax_branch (void)
725 rx_bytes
.link_relax
|= RX_RELAXA_BRA
;
729 rx_fixup (expressionS exp
, int offsetbits
, int nbits
, int type
)
731 rx_bytes
.fixups
[rx_bytes
.n_fixups
].exp
= exp
;
732 rx_bytes
.fixups
[rx_bytes
.n_fixups
].offset
= offsetbits
;
733 rx_bytes
.fixups
[rx_bytes
.n_fixups
].nbits
= nbits
;
734 rx_bytes
.fixups
[rx_bytes
.n_fixups
].type
= type
;
735 rx_bytes
.fixups
[rx_bytes
.n_fixups
].reloc
= exp
.X_md
;
736 rx_bytes
.n_fixups
++;
739 #define rx_field_fixup(exp, offset, nbits, type) \
740 rx_fixup (exp, offset, nbits, type)
742 #define rx_op_fixup(exp, offset, nbits, type) \
743 rx_fixup (exp, offset + 8 * rx_bytes.n_base, nbits, type)
748 rx_bytes
.base
[0] = b1
;
753 rx_base2 (int b1
, int b2
)
755 rx_bytes
.base
[0] = b1
;
756 rx_bytes
.base
[1] = b2
;
761 rx_base3 (int b1
, int b2
, int b3
)
763 rx_bytes
.base
[0] = b1
;
764 rx_bytes
.base
[1] = b2
;
765 rx_bytes
.base
[2] = b3
;
770 rx_base4 (int b1
, int b2
, int b3
, int b4
)
772 rx_bytes
.base
[0] = b1
;
773 rx_bytes
.base
[1] = b2
;
774 rx_bytes
.base
[2] = b3
;
775 rx_bytes
.base
[3] = b4
;
779 /* This gets complicated when the field spans bytes, because fields
780 are numbered from the MSB of the first byte as zero, and bits are
781 stored LSB towards the LSB of the byte. Thus, a simple four-bit
782 insertion of 12 at position 4 of 0x00 yields: 0x0b. A three-bit
783 insertion of b'MXL at position 7 is like this:
785 - - - - - - - - - - - - - - - -
789 rx_field (int val
, int pos
, int sz
)
796 if (val
< 0 || val
>= (1 << sz
))
797 as_bad (_("Value %d doesn't fit in unsigned %d-bit field"), val
, sz
);
802 if (val
< -(1 << (sz
- 1)) || val
>= (1 << (sz
- 1)))
803 as_bad (_("Value %d doesn't fit in signed %d-bit field"), val
, sz
);
806 /* This code points at 'M' in the above example. */
810 while (bitp
+ sz
> 8)
815 svalm
= val
>> (sz
- ssz
);
816 svalm
= svalm
& ((1 << ssz
) - 1);
817 svalm
= svalm
<< (8 - bitp
- ssz
);
818 gas_assert (bytep
< rx_bytes
.n_base
);
819 rx_bytes
.base
[bytep
] |= svalm
;
825 valm
= val
& ((1 << sz
) - 1);
826 valm
= valm
<< (8 - bitp
- sz
);
827 gas_assert (bytep
< rx_bytes
.n_base
);
828 rx_bytes
.base
[bytep
] |= valm
;
831 /* Special case of the above, for 3-bit displacements of 2..9. */
834 rx_disp3 (expressionS exp
, int pos
)
836 rx_field_fixup (exp
, pos
, 3, RXREL_PCREL
);
839 /* Special case of the above, for split 5-bit displacements. Assumes
840 the displacement has been checked with rx_disp5op. */
841 /* ---- -432 1--- 0--- */
844 rx_field5s (expressionS exp
)
848 val
= exp
.X_add_number
;
849 rx_bytes
.base
[0] |= val
>> 2;
850 rx_bytes
.base
[1] |= (val
<< 6) & 0x80;
851 rx_bytes
.base
[1] |= (val
<< 3) & 0x08;
854 /* ---- ---- 4--- 3210 */
857 rx_field5s2 (expressionS exp
)
861 val
= exp
.X_add_number
;
862 rx_bytes
.base
[1] |= (val
<< 3) & 0x80;
863 rx_bytes
.base
[1] |= (val
) & 0x0f;
866 #define OP(x) rx_bytes.ops[rx_bytes.n_ops++] = (x)
868 #define F_PRECISION 2
871 rx_op (expressionS exp
, int nbytes
, int type
)
875 if ((exp
.X_op
== O_constant
|| exp
.X_op
== O_big
)
876 && type
!= RXREL_PCREL
)
878 if (exp
.X_op
== O_big
&& exp
.X_add_number
<= 0)
881 char * ip
= rx_bytes
.ops
+ rx_bytes
.n_ops
;
883 gen_to_words (w
, F_PRECISION
, 8);
884 #if RX_OPCODE_BIG_ENDIAN
899 v
= exp
.X_add_number
;
902 #if RX_OPCODE_BIG_ENDIAN
903 OP ((v
>> (8 * (nbytes
- 1))) & 0xff);
914 rx_op_fixup (exp
, rx_bytes
.n_ops
* 8, nbytes
* 8, type
);
915 memset (rx_bytes
.ops
+ rx_bytes
.n_ops
, 0, nbytes
);
916 rx_bytes
.n_ops
+= nbytes
;
926 #define APPEND(B, N_B) \
929 memcpy (bytes + idx, rx_bytes.B, rx_bytes.N_B); \
930 idx += rx_bytes.N_B; \
934 rx_frag_init (fragS
* fragP
)
936 if (rx_bytes
.n_relax
|| rx_bytes
.link_relax
)
938 fragP
->tc_frag_data
= malloc (sizeof (rx_bytesT
));
939 memcpy (fragP
->tc_frag_data
, & rx_bytes
, sizeof (rx_bytesT
));
942 fragP
->tc_frag_data
= 0;
945 /* Handle the as100's version of the .equ pseudo-op. It has the syntax:
946 <symbol_name> .equ <expression> */
949 rx_equ (char * name
, char * expression
)
951 char saved_name_end_char
;
955 while (ISSPACE (* name
))
958 for (name_end
= name
+ 1; *name_end
; name_end
++)
959 if (! ISALNUM (* name_end
))
962 saved_name_end_char
= * name_end
;
965 saved_ilp
= input_line_pointer
;
966 input_line_pointer
= expression
;
970 input_line_pointer
= saved_ilp
;
971 * name_end
= saved_name_end_char
;
974 /* Look for Renesas as100 pseudo-ops that occur after a symbol name
975 rather than at the start of a line. (eg .EQU or .DEFINE). If one
976 is found, process it and return TRUE otherwise return FALSE. */
979 scan_for_infix_rx_pseudo_ops (char * str
)
983 char * dot
= strchr (str
, '.');
985 if (dot
== NULL
|| dot
== str
)
988 /* A real pseudo-op must be preceeded by whitespace. */
989 if (dot
[-1] != ' ' && dot
[-1] != '\t')
994 if (!ISALNUM (* pseudo_op
))
997 for (p
= pseudo_op
+ 1; ISALNUM (* p
); p
++)
1000 if (strncasecmp ("EQU", pseudo_op
, p
- pseudo_op
) == 0)
1002 else if (strncasecmp ("DEFINE", pseudo_op
, p
- pseudo_op
) == 0)
1003 as_warn (_("The .DEFINE pseudo-op is not implemented"));
1004 else if (strncasecmp ("MACRO", pseudo_op
, p
- pseudo_op
) == 0)
1005 as_warn (_("The .MACRO pseudo-op is not implemented"));
1006 else if (strncasecmp ("BTEQU", pseudo_op
, p
- pseudo_op
) == 0)
1007 as_warn (_("The .BTEQU pseudo-op is not implemented."));
1015 md_assemble (char * str
)
1020 fragS
* frag_then
= frag_now
;
1023 memset (& rx_bytes
, 0, sizeof (rx_bytes
));
1025 rx_lex_init (str
, str
+ strlen (str
));
1026 if (scan_for_infix_rx_pseudo_ops (str
))
1030 /* This simplifies the relaxation code. */
1031 if (rx_bytes
.n_relax
|| rx_bytes
.link_relax
)
1033 /* We do it this way because we want the frag to have the
1034 rx_bytes in it, which we initialize above. */
1035 bytes
= frag_more (12);
1036 frag_then
= frag_now
;
1037 frag_variant (rs_machine_dependent
,
1044 frag_then
->fr_opcode
= bytes
;
1045 frag_then
->fr_fix
+= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
1046 frag_then
->fr_subtype
= rx_bytes
.n_base
+ rx_bytes
.n_ops
;
1050 bytes
= frag_more (rx_bytes
.n_base
+ rx_bytes
.n_ops
);
1051 frag_then
= frag_now
;
1054 APPEND (base
, n_base
);
1055 APPEND (ops
, n_ops
);
1057 if (rx_bytes
.link_relax
&& rx_bytes
.n_fixups
)
1061 f
= fix_new (frag_then
,
1062 (char *) bytes
- frag_then
->fr_literal
,
1065 rx_bytes
.link_relax
| rx_bytes
.n_fixups
,
1067 BFD_RELOC_RX_RELAX
);
1068 frag_then
->tc_frag_data
->link_relax_fixP
= f
;
1071 for (i
= 0; i
< rx_bytes
.n_fixups
; i
++)
1073 /* index: [nbytes][type] */
1074 static int reloc_map
[5][4] =
1076 { 0, 0, 0, BFD_RELOC_RX_DIR3U_PCREL
},
1077 { BFD_RELOC_8
, BFD_RELOC_RX_8U
, BFD_RELOC_RX_NEG8
, BFD_RELOC_8_PCREL
},
1078 { BFD_RELOC_RX_16_OP
, BFD_RELOC_RX_16U
, BFD_RELOC_RX_NEG16
, BFD_RELOC_16_PCREL
},
1079 { BFD_RELOC_RX_24_OP
, BFD_RELOC_RX_24U
, BFD_RELOC_RX_NEG24
, BFD_RELOC_24_PCREL
},
1080 { BFD_RELOC_RX_32_OP
, BFD_RELOC_32
, BFD_RELOC_RX_NEG32
, BFD_RELOC_32_PCREL
},
1084 idx
= rx_bytes
.fixups
[i
].offset
/ 8;
1085 rel
= reloc_map
[rx_bytes
.fixups
[i
].nbits
/ 8][(int) rx_bytes
.fixups
[i
].type
];
1087 if (rx_bytes
.fixups
[i
].reloc
)
1088 rel
= rx_bytes
.fixups
[i
].reloc
;
1090 if (frag_then
->tc_frag_data
)
1091 exp
= & frag_then
->tc_frag_data
->fixups
[i
].exp
;
1093 exp
= & rx_bytes
.fixups
[i
].exp
;
1095 f
= fix_new_exp (frag_then
,
1096 (char *) bytes
+ idx
- frag_then
->fr_literal
,
1097 rx_bytes
.fixups
[i
].nbits
/ 8,
1099 rx_bytes
.fixups
[i
].type
== RXREL_PCREL
? 1 : 0,
1101 if (frag_then
->tc_frag_data
)
1102 frag_then
->tc_frag_data
->fixups
[i
].fixP
= f
;
1105 dwarf2_emit_insn (idx
);
1113 /* Write a value out to the object file, using the appropriate endianness. */
1116 md_number_to_chars (char * buf
, valueT val
, int n
)
1118 if (target_big_endian
)
1119 number_to_chars_bigendian (buf
, val
, n
);
1121 number_to_chars_littleendian (buf
, val
, n
);
1131 { "gp", BFD_RELOC_GPREL16
},
1136 md_operand (expressionS
* exp ATTRIBUTE_UNUSED
)
1141 for (i
= 0; reloc_functions
[i
].fname
; i
++)
1143 int flen
= strlen (reloc_functions
[i
].fname
);
1145 if (input_line_pointer
[0] == '%'
1146 && strncasecmp (input_line_pointer
+ 1, reloc_functions
[i
].fname
, flen
) == 0
1147 && input_line_pointer
[flen
+ 1] == '(')
1149 reloc
= reloc_functions
[i
].reloc
;
1150 input_line_pointer
+= flen
+ 2;
1158 if (* input_line_pointer
== ')')
1159 input_line_pointer
++;
1165 md_section_align (segT segment
, valueT size
)
1167 int align
= bfd_get_section_alignment (stdoutput
, segment
);
1168 return ((size
+ (1 << align
) - 1) & (-1 << align
));
1172 static unsigned char nop_1
[] = { 0x03};
1173 /* MOV.L R0,R0 - 1 cycle */
1174 static unsigned char nop_2
[] = { 0xef, 0x00};
1175 /* MAX R0,R0 - 1 cycle */
1176 static unsigned char nop_3
[] = { 0xfc, 0x13, 0x00 };
1177 /* MUL #1,R0 - 1 cycle */
1178 static unsigned char nop_4
[] = { 0x76, 0x10, 0x01, 0x00 };
1179 /* MUL #1,R0 - 1 cycle */
1180 static unsigned char nop_5
[] = { 0x77, 0x10, 0x01, 0x00, 0x00 };
1181 /* MUL #1,R0 - 1 cycle */
1182 static unsigned char nop_6
[] = { 0x74, 0x10, 0x01, 0x00, 0x00, 0x00 };
1183 /* BRA.S .+7 - 1 cycle */
1184 static unsigned char nop_7
[] = { 0x0F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };
1186 static unsigned char *nops
[] = { NULL
, nop_1
, nop_2
, nop_3
, nop_4
, nop_5
, nop_6
, nop_7
};
1187 #define BIGGEST_NOP 7
1189 /* When relaxing, we need to output a reloc for any .align directive
1190 so that we can retain this alignment as we adjust opcode sizes. */
1192 rx_handle_align (fragS
* frag
)
1194 /* If handling an alignment frag, use an optimal NOP pattern.
1195 Only do this if a fill value has not already been provided.
1196 FIXME: This test fails if the provided fill value is zero. */
1197 if ((frag
->fr_type
== rs_align
1198 || frag
->fr_type
== rs_align_code
)
1199 && subseg_text_p (now_seg
))
1201 int count
= (frag
->fr_next
->fr_address
1204 unsigned char *base
= (unsigned char *)frag
->fr_literal
+ frag
->fr_fix
;
1208 if (count
> BIGGEST_NOP
)
1216 memcpy (base
, nops
[count
], count
);
1217 frag
->fr_var
= count
;
1223 && (frag
->fr_type
== rs_align
1224 || frag
->fr_type
== rs_align_code
)
1225 && frag
->fr_address
+ frag
->fr_fix
> 0
1226 && frag
->fr_offset
> 0
1227 && now_seg
!= bss_section
)
1229 fix_new (frag
, frag
->fr_fix
, 0,
1230 &abs_symbol
, RX_RELAXA_ALIGN
+ frag
->fr_offset
,
1231 0, BFD_RELOC_RX_RELAX
);
1232 /* For the purposes of relaxation, this relocation is attached
1233 to the byte *after* the alignment - i.e. the byte that must
1235 fix_new (frag
->fr_next
, 0, 0,
1236 &abs_symbol
, RX_RELAXA_ELIGN
+ frag
->fr_offset
,
1237 0, BFD_RELOC_RX_RELAX
);
1242 md_atof (int type
, char * litP
, int * sizeP
)
1244 return ieee_md_atof (type
, litP
, sizeP
, target_big_endian
);
1248 md_undefined_symbol (char * name ATTRIBUTE_UNUSED
)
1253 /*----------------------------------------------------------------------*/
1254 /* To recap: we estimate everything based on md_estimate_size, then
1255 adjust based on rx_relax_frag. When it all settles, we call
1256 md_convert frag to update the bytes. The relaxation types and
1257 relocations are in fragP->tc_frag_data, which is a copy of that
1260 Our scheme is as follows: fr_fix has the size of the smallest
1261 opcode (like BRA.S). We store the number of total bytes we need in
1262 fr_subtype. When we're done relaxing, we use fr_subtype and the
1263 existing opcode bytes to figure out what actual opcode we need to
1264 put in there. If the fixup isn't resolvable now, we use the
1267 #define TRACE_RELAX 0
1268 #define tprintf if (TRACE_RELAX) printf
1280 /* We're looking for these types of relaxations:
1283 BRA.B 00101110 dspppppp
1284 BRA.W 00111000 dspppppp pppppppp
1285 BRA.A 00000100 dspppppp pppppppp pppppppp
1288 BEQ.B 00100000 dspppppp
1289 BEQ.W 00111010 dspppppp pppppppp
1292 BNE.B 00100001 dspppppp
1293 BNE.W 00111011 dspppppp pppppppp
1295 BSR.W 00111001 dspppppp pppppppp
1296 BSR.A 00000101 dspppppp pppppppp pppppppp
1298 Bcc.B 0010cond dspppppp
1300 Additionally, we can synthesize longer conditional branches using
1301 pairs of opcodes, one with an inverted conditional (flip LSB):
1303 Bcc.W 0010ncnd 00000110 00111000 dspppppp pppppppp
1304 Bcc.A 0010ncnd 00000111 00000100 dspppppp pppppppp pppppppp
1305 BEQ.A 00011100 00000100 dspppppp pppppppp pppppppp
1306 BNE.A 00010100 00000100 dspppppp pppppppp pppppppp */
1308 /* Given the opcode bytes at OP, figure out which opcode it is and
1309 return the type of opcode. We use this to re-encode the opcode as
1310 a different size later. */
1313 rx_opcode_type (char * op
)
1315 unsigned char b
= (unsigned char) op
[0];
1319 case 0x08: return OT_bra
;
1320 case 0x10: return OT_beq
;
1321 case 0x18: return OT_bne
;
1326 case 0x2e: return OT_bra
;
1327 case 0x38: return OT_bra
;
1328 case 0x04: return OT_bra
;
1330 case 0x20: return OT_beq
;
1331 case 0x3a: return OT_beq
;
1333 case 0x21: return OT_bne
;
1334 case 0x3b: return OT_bne
;
1336 case 0x39: return OT_bsr
;
1337 case 0x05: return OT_bsr
;
1340 if ((b
& 0xf0) == 0x20)
1346 /* Returns zero if *addrP has the target address. Else returns nonzero
1347 if we cannot compute the target address yet. */
1350 rx_frag_fix_value (fragS
* fragP
,
1355 addressT
* sym_addr
)
1358 rx_bytesT
* b
= fragP
->tc_frag_data
;
1359 expressionS
* exp
= & b
->fixups
[which
].exp
;
1361 if (need_diff
&& exp
->X_op
!= O_subtract
)
1364 if (exp
->X_add_symbol
)
1366 if (S_FORCE_RELOC (exp
->X_add_symbol
, 1))
1368 if (S_GET_SEGMENT (exp
->X_add_symbol
) != segment
)
1370 addr
+= S_GET_VALUE (exp
->X_add_symbol
);
1373 if (exp
->X_op_symbol
)
1375 if (exp
->X_op
!= O_subtract
)
1377 if (S_FORCE_RELOC (exp
->X_op_symbol
, 1))
1379 if (S_GET_SEGMENT (exp
->X_op_symbol
) != segment
)
1381 addr
-= S_GET_VALUE (exp
->X_op_symbol
);
1385 addr
+= exp
->X_add_number
;
1390 /* Estimate how big the opcode is after this relax pass. The return
1391 value is the difference between fr_fix and the actual size. We
1392 compute the total size in rx_relax_frag and store it in fr_subtype,
1393 sowe only need to subtract fx_fix and return it. */
1396 md_estimate_size_before_relax (fragS
* fragP ATTRIBUTE_UNUSED
, segT segment ATTRIBUTE_UNUSED
)
1401 tprintf ("\033[32m est frag: addr %08lx fix %ld var %ld ofs %ld lit %p opc %p type %d sub %d\033[0m\n",
1402 (unsigned long) (fragP
->fr_address
1403 + (fragP
->fr_opcode
- fragP
->fr_literal
)),
1404 (long) fragP
->fr_fix
, (long) fragP
->fr_var
, (long) fragP
->fr_offset
,
1405 fragP
->fr_literal
, fragP
->fr_opcode
, fragP
->fr_type
, fragP
->fr_subtype
);
1407 /* This is the size of the opcode that's accounted for in fr_fix. */
1408 opfixsize
= fragP
->fr_fix
- (fragP
->fr_opcode
- fragP
->fr_literal
);
1409 /* This is the size of the opcode that isn't. */
1410 delta
= (fragP
->fr_subtype
- opfixsize
);
1412 tprintf (" -> opfixsize %d delta %d\n", opfixsize
, delta
);
1416 /* Given the new addresses for this relax pass, figure out how big
1417 each opcode must be. We store the total number of bytes needed in
1418 fr_subtype. The return value is the difference between the size
1419 after the last pass and the size after this pass, so we use the old
1420 fr_subtype to calculate the difference. */
1423 rx_relax_frag (segT segment ATTRIBUTE_UNUSED
, fragS
* fragP
, long stretch
)
1425 addressT addr0
, sym_addr
;
1428 int oldsize
= fragP
->fr_subtype
;
1429 int newsize
= oldsize
;
1431 /* Index of relaxation we care about. */
1434 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",
1435 (unsigned long) (fragP
->fr_address
1436 + (fragP
->fr_opcode
- fragP
->fr_literal
)),
1437 (long) fragP
->fr_fix
, (long) fragP
->fr_var
, (long) fragP
->fr_offset
,
1438 fragP
->fr_literal
, fragP
->fr_opcode
, fragP
->fr_type
, fragP
->fr_subtype
, stretch
);
1440 optype
= rx_opcode_type (fragP
->fr_opcode
);
1442 /* In the one case where we have both a disp and imm relaxation, we want
1443 the imm relaxation here. */
1445 if (fragP
->tc_frag_data
->n_relax
> 1
1446 && fragP
->tc_frag_data
->relax
[0].type
== RX_RELAX_DISP
)
1449 /* Try to get the target address. */
1450 if (rx_frag_fix_value (fragP
, segment
, ri
, & addr0
,
1451 fragP
->tc_frag_data
->relax
[ri
].type
!= RX_RELAX_BRANCH
,
1454 /* If we don't, we must use the maximum size for the linker.
1455 Note that we don't use synthetically expanded conditionals
1457 switch (fragP
->tc_frag_data
->relax
[ri
].type
)
1459 case RX_RELAX_BRANCH
:
1480 newsize
= fragP
->tc_frag_data
->relax
[ri
].val_ofs
+ 4;
1483 fragP
->fr_subtype
= newsize
;
1484 tprintf (" -> new %d old %d delta %d (external)\n", newsize
, oldsize
, newsize
-oldsize
);
1485 return newsize
- oldsize
;
1488 mypc
= fragP
->fr_address
+ (fragP
->fr_opcode
- fragP
->fr_literal
);
1489 if (sym_addr
> mypc
)
1492 switch (fragP
->tc_frag_data
->relax
[ri
].type
)
1494 case RX_RELAX_BRANCH
:
1495 tprintf ("branch, addr %08lx pc %08lx disp %ld\n",
1496 (unsigned long) addr0
, (unsigned long) mypc
,
1497 (long) (addr0
- mypc
));
1498 disp
= (int) addr0
- (int) mypc
;
1503 if (disp
>= -128 && (disp
- (oldsize
-2)) <= 127)
1506 else if (disp
>= -32768 && (disp
- (oldsize
-5)) <= 32767)
1516 if ((disp
- (oldsize
-1)) >= 3 && (disp
- (oldsize
-1)) <= 10 && !linkrelax
)
1519 else if (disp
>= -128 && (disp
- (oldsize
-2)) <= 127)
1522 else if (disp
>= -32768 && (disp
- (oldsize
-3)) <= 32767)
1532 if ((disp
- (oldsize
-1)) >= 3 && (disp
- (oldsize
-1)) <= 10 && !linkrelax
)
1535 else if (disp
>= -128 && (disp
- (oldsize
-2)) <= 127)
1538 else if (disp
>= -32768 && (disp
- (oldsize
-3)) <= 32767)
1549 tprintf (" - newsize %d\n", newsize
);
1553 tprintf ("other, addr %08lx pc %08lx LI %d OF %d\n",
1554 (unsigned long) addr0
, (unsigned long) mypc
,
1555 fragP
->tc_frag_data
->relax
[ri
].field_pos
,
1556 fragP
->tc_frag_data
->relax
[ri
].val_ofs
);
1558 newsize
= fragP
->tc_frag_data
->relax
[ri
].val_ofs
;
1560 if ((long) addr0
>= -128 && (long) addr0
<= 127)
1562 else if ((long) addr0
>= -32768 && (long) addr0
<= 32767)
1564 else if ((long) addr0
>= -8388608 && (long) addr0
<= 8388607)
1574 if (fragP
->tc_frag_data
->relax
[ri
].type
== RX_RELAX_BRANCH
)
1590 /* This prevents infinite loops in align-heavy sources. */
1591 if (newsize
< oldsize
)
1593 if (fragP
->tc_frag_data
->times_shrank
> 10
1594 && fragP
->tc_frag_data
->times_grown
> 10)
1596 if (fragP
->tc_frag_data
->times_shrank
< 20)
1597 fragP
->tc_frag_data
->times_shrank
++;
1599 else if (newsize
> oldsize
)
1601 if (fragP
->tc_frag_data
->times_grown
< 20)
1602 fragP
->tc_frag_data
->times_grown
++;
1605 fragP
->fr_subtype
= newsize
;
1606 tprintf (" -> new %d old %d delta %d\n", newsize
, oldsize
, newsize
-oldsize
);
1607 return newsize
- oldsize
;
1610 /* This lets us test for the opcode type and the desired size in a
1611 switch statement. */
1612 #define OPCODE(type,size) ((type) * 16 + (size))
1614 /* Given the opcode stored in fr_opcode and the number of bytes we
1615 think we need, encode a new opcode. We stored a pointer to the
1616 fixup for this opcode in the tc_frag_data structure. If we can do
1617 the fixup here, we change the relocation type to "none" (we test
1618 for that in tc_gen_reloc) else we change it to the right type for
1619 the new (biggest) opcode. */
1622 md_convert_frag (bfd
* abfd ATTRIBUTE_UNUSED
,
1623 segT segment ATTRIBUTE_UNUSED
,
1624 fragS
* fragP ATTRIBUTE_UNUSED
)
1626 rx_bytesT
* rxb
= fragP
->tc_frag_data
;
1627 addressT addr0
, mypc
;
1629 int reloc_type
, reloc_adjust
;
1630 char * op
= fragP
->fr_opcode
;
1633 int fi
= (rxb
->n_fixups
> 1) ? 1 : 0;
1634 fixS
* fix
= rxb
->fixups
[fi
].fixP
;
1636 tprintf ("\033[31mconvrt frag: addr %08lx fix %ld var %ld ofs %ld lit %p opc %p type %d sub %d\033[0m\n",
1637 (unsigned long) (fragP
->fr_address
1638 + (fragP
->fr_opcode
- fragP
->fr_literal
)),
1639 (long) fragP
->fr_fix
, (long) fragP
->fr_var
, (long) fragP
->fr_offset
,
1640 fragP
->fr_literal
, fragP
->fr_opcode
, fragP
->fr_type
,
1647 printf ("lit %08x opc %08x", (int) fragP
->fr_literal
, (int) fragP
->fr_opcode
);
1648 for (i
= 0; i
< 10; i
++)
1649 printf (" %02x", (unsigned char) (fragP
->fr_opcode
[i
]));
1654 /* In the one case where we have both a disp and imm relaxation, we want
1655 the imm relaxation here. */
1657 if (fragP
->tc_frag_data
->n_relax
> 1
1658 && fragP
->tc_frag_data
->relax
[0].type
== RX_RELAX_DISP
)
1661 /* We used a new frag for this opcode, so the opcode address should
1662 be the frag address. */
1663 mypc
= fragP
->fr_address
+ (fragP
->fr_opcode
- fragP
->fr_literal
);
1665 /* Try to get the target address. If we fail here, we just use the
1667 if (rx_frag_fix_value (fragP
, segment
, 0, & addr0
,
1668 fragP
->tc_frag_data
->relax
[ri
].type
!= RX_RELAX_BRANCH
, 0))
1670 /* We don't know the target address. */
1677 /* We know the target address, and it's in addr0. */
1678 disp
= (int) addr0
- (int) mypc
;
1684 reloc_type
= BFD_RELOC_NONE
;
1687 tprintf ("convert, op is %d, disp %d (%lx-%lx)\n",
1688 rx_opcode_type (fragP
->fr_opcode
), disp
,
1689 (unsigned long) addr0
, (unsigned long) mypc
);
1690 switch (fragP
->tc_frag_data
->relax
[ri
].type
)
1692 case RX_RELAX_BRANCH
:
1693 switch (OPCODE (rx_opcode_type (fragP
->fr_opcode
), fragP
->fr_subtype
))
1695 case OPCODE (OT_bra
, 1): /* BRA.S - no change. */
1696 op
[0] = 0x08 + (disp
& 7);
1698 case OPCODE (OT_bra
, 2): /* BRA.B - 8 bit. */
1701 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1704 case OPCODE (OT_bra
, 3): /* BRA.W - 16 bit. */
1706 #if RX_OPCODE_BIG_ENDIAN
1707 op
[1] = (disp
>> 8) & 0xff;
1710 op
[2] = (disp
>> 8) & 0xff;
1714 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1716 case OPCODE (OT_bra
, 4): /* BRA.A - 24 bit. */
1718 #if RX_OPCODE_BIG_ENDIAN
1719 op
[1] = (disp
>> 16) & 0xff;
1720 op
[2] = (disp
>> 8) & 0xff;
1723 op
[3] = (disp
>> 16) & 0xff;
1724 op
[2] = (disp
>> 8) & 0xff;
1727 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1731 case OPCODE (OT_beq
, 1): /* BEQ.S - no change. */
1732 op
[0] = 0x10 + (disp
& 7);
1734 case OPCODE (OT_beq
, 2): /* BEQ.B - 8 bit. */
1738 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1740 case OPCODE (OT_beq
, 3): /* BEQ.W - 16 bit. */
1742 #if RX_OPCODE_BIG_ENDIAN
1743 op
[1] = (disp
>> 8) & 0xff;
1746 op
[2] = (disp
>> 8) & 0xff;
1749 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1752 case OPCODE (OT_beq
, 5): /* BEQ.A - synthetic. */
1753 op
[0] = 0x1d; /* bne.s .+5. */
1754 op
[1] = 0x04; /* bra.a dsp:24. */
1756 #if RX_OPCODE_BIG_ENDIAN
1757 op
[2] = (disp
>> 16) & 0xff;
1758 op
[3] = (disp
>> 8) & 0xff;
1761 op
[4] = (disp
>> 16) & 0xff;
1762 op
[3] = (disp
>> 8) & 0xff;
1765 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1769 case OPCODE (OT_bne
, 1): /* BNE.S - no change. */
1770 op
[0] = 0x18 + (disp
& 7);
1772 case OPCODE (OT_bne
, 2): /* BNE.B - 8 bit. */
1776 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1778 case OPCODE (OT_bne
, 3): /* BNE.W - 16 bit. */
1780 #if RX_OPCODE_BIG_ENDIAN
1781 op
[1] = (disp
>> 8) & 0xff;
1784 op
[2] = (disp
>> 8) & 0xff;
1787 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1790 case OPCODE (OT_bne
, 5): /* BNE.A - synthetic. */
1791 op
[0] = 0x15; /* beq.s .+5. */
1792 op
[1] = 0x04; /* bra.a dsp:24. */
1794 #if RX_OPCODE_BIG_ENDIAN
1795 op
[2] = (disp
>> 16) & 0xff;
1796 op
[3] = (disp
>> 8) & 0xff;
1799 op
[4] = (disp
>> 16) & 0xff;
1800 op
[3] = (disp
>> 8) & 0xff;
1803 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1807 case OPCODE (OT_bsr
, 3): /* BSR.W - 16 bit. */
1809 #if RX_OPCODE_BIG_ENDIAN
1810 op
[1] = (disp
>> 8) & 0xff;
1813 op
[2] = (disp
>> 8) & 0xff;
1816 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1819 case OPCODE (OT_bsr
, 4): /* BSR.A - 24 bit. */
1821 #if RX_OPCODE_BIG_ENDIAN
1822 op
[1] = (disp
>> 16) & 0xff;
1823 op
[2] = (disp
>> 8) & 0xff;
1826 op
[3] = (disp
>> 16) & 0xff;
1827 op
[2] = (disp
>> 8) & 0xff;
1830 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1834 case OPCODE (OT_bcc
, 2): /* Bcond.B - 8 bit. */
1836 reloc_type
= keep_reloc
? BFD_RELOC_8_PCREL
: BFD_RELOC_NONE
;
1838 case OPCODE (OT_bcc
, 5): /* Bcond.W - synthetic. */
1839 op
[0] ^= 1; /* Invert condition. */
1840 op
[1] = 5; /* Displacement. */
1843 #if RX_OPCODE_BIG_ENDIAN
1844 op
[3] = (disp
>> 8) & 0xff;
1847 op
[4] = (disp
>> 8) & 0xff;
1850 reloc_type
= keep_reloc
? BFD_RELOC_16_PCREL
: BFD_RELOC_NONE
;
1853 case OPCODE (OT_bcc
, 6): /* Bcond.S - synthetic. */
1854 op
[0] ^= 1; /* Invert condition. */
1855 op
[1] = 6; /* Displacement. */
1858 #if RX_OPCODE_BIG_ENDIAN
1859 op
[3] = (disp
>> 16) & 0xff;
1860 op
[4] = (disp
>> 8) & 0xff;
1863 op
[5] = (disp
>> 16) & 0xff;
1864 op
[4] = (disp
>> 8) & 0xff;
1867 reloc_type
= keep_reloc
? BFD_RELOC_24_PCREL
: BFD_RELOC_NONE
;
1872 /* These are opcodes we'll relax in th linker, later. */
1874 reloc_type
= rxb
->fixups
[ri
].fixP
->fx_r_type
;
1881 int nbytes
= fragP
->fr_subtype
- fragP
->tc_frag_data
->relax
[ri
].val_ofs
;
1883 char * imm
= op
+ fragP
->tc_frag_data
->relax
[ri
].val_ofs
;
1890 reloc_type
= BFD_RELOC_8
;
1894 #if RX_OPCODE_BIG_ENDIAN
1896 imm
[0] = addr0
>> 8;
1899 imm
[1] = addr0
>> 8;
1901 reloc_type
= BFD_RELOC_RX_16_OP
;
1905 #if RX_OPCODE_BIG_ENDIAN
1907 imm
[1] = addr0
>> 8;
1908 imm
[0] = addr0
>> 16;
1911 imm
[1] = addr0
>> 8;
1912 imm
[2] = addr0
>> 16;
1914 reloc_type
= BFD_RELOC_RX_24_OP
;
1918 #if RX_OPCODE_BIG_ENDIAN
1920 imm
[2] = addr0
>> 8;
1921 imm
[1] = addr0
>> 16;
1922 imm
[0] = addr0
>> 24;
1925 imm
[1] = addr0
>> 8;
1926 imm
[2] = addr0
>> 16;
1927 imm
[3] = addr0
>> 24;
1929 reloc_type
= BFD_RELOC_RX_32_OP
;
1932 as_bad (_("invalid immediate size"));
1936 switch (fragP
->tc_frag_data
->relax
[ri
].field_pos
)
1951 as_bad (_("invalid immediate field position"));
1959 reloc_type
= fix
->fx_r_type
;
1968 fix
->fx_r_type
= reloc_type
;
1969 fix
->fx_where
+= reloc_adjust
;
1972 case BFD_RELOC_NONE
:
1978 case BFD_RELOC_16_PCREL
:
1979 case BFD_RELOC_RX_16_OP
:
1982 case BFD_RELOC_24_PCREL
:
1983 case BFD_RELOC_RX_24_OP
:
1986 case BFD_RELOC_RX_32_OP
:
1992 fragP
->fr_fix
= fragP
->fr_subtype
+ (fragP
->fr_opcode
- fragP
->fr_literal
);
1993 tprintf ("fragP->fr_fix now %ld (%d + (%p - %p)\n", (long) fragP
->fr_fix
,
1994 fragP
->fr_subtype
, fragP
->fr_opcode
, fragP
->fr_literal
);
1997 if (fragP
->fr_next
!= NULL
1998 && ((offsetT
) (fragP
->fr_next
->fr_address
- fragP
->fr_address
)
2000 as_bad (_("bad frag at %p : fix %ld addr %ld %ld \n"), fragP
,
2001 (long) fragP
->fr_fix
,
2002 (long) fragP
->fr_address
, (long) fragP
->fr_next
->fr_address
);
2008 rx_validate_fix_sub (struct fix
* f
)
2010 /* We permit the subtraction of two symbols in a few cases. */
2011 /* mov #sym1-sym2, R3 */
2012 if (f
->fx_r_type
== BFD_RELOC_RX_32_OP
)
2014 /* .long sym1-sym2 */
2015 if (f
->fx_r_type
== BFD_RELOC_RX_DIFF
2017 && (f
->fx_size
== 4 || f
->fx_size
== 2 || f
->fx_size
== 1))
2023 md_pcrel_from_section (fixS
* fixP
, segT sec
)
2027 if (fixP
->fx_addsy
!= NULL
2028 && (! S_IS_DEFINED (fixP
->fx_addsy
)
2029 || S_GET_SEGMENT (fixP
->fx_addsy
) != sec
))
2030 /* The symbol is undefined (or is defined but not in this section).
2031 Let the linker figure it out. */
2034 rv
= fixP
->fx_frag
->fr_address
+ fixP
->fx_where
;
2035 switch (fixP
->fx_r_type
)
2037 case BFD_RELOC_RX_DIR3U_PCREL
:
2045 rx_cons_fix_new (fragS
* frag
,
2050 bfd_reloc_code_real_type type
;
2058 type
= BFD_RELOC_16
;
2061 type
= BFD_RELOC_24
;
2064 type
= BFD_RELOC_32
;
2067 as_bad (_("unsupported constant size %d\n"), size
);
2071 if (exp
->X_op
== O_subtract
&& exp
->X_op_symbol
)
2073 if (size
!= 4 && size
!= 2 && size
!= 1)
2074 as_bad (_("difference of two symbols only supported with .long, .short, or .byte"));
2076 type
= BFD_RELOC_RX_DIFF
;
2079 fix_new_exp (frag
, where
, (int) size
, exp
, 0, type
);
2083 md_apply_fix (struct fix
* f ATTRIBUTE_UNUSED
,
2084 valueT
* t ATTRIBUTE_UNUSED
,
2085 segT s ATTRIBUTE_UNUSED
)
2087 /* Instruction bytes are always little endian. */
2091 if (f
->fx_addsy
&& S_FORCE_RELOC (f
->fx_addsy
, 1))
2093 if (f
->fx_subsy
&& S_FORCE_RELOC (f
->fx_subsy
, 1))
2096 #define OP2(x) op[target_big_endian ? 1-x : x]
2097 #define OP3(x) op[target_big_endian ? 2-x : x]
2098 #define OP4(x) op[target_big_endian ? 3-x : x]
2100 op
= f
->fx_frag
->fr_literal
+ f
->fx_where
;
2101 val
= (unsigned long) * t
;
2103 /* Opcode words are always the same endian. Data words are either
2104 big or little endian. */
2106 switch (f
->fx_r_type
)
2108 case BFD_RELOC_NONE
:
2111 case BFD_RELOC_RX_RELAX
:
2115 case BFD_RELOC_RX_DIR3U_PCREL
:
2116 if (val
< 3 || val
> 10)
2117 as_bad_where (f
->fx_file
, f
->fx_line
,
2118 _("jump not 3..10 bytes away (is %d)"), (int) val
);
2120 op
[0] |= val
& 0x07;
2124 case BFD_RELOC_8_PCREL
:
2125 case BFD_RELOC_RX_8U
:
2130 OP2(1) = val
& 0xff;
2131 OP2(0) = (val
>> 8) & 0xff;
2134 case BFD_RELOC_16_PCREL
:
2135 case BFD_RELOC_RX_16_OP
:
2136 case BFD_RELOC_RX_16U
:
2137 #if RX_OPCODE_BIG_ENDIAN
2139 op
[0] = (val
>> 8) & 0xff;
2142 op
[1] = (val
>> 8) & 0xff;
2147 OP3(0) = val
& 0xff;
2148 OP3(1) = (val
>> 8) & 0xff;
2149 OP3(2) = (val
>> 16) & 0xff;
2152 case BFD_RELOC_24_PCREL
:
2153 case BFD_RELOC_RX_24_OP
:
2154 case BFD_RELOC_RX_24U
:
2155 #if RX_OPCODE_BIG_ENDIAN
2157 op
[1] = (val
>> 8) & 0xff;
2158 op
[0] = (val
>> 16) & 0xff;
2161 op
[1] = (val
>> 8) & 0xff;
2162 op
[2] = (val
>> 16) & 0xff;
2166 case BFD_RELOC_RX_DIFF
:
2173 OP2(0) = val
& 0xff;
2174 OP2(1) = (val
>> 8) & 0xff;
2177 OP4(0) = val
& 0xff;
2178 OP4(1) = (val
>> 8) & 0xff;
2179 OP4(2) = (val
>> 16) & 0xff;
2180 OP4(3) = (val
>> 24) & 0xff;
2186 OP4(0) = val
& 0xff;
2187 OP4(1) = (val
>> 8) & 0xff;
2188 OP4(2) = (val
>> 16) & 0xff;
2189 OP4(3) = (val
>> 24) & 0xff;
2192 case BFD_RELOC_RX_32_OP
:
2193 #if RX_OPCODE_BIG_ENDIAN
2195 op
[2] = (val
>> 8) & 0xff;
2196 op
[1] = (val
>> 16) & 0xff;
2197 op
[0] = (val
>> 24) & 0xff;
2200 op
[1] = (val
>> 8) & 0xff;
2201 op
[2] = (val
>> 16) & 0xff;
2202 op
[3] = (val
>> 24) & 0xff;
2206 case BFD_RELOC_RX_NEG8
:
2210 case BFD_RELOC_RX_NEG16
:
2212 #if RX_OPCODE_BIG_ENDIAN
2214 op
[0] = (val
>> 8) & 0xff;
2217 op
[1] = (val
>> 8) & 0xff;
2221 case BFD_RELOC_RX_NEG24
:
2223 #if RX_OPCODE_BIG_ENDIAN
2225 op
[1] = (val
>> 8) & 0xff;
2226 op
[0] = (val
>> 16) & 0xff;
2229 op
[1] = (val
>> 8) & 0xff;
2230 op
[2] = (val
>> 16) & 0xff;
2234 case BFD_RELOC_RX_NEG32
:
2236 #if RX_OPCODE_BIG_ENDIAN
2238 op
[2] = (val
>> 8) & 0xff;
2239 op
[1] = (val
>> 16) & 0xff;
2240 op
[0] = (val
>> 24) & 0xff;
2243 op
[1] = (val
>> 8) & 0xff;
2244 op
[2] = (val
>> 16) & 0xff;
2245 op
[3] = (val
>> 24) & 0xff;
2249 case BFD_RELOC_RX_GPRELL
:
2251 case BFD_RELOC_RX_GPRELW
:
2253 case BFD_RELOC_RX_GPRELB
:
2254 #if RX_OPCODE_BIG_ENDIAN
2256 op
[0] = (val
>> 8) & 0xff;
2259 op
[1] = (val
>> 8) & 0xff;
2264 as_bad (_("Unknown reloc in md_apply_fix: %s"),
2265 bfd_get_reloc_code_name (f
->fx_r_type
));
2269 if (f
->fx_addsy
== NULL
)
2274 tc_gen_reloc (asection
* sec ATTRIBUTE_UNUSED
, fixS
* fixp
)
2276 static arelent
* reloc
[5];
2277 bfd_boolean is_opcode
= FALSE
;
2279 if (fixp
->fx_r_type
== BFD_RELOC_NONE
)
2286 && S_GET_SEGMENT (fixp
->fx_subsy
) == absolute_section
)
2288 fixp
->fx_offset
-= S_GET_VALUE (fixp
->fx_subsy
);
2289 fixp
->fx_subsy
= NULL
;
2292 reloc
[0] = (arelent
*) xmalloc (sizeof (arelent
));
2293 reloc
[0]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2294 * reloc
[0]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
2295 reloc
[0]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2296 reloc
[0]->addend
= fixp
->fx_offset
;
2298 if (fixp
->fx_r_type
== BFD_RELOC_RX_32_OP
2301 fixp
->fx_r_type
= BFD_RELOC_RX_DIFF
;
2305 is_opcode
= sec
->flags
& SEC_CODE
;
2307 /* Certain BFD relocations cannot be translated directly into
2308 a single (non-Red Hat) RX relocation, but instead need
2309 multiple RX relocations - handle them here. */
2310 switch (fixp
->fx_r_type
)
2312 case BFD_RELOC_RX_DIFF
:
2313 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2315 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2316 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2317 * reloc
[1]->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_subsy
);
2318 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2319 reloc
[1]->addend
= 0;
2320 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2322 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2323 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2324 reloc
[2]->addend
= 0;
2325 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2326 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2328 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2329 switch (fixp
->fx_size
)
2332 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS8
);
2335 if (!is_opcode
&& target_big_endian
)
2336 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16_REV
);
2338 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16UL
);
2340 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16
);
2343 if (!is_opcode
&& target_big_endian
)
2344 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS32_REV
);
2346 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS32
);
2349 reloc
[3]->addend
= 0;
2350 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2351 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2356 case BFD_RELOC_RX_GPRELL
:
2357 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2359 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2360 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2361 if (gp_symbol
== NULL
)
2363 if (symbol_table_frozen
)
2367 gp
= symbol_find ("__gp");
2369 as_bad (("unable to create __gp symbol: please re-assemble with the -msmall-data-limit option specified"));
2371 gp_symbol
= symbol_get_bfdsym (gp
);
2374 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
2376 * reloc
[1]->sym_ptr_ptr
= gp_symbol
;
2377 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2378 reloc
[1]->addend
= 0;
2379 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2381 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2382 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2383 reloc
[2]->addend
= 0;
2384 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2385 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2387 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2388 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16UL
);
2389 reloc
[3]->addend
= 0;
2390 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2391 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2396 case BFD_RELOC_RX_GPRELW
:
2397 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2399 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2400 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2401 if (gp_symbol
== NULL
)
2403 if (symbol_table_frozen
)
2407 gp
= symbol_find ("__gp");
2409 as_bad (("unable to create __gp symbol: please re-assemble with the -msmall-data-limit option specified"));
2411 gp_symbol
= symbol_get_bfdsym (gp
);
2414 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
2416 * reloc
[1]->sym_ptr_ptr
= gp_symbol
;
2417 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2418 reloc
[1]->addend
= 0;
2419 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2421 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2422 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2423 reloc
[2]->addend
= 0;
2424 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2425 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2427 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2428 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16UW
);
2429 reloc
[3]->addend
= 0;
2430 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2431 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2436 case BFD_RELOC_RX_GPRELB
:
2437 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2439 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2440 reloc
[1]->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
2441 if (gp_symbol
== NULL
)
2443 if (symbol_table_frozen
)
2447 gp
= symbol_find ("__gp");
2449 as_bad (("unable to create __gp symbol: please re-assemble with the -msmall-data-limit option specified"));
2451 gp_symbol
= symbol_get_bfdsym (gp
);
2454 gp_symbol
= symbol_get_bfdsym (symbol_find_or_make ("__gp"));
2456 * reloc
[1]->sym_ptr_ptr
= gp_symbol
;
2457 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2458 reloc
[1]->addend
= 0;
2459 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2461 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2462 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_SUBTRACT
);
2463 reloc
[2]->addend
= 0;
2464 reloc
[2]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2465 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2467 reloc
[3] = (arelent
*) xmalloc (sizeof (arelent
));
2468 reloc
[3]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS16U
);
2469 reloc
[3]->addend
= 0;
2470 reloc
[3]->sym_ptr_ptr
= reloc
[1]->sym_ptr_ptr
;
2471 reloc
[3]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2476 case BFD_RELOC_RX_NEG32
:
2477 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_SYM
);
2479 reloc
[1] = (arelent
*) xmalloc (sizeof (arelent
));
2480 reloc
[1]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_OP_NEG
);
2481 reloc
[1]->addend
= 0;
2482 reloc
[1]->sym_ptr_ptr
= reloc
[0]->sym_ptr_ptr
;
2483 reloc
[1]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2485 reloc
[2] = (arelent
*) xmalloc (sizeof (arelent
));
2486 reloc
[2]->howto
= bfd_reloc_type_lookup (stdoutput
, BFD_RELOC_RX_ABS32
);
2487 reloc
[2]->addend
= 0;
2488 reloc
[2]->sym_ptr_ptr
= reloc
[0]->sym_ptr_ptr
;
2489 reloc
[2]->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
2495 reloc
[0]->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
2503 /* Set the ELF specific flags. */
2506 rx_elf_final_processing (void)
2508 elf_elfheader (stdoutput
)->e_flags
|= elf_flags
;
2511 /* Scan the current input line for occurances of Renesas
2512 local labels and replace them with the GAS version. */
2515 rx_start_line (void)
2517 int in_double_quote
= 0;
2518 int in_single_quote
= 0;
2520 char * p
= input_line_pointer
;
2522 /* Scan the line looking for question marks. Skip past quote enclosed regions. */
2533 in_double_quote
= ! in_double_quote
;
2537 in_single_quote
= ! in_single_quote
;
2541 if (in_double_quote
|| in_single_quote
)
2546 else if (p
[1] == '+')
2551 else if (p
[1] == '-')