[ORC][ORC-RT][MachO] Reset __data and __common sections on library close.
authorLang Hames <lhames@gmail.com>
Fri, 16 Sep 2022 18:23:08 +0000 (11:23 -0700)
committerLang Hames <lhames@gmail.com>
Fri, 16 Sep 2022 20:40:19 +0000 (13:40 -0700)
commit47e9e588083493414d0abfbe33fe3566879c219b
tree8e0ab981b6647066fcafb3b80ec768f49f2d8159
parent1d5393526c29312eb51ab7dbbc082d10dfd44a5b
[ORC][ORC-RT][MachO] Reset __data and __common sections on library close.

If we want to be able to close and then re-open a library then we need to reset
the data section states when the library is closed. This commit updates
MachOPlatform and the ORC runtime to track __data and __common sections, and
reset the state in MachOPlatformRuntimeState::dlcloseDeinitialize.

This is only a first step to full support -- there are other data sections that
we're not capturing, and we'll probably want a more efficient representation
for the sections (rather than passing their string name over IPC), but this is
a reasonable first step.

This commit also contains a fix to MapperJITLinkMemoryManager that prevents it
from calling OnDeallocated twice in the case of an error.
compiler-rt/lib/orc/macho_platform.cpp
compiler-rt/test/orc/TestCases/Darwin/x86-64/jit-re-dlopen-data-reset.S [new file with mode: 0644]
llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
llvm/lib/ExecutionEngine/Orc/MapperJITLinkMemoryManager.cpp