1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o 3 4## -z noseparate-code is the default: text segment is not tail padded. 5# RUN: ld.lld %t.o -o %t 6# RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,NOPAD 7# RUN: ld.lld %t.o -z noseparate-code -o %t 8# RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,NOPAD 9 10## -z separate-code pads the tail of text segment with traps. 11# RUN: ld.lld %t.o -z separate-code -o %t 12# RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,PAD 13# RUN: od -Ax -x -N16 -j0x1ff0 %t | FileCheck %s --check-prefix=FILL 14 15## -z separate-loadable-segments pads all segments, including the text segment. 16# RUN: ld.lld %t.o -z separate-loadable-segments -o %t 17# RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,PAD 18# RUN: od -Ax -x -N16 -j0x1ff0 %t | FileCheck %s --check-prefix=FILL 19 20# RUN: ld.lld %t.o -z separate-code -z noseparate-code -o %t 21# RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,NOPAD 22 23# CHECK: ProgramHeader { 24# CHECK: Type: PT_LOAD 25# PAD: Offset: 0x1000 26# NOPAD: Offset: 0x120 27# CHECK-NEXT: VirtualAddress: 28# CHECK-NEXT: PhysicalAddress: 29# PAD-NEXT: FileSize: 4096 30# NOPAD-NEXT: FileSize: 1 31# CHECK-NEXT: MemSize: 32# CHECK-NEXT: Flags [ 33# CHECK-NEXT: PF_R 34# CHECK-NEXT: PF_X 35# CHECK-NEXT: ] 36 37## Check that executable page is filled with traps at its end. 38# FILL: 001ff0 cccc cccc cccc cccc cccc cccc cccc cccc 39 40.globl _start 41_start: 42 nop 43