|
1 | 1 | # REQUIRES: x86
|
2 |
| -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o |
| 2 | +# RUN: rm -rf %t && split-file %s %t && cd %t |
| 3 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o |
| 4 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 bss.s -o bss.o |
3 | 5 |
|
4 | 6 | ## -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 |
| 7 | +# RUN: ld.lld a.o -o out |
| 8 | +# RUN: llvm-readobj -l out | FileCheck %s --check-prefixes=CHECK,NOPAD |
| 9 | +# RUN: ld.lld a.o -z noseparate-code -z common-page-size=512 -o out |
| 10 | +# RUN: llvm-readobj -l out | FileCheck %s --check-prefixes=CHECK,NOPAD |
9 | 11 |
|
10 | 12 | ## -z separate-code pads the tail of text segment with traps.
|
11 | 13 | ## Make common-page-size smaller than max-page-size.
|
12 | 14 | ## 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 |
| 15 | +# RUN: ld.lld a.o -z separate-code -z common-page-size=512 -o out |
| 16 | +# RUN: llvm-readobj -l out | FileCheck %s --check-prefixes=CHECK,PAD |
| 17 | +# RUN: od -Ax -x -N16 -j0x1ff0 out | FileCheck %s --check-prefix=FILL |
16 | 18 |
|
17 | 19 | ## -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 |
| 20 | +# RUN: ld.lld a.o -z separate-loadable-segments -z common-page-size=512 -o out |
| 21 | +# RUN: llvm-readobj -l out | FileCheck %s --check-prefixes=CHECK,PAD |
| 22 | +# RUN: od -Ax -x -N16 -j0x1ff0 out | FileCheck %s --check-prefix=FILL |
21 | 23 |
|
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 |
| 24 | +# RUN: ld.lld a.o -z separate-code -z noseparate-code -z common-page-size=512 -o out |
| 25 | +# RUN: llvm-readobj -l out | FileCheck %s --check-prefixes=CHECK,NOPAD |
24 | 26 |
|
25 | 27 | # CHECK: ProgramHeader {
|
26 | 28 | # CHECK: Type: PT_LOAD
|
|
39 | 41 | ## Check that executable page is filled with traps at its end.
|
40 | 42 | # FILL: 001ff0 cccc cccc cccc cccc cccc cccc cccc cccc
|
41 | 43 |
|
| 44 | +## There is a single RWX segment. Test that p_memsz is not truncated to p_filesz. |
| 45 | +# RUN: ld.lld a.o bss.o -z separate-loadable-segments -T rwx.lds -z max-page-size=64 -o rwx |
| 46 | +# RUN: llvm-readelf -l rwx | FileCheck %s --check-prefix=RWX |
| 47 | + |
| 48 | +# RWX: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align |
| 49 | +# RWX-NEXT: LOAD 0x000080 0x0000000000000000 0x0000000000000000 0x000040 0x000404 RWE 0x40 |
| 50 | + |
| 51 | +# RUN: ld.lld a.o bss.o -z separate-loadable-segments --omagic -o omagic |
| 52 | +# RUN: llvm-readelf -l omagic | FileCheck %s --check-prefix=OMAGIC |
| 53 | + |
| 54 | +# OMAGIC: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align |
| 55 | +# OMAGIC-NEXT:LOAD 0x0000b0 0x00000000002000b0 0x00000000002000b0 0x000004 0x000404 RWE 0x4 |
| 56 | + |
| 57 | +#--- a.s |
42 | 58 | .globl _start
|
43 | 59 | _start:
|
44 | 60 | nop
|
| 61 | + |
| 62 | +#--- bss.s |
| 63 | +.bss |
| 64 | +.space 1024 |
| 65 | + |
| 66 | +#--- rwx.lds |
| 67 | +PHDRS { all PT_LOAD; } |
| 68 | +SECTIONS { |
| 69 | + .text : {*(.text*)} :all |
| 70 | + .bss : {*(.bss*)} :all |
| 71 | +} |
0 commit comments