Android tls issue

Newbie2019 newbie2019 at gmail.com
Mon Jun 24 22:24:47 UTC 2019


On Monday, 24 June 2019 at 18:31:36 UTC, kinke wrote:
> On Monday, 24 June 2019 at 17:29:02 UTC, Newbie2019 wrote:
>> I will try some work around.
>
> You could try adding the following to driver/main.d:
>
> import ldc.attributes;
>
> extern (C) __gshared
> {
>     @section(".tdata")
>     int _tlsstart = 0;
>     @section(".tcommon")
>     int _tlsend = 0;
> }

This solve the _tlsstart/_tlsend problem, now I get a ldc2 binary 
for aarch64.

when I use the new ldc2 built example, I get this error:


ldc2 sieve.d
#### rootHasMain=1 env=10 android=10
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: 
_tlsstart: TLS definition in sieve.o section .tdata mismatches 
non-TLS reference in 
/data/data/com.termux/files/home/d/tmp/lib/libdruntime-ldc.a(sections_android.o)
/data/data/com.termux/files/usr/bin/aarch64-linux-android-ld: 
/data/data/com.termux/files/home/d/tmp/lib/libdruntime-ldc.a: 
error adding symbols: bad value
clang-8: error: linker command failed with exit code 1 (use -v to 
see invocation)
Error: /data/data/com.termux/files/usr/bin/gcc failed with 
status: 1


ldc2 sieve.d -Xcc=-fuse-ld=lld -Xcc=-L/system/lib64
ld.lld: error: undefined symbol: __bss_end__
>>> referenced by sections_android.d
>>>               
>>> sections_android.o:(_D2rt16sections_android12initSectionsFNbNiZv) in archive /data/data/com.termux/files/home/d/tmp/lib/libdruntime-ldc.a

ld.lld: error: undefined symbol: __bss_end__
>>> referenced by sections_android.d
>>>               
>>> sections_android.o:(_D2rt16sections_android12initSectionsFNbNiZv) in archive /data/data/com.termux/files/home/d/tmp/lib/libdruntime-ldc.a
clang-8: error: linker command failed with exit code 1 (use -v to 
see invocation)
Error: /data/data/com.termux/files/usr/bin/gcc failed with 
status: 1


Link with lld report there is no symbol __bss_end__,  I guess we 
need patch driver/codegenerator.cpp to fix this error ?

I add ` emitSymbolAddrGlobal(ir_->module, "__bss_end__", 
"_d_execBssEndAddr");`  after the `endSymbol` define, but not 
work.

any suggestion to fix this __bss_end__ issue for Android ?







More information about the digitalmars-d-ldc mailing list