Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / linkerscript / end-overflow-check.test
blob3d0cd6d832ab67fab5f53d9f70aaf38a8af1d17a
1 REQUIRES: x86
3 # RUN: rm -rf %t && split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
6 ## The error should be triggered only for the second test where the overflow really exists.
8 RUN: ld.lld %t/a.o -T %t/b.lds -o /dev/null 2>&1
9 RUN: not ld.lld %t/a.o -T %t/c.lds -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR %s
11 # ERROR: error: section '_abss' will not fit in region 'SRAM0': overflowed by 1024 bytes
12 # ERROR: error: section '.c.bss' will not fit in region 'SRAM0': overflowed by 1024 bytes
13 # ERROR: error: section '.text' will not fit in region 'SRAM0': overflowed by 1025 bytes
15 #--- a.s
16 .section .a.bss, "aw", %nobits
17 .globl abss
18 abss:
19 .zero 0xDF0
20 .size abss, 0xDF0
22 .section .c.bss, "aw", %nobits
23 .globl cbss
25 .text
26 .globl _start
27 _start:
28 nop
30 #--- b.lds
31 MEMORY
33     SRAM0 (rw) : ORIGIN = 0x20000400, LENGTH = 10K
36 SECTIONS
38     _abss ALIGN(REGION1__PRE_ALIGNMENT) :
39     {
40         REGION1__BEGIN = .; REGION1__ALIGNED_BEGIN = .; REGION1_ALIGNED_BEGIN = .;
41         *(.a.bss)
42         REGION1__END = .; . = ALIGN(REGION1__POST_ALIGNMENT); REGION1_ALIGNED_END = .;
43     } > SRAM0
46 REGION1__PRE_ALIGNMENT = 0x00000800;
47 REGION1__PADDED_XOR = ((ABSOLUTE(REGION1__ALIGNED_BEGIN) | (ABSOLUTE(REGION1__END) - 1)) & ~(ABSOLUTE(REGION1__ALIGNED_BEGIN) & (ABSOLUTE(REGION1__END) - 1)));
48 REGION1__PADDED_REGION_SHIFT = LOG2CEIL(REGION1__PADDED_XOR);
49 REGION1__PADDED_SR_SHIFT = REGION1__PADDED_REGION_SHIFT - 3;
50 REGION1__PADDED_SR_SIZE = MAX(1 << REGION1__PADDED_SR_SHIFT, 32);
51 REGION1__POST_ALIGNMENT = REGION1__PADDED_SR_SIZE;
53 #--- c.lds
54 MEMORY
56     SRAM0 (rw) : ORIGIN = 0x20000400, LENGTH = 4K
59 SECTIONS
61     _abss ALIGN(REGION1__PRE_ALIGNMENT) :
62     {
63         REGION1__BEGIN = .; REGION1__ALIGNED_BEGIN = .; REGION1_ALIGNED_BEGIN = .;
64         *(.a.bss)
65         REGION1__END = .; . = ALIGN(REGION1__POST_ALIGNMENT); REGION1_ALIGNED_END = .;
66     } > SRAM0
69 REGION1__PRE_ALIGNMENT = 0x00000800;
70 REGION1__PADDED_XOR = ((ABSOLUTE(REGION1__ALIGNED_BEGIN) | (ABSOLUTE(REGION1__END) - 1)) & ~(ABSOLUTE(REGION1__ALIGNED_BEGIN) & (ABSOLUTE(REGION1__END) - 1)));
71 REGION1__PADDED_REGION_SHIFT = LOG2CEIL(REGION1__PADDED_XOR);
72 REGION1__PADDED_SR_SHIFT = REGION1__PADDED_REGION_SHIFT - 3;
73 REGION1__PADDED_SR_SIZE = MAX(1 << REGION1__PADDED_SR_SHIFT, 32);
74 REGION1__POST_ALIGNMENT = REGION1__PADDED_SR_SIZE;