blob: 7d5201c3726d113f1b734d99ed4add3a0c2ea128 [file] [log] [blame]
Eugene Leviantbbe38602016-07-19 09:25:43 +00001# 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 Rimar215dd472016-08-10 14:02:35 +00006# RUN: .text : {*(.text*)} :all \
Eugene Leviantbbe38602016-07-19 09:25:43 +00007# RUN: .foo : {*(.foo.*)} :all \
8# RUN: .data : {*(.data.*)} :all}" > %t.script
Eugene Leviantbbe38602016-07-19 09:25:43 +00009# RUN: ld.lld -o %t1 --script %t.script %t
10# RUN: llvm-readobj -program-headers %t1 | FileCheck %s
Eugene Leviant56b21c82016-09-09 09:46:16 +000011
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 Leviantbbe38602016-07-19 09:25:43 +000022# CHECK: ProgramHeaders [
23# CHECK-NEXT: ProgramHeader {
24# CHECK-NEXT: Type: PT_LOAD (0x1)
25# CHECK-NEXT: Offset: 0x0
26# CHECK-NEXT: VirtualAddress: 0x10000000
27# CHECK-NEXT: PhysicalAddress: 0x10000000
28# CHECK-NEXT: FileSize: 521
29# CHECK-NEXT: MemSize: 521
George Rimara14b13d2016-09-07 10:46:07 +000030# CHECK-NEXT: Flags [ (0x7)
Eugene Leviantbbe38602016-07-19 09:25:43 +000031# CHECK-NEXT: PF_R (0x4)
George Rimara14b13d2016-09-07 10:46:07 +000032# CHECK-NEXT: PF_W (0x2)
Eugene Leviantbbe38602016-07-19 09:25:43 +000033# CHECK-NEXT: PF_X (0x1)
34# CHECK-NEXT: ]
35
Eugene Leviant56b21c82016-09-09 09:46:16 +000036# AT: ProgramHeaders [
37# AT-NEXT: ProgramHeader {
38# AT-NEXT: Type: PT_LOAD (0x1)
39# AT-NEXT: Offset: 0x0
40# AT-NEXT: VirtualAddress: 0x10000000
41# AT-NEXT: PhysicalAddress: 0xA00
42# AT-NEXT: FileSize: 521
43# AT-NEXT: MemSize: 521
44# AT-NEXT: Flags [ (0x7)
45# AT-NEXT: PF_R (0x4)
46# AT-NEXT: PF_W (0x2)
47# AT-NEXT: PF_X (0x1)
48# AT-NEXT: ]
49
George Rimar95dd7182016-10-18 10:49:50 +000050## Check the numetic values for PHDRS.
51# RUN: echo "PHDRS {text PT_LOAD FILEHDR PHDRS; foo 0x11223344; } \
52# RUN: SECTIONS { . = SIZEOF_HEADERS; .foo : { *(.*) } : text : foo}" > %t1.script
53# RUN: ld.lld -o %t2 --script %t1.script %t
54# RUN: llvm-readobj -program-headers %t2 | FileCheck --check-prefix=INT-PHDRS %s
55
56# INT-PHDRS: ProgramHeaders [
57# INT-PHDRS: ProgramHeader {
58# INT-PHDRS: Type: (0x11223344)
59# INT-PHDRS-NEXT: Offset: 0xB0
60# INT-PHDRS-NEXT: VirtualAddress: 0xB0
61# INT-PHDRS-NEXT: PhysicalAddress: 0xB0
62# INT-PHDRS-NEXT: FileSize: 9
63# INT-PHDRS-NEXT: MemSize: 9
64# INT-PHDRS-NEXT: Flags [
65# INT-PHDRS-NEXT: PF_R
66# INT-PHDRS-NEXT: PF_W
67# INT-PHDRS-NEXT: PF_X
68# INT-PHDRS-NEXT: ]
69# INT-PHDRS-NEXT: Alignment: 4
70# INT-PHDRS-NEXT: }
71# INT-PHDRS-NEXT: ]
72
Eugene Leviantbbe38602016-07-19 09:25:43 +000073.global _start
74_start:
75 nop
76
77.section .foo.1,"a"
78foo1:
79 .long 0
80
81.section .foo.2,"aw"
82foo2:
83 .long 0