1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-26 01:44:29 +03:00
mold/test/tls-gd.sh

49 lines
1.0 KiB
Bash
Raw Normal View History

2020-12-11 13:34:05 +03:00
#!/bin/bash
set -e
2021-03-01 10:28:16 +03:00
cd $(dirname $0)
2021-01-25 05:02:01 +03:00
echo -n "Testing $(basename -s .sh $0) ... "
2020-12-11 13:34:05 +03:00
t=$(pwd)/tmp/$(basename -s .sh $0)
mkdir -p $t
cat <<EOF | cc -fPIC -c -o $t/a.o -xc -
#include <stdio.h>
2021-06-06 08:52:46 +03:00
static _Thread_local int x1 = 1;
static _Thread_local int x2;
extern _Thread_local int x3;
extern _Thread_local int x4;
int get_x5();
int get_x6();
2020-12-11 13:34:05 +03:00
int main() {
2021-06-06 08:52:46 +03:00
x2 = 2;
2020-12-11 13:34:05 +03:00
2021-06-06 08:52:46 +03:00
printf("%d %d %d %d %d %d\n", x1, x2, x3, x4, get_x5(), get_x6());
2020-12-11 13:34:05 +03:00
return 0;
}
EOF
2021-06-06 08:52:46 +03:00
cat <<EOF | cc -fPIC -c -o $t/b.o -xc -
_Thread_local int x3 = 3;
static _Thread_local int x5 = 5;
int get_x5() { return x5; }
2020-12-11 13:34:05 +03:00
EOF
2021-06-06 08:52:46 +03:00
cat <<EOF | cc -fPIC -c -o $t/c.o -xc -
_Thread_local int x4 = 4;
static _Thread_local int x6 = 6;
int get_x6() { return x6; }
EOF
2021-06-07 09:24:03 +03:00
clang -fuse-ld=`pwd`/../mold -shared -o $t/d.so $t/b.o
clang -fuse-ld=`pwd`/../mold -shared -o $t/e.so $t/c.o -Wl,--no-relax
2021-06-06 08:52:46 +03:00
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o $t/d.so $t/e.so
$t/exe | grep -q '1 2 3 4 5 6'
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o $t/d.so $t/e.so -Wl,-no-relax
$t/exe | grep -q '1 2 3 4 5 6'
2021-01-14 08:08:34 +03:00
2021-01-25 05:02:01 +03:00
echo OK