1 // This test check that LSDA section named by .gcc_except_table.main is
2 // disassembled by BOLT.
4 // RUN: %clang++ %cxxflags -O3 -no-pie -c %s -o %t.o
5 // RUN: %clang++ %cxxflags -O3 -no-pie -fuse-ld=lld %t.o -o %t
6 // RUN: llvm-objcopy --rename-section .gcc_except_table=.gcc_except_table.main %t
7 // RUN: llvm-readelf -SW %t | FileCheck %s
8 // RUN: llvm-bolt %t -o %t.bolt
10 // CHECK: .gcc_except_table.main
14 class MyException
: public std::exception
{
16 const char *what() const throw() {
17 return "Custom Exception: an error occurred!";
21 int divide(int a
, int b
) {
30 int result
= divide(10, 2); // normal case
31 std::cout
<< "Result: " << result
<< std::endl
;
32 result
= divide(5, 0); // will cause exception
33 std::cout
<< "Result: " << result
<< std::endl
;
34 // this line will not execute
35 } catch (const MyException
&e
) {
36 // catch custom exception
37 std::cerr
<< "Caught exception: " << e
.what() << std::endl
;
38 } catch (const std::exception
&e
) {
39 // catch other C++ exceptions
40 std::cerr
<< "Caught exception: " << e
.what() << std::endl
;
42 // catch all other exceptions
43 std::cerr
<< "Caught unknown exception" << std::endl
;