Issue 141212.1: DW_AT_export_symbols
Proposal
========
Add DW_AT_export_symbols attribute to indicate that the symbols
defined within the current scope are to be exported into the enclosing
scope.
This proposal is an alternate to 141020.1.
Background
==========
C++11 adds a new use for the keword "inline" as a modifier for
namespace, which exports the symbols defined within the namespace
into the enclosing scope. From the proposed extension
Section 7.3.1:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf
"Members of an inline namespace can be used in most respects as
though they were members of the enclosing namespace."
This is similar to the use of anonymous structs in C/C++, where symbols
within the interior struct are referenced as if they were defined
in the enclosing structure.
Example -- C++ inline namespace
namespace A {
inline namespace B { // (1) inline namespace
int a;
}
}
void foo (void)
{
using A::B::a;
a = 1;
}
void bar (void)
{
using A::a;
a = 2;
}
<1> DW_TAG_namespace
DW_AT_name : A
<2> DW_TAG_namespace
DW_AT_name : B
DW_AT_export_symbols
<3> DW_TAG_variable)
DW_AT_name : a
In this example, 'a' may be referenced either as a member of
the fully qualified namespace A::B, or as if it were defined
in the enclosing namespace, A.
Example -- C/C++ anonymous structs
struct foo {
int a;
struct {
int b;
};
} x;
void bar(void)
{
struct foo t;
t.a = 1;
t.b = 2;
}
<1> DW_TAG_structure_type
DW_AT_name (foo)
<2> DW_TAG_member
DW_AT_name (a)
<3> DW_TAG_structure_type
DW_AT_export_symbols
<4> DW_TAG_member
DW_AT_name (b)
In this example, 'b' is referenced as if it were defined in the
enclosing struct 'foo'.
Note: GCC currently generates the following DWARF, with the nested
anonymous struct described as being at top-level, rather than within
struct foo, and with an unnamed member within struct foo with the
type of the anonymous struct.
<1> DW_TAG_structure_type
<2> DW_TAG_member
DW_AT_name (b)
<3> DW_TAG_structure_type
DW_AT_name (foo)
<4> DW_TAG_member
DW_AT_name (a)
<5> DW_TAG_member
DW_AT_type <1>
Document changes
================
Add to Table 2.2 (Attribute names)
DW_AT_export_symbols Namespace Entries
Structure, Union and Class Type Entries
Add to end of 3.2.2 (Namespace Entries)
A namespace may have a DW_AT_export_symbols attribute which indicates
that all member names defined within the namespace may be referenced
as if they were defined within the containing namespace.
*This may be used to describe inline namespaces in C++.*
Add to end of 5.7.1 (Structure, Union and Class Type Entries)
A structure, union, or class type may have a DW_AT_export_symbols
attribute which indicates that all member names defined within
the structure, union, or class may be referenced as if they were
defined within the containing structure, union, or class.
*This may be used to describe anonymous structs, etc., in C or C++.*
Add to Table 7.5 (Attribute encodings)
DW_AT_export_symbols 0x89 flag
Modify Table A.1
DW_TAG_class_type -- Add DW_AT_export_symbols
DW_TAG_namespace -- Add DW_AT_export_symbols
DW_TAG_structure_type -- Add DW_AT_export_symbols
DW_TAG_union_type -- Add DW_AT_export_symbols