This is a bit of an odd link. The linked file doesn't really do much of anything -- just opens it and checks to make sure the magic number is valid, essentially. The actual file reader is at https://github.com/afrighetto/Mach-O/blob/master/parser/mach...
HN is funny sometimes. A 50-line C file that reads a Mach-O header hits the front page, but last week my new tool for reading ELF/Mach-O binaries and showing size profiles didn't. (http://blog.reverberate.org/2016/11/07/introducing-bloaty-mc...) Oh well, c'est la vie. :)
4 comments
[ 22.9 ms ] story [ 25.4 ms ] threadFWIW, here is the ELF parser from Bloaty; I'm happy with how it turned out (the first 400 lines are the ELF parser): https://github.com/google/bloaty/blob/master/src/elf.cc