}
case OPT_INPUT:
- case OPT_l: {
+ case OPT_l:
+ case OPT_T: {
bool dashL = (arg->getOption().getID() == OPT_l);
StringRef path = arg->getValue();
" will be resolved to symbol.">,
MetaVarName<"<symbol>">,
Group<grp_symbolopts>;
+
+//===----------------------------------------------------------------------===//
+/// Script Options
+//===----------------------------------------------------------------------===//
+def grp_scriptopts : OptionGroup<"opts">,
+ HelpText<"SCRIPT OPTIONS">;
+defm T : smDash<"T", "script",
+ "Use the given linker script in place of the default script.">,
+ Group<grp_scriptopts>;
+
//===----------------------------------------------------------------------===//
/// Optimization Options
//===----------------------------------------------------------------------===//
* -s,--strip-all
* -S,--strip-debug
* --trace
-* -T,--script
* -dT,--default-script
* -Ur
* --unique
if (llvm::sys::fs::exists(path.str()))
return StringRef(*new (_allocator) std::string(path.str()));
}
- if (!llvm::sys::fs::exists(libName))
- return make_error_code(llvm::errc::no_such_file_or_directory);
+ if (hasColonPrefix && llvm::sys::fs::exists(libName.drop_front()))
+ return libName.drop_front();
- return libName;
+ return make_error_code(llvm::errc::no_such_file_or_directory);
}
ErrorOr<StringRef> ELFLinkingContext::searchFile(StringRef fileName,
--- /dev/null
+/* A simple valid linker script used for testing the -T/--script options.
+ *
+ * An unresolved symbol named '_entry_point' can be scanned for by the tests
+ * to determine that the linker script was processed.
+ */
+ENTRY(_entry_point)
--- /dev/null
+# Check that the -T/--script options issue an error when passed
+# filenames for files that do not exist.
+
+RUN: not lld -flavor gnu -target x86_64 -T idonotexist.ls 2> %t.err
+RUN: FileCheck %s < %t.err
+
+RUN: not lld -flavor gnu -target x86_64 --script=idonotexist.ls 2> %t.err
+RUN: FileCheck %s < %t.err
+
+CHECK: {{.*}}lld: cannot find file {{.*}}idonotexist.ls
--- /dev/null
+# Check that linker script are *not* picked up with -lscript.ls.
+
+RUN: not lld -flavor gnu -target x86_64 -L%p/Inputs/ -lvalid.ls 2> %t.err
+RUN: FileCheck %s < %t.err
+
+CHECK: {{.*}}: Unable to find library -lvalid.ls
--- /dev/null
+# Check that the linker script inputs are accepted properly.
+
+# RUN: lld -flavor gnu -target x86_64 %p/Inputs/valid.ls -r %s \
+# RUN: --output-filetype=yaml | FileCheck %s
+
+# RUN: lld -flavor gnu -target x86_64 -T %p/Inputs/valid.ls -r %s \
+# RUN: --output-filetype=yaml | FileCheck %s
+
+# RUN: lld -flavor gnu -target x86_64 --script=%p/Inputs/valid.ls -r %s \
+# RUN: --output-filetype=yaml | FileCheck %s
+
+# RUN: lld -flavor gnu -target x86_64 -L%p/Inputs/ -l:valid.ls -r %s \
+# RUN: --output-filetype=yaml | FileCheck %s
+
+defined-atoms:
+ - name: main
+ scope: global
+ content: [ B8, 00, 00, 00, 00, C7, 44, 24, FC, 00, 00, 00, 00, C3 ]
+ alignment: 2^4
+ section-choice: custom-required
+ section-name: .text
+
+# CHECK: _entry_point