diff options
author | Richard Mitton <richard@codersnotes.com> | 2013-10-03 22:07:08 +0000 |
---|---|---|
committer | Richard Mitton <richard@codersnotes.com> | 2013-10-03 22:07:08 +0000 |
commit | 7c9659a3b297be6298ffae4656b86797295c5d58 (patch) | |
tree | f181ed08efaa1a720a79b6989c47073ac54ad31f /lib | |
parent | 03e84c9df91cbc1fe0219a51109e260cacdfd2b7 (diff) | |
download | external_llvm-7c9659a3b297be6298ffae4656b86797295c5d58.zip external_llvm-7c9659a3b297be6298ffae4656b86797295c5d58.tar.gz external_llvm-7c9659a3b297be6298ffae4656b86797295c5d58.tar.bz2 |
Fixed a bug with section names containing special characters.
Changed the dwarf aranges code to not use getLabelEndName, as it turns out it's not reliable to call that given user-defined section names. Section names can have characters in that aren't representable as symbol names.
The dwarf-aranges test case has been updated to include a special character, to check this.
This fixes pr17416.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191932 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 557ae1d..c90d84b 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -312,6 +312,13 @@ static StringRef getObjCMethodName(StringRef In) { return In.slice(In.find(' ') + 1, In.find(']')); } +// Helper for sorting sections into a stable output order. +static bool SectionSort(const MCSection *A, const MCSection *B) { + std::string LA = (A ? A->getLabelBeginName() : ""); + std::string LB = (B ? B->getLabelBeginName() : ""); + return LA < LB; +} + // Add the various names to the Dwarf accelerator table names. // TODO: Determine whether or not we should add names for programs // that do not have a DW_AT_name or DW_AT_linkage_name field - this @@ -1119,14 +1126,29 @@ void DwarfDebug::endSections() { } } - // Add terminating symbols for each section. + // Build a list of sections used. + std::vector<const MCSection *> Sections; for (SectionMapType::iterator it = SectionMap.begin(); it != SectionMap.end(); it++) { const MCSection *Section = it->first; + Sections.push_back(Section); + } + + // Sort the sections into order. + // This is only done to ensure consistent output order across different runs. + std::sort(Sections.begin(), Sections.end(), SectionSort); + + // Add terminating symbols for each section. + for (unsigned ID=0;ID<Sections.size();ID++) { + const MCSection *Section = Sections[ID]; MCSymbol *Sym = NULL; if (Section) { - Sym = Asm->GetTempSymbol(Section->getLabelEndName()); + // We can't call MCSection::getLabelEndName, as it's only safe to do so + // if we know the section name up-front. For user-created sections, the resulting + // label may not be valid to use as a label. (section names can use a greater + // set of characters on some systems) + Sym = Asm->GetTempSymbol("debug_end", ID); Asm->OutStreamer.SwitchSection(Section); Asm->OutStreamer.EmitLabel(Sym); } @@ -2745,12 +2767,6 @@ struct SymbolCUSorter { } }; -static bool SectionSort(const MCSection *A, const MCSection *B) { - std::string LA = (A ? A->getLabelBeginName() : ""); - std::string LB = (B ? B->getLabelBeginName() : ""); - return LA < LB; -} - static bool CUSort(const CompileUnit *A, const CompileUnit *B) { return (A->getUniqueID() < B->getUniqueID()); } |