You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Don't pad .text to page size for pulley
When targeting pulley we aren't directly emitting executable
code in the .text section and we don't have a good idea of the
true target page size so we end up with ELF files that can
have a significant amount of extra padding around the .text
section with no benefit to the consumer.
The change here aligns with the already present section flag
SH_WASMTIME_NOT_EXECUTED. Padding elimination for the .rodata.wasm
section is already handled by the presence/absence of the
memory-init-on-cow configuration.
For a basic wasip1 hello-world rust program with the combination
of this patch and `-O memory-init-cow=n` I saw a reduction in
the compiled wasm ELF from 421KB to 189KB with the sections no
longer showing as being padded out significantly:
```
$ objdump --section-headers target/wasm32-wasip1/release/hello-wasm-world-0x00.cwasm
target/wasm32-wasip1/release/hello-wasm-world-0x00.cwasm: file format elf64-littleriscv
Sections:
Idx Name Size VMA Type
0 00000000 0000000000000000
1 .wasmtime.engine 00000353 0000000000000000 DATA
2 .wasmtime.bti 00000001 0000000000000000 DATA
3 .text 00011bdc 0000000000000000
4 .wasmtime.addrmap 00011c5c 0000000000000000 DATA
5 .wasmtime.traps 00000ae0 0000000000000000 DATA
6 .rodata.wasm 000019e8 0000000000000000 DATA
7 .name.wasm 000027a6 0000000000000000 DATA
8 .wasmtime.info 000010f9 0000000000000000 DATA
9 .symtab 00001788 0000000000000000
10 .strtab 000040f0 0000000000000000
11 .shstrtab 00000089 0000000000000000
```
* code_memory: don't unpublish non-published memory
For the case that we construct a CodeMemory with a custom_code_memory
implementation but we don't end up publishing memory, do not try
to unpublish the memory.
This could happen in a few cases:
- The .text didn't require being made executable
- There's an error or other circumstances cause the CodeMemory
to be dropped prior to publish being called.
Within the context of the .text size optimizations for pulley,
this caused CI failures for a default pulley target as the
errant unpublish was now being called on non-aligned memory.
Prior to the .text optimizations there was still an mprotect
being called to change bits on the .text region which just happened
to be benign.
* In addition to published, check needs_executable before custom unpublishing
Changing the placement of published or introducing new state could
be other ways of addressing the problem of doing a custom
unpublish but those approaches would potentially create other issues
with avoiding duplicate relocations.
Given where this code would be used and the ability for the
`custom_code_memory` to provide their own protections, this
seems very much so Good Enough and gets the tests passing
again while providing more reasonable behavior for user code.
0 commit comments