Skip to content

Commit

Permalink
logging: Add option to remove strings from binary
Browse files Browse the repository at this point in the history
Add option to remove string literals which are constant and
never touched by the firmware. It can save significant amount
of RO memory.

Signed-off-by: Krzysztof Chruściński <[email protected]>
  • Loading branch information
nordic-krch authored and carlescufi committed Oct 27, 2023
1 parent f172a1a commit 59abf92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/zephyr/linker/common-rom/common-rom-logging.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

#include <zephyr/linker/iterable_sections.h>

#ifdef CONFIG_LOG_FMT_SECTION_STRIP
SECTION_PROLOGUE(log_strings,(COPY),SUBALIGN(4))
{
Z_LINK_ITERABLE(log_strings);
} GROUP_ROM_LINK_IN(DEVNULL_REGION, DEVNULL_REGION)
#else
ITERABLE_SECTION_ROM(log_strings, 4)
#endif

ITERABLE_SECTION_ROM(log_const, 4)

Expand Down
7 changes: 7 additions & 0 deletions subsys/logging/Kconfig.misc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ config LOG_FMT_SECTION
removing strings from final binary and should be used for dictionary
logging.

config LOG_FMT_SECTION_STRIP
bool "Strip log strings from binary"
depends on !LOG_OUTPUT
depends on LOG_FMT_SECTION
depends on LINKER_DEVNULL_SUPPORT
imply LINKER_DEVNULL_MEMORY

config LOG_USE_TAGGED_ARGUMENTS
bool "Using tagged arguments for packaging"
depends on !PICOLIBC
Expand Down

0 comments on commit 59abf92

Please sign in to comment.