1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t 3 4# RUN: ld.lld %t -o %t1 5# RUN: llvm-readobj --program-headers %t1 | FileCheck --check-prefix=ROSEGMENT %s 6# RUN: ld.lld --no-rosegment --rosegment %t -o - | cmp - %t1 7# RUN: ld.lld --omagic --no-omagic %t -o - | cmp - %t1 8 9# ROSEGMENT: ProgramHeader { 10# ROSEGMENT: Type: PT_LOAD 11# ROSEGMENT-NEXT: Offset: 0x0 12# ROSEGMENT-NEXT: VirtualAddress: 13# ROSEGMENT-NEXT: PhysicalAddress: 14# ROSEGMENT-NEXT: FileSize: 15# ROSEGMENT-NEXT: MemSize: 16# ROSEGMENT-NEXT: Flags [ 17# ROSEGMENT-NEXT: PF_R 18# ROSEGMENT-NEXT: ] 19# ROSEGMENT-NEXT: Alignment: 4096 20# ROSEGMENT-NEXT: } 21# ROSEGMENT-NEXT: ProgramHeader { 22# ROSEGMENT-NEXT: Type: PT_LOAD 23# ROSEGMENT-NEXT: Offset: 0x15C 24# ROSEGMENT-NEXT: VirtualAddress: 25# ROSEGMENT-NEXT: PhysicalAddress: 26# ROSEGMENT-NEXT: FileSize: 27# ROSEGMENT-NEXT: MemSize: 28# ROSEGMENT-NEXT: Flags [ 29# ROSEGMENT-NEXT: PF_R 30# ROSEGMENT-NEXT: PF_X 31# ROSEGMENT-NEXT: ] 32# ROSEGMENT-NEXT: Alignment: 4096 33# ROSEGMENT-NEXT: } 34# ROSEGMENT-NEXT: ProgramHeader { 35# ROSEGMENT-NEXT: Type: PT_LOAD 36# ROSEGMENT-NEXT: Offset: 0x15E 37# ROSEGMENT-NEXT: VirtualAddress: 38# ROSEGMENT-NEXT: PhysicalAddress: 39# ROSEGMENT-NEXT: FileSize: 1 40# ROSEGMENT-NEXT: MemSize: 1 41# ROSEGMENT-NEXT: Flags [ 42# ROSEGMENT-NEXT: PF_R 43# ROSEGMENT-NEXT: PF_W 44# ROSEGMENT-NEXT: ] 45# ROSEGMENT-NEXT: Alignment: 4096 46# ROSEGMENT-NEXT: } 47 48# RUN: ld.lld --no-rosegment %t -o %t2 49# RUN: llvm-readobj --program-headers %t2 | FileCheck --check-prefix=NOROSEGMENT %s 50 51# NOROSEGMENT: ProgramHeader { 52# NOROSEGMENT: Type: PT_LOAD 53# NOROSEGMENT-NEXT: Offset: 0x0 54# NOROSEGMENT-NEXT: VirtualAddress: 55# NOROSEGMENT-NEXT: PhysicalAddress: 56# NOROSEGMENT-NEXT: FileSize: 57# NOROSEGMENT-NEXT: MemSize: 58# NOROSEGMENT-NEXT: Flags [ 59# NOROSEGMENT-NEXT: PF_R 60# NOROSEGMENT-NEXT: PF_X 61# NOROSEGMENT-NEXT: ] 62# NOROSEGMENT-NEXT: Alignment: 4096 63# NOROSEGMENT-NEXT: } 64# NOROSEGMENT-NEXT: ProgramHeader { 65# NOROSEGMENT-NEXT: Type: PT_LOAD 66# NOROSEGMENT-NEXT: Offset: 0x126 67# NOROSEGMENT-NEXT: VirtualAddress: 68# NOROSEGMENT-NEXT: PhysicalAddress: 69# NOROSEGMENT-NEXT: FileSize: 70# NOROSEGMENT-NEXT: MemSize: 71# NOROSEGMENT-NEXT: Flags [ 72# NOROSEGMENT-NEXT: PF_R 73# NOROSEGMENT-NEXT: PF_W 74# NOROSEGMENT-NEXT: ] 75# NOROSEGMENT-NEXT: Alignment: 4096 76# NOROSEGMENT-NEXT: } 77# NOROSEGMENT-NEXT: ProgramHeader { 78# NOROSEGMENT-NEXT: Type: PT_GNU_STACK 79 80# RUN: ld.lld -N %t -o %t3 81# RUN: llvm-readobj --program-headers %t3 | FileCheck --check-prefix=OMAGIC %s 82# RUN: ld.lld --omagic %t -o %t3 83# RUN: llvm-readobj --program-headers %t3 | FileCheck --check-prefix=OMAGIC %s 84 85# OMAGIC: ProgramHeader { 86# OMAGIC: Type: PT_LOAD 87# OMAGIC-NEXT: Offset: 0xB0 88# OMAGIC-NEXT: VirtualAddress: 89# OMAGIC-NEXT: PhysicalAddress: 90# OMAGIC-NEXT: FileSize: 91# OMAGIC-NEXT: MemSize: 92# OMAGIC-NEXT: Flags [ 93# OMAGIC-NEXT: PF_R 94# OMAGIC-NEXT: PF_W 95# OMAGIC-NEXT: PF_X 96# OMAGIC-NEXT: ] 97# OMAGIC-NEXT: Alignment: 4 98# OMAGIC-NEXT: } 99# OMAGIC-NEXT: ProgramHeader { 100# OMAGIC-NEXT: Type: PT_GNU_STACK 101 102# RUN: ld.lld -n %t -o %t4 103# RUN: llvm-readobj --program-headers %t4 | FileCheck --check-prefix=NMAGIC %s 104# RUN: ld.lld --nmagic %t -o %t4 105# RUN: llvm-readobj --program-headers %t4 | FileCheck --check-prefix=NMAGIC %s 106 107# NMAGIC: ProgramHeader { 108# NMAGIC-NEXT: Type: PT_LOAD 109# NMAGIC-NEXT: Offset: 0x120 110# NMAGIC-NEXT: VirtualAddress: 111# NMAGIC-NEXT: PhysicalAddress: 112# NMAGIC-NEXT: FileSize: 1 113# NMAGIC-NEXT: MemSize: 1 114# NMAGIC-NEXT: Flags [ 115# NMAGIC-NEXT: PF_R 116# NMAGIC-NEXT: ] 117# NMAGIC-NEXT: Alignment: 1 118# NMAGIC-NEXT: } 119# NMAGIC-NEXT: ProgramHeader { 120# NMAGIC-NEXT: Type: PT_LOAD 121# NMAGIC-NEXT: Offset: 0x124 122# NMAGIC-NEXT: VirtualAddress: 123# NMAGIC-NEXT: PhysicalAddress: 124# NMAGIC-NEXT: FileSize: 2 125# NMAGIC-NEXT: MemSize: 2 126# NMAGIC-NEXT: Flags [ 127# NMAGIC-NEXT: PF_R 128# NMAGIC-NEXT: PF_X 129# NMAGIC-NEXT: ] 130# NMAGIC-NEXT: Alignment: 4 131# NMAGIC-NEXT: } 132# NMAGIC-NEXT: ProgramHeader { 133# NMAGIC-NEXT: Type: PT_LOAD (0x1) 134# NMAGIC-NEXT: Offset: 0x126 135# NMAGIC-NEXT: VirtualAddress: 136# NMAGIC-NEXT: PhysicalAddress: 137# NMAGIC-NEXT: FileSize: 1 138# NMAGIC-NEXT: MemSize: 1 139# NMAGIC-NEXT: Flags [ 140# NMAGIC-NEXT: PF_R 141# NMAGIC-NEXT: PF_W 142# NMAGIC-NEXT: ] 143# NMAGIC-NEXT: Alignment: 1 144# NMAGIC-NEXT: } 145 146.global _start 147_start: 148 nop 149 150.section .ro,"a" 151nop 152 153.section .rw,"aw" 154nop 155 156.section .rx,"ax" 157nop 158