1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 16:48:04 +03:00
mold/test/elf/dso-undef.sh
2022-01-24 10:21:08 +09:00

39 lines
618 B
Bash
Executable File

#!/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
cat <<EOF | $CC -fPIC -o $t/a.o -c -xc -
extern int foo;
int bar = 5;
int baz() { return foo; }
EOF
$CC -B. -o $t/b.so -shared $t/a.o
cat <<EOF | $CC -o $t/c.o -c -xc -
int foo = 3;
EOF
rm -f $t/d.a
ar rcs $t/d.a $t/c.o
cat <<EOF | $CC -o $t/e.o -c -xc -
extern int bar;
int main() {
return bar - 5;
}
EOF
$CC -B. -o $t/exe $t/b.so $t/d.a $t/e.o
readelf --dyn-syms $t/exe | grep -q ' foo$'
echo OK