Specifications

Figure 6-4: Small Global Data Sections
RAM
.rwdata
.bss
.sbss2
.sbss
.sdata2
.sdata
If the total size of the small global data structures is more than 64 KB, these data structures overflow the
global pointer region. The linker produces an error message saying "Unable to reach <variable
name> ... from the global pointer ... because the offset ... is out of the allowed
range, -32678 to 32767."
You can fix this by using fewer globals or using the following compiler options:
-mno-gpopt -- Do not generate global pointer accesses. You may need to specify this switch explicitly
when building programs that include large amounts of small data structures.
-G <size> -- This option sets the threshold size. For example, -G 4 restricts global pointer usage to
data structures 4 bytes long or smaller. Reducing the global pointer threshold reduces the size of the
small global data sections. <size> is expressed in decimal. You can specify this compiler option
through a project setting. You must set this option to the same value for both the BSP and the applica‐
tion project.
For information about manipulating project settings, refer to "HAL BSP Settings".
Related Information
HAL BSP Settings on page 6-1
GCC Nios II Options
6-40
Global Pointer Register
NII5V2
2015.05.14
Altera Corporation
Developing Programs Using the Hardware Abstraction Layer
Send Feedback