The implementation of _Unwind_FindEnclosingFunction(void *ip) takes the context of itself and then uses the context to get the info of the function enclosing ip. This approach does not work for AIX because on AIX, the TOC base in GPR2 is used as the base for calculating relative addresses. Since _Unwind_FindEnclosingFunction() may be in a different shared lib than the function containing ip, their TOC bases can be different. Therefore, using the value of GPR2 in the context from _Unwind_FindEnclosingFunction() as the base results in incorrect addresses. On the other hand, the start address of a function is available in the traceback table following the instructions of each function on AIX. To get to the traceback table, search a word of 0 starting from ip and the traceback table is located after the word 0. This patch implements _Unwind_FindEnclosingFunction() for AIX by obtaining the function start address from its traceback table.
Details
Details
- Reviewers
compnerd MaskRay cebowleratibm - Group Reviewers
Restricted Project - Commits
- rG2366c6adfc95: [libunwind][AIX] Implement _Unwind_FindEnclosingFunction() using traceback…
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Addressed comment.
- _Unwind_FindEnclosingFunction() returns NULL if argument pc is NULL;
- dropped else for returning NULL as suggested.
libunwind/src/UnwindLevel1-gcc-ext.c | ||
---|---|---|
100 | llvm style prefers pre-increment ++p |
libunwind/src/UnwindLevel1-gcc-ext.c | ||
---|---|---|
100 | Sorry, changed both instances as suggested, thanks! |
Should we use uintptr_t here instead of uint32_t?