-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Convert Imports to Indirect Calls for Dynamic Linking #10003
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
Closed
awtcode
wants to merge
14
commits into
emscripten-core:main
from
awtcode:convert_imports_to_indirects
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dace97e
Pass emscripten library functions to Binaryen
cadcode f7d9146
Generate JS lib functions
cadcode 6dd79a2
Export original version of functions from side module to avoid legali…
cadcode 9302439
Add more comments
cadcode f033cb6
Change library-file to js-symbols
cadcode ea7f146
Incorporate review comments.
cadcode 52d370b
Add test for ImportsToIndirectCalls pass
cadcode f68f43a
Disable test_dylink_function_pointer_equality for ASAN and LSAN
cadcode 462cc81
Do not encode to utf-8 to avoid byte and str concatenation
f2153c9
Fix rebase errors
cadcode c39972d
Remove unnecessary macros
cadcode 4cb8d94
Remove unnecessary originalAccessor variable
cadcode 8688871
Merge branch 'master' into convert_imports_to_indirects
cadcode f100e2f
Do not run test_dylink_imports_to_indirect_calls in wasm2js mode.
cadcode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8559,6 +8559,41 @@ def test_safe_stack_dylink(self): | |
| } | ||
| ''', ['abort(stack overflow)', '__handle_stack_overflow'], assert_returncode=None) | ||
|
|
||
| @no_fastcomp('WASM backend convert imports to indirect calls') | ||
| @needs_dlfcn | ||
| def test_dylink_imports_to_indirect_calls(self): | ||
| # The ImportsToIndirectCalls pass in Binaryen should not allocate a new fp$ for | ||
| # imports that are already address taken. Test out both cases whereby the imports | ||
| # are either used directly or thru its address. | ||
| self.set_setting('EXIT_RUNTIME', 1) | ||
| self.dylink_test(main=r''' | ||
| #include <stdio.h> | ||
| extern int sidey(); | ||
| extern int sidey2(); | ||
| typedef int (*func)(); | ||
| int mainy() { | ||
| return 19; | ||
| } | ||
|
|
||
| int main(int argc, char **argv) { | ||
| sidey(); | ||
| func funcPtr = (0 == argc) ? sidey:sidey2; | ||
| funcPtr(); | ||
| return 0; | ||
| } | ||
| ''', side=r''' | ||
| #include <stdio.h> | ||
| int sidey() { | ||
| printf("sidey says %d ", 17); | ||
| return 17; | ||
| } | ||
|
|
||
| int sidey2() { | ||
| printf("sidey2 says %d", 18); | ||
| return 18; | ||
| } | ||
| ''', expected='sidey says 17 sidey2 says 18', need_reverse=False) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we somehow verify that this worked by looking at import/exports of the resulting wasm file? |
||
|
|
||
| @also_with_standalone_wasm | ||
| def test_undefined_main(self): | ||
| # By default in emscripten we allow main to be undefined. Its used when | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stole this idea/code and made it part of #10350 in a function called
get_all_js_library_funcshopefully that is about to land and we can use that shared function here.