Menu

Decorated names in DLLs

Vortex
2011-07-10
2013-04-20
  • Vortex

    Vortex - 2011-07-10

    Hello,

    I am able to create a DLL with the latest JWlink but the exported functions are always decorated. I tried the EXPORT switch to get an undecorated exported symbol but I received the following error message :

    jwlink format windows nt dll file ConsFuncs.obj op implib export StdOut=_StdOut@4
    
    JWlink Version 1.9
    Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
    Source code is available under the Sybase Open Watcom Public License.
    Error! E2093: cannot open 4
    

    Inserting double quotes between _StdOut@4 didn't help too. I am probably not using correctly the EXPORT directive.  Could Japheth or any other member point me in the right way?

    Thanks,

    Vortex

     
  • japheth

    japheth - 2011-07-10

    > Inserting double quotes between _StdOut@4 didn't help too.

    It must be SINGLE quotes - don't ask me why! I'll add this hint to the jwlink help file.

    Sample ( found in JWasm's OWWinDll.mak):

    system nt_dll op export AssembleModule='_AssembleModule@4', ParseCmdline='_ParseCmdline@8'

     
  • Vortex

    Vortex - 2011-07-10

    Hi Japheth,

    Many thanks for your support. Now, It works fine :

    jwlink format windows nt dll file ConsFuncs.obj op implib export StdOut='_StdOut@4',ClearScreen='_ClearScreen@0'
    

    Checking the exported functions with dumpbin, I found that there exists an extra decorated symbol named _ClearScreen@

    \masm32\bin\dumpbin.exe /EXPORTS ConsFuncs.dll
    
    File Type: DLL
      Section contains the following exports for ConsFuncs.dll
               0 characteristics
               0 time date stamp Thu Jan 01 02:00:00 1970
            0.00 version
               1 ordinal base
               4 number of functions
               4 number of names
        ordinal hint RVA      name
              2    0 000010A0 ClearScreen
              1    1 0000106A StdOut
              4    2 000010A0 _ClearScreen@
              3    3 0000106A
    

    Here is the example project :

    http://vortex.masmcode.com/misc/DLLtest.zip

     
  • japheth

    japheth - 2011-07-11

    Vortex,

    the dumpbin protocol revealed a bug in jwlink:  it sometimes calculated the size of the export data 4 bytes too small - that's why the last entry in the protocol has "no name" ( it "should" have been _StdOut@4 ). This has been fixed now.

    The issue that both variants, the decorated and the undecorated names, are contained in the export table is "expected behavior". MS link behaves equally. Technically spoken, the problem is that the "export" attribute in Masm/JWasm will make the assembler add an "-export" entry in the .drectve section. That's why the linker will find -export directives for ALL variants.

    there are 2l workarounds if you don't want the decorated entries:

    - don't use the EXPORT attribute in the assembler source
    - use JWasm's -zze switch

    Instead of using the EXPORT attribute, you could also try to write the export directives for the linker manually in the .drectve section in the assembly source.

     
  • Vortex

    Vortex - 2011-07-11

    Hi Japheth,

    Many thanks for the new release of Jwlink. Removing the EXPORT attribute and specifying the switch -zze solved the problem.

     
  • japheth

    japheth - 2011-07-13

    > Removing the EXPORT attribute and specifying the switch -zze solved the problem.

    Just for the record: my suggestion was to remove the attribute OR adding -zze. -zze has no effect at all if no EXPORT attributes were found in the source.

     

Log in to post a comment.