Repository navigation
Drop the unwind tables the COFF JIT cannot relocate - #324
Merged
Merged
Conversation
Owner
Author
|
Cross built and checked on a Windows host. That is A larger program that exercises |
Every x86_64 Windows function carries a .pdata entry saying how to unwind out of it, and each entry is three offsets from the image base. A linker writes one by subtracting the address of __ImageBase from the address of what the entry describes. JIT'd code is not in an image, so JITLink adds __ImageBase as an undefined external, no COFF platform ever defines it, and its address stays zero. The subtraction is then a no op, the 64 bit address is left where a 32 bit offset should be, and the link fails on the first function that has unwind info, which is all of them. So mojo run on Windows died with "relocation target 0x... (.text) is out of range of Pointer32 fixup" right after it finished resolving symbols. This adds an object linking layer plugin that removes .pdata and .xdata from COFF link graphs. It goes in at the front of the pre prune passes so that it runs before JITLink's SEHFrameKeepAlivePass, which ties each .pdata block to the code it describes with a keep alive edge and would otherwise leave those edges pointing at blocks that are gone. The tables were not doing anything. Handing unwind info to Windows is the ORC COFF platform's job and no platform is created here, so they were being relocated for nobody. What is given up is walking out of a JIT'd frame in a Windows debugger, which does not work today either, for the same reason.
tamnd
force-pushed
the
coff-jit-unwind
branch
from
September 9, 2026 07:00
e908c3d to
3ef3045
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #323.
With #322 merged,
mojo runon Windows resolves every symbol it needs and then fails in the linker instead:Every x86_64 Windows function carries a
.pdataentry describing how to unwind out of it, and each entry is three offsets from the image base. A linker writes one by subtracting the address of__ImageBasefrom the address of the thing being described, which is whatIMAGE_REL_AMD64_ADDR32NBasks for and what JITLink models as aPointer32NBedge. JIT'd code is not in an image, soCOFFLinkGraphBuilderadds__ImageBaseas an undefined external, no COFF platform is ever created to define it, and its address stays zero. The lowering pass still runs the subtraction, gets the untouched 64 bit address back, and hands it to a 32 bit fixup. The first function with unwind info trips it, which is all of them.So this adds an object linking layer plugin that removes
.pdataand.xdatafrom COFF link graphs. It goes in at the front of the pre prune passes, ahead of JITLink's ownSEHFrameKeepAlivePass, because that pass gives every.pdatablock a keep alive edge to the code it describes and those edges would otherwise be pointing at blocks that are no longer there..xdatagoes too: it is only ever reached through.pdataand it carries the same kind of image relative pointer.The tables were not being used. Handing unwind info to Windows is the ORC COFF platform's job, we do not create a platform, and the execution engine destructor's platform shutdown branch is unreachable for the same reason, so the entries were being relocated for nobody. What this gives up is walking out of a JIT'd frame in a Windows debugger, which does not work today either. If the COFF platform is ever set up properly the plugin should come back out.
Everything is behind a COFF check, so the ELF and Mach-O paths are untouched.
Part of #31.