]> granicus.if.org Git - llvm/commitdiff
gold: Add ability to toggle function/data sections
authorBill Wendling <isanbard@gmail.com>
Wed, 11 Jul 2018 19:13:26 +0000 (19:13 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 11 Jul 2018 19:13:26 +0000 (19:13 +0000)
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

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

tools/gold/gold-plugin.cpp

index 25ba80d2666621ae3da398ea8db4b814c8b96cbd..e88afd1cfb0e28824f80125477109c53d8c4ee9f 100644 (file)
@@ -834,9 +834,11 @@ static std::unique_ptr<LTO> createLTO(IndexWriteCallback OnIndexWrite,
   // 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;