lui $4,%hi(addr) daddiu $4,$4,%lo(addr)
The sequence is much longer when ‘ addr ’ is a 64-bit symbol. See Directives to override the size of symbols .
In order to cut down on this overhead, most embedded MIPS systems set aside a 64-kilobyte “small data” area and guarantee that all data of size n and smaller will be placed in that area. The limit n is passed to both the assembler and the linker using the command-line option -G n , see Assembler options . Note that the same value of n must be used when linking and when assembling all input files to the link; any inconsistency could cause a relocation overflow error.
The size of an object in the
section is set by the
directive that defines it. The size of an external object may be set with the
directive. For example, ‘
’ declares that the object at
is 4 bytes in length, while leaving
When no -G option is given, the default limit is 8 bytes. The option -G 0 prevents any data from being automatically classified as small.
It is also possible to mark specific objects as small by putting them in the special sections
, which are “small” counterparts of
respectively. The toolchain will treat such data as small regardless of the
On startup, systems that support a small data area are expected to initialize register
, also known as
, in such a way that small data can be accessed using a 16-bit offset from that register. For example, when ‘
’ is small data, the ‘
’ instruction above is equivalent to:
Small data is not supported for SVR4-style PIC.