xref: /llvm-project/lld/test/ELF/linkerscript/print-memory-usage.s (revision 361a8226f981252bd8b152e9d0f2b47c7a25c266)
1# REQUIRES: x86
2
3# RUN: rm -rf %t && split-file %s %t
4# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a1.s -o %t/a1.o
5# RUN: ld.lld -T %t/1.t %t/a1.o -o %t/a1 --print-memory-usage \
6# RUN:     | FileCheck %s --check-prefix=CHECK1 --match-full-lines --strict-whitespace
7# RUN: ld.lld -T %t/2.t %t/a1.o -o %t/a2 --print-memory-usage \
8# RUN:     | FileCheck %s --check-prefix=CHECK2 --match-full-lines --strict-whitespace
9# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a2.s -o %t/a2.o
10# RUN: ld.lld -T %t/3.t %t/a2.o -o %t/a3 --print-memory-usage \
11# RUN:     | FileCheck %s --check-prefix=CHECK3 --match-full-lines --strict-whitespace
12
13#      CHECK1:Memory region         Used Size  Region Size  %age Used
14# CHECK1-NEXT:             ROM:           4 B         1 KB      0.39%
15# CHECK1-NEXT:             RAM:           4 B       256 KB      0.00%
16#  CHECK1-NOT:{{.}}
17
18# CHECK2:Memory region         Used Size  Region Size  %age Used
19# CHECK2-NOT:{{.}}
20
21#      CHECK3:Memory region         Used Size  Region Size  %age Used
22# CHECK3-NEXT:             ROM:        256 KB         1 MB     25.00%
23# CHECK3-NEXT:             RAM:          32 B         2 GB      0.00%
24#  CHECK3-NOT:{{.}}
25
26#--- a1.s
27.text
28.globl _start
29_start:
30  .long 1
31
32.data
33.globl b
34b:
35  .long 2
36
37#--- a2.s
38.text
39.globl _start
40_start:
41  .space 256*1024
42
43.data
44.globl b
45b:
46  .space 32
47
48#--- 1.t
49MEMORY {
50  ROM (RX) : ORIGIN = 0x0, LENGTH = 1K
51  RAM (W)  : ORIGIN = 0x100000, LENGTH = 256K
52}
53SECTIONS {
54  . = 0;
55  .text : { *(.text) }
56  .data : { *(.data) }
57}
58
59#--- 2.t
60SECTIONS {
61  . = 0;
62  .text : { *(.text) }
63  .data : { *(.data) }
64}
65
66#--- 3.t
67MEMORY {
68  ROM (RX) : ORIGIN = 0x0, LENGTH = 1M
69  RAM (W)  : ORIGIN = 0x1000000, LENGTH = 2048M
70}
71SECTIONS {
72  . = 0;
73  .text : { *(.text) }
74  .data : { *(.data) }
75}
76