sbrk.c: undefined reference to `end' in nrf connect SDK v2.4.0

Hi Team,

Earlier, we developed a library using nordic sdk v2.3.0 on nRF5340 TF-M secure environment. Now we planned to switch from nordic sdk v2.3.0 to v2.4.0.

While trying to compile our source code using nordic sdk v2.4.0, we observed the linker error (undefined reference to end) but this error is not observed in nordic sdk v2.3.0.

Linker Error:

c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/lib/thumb/v8-m.main+fp/hard\libnosys.a(sbrk.o): in function `_sbrk':
sbrk.c:(.text._sbrk+0x1c): undefined reference to `end'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

I could find the same problem in below link(ticket). But we are not using malloc or any Dynamic memory related functions anywhere in the code. But unable to understand why we are getting this error.

https://devzone.nordicsemi.com/f/nordic-q-a/101643/undefined-reference-to-end-with-nrf-connect-sdk-v2-4-0

After adding CONFIG_DEBUG=y, this error is resolved. As you suggested, we are unwilling to use this.

For v2.3.0, In CMakeLists.txt we were using below libs

target_link_libraries(tfm_lib
    PRIVATE
       tfm_secure_api
       platform_s
       psa_interface
       secure_fw
       tfm_psa_rot_partition_crypto
)

 

For v2.4.0, we tried with below params

target_link_libraries(tfm_lib
    PRIVATE
       tfm_secure_api
       platform_s
       psa_interface
       secure_fw
       tfm_psa_rot_partition_crypto
)

and 

target_link_libraries(tfm_lib
    PRIVATE
        tfm_sprt
        platform_s
)

Anything need to added in CMakeLists.txt or prj.conf to fix the error(undefined reference to end). Could you please point out if we missed anything.

Note: We are using attestation and key derivation APIs in code.

Related