[Dwarf-Discuss] qualifier modifier type tags vs type signatures

Mark Wielaard mjw at redhat.com
Fri Sep 26 01:03:43 PDT 2014

Hi John,

On Thu, 2014-09-25 at 14:58 -0400, John DelSignore wrote:
> IMHO, the compiler should be picking a canonical order for the
> qualifiers in the DWARF, just like it does for name mangling:
> % cat xxx.cxx
> void fpcvi(const volatile int*){}
> void fpvci(volatile const int*){}
> % g++ -g -c xxx.cxx
> % nm -C xxx.o
> 0000000000000000 T fpcvi(int const volatile*)
> 000000000000000a T fpvci(int const volatile*)
>                  U __gxx_personality_v0
> % nm xxx.o
> 0000000000000000 T _Z5fpcviPVKi
> 000000000000000a T _Z5fpvciPVKi
>                  U __gxx_personality_v0
> %
> The compiler (GCC 4.1.2) canonicalized the qualifier order in the
> overload portion of the mangled name to "PVKi", which is "pointer-to
> volatile const int". I think the demangler just spit the type out
> right-to-left.

That is a good suggestion. If the language already has another concept
where the ordering of type qualifiers matters. That way producers can
generate more predictable DWARF. I see this ordering is mandated by the
c++ abi standard:

Are there standards for other languages that DWARF could refer to when
producers have to turn an order insensitive qualifier set in an ordered
list to express them with DWARF type modifier tags?

> Given that, your option "0" along seems like the best choice to me. If
> someone really wants to squeeze out every last bit of compression, I
> think gcc could be changed to canonicalize the order of const/volatile
> in your example, and no one would (should) care about the rearrangement
> of the qualifiers.

Note that GCC defaults to not use type units at the moment. So it would
be a change to optimize for a slightly different default use case. But
maybe it is time for that. Given that it probably also helps with tools
like dwz. And that the current "smallest possible compile unit"
representation probably doesn't really safe that much normally (it only
matters when the same type is used with different, multiple,
qualifiers). Although I didn't do any measuring.

Ideally though some future DWARF.Next would make it possible to
represent type qualifiers in an order-insensitive way to really make it
language neutral.



More information about the Dwarf-Discuss mailing list