/* Why isn't this in coff/sym.h? */
#define ST_RFDESCAPE 0xfff
+/* Why isn't this in listing.h? */
+extern int listing;
+
/* The ECOFF file format uses COFF style sections, but with a unique
debugging format. We just build generic BFD sections since BFD
knows how to write them out. The debugging format, however, we
0, /* rfdBase: index into the file indirect table */
0, /* crfd: count file indirect entries */
langC, /* lang: language for this file */
- 1, /* fMerge: whether this file can be merged */
+ 0, /* fMerge: whether this file can be merged */
0, /* fReadin: true if read in (not just created) */
#ifdef TARGET_BYTES_BIG_ENDIAN
1, /* fBigendian: if 1, compiled on big endian machine */
long offset));
static long ecoff_build_fdr PARAMS ((char **buf, char **bufend,
long offset));
-static void ecoff_set_vma PARAMS ((void));
static page_t *allocate_cluster PARAMS ((unsigned long npages));
static page_t *allocate_page PARAMS ((void));
static scope_t *allocate_scope PARAMS ((void));
obj_read_begin_hook ()
{
tag_hash = hash_new ();
- if (tag_hash == (struct hash_control *) NULL)
- as_fatal ("Can't create hash table");
top_tag_head = allocate_thead ();
top_tag_head->first_tag = (tag_t *) NULL;
top_tag_head->free = (thead_t *) NULL;
obj_symbol_new_hook (symbolP)
symbolS *symbolP;
{
+ if (cur_file_ptr == (efdr_t *) NULL)
+ add_file ((const char *) NULL, 0);
symbolP->ecoff_file = cur_file_ptr;
symbolP->ecoff_symbol = 0;
symbolP->ecoff_undefined = 0;
register thead_t *ptag_head;
register tag_t *ptag;
register tag_t *ptag_next;
- register varray_t *vp = &cur_file_ptr->symbols;
+ register varray_t *vp;
register int scope_delta = 0;
shash_t *hash_ptr = (shash_t *) NULL;
}
}
+#ifndef NO_LISTING
+ if (listing)
+ listing_source_file (file_name);
+#endif
+
/* If we're creating stabs, then we don't actually make a new FDR.
Instead, we just create a stabs symbol. */
if (stabs_seen)
/* Allocate the string hash table. */
fil_ptr->str_hash = hash_new ();
- if (fil_ptr->str_hash == (struct hash_control *) NULL)
- as_fatal ("Can't create hash table");
/* Make sure 0 byte in string table is null */
add_string (&fil_ptr->strings,
int ignore;
{
lineno_list_t *list;
+ int lineno;
if (cur_file_ptr == (efdr_t *) NULL)
{
get_absolute_expression ();
SKIP_WHITESPACE ();
+ lineno = get_absolute_expression ();
+
+#ifndef NO_LISTING
+ if (listing)
+ listing_source_line (lineno);
+#endif
+
/* If we're building stabs, then output a special label rather than
ECOFF line number info. */
if (stabs_seen)
(void) add_ecoff_symbol ((char *) NULL, st_Label, sc_Text,
symbol_new ("L0\001", now_seg,
frag_now_fix (), frag_now),
- 0, get_absolute_expression ());
+ 0, lineno);
return;
}
list->proc = cur_proc_ptr;
list->frag = frag_now;
list->paddr = frag_now_fix ();
- list->lineno = get_absolute_expression ();
+ list->lineno = lineno;
/* A .loc directive will sometimes appear before a .ent directive,
which means that cur_proc_ptr will be NULL here. Arrange to
st_t st;
sc_t sc;
+ if (cur_file_ptr == (efdr_t *) NULL)
+ {
+ add_file ((const char *) NULL, 0);
+ save_file_ptr = cur_file_ptr;
+ }
+
if (stabs_seen == 0)
mark_stabs (0);
code = (symint_t) get_absolute_expression ();
+#ifndef NO_LISTING
+ if (listing)
+ listing_source_line (code);
+#endif
+
if (*input_line_pointer++ != ',')
{
as_warn ("Bad .stab%c directive", type);
}
else
{
+#ifndef NO_LISTING
+ if (listing && (code == N_SO || code == N_SOL))
+ listing_source_file (string);
+#endif
+
/* The next number is sometimes the line number of the
declaration. We have nowhere to put it, so we just ignore
it. */
long iline;
long totcount;
+ if (linecntptr != (long *) NULL)
+ *linecntptr = 0;
+
bufptr = *buf + offset;
file = (efdr_t *) NULL;
/* The cline field is ill-documented. This is a guess
at the right value. */
file->fdr.cline = totcount + count;
+ if (linecntptr != (long *) NULL)
+ *linecntptr += totcount + count;
+ totcount = 0;
}
if (l->file != file)
file->fdr.cline = totcount;
}
- c = ecoff_longword_adjust (buf, bufend, c, &bufptr);
-
if (linecntptr != (long *) NULL)
- *linecntptr = totcount;
+ *linecntptr += totcount;
+
+ c = ecoff_longword_adjust (buf, bufend, c, &bufptr);
return c;
}
{
know (sym_ptr->proc_ptr != (proc_t *) NULL);
sym_ptr->ecoff_sym.value =
- (S_GET_VALUE (as_sym)
- - S_GET_VALUE (sym_ptr->proc_ptr->sym->as_sym));
+ (bfd_asymbol_value (as_sym->bsym)
+ - bfd_asymbol_value (sym_ptr->proc_ptr->sym
+ ->as_sym->bsym));
}
else
- sym_ptr->ecoff_sym.value = S_GET_VALUE (as_sym);
+ sym_ptr->ecoff_sym.value =
+ bfd_asymbol_value (as_sym->bsym);
+
+ /* Set st_Proc to st_StaticProc for local
+ functions. */
+ if (sym_ptr->ecoff_sym.st == st_Proc
+ && S_IS_DEFINED (as_sym)
+ && ! S_IS_EXTERNAL (as_sym))
+ sym_ptr->ecoff_sym.st = st_StaticProc;
/* Get the type and storage class based on where
the symbol actually wound up. Traditionally,
sc = sc_Bss;
else if (strcmp (segname, ".sbss") == 0)
sc = sc_SBss;
+ else if (seg == &bfd_abs_section)
+ sc = sc_Abs;
else
abort ();
know (as_sym != (symbolS *) NULL);
know (begin_ptr->as_sym != (symbolS *) NULL);
sym_ptr->ecoff_sym.value =
- (S_GET_VALUE (as_sym)
- - S_GET_VALUE (begin_ptr->as_sym));
+ (bfd_asymbol_value (as_sym->bsym)
+ - bfd_asymbol_value (begin_ptr->as_sym->bsym));
}
else if (begin_type == st_Block
&& sym_ptr->ecoff_sym.sc != (int) sc_Info)
know (as_sym != (symbolS *) NULL);
know (sym_ptr->proc_ptr != (proc_t *) NULL);
sym_ptr->ecoff_sym.value =
- (S_GET_VALUE (as_sym)
- - S_GET_VALUE (sym_ptr->proc_ptr->sym->as_sym));
+ (bfd_asymbol_value (as_sym->bsym)
+ - bfd_asymbol_value (sym_ptr->proc_ptr->sym
+ ->as_sym->bsym));
}
}
memset (&ext, 0, sizeof ext);
ext.asym = sym_ptr->ecoff_sym;
+ if (sym_ptr->ecoff_sym.st == st_Proc
+ || sym_ptr->ecoff_sym.st == st_StaticProc)
+ {
+ know (local);
+ ext.asym.index = isym - ifilesym - 1;
+ }
ext.ifd = fil_ptr->file_index;
ext.asym.iss = add_string (ext_strings,
ext_str_hash,
long offset;
{
struct pdr_ext *pdr_out;
+ int first_fil;
long iproc;
vlinks_t *file_link;
pdr_out = (struct pdr_ext *) (*buf + offset);
+ first_fil = 1;
iproc = 0;
/* The procedures are stored by file. */
{
unsigned long adr;
- adr = S_GET_VALUE (proc_ptr->sym->as_sym);
+ adr = bfd_asymbol_value (proc_ptr->sym->as_sym->bsym);
if (first)
{
- fil_ptr->fdr.adr = adr;
+ if (first_fil)
+ first_fil = 0;
+ else
+ fil_ptr->fdr.adr = adr;
first = 0;
}
proc_ptr->pdr.adr = adr - fil_ptr->fdr.adr;
return offset + ifile * sizeof (struct fdr_ext);
}
-/* Set the vma for all the sections. */
-
-static void
-ecoff_set_vma ()
-{
- register bfd_vma addr;
- register asection *sec;
-
- addr = 0;
- for (sec = stdoutput->sections; sec != (asection *) NULL; sec = sec->next)
- {
- bfd_set_section_vma (stdoutput, sec, addr);
- addr += bfd_section_size (stdoutput, sec);
- }
-}
-
-/* Adjust the value of a symbol by the vma of the section. */
-
-void
-ecoff_frob_symbol (sym)
- symbolS *sym;
-{
- static int setvma = 0;
-
- if (! setvma)
- {
- ecoff_set_vma ();
- setvma = 1;
- }
-
- S_SET_VALUE (sym,
- (S_GET_VALUE (sym)
- + bfd_get_section_vma (stdoutput,
- bfd_get_section (sym->bsym))));
-}
-
/* Swap out the symbols and debugging information for BFD. */
void
efdr_t *fil_ptr;
efdr_t *hold_file_ptr;
proc_t * hold_proc_ptr;
+ bfd_vma addr;
+ asection *sec;
symbolS *sym;
HDRR *hdr;
char *buf;
(symint_t) 0);
}
+ /* Set the section VMA values. */
+ addr = 0;
+ for (sec = stdoutput->sections; sec != (asection *) NULL; sec = sec->next)
+ {
+ bfd_set_section_vma (stdoutput, sec, addr);
+ addr += bfd_section_size (stdoutput, sec);
+ }
+
/* Look through the symbols. Add debugging information for each
symbol that has not already received it. */
hold_file_ptr = cur_file_ptr;
for (sym = symbol_rootP; sym != (symbolS *) NULL; sym = symbol_next (sym))
{
if (sym->ecoff_symbol
- || sym->ecoff_file == (efdr_t *) NULL)
+ || sym->ecoff_file == (efdr_t *) NULL
+ || (sym->bsym->flags & BSF_SECTION_SYM) != 0)
continue;
cur_file_ptr = sym->ecoff_file;
add_ecoff_symbol ((const char *) NULL, st_Nil, sc_Nil, sym,
- S_GET_VALUE (sym), indexNil);
+ bfd_asymbol_value (sym->bsym), indexNil);
}
cur_proc_ptr = hold_proc_ptr;
cur_file_ptr = hold_file_ptr;
hdr->magic = magicSym;
/* FIXME: what should hdr->vstamp be? */
+
+ bfd_set_symtab (stdoutput, bfd_get_outsymbols (stdoutput),
+ hdr->isymMax + hdr->iextMax);
}
\f
/* Allocate a cluster of pages. */
#endif /* NO_VARARGS */
#endif /* NO_STDARG */
-#include "mips-opcode.h"
+#include "opcode/mips.h"
#define AT 1
#define GP 28
\f
const relax_typeS md_relax_table[] =
{
- 0
+ { 0 }
};
/* set the default alignment for the text section (2**2) */
/* This should go in md_begin but text_section isn't initialized then */
record_alignment (text_section, 2);
+#ifdef OBJ_ECOFF
bfd_set_gp_size (stdoutput, g_switch_value);
+#endif
init = 1;
}
};
/* One extra nop */
- if (ip->insn_mo->pinfo & INSN_EXTRA_DELAY)
+ if (ip->insn_mo->pinfo & (INSN_READ_HI | INSN_READ_LO))
{
f = frag_more (4);
md_number_to_chars (f, 0, 4);
case 't':
case 'w':
+ case 'E':
insn.insn_opcode |= va_arg (args, int) << 16;
continue;
continue;
case 'd':
+ case 'G':
insn.insn_opcode |= va_arg (args, int) << 11;
continue;
insn.insn_opcode |= va_arg (args, int) << 6;
continue;
+ case 'B':
+ insn.insn_opcode |= va_arg (args, int) << 6;
+ continue;
+
case 'b':
case 's':
case 'r':
*/
save_reorder_condition = mips_noreorder;
mips_noreorder = 1;
- macro_build (&icnt, NULL, "cfc1", "t,d", treg, 31);
- macro_build (&icnt, NULL, "cfc1", "t,d", treg, 31);
+ macro_build (&icnt, NULL, "cfc1", "t,G", treg, 31);
+ macro_build (&icnt, NULL, "cfc1", "t,G", treg, 31);
macro_build (&icnt, NULL, "nop", "");
expr1.X_add_number = 3;
macro_build (&icnt, &expr1, "ori", "t,r,i", AT, treg);
expr1.X_add_number = 2;
macro_build (&icnt, &expr1, "xori", "t,r,i", AT, AT);
- macro_build (&icnt, NULL, "ctc1", "t,d", AT, 31);
+ macro_build (&icnt, NULL, "ctc1", "t,G", AT, 31);
macro_build (&icnt, NULL, "nop", "");
macro_build (&icnt, NULL,
mask == M_TRUNCWD ? "cvt.w.d" : "cvt.w.s", "D,S", dreg, sreg);
- macro_build (&icnt, NULL, "ctc1", "t,d", treg, 31);
+ macro_build (&icnt, NULL, "ctc1", "t,G", treg, 31);
macro_build (&icnt, NULL, "nop", "");
mips_noreorder = save_reorder_condition;
break;
s = expr_end;
continue;
+ case 'B': /* syscall code */
+ my_getExpression (&imm_expr, s);
+ check_absolute_expr (ip, &imm_expr);
+ if ((unsigned) imm_expr.X_add_number > 0xfffff)
+ as_warn ("Illegal syscall code (%d)", imm_expr.X_add_number);
+ ip->insn_opcode |= imm_expr.X_add_number << 6;
+ imm_expr.X_seg = absent_section;
+ s = expr_end;
+ continue;
+
case 'b': /* base register */
case 'd': /* destination register */
case 's': /* source register */
case 'r': /* both target and source */
case 'v': /* both dest and source */
case 'w': /* both dest and target */
+ case 'E': /* coprocessor target register */
+ case 'G': /* coprocessor destination register */
s_reset = s;
if (s[0] == '$')
{
ip->insn_opcode |= regno << 21;
break;
case 'd':
+ case 'G':
ip->insn_opcode |= regno << 11;
break;
case 'w':
case 't':
+ case 'E':
ip->insn_opcode |= regno << 16;
}
lastregno = regno;
void
md_number_to_chars (buf, val, n)
char *buf;
- long val;
+ valueT val;
int n;
{
switch (byte_order)
int
md_apply_fix (fixP, valueP)
fixS *fixP;
- long *valueP;
+ valueT *valueP;
{
unsigned char *buf;
long insn, value;
return 0;
}
insn |= value & 0xFFFF;
- md_number_to_chars (buf, insn, 4);
+ md_number_to_chars ((char *) buf, insn, 4);
break;
default:
continue;
case 'd':
+ case 'G':
printf ("$%d", dreg);
continue;
case 't':
+ case 'E':
printf ("$%d", treg);
continue;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
assert (reloc->howto != 0);
-#ifdef OBJ_ECOFF
- /* FIXME: This does the right thing, but it's confusing. There
- should be a more coherent approach, but I don't know what it
- would be. */
- reloc->addend -=
- bfd_get_section_vma (stdoutput,
- bfd_get_section (fixp->fx_addsy->bsym));
-#endif
-
return reloc;
}
/* should never be called */
-long
+valueT
md_section_align (seg, addr)
asection *seg;
- long addr;
+ valueT addr;
{
int align = bfd_get_section_alignment (stdoutput, seg);