Ryan Prichard | 8ea6af5 | 2022-03-24 21:14:27 -0700 | [diff] [blame] | 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 | |
| 7 | set -e |
| 8 | |
| 9 | cat >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; } |
| 14 | EOF |
| 15 | cat >test2.c <<EOF |
| 16 | __attribute__((visibility("hidden"))) __thread int tls_var_2; |
| 17 | EOF |
| 18 | |
| 19 | build() { |
| 20 | arch=$1 |
| 21 | target=$2 |
Juan Yescas | 0225a38 | 2024-10-03 14:10:09 -0700 | [diff] [blame] | 22 | |
| 23 | if [[ "$arch" == "arm64" || "$arch" == "x86_64" ]]; then |
| 24 | alignment="-Wl,-z,max-page-size=16384" |
| 25 | fi |
| 26 | |
Ryan Prichard | 8ea6af5 | 2022-03-24 21:14:27 -0700 | [diff] [blame] | 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 \ |
Juan Yescas | 0225a38 | 2024-10-03 14:10:09 -0700 | [diff] [blame] | 29 | $alignment -fuse-ld=gold test.c test2.c |
Ryan Prichard | 8ea6af5 | 2022-03-24 21:14:27 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | build arm armv7a-linux-androideabi29 |
| 33 | build arm64 aarch64-linux-android29 |
| 34 | build x86 i686-linux-android29 |
| 35 | build x86_64 x86_64-linux-android29 |
Juan Yescas | 0225a38 | 2024-10-03 14:10:09 -0700 | [diff] [blame] | 36 | |