Supporting Windows SEH without the ORC runtime
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
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 https://github.com/llvm/llvm-project/blob/d83fe1201e9d91da192d9292fea1a65579086e04/llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.h#L634)
Contributor guide
Research direction
Start by reading CompactUnwindSupport.h and tracing how JITLink currently handles unwind metadata. Then investigate RtlAddFunctionTable and RtlDeleteFunctionTable, including whether the base address needs metadata. Done means Windows SEH works in-process without requiring the ORC runtime.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100