Difference between revisions of "DW AT linkage name"

From Dwarf Wiki
Jump to: navigation, search
Line 37: Line 37:
 
so that people can understand it's use better.  (And we can
 
so that people can understand it's use better.  (And we can
 
point out the size issues related to its use).
 
point out the size issues related to its use).
 +
 +
 +
-----
 +
We invented this at MIPS/SGI circa 1992 because we did not have a reliable demangler
 +
and we were transistioning from cfront to Edison front ends.  And we were
 +
far from sure how to handle mangler-rules-transistions and far from sure how often
 +
mangler/demangler rules would change.  At that time there was not much C++ code
 +
and the mangled names were not so long! So the space use was not too bad. (David Anderson)

Revision as of 08:36, 14 May 2007

There is an attribute DW_AT_MIPS_linkage_name which is used by gcc and g++ to record the external linker symbol for a subprogram. This is a vendor extension that's been in use for a very long time and shared by multiple vendors.

I propose we create DW_AT_linkage_name as a standardization of the extension DW_AT_MIPS_linkage_name.

Sun uses something similar in cases where an address (IE a relocation) cannot be used to point at an external function or variable. In those cases, the compiler puts the mangled name into the dwarf data instead of the address of the function, and then the mangled name is looked up in the symbol table of the final a.out to find the address of the symbol.

In practice, it is impossible to reliably recreate the "mangled name" for a C++ symbol based on the type information recorded in dwarf. Even if it were possible it would require implementing a serious C++ compiler dependency (that is: the complete mangling algorithm) inside any dwarf consumer who wanted to look up the symbol in the ELF symbol table.


Commentary:

Dan Berlin said he was working to get rid of it in gcc, and I can say Sun is also trying to get rid of it wherever possible. (The problems are because of the space needed for the very long strings). But it turns out to be necessary in some cases.

I needed to add this to the Sun compilers in more cases when we're trying to be "gdb friendly". Assuming it's removal from gcc is not imminent, I'd rather create a standard name for it, so we don't have such a wide-spread use of a vendor extension which has essentially become a defacto part of the standard. If it one day goes away that's fine. But I'd like to be able to document it as part of the standard so that people can understand it's use better. (And we can point out the size issues related to its use).



We invented this at MIPS/SGI circa 1992 because we did not have a reliable demangler and we were transistioning from cfront to Edison front ends. And we were far from sure how to handle mangler-rules-transistions and far from sure how often mangler/demangler rules would change. At that time there was not much C++ code and the mangled names were not so long! So the space use was not too bad. (David Anderson)