1#!/bin/bash 2# 3# Bionic doesn't support the references to STB_LOCAL symbols of type STT_TLS 4# and STT_SECTION that ld.gold generates. Set NDK21E to the path to a copy of 5# NDK r21e, which still has ld.gold (unlike the platform build or newer NDKs). 6 7set -e 8 9cat >test.c <<EOF 10 static __thread int tls_var_1; 11 extern __thread int tls_var_2; 12 int* getaddr1() { return &tls_var_1; } 13 int* getaddr2() { return &tls_var_2; } 14EOF 15cat >test2.c <<EOF 16 __attribute__((visibility("hidden"))) __thread int tls_var_2; 17EOF 18 19build() { 20 arch=$1 21 target=$2 22 23 if [[ "$arch" == "arm64" || "$arch" == "x86_64" ]]; then 24 alignment="-Wl,-z,max-page-size=16384" 25 fi 26 27 $NDK21E/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -O2 --target=$target \ 28 -fpic -shared -o $arch/libtest_invalid-local-tls.so -fno-emulated-tls \ 29 $alignment -fuse-ld=gold test.c test2.c 30} 31 32build arm armv7a-linux-androideabi29 33build arm64 aarch64-linux-android29 34build x86 i686-linux-android29 35build x86_64 x86_64-linux-android29 36 37