alexcrichton opened PR #4314 from xdata-pdata
to main
:
Unwind information on Windows is stored in two separate locations. The
first location is the unwind information itself which corresponds to
UNWIND_INFO
. The second location is a list ofRUNTIME_INFO
structures which point to function bodes andUNWIND_INFO
structures.Currently in Wasmtime the
UNWIND_INFO
structures are stored just after
functions themselves with a somewhat cryptic comment indicating that
Windows prefers this (I'm unsure as to the provenance of this comment).
TheRUNTIME_INFO
data is then stored in a separate section which has
the custom name of_wasmtime_winx64_unwind
.After my recent foray into trying to debug windows-2022 bad unwind
information again I realized though that Windows actually has official
sections for these two unwind information items. The.xdata
section is
used to store theUNWIND_INFO
structures and the.pdata
section
stores theRUNTIME_INFO
list. To try to be somewhat idiomatic and
perhaps one day even hook into standard Windows debugging tools I went
ahead and refactored how our unwind information is stored to match this.Perhaps the main benefit of this is that it reduces the size of the
read/execute section of the binary. Previously the unwind information
was executable since it was stored in the.text
section, but
unnecessarily so. Now it's in a read-only section which is in theory a
small amount of hardening.Otherwise though I don't think this will really help all that much to
hook up in to standard debugging tools likeobjdump
because it's all
still stored in an ELF file rather than a COFF file.<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton requested peterhuene for a review on PR #4314.
peterhuene created PR review comment:
It's fairer to say that every address in the
RUNTIME_FUNCTION
structure must be start-of-text-section relative (thus necessitating that.xdata
comes _after_ the text section) because we're usingRtlAddFunctionTable
to register the.pdata
section contents and using the loaded text section's address as the "image base address".I think mentioning "relocations" here might be confusing since technically no fixups are being recorded in the artifact to apply at load time (unlike what a real
.pdata
section would have in a PE sinceRtlAddFunctionTable
wouldn't be used in that case).
peterhuene submitted PR review.
peterhuene created PR review comment:
Nit:
append_data
argument was removed but still documented above.
peterhuene submitted PR review.
peterhuene edited PR review comment.
alexcrichton updated PR #4314 from xdata-pdata
to main
.
alexcrichton has enabled auto merge for PR #4314.
alexcrichton merged PR #4314.
Last updated: Dec 23 2024 at 12:05 UTC