summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-10-03 08:54:43 +0000
committerAlexey Samsonov <samsonov@google.com>2013-10-03 08:54:43 +0000
commit9d08d69fd4562a4433cf19eb4b96c17b34f6da2e (patch)
treea9c8dcaca15ab59ba57c34be40e46edc10c4dd14 /lib
parent198f1b340a71b26f70849db86d72f7b79fd56d03 (diff)
downloadllvm-9d08d69fd4562a4433cf19eb4b96c17b34f6da2e.tar.gz
llvm-9d08d69fd4562a4433cf19eb4b96c17b34f6da2e.tar.bz2
llvm-9d08d69fd4562a4433cf19eb4b96c17b34f6da2e.tar.xz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp16
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp9
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.h7
3 files changed, 10 insertions, 22 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index c9941086c2..afe8a7d283 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -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);
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 587ee35beb..b8fa9743ab 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1110,8 +1110,8 @@ void DwarfDebug::finalizeModuleInfo() {
void DwarfDebug::endSections() {
// Filter labels by section.
- for (size_t n = 0; n < Labels.size(); n++) {
- const SymbolCU &SCU = Labels[n];
+ for (size_t n = 0; n < ArangeLabels.size(); n++) {
+ const SymbolCU &SCU = ArangeLabels[n];
if (SCU.Sym->isInSection()) {
// Make a note of this symbol and it's section.
const MCSection *Section = &SCU.Sym->getSection();
@@ -1138,10 +1138,7 @@ void DwarfDebug::endSections() {
}
// Insert a final terminator.
- SymbolCU Entry;
- Entry.CU = NULL;
- Entry.Sym = Sym;
- SectionMap[Section].push_back(Entry);
+ SectionMap[Section].push_back(SymbolCU(NULL, Sym));
}
}
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 7405fe12a9..423ff342ec 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -303,6 +303,7 @@ public:
/// \brief Helper used to pair up a symbol and it's DWARF compile unit.
struct SymbolCU {
+ SymbolCU(CompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
const MCSymbol *Sym;
CompileUnit *CU;
};
@@ -363,8 +364,8 @@ class DwarfDebug {
// separated by a zero byte, mapped to a unique id.
StringMap<unsigned, BumpPtrAllocator&> SourceIdMap;
- // List of all labels used in the output.
- std::vector<SymbolCU> Labels;
+ // List of all labels used in aranges generation.
+ std::vector<SymbolCU> ArangeLabels;
// Size of each symbol emitted (for those symbols that have a specific size).
DenseMap <const MCSymbol *, uint64_t> SymSize;
@@ -731,7 +732,7 @@ public:
void addTypeUnitType(DIE *Die) { TypeUnits.push_back(Die); }
/// \brief Add a label so that arange data can be generated for it.
- void addLabel(SymbolCU SCU) { Labels.push_back(SCU); }
+ void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
/// \brief For symbols that have a size designated (e.g. common symbols),
/// this tracks that size.