Skip to content

Put all EM_JS/EM_ASM strings in a specific data section - #13443

Merged
sbc100 merged 1 commit into
masterfrom
em_js_data_section
Feb 17, 2021
Merged

sbc100 merged 1 commit into
masterfrom
em_js_data_section

Conversation

@sbc100

@sbc100 sbc100 commented Feb 8, 2021 •

Copy link
Copy Markdown
Collaborator

This way, once binaryen has extracted that string data
it can potentially remove the segment or at least zero it
out.

Fixes #9366

@sbc100 sbc100 changed the title Put all em_js strings in a specific data section Put all EM_JS strings in a specific data section Feb 8, 2021
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 8, 2021
If we find a data segment with the name "em_js", strip it from the
binary.  Even in debug mode the names given to data segments by clang
will always start with ".data." or ".rodata" so there is no risk of
normal data ending up in a section with this name.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 8, 2021
If we find a data segment with the name "em_js", strip it from the
binary.  Even in debug mode the names given to data segments by clang
will always start with ".data." or ".rodata" so there is no risk of
normal data ending up in a section with this name.

See: emscripten-core/emscripten#13443
@kripken

kripken commented Feb 8, 2021

Copy link
Copy Markdown
Member

Is it worth working on an EM_JS-specific solution? That is, is there no solution for EM_JS and EM_ASM?

@sbc100

sbc100 commented Feb 8, 2021

Copy link
Copy Markdown
Collaborator Author

Is it worth working on an EM_JS-specific solution? That is, is there no solution for EM_JS and EM_ASM?

Sure, I'm just doing it one step at a time. EM_JS is actually quite different to EM_ASM in that the strings don't actually need to have addresses in LLVM sense... so the solution we end up with might look different.

But also I do think and EM_JS-only solution is better than nothing.

@sbc100

sbc100 commented Feb 8, 2021

Copy link
Copy Markdown
Collaborator Author

This part of the change is really a no-brainer (IMHO). It doesn't actually do anything except group the EM_JS strings into a single data section. Even if we never get around to actually purging it on the binaryen side (which I totally think we will) I still think its good for debugging / understandably.

@sbc100

sbc100 commented Feb 8, 2021

Copy link
Copy Markdown
Collaborator Author

Updated the comment to include plans to further investigate the EM_ASM situation.

sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 8, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 8, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 8, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 8, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 8, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 8, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 8, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443

@kripken kripken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, sounds great.

sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 9, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 9, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 11, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 11, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 11, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 11, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 12, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
sbc100 added a commit to WebAssembly/binaryen that referenced this pull request Feb 12, 2021
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.

See: emscripten-core/emscripten#13443
@sbc100 sbc100 changed the title Put all EM_JS strings in a specific data section Put all EM_JS/EM_ASM strings in a specific data section Feb 14, 2021
This way, once binaryen has extracted that string data
it can potentially remove the segment or at least zero it
out.

Fixes #9366
@sbc100
sbc100 force-pushed the em_js_data_section branch from 842309d to 510d924 Compare February 17, 2021 23:03
@sbc100
sbc100 merged commit 2e38ed2 into master Feb 17, 2021
@sbc100
sbc100 deleted the em_js_data_section branch February 17, 2021 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why are JavaScript inline snippets embedded in wasm data?

2 participants