[lld] r280528 - Add -nostdlib.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 2 12:20:33 PDT 2016
Author: ruiu
Date: Fri Sep 2 14:20:33 2016
New Revision: 280528
URL: http://llvm.org/viewvc/llvm-project?rev=280528&view=rev
Log:
Add -nostdlib.
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/Options.td
lld/trunk/test/ELF/libsearch.s
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=280528&r1=280527&r2=280528&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Sep 2 14:20:33 2016
@@ -98,6 +98,7 @@ struct Configuration {
bool Mips64EL = false;
bool NoGnuUnique;
bool NoUndefinedVersion;
+ bool Nostdlib;
bool OFormatBinary;
bool Pic;
bool Pie;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=280528&r1=280527&r2=280528&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Sep 2 14:20:33 2016
@@ -410,6 +410,7 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->ICF = Args.hasArg(OPT_icf);
Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
Config->NoUndefinedVersion = Args.hasArg(OPT_no_undefined_version);
+ Config->Nostdlib = Args.hasArg(OPT_nostdlib);
Config->Pie = Args.hasArg(OPT_pie);
Config->PrintGcSections = Args.hasArg(OPT_print_gc_sections);
Config->Relocatable = Args.hasArg(OPT_relocatable);
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=280528&r1=280527&r2=280528&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Sep 2 14:20:33 2016
@@ -870,7 +870,8 @@ void ScriptParser::readPhdrs() {
void ScriptParser::readSearchDir() {
expect("(");
- Config->SearchPaths.push_back(next());
+ if (!Config->Nostdlib)
+ Config->SearchPaths.push_back(next());
expect(")");
}
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=280528&r1=280527&r2=280528&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Fri Sep 2 14:20:33 2016
@@ -97,6 +97,9 @@ def lto_O: J<"lto-O">, MetaVarName<"<opt
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
+def nostdlib: F<"nostdlib">,
+ HelpText<"Only search directories specified on the command line">;
+
def no_as_needed: F<"no-as-needed">,
HelpText<"Always DT_NEEDED for shared libraries">;
Modified: lld/trunk/test/ELF/libsearch.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/libsearch.s?rev=280528&r1=280527&r2=280528&view=diff
==============================================================================
--- lld/trunk/test/ELF/libsearch.s (original)
+++ lld/trunk/test/ELF/libsearch.s Fri Sep 2 14:20:33 2016
@@ -85,5 +85,10 @@
// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -call_shared -lls
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
+// -nostdlib
+// RUN: echo 'SEARCH_DIR(' %t.dir ')' > %t.script
+// RUN: ld.lld -o %t3 %t.o -script %t.script -lls
+// RUN: not ld.lld -o %t3 %t.o -script %t.script -lls -nostdlib
+
.globl _start,_bar
_start:
More information about the llvm-commits
mailing list