为arm64或arm7s编译OpenSSL FIPS Capable库时,未知的cpu类型

时间:2014-09-10 15:05:53

标签: ios openssl fips

我可以成功(至少没有警告和产生的.a文件)编译arm7,x86_64和i386。

当我为arm64编译时,我得到Unknown cpu type 100000c, no adjustments made。当我编译arm7s时,我得到Unknown cpu type 100000c, no adjustments made。这两个体系结构的脚本是从https://github.com/noloader/openssl-1.0.1i-ios修改并使用来自https://github.com/noloader/incore_macho的环境脚本,包括arm7,它可以工作,arm7s和arm64,后面是arm64的日志尾部。这些脚本在修改之前成功构建了非fips库。 incore_macho和fips canisters是从此脚本预生成和引用的。我通过修改来自OpenSSL FIPS 2.0用户指南iOS附录的指令类似地创建了fips canisters,这些指令非常过时并且不能自行运行。如何为这两个平台编译支持FIPS的库?

编辑:

我看到libssl.a和libcrypto.a实际上已经创建并具有正确的体系结构,但incore_macho返回相同的Unknown cpu type错误。

更新

在{{3}}使用@jww为armv7更新的incore_macho副本,它现在可以编译arm7s没有错误,所以我现在假设可能需要为arm64更新core_macho。可以这样做吗?

sed -i "" 's|\"iphoneos-cross\"\,\"llvm-gcc\:-O3|\"iphoneos-cross\"\,\"clang\:-Os|g' Configure
sed -i "" 's/CC= cc/CC= clang/g' Makefile.org
sed -i "" 's/CFLAG= -O/CFLAG= -Os/g' Makefile.org
sed -i "" 's/MAKEDEPPROG=makedepend/MAKEDEPPROG=$(CC) -M/g' Makefile.org

export LANG=$OLD_LANG
export CC=clang
export IOS_INSTALLDIR="/usr/local/ssl/ios"
unset OPENSSLDIR

################################################################
# Third, build ARMv7
echo "****************************************"
THIS_ARCH=armv7
unset CROSS_ARCH

. ./setenv-ios-$THIS_ARCH.sh
export HOSTCC=/usr/bin/cc
export HOSTCFLAGS="-arch i386"
export FIPS_SIG="/tmp/incore_macho"

./config fips -no-ssl2 -no-ssl3 -no-asm -no-shared -no-hw -no-engine --with-fipsdir="/tmp/openssl fips-2.0.1-iOS-${THIS_ARCH}" --openssldir=$IOS_INSTALLDIR
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.1 !" "Makefile"
make clean 2>&1>/dev/null && make all
mkdir $THIS_ARCH
\cp ./libcrypto.a $THIS_ARCH/libcrypto.a
\cp ./libssl.a $THIS_ARCH/libssl.a

################################################################
# Fourth, build ARMv7s
echo "****************************************"
THIS_ARCH=armv7s
unset CROSS_ARCH

. ./setenv-ios-$THIS_ARCH.sh
export HOSTCC=/usr/bin/cc
export HOSTCFLAGS="-arch i386"
export FIPS_SIG="/tmp/incore_macho"

./config fips -no-ssl2 -no-ssl3 -no-asm -no-shared -no-hw -no-engine --with-fipsdir="/tmp/openssl-fips-2.0.1-iOS-${THIS_ARCH}" --openssldir=$IOS_INSTALLDIR
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.1 !" "Makefile"
make clean 2>&1>/dev/null && make all
mkdir $THIS_ARCH
\cp ./libcrypto.a $THIS_ARCH/libcrypto.a
\cp ./libssl.a $THIS_ARCH/libssl.a

################################################################
# Fifth, build ARM64
#echo "****************************************"
THIS_ARCH=arm64
unset CROSS_ARCH

. ./setenv-ios-$THIS_ARCH.sh
export HOSTCC=/usr/bin/cc
export HOSTCFLAGS="-arch i386"
export FIPS_SIG="/tmp/incore_macho"

./config fips -no-ssl2 -no-ssl3 -no-asm -no-shared -no-hw -no-engine --with-fipsdir="/tmp/openssl-fips-2.0.1-iOS-${THIS_ARCH}" --openssldir=$IOS_INSTALLDIR
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.1 !" "Makefile"
make clean 2>&1>/dev/null && make all
mkdir $THIS_ARCH
\cp ./libcrypto.a $THIS_ARCH/libcrypto.a
\cp ./libssl.a $THIS_ARCH/libssl.a

arm64的输出尾部:

shlib_target=; if [ -n "" ]; then \
        shlib_target="darwin-shared"; \
    elif [ -n "libcrypto" ]; then \
      FIPSLD_CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"; CC=/tmp/openssl-fips-2.0.1-iOS-arm64/bin/fipsld; export CC FIPSLD_CC; \
    fi; \
    LIBRARIES="-L.. -lssl  -L.. -lcrypto" ; \
    make -f ../Makefile.shared -e \
        APPNAME=openssl OBJECTS="openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o" \
        LIBDEPS="-Wl,-search_paths_first $LIBRARIES " \
        link_app.${shlib_target}
( :; LIBDEPS="${LIBDEPS:--Wl,-search_paths_first -L.. -lssl  -L.. -lcrypto }"; LDCMD="${LDCMD:-/tmp/openssl-fips-2.0.1-iOS-arm64/bin/fipsld}"; LDFLAGS="${LDFLAGS:--isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -miphoneos-version-min=7.1  -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch arm64 -Os -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -fomit-frame-pointer -fno-common -I/tmp/openssl-fips-2.0.1-iOS-arm64/include}"; LIBPATH=`for x in $LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o ${LIBDEPS} )
Unknown cpu type 100000c, no adjustments made

2 个答案:

答案 0 :(得分:3)

如果将其添加到cpu_adjustment []

,它将起作用
CPU_TYPE_ARM64,   CPU_SUBTYPE_ARM64_ALL,  12, 12 ,

供参考:

#define CPU_ARCH_ABI64  0x01000000      /* 64 bit ABI */

#define CPU_TYPE_ARM64          (CPU_TYPE_ARM | CPU_ARCH_ABI64)

/*
 *  ARM64 subtypes
 */
#define CPU_SUBTYPE_ARM64_ALL           ((cpu_subtype_t) 0)

找到调整很有趣。 ; - )

答案 1 :(得分:0)

之前我修改了CPU类型,所以它是可行的。您可能还需要修改CPU调整。您需要在incore_macho.c和cputype

中向cpu_adjustment []添加一个条目

我认为对于arm64它是CPU_SUBTYPE_ARM64_V8我不知道调整。如果你让它工作,请告诉我们