summaryrefslogtreecommitdiff
path: root/test/elf/linkerscript
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-03-24 21:31:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-03-24 21:31:36 +0000
commitfb911942f1434f3d1750f83f25f5e42c80e60638 (patch)
tree1678c4a4f0182e4029a86d135aa4a1b7d09e3c41 /test/elf/linkerscript
Notes
Diffstat (limited to 'test/elf/linkerscript')
-rw-r--r--test/elf/linkerscript/Inputs/externs.ls3
-rw-r--r--test/elf/linkerscript/Inputs/invalid.ls1
-rw-r--r--test/elf/linkerscript/Inputs/prog1.o.yaml88
-rw-r--r--test/elf/linkerscript/Inputs/prog2.o.yaml89
-rw-r--r--test/elf/linkerscript/Inputs/prog3.o.yaml52
-rw-r--r--test/elf/linkerscript/Inputs/simple.o.yaml52
-rw-r--r--test/elf/linkerscript/Inputs/valid.ls6
-rw-r--r--test/elf/linkerscript/externs.objtxt21
-rw-r--r--test/elf/linkerscript/invalid-script-cli-1.test10
-rw-r--r--test/elf/linkerscript/invalid-script-cli-2.test6
-rw-r--r--test/elf/linkerscript/invalid.test5
-rw-r--r--test/elf/linkerscript/sections-order.test97
-rw-r--r--test/elf/linkerscript/sections-with-wildcards.test88
-rw-r--r--test/elf/linkerscript/symbol-definition.test54
-rw-r--r--test/elf/linkerscript/valid-script-cli.objtxt23
15 files changed, 595 insertions, 0 deletions
diff --git a/test/elf/linkerscript/Inputs/externs.ls b/test/elf/linkerscript/Inputs/externs.ls
new file mode 100644
index 0000000000000..20fdc0c3f9803
--- /dev/null
+++ b/test/elf/linkerscript/Inputs/externs.ls
@@ -0,0 +1,3 @@
+/* A simple valid linker script used for testing the EXTERN command.
+ */
+EXTERN(_foo bar __baz)
diff --git a/test/elf/linkerscript/Inputs/invalid.ls b/test/elf/linkerscript/Inputs/invalid.ls
new file mode 100644
index 0000000000000..894d4bef2732c
--- /dev/null
+++ b/test/elf/linkerscript/Inputs/invalid.ls
@@ -0,0 +1 @@
+GROUP(
diff --git a/test/elf/linkerscript/Inputs/prog1.o.yaml b/test/elf/linkerscript/Inputs/prog1.o.yaml
new file mode 100644
index 0000000000000..ded590e395d43
--- /dev/null
+++ b/test/elf/linkerscript/Inputs/prog1.o.yaml
@@ -0,0 +1,88 @@
+---
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_GNU
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000010
+ Content: 554889E5B000E800000000BF01000000BA0E0000004889C6E80000000031C05DC3
+ - Name: .rela.text
+ Type: SHT_RELA
+ Link: .symtab
+ AddressAlign: 0x0000000000000008
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000007
+ Symbol: prog2
+ Type: R_X86_64_PC32
+ Addend: -4
+ - Offset: 0x0000000000000019
+ Symbol: write
+ Type: R_X86_64_PC32
+ Addend: -4
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+ - Name: .comment
+ Type: SHT_PROGBITS
+ Flags: [ SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x0000000000000001
+ Content: 00636C616E672076657273696F6E20332E372E302028687474703A2F2F6C6C766D2E6F72672F6769742F636C616E672E6769742036336134646334616430343938646139623934386330383263623735336430353735323938346638292028687474703A2F2F6C6C766D2E6F72672F6769742F6C6C766D2E67697420623838363135326664656538376564653738613565643965616638663664313839343033616266312900
+ - Name: .note.GNU-stack
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: ''
+ - Name: .eh_frame
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 0x0000000000000008
+ Content: 1400000000000000037A5200017810011B0C0708900100001C0000001C000000000000002100000000410E108602430D0600000000000000
+ - Name: .rela.eh_frame
+ Type: SHT_RELA
+ Link: .symtab
+ AddressAlign: 0x0000000000000008
+ Info: .eh_frame
+ Relocations:
+ - Offset: 0x0000000000000020
+ Symbol: .text
+ Type: R_X86_64_PC32
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ - Name: .comment
+ Type: STT_SECTION
+ Section: .comment
+ - Name: .note.GNU-stack
+ Type: STT_SECTION
+ Section: .note.GNU-stack
+ - Name: .eh_frame
+ Type: STT_SECTION
+ Section: .eh_frame
+ Global:
+ - Name: main
+ Type: STT_FUNC
+ Section: .text
+ Size: 0x0000000000000021
+ - Name: prog2
+ - Name: write
+...
diff --git a/test/elf/linkerscript/Inputs/prog2.o.yaml b/test/elf/linkerscript/Inputs/prog2.o.yaml
new file mode 100644
index 0000000000000..f88b0ddc96b22
--- /dev/null
+++ b/test/elf/linkerscript/Inputs/prog2.o.yaml
@@ -0,0 +1,89 @@
+---
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_GNU
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000010
+ Content: 554889E548B800000000000000005DC3
+ - Name: .rela.text
+ Type: SHT_RELA
+ Link: .symtab
+ AddressAlign: 0x0000000000000008
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000006
+ Symbol: .rodata.str1.1
+ Type: R_X86_64_64
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+ - Name: .rodata.str1.1
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x0000000000000001
+ Content: 48656C6C6F2C20776F726C64210A00
+ - Name: .comment
+ Type: SHT_PROGBITS
+ Flags: [ SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x0000000000000001
+ Content: 00636C616E672076657273696F6E20332E372E302028687474703A2F2F6C6C766D2E6F72672F6769742F636C616E672E6769742036336134646334616430343938646139623934386330383263623735336430353735323938346638292028687474703A2F2F6C6C766D2E6F72672F6769742F6C6C766D2E67697420623838363135326664656538376564653738613565643965616638663664313839343033616266312900
+ - Name: .note.GNU-stack
+ Type: SHT_PROGBITS
+ AddressAlign: 0x0000000000000001
+ Content: ''
+ - Name: .eh_frame
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 0x0000000000000008
+ Content: 1400000000000000037A5200017810011B0C0708900100001C0000001C000000000000001000000000410E108602430D0600000000000000
+ - Name: .rela.eh_frame
+ Type: SHT_RELA
+ Link: .symtab
+ AddressAlign: 0x0000000000000008
+ Info: .eh_frame
+ Relocations:
+ - Offset: 0x0000000000000020
+ Symbol: .text
+ Type: R_X86_64_PC32
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ - Name: .rodata.str1.1
+ Type: STT_SECTION
+ Section: .rodata.str1.1
+ - Name: .comment
+ Type: STT_SECTION
+ Section: .comment
+ - Name: .note.GNU-stack
+ Type: STT_SECTION
+ Section: .note.GNU-stack
+ - Name: .eh_frame
+ Type: STT_SECTION
+ Section: .eh_frame
+ Global:
+ - Name: prog2
+ Type: STT_FUNC
+ Section: .text
+ Size: 0x0000000000000010
+...
diff --git a/test/elf/linkerscript/Inputs/prog3.o.yaml b/test/elf/linkerscript/Inputs/prog3.o.yaml
new file mode 100644
index 0000000000000..76aa22267f0b6
--- /dev/null
+++ b/test/elf/linkerscript/Inputs/prog3.o.yaml
@@ -0,0 +1,52 @@
+---
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_GNU
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000004
+ Content: B8010000000F05C3E800000000B83C0000000F05C3
+ - Name: .rela.text
+ Type: SHT_RELA
+ Link: .symtab
+ AddressAlign: 0x0000000000000008
+ Info: .text
+ Relocations:
+ - Offset: 0x0000000000000009
+ Symbol: main
+ Type: R_X86_64_PC32
+ Addend: -4
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ Global:
+ - Name: _start
+ Section: .text
+ Value: 0x0000000000000008
+ - Name: write
+ Section: .text
+ - Name: main
+...
diff --git a/test/elf/linkerscript/Inputs/simple.o.yaml b/test/elf/linkerscript/Inputs/simple.o.yaml
new file mode 100644
index 0000000000000..91d4e1b577869
--- /dev/null
+++ b/test/elf/linkerscript/Inputs/simple.o.yaml
@@ -0,0 +1,52 @@
+---
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_GNU
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000004
+ Content: B80100000048C7C70100000048C7C60000000048C7C20E0000000F05C3E8DEFFFFFFB83C0000000F05C3
+ - Name: .rela.text
+ Type: SHT_RELA
+ Link: .symtab
+ AddressAlign: 0x0000000000000008
+ Info: .text
+ Relocations:
+ - Offset: 0x000000000000000F
+ Symbol: .data
+ Type: R_X86_64_32S
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: 48656C6C6F2C20576F726C64210A00
+ - Name: .bss
+ Type: SHT_NOBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 0x0000000000000004
+ Content: ''
+Symbols:
+ Local:
+ - Name: main
+ Section: .text
+ - Name: msg
+ Section: .data
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ - Name: .data
+ Type: STT_SECTION
+ Section: .data
+ - Name: .bss
+ Type: STT_SECTION
+ Section: .bss
+ Global:
+ - Name: _start
+ Section: .text
+ Value: 0x000000000000001D
+...
diff --git a/test/elf/linkerscript/Inputs/valid.ls b/test/elf/linkerscript/Inputs/valid.ls
new file mode 100644
index 0000000000000..43593602d3fbf
--- /dev/null
+++ b/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)
diff --git a/test/elf/linkerscript/externs.objtxt b/test/elf/linkerscript/externs.objtxt
new file mode 100644
index 0000000000000..154891eaf7107
--- /dev/null
+++ b/test/elf/linkerscript/externs.objtxt
@@ -0,0 +1,21 @@
+# Check symbols defined with the EXTERN command are added as undefined
+# symbols.
+
+# RUN: lld -flavor gnu -target x86_64 -T %p/Inputs/externs.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: undefined-atoms:
+# CHECK: - name: _foo
+# CHECK: can-be-null: at-buildtime
+# CHECK: - name: bar
+# CHECK: can-be-null: at-buildtime
+# CHECK: - name: __baz
+# CHECK: can-be-null: at-buildtime
diff --git a/test/elf/linkerscript/invalid-script-cli-1.test b/test/elf/linkerscript/invalid-script-cli-1.test
new file mode 100644
index 0000000000000..904ba17557c0c
--- /dev/null
+++ b/test/elf/linkerscript/invalid-script-cli-1.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
diff --git a/test/elf/linkerscript/invalid-script-cli-2.test b/test/elf/linkerscript/invalid-script-cli-2.test
new file mode 100644
index 0000000000000..6e0e42adc71d6
--- /dev/null
+++ b/test/elf/linkerscript/invalid-script-cli-2.test
@@ -0,0 +1,6 @@
+# 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
diff --git a/test/elf/linkerscript/invalid.test b/test/elf/linkerscript/invalid.test
new file mode 100644
index 0000000000000..42833a6664ffb
--- /dev/null
+++ b/test/elf/linkerscript/invalid.test
@@ -0,0 +1,5 @@
+# Check for errors from invalid linker scripts
+RUN: not lld -flavor gnu -target x86_64 %p/Inputs/invalid.ls 2> %t.err
+RUN: FileCheck %s < %t.err
+
+CHECK: {{.*}}invalid.ls: Error parsing linker script
diff --git a/test/elf/linkerscript/sections-order.test b/test/elf/linkerscript/sections-order.test
new file mode 100644
index 0000000000000..85a172cb07adc
--- /dev/null
+++ b/test/elf/linkerscript/sections-order.test
@@ -0,0 +1,97 @@
+/*
+Tests a simple linker script that changes the order of output sections and
+also changes the address of output sections by using simple expressions.
+
+This test uses three X86-64 input objects, prog1.o, prog2.o and prog3.o,
+which were created with the following C or assembly code:
+
+*** prog1.o:
+
+(command line clang -c prog1.c -o prog1.o)
+
+const char *prog2();
+void write(int, const char *, int);
+
+int main() {
+ write(1, prog2(), 14);
+}
+
+*** prog2.o:
+
+(command line clang -c prog2.c -o prog2.o)
+
+const char *prog2() {
+ return "Hello, world!\n";
+}
+
+*** prog3.o:
+
+(command line clang -c prog3.S -o prog3.o)
+
+ .globl write
+write:
+ mov $1, %eax
+ syscall
+ ret
+
+ .globl _start
+_start:
+ call main
+ mov $60, %eax
+ syscall
+ ret
+
+We use the following linker script for this test:
+*/
+
+ENTRY(_start)
+
+SECTIONS
+{
+ . = 0x500000;
+ .text : { prog1.o(.text) }
+ .mystring : { prog2.o(.rodata.str1.1) }
+ . = . + 0x6000;
+ .text.2 : {prog3.o(.text) prog2.o(.text) }
+}
+
+/*
+RUN: mkdir -p %T
+RUN: yaml2obj -format=elf %p/Inputs/prog1.o.yaml -o=%T/prog1.o
+RUN: yaml2obj -format=elf %p/Inputs/prog2.o.yaml -o=%T/prog2.o
+RUN: yaml2obj -format=elf %p/Inputs/prog3.o.yaml -o=%T/prog3.o
+RUN: cd %T
+
+RUN: lld -flavor gnu -target x86_64 -T %s prog1.o prog2.o prog3.o \
+RUN: -static -o %t1
+RUN: llvm-readobj -s %t1 | FileCheck -check-prefix CHECKSECTIONS %s
+
+CHECKSECTIONS: Index: 1
+CHECKSECTIONS: Name: .text
+CHECKSECTIONS: Address: 0x500000
+CHECKSECTIONS: Size: 33
+
+CHECKSECTIONS: Index: 2
+CHECKSECTIONS: Name: .mystring
+CHECKSECTIONS: Address: 0x500021
+CHECKSECTIONS: Size: 15
+
+CHECKSECTIONS: Index: 3
+CHECKSECTIONS: Name: .text.2
+CHECKSECTIONS: Address: 0x506030
+CHECKSECTIONS: Size: 48
+
+RUN: llvm-readobj -symbols %t1 | FileCheck -check-prefix CHECKSYMS %s
+
+CHECKSYMS: Name: main
+CHECKSYMS-NEXT: Value: 0x500000
+
+CHECKSYMS: Name: write
+CHECKSYMS-NEXT: Value: 0x506030
+
+CHECKSYMS: Name: _start
+CHECKSYMS-NEXT: Value: 0x506038
+
+CHECKSYMS: Name: prog2
+CHECKSYMS-NEXT: Value: 0x506050
+*/
diff --git a/test/elf/linkerscript/sections-with-wildcards.test b/test/elf/linkerscript/sections-with-wildcards.test
new file mode 100644
index 0000000000000..6af80d0883dea
--- /dev/null
+++ b/test/elf/linkerscript/sections-with-wildcards.test
@@ -0,0 +1,88 @@
+/*
+Tests a linker script that uses the SECTIONS command with rules containing
+wildcards and simple SORT directives. It also tests that the linker script
+evaluates the expressions in the same order as the one written in the script
+file.
+
+This test uses three X86-64 input objects, prog1.o, prog2.o and prog3.o,
+which were created with the following C or assembly code:
+
+*** prog1.o:
+
+(command line clang -c prog1.c -o prog1.o)
+
+const char *prog2();
+void write(int, const char *, int);
+
+int main() {
+ write(1, prog2(), 14);
+}
+
+*** prog2.o:
+
+(command line clang -c prog2.c -o prog2.o)
+
+const char *prog2() {
+ return "Hello, world!\n";
+}
+
+*** prog3.o:
+
+(command line clang -c prog3.S -o prog3.o)
+
+ .globl write
+write:
+ mov $1, %eax
+ syscall
+ ret
+
+ .globl _start
+_start:
+ call main
+ mov $60, %eax
+ syscall
+ ret
+
+We use the following linker script for this test:
+*/
+
+ENTRY(_start)
+
+SECTIONS
+{
+ my_start_addr = 0x500000;
+ my_symbol = my_start_addr;
+ . = my_symbol;
+ .foo : { SORT(*)(.text .rodata*) }
+}
+
+/*
+RUN: mkdir -p %T
+RUN: yaml2obj -format=elf %p/Inputs/prog1.o.yaml -o=%T/p1.o
+RUN: yaml2obj -format=elf %p/Inputs/prog2.o.yaml -o=%T/p2.o
+RUN: yaml2obj -format=elf %p/Inputs/prog3.o.yaml -o=%T/p3.o
+RUN: cd %T
+
+RUN: lld -flavor gnu -target x86_64 -T %s p1.o p2.o p3.o \
+RUN: -static -o %t1
+RUN: llvm-readobj -s %t1 | FileCheck -check-prefix CHECKSECTIONS %s
+
+CHECKSECTIONS: Index: 1
+CHECKSECTIONS: Name: .foo
+CHECKSECTIONS: Address: 0x500000
+CHECKSECTIONS: Size: 101
+
+RUN: llvm-readobj -symbols %t1 | FileCheck -check-prefix CHECKSYMS %s
+
+CHECKSYMS: Name: main
+CHECKSYMS-NEXT: Value: 0x500000
+
+CHECKSYMS: Name: prog2
+CHECKSYMS-NEXT: Value: 0x500030
+
+CHECKSYMS: Name: write
+CHECKSYMS-NEXT: Value: 0x500050
+
+CHECKSYMS: Name: _start
+CHECKSYMS-NEXT: Value: 0x500058
+*/
diff --git a/test/elf/linkerscript/symbol-definition.test b/test/elf/linkerscript/symbol-definition.test
new file mode 100644
index 0000000000000..fc595bbe1f105
--- /dev/null
+++ b/test/elf/linkerscript/symbol-definition.test
@@ -0,0 +1,54 @@
+/*
+We test whether we can define symbols in a linker script and have them exported
+to the output file symbol table.
+
+This test uses a single X86-64 input object, simple.o, created with the
+following X86-64 assembly code:
+
+*** simple.S:
+
+(command line clang -c simple.S -o simple.o)
+
+ .text
+ main:
+ mov $1, %eax
+ movq $1, %rdi
+ movq $msg, %rsi
+ movq $14, %rdx
+ syscall
+ ret
+
+ .globl _start
+ _start:
+ call main
+ mov $60, %eax
+ syscall
+ ret
+
+ .data
+ msg: .asciz "Hello, World!\n"
+
+
+We use the following linker script for this test:
+*/
+
+ENTRY(_start)
+
+SECTIONS
+{
+ . = 0x500000;
+ .text : { *(.text) }
+ MYSTRING = .;
+ .data : { *(.data) }
+}
+
+/*
+RUN: mkdir -p %T
+RUN: yaml2obj -format=elf %p/Inputs/simple.o.yaml -o=%T/simple.o
+
+RUN: lld -flavor gnu -target x86_64 -T %s %T/simple.o -static -o %t1
+RUN: llvm-readobj -symbols %t1 | FileCheck -check-prefix CHECKSYMS %s
+
+CHECKSYMS: Name: MYSTRING
+CHECKSYMS-NEXT: Value: 0x501000
+*/
diff --git a/test/elf/linkerscript/valid-script-cli.objtxt b/test/elf/linkerscript/valid-script-cli.objtxt
new file mode 100644
index 0000000000000..b68d430fd98ed
--- /dev/null
+++ b/test/elf/linkerscript/valid-script-cli.objtxt
@@ -0,0 +1,23 @@
+# 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