return 0;
}
+int
+rl78_isa_g10 (void)
+{
+ return (elf_flags & E_FLAG_RL78_CPU_MASK) == E_FLAG_RL78_G10;
+}
+
+int
+rl78_isa_g13 (void)
+{
+ return (elf_flags & E_FLAG_RL78_CPU_MASK) == E_FLAG_RL78_G13;
+}
+
+int
+rl78_isa_g14 (void)
+{
+ return (elf_flags & E_FLAG_RL78_CPU_MASK) == E_FLAG_RL78_G14;
+}
+
void
-md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
+md_show_usage (FILE * stream)
{
fprintf (stream, _(" RL78 specific command line options:\n"));
+ fprintf (stream, _(" --mrelax Enable link time relaxation\n"));
fprintf (stream, _(" --mg10 Enable support for G10 variant\n"));
fprintf (stream, _(" --mg13 Selects the G13 core.\n"));
fprintf (stream, _(" --mg14 Selects the G14 core [default]\n"));
fprintf (stream, _(" --mrl78 Alias for --mg14\n"));
fprintf (stream, _(" --m32bit-doubles [default]\n"));
- fprintf (stream, _(" --m64bit-doubles\n"));
+ fprintf (stream, _(" --m64bit-doubles Source code uses 64-bit doubles\n"));
}
static void
{ NULL, NULL, 0 }
};
+static symbolS * rl78_abs_sym = NULL;
+
void
md_begin (void)
{
+ rl78_abs_sym = symbol_make ("__rl78_abs__");
}
void
case BFD_RELOC_RL78_LO16:
case BFD_RELOC_RL78_HI16:
if (size != 2)
- as_bad (_("%%hi16/%%lo16 only applies to .short or .hword"));
- type = exp->X_md;
+ {
+ /* Fixups to assembler generated expressions do not use %hi or %lo. */
+ if (frag->fr_file)
+ as_bad (_("%%hi16/%%lo16 only applies to .short or .hword"));
+ }
+ else
+ type = exp->X_md;
break;
case BFD_RELOC_RL78_HI8:
if (size != 1)
- as_bad (_("%%hi8 only applies to .byte"));
- type = exp->X_md;
+ {
+ /* Fixups to assembler generated expressions do not use %hi or %lo. */
+ if (frag->fr_file)
+ as_bad (_("%%hi8 only applies to .byte"));
+ }
+ else
+ type = exp->X_md;
break;
default:
break;
/* Estimate how big the opcode is after this relax pass. The return
value is the difference between fr_fix and the actual size. We
compute the total size in rl78_relax_frag and store it in fr_subtype,
- sowe only need to subtract fx_fix and return it. */
+ so we only need to subtract fx_fix and return it. */
int
md_estimate_size_before_relax (fragS * fragP ATTRIBUTE_UNUSED, segT segment ATTRIBUTE_UNUSED)
fragP->fr_subtype = newsize;
tprintf (" -> new %d old %d delta %d\n", newsize, oldsize, newsize-oldsize);
return newsize - oldsize;
- }
-
+}
+
/* This lets us test for the opcode type and the desired size in a
switch statement. */
#define OPCODE(type,size) ((type) * 16 + (size))
/* We used a new frag for this opcode, so the opcode address should
be the frag address. */
mypc = fragP->fr_address + (fragP->fr_opcode - fragP->fr_literal);
- tprintf("\033[32mmypc: 0x%x\033[0m\n", (int)mypc);
+ tprintf ("\033[32mmypc: 0x%x\033[0m\n", (int)mypc);
/* Try to get the target address. If we fail here, we just use the
largest format. */
if (rl78_frag_fix_value (fragP, segment, 0, & addr0,
- fragP->tc_frag_data->relax[ri].type != RL78_RELAX_BRANCH, 0))
+ fragP->tc_frag_data->relax[ri].type != RL78_RELAX_BRANCH, 0))
{
/* We don't know the target address. */
keep_reloc = 1;
reloc[rp]->address = fixp->fx_frag->fr_address + fixp->fx_where; \
reloc[++rp] = NULL
#define OPSYM(SYM) OPX(BFD_RELOC_RL78_SYM, SYM, 0)
-#define OPIMM(IMM) OPX(BFD_RELOC_RL78_SYM, abs_symbol.bsym, IMM)
+
+ /* FIXME: We cannot do the normal thing for an immediate value reloc,
+ ie creating a RL78_SYM reloc in the *ABS* section with an offset
+ equal to the immediate value we want to store. This fails because
+ the reloc processing in bfd_perform_relocation and bfd_install_relocation
+ will short circuit such relocs and never pass them on to the special
+ reloc processing code. So instead we create a RL78_SYM reloc against
+ the __rl78_abs__ symbol and arrange for the linker scripts to place
+ this symbol at address 0. */
+#define OPIMM(IMM) OPX (BFD_RELOC_RL78_SYM, symbol_get_bfdsym (rl78_abs_sym), IMM)
+
#define OP(OP) OPX(BFD_RELOC_RL78_##OP, *reloc[0]->sym_ptr_ptr, 0)
#define SYM0() reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RL78_SYM)
val);
/* Fall through. */
case BFD_RELOC_8:
+ case BFD_RELOC_RL78_SADDR: /* We need to store the 8 LSB, but this works. */
op[0] = val;
break;