From dfbd498a50868d743296b12db765c05e3f6c152c Mon Sep 17 00:00:00 2001 From: PritamP20 Date: Fri, 13 Mar 2026 10:25:40 +0530 Subject: [PATCH] test: Add test for hidden symbol that can only be resolved from a DSO --- wild/tests/external_tests/mold_skip_tests.toml | 2 +- wild/tests/integration_tests.rs | 1 + wild/tests/sources/hidden-undef-lib.c | 1 + wild/tests/sources/hidden-undef.c | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 wild/tests/sources/hidden-undef-lib.c create mode 100644 wild/tests/sources/hidden-undef.c diff --git a/wild/tests/external_tests/mold_skip_tests.toml b/wild/tests/external_tests/mold_skip_tests.toml index b3c616a72..68af38583 100644 --- a/wild/tests/external_tests/mold_skip_tests.toml +++ b/wild/tests/external_tests/mold_skip_tests.toml @@ -175,6 +175,7 @@ tests = [ "empty-input.sh", # Different message formats "gc-sections.sh", # Passes when `--no-gc-sections` is passed. "hash-style.sh", # Wild doesn't support `--hash-style=none`. + "hidden-undef.sh", # Wild correctly errors, but message format differs from mold's. "help.sh", "invalid-version-script.sh", # Different message formats "linker-script-error.sh", # Different message formats @@ -229,7 +230,6 @@ tests = [ "discard.sh", "dynamic-linker.sh", "glibc-2.22-bug.sh", - "hidden-undef.sh", "initfirst.sh", "mergeable-strings.sh", "missing-error.sh", diff --git a/wild/tests/integration_tests.rs b/wild/tests/integration_tests.rs index 46e2e324a..f590368d8 100644 --- a/wild/tests/integration_tests.rs +++ b/wild/tests/integration_tests.rs @@ -3543,6 +3543,7 @@ fn integration_test( "symbol-priority.c", "symbol-binding.c", "hidden-ref.c", + "hidden-undef.c", "trivial_asm.s", "non-alloc.s", "gnu-unique.c", diff --git a/wild/tests/sources/hidden-undef-lib.c b/wild/tests/sources/hidden-undef-lib.c new file mode 100644 index 000000000..b4d9546c2 --- /dev/null +++ b/wild/tests/sources/hidden-undef-lib.c @@ -0,0 +1 @@ +int foo(void) { return 1; } diff --git a/wild/tests/sources/hidden-undef.c b/wild/tests/sources/hidden-undef.c new file mode 100644 index 000000000..6f71e893b --- /dev/null +++ b/wild/tests/sources/hidden-undef.c @@ -0,0 +1,17 @@ +// Tests that linking fails when a hidden symbol is only available from a DSO. + +//#Object:runtime.c +//#Mode:dynamic +//#RunEnabled:false +//#Shared:hidden-undef-lib.c +//#ExpectError:foo + +#include "runtime.h" + +// foo is declared hidden — must not be resolved from the DSO above. +__attribute__((visibility("hidden"))) int foo(void); + +void _start(void) { + runtime_init(); + exit_syscall(foo()); +}