Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dylink test to show weakly defined function issue. NFC #13774

Merged
merged 1 commit into from
Mar 26, 2021
Merged
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
Add dylink test to show weakly defined function issue. NFC
Currently we don't support weakly defined functions that
exist in both the main and the side module.
sbc100 committed Mar 26, 2021
commit a9f91fb94573e6c19ce0f8f650fdde182f7d2f37
13 changes: 13 additions & 0 deletions tests/core/test_dylink_weak_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>

void side();

__attribute__((weak)) int foo() {
return 42;
}

int main(int argc, char const *argv[]) {
printf("main foo() -> %d\n", foo());
side();
return 0;
}
2 changes: 2 additions & 0 deletions tests/core/test_dylink_weak_main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main foo() -> 42
side foo() -> 42
11 changes: 11 additions & 0 deletions tests/core/test_dylink_weak_side.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdio.h>

extern int foo();

__attribute__((weak)) int foo() {
return 99;
}

void side() {
printf("side foo() -> %d\n", foo());
}
8 changes: 8 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -4602,6 +4602,14 @@ def test_dylink_argv_argc(self):
expected='3 hello world!',
need_reverse=False)

@disabled('https://github.com/emscripten-core/emscripten/issues/13773')
def test_dylink_weak(self):
# Verify that weakly symbols can be defined in both side module and main
# module
main = test_file('core', 'test_dylink_weak_main.c')
side = test_file('core', 'test_dylink_weak_side.c')
self.dylink_testf(main, side, force_c=True, need_reverse=False)

def test_random(self):
src = r'''#include <stdlib.h>
#include <stdio.h>