Index: lib/Driver/GnuLdDriver.cpp =================================================================== --- lib/Driver/GnuLdDriver.cpp +++ lib/Driver/GnuLdDriver.cpp @@ -654,7 +654,8 @@ } case OPT_INPUT: - case OPT_l: { + case OPT_l: + case OPT_T: { bool dashL = (arg->getOption().getID() == OPT_l); StringRef path = arg->getValue(); Index: lib/Driver/GnuLdOptions.td =================================================================== --- lib/Driver/GnuLdOptions.td +++ lib/Driver/GnuLdOptions.td @@ -253,6 +253,16 @@ " will be resolved to symbol.">, MetaVarName<"">, Group; + +//===----------------------------------------------------------------------===// +/// 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; + //===----------------------------------------------------------------------===// /// Optimization Options //===----------------------------------------------------------------------===// Index: lib/Driver/TODO.rst =================================================================== --- lib/Driver/TODO.rst +++ lib/Driver/TODO.rst @@ -31,7 +31,6 @@ * -s,--strip-all * -S,--strip-debug * --trace -* -T,--script * -dT,--default-script * -Ur * --unique Index: test/elf/linkerscript/Inputs/valid.ls =================================================================== --- /dev/null +++ test/elf/linkerscript/Inputs/valid.ls @@ -0,0 +1,6 @@ +/* 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) Index: test/elf/linkerscript/invalid-T-option.test =================================================================== --- /dev/null +++ test/elf/linkerscript/invalid-T-option.test @@ -0,0 +1,10 @@ +# 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 Index: test/elf/linkerscript/valid-T-option.objtxt =================================================================== --- /dev/null +++ test/elf/linkerscript/valid-T-option.objtxt @@ -0,0 +1,20 @@ +# Check that the -T/--script options are accepted. + +# 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 + +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