1# Copyright (c) 2024 Nordic Semiconductor 2# 3# SPDX-License-Identifier: Apache-2.0 4 5check_set_linker_property(TARGET linker PROPERTY base 6 ${LINKERFLAGPREFIX},--gc-sections 7 ${LINKERFLAGPREFIX},--build-id=none 8) 9 10check_set_linker_property(TARGET linker PROPERTY baremetal 11 -nostdlib 12 -static 13 ${LINKERFLAGPREFIX},-X 14 ${LINKERFLAGPREFIX},-N 15) 16 17check_set_linker_property(TARGET linker PROPERTY orphan_warning 18 ${LINKERFLAGPREFIX},--orphan-handling=warn 19) 20 21check_set_linker_property(TARGET linker PROPERTY orphan_error 22 ${LINKERFLAGPREFIX},--orphan-handling=error 23) 24 25check_set_linker_property(TARGET linker PROPERTY memusage "${LINKERFLAGPREFIX},--print-memory-usage") 26 27# -no-pie is not supported until binutils 2.37. 28# If -no-pie is passed to old binutils <= 2.36, it is parsed 29# as separate arguments -n and -o, which results in output file 30# called "-pie". 31if("${GNULD_VERSION_STRING}" VERSION_GREATER_EQUAL 2.37) 32 set_property(TARGET linker PROPERTY no_position_independent "${LINKERFLAGPREFIX},-no-pie") 33else() 34 set_property(TARGET linker PROPERTY no_position_independent) 35endif() 36 37set_property(TARGET linker PROPERTY partial_linking "-r") 38 39set_property(TARGET linker PROPERTY lto_arguments -flto=auto -fno-ipa-sra -ffunction-sections -fdata-sections) 40 41check_set_linker_property(TARGET linker PROPERTY no_relax ${LINKERFLAGPREFIX},--no-relax) 42 43check_set_linker_property(TARGET linker PROPERTY sort_alignment 44 ${LINKERFLAGPREFIX},--sort-common=descending 45 ${LINKERFLAGPREFIX},--sort-section=alignment 46) 47 48# Some linker flags might not be purely ld specific, but a combination of 49# linker and compiler, such as: 50# --coverage for clang 51# --gcov for gcc 52# So load those flags now. 53include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/${COMPILER}/linker_flags.cmake OPTIONAL) 54