forked from bluewhalesystems/sold
-
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.
- Loading branch information
Showing
58 changed files
with
1,041 additions
and
767 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
*.o | ||
*~ | ||
/mold | ||
/test/Output | ||
/test/tmp | ||
options.inc | ||
core |
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/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 _start | ||
_start: | ||
call fn1@PLT | ||
EOF | ||
|
||
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 - | ||
int fn2() { return 42; } | ||
EOF | ||
|
||
../mold -o $t/exe $t/a.o $t/b.so $t/c.so > /dev/null | ||
|
||
readelf --dynamic $t/exe > $t/readelf | ||
fgrep -q 'Shared library: [libfoo.so]' $t/readelf | ||
fgrep -q 'Shared library: [libbar.so]' $t/readelf | ||
|
||
../mold -o $t/exe $t/a.o --as-needed $t/b.so $t/c.so > /dev/null | ||
|
||
readelf --dynamic $t/exe > $t/readelf | ||
fgrep -q 'Shared library: [libfoo.so]' $t/readelf | ||
! fgrep -q 'Shared library: [libbar.so]' $t/readelf | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -e | ||
echo -n "Testing $(basename -s .sh $0) ..." | ||
t=$(pwd)/tmp/$(basename -s .sh $0) | ||
mkdir -p $t | ||
|
||
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 > /dev/null | ||
objdump -d $t/exe > /dev/null | ||
file $t/exe | grep -q ELF | ||
|
||
echo ' OK' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/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 -xc - | ||
#include <stdio.h> | ||
extern int foo; | ||
extern int bar; | ||
int main() { | ||
printf("%d %d %d\n", foo, bar, &foo == &bar); | ||
return 0; | ||
} | ||
EOF | ||
|
||
cat <<EOF | cc -o $t/b.o -c -x assembler - | ||
.globl foo, bar | ||
.data; | ||
foo: | ||
bar: | ||
.long 42 | ||
EOF | ||
|
||
../mold -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/crtbegin.o \ | ||
$t/a.o $t/b.o \ | ||
/usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a \ | ||
/usr/lib/x86_64-linux-gnu/libgcc_s.so.1 \ | ||
/lib/x86_64-linux-gnu/libc.so.6 \ | ||
/usr/lib/x86_64-linux-gnu/libc_nonshared.a \ | ||
/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 \ | ||
/usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \ | ||
/usr/lib/x86_64-linux-gnu/crtn.o > /dev/null | ||
|
||
$t/exe | grep -q '42 42 1' | ||
|
||
echo ' OK' |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/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: | ||
nop | ||
EOF | ||
|
||
! ../mold -o $t/exe $t/a.o $t/a.o 2> $t/log | ||
grep -q 'duplicate symbol: .*\.o: .*\.o: main' $t/log | ||
|
||
echo ' OK' |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
set -e | ||
echo -n "Testing $(basename -s .sh $0) ..." | ||
t=$(pwd)/tmp/$(basename -s .sh $0) | ||
mkdir -p $t | ||
|
||
echo '.globl main; main:' | cc -o $t/a.o -c -x assembler - | ||
|
||
../mold -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/crtbegin.o \ | ||
$t/a.o \ | ||
/usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \ | ||
/usr/lib/x86_64-linux-gnu/crtn.o \ | ||
/usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a \ | ||
/usr/lib/x86_64-linux-gnu/libgcc_s.so.1 \ | ||
/lib/x86_64-linux-gnu/libc.so.6 \ | ||
/usr/lib/x86_64-linux-gnu/libc_nonshared.a \ | ||
/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 > /dev/null | ||
|
||
readelf --dynamic $t/exe | grep -q " | ||
Dynamic section at offset 0x2048 contains 26 entries: | ||
Tag Type Name/Value | ||
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1] | ||
0x0000000000000001 (NEEDED) Shared library: [libc.so.6] | ||
0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2] | ||
0x0000000000000007 (RELA) 0x2001c8 | ||
0x0000000000000008 (RELASZ) 24 (bytes) | ||
0x0000000000000009 (RELAENT) 24 (bytes) | ||
0x0000000000000017 (JMPREL) 0x2001b0 | ||
0x0000000000000002 (PLTRELSZ) 24 (bytes) | ||
0x0000000000000003 (PLTGOT) 0x202028 | ||
0x0000000000000014 (PLTREL) RELA | ||
0x0000000000000006 (SYMTAB) 0x2001e0 | ||
0x000000000000000b (SYMENT) 24 (bytes) | ||
0x0000000000000005 (STRTAB) 0x200228 | ||
0x000000000000000a (STRSZ) 83 (bytes) | ||
0x0000000000000004 (HASH) 0x20027c | ||
0x0000000000000019 (INIT_ARRAY) 0x202210 | ||
0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) | ||
0x000000000000001a (FINI_ARRAY) 0x202208 | ||
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) | ||
0x000000006ffffff0 (VERSYM) 0x20029c | ||
0x000000006ffffffe (VERNEED) 0x2002a8 | ||
0x000000006fffffff (VERNEEDNUM) 1 | ||
0x0000000000000015 (DEBUG) 0x0 | ||
0x000000000000000c (INIT) 0x201030 | ||
0x000000000000000d (FINI) 0x201020 | ||
0x0000000000000000 (NULL) 0x0 | ||
" | ||
|
||
readelf --symbols --use-dynamic $t/exe | grep -q " | ||
Symbol table for image: | ||
Num Buc: Value Size Type Bind Vis Ndx Name | ||
1 1: 0000000000000000 483 FUNC GLOBAL DEFAULT UND __libc_start_main | ||
2 2: 0000000000000000 204 FUNC GLOBAL DEFAULT UND printf | ||
" | ||
|
||
echo ' OK' |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.