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

llvm-svn: 336838

llvm/tools/gold/gold-plugin.cpp

index 25ba80d..e88afd1 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;