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. |
3 | |
4 | // REQUIRES: system-linux,bolt-runtime,target=x86_64{{.*}} |
5 | |
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 |
12 | |
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:]] |
16 | // |
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)]] |
21 | |
22 | #include <cstdio> |
23 | #include <stdexcept> |
24 | |
25 | void foo() { throw std::runtime_error("Exception from foo()"); } |
26 | |
27 | void bar() { foo(); } |
28 | |
29 | int main() { |
30 | try { |
31 | bar(); |
32 | } catch (const std::exception &e) { |
33 | printf(format: "Exception caught: %s\n", e.what()); |
34 | } |
35 | } |
36 | |
37 | extern "C"{ |
38 | void _start(); |
39 | } |
40 | |
41 | void _start() { main(); } |
42 |