[TableGen][SystemZ] Correctly check the range of a leaf immediate (#119931)
[llvm-project.git] / bolt / test / X86 / instrumentation-eh_frame_hdr.cpp
blobb360530099ce321f0ae9935ce8382dae0604c675
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 > %t.sections
10 // RUN: llvm-readelf -lW %t.instr | grep LOAD | tail -n 1 >> %t.sections
11 // RUN: FileCheck %s < %t.sections
13 // CHECK: {{.*}} .eh_frame_hdr PROGBITS [[#%x, EH_ADDR:]]
14 // CHECK: LOAD 0x[[#%x, LD_OFFSET:]] 0x[[#%x, LD_VADDR:]] 0x[[#%x, LD_FSIZE:]]
15 // CHECK-SAME: 0x[[#%x, LD_MEMSIZE:]]
17 // If .eh_frame_hdr address bigger then last LOAD segment end address test would
18 // fail with overflow error, otherwise the result of the expression is 0 that
19 // could be found on this line e.g. in LOAD align field.
20 // CHECK-SAME: [[#LD_VADDR + LD_MEMSIZE - max(LD_VADDR + LD_MEMSIZE,EH_ADDR)]]
22 #include <cstdio>
23 #include <stdexcept>
25 void foo() { throw std::runtime_error("Exception from foo()"); }
27 void bar() { foo(); }
29 int main() {
30 try {
31 bar();
32 } catch (const std::exception &e) {
33 printf("Exception caught: %s\n", e.what());
37 extern "C" {
38 void _start();
41 void _start() { main(); }