2019-04-06 21:08:09 +08:00
|
|
|
/* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
|
linker: sort app shared mem partition by alignment
If CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT is enabled,
the app shared memory partition may cause waste of memory
due to the need for padding.
For example, tests/subsys/jwt and board mps2_an385:
z_test_mem_partition: addr 0x20000000, size 52
z_libc_partition : addr 0x20000040, size 4
k_mbedtls_partition : addr 0x20008000, size 32736
ending at 0x2000ffff, taking up 65536 bytes
With power-of-two size and alignment requirement,
k_mbedtls_partition takes up 32KB memory and needs to be
aligned on 32KB boundary. If the above partitions are
ordered as shown, there needs to be a lot of padding
after z_libc_partition before k_mbedtls_partition can
start. In order to minimize padding, these partitions
need to be sort by size in descending order.
After the changes here, the partitions are:
k_mbedtls_partition : addr 0x20000000, size 32736
z_test_mem_partition: addr 0x20008000, size 52
z_libc_partition : addr 0x20008040, size 4
ending at 0x2000805f, taking up 32864 bytes
With the above example, sorting results in a saving
of 32672 bytes of saving.
Fixes #14121
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-03-11 05:20:21 +08:00
|
|
|
/*
|
|
|
|
* This hackish way of including files is due to CMake issues:
|
|
|
|
* https://gitlab.kitware.com/cmake/cmake/issues/11985
|
|
|
|
* https://gitlab.kitware.com/cmake/cmake/issues/13718
|
|
|
|
*
|
|
|
|
* When using the "Unix Makefiles" generator, CMake simply
|
|
|
|
* greps for "#include" to generate dependency list.
|
|
|
|
* So if doing it normally, both files are being included
|
|
|
|
* in the dependency list. This creates weird dependency
|
|
|
|
* issue:
|
|
|
|
*
|
|
|
|
* 1. Using A.ld to create a linker script A.cmd.
|
|
|
|
* 2. Using A.cmd to generate A_prebuilt.elf.
|
|
|
|
* 3. Using A_prebuilt.elf to create B.ld.
|
|
|
|
* 4. Creating B.cmd with B.ld.
|
|
|
|
* 5. Creating B_prebuilt.elf using B.cmd.
|
|
|
|
*
|
|
|
|
* Since the dependency list of A.cmd contains both
|
|
|
|
* A.ld and B.ld, when make is invoked again, B.ld
|
|
|
|
* is newer than A.cmd so everything from this point on
|
|
|
|
* gets rebuilt. In order to break this cycle, this
|
|
|
|
* hackish needs to be used since CMake does not parse
|
|
|
|
* macros, and thus these will not appear in
|
|
|
|
* the dependency list. The dependencies should then be
|
|
|
|
* put in CMakeLists.txt instead.
|
|
|
|
*
|
|
|
|
* Note: Ninja generator does not suffer from this issue.
|
|
|
|
*/
|
|
|
|
#ifdef LINKER_APP_SMEM_UNALIGNED
|
|
|
|
#define APP_SMEM_LD <app_smem_unaligned.ld>
|
|
|
|
#else
|
|
|
|
#define APP_SMEM_LD <app_smem_aligned.ld>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include APP_SMEM_LD
|
|
|
|
#undef APP_SMEM_LD
|