/* tc-alpha.c - Processor-specific code for the DEC Alpha AXP CPU.
Copyright 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+ 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+ Free Software Foundation, Inc.
Contributed by Carnegie Mellon University, 1993.
Written by Alessandro Forin, based on earlier gas-1.38 target CPU files.
Modified by Ken Raeburn for gas-2.x and ECOFF support.
#define MAX_INSN_FIXUPS 2
#define MAX_INSN_ARGS 5
+/* Used since new relocation types are introduced in this
+ file (DUMMY_RELOC_LITUSE_*) */
+typedef int extended_bfd_reloc_code_real_type;
+
struct alpha_fixup
{
expressionS exp;
- bfd_reloc_code_real_type reloc;
+ /* bfd_reloc_code_real_type reloc; */
+ extended_bfd_reloc_code_real_type reloc;
#ifdef OBJ_EVAX
symbolS *xtrasym, *procsym;
#endif
and the section happens to not be on an eight byte boundary, it
will align both the symbol and the .quad to an eight byte boundary. */
static symbolS *alpha_insn_label;
-#ifdef OBJ_ELF
+#if defined(OBJ_ELF) || defined (OBJ_EVAX)
static symbolS *alpha_prologue_label;
#endif
const char *name; /* String to lookup. */
size_t length; /* Size of the string. */
operatorT op; /* Which operator to use. */
- bfd_reloc_code_real_type reloc; /* Relocation before frob. */
+ extended_bfd_reloc_code_real_type reloc;
unsigned int require_seq : 1; /* Require a sequence number. */
unsigned int allow_seq : 1; /* Allow a sequence number. */
}
static const char * const stX_op[] = { "stb", "stw", "stl", "stq" };
static const char * const ldXu_op[] = { "ldbu", "ldwu", NULL, NULL };
-static void assemble_insn (const struct alpha_opcode *, const expressionS *, int, struct alpha_insn *, bfd_reloc_code_real_type);
+static void assemble_insn (const struct alpha_opcode *, const expressionS *, int, struct alpha_insn *, extended_bfd_reloc_code_real_type);
static void emit_insn (struct alpha_insn *);
static void assemble_tokens (const char *, const expressionS *, int, int);
#ifdef OBJ_EVAX
size_t len = strlen (buffer);
const char *errmsg;
- info = xcalloc (sizeof (struct alpha_reloc_tag) + len, 1);
+ info = (struct alpha_reloc_tag *)
+ xcalloc (sizeof (struct alpha_reloc_tag) + len, 1);
info->segment = now_seg;
info->sequence = sequence;
strcpy (info->string, buffer);
errmsg = hash_insert (alpha_literal_hash, info->string, (void *) info);
if (errmsg)
- as_fatal (errmsg);
+ as_fatal ("%s", errmsg);
#ifdef OBJ_EVAX
info->sym = 0;
info->psym = 0;
assemble_tokens_to_insn ("ldq", newtok, 3, &insn);
- assert (insn.nfixups == 1);
+ gas_assert (insn.nfixups == 1);
insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITERAL;
insn.sequence = emit_lituse = next_sequence_num--;
#endif /* OBJ_ECOFF */
assemble_tokens_to_insn ("ldq", newtok, 3, &insn);
- assert (insn.nfixups == 1);
+ gas_assert (insn.nfixups == 1);
insn.fixups[0].reloc = BFD_RELOC_ALPHA_ELF_LITERAL;
insn.sequence = emit_lituse = next_sequence_num--;
#endif /* OBJ_ELF */
memcpy (ensymname, ptr1, ptr2 - ptr1);
memcpy (ensymname + (ptr2 - ptr1), "..en", 5);
- assert (insn.nfixups + 1 <= MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups + 1 <= MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = BFD_RELOC_ALPHA_NOP;
ensym = symbol_find_or_make (ensymname);
ensym->sy_used = 1;
psymname = (char *) xmalloc (ptr2 - ptr1 + 1);
memcpy (psymname, ptr1, ptr2 - ptr1);
psymname [ptr2 - ptr1] = 0;
- assert (insn.nfixups + 1 <= MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups + 1 <= MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = BFD_RELOC_ALPHA_LDA;
psym = symbol_find_or_make (psymname);
psym->sy_used = 1;
assemble_tokens_to_insn ("ldq", newtok, 3, &insn);
- assert (insn.nfixups == 1);
+ gas_assert (insn.nfixups == 1);
#ifdef OBJ_ECOFF
insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITERAL;
#endif
assemble_tokens_to_insn ("ldq", newtok, 3, &insn);
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_BASE;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
}
else
{
- reloc_howto_type *reloc_howto
- = bfd_reloc_type_lookup (stdoutput, fixup->reloc);
- assert (reloc_howto);
+ reloc_howto_type *reloc_howto =
+ bfd_reloc_type_lookup (stdoutput,
+ (bfd_reloc_code_real_type) fixup->reloc);
+ gas_assert (reloc_howto);
size = bfd_get_reloc_size (reloc_howto);
break;
#endif
default:
- assert (size >= 1 && size <= 4);
+ gas_assert (size >= 1 && size <= 4);
}
pcrel = reloc_howto->pc_relative;
}
fixP = fix_new_exp (frag_now, f - frag_now->fr_literal, size,
- &fixup->exp, pcrel, fixup->reloc);
+ &fixup->exp, pcrel, (bfd_reloc_code_real_type) fixup->reloc);
/* Turn off complaints that the addend is too large for some fixups,
and copy in the sequence number for the explicit relocations. */
insn = (*operand->insert) (insn, val, &errmsg);
if (errmsg)
- as_warn (errmsg);
+ as_warn ("%s", errmsg);
}
else
insn |= ((val & ((1 << operand->bits) - 1)) << operand->shift);
const expressionS *tok,
int ntok,
struct alpha_insn *insn,
- bfd_reloc_code_real_type reloc)
+ extended_bfd_reloc_code_real_type reloc)
{
const struct alpha_operand *reloc_operand = NULL;
const expressionS *reloc_exp = NULL;
case O_constant:
image = insert_operand (image, operand, t->X_add_number, NULL, 0);
- assert (reloc_operand == NULL);
+ gas_assert (reloc_operand == NULL);
reloc_operand = operand;
reloc_exp = t;
break;
if (reloc == BFD_RELOC_UNUSED)
reloc = operand->default_reloc;
- assert (reloc_operand == NULL);
+ gas_assert (reloc_operand == NULL);
reloc_operand = operand;
reloc_exp = t;
}
else if (reloc < BFD_RELOC_UNUSED && reloc > 0)
{
reloc_howto_type *reloc_howto
- = bfd_reloc_type_lookup (stdoutput, reloc);
+ = bfd_reloc_type_lookup (stdoutput,
+ (bfd_reloc_code_real_type) reloc);
if (reloc_operand == NULL
|| reloc_howto->bitsize != reloc_operand->bits)
{
basereg = tok[2].X_add_number;
lituse = load_expression (tok[0].X_add_number, &tok[1],
- &basereg, &newtok[1], opname);
+ &basereg, &newtok[1], (const char *) opname);
if (basereg == alpha_gp_register &&
(symlen > 4 && strcmp (&symname [symlen - 4], "..lk") == 0))
if (lituse)
{
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_BASE;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
as_bad (_("macro requires $at register while noat in effect"));
lituse = load_expression (AXP_REG_AT, &tok[1],
- &basereg, &newtok[1], opname);
+ &basereg, &newtok[1], (const char *) opname);
}
else
{
if (lituse)
{
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_BASE;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
if (lituse)
{
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_BASE;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
if (lituse)
{
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_BYTOFF;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
if (lituse)
{
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_BASE;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
if (lituse)
{
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_BYTOFF;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
if (lituse)
{
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_BYTOFF;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
if (lituse)
{
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_BASE;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
if (lituse)
{
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
insn.fixups[insn.nfixups].reloc = DUMMY_RELOC_LITUSE_JSR;
insn.fixups[insn.nfixups].exp.X_op = O_absent;
insn.nfixups++;
memcpy (ensymname, symname, symlen);
memcpy (ensymname + symlen, "..en", 5);
- assert (insn.nfixups < MAX_INSN_FIXUPS);
+ gas_assert (insn.nfixups < MAX_INSN_FIXUPS);
if (insn.nfixups > 0)
{
memmove (&insn.fixups[1], &insn.fixups[0],
const struct alpha_opcode *opcode;
const struct alpha_macro *macro;
int cpumatch = 1;
- bfd_reloc_code_real_type reloc = BFD_RELOC_UNUSED;
+ extended_bfd_reloc_code_real_type reloc = BFD_RELOC_UNUSED;
#ifdef RELOC_OP_P
/* If a user-specified relocation is present, this is not a macro. */
if (S_GET_VALUE (symbolP))
{
if (S_GET_VALUE (symbolP) != (valueT) size)
- as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.",
+ as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
S_GET_NAME (symbolP),
(long) S_GET_VALUE (symbolP),
(long) size);
sym = symbol_find_or_make (name);
symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION;
- cur_frame_data = calloc (1, sizeof (*cur_frame_data));
+ cur_frame_data = (struct alpha_elf_frame_data *)
+ calloc (1, sizeof (*cur_frame_data));
cur_frame_data->func_sym = sym;
/* Provide sensible defaults. */
if (sym && cur_frame_data)
{
OBJ_SYMFIELD_TYPE *obj = symbol_get_obj (sym);
- expressionS *exp = xmalloc (sizeof (expressionS));
+ expressionS *exp = (expressionS *) xmalloc (sizeof (expressionS));
obj->size = exp;
exp->X_op = O_subtract;
discard_rest_of_line ();
len = input_line_pointer - start;
- first_file_directive = xmalloc (len + 1);
+ first_file_directive = (char *) xmalloc (len + 1);
memcpy (first_file_directive, start, len);
first_file_directive[len] = '\0';
ecoff_directive_val,
};
- assert (which >= 0 && which < (int) (sizeof (fns)/sizeof (*fns)));
+ gas_assert (which >= 0 && which < (int) (sizeof (fns)/sizeof (*fns)));
if (ECOFF_DEBUGGING)
(*fns[which]) (0);
alpha_target_name = p->name, alpha_target = p->flags;
goto found;
}
- as_warn ("Unknown CPU identifier `%s'", name);
+ as_warn (_("Unknown CPU identifier `%s'"), name);
found:
*input_line_pointer = ch;
static void
select_gp_value (void)
{
- assert (alpha_gp_value == 0);
+ gas_assert (alpha_gp_value == 0);
/* Get minus-one in whatever width... */
alpha_gp_value = 0;
expressionS e;
e.X_op = O_max;
- assert (e.X_op == O_max);
+ gas_assert (e.X_op == O_max);
}
/* Create the opcode hash table. */
if ((slash = strchr (name, '/')) != NULL)
{
- char *p = xmalloc (strlen (name));
+ char *p = (char *) xmalloc (strlen (name));
memcpy (p, name, slash - name);
strcpy (p + (slash - name), slash + 1);
#ifdef OBJ_ECOFF
case BFD_RELOC_GPREL32:
- assert (fixP->fx_subsy == alpha_gp_symbol);
+ gas_assert (fixP->fx_subsy == alpha_gp_symbol);
fixP->fx_subsy = 0;
/* FIXME: inherited this obliviousness of `value' -- why? */
md_number_to_chars (fixpos, -alpha_gp_value, 4);
as_fatal (_("unhandled relocation type %s"),
bfd_get_reloc_code_name (fixP->fx_r_type));
- assert (-(int) fixP->fx_r_type < (int) alpha_num_operands);
+ gas_assert (-(int) fixP->fx_r_type < (int) alpha_num_operands);
operand = &alpha_operands[-(int) fixP->fx_r_type];
/* The rest of these fixups only exist internally during symbol
{
arelent *reloc;
- reloc = xmalloc (sizeof (* reloc));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = (arelent *) xmalloc (sizeof (* reloc));
+ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
/* Make sure none of our internal relocations make it this far.
They'd better have been fully resolved by this point. */
- assert ((int) fixp->fx_r_type > 0);
+ gas_assert ((int) fixp->fx_r_type > 0);
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
if (reloc->howto == NULL)
as_fatal (_("internal error? cannot generate `%s' relocation"),
bfd_get_reloc_code_name (fixp->fx_r_type));
- assert (!fixp->fx_pcrel == !reloc->howto->pc_relative);
+ gas_assert (!fixp->fx_pcrel == !reloc->howto->pc_relative);
#ifdef OBJ_ECOFF
if (fixp->fx_r_type == BFD_RELOC_ALPHA_LITERAL)