[PATCH] D48756: Add option for section ordering
Bill Wendling via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 29 01:07:27 PDT 2018
void created this revision.
void added a reviewer: tejohnson.
Herald added subscribers: llvm-commits, dexonsmith, mehdi_amini.
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.
Repository:
rL LLVM
https://reviews.llvm.org/D48756
Files:
test/tools/gold/X86/multiple-data.s
test/tools/gold/X86/multiple-sections.ll
tools/gold/gold-plugin.cpp
Index: tools/gold/gold-plugin.cpp
===================================================================
--- tools/gold/gold-plugin.cpp
+++ tools/gold/gold-plugin.cpp
@@ -203,6 +203,8 @@
static std::string dwo_dir;
/// Statistics output filename.
static std::string stats_file;
+ // Section ordering.
+ static bool section_ordering;
// Optimization remarks filename and hotness options
static std::string OptRemarksFilename;
@@ -278,6 +280,8 @@
OptRemarksWithHotness = true;
} else if (opt.startswith("stats-file=")) {
stats_file = opt.substr(strlen("stats-file="));
+ } else if (opt == "section-ordering") {
+ section_ordering = true;
} else {
// Save this option to pass to the code generator.
// ParseCommandLineOptions() expects argv[0] to be program name. Lazily
@@ -834,9 +838,8 @@
// 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;
+ Conf.Options.FunctionSections = options::section_ordering;
+ Conf.Options.DataSections = options::section_ordering;
Conf.MAttrs = MAttrs;
Conf.RelocModel = RelocationModel;
Index: test/tools/gold/X86/multiple-sections.ll
===================================================================
--- test/tools/gold/X86/multiple-sections.ll
+++ test/tools/gold/X86/multiple-sections.ll
@@ -3,6 +3,7 @@
; RUN: echo ".text.pat" >> %t_order_lto.txt
; RUN: llvm-as %s -o %t.o
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN: -plugin-option=section-ordering \
; RUN: -m elf_x86_64 -o %t.exe %t.o \
; RUN: --section-ordering-file=%t_order_lto.txt
; RUN: llvm-readobj -elf-output-style=GNU -t %t.exe | FileCheck %s
Index: test/tools/gold/X86/multiple-data.s
===================================================================
--- test/tools/gold/X86/multiple-data.s
+++ test/tools/gold/X86/multiple-data.s
@@ -5,6 +5,7 @@
# RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-unknown-linux-gnu
# RUN: llvm-as %p/Inputs/multiple-data.ll -o %t2.o
# RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
+# RUN: -plugin-opt=section-ordering \
# RUN: -m elf_x86_64 -o %t.exe %t2.o %t.o \
# RUN: --section-ordering-file=%t_order_lto.txt
# RUN: llvm-readobj -elf-output-style=GNU -t %t.exe | FileCheck %s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48756.153441.patch
Type: text/x-patch
Size: 2443 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180629/11a3657a/attachment.bin>
More information about the llvm-commits
mailing list