[llvm] r336943 - [gold-plugin] Disable section ordering for relocatable links
Bill Wendling via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 12 13:35:58 PDT 2018
Author: void
Date: Thu Jul 12 13:35:58 2018
New Revision: 336943
URL: http://llvm.org/viewvc/llvm-project?rev=336943&view=rev
Log:
[gold-plugin] Disable section ordering for relocatable links
Not all programs want section ordering when compiled with LTO.
In particular, the Linux kernel is very sensitive when it comes to linking, and
doesn't boot when each function is placed in its own sections.
Reviewed By: pcc
Differential Revision: https://reviews.llvm.org/D48756
Modified:
llvm/trunk/test/tools/gold/X86/relocatable.ll
llvm/trunk/tools/gold/gold-plugin.cpp
Modified: llvm/trunk/test/tools/gold/X86/relocatable.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/gold/X86/relocatable.ll?rev=336943&r1=336942&r2=336943&view=diff
==============================================================================
--- llvm/trunk/test/tools/gold/X86/relocatable.ll (original)
+++ llvm/trunk/test/tools/gold/X86/relocatable.ll Thu Jul 12 13:35:58 2018
@@ -10,7 +10,7 @@
; CHECK-NEXT: Binding: Global
; CHECK-NEXT: Type: Function
; CHECK-NEXT: Other: 0
-; CHECK-NEXT: Section: .text.foo
+; CHECK-NEXT: Section: .text
; CHECK-NEXT: }
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=336943&r1=336942&r2=336943&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Thu Jul 12 13:35:58 2018
@@ -115,6 +115,7 @@ static ld_plugin_add_input_file add_inpu
static ld_plugin_set_extra_library_path set_extra_library_path = nullptr;
static ld_plugin_get_view get_view = nullptr;
static bool IsExecutable = false;
+static bool SplitSections = true;
static Optional<Reloc::Model> RelocationModel = None;
static std::string output_name = "";
static std::list<claimed_file> Modules;
@@ -324,6 +325,7 @@ ld_plugin_status onload(ld_plugin_tv *tv
switch (tv->tv_u.tv_val) {
case LDPO_REL: // .o
IsExecutable = false;
+ SplitSections = false;
break;
case LDPO_DYN: // .so
IsExecutable = false;
@@ -834,9 +836,9 @@ 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.
+ Conf.Options.FunctionSections = SplitSections;
+ Conf.Options.DataSections = SplitSections;
Conf.MAttrs = MAttrs;
Conf.RelocModel = RelocationModel;
More information about the llvm-commits
mailing list