#!/bin/bash set -e cd $(dirname $0) echo -n "Testing $(basename -s .sh $0) ... " t=$(pwd)/tmp/$(basename -s .sh $0) mkdir -p $t cat < $t/c.c #include int get_foo(); int get_bar(); int baz = 2; int main() { printf("%d %d %d\n", get_foo(), get_bar(), baz); } EOF clang -c -o $t/d.o $t/c.c -fno-PIC -m32 clang -fuse-ld=`pwd`/../mold -o $t/exe $t/d.o $t/b.so -m32 $t/exe | grep -q '5 7 2' clang -c -o $t/e.o $t/c.c -fPIE -m32 clang -fuse-ld=`pwd`/../mold -o $t/exe $t/e.o $t/b.so -m32 $t/exe | grep -q '5 7 2' clang -c -o $t/f.o $t/c.c -fPIC -m32 clang -fuse-ld=`pwd`/../mold -o $t/exe $t/f.o $t/b.so -m32 $t/exe | grep -q '5 7 2' echo OK