Knowledge Base Article
Why do I get a linker error with global pointers when trying to compile my Nios II code?
Description
An issue has been identified with the linker script generated by the 11.1 version of the Nios® II Board Support Package (BSP) generator. The issue leads to link errors similar to the following:
/opt/altera/11.0sp1/nios2eds/bin/gnu/H-i686-pc-linux-gnu/bin/../lib/gcc/nios2-elf/4.1.2/../../../../nios2-elf/lib/libstdc .a(locale.o): In function `std::locale::id::_M_id() const':
/build/swbuild/SJ/nightly/11.0sp1/208/l32/work/ip/sopc/app/gnu/BUILD/gnu/build-0-gcc.nios2-elf.i686-pc-linux-gnu/nios2-elf/libstdc -v3/src/../../../../src/gcc-4.1/libstdc -v3/src/locale.cc:436: warning: Unable to reach (null) (at 0x00e77e74) from the global pointer (at 0x00d217f0) because the offset (1402500) is out of the allowed range, -32678 to 32767.
Resolution
To resolve this issue, open the linker.x linker script in the BSP and edit the following line:
.rwdata LOADADDR (.rodata) SIZEOF (.rodata) : AT ( LOADADDR (.rodata) SIZEOF (.rodata) SIZEOF (.rwdata) )
Remove the last SIZEOF (.rwdata) directive, to correctly define the .rwdata section as follows:
.rwdata LOADADDR (.rodata) SIZEOF (.rodata) : AT ( LOADADDR (.rodata) SIZEOF (.rodata) )
This issue shall be fixed in a future version of the Nios II Software Build Tools for Eclipse.