forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linker: Add devnull memory for cortex_m and riscv32
Added memory region which is intended to be removed from the final binary but may be using in byproduct to extract data used by the host tools (e.g. strings used by logging). Add devnull region to Cortex-M and RISCV linker scripts. Signed-off-by: Krzysztof Chruściński <[email protected]>
- Loading branch information
1 parent
0fe6c72
commit dfb3674
Showing
4 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* | ||
* DESCRIPTION | ||
* Platform independent set of macros for creating a memory segment for | ||
* aggregating data that shall be kept in the elf file but not in the binary. | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDE_LINKER_LINKER_DEVNULL_H_ | ||
|
||
#if defined(CONFIG_LINKER_DEVNULL_MEMORY) | ||
|
||
#if defined(CONFIG_XIP) | ||
#if (!defined(ROM_ADDR) && !defined(ROM_BASE)) || !defined(ROM_SIZE) | ||
#error "ROM_SIZE, ROM_ADDR or ROM_BASE not defined" | ||
#endif | ||
#endif /* CONFIG_XIP */ | ||
|
||
#if (!defined(RAM_ADDR) && !defined(RAM_BASE)) || !defined(RAM_SIZE) | ||
#error "RAM_SIZE, RAM_ADDR or RAM_BASE not defined" | ||
#endif | ||
|
||
#if defined(CONFIG_XIP) && !defined(ROM_ADDR) | ||
#define ROM_ADDR ROM_BASE | ||
#endif | ||
|
||
#if !defined(RAM_ADDR) | ||
#define RAM_ADDR RAM_BASE | ||
#endif | ||
|
||
#define ROM_END_ADDR (ROM_ADDR + ROM_SIZE) | ||
#define DEVNULL_SIZE CONFIG_LINKER_DEVNULL_MEMORY_SIZE | ||
#define ROM_DEVNULL_END_ADDR (ROM_END_ADDR + DEVNULL_SIZE) | ||
#define MAX_ADDR UINT32_MAX | ||
|
||
/* Determine where to put the devnull region. It should be adjacent to the ROM | ||
* region. If ROM starts after RAM or the distance between ROM and RAM is big | ||
* enough to fit the devnull region then devnull region is placed just after | ||
* the ROM region. If it cannot be done then the devnull region is placed before | ||
* the ROM region. It is possible that the devnull region cannot be placed | ||
* adjacent to the ROM (e.g. ROM starts at 0 and RAM follows ROM). In that | ||
* case compilation fails and the devnull region is not supported in that | ||
* configuration. | ||
*/ | ||
#if !defined(CONFIG_XIP) | ||
|
||
#if RAM_ADDR >= DEVNULL_SIZE | ||
#define DEVNULL_ADDR (RAM_ADDR - DEVNULL_SIZE) | ||
#else | ||
#define DEVNULL_ADDR (RAM_ADDR + RAM_SIZE) | ||
#endif | ||
|
||
#else /* CONFIG_XIP */ | ||
|
||
#if ((ROM_ADDR > RAM_ADDR) && ((MAX_ADDR - ROM_END_ADDR) >= DEVNULL_SIZE)) || \ | ||
((ROM_END_ADDR + DEVNULL_SIZE) <= RAM_ADDR) | ||
#define DEVNULL_ADDR ROM_END_ADDR | ||
#elif ROM_ADDR > DEVNULL_SIZE | ||
#define DEVNULL_ADDR (ROM_ADDR - DEVNULL_SIZE) | ||
#else | ||
#error "Cannot place devnull segment adjacent to ROM region." | ||
#endif | ||
|
||
#if defined(CONFIG_LINKER_DEVNULL_MEMORY) | ||
#define DEVNULL_REGION DEVNULL_ROM | ||
#else | ||
#define DEVNULL_REGION ROMABLE_REGION | ||
#endif | ||
|
||
#endif /* CONFIG_XIP */ | ||
|
||
#endif /* CONFIG_LINKER_DEVNULL_MEMORY */ | ||
|
||
#endif /* ZEPHYR_INCLUDE_LINKER_LINKER_DEVNULL_H_ */ |