SPRUIG8H January 2018 – February 2023
The C7000 compiler treats memory as a single linear block that is partitioned into subblocks of code and data. Each subblock of code or data generated by a C program is placed in its own continuous memory space. The compiler assumes that a full 48-bit address space is available in target memory.
The linker, not the compiler, defines the memory map and allocates code and data into target memory. The compiler assumes nothing about the types of memory available, about any locations not available for code or data (holes), or about any locations reserved for I/O or control purposes. The compiler produces relocatable code that allows the linker to allocate code and data into the appropriate memory spaces. For example, you can use the linker to allocate global variables into on-chip RAM or to allocate executable code into external ROM. You can allocate each block of code or data individually into memory, but this is not a general practice (an exception to this is memory-mapped I/O, although you can access physical memory locations with C/C++ pointer types).
The C7000 compiler requires that all code and data lie within 2 GB of virtual address space. Use a linker command file to place your code and data within this 2 GB virtual address region. The C7000 compiler produces code that uses position-independent addressing to obtain the addresses of functions (in some cases) and to access statically allocated data in memory. Instructions that use position-independent addressing have limited reach.
Information about linker command files can be found in Section 12.5. For further information, see the C7000 Embedded Application Binary Interface (EABI) Reference Guide (SPRUIG4), specifically the sections on “Computing Code Addresses” and “Data Allocation and Addressing”.