lipo指令 及 ar -x

lipo指令是Mac上的一款处理Binaries的工具,大致哪些用法在终端输入lipo查看:

-archs
    -create [-arch_blank <arch_type>]
    -detailed_info
    -extract <arch_type> [-extract <arch_type> ...]
    -extract_family <arch_type> [-extract_family <arch_type> ...]
    -info
    -remove <arch_type> [-remove <arch_type> ...]
    -replace <arch_type> <file_name> [-replace <arch_type> <file_name> ...]
    -thin <arch_type>
    -verify_arch <arch_type> ...
  options are one or more of:
    -arch <arch_type> <input_file>
    -hideARM64
    -output <output_file>
    -segalign <arch_type> <alignment>

lipo -info xxx,查看当前可执行文件的架构组成,是否是胖二进制,由哪些CPU架构组成。

Non-fat file: xxxx is architecture: x86_64 arm64

lipo -thin ,从胖二进制可执行文件中剥离出想要的CPU架构,例如下面是剥离x86_64, 生成xxx_x86_64可执行文件

lipo -thin x86_64 xxx -output xxx_x86_64

-> xxxxx $ lipo -info xxx_x86_64 
Non-fat file: xxx_x86_64 is architecture: x86_64

lipo -remove,从胖二进制可执行文件移除不想要的CPU架构,这个和lipo -thin非常相似,不同点是剥离出去的架构,依然是胖二进制类型。例如下面生成的xxx_arm64可执行文件,用lipo -info查看依然是胖二进制可执行文件 fat file

lipo -remove arm64 xxx -output xxx_arm64

-> xxxxx $ lipo -info xxx_arm64
Architectures in the fat file: xxx_arm64 are: arm64 

 

lipo -create 合并二进制
lipo -create a二进制 b二进制 -output c二进制

 

lipo -remove执行结果,会导致在执行ar -x 指令的时候无法执行 报错如下:

ar: libBBAVendorAd_arm64 is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: libBBAVendorAd_arm64: Inappropriate file type or format

必须使用Non-fat file才可以,补充ar -x指令是摘取可执行文件内部的文件组成,例如在iOS中就是拿到可执行文件内部的所有.o文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值