1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 16:48:04 +03:00
mold/test/elf/thin-archive.sh

48 lines
963 B
Bash
Raw Normal View History

2020-12-13 12:46:07 +03:00
#!/bin/bash
export LANG=
2020-12-13 12:46:07 +03:00
set -e
testname=$(basename -s .sh "$0")
echo -n "Testing $testname ... "
cd "$(dirname "$0")"/../..
mold="$(pwd)/mold"
t="$(pwd)/out/test/elf/$testname"
mkdir -p "$t"
2020-12-13 12:46:07 +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
cat <<EOF | cc -o "$t"/b.o -c -xc -
2020-12-13 12:46:07 +03:00
int five() { return 5; }
EOF
cat <<EOF | cc -o "$t"/c.o -c -xc -
int seven() { return 7; }
EOF
cat <<EOF | cc -o "$t"/d.o -c -xc -
2020-12-13 12:46:07 +03:00
#include <stdio.h>
int three();
int five();
int seven();
2020-12-13 12:46:07 +03:00
int main() {
printf("%d\n", three() + five() + seven());
2020-12-13 12:46:07 +03:00
}
EOF
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
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
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
"$t"/exe | grep -q 15
2020-12-13 12:46:07 +03:00
2021-01-25 05:02:01 +03:00
echo OK