Issue 140528.1: Add DW_TAG_aligned tag and DW_AT_alignment attribute

Author: Mark Wielaard
Champion: Eric Christopher
Date submitted: 2014-05-28
Date revised:
Date closed:
Type: Enhancement
Status: Accepted with modifications
DWARF Version: 5
Section 5.2, pg 80

As discussed on the DWARF discuss list, it is useful for debuggers to know the alignment
used for an data object in case they need to create an object for use with some expressions
to be evaluated in the inferior and for type analyzers to know whether two types are compatible.
In C11 (or through GNU attribute extensions) a user can declare the alignment of a type or 
variable. The below proposal adds a new DW_AT_alignment attribute. 


Table 2.2, Attribute names add:

DW_AT_alignment non-default alignment requirements of type, subprogram, or variable.

At the end of Chapter 2 add a paragraph:

2.24 Alignment

An debugging information entry may have a DW_AT_alignment attribute
that describes the (non-default) alignment requirements of the entry.
DW_AT_alignment has a positive, non-zero, constant describing the
strictest specified (non-default) alignment of the type. This constant
describes the actual alignment used by the compiler (if there are multiple
specified by the user, or if the user specified an alignment the compiler
couldn't satisfy, then only the strictest alignment will be added through a

with the non-normative text below:

Debugging information entries to which DW_AT_alignment may apply include (but
are not limited to):
DW_TAG_class_type, DW_TAG_structure_type, DW_TAG_typedef, DW_TAG_subprogram,
DW_TAG_variable. See Table A.1 for the tags to which this attribute could apply.

Table 7.5, Attribute encodings add:

DW_AT_alignment 0xXX constant

Table A.1, Attributes by tag value add:


to DW_TAG_array_type, DW_TAG_atomic_type, DW_TAG_base_type, DW_TAG_class_type,
DW_TAG_coarray_type, DW_TAG_const_type, DW_TAG_dynamic_type,
DW_TAG_enumeration_type, DW_TAG_file_type, DW_TAG_interface_type,
DW_TAG_packed_type, DW_TAG_pointer_type, DW_TAG_pointer_to_member_type,
DW_TAG_reference_type, DW_TAG_restrict_type, DW_TAG_rvalue_reference_type,
DW_TAG_set_type, DW_TAG_shared_type, DW_TAG_string_type, DW_TAG_structure_type,
DW_TAG_subprogram, DW_TAG_subrange_type, DW_TAG_subroutine_type,
DW_TAG_thrown_type, DW_TAG_typedef, DW_TAG_union_type, DW_TAG_variable.

7.27 Type Signature Computation.

DW_AT_alignment should be added under point 4.

8/19/2014 -- Accepted with modifications:
  Remove DW_TAG_aligned_type; DW_AT_alignment is number of bytes; 
  DW_AT_alignment may be used with types, variables, or programs.
12/12/2014 -- Updated with revised text.