brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · b360530 Raw
42 lines · cpp
1// This test checks that .eh_frame_hdr address is in bounds of the last LOAD2// 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=_start7// RUN: llvm-bolt %t.exe -o %t.instr -instrument \8// RUN:   --instrumentation-file=%t.fdata -instrumentation-sleep-time=19// RUN: llvm-readelf -SW %t.instr | grep -v bolt > %t.sections10// RUN: llvm-readelf -lW %t.instr | grep LOAD | tail -n 1 >> %t.sections11// RUN: FileCheck %s < %t.sections12 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 would18// fail with overflow error, otherwise the result of the expression is 0 that19// 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 25void foo() { throw std::runtime_error("Exception from foo()"); }26 27void bar() { foo(); }28 29int main() {30  try {31    bar();32  } catch (const std::exception &e) {33    printf("Exception caught: %s\n", e.what());34  }35}36 37extern "C" {38void _start();39}40 41void _start() { main(); }42