2022-02-05 05:23:02 +03:00
|
|
|
#!/bin/bash
|
|
|
|
export LANG=
|
|
|
|
set -e
|
|
|
|
CC="${CC:-cc}"
|
|
|
|
CXX="${CXX:-c++}"
|
|
|
|
testname=$(basename "$0" .sh)
|
|
|
|
echo -n "Testing $testname ... "
|
|
|
|
cd "$(dirname "$0")"/../..
|
|
|
|
mold="$(pwd)/mold"
|
|
|
|
t=out/test/elf/$testname
|
|
|
|
mkdir -p $t
|
|
|
|
|
2022-02-05 06:08:24 +03:00
|
|
|
cat <<EOF | $CC -c -fPIC -xc -o $t/a.o -
|
2022-02-05 05:23:02 +03:00
|
|
|
extern int foo;
|
|
|
|
int x() { return foo; }
|
|
|
|
EOF
|
|
|
|
|
2022-02-05 06:08:24 +03:00
|
|
|
cat <<EOF | $CC -c -fPIC -xc -o $t/b.o -
|
2022-02-05 05:23:02 +03:00
|
|
|
extern int foo;
|
|
|
|
int y() { return foo; }
|
|
|
|
int main() {}
|
|
|
|
EOF
|
|
|
|
|
2022-02-05 06:08:24 +03:00
|
|
|
$CC -B. -o $t/exe $t/a.o $t/b.o -Wl,--warn-unresolved-symbols,--warn-once >& $t/log
|
2022-02-05 05:23:02 +03:00
|
|
|
|
2022-02-05 06:08:24 +03:00
|
|
|
[ "$(grep 'undefined symbol:.* foo$' $t/log | wc -l)" = 1 ]
|
2022-02-05 05:23:02 +03:00
|
|
|
|
|
|
|
echo OK
|