Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12604 Discussions

problems with the global pointer

Altera_Forum
Honored Contributor II
1,218 Views

Hello! 

 

I have a project with three memories, one sram, one sram with back up and an On-Chip Memory. I'm using Interniche stack, superloop mode. 

 

When all code sections goes in th SRAMs, the compialtion i succesfull. However, I NEED to put .rwdata secion in the onchip memory. But with that setting I have the following linking error: 

 

/cygdrive/e/Raul/Proyectos/ProyectoComunicacion/Hardware/Version25/Progressive_CIII_V12/software/FinalEthernetPort/TCPTask.c:58: Unable to reach cticks (at 0x028426c0) from the global pointer (at 0x0301d20c) because the offset (-8235852) is out of the allowed range, -32678 to 32767. 

 

cticks it's a global variable. It's declared as a extern in the interniche library, and i'm defining it in one of my source files. 

 

Following to "NIOS Software Developer Handbook", Global Pointer Section, pag 161, I added the option "-G 4" but this it's not helping, I get exactly the same error http://www.alteraforum.com/images/smilies/frown.gif

 

Does anybody knows how to deal with this problem?.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
414 Views

The global pointer area normally spans both .rwdata and .bss. If these sections are not consecutive in memory, the global pointer may not be able to reach them both. 

 

Some ideas: 

 

Can you move both .rwdata and .bss to the same location? 

 

Can you change you address map so that .rwdata and .bss are closer together? 

 

Perhaps the global pointer can be disabled. Maybe "-G 0" would disable it completely? Although, I am not sure if that is a valid value for the -G option.
0 Kudos
Altera_Forum
Honored Contributor II
414 Views

You can force a data item into (or out of) the 'small data' areas - accessed though %gp - using gcc __attribute__((section("name"))). 

Data in sections .sdata, .sdata.*, .sbss, .sbss.* etc is accessed through %gp. 

The linker script defines how the sections are actually mapped into memory. You'll probably need to edit the one the IDE uses. 

 

There is also a bug (well missing optimisation) in gcc so it fails to uses %gprel(symbol+offset)(gp) when accessing structures that have been placed in the 'small data' area.
0 Kudos
Altera_Forum
Honored Contributor II
414 Views
0 Kudos
Reply