Remove wild .debug_aranges entries generated from unimportant labels

r191052 added emitting .debug_aranges to Clang, but this
functionality is broken: it uses all MC labels added in DWARF Asm
printer, including the labels for build relocations between
different DWARF sections, like .Lsection_line or .Ldebug_loc0.

As a result, if any DIE .debug_info would contain "DW_AT_location=0x123"
attribute, .debug_aranges would also contain a range starting from 0x123,
breaking tools that rely on this section.

This patch fixes this by using only MC labels that corresponds to the
addresses in the user program.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191884 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexey Samsonov
2013-10-03 08:54:43 +00:00
parent 198f1b340a
commit 9d08d69fd4
4 changed files with 98 additions and 22 deletions

View File

@@ -181,12 +181,6 @@ void CompileUnit::addLabel(DIE *Die, uint16_t Attribute, uint16_t Form,
const MCSymbol *Label) {
DIEValue *Value = new (DIEValueAllocator) DIELabel(Label);
Die->addValue(Attribute, Form, Value);
SymbolCU Entry;
Entry.CU = this;
Entry.Sym = Label;
DD->addLabel(Entry);
}
/// addLabelAddress - Add a dwarf label attribute data and value using
@@ -194,13 +188,8 @@ void CompileUnit::addLabel(DIE *Die, uint16_t Attribute, uint16_t Form,
///
void CompileUnit::addLabelAddress(DIE *Die, uint16_t Attribute,
MCSymbol *Label) {
if (Label) {
SymbolCU Entry;
Entry.CU = this;
Entry.Sym = Label;
DD->addLabel(Entry);
}
if (Label)
DD->addArangeLabel(SymbolCU(this, Label));
if (!DD->useSplitDwarf()) {
if (Label != NULL) {
@@ -221,6 +210,7 @@ void CompileUnit::addLabelAddress(DIE *Die, uint16_t Attribute,
/// form given and an op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
///
void CompileUnit::addOpAddress(DIE *Die, const MCSymbol *Sym) {
DD->addArangeLabel(SymbolCU(this, Sym));
if (!DD->useSplitDwarf()) {
addUInt(Die, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
addLabel(Die, 0, dwarf::DW_FORM_udata, Sym);