[Dwarf-Discuss] Proposal to add DW_AT_alignment

Mark Wielaard mjw at redhat.com
Thu May 15 06:29:08 PDT 2014


Another thing added in C11 is the _Alignas specifier through which a
user can request to have a type or object that is stricter than the
default alignment for the type of object. Existing compilers like GCC
already allow users to specify the alignment of types and variables
through implementation specific attributes.

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.

The _Alignas request may be zero, which means the object will have the
default alignment. In which case I think the DWARF should not contain
the attribute. But we could also explicitly specify that an
DW_AT_alignment of zero means the default alignment. An object can also
have multiple alignment specifiers in which case the used alignment will
be the strictest specified. In which case the object or type should just
have this strictest DW_AT_alignement constant.

The C11 _Alignas allows both a constant or a type-name (to indicate that
the object should be aligned as if it was of that type). Since in both
cases it is the actual constant carries the actual useful information I
think DW_AT_alignment only needs a positive constant integer form. But
if people think having a variant that is encoded as type reference form
is useful then that could of course be added.

Maybe there is already an existing way to express non-default alignement
of objects and types that I am missing. If not I will write up a formal
proposal for an DW_AT_alignment that can be added to types and/or data



More information about the Dwarf-Discuss mailing list