]> granicus.if.org Git - clang/commitdiff
DebugInfo compression: Enable compression before any sections are created.
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 31 Mar 2014 23:13:30 +0000 (23:13 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 31 Mar 2014 23:13:30 +0000 (23:13 +0000)
For those playing at home this produced some fairly subtle behavior. The
sections created in InitMCObjectFileInfo were created without compressed
debug info (a mistake, but not necessarily /broken). Since these
sections were almost always referenced by the existing MCSection object,
this almost worked.

This got weird when we got to handling the relocations for a section.
See ELFObjectWriter::WriteSection where we compute the true section for
a relocation section by simply stripping the ".rela" prefix and then
looking up that section - doing so hit the compression codepath, looked
up .zdebug_blah and found a newly constructed empty section... thus,
things got weird.

This is untestable without a cross-project test (let me know if people
would prefer that to no testing).

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

tools/driver/cc1as_main.cpp

index c6bc870c0b9334c7c594cbda76142e87ebfdd9bf..0d06371dc16d2a55f42eeba5187a013376d3d8ff 100644 (file)
@@ -304,6 +304,10 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
   // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
   std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
+
+  if (Opts.CompressDebugSections)
+    MAI->setCompressDebugSections(true);
+
   MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
   // FIXME: Assembler behavior can change with -static.
   MOFI->InitMCObjectFileInfo(Opts.Triple,
@@ -320,8 +324,6 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
     Ctx.setCompilationDir(Opts.DebugCompilationDir);
   if (!Opts.MainFileName.empty())
     Ctx.setMainFileName(StringRef(Opts.MainFileName));
-  if (Opts.CompressDebugSections)
-    MAI->setCompressDebugSections(true);
 
   // Build up the feature string from the target feature list.
   std::string FS;