1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[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

llvm-svn: 336943
This commit is contained in:
Bill Wendling 2018-07-12 20:35:58 +00:00
parent f9e3d03e9f
commit 11ff2c5133
2 changed files with 6 additions and 4 deletions

View File

@ -10,7 +10,7 @@
; CHECK-NEXT: Binding: Global ; CHECK-NEXT: Binding: Global
; CHECK-NEXT: Type: Function ; CHECK-NEXT: Type: Function
; CHECK-NEXT: Other: 0 ; CHECK-NEXT: Other: 0
; CHECK-NEXT: Section: .text.foo ; CHECK-NEXT: Section: .text
; CHECK-NEXT: } ; CHECK-NEXT: }
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

View File

@ -115,6 +115,7 @@ static ld_plugin_add_input_file add_input_file = nullptr;
static ld_plugin_set_extra_library_path set_extra_library_path = nullptr; static ld_plugin_set_extra_library_path set_extra_library_path = nullptr;
static ld_plugin_get_view get_view = nullptr; static ld_plugin_get_view get_view = nullptr;
static bool IsExecutable = false; static bool IsExecutable = false;
static bool SplitSections = true;
static Optional<Reloc::Model> RelocationModel = None; static Optional<Reloc::Model> RelocationModel = None;
static std::string output_name = ""; static std::string output_name = "";
static std::list<claimed_file> Modules; static std::list<claimed_file> Modules;
@ -324,6 +325,7 @@ ld_plugin_status onload(ld_plugin_tv *tv) {
switch (tv->tv_u.tv_val) { switch (tv->tv_u.tv_val) {
case LDPO_REL: // .o case LDPO_REL: // .o
IsExecutable = false; IsExecutable = false;
SplitSections = false;
break; break;
case LDPO_DYN: // .so case LDPO_DYN: // .so
IsExecutable = false; IsExecutable = false;
@ -834,9 +836,9 @@ static std::unique_ptr<LTO> createLTO(IndexWriteCallback OnIndexWrite,
// FIXME: Check the gold version or add a new option to enable them. // FIXME: Check the gold version or add a new option to enable them.
Conf.Options.RelaxELFRelocations = false; Conf.Options.RelaxELFRelocations = false;
// Enable function/data sections by default. // Toggle function/data sections.
Conf.Options.FunctionSections = true; Conf.Options.FunctionSections = SplitSections;
Conf.Options.DataSections = true; Conf.Options.DataSections = SplitSections;
Conf.MAttrs = MAttrs; Conf.MAttrs = MAttrs;
Conf.RelocModel = RelocationModel; Conf.RelocModel = RelocationModel;