As mentioned, the ABI does not define specific behavior in all instances but rather is a canon of principles that allow for platform or system-specific variation. For example, the ABI does not specify that PIC (position independent code) addressing will be used in all cases, but standardizes its implementation for those cases where it is used. Some of the variants are incompatible with each other. For example, if any object uses the DBST PIC model, then all must. In such cases, toolchains are expected to use build attributes to prevent incompatible objects from being combined.
This section describes some of the more common use cases and how they relate to the ABI. These cases are not mutually exclusive, nor do they completely cover all the possibilities.
- Bare Metal—Standalone. This model refers to a single self-contained statically-linked executable. It is the simplest form in terms of interoperability. The relevant parts of the ABI are the object-level components in the lower part of Figure 1-1. Since the executable is statically linked and bound (relocated), there is typically no need for position-independence. Since it is self-contained, it need not contain dynamic linking information, procedure linkage table (PLT) stubs, or a global offset table (GOT).
- Bare Metal—Dynamic Linking. This model refers to a system in which an executable may dynamically link to separately linked modules, but not within the controlled environment of an OS. Addressing may or may not be position-independent, depending on the environment. The environment may impose additional conventions on addressing or placement. This model would use the dynamic linking components of Figure 1-1. Specifics of the bare-metal dynamic linking model are detailed in Section 14.5.
- Shared Objects. This refers to a dynamic linking model in which statically linked modules (libraries) can be shared among multiple separately-linked clients (executables or other libraries). The fundamental issue is that each client must have its own copy of the library's data. The ABI solves this through two related structures: position-independent addressing, and the data segment base table (DSBT) mechanism.
- Position Independence. This refers to a means of addressing without the use of address constants, enabling code and/or data to be loaded and run at any address without relocation. The term PIC generally means Position Independent Code, but position independence can refer to code, data, or both. Shared libraries require position independent data so that multiple clients can have private copies; in the context of shared libraries, the term PIC sometimes connotes this narrower definition. Libraries in ROM may require position independent addressing to reference other objects if their addresses are not bound when the ROM is created. Position-independent data relies on the Data Page register (B14). When multiple modules are involved, such as with dynamic linking, the DSBT (Data Segment Base Table) model is a mechanism that can be used to reset the DP when calling from one module to another.
- Linux. Executables and Shared Libraries built for the Linux environment must follow certain conventions. They have dynamic linking information. They require position independence using the DSBT model. Objects built for Linux have the ELFOSABI_C6000_LINUX flag in the EI_OSABI field of the ELF header. Augmentations to the ABI for the Linux platform are detailed in Chapter 15.
- ROMing. It may be desirable to build a separately linked module that will reside in ROM. Once linked, its addresses are permanently bound. It may be subsequently linked against other modules, either statically or dynamically. For this purpose, the ABI defines a special class of ELF file that presents both a static and dynamic linking view and a handful of section flags to indicate sections whose addresses are permanently bound. ROM modules typically use PIC addressing to make them independent of the placement of other modules they reference.