File: instrumentation-eh_frame_hdr.cpp

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (40 lines) | stat: -rw-r--r-- 1,308 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// This test checks that .eh_frame_hdr address is in bounds of the last LOAD
// end address i.e. the section address is smaller then the LOAD end address.

// REQUIRES: system-linux,bolt-runtime

// RUN: %clangxx %cxxflags -static -Wl,-q %s -o %t.exe -Wl,--entry=_start
// RUN: llvm-bolt %t.exe -o %t.instr -instrument \
// RUN:   --instrumentation-file=%t.fdata -instrumentation-sleep-time=1
// RUN: (llvm-readelf -SW %t.instr | grep -v bolt; llvm-readelf -lW %t.instr | \
// RUN:   grep LOAD | tail -n 1) | FileCheck %s

// CHECK: {{.*}} .eh_frame_hdr PROGBITS [[#%x, EH_ADDR:]]
// CHECK: LOAD 0x[[#%x, LD_OFFSET:]] 0x[[#%x, LD_VADDR:]] 0x[[#%x, LD_FSIZE:]]
// CHECK-SAME: 0x[[#%x, LD_MEMSIZE:]]
//
// If .eh_frame_hdr address bigger then last LOAD segment end address test would
// fail with overflow error, otherwise the result of the expression is 0 that
// could be found on this line e.g. in LOAD align field.
// CHECK-SAME: [[#LD_VADDR + LD_MEMSIZE - max(LD_VADDR + LD_MEMSIZE,EH_ADDR)]]

#include <cstdio>
#include <stdexcept>

void foo() { throw std::runtime_error("Exception from foo()"); }

void bar() { foo(); }

int main() {
  try {
    bar();
  } catch (const std::exception &e) {
    printf("Exception caught: %s\n", e.what());
  }
}

extern "C" {
void _start();
}

void _start() { main(); }