Repository navigation
Key the Linux Mono builds on the first patch of each layout (#154) #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3e090f2
key linux mono builds on first patch of each layout
ero-qt a576aaa
add 2018.1.0 and 2018.2.0 linux mono builds
ero-qt a3e61be
add 2017.1.0 linux mono bdwgc build
ero-qt b21ce8a
rekey linux mono 2018.2.0 build to 2018.1.7
ero-qt 87a26aa
Require alloc for automatic Mono attachment
CryZe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| //! Attachment to an older Linux player whose engine is in the executable, | ||
| //! rather than a separate `UnityPlayer.so` module. | ||
|
|
||
| use super::{profiles, Module}; | ||
| use crate::runtime::mock::{poll_once, with_modules}; | ||
| use std::{task::Poll, vec, vec::Vec}; | ||
|
|
||
| const RUNTIME: u64 = 0x7F00_0000_0000; | ||
| #[cfg(feature = "alloc")] | ||
| const EXECUTABLE: u64 = 0x7F00_0010_0000; | ||
|
|
||
| // The real Unity 5.6.7f1 Linux legacy-Mono fixture ships this libmono.so ID | ||
| // and no UnityPlayer.so. The process memory below is synthetic: it provides | ||
| // a GNU note, the assembly export and its getter, but does not run Unity. | ||
| const BUILD_ID: [u8; 20] = [ | ||
| 0xC1, 0xA5, 0x3E, 0xA7, 0x10, 0x9A, 0x2D, 0xA5, 0x82, 0x20, 0xAB, 0x30, 0xF4, 0xCA, 0xB7, 0xC8, | ||
| 0xCE, 0x8F, 0x38, 0x13, | ||
| ]; | ||
|
|
||
| fn put(image: &mut [u8], at: usize, bytes: &[u8]) { | ||
| image[at..at + bytes.len()].copy_from_slice(bytes); | ||
| } | ||
|
|
||
| fn runtime() -> Vec<u8> { | ||
| let mut image = vec![0; 0x2000]; | ||
| put(&mut image, 0, b"\x7fELF"); | ||
| image[4..7].copy_from_slice(&[2, 1, 1]); | ||
| put(&mut image, 0x10, &3_u16.to_le_bytes()); | ||
| put(&mut image, 0x12, &0x3E_u16.to_le_bytes()); | ||
| put(&mut image, 0x20, &0x40_u64.to_le_bytes()); | ||
| put(&mut image, 0x36, &56_u16.to_le_bytes()); | ||
| put(&mut image, 0x38, &3_u16.to_le_bytes()); | ||
| put(&mut image, 0x40, &1_u32.to_le_bytes()); // PT_LOAD | ||
| put(&mut image, 0x60, &0x2000_u64.to_le_bytes()); | ||
| put(&mut image, 0x68, &0x2000_u64.to_le_bytes()); | ||
| put(&mut image, 0x78, &4_u32.to_le_bytes()); // PT_NOTE | ||
| put(&mut image, 0x88, &0x200_u64.to_le_bytes()); | ||
| put(&mut image, 0x98, &0x24_u64.to_le_bytes()); | ||
| put(&mut image, 0xA0, &0x24_u64.to_le_bytes()); | ||
| put(&mut image, 0xB0, &2_u32.to_le_bytes()); // PT_DYNAMIC | ||
| put(&mut image, 0xC0, &0x300_u64.to_le_bytes()); | ||
| put(&mut image, 0xD0, &0x30_u64.to_le_bytes()); | ||
| put(&mut image, 0xD8, &0x30_u64.to_le_bytes()); | ||
| put(&mut image, 0x200, &4_u32.to_le_bytes()); | ||
| put(&mut image, 0x204, &20_u32.to_le_bytes()); | ||
| put(&mut image, 0x208, &3_u32.to_le_bytes()); | ||
| put(&mut image, 0x20C, b"GNU\0"); | ||
| put(&mut image, 0x210, &BUILD_ID); | ||
| for (slot, (tag, value)) in [(6_u64, RUNTIME + 0x400), (5, RUNTIME + 0x500), (10, 0x80)] | ||
| .into_iter() | ||
| .enumerate() | ||
| { | ||
| put(&mut image, 0x300 + slot * 16, &tag.to_le_bytes()); | ||
| put(&mut image, 0x308 + slot * 16, &value.to_le_bytes()); | ||
| } | ||
| put(&mut image, 0x418, &1_u32.to_le_bytes()); // second Elf64_Sym name | ||
| put(&mut image, 0x420, &0x800_u64.to_le_bytes()); // symbol value | ||
| put(&mut image, 0x428, &0x100_u64.to_le_bytes()); // symbol size | ||
| put(&mut image, 0x430, &0x80_u32.to_le_bytes()); // terminate symbol walk | ||
| put(&mut image, 0x501, b"mono_assembly_foreach\0"); | ||
| put(&mut image, 0x800, &[0x48, 0x8B, 0x3D]); | ||
| put(&mut image, 0x803, &0x1F9_i32.to_le_bytes()); // global at 0xA00 | ||
| image | ||
| } | ||
|
|
||
| #[test] | ||
| fn an_explicit_profile_needs_neither_a_player_nor_alloc() { | ||
| let runtime = runtime(); | ||
| with_modules( | ||
| &[(RUNTIME, &runtime)], | ||
| &[("libmono.so", RUNTIME, runtime.len() as u64)], | ||
| |process| { | ||
| let profile = profiles::UNITY_5_6_0F1_LINUX_MONO_X86_64; | ||
| let attached = Module::attach(process, profile).unwrap(); | ||
| assert_eq!(attached.profile, profile); | ||
| let Poll::Ready(attached) = poll_once(Module::wait_attach(process, profile)) else { | ||
| panic!("the explicit profile should attach immediately"); | ||
| }; | ||
| assert_eq!(attached.profile, profile); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| #[cfg(feature = "alloc")] | ||
| #[test] | ||
| fn an_unknown_legacy_runtime_uses_the_executables_version() { | ||
| let runtime = runtime(); | ||
| let mut executable = vec![0; 0x2000]; | ||
| let version = b"\x005.6.7f1\0"; | ||
| put(&mut executable, 0x100, version); | ||
| with_modules( | ||
| &[(EXECUTABLE, &executable), (RUNTIME, &runtime)], | ||
| &[ | ||
| ("fixture", EXECUTABLE, executable.len() as u64), | ||
| ("libmono.so", RUNTIME, runtime.len() as u64), | ||
| ], | ||
| |process| { | ||
| // Ensure this goes through version detection, not a known-ID match. | ||
| assert!(super::linux_builds::find(&BUILD_ID).is_none()); | ||
| assert_eq!( | ||
| Module::unity_version(process, super::BinaryFormat::ELF), | ||
| Some((5, 6, 7, 0)) | ||
| ); | ||
| let profile = profiles::UNITY_5_6_0F1_LINUX_MONO_X86_64; | ||
| let attached = Module::attach_auto_detect(process).unwrap(); | ||
| assert_eq!(attached.profile, profile); | ||
| let Poll::Ready(attached) = poll_once(Module::wait_attach_auto_detect(process)) else { | ||
| panic!("the executable's version should allow automatic attachment"); | ||
| }; | ||
| assert_eq!(attached.profile, profile); | ||
| }, | ||
| ); | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.