nRF Connect SDK link error with GCC 12

I'm using arm-none-eabi-gcc from Fedora linux repositories. It got updated to version 12, and now it's not possible to compile the SDK - there is a problem with linking. It can be replicated, e.g. on the NRF9160 udp example with SDK version 2.1.0. It can be temporarily solved by lowering binutils to v2.37.

Problematic versions:

  • arm-none-eabi-gcc-cs-1:12.2.0-1.fc36.x86_64
  • arm-none-eabi-gcc-cs-c++-1:12.2.0-1.fc36.x86_64
  • arm-none-eabi-binutils-cs-1:2.39-1.fc36.x86_64

[ 97%] Linking C executable ../bin/tfm_s.axf
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: warning: ../bin/tfm_s.axf has a LOAD segment with RWX permissions
/usr/lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: warning: ../bin/tfm_s.axf has a LOAD segment with RWX permissions
collect2: error: ld returned 1 exit status

Parents Reply Children
  • The problem is that TFM is built as a separate CMake project. Therefore, zephyr_ld_options are not passed to it.

    As a fix for now, I've added --no-warn-rwx-segments to ncs/modules/tee/tf-m/trusted-firmware-m/toolchain_GNUARM.cmake:

    macro(tfm_toolchain_reset_linker_flags)
        set_property(DIRECTORY PROPERTY LINK_OPTIONS "")
    
        add_link_options(
            --entry=Reset_Handler
            --specs=nano.specs
            LINKER:--no-warn-rwx-segments
            LINKER:-check-sections
            LINKER:-fatal-warnings
            LINKER:--gc-sections
            LINKER:--no-wchar-size-warning
            ${MEMORY_USAGE_FLAG}
        )
    endmacro()

Related