> On 8 dec 2015, at 22:20, Jacob Carlborg via dmd-internals 
> <[email protected]> wrote:
> 
> I’m looking in to if I can get to DMD output native TLS on OS X. I’m trying 
> to output a reference to a symbol (not sure if that’s the correct 
> terminology) using the “dtxoff” function that matches Clang. The code I have 
> looks like this:
> 
> const char *tlvInitName = concat(s->Sident, strlen(s->Sident), "$tlv$init", 
> 9);
> Symbol* tlvInit = symbol_name(tlvInitName, SCstatic, type_fake(TYnfunc));
> tlvInit->Sdt = NULL;
> tlvInit->Sseg = MachObj::getsegment("__thread_data", "__DATA", 2, 
> S_THREAD_LOCAL_REGULAR);
> Initializer_toDt(vd->_init, &tlvInit->Sdt);
> outdata(tlvInit);
> 
> Symbol* tlvBootstrap = symbol_name("__tlv_bootstrap", SCglobal, 
> type_fake(TYnfunc));
> 
> dtxoff(&s->Sdt, tlvBootstrap, 0, TYnptr);
> dtsize_t(&s->Sdt, 0);
> dtxoff(&s->Sdt, tlvInit, 0, TYnptr);

I managed to solve the problem by changing the class of the “tlvInit” symbol to 
“export” after outputting it.

tlvInit->Sclass = SCextern;

-- 
/Jacob Carlborg


_______________________________________________
dmd-internals mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-internals

Reply via email to