[lld] e96d7b5 - [ELF] Add --rosegment to complement --no-rosegment
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 18:01:04 PDT 2020
Author: Fangrui Song
Date: 2020-04-29T18:00:00-07:00
New Revision: e96d7b5e9ef00c4ea5dfbc8918c2db2c585b652b
URL: https://github.com/llvm/llvm-project/commit/e96d7b5e9ef00c4ea5dfbc8918c2db2c585b652b
DIFF: https://github.com/llvm/llvm-project/commit/e96d7b5e9ef00c4ea5dfbc8918c2db2c585b652b.diff
LOG: [ELF] Add --rosegment to complement --no-rosegment
This option can cancel --no-rosegment and it just seems right to have
a corresponding positive option for a --no-* negative option.
Anecdotally, gold had --rosegment but did not have --no-rosegment.
I added --no-rosegment (https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9a6c68caa9543e09b064b7ac7c2b658f277bc19c) for binutils>=2.35
Added:
Modified:
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/test/ELF/segments.s
Removed:
################################################################################
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index ff0c115e9cad..31a2a3a3a860 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -965,7 +965,7 @@ static void readConfigs(opt::InputArgList &args) {
config->searchPaths = args::getStrings(args, OPT_library_path);
config->sectionStartMap = getSectionStartMap(args);
config->shared = args.hasArg(OPT_shared);
- config->singleRoRx = args.hasArg(OPT_no_rosegment);
+ config->singleRoRx = !args.hasFlag(OPT_rosegment, OPT_no_rosegment, true);
config->soName = args.getLastArgValue(OPT_soname);
config->sortSection = getSortSection(args);
config->splitStackAdjustSize = args::getInteger(args, OPT_split_stack_adjust_size, 16384);
diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index ad4e489f7f90..cb0c12a9a320 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -256,9 +256,6 @@ def no_nmagic: F<"no-nmagic">, MetaVarName<"<magic>">,
def no_omagic: F<"no-omagic">, MetaVarName<"<magic>">,
HelpText<"Do not set the text data sections to be writable, page align sections (default)">;
-def no_rosegment: F<"no-rosegment">,
- HelpText<"Do not put read-only non-executable sections in their own segment">;
-
def no_undefined: F<"no-undefined">,
HelpText<"Report unresolved symbols even if the linker is creating a shared library">;
@@ -311,6 +308,10 @@ def print_map: F<"print-map">,
defm reproduce: Eq<"reproduce", "Write a tar file containing input files and command line options to reproduce link">;
+defm rosegment: B<"rosegment",
+ "Put read-only non-executable sections in their own segment (default)",
+ "Do not put read-only non-executable sections in their own segment">;
+
defm rpath: Eq<"rpath", "Add a DT_RUNPATH to the output">;
def relocatable: F<"relocatable">, HelpText<"Create relocatable object file">;
diff --git a/lld/test/ELF/segments.s b/lld/test/ELF/segments.s
index 5165fc3c4858..9b88f48ac090 100644
--- a/lld/test/ELF/segments.s
+++ b/lld/test/ELF/segments.s
@@ -3,8 +3,8 @@
# RUN: ld.lld %t -o %t1
# RUN: llvm-readobj --program-headers %t1 | FileCheck --check-prefix=ROSEGMENT %s
-# RUN: ld.lld --omagic --no-omagic %t -o %t1
-# RUN: llvm-readobj --program-headers %t1 | FileCheck --check-prefix=ROSEGMENT %s
+# RUN: ld.lld --no-rosegment --rosegment %t -o - | cmp - %t1
+# RUN: ld.lld --omagic --no-omagic %t -o - | cmp - %t1
# ROSEGMENT: ProgramHeader {
# ROSEGMENT: Type: PT_LOAD
More information about the llvm-commits
mailing list