{
"macro definition contains spaces in formal argument list:\n`%s'", 0, 0
};
+static struct complaint dwarf2_invalid_attrib_class =
+{
+ "invalid attribute class or form for '%s' in '%s'", 0, 0
+};
/* local function prototypes */
char *, bfd *, const struct comp_unit_head *,
struct objfile *);
+static int attr_form_is_block (struct attribute *);
+
/* Try to locate the sections we need for DWARF 2 debugging
information and return true if we have enough to do something. */
attr = dwarf_attr (die, DW_AT_frame_base);
if (attr)
{
- CORE_ADDR addr = decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ CORE_ADDR addr;
+
+ /* Support the .debug_loc offsets */
+ if (attr_form_is_block (attr))
+ {
+ addr = decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ }
+ else if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8)
+ {
+ complain (&dwarf2_complex_location_expr);
+ addr = 0;
+ }
+ else
+ {
+ complain (&dwarf2_invalid_attrib_class, "DW_AT_frame_base", name);
+ addr = 0;
+ }
+
if (isderef)
complain (&dwarf2_unsupported_at_frame_base, name);
else if (isreg)
/* Get index in virtual function table if it is a virtual member function. */
attr = dwarf_attr (die, DW_AT_vtable_elem_location);
if (attr)
- fnp->voffset = decode_locdesc (DW_BLOCK (attr), objfile, cu_header) + 2;
+ {
+ /* Support the .debug_loc offsets */
+ if (attr_form_is_block (attr))
+ {
+ fnp->voffset = decode_locdesc (DW_BLOCK (attr), objfile, cu_header) + 2;
+ }
+ else if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8)
+ {
+ complain (&dwarf2_complex_location_expr);
+ }
+ else
+ {
+ complain (&dwarf2_invalid_attrib_class, "DW_AT_vtable_elem_location",
+ fieldname);
+ }
+ }
}
/* Create the vector of member function fields, and attach it to the type. */
attr = dwarf_attr (die, DW_AT_location);
if (attr)
{
- base = decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ /* Support the .debug_loc offsets */
+ if (attr_form_is_block (attr))
+ {
+ base = decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ }
+ else if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8)
+ {
+ complain (&dwarf2_complex_location_expr);
+ }
+ else
+ {
+ complain (&dwarf2_invalid_attrib_class, "DW_AT_location",
+ "common block member");
+ }
}
if (die->has_children)
{
part_die->highpc = DW_ADDR (&attr);
break;
case DW_AT_location:
- part_die->locdesc = DW_BLOCK (&attr);
+ /* Support the .debug_loc offsets */
+ if (attr_form_is_block (&attr))
+ {
+ part_die->locdesc = DW_BLOCK (&attr);
+ }
+ else if (attr.form == DW_FORM_data4 || attr.form == DW_FORM_data8)
+ {
+ complain (&dwarf2_complex_location_expr);
+ }
+ else
+ {
+ complain (&dwarf2_invalid_attrib_class, "DW_AT_location",
+ "partial symbol information");
+ }
break;
case DW_AT_language:
part_die->language = DW_UNSND (&attr);
char *name;
struct attribute *attr = NULL;
struct attribute *attr2 = NULL;
- CORE_ADDR addr;
+ CORE_ADDR addr = 0;
name = dwarf2_linkage_name (die);
if (name)
attr2 = dwarf_attr (die, DW_AT_external);
if (attr2 && (DW_UNSND (attr2) != 0))
{
- SYMBOL_VALUE_ADDRESS (sym) =
- decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ /* Support the .debug_loc offsets */
+ if (attr_form_is_block (attr))
+ {
+ SYMBOL_VALUE_ADDRESS (sym) =
+ decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ }
+ else if (attr->form == DW_FORM_data4
+ || attr->form == DW_FORM_data8)
+ {
+ complain (&dwarf2_complex_location_expr);
+ }
+ else
+ {
+ complain (&dwarf2_invalid_attrib_class, "DW_AT_location",
+ "external variable");
+ }
add_symbol_to_list (sym, &global_symbols);
/* In shared libraries the address of the variable
}
else
{
- SYMBOL_VALUE (sym) = addr =
- decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ /* Support the .debug_loc offsets */
+ if (attr_form_is_block (attr))
+ {
+ SYMBOL_VALUE (sym) = addr =
+ decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
+ }
+ else if (attr->form == DW_FORM_data4
+ || attr->form == DW_FORM_data8)
+ {
+ complain (&dwarf2_complex_location_expr);
+ }
+ else
+ {
+ complain (&dwarf2_invalid_attrib_class, "DW_AT_location",
+ "external variable");
+ addr = 0;
+ }
add_symbol_to_list (sym, list_in_scope);
if (optimized_out)
{
}
}
}
+
+/* Check if the attribute's form is a DW_FORM_block*
+ if so return true else false. */
+static int
+attr_form_is_block (struct attribute *attr)
+{
+ return (attr == NULL ? 0 :
+ attr->form == DW_FORM_block1
+ || attr->form == DW_FORM_block2
+ || attr->form == DW_FORM_block4
+ || attr->form == DW_FORM_block);
+}