xref: /llvm-project/bolt/test/reorder-data-writable-ptload.c (revision 8592241e29e29f0e7e407e0989489c6e70c91c42)
1 // This test checks that reorder-data pass puts new hot .data section
2 // to the writable segment.
3 
4 // Use -fPIC -pie to prevent the globals being put in .sdata instead of .data on
5 // RISC-V.
6 // RUN: %clang %cflags -fPIC -pie -O3 -nostdlib -Wl,-q %s -o %t.exe
7 // RUN: llvm-bolt %t.exe -o %t.bolt --reorder-data=".data" \
8 // RUN:   -data %S/Inputs/reorder-data-writable-ptload.fdata
9 // RUN: llvm-readelf -SlW %t.bolt | FileCheck %s
10 
11 // CHECK: .bolt.org.data
12 // CHECK: {{.*}} .data PROGBITS [[#%x,ADDR:]] [[#%x,OFF:]]
13 // CHECK: LOAD 0x{{.*}}[[#OFF]] 0x{{.*}}[[#ADDR]] {{.*}} RW
14 
15 volatile int cold1 = 42;
16 volatile int hot1 = 42;
17 volatile int cold2 = 42;
18 volatile int cold3 = 42;
19 
_start()20 void _start() {
21   hot1++;
22   _start();
23 }
24