zephyr/tests/application_development/code_relocation
Grzegorz Swiderski 460b6ef122 code_relocation: Add NOKEEP option
When using the code and data relocation feature, every relocated symbol
would be marked with `KEEP()` in the generated linker script. Therefore,
if any input files contained unused code, then it wouldn't be discarded
by the linker, even when invoked with `--gc-sections`.

This can cause unexpected bloat, or other link-time issues stemming from
some symbols being discarded and others not.

On the other hand, this behavior has been present since the feature's
introduction, so it should remain default for the users who rely on it.

This patch introduces support for `zephyr_code_relocate(... NOKEEP)`.
This will suppress the generation of `KEEP()` statements for all symbols
in a particular library or set of files.

Much like `NOCOPY`, the `NOKEEP` flag is passed to `gen_relocate_app.py`
in string form. The script is now equipped to handle multiple such flags
when passed from CMake as a semicolon-separated list, like so:

   "SRAM2:NOCOPY;NOKEEP:/path/to/file1.c;/path/to/file2.c"

Documentation and tests are updated here as well.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2024-01-15 13:20:17 +01:00
..
src modules: cmsis: move glue code to modules/cmsis 2023-08-24 13:20:21 +02:00
test_lib tests: application_development: code_relocation: Add absolute paths 2023-07-10 12:05:00 +02:00
CMakeLists.txt code_relocation: Add NOKEEP option 2024-01-15 13:20:17 +01:00
custom-sections.ld tests: application_development: add code_relocation test 2022-08-01 18:09:28 +01:00
Kconfig arch/riscv: support CONFIG_CODE_DATA_RELOCATION 2022-08-24 10:08:06 +02:00
linker_arm_sram2.ld tests: code_relocation: use per-SoC linker file for Arm tests 2023-07-14 09:38:43 +02:00
linker_riscv_qemu_sram2.ld tests: remove incorrect comment from code_relocation for RISCV 2022-10-03 10:09:53 +02:00
linker_xtensa_qemu_sram2.ld boards: qemu_xtensa: use dc233c core 2023-10-20 15:00:14 +02:00
prj.conf tests: remove CONFIG_ZTEST_NEW_API in all tests 2023-10-20 15:04:29 +02:00
prj_riscv.conf tests: remove CONFIG_ZTEST_NEW_API in all tests 2023-10-20 15:04:29 +02:00
prj_xtensa.conf tests: remove CONFIG_ZTEST_NEW_API in all tests 2023-10-20 15:04:29 +02:00
README.rst tests: application_development: add code_relocation test 2022-08-01 18:09:28 +01:00
testcase.yaml tests: code_relocation: exclude mr_canhubk3 board 2023-09-18 10:37:22 +01:00

.. _code_relocation:

Code relocation
#################

Overview
********
A simple example that demonstrates how relocation of code, data or bss sections
using a custom linker script.