target_baremetal.cmake 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. -no-pie
  9. ${LINKERFLAGPREFIX},-X
  10. ${LINKERFLAGPREFIX},-N
  11. )
  12. # Funny thing is if this is set to =error, some architectures will
  13. # skip this flag even though the compiler flag check passes
  14. # (e.g. ARC and Xtensa). So warning should be the default for now.
  15. #
  16. # Skip this for native application as Zephyr only provides
  17. # additions to the host toolchain linker script. The relocation
  18. # sections (.rel*) requires us to override those provided
  19. # by host toolchain. As we can't account for all possible
  20. # combination of compiler and linker on all machines used
  21. # for development, it is better to turn this off.
  22. #
  23. # CONFIG_LINKER_ORPHAN_SECTION_PLACE is to place the orphan sections
  24. # without any warnings or errors, which is the default behavior.
  25. # So there is no need to explicitly set a linker flag.
  26. if(CONFIG_LINKER_ORPHAN_SECTION_WARN)
  27. zephyr_ld_options(
  28. ${LINKERFLAGPREFIX},--orphan-handling=warn
  29. )
  30. elseif(CONFIG_LINKER_ORPHAN_SECTION_ERROR)
  31. zephyr_ld_options(
  32. ${LINKERFLAGPREFIX},--orphan-handling=error
  33. )
  34. endif()
  35. endmacro()