Eugene Leviant | bbe3860 | 2016-07-19 09:25:43 +0000 | [diff] [blame] | 1 | # REQUIRES: x86 |
| 2 | # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t |
| 3 | # RUN: echo "PHDRS {all PT_LOAD FILEHDR PHDRS ;} \ |
| 4 | # RUN: SECTIONS { \ |
| 5 | # RUN: . = 0x10000200; \ |
George Rimar | 215dd47 | 2016-08-10 14:02:35 +0000 | [diff] [blame] | 6 | # RUN: .text : {*(.text*)} :all \ |
Eugene Leviant | bbe3860 | 2016-07-19 09:25:43 +0000 | [diff] [blame] | 7 | # RUN: .foo : {*(.foo.*)} :all \ |
| 8 | # RUN: .data : {*(.data.*)} :all}" > %t.script |
Eugene Leviant | bbe3860 | 2016-07-19 09:25:43 +0000 | [diff] [blame] | 9 | # RUN: ld.lld -o %t1 --script %t.script %t |
| 10 | # RUN: llvm-readobj -program-headers %t1 | FileCheck %s |
Eugene Leviant | 56b21c8 | 2016-09-09 09:46:16 +0000 | [diff] [blame] | 11 | |
| 12 | ## Check the AT(expr) |
| 13 | # RUN: echo "PHDRS {all PT_LOAD FILEHDR PHDRS AT(0x500 + 0x500) ;} \ |
| 14 | # RUN: SECTIONS { \ |
| 15 | # RUN: . = 0x10000200; \ |
| 16 | # RUN: .text : {*(.text*)} :all \ |
| 17 | # RUN: .foo : {*(.foo.*)} :all \ |
| 18 | # RUN: .data : {*(.data.*)} :all}" > %t.script |
| 19 | # RUN: ld.lld -o %t1 --script %t.script %t |
| 20 | # RUN: llvm-readobj -program-headers %t1 | FileCheck --check-prefix=AT %s |
| 21 | |
Eugene Leviant | ce30b1c | 2016-10-19 15:04:49 +0000 | [diff] [blame^] | 22 | # RUN: echo "PHDRS {all PT_LOAD FILEHDR PHDRS ;} \ |
| 23 | # RUN: SECTIONS { \ |
| 24 | # RUN: . = 0x10000200; \ |
| 25 | # RUN: .text : {*(.text*)} :all \ |
| 26 | # RUN: .foo : {*(.foo.*)} \ |
| 27 | # RUN: .data : {*(.data.*)} }" > %t.script |
| 28 | # RUN: ld.lld -o %t1 --script %t.script %t |
| 29 | # RUN: llvm-readobj -program-headers %t1 | FileCheck --check-prefix=DEFHDR %s |
| 30 | |
Eugene Leviant | bbe3860 | 2016-07-19 09:25:43 +0000 | [diff] [blame] | 31 | # CHECK: ProgramHeaders [ |
| 32 | # CHECK-NEXT: ProgramHeader { |
| 33 | # CHECK-NEXT: Type: PT_LOAD (0x1) |
| 34 | # CHECK-NEXT: Offset: 0x0 |
| 35 | # CHECK-NEXT: VirtualAddress: 0x10000000 |
| 36 | # CHECK-NEXT: PhysicalAddress: 0x10000000 |
| 37 | # CHECK-NEXT: FileSize: 521 |
| 38 | # CHECK-NEXT: MemSize: 521 |
George Rimar | a14b13d | 2016-09-07 10:46:07 +0000 | [diff] [blame] | 39 | # CHECK-NEXT: Flags [ (0x7) |
Eugene Leviant | bbe3860 | 2016-07-19 09:25:43 +0000 | [diff] [blame] | 40 | # CHECK-NEXT: PF_R (0x4) |
George Rimar | a14b13d | 2016-09-07 10:46:07 +0000 | [diff] [blame] | 41 | # CHECK-NEXT: PF_W (0x2) |
Eugene Leviant | bbe3860 | 2016-07-19 09:25:43 +0000 | [diff] [blame] | 42 | # CHECK-NEXT: PF_X (0x1) |
| 43 | # CHECK-NEXT: ] |
| 44 | |
Eugene Leviant | 56b21c8 | 2016-09-09 09:46:16 +0000 | [diff] [blame] | 45 | # AT: ProgramHeaders [ |
| 46 | # AT-NEXT: ProgramHeader { |
| 47 | # AT-NEXT: Type: PT_LOAD (0x1) |
| 48 | # AT-NEXT: Offset: 0x0 |
| 49 | # AT-NEXT: VirtualAddress: 0x10000000 |
| 50 | # AT-NEXT: PhysicalAddress: 0xA00 |
| 51 | # AT-NEXT: FileSize: 521 |
| 52 | # AT-NEXT: MemSize: 521 |
| 53 | # AT-NEXT: Flags [ (0x7) |
| 54 | # AT-NEXT: PF_R (0x4) |
| 55 | # AT-NEXT: PF_W (0x2) |
| 56 | # AT-NEXT: PF_X (0x1) |
| 57 | # AT-NEXT: ] |
| 58 | |
George Rimar | 95dd718 | 2016-10-18 10:49:50 +0000 | [diff] [blame] | 59 | ## Check the numetic values for PHDRS. |
| 60 | # RUN: echo "PHDRS {text PT_LOAD FILEHDR PHDRS; foo 0x11223344; } \ |
| 61 | # RUN: SECTIONS { . = SIZEOF_HEADERS; .foo : { *(.*) } : text : foo}" > %t1.script |
| 62 | # RUN: ld.lld -o %t2 --script %t1.script %t |
| 63 | # RUN: llvm-readobj -program-headers %t2 | FileCheck --check-prefix=INT-PHDRS %s |
| 64 | |
| 65 | # INT-PHDRS: ProgramHeaders [ |
| 66 | # INT-PHDRS: ProgramHeader { |
| 67 | # INT-PHDRS: Type: (0x11223344) |
| 68 | # INT-PHDRS-NEXT: Offset: 0xB0 |
| 69 | # INT-PHDRS-NEXT: VirtualAddress: 0xB0 |
| 70 | # INT-PHDRS-NEXT: PhysicalAddress: 0xB0 |
| 71 | # INT-PHDRS-NEXT: FileSize: 9 |
| 72 | # INT-PHDRS-NEXT: MemSize: 9 |
| 73 | # INT-PHDRS-NEXT: Flags [ |
| 74 | # INT-PHDRS-NEXT: PF_R |
| 75 | # INT-PHDRS-NEXT: PF_W |
| 76 | # INT-PHDRS-NEXT: PF_X |
| 77 | # INT-PHDRS-NEXT: ] |
| 78 | # INT-PHDRS-NEXT: Alignment: 4 |
| 79 | # INT-PHDRS-NEXT: } |
| 80 | # INT-PHDRS-NEXT: ] |
| 81 | |
Eugene Leviant | ce30b1c | 2016-10-19 15:04:49 +0000 | [diff] [blame^] | 82 | # DEFHDR: ProgramHeaders [ |
| 83 | # DEFHDR-NEXT: ProgramHeader { |
| 84 | # DEFHDR-NEXT: Type: PT_LOAD (0x1) |
| 85 | # DEFHDR-NEXT: Offset: 0x0 |
| 86 | # DEFHDR-NEXT: VirtualAddress: 0x10000000 |
| 87 | # DEFHDR-NEXT: PhysicalAddress: 0x10000000 |
| 88 | # DEFHDR-NEXT: FileSize: 521 |
| 89 | # DEFHDR-NEXT: MemSize: 521 |
| 90 | # DEFHDR-NEXT: Flags [ (0x7) |
| 91 | # DEFHDR-NEXT: PF_R (0x4) |
| 92 | # DEFHDR-NEXT: PF_W (0x2) |
| 93 | # DEFHDR-NEXT: PF_X (0x1) |
| 94 | # DEFHDR-NEXT: ] |
| 95 | |
Eugene Leviant | bbe3860 | 2016-07-19 09:25:43 +0000 | [diff] [blame] | 96 | .global _start |
| 97 | _start: |
| 98 | nop |
| 99 | |
| 100 | .section .foo.1,"a" |
| 101 | foo1: |
| 102 | .long 0 |
| 103 | |
| 104 | .section .foo.2,"aw" |
| 105 | foo2: |
| 106 | .long 0 |