2020-12-11 13:34:05 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
echo -n "Testing $(basename -s .sh $0) ..."
|
|
|
|
t=$(pwd)/tmp/$(basename -s .sh $0)
|
|
|
|
mkdir -p $t
|
|
|
|
|
|
|
|
cat <<EOF | cc -o $t/a.o -c -x assembler -
|
|
|
|
.text
|
|
|
|
.globl main
|
|
|
|
main:
|
|
|
|
lea msg(%rip), %rdi
|
|
|
|
xor %rax, %rax
|
|
|
|
call printf
|
|
|
|
xor %rax, %rax
|
|
|
|
ret
|
|
|
|
|
|
|
|
.data
|
|
|
|
msg:
|
|
|
|
.string "Hello world\n"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
../mold -static -o $t/exe /usr/lib/x86_64-linux-gnu/crt1.o \
|
|
|
|
/usr/lib/x86_64-linux-gnu/crti.o \
|
|
|
|
/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginT.o \
|
|
|
|
$t/a.o \
|
|
|
|
/usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a \
|
|
|
|
/usr/lib/gcc/x86_64-linux-gnu/9/libgcc_eh.a \
|
|
|
|
/usr/lib/x86_64-linux-gnu/libc.a \
|
|
|
|
/usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \
|
2020-12-13 16:41:50 +03:00
|
|
|
/usr/lib/x86_64-linux-gnu/crtn.o
|
2020-12-11 13:34:05 +03:00
|
|
|
|
|
|
|
$t/exe | grep -q 'Hello world'
|
|
|
|
|
|
|
|
echo ' OK'
|