1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 16:48:04 +03:00
mold/test/elf/riscv-hello-dynamic.sh
Rui Ueyama 00203dbc7c [ELF][RISC-V] Implement TLS_GOT_HI20 and TLS_GD_HI20
Now all test passed on my SiFive Unmatched RISC-V PC.
2022-01-29 22:35:04 +09:00

37 lines
828 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
[ "$(uname -m)" = riscv64 ] && { echo skipped; exit; }
echo 'int main() {}' | riscv64-linux-gnu-gcc-10 -o $t/exe -xc - >& /dev/null \
|| { echo skipped; exit; }
cat <<EOF | riscv64-linux-gnu-gcc-10 -o $t/a.o -c -g -xc -
#include <stdio.h>
int main() {
printf("Hello world\n");
return 0;
}
EOF
riscv64-linux-gnu-gcc-10 -B. -o $t/exe $t/a.o
riscv64-linux-gnu-readelf -p .comment $t/exe | grep -qw mold
riscv64-linux-gnu-readelf -a $t/exe >& $t/log
grep -iqE 'Machine:.*RISC-?V' $t/log
grep -q 'Shared library:.*libc.so' $t/log
qemu-riscv64 -L /usr/riscv64-linux-gnu $t/exe | grep -q 'Hello world'
echo OK