> It doesn't look to me like DW_AT_endianity is applicable to array types
> or members in DWARF 3/4; instead, it should be applied to the underlying
> base type.
OK, the attached patch does that so is more invasive as expected.
Tested on x86_64-suse-linux, OK for the mainline?
2016-01-05 Eric Botcazou
* dwarf2out.c (need_endianity_attribute_p): New inline predicate.
(base_type_die): Add REVERSE parameter and attach DW_AT_endianity to
the DIE accordingly.
(modified_type_die): Add REVERSE parameter and pass it recursively,
as well as to base_type_die. Adjust presence check accordingly.
(base_type_for_mode): Adjust call to modified_type_die.
(add_type_attribute): Add REVERSE parameter and pass it to
modified_type_die.
(generic_parameter_die): Adjust call to add_type_attribute.
(add_scalar_info): Likewise.
(add_subscript_info): Likewise.
(gen_array_type_die): Likewise.
(gen_descr_array_type_die): Likewise.
(gen_entry_point_die): Likewise.
(gen_enumeration_type_die): Likewise.
(gen_formal_parameter_die): Likewise.
(gen_subprogram_die): Likewise.
(gen_variable_die ): Likewise.
(gen_const_die): Likewise.
(gen_field_die): Likewise.
(gen_pointer_type_die): Likewise.
(gen_reference_type_die): Likewise.
(gen_ptr_to_mbr_type_die): Likewise.
(gen_inheritance_die): Likewise.
(gen_subroutine_type_die): Likewise.
(gen_typedef_die): Likewise.
(force_type_die): Adjust call to modified_type_die.
2016-01-05 Eric Botcazou
* gcc.dg/debug/dwarf2/sso.c: New test.
--
Eric BotcazouIndex: dwarf2out.c
===
--- dwarf2out.c (revision 232035)
+++ dwarf2out.c (working copy)
@@ -3286,11 +3286,11 @@ static void output_ranges (void);
static dw_line_info_table *new_line_info_table (void);
static void output_line_info (bool);
static void output_file_names (void);
-static dw_die_ref base_type_die (tree);
+static dw_die_ref base_type_die (tree, bool);
static int is_base_type (tree);
static dw_die_ref subrange_type_die (tree, tree, tree, tree, dw_die_ref);
static int decl_quals (const_tree);
-static dw_die_ref modified_type_die (tree, int, dw_die_ref);
+static dw_die_ref modified_type_die (tree, int, bool, dw_die_ref);
static dw_die_ref generic_parameter_die (tree, tree, bool, dw_die_ref);
static dw_die_ref template_parameter_pack_die (tree, tree, dw_die_ref);
static int type_is_enum (const_tree);
@@ -3362,7 +3362,7 @@ static dw_die_ref scope_die_for (tree, d
static inline int local_scope_p (dw_die_ref);
static inline int class_scope_p (dw_die_ref);
static inline int class_or_namespace_scope_p (dw_die_ref);
-static void add_type_attribute (dw_die_ref, tree, int, dw_die_ref);
+static void add_type_attribute (dw_die_ref, tree, int, bool, dw_die_ref);
static void add_calling_convention_attribute (dw_die_ref, tree);
static const char *type_tag (const_tree);
static tree member_declared_type (const_tree);
@@ -10796,14 +10796,23 @@ output_line_info (bool prologue_only)
ASM_OUTPUT_LABEL (asm_out_file, l2);
}
+/* Return true if DW_AT_endianity should be emitted according to REVERSE. */
+
+static inline bool
+need_endianity_attribute_p (bool reverse)
+{
+ return reverse && (dwarf_version >= 3 || !dwarf_strict);
+}
+
/* Given a pointer to a tree node for some base type, return a pointer to
- a DIE that describes the given type.
+ a DIE that describes the given type. REVERSE is true if this type is
+ to be interpreted in reverse storage order wrt to the target order.
This routine must only be called for GCC type nodes that correspond to
Dwarf base (fundamental) types. */
static dw_die_ref
-base_type_die (tree type)
+base_type_die (tree type, bool reverse)
{
dw_die_ref base_type_result;
enum dwarf_type encoding;
@@ -10912,6 +10921,10 @@ base_type_die (tree type)
int_size_in_bytes (type));
add_AT_unsigned (base_type_result, DW_AT_encoding, encoding);
+ if (need_endianity_attribute_p (reverse))
+add_AT_unsigned (base_type_result, DW_AT_endianity,
+ BYTES_BIG_ENDIAN ? DW_END_little : DW_END_big);
+
if (fpt_used)
{
switch (fpt_info.scale_factor_kind)
@@ -10948,12 +10961,14 @@ base_type_die (tree type)
gcc_unreachable ();
}
}
- if (type_bias != NULL)
+
+ if (type_bias)
add_scalar_info (base_type_result, DW_AT_GNU_bias, type_bias,
dw_scalar_form_constant
| dw_scalar_form_exprloc
| dw_scalar_form_reference,
NULL);
+
add_pubtype (type, base_type_result);
return base_type_result;
@@ -11138,7 +11153,8 @@ get_nearest_type_subqualifiers (tree typ
entry that chains various modifiers in front of the given type. */
static dw_die_ref
-modified_type_die (tree type, int cv_quals,