[Issue 9816] Export is mostly broken

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 27 00:07:51 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9816


Rainer Schuetze <r.sagitario at gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario at gmx.de


--- Comment #7 from Rainer Schuetze <r.sagitario at gmx.de> 2013-08-27 00:07:48 PDT ---
A few random comments:

- I think in a situation where you want to use the same code for static and
dynamic linking, "export" is not usable. I'd propose to export every public
symbol at module granularity depending on a compile switch.

- but then, there is no easy way to tell whether symbols in a module are
imported from a static or dynamic library. This distinction is necessary
though, as the code is different for both situations. Maybe a versioned pragma
at module level can control this.

- Using TLS variables from other DLLs is possible, but probably not with the
current tool chain. What needs to be exported is the offset of the symbol in
the TLS section and the address of the _tls_index variable in the DLL that
exports the symbol. The code to read the variable could then look like this

  mov EAX,[_imp_variable.tls_index]; // read address of tls_index in import
table
  mov EAX,[EAX]; // read tls_index of DLL
  mov EBX,FS:[2C]; // tls_array
  mov EBX,[EBX+4*EAX]; // tls_start of DLL
  mov ECX,[_imp_variable.offset]; // read offset of variable in TLS of DLL
  mov EDX,[EBX+ECX]; // read variable

If the offset is not exportable, _tls_start is also needed for the DLL.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list