Repository navigation
Conversation
MachOUniversalFile wrapped the selected slice in a read-only MemoryStream, but MachOFile applies chained fixups in place through WriteWord, so any universal binary using chained fixups failed to load with "Stream does not support writing". This is the default for macOS 12+ deployment targets, e.g. the GameAssembly.dylib of Unity 6 macOS builds. Adds a small universal fixture built from the included C source and a test checking that the selected slice's rebases are applied.
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.
MachOUniversalFilewraps the selected slice in a read-onlyMemoryStream.MachOFileapplies chained fixups in place throughWriteWord, so any universal binary that uses chained fixups fails to load withNotSupportedException: Stream does not support writing. Chained fixups are the default for macOS 12+ deployment targets, so this hits the universalGameAssembly.dylibof Unity 6 macOS builds.The fix makes the slice stream writable (
new MemoryStream(buffer, 0, size, writable: true, publiclyVisible: true)).Test: adds
TestFiles/MachO/ChainedFixupsUniversal.dylib, a 49,792-byte x86_64+arm64 universal binary, with its C source and build command. It also addsMachOUniversalFileTests, which checks that the x86_64 slice's two-pointer rebase chain resolves to0x1000/0x1008. Before the fix, the test throws "Stream does not support writing". After the fix,dotnet test -c Releasepasses 82 of 82 tests.Real-world check: Dofus 3.6.10.11 (Unity 6000.3.16f1) produced 143 assemblies in 35 s with a self-contained osx-x64 build at
2022.1.0-pre-release.21with this fix.