[Orc] Support atexit in Orc(JITLink)
authorluxufan <932494295@qq.com>
Sat, 9 Oct 2021 00:36:41 +0000 (08:36 +0800)
committerluxufan <932494295@qq.com>
Sat, 9 Oct 2021 04:25:47 +0000 (12:25 +0800)
commit590326382dad4888111844efa5af0fdeff84c55c
tree28ccac45401c602ae16ed391a29d5a5624def60b
parent778bf73d7ba693f4bb74d137a70870bce128a19f
[Orc] Support atexit in Orc(JITLink)

There is a bug reported at https://bugs.llvm.org/show_bug.cgi?id=48938

After looking through the glibc, I found the `atexit(f)` is the same as `__cxa_atexit(f, NULL, NULL)`. In orc runtime, we identify different JITDylib by their dso_handle value, so that a NULL dso_handle is invalid. So in this patch, I added a `PlatformJDDSOHandle` to ELFNixRuntimeState, and functions which are registered by atexit will be registered at PlatformJD.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D111413
compiler-rt/lib/orc/elfnix_platform.cpp
compiler-rt/lib/orc/elfnix_platform.h
compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-atexit.S [new file with mode: 0644]
llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp