https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122146
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The bug is how you define the section variables:
extern u32 _sdata;
extern u32 _edata;
extern u32 _data_loadaddr;
extern u32 _sbss;
extern u32 _ebss;
extern u32 _estack;
extern u32 _stack_size;
extern u32 _data_size;
extern u32 _bss_size;
They need to declared as array with unknown bounds like this:
extern u32 _sdata[];
extern u32 _edata[];
extern u32 _data_loadaddr[];
extern u32 _sbss[];
extern u32 _ebss[];
extern u32 _estack[];
extern u32 _stack_size;
extern u32 _data_size;
extern u32 _bss_size;
Otherwise gcc thinks there is only one element to the variables and optimizes
as such.