Forum Discussion
Altera_Forum
Honored Contributor
11 years ago --- Quote Start --- hello,mallocr.c:2150: warning: unable to reach (null) (at 0x0023814c) from the global pointer (at 0x0022addc) because the offset (54128) is out of the allowed range, -32678 to 32767. --- Quote End --- This (lamentably obscure) error message indicates overflow of the .sdata segment. By default (see -G n -- but use with extreme caution!) globals of size 8 bytes or less are assigned to .sdata, which is limited to 64KB (32KB in Nios2 toolchains before ACDS 14.1 iirc). The purpose of this is to allow these globals to be accessed via fast, compact 16-bit offsets from the GP register. Globals may also be assigned to .sdata using the gcc __attribute__ mechanism, which can result in faster or more compact code if used judiciously. The simplest (if not necessarily best) way to deal with .sdata overflow as above is to use the -mno-gpopt switch (available in Nios2 gcc 3.x toolchains and also in gcc 4.x starting with ACDS 14.1). This will eliminate the 64KB limit at the cost of generating slower less dense code which uses 32-bit offsets throughout to access these globals. Some might argue that using fewer globals is a better solution. :-)