Skip to content

Supporting Windows SEH without the ORC runtime #163503

@lhames

Description

@lhames

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 grab.

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) {
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions