projects
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use bool in gas
[binutils-gdb.git]
/
gas
/
config
/
tc-moxie.c
diff --git
a/gas/config/tc-moxie.c
b/gas/config/tc-moxie.c
index f5140c5f8c3954c13c5b071020ccfc1761cda076..22a29a0b74d0d1fdb12623e73826e5d554eb7a8c 100644
(file)
--- a/
gas/config/tc-moxie.c
+++ b/
gas/config/tc-moxie.c
@@
-1,6
+1,5
@@
/* tc-moxie.c -- Assemble code for moxie
/* tc-moxie.c -- Assemble code for moxie
- Copyright 2009
- Free Software Foundation, Inc.
+ Copyright (C) 2009-2021 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
This file is part of GAS, the GNU Assembler.
@@
-33,7
+32,7
@@
const char line_separator_chars[] = ";";
const char line_comment_chars[] = "#";
static int pending_reloc;
const char line_comment_chars[] = "#";
static int pending_reloc;
-static
struct hash_control *
opcode_hash_control;
+static
htab_t
opcode_hash_control;
const pseudo_typeS md_pseudo_table[] =
{
const pseudo_typeS md_pseudo_table[] =
{
@@
-43,7
+42,10
@@
const pseudo_typeS md_pseudo_table[] =
const char FLT_CHARS[] = "rRsSfFdDxXpP";
const char EXP_CHARS[] = "eE";
const char FLT_CHARS[] = "rRsSfFdDxXpP";
const char EXP_CHARS[] = "eE";
-static int md_chars_to_number (char *val, int n);
+static valueT md_chars_to_number (char * buf, int n);
+
+/* Byte order. */
+extern int target_big_endian;
void
md_operand (expressionS *op __attribute__((unused)))
void
md_operand (expressionS *op __attribute__((unused)))
@@
-60,17
+62,17
@@
md_begin (void)
{
int count;
const moxie_opc_info_t *opcode;
{
int count;
const moxie_opc_info_t *opcode;
- opcode_hash_control =
hash_new
();
+ opcode_hash_control =
str_htab_create
();
/* Insert names into hash table. */
for (count = 0, opcode = moxie_form1_opc_info; count++ < 64; opcode++)
/* Insert names into hash table. */
for (count = 0, opcode = moxie_form1_opc_info; count++ < 64; opcode++)
-
hash_insert (opcode_hash_control, opcode->name, (char *) opcode
);
+
str_hash_insert (opcode_hash_control, opcode->name, opcode, 0
);
for (count = 0, opcode = moxie_form2_opc_info; count++ < 4; opcode++)
for (count = 0, opcode = moxie_form2_opc_info; count++ < 4; opcode++)
-
hash_insert (opcode_hash_control, opcode->name, (char *) opcode
);
+
str_hash_insert (opcode_hash_control, opcode->name, opcode, 0
);
for (count = 0, opcode = moxie_form3_opc_info; count++ < 10; opcode++)
for (count = 0, opcode = moxie_form3_opc_info; count++ < 10; opcode++)
-
hash_insert (opcode_hash_control, opcode->name, (char *) opcode
);
+
str_hash_insert (opcode_hash_control, opcode->name, opcode, 0
);
bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
}
bfd_set_arch_mach (stdoutput, TARGET_ARCH, 0);
}
@@
-176,7
+178,7
@@
md_assemble (char *str)
if (nlen == 0)
as_bad (_("can't find opcode "));
if (nlen == 0)
as_bad (_("can't find opcode "));
- opcode = (moxie_opc_info_t *) hash_find (opcode_hash_control, op_start);
+ opcode = (moxie_opc_info_t *)
str_
hash_find (opcode_hash_control, op_start);
*op_end = pend;
if (opcode == NULL)
*op_end = pend;
if (opcode == NULL)
@@
-199,11
+201,11
@@
md_assemble (char *str)
reg = parse_register_operand (&op_end);
iword += (reg << 8);
if (*op_end != ',')
reg = parse_register_operand (&op_end);
iword += (reg << 8);
if (*op_end != ',')
- as_warn (_("expecting comma delim
e
ted register operands"));
+ as_warn (_("expecting comma delim
i
ted register operands"));
op_end++;
op_end = parse_exp_save_ilp (op_end, &arg);
fix_new_exp (frag_now,
op_end++;
op_end = parse_exp_save_ilp (op_end, &arg);
fix_new_exp (frag_now,
- ((p
+1
) - frag_now->fr_literal),
+ ((p
+ (target_big_endian ? 1 : 0)
) - frag_now->fr_literal),
1,
&arg,
0,
1,
&arg,
0,
@@
-218,7
+220,7
@@
md_assemble (char *str)
int dest, src;
dest = parse_register_operand (&op_end);
if (*op_end != ',')
int dest, src;
dest = parse_register_operand (&op_end);
if (*op_end != ',')
- as_warn (_("expecting comma delim
eted register operands"0
);
+ as_warn (_("expecting comma delim
ited register operands")
);
op_end++;
src = parse_register_operand (&op_end);
iword += (dest << 4) + src;
op_end++;
src = parse_register_operand (&op_end);
iword += (dest << 4) + src;
@@
-309,7
+311,7
@@
md_assemble (char *str)
int a, b;
a = parse_register_operand (&op_end);
if (*op_end != ',')
int a, b;
a = parse_register_operand (&op_end);
if (*op_end != ',')
- as_warn (_("expecting comma delim
e
ted register operands"));
+ as_warn (_("expecting comma delim
i
ted register operands"));
op_end++;
if (*op_end != '(')
{
op_end++;
if (*op_end != '(')
{
@@
-355,7
+357,7
@@
md_assemble (char *str)
}
op_end++;
if (*op_end != ',')
}
op_end++;
if (*op_end != ',')
- as_warn (_("expecting comma delim
e
ted register operands"));
+ as_warn (_("expecting comma delim
i
ted register operands"));
op_end++;
b = parse_register_operand (&op_end);
iword += (a << 4) + b;
op_end++;
b = parse_register_operand (&op_end);
iword += (a << 4) + b;
@@
-400,7
+402,7
@@
md_assemble (char *str)
iword += (a << 4);
}
break;
iword += (a << 4);
}
break;
- case MOXIE_F1_ABi
4
:
+ case MOXIE_F1_ABi
2
:
iword = opcode->opcode << 8;
while (ISSPACE (*op_end))
op_end++;
iword = opcode->opcode << 8;
while (ISSPACE (*op_end))
op_end++;
@@
-422,13
+424,13
@@
md_assemble (char *str)
op_end++;
op_end = parse_exp_save_ilp (op_end, &arg);
op_end++;
op_end = parse_exp_save_ilp (op_end, &arg);
- offset = frag_more (
4
);
+ offset = frag_more (
2
);
fix_new_exp (frag_now,
(offset - frag_now->fr_literal),
fix_new_exp (frag_now,
(offset - frag_now->fr_literal),
-
4
,
+
2
,
&arg,
0,
&arg,
0,
- BFD_RELOC_
32
);
+ BFD_RELOC_
16
);
if (*op_end != '(')
{
if (*op_end != '(')
{
@@
-454,7
+456,7
@@
md_assemble (char *str)
iword += (a << 4) + b;
}
break;
iword += (a << 4) + b;
}
break;
- case MOXIE_F1_AiB
4
:
+ case MOXIE_F1_AiB
2
:
iword = opcode->opcode << 8;
while (ISSPACE (*op_end))
op_end++;
iword = opcode->opcode << 8;
while (ISSPACE (*op_end))
op_end++;
@@
-464,13
+466,13
@@
md_assemble (char *str)
int a, b;
op_end = parse_exp_save_ilp (op_end, &arg);
int a, b;
op_end = parse_exp_save_ilp (op_end, &arg);
- offset = frag_more (
4
);
+ offset = frag_more (
2
);
fix_new_exp (frag_now,
(offset - frag_now->fr_literal),
fix_new_exp (frag_now,
(offset - frag_now->fr_literal),
-
4
,
+
2
,
&arg,
0,
&arg,
0,
- BFD_RELOC_
32
);
+ BFD_RELOC_
16
);
if (*op_end != '(')
{
if (*op_end != '(')
{
@@
-527,15
+529,23
@@
md_assemble (char *str)
(p - frag_now->fr_literal),
2,
&arg,
(p - frag_now->fr_literal),
2,
&arg,
-
TRUE
,
+
true
,
BFD_RELOC_MOXIE_10_PCREL);
}
break;
BFD_RELOC_MOXIE_10_PCREL);
}
break;
+ case MOXIE_BAD:
+ iword = 0;
+ while (ISSPACE (*op_end))
+ op_end++;
+ if (*op_end != 0)
+ as_warn (_("extra stuff on line ignored"));
+ break;
default:
abort ();
}
md_number_to_chars (p, iword, 2);
default:
abort ();
}
md_number_to_chars (p, iword, 2);
+ dwarf2_emit_insn (2);
while (ISSPACE (*op_end))
op_end++;
while (ISSPACE (*op_end))
op_end++;
@@
-552,7
+562,7
@@
md_assemble (char *str)
of LITTLENUMS emitted is stored in *SIZEP . An error message is
returned, or NULL on OK. */
of LITTLENUMS emitted is stored in *SIZEP . An error message is
returned, or NULL on OK. */
-char *
+c
onst c
har *
md_atof (int type, char *litP, int *sizeP)
{
int prec;
md_atof (int type, char *litP, int *sizeP)
{
int prec;
@@
-589,54
+599,94
@@
md_atof (int type, char *litP, int *sizeP)
return NULL;
}
return NULL;
}
-
\f
-const char *md_shortopts = "";
+
+enum options
+{
+ OPTION_EB = OPTION_MD_BASE,
+ OPTION_EL,
+};
struct option md_longopts[] =
{
struct option md_longopts[] =
{
- {NULL, no_argument, NULL, 0}
+ { "EB", no_argument, NULL, OPTION_EB},
+ { "EL", no_argument, NULL, OPTION_EL},
+ { NULL, no_argument, NULL, 0}
};
};
+
size_t md_longopts_size = sizeof (md_longopts);
size_t md_longopts_size = sizeof (md_longopts);
+
\f
+const char *md_shortopts = "";
-/* We have no target specific options yet, so these next
- two functions are empty. */
int
int
-md_parse_option (int c ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED)
+md_parse_option (int c ATTRIBUTE_UNUSED, c
onst c
har *arg ATTRIBUTE_UNUSED)
{
{
- return 0;
+ switch (c)
+ {
+ case OPTION_EB:
+ target_big_endian = 1;
+ break;
+ case OPTION_EL:
+ target_big_endian = 0;
+ break;
+ default:
+ return 0;
+ }
+
+ return 1;
}
void
md_show_usage (FILE *stream ATTRIBUTE_UNUSED)
{
}
void
md_show_usage (FILE *stream ATTRIBUTE_UNUSED)
{
+ fprintf (stream, _("\
+ -EB assemble for a big endian system (default)\n\
+ -EL assemble for a little endian system\n"));
}
/* Apply a fixup to the object file. */
void
}
/* Apply a fixup to the object file. */
void
-md_apply_fix (fixS *fixP 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;
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;
max = min = 0;
max = min = 0;
- shift = 0;
switch (fixP->fx_r_type)
{
case BFD_RELOC_32:
switch (fixP->fx_r_type)
{
case BFD_RELOC_32:
- *buf++ = val >> 24;
- *buf++ = val >> 16;
- *buf++ = val >> 8;
- *buf++ = val >> 0;
+ if (target_big_endian)
+ {
+ buf[0] = val >> 24;
+ buf[1] = val >> 16;
+ buf[2] = val >> 8;
+ buf[3] = val >> 0;
+ }
+ else
+ {
+ buf[3] = val >> 24;
+ buf[2] = val >> 16;
+ buf[1] = val >> 8;
+ buf[0] = val >> 0;
+ }
+ buf += 4;
break;
case BFD_RELOC_16:
break;
case BFD_RELOC_16:
- *buf++ = val >> 8;
- *buf++ = val >> 0;
+ if (target_big_endian)
+ {
+ buf[0] = val >> 8;
+ buf[1] = val >> 0;
+ }
+ else
+ {
+ buf[1] = val >> 8;
+ buf[0] = val >> 0;
+ }
+ buf += 2;
break;
case BFD_RELOC_8:
break;
case BFD_RELOC_8:
@@
-667,28
+717,43
@@
md_apply_fix (fixS *fixP ATTRIBUTE_UNUSED,
fixP->fx_done = 1;
}
fixP->fx_done = 1;
}
-/* Put number into target byte order
(big endian)
. */
+/* Put number into target byte order. */
void
void
-md_number_to_chars (char *ptr, valueT use, int nbytes)
+md_number_to_chars (char *
ptr, valueT use, int nbytes)
{
{
- number_to_chars_bigendian (ptr, use, nbytes);
+ if (target_big_endian)
+ number_to_chars_bigendian (ptr, use, nbytes);
+ else
+ number_to_chars_littleendian (ptr, use, nbytes);
}
/* Convert from target byte order to host byte order. */
}
/* Convert from target byte order to host byte order. */
-static
int
-md_chars_to_number (char *
val
, int n)
+static
valueT
+md_chars_to_number (char *
buf
, int n)
{
{
- int retval = 0;
+ valueT result = 0;
+ unsigned char * where = (unsigned char *) buf;
-
while (n--
)
+
if (target_big_endian
)
{
{
- retval <<= 8;
- retval |= (*val++ & 255);
+ while (n--)
+ {
+ result <<= 8;
+ result |= (*where++ & 255);
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ result <<= 8;
+ result |= (where[n] & 255);
+ }
}
}
- return re
tval
;
+ return re
sult
;
}
/* Generate a machine-dependent relocation. */
}
/* Generate a machine-dependent relocation. */
@@
-712,9
+777,8
@@
tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
return 0;
}
return 0;
}
- relP = xmalloc (sizeof (arelent));
- gas_assert (relP != 0);
- relP->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ relP = XNEW (arelent);
+ relP->sym_ptr_ptr = XNEW (asymbol *);
*relP->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
*relP->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
@@
-776,7
+840,8
@@
md_pcrel_from (fixS *fixP)
case BFD_RELOC_32:
return addr + 4;
case BFD_RELOC_MOXIE_10_PCREL:
case BFD_RELOC_32:
return addr + 4;
case BFD_RELOC_MOXIE_10_PCREL:
- return addr;
+ /* Offset is from the end of the instruction. */
+ return addr + 2;
default:
abort ();
return addr;
default:
abort ();
return addr;