target_base.cmake 857 B

123456789101112131415161718192021222324252627282930
  1. # SPDX-License-Identifier: Apache-2.0
  2. # See root CMakeLists.txt for description and expectations of these macros
  3. macro(toolchain_ld_base)
  4. if(NOT PROPERTY_LINKER_SCRIPT_DEFINES)
  5. set_property(GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES -D__GCC_LINKER_CMD__)
  6. endif()
  7. # TOOLCHAIN_LD_FLAGS comes from compiler/gcc/target.cmake
  8. # LINKERFLAGPREFIX comes from linker/ld/target.cmake
  9. zephyr_ld_options(
  10. ${TOOLCHAIN_LD_FLAGS}
  11. )
  12. zephyr_ld_options(
  13. ${LINKERFLAGPREFIX},--gc-sections
  14. ${LINKERFLAGPREFIX},--build-id=none
  15. )
  16. # Sort the common symbols and each input section by alignment
  17. # in descending order to minimize padding between these symbols.
  18. zephyr_ld_option_ifdef(
  19. CONFIG_LINKER_SORT_BY_ALIGNMENT
  20. ${LINKERFLAGPREFIX},--sort-common=descending
  21. ${LINKERFLAGPREFIX},--sort-section=alignment
  22. )
  23. endmacro()