4 ms·
SJLJ exceptions do not need to perform ancillary data lookup using program counter values. Instead, there is code on the non-error path that maintains a linked
by fweimer 2y ago
SJLJ exceptions do not need to perform ancillary data lookup using program counter values. Instead, there is code on the non-error path that maintains a linked list of exception landing sites when try blocks are entered/exited. Run-time type information is still needed for catch clause matching, but that data can be accessed easily via the vtable pointer and information next to the vtable. None of this needs to access mutable global data structures.
DWARF exception handling needs DWARF unwind information, which is mapped in memory along with the code. But the stack only has program counters, not the addresses of the DWARF data. Therefore, the first step is to locate the DWARF data. The semi-portable interface (supported on GNU/Linux, various BSD, and likely others) for that is dl_iterate_phdr, and that invokes a callback under a global lock. The global lock is required because the list of objects can change in response to dlopen and dlclose calls. With the new way, the GCC unwinder directly asks the glibc dynamic linker for the ELF object corresponding to a program counter value and its DWARF unwind information address. This way, the synchronization with dlopen/dlclose is an internal dynamic linker implementation detail.