blob: 67c1e3507ce74b55e38c915387f9c00211ecead7 [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 Leviantce30b1c2016-10-19 15:04:49 +000022# 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 Leviantbbe38602016-07-19 09:25:43 +000031# 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 Rimara14b13d2016-09-07 10:46:07 +000039# CHECK-NEXT: Flags [ (0x7)
Eugene Leviantbbe38602016-07-19 09:25:43 +000040# CHECK-NEXT: PF_R (0x4)
George Rimara14b13d2016-09-07 10:46:07 +000041# CHECK-NEXT: PF_W (0x2)
Eugene Leviantbbe38602016-07-19 09:25:43 +000042# CHECK-NEXT: PF_X (0x1)
43# CHECK-NEXT: ]
44
Eugene Leviant56b21c82016-09-09 09:46:16 +000045# 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 Rimar95dd7182016-10-18 10:49:50 +000059## 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 Leviantce30b1c2016-10-19 15:04:49 +000082# 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 Leviantbbe38602016-07-19 09:25:43 +000096.global _start
97_start:
98 nop
99
100.section .foo.1,"a"
101foo1:
102 .long 0
103
104.section .foo.2,"aw"
105foo2:
106 .long 0