Add -nostdlib.

llvm-svn: 280528
This commit is contained in:
Rui Ueyama 2016-09-02 19:20:33 +00:00
parent c50dfe38ac
commit 6c7ad13f89
5 changed files with 12 additions and 1 deletions

View File

@ -98,6 +98,7 @@ struct Configuration {
bool Mips64EL = false;
bool NoGnuUnique;
bool NoUndefinedVersion;
bool Nostdlib;
bool OFormatBinary;
bool Pic;
bool Pie;

View File

@ -410,6 +410,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
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);

View File

@ -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(")");
}

View File

@ -97,6 +97,9 @@ def lto_O: J<"lto-O">, MetaVarName<"<opt-level>">,
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">;

View File

@ -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: