This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

c55x: How to zero initialize .bss

Zero-initializing .bss is a standard function of startup code, but unfortunately not for c55x.

It can be done as follows.

 

Your linker .cmd file has something like this:

   .bss      > DARAM0

Change it to:

   .bss      { *(.bss*) } > DARAM0

 

This will auto-magically give you the symbols __bss__ and __end__, denoting the start and end of the .bss section.

With these you can simply memset the area:

void zero_init(void)
{
  extern unsigned char __bss__;
  extern unsigned char __end__;
  memset(&__bss__, 0, &__end__ - &__bss__);
}

 

Call it during startup, for example just before auto_init in boot.asm.

 

BR. Leo.

  • This topic is also discussed in the C55x compiler manual, in the section titled Initializing Static and Global Variables.  

    Leo Havmoeller said:
      .bss      { *(.bss*) } > DARAM0

    You shouldn't need to change the link command file to get the symbols __bss__ and __end__.

    Thanks and regards,

    -George

  • > This topic is also discussed in the C55x compiler manual, in the section titled Initializing Static and Global Variables.  

    Yes, but the simple solution shown above (for a ROM model) is not mentioned. It is also not found on either the wiki or forum, hence I found it relevant to post it.

    BR. Leo.