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
|
2015-09-30 05:49:40 +08:00
|
|
|
|
2015-07-25 05:03:07 +08:00
|
|
|
# exits with return code 42 on linux
|
|
|
|
.globl _start;
|
|
|
|
_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
|
2015-11-04 04:02:28 +08:00
|
|
|
# CHECK-NEXT: SectionHeaderOffset: 0x1070
|
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
|
2015-11-04 05:35:14 +08:00
|
|
|
# CHECK-NEXT: SectionHeaderCount: 5
|
|
|
|
# CHECK-NEXT: StringTableSectionIndex: 3
|
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: ]
|
2015-09-10 23:41:34 +08:00
|
|
|
# CHECK-NEXT: Address: 0x11000
|
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
|
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
|
|
|
|
# CHECK-NEXT: Offset: 0x1010
|
2015-08-14 21:07:05 +08:00
|
|
|
# CHECK-NEXT: Size: 48
|
2015-11-04 05:35:14 +08:00
|
|
|
# CHECK-NEXT: Link: 4
|
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 {
|
2015-11-04 05:35:14 +08:00
|
|
|
# CHECK-NEXT: Index: 3
|
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
|
2015-08-14 21:07:05 +08:00
|
|
|
# CHECK-NEXT: Offset: 0x1040
|
2015-11-04 05:35:14 +08:00
|
|
|
# CHECK-NEXT: Size: 33
|
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 {
|
2015-11-04 05:35:14 +08:00
|
|
|
# CHECK-NEXT: Index: 4
|
2016-01-07 10:35:32 +08:00
|
|
|
# CHECK-NEXT: Name: .strtab (25)
|
2015-10-21 01:21:35 +08:00
|
|
|
# CHECK-NEXT: Type: SHT_STRTAB (0x3)
|
|
|
|
# CHECK-NEXT: Flags [ (0x0)
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Address: 0x0
|
2015-11-04 05:35:14 +08:00
|
|
|
# CHECK-NEXT: Offset: 0x1061
|
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
|
|
|
|
# CHECK-NEXT: VirtualAddress: 0x10040
|
|
|
|
# CHECK-NEXT: PhysicalAddress: 0x10040
|
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
|
2015-09-10 06:53:55 +08:00
|
|
|
# CHECK-NEXT: VirtualAddress: 0x10000
|
|
|
|
# CHECK-NEXT: PhysicalAddress: 0x10000
|
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
|
|
|
|
# CHECK-NEXT: VirtualAddress: 0x11000
|
|
|
|
# CHECK-NEXT: PhysicalAddress: 0x11000
|
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: ]
|
|
|
|
|
2015-10-01 01:06:09 +08:00
|
|
|
# Test for the response file
|
2015-09-25 23:37:33 +08:00
|
|
|
# RUN: echo " -o %t2" > %t.responsefile
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: ld.lld %t @%t.responsefile
|
2015-09-25 23:37:33 +08:00
|
|
|
# RUN: llvm-readobj -file-headers -sections -program-headers -symbols %t2 \
|
|
|
|
# RUN: | FileCheck %s
|
|
|
|
|
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-03-11 22:43:02 +08:00
|
|
|
# NO_INPUT: 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-03-11 22:43:02 +08:00
|
|
|
# NO_O_VAL: missing arg value for "-o", expected 1 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-03-11 22:43:02 +08:00
|
|
|
# DUP: duplicate symbol: _start in {{.*}} and {{.*}}
|
2015-10-07 17:13:03 +08:00
|
|
|
|
2015-11-18 14:11:01 +08:00
|
|
|
# RUN: not ld.lld %t -o %t -m wrong_emul 2>&1 | FileCheck --check-prefix=UNKNOWN_EMUL %s
|
2016-03-12 16:31:34 +08:00
|
|
|
# UNKNOWN_EMUL: unknown emulation: wrong_emul
|
2016-04-16 06:38:10 +08:00
|
|
|
|
|
|
|
# RUN: not ld.lld %t --lto-jobs=0 2>&1 | FileCheck --check-prefix=NOTHREADS %s
|
|
|
|
# NOTHREADS: number of threads must be > 0
|