Specifying Constant Data Location

By default, the CodeWarrior compiler allocates all constant values of a size greater than 8 bytes in the .rodata section. There are two solutions for storing constants with sizes smaller than 8 bytes to be allocated in this section:

Solution 1: Define the variable in section .rodata using the __declspec(section) directive in C or C++ source code. Using __declspec(section) to store small constants in .rodata shows an example.

Listing 1. Using __declspec(section) to store small constants in .rodata
#define SMALL_ROM_CONST __declspec(section ".rodata")

SMALL_ROM_CONST const unsigned int MyInt2 = 0x4534

Solution 2: Enter 0 in the Small Data2 option in the CodeWarrior IDE's Properties > C/C++ Build > Settings > Tool Settings > PowerPC CPU panel.