[libcxx-commits] [PATCH] D101298: [libc++abi][AIX] Enable calculating addresses with DW_EH_PE_datarel

Xing Xue via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 13 13:36:56 PDT 2021


xingxue added inline comments.


================
Comment at: libcxxabi/src/cxa_personality.cpp:971
     set_registers(unwind_exception, context, results);
+    // Cache base for calculating the address of ttype in __cxa_call_unexpected.
+    if (results.ttypeIndex < 0) {
----------------
MaskRay wrote:
> Normal Itanium doesn't need/shouldn't have this code. `_UA_CLEANUP_PHASE` doesn't need caching.
> 
> Can you re-confirm AIX needs this? (I suspect this is not the right place to add the code.)
For `AIX` `EH`, the `DW_EH_PE_datarel` encoding is used in the range table to calculate relative addresses with a `base`.  So, parameter `base` is added to functions invoked by `scan_eh_tab()` and `readEncodedPointer()` is extended to enable the `DW_EH_PE_datarel` encoding.

For code such as the segment below, the `landingpad` calls `__cxa_call_unexpected()` which in turn calls the unexpected exception handler.  When `__cxa_call_unexpected()` handles the exception thrown from the unexpected exception handler, it calls `exception_spec_can_catch()` where a `base` is needed for the `DW_EH_PE_datarel` encoding. `__cxa_call_unexpected()` takes one parameter which is the pointer to the exception object.  So, we need a way to communicate the `base` to `__cxa_call_unexpected()`. `catchTemp` is used for caching the `landingpad` but after `get_registers()` sets the `landingpad` into the `IP` register, the `landingpad` cached in `catchTemp` is no longer useful. This is why this location is chosen. The `__cxa_exception` structure has being used in communicating `lsda`, `ttypeIndex`, etc. between the personality routine and `__cxa_call_unexpected()`.  So, I think it makes sense to use `catchTemp` which is also a member of `__cxa_exception` for this purpose as well but I am open to suggestions.

```
struct E {
        int i;
        E() { i=0; }
};

struct S {
        S() {}
        S(int i) {}
        ~S() { ret = std::uncaught_exception(); }
};

void f(void) throw (E) {
    register S s;
    throw 1;
}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101298/new/

https://reviews.llvm.org/D101298



More information about the libcxx-commits mailing list