mirror of
https://github.com/rui314/mold.git
synced 2024-10-04 16:48:04 +03:00
0dcc910223
This makes it possible to build and test mold in a path that contains whitespace characters - with the notable exception of the tests where `LD_PRELOAD` is used. That's because `LD_PRELOAD` unconditionally treats any whitespace as separator, regardless of quoting. The following ShellCheck warnings are eliminated by this commit: * SC2046: Quote this to prevent word splitting. * SC2086: Double quote to prevent globbing and word splitting. Signed-off-by: Christoph Erhardt <github@sicherha.de>
132 lines
1.7 KiB
Bash
Executable File
132 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
export LANG=
|
|
set -e
|
|
cd "$(dirname "$0")"
|
|
mold=`pwd`/../../mold
|
|
echo -n "Testing $(basename -s .sh "$0") ... "
|
|
t=$(pwd)/../../out/test/elf/$(basename -s .sh "$0")
|
|
mkdir -p "$t"
|
|
|
|
[ "$(uname -m)" = x86_64 ] || { echo skipped; exit; }
|
|
|
|
# Skip if libc is musl
|
|
echo 'int main() {}' | cc -o "$t"/exe -xc -
|
|
ldd "$t"/exe | grep -q ld-musl && { echo OK; exit; }
|
|
|
|
cat <<'EOF' | clang -c -o "$t"/a.o -x assembler -
|
|
.L0:
|
|
mov $0, %edi
|
|
call print
|
|
ret
|
|
.L1:
|
|
mov $1, %edi
|
|
call print
|
|
ret
|
|
.L2:
|
|
mov $2, %edi
|
|
call print
|
|
ret
|
|
.L3:
|
|
mov $3, %edi
|
|
call print
|
|
ret
|
|
.L4:
|
|
mov $4, %edi
|
|
call print
|
|
ret
|
|
.L5:
|
|
mov $5, %edi
|
|
call print
|
|
ret
|
|
.L6:
|
|
mov $6, %edi
|
|
call print
|
|
ret
|
|
.L7:
|
|
mov $7, %edi
|
|
call print
|
|
ret
|
|
|
|
.section .init_array,"aw",@init_array
|
|
.quad .L0
|
|
.quad .L1
|
|
|
|
.section .ctors,"aw",@progbits
|
|
.quad .L2
|
|
.quad .L3
|
|
|
|
.section .fini_array,"aw",@fini_array
|
|
.quad .L4
|
|
.quad .L5
|
|
|
|
.section .dtors,"aw",@progbits
|
|
.quad .L6
|
|
.quad .L7
|
|
EOF
|
|
|
|
cat <<'EOF' | clang -c -o "$t"/b.o -x assembler -
|
|
.L8:
|
|
mov $8, %edi
|
|
call print
|
|
ret
|
|
.L9:
|
|
mov $9, %edi
|
|
call print
|
|
ret
|
|
.La:
|
|
mov $10, %edi
|
|
call print
|
|
ret
|
|
.Lb:
|
|
mov $11, %edi
|
|
call print
|
|
ret
|
|
.Lc:
|
|
mov $12, %edi
|
|
call print
|
|
ret
|
|
.Ld:
|
|
mov $13, %edi
|
|
call print
|
|
ret
|
|
.Le:
|
|
mov $14, %edi
|
|
call print
|
|
ret
|
|
.Lf:
|
|
mov $15, %edi
|
|
call print
|
|
ret
|
|
|
|
.section .init_array,"aw",@init_array
|
|
.quad .L8
|
|
.quad .L9
|
|
|
|
.section .ctors,"aw",@progbits
|
|
.quad .La
|
|
.quad .Lb
|
|
|
|
.section .fini_array,"aw",@fini_array
|
|
.quad .Lc
|
|
.quad .Ld
|
|
|
|
.section .dtors,"aw",@progbits
|
|
.quad .Le
|
|
.quad .Lf
|
|
EOF
|
|
|
|
cat <<EOF | clang -c -o "$t"/c.o -xc -
|
|
#include <stdio.h>
|
|
|
|
void print(int n) {
|
|
printf("%x", n);
|
|
}
|
|
|
|
int main() {}
|
|
EOF
|
|
|
|
clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.o "$t"/b.o "$t"/c.o
|
|
"$t"/exe | grep -q '^013289baefdc6754$'
|
|
|
|
echo OK
|