Building OpenSSL 1.1.1b for WinCE700

田中創樹 sojulibra at gmail.com
Tue Mar 19 07:08:56 UTC 2019


Hello,

I have successfully build OpenSSL 1.1.1b (only libraries, no app) for
WINCE700-ARMV4I, though I don't do any tests. Here is what I did. I hope
original sources will be changed so as there is no need to change.

1. Modify wcecompat.

Add an alias, "_access" for access() in wcecompat io.h as below.
--
#define access _wceaccess
#define _access _wceaccess
--

2. Set Environmental variables

set OSVERSION=WCE700
set PLATFORM=VC-CE
set TARGETCPU=ARMV4I
set WCECOMPAT=C:\Users\dev\tanaka\wcecompat
set LIB=C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\ATLMFC\LIB;C:\Program Files (x86)\Windows CE
Tools\SDKs\YOUR_SDK_NAME\Lib\ARMV4I;C:\Program Files\Microsoft
SDKs\Windows\v6.0A\Lib;C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\ce\lib\ARMV4I;C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\lib
set INCLUDE=C:\Program Files (x86)\Windows CE
Tools\SDKs\YOUR_SDK_NAME\Include\ARMV4I;C:\Program Files (x86)\Microsoft
Visual Studio 9.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual
Studio 9.0\VC\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v6.0A\include;
set Path=C:\WINCE700\sdk\bin\i386\arm;C:\Program Files (x86)\Microsoft
Visual Studio 9.0\Common7\Tools;C:\Program Files (x86)\Microsoft Visual
Studio 9.0\VC\VCPackages;C:\Program Files\Microsoft
SDKs\Windows\v6.0A\bin;C:\cygwin64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program
Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files
(x86)\Microsoft Visual Studio 9.0\VC\BIN;%Path%
set LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\ATLMFC\LIB;"C:\Program Files (x86)\Windows CE
Tools\SDKs\YOUR_SDK_NAME\Lib\ARMV4I";C:\Program Files (x86)\Microsoft
Visual Studio 9.0\VC\lib;C:\Program Files (x86)\Microsoft Visual Studio
9.0\VC\ce\lib\ARMV4I;

3. Configure

(for ARM)(Configurations/windows-makefile.tmpl) Delete a line of
"setargv.obj". setargv.obj in C:\Program Files (x86)\Microsoft Visual
Studio 9.0\VC\lib is for x86 and cannot be linked with ARM objs.

C:\Strawberry\perl\bin\perl Configure no-idea no-mdc2 no-rc5 no-asm no-ssl3
no-stdio no-async no-engine VC-CE

Using full path to specify Strawberry perl. I recommend Strawberry perl
here to avoid error messages, I used 5.24.4.1-32bit.

I added 3 options of "no-stdio" and "no-engine", "no-async". Because..
  * no-stdio: GetStdHandle() and STD_INPUT_HANDLE cannot be used in WinCE.
(used in apps\apps.c)
  * no-engine: Lack of CreatePipe() in WinCE (used in engines\e_dasync.c)
  * no-async: Lack of ConvertFiberToThread() in WinCE (used in
crypto\async\arch\async_win.c)
By "no-stdio" option, we build only libraries. No command line application
are generated.

4. Modify "makefile"

  * Add -D_MSC_VER=1300 in "CFLAGS="
  * In "CNF_CPPFLAGS=", change -I"\$(WCECOMPAT)/include" to
-I$(WCECOMPAT)/include
  * Change CNF_EX_LIBS=3 to CNF_EX_LIBS=ws2.lib crypt32.lib kernel32.lib
$(WCECOMPAT)\lib\wcecompat.lib $(WCECOMPAT)\lib\wcecompatex.lib
corelibc.lib coredll.lib

5. Modify C Source

Comment out a line of "#  define stat    _stat" in
  crypto\conf\conf_def.c
  crypto\rand\randfile.c
  crypto\store\loader_file.c
Comment out a line of "#  define fstat   _fstat" in crypto\rand\randfile.c.

(crypt/init.c 167l and 777l) For lack of GetModuleHandleEx() in CE, Change
"# ifdef DSO_WIN32" to "# if defined(DSO_WIN32) && !defined(_WIN32_WCE)"
-----------------
# ifdef DSO_WIN32
    {
        HMODULE handle = NULL;
        BOOL ret;

        /* We don't use the DSO route for WIN32 because there is a better
way */
        ret = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
-----------------

(crypto\rand\randfile.c 257l) For lack of GetEnvironmentVariableW() in CE,
Change "#if defined(_WIN32) && defined(CP_UTF8)" to "#if defined(_WIN32) &&
defined(CP_UTF8) && !defined(_WIN32_WCE)"

(for ARM)(include\internal\refcount.h)
  * Add "#include <winbase.h>" for InterlockedExchangeAdd().
  * (106l) In function CRYPTO_UP_REF() and CRYPTO_DOWN_REF(), change 2
"_InterlockedExchangeAdd()" to be "InterlockedExchangeAdd()". There is no
_InterlockedExchangeAdd() for non x86 in C:\Program Files (x86)\Windows CE
Tools\SDKs\YOUR_SDK_NAME\Include\Armv4i\winbase.h.

(crypt/threads_win.c 27l) For lack of
InitializeCriticalSectionAndSpinCount() in CE, change
------------------
    /* 0x400 is the spin count value suggested in the documentation */
    if (!InitializeCriticalSectionAndSpinCount(lock, 0x400)) {
        OPENSSL_free(lock);
        return NULL;
    }
------------------
to
------------------
#ifndef _WIN32_WCE
    /* 0x400 is the spin count value suggested in the documentation */
    if (!InitializeCriticalSectionAndSpinCount(lock, 0x400)) {
        OPENSSL_free(lock);
        return NULL;
    }
#else
    InitializeCriticalSection(lock);
#endif
------------------

6. Build

nmake

Then we will get the following artifacts.
  libcrypto.lib
  libcrypto-1_1.dll
  libcrypto-1_1.pdb
  libssl.lib
  libssl-1_1.dll
  libssl-1_1.pdb

Regards,
Soju TANAKA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20190319/693b80b4/attachment.html>


More information about the openssl-users mailing list