Forum Discussion
Altera_Forum
Honored Contributor
21 years agoDisabling GP-addressing in generated source code
Hi Everybody, I would like to share some thougts about the way to control when the compiler uses GP-addressing to address global data structures. This is resulted also from a talk with Mon...
Altera_Forum
Honored Contributor
21 years agoThe compiler assumes that all data in the sdata and sbss sections can be reached using the GP register. The compiler otherwise treats these sections the same as the data and bss sections.
So if you declare global variables as being in a different section (different memory) the compiler won't use GP relative addressing which will be safe but potentially slower. Are you using your own linker script? If so then you need to ensure that the _gp linker variable (which sets up the value of gp) is within range of the .sbss and .sdata sections. ps. It would be possible to perform the gprel optimisations at link time but this would be a lot more work so isn't near the top of the list yet.