[llvm] r336838 - gold: Add ability to toggle function/data sections

Bill Wendling via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 11 12:13:26 PDT 2018


Author: void
Date: Wed Jul 11 12:13:26 2018
New Revision: 336838

URL: http://llvm.org/viewvc/llvm-project?rev=336838&view=rev
Log:
gold: Add ability to toggle function/data sections

Some programs (e.g. Linux) aren't able to handle function/data sections when
LTO is used. Thus they need a way to disable it. That can be done with these
plugin options:

    -plugin-opt=-function-sections=0
    -plugin-opt=-data-sections=0

Modified:
    llvm/trunk/tools/gold/gold-plugin.cpp

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=336838&r1=336837&r2=336838&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Wed Jul 11 12:13:26 2018
@@ -834,9 +834,11 @@ static std::unique_ptr<LTO> createLTO(In
   // FIXME: Check the gold version or add a new option to enable them.
   Conf.Options.RelaxELFRelocations = false;
 
-  // Enable function/data sections by default.
-  Conf.Options.FunctionSections = true;
-  Conf.Options.DataSections = true;
+  // Toggle function/data sections.
+  if (FunctionSections.getNumOccurrences() == 0)
+    Conf.Options.FunctionSections = true;
+  if (DataSections.getNumOccurrences() == 0)
+    Conf.Options.DataSections = true;
 
   Conf.MAttrs = MAttrs;
   Conf.RelocModel = RelocationModel;




More information about the llvm-commits mailing list