Skip to content

Commit ff0c5cc

Browse files
authored
[BOLT] Add a test for BOLT-reserved space in a binary (#91399)
Test case for #90300.
1 parent 8fc6887 commit ff0c5cc

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

bolt/test/runtime/bolt-reserved.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// REQUIRES: system-linux
2+
3+
/*
4+
* Check that llvm-bolt uses reserved space in a binary for allocating
5+
* new sections.
6+
*/
7+
8+
// RUN: %clang %s -o %t.exe -Wl,-q
9+
// RUN: llvm-bolt %t.exe -o %t.bolt.exe 2>&1 | FileCheck %s
10+
// RUN: %t.bolt.exe
11+
12+
// CHECK: BOLT-INFO: using reserved space
13+
14+
/*
15+
* Check that llvm-bolt detects a condition when the reserved space is
16+
* not enough for allocating new sections.
17+
*/
18+
19+
// RUN: %clang %s -o %t.exe -Wl,--no-eh-frame-hdr -Wl,-q -DTINY
20+
// RUN: not llvm-bolt %t.exe -o %t.bolt.exe 2>&1 | \
21+
// RUN: FileCheck %s --check-prefix=CHECK-TINY
22+
23+
// CHECK-TINY: BOLT-ERROR: reserved space (1 byte) is smaller than required
24+
25+
#ifdef TINY
26+
#define RSIZE "1"
27+
#else
28+
#define RSIZE "8192 * 1024"
29+
#endif
30+
31+
asm(".pushsection .text \n\
32+
.globl __bolt_reserved_start \n\
33+
.type __bolt_reserved_start, @object \n\
34+
__bolt_reserved_start: \n\
35+
.space " RSIZE " \n\
36+
.globl __bolt_reserved_end \n\
37+
__bolt_reserved_end: \n\
38+
.popsection");
39+
40+
int main() { return 0; }

0 commit comments

Comments
 (0)