It'd be nice to get Windows SEH working without requiring the ORC runtime.
This would bring Windows into line with Darwin and Linux, both of which support exceptions in-process without the runtime.
RtlAddFunctionTable (https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtladdfunctiontable) and RtlDeleteFunctionTable seem to be the registration APIs.
RtlAddFunctionTable takes a base address and a pointer to a table where function addresses are expressed as 32-bit offsets from the base:
NTSYSAPI BOOLEAN RtlAddFunctionTable(
[in] PRUNTIME_FUNCTION FunctionTable,
[in] DWORD EntryCount,
[in] DWORD64 BaseAddress
);
I do not know whether the SEH runtime looks at any metadata at the base address, or whether it's used purely for address calculations, but I suspect the latter (or the various out-of-tree SEH experiments that people have gotten working would have blown up differently).
Assuming that BaseAddress is only used for address calculation then we can probably just find the lowest address in the graph and use that for each graph.
If BaseAddress needs to contain useful metadata (e.g. a COFF header) then we can do something similar to what we do for compact-unwind (see
|
Error getOrCreateCompactUnwindBase(LinkGraph &G) { |
)
It'd be nice to get Windows SEH working without requiring the ORC runtime.
This would bring Windows into line with Darwin and Linux, both of which support exceptions in-process without the runtime.
RtlAddFunctionTable(https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtladdfunctiontable) andRtlDeleteFunctionTableseem to be the registration APIs.RtlAddFunctionTabletakes a base address and a pointer to a table where function addresses are expressed as 32-bit offsets from the base:I do not know whether the SEH runtime looks at any metadata at the base address, or whether it's used purely for address calculations, but I suspect the latter (or the various out-of-tree SEH experiments that people have gotten working would have blown up differently).
Assuming that
BaseAddressis only used for address calculation then we can probably just find the lowest address in the graph and use that for each graph.If
BaseAddressneeds to contain useful metadata (e.g. a COFF header) then we can do something similar to what we do for compact-unwind (seellvm-project/llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.h
Line 634 in d83fe12