summaryrefslogtreecommitdiff
path: root/bolt/test/runtime/bolt-reserved.cpp
blob: 2ebadfea5fa0285b00b43ecf46658d2aa0120c35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// REQUIRES: system-linux

/*
 * Check that llvm-bolt uses reserved space in a binary for allocating
 * new sections.
 */

// RUN: %clangxx %s -o %t.exe -Wl,-q
// RUN: llvm-bolt %t.exe -o %t.bolt.exe 2>&1 | FileCheck %s
// RUN: %t.bolt.exe

// CHECK: BOLT-INFO: using reserved space

/*
 * Check that llvm-bolt detects a condition when the reserved space is
 * not enough for allocating new sections.
 */

// RUN: %clangxx %s -o %t.tiny.exe -Wl,--no-eh-frame-hdr -Wl,-q -DTINY
// RUN: not llvm-bolt %t.tiny.exe -o %t.tiny.bolt.exe 2>&1 | \
// RUN:   FileCheck %s --check-prefix=CHECK-TINY

// CHECK-TINY: BOLT-ERROR: reserved space (1 byte) is smaller than required

#ifdef TINY
#define RSIZE "1"
#else
#define RSIZE "8192 * 1024"
#endif

asm(".pushsection .text \n\
       .globl __bolt_reserved_start \n\
       .type __bolt_reserved_start, @object \n\
       __bolt_reserved_start: \n\
       .space " RSIZE " \n\
       .globl __bolt_reserved_end \n\
       __bolt_reserved_end: \n\
     .popsection");

int main() { return 0; }