Skip to content

Commit

Permalink
Merge pull request #887 from knurling-rs/fix-interning-example
Browse files Browse the repository at this point in the history
Fix interning example
  • Loading branch information
jonathanpallant authored Nov 22, 2024
2 parents 4e77173 + c6200cb commit c874f24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
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

0 comments on commit c874f24

Please sign in to comment.