1 /* tc-sh64.c -- Assemble code for the SuperH SH SHcompact and SHmedia.
2 Copyright 2000, 2001, 2002, 2003 Free Software Foundation.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* This file defines SHmedia ISA-specific functions and includes tc-sh.c.
22 The SHcompact ISA is in all useful aspects the "old" sh4 as implemented
23 in tc-sh.c. Not making this file part of tc-sh.c makes it easier to
24 keep a leaner sh[1-4]-only implementation. */
30 #include "safe-ctype.h"
31 #include "opcodes/sh64-opc.h"
34 #error This file assumes object output is in the ELF format
37 /* Suffix used when we make "datalabel" symbol copies. It must not
38 collide with anything that can normally appear in a symbol, "faked
39 symbol" or local symbol. */
40 #define DATALABEL_SUFFIX " DL"
42 /* See shmedia_md_apply_fix3 and shmedia_md_pcrel_from_section for usage. */
43 #define SHMEDIA_MD_PCREL_FROM_FIX(FIXP) \
44 ((FIXP)->fx_size + (FIXP)->fx_where + (FIXP)->fx_frag->fr_address - 4)
46 /* We use this internally to see which one is PT and which is a PTA/PTB
47 that should be error-checked. We give it a better name here (but not
48 one that looks official). Adding it to reloc.c would make it look too
49 much of a real reloc; it is just used temporarily as a fixup-type. */
50 #define SHMEDIA_BFD_RELOC_PT BFD_RELOC_12_PCREL
54 shmedia_arg_type type
;
56 /* These could go into a union, but that would uglify the code. */
58 expressionS immediate
;
60 /* If IMMEDIATE was a shift-expression, like "(S >> N) & 65535", where
61 N = 0, 16, 32, 48, used to extract a certain 16-bit-field to make up
62 a MOVI or SHORI relocation for a symbol, then we put the
63 corresponding reloc-type here and modify the "immediate" expression
64 to S. Otherwise, this is just BFD_RELOC_NONE. */
65 bfd_reloc_code_real_type reloctype
;
66 } shmedia_operand_info
;
68 /* Frag containing last base instruction. This is put in the TC field in
69 a frag, so we can emit fixups for fr_opcode without needing to make
70 sure that the opcode is in the same frag as any variant operand. */
71 fragS
*sh64_last_insn_frag
= NULL
;
75 shmedia_operand_info operands
[3];
76 unsigned long ops_val
;
77 } shmedia_operands_info
;
80 { sh64_abi_unspecified
, sh64_abi_32
, sh64_abi_64
};
82 /* What ISA are we assembling code for? */
83 enum sh64_isa_values sh64_isa_mode
= sh64_isa_unspecified
;
85 /* What ABI was specified, if any (implicitly or explicitly)? */
86 static enum sh64_abi_values sh64_abi
= sh64_abi_unspecified
;
88 /* A note that says if we're in a sequence of insns without label
89 settings, segment or ISA mode changes or emitted data. */
90 static bfd_boolean seen_insn
= FALSE
;
92 /* This is set to TRUE in shmedia_md_end, so that we don't emit any
93 .cranges entries when the assembler calls output functions while
94 grinding along after all input is seen. */
95 static bfd_boolean sh64_end_of_assembly
= FALSE
;
97 /* Controlled by the option -no-mix, this invalidates mixing SHcompact and
98 SHmedia code in the same section, and also invalidates mixing data and
99 SHmedia code in the same section. No .cranges will therefore be
100 emitted, unless -shcompact-const-crange is specified and there is a
101 constant pool in SHcompact code. */
102 static bfd_boolean sh64_mix
= TRUE
;
104 static bfd_boolean sh64_shcompact_const_crange
= FALSE
;
106 /* Controlled by the option -no-expand, this says whether or not we expand
107 MOVI and PT/PTA/PTB. When we do not expand these insns to fit an
108 operand, we will emit errors for operands out of range and generate the
109 basic instruction and reloc for an external symbol. */
110 static bfd_boolean sh64_expand
= TRUE
;
112 /* Controlled by the option -expand-pt32, this says whether we expand
113 PT/PTA/PTB of an external symbol to (only) 32 or (the full) 64 bits
114 when -abi=64 is in effect. */
115 static bfd_boolean sh64_pt32
= FALSE
;
117 /* When emitting a .cranges descriptor, we want to avoid getting recursive
118 calls through emit_expr. */
119 static bfd_boolean emitting_crange
= FALSE
;
121 /* SHmedia mnemonics. */
122 static struct hash_control
*shmedia_opcode_hash_control
= NULL
;
124 static const unsigned char shmedia_big_nop_pattern
[4] =
126 (SHMEDIA_NOP_OPC
>> 24) & 255, (SHMEDIA_NOP_OPC
>> 16) & 255,
127 (SHMEDIA_NOP_OPC
>> 8) & 255, SHMEDIA_NOP_OPC
& 255
130 static const unsigned char shmedia_little_nop_pattern
[4] =
132 SHMEDIA_NOP_OPC
& 255, (SHMEDIA_NOP_OPC
>> 8) & 255,
133 (SHMEDIA_NOP_OPC
>> 16) & 255, (SHMEDIA_NOP_OPC
>> 24) & 255
136 static void shmedia_md_begin (void);
137 static int shmedia_parse_reg (char *, int *, int *, shmedia_arg_type
);
138 static void shmedia_md_assemble (char *);
139 static void shmedia_md_apply_fix3 (fixS
*, valueT
*);
140 static int shmedia_md_estimate_size_before_relax (fragS
*, segT
);
141 static int shmedia_init_reloc (arelent
*, fixS
*);
142 static char *shmedia_get_operands (shmedia_opcode_info
*, char *,
143 shmedia_operands_info
*);
144 static void s_sh64_mode (int);
145 static void s_sh64_abi (int);
146 static void shmedia_md_convert_frag (bfd
*, segT
, fragS
*, bfd_boolean
);
147 static void shmedia_check_limits (offsetT
*, bfd_reloc_code_real_type
,
149 static void sh64_set_contents_type (enum sh64_elf_cr_type
);
150 static void shmedia_get_operand (char **, shmedia_operand_info
*,
152 static unsigned long shmedia_immediate_op (char *, shmedia_operand_info
*,
153 int, bfd_reloc_code_real_type
);
154 static char *shmedia_parse_exp (char *, shmedia_operand_info
*);
155 static void shmedia_frob_file_before_adjust (void);
156 static void sh64_emit_crange (symbolS
*, symbolS
*, enum sh64_elf_cr_type
);
157 static void sh64_flush_last_crange (bfd
*, asection
*, void *);
158 static void sh64_flag_output (void);
159 static void sh64_update_contents_mark (bfd_boolean
);
160 static void sh64_vtable_entry (int);
161 static void sh64_vtable_inherit (int);
162 static char *strip_datalabels (void);
163 static int shmedia_build_Mytes (shmedia_opcode_info
*,
164 shmedia_operands_info
*);
165 static shmedia_opcode_info
*shmedia_find_cooked_opcode (char **);
166 static unsigned long shmedia_mask_number (unsigned long,
167 bfd_reloc_code_real_type
);
172 shmedia_md_end (void)
176 /* First, update the last range to include whatever data was last
178 sh64_update_contents_mark (TRUE
);
180 /* Make sure frags generated after this point are not marked with the
181 wrong ISA; make them easily spottable. We still want to distinguish
182 it from sh64_isa_unspecified when we compile for SHcompact or
184 if (sh64_isa_mode
!= sh64_isa_unspecified
)
185 sh64_isa_mode
= sh64_isa_sh5_guard
;
187 sh64_end_of_assembly
= TRUE
;
189 bfd_map_over_sections (stdoutput
, sh64_flush_last_crange
, NULL
);
191 /* Iterate over segments and emit the last .cranges descriptor. */
192 for (symp
= symbol_rootP
; symp
!= NULL
; symp
= symp
->sy_next
)
194 symbolS
*mainsym
= *symbol_get_tc (symp
);
196 /* Is this a datalabel symbol; does it have a pointer to the main
200 /* If the datalabel symbol is undefined, check if the main
201 symbol has changed in that respect. */
202 if (S_GET_SEGMENT (symp
) == undefined_section
)
206 symseg
= S_GET_SEGMENT (mainsym
);
208 /* If the symbol is now defined to something that is not
209 global and without STO_SH5_ISA32, we just equate the
210 datalabel symbol to the main symbol, and the lack of
211 STO_SH5_ISA32 will handle the datalabelness. */
212 if (symseg
!= undefined_section
)
214 if (S_GET_OTHER (mainsym
) != STO_SH5_ISA32
)
216 symp
->sy_value
.X_op
= O_symbol
;
217 symp
->sy_value
.X_add_symbol
= mainsym
;
218 symp
->sy_value
.X_op_symbol
= NULL
;
219 symp
->sy_value
.X_add_number
= 0;
220 S_SET_SEGMENT (symp
, S_GET_SEGMENT (mainsym
));
221 symbol_set_frag (symp
, &zero_address_frag
);
222 copy_symbol_attributes (symp
, mainsym
);
226 /* An undefined symbol has since we saw it at
227 "datalabel", been defined to a BranchTarget
228 symbol. What we need to do here is very similar
229 to when we find the "datalabel" for a defined
230 symbol. FIXME: Break out to common function. */
231 symbol_set_value_expression (symp
,
232 symbol_get_value_expression
234 S_SET_SEGMENT (symp
, symseg
);
235 symbol_set_frag (symp
, symbol_get_frag (mainsym
));
236 copy_symbol_attributes (symp
, mainsym
);
238 /* Unset the BranchTarget mark that can be set at
239 attribute-copying. */
241 S_GET_OTHER (symp
) & ~STO_SH5_ISA32
);
243 /* The GLOBAL and WEAK attributes are not copied
244 over by copy_symbol_attributes. Do it here. */
245 if (S_IS_WEAK (mainsym
))
247 else if (S_IS_EXTERNAL (mainsym
))
248 S_SET_EXTERNAL (symp
);
253 /* A symbol that was defined at the time we saw
254 "datalabel" can since have been attributed with being
256 if (S_IS_WEAK (mainsym
))
258 else if (S_IS_EXTERNAL (mainsym
))
259 S_SET_EXTERNAL (symp
);
265 for (symp
= symbol_rootP
; symp
!= NULL
; symp
= symp
->sy_next
)
266 if (S_GET_OTHER (symp
) & STO_SH5_ISA32
)
267 symp
->sy_value
.X_add_number
++;
270 /* When resolving symbols, the main assembler has done us a misfavour. It
271 has removed the equation to the main symbol for a datalabel reference
272 that should be equal to the main symbol, e.g. when it's a global or
273 weak symbol and is a non-BranchTarget symbol anyway. We change that
274 back, so that relocs are against the main symbol, not the local "section
278 shmedia_frob_file_before_adjust (void)
281 for (symp
= symbol_rootP
; symp
!= NULL
; symp
= symp
->sy_next
)
283 symbolS
*mainsym
= *symbol_get_tc (symp
);
286 && S_GET_OTHER (mainsym
) != STO_SH5_ISA32
287 && (S_IS_EXTERN (mainsym
) || S_IS_WEAK (mainsym
)))
289 symp
->sy_value
.X_op
= O_symbol
;
290 symp
->sy_value
.X_add_symbol
= mainsym
;
291 symp
->sy_value
.X_op_symbol
= NULL
;
292 symp
->sy_value
.X_add_number
= 0;
294 /* For the "equation trick" to work, we have to set the section
296 S_SET_SEGMENT (symp
, undefined_section
);
297 symbol_set_frag (symp
, &zero_address_frag
);
298 copy_symbol_attributes (symp
, mainsym
);
300 /* Don't forget to remove the STO_SH5_ISA32 attribute after
301 copying the other attributes. */
302 S_SET_OTHER (symp
, S_GET_OTHER (symp
) & ~STO_SH5_ISA32
);
307 /* We need to mark the current location after the alignment. This is
308 copied code the caller, do_align. We mark the frag location before and
309 after as we need and arrange to skip the same code in do_align.
311 An alternative to code duplication is to call the do_align recursively,
312 arranging to fall through into do_align if we're already here. That
313 would require do_align as an incoming function parameter, since it's
314 static in read.c. That solution was discarded a too kludgy. */
317 sh64_do_align (int n
, const char *fill
, int len
, int max
)
319 /* Update region, or put a data region in front. */
320 sh64_update_contents_mark (TRUE
);
322 /* Only make a frag if we HAVE to... */
323 if (n
!= 0 && !need_pass_2
)
327 if (subseg_text_p (now_seg
))
328 frag_align_code (n
, max
);
330 frag_align (n
, 0, max
);
333 frag_align (n
, *fill
, max
);
335 frag_align_pattern (n
, fill
, len
, max
);
338 /* Update mark for current region with current type. */
339 sh64_update_contents_mark (FALSE
);
342 /* The MAX_MEM_FOR_RS_ALIGN_CODE worker. We have to find out the ISA of
343 the current segment at this position. We can't look just at
344 sh64_isa_shmedia, and we can't look at frag_now. This is brittle:
345 callers are currently frag_align_code from subsegs_finish in write.c
346 (end of assembly) and frag_align_code from do_align in read.c (during
350 sh64_max_mem_for_rs_align_code (void)
352 segment_info_type
*seginfo
;
353 fragS
*mode_start_frag
;
354 seginfo
= seg_info (now_seg
);
356 /* We don't use the contents type we find at the tc_segment_info_data,
357 since that does not give us absolute information about the ISA; the
358 contents type can presumably be CRT_DATA and we'd be none the wiser.
359 Instead we use the information stored at the frag of the symbol at
360 the start of this range. If any information is missing or NULL,
363 /* If the current ISA mode is SHmedia, that's the mode that we're
364 going to assign to the new frag, so request enough memory for
365 it, even if we switch modes afterwards, otherwise we may
366 allocate too little memory and end up overflowing our buffer. */
367 (sh64_isa_mode
== sh64_isa_shmedia
368 || (sh64_isa_mode
!= sh64_isa_unspecified
370 && seginfo
->tc_segment_info_data
.mode_start_symbol
!= NULL
373 (seginfo
->tc_segment_info_data
.mode_start_symbol
)))
375 && mode_start_frag
->tc_frag_data
.isa
== sh64_isa_shmedia
))
379 /* Put in SHmedia NOP:s if the alignment was created when in SHmedia mode. */
382 sh64_handle_align (fragS
* frag
)
384 int bytes
= frag
->fr_next
->fr_address
- frag
->fr_address
- frag
->fr_fix
;
385 char * p
= frag
->fr_literal
+ frag
->fr_fix
;
387 if (frag
->tc_frag_data
.isa
== sh64_isa_shmedia
388 && frag
->fr_type
== rs_align_code
)
397 if (target_big_endian
)
399 memcpy (p
, shmedia_big_nop_pattern
,
400 sizeof shmedia_big_nop_pattern
);
401 frag
->fr_var
= sizeof shmedia_big_nop_pattern
;
405 memcpy (p
, shmedia_little_nop_pattern
,
406 sizeof shmedia_little_nop_pattern
);
407 frag
->fr_var
= sizeof shmedia_little_nop_pattern
;
411 /* Punt to SHcompact function. */
412 sh_handle_align (frag
);
415 /* Set SEC_SH64_ISA32 for SHmedia sections. */
418 shmedia_frob_section_type (asection
*sec
)
420 segment_info_type
*seginfo
;
421 seginfo
= seg_info (sec
);
423 /* This and elf32-sh64.c:sh64_elf_fake_sections are the only places
424 where we use anything else than ELF header flags to communicate the
425 section as containing SHmedia or other contents. BFD SEC_* section
426 flags are running out and should not be overloaded with
427 target-specific semantics. This target is ELF only (semantics not
428 defined for other formats), so we use the target-specific pointer
429 field of the ELF section data. */
430 if (seginfo
&& sh64_abi
== sh64_abi_32
)
432 struct sh64_section_data
*sec_elf_data
;
433 flagword sec_type
= 0;
435 if (seginfo
->tc_segment_info_data
.emitted_ranges
!= 0)
436 sec_type
= SHF_SH5_ISA32_MIXED
;
437 else if (seginfo
->tc_segment_info_data
.contents_type
== CRT_SH5_ISA32
)
438 sec_type
= SHF_SH5_ISA32
;
440 sec_elf_data
= sh64_elf_section_data (sec
)->sh64_info
;
441 if (sec_elf_data
== NULL
)
443 sec_elf_data
= xcalloc (1, sizeof (*sec_elf_data
));
444 sh64_elf_section_data (sec
)->sh64_info
= sec_elf_data
;
447 sec_elf_data
->contents_flags
= sec_type
;
451 /* This function is called by write_object_file right before the symbol
452 table is written. We subtract 1 from all symbols marked STO_SH5_ISA32,
453 as their values are temporarily incremented in shmedia_md_end, before
454 symbols values are used by relocs and fixups.
456 To increment all symbols and then decrement here is admittedly a
457 hackish solution. The alternative is to add infrastructure and hooks
458 to symbol evaluation that evaluates symbols differently internally to
459 the value output into the object file, but at the moment that just
460 seems too much for little benefit. */
463 sh64_adjust_symtab (void)
467 for (symp
= symbol_rootP
; symp
; symp
= symbol_next (symp
))
469 symbolS
*main_symbol
= *symbol_get_tc (symp
);
473 char *sym_name
= (char *) S_GET_NAME (symp
);
475 /* All datalabels not used in relocs should be gone by now.
477 We change those remaining to have the name of the main
478 symbol, and we set the ELF type of the symbol of the reloc to
480 sym_name
[strlen (sym_name
) - strlen (DATALABEL_SUFFIX
)] = 0;
481 elf_symbol (symbol_get_bfdsym (symp
))->internal_elf_sym
.st_info
484 /* Also set this symbol to "undefined", so we'll have only one
486 S_SET_SEGMENT (symp
, undefined_section
);
488 else if (S_GET_OTHER (symp
) & STO_SH5_ISA32
)
490 /* It's important to change the BFD symbol value, since it is now
491 set to the GAS symbolS value. */
494 /* Note that we do *not* adjust symp->sy_value.X_add_number. If
495 you do this, the test case in sh/sh64/immexpr2.s will fail.
496 This is because *after* symbols have been output but before
497 relocs are output, fixups are inspected one more time, and
498 some leftover expressions are resolved. To resolve to the
499 same values, those expressions must have the same GAS symbol
500 values before as after symbols have been output. We could
501 "symp->sy_value.X_add_number++" on the STO_SH5_ISA32 symbols
502 through tc_frob_file after symbols have been output, but that
503 would be too gross. */
508 /* Fill-in an allocated arelent. */
511 shmedia_init_reloc (arelent
*rel
, fixS
*fixP
)
513 /* Adjust parts of *relp according to *fixp, and tell that it has been
514 done, so default initializations will not happen. */
515 switch (fixP
->fx_r_type
)
518 case BFD_RELOC_64_PCREL
:
519 case BFD_RELOC_SH_IMM_LOW16
:
520 case BFD_RELOC_SH_IMM_MEDLOW16
:
521 case BFD_RELOC_SH_IMM_MEDHI16
:
522 case BFD_RELOC_SH_IMM_HI16
:
523 case BFD_RELOC_SH_IMM_LOW16_PCREL
:
524 case BFD_RELOC_SH_IMM_MEDLOW16_PCREL
:
525 case BFD_RELOC_SH_IMM_MEDHI16_PCREL
:
526 case BFD_RELOC_SH_IMM_HI16_PCREL
:
527 case BFD_RELOC_SH_IMMU5
:
528 case BFD_RELOC_SH_IMMU6
:
529 case BFD_RELOC_SH_IMMS6
:
530 case BFD_RELOC_SH_IMMS10
:
531 case BFD_RELOC_SH_IMMS10BY2
:
532 case BFD_RELOC_SH_IMMS10BY4
:
533 case BFD_RELOC_SH_IMMS10BY8
:
534 case BFD_RELOC_SH_IMMS16
:
535 case BFD_RELOC_SH_IMMU16
:
536 case BFD_RELOC_SH_PT_16
:
537 case BFD_RELOC_SH_GOT_LOW16
:
538 case BFD_RELOC_SH_GOT_MEDLOW16
:
539 case BFD_RELOC_SH_GOT_MEDHI16
:
540 case BFD_RELOC_SH_GOT_HI16
:
541 case BFD_RELOC_SH_GOT10BY4
:
542 case BFD_RELOC_SH_GOT10BY8
:
543 case BFD_RELOC_SH_GOTPLT_LOW16
:
544 case BFD_RELOC_SH_GOTPLT_MEDLOW16
:
545 case BFD_RELOC_SH_GOTPLT_MEDHI16
:
546 case BFD_RELOC_SH_GOTPLT_HI16
:
547 case BFD_RELOC_SH_GOTPLT10BY4
:
548 case BFD_RELOC_SH_GOTPLT10BY8
:
549 case BFD_RELOC_SH_GOTOFF_LOW16
:
550 case BFD_RELOC_SH_GOTOFF_MEDLOW16
:
551 case BFD_RELOC_SH_GOTOFF_MEDHI16
:
552 case BFD_RELOC_SH_GOTOFF_HI16
:
553 case BFD_RELOC_SH_GOTPC_LOW16
:
554 case BFD_RELOC_SH_GOTPC_MEDLOW16
:
555 case BFD_RELOC_SH_GOTPC_MEDHI16
:
556 case BFD_RELOC_SH_GOTPC_HI16
:
557 case BFD_RELOC_SH_PLT_LOW16
:
558 case BFD_RELOC_SH_PLT_MEDLOW16
:
559 case BFD_RELOC_SH_PLT_MEDHI16
:
560 case BFD_RELOC_SH_PLT_HI16
:
561 rel
->addend
= fixP
->fx_addnumber
+ fixP
->fx_offset
;
564 case BFD_RELOC_SH_IMMS6BY32
:
565 /* This must be resolved in assembly; we do not support it as a
566 reloc in an object file. */
567 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
568 _("This operand must be constant at assembly time"));
571 /* There are valid cases where we get here for other than SHmedia
572 relocs, so don't make a BAD_CASE out of this. */
580 /* Hook called from md_apply_fix3 in tc-sh.c. */
583 shmedia_md_apply_fix3 (fixS
*fixP
, valueT
*valp
)
586 char *buf
= fixP
->fx_where
+ fixP
->fx_frag
->fr_literal
;
588 = target_big_endian
? bfd_getb32 (buf
) : bfd_getl32 (buf
);
589 bfd_reloc_code_real_type orig_fx_r_type
= fixP
->fx_r_type
;
591 /* Change a 64-bit pc-relative reloc into the correct type, just like
592 tc-sh.c:md_apply_fix. */
595 switch (orig_fx_r_type
)
598 case BFD_RELOC_SH_IMM_LOW16
:
599 case BFD_RELOC_SH_IMM_MEDLOW16
:
600 case BFD_RELOC_SH_IMM_MEDHI16
:
601 case BFD_RELOC_SH_IMM_HI16
:
602 /* Because write.c calls MD_PCREL_FROM_SECTION twice, we need to
603 undo one of the adjustments, if the relocation is not
604 actually for a symbol within the same segment (which we
605 cannot check, because we're not called from md_apply_fix3, so
606 we have to keep the reloc). FIXME: This is a bug in
607 write.c:fixup_segment affecting most targets that change
608 ordinary relocs to pcrel relocs in md_apply_fix. */
610 = *valp
+ SHMEDIA_MD_PCREL_FROM_FIX (fixP
);
613 case BFD_RELOC_SH_PLT_LOW16
:
614 case BFD_RELOC_SH_PLT_MEDLOW16
:
615 case BFD_RELOC_SH_PLT_MEDHI16
:
616 case BFD_RELOC_SH_PLT_HI16
:
617 case BFD_RELOC_SH_GOTPC_LOW16
:
618 case BFD_RELOC_SH_GOTPC_MEDLOW16
:
619 case BFD_RELOC_SH_GOTPC_MEDHI16
:
620 case BFD_RELOC_SH_GOTPC_HI16
:
628 /* We might need to change some relocs into the corresponding
630 switch (orig_fx_r_type
)
633 fixP
->fx_r_type
= BFD_RELOC_64_PCREL
;
636 case BFD_RELOC_SH_IMM_LOW16
:
637 fixP
->fx_r_type
= BFD_RELOC_SH_IMM_LOW16_PCREL
;
640 case BFD_RELOC_SH_IMM_MEDLOW16
:
641 fixP
->fx_r_type
= BFD_RELOC_SH_IMM_MEDLOW16_PCREL
;
644 case BFD_RELOC_SH_IMM_MEDHI16
:
645 fixP
->fx_r_type
= BFD_RELOC_SH_IMM_MEDHI16_PCREL
;
648 case BFD_RELOC_SH_IMM_HI16
:
649 fixP
->fx_r_type
= BFD_RELOC_SH_IMM_HI16_PCREL
;
652 case SHMEDIA_BFD_RELOC_PT
:
653 /* This is how we see a difference between PT and PTA when not
654 expanding (in which case we handle it in
655 shmedia_md_convert_frag). Note that we don't see a
656 difference after the reloc is emitted. */
657 fixP
->fx_r_type
= BFD_RELOC_SH_PT_16
;
660 case BFD_RELOC_SH_PT_16
:
661 /* This tells us there was a PTA or PTB insn explicitly
662 expressed as such (not as PT). We "or" in a 1 into the
663 lowest bit in the (unused) destination field to tell the
664 linker that it should check the right ISA type of the
665 destination and not just change a PTA to PTB (if necessary). */
666 md_number_to_chars (buf
, insn
| (1 << 10), 4);
669 case BFD_RELOC_64_PCREL
:
670 case BFD_RELOC_SH_IMM_LOW16_PCREL
:
671 case BFD_RELOC_SH_IMM_MEDLOW16_PCREL
:
672 case BFD_RELOC_SH_IMM_MEDHI16_PCREL
:
673 case BFD_RELOC_SH_IMM_HI16_PCREL
:
674 /* Already handled. */
678 /* Everything else that changes into a pc-relative relocation is
680 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
681 _("Invalid operand expression"));
688 /* If an expression looked like it was PC-relative, but was completely
689 resolvable, we end up here with the result only in *VALP, and no
690 relocation will be emitted. */
691 if (fixP
->fx_addsy
== NULL
&& fixP
->fx_pcrel
== 0)
693 /* Emit error for an out-of-range value. */
694 shmedia_check_limits (valp
, fixP
->fx_r_type
, fixP
);
696 switch (fixP
->fx_r_type
)
698 case BFD_RELOC_SH_IMM_LOW16
:
699 md_number_to_chars (buf
, insn
| ((val
& 65535) << 10), 4);
702 case BFD_RELOC_SH_IMM_MEDLOW16
:
703 md_number_to_chars (buf
,
705 | ((valueT
) (val
& ((valueT
) 65535 << 16))
709 case BFD_RELOC_SH_IMM_MEDHI16
:
710 md_number_to_chars (buf
,
712 | ((valueT
) (val
& ((valueT
) 65535 << 32))
716 case BFD_RELOC_SH_IMM_HI16
:
717 md_number_to_chars (buf
,
719 | ((valueT
) (val
& ((valueT
) 65535 << 48))
723 case BFD_RELOC_SH_IMMS16
:
724 case BFD_RELOC_SH_IMMU16
:
725 md_number_to_chars (buf
, insn
| ((val
& 65535) << 10), 4);
728 case BFD_RELOC_SH_IMMS10
:
729 md_number_to_chars (buf
, insn
| ((val
& 0x3ff) << 10), 4);
732 case BFD_RELOC_SH_IMMS10BY2
:
733 md_number_to_chars (buf
,
734 insn
| ((val
& (0x3ff << 1)) << (10 - 1)), 4);
737 case BFD_RELOC_SH_IMMS10BY4
:
738 md_number_to_chars (buf
,
739 insn
| ((val
& (0x3ff << 2)) << (10 - 2)), 4);
742 case BFD_RELOC_SH_SHMEDIA_CODE
:
743 /* We just ignore and remove this one for the moment. FIXME:
744 Use it when implementing relaxing. */
748 md_number_to_chars (buf
, val
, 8);
751 case SHMEDIA_BFD_RELOC_PT
:
752 /* Change a PT to PTB if the operand turned out to be SHcompact.
753 The basic opcode specified with PT is equivalent to PTA. */
755 insn
|= SHMEDIA_PTB_BIT
;
758 case BFD_RELOC_SH_PT_16
:
759 if (! sh64_expand
|| sh_relax
)
761 /* Check if the operand of a PTA or PTB was for the "wrong"
762 ISA. A PT had an incoming fixup of SHMEDIA_BFD_RELOC_PT,
763 which we have changed to the right type above. */
764 if (orig_fx_r_type
!= SHMEDIA_BFD_RELOC_PT
)
766 if ((insn
& SHMEDIA_PTB_BIT
) != 0 && (val
& 1) != 0)
767 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
768 _("PTB operand is a SHmedia symbol"));
769 else if ((insn
& SHMEDIA_PTB_BIT
) == 0 && (val
& 1) == 0)
770 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
771 _("PTA operand is a SHcompact symbol"));
774 md_number_to_chars (buf
,
775 insn
| ((val
& (0xffff << 2))
783 /* This isn't a BAD_CASE, because presumably we can get here
784 from unexpected operands. Since we don't handle them, make
785 them syntax errors. */
786 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
787 _("invalid expression in operand"));
793 /* Hook called from md_convert_frag in tc-sh.c. */
796 shmedia_md_convert_frag (bfd
*output_bfd ATTRIBUTE_UNUSED
,
797 segT seg ATTRIBUTE_UNUSED
, fragS
*fragP
,
800 /* Pointer to first byte in variable-sized part of the frag. */
803 /* Pointer to first opcode byte in frag. */
806 /* Pointer to frag of opcode. */
807 fragS
*opc_fragP
= fragP
->tc_frag_data
.opc_frag
;
809 /* Size in bytes of variable-sized part of frag. */
810 int var_part_size
= 0;
812 /* This is part of *fragP. It contains all information about addresses
813 and offsets to varying parts. */
814 symbolS
*symbolP
= fragP
->fr_symbol
;
816 bfd_boolean reloc_needed
820 || ! S_IS_DEFINED (symbolP
)
821 || S_IS_EXTERN (symbolP
)
822 || S_IS_WEAK (symbolP
)
823 || (S_GET_SEGMENT (fragP
->fr_symbol
) != absolute_section
824 && S_GET_SEGMENT (fragP
->fr_symbol
) != seg
));
826 bfd_reloc_code_real_type reloctype
= BFD_RELOC_NONE
;
828 unsigned long var_part_offset
;
830 /* Where, in file space, does addr point? */
831 bfd_vma target_address
;
832 bfd_vma opcode_address
;
834 /* What was the insn? */
836 know (fragP
->fr_type
== rs_machine_dependent
);
838 var_part_offset
= fragP
->fr_fix
;
839 var_partp
= fragP
->fr_literal
+ var_part_offset
;
840 opcodep
= fragP
->fr_opcode
;
842 insn
= target_big_endian
? bfd_getb32 (opcodep
) : bfd_getl32 (opcodep
);
845 = ((symbolP
&& final
&& ! sh_relax
? S_GET_VALUE (symbolP
) : 0)
848 /* The opcode that would be extended is the last four "fixed" bytes. */
849 opcode_address
= fragP
->fr_address
+ fragP
->fr_fix
- 4;
851 switch (fragP
->fr_subtype
)
853 case C (SH64PCREL16PT_64
, SH64PCREL16
):
854 case C (SH64PCREL16PT_32
, SH64PCREL16
):
855 /* We can get a PT to a relaxed SHcompact address if it is in the
856 same section; a mixed-ISA section. Change the opcode to PTB if
858 if ((target_address
& 1) == 0)
859 insn
|= SHMEDIA_PTB_BIT
;
862 case C (SH64PCREL16_32
, SH64PCREL16
):
863 case C (SH64PCREL16_64
, SH64PCREL16
):
864 /* Check that a PTA or PTB points to the right type of target. We
865 can get here for a SHcompact target if we are in a mixed-ISA
867 if (((target_address
& 1) == 0) && ((insn
& SHMEDIA_PTB_BIT
) == 0))
868 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
869 _("PTA operand is a SHcompact symbol"));
870 if (((target_address
& 1) != 0) && ((insn
& SHMEDIA_PTB_BIT
) != 0))
871 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
872 _("PTB operand is a SHmedia symbol"));
874 /* When relaxing, we do not output the address in the insn, but
875 instead a 1 into the low bit. This matches what the linker
876 expects to find for a BFD_RELOC_SH_PT_16 reloc, when it checks
877 correctness for PTA/PTB insn; used when the target address is
878 unknown (which is not the case here). */
879 md_number_to_chars (opcodep
,
882 ? 1 : ((target_address
- opcode_address
) / 4))
883 & ((1 << 16) - 1)) << 10),
886 /* Note that we do not emit info that this was originally a PT since
887 we have resolved to which one of PTA or PTB it will be. */
889 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
890 fragP
->fr_symbol
, fragP
->fr_offset
, 1, BFD_RELOC_SH_PT_16
);
894 case C (SH64PCREL16_32
, SH64PCRELPLT
):
895 case C (SH64PCREL16PT_32
, SH64PCRELPLT
):
896 reloctype
= BFD_RELOC_32_PLT_PCREL
;
900 case C (SH64PCREL16_32
, SH64PCREL32
):
901 case C (SH64PCREL16_64
, SH64PCREL32
):
902 case C (SH64PCREL16PT_32
, SH64PCREL32
):
903 case C (SH64PCREL16PT_64
, SH64PCREL32
):
904 /* In the fixed bit, put in a MOVI. */
905 md_number_to_chars (opcodep
,
907 | (SHMEDIA_TEMP_REG
<< 4)
909 ? 0 : (target_address
- (opcode_address
+ 8))
910 ) >> 16) & 65535) << 10),
913 /* Fill in a SHORI for the low part. */
914 md_number_to_chars (var_partp
,
916 | (SHMEDIA_TEMP_REG
<< 4)
918 ? 0 : (target_address
- (opcode_address
+ 8)))
922 /* End with a "PTREL R25,TRd". */
923 md_number_to_chars (var_partp
+ 4,
924 SHMEDIA_PTREL_OPC
| (insn
& SHMEDIA_LIKELY_BIT
)
925 | (SHMEDIA_TEMP_REG
<< 10)
929 /* We need relocs only if the target symbol was undefined or if
933 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
934 fragP
->fr_symbol
, fragP
->fr_offset
- 8, 1,
935 reloctype
== BFD_RELOC_32_PLT_PCREL
936 ? BFD_RELOC_SH_PLT_MEDLOW16
937 : BFD_RELOC_SH_IMM_MEDLOW16_PCREL
);
938 fix_new (fragP
, var_partp
- fragP
->fr_literal
, 4, fragP
->fr_symbol
,
939 fragP
->fr_offset
- 4, 1,
940 reloctype
== BFD_RELOC_32_PLT_PCREL
941 ? BFD_RELOC_SH_PLT_LOW16
942 : BFD_RELOC_SH_IMM_LOW16_PCREL
);
948 case C (SH64PCREL16_64
, SH64PCREL48
):
949 case C (SH64PCREL16PT_64
, SH64PCREL48
):
950 /* In the fixed bit, put in a MOVI. */
951 md_number_to_chars (opcodep
,
953 | (SHMEDIA_TEMP_REG
<< 4)
955 ? 0 : (target_address
- (opcode_address
+ 12))
956 ) >> 32) & 65535) << 10),
959 /* The first SHORI, for the medium part. */
960 md_number_to_chars (var_partp
,
962 | (SHMEDIA_TEMP_REG
<< 4)
964 ? 0 : (target_address
- (opcode_address
+ 12))
965 ) >> 16) & 65535) << 10),
968 /* Fill in a SHORI for the low part. */
969 md_number_to_chars (var_partp
+ 4,
971 | (SHMEDIA_TEMP_REG
<< 4)
973 ? 0 : (target_address
- (opcode_address
+ 12)))
977 /* End with a "PTREL R25,TRd". */
978 md_number_to_chars (var_partp
+ 8,
979 SHMEDIA_PTREL_OPC
| (insn
& SHMEDIA_LIKELY_BIT
)
980 | (SHMEDIA_TEMP_REG
<< 10)
984 /* We need relocs only if the target symbol was undefined or if
988 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
989 fragP
->fr_symbol
, fragP
->fr_offset
- 12, 1,
990 reloctype
== BFD_RELOC_32_PLT_PCREL
991 ? BFD_RELOC_SH_PLT_MEDHI16
992 : BFD_RELOC_SH_IMM_MEDHI16_PCREL
);
993 fix_new (fragP
, var_partp
- fragP
->fr_literal
, 4, fragP
->fr_symbol
,
994 fragP
->fr_offset
- 8, 1,
995 reloctype
== BFD_RELOC_32_PLT_PCREL
996 ? BFD_RELOC_SH_PLT_MEDLOW16
997 : BFD_RELOC_SH_IMM_MEDLOW16_PCREL
);
998 fix_new (fragP
, var_partp
- fragP
->fr_literal
+ 4, 4, fragP
->fr_symbol
,
999 fragP
->fr_offset
- 4, 1,
1000 reloctype
== BFD_RELOC_32_PLT_PCREL
1001 ? BFD_RELOC_SH_PLT_LOW16
1002 : BFD_RELOC_SH_IMM_LOW16_PCREL
);
1008 case C (SH64PCREL16_64
, SH64PCRELPLT
):
1009 case C (SH64PCREL16PT_64
, SH64PCRELPLT
):
1010 reloctype
= BFD_RELOC_32_PLT_PCREL
;
1014 case C (SH64PCREL16_64
, SH64PCREL64
):
1015 case C (SH64PCREL16PT_64
, SH64PCREL64
):
1016 /* In the fixed bit, put in a MOVI. */
1017 md_number_to_chars (opcodep
,
1019 | (SHMEDIA_TEMP_REG
<< 4)
1021 ? 0 : (target_address
- (opcode_address
+ 16))
1022 ) >> 48) & 65535) << 10),
1025 /* The first SHORI, for the medium-high part. */
1026 md_number_to_chars (var_partp
,
1028 | (SHMEDIA_TEMP_REG
<< 4)
1030 ? 0 : (target_address
- (opcode_address
+ 16))
1031 ) >> 32) & 65535) << 10),
1034 /* A SHORI, for the medium-low part. */
1035 md_number_to_chars (var_partp
+ 4,
1037 | (SHMEDIA_TEMP_REG
<< 4)
1039 ? 0 : (target_address
- (opcode_address
+ 16))
1040 ) >> 16) & 65535) << 10),
1043 /* Fill in a SHORI for the low part. */
1044 md_number_to_chars (var_partp
+ 8,
1046 | (SHMEDIA_TEMP_REG
<< 4)
1048 ? 0 : (target_address
- (opcode_address
+ 16)))
1052 /* End with a "PTREL R25,TRd". */
1053 md_number_to_chars (var_partp
+ 12,
1054 SHMEDIA_PTREL_OPC
| (insn
& SHMEDIA_LIKELY_BIT
)
1055 | (SHMEDIA_TEMP_REG
<< 10)
1056 | (insn
& (7 << 4)),
1059 /* We need relocs only if the target symbol was undefined or if
1063 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
1064 fragP
->fr_symbol
, fragP
->fr_offset
- 16, 1,
1065 reloctype
== BFD_RELOC_32_PLT_PCREL
1066 ? BFD_RELOC_SH_PLT_HI16
1067 : BFD_RELOC_SH_IMM_HI16_PCREL
);
1068 fix_new (fragP
, var_partp
- fragP
->fr_literal
, 4, fragP
->fr_symbol
,
1069 fragP
->fr_offset
- 12, 1,
1070 reloctype
== BFD_RELOC_32_PLT_PCREL
1071 ? BFD_RELOC_SH_PLT_MEDHI16
1072 : BFD_RELOC_SH_IMM_MEDHI16_PCREL
);
1073 fix_new (fragP
, var_partp
- fragP
->fr_literal
+ 4, 4, fragP
->fr_symbol
,
1074 fragP
->fr_offset
- 8, 1,
1075 reloctype
== BFD_RELOC_32_PLT_PCREL
1076 ? BFD_RELOC_SH_PLT_MEDLOW16
1077 : BFD_RELOC_SH_IMM_MEDLOW16_PCREL
);
1078 fix_new (fragP
, var_partp
- fragP
->fr_literal
+ 8, 4, fragP
->fr_symbol
,
1079 fragP
->fr_offset
- 4, 1,
1080 reloctype
== BFD_RELOC_32_PLT_PCREL
1081 ? BFD_RELOC_SH_PLT_LOW16
1082 : BFD_RELOC_SH_IMM_LOW16_PCREL
);
1088 case C (MOVI_IMM_64
, MOVI_GOTOFF
):
1089 reloctype
= BFD_RELOC_32_GOTOFF
;
1093 case C (MOVI_IMM_64
, UNDEF_MOVI
):
1094 case C (MOVI_IMM_64
, MOVI_64
):
1096 /* We only get here for undefined symbols, so we can simplify
1097 handling compared to those above; we have 0 in the parts that
1098 will be filled with the symbol parts. */
1100 int reg
= (insn
>> 4) & 0x3f;
1102 /* In the fixed bit, put in a MOVI. */
1103 md_number_to_chars (opcodep
, SHMEDIA_MOVI_OPC
| (reg
<< 4), 4);
1104 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
1105 fragP
->fr_symbol
, fragP
->fr_offset
, 0,
1106 reloctype
== BFD_RELOC_NONE
1107 ? BFD_RELOC_SH_IMM_HI16
1108 : reloctype
== BFD_RELOC_32_GOTOFF
1109 ? BFD_RELOC_SH_GOTOFF_HI16
1110 : (abort (), BFD_RELOC_SH_IMM_HI16
));
1112 /* The first SHORI, for the medium-high part. */
1113 md_number_to_chars (var_partp
, SHMEDIA_SHORI_OPC
| (reg
<< 4), 4);
1114 fix_new (fragP
, var_partp
- fragP
->fr_literal
, 4, fragP
->fr_symbol
,
1115 fragP
->fr_offset
, 0,
1116 reloctype
== BFD_RELOC_NONE
1117 ? BFD_RELOC_SH_IMM_MEDHI16
1118 : reloctype
== BFD_RELOC_32_GOTOFF
1119 ? BFD_RELOC_SH_GOTOFF_MEDHI16
1120 : (abort (), BFD_RELOC_SH_IMM_MEDHI16
));
1122 /* A SHORI, for the medium-low part. */
1123 md_number_to_chars (var_partp
+ 4,
1124 SHMEDIA_SHORI_OPC
| (reg
<< 4), 4);
1125 fix_new (fragP
, var_partp
- fragP
->fr_literal
+ 4, 4, fragP
->fr_symbol
,
1126 fragP
->fr_offset
, 0,
1127 reloctype
== BFD_RELOC_NONE
1128 ? BFD_RELOC_SH_IMM_MEDLOW16
1129 : reloctype
== BFD_RELOC_32_GOTOFF
1130 ? BFD_RELOC_SH_GOTOFF_MEDLOW16
1131 : (abort (), BFD_RELOC_SH_IMM_MEDLOW16
));
1133 /* Fill in a SHORI for the low part. */
1134 md_number_to_chars (var_partp
+ 8,
1135 SHMEDIA_SHORI_OPC
| (reg
<< 4), 4);
1136 fix_new (fragP
, var_partp
- fragP
->fr_literal
+ 8, 4, fragP
->fr_symbol
,
1137 fragP
->fr_offset
, 0,
1138 reloctype
== BFD_RELOC_NONE
1139 ? BFD_RELOC_SH_IMM_LOW16
1140 : reloctype
== BFD_RELOC_32_GOTOFF
1141 ? BFD_RELOC_SH_GOTOFF_LOW16
1142 : (abort (), BFD_RELOC_SH_IMM_LOW16
));
1148 case C (MOVI_IMM_32
, MOVI_GOTOFF
):
1149 reloctype
= BFD_RELOC_32_GOTOFF
;
1153 case C (MOVI_IMM_32
, UNDEF_MOVI
):
1154 case C (MOVI_IMM_32
, MOVI_32
):
1156 /* Note that we only get here for undefined symbols. */
1158 int reg
= (insn
>> 4) & 0x3f;
1160 /* A MOVI, for the high part. */
1161 md_number_to_chars (opcodep
, SHMEDIA_MOVI_OPC
| (reg
<< 4), 4);
1162 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
1163 fragP
->fr_symbol
, fragP
->fr_offset
, 0,
1164 reloctype
== BFD_RELOC_NONE
1165 ? BFD_RELOC_SH_IMM_MEDLOW16
1166 : reloctype
== BFD_RELOC_32_GOTOFF
1167 ? BFD_RELOC_SH_GOTOFF_MEDLOW16
1168 : reloctype
== BFD_RELOC_SH_GOTPC
1169 ? BFD_RELOC_SH_GOTPC_MEDLOW16
1170 : reloctype
== BFD_RELOC_32_PLT_PCREL
1171 ? BFD_RELOC_SH_PLT_MEDLOW16
1172 : (abort (), BFD_RELOC_SH_IMM_MEDLOW16
));
1174 /* Fill in a SHORI for the low part. */
1175 md_number_to_chars (var_partp
,
1176 SHMEDIA_SHORI_OPC
| (reg
<< 4), 4);
1177 fix_new (fragP
, var_partp
- fragP
->fr_literal
, 4, fragP
->fr_symbol
,
1178 fragP
->fr_offset
, 0,
1179 reloctype
== BFD_RELOC_NONE
1180 ? BFD_RELOC_SH_IMM_LOW16
1181 : reloctype
== BFD_RELOC_32_GOTOFF
1182 ? BFD_RELOC_SH_GOTOFF_LOW16
1183 : reloctype
== BFD_RELOC_SH_GOTPC
1184 ? BFD_RELOC_SH_GOTPC_LOW16
1185 : reloctype
== BFD_RELOC_32_PLT_PCREL
1186 ? BFD_RELOC_SH_PLT_LOW16
1187 : (abort (), BFD_RELOC_SH_IMM_LOW16
));
1193 case C (MOVI_IMM_32_PCREL
, MOVI_16
):
1194 case C (MOVI_IMM_64_PCREL
, MOVI_16
):
1195 md_number_to_chars (opcodep
,
1198 ? 0 : (target_address
- opcode_address
))
1202 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
1203 fragP
->fr_symbol
, fragP
->fr_offset
, 1,
1204 BFD_RELOC_SH_IMM_LOW16_PCREL
);
1208 case C (MOVI_IMM_32
, MOVI_16
):
1209 case C (MOVI_IMM_64
, MOVI_16
):
1210 md_number_to_chars (opcodep
,
1212 | (((reloc_needed
? 0 : target_address
)
1220 case C (MOVI_IMM_32_PCREL
, MOVI_PLT
):
1221 reloctype
= BFD_RELOC_32_PLT_PCREL
;
1222 goto movi_imm_32_pcrel_reloc_needed
;
1224 case C (MOVI_IMM_32_PCREL
, MOVI_GOTPC
):
1225 reloctype
= BFD_RELOC_SH_GOTPC
;
1228 movi_imm_32_pcrel_reloc_needed
:
1232 case C (MOVI_IMM_32_PCREL
, MOVI_32
):
1233 case C (MOVI_IMM_64_PCREL
, MOVI_32
):
1235 int reg
= (insn
>> 4) & 0x3f;
1237 md_number_to_chars (opcodep
,
1240 ? 0 : (target_address
- opcode_address
)))
1241 >> 16) & 65535) << 10), 4);
1243 /* A SHORI, for the low part. */
1244 md_number_to_chars (var_partp
,
1248 ? 0 : (target_address
- opcode_address
))
1249 & 65535) << 10), 4);
1252 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
1253 fragP
->fr_symbol
, fragP
->fr_offset
, 1,
1254 reloctype
== BFD_RELOC_NONE
1255 ? BFD_RELOC_SH_IMM_MEDLOW16_PCREL
1256 : reloctype
== BFD_RELOC_SH_GOTPC
1257 ? BFD_RELOC_SH_GOTPC_MEDLOW16
1258 : reloctype
== BFD_RELOC_32_PLT_PCREL
1259 ? BFD_RELOC_SH_PLT_MEDLOW16
1260 : (abort (), BFD_RELOC_SH_IMM_MEDLOW16_PCREL
));
1261 fix_new (fragP
, var_partp
- fragP
->fr_literal
, 4, fragP
->fr_symbol
,
1262 fragP
->fr_offset
+ 4, 1,
1263 reloctype
== BFD_RELOC_NONE
1264 ? BFD_RELOC_SH_IMM_LOW16_PCREL
1265 : reloctype
== BFD_RELOC_SH_GOTPC
1266 ? BFD_RELOC_SH_GOTPC_LOW16
1267 : reloctype
== BFD_RELOC_32_PLT_PCREL
1268 ? BFD_RELOC_SH_PLT_LOW16
1269 : (abort (), BFD_RELOC_SH_IMM_LOW16_PCREL
));
1275 case C (MOVI_IMM_32_PCREL
, MOVI_48
):
1276 case C (MOVI_IMM_64_PCREL
, MOVI_48
):
1278 int reg
= (insn
>> 4) & 0x3f;
1280 md_number_to_chars (opcodep
,
1283 ? 0 : (target_address
- opcode_address
)))
1284 >> 32) & 65535) << 10), 4);
1286 /* A SHORI, for the medium part. */
1287 md_number_to_chars (var_partp
,
1291 ? 0 : (target_address
- opcode_address
))
1292 >> 16) & 65535) << 10), 4);
1294 /* A SHORI, for the low part. */
1295 md_number_to_chars (var_partp
+ 4,
1299 ? 0 : (target_address
- opcode_address
))
1300 & 65535) << 10), 4);
1303 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
1304 fragP
->fr_symbol
, fragP
->fr_offset
, 1,
1305 BFD_RELOC_SH_IMM_MEDHI16_PCREL
);
1306 fix_new (fragP
, var_partp
- fragP
->fr_literal
, 4, fragP
->fr_symbol
,
1307 fragP
->fr_offset
+ 4, 1, BFD_RELOC_SH_IMM_MEDLOW16_PCREL
);
1308 fix_new (fragP
, var_partp
- fragP
->fr_literal
+ 4, 4, fragP
->fr_symbol
,
1309 fragP
->fr_offset
+ 8, 1, BFD_RELOC_SH_IMM_LOW16_PCREL
);
1315 case C (MOVI_IMM_64_PCREL
, MOVI_PLT
):
1316 reloctype
= BFD_RELOC_32_PLT_PCREL
;
1317 goto movi_imm_64_pcrel_reloc_needed
;
1319 case C (MOVI_IMM_64_PCREL
, MOVI_GOTPC
):
1320 reloctype
= BFD_RELOC_SH_GOTPC
;
1323 movi_imm_64_pcrel_reloc_needed
:
1327 case C (MOVI_IMM_32_PCREL
, MOVI_64
):
1328 case C (MOVI_IMM_64_PCREL
, MOVI_64
):
1330 int reg
= (insn
>> 4) & 0x3f;
1332 md_number_to_chars (opcodep
,
1335 ? 0 : (target_address
- opcode_address
)))
1336 >> 48) & 65535) << 10), 4);
1338 /* A SHORI, for the medium-high part. */
1339 md_number_to_chars (var_partp
,
1343 ? 0 : (target_address
- opcode_address
))
1344 >> 32) & 65535) << 10), 4);
1346 /* A SHORI, for the medium-low part. */
1347 md_number_to_chars (var_partp
+ 4,
1351 ? 0 : (target_address
- opcode_address
))
1352 >> 16) & 65535) << 10), 4);
1354 /* A SHORI, for the low part. */
1355 md_number_to_chars (var_partp
+ 8,
1359 ? 0 : (target_address
- opcode_address
))
1360 & 65535) << 10), 4);
1363 fix_new (opc_fragP
, opcodep
- opc_fragP
->fr_literal
, 4,
1364 fragP
->fr_symbol
, fragP
->fr_offset
, 1,
1365 reloctype
== BFD_RELOC_NONE
1366 ? BFD_RELOC_SH_IMM_HI16_PCREL
1367 : reloctype
== BFD_RELOC_SH_GOTPC
1368 ? BFD_RELOC_SH_GOTPC_HI16
1369 : reloctype
== BFD_RELOC_32_PLT_PCREL
1370 ? BFD_RELOC_SH_PLT_HI16
1371 : (abort (), BFD_RELOC_SH_IMM_HI16_PCREL
));
1372 fix_new (fragP
, var_partp
- fragP
->fr_literal
, 4, fragP
->fr_symbol
,
1373 fragP
->fr_offset
+ 4, 1,
1374 reloctype
== BFD_RELOC_NONE
1375 ? BFD_RELOC_SH_IMM_MEDHI16_PCREL
1376 : reloctype
== BFD_RELOC_SH_GOTPC
1377 ? BFD_RELOC_SH_GOTPC_MEDHI16
1378 : reloctype
== BFD_RELOC_32_PLT_PCREL
1379 ? BFD_RELOC_SH_PLT_MEDHI16
1380 : (abort (), BFD_RELOC_SH_IMM_MEDHI16_PCREL
));
1381 fix_new (fragP
, var_partp
- fragP
->fr_literal
+ 4, 4,
1383 fragP
->fr_offset
+ 8, 1,
1384 reloctype
== BFD_RELOC_NONE
1385 ? BFD_RELOC_SH_IMM_MEDLOW16_PCREL
1386 : reloctype
== BFD_RELOC_SH_GOTPC
1387 ? BFD_RELOC_SH_GOTPC_MEDLOW16
1388 : reloctype
== BFD_RELOC_32_PLT_PCREL
1389 ? BFD_RELOC_SH_PLT_MEDLOW16
1390 : (abort (), BFD_RELOC_SH_IMM_MEDLOW16_PCREL
));
1391 fix_new (fragP
, var_partp
- fragP
->fr_literal
+ 8, 4,
1393 fragP
->fr_offset
+ 12, 1,
1394 reloctype
== BFD_RELOC_NONE
1395 ? BFD_RELOC_SH_IMM_LOW16_PCREL
1396 : reloctype
== BFD_RELOC_SH_GOTPC
1397 ? BFD_RELOC_SH_GOTPC_LOW16
1398 : reloctype
== BFD_RELOC_32_PLT_PCREL
1399 ? BFD_RELOC_SH_PLT_LOW16
1400 : (abort (), BFD_RELOC_SH_IMM_LOW16_PCREL
));
1407 BAD_CASE (fragP
->fr_subtype
);
1410 fragP
->fr_fix
+= var_part_size
;
1414 /* Mask NUMBER (originating from a signed number) corresponding to the HOW
1417 static unsigned long
1418 shmedia_mask_number (unsigned long number
, bfd_reloc_code_real_type how
)
1422 case BFD_RELOC_SH_IMMU5
:
1423 number
&= (1 << 5) - 1;
1426 case BFD_RELOC_SH_IMMS6
:
1427 case BFD_RELOC_SH_IMMU6
:
1428 number
&= (1 << 6) - 1;
1431 case BFD_RELOC_SH_IMMS6BY32
:
1432 number
= (number
& ((1 << (6 + 5)) - 1)) >> 5;
1435 case BFD_RELOC_SH_IMMS10
:
1436 number
&= (1 << 10) - 1;
1439 case BFD_RELOC_SH_IMMS10BY2
:
1440 number
= (number
& ((1 << (10 + 1)) - 1)) >> 1;
1443 case BFD_RELOC_SH_IMMS10BY4
:
1444 number
= (number
& ((1 << (10 + 2)) - 1)) >> 2;
1447 case BFD_RELOC_SH_IMMS10BY8
:
1448 number
= (number
& ((1 << (10 + 3)) - 1)) >> 3;
1451 case BFD_RELOC_SH_IMMS16
:
1452 case BFD_RELOC_SH_IMMU16
:
1453 number
&= (1 << 16) - 1;
1463 /* Emit errors for values out-of-range, using as_bad_where if FRAGP is
1464 non-NULL, as_bad otherwise. */
1467 shmedia_check_limits (offsetT
*valp
, bfd_reloc_code_real_type reloc
,
1470 offsetT val
= *valp
;
1476 case BFD_RELOC_SH_IMMU5
:
1477 if (val
< 0 || val
> (1 << 5) - 1)
1478 msg
= _("invalid operand, not a 5-bit unsigned value: %d");
1481 case BFD_RELOC_SH_IMMS6
:
1482 if (val
< -(1 << 5) || val
> (1 << 5) - 1)
1483 msg
= _("invalid operand, not a 6-bit signed value: %d");
1486 case BFD_RELOC_SH_IMMU6
:
1487 if (val
< 0 || val
> (1 << 6) - 1)
1488 msg
= _("invalid operand, not a 6-bit unsigned value: %d");
1491 case BFD_RELOC_SH_IMMS6BY32
:
1492 if (val
< -(1 << 10) || val
> (1 << 10) - 1)
1493 msg
= _("invalid operand, not a 11-bit signed value: %d");
1495 msg
= _("invalid operand, not a multiple of 32: %d");
1498 case BFD_RELOC_SH_IMMS10
:
1499 if (val
< -(1 << 9) || val
> (1 << 9) - 1)
1500 msg
= _("invalid operand, not a 10-bit signed value: %d");
1503 case BFD_RELOC_SH_IMMS10BY2
:
1504 if (val
< -(1 << 10) || val
> (1 << 10) - 1)
1505 msg
= _("invalid operand, not a 11-bit signed value: %d");
1507 msg
= _("invalid operand, not an even value: %d");
1510 case BFD_RELOC_SH_IMMS10BY4
:
1511 if (val
< -(1 << 11) || val
> (1 << 11) - 1)
1512 msg
= _("invalid operand, not a 12-bit signed value: %d");
1514 msg
= _("invalid operand, not a multiple of 4: %d");
1517 case BFD_RELOC_SH_IMMS10BY8
:
1518 if (val
< -(1 << 12) || val
> (1 << 12) - 1)
1519 msg
= _("invalid operand, not a 13-bit signed value: %d");
1521 msg
= _("invalid operand, not a multiple of 8: %d");
1524 case BFD_RELOC_SH_IMMS16
:
1525 if (val
< -(1 << 15) || val
> (1 << 15) - 1)
1526 msg
= _("invalid operand, not a 16-bit signed value: %d");
1529 case BFD_RELOC_SH_IMMU16
:
1530 if (val
< 0 || val
> (1 << 16) - 1)
1531 msg
= _("invalid operand, not an 16-bit unsigned value: %d");
1534 case BFD_RELOC_SH_PT_16
:
1535 case SHMEDIA_BFD_RELOC_PT
:
1536 if (val
< -(1 << 15) * 4 || val
> ((1 << 15) - 1) * 4 + 1)
1537 msg
= _("operand out of range for PT, PTA and PTB");
1538 else if ((val
% 4) != 0 && ((val
- 1) % 4) != 0)
1539 msg
= _("operand not a multiple of 4 for PT, PTA or PTB: %d");
1542 /* These have no limits; they take a 16-bit slice of a 32- or 64-bit
1544 case BFD_RELOC_SH_IMM_HI16
:
1545 case BFD_RELOC_SH_IMM_MEDHI16
:
1546 case BFD_RELOC_SH_IMM_MEDLOW16
:
1547 case BFD_RELOC_SH_IMM_LOW16
:
1548 case BFD_RELOC_SH_IMM_HI16_PCREL
:
1549 case BFD_RELOC_SH_IMM_MEDHI16_PCREL
:
1550 case BFD_RELOC_SH_IMM_MEDLOW16_PCREL
:
1551 case BFD_RELOC_SH_IMM_LOW16_PCREL
:
1553 case BFD_RELOC_SH_SHMEDIA_CODE
:
1556 /* This one has limits out of our reach. */
1567 as_bad_where (fixp
->fx_file
, fixp
->fx_line
, msg
, val
);
1573 /* Handle an immediate operand by checking limits and noting it for later
1574 evaluation if not computable yet, and return a bitfield suitable to
1575 "or" into the opcode (non-zero if the value was a constant number). */
1577 static unsigned long
1578 shmedia_immediate_op (char *where
, shmedia_operand_info
*op
, int pcrel
,
1579 bfd_reloc_code_real_type how
)
1581 unsigned long retval
= 0;
1583 /* If this is not an absolute number, make it a fixup. A constant in
1584 place of a pc-relative operand also needs a fixup. */
1585 if (op
->immediate
.X_op
!= O_constant
|| pcrel
)
1586 fix_new_exp (frag_now
,
1587 where
- frag_now
->fr_literal
,
1594 /* Check that the number is within limits as represented by the
1595 reloc, and return the number. */
1596 shmedia_check_limits (&op
->immediate
.X_add_number
, how
, NULL
);
1599 = shmedia_mask_number ((unsigned long) op
->immediate
.X_add_number
,
1603 return retval
<< 10;
1606 /* Try and parse a register name case-insensitively, return the number of
1610 shmedia_parse_reg (char *src
, int *mode
, int *reg
, shmedia_arg_type argtype
)
1612 int l0
= TOLOWER (src
[0]);
1613 int l1
= l0
? TOLOWER (src
[1]) : 0;
1617 if (src
[1] >= '1' && src
[1] <= '5')
1619 if (src
[2] >= '0' && src
[2] <= '9'
1620 && ! IDENT_CHAR ((unsigned char) src
[3]))
1623 *reg
= 10 * (src
[1] - '0') + src
[2] - '0';
1630 if (src
[2] >= '0' && src
[2] <= '3'
1631 && ! IDENT_CHAR ((unsigned char) src
[3]))
1634 *reg
= 60 + src
[2] - '0';
1639 if (src
[1] >= '0' && src
[1] <= '9'
1640 && ! IDENT_CHAR ((unsigned char) src
[2]))
1643 *reg
= (src
[1] - '0');
1648 if (l0
== 't' && l1
== 'r')
1650 if (src
[2] >= '0' && src
[2] <= '7'
1651 && ! IDENT_CHAR ((unsigned char) src
[3]))
1654 *reg
= (src
[2] - '0');
1659 if (l0
== 'f' && l1
== 'r')
1661 if (src
[2] >= '1' && src
[2] <= '5')
1663 if (src
[3] >= '0' && src
[3] <= '9'
1664 && ! IDENT_CHAR ((unsigned char) src
[4]))
1667 *reg
= 10 * (src
[2] - '0') + src
[3] - '0';
1673 if (src
[3] >= '0' && src
[3] <= '3'
1674 && ! IDENT_CHAR ((unsigned char) src
[4]))
1677 *reg
= 60 + src
[3] - '0';
1681 if (src
[2] >= '0' && src
[2] <= '9'
1682 && ! IDENT_CHAR ((unsigned char) src
[3]))
1685 *reg
= (src
[2] - '0');
1690 if (l0
== 'f' && l1
== 'v')
1692 if (src
[2] >= '1' && src
[2] <= '5')
1694 if (src
[3] >= '0' && src
[3] <= '9'
1695 && ((10 * (src
[2] - '0') + src
[3] - '0') % 4) == 0
1696 && ! IDENT_CHAR ((unsigned char) src
[4]))
1699 *reg
= 10 * (src
[2] - '0') + src
[3] - '0';
1706 && ! IDENT_CHAR ((unsigned char) src
[4]))
1709 *reg
= 60 + src
[3] - '0';
1713 if (src
[2] >= '0' && src
[2] <= '9'
1714 && ((src
[2] - '0') % 4) == 0
1715 && ! IDENT_CHAR ((unsigned char) src
[3]))
1718 *reg
= (src
[2] - '0');
1723 if (l0
== 'd' && l1
== 'r')
1725 if (src
[2] >= '1' && src
[2] <= '5')
1727 if (src
[3] >= '0' && src
[3] <= '9'
1728 && ((src
[3] - '0') % 2) == 0
1729 && ! IDENT_CHAR ((unsigned char) src
[4]))
1732 *reg
= 10 * (src
[2] - '0') + src
[3] - '0';
1739 if ((src
[3] == '0' || src
[3] == '2')
1740 && ! IDENT_CHAR ((unsigned char) src
[4]))
1743 *reg
= 60 + src
[3] - '0';
1748 if (src
[2] >= '0' && src
[2] <= '9'
1749 && ((src
[2] - '0') % 2) == 0
1750 && ! IDENT_CHAR ((unsigned char) src
[3]))
1753 *reg
= (src
[2] - '0');
1758 if (l0
== 'f' && l1
== 'p')
1760 if (src
[2] >= '1' && src
[2] <= '5')
1762 if (src
[3] >= '0' && src
[3] <= '9'
1763 && ((src
[3] - '0') % 2) == 0
1764 && ! IDENT_CHAR ((unsigned char) src
[4]))
1767 *reg
= 10 * (src
[2] - '0') + src
[3] - '0';
1774 if ((src
[3] == '0' || src
[3] == '2')
1775 && ! IDENT_CHAR ((unsigned char) src
[4]))
1778 *reg
= 60 + src
[3] - '0';
1783 if (src
[2] >= '0' && src
[2] <= '9'
1784 && ((src
[2] - '0') % 2) == 0
1785 && ! IDENT_CHAR ((unsigned char) src
[3]))
1788 *reg
= (src
[2] - '0');
1793 if (l0
== 'm' && strncasecmp (src
, "mtrx", 4) == 0)
1795 if (src
[4] == '0' && ! IDENT_CHAR ((unsigned char) src
[5]))
1802 if (src
[4] == '1' && src
[5] == '6'
1803 && ! IDENT_CHAR ((unsigned char) src
[6]))
1810 if (src
[4] == '3' && src
[5] == '2'
1811 && ! IDENT_CHAR ((unsigned char) src
[6]))
1818 if (src
[4] == '4' && src
[5] == '8'
1819 && ! IDENT_CHAR ((unsigned char) src
[6]))
1827 if (l0
== 'c' && l1
== 'r')
1829 if (src
[2] >= '1' && src
[2] <= '5')
1831 if (src
[3] >= '0' && src
[3] <= '9'
1832 && ! IDENT_CHAR ((unsigned char) src
[4]))
1835 *reg
= 10 * (src
[2] - '0') + src
[3] - '0';
1841 if (src
[3] >= '0' && src
[3] <= '3'
1842 && ! IDENT_CHAR ((unsigned char) src
[4]))
1845 *reg
= 60 + src
[3] - '0';
1849 if (src
[2] >= '0' && src
[2] <= '9'
1850 && ! IDENT_CHAR ((unsigned char) src
[3]))
1853 *reg
= (src
[2] - '0');
1858 /* We either have an error, a symbol or a control register by predefined
1859 name. To keep things simple but still fast for normal cases, we do
1860 linear search in the (not to big) table of predefined control
1861 registers. We only do this when we *expect* a control register.
1862 Those instructions should be rare enough that linear searching is ok.
1863 Or just read them into a hash-table in shmedia_md_begin. Since they
1864 cannot be specified in the same place of symbol operands, don't add
1865 them there to the *main* symbol table as being in "reg_section". */
1866 if (argtype
== A_CREG_J
|| argtype
== A_CREG_K
)
1868 const shmedia_creg_info
*cregp
;
1871 for (cregp
= shmedia_creg_table
; cregp
->name
!= NULL
; cregp
++)
1873 len
= strlen (cregp
->name
);
1874 if (strncasecmp (cregp
->name
, src
, len
) == 0
1875 && ! IDENT_CHAR (src
[len
]))
1879 if (cregp
->name
!= NULL
)
1882 *reg
= cregp
->cregno
;
1890 /* Called from md_estimate_size_before_relax in tc-sh.c */
1893 shmedia_md_estimate_size_before_relax (fragS
*fragP
,
1894 segT segment_type ATTRIBUTE_UNUSED
)
1899 /* For ELF, we can't relax externally visible symbols; see tc-i386.c. */
1900 bfd_boolean sym_relaxable
1902 && S_GET_SEGMENT (fragP
->fr_symbol
) == segment_type
1903 && ! S_IS_EXTERNAL (fragP
->fr_symbol
)
1904 && ! S_IS_WEAK (fragP
->fr_symbol
));
1906 old_fr_fix
= fragP
->fr_fix
;
1908 switch (fragP
->fr_subtype
)
1910 case C (SH64PCREL16_32
, UNDEF_SH64PCREL
):
1911 case C (SH64PCREL16PT_32
, UNDEF_SH64PCREL
):
1912 /* Used to be to somewhere which was unknown. */
1915 int what
= GET_WHAT (fragP
->fr_subtype
);
1917 /* In this segment, so head for shortest. */
1918 fragP
->fr_subtype
= C (what
, SH64PCREL16
);
1922 int what
= GET_WHAT (fragP
->fr_subtype
);
1923 /* We know the abs value, but we don't know where we will be
1924 linked, so we must make it the longest. Presumably we could
1925 switch to a non-pcrel representation, but having absolute
1926 values in PT operands should be rare enough not to be worth
1927 adding that code. */
1928 fragP
->fr_subtype
= C (what
, SH64PCREL32
);
1930 fragP
->fr_var
= md_relax_table
[fragP
->fr_subtype
].rlx_length
;
1933 case C (SH64PCREL16_64
, UNDEF_SH64PCREL
):
1934 case C (SH64PCREL16PT_64
, UNDEF_SH64PCREL
):
1935 /* Used to be to somewhere which was unknown. */
1938 int what
= GET_WHAT (fragP
->fr_subtype
);
1940 /* In this segment, so head for shortest. */
1941 fragP
->fr_subtype
= C (what
, SH64PCREL16
);
1945 int what
= GET_WHAT (fragP
->fr_subtype
);
1946 /* We know the abs value, but we don't know where we will be
1947 linked, so we must make it the longest. Presumably we could
1948 switch to a non-pcrel representation, but having absolute
1949 values in PT operands should be rare enough not to be worth
1950 adding that code. */
1951 fragP
->fr_subtype
= C (what
, SH64PCREL64
);
1953 fragP
->fr_var
= md_relax_table
[fragP
->fr_subtype
].rlx_length
;
1956 case C (MOVI_IMM_64
, UNDEF_MOVI
):
1957 case C (MOVI_IMM_32
, UNDEF_MOVI
):
1960 /* Look inside the "symbol". If we find a PC-relative expression,
1961 change this to a PC-relative, relaxable expression. */
1962 if (fragP
->fr_symbol
!= NULL
1963 && (exp
= symbol_get_value_expression (fragP
->fr_symbol
)) != NULL
1964 && exp
->X_op
== O_subtract
1965 && exp
->X_op_symbol
!= NULL
1966 && S_GET_SEGMENT (exp
->X_op_symbol
) == segment_type
)
1968 int what
= GET_WHAT (fragP
->fr_subtype
);
1969 int what_high
= what
== MOVI_IMM_32
? MOVI_32
: MOVI_64
;
1971 = symbol_get_value_expression (exp
->X_op_symbol
);
1973 = symbol_get_value_expression (exp
->X_add_symbol
);
1975 /* Change the MOVI expression to the "X" in "X - Y" and subtract
1976 Y:s offset to this location from X. Note that we can only
1977 allow an Y which is offset from this frag. */
1980 && opexp
->X_op
== O_constant
1981 && fragP
== symbol_get_frag (exp
->X_op_symbol
))
1983 /* At this point, before relaxing, the add-number of opexp
1984 is the offset from the fr_fix part. */
1986 = (exp
->X_add_number
1987 - (opexp
->X_add_number
- (fragP
->fr_fix
- 4)));
1988 fragP
->fr_symbol
= exp
->X_add_symbol
;
1990 what
= what
== MOVI_IMM_32
1991 ? MOVI_IMM_32_PCREL
: MOVI_IMM_64_PCREL
;
1993 /* Check the "X" symbol to estimate the size of this
1994 PC-relative expression. */
1995 if (S_GET_SEGMENT (exp
->X_add_symbol
) == segment_type
1996 && ! S_IS_EXTERNAL (exp
->X_add_symbol
)
1997 && ! S_IS_WEAK (exp
->X_add_symbol
))
1998 fragP
->fr_subtype
= C (what
, MOVI_16
);
2000 fragP
->fr_subtype
= C (what
, what_high
);
2002 /* This is now a PC-relative expression, fit to be relaxed. */
2005 fragP
->fr_subtype
= C (what
, what_high
);
2007 else if (fragP
->fr_symbol
== NULL
2008 || (S_GET_SEGMENT (fragP
->fr_symbol
) == absolute_section
2009 && exp
->X_op
== O_constant
))
2012 = (target_big_endian
2013 ? bfd_getb32 (fragP
->fr_opcode
)
2014 : bfd_getl32 (fragP
->fr_opcode
));
2015 offsetT one
= (offsetT
) 1;
2016 offsetT value
= fragP
->fr_offset
2017 + (fragP
->fr_symbol
== NULL
? 0 : S_GET_VALUE (fragP
->fr_symbol
));
2019 if (value
>= ((offsetT
) -1 << 15) && value
< ((offsetT
) 1 << 15))
2021 /* Fits in 16-bit signed number. */
2022 int what
= GET_WHAT (fragP
->fr_subtype
);
2023 fragP
->fr_subtype
= C (what
, MOVI_16
);
2025 /* Just "or" in the value. */
2026 md_number_to_chars (fragP
->fr_opcode
,
2027 insn
| ((value
& ((1 << 16) - 1)) << 10),
2030 else if (value
>= -(one
<< 31)
2031 && (value
< (one
<< 31)
2032 || (sh64_abi
== sh64_abi_32
&& value
< (one
<< 32))))
2034 /* The value fits in a 32-bit signed number. */
2035 int reg
= (insn
>> 4) & 0x3f;
2037 /* Just "or" in the high bits of the value, making the first
2039 md_number_to_chars (fragP
->fr_opcode
,
2041 | (((value
>> 16) & ((1 << 16) - 1)) << 10),
2044 /* Add a SHORI with the low bits. Note that this insn lives
2045 in the variable fragment part. */
2046 md_number_to_chars (fragP
->fr_literal
+ old_fr_fix
,
2049 | ((value
& ((1 << 16) - 1)) << 10),
2052 /* We took a piece of the variable part. */
2055 else if (GET_WHAT (fragP
->fr_subtype
) == MOVI_IMM_32
)
2057 /* Value out of range. */
2058 as_bad_where (fragP
->fr_file
, fragP
->fr_line
,
2059 _("MOVI operand is not a 32-bit signed value: 0x%8x%08x"),
2060 ((unsigned int) (value
>> 32)
2061 & (unsigned int) 0xffffffff),
2062 (unsigned int) value
& (unsigned int) 0xffffffff);
2064 /* Must advance size, or we will get internal inconsistency
2065 and fall into an assert. */
2068 /* Now we know we are allowed to expand to 48- and 64-bit values. */
2069 else if (value
>= -(one
<< 47) && value
< (one
<< 47))
2071 /* The value fits in a 48-bit signed number. */
2072 int reg
= (insn
>> 4) & 0x3f;
2074 /* Just "or" in the high bits of the value, making the first
2076 md_number_to_chars (fragP
->fr_opcode
,
2078 | (((value
>> 32) & ((1 << 16) - 1)) << 10),
2081 /* Add a SHORI with the middle bits. Note that this insn lives
2082 in the variable fragment part. */
2083 md_number_to_chars (fragP
->fr_literal
+ old_fr_fix
,
2086 | (((value
>> 16) & ((1 << 16) - 1)) << 10),
2089 /* Add a SHORI with the low bits. */
2090 md_number_to_chars (fragP
->fr_literal
+ old_fr_fix
+ 4,
2093 | ((value
& ((1 << 16) - 1)) << 10),
2096 /* We took a piece of the variable part. */
2101 /* A 64-bit number. */
2102 int reg
= (insn
>> 4) & 0x3f;
2104 /* Just "or" in the high bits of the value, making the first
2106 md_number_to_chars (fragP
->fr_opcode
,
2108 | (((value
>> 48) & ((1 << 16) - 1)) << 10),
2111 /* Add a SHORI with the midhigh bits. Note that this insn lives
2112 in the variable fragment part. */
2113 md_number_to_chars (fragP
->fr_literal
+ old_fr_fix
,
2116 | (((value
>> 32) & ((1 << 16) - 1)) << 10),
2119 /* Add a SHORI with the midlow bits. */
2120 md_number_to_chars (fragP
->fr_literal
+ old_fr_fix
+ 4,
2123 | (((value
>> 16) & ((1 << 16) - 1)) << 10),
2126 /* Add a SHORI with the low bits. */
2127 md_number_to_chars (fragP
->fr_literal
+ old_fr_fix
+ 8,
2130 | ((value
& ((1 << 16) - 1)) << 10), 4);
2131 /* We took all of the variable part. */
2132 fragP
->fr_fix
+= 12;
2135 /* MOVI expansions that get here have not been converted to
2136 PC-relative frags, but instead expanded by
2137 md_number_to_chars or by calling shmedia_md_convert_frag
2138 with final == FALSE. We must not have them around as
2139 frags anymore; symbols would be prematurely evaluated
2140 when relaxing. We will not need to have md_convert_frag
2141 called again with them; any further handling is through
2142 the already emitted fixups. */
2146 fragP
->fr_var
= md_relax_table
[fragP
->fr_subtype
].rlx_length
;
2149 /* For relaxation states that remain unchanged, report the
2150 estimated length. */
2151 case C (SH64PCREL16_32
, SH64PCREL16
):
2152 case C (SH64PCREL16PT_32
, SH64PCREL16
):
2153 case C (SH64PCREL16_32
, SH64PCREL32
):
2154 case C (SH64PCREL16PT_32
, SH64PCREL32
):
2155 case C (SH64PCREL16_32
, SH64PCRELPLT
):
2156 case C (SH64PCREL16PT_32
, SH64PCRELPLT
):
2157 case C (SH64PCREL16_64
, SH64PCREL16
):
2158 case C (SH64PCREL16PT_64
, SH64PCREL16
):
2159 case C (SH64PCREL16_64
, SH64PCREL32
):
2160 case C (SH64PCREL16PT_64
, SH64PCREL32
):
2161 case C (SH64PCREL16_64
, SH64PCREL48
):
2162 case C (SH64PCREL16PT_64
, SH64PCREL48
):
2163 case C (SH64PCREL16_64
, SH64PCREL64
):
2164 case C (SH64PCREL16PT_64
, SH64PCREL64
):
2165 case C (SH64PCREL16_64
, SH64PCRELPLT
):
2166 case C (SH64PCREL16PT_64
, SH64PCRELPLT
):
2167 case C (MOVI_IMM_32
, MOVI_16
):
2168 case C (MOVI_IMM_32
, MOVI_32
):
2169 case C (MOVI_IMM_32
, MOVI_GOTOFF
):
2170 case C (MOVI_IMM_32_PCREL
, MOVI_16
):
2171 case C (MOVI_IMM_32_PCREL
, MOVI_32
):
2172 case C (MOVI_IMM_32_PCREL
, MOVI_PLT
):
2173 case C (MOVI_IMM_32_PCREL
, MOVI_GOTPC
):
2174 case C (MOVI_IMM_64
, MOVI_16
):
2175 case C (MOVI_IMM_64
, MOVI_32
):
2176 case C (MOVI_IMM_64
, MOVI_48
):
2177 case C (MOVI_IMM_64
, MOVI_64
):
2178 case C (MOVI_IMM_64
, MOVI_GOTOFF
):
2179 case C (MOVI_IMM_64_PCREL
, MOVI_16
):
2180 case C (MOVI_IMM_64_PCREL
, MOVI_32
):
2181 case C (MOVI_IMM_64_PCREL
, MOVI_48
):
2182 case C (MOVI_IMM_64_PCREL
, MOVI_64
):
2183 case C (MOVI_IMM_64_PCREL
, MOVI_PLT
):
2184 case C (MOVI_IMM_64_PCREL
, MOVI_GOTPC
):
2185 fragP
->fr_var
= md_relax_table
[fragP
->fr_subtype
].rlx_length
;
2192 return fragP
->fr_var
+ (fragP
->fr_fix
- old_fr_fix
);
2195 /* Parse an expression, SH64-style. Copied from tc-sh.c, but with
2196 datatypes adjusted. */
2199 shmedia_parse_exp (char *s
, shmedia_operand_info
*op
)
2204 save
= input_line_pointer
;
2205 input_line_pointer
= s
;
2206 expression (&op
->immediate
);
2207 if (op
->immediate
.X_op
== O_absent
)
2208 as_bad (_("missing operand"));
2209 new = input_line_pointer
;
2210 input_line_pointer
= save
;
2214 /* Parse an operand. Store pointer to next character in *PTR. */
2217 shmedia_get_operand (char **ptr
, shmedia_operand_info
*op
,
2218 shmedia_arg_type argtype
)
2224 len
= shmedia_parse_reg (src
, &mode
, &(op
->reg
), argtype
);
2232 /* Not a reg, so it must be a displacement. */
2233 *ptr
= shmedia_parse_exp (src
, op
);
2236 /* This is just an initialization; shmedia_get_operands will change
2238 op
->reloctype
= BFD_RELOC_NONE
;
2242 /* Parse the operands for this insn; return NULL if invalid, else return
2243 how much text was consumed. */
2246 shmedia_get_operands (shmedia_opcode_info
*info
, char *args
,
2247 shmedia_operands_info
*operands
)
2255 for (i
= 0; info
->arg
[i
] != 0; i
++)
2257 memset (operands
->operands
+ i
, 0, sizeof (operands
->operands
[0]));
2259 /* No operand to get for these fields. */
2260 if (info
->arg
[i
] == A_REUSE_PREV
)
2263 shmedia_get_operand (&ptr
, &operands
->operands
[i
], info
->arg
[i
]);
2265 /* Check operands type match. */
2266 switch (info
->arg
[i
])
2271 if (operands
->operands
[i
].type
!= A_GREG_M
)
2278 if (operands
->operands
[i
].type
!= A_FREG_G
)
2285 if (operands
->operands
[i
].type
!= A_FVREG_G
)
2292 if (operands
->operands
[i
].type
!= A_FMREG_G
)
2299 if (operands
->operands
[i
].type
!= A_FPREG_G
)
2306 if (operands
->operands
[i
].type
!= A_DREG_G
)
2312 if (operands
->operands
[i
].type
!= A_TREG_B
)
2318 if (operands
->operands
[i
].type
!= A_CREG_K
)
2324 /* Check for an expression that looks like S & 65535 or
2325 (S >> N) & 65535, where N = 0, 16, 32, 48.
2327 Get the S and put at operands->operands[i].immediate, and
2328 adjust operands->operands[i].reloctype. */
2330 expressionS
*imm_expr
= &operands
->operands
[i
].immediate
;
2331 expressionS
*right_expr
;
2333 if (operands
->operands
[i
].type
== A_IMMM
2334 && imm_expr
->X_op
== O_bit_and
2335 && imm_expr
->X_op_symbol
!= NULL
2337 = symbol_get_value_expression (imm_expr
->X_op_symbol
))
2338 ->X_op
== O_constant
)
2339 && right_expr
->X_add_number
== 0xffff)
2341 symbolS
*inner
= imm_expr
->X_add_symbol
;
2342 bfd_reloc_code_real_type reloctype
= BFD_RELOC_SH_IMM_LOW16
;
2343 expressionS
*inner_expr
2344 = symbol_get_value_expression (inner
);
2346 if (inner_expr
->X_op
== O_right_shift
)
2348 expressionS
*inner_right
;
2350 if (inner_expr
->X_op_symbol
!= NULL
2352 = symbol_get_value_expression (inner_expr
2354 ->X_op
== O_constant
))
2357 = inner_right
->X_add_number
;
2359 if (addnum
== 0 || addnum
== 16 || addnum
== 32
2364 ? BFD_RELOC_SH_IMM_LOW16
2366 ? BFD_RELOC_SH_IMM_MEDLOW16
2368 ? BFD_RELOC_SH_IMM_MEDHI16
2369 : BFD_RELOC_SH_IMM_HI16
)));
2371 inner
= inner_expr
->X_add_symbol
;
2372 inner_expr
= symbol_get_value_expression (inner
);
2377 /* I'm not sure I understand the logic, but evidently the
2378 inner expression of a lone symbol is O_constant, with
2379 the actual symbol in expr_section. For a constant, the
2380 section would be absolute_section. For sym+offset,
2381 it's O_symbol as always. See expr.c:make_expr_symbol,
2382 first statements. */
2384 if (inner_expr
->X_op
== O_constant
2385 && S_GET_SEGMENT (inner
) != absolute_section
)
2387 operands
->operands
[i
].immediate
.X_op
= O_symbol
;
2388 operands
->operands
[i
].immediate
.X_add_symbol
= inner
;
2389 operands
->operands
[i
].immediate
.X_add_number
= 0;
2392 operands
->operands
[i
].immediate
2393 = *symbol_get_value_expression (inner
);
2395 operands
->operands
[i
].reloctype
= reloctype
;
2407 case A_PCIMMS16BY4_PT
:
2410 if (operands
->operands
[i
].type
!= A_IMMM
)
2413 if (sh_check_fixup (&operands
->operands
[i
].immediate
,
2414 &operands
->operands
[i
].reloctype
))
2416 as_bad (_("invalid PIC reference"));
2423 BAD_CASE (info
->arg
[i
]);
2426 if (*ptr
== ',' && info
->arg
[i
+ 1])
2433 /* Find an opcode at the start of *STR_P in the hash table, and set
2434 *STR_P to the first character after the last one read. */
2436 static shmedia_opcode_info
*
2437 shmedia_find_cooked_opcode (char **str_p
)
2443 unsigned int nlen
= 0;
2445 /* Drop leading whitespace. */
2449 /* Find the op code end. */
2450 for (op_start
= op_end
= str
;
2452 && nlen
< sizeof (name
) - 1
2453 && ! is_end_of_line
[(unsigned char) *op_end
]
2454 && ! ISSPACE ((unsigned char) *op_end
);
2457 unsigned char c
= op_start
[nlen
];
2459 /* The machine independent code will convert CMP/EQ into cmp/EQ
2460 because it thinks the '/' is the end of the symbol. Moreover,
2461 all but the first sub-insn is a parallel processing insn won't
2462 be capitalized. Instead of hacking up the machine independent
2463 code, we just deal with it here. */
2473 as_bad (_("can't find opcode"));
2476 (shmedia_opcode_info
*) hash_find (shmedia_opcode_hash_control
, name
);
2479 /* Build up an instruction, including allocating the frag. */
2482 shmedia_build_Mytes (shmedia_opcode_info
*opcode
,
2483 shmedia_operands_info
*operands
)
2485 unsigned long insn
= opcode
->opcode_base
;
2487 char *insn_loc
= frag_more (4);
2489 /* The parameter to dwarf2_emit_insn is actually the offset to the start
2490 of the insn from the fix piece of instruction that was emitted.
2491 Since we want .debug_line addresses to record (address | 1) for
2492 SHmedia insns, we get the wanted effect by taking one off the size,
2493 knowing it's a multiple of 4. We count from the first fix piece of
2494 the insn. There must be no frags changes (frag_more or frag_var)
2495 calls in-between the frag_more call we account for, and this
2496 dwarf2_emit_insn call. */
2497 dwarf2_emit_insn (3);
2499 /* This is stored into any frag_var operand. */
2500 sh64_last_insn_frag
= frag_now
;
2502 /* Loop over opcode info, emit an instruction. */
2503 for (i
= 0, j
= 0; opcode
->arg
[i
]; i
++)
2505 shmedia_arg_type argtype
= opcode
->arg
[i
];
2506 shmedia_operand_info
*opjp
= &operands
->operands
[j
];
2531 /* Six-bit register fields. They just get filled with the
2532 parsed register number. */
2533 insn
|= (opjp
->reg
<< opcode
->nibbles
[i
]);
2538 /* Copy the register for the previous operand to this position. */
2539 insn
|= (operands
->operands
[j
- 1].reg
<< opcode
->nibbles
[i
]);
2544 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2545 BFD_RELOC_SH_IMMS6
);
2550 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2551 BFD_RELOC_SH_IMMS6BY32
);
2557 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2558 BFD_RELOC_SH_IMMS10
);
2563 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2564 BFD_RELOC_SH_IMMS10BY2
);
2569 if (opjp
->reloctype
== BFD_RELOC_NONE
)
2570 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2571 BFD_RELOC_SH_IMMS10BY4
);
2572 else if (opjp
->reloctype
== BFD_RELOC_SH_GOTPLT32
)
2573 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2574 BFD_RELOC_SH_GOTPLT10BY4
);
2575 else if (opjp
->reloctype
== BFD_RELOC_32_GOT_PCREL
)
2576 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2577 BFD_RELOC_SH_GOT10BY4
);
2579 as_bad (_("invalid PIC reference"));
2584 if (opjp
->reloctype
== BFD_RELOC_NONE
)
2585 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2586 BFD_RELOC_SH_IMMS10BY8
);
2587 else if (opjp
->reloctype
== BFD_RELOC_SH_GOTPLT32
)
2588 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2589 BFD_RELOC_SH_GOTPLT10BY8
);
2590 else if (opjp
->reloctype
== BFD_RELOC_32_GOT_PCREL
)
2591 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2592 BFD_RELOC_SH_GOT10BY8
);
2594 as_bad (_("invalid PIC reference"));
2599 /* Sneak a peek if this is the MOVI insn. If so, check if we
2600 should expand it. */
2601 if (opjp
->reloctype
== BFD_RELOC_32_GOT_PCREL
)
2602 opjp
->reloctype
= BFD_RELOC_SH_GOT_LOW16
;
2603 else if (opjp
->reloctype
== BFD_RELOC_SH_GOTPLT32
)
2604 opjp
->reloctype
= BFD_RELOC_SH_GOTPLT_LOW16
;
2606 if ((opjp
->reloctype
== BFD_RELOC_NONE
2607 || opjp
->reloctype
== BFD_RELOC_32_GOTOFF
2608 || opjp
->reloctype
== BFD_RELOC_32_PLT_PCREL
2609 || opjp
->reloctype
== BFD_RELOC_SH_GOTPC
)
2610 && opcode
->opcode_base
== SHMEDIA_MOVI_OPC
2611 && (opjp
->immediate
.X_op
!= O_constant
2612 || opjp
->immediate
.X_add_number
< -32768
2613 || opjp
->immediate
.X_add_number
> 32767)
2615 || opjp
->reloctype
== BFD_RELOC_32_GOTOFF
2616 || opjp
->reloctype
== BFD_RELOC_32_PLT_PCREL
2617 || opjp
->reloctype
== BFD_RELOC_SH_GOTPC
))
2619 int what
= sh64_abi
== sh64_abi_64
? MOVI_IMM_64
: MOVI_IMM_32
;
2620 offsetT max
= sh64_abi
== sh64_abi_64
? MOVI_64
: MOVI_32
;
2621 offsetT min
= MOVI_16
;
2622 offsetT init
= UNDEF_MOVI
;
2624 = opjp
->immediate
.X_op_symbol
!= NULL
2625 ? 0 : opjp
->immediate
.X_add_number
;
2627 = opjp
->immediate
.X_op_symbol
!= NULL
2628 ? make_expr_symbol (&opjp
->immediate
)
2629 : opjp
->immediate
.X_add_symbol
;
2631 if (opjp
->reloctype
== BFD_RELOC_32_GOTOFF
)
2632 init
= max
= min
= MOVI_GOTOFF
;
2633 else if (opjp
->reloctype
== BFD_RELOC_32_PLT_PCREL
)
2635 init
= max
= min
= MOVI_PLT
;
2636 what
= (sh64_abi
== sh64_abi_64
2638 : MOVI_IMM_32_PCREL
);
2640 else if (opjp
->reloctype
== BFD_RELOC_SH_GOTPC
)
2642 init
= max
= min
= MOVI_GOTPC
;
2643 what
= (sh64_abi
== sh64_abi_64
2645 : MOVI_IMM_32_PCREL
);
2648 frag_var (rs_machine_dependent
,
2649 md_relax_table
[C (what
, max
)].rlx_length
,
2650 md_relax_table
[C (what
, min
)].rlx_length
,
2651 C (what
, init
), sym
, addvalue
, insn_loc
);
2654 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2657 ? BFD_RELOC_SH_IMMS16
2665 = ((sh64_abi
== sh64_abi_64
&& ! sh64_pt32
)
2666 ? SH64PCREL16_64
: SH64PCREL16_32
);
2668 = ((sh64_abi
== sh64_abi_64
&& ! sh64_pt32
)
2669 ? SH64PCREL64
: SH64PCREL32
);
2670 offsetT min
= SH64PCREL16
;
2671 offsetT init
= UNDEF_SH64PCREL
;
2673 /* Don't allow complex expressions here. */
2674 if (opjp
->immediate
.X_op_symbol
!= NULL
)
2677 if (opjp
->reloctype
== BFD_RELOC_32_PLT_PCREL
)
2678 init
= max
= min
= SH64PCRELPLT
;
2680 /* If we're not expanding, then just emit a fixup. */
2681 if (sh64_expand
|| opjp
->reloctype
!= BFD_RELOC_NONE
)
2682 frag_var (rs_machine_dependent
,
2683 md_relax_table
[C (what
, max
)].rlx_length
,
2684 md_relax_table
[C (what
, min
)].rlx_length
,
2686 opjp
->immediate
.X_add_symbol
,
2687 opjp
->immediate
.X_add_number
,
2690 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 1,
2691 opjp
->reloctype
== BFD_RELOC_NONE
2692 ? BFD_RELOC_SH_PT_16
2699 case A_PCIMMS16BY4_PT
:
2702 = ((sh64_abi
== sh64_abi_64
&& ! sh64_pt32
)
2703 ? SH64PCREL16PT_64
: SH64PCREL16PT_32
);
2705 = ((sh64_abi
== sh64_abi_64
&& ! sh64_pt32
)
2706 ? SH64PCREL64
: SH64PCREL32
);
2707 offsetT min
= SH64PCREL16
;
2708 offsetT init
= UNDEF_SH64PCREL
;
2710 /* Don't allow complex expressions here. */
2711 if (opjp
->immediate
.X_op_symbol
!= NULL
)
2714 if (opjp
->reloctype
== BFD_RELOC_32_PLT_PCREL
)
2715 init
= max
= min
= SH64PCRELPLT
;
2717 /* If we're not expanding, then just emit a fixup. */
2718 if (sh64_expand
|| opjp
->reloctype
!= BFD_RELOC_NONE
)
2719 frag_var (rs_machine_dependent
,
2720 md_relax_table
[C (what
, max
)].rlx_length
,
2721 md_relax_table
[C (what
, min
)].rlx_length
,
2723 opjp
->immediate
.X_add_symbol
,
2724 opjp
->immediate
.X_add_number
,
2727 /* This reloc-type is just temporary, so we can distinguish
2728 PTA from PT. It is changed in shmedia_md_apply_fix3 to
2729 BFD_RELOC_SH_PT_16. */
2730 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 1,
2731 opjp
->reloctype
== BFD_RELOC_NONE
2732 ? SHMEDIA_BFD_RELOC_PT
2740 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2741 BFD_RELOC_SH_IMMU5
);
2746 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2747 BFD_RELOC_SH_IMMU6
);
2752 insn
|= shmedia_immediate_op (insn_loc
, opjp
, 0,
2755 ? BFD_RELOC_SH_IMMU16
2765 md_number_to_chars (insn_loc
, insn
, 4);
2769 /* Assemble a SHmedia instruction. */
2772 shmedia_md_assemble (char *str
)
2775 shmedia_opcode_info
*opcode
;
2776 shmedia_operands_info operands
;
2779 opcode
= shmedia_find_cooked_opcode (&str
);
2784 as_bad (_("unknown opcode"));
2788 /* Start a SHmedia code region, if there has been pseudoinsns or similar
2789 seen since the last one. */
2792 sh64_update_contents_mark (TRUE
);
2793 sh64_set_contents_type (CRT_SH5_ISA32
);
2797 op_end
= shmedia_get_operands (opcode
, op_end
, &operands
);
2801 as_bad (_("invalid operands to %s"), opcode
->name
);
2807 as_bad (_("excess operands to %s"), opcode
->name
);
2811 size
= shmedia_build_Mytes (opcode
, &operands
);
2816 /* Hook called from md_begin in tc-sh.c. */
2819 shmedia_md_begin (void)
2821 const shmedia_opcode_info
*shmedia_opcode
;
2822 shmedia_opcode_hash_control
= hash_new ();
2824 /* Create opcode table for SHmedia mnemonics. */
2825 for (shmedia_opcode
= shmedia_table
;
2826 shmedia_opcode
->name
;
2828 hash_insert (shmedia_opcode_hash_control
, shmedia_opcode
->name
,
2829 (char *) shmedia_opcode
);
2832 /* Switch instruction set. Only valid if one of the --isa or --abi
2833 options was specified. */
2836 s_sh64_mode (int ignore ATTRIBUTE_UNUSED
)
2838 char *name
= input_line_pointer
, ch
;
2840 /* Make sure data up to this location is handled according to the
2842 sh64_update_contents_mark (TRUE
);
2844 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2845 input_line_pointer
++;
2846 ch
= *input_line_pointer
;
2847 *input_line_pointer
= '\0';
2849 /* If the mode was not set before, explicitly or implicitly, then we're
2850 not emitting SH64 code, so this pseudo is invalid. */
2851 if (sh64_isa_mode
== sh64_isa_unspecified
)
2852 as_bad (_("The `.mode %s' directive is not valid with this architecture"),
2855 if (strcasecmp (name
, "shcompact") == 0)
2856 sh64_isa_mode
= sh64_isa_shcompact
;
2857 else if (strcasecmp (name
, "shmedia") == 0)
2858 sh64_isa_mode
= sh64_isa_shmedia
;
2860 as_bad (_("Invalid argument to .mode: %s"), name
);
2862 /* Make a new frag, marking it with the supposedly-changed ISA. */
2863 frag_wane (frag_now
);
2866 /* Contents type up to this new point is the same as before; don't add a
2867 data region just because the new frag we created. */
2868 sh64_update_contents_mark (FALSE
);
2870 *input_line_pointer
= ch
;
2871 demand_empty_rest_of_line ();
2874 /* Check that the right ABI is used. Only valid if one of the --isa or
2875 --abi options was specified. */
2878 s_sh64_abi (int ignore ATTRIBUTE_UNUSED
)
2880 char *name
= input_line_pointer
, ch
;
2882 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2883 input_line_pointer
++;
2884 ch
= *input_line_pointer
;
2885 *input_line_pointer
= '\0';
2887 /* If the mode was not set before, explicitly or implicitly, then we're
2888 not emitting SH64 code, so this pseudo is invalid. */
2889 if (sh64_abi
== sh64_abi_unspecified
)
2890 as_bad (_("The `.abi %s' directive is not valid with this architecture"),
2893 if (strcmp (name
, "64") == 0)
2895 if (sh64_abi
!= sh64_abi_64
)
2896 as_bad (_("`.abi 64' but command-line options do not specify 64-bit ABI"));
2898 else if (strcmp (name
, "32") == 0)
2900 if (sh64_abi
!= sh64_abi_32
)
2901 as_bad (_("`.abi 32' but command-line options do not specify 32-bit ABI"));
2904 as_bad (_("Invalid argument to .abi: %s"), name
);
2906 *input_line_pointer
= ch
;
2907 demand_empty_rest_of_line ();
2910 /* This function is the first target-specific function called after
2911 parsing command-line options. Therefore we set default values from
2912 command-line options here and do some sanity checking we couldn't do
2913 when options were being parsed. */
2916 sh64_target_format (void)
2919 /* For NetBSD, if the ISA is unspecified, always use SHmedia. */
2920 if (sh64_isa_mode
== sh64_isa_unspecified
)
2921 sh64_isa_mode
= sh64_isa_shmedia
;
2923 /* If the ABI is unspecified, select a default: based on how
2924 we were configured: sh64 == sh64_abi_64, else sh64_abi_32. */
2925 if (sh64_abi
== sh64_abi_unspecified
)
2927 if (sh64_isa_mode
== sh64_isa_shcompact
)
2928 sh64_abi
= sh64_abi_32
;
2929 else if (strncmp (TARGET_CPU
, "sh64", 4) == 0)
2930 sh64_abi
= sh64_abi_64
;
2932 sh64_abi
= sh64_abi_32
;
2937 if (sh64_isa_mode
== sh64_isa_unspecified
)
2938 sh64_isa_mode
= sh64_isa_shmedia
;
2940 if (sh64_abi
== sh64_abi_unspecified
)
2941 sh64_abi
= sh64_abi_32
;
2944 if (sh64_abi
== sh64_abi_64
&& sh64_isa_mode
== sh64_isa_unspecified
)
2945 sh64_isa_mode
= sh64_isa_shmedia
;
2947 if (sh64_abi
== sh64_abi_32
&& sh64_isa_mode
== sh64_isa_unspecified
)
2948 sh64_isa_mode
= sh64_isa_shcompact
;
2950 if (sh64_isa_mode
== sh64_isa_shcompact
2951 && sh64_abi
== sh64_abi_unspecified
)
2952 sh64_abi
= sh64_abi_32
;
2954 if (sh64_isa_mode
== sh64_isa_shmedia
2955 && sh64_abi
== sh64_abi_unspecified
)
2956 sh64_abi
= sh64_abi_64
;
2958 if (sh64_isa_mode
== sh64_isa_unspecified
&& ! sh64_mix
)
2959 as_bad (_("-no-mix is invalid without specifying SHcompact or SHmedia"));
2961 if ((sh64_isa_mode
== sh64_isa_unspecified
2962 || sh64_isa_mode
== sh64_isa_shmedia
)
2963 && sh64_shcompact_const_crange
)
2964 as_bad (_("-shcompact-const-crange is invalid without SHcompact"));
2966 if (sh64_pt32
&& sh64_abi
!= sh64_abi_64
)
2967 as_bad (_("-expand-pt32 only valid with -abi=64"));
2969 if (! sh64_expand
&& sh64_isa_mode
== sh64_isa_unspecified
)
2970 as_bad (_("-no-expand only valid with SHcompact or SHmedia"));
2972 if (sh64_pt32
&& ! sh64_expand
)
2973 as_bad (_("-expand-pt32 invalid together with -no-expand"));
2976 if (sh64_abi
== sh64_abi_64
)
2977 return (target_big_endian
? "elf64-sh64-nbsd" : "elf64-sh64l-nbsd");
2979 return (target_big_endian
? "elf32-sh64-nbsd" : "elf32-sh64l-nbsd");
2980 #elif defined (TE_LINUX)
2981 if (sh64_abi
== sh64_abi_64
)
2982 return (target_big_endian
? "elf64-sh64big-linux" : "elf64-sh64-linux");
2984 return (target_big_endian
? "elf32-sh64big-linux" : "elf32-sh64-linux");
2986 /* When the ISA is not one of SHmedia or SHcompact, use the old SH
2988 if (sh64_isa_mode
== sh64_isa_unspecified
)
2989 return (target_big_endian
? "elf32-sh" : "elf32-shl");
2990 else if (sh64_abi
== sh64_abi_64
)
2991 return (target_big_endian
? "elf64-sh64" : "elf64-sh64l");
2993 return (target_big_endian
? "elf32-sh64" : "elf32-sh64l");
2997 /* The worker function of TARGET_MACH. */
3000 sh64_target_mach (void)
3002 /* We need to explicitly set bfd_mach_sh5 instead of the default 0. But
3003 we only do this for the 64-bit ABI: if we do it for the 32-bit ABI,
3004 the SH5 info in the bfd_arch_info structure will be selected.
3005 However correct, as the machine has 64-bit addresses, functions
3006 expected to emit 32-bit data for addresses will start failing. For
3007 example, the dwarf2dbg.c functions will emit 64-bit debugging format,
3008 and we don't want that in the 32-bit ABI.
3010 We could have two bfd_arch_info structures for SH64; one for the
3011 32-bit ABI and one for the rest (64-bit ABI). But that would be a
3012 bigger kludge: it's a flaw in the BFD design, and we need to just
3013 work around it by having the default machine set here in the
3014 assembler. For everything else but the assembler, the various bfd
3015 functions will set the machine type right to bfd_mach_sh5 from object
3016 file header flags regardless of the 0 here. */
3018 return (sh64_abi
== sh64_abi_64
) ? bfd_mach_sh5
: 0;
3021 /* This is MD_PCREL_FROM_SECTION, we we define so it is called instead of
3022 md_pcrel_from (in tc-sh.c). */
3025 shmedia_md_pcrel_from_section (struct fix
*fixP
, segT sec ATTRIBUTE_UNUSED
)
3027 know (fixP
->fx_frag
->fr_type
== rs_machine_dependent
);
3029 /* Use the ISA for the instruction to decide which offset to use. We
3030 can glean it from the fisup type. */
3031 switch (fixP
->fx_r_type
)
3033 case BFD_RELOC_SH_IMM_LOW16
:
3034 case BFD_RELOC_SH_IMM_MEDLOW16
:
3035 case BFD_RELOC_SH_IMM_MEDHI16
:
3036 case BFD_RELOC_SH_IMM_HI16
:
3037 case BFD_RELOC_SH_IMM_LOW16_PCREL
:
3038 case BFD_RELOC_SH_IMM_MEDLOW16_PCREL
:
3039 case BFD_RELOC_SH_IMM_MEDHI16_PCREL
:
3040 case BFD_RELOC_SH_IMM_HI16_PCREL
:
3041 case BFD_RELOC_SH_IMMU5
:
3042 case BFD_RELOC_SH_IMMU6
:
3043 case BFD_RELOC_SH_IMMS6
:
3044 case BFD_RELOC_SH_IMMS10
:
3045 case BFD_RELOC_SH_IMMS10BY2
:
3046 case BFD_RELOC_SH_IMMS10BY4
:
3047 case BFD_RELOC_SH_IMMS10BY8
:
3048 case BFD_RELOC_SH_IMMS16
:
3049 case BFD_RELOC_SH_IMMU16
:
3050 case BFD_RELOC_SH_PT_16
:
3051 case SHMEDIA_BFD_RELOC_PT
:
3052 /* PC-relative relocs are relative to the address of the last generated
3053 instruction, i.e. fx_size - 4. */
3054 return SHMEDIA_MD_PCREL_FROM_FIX (fixP
);
3057 case BFD_RELOC_64_PCREL
:
3058 know (0 /* Shouldn't get here. */);
3062 /* If section was SHcompact, use its function. */
3063 return (valueT
) md_pcrel_from_section (fixP
, sec
);
3066 know (0 /* Shouldn't get here. */);
3070 /* Create one .cranges descriptor from two symbols, STARTSYM marking begin
3071 and ENDSYM marking end, and CR_TYPE specifying the type. */
3074 sh64_emit_crange (symbolS
*startsym
, symbolS
*endsym
,
3075 enum sh64_elf_cr_type cr_type
)
3078 segT current_seg
= now_seg
;
3079 subsegT current_subseg
= now_subseg
;
3082 = bfd_make_section_old_way (stdoutput
,
3083 SH64_CRANGES_SECTION_NAME
);
3085 /* Temporarily change to the .cranges section. */
3086 subseg_set (cranges
, 0);
3088 /* Emit the cr_addr part. */
3089 exp
.X_op
= O_symbol
;
3090 exp
.X_add_number
= 0;
3091 exp
.X_op_symbol
= NULL
;
3092 exp
.X_add_symbol
= startsym
;
3093 emit_expr (&exp
, 4);
3095 /* Emit the cr_size part. */
3096 exp
.X_op
= O_subtract
;
3097 exp
.X_add_number
= 0;
3098 exp
.X_add_symbol
= endsym
;
3099 exp
.X_op_symbol
= startsym
;
3100 emit_expr (&exp
, 4);
3102 /* Emit the cr_size part. */
3103 exp
.X_op
= O_constant
;
3104 exp
.X_add_number
= cr_type
;
3105 exp
.X_add_symbol
= NULL
;
3106 exp
.X_op_symbol
= NULL
;
3107 emit_expr (&exp
, 2);
3109 /* Now back to our regular program. */
3110 subseg_set (current_seg
, current_subseg
);
3113 /* Called when the assembler is about to emit contents of some type into
3114 SEG, so it is *known* that the type of that new contents is in
3115 NEW_CONTENTS_TYPE. If just switching back and forth between different
3116 contents types (for example, with consecutive .mode pseudos), then this
3117 function isn't called. */
3120 sh64_set_contents_type (enum sh64_elf_cr_type new_contents_type
)
3122 segment_info_type
*seginfo
;
3124 /* We will not be called when emitting .cranges output, since callers
3125 stop that. Validize that assumption. */
3126 know (!emitting_crange
);
3128 seginfo
= seg_info (now_seg
);
3132 symbolS
*symp
= seginfo
->tc_segment_info_data
.last_contents_mark
;
3134 enum sh64_elf_cr_type contents_type
3135 = seginfo
->tc_segment_info_data
.contents_type
;
3137 /* If it was just SHcompact switching between code and constant
3138 pool, don't change contents type. Just make sure we don't set
3139 the contents type to data, as that would join with a data-region
3141 if (sh64_isa_mode
== sh64_isa_shcompact
3142 && ! sh64_shcompact_const_crange
)
3143 new_contents_type
= CRT_SH5_ISA16
;
3145 /* If nothing changed, stop here. */
3146 if (contents_type
== new_contents_type
)
3149 /* If we're in 64-bit ABI mode, we do not emit .cranges, as it is
3150 only specified for 32-bit addresses. It could presumably be
3151 extended, but in 64-bit ABI mode we don't have SHcompact code, so
3152 we would only use it to mark code and data. */
3153 if (sh64_abi
== sh64_abi_64
)
3155 /* Make the code type "sticky". We don't want to set the
3156 sections contents type to data if there's any code in it as
3157 we don't have .cranges in 64-bit mode to notice the
3159 seginfo
->tc_segment_info_data
.contents_type
3160 = (new_contents_type
== CRT_SH5_ISA32
3161 || contents_type
== CRT_SH5_ISA32
)
3162 ? CRT_SH5_ISA32
: new_contents_type
;
3166 /* If none was marked, create a start symbol for this range and
3167 perhaps as a closing symbol for the old one. */
3169 symp
= symbol_new (FAKE_LABEL_NAME
, now_seg
, (valueT
) frag_now_fix (),
3172 /* We will use this symbol, so don't leave a pointer behind. */
3173 seginfo
->tc_segment_info_data
.last_contents_mark
= NULL
;
3175 /* We'll be making only datalabel references to it, if we emit a
3176 .cranges descriptor, so remove any code flag. */
3177 S_SET_OTHER (symp
, S_GET_OTHER (symp
) & ~STO_SH5_ISA32
);
3179 /* If we have already marked the start of a range, we need to close
3180 and emit it before marking a new one, so emit a new .cranges
3181 descriptor into the .cranges section. */
3182 if (seginfo
->tc_segment_info_data
.mode_start_symbol
)
3184 /* If we're not supposed to emit mixed-mode sections, make it an
3185 error, but continue processing. */
3187 && (new_contents_type
== CRT_SH5_ISA32
3188 || contents_type
== CRT_SH5_ISA32
))
3190 _("SHmedia code not allowed in same section as constants and SHcompact code"));
3192 emitting_crange
= TRUE
;
3193 sh64_emit_crange (seginfo
->tc_segment_info_data
.mode_start_symbol
,
3194 symp
, contents_type
);
3195 emitting_crange
= FALSE
;
3196 seginfo
->tc_segment_info_data
.emitted_ranges
++;
3199 seginfo
->tc_segment_info_data
.mode_start_symbol
= symp
;
3200 seginfo
->tc_segment_info_data
.mode_start_subseg
= now_subseg
;
3201 seginfo
->tc_segment_info_data
.contents_type
= new_contents_type
;
3203 /* Always reset this, so the SHcompact code will emit a reloc when
3204 it prepares to relax. */
3205 seginfo
->tc_segment_info_data
.in_code
= 0;
3208 as_bad (_("No segment info for current section"));
3211 /* Hook when defining symbols and labels. We set the ST_OTHER field if
3212 the symbol is "shmedia" (with "bitor 1" automatically applied). Simple
3213 semantics for a label being "shmedia" : It was defined when .mode
3214 SHmedia was in effect, and it was defined in a code section. It
3215 doesn't matter whether or not an assembled opcode is nearby. */
3218 sh64_frob_label (symbolS
*symp
)
3220 segT seg
= S_GET_SEGMENT (symp
);
3221 static const symbolS
*null
= NULL
;
3223 /* Reset the tc marker for all newly created symbols. */
3224 symbol_set_tc (symp
, (symbolS
**) &null
);
3226 if (seg
!= NULL
&& sh64_isa_mode
== sh64_isa_shmedia
&& subseg_text_p (seg
))
3227 S_SET_OTHER (symp
, S_GET_OTHER (symp
) | STO_SH5_ISA32
);
3230 /* Handle the "datalabel" qualifier. We need to call "operand", but it's
3231 static, so a function pointer is passed here instead. FIXME: A target
3232 hook for qualifiers is needed; we currently use the md_parse_name
3236 sh64_consume_datalabel (const char *name
, expressionS
*exp
, char *cp
,
3237 segT (*operandf
) (expressionS
*))
3239 static int parsing_datalabel
= 0;
3241 if (strcasecmp (name
, "datalabel") == 0)
3243 int save_parsing_datalabel
= parsing_datalabel
;
3245 if (parsing_datalabel
)
3246 as_bad (_("duplicate datalabel operator ignored"));
3248 *input_line_pointer
= *cp
;
3249 parsing_datalabel
= 1;
3251 parsing_datalabel
= save_parsing_datalabel
;
3253 if (exp
->X_op
== O_symbol
|| exp
->X_op
== O_PIC_reloc
)
3255 symbolS
*symp
= exp
->X_add_symbol
;
3256 segT symseg
= S_GET_SEGMENT (symp
);
3258 /* If the symbol is defined to something that is already a
3259 datalabel, we don't need to bother with any special handling. */
3260 if (symseg
!= undefined_section
3261 && S_GET_OTHER (symp
) != STO_SH5_ISA32
)
3267 const char *name
= S_GET_NAME (symp
);
3269 = xmalloc (strlen (name
) + sizeof (DATALABEL_SUFFIX
));
3271 /* Now we copy the datalabel-qualified symbol into a symbol
3272 with the same name, but with " DL" appended. We mark the
3273 symbol using the TC_SYMFIELD_TYPE field with a pointer to
3274 the main symbol, so we don't have to inspect all symbol
3275 names. Note that use of "datalabel" is not expected to
3276 be a common case. */
3277 strcpy (dl_name
, name
);
3278 strcat (dl_name
, DATALABEL_SUFFIX
);
3280 /* A FAKE_LABEL_NAME marks "$" or ".". There can be any
3281 number of them and all have the same (faked) name; we
3282 must make a new one each time. */
3283 if (strcmp (name
, FAKE_LABEL_NAME
) == 0)
3284 dl_symp
= symbol_make (dl_name
);
3286 dl_symp
= symbol_find_or_make (dl_name
);
3289 symbol_set_value_expression (dl_symp
,
3290 symbol_get_value_expression (symp
));
3291 S_SET_SEGMENT (dl_symp
, symseg
);
3292 symbol_set_frag (dl_symp
, symbol_get_frag (symp
));
3293 symbol_set_tc (dl_symp
, &symp
);
3294 copy_symbol_attributes (dl_symp
, symp
);
3295 exp
->X_add_symbol
= dl_symp
;
3297 /* Unset the BranchTarget mark that can be set at symbol
3298 creation or attributes copying. */
3299 S_SET_OTHER (dl_symp
, S_GET_OTHER (dl_symp
) & ~STO_SH5_ISA32
);
3301 /* The GLOBAL and WEAK attributes are not copied over by
3302 copy_symbol_attributes. Do it here. */
3303 if (S_IS_WEAK (symp
))
3304 S_SET_WEAK (dl_symp
);
3305 else if (S_IS_EXTERNAL (symp
))
3306 S_SET_EXTERNAL (dl_symp
);
3309 /* Complain about other types of operands than symbol, unless they
3310 have already been complained about. A constant is always a
3311 datalabel. Removing the low bit would therefore be wrong.
3312 Complaining about it would also be wrong. */
3313 else if (exp
->X_op
!= O_illegal
3314 && exp
->X_op
!= O_absent
3315 && exp
->X_op
!= O_constant
)
3316 as_bad (_("Invalid DataLabel expression"));
3318 *cp
= *input_line_pointer
;
3323 return sh_parse_name (name
, exp
, cp
);
3326 /* This function is called just before symbols are being output. It
3327 returns zero when a symbol must be output, non-zero otherwise.
3328 Datalabel references that were fully resolved to local symbols are not
3329 necessary to output. We also do not want to output undefined symbols
3330 that are not used in relocs. For symbols that are used in a reloc, it
3331 does not matter what we set here. If it is *not* used in a reloc, then
3332 it was probably the datalabel counterpart that was used in a reloc;
3333 then we need not output the main symbol. */
3336 sh64_exclude_symbol (symbolS
*symp
)
3338 symbolS
*main_symbol
= *symbol_get_tc (symp
);
3340 return main_symbol
!= NULL
|| ! S_IS_DEFINED (symp
);
3343 /* If we haven't seen an insn since the last update, and location
3344 indicators have moved (a new frag, new location within frag) we have
3345 emitted data, so change contents type to data. Forget that we have
3346 seen a sequence of insns and store the current location so we can mark
3347 a new region if needed. */
3350 sh64_update_contents_mark (bfd_boolean update_type
)
3352 segment_info_type
*seginfo
;
3353 seginfo
= seg_info (now_seg
);
3355 if (seginfo
!= NULL
)
3357 symbolS
*symp
= seginfo
->tc_segment_info_data
.last_contents_mark
;
3361 symp
= symbol_new (FAKE_LABEL_NAME
, now_seg
,
3362 (valueT
) frag_now_fix (), frag_now
);
3363 seginfo
->tc_segment_info_data
.last_contents_mark
= symp
;
3367 /* If we have moved location since last flush, we need to emit a
3368 data range. The previous contents type ended at the location
3369 of the last update. */
3370 if ((S_GET_VALUE (symp
) != frag_now_fix ()
3371 || symbol_get_frag (symp
) != frag_now
))
3373 enum sh64_elf_cr_type contents_type
3374 = seginfo
->tc_segment_info_data
.contents_type
;
3377 && contents_type
!= CRT_DATA
3378 && contents_type
!= CRT_NONE
3381 sh64_set_contents_type (CRT_DATA
);
3382 symp
= seginfo
->tc_segment_info_data
.last_contents_mark
;
3385 /* If the symbol wasn't used up to make up a new range
3386 descriptor, update it to this new location. */
3389 S_SET_VALUE (symp
, (valueT
) frag_now_fix ());
3390 symbol_set_frag (symp
, frag_now
);
3399 /* Called when the assembler is about to output some data, or maybe it's
3400 just switching segments. */
3403 sh64_flush_pending_output (void)
3405 sh64_update_contents_mark (TRUE
);
3406 sh_flush_pending_output ();
3409 /* Flush out the last crange descriptor after all insns have been emitted. */
3412 sh64_flush_last_crange (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*seg
,
3413 void *countparg ATTRIBUTE_UNUSED
)
3415 segment_info_type
*seginfo
;
3417 seginfo
= seg_info (seg
);
3420 /* Only emit .cranges descriptors if we would make it more than one. */
3421 && seginfo
->tc_segment_info_data
.emitted_ranges
!= 0)
3425 /* We need a closing symbol, so switch to the indicated section and
3428 /* Change to the section we're about to handle. */
3429 subseg_set (seg
, seginfo
->tc_segment_info_data
.mode_start_subseg
);
3431 symp
= symbol_new (FAKE_LABEL_NAME
, now_seg
, (valueT
) frag_now_fix (),
3434 /* We'll be making a datalabel reference to it, so remove any code
3436 S_SET_OTHER (symp
, S_GET_OTHER (symp
) & ~STO_SH5_ISA32
);
3438 sh64_emit_crange (seginfo
->tc_segment_info_data
.mode_start_symbol
,
3440 seginfo
->tc_segment_info_data
.contents_type
);
3444 /* If and only if we see a call to md_number_to_chars without flagging the
3445 start of an insn, we set the contents type to CRT_DATA, and only when
3446 in SHmedia mode. Note that by default we don't bother changing when
3447 going from SHcompact to data, as the constant pools in GCC-generated
3448 SHcompact code would create an inordinate amount of .cranges
3452 sh64_flag_output (void)
3454 if (sh64_isa_mode
!= sh64_isa_unspecified
3456 && !sh64_end_of_assembly
3457 && !emitting_crange
)
3459 md_flush_pending_output ();
3460 sh64_set_contents_type (CRT_DATA
);
3464 /* Vtables don't need "datalabel" but we allow it by simply deleting
3468 strip_datalabels (void)
3470 char *src
, *dest
, *start
=input_line_pointer
;
3472 for (src
=input_line_pointer
, dest
=input_line_pointer
; *src
!= '\n'; )
3474 if (strncasecmp (src
, "datalabel", 9) == 0
3476 && (src
== start
|| !(ISALNUM (src
[-1])) || src
[-1] == '_'))
3488 sh64_vtable_entry (int ignore ATTRIBUTE_UNUSED
)
3490 char *eol
= strip_datalabels ();
3492 obj_elf_vtable_entry (0);
3493 input_line_pointer
= eol
;
3497 sh64_vtable_inherit (int ignore ATTRIBUTE_UNUSED
)
3499 char *eol
= strip_datalabels ();
3501 obj_elf_vtable_inherit (0);
3502 input_line_pointer
= eol
;