Bug report
OpenSSL 1.0.0a
Windows x64 (static library)

I have problems with warnings from the linker on Windows, indicating 
that the initializer OPENSSL_cpuid_setup will not be called. I've built 1.0.0a 
with VS2005, 
using nt.mak to get static libraries.

With x64 I get warnings when linking applications, both openssl.exe and 
test programs like sha1test.exe. A snippet of output from nmake -f 
ms\nt.mak:
       link /nologo /subsystem:console /opt:ref /debug 
/out:out32\openssl.exe @C:\DOCUME~1\FRYKEN~1\LOCALS~1\Temp\nm3B3.tmp

LIBCMT.lib(crt0init.obj) : warning LNK4254: section '.CRT' (60000020) 
merged into '.rdata' (40000040) with different attributes

And when linking our own application on x64/Release platform:
   libeay32.lib(x86_64cpuid.obj) : warning LNK4078: multiple '.CRT' sections 
found with different attributes (60500020)
   libeay32.lib(x86_64cpuid.obj) : warning LNK4210: .CRT section exists; there 
may be unhandled static initializers or terminators


I've done the following to build openssl, on Win XP, Visual Studio 2005:
   cd /d C:\utv\snibu\openssl\x64\release\openssl-1.0.0a
   call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86_amd64
   perl Configure VC-WIN64A --prefix=c:\appl\openssl-1.0.0a\x64\release
   ms\do_win64a.bat
   nmake -f ms\nt.mak
   nmake -f ms\nt.mak install


And the file x86_64cpuid.asm mentioned in the warnings starts with the 
following:
   default    rel
   EXTERN    OPENSSL_cpuid_setup
   section    .CRT$XCU
       ALIGN    8
       DQ    OPENSSL_cpuid_setup

   section    .text code align=64
...



The warning implies that OPENSSL_cpuid_setup will not be called. I 
confirmed this with printf("%lu", *OPENSSL_ia32cap_loc()) in our 
application, which prints out 0 using the x64 code, while printing 
2951479295 using 32-bit code, indicating that OPENSSL_cpuid_setup has 
only been executed with the 32-bit code.


I've tried the following workaround, kindly suggested by Jakob Bohm:

According to the NASM manual at

    http://www.nasm.us/doc/nasmdoc7.html#section-7.5.1

The following change to the generated .asm file should fix this
without having to modify .obj files:

Current:

    section    .CRT$XCU

Fixed:

    section    .CRT$XCU rdata align=8



The workaround seems good. At least the warnings disappeared, and  
*OPENSSL_ia32cap_loc()  is now EFFBFFFF instead of 0.

Could someone fix this permanently in the perl script in crypto/perlasm 
that generates the section directive?

Best regards,
Per Frykenvall,
Software developer,
Logica,
Sweden


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [email protected]

Reply via email to