2021-03-23 19:06:24 +03:00
|
|
|
#!/bin/bash
|
2021-12-17 14:05:14 +03:00
|
|
|
export LANG=
|
2021-03-23 19:06:24 +03:00
|
|
|
set -e
|
2021-12-30 05:11:06 +03:00
|
|
|
testname=$(basename -s .sh "$0")
|
|
|
|
echo -n "Testing $testname ... "
|
|
|
|
cd "$(dirname "$0")"/../..
|
|
|
|
mold="$(pwd)/mold"
|
|
|
|
t="$(pwd)/out/test/elf/$testname"
|
2021-12-22 13:38:00 +03:00
|
|
|
mkdir -p "$t"
|
2021-03-23 19:06:24 +03:00
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
cat <<EOF | clang -fcommon -xc -c -o "$t"/a.o -
|
2021-03-23 19:06:24 +03:00
|
|
|
int foo;
|
|
|
|
int bar;
|
|
|
|
int baz = 42;
|
|
|
|
EOF
|
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
cat <<EOF | clang -fcommon -xc -c -o "$t"/b.o -
|
2021-03-23 19:06:24 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int foo;
|
|
|
|
int bar = 5;
|
|
|
|
int baz;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
printf("%d %d %d\n", foo, bar, baz);
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.o "$t"/b.o
|
|
|
|
"$t"/exe | grep -q '0 5 42'
|
2021-03-23 19:06:24 +03:00
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
readelf --sections "$t"/exe > "$t"/log
|
|
|
|
grep -q '.common .*NOBITS' "$t"/log
|
2021-03-25 11:55:59 +03:00
|
|
|
|
2021-03-23 19:06:24 +03:00
|
|
|
echo OK
|