OSDN Git Service

[dsymutil] Emit label at the begin of a CU
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 6 Jul 2018 12:49:54 +0000 (12:49 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 6 Jul 2018 12:49:54 +0000 (12:49 +0000)
When emitting a CU, store the MCSymbol pointing to the beginning of the
CU. We'll need this information later when emitting the .debug_names
section (DWARF5 accelerator table).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336433 91177308-0d34-0410-b5e6-96231b3b80d8

tools/dsymutil/CompileUnit.h
tools/dsymutil/DwarfStreamer.cpp

index d56f298..0f5efdd 100644 (file)
@@ -247,11 +247,15 @@ public:
     ResolvedPaths[FileNum] = Path;
   }
 
+  MCSymbol *getLabelBegin() { return LabelBegin; }
+  void setLabelBegin(MCSymbol *S) { LabelBegin = S; }
+
 private:
   DWARFUnit &OrigUnit;
   unsigned ID;
   std::vector<DIEInfo> Info; ///< DIE info indexed by DIE index.
   Optional<BasicDIEUnit> NewUnit;
+  MCSymbol *LabelBegin = nullptr;
 
   uint64_t StartOffset;
   uint64_t NextUnitOffset;
index 0503467..5bf2382 100644 (file)
@@ -136,11 +136,16 @@ void DwarfStreamer::emitCompileUnitHeader(CompileUnit &Unit) {
   unsigned Version = Unit.getOrigUnit().getVersion();
   switchToDebugInfoSection(Version);
 
+  /// The start of the unit within its section.
+  Unit.setLabelBegin(Asm->createTempSymbol("cu_begin"));
+  Asm->OutStreamer->EmitLabel(Unit.getLabelBegin());
+
   // Emit size of content not including length itself. The size has already
   // been computed in CompileUnit::computeOffsets(). Subtract 4 to that size to
   // account for the length field.
   Asm->emitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset() - 4);
   Asm->emitInt16(Version);
+
   // We share one abbreviations table across all units so it's always at the
   // start of the section.
   Asm->emitInt32(0);