/* tc-alpha.c - Processor-specific code for the DEC Alpha AXP CPU.
- Copyright (C) 1989, 93-98, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1989, 93-98, 1999, 2000, 2001 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.
#ifdef OBJ_ELF
#include "elf/alpha.h"
+#include "dwarf2dbg.h"
#endif
#include <ctype.h>
enum alpha_macro_arg argsets[16];
};
-/* Extra expression types. */
+/* Extra expression types. */
#define O_pregister O_md1 /* O_register, in parentheses */
#define O_cpregister O_md2 /* + a leading comma */
#define USER_RELOC_P(R) ((R) >= O_literal && (R) <= O_gprellow)
#endif
-
/* Macros for extracting the type and number of encoded register tokens */
#define is_ir_num(x) (((x) & 32) == 0)
#if 1
#define range_signed_16(x) \
- (((offsetT)(x) >> 15) == 0 || ((offsetT)(x) >> 15) == -1)
+ (((offsetT) (x) >> 15) == 0 || ((offsetT) (x) >> 15) == -1)
#define range_signed_32(x) \
- (((offsetT)(x) >> 31) == 0 || ((offsetT)(x) >> 31) == -1)
+ (((offsetT) (x) >> 31) == 0 || ((offsetT) (x) >> 31) == -1)
#else
-#define range_signed_16(x) ((offsetT)(x) >= -(offsetT)0x8000 && \
- (offsetT)(x) <= (offsetT)0x7FFF)
-#define range_signed_32(x) ((offsetT)(x) >= -(offsetT)0x80000000 && \
- (offsetT)(x) <= (offsetT)0x7FFFFFFF)
+#define range_signed_16(x) ((offsetT) (x) >= -(offsetT)0x8000 && \
+ (offsetT) (x) <= (offsetT)0x7FFF)
+#define range_signed_32(x) ((offsetT) (x) >= -(offsetT)0x80000000 && \
+ (offsetT) (x) <= (offsetT)0x7FFFFFFF)
#endif
/* Macros for sign extending from 16- and 32-bits. */
but really a predicate should be found to use the non-cast forms. */
#if 1
-#define sign_extend_16(x) ((short)(x))
-#define sign_extend_32(x) ((int)(x))
+#define sign_extend_16(x) ((short) (x))
+#define sign_extend_32(x) ((int) (x))
#else
-#define sign_extend_16(x) ((offsetT)(((x) & 0xFFFF) ^ 0x8000) - 0x8000)
-#define sign_extend_32(x) ((offsetT)(((x) & 0xFFFFFFFF) \
+#define sign_extend_16(x) ((offsetT) (((x) & 0xFFFF) ^ 0x8000) - 0x8000)
+#define sign_extend_32(x) ((offsetT) (((x) & 0xFFFFFFFF) \
^ 0x80000000) - 0x80000000)
#endif
/* Macros to build tokens */
-#define set_tok_reg(t, r) (memset(&(t), 0, sizeof(t)), \
+#define set_tok_reg(t, r) (memset(&(t), 0, sizeof (t)), \
(t).X_op = O_register, \
(t).X_add_number = (r))
-#define set_tok_preg(t, r) (memset(&(t), 0, sizeof(t)), \
+#define set_tok_preg(t, r) (memset(&(t), 0, sizeof (t)), \
(t).X_op = O_pregister, \
(t).X_add_number = (r))
-#define set_tok_cpreg(t, r) (memset(&(t), 0, sizeof(t)), \
+#define set_tok_cpreg(t, r) (memset(&(t), 0, sizeof (t)), \
(t).X_op = O_cpregister, \
(t).X_add_number = (r))
-#define set_tok_freg(t, r) (memset(&(t), 0, sizeof(t)), \
+#define set_tok_freg(t, r) (memset(&(t), 0, sizeof (t)), \
(t).X_op = O_register, \
(t).X_add_number = (r)+32)
-#define set_tok_sym(t, s, a) (memset(&(t), 0, sizeof(t)), \
+#define set_tok_sym(t, s, a) (memset(&(t), 0, sizeof (t)), \
(t).X_op = O_symbol, \
(t).X_add_symbol = (s), \
(t).X_add_number = (a))
-#define set_tok_const(t, n) (memset(&(t), 0, sizeof(t)), \
+#define set_tok_const(t, n) (memset(&(t), 0, sizeof (t)), \
(t).X_op = O_constant, \
(t).X_add_number = (n))
static void s_alpha_mask PARAMS ((int));
static void s_alpha_frame PARAMS ((int));
static void s_alpha_prologue PARAMS ((int));
+static void s_alpha_file PARAMS ((int));
+static void s_alpha_loc PARAMS ((int));
+static void s_alpha_stab PARAMS ((int));
static void s_alpha_coff_wrapper PARAMS ((int));
#endif
#ifdef OBJ_EVAX
{ NULL, no_argument, NULL, 0 }
};
-size_t md_longopts_size = sizeof(md_longopts);
+size_t md_longopts_size = sizeof (md_longopts);
\f
#ifdef OBJ_EVAX
#endif
static segT alpha_lit8_section;
-/* Symbols referring to said sections. */
+/* Symbols referring to said sections. */
#ifdef OBJ_ECOFF
static symbolS *alpha_lita_symbol;
static symbolS *alpha_lit4_symbol;
static offsetT alpha_lit8_literal;
#endif
-/* The active .ent symbol. */
#ifdef OBJ_ELF
+/* The active .ent symbol. */
static symbolS *alpha_cur_ent_sym;
#endif
#ifdef OBJ_ELF
/* Whether we are emitting an mdebug section. */
-int alpha_flag_mdebug = 1;
+int alpha_flag_mdebug = -1;
#endif
/* Don't fully resolve relocations, allowing code movement in the linker. */
#define ALPHA_RELOC_TABLE(op) \
&alpha_reloc_op[ ((!USER_RELOC_P (op)) \
? (abort (), 0) \
- : (int)(op) - (int)O_literal) ]
+ : (int) (op) - (int)O_literal) ]
#define LITUSE_BASE 1
#define LITUSE_BYTOFF 2
};
static const int alpha_num_reloc_op
- = sizeof(alpha_reloc_op) / sizeof(*alpha_reloc_op);
+ = sizeof (alpha_reloc_op) / sizeof (*alpha_reloc_op);
/* Maximum # digits needed to hold the largest sequence # */
#define ALPHA_RELOC_DIGITS 25
/* Whether a sequence number is valid. */
-#define ALPHA_RELOC_SEQUENCE_OK(X) ((X) > 0 && ((unsigned)(X)) == (X))
+#define ALPHA_RELOC_SEQUENCE_OK(X) ((X) > 0 && ((unsigned) (X)) == (X))
/* Structure to hold explict sequence information. */
struct alpha_literal_tag
} cpu_types[] =
{
/* Ad hoc convention: cpu number gets palcode, process code doesn't.
- This supports usage under DU 4.0b that does ".arch ev4", and
+ This supports usage under DU 4.0b that does ".arch ev4", and
usage in MILO that does -m21064. Probably something more
specific like -m21064-pal should be used, but oh well. */
};
static const unsigned int alpha_num_macros
- = sizeof(alpha_macros) / sizeof(*alpha_macros);
+ = sizeof (alpha_macros) / sizeof (*alpha_macros);
\f
/* Public interface functions */
for (i = 0; i < 32; ++i)
{
char name[4];
- sprintf(name, "$%d", i);
+ sprintf (name, "$%d", i);
alpha_register_table[i] = symbol_create(name, reg_section, i,
&zero_address_frag);
}
for (; i < 64; ++i)
{
char name[5];
- sprintf(name, "$f%d", i-32);
+ sprintf (name, "$f%d", i-32);
alpha_register_table[i] = symbol_create(name, reg_section, i,
&zero_address_frag);
}
size_t opnamelen;
/* split off the opcode */
- opnamelen = strspn (str, "abcdefghijklmnopqrstuvwxyz_/468");
+ opnamelen = strspn (str, "abcdefghijklmnopqrstuvwxyz_/46819");
trunclen = (opnamelen < sizeof (opname) - 1
? opnamelen
: sizeof (opname) - 1);
}
/* Turn a string in input_line_pointer into a floating point constant
- of type type, and store the appropriate bytes in *litP. The number
- of LITTLENUMS emitted is stored in *sizeP. An error message is
+ of type TYPE, and store the appropriate bytes in *LITP. The number
+ of LITTLENUMS emitted is stored in *SIZEP. An error message is
returned, or NULL on OK. */
/* Equal to MAX_PRECISION in atof-ieee.c */
break;
#ifdef OBJ_EVAX
- case '+': /* For g++. Hash any name > 63 chars long. */
+ case '+': /* For g++. Hash any name > 63 chars long. */
alpha_flag_hash_long_names = 1;
break;
abort ();
#endif
+ case BFD_RELOC_VTABLE_INHERIT:
+ case BFD_RELOC_VTABLE_ENTRY:
+ return 1;
+
default:
{
const struct alpha_operand *operand;
else
break;
- if (!alpha_noat_on && num == AXP_REG_AT)
+ if (!alpha_noat_on && (num + is_float) == AXP_REG_AT)
as_warn(_("Used $at without \".set noat\""));
return alpha_register_table[num + is_float];
case BFD_RELOC_ALPHA_USER_GPRELHIGH:
case BFD_RELOC_ALPHA_USER_GPRELLOW:
#endif
+ case BFD_RELOC_VTABLE_INHERIT:
+ case BFD_RELOC_VTABLE_ENTRY:
return 1;
case BFD_RELOC_23_PCREL_S2:
case BFD_RELOC_ALPHA_USER_GPRELHIGH:
case BFD_RELOC_ALPHA_USER_GPRELLOW:
#endif
+ case BFD_RELOC_VTABLE_ENTRY:
+ case BFD_RELOC_VTABLE_INHERIT:
return 0;
case BFD_RELOC_GPREL32:
static void
alpha_adjust_symtab_relocs (abfd, sec, ptr)
- bfd *abfd;
+ bfd *abfd ATTRIBUTE_UNUSED;
asection *sec;
- PTR ptr;
+ PTR ptr ATTRIBUTE_UNUSED;
{
segment_info_type *seginfo = seg_info (sec);
fixS **prevP;
{
char *hold = input_line_pointer++;
- /* First try for parenthesized register ... */
+ /* First try for parenthesized register ... */
expression (tok);
if (*input_line_pointer == ')' && tok->X_op == O_register)
{
default:
/* everything else should have been fake */
- abort();
+ abort ();
}
++tokidx;
}
}
break;
default:
- abort();
+ abort ();
}
}
else
f = frag_more (4);
md_number_to_chars (f, insn->insn, 4);
+#ifdef OBJ_ELF
+ dwarf2_emit_insn (4);
+#endif
+
/* Apply the fixups in order */
for (i = 0; i < insn->nfixups; ++i)
{
else switch (fixup->reloc)
{
#ifdef OBJ_ELF
- /* These relocation types are only used internally. */
+ /* These relocation types are only used internally. */
case BFD_RELOC_ALPHA_GPDISP_HI16:
case BFD_RELOC_ALPHA_GPDISP_LO16:
size = 2;
case O_subtract:
/* Assume that this difference expression will be resolved to an
- absolute value and that that value will fit in 16 bits. */
+ absolute value and that that value will fit in 16 bits. */
assert (explicit_reloc == (const expressionS *)0);
set_tok_reg (newtok[0], targreg);
if (insn.nfixups > 0)
{
memmove (&insn.fixups[1], &insn.fixups[0],
- sizeof(struct alpha_fixup) * insn.nfixups);
+ sizeof (struct alpha_fixup) * insn.nfixups);
}
insn.nfixups++;
insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE;
|| tok[2].X_op != O_pregister
|| !is_ir_num(tok[2].X_add_number))
{
- as_bad (_("bad instruction format for lda !%s!%d"), r->name,
- reloc->X_add_number);
+ as_bad (_("bad instruction format for lda !%s!%ld"), r->name,
+ (long) reloc->X_add_number);
reloc = (const expressionS *)0;
ntok--;
if (insn.nfixups > 0)
{
memmove (&insn.fixups[1], &insn.fixups[0],
- sizeof(struct alpha_fixup) * insn.nfixups);
+ sizeof (struct alpha_fixup) * insn.nfixups);
}
insn.nfixups++;
insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE;
if (insn.nfixups > 0)
{
memmove (&insn.fixups[1], &insn.fixups[0],
- sizeof(struct alpha_fixup) * insn.nfixups);
+ sizeof (struct alpha_fixup) * insn.nfixups);
}
insn.nfixups++;
insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE;
}
#endif
- memcpy (newtok, tok, sizeof(newtok));
+ memcpy (newtok, tok, sizeof (newtok));
newtok[1].X_add_number = sign_extend_32 (tok[1].X_add_number);
assemble_tokens ("lda", newtok, ntok, 1);
int ntok;
const PTR vlgsize;
{
- int lgsize = (int)(long)vlgsize;
+ int lgsize = (int) (long)vlgsize;
if (alpha_target & AXP_OPCODE_BWX)
emit_loadstore (tok, ntok, stX_op[lgsize]);
int ntok;
const PTR vlgsize;
{
- int lgsize = (int)(long)vlgsize;
+ int lgsize = (int) (long)vlgsize;
expressionS newtok[3];
/* emit "lda $at, exp" */
if (insn.nfixups > 0)
{
memmove (&insn.fixups[1], &insn.fixups[0],
- sizeof(struct alpha_fixup) * insn.nfixups);
+ sizeof (struct alpha_fixup) * insn.nfixups);
}
insn.nfixups++;
insn.fixups[0].reloc = BFD_RELOC_ALPHA_LITUSE;
{
offsetT align;
- input_line_pointer++;
+ input_line_pointer++;
align = get_absolute_expression ();
bfd_set_section_alignment (stdoutput, new_seg, align);
}
#ifdef OBJ_EVAX
if (bfd_section_size (stdoutput, new_seg) > 0)
- {
+ {
if (bfd_section_size (stdoutput, new_seg) != temp)
as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
S_GET_NAME (symbolP),
#endif
else
{
-#ifdef OBJ_EVAX
+#ifdef OBJ_EVAX
subseg_set (new_seg, 0);
p = frag_more (temp);
new_seg->flags |= SEC_IS_COMMON;
switch (arg)
{
case 0: /* No PV required. */
- S_SET_OTHER (sym, STO_ALPHA_NOPV);
+ S_SET_OTHER (sym, STO_ALPHA_NOPV
+ | (S_GET_OTHER (sym) & ~STO_ALPHA_STD_GPLOAD));
break;
case 1: /* Std GP load. */
- S_SET_OTHER (sym, STO_ALPHA_STD_GPLOAD);
+ S_SET_OTHER (sym, STO_ALPHA_STD_GPLOAD
+ | (S_GET_OTHER (sym) & ~STO_ALPHA_STD_GPLOAD));
break;
case 2: /* Non-std use of PV. */
break;
default:
as_bad (_("Invalid argument %d to .prologue."), arg);
break;
- }
+ }
+}
+
+static char * first_file_directive;
+
+static void
+s_alpha_file (ignore)
+ int ignore ATTRIBUTE_UNUSED;
+{
+ /* Save the first .file directive we see, so that we can change our
+ minds about whether ecoff debugging should or shouldn't be enabled. */
+ if (alpha_flag_mdebug < 0 && ! first_file_directive)
+ {
+ char *start = input_line_pointer;
+ size_t len;
+
+ discard_rest_of_line ();
+
+ len = input_line_pointer - start;
+ first_file_directive = xmalloc (len + 1);
+ memcpy (first_file_directive, start, len);
+ first_file_directive[len] = '\0';
+
+ input_line_pointer = start;
+ }
+
+ if (ECOFF_DEBUGGING)
+ ecoff_directive_file (0);
+ else
+ dwarf2_directive_file (0);
+}
+
+static void
+s_alpha_loc (ignore)
+ int ignore ATTRIBUTE_UNUSED;
+{
+ if (ECOFF_DEBUGGING)
+ ecoff_directive_loc (0);
+ else
+ dwarf2_directive_loc (0);
+}
+
+static void
+s_alpha_stab (n)
+ int n;
+{
+ /* If we've been undecided about mdebug, make up our minds in favour. */
+ if (alpha_flag_mdebug < 0)
+ {
+ segT sec = subseg_new(".mdebug", 0);
+ bfd_set_section_flags(stdoutput, sec, SEC_HAS_CONTENTS|SEC_READONLY);
+ bfd_set_section_alignment(stdoutput, sec, 3);
+
+ ecoff_read_begin_hook ();
+
+ if (first_file_directive)
+ {
+ char *save_ilp = input_line_pointer;
+ input_line_pointer = first_file_directive;
+ ecoff_directive_file (0);
+ input_line_pointer = save_ilp;
+ free (first_file_directive);
+ }
+
+ alpha_flag_mdebug = 1;
+ }
+ s_stab (n);
}
static void
ecoff_directive_def,
ecoff_directive_dim,
ecoff_directive_endef,
- ecoff_directive_file,
ecoff_directive_scl,
ecoff_directive_tag,
ecoff_directive_val,
- ecoff_directive_loc,
};
- assert (which >= 0 && which < (int)(sizeof(fns)/sizeof(*fns)));
+ assert (which >= 0 && which < (int) (sizeof (fns)/sizeof (*fns)));
if (ECOFF_DEBUGGING)
- (*fns[which])(0);
+ (*fns[which]) (0);
else
{
as_bad (_("ECOFF debugging is disabled."));
#endif /* OBJ_ELF */
#ifdef OBJ_EVAX
-
+
/* Handle the section specific pseudo-op. */
-
+
static void
s_alpha_section (secid)
int secid;
alpha_current_align = 0;
}
-
/* Parse .ent directives. */
static void
return;
}
-
/* Parse .frame <framreg>,<framesize>,RA,<rsa_offset> directives. */
static void
return;
}
-
/* Support for crash debug on vms. */
static void
return;
}
-
static void
s_alpha_linkage (ignore)
int ignore;
return;
}
-
static void
s_alpha_code_address (ignore)
int ignore;
return;
}
-
static void
s_alpha_fp_save (ignore)
int ignore;
return;
}
-
static void
s_alpha_mask (ignore)
int ignore;
return;
}
-
static void
s_alpha_fmask (ignore)
int ignore;
return;
}
-
static void
s_alpha_file (ignore)
int ignore;
case O_symbol:
break;
default:
- abort();
+ abort ();
}
#else
#ifdef OBJ_ECOFF
{"fmask", s_alpha_mask, 1},
{"frame", s_alpha_frame, 0},
{"prologue", s_alpha_prologue, 0},
+ {"file", s_alpha_file, 5},
+ {"loc", s_alpha_loc, 9},
+ {"stabs", s_alpha_stab, 's'},
+ {"stabn", s_alpha_stab, 'n'},
/* COFF debugging related pseudos. */
{"begin", s_alpha_coff_wrapper, 0},
{"bend", s_alpha_coff_wrapper, 1},
{"def", s_alpha_coff_wrapper, 2},
{"dim", s_alpha_coff_wrapper, 3},
{"endef", s_alpha_coff_wrapper, 4},
- {"file", s_alpha_coff_wrapper, 5},
- {"scl", s_alpha_coff_wrapper, 6},
- {"tag", s_alpha_coff_wrapper, 7},
- {"val", s_alpha_coff_wrapper, 8},
- {"loc", s_alpha_coff_wrapper, 9},
+ {"scl", s_alpha_coff_wrapper, 5},
+ {"tag", s_alpha_coff_wrapper, 6},
+ {"val", s_alpha_coff_wrapper, 7},
#else
{"prologue", s_ignore, 0},
#endif
if (pfill == NULL)
{
- if (n > 2
- && (bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0)
- {
- static char const unop[4] = { 0x00, 0x00, 0xe0, 0x2f };
- static char const nopunop[8] = {
- 0x1f, 0x04, 0xff, 0x47,
- 0x00, 0x00, 0xe0, 0x2f
- };
-
- /* First, make sure we're on a four-byte boundary, in case
- someone has been putting .byte values into the text
- section. The DEC assembler silently fills with unaligned
- no-op instructions. This will zero-fill, then nop-fill
- with proper alignment. */
- if (alpha_current_align < 2)
- frag_align (2, 0, 0);
- if (alpha_current_align < 3)
- frag_align_pattern (3, unop, sizeof unop, 0);
- if (n > 3)
- frag_align_pattern (n, nopunop, sizeof nopunop, 0);
- }
+ if (subseg_text_p (now_seg))
+ frag_align_code (n, 0);
else
frag_align (n, 0, 0);
}
record_alignment (now_seg, n);
- /* ??? if alpha_flag_relax && force && elf, record the requested alignment
+ /* ??? If alpha_flag_relax && force && elf, record the requested alignment
in a reloc for the linker to see. */
}
+/* This is called from HANDLE_ALIGN in write.c. Fill in the contents
+ of an rs_align_code fragment. */
+
+void
+alpha_handle_align (fragp)
+ fragS *fragp;
+{
+ static char const unop[4] = { 0x00, 0x00, 0xe0, 0x2f };
+ static char const nopunop[8] = {
+ 0x1f, 0x04, 0xff, 0x47,
+ 0x00, 0x00, 0xe0, 0x2f
+ };
+
+ int bytes, fix;
+ char *p;
+
+ if (fragp->fr_type != rs_align_code)
+ return;
+
+ bytes = fragp->fr_next->fr_address - fragp->fr_address - fragp->fr_fix;
+ p = fragp->fr_literal + fragp->fr_fix;
+ fix = 0;
+
+ if (bytes & 3)
+ {
+ fix = bytes & 3;
+ memset (p, 0, fix);
+ p += fix;
+ bytes -= fix;
+ }
+
+ if (bytes & 4)
+ {
+ memcpy (p, unop, 4);
+ p += 4;
+ bytes -= 4;
+ fix += 4;
+ }
+
+ memcpy (p, nopunop, 8);
+
+ fragp->fr_fix += fix;
+ fragp->fr_var = 8;
+}
+
/* The Alpha has support for some VAX floating point types, as well as for
IEEE floating point. We consider IEEE to be the primary floating point
format, and sneak in the VAX floating point support here. */