From f89e0aa367a7a77722998a16ef78f230b08a538c Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 25 Mar 2021 18:02:42 +0900 Subject: [PATCH] wip --- Makefile | 2 +- main.cc | 6 ++---- test/dynamic-linker.sh | 26 ++++++++++++++++++++++++++ test/strip.sh | 30 ++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 5 deletions(-) create mode 100755 test/dynamic-linker.sh create mode 100755 test/strip.sh diff --git a/Makefile b/Makefile index 59f6cf00..10f5a855 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ TBB_LIBDIR=$(wildcard $(CURRENT_DIR)/oneTBB/build/linux_intel64_*_release/) MALLOC_LIBDIR=$(CURRENT_DIR)/mimalloc/out/release CPPFLAGS=-g -IoneTBB/include -IxxHash -pthread -std=c++20 \ - -Wno-deprecated-volatile -Wno-switch -O0 \ + -Wno-deprecated-volatile -Wno-switch -O2 \ -DGIT_HASH=\"$(shell git rev-parse HEAD)\" LDFLAGS=-L$(TBB_LIBDIR) -Wl,-rpath=$(TBB_LIBDIR) \ -L$(MALLOC_LIBDIR) -Wl,-rpath=$(MALLOC_LIBDIR) \ diff --git a/main.cc b/main.cc index 44076987..2ec125ba 100644 --- a/main.cc +++ b/main.cc @@ -209,13 +209,11 @@ static void create_synthetic_sections() { add(out::got = new GotSection); add(out::gotplt = new GotPltSection); add(out::relplt = new RelPltSection); - if (!config.strip_all) - add(out::strtab = new StrtabSection); + add(out::strtab = new StrtabSection); add(out::shstrtab = new ShstrtabSection); add(out::plt = new PltSection); add(out::pltgot = new PltGotSection); - if (!config.strip_all) - add(out::symtab = new SymtabSection); + add(out::symtab = new SymtabSection); add(out::dynsym = new DynsymSection); add(out::dynstr = new DynstrSection); add(out::eh_frame = new EhFrameSection); diff --git a/test/dynamic-linker.sh b/test/dynamic-linker.sh new file mode 100755 index 00000000..b7c802ae --- /dev/null +++ b/test/dynamic-linker.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e +cd $(dirname $0) +echo -n "Testing $(basename -s .sh $0) ... " +t=$(pwd)/tmp/$(basename -s .sh $0) +mkdir -p $t + +cat < $t/log +! fgrep .interp $t/log + +readelf --dynamic $t/exe > $t/log + +../mold -o $t/exe $t/a.o --dynamic-linker=/foo/bar + +readelf --sections $t/exe > $t/log +fgrep -q .interp $t/log + +echo OK diff --git a/test/strip.sh b/test/strip.sh new file mode 100755 index 00000000..996c6637 --- /dev/null +++ b/test/strip.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e +cd $(dirname $0) +echo -n "Testing $(basename -s .sh $0) ... " +t=$(pwd)/tmp/$(basename -s .sh $0) +mkdir -p $t + +cat <<'EOF' | cc -x assembler -c -o $t/a.o -Wa,--keep-locals - +.globl _start, foo +_start: +foo: +bar: +.L.baz: +EOF + +../mold -o $t/exe $t/a.o +readelf --symbols $t/exe > $t/log +fgrep -q _start $t/log +fgrep -q foo $t/log +fgrep -q bar $t/log +fgrep -q .L.baz $t/log + +../mold -o $t/exe $t/a.o -strip-all +readelf --symbols $t/exe > $t/log +! fgrep -q _start $t/log +! fgrep -q foo $t/log +! fgrep -q bar $t/log +! fgrep -q .L.baz $t/log + +echo OK