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
15volatile int cold1 = 42;
16volatile int hot1 = 42;
17volatile int cold2 = 42;
18volatile int cold3 = 42;
19
20void _start() {
21 hot1++;
22 _start();
23}
24

source code of bolt/test/reorder-data-writable-ptload.c