blob: 98a2b0085ae922866dbfe98f3b2b13e5825e809d [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
Juan Yescas0225a382024-10-03 14:10:09 -070022
23 if [[ "$arch" == "arm64" || "$arch" == "x86_64" ]]; then
24 alignment="-Wl,-z,max-page-size=16384"
25 fi
26
Ryan Prichard8ea6af52022-03-24 21:14:27 -070027 $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 \
Juan Yescas0225a382024-10-03 14:10:09 -070029 $alignment -fuse-ld=gold test.c test2.c
Ryan Prichard8ea6af52022-03-24 21:14:27 -070030}
31
32build arm armv7a-linux-androideabi29
33build arm64 aarch64-linux-android29
34build x86 i686-linux-android29
35build x86_64 x86_64-linux-android29
Juan Yescas0225a382024-10-03 14:10:09 -070036