After a day of fun: % ./scanmacho -vvv -F"%f %o %M %D %n %i %S %Z" libz.dylib scanelf{,.o} $EPREFIX/usr/lib/libxml2.dylib Format: %f %o %M %D %n %i %S %Z libz.dylib: scanning file {POWERPC,POWERPC_ALL} FILE TYPE CLASS ENDIAN NEEDED INTERP SONAME SIZE libz.dylib MH_DYLIB_STUB POWERPC BE /usr/lib/libgcc_s.1.dylib,/usr/lib/libSystem.B.dylib /usr/lib/libz.1.dylib 28124 libz.dylib: scanning file {POWERPC64,POWERPC_ALL} libz.dylib MH_DYLIB_STUB POWERPC64 BE /usr/lib/libgcc_s_ppc64.1.dylib,/usr/lib/libSystem.B.dylib /usr/lib/libz.1.dylib 28124 libz.dylib: scanning file {I386,POWERPC_603} libz.dylib MH_DYLIB_STUB I386 LE /usr/lib/libgcc_s.1.dylib,/usr/lib/libSystem.B.dylib /usr/lib/libz.1.dylib 28124 libz.dylib: scanning file {X86_64,POWERPC_603} libz.dylib MH_DYLIB_STUB X86_64 LE /usr/lib/libgcc_s.1.dylib,/usr/lib/libSystem.B.dylib /usr/lib/libz.1.dylib 28124 scanelf: scanning file {POWERPC,POWERPC_ALL} scanelf MH_EXECUTE POWERPC BE /Library/Gentoo/usr/lib/gcc/powerpc-apple-darwin8/4.2.1/libgcc_s.1.dylib,/usr/lib/libSystem.B.dylib /usr/lib/dyld 146160 scanelf.o: scanning file {POWERPC,POWERPC_ALL} scanmacho: Mach-O lacks LC_LOAD_DYLIB commands: scanelf.o scanelf.o MH_OBJECT POWERPC BE 200080 /Library/Gentoo/usr/lib/libxml2.dylib: scanning file {POWERPC,POWERPC_970} libxml2.dylib MH_DYLIB POWERPC BE /usr/lib/libSystem.B.dylib,/Library/Gentoo/lib/libz.dylib,/Library/Gentoo/lib/libiconv.2.dylib /Library/Gentoo/usr/lib/libxml2.2.dylib 1712868 I made changes to paxmacho and added scanmacho and macho.h. It isn't perfect yet, but a good step towards some better interoperability with portage and shared libraries on Darwin. The code should compile on other platforms fine too, like scanelf does on Darwin at the moment. I can attach a (bit large) diff if you'd like to review it first.
Approved by solar for all MACHO related files. Please have vapier give the final thumbs up.
i'll review it once you commit it ... i'm assuming you dont touch any common files other than like the Makefile ...
Created attachment 164881 [details] 4-arch FAT Mach-O object (library stub) committed, I attach two Mach-O files which allow you to test scanmacho. First, a FAT library (containing 4 archs)
Created attachment 164882 [details] Mach-O executable (scanmacho itself) a Mach-O executable
this has been committed already a while ago
i finally got around to reviewing the code and i committed style/code cleanups and such ... please check it out and make sure i didnt screw anything up ...
All non-style changes look like they clean up some re-iterating code all the time, which is good. Code still seems to work as expected. Thanks! One suggestion, would it be an idea to ban gnuisms (like strndup) in your `make test` script? Most notably that one breaks on FreeBSD, but on nearly everywhere else too...
strndup() is in POSIX http://www.opengroup.org/onlinepubs/9699919799/functions/strndup.html