2015-09-30 05:49:40 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld %t -o %t2
|
2015-09-09 06:34:57 +08:00
|
|
|
# RUN: llvm-readobj -file-headers -sections -program-headers -symbols %t2 \
|
|
|
|
# RUN: | FileCheck %s
|
2017-01-10 07:07:05 +08:00
|
|
|
# RUN: ld.lld %t -o /dev/null
|
2015-09-30 05:49:40 +08:00
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
# exits with return code 42 on linux
|
2016-04-27 10:58:27 +08:00
|
|
|
.globl _start
|
2015-07-25 05:03:07 +08:00
|
|
|
_start:
|
|
|
|
mov $60, %rax
|
|
|
|
mov $42, %rdi
|
|
|
|
syscall
|
|
|
|
|
|
|
|
# CHECK: ElfHeader {
|
|
|
|
# CHECK-NEXT: Ident {
|
|
|
|
# CHECK-NEXT: Magic: (7F 45 4C 46)
|
|
|
|
# CHECK-NEXT: Class: 64-bit (0x2)
|
|
|
|
# CHECK-NEXT: DataEncoding: LittleEndian (0x1)
|
|
|
|
# CHECK-NEXT: FileVersion: 1
|
2015-08-05 19:55:52 +08:00
|
|
|
# CHECK-NEXT: OS/ABI: SystemV (0x0)
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: ABIVersion: 0
|
|
|
|
# CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: Type: Executable (0x2)
|
|
|
|
# CHECK-NEXT: Machine: EM_X86_64 (0x3E)
|
|
|
|
# CHECK-NEXT: Version: 1
|
2015-09-09 06:34:57 +08:00
|
|
|
# CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]]
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: ProgramHeaderOffset: 0x40
|
2016-11-11 04:20:37 +08:00
|
|
|
# CHECK-NEXT: SectionHeaderOffset: 0x1080
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: Flags [ (0x0)
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: HeaderSize: 64
|
|
|
|
# CHECK-NEXT: ProgramHeaderEntrySize: 56
|
2015-11-25 02:48:16 +08:00
|
|
|
# CHECK-NEXT: ProgramHeaderCount: 4
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: SectionHeaderEntrySize: 64
|
2016-11-11 04:20:37 +08:00
|
|
|
# CHECK-NEXT: SectionHeaderCount: 6
|
|
|
|
# CHECK-NEXT: StringTableSectionIndex: 4
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: }
|
2015-07-29 08:30:10 +08:00
|
|
|
# CHECK-NEXT: Sections [
|
|
|
|
# CHECK-NEXT: Section {
|
|
|
|
# CHECK-NEXT: Index: 0
|
|
|
|
# CHECK-NEXT: Name: (0)
|
|
|
|
# CHECK-NEXT: Type: SHT_NULL (0x0)
|
|
|
|
# CHECK-NEXT: Flags [ (0x0)
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Address: 0x0
|
|
|
|
# CHECK-NEXT: Offset: 0x0
|
|
|
|
# CHECK-NEXT: Size: 0
|
|
|
|
# CHECK-NEXT: Link: 0
|
|
|
|
# CHECK-NEXT: Info: 0
|
|
|
|
# CHECK-NEXT: AddressAlignment: 0
|
|
|
|
# CHECK-NEXT: EntrySize: 0
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: Section {
|
|
|
|
# CHECK-NEXT: Index: 1
|
2015-10-02 05:15:02 +08:00
|
|
|
# CHECK-NEXT: Name: .text
|
|
|
|
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
|
|
|
|
# CHECK-NEXT: Flags [ (0x6)
|
2015-07-30 06:14:50 +08:00
|
|
|
# CHECK-NEXT: SHF_ALLOC (0x2)
|
2015-10-02 05:15:02 +08:00
|
|
|
# CHECK-NEXT: SHF_EXECINSTR (0x4)
|
2015-07-29 08:30:10 +08:00
|
|
|
# CHECK-NEXT: ]
|
2016-11-24 01:44:02 +08:00
|
|
|
# CHECK-NEXT: Address: 0x201000
|
2015-07-29 08:30:10 +08:00
|
|
|
# CHECK-NEXT: Offset: 0x1000
|
2015-10-02 05:15:02 +08:00
|
|
|
# CHECK-NEXT: Size: 16
|
2015-07-29 08:30:10 +08:00
|
|
|
# CHECK-NEXT: Link: 0
|
|
|
|
# CHECK-NEXT: Info: 0
|
2015-08-14 04:13:39 +08:00
|
|
|
# CHECK-NEXT: AddressAlignment: 4
|
2015-07-29 08:30:10 +08:00
|
|
|
# CHECK-NEXT: EntrySize: 0
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: Section {
|
|
|
|
# CHECK-NEXT: Index: 2
|
2016-11-11 04:20:37 +08:00
|
|
|
# CHECK-NEXT: Name: .comment
|
|
|
|
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
|
|
|
|
# CHECK-NEXT: Flags [ (0x30)
|
|
|
|
# CHECK-NEXT: SHF_MERGE (0x10)
|
|
|
|
# CHECK-NEXT: SHF_STRINGS (0x20)
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Address: 0x0
|
|
|
|
# CHECK-NEXT: Offset: 0x1010
|
|
|
|
# CHECK-NEXT: Size: 8
|
|
|
|
# CHECK-NEXT: Link: 0
|
|
|
|
# CHECK-NEXT: Info: 0
|
|
|
|
# CHECK-NEXT: AddressAlignment: 1
|
|
|
|
# CHECK-NEXT: EntrySize: 1
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: Section {
|
|
|
|
# CHECK-NEXT: Index: 3
|
2015-08-14 10:42:20 +08:00
|
|
|
# CHECK-NEXT: Name: .symtab
|
|
|
|
# CHECK-NEXT: Type: SHT_SYMTAB (0x2)
|
|
|
|
# CHECK-NEXT: Flags [ (0x0)
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Address: 0x0
|
2016-11-11 04:20:37 +08:00
|
|
|
# CHECK-NEXT: Offset: 0x1018
|
2015-08-14 21:07:05 +08:00
|
|
|
# CHECK-NEXT: Size: 48
|
2016-11-11 04:20:37 +08:00
|
|
|
# CHECK-NEXT: Link: 5
|
2015-08-14 10:42:20 +08:00
|
|
|
# CHECK-NEXT: Info: 1
|
|
|
|
# CHECK-NEXT: AddressAlignment: 8
|
|
|
|
# CHECK-NEXT: EntrySize: 24
|
2015-10-21 01:21:35 +08:00
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: Section {
|
2016-11-11 04:20:37 +08:00
|
|
|
# CHECK-NEXT: Index: 4
|
2015-10-21 01:21:35 +08:00
|
|
|
# CHECK-NEXT: Name: .shstrtab
|
2015-08-12 08:00:24 +08:00
|
|
|
# CHECK-NEXT: Type: SHT_STRTAB (0x3)
|
|
|
|
# CHECK-NEXT: Flags [ (0x0)
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Address: 0x0
|
2016-11-11 04:20:37 +08:00
|
|
|
# CHECK-NEXT: Offset: 0x1048
|
|
|
|
# CHECK-NEXT: Size: 42
|
2015-10-21 01:21:35 +08:00
|
|
|
# CHECK-NEXT: Link: 0
|
|
|
|
# CHECK-NEXT: Info: 0
|
|
|
|
# CHECK-NEXT: AddressAlignment: 1
|
|
|
|
# CHECK-NEXT: EntrySize: 0
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: Section {
|
2016-11-11 04:20:37 +08:00
|
|
|
# CHECK-NEXT: Index: 5
|
2016-11-02 05:26:28 +08:00
|
|
|
# CHECK-NEXT: Name: .strtab
|
2015-10-21 01:21:35 +08:00
|
|
|
# CHECK-NEXT: Type: SHT_STRTAB (0x3)
|
|
|
|
# CHECK-NEXT: Flags [ (0x0)
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Address: 0x0
|
2016-11-11 04:20:37 +08:00
|
|
|
# CHECK-NEXT: Offset: 0x1072
|
2015-10-21 01:21:35 +08:00
|
|
|
# CHECK-NEXT: Size: 8
|
2015-08-12 08:00:24 +08:00
|
|
|
# CHECK-NEXT: Link: 0
|
|
|
|
# CHECK-NEXT: Info: 0
|
|
|
|
# CHECK-NEXT: AddressAlignment: 1
|
|
|
|
# CHECK-NEXT: EntrySize: 0
|
|
|
|
# CHECK-NEXT: }
|
2015-07-29 08:30:10 +08:00
|
|
|
# CHECK-NEXT: ]
|
2015-09-09 06:34:57 +08:00
|
|
|
# CHECK-NEXT: Symbols [
|
|
|
|
# CHECK-NEXT: Symbol {
|
|
|
|
# CHECK-NEXT: Name: (0)
|
|
|
|
# CHECK-NEXT: Value: 0x0
|
|
|
|
# CHECK-NEXT: Size: 0
|
|
|
|
# CHECK-NEXT: Binding: Local (0x0)
|
|
|
|
# CHECK-NEXT: Type: None (0x0)
|
|
|
|
# CHECK-NEXT: Other: 0
|
|
|
|
# CHECK-NEXT: Section: Undefined (0x0)
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: Symbol {
|
2015-10-21 01:21:35 +08:00
|
|
|
# CHECK-NEXT: Name: _start
|
2015-09-09 06:34:57 +08:00
|
|
|
# CHECK-NEXT: Value: [[ENTRY]]
|
|
|
|
# CHECK-NEXT: Size: 0
|
|
|
|
# CHECK-NEXT: Binding: Global (0x1)
|
|
|
|
# CHECK-NEXT: Type: None (0x0)
|
|
|
|
# CHECK-NEXT: Other: 0
|
2015-09-24 02:25:05 +08:00
|
|
|
# CHECK-NEXT: Section: .text
|
2015-09-09 06:34:57 +08:00
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: ]
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: ProgramHeaders [
|
|
|
|
# CHECK-NEXT: ProgramHeader {
|
2015-10-09 23:31:49 +08:00
|
|
|
# CHECK-NEXT: Type: PT_PHDR (0x6)
|
|
|
|
# CHECK-NEXT: Offset: 0x40
|
2016-11-24 01:44:02 +08:00
|
|
|
# CHECK-NEXT: VirtualAddress: 0x200040
|
|
|
|
# CHECK-NEXT: PhysicalAddress: 0x200040
|
2015-11-25 02:48:16 +08:00
|
|
|
# CHECK-NEXT: FileSize: 224
|
|
|
|
# CHECK-NEXT: MemSize: 224
|
2015-10-09 23:31:49 +08:00
|
|
|
# CHECK-NEXT: Flags [ (0x4)
|
|
|
|
# CHECK-NEXT: PF_R (0x4)
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Alignment: 8
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: ProgramHeader {
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: Type: PT_LOAD (0x1)
|
2015-09-10 23:41:34 +08:00
|
|
|
# CHECK-NEXT: Offset: 0x0
|
2016-11-24 01:44:02 +08:00
|
|
|
# CHECK-NEXT: VirtualAddress: 0x200000
|
|
|
|
# CHECK-NEXT: PhysicalAddress: 0x200000
|
2015-11-25 02:48:16 +08:00
|
|
|
# CHECK-NEXT: FileSize: 288
|
|
|
|
# CHECK-NEXT: MemSize: 288
|
2015-09-10 23:41:34 +08:00
|
|
|
# CHECK-NEXT: Flags [
|
|
|
|
# CHECK-NEXT: PF_R
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Alignment: 4096
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: ProgramHeader {
|
|
|
|
# CHECK-NEXT: Type: PT_LOAD (0x1)
|
|
|
|
# CHECK-NEXT: Offset: 0x1000
|
2016-11-24 01:44:02 +08:00
|
|
|
# CHECK-NEXT: VirtualAddress: 0x201000
|
|
|
|
# CHECK-NEXT: PhysicalAddress: 0x201000
|
2015-09-10 04:48:09 +08:00
|
|
|
# CHECK-NEXT: FileSize: 16
|
|
|
|
# CHECK-NEXT: MemSize: 16
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: Flags [ (0x5)
|
|
|
|
# CHECK-NEXT: PF_R (0x4)
|
|
|
|
# CHECK-NEXT: PF_X (0x1)
|
|
|
|
# CHECK-NEXT: ]
|
2015-09-10 04:48:09 +08:00
|
|
|
# CHECK-NEXT: Alignment: 4096
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: }
|
2015-11-25 02:48:16 +08:00
|
|
|
# CHECK-NEXT: ProgramHeader {
|
|
|
|
# CHECK-NEXT: Type: PT_GNU_STACK
|
|
|
|
# CHECK-NEXT: Offset: 0x0
|
|
|
|
# CHECK-NEXT: VirtualAddress: 0x0
|
|
|
|
# CHECK-NEXT: PhysicalAddress: 0x0
|
|
|
|
# CHECK-NEXT: FileSize: 0
|
|
|
|
# CHECK-NEXT: MemSize: 0
|
|
|
|
# CHECK-NEXT: Flags [
|
|
|
|
# CHECK-NEXT: PF_R
|
|
|
|
# CHECK-NEXT: PF_W
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Alignment: 0
|
|
|
|
# CHECK-NEXT: }
|
2015-07-25 05:03:07 +08:00
|
|
|
# CHECK-NEXT: ]
|
|
|
|
|
2016-07-07 05:24:34 +08:00
|
|
|
# Test for the response file (POSIX quoting style)
|
2015-09-25 23:37:33 +08:00
|
|
|
# RUN: echo " -o %t2" > %t.responsefile
|
2016-07-07 05:24:34 +08:00
|
|
|
# RUN: ld.lld %t --rsp-quoting=posix @%t.responsefile
|
2015-09-25 23:37:33 +08:00
|
|
|
# RUN: llvm-readobj -file-headers -sections -program-headers -symbols %t2 \
|
|
|
|
# RUN: | FileCheck %s
|
|
|
|
|
2016-07-07 05:24:34 +08:00
|
|
|
# Test for the response file (Windows quoting style)
|
|
|
|
# RUN: echo " c:\blah\foo" > %t.responsefile
|
|
|
|
# RUN: not ld.lld --rsp-quoting=windows %t @%t.responsefile 2>&1 | FileCheck \
|
|
|
|
# RUN: %s --check-prefix=WINRSP
|
|
|
|
# WINRSP: cannot open c:\blah\foo
|
|
|
|
|
|
|
|
# Test for the response file (invalid quoting style)
|
|
|
|
# RUN: not ld.lld --rsp-quoting=patatino %t 2>&1 | FileCheck %s \
|
|
|
|
# RUN: --check-prefix=INVRSP
|
|
|
|
# INVRSP: invalid response file quoting: patatino
|
|
|
|
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: not ld.lld %t.foo -o %t2 2>&1 | \
|
2015-07-25 05:03:07 +08:00
|
|
|
# RUN: FileCheck --check-prefix=MISSING %s
|
2016-03-11 22:43:02 +08:00
|
|
|
# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: not ld.lld -o %t2 2>&1 | \
|
2015-07-25 05:03:07 +08:00
|
|
|
# RUN: FileCheck --check-prefix=NO_INPUT %s
|
2016-10-20 04:05:43 +08:00
|
|
|
# NO_INPUT: ld.lld{{.*}}: no input files
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: not ld.lld %t.no.such.file -o %t2 2>&1 | \
|
2015-08-06 23:18:59 +08:00
|
|
|
# RUN: FileCheck --check-prefix=CANNOT_OPEN %s
|
2016-03-11 22:43:02 +08:00
|
|
|
# CANNOT_OPEN: cannot open {{.*}}.no.such.file: {{[Nn]}}o such file or directory
|
2015-08-06 23:18:59 +08:00
|
|
|
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: not ld.lld %t -o 2>&1 | FileCheck --check-prefix=NO_O_VAL %s
|
2016-11-20 02:49:38 +08:00
|
|
|
# NO_O_VAL: -o: missing argument
|
2015-07-25 05:03:07 +08:00
|
|
|
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: not ld.lld --foo 2>&1 | FileCheck --check-prefix=UNKNOWN %s
|
2016-03-11 22:43:02 +08:00
|
|
|
# UNKNOWN: unknown argument: --foo
|
2015-07-25 05:03:07 +08:00
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: not ld.lld %t %t -o %t2 2>&1 | FileCheck --check-prefix=DUP %s
|
2016-11-21 21:49:57 +08:00
|
|
|
# DUP: {{.*}}:(.text+0x0): duplicate symbol '_start'
|
|
|
|
# DUP: {{.*}}:(.text+0x0): previous definition was here
|
2015-10-07 17:13:03 +08:00
|
|
|
|
2016-09-09 03:36:22 +08:00
|
|
|
# RUN: not ld.lld %t -o %t -m wrong_emul_fbsd 2>&1 | FileCheck --check-prefix=UNKNOWN_EMUL %s
|
|
|
|
# UNKNOWN_EMUL: unknown emulation: wrong_emul_fbsd
|
2016-04-16 06:38:10 +08:00
|
|
|
|
2016-10-11 07:12:14 +08:00
|
|
|
# RUN: not ld.lld %t --lto-partitions=0 2>&1 | FileCheck --check-prefix=NOTHREADS %s
|
|
|
|
# NOTHREADS: --lto-partitions: number of threads must be > 0
|
|
|
|
|
|
|
|
# RUN: not ld.lld %t --thinlto-jobs=0 2>&1 | FileCheck --check-prefix=NOTHREADSTHIN %s
|
|
|
|
# NOTHREADSTHIN: --thinlto-jobs: number of threads must be > 0
|