Test program below, provided by robert@ blows up when compiled with
"-static" and "-no-pie":
$ c++ -no-pie -static e.cc && ./a.out
Segmentation fault (core dumped)
#0 libunwind::EHHeaderParser<libunwind::LocalAddressSpace>::decodeEHHdr
(addressSpace=..., ehHdrStart=4211204, ehHdrEnd=4876, ehHdrInfo=...)
at /usr/src/lib/libcxxabi/../libunwind/src/EHHeaderParser.hpp:60
#1 libunwind::LocalAddressSpace::findUnwindSections(unsigned long,
libunwind::UnwindInfoSections&)::{lambda(dl_phdr_info*, unsigned long,
void*)#1}::operator()(dl_phdr_info*, unsigned long, void*) const
(this=<optimized out>, pinfo=0x24a058 <_static_phdr_info>, data=<optimized out>)
at /usr/src/lib/libcxxabi/../libunwind/src/AddressSpace.hpp:598
#2 0x00000000002110c4 in libunwind::LocalAddressSpace::findUnwindSections
(this=<optimized out>, targetAddr=<optimized out>, info=...)
at /usr/src/lib/libcxxabi/../libunwind/src/AddressSpace.hpp:538
#3 libunwind::UnwindCursor<libunwind::LocalAddressSpace,
libunwind::Registers_x86_64>::setInfoBasedOnIPRegister (this=0x7f7fffff8a08,
isReturnAddress=<optimized out>)
at /usr/src/lib/libcxxabi/../libunwind/src/UnwindCursor.hpp:1827
#4 0x00000000002103ee in unw_init_local (cursor=0x7f7fffff8a08,
context=<optimized out>) at
/usr/src/lib/libcxxabi/../libunwind/src/libunwind.cpp:82
#5 0x000000000020fd8c in unwind_phase1 (uc=0x20f600
<__cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)>,
cursor=0x247f88 <vtable for
libunwind::UnwindCursor<libunwind::LocalAddressSpace,
libunwind::Registers_x86_64>+16>, exception_object=0x2749dfe60)
at /usr/src/lib/libcxxabi/../libunwind/src/UnwindLevel1.c:39
#6 _Unwind_RaiseException (exception_object=0x2749dfe60) at
/usr/src/lib/libcxxabi/../libunwind/src/UnwindLevel1.c:357
#7 0x000000000020f5f3 in __cxa_throw (thrown_object=0x2749dfe80,
tinfo=0x2475c8 <typeinfo for char const*>, dest=<optimized out>)
at /usr/src/lib/libcxxabi/src/cxa_exception.cpp:281
#8 0x000000000020c38f in division(int, int) ()
#9 0x000000000020c410 in main ()
That means it's currently impossible to profile C++ binaries on OpenBSD,
which is what we need :o)
#include <iostream>
using namespace std;
double division(int a, int b) {
if (b == 0) {
throw "Division by zero condition!";
}
return (a/b);
}
int main () {
int x = 50;
int y = 0;
double z = 0;
for (uint64_t n = 40; n > 0; n--) {
try {
z = division(x, y);
} catch (const char* msg) {
}
}
return 0;
}