target_baremetal.cmake 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # SPDX-License-Identifier: Apache-2.0
  2. # See root CMakeLists.txt for description and expectations of these macros
  3. macro(toolchain_ld_baremetal)
  4. # LINKERFLAGPREFIX comes from linker/ld/target.cmake
  5. zephyr_ld_options(
  6. -nostdlib
  7. -static
  8. ${LINKERFLAGPREFIX},-X
  9. ${LINKERFLAGPREFIX},-N
  10. )
  11. # Funny thing is if this is set to =error, some architectures will
  12. # skip this flag even though the compiler flag check passes
  13. # (e.g. ARC and Xtensa). So warning should be the default for now.
  14. #
  15. # Skip this for native application as Zephyr only provides
  16. # additions to the host toolchain linker script. The relocation
  17. # sections (.rel*) requires us to override those provided
  18. # by host toolchain. As we can't account for all possible
  19. # combination of compiler and linker on all machines used
  20. # for development, it is better to turn this off.
  21. #
  22. # CONFIG_LINKER_ORPHAN_SECTION_PLACE is to place the orphan sections
  23. # without any warnings or errors, which is the default behavior.
  24. # So there is no need to explicitly set a linker flag.
  25. if(CONFIG_LINKER_ORPHAN_SECTION_WARN)
  26. zephyr_ld_options(
  27. ${LINKERFLAGPREFIX},--orphan-handling=warn
  28. )
  29. elseif(CONFIG_LINKER_ORPHAN_SECTION_ERROR)
  30. zephyr_ld_options(
  31. ${LINKERFLAGPREFIX},--orphan-handling=error
  32. )
  33. endif()
  34. endmacro()