3 ms·
Hi everyone! This post is a writeup of some curiosities from the course of developing an iOS app simulator from scratch. Like with any simulator, it was immens
by codyd51 3y ago
Hi everyone! This post is a writeup of some curiosities from the course of developing an iOS app simulator from scratch.
Like with any simulator, it was immensely gratifying watching third-party code run in an entirely controlled virtual environment!
This project also got me very familiar with some unintuitive AArch64 addressing rules, and taught me the internals of how funny Objective-C constructors that accept variadic arguments lists are handled.
In one late-night push, I managed to get the real CoreFoundation library dynamically loaded and running, which meant that the real standard library was able to create bona-fide Objective-C objects!
This post also goes into some fun bugs I created for myself, such as the simulator skipping over undefined functions resulting in an infinite loop when simulated code tried to abort(). I hope it's fun to follow along with, and thanks for reading!
- solarexplorer 3y agoVery nice! Thanks for sharing! Getting to the point where you can run other people’s code is a great achievement! I have one question: Did you really implement this in Python? Why not C++ or Rust?
- codyd51 3y agoThank you very much! Yes, this was all in Python. This simulator was a bit unique in that there was no live user interaction, and therefore no realtime required. Overall, performance wasn't too much of a concern. More particularly, I built this on top of strongarm, a Mach-O analysis library I had already written in Python. My employer encouraged us to write things in Python so that there was lower cognitive overhead for people to see each other's projects. This was more of an off-time passion project, but I still took the advice.
- JackYoustra 3y agoObjective-C stuff is so so weird. I often remember mike ash's post about arc runtime optimizations and how whole retain/release pairs can be elided when they're across functional boundaries. Is there a repo? Also - any reason why such old OSes?
- pjmlp 3y agoIt was a very interesting read, great piece of work.
- codyd51 3y agoThat’s really kind feedback, thank you!