Forum Discussion
Altera_Forum
Honored Contributor
20 years agoHi Cliff,
By default, the compiler wants to access data less than 8 bytes with the global pointer. An int is less than 8 bytes, so the global pointer is used to calculate the address. In your case, .text section can't be reached with the gp. The -G0 option can be used to turn off addressing via the gp, but it's not very portable. So far, I've found it best to use a void data type so you don't have to worry about the gp at all: <div class='quotetop'>QUOTE </div> --- Quote Start --- - extern int stext; + extern void stext; - extern int etext; + extern void etext;[/b] --- Quote End --- Basically, void doesn't have a size, so the compiler _should_ never use the gp. You can also define the symbols as functions & cast on assignment, but void is probably more readible ;-) Regards, --Scott