I was looking into a lib file provided by some SDK, I need to extract lib by architecture. The first choice was the super 7-Zip which can extract almost every file on the Earth, but unfortunately files cannot be recognized by Hopper/IDA.
Here we go on OS X 10.9.
file
1 2 3 4 5 |
$ /usr/bin/file libXXX.a libXXX.a: Mach-O universal binary with 3 architectures libXXX.a (for architecture armv7): current ar archive random library libXXX.a (for architecture armv7s): current ar archive random library libXXX.a (for architecture i386): current ar archive random library |
otool
Display all architectures and object files
1 |
$ otool -L libXXX.a |
lipo
Display architectures
1 2 |
$ lipo -info libXXX.a Architectures in the fat file: libXXX.a are: armv7 armv7s i386 |
Display architecture details
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
lipo -detailed_info libXXX.a Fat header in: libXXX.a fat_magic 0x00000000 nfat_arch 3 architecture armv7 cputype (12) cpusubtype cpusubtype (9) offset 00 size 000000 align 2^2 (4) architecture armv7s cputype (12) cpusubtype cpusubtype (11) offset 000000 size 000000 align 2^2 (4) architecture i386 cputype CPU_TYPE_I386 cpusubtype CPU_SUBTYPE_I386_ALL offset 000000 size 000000 align 2^2 (4) |
Extract file by arch
output is still a universal binary file
1 |
$ lipo -extract i386 libXXX.a -output libXXX/libXXX.i386 |
Extract file by arch
output is an archive file
1 |
$ lipo -thin i386 libXXX.a -output libXXX/libXXX.i386 |
ar
Extract all obj files
Input file must be an archive file.
1 |
$ ar -x libXXX.i386 |
TBC.
Mac OS X Command line tools for Application Analysis by @sskaje: https://sskaje.me/2013/10/mac-os-x-command-line-tools-for-application-analysis/
Link to this post!