我正在尝试建立和运行自托管的越狱iOS设备(Corellium Virtual设备(。进行引导程序,可以构建并运行常规二进制文件。但是,Go档案无法构建,因为AR不起作用:
$ dpkg -S /usr/bin/clang /usr/bin/ar /usr/bin/libtool
org.coolstar.llvm-clang64: /usr/bin/clang
org.coolstar.cctools: /usr/bin/ar
org.coolstar.cctools: /usr/bin/libtool
$ apt policy org.coolstar.cctools org.coolstar.llvm-clang64
org.coolstar.cctools:
Installed: 895
Candidate: 895
Version table:
*** 895 500
500 http://apt.thebigboss.org/repofiles/cydia stable/main iphoneos-arm Packages
100 /Library/dpkg/status
org.coolstar.llvm-clang64:
Installed: 5.0.1-2
Candidate: 5.0.1-2
Version table:
*** 5.0.1-2 500
500 http://apt.thebigboss.org/repofiles/cydia stable/main iphoneos-arm Packages
100 /Library/dpkg/status
$ ../bin/go build -buildmode=c-archive -ldflags="-v" -work ../misc/ios/detect.go
WORK=/tmp/go-build734936238
# command-line-arguments
HEADER = -H1 -T0x2000 -R0x1000
0.00 deadcode
0.05 symsize = 0
0.08 pclntab=740717 bytes, funcdata total 185492 bytes
0.08 dodata
0.08 symsize = 0
0.08 symsize = 0
0.09 dynreloc
0.09 dwarf
0.12 asmb
0.13 datblk
0.14 reloc
0.20 sym
0.22 header
archive: ar -q -c -s $WORK/b001/exe/a.out.a /tmp/go-link-569975294/go.o /tmp/go-link-569975294/000000.o /tmp/go-link-569975294/000001.o /tmp/go-link-569975294/000002.o /tmp/go-link-569975294/000003.o /tmp/go-link-569975294/000004.o /tmp/go-link-569975294/000005.o /tmp/go-link-569975294/000006.o /tmp/go-link-569975294/000007.o /tmp/go-link-569975294/000008.o /tmp/go-link-569975294/000009.o /tmp/go-link-569975294/000010.o /tmp/go-link-569975294/000011.o /tmp/go-link-569975294/000012.o /tmp/go-link-569975294/000013.o /tmp/go-link-569975294/000014.o
/var/mobile/go-tip/pkg/tool/darwin_arm64/link: running ar failed: exit status 1
fatal error: ar: can't find or exec: /usr/bin/arm64-apple-darwin14-ranlib (No such file or directory)
ar: internal ranlib command failed
乐观,我尝试与Ranlib进行链接:
# ln -s /usr/bin/ranlib /usr/bin/arm64-apple-darwin14-ranlib
$ ../bin/go build -buildmode=c-archive -ldflags="-v" -work ../misc/ios/detect.go
WORK=/tmp/go-build239621581
# command-line-arguments
HEADER = -H1 -T0x2000 -R0x1000
0.00 deadcode
0.06 symsize = 0
0.08 pclntab=740717 bytes, funcdata total 185492 bytes
0.08 dodata
0.09 symsize = 0
0.09 symsize = 0
0.09 dynreloc
0.10 dwarf
0.12 asmb
0.13 datblk
0.15 reloc
0.20 sym
0.22 header
archive: ar -q -c -s $WORK/b001/exe/a.out.a /tmp/go-link-618780113/go.o /tmp/go-link-618780113/000000.o /tmp/go-link-618780113/000001.o /tmp/go-link-618780113/000002.o /tmp/go-link-618780113/000003.o /tmp/go-link-618780113/000004.o /tmp/go-link-618780113/000005.o /tmp/go-link-618780113/000006.o /tmp/go-link-618780113/000007.o /tmp/go-link-618780113/000008.o /tmp/go-link-618780113/000009.o /tmp/go-link-618780113/000010.o /tmp/go-link-618780113/000011.o /tmp/go-link-618780113/000012.o /tmp/go-link-618780113/000013.o /tmp/go-link-618780113/000014.o
/var/mobile/go-tip/pkg/tool/darwin_arm64/link: running ar failed: exit status 1
/usr/bin/arm64-apple-darwin14-ranlib: archive member: $WORK/b001/exe/a.out.a(go.o) offset in archive not a multiple of 8 (must be since member is an 64-bit object file)
fatal error: ar: fatal error in /usr/bin/arm64-apple-darwin14-ranlib
我什至切换到使用libtool:
$ ../bin/go build -buildmode=c-archive -ldflags="-v" -work ../misc/ios/detect.go
WORK=/tmp/go-build502332895
# command-line-arguments
HEADER = -H1 -T0x2000 -R0x1000
0.00 deadcode
0.04 symsize = 0
0.08 pclntab=740717 bytes, funcdata total 185492 bytes
0.08 dodata
0.08 symsize = 0
0.09 symsize = 0
0.09 dynreloc
0.10 dwarf
0.12 asmb
0.14 datblk
0.15 reloc
0.20 sym
0.22 header
archive: libtool -static -o $WORK/b001/exe/a.out.a /tmp/go-link-320669019/go.o /tmp/go-link-320669019/000000.o /tmp/go-link-320669019/000001.o /tmp/go-link-320669019/000002.o /tmp/go-link-320669019/000003.o /tmp/go-link-320669019/000004.o /tmp/go-link-320669019/000005.o /tmp/go-link-320669019/000006.o /tmp/go-link-320669019/000007.o /tmp/go-link-320669019/000008.o /tmp/go-link-320669019/000009.o /tmp/go-link-320669019/000010.o /tmp/go-link-320669019/000011.o /tmp/go-link-320669019/000012.o /tmp/go-link-320669019/000013.o /tmp/go-link-320669019/000014.o
/var/mobile/go-tip/pkg/tool/darwin_arm64/link: running libtool failed: signal: segmentation fault
现在,AR(与Symlinked Ranlib一起(甚至在简单的对象文件上失败:
$ cat blah.c
int blah() {
return 0;
}
$ clang -c blah.c
$ ar -q -c -s blah.a blah.o
/usr/bin/arm64-apple-darwin14-ranlib: archive member: blah.a(blah.o) offset in archive not a multiple of 8 (must be since member is an 64-bit object file)
libtool作品:
$ libtool -static -o blah.a blah.o
,但如上所述,segfault在更复杂的对象文件上。
GO已经可以使用Xcode AR工具成功创建档案。失败的只是iOS本机" CCTOOLS"版本。
我使用LLVM-AR解决了问题。命令行标志略有不同,但至少我现在有一个工作档案。