Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wild/tests/external_tests/mold_skip_tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ tests = [
"arch-x86_64-note2.sh", # The order of sections is different.
"arch-x86_64-plt.sh", # We use `.got.plt`, not `.plt.got`.
"arch-x86_64-reloc-overflow.sh", # Different message formats
"as-needed-weak.sh", # Mold-specific behaviour: GNU ld and lld do not activate --as-needed libs for weak refs
"auxiliary.sh", # Different message format
"build-id.sh", # Different build ID data size
"cmdline.sh", # Different message formats for unknown options.
Expand Down Expand Up @@ -217,7 +218,6 @@ tests = [
[skipped_groups.misc]
reason = "Not grouped yet"
tests = [
"as-needed-weak.sh",
"bno-symbolic.sh",
"canonical-plt.sh",
"common-archive.sh",
Expand Down
1 change: 1 addition & 0 deletions wild/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3618,6 +3618,7 @@ fn integration_test(
"segment-end-syms.c",
"linker-script-filename-match.c",
"tls-apx-relocs.s",
"as-needed-weak.c",
"linker-script-unclosed-comment.c",
"execstack.s"
)]
Expand Down
1 change: 1 addition & 0 deletions wild/tests/sources/as-needed-weak-lib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int fn1(void) { return 1; }
27 changes: 27 additions & 0 deletions wild/tests/sources/as-needed-weak.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//#Object:runtime.c
//#Mode:dynamic
//#Shared:force-dynamic-linking.c
//#Shared:template(--push-state --as-needed $O --pop-state):as-needed-weak-lib.c
// Tests that --as-needed shared libraries are NOT activated for weak symbol
// references. This matches the behaviour of GNU ld and lld (mold differs).
// If fn1 is non-null the lib was incorrectly activated; exit with fn1() (1)
// so the test fails. If fn1 is null the lib was correctly excluded; exit 42.
// force-dynamic-linking.c is linked without --as-needed so both Wild and GNU
// ld produce a dynamic binary, enabling a meaningful diff.
//#DiffIgnore:.dynamic.DT_NEEDED
//#DiffIgnore:section.got
//#DiffIgnore:.dynamic.DT_RELA
//#DiffIgnore:.dynamic.DT_RELAENT
//#DiffIgnore:rel.undefined-weak.dynamic.R_X86_64_GLOB_DAT

#include "runtime.h"

__attribute__((weak)) int fn1(void);

void _start(void) {
runtime_init();
if (fn1) {
exit_syscall(fn1());
}
exit_syscall(42);
}
Loading