From af10d16a087b4264e55f39696b495ef45f135261 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Sat, 9 Mar 2019 00:58:57 -0800 Subject: [PATCH] linker: sort sections by alignment This turns on the linker flag to sort sections by alignment in decreasing size of symbols. This helps to minimize padding between symbols. This also adds the linker options to sort common symbols by alignment in descending to minimize the need for padding. Signed-off-by: Daniel Leung --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e04694a38b..3ab4ef394cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -384,6 +384,13 @@ zephyr_ld_options( ${LINKERFLAGPREFIX},--build-id=none ) +# Sort the common symbols and each input section by alignment +# in descending order to minimize padding between these symbols. +zephyr_ld_options( + ${LINKERFLAGPREFIX},--sort-common=descending + ${LINKERFLAGPREFIX},--sort-section=alignment + ) + get_property(TOPT GLOBAL PROPERTY TOPT) set_ifndef( TOPT -T)