1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o 3 4## Default is no PIE. 5# RUN: ld.lld %t1.o -o %t 6# RUN: llvm-readobj --file-headers --sections -l --symbols -r %t \ 7# RUN: | FileCheck %s --check-prefix=NOPIE 8 9## Check -pie. 10# RUN: ld.lld -pie %t1.o -o %t 11# RUN: llvm-readobj --file-headers --sections -l -d --symbols -r %t | FileCheck %s 12 13## Test --pic-executable alias 14# RUN: ld.lld --pic-executable %t1.o -o %t 15# RUN: llvm-readobj --file-headers --sections -l -d --symbols -r %t | FileCheck %s 16 17# CHECK: ElfHeader { 18# CHECK-NEXT: Ident { 19# CHECK-NEXT: Magic: (7F 45 4C 46) 20# CHECK-NEXT: Class: 64-bit 21# CHECK-NEXT: DataEncoding: LittleEndian 22# CHECK-NEXT: FileVersion: 1 23# CHECK-NEXT: OS/ABI: SystemV 24# CHECK-NEXT: ABIVersion: 0 25# CHECK-NEXT: Unused: (00 00 00 00 00 00 00) 26# CHECK-NEXT: } 27# CHECK-NEXT: Type: SharedObject 28 29# CHECK: ProgramHeaders [ 30# CHECK-NEXT: ProgramHeader { 31# CHECK-NEXT: Type: PT_PHDR 32# CHECK-NEXT: Offset: 0x40 33# CHECK-NEXT: VirtualAddress: 0x40 34# CHECK-NEXT: PhysicalAddress: 0x40 35# CHECK-NEXT: FileSize: 36# CHECK-NEXT: MemSize: 37# CHECK-NEXT: Flags [ 38# CHECK-NEXT: PF_R 39# CHECK-NEXT: ] 40# CHECK-NEXT: Alignment: 8 41# CHECK-NEXT: } 42# CHECK-NEXT: ProgramHeader { 43# CHECK-NEXT: Type: PT_LOAD 44# CHECK-NEXT: Offset: 0x0 45# CHECK-NEXT: VirtualAddress: 0x0 46# CHECK-NEXT: PhysicalAddress: 0x0 47 48# CHECK: Type: PT_DYNAMIC 49 50# CHECK: DynamicSection [ 51# CHECK: 0x000000006FFFFFFB FLAGS_1 PIE 52 53## Check -nopie 54# RUN: ld.lld -no-pie %t1.o -o %t2 55# RUN: llvm-readobj --file-headers -r %t2 | FileCheck %s --check-prefix=NOPIE 56# RUN: ld.lld -no-pic-executable %t1.o -o %t2 57# RUN: llvm-readobj --file-headers -r %t2 | FileCheck %s --check-prefix=NOPIE 58# NOPIE-NOT: Type: SharedObject 59 60.globl _start 61_start: 62