Shared library in D on Linux

Iain Buclaw ibuclaw at ubuntu.com
Mon Apr 9 12:59:06 PDT 2012


On 9 April 2012 20:37,  <"Timo Westkämper\"
<timo.westkamper at gmail.com>"@puremagic.com> wrote:
> On Monday, 9 April 2012 at 15:14:45 UTC, Ellery Newcomer wrote:
>>
>> Well, if you're really hankering for a shared lib, try ldc. I have gotten
>> it to compile working shared libs in the past.
>>
>> On 04/09/2012 01:24 AM, "Timo Westkämper" <timo.westkamper at gmail.com>"
>> wrote:
>>>
>>> On Sunday, 8 April 2012 at 17:59:28 UTC, Timo Westkämper wrote:
>>>>
>>>> Does someone know why the lib (.a) packaging instead of objects (.o)
>>>> works better in this case?
>>>
>>>
>>> Didn't work after all with -lib. I mixed up outputs.
>
>
> Thanks, I might switch to ldc, if dmd and gdc fail here.
>
> I found this tls.S script in the druntime sources (src/rt/tls.S). Do you
> think it could be included in the library to make tls initialization work?
>
> #if linux
>
> /* The memory between the addresses of _tlsstart and _tlsend is the storage
> for
>  * thread-local data in D 2.0.  Both of these rely on the default linker
> script
>  * of:
>  *      .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
>  *      .tbss  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
>  * to group the sections in that order.
>  *
>  * Sadly, this does not work because ld orders .tdata after .tdata.*,
> despite
>  * what the linker script says.
>  */
>
> .file "tls.S"
>
> .globl _tlsstart
>    .section .tdata,"awT", at progbits
>    .align 4
>    .type   _tlsstart, @object
>    .size   _tlsstart, 4
> _tlsstart:
>    .long   3
>
> .globl _tlsend
>    .section .tcommon,"awT", at nobits
>    .align 4
>    .type   _tlsend, @object
>    .size   _tlsend, 4
> _tlsend:
>    .zero   4
>
> #endif
>
>

That assembly file does nothing for shared library support.  I have
been meaning to finish up a solution to help support shared libs,
would mean more deviation from the dmd compiler's runtime library, but
that's fine.

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the Digitalmars-d mailing list