2016-03-17 13:57:33 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
|
2016-10-17 22:42:11 +08:00
|
|
|
|
|
|
|
## Default is no PIE.
|
|
|
|
# RUN: ld.lld %t1.o -o %t
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --file-headers --sections -l --symbols -r %t \
|
2016-10-17 22:42:11 +08:00
|
|
|
# RUN: | FileCheck %s --check-prefix=NOPIE
|
|
|
|
|
|
|
|
## Check -pie.
|
2016-03-17 13:57:33 +08:00
|
|
|
# RUN: ld.lld -pie %t1.o -o %t
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --file-headers --sections -l --symbols -r %t | FileCheck %s
|
2016-03-17 13:57:33 +08:00
|
|
|
|
|
|
|
## Test --pic-executable alias
|
|
|
|
# RUN: ld.lld --pic-executable %t1.o -o %t
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --file-headers --sections -l --symbols -r %t | FileCheck %s
|
2016-03-17 13:57:33 +08:00
|
|
|
|
|
|
|
# CHECK: ElfHeader {
|
|
|
|
# CHECK-NEXT: Ident {
|
|
|
|
# CHECK-NEXT: Magic: (7F 45 4C 46)
|
|
|
|
# CHECK-NEXT: Class: 64-bit
|
|
|
|
# CHECK-NEXT: DataEncoding: LittleEndian
|
|
|
|
# CHECK-NEXT: FileVersion: 1
|
|
|
|
# CHECK-NEXT: OS/ABI: SystemV
|
|
|
|
# CHECK-NEXT: ABIVersion: 0
|
|
|
|
# CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: Type: SharedObject
|
|
|
|
|
|
|
|
# CHECK: ProgramHeaders [
|
|
|
|
# CHECK-NEXT: ProgramHeader {
|
|
|
|
# CHECK-NEXT: Type: PT_PHDR
|
|
|
|
# CHECK-NEXT: Offset: 0x40
|
|
|
|
# CHECK-NEXT: VirtualAddress: 0x40
|
|
|
|
# CHECK-NEXT: PhysicalAddress: 0x40
|
2016-12-06 06:27:21 +08:00
|
|
|
# CHECK-NEXT: FileSize:
|
|
|
|
# CHECK-NEXT: MemSize:
|
2016-03-17 13:57:33 +08:00
|
|
|
# CHECK-NEXT: Flags [
|
|
|
|
# CHECK-NEXT: PF_R
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: Alignment: 8
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: ProgramHeader {
|
|
|
|
# CHECK-NEXT: Type: PT_LOAD
|
|
|
|
# CHECK-NEXT: Offset: 0x0
|
|
|
|
# CHECK-NEXT: VirtualAddress: 0x0
|
|
|
|
# CHECK-NEXT: PhysicalAddress: 0x0
|
2016-12-06 06:27:21 +08:00
|
|
|
|
|
|
|
# CHECK: Type: PT_DYNAMIC
|
2016-03-17 13:57:33 +08:00
|
|
|
|
2018-02-22 04:08:14 +08:00
|
|
|
## Check -nopie
|
2018-02-02 08:31:05 +08:00
|
|
|
# RUN: ld.lld -no-pie %t1.o -o %t2
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --file-headers -r %t2 | FileCheck %s --check-prefix=NOPIE
|
2018-02-06 08:45:15 +08:00
|
|
|
# RUN: ld.lld -no-pic-executable %t1.o -o %t2
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --file-headers -r %t2 | FileCheck %s --check-prefix=NOPIE
|
2016-10-17 22:42:11 +08:00
|
|
|
# NOPIE-NOT: Type: SharedObject
|
|
|
|
|
2016-03-17 13:57:33 +08:00
|
|
|
.globl _start
|
|
|
|
_start:
|