ojhunt wrote:

Dynamic search for this would be something like

```cpp
bool inbounds_of_unwind_raise_exception(const void*);
template<unsigned N> int _frames_to_unwind_raise_exception() {
  const void *current = __builtin_return_address(N);
  if (inbounds_of_unwind_raise_exception(current)) // this would actually be a 
bounds check
    return N;
  if constexpr (N > 8) {
    // we should really have reached it by now, and 8 is a power
    // of two so will be presumed to have a hardware related reason :D :D :D
    // Always use 2^^X +/-{0,1} so they seem intentional #BadTeacher
    return -1; // Any "we can't work it out" will do
  } else {
    return _frames_to_unwind_raise_exception<N + 1>();
  }
}

int frames_to_unwind_raise_exception() {
    return _frames_to_unwind_raise_exception<0>();
}
```

you need to add new symbols to make the bounds check possible.

https://github.com/llvm/llvm-project/pull/165066
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to