This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BUG in nrf52_common.ld?

Using GCC 4.8.4, it seems to me, that the nrf52_common.ld shiped with the sdk version 12.2 contains a bug:

If an image is defined where the .text data fits into the flash, but where the .data initialization data would lead to an overflow of the flash, the linker does not complain about the overflow.

The reasons for this seems to be that the linker script doesn't declare the .data section to be within the flash MEMORY. Adding AT > FLASHto the end of the .data section declaration seems to fix the issue:

__etext = .;

.data : 
{
    __data_start__ = .;
    *(vtable)
    *(.data*)

    . = ALIGN(4);
...
    __data_end__ = .;

} > RAM AT > FLASH

The start of the section seems a little bit suspicious to me too. What happens if __etext is not properly aligned?

Parents
  • Hi

    I have checked the problem and you are entirely right. Nevertheless instead of your proposed solution what do you think of an assert? (Adding some spacings on underscores to avoid text formatting)

    {code} Wrong code, see bellow. {endcode}

    The symbols used allow for users to add sections after .text (before .ARM.extab) and after .data (before .bss) and still be covered.

    I will modify the linker scripts on a future release if you do not think there is any problem.

Reply
  • Hi

    I have checked the problem and you are entirely right. Nevertheless instead of your proposed solution what do you think of an assert? (Adding some spacings on underscores to avoid text formatting)

    {code} Wrong code, see bellow. {endcode}

    The symbols used allow for users to add sections after .text (before .ARM.extab) and after .data (before .bss) and still be covered.

    I will modify the linker scripts on a future release if you do not think there is any problem.

Children
Related