1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-11 05:46:58 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-12-13 22:41:50 +09:00
parent f4886d4dae
commit 695f4da80a
23 changed files with 33 additions and 25 deletions

11
main.cc
View File

@ -814,6 +814,8 @@ int main(int argc, char **argv) {
config.rpaths.push_back(arg);
} else if (read_arg(args, arg, "version-script")) {
parse_version_script(arg);
} else if (read_flag(args, "perf")) {
config.perf = true;
} else if (read_arg(args, arg, "l")) {
read_file(find_library(arg));
} else if (read_arg(args, arg, "z")) {
@ -1110,7 +1112,12 @@ int main(int argc, char **argv) {
Counter num_dsos("num_dsos", out::dsos.size());
Counter filesize_counter("filesize", filesize);
Counter::print();
Timer::print();
if (Counter::enabled)
Counter::print();
if (config.perf)
Timer::print();
std::cout << std::flush;
std::cerr << std::flush;
_exit(0);
}

1
mold.h
View File

@ -55,6 +55,7 @@ struct Config {
bool as_needed = false;
bool export_dynamic = false;
bool is_static = false;
bool perf = false;
bool print_map = false;
bool trace = false;
int filler = -1;

View File

@ -6,7 +6,7 @@
#include <sys/time.h>
std::vector<Counter *> Counter::instances;
bool Counter::enabled = true;
bool Counter::enabled = false;
std::vector<Timer *> Timer::instances;

View File

@ -19,13 +19,13 @@ 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
../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
../mold -o $t/exe $t/a.o --as-needed $t/b.so $t/c.so > /dev/null
../mold -o $t/exe $t/a.o --as-needed $t/b.so $t/c.so
readelf --dynamic $t/exe > $t/readelf
fgrep -q 'Shared library: [libfoo.so]' $t/readelf

View File

@ -6,7 +6,7 @@ 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
../mold -static -o $t/exe $t/a.o $t/b.o
objdump -d $t/exe > /dev/null
file $t/exe | grep -q ELF

View File

@ -34,7 +34,7 @@ EOF
/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
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q '42 42 1'

View File

@ -28,7 +28,7 @@ EOF
/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 \
/usr/lib/x86_64-linux-gnu/crtn.o > /dev/null
/usr/lib/x86_64-linux-gnu/crtn.o
../mold -static --filler 0x0 -o $t/exe2 \
/usr/lib/x86_64-linux-gnu/crt1.o \
@ -39,7 +39,7 @@ EOF
/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 \
/usr/lib/x86_64-linux-gnu/crtn.o > /dev/null
/usr/lib/x86_64-linux-gnu/crtn.o
hexdump -C $t/exe1 > $t/txt1
hexdump -C $t/exe2 > $t/txt2

View File

@ -29,7 +29,7 @@ EOF
/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
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q 'Hello world'

View File

@ -27,7 +27,7 @@ EOF
/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 \
/usr/lib/x86_64-linux-gnu/crtn.o > /dev/null
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q 'Hello world'

View File

@ -53,7 +53,7 @@ EOF
/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
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q 'Hello world'

View File

@ -50,7 +50,7 @@ EOF
/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
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q 'Hello world'

View File

@ -49,7 +49,7 @@ EOF
/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 \
/usr/lib/x86_64-linux-gnu/crtn.o > /dev/null
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q 'Hello world'

View File

@ -46,7 +46,7 @@ EOF
-lgcc_s \
--no-as-needed \
/usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \
/usr/lib/x86_64-linux-gnu/crtn.o > /dev/null
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q 'Hello world'

View File

@ -40,7 +40,7 @@ EOF
-lgcc_eh \
-lc \
/usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \
/usr/lib/x86_64-linux-gnu/crtn.o > /dev/null
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q 'Hello world'

View File

@ -35,7 +35,7 @@ EOF
/usr/lib/x86_64-linux-gnu/libgcc_s.so.1 \
$t/script \
/usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \
/usr/lib/x86_64-linux-gnu/crtn.o > /dev/null
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q 'Hello world'

View File

@ -32,7 +32,7 @@ EOF
/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 \
/usr/lib/x86_64-linux-gnu/crtn.o > /dev/null
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q 'Hello world'

View File

@ -11,6 +11,6 @@ _start:
nop
EOF
../mold -o $t/exe $t/a.o > /dev/null
../mold -o $t/exe $t/a.o
echo ' OK'

View File

@ -18,7 +18,7 @@ local2:
this_is_global:
EOF
../mold -o $t/exe $t/a.o $t/b.o > /dev/null
../mold -o $t/exe $t/a.o $t/b.o
readelf --symbols $t/exe | grep -q "
Symbol table '.symtab' contains 21 entries:

View File

@ -35,7 +35,7 @@ EOF
/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
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q '3 5 3 5'

View File

@ -35,7 +35,7 @@ EOF
/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
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q '3 5 3 5'

View File

@ -36,7 +36,7 @@ EOF
/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
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q '3 5 3 5'

View File

@ -35,7 +35,7 @@ EOF
/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
/usr/lib/x86_64-linux-gnu/crtn.o
$t/exe | grep -q '3 5 3 5'

View File

@ -12,7 +12,7 @@ _start:
EOF
../mold -o $t/exe $t/a.o > /dev/null
../mold -o $t/exe $t/a.o
readelf -a $t/exe > /dev/null
echo ' OK'