Unknown cpu type when compiling OpenSSL FIPS Capable libraries for arm64 or arm7s

I can successfully (at least without warnings and with the resulting .a files) compile for arm7, x86_64 and i386.

When I compile for arm64 I get Unknown cpu type 100000c, no adjustments made

. When I compile for arm7s I get Unknown cpu type 100000c, no adjustments made

. script for these two architectures that are modified and use environment scripts from https://github.com/noloader/openssl-1.0.1i-ios below, including arm7, which works for both arm7s and arm64, and then a log tail for arm64. The scripts build non-fips libraries successfully before modifying. the incore_macho and fips containers are pre-generated and referenced by this script. I created the fips canisters in a similar manner, modifying the instructions from the IOS OpenSSL FIPS 2.0 User Guide app, which is incredibly out of date and doesn't work on its own. How can one compile a FIPS compliant library for these two platforms?

Edit:

I see that libssl.a and libcrypto.a are indeed built and have the correct architectures, but incore_macho returns an identical error Unknown cpu type

.

Update:

Using a copy of incore_macho updated for armv7 from @jww at https://github.com/noloader/incore_macho it now compiles without error for arm7, so I'm now guessing that core_macho might need to be updated for arm64. It can be done?

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

      

output tail for 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

      

+3


source to share


2 answers


It will work if you add this to cpu_adjustment []

CPU_TYPE_ARM64,   CPU_SUBTYPE_ARM64_ALL,  12, 12 ,

      

For reference:



#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)

      

Finding the setting was fun .; -)

+3


source


I previously modified the processor type so it is executable. You may also need to change the CPU setting. You need to add an entry to cpu_adjustment [] in incore_macho.c and cputpe



I think for arm64 it is CPU_SUBTYPE_ARM64_V8 I don't know the setting. Please let us know if you do.

0


source







All Articles