forked from rui314/mold
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
Showing
221 changed files
with
2,474 additions
and
2,474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
#!/bin/bash | ||
export LANG= | ||
set -e | ||
cd $(dirname $0) | ||
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 | ||
echo -n "Testing $(basename -s .sh "$0") ... " | ||
t=$(pwd)/../../out/test/elf/$(basename -s .sh "$0") | ||
mkdir -p "$t" | ||
|
||
echo 'int main() { return 0; }' > $t/a.c | ||
echo 'int main() { return 0; }' > $t/b.c | ||
echo 'int main() { return 0; }' > "$t"/a.c | ||
echo 'int main() { return 0; }' > "$t"/b.c | ||
|
||
! clang -fuse-ld=$mold -o $t/exe $t/a.c $t/b.c 2> /dev/null || false | ||
clang -fuse-ld=$mold -o $t/exe $t/a.c $t/b.c -Wl,-allow-multiple-definition | ||
clang -fuse-ld=$mold -o $t/exe $t/a.c $t/b.c -Wl,-z,muldefs | ||
! clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.c "$t"/b.c 2> /dev/null || false | ||
clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.c "$t"/b.c -Wl,-allow-multiple-definition | ||
clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.c "$t"/b.c -Wl,-z,muldefs | ||
|
||
echo OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
#!/bin/bash | ||
export LANG= | ||
set -e | ||
cd $(dirname $0) | ||
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 | ||
echo -n "Testing $(basename -s .sh "$0") ... " | ||
t=$(pwd)/../../out/test/elf/$(basename -s .sh "$0") | ||
mkdir -p "$t" | ||
|
||
cat <<EOF | cc -fPIC -o $t/a.o -c -xc - | ||
cat <<EOF | cc -fPIC -o "$t"/a.o -c -xc - | ||
__attribute__((weak)) int fn1(); | ||
int main() { | ||
fn1(); | ||
} | ||
EOF | ||
|
||
cat <<EOF | cc -o $t/b.so -shared -fPIC -Wl,-soname,libfoo.so -xc - | ||
cat <<EOF | cc -o "$t"/b.so -shared -fPIC -Wl,-soname,libfoo.so -xc - | ||
int fn1() { return 42; } | ||
EOF | ||
|
||
cat <<EOF | cc -o $t/c.so -shared -fPIC -Wl,-soname,libbar.so -xc - | ||
cat <<EOF | cc -o "$t"/c.so -shared -fPIC -Wl,-soname,libbar.so -xc - | ||
int fn2() { return 42; } | ||
EOF | ||
|
||
clang -fuse-ld=$mold -o $t/exe $t/a.o $t/b.so $t/c.so | ||
clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.o "$t"/b.so "$t"/c.so | ||
|
||
readelf --dynamic $t/exe > $t/readelf | ||
fgrep -q 'Shared library: [libfoo.so]' $t/readelf | ||
fgrep -q 'Shared library: [libbar.so]' $t/readelf | ||
readelf --dynamic "$t"/exe > "$t"/readelf | ||
fgrep -q 'Shared library: [libfoo.so]' "$t"/readelf | ||
fgrep -q 'Shared library: [libbar.so]' "$t"/readelf | ||
|
||
clang -fuse-ld=$mold -o $t/exe $t/a.o -Wl,-as-needed $t/b.so $t/c.so | ||
clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.o -Wl,-as-needed "$t"/b.so "$t"/c.so | ||
|
||
readelf --dynamic $t/exe > $t/readelf | ||
! fgrep -q 'Shared library: [libfoo.so]' $t/readelf || false | ||
! fgrep -q 'Shared library: [libbar.so]' $t/readelf || false | ||
readelf --dynamic "$t"/exe > "$t"/readelf | ||
! fgrep -q 'Shared library: [libfoo.so]' "$t"/readelf || false | ||
! fgrep -q 'Shared library: [libbar.so]' "$t"/readelf || false | ||
|
||
echo OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
#!/bin/bash | ||
export LANG= | ||
set -e | ||
cd $(dirname $0) | ||
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 | ||
echo -n "Testing $(basename -s .sh "$0") ... " | ||
t=$(pwd)/../../out/test/elf/$(basename -s .sh "$0") | ||
mkdir -p "$t" | ||
|
||
cat <<EOF | cc -o $t/a.o -c -xc - | ||
cat <<EOF | cc -o "$t"/a.o -c -xc - | ||
void fn1(); | ||
int main() { | ||
fn1(); | ||
} | ||
EOF | ||
|
||
cat <<EOF | cc -o $t/b.so -shared -fPIC -Wl,-soname,libfoo.so -xc - | ||
cat <<EOF | cc -o "$t"/b.so -shared -fPIC -Wl,-soname,libfoo.so -xc - | ||
int fn1() { return 42; } | ||
EOF | ||
|
||
cat <<EOF | cc -o $t/c.so -shared -fPIC -Wl,-soname,libbar.so -xc - | ||
cat <<EOF | cc -o "$t"/c.so -shared -fPIC -Wl,-soname,libbar.so -xc - | ||
int fn2() { return 42; } | ||
EOF | ||
|
||
clang -fuse-ld=$mold -o $t/exe $t/a.o $t/b.so $t/c.so | ||
clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.o "$t"/b.so "$t"/c.so | ||
|
||
readelf --dynamic $t/exe > $t/readelf | ||
fgrep -q 'Shared library: [libfoo.so]' $t/readelf | ||
fgrep -q 'Shared library: [libbar.so]' $t/readelf | ||
readelf --dynamic "$t"/exe > "$t"/readelf | ||
fgrep -q 'Shared library: [libfoo.so]' "$t"/readelf | ||
fgrep -q 'Shared library: [libbar.so]' "$t"/readelf | ||
|
||
clang -fuse-ld=$mold -o $t/exe $t/a.o -Wl,--as-needed $t/b.so $t/c.so | ||
clang -fuse-ld="$mold" -o "$t"/exe "$t"/a.o -Wl,--as-needed "$t"/b.so "$t"/c.so | ||
|
||
readelf --dynamic $t/exe > $t/readelf | ||
fgrep -q 'Shared library: [libfoo.so]' $t/readelf | ||
! fgrep -q 'Shared library: [libbar.so]' $t/readelf || false | ||
readelf --dynamic "$t"/exe > "$t"/readelf | ||
fgrep -q 'Shared library: [libfoo.so]' "$t"/readelf | ||
! fgrep -q 'Shared library: [libbar.so]' "$t"/readelf || false | ||
|
||
echo OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
#!/bin/bash | ||
export LANG= | ||
set -e | ||
cd $(dirname $0) | ||
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 | ||
echo -n "Testing $(basename -s .sh "$0") ... " | ||
t=$(pwd)/../../out/test/elf/$(basename -s .sh "$0") | ||
mkdir -p "$t" | ||
|
||
cat <<EOF | cc -shared -fPIC -o $t/a.so -xc - | ||
cat <<EOF | cc -shared -fPIC -o "$t"/a.so -xc - | ||
int foo() { return 3; } | ||
EOF | ||
|
||
cat <<EOF | cc -shared -fPIC -o $t/b.so -xc - | ||
cat <<EOF | cc -shared -fPIC -o "$t"/b.so -xc - | ||
int bar() { return 3; } | ||
EOF | ||
|
||
cat <<EOF | cc -shared -fPIC -o $t/c.so -xc - | ||
cat <<EOF | cc -shared -fPIC -o "$t"/c.so -xc - | ||
int foo(); | ||
int baz() { return foo(); } | ||
EOF | ||
|
||
cat <<EOF | cc -c -o $t/d.o -xc - | ||
cat <<EOF | cc -c -o "$t"/d.o -xc - | ||
#include <stdio.h> | ||
int baz(); | ||
int main() { | ||
printf("%d\n", baz()); | ||
} | ||
EOF | ||
|
||
clang -fuse-ld=$mold -o $t/exe $t/d.o -Wl,--as-needed \ | ||
$t/c.so $t/b.so $t/a.so | ||
clang -fuse-ld="$mold" -o "$t"/exe "$t"/d.o -Wl,--as-needed \ | ||
"$t"/c.so "$t"/b.so "$t"/a.so | ||
|
||
readelf --dynamic $t/exe > $t/log | ||
grep -q /a.so $t/log | ||
grep -q /c.so $t/log | ||
! grep -q /b.so $t/log || false | ||
readelf --dynamic "$t"/exe > "$t"/log | ||
grep -q /a.so "$t"/log | ||
grep -q /c.so "$t"/log | ||
! grep -q /b.so "$t"/log || false | ||
|
||
echo OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
#!/bin/bash | ||
export LANG= | ||
set -e | ||
cd $(dirname $0) | ||
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 | ||
echo -n "Testing $(basename -s .sh "$0") ... " | ||
t=$(pwd)/../../out/test/elf/$(basename -s .sh "$0") | ||
mkdir -p "$t" | ||
|
||
cat <<EOF | cc -o $t/a.o -c -x assembler - | ||
cat <<EOF | cc -o "$t"/a.o -c -x assembler - | ||
.text | ||
.globl _start | ||
_start: | ||
nop | ||
EOF | ||
|
||
$mold -o $t/b.so $t/a.o -auxiliary foo -f bar -shared | ||
"$mold" -o "$t"/b.so "$t"/a.o -auxiliary foo -f bar -shared | ||
|
||
readelf --dynamic $t/b.so > $t/log | ||
fgrep -q 'Auxiliary library: [foo]' $t/log | ||
fgrep -q 'Auxiliary library: [bar]' $t/log | ||
readelf --dynamic "$t"/b.so > "$t"/log | ||
fgrep -q 'Auxiliary library: [foo]' "$t"/log | ||
fgrep -q 'Auxiliary library: [bar]' "$t"/log | ||
|
||
echo OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#!/bin/bash | ||
export LANG= | ||
set -e | ||
cd $(dirname $0) | ||
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 | ||
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; } | ||
[ "$(uname -m)" = x86_64 ] || { echo skipped; exit; } | ||
|
||
echo '.globl _start; _start: jmp loop' | cc -o $t/a.o -c -x assembler - | ||
echo '.globl loop; loop: jmp loop' | cc -o $t/b.o -c -x assembler - | ||
$mold -static -o $t/exe $t/a.o $t/b.o | ||
objdump -d $t/exe > /dev/null | ||
file $t/exe | grep -q ELF | ||
echo '.globl _start; _start: jmp loop' | cc -o "$t"/a.o -c -x assembler - | ||
echo '.globl loop; loop: jmp loop' | cc -o "$t"/b.o -c -x assembler - | ||
"$mold" -static -o "$t"/exe "$t"/a.o "$t"/b.o | ||
objdump -d "$t"/exe > /dev/null | ||
file "$t"/exe | grep -q ELF | ||
|
||
echo OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.