1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-24 17:01:50 +03:00
mold/test/dt_init.sh

35 lines
878 B
Bash
Raw Normal View History

2021-03-01 06:45:13 +03:00
#!/bin/bash
set -e
2021-03-01 10:28:16 +03:00
cd $(dirname $0)
2021-03-01 06:45:13 +03:00
echo -n "Testing $(basename -s .sh $0) ... "
t=$(pwd)/tmp/$(basename -s .sh $0)
mkdir -p $t
cat <<EOF | clang -c -o $t/a.o -x assembler -
2021-03-01 06:49:09 +03:00
.globl main, init, fini
2021-03-01 06:45:13 +03:00
main:
ret
2021-03-01 06:49:09 +03:00
init:
ret
fini:
ret
2021-03-01 06:45:13 +03:00
EOF
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o
readelf -a $t/exe > $t/log
grep -Pq '\(INIT\)\s+0x201010' $t/log
grep -Pq '\(FINI\)\s+0x201000' $t/log
grep -Pq '0000000000201010\s+0 FUNC GLOBAL HIDDEN \d+ _init$' $t/log
grep -Pq '0000000000201000\s+0 FUNC GLOBAL HIDDEN \d+ _fini$' $t/log
2021-03-01 06:45:13 +03:00
2021-03-01 06:49:09 +03:00
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o -Wl,-init,init -Wl,-fini,fini
readelf -a $t/exe > $t/log
grep -Pq '\(INIT\)\s+0x201119' $t/log
grep -Pq '\(FINI\)\s+0x20111a' $t/log
grep -Pq '0000000000201119\s+0 NOTYPE GLOBAL DEFAULT \d+ init$' $t/log
grep -Pq '000000000020111a\s+0 NOTYPE GLOBAL DEFAULT \d+ fini$' $t/log
2021-03-01 06:49:09 +03:00
2021-03-01 06:45:13 +03:00
echo OK