DIP45: fixing the dllimport/dllexport issue

Benjamin Thaut code at benjamin-thaut.de
Fri Sep 6 00:23:08 PDT 2013


Am 06.09.2013 03:51, schrieb Martin Nowak:
> On 09/01/2013 05:26 PM, Rainer Schuetze wrote:
>>
>> Maybe already deep into implementation but how are we going to deal with
>> the initialization of data?
>>
>> module sharedlib;
>> __gshared int var;
>>
>> module exe;
>> import sharedlib;
>> __gshared int* pvar = &var;
>>
>> (This kind of relocation also has to be done for stuff like
>> TypeInfo_Class). It needs initialization code to fill pvar with the
>> correct pointer.
>>
> Based on your saying that there are no absolute data relocations for
> this on windows we'd have to perform runtime initialization.
> At runtime it would simply copy _imp_var into pvar, right?

Yes. As Rainer already mentioned we can either do this by running some 
initialiers before initializing druntime, or we could add additional 
information in a section of the dll and run some generic dll 
initialization code.

>
>> Do we support the same for pointers in TLS?
>>
>> int* tlsvar = &var;
>>
>> This might need initialization per thread, or patching the original TLS
>> segment.
> No you can't take the address of a TLS var at compile time.

Its not taking a address of a TLS variable. It is initializing a TLS 
variable with the address of a __gshared variable.


-- 
Kind Regards
Benjamin Thaut


More information about the Digitalmars-d mailing list