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

Fix interning example #887

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]

- [#889]: Add script for book hosting
- [#887]: Fix interning example in the book
- [#884]: Upgrade dependencies: notify is now at v7, thiserror is now at v2
- [#883]: Mark decoder and parser not as unstable anymore
- [#880]: Merge function calls emitted by the macro to save space.
Expand All @@ -30,6 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [#807]: `defmt-print`: Add `watch_elf` flag to allow ELF file reload without restarting `defmt-print`

[#889]: https://github.com/knurling-rs/defmt/pull/889
[#887]: https://github.com/knurling-rs/defmt/pull/887
[#884]: https://github.com/knurling-rs/defmt/pull/884
[#883]: https://github.com/knurling-rs/defmt/pull/883
[#880]: https://github.com/knurling-rs/defmt/pull/880
Expand Down
23 changes: 13 additions & 10 deletions book/src/interning.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All string literals are interned in a custom ELF section.
This has proven to be the way that requires the less post-processing and implementation work.
It is not without downsides as we'll see.

The basic pattern for interning a string is this:
The basic pattern for interning a string is this (although note that what `defmt` actually does is more complicated - see the [Dealing with duplicates](./duplicates.md) section for more details):

``` rust,no_run,noplayground
#[export_name = "the string that will be interned"]
Expand All @@ -21,15 +21,18 @@ A linker script is required to group all these strings into a single OUTPUT link
``` text
SECTIONS
{
/* NOTE: simplified */
.my_custom_section /* <- name of the OUTPUT linker section */
(INFO) /* <- metadata section: not placed in Flash */
: 0 /* <- start address of this section */
{
*(.my_custom_section.*); /* <- name of the INPUT linker section */
/*^ ^ glob pattern */
/*^ from any object file (~= crate) */
}
/* NOTE: simplified */
.my_custom_section 0 (INFO) :
/* ^^^^^^ metadata section: not placed in Flash */
/* ^ start address of this section */
/* ^^^^^^^^^^^^^^^ name of the OUTPUT linker section */
{
*(.my_custom_section);
*(.my_custom_section.*);
/* ^ glob pattern for sub-sections */
/* ^^^^^^^^^^^^^^^^^ name of the INPUT linker section */
/* ^ from any object file (~= crate) */
}
}
```

Expand Down
Loading