PE: Resolve the machine type of a ReadyToRun image built for another system - #757
PE: Resolve the machine type of a ReadyToRun image built for another system#757zardus wants to merge 1 commit into
Conversation
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Validation record for head
Corpus A/B, 1,557 PE objects, one process per object:
Reproduction without the corpus: $ dotnet new classlib -o readytorun --framework net9.0 && cd readytorun
$ dotnet publish -c Release -r linux-x64 --self-contained false -p:PublishReadyToRun=true
$ python -c 'import cle; cle.Loader("bin/Release/net9.0/linux-x64/publish/readytorun.dll")'Caveats: the corpus is a private dataset, so objects are named by machine type and count rather than by path; the fixture in angr/binaries#183 is built by exactly the recipe above with .NET SDK 9.0.316. Only the Linux override is exercised by real images here; the other five constants come from the .NET runtime's CI on this PR: every job that resolves the referenced sibling pull request is |
|
Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/cle_757 |
…system A .NET ReadyToRun assembly published for a target other than Windows could not be loaded at all: arch_from_id raised ArchNotFound for machine type 0xfd1d. The ReadyToRun compiler exclusive-ors the COFF machine type with a constant naming the target operating system so that the Windows loader refuses a file that is not for it, and 0xfd1d is IMAGE_FILE_MACHINE_AMD64 ^ 0x7b79. Recognise those constants, which the .NET runtime defines as IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE in src/coreclr/inc/pedecoder.h, when the raw machine type is unknown and the image really is ReadyToRun.
5eacf2d to
ecae05b
Compare
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS
A .NET ReadyToRun assembly published for a target other than Windows cannot be
loaded at all:
arch_from_idraisesArchNotFoundfor machine type0xfd1d.The ReadyToRun compiler exclusive-ors the COFF machine type with a constant
naming the target operating system so the Windows loader refuses a file that is
not for it, and
0xfd1disIMAGE_FILE_MACHINE_AMD64 ^ 0x7b79.The backend now recognises those constants, which the .NET runtime defines as
IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDEinsrc/coreclr/inc/pedecoder.h. Ittries them only when the raw machine type is unknown and the image really is
ReadyToRun, so a corrupt
Machinefield elsewhere cannot be rescued by anexclusive-or that happens to land somewhere valid.
osstays"windows".Fixes #751. Needs angr/binaries#183 for the fixture. Validation: #757 (comment)