+2009-06-11 Anthony Green <green@moxielogic.com>
+
+ * reloc.c: Add BFD_RELOC_MOXIE_10_PCREL.
+ * bfd-in2.h: Rebuilt.
+ * libbfd.h: Rebuilt.
+ * elf32-moxie.c (moxie_elf_howto_table): Add R_MOXIE_PCREL10
+ relocation support.
+ (moxie_reloc_map): Ditto.
+ Clean up copyright notice.
+
2009-06-10 Paul Pluzhnikov <ppluzhnikov@google.com>
* bfd-in2.h: bfd_mmap prototype.
BFD_RELOC_MIPS_JUMP_SLOT,
+/* Moxie ELF relocations. */
+ BFD_RELOC_MOXIE_10_PCREL,
+
+
/* Fujitsu Frv Relocations. */
BFD_RELOC_FRV_LABEL16,
BFD_RELOC_FRV_LABEL24,
/* moxie-specific support for 32-bit ELF.
- Copyright 2008 Anthony Green.
Copyright 2009 Free Software Foundation, Inc.
Copied from elf32-fr30.c which is..
0x00000000, /* src_mask */
0xffffffff, /* dst_mask */
FALSE), /* pcrel_offset */
+
+ /* A 10 bit PC-relative relocation. */
+ HOWTO (R_MOXIE_PCREL10, /* type. */
+ 1, /* rightshift. */
+ 1, /* size (0 = byte, 1 = short, 2 = long). */
+ 10, /* bitsize. */
+ TRUE, /* pc_relative. */
+ 0, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_MOXIE_PCREL10", /* name. */
+ FALSE, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0x000003FF, /* dst_mask. */
+ TRUE), /* pcrel_offset. */
};
\f
/* Map BFD reloc types to MOXIE ELF reloc types. */
static const struct moxie_reloc_map moxie_reloc_map [] =
{
- { BFD_RELOC_NONE, R_MOXIE_NONE },
- { BFD_RELOC_32, R_MOXIE_32 },
+ { BFD_RELOC_NONE, R_MOXIE_NONE },
+ { BFD_RELOC_32, R_MOXIE_32 },
+ { BFD_RELOC_MOXIE_10_PCREL, R_MOXIE_PCREL10 },
};
static reloc_howto_type *
"BFD_RELOC_MIPS_COPY",
"BFD_RELOC_MIPS_JUMP_SLOT",
+ "BFD_RELOC_MOXIE_10_PCREL",
+
"BFD_RELOC_FRV_LABEL16",
"BFD_RELOC_FRV_LABEL24",
"BFD_RELOC_FRV_LO16",
MIPS ELF relocations (VxWorks and PLT extensions).
COMMENT
+ENUM
+ BFD_RELOC_MOXIE_10_PCREL
+ENUMDOC
+ Moxie ELF relocations.
+COMMENT
+
ENUM
BFD_RELOC_FRV_LABEL16
ENUMX
+2009-06-11 Anthony Green <green@moxielogic.com>
+
+ * config/tc-moxie.c (md_chars_to_number): Define.
+ (md_begin): Populate opcode hashtable with more form 3 opcodes.
+ (md_assemble): Assemble MOXIE_F3_PCREL encoded instructions.
+ (md_apply_fix): Handle BFD_RELOC_MOXIE_10_PCREL relocations.
+ (tc_gen_reloc): Ditto.
+ (md_pcrel_from): Ditto.
+ (md_chars_to_number): New function.
+
2009-06-10 Anthony Green <green@moxielogic.com>
* config/tc-moxie.c (md_assemble): Handle MOXIE_F1_M encoded
const char FLT_CHARS[] = "rRsSfFdDxXpP";
const char EXP_CHARS[] = "eE";
+static int md_chars_to_number (char *val, int n);
+
void
md_operand (expressionS *op __attribute__((unused)))
{
for (count = 0, opcode = moxie_form2_opc_info; count++ < 4; opcode++)
hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
- for (count = 0, opcode = moxie_form3_opc_info; count++ < 4; opcode++)
+ for (count = 0, opcode = moxie_form3_opc_info; count++ < 10; opcode++)
hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
if (*op_end != 0)
as_warn ("extra stuff on line ignored");
break;
+ case MOXIE_F3_PCREL:
+ iword = (3<<14) | (opcode->opcode << 10);
+ while (ISSPACE (*op_end))
+ op_end++;
+ {
+ expressionS arg;
+
+ op_end = parse_exp_save_ilp (op_end, &arg);
+ fix_new_exp (frag_now,
+ (p - frag_now->fr_literal),
+ 2,
+ &arg,
+ TRUE,
+ BFD_RELOC_MOXIE_10_PCREL);
+ }
+ break;
default:
abort();
}
/* Apply a fixup to the object file. */
void
-md_apply_fix (fixS *fixP ATTRIBUTE_UNUSED, valueT * valP ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED)
+md_apply_fix (fixS *fixP ATTRIBUTE_UNUSED,
+ valueT * valP ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED)
{
char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
long val = *valP;
+ long newval;
long max, min;
int shift;
*buf++ = val;
break;
+ case BFD_RELOC_MOXIE_10_PCREL:
+ if (!val)
+ break;
+ if (val < -1024 || val > 1022)
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("pcrel too far BFD_RELOC_MOXIE_10"));
+ /* 11 bit offset even numbered, so we remove right bit. */
+ val >>= 1;
+ newval = md_chars_to_number (buf, 2);
+ newval |= val & 0x03ff;
+ md_number_to_chars (buf, newval, 2);
+ break;
+
default:
abort ();
}
number_to_chars_bigendian (ptr, use, nbytes);
}
+/* Convert from target byte order to host byte order. */
+
+static int
+md_chars_to_number (char *val, int n)
+{
+ int retval = 0;
+
+ while (n--)
+ {
+ retval <<= 8;
+ retval |= (*val++ & 255);
+ }
+
+ return retval;
+}
+
/* Generate a machine-dependent relocation. */
arelent *
tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
case BFD_RELOC_32:
code = fixP->fx_r_type;
break;
+ case BFD_RELOC_MOXIE_10_PCREL:
+ code = fixP->fx_r_type;
+ break;
default:
as_bad_where (fixP->fx_file, fixP->fx_line,
_("Semantics error. This type of operand can not be relocated, it must be an assembly-time constant"));
{
valueT addr = fixP->fx_where + fixP->fx_frag->fr_address;
- fprintf (stderr, "md_pcrel_from 0x%d\n", fixP->fx_r_type);
-
switch (fixP->fx_r_type)
{
case BFD_RELOC_32:
return addr + 4;
+ case BFD_RELOC_MOXIE_10_PCREL:
+ return addr;
default:
abort ();
return addr;
+2009-06-11 Anthony Green <green@moxielogic.org>
+
+ * moxie.h (R_MOXIE_PCREL10): New.
+
2009-06-01 H.J. Lu <hongjiu.lu@intel.com>
PR ld/10205
START_RELOC_NUMBERS (elf_moxie_reloc_type)
RELOC_NUMBER (R_MOXIE_NONE, 0)
RELOC_NUMBER (R_MOXIE_32, 1)
+ RELOC_NUMBER (R_MOXIE_PCREL10, 2)
END_RELOC_NUMBERS (R_MOXIE_max)
#endif /* _ELF_MOXIE_H */
+2009-06-11 Anthony Green <green@moxielogic.com>
+
+ * moxie.h (MOXIE_F3_PCREL): Define.
+ (moxie_form3_opc_info): Grow.
+
2009-06-06 Anthony Green <green@moxielogic.com>
* moxie.h (MOXIE_F1_M): Define.
Form 3 instructions also come in different flavors:
- Some have no arguments (MOXIE_F3_NARG). */
+ Some have no arguments (MOXIE_F3_NARG)
+ Some have a 10-bit PC relative operand (MOXIE_F3_PCREL). */
#define MOXIE_F1_NARG 0x100
#define MOXIE_F1_A 0x101
#define MOXIE_F2_NARG 0x200
#define MOXIE_F2_A8V 0x201
-#define MOXIE_F3_NARG 0x300
+#define MOXIE_F3_NARG 0x300
+#define MOXIE_F3_PCREL 0x301
typedef struct moxie_opc_info_t
{
extern const moxie_opc_info_t moxie_form1_opc_info[64];
extern const moxie_opc_info_t moxie_form2_opc_info[4];
-extern const moxie_opc_info_t moxie_form3_opc_info[4];
+extern const moxie_opc_info_t moxie_form3_opc_info[16];
+2009-06-11 Anthony Green <green@moxielogic.com>
+
+ * moxie-opc.c (moxie_form1_opc_info): Remove branch instructions.
+ (moxie_form3_opc_info): Add branch instructions.
+ * moxie-dis.c (print_insn_moxie): Disassemble MOXIE_F3_PCREL
+ encoded instructions.
+
2009-06-06 Anthony Green <green@moxielogic.com>
* moxie-opc.c: Recode some MOXIE_F1_4 opcodes as MOXIE_F1_M.
/* Macros to extract operands from the instruction word. */
#define OP_A(i) ((i >> 4) & 0xf)
#define OP_B(i) (i & 0xf)
+#define INST2OFFSET(o) ((((signed short)((o & ((1<<10)-1))<<6))>>6)<<1)
static const char * reg_names[16] =
{ "$fp", "$sp", "$r0", "$r1", "$r2", "$r3", "$r4", "$r5",
else
{
/* Extract the Form 3 opcode. */
- opcode = &moxie_form2_opc_info[(iword >> 12) & 3];
+ opcode = &moxie_form3_opc_info[(iword >> 10) & 15];
switch (opcode->itype)
{
- case MOXIE_F3_NARG:
- fpr (stream, "%s", opcode->name);
+ case MOXIE_F3_PCREL:
+ fpr (stream, "%s\t", opcode->name);
+ info->print_address_func ((bfd_vma) (addr + INST2OFFSET(iword)),
+ info);
break;
default:
abort();
FORM 3 instructions start with a bits "11"...
- 11oovvvvvvvvvvvv
+ 11oooovvvvvvvvvv
0 F
- oo - form 3 opcode number
- vvvvvvvvvvvv - 12-bit immediate value. */
+ oooo - form 3 opcode number
+ vvvvvvvvvv - 10-bit immediate value. */
const moxie_opc_info_t moxie_form1_opc_info[64] =
{
{ 0x0c, MOXIE_F1_ABi4, "ldo.l" },
{ 0x0d, MOXIE_F1_AiB4, "sto.l" },
{ 0x0e, MOXIE_F1_AB, "cmp" },
- { 0x0f, MOXIE_F1_M, "beq" },
- { 0x10, MOXIE_F1_M, "bne" },
- { 0x11, MOXIE_F1_M, "blt" },
- { 0x12, MOXIE_F1_M, "bgt" },
- { 0x13, MOXIE_F1_M, "bltu" },
- { 0x14, MOXIE_F1_M, "bgtu" },
- { 0x15, MOXIE_F1_M, "bge" },
- { 0x16, MOXIE_F1_M, "ble" },
- { 0x17, MOXIE_F1_M, "bgeu" },
- { 0x18, MOXIE_F1_M, "bleu" },
+ { 0x0f, MOXIE_F1_NARG, "bad" },
+ { 0x10, MOXIE_F1_NARG, "bad" },
+ { 0x11, MOXIE_F1_NARG, "bad" },
+ { 0x12, MOXIE_F1_NARG, "bad" },
+ { 0x13, MOXIE_F1_NARG, "bad" },
+ { 0x14, MOXIE_F1_NARG, "bad" },
+ { 0x15, MOXIE_F1_NARG, "bad" },
+ { 0x16, MOXIE_F1_NARG, "bad" },
+ { 0x17, MOXIE_F1_NARG, "bad" },
+ { 0x18, MOXIE_F1_NARG, "bad" },
{ 0x19, MOXIE_F1_A, "jsr" },
{ 0x1a, MOXIE_F1_M, "jmpa" },
{ 0x1b, MOXIE_F1_A4, "ldi.b" },
{ 0x03, MOXIE_F2_A8V, "ssr" }
};
-const moxie_opc_info_t moxie_form3_opc_info[4] =
+const moxie_opc_info_t moxie_form3_opc_info[16] =
{
- { 0x00, MOXIE_F2_NARG, "bad" },
- { 0x01, MOXIE_F2_NARG, "bad" },
- { 0x02, MOXIE_F2_NARG, "bad" },
- { 0x03, MOXIE_F2_NARG, "bad" }
+ { 0x00, MOXIE_F3_PCREL,"beq" },
+ { 0x01, MOXIE_F3_PCREL,"bne" },
+ { 0x02, MOXIE_F3_PCREL,"blt" },
+ { 0x03, MOXIE_F3_PCREL,"bgt" },
+ { 0x04, MOXIE_F3_PCREL,"bltu" },
+ { 0x05, MOXIE_F3_PCREL,"bgtu" },
+ { 0x06, MOXIE_F3_PCREL,"bge" },
+ { 0x07, MOXIE_F3_PCREL,"ble" },
+ { 0x08, MOXIE_F3_PCREL,"bgeu" },
+ { 0x09, MOXIE_F3_PCREL,"bleu" },
+ { 0x0a, MOXIE_F3_NARG, "bad" },
+ { 0x0b, MOXIE_F3_NARG, "bad" },
+ { 0x0c, MOXIE_F3_NARG, "bad" },
+ { 0x0d, MOXIE_F3_NARG, "bad" },
+ { 0x0e, MOXIE_F3_NARG, "bad" },
+ { 0x0f, MOXIE_F3_NARG, "bad" }
};
+