为二进制文件添加com.apple.security.app-sandbox沙箱权限后触发illegal hardware instruction崩溃的问题求助
为二进制文件添加com.apple.security.app-sandbox沙箱权限后触发illegal hardware instruction崩溃的问题求助
我最近在尝试把一个通过DMG安装的应用迁移到App Store,需要验证它在沙箱模式下是否能正常运行。我的操作思路是先复制应用的二进制文件,移除原有签名,再携带com.apple.security.app-sandbox授权重新签名,但最后签名后的可执行文件一运行就崩溃,报错提示illegal hardware instruction。
为了缩小排查范围,我用最简单的Hello World程序做了复现测试,完整步骤如下:
1. 编写并编译Hello World程序
main.cpp代码:
#include <iostream> int main() { std::cout << "hello,world\n"; return 0; }
编译命令:
clang++ -std=c++20 -O2 -o hello main.cpp
2. 准备沙箱授权文件
entitlements.plist内容:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.security.app-sandbox</key> <true/> </dict> </plist>
3. 重新签名并运行
签名命令(替换<identity>为本地有效的签名身份):
codesign --sign <identity> --timestamp --options runtime --entitlements entitlements.plist hello
运行签名后的程序:
./hello
结果还是触发了同样的illegal hardware instruction崩溃。
我反复检查了操作步骤,实在没发现哪里遗漏。我的设备是Intel芯片的Mac,排除了ARM架构相关的兼容性问题,系统版本为macOS 15.6。有没有大佬能帮忙分析下可能的问题点?
内容来源于stack exchange
相关产品推荐
相关产品推荐

