Skip to content

Commit 8c909b9

Browse files
committed
update readme
1 parent b0ef3ce commit 8c909b9

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

samples/custom_section/README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
description: "The related code/working directory of this example resides in directory {WAMR_DIR}/samples/custom_section"
33
---
44

5-
The "custom_section" sample project
6-
==============
5+
# The "custom_section" sample project
76

87
This sample demonstrates how to:
98

@@ -21,8 +20,20 @@ The Wasm application is built from:
2120

2221
The assembler file emits a section named `.custom_section.demo`, which becomes a Wasm custom section named `demo` in the final `.wasm` file.
2322

24-
Build this sample
25-
==============
23+
## Why use a custom section for this payload
24+
25+
The payload in this sample is treated as read-only metadata. Putting it in a custom section lets the embedder access the bytes directly from the loaded module through `wasm_runtime_get_custom_section`, instead of copying the data into Wasm linear memory per instance.
26+
27+
That matters when the data is large or rarely changed:
28+
29+
- the bytes stay in the module image as immutable data
30+
- the host can look them up by section name and use them in place
31+
- the Wasm app only needs to pass a small section name and receive a small handle
32+
- no extra application-level serialization or buffer duplication is needed for the read-only payload
33+
34+
This pattern is useful for embedded assets, lookup tables, model metadata, certificates, and other static blobs that the host wants to consume without treating them as mutable Wasm heap data.
35+
36+
## Build this sample
2637

2738
Execute the `build.sh` script. The host executable and the Wasm app are generated in `out`.
2839

@@ -36,8 +47,7 @@ Build the AoT variant only when needed by passing `--aot`. This preserves the `d
3647
./build.sh --aot
3748
```
3849

39-
Run the sample
40-
==========================
50+
## Run the sample
4151

4252
Enter the output directory and run the Wasm sample directly:
4353

@@ -57,5 +67,3 @@ To run the AoT artifact instead, pass `--aot` to the helper script:
5767
```sh
5868
./run.sh --aot
5969
```
60-
61-
When running under WSL, use the Linux workspace path layout, for example `/home/tl/projects/wasm-micro-runtime/...`, not a Windows drive path.

0 commit comments

Comments
 (0)