2020-12-13 12:46:07 +03:00
|
|
|
#!/bin/bash
|
2021-12-17 14:05:14 +03:00
|
|
|
export LANG=
|
2020-12-13 12:46:07 +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"
|
2020-12-13 12:46:07 +03:00
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
cat <<EOF | cc -o "$t"/long-long-long-filename.o -c -xc -
|
2020-12-13 12:46:07 +03:00
|
|
|
int three() { return 3; }
|
|
|
|
EOF
|
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
cat <<EOF | cc -o "$t"/b.o -c -xc -
|
2020-12-13 12:46:07 +03:00
|
|
|
int five() { return 5; }
|
|
|
|
EOF
|
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
cat <<EOF | cc -o "$t"/c.o -c -xc -
|
2021-06-17 06:38:20 +03:00
|
|
|
int seven() { return 7; }
|
|
|
|
EOF
|
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
cat <<EOF | cc -o "$t"/d.o -c -xc -
|
2020-12-13 12:46:07 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int three();
|
|
|
|
int five();
|
2021-06-17 06:38:20 +03:00
|
|
|
int seven();
|
2020-12-13 12:46:07 +03:00
|
|
|
|
|
|
|
int main() {
|
2021-06-17 06:38:20 +03:00
|
|
|
printf("%d\n", three() + five() + seven());
|
2020-12-13 12:46:07 +03:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
rm -f "$t"/d.a
|
|
|
|
(cd "$t"; ar rcsT d.a long-long-long-filename.o b.o "`pwd`"/c.o)
|
2020-12-13 12:46:07 +03:00
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
clang -fuse-ld="$mold" -Wl,--trace -o "$t"/exe "$t"/d.o "$t"/d.a > "$t"/log
|
2020-12-13 12:46:07 +03:00
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
grep -Pq 'thin-archive/d.a\(.*long-long-long-filename.o\)' "$t"/log
|
|
|
|
grep -Pq 'thin-archive/d.a\(.*b.o\)' "$t"/log
|
|
|
|
grep -Pq 'thin-archive/d.a\(/.*/b.o\)' "$t"/log
|
|
|
|
fgrep -q thin-archive/d.o "$t"/log
|
2020-12-13 12:46:07 +03:00
|
|
|
|
2021-12-22 13:38:00 +03:00
|
|
|
"$t"/exe | grep -q 15
|
2020-12-13 12:46:07 +03:00
|
|
|
|
2021-01-25 05:02:01 +03:00
|
|
|
echo OK
|