locked
Data varible in ml64 asm to be used in cpp dll RRS feed

  • Question

  • How to get a variable declared in asm file to be accessible in a cpp dll? Linker complains Error LNK2001 unresolved external symbol "__int64 qwa" (?qwa@@3_JA) adll_t0 and warns that LNK4078 multiple 'sdata' sections found with different attributes (D0500040) adll D:\c\vs2017\adll\adll\adlla.obj. I've tried PUBLIC qwa and /Zf a, and all functions in asm work as expected.

    asm

    sdata SEGMENT    read write shared
     qwa dq 123456789abcdefh
    sdata ends

    dll

    pragma data_seg("sdata")
    ADLL_API volatile unsigned int uix_ini = -1;
    ADLL_API volatile unsigned int ithread = -1;
    extern _int64 qwa;
    #pragma data_seg()
    #pragma comment(linker, "/Section:sdata,RWS")

    Thursday, January 31, 2019 6:31 AM

Answers

All replies

    • Proposed as answer by Richard MuellerMVP Thursday, January 31, 2019 10:51 AM
    • Unproposed as answer by mwindham Thursday, January 31, 2019 1:30 PM
    • Proposed as answer by Guido Franzke Friday, February 1, 2019 6:53 AM
    Thursday, January 31, 2019 7:04 AM
  • Another option would be to ask here:

    https://stackoverflow.com/questions/10179933/asm-masm-nasm-fasm


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Thursday, January 31, 2019 10:52 AM
  • I feel that it is Microsoft's responsibility to address issues in documentation and functionality of its products, and considering marketing claims for MSDN about priority forum support in subscriptions, I would expect an answer that solves the problem. The suggestion to post elsewhere is good advice and perhaps the best advice. MASM needs some attention by Microsoft in x64 examples and documentation, and a user question is at least one hint of what would be interesting.  
    • Edited by mwindham Thursday, January 31, 2019 1:50 PM
    Thursday, January 31, 2019 1:49 PM
  • In order to get the priority support you'll need to post on topic in one of these forums.

    https://blogs.msdn.microsoft.com/msdnts/2015/12/27/priority-subscriber-support-in-msdn-forums/

     The closest to on topic, in this list, to me look like the two C++ forums

     There's also the new microsoft partner forums here but since the move to new location there's almost no one replying to threads there.

    https://www.microsoftpartnercommunity.com/

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.



    Thursday, January 31, 2019 2:09 PM
  • Thanks, I was unaware of the "reorganization" of  forums into paid and unpaid monitoring.
    Thursday, January 31, 2019 3:31 PM
  • You're welcome.

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Thursday, January 31, 2019 3:34 PM
  • I try to stay away from def-files, but

    One solution was to make def-file

    $(ProjectDir)adll.def as

    EXPORTS

    qwa DATA

    qwa2 DATA

    asm:

    PUBLIC qwa, qwa2 ;  /Cp,too

    .data

    sdata SEGMENT read write shared

    qwa qword 123456789abcdefh

    sdata ends

    qwa2 dq 8989ababcdcdefefh

    .code

    addl.h:

    extern "C" ADLL_API _int64 qwa;

    extern "C" ADLL_API _int64 qwa2;

    addl.cpp

    #pragma data_seg("sdata")

    //....

    ADLL_API volatile unsigned int ithread = -1;

    extern "C" ADLL_API _int64 qwa;

    #pragma data_seg()

    #pragma comment(linker, "/Section:sdata,RWS")

    extern _int64 qwa2;

    RWS section still complaining

    adlla.obj : warning LNK4078: multiple 'sdata' sections found with different attributes (D0500040)

    but working 

    Thursday, January 31, 2019 6:23 PM