From e033b3afe392677d7e9fa302da89f8714c0f7e75 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 11 Jul 2018 19:13:26 +0000 Subject: [PATCH] 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 llvm-svn: 336838 --- llvm/tools/gold/gold-plugin.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 25ba80d..e88afd1 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -834,9 +834,11 @@ static std::unique_ptr 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; -- 2.7.4