/* Return the slot for a type. */
static debug_type *
-coff_get_slot (struct coff_types **types, long indx)
+coff_get_slot (void *dhandle, struct coff_types **types, long indx)
{
unsigned int base_index;
if (*types == NULL || (*types)->base_index != base_index)
{
- struct coff_types *n = xcalloc (1, sizeof (*n));
+ struct coff_types *n = debug_xzalloc (dhandle, sizeof (*n));
n->next = *types;
n->base_index = base_index;
*types = n;
return type;
}
- if (pauxent != NULL && pauxent->x_sym.x_tagndx.l > 0)
+ if (pauxent != NULL && (int32_t) pauxent->x_sym.x_tagndx.u32 > 0)
{
debug_type *slot;
/* This is a reference to an existing type. FIXME: gdb checks
that the class is not C_STRTAG, nor C_UNTAG, nor C_ENTAG. */
- slot = coff_get_slot (types, pauxent->x_sym.x_tagndx.l);
+ slot = coff_get_slot (dhandle, types, pauxent->x_sym.x_tagndx.u32);
if (*slot != DEBUG_TYPE_NULL)
return *slot;
else
if (name != NULL)
ret = debug_name_type (dhandle, name, ret);
- debug_type *slot = coff_get_slot (types, coff_symno);
+ debug_type *slot = coff_get_slot (dhandle, types, coff_symno);
*slot = ret;
return ret;
{
long symend;
int alloc;
- debug_field *fields;
+ debug_field *fields, *xfields;
int count;
bool done;
- symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
+ symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.u32;
alloc = 10;
fields = (debug_field *) xmalloc (alloc * sizeof *fields);
case C_FIELD:
bitpos = bfd_asymbol_value (sym);
- bitsize = auxent.x_sym.x_misc.x_lnsz.x_size;
+ if (psubaux != NULL)
+ bitsize = psubaux->x_sym.x_misc.x_lnsz.x_size;
break;
case C_EOS:
f = debug_make_field (dhandle, bfd_asymbol_name (sym), ftype,
bitpos, bitsize, DEBUG_VISIBILITY_PUBLIC);
if (f == DEBUG_FIELD_NULL)
- return DEBUG_TYPE_NULL;
+ {
+ free (fields);
+ return DEBUG_TYPE_NULL;
+ }
if (count + 1 >= alloc)
{
}
fields[count] = DEBUG_FIELD_NULL;
+ xfields = debug_xalloc (dhandle, (count + 1) * sizeof (*fields));
+ memcpy (xfields, fields, (count + 1) * sizeof (*fields));
+ free (fields);
return debug_make_struct_type (dhandle, ntype == T_STRUCT,
pauxent->x_sym.x_misc.x_lnsz.x_size,
- fields);
+ xfields);
}
/* Parse an enum type. */
{
long symend;
int alloc;
- const char **names;
- bfd_signed_vma *vals;
+ const char **names, **xnames;
+ bfd_signed_vma *vals, *xvals;
int count;
bool done;
- symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
+ symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.u32;
alloc = 10;
names = (const char **) xmalloc (alloc * sizeof *names);
}
names[count] = NULL;
-
- return debug_make_enum_type (dhandle, names, vals);
+ vals[count] = 0;
+ xnames = debug_xalloc (dhandle, (count + 1) * sizeof (*names));
+ memcpy (xnames, names, (count + 1) * sizeof (*names));
+ free (names);
+ xvals = debug_xalloc (dhandle, (count + 1) * sizeof (*vals));
+ memcpy (xvals, vals, (count + 1) * sizeof (*vals));
+ free (vals);
+
+ return debug_make_enum_type (dhandle, xnames, xvals);
}
/* Handle a single COFF symbol. */
/* Store the named type into the slot, so that references get
the name. */
- slot = coff_get_slot (types, coff_symno);
+ slot = coff_get_slot (dhandle, types, coff_symno);
*slot = type;
}
break;