[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / bolt / test / X86 / instrumentation-eh_frame_hdr.cpp
blob4ed8be42cd0f37fdfa6e02e165059dc33d943cc6
1 // This test checks that .eh_frame_hdr address is in bounds of the last LOAD
2 // end address i.e. the section address is smaller then the LOAD end address.
4 // REQUIRES: system-linux,bolt-runtime,target=x86_64{{.*}}
6 // RUN: %clangxx %cxxflags -static -Wl,-q %s -o %t.exe -Wl,--entry=_start
7 // RUN: llvm-bolt %t.exe -o %t.instr -instrument \
8 // RUN: --instrumentation-file=%t.fdata -instrumentation-sleep-time=1
9 // RUN: (llvm-readelf -SW %t.instr | grep -v bolt; llvm-readelf -lW %t.instr | \
10 // RUN: grep LOAD | tail -n 1) | FileCheck %s
12 // CHECK: {{.*}} .eh_frame_hdr PROGBITS [[#%x, EH_ADDR:]]
13 // CHECK: LOAD 0x[[#%x, LD_OFFSET:]] 0x[[#%x, LD_VADDR:]] 0x[[#%x, LD_FSIZE:]]
14 // CHECK-SAME: 0x[[#%x, LD_MEMSIZE:]]
16 // If .eh_frame_hdr address bigger then last LOAD segment end address test would
17 // fail with overflow error, otherwise the result of the expression is 0 that
18 // could be found on this line e.g. in LOAD align field.
19 // CHECK-SAME: [[#LD_VADDR + LD_MEMSIZE - max(LD_VADDR + LD_MEMSIZE,EH_ADDR)]]
21 #include <cstdio>
22 #include <stdexcept>
24 void foo() { throw std::runtime_error("Exception from foo()"); }
26 void bar() { foo(); }
28 int main() {
29 try {
30 bar();
31 } catch (const std::exception &e) {
32 printf("Exception caught: %s\n", e.what());
36 extern "C" {
37 void _start();
40 void _start() { main(); }