2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
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 -z common-page-size=512 -o %t
8 # RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,NOPAD
10 ## -z separate-code pads the tail of text segment with traps.
11 ## Make common-page-size smaller than max-page-size.
12 ## Check that we use max-page-size instead of common-page-size for padding.
13 # RUN: ld.lld %t.o -z separate-code -z common-page-size=512 -o %t
14 # RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,PAD
15 # RUN: od -Ax -x -N16 -j0x1ff0 %t | FileCheck %s --check-prefix=FILL
17 ## -z separate-loadable-segments pads all segments, including the text segment.
18 # RUN: ld.lld %t.o -z separate-loadable-segments -z common-page-size=512 -o %t
19 # RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,PAD
20 # RUN: od -Ax -x -N16 -j0x1ff0 %t | FileCheck %s --check-prefix=FILL
22 # RUN: ld.lld %t.o -z separate-code -z noseparate-code -z common-page-size=512 -o %t
23 # RUN: llvm-readobj -l %t | FileCheck %s --check-prefixes=CHECK,NOPAD
25 # CHECK: ProgramHeader {
26 # CHECK: Type: PT_LOAD
28 # NOPAD: Offset: 0x120
29 # CHECK-NEXT: VirtualAddress:
30 # CHECK-NEXT: PhysicalAddress:
31 # PAD-NEXT: FileSize: 4096
32 # NOPAD-NEXT: FileSize: 1
33 # CHECK-NEXT: MemSize:
39 ## Check that executable page is filled with traps at its end.
40 # FILL: 001ff0 cccc cccc cccc cccc cccc cccc cccc cccc