Actually, that section (specifically, the DQ line) places a single
pointer constant in a data section with the "magic" name ".CRT$XCU".

Background:

The Microsoft linker, upon seeing a $ sign in a section name will
merge this section with all other sections name ".CRT" or ".CRT$whatever", but only after it has ordered the layout of that
section alphabetically according to the non-truncated section name.
Thus the constants in .obj section ".CRT$XCU" will be placed between
anything in sections ".CRT$XCT" (or less) and anything in sections
".CRT$XCV" (or more).

The Microsoft C runtime startup code contains declarations for dummy
NULL variables in sections ".CRT$XCA" and ".CRT$XCZ" and a loop
which treats the data between those sections (including the DQ placed
there by this ASM file and any constructors for C++ global variables
etc.) as an array of function pointers to be called before
invoking main().  A similar method (with a different letter after X
is used for functions to call after main() returns or during a call to
exit()).

The above description matches at least the C runtime in Visual Studio
2005 (look at the files VC\CRT\src\crt0init.c and VC\CRT\src\crt0dat.c).

Error message analysis:

The warning complains that something in section .CRT has been given
the section attributes 0x60000020 (meaning Read/Execute, contains code),
even though the rest of the file section it ultimately goes into (".rdata") has attributes 0x40000040 (meaning Read, contains initialized data).

Thus my guess is that the line "section    .CRT$XCU" is lacking
some keywords to tell the assembler to mark that section as
read-only data, not code.  Unfortunately, I am not sure of the
syntax to do that in the x86_64 version of MASM.


On 23-09-2010 15:09, Jack Zhang wrote:
According to my understanding, that section is just a declaration of an
external function. The section is needed to be there only if the
function is called in the x86_64cpuid.asm. So, I don't think it will
affect anything. In fact, my x64 version build runs perfectly. (I am
using openssl 1.0.0 and then 1.0.0a)



On Thu, Sep 23, 2010 at 7:12 AM, per fry kenvall <per...@got.wmdata.se
<mailto:per...@got.wmdata.se>> wrote:

    Hi,

    Thanks for your suggestion! But as far as I see, the assembler code
    in x86_64cpuid.asm _is_ the reference to OPENSSL_cpuid_setup! The
    runtime will call the functions given in the .CRT$XCU section before
    calling the main() entry. And it seems to me that the
    OPENSSL_cpuid_setup function in crypto/cryptlib.c does have useful
    code on Windows platforms, and so should be called, shouldn't it? It
    initializes a static variable with some processor specific info,
    whose value may be taken via the OPENSSL_ia32cap_loc() function.

    I tried printf("%lu", *OPENSSL_ia32cap_loc()), 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. What's the impact of this? Isn't it a bug?

    Cheers,
    Per

    Jack Zhang wrote:

        I had got the same problem. I just simply deleted that section
          EXTERN    OPENSSL_cpuid_setup
          section    .CRT$XCU
              ALIGN    8
              DQ    OPENSSL_cpuid_setup

          section    .text code align=64

        from the asm file because the extern OpenSSL_cpuid_setup is
        never referenced.

        Good luck

        On Tue, Sep 21, 2010 at 9:57 AM, perfry wrote:

            Hi,

            I've built 1.0.0a on Windows 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


            The linker command can be deduced from the following:
              Creating temporary file
        "c:\utv\ccbas4\ccbase\x64\Release\RSP0000132444832.rsp" with
        contents
              [
              /OUT:"../deploy/execs/x64/Release/etnode.exe" /INCREMENTAL:NO
            /MANIFEST
            /MANIFESTFILE:"x64/Release\etnode.exe.intermediate.manifest"
            /DELAYLOAD:"oci.dll" /DEBUG
            /PDB:"../deploy/execs/x64/Release/etnode.pdb" /SUBSYSTEM:CONSOLE
            /LTCG psapi.lib odbc32.lib odbccp32.lib WS2_32.LIB ADVAPI32.LIB
            GDI32.LIB USER32.LIB dbghelp.lib
            ../snibu/logging-log4cxx/msvc/lib/x64/Release/log4cxxs.lib
            ../snibu/openssl-1.0.0a/x64/Release/lib/ssleay32.lib
            ../snibu/openssl-1.0.0a/x64/Release/lib/libeay32.lib
            ../snibu/oracle/x64/instantclient_10_2/sdk/lib/msvc/oci.lib
            ../snibu/zlib/msvc/lib/x64/Release/zlibstat.lib kernel32.lib
            user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
            shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
            odbccp32.lib DelayImp.lib

        ".\x64\Release\CCcServApp.obj"
              ...
        ".\x64\Release\Bas4Bridge.obj"
              ]
              Creating command line "link.exe
            @c:\utv\ccbas4\ccbase\x64\Release\RSP0000132444832.rsp /NOLOGO
            /ERRORREPORT:PROMPT"


            I've done the following to build openssl:
              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
            ...


            Could somebody help me solve this warning, it seems to me that
            OPENSSL_cpuid_setup will not be executed.


            Best regards,
            Per Frykenvall

          ______________________________________________________________________
            OpenSSL Project http://www.openssl.org
            User Support Mailing List openssl-users@openssl.org
        <mailto:openssl-users@openssl.org>
        <mailto:openssl-users@openssl.org
        <mailto:openssl-users@openssl.org>>
            Automated List Manager majord...@openssl.org
        <mailto:majord...@openssl.org> <mailto:majord...@openssl.org
        <mailto:majord...@openssl.org>>



    ______________________________________________________________________
    OpenSSL Project http://www.openssl.org
    User Support Mailing List openssl-users@openssl.org
    <mailto:openssl-users@openssl.org>
    Automated List Manager majord...@openssl.org
    <mailto:majord...@openssl.org>



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to