From: David Blaikie Date: Mon, 31 Mar 2014 23:13:30 +0000 (+0000) Subject: DebugInfo compression: Enable compression before any sections are created. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=af63dddc586e02fd3cd36d5635db43f1682814a2;p=clang DebugInfo compression: Enable compression before any sections are created. 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 --- diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp index c6bc870c0b..0d06371dc1 100644 --- a/tools/driver/cc1as_main.cpp +++ b/tools/driver/cc1as_main.cpp @@ -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 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;