This patch enables calculating relative addresses with the DW_EH_PE_datarel encoding using a base for AIX. After setting registers for jumping to the user code in gxx_personality_v0(), base is cached in exception_header member catchTemp for use in __cxa_call_unexpected if ttypeIndex is less than 0 (exception spec).
Details
- Reviewers
MaskRay phosek mstorsjo sfertile jasonliu hubert.reinterpretcast cebowleratibm compnerd - Group Reviewers
Restricted Project - Commits
- rGafd3607c8f36: [libc++abi][AIX] Enable calculating addresses with DW_EH_PE_datarel
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Removed the incorrect setting of parent revision. Reload the patch to trigger the pre-merge check. Sorry for the noise.
libcxxabi/src/cxa_personality.cpp | ||
---|---|---|
91 | errant whitespace change. | |
249 | I'm guessing these indentation changes, and brace placement changes are from clang format, but it no longer matches the formatting of the rest of the file. We shouldn't be changing formatting on otherwise untouched lines, and the changes we do make should match the formatting of the rest of the file. |
libcxxabi/src/cxa_personality.cpp | ||
---|---|---|
942 | 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.) |
libcxxabi/src/cxa_personality.cpp | ||
---|---|---|
942 | 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; } |
libcxxabi/src/cxa_personality.cpp | ||
---|---|---|
632 | IIUC this is going to work for AIX because the encoding is DW_EH_PE_omit, but if we are adding support for `DW_EH_PE_datarel then we need to pass base in here. If someone comes along and adds a target that uses data relative encoding for the offset to the lsda then it should already work (after this patch). | |
661 | Does it make sense to add an assert here that callSiteEncoding is not data relative for documentation as why we use the default value of base=0. (Sorry this should;ld have probably gone in the previous patch) | |
942 |
FWIW it makes sense that targets that use DW_EH_PE_pcrel or DW_EH_PE_absptr don't need the caching. The absptr encoding you don't add any base address, and the pcrel encoding you use the data pointer you just read from as the base address. | |
1159–1160 | ditto on adding base argument to this call. |
Minor changes related to the -Wunused-parameter warning.
- Reverted the change in D104235 that was to avoid the warning because the parameter is used in this patch.
- Changed from uintptr_t base = 0 to uintptr_t /*base*/ = 0 in 2 places to avoid the warning.
libcxxabi/src/cxa_personality.cpp | ||
---|---|---|
1252 | It would be nice to use the reserved spelling (__attribute__((__alias__("__gxx_personality_v0")))) |
libcxxabi/src/cxa_personality.cpp | ||
---|---|---|
1252 | Changed as suggested, thanks! |
errant whitespace change.