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>
This commit is contained in:
parent
bccec3cccd
commit
460b6ef122
4 changed files with 67 additions and 29 deletions
|
@ -37,8 +37,9 @@ zephyr_code_relocate(FILES src/test_file3.c LOCATION SRAM2_TEXT)
|
|||
zephyr_code_relocate(FILES src/test_file3.c LOCATION RAM_DATA)
|
||||
zephyr_code_relocate(FILES src/test_file3.c LOCATION SRAM2_BSS)
|
||||
|
||||
|
||||
zephyr_code_relocate(FILES ${ZEPHYR_BASE}/kernel/sem.c ${RAM_PHDR} LOCATION RAM)
|
||||
# Test NOKEEP support. Placing both KEEP and NOKEEP symbols in the same location
|
||||
# (this and test_file2.c in RAM) should work fine.
|
||||
zephyr_code_relocate(FILES ${ZEPHYR_BASE}/kernel/sem.c ${RAM_PHDR} LOCATION RAM NOKEEP)
|
||||
|
||||
if (CONFIG_RELOCATE_TO_ITCM)
|
||||
zephyr_code_relocate(FILES ${ZEPHYR_BASE}/lib/libc/minimal/source/string/string.c
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue