[lld] r324150 - Add -{no, }-check-sections flags to enable/disable section overlchecking
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 2 14:24:06 PST 2018
Author: ruiu
Date: Fri Feb 2 14:24:06 2018
New Revision: 324150
URL: http://llvm.org/viewvc/llvm-project?rev=324150&view=rev
Log:
Add -{no,}-check-sections flags to enable/disable section overlchecking
GNU linkers have this option.
Differential Revision: https://reviews.llvm.org/D42858
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/linkerscript/overlapping-sections.s
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=324150&r1=324149&r2=324150&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Feb 2 14:24:06 2018
@@ -112,6 +112,7 @@ struct Configuration {
bool AsNeeded = false;
bool Bsymbolic;
bool BsymbolicFunctions;
+ bool CheckSections;
bool CompressDebugSections;
bool DefineCommon;
bool Demangle = true;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=324150&r1=324149&r2=324150&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Feb 2 14:24:06 2018
@@ -600,6 +600,8 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->AuxiliaryList = args::getStrings(Args, OPT_auxiliary);
Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic);
Config->BsymbolicFunctions = Args.hasArg(OPT_Bsymbolic_functions);
+ Config->CheckSections =
+ Args.hasFlag(OPT_check_sections, OPT_no_check_sections, true);
Config->Chroot = Args.getLastArgValue(OPT_chroot);
Config->CompressDebugSections = getCompressDebugSections(Args);
Config->DefineCommon = Args.hasFlag(OPT_define_common, OPT_no_define_common,
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=324150&r1=324149&r2=324150&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Fri Feb 2 14:24:06 2018
@@ -31,6 +31,10 @@ def build_id: F<"build-id">, HelpText<"G
def build_id_eq: J<"build-id=">, HelpText<"Generate build ID note">;
+defm check_sections : B<"check-sections",
+ "Check section addresses for overlaps",
+ "Do not check section addresses for overlaps">;
+
defm compress_debug_sections : Eq<"compress-debug-sections">,
HelpText<"Compress DWARF debug sections">;
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=324150&r1=324149&r2=324150&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Feb 2 14:24:06 2018
@@ -455,7 +455,8 @@ template <class ELFT> void Writer<ELFT>:
Sec->Addr = 0;
}
- checkNoOverlappingSections();
+ if (Config->CheckSections)
+ checkNoOverlappingSections();
// It does not make sense try to open the file if we have error already.
if (errorCount())
Modified: lld/trunk/test/ELF/linkerscript/overlapping-sections.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/overlapping-sections.s?rev=324150&r1=324149&r2=324150&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/overlapping-sections.s (original)
+++ lld/trunk/test/ELF/linkerscript/overlapping-sections.s Fri Feb 2 14:24:06 2018
@@ -66,8 +66,10 @@
# LMA-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000 -> 0x80FF]
# LMA-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8080 -> 0x817F]
-# check that we create the expected binary with --noinhibit-exec:
+# Check that we create the expected binary with --noinhibit-exec or --no-check-sections:
# RUN: ld.lld -o %t.so --script %t-lma.script %t.o -shared --noinhibit-exec
+# RUN: ld.lld -o %t.so --script %t-lma.script %t.o -shared --no-check-sections
+# RUN: ld.lld -o %t.so --script %t-lma.script %t.o -shared --check-sections --no-check-sections
# Verify that the .sec2 was indeed placed in a PT_LOAD where the PhysAddr
# overlaps with where .sec1 is loaded:
More information about the llvm-commits
mailing list