/* ECOFF debugging support.
- Copyright (C) 1993-2016 Free Software Foundation, Inc.
+ Copyright (C) 1993-2021 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file was put together by Ian Lance Taylor <ian@cygnus.com>. A
good deal of it comes directly from mips-tfile.c, by Michael
Each file table has offsets for where the line numbers, local
strings, local symbols, and procedure table starts from within the
- global tables, and the indexs are reset to 0 for each of those
+ global tables, and the indices are reset to 0 for each of those
tables for the file.
The procedure table contains the binary equivalents of the .ent
#26 48 0x00000030 struct no name { ifd = -1, index = 1048575 }
*/
\f
-/* Redefinition of of storage classes as an enumeration for better
+/* Redefinition of storage classes as an enumeration for better
debugging. */
typedef enum sc {
varray_t aux_syms; /* auxiliary symbols */
struct efdr *next_file; /* next file descriptor */
/* string/type hash tables */
- struct hash_control *str_hash; /* string hash table */
+ htab_t str_hash; /* string hash table */
thash_t *thash_head[THASH_SIZE];
} efdr_t;
(struct efdr *)0, /* next_file: next file structure */
- (struct hash_control *)0, /* str_hash: string hash table */
+ (htab_t)0, /* str_hash: string hash table */
{ 0 }, /* thash_head: type hash table */
};
static varray_t file_desc = INIT_VARRAY (efdr_t);
-static struct hash_control *tag_hash;
+static htab_t tag_hash;
/* Static types for int and void. Also, remember the last function's
type (which is set up when we encounter the declaration for the
static void add_varray_page (varray_t *vp);
static symint_t add_string (varray_t *vp,
- struct hash_control *hash_tbl,
+ htab_t hash_tbl,
const char *str,
shash_t **ret_hash);
static localsym_t *add_ecoff_symbol (const char *str, st_t type,
thash_t **hash_tbl);
static tag_t *get_tag (const char *tag, localsym_t *sym, bt_t basic_type);
static void add_unknown_tag (tag_t *ptag);
-static void add_procedure (char *func);
+static void add_procedure (char *func, int aent);
static void add_file (const char *file_name, int indx, int fake);
#ifdef ECOFF_DEBUG
static char *sc_to_string (sc_t storage_class);
void
ecoff_read_begin_hook (void)
{
- tag_hash = hash_new ();
+ tag_hash = str_htab_create ();
top_tag_head = allocate_thead ();
top_tag_head->first_tag = (tag_t *) NULL;
top_tag_head->free = (thead_t *) NULL;
static symint_t
add_string (varray_t *vp, /* string obstack */
- struct hash_control *hash_tbl, /* ptr to hash table */
+ htab_t hash_tbl, /* ptr to hash table */
const char *str, /* string */
shash_t **ret_hash /* return hash pointer */)
{
if (len >= PAGE_USIZE)
as_fatal (_("string too big (%lu bytes)"), len);
- hash_ptr = (shash_t *) hash_find (hash_tbl, str);
+ hash_ptr = (shash_t *) str_hash_find (hash_tbl, str);
if (hash_ptr == (shash_t *) NULL)
{
- const char *err;
-
if (vp->objects_last_page + len >= PAGE_USIZE)
{
vp->num_allocated =
strcpy (hash_ptr->string, str);
- err = hash_insert (hash_tbl, str, (char *) hash_ptr);
- if (err)
- as_fatal (_("inserting \"%s\" into string hash table: %s"),
- str, err);
+ if (str_hash_insert (hash_tbl, str, hash_ptr, 0) != NULL)
+ as_fatal (_("duplicate %s"), str);
}
if (ret_hash != (shash_t **) NULL)
bt_t basic_type /* bt_Struct, bt_Union, or bt_Enum */)
{
shash_t *hash_ptr;
- const char *err;
tag_t *tag_ptr;
if (cur_file_ptr == (efdr_t *) NULL)
as_fatal (_("no current file pointer"));
- hash_ptr = (shash_t *) hash_find (tag_hash, tag);
+ hash_ptr = (shash_t *) str_hash_find (tag_hash, tag);
if (hash_ptr != (shash_t *) NULL
&& hash_ptr->tag_ptr != (tag_t *) NULL)
perm = xstrdup (tag);
hash_ptr = allocate_shash ();
- err = hash_insert (tag_hash, perm, (char *) hash_ptr);
- if (err)
- as_fatal (_("inserting \"%s\" into tag hash table: %s"),
- tag, err);
+ str_hash_insert (tag_hash, perm, hash_ptr, 0);
hash_ptr->string = perm;
}
}
\f
/* Add a procedure to the current file's list of procedures, and record
- this is the current procedure. */
+ this is the current procedure. If AENT, then only set the requested
+ symbol's function type. */
static void
-add_procedure (char *func /* func name */)
+add_procedure (char *func /* func name */, int aent)
{
varray_t *vp;
proc_t *new_proc_ptr;
fputc ('\n', stderr);
#endif
+ /* Set the BSF_FUNCTION flag for the symbol. */
+ sym = symbol_find_or_make (func);
+ symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION;
+
+ if (aent)
+ return;
+
if (cur_file_ptr == (efdr_t *) NULL)
as_fatal (_("no current file pointer"));
new_proc_ptr->pdr.lnLow = -1;
new_proc_ptr->pdr.lnHigh = -1;
- /* Set the BSF_FUNCTION flag for the symbol. */
- sym = symbol_find_or_make (func);
- symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION;
-
/* Push the start of the function. */
new_proc_ptr->sym = add_ecoff_symbol ((const char *) NULL, st_Proc, sc_Text,
sym, (bfd_vma) 0, (symint_t) 0,
want to use the actual file name. */
if (file_name == (const char *) NULL)
{
- char *file;
-
if (first_file != (efdr_t *) NULL)
as_fatal (_("fake .file after real one"));
- as_where (&file, (unsigned int *) NULL);
- file_name = (const char *) file;
+ file_name = as_where ((unsigned int *) NULL);
/* Automatically generate ECOFF debugging information, since I
think that's what other ECOFF assemblers do. We don't do
if (stabs_seen)
{
(void) add_ecoff_symbol (file_name, st_Nil, sc_Nil,
- symbol_new ("L0\001", now_seg,
- (valueT) frag_now_fix (),
- frag_now),
+ symbol_new (FAKE_LABEL_NAME, now_seg,
+ frag_now, frag_now_fix ()),
(bfd_vma) 0, 0, ECOFF_MARK_STAB (N_SOL));
return;
}
fil_ptr->fake = fake;
/* Allocate the string hash table. */
- fil_ptr->str_hash = hash_new ();
+ fil_ptr->str_hash = str_htab_create ();
/* Make sure 0 byte in string table is null */
add_string (&fil_ptr->strings,
as_warn (_("empty symbol name in .def; ignored"));
else
{
- if (coff_sym_name != (char *) NULL)
- free (coff_sym_name);
- if (coff_tag != (char *) NULL)
- free (coff_tag);
+ free (coff_sym_name);
+ free (coff_tag);
coff_sym_name = xstrdup (name);
coff_type = type_info_init;
as_warn (_(".end directive names unknown symbol"));
else
(void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text,
- symbol_new ("L0\001", now_seg,
- (valueT) frag_now_fix (),
- frag_now),
+ symbol_new (FAKE_LABEL_NAME, now_seg,
+ frag_now, frag_now_fix ()),
(bfd_vma) 0, (symint_t) 0, (symint_t) 0);
+#ifdef md_flush_pending_output
+ md_flush_pending_output ();
+#endif
+
cur_proc_ptr = (proc_t *) NULL;
(void) restore_line_pointer (name_end);
/* Parse .ent directives. */
void
-ecoff_directive_ent (int ignore ATTRIBUTE_UNUSED)
+ecoff_directive_ent (int aent)
{
char *name;
char name_end;
if (cur_file_ptr == (efdr_t *) NULL)
add_file ((const char *) NULL, 0, 1);
- if (cur_proc_ptr != (proc_t *) NULL)
+ if (!aent && cur_proc_ptr != (proc_t *) NULL)
{
as_warn (_("second .ent directive found before .end directive"));
demand_empty_rest_of_line ();
if (name == input_line_pointer)
{
- as_warn (_(".ent directive has no name"));
+ as_warn (_("%s directive has no name"), aent ? ".aent" : ".ent");
(void) restore_line_pointer (name_end);
demand_empty_rest_of_line ();
return;
}
- add_procedure (name);
+ add_procedure (name, aent);
(void) restore_line_pointer (name_end);
if (stabs_seen)
{
(void) add_ecoff_symbol ((char *) NULL, st_Label, sc_Text,
- symbol_new ("L0\001", now_seg,
- (valueT) frag_now_fix (),
- frag_now),
+ symbol_new (FAKE_LABEL_NAME, now_seg,
+ frag_now, frag_now_fix ()),
(bfd_vma) 0, 0, lineno);
return;
}
{
if (! stabs_seen)
{
- /* Add a dummy @stabs dymbol. */
+ /* Add a dummy @stabs symbol. */
stabs_seen = 1;
(void) add_ecoff_symbol (stabs_symbol, st_Nil, sc_Info,
(symbolS *) NULL,
cur_file_ptr = save_file_ptr;
}
\f
+static asection ecoff_scom_section;
+static const asymbol ecoff_scom_symbol =
+ GLOBAL_SYM_INIT (SCOMMON, &ecoff_scom_section);
+static asection ecoff_scom_section =
+ BFD_FAKE_SECTION (ecoff_scom_section, &ecoff_scom_symbol,
+ SCOMMON, 0, SEC_IS_COMMON | SEC_SMALL_DATA);
+
/* Frob an ECOFF symbol. Small common symbols go into a special
.scommon section rather than bfd_com_section. */
&& S_GET_VALUE (sym) > 0
&& S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
{
- static asection scom_section;
- static asymbol scom_symbol;
-
- /* We must construct a fake section similar to bfd_com_section
- but with the name .scommon. */
- if (scom_section.name == NULL)
- {
- scom_section = *bfd_com_section_ptr;
- scom_section.name = ".scommon";
- scom_section.output_section = &scom_section;
- scom_section.symbol = &scom_symbol;
- scom_section.symbol_ptr_ptr = &scom_section.symbol;
- scom_symbol = *bfd_com_section_ptr->symbol;
- scom_symbol.name = ".scommon";
- scom_symbol.section = &scom_section;
- }
- S_SET_SEGMENT (sym, &scom_section);
+ S_SET_SEGMENT (sym, &ecoff_scom_section);
}
/* Double check weak symbols. */
if (need < PAGE_SIZE)
need = PAGE_SIZE;
want = (*bufend - *buf) + need;
- *buf = (char *) xrealloc (*buf, want);
+ *buf = XRESIZEVEC (char, *buf, want);
*bufend = *buf + want;
return *buf + at;
}
&& first_proc_ptr != (proc_t *) NULL
&& local_first_lineno != (lineno_list_t *) NULL
&& ((S_GET_VALUE (first_proc_ptr->sym->as_sym)
- + bfd_get_section_vma (stdoutput,
- S_GET_SEGMENT (first_proc_ptr->sym->as_sym)))
+ + bfd_section_vma (S_GET_SEGMENT (first_proc_ptr->sym->as_sym)))
!= 0))
{
first.file = local_first_lineno->file;
else
sym_ptr->ecoff_sym.asym.value =
(S_GET_VALUE (as_sym)
- + bfd_get_section_vma (stdoutput,
- S_GET_SEGMENT (as_sym))
+ + bfd_section_vma (S_GET_SEGMENT (as_sym))
+ sym_ptr->addend);
sym_ptr->ecoff_sym.weakext = S_IS_WEAK (as_sym);
/* If an st_end symbol has an associated gas
symbol, then it is a local label created for
a .bend or .end directive. Stabs line
- numbers will have \001 in the names. */
+ numbers will have FAKE_LABEL_CHAR in the names. */
if (local
&& sym_ptr->ecoff_sym.asym.st != st_End
- && strchr (sym_ptr->name, '\001') == 0)
+ && strchr (sym_ptr->name, FAKE_LABEL_CHAR) == 0)
sym_ptr->ecoff_sym.asym.iss =
add_string (&fil_ptr->strings,
fil_ptr->str_hash,
adr_sym = proc_ptr->sym->as_sym;
adr = (S_GET_VALUE (adr_sym)
- + bfd_get_section_vma (stdoutput,
- S_GET_SEGMENT (adr_sym)));
+ + bfd_section_vma (S_GET_SEGMENT (adr_sym)));
if (first)
{
/* This code used to force the adr of the very
/* Build the symbolic information. */
offset = 0;
- buf = (char *) xmalloc (PAGE_SIZE);
+ buf = XNEWVEC (char, PAGE_SIZE);
bufend = buf + PAGE_SIZE;
/* Build the line number information. */
#else
- ptr = (scope_t *) xmalloc (sizeof (scope_t));
+ ptr = XNEW (scope_t);
#endif
#else
- ptr = (vlinks_t *) xmalloc (sizeof (vlinks_t));
+ ptr = XNEW (vlinks_t);
#endif
#else
- ptr = (shash_t *) xmalloc (sizeof (shash_t));
+ ptr = XNEW (shash_t);
#endif
#else
- ptr = (thash_t *) xmalloc (sizeof (thash_t));
+ ptr = XNEW (thash_t);
#endif
#else
- ptr = (tag_t *) xmalloc (sizeof (tag_t));
+ ptr = XNEW (tag_t);
#endif
#else
- ptr = (forward_t *) xmalloc (sizeof (forward_t));
+ ptr = XNEW (forward_t);
#endif
#else
- ptr = (thead_t *) xmalloc (sizeof (thead_t));
+ ptr = XNEW (thead_t);
#endif
#else
- ptr = (lineno_list_t *) xmalloc (sizeof (lineno_list_t));
+ ptr = XNEW (lineno_list_t);
#endif
ecoff_generate_asm_lineno (void)
{
unsigned int lineno;
- char *filename;
+ const char *filename;
lineno_list_t *list;
- as_where (&filename, &lineno);
+ filename = as_where (&lineno);
if (current_stabs_filename == (char *) NULL
|| filename_cmp (current_stabs_filename, filename))