Why Are Some Objects Positioned Into Memory That I Reserved?

The memory reservation options (see Section 2.4.3.6 “How Do I Place a Function Into a Unique Section?”) will adjust the range of addresses associated with classes used by the linker. Most variables and function are placed into sections (see Compiler-Generated Psects) that are linked anywhere inside these class ranges and so are affected by these reservation options.

Some sections are explicitly placed at an address rather than being linked anywhere in an address range, e.g., the sections that holds the code to be executed at Reset is always linked to address 0 because that is where the Reset location is defined to be for 8-bit devices. Such a section will not be affected by the -mrom option, even if you use it to reserve memory address 0. Sections that hold code associated with Reset and interrupts can be shifted using the -mcodeoffset option (see Section 4.6.1.3 “Codeoffset Option”).

Check the assembly list file (see Assembly List Files) to determine the names of sections that hold objects and code. Check the linker options in the map file (see Map Files), to see if psects have been linked explicitly or if they are linked anywhere in a class. See also, the linker options -p (P: Position Psect) and -A (A: Define Linker Class).