blob: 0f3e736285eaba2af4eb5d210f9aa08f5d55d25a [file] [log] [blame]
Ryan Prichard8ea6af52022-03-24 21:14:27 -07001#!/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 $NDK21E/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -O2 --target=$target \
23 -fpic -shared -o $arch/libtest_invalid-local-tls.so -fno-emulated-tls \
24 -fuse-ld=gold test.c test2.c
25}
26
27build arm armv7a-linux-androideabi29
28build arm64 aarch64-linux-android29
29build x86 i686-linux-android29
30build x86_64 x86_64-linux-android29