diff options
Diffstat (limited to 'sys-devel/mold/files')
-rw-r--r-- | sys-devel/mold/files/mold-2.0.0-reloc-test-fix.patch | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/sys-devel/mold/files/mold-2.0.0-reloc-test-fix.patch b/sys-devel/mold/files/mold-2.0.0-reloc-test-fix.patch new file mode 100644 index 000000000000..8e6e04f5d535 --- /dev/null +++ b/sys-devel/mold/files/mold-2.0.0-reloc-test-fix.patch @@ -0,0 +1,58 @@ +https://github.com/rui314/mold/issues/1067 +https://github.com/rui314/mold/commit/1582b720d58df61bc4c0ae39fa269e3b250b94df + +From 1582b720d58df61bc4c0ae39fa269e3b250b94df Mon Sep 17 00:00:00 2001 +From: Rui Ueyama <ruiu@bluewhale.systems> +Date: Fri, 28 Jul 2023 14:58:57 +0900 +Subject: [PATCH] Weak undefs should not keep DSOs alive + +Fixes https://github.com/rui314/mold/issues/1067 +--- a/elf/input-files.cc ++++ b/elf/input-files.cc +@@ -1396,7 +1396,8 @@ SharedFile<E>::mark_live_objects(Context<E> &ctx, + if (sym.is_traced) + print_trace_symbol(ctx, *this, esym, sym); + +- if (esym.is_undef() && sym.file && !sym.file->is_alive.test_and_set()) { ++ if (esym.is_undef() && !esym.is_weak() && sym.file && ++ !sym.file->is_alive.test_and_set()) { + feeder(sym.file); + + if (sym.is_traced) +--- /dev/null ++++ b/test/elf/as-needed-dso2.sh +@@ -0,0 +1,33 @@ ++#!/bin/bash ++. $(dirname $0)/common.inc ++ ++cat <<EOF | $CC -c -fPIC -o $t/a.o -xc - ++int foo() { ++ return 0; ++} ++EOF ++ ++cat <<EOF | $CC -c -fPIC -o $t/b.o -xc - ++__attribute__((weak)) int foo(); ++ ++int bar() { ++ if (foo) return foo(); ++ return 0; ++} ++EOF ++ ++cat <<EOF | $CC -xc -c -o $t/c.o - ++int bar(); ++ ++int main() { ++ return bar(); ++} ++EOF ++ ++$CC -B. -shared -o $t/libfoo.so $t/a.o ++$CC -B. -shared -o $t/libbar.so $t/b.o ++$CC -B. -o $t/exe $t/c.o -L$t -Wl,--as-needed -lfoo -lbar ++ ++readelf --dynamic $t/exe > $t/log ++! grep libfoo.so $t/log || false ++grep -q libbar.so $t/log + |