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++
12748 ディスカッション

Help! Problem in linking!

Altera_Forum
名誉コントリビューター II
1,349件の閲覧回数

I met the problem whem linking: 

Unable to reach (at 0x0009bf4c) from the global pointer (at 0x000861e0) because the offset (89452) is out of the allowed range, -32678 to 32767. 

 

The code was more than 64KB。 How to solve it? 

A document said that the -G compiler option should be fixed. This option sets the 

threshold size. But how to make it? 

Help me. Thanks!
0 件の賞賛
5 返答(返信)
Altera_Forum
名誉コントリビューター II
604件の閲覧回数

hi Dugufei, 

 

did you try -G0 ? 

i had this problem with redboot... fixed with this option. found somewhere here in this forum. maybe it works for you, too.  

 

regards, martin
Altera_Forum
名誉コントリビューター II
604件の閲覧回数

Yes, I've tried from -G0 to -G4. But it didn't work! 

The Altera's document didn't say clearly. 

 

 

--- Quote Start ---  

originally posted by mrwgm@Oct 26 2006, 04:24 AM 

hi dugufei, 

 

did you try -g0 ? 

i had this problem with redboot... fixed with this option. found somewhere here in this forum. maybe it works for you, too.  

 

regards, martin 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=18925) 

--- quote end ---  

 

--- Quote End ---  

Altera_Forum
名誉コントリビューター II
604件の閲覧回数

you should double check your code, something should be wrong with your source. 

you can try get rid of the variable which lead to fail.
Altera_Forum
名誉コントリビューター II
604件の閲覧回数

Hi Dugufei, 

 

I sometimes get this error when trying to access data in a different section. I have a section of battery-backed SRAM, away from the RAM used for my code and bss. To put something in the NVR I have to use: 

# define COMM_NVR __attribute__((section(".common_nvr"))) 

 

// example of putting variable in NVR. 

unsigned char fred COMMON_NVR; 

 

When I want to access fred from another file I have to: 

 

extern unsigned char fred COMMON_NVR; 

 

If I forget to add the COMMON_NVR attribute then I get the linker error you describe, &#39;Can&#39;t reach....&#39;. 

 

So maybe your unreachable variable isn&#39;t where you think it is. 

 

Banx.
Altera_Forum
名誉コントリビューター II
604件の閲覧回数

But I can run seccussfly the same code in ARM7 platform. So, I think the code is all right. 

Now I want to port the code into Nios2.  

The problem is what is the right -G compiler option&#12290;
返信