Draft
Conversation
Member
|
I tried the following test with this change: diff --git a/wild/tests/sources/elf/weak-ref-strong-def/weak-ref-strong-def-1.c b/wild/tests/sources/elf/weak-ref-strong-def/weak-ref-strong-def-1.c
new file mode 100644
index 0000000000..6cf1236844
--- /dev/null
+++ b/wild/tests/sources/elf/weak-ref-strong-def/weak-ref-strong-def-1.c
@@ -0,0 +1,7 @@
+int foo(void) {
+ return 42;
+}
+
+int bar(void) {
+ return 42;
+}
diff --git a/wild/tests/sources/elf/weak-ref-strong-def/weak-ref-strong-def-2.c b/wild/tests/sources/elf/weak-ref-strong-def/weak-ref-strong-def-2.c
new file mode 100644
index 0000000000..8737aa7886
--- /dev/null
+++ b/wild/tests/sources/elf/weak-ref-strong-def/weak-ref-strong-def-2.c
@@ -0,0 +1,5 @@
+int bar(void);
+
+int call_bar(void) {
+ return bar();
+}
diff --git a/wild/tests/sources/elf/weak-ref-strong-def/weak-ref-strong-def.c b/wild/tests/sources/elf/weak-ref-strong-def/weak-ref-strong-def.c
new file mode 100644
index 0000000000..3a1d90ba6e
--- /dev/null
+++ b/wild/tests/sources/elf/weak-ref-strong-def/weak-ref-strong-def.c
@@ -0,0 +1,31 @@
+//#Config:shared
+//#Mode:dynamic
+//#Object:runtime.c
+//#Shared:weak-ref-strong-def-1.c
+//#Object:weak-ref-strong-def-2.c
+//#ExpectDynSym:foo binding=weak
+//#ExpectDynSym:bar binding=global
+//#DiffIgnore:section.got
+//#DiffIgnore:.dynamic.DT_NEEDED
+
+#include "../common/runtime.h"
+
+// This weak reference is the only reference to foo.
+int __attribute__((weak)) foo(void);
+
+// For bar, there's also a non-weak reference in a different object file.
+int __attribute__((weak)) bar(void);
+
+void _start(void) {
+ runtime_init();
+
+ if (!foo || foo() != 42) {
+ exit_syscall(10);
+ }
+
+ if (!bar || bar() != 42) {
+ exit_syscall(11);
+ }
+
+ exit_syscall(42);
+}Linker-diff showed diffs for |
Member
Author
|
There is also a race condition there. Once in a few runs this passes: While failing case produces: Also, sym-info: DetailsWeak bar (failing test) Strong bar (passing test): I guess once in a while we process 31 before 44, so 31 adds WEAK and 44 removes it. I had posted this PoC because I was wondering if this is somewhat close to being a solution. Thank you for showing me how well it falls apart 😆. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proof of concept for #1817 (comment)