![]() |
![]() |
| |||
|
Move sections supplied from relocatable objects are concatenated and output in the object being created by the link-editor. However, the following conditions cause the link-editor to process the move entries and expand their contents into a traditional data item:
Note SectionSometimes a vendor or system engineer needs to mark an object file with special information that other programs will check for conformance, compatibility, and so forth. Sections of type SHT_NOTE and program header elements of type PT_NOTE can be used for this purpose. The note information in sections and program header elements holds any number of entries, as shown in the following figure. For 64- and 32-bit objects, each entry is an array of 4-byte words in the format of the target processor. Labels are shown in Figure 7-6 to help explain note information organization, but they are not part of the specification. Figure 7-5 Note Information ![]() The elements of the structure are:
The note segment shown in the following figure holds two entries. Figure 7-6 Example Note Segment ![]() Note - The system reserves note information with no name (namesz == 0) and with a zero-length name (name[0] == '\0') but currently defines no types. All other names must have at least one non-null character. Relocation SectionsRelocation is the process of connecting symbolic references with symbolic definitions. For example, when a program calls a function, the associated call instruction must transfer control to the proper destination address at execution. Relocatable files must have information that describes how to modify their section contents, thus allowing executable and shared object files to hold the right information for a process's program image. Relocation entries are these data. Relocation entries can have the following structure, defined in sys/elf.h:
The elements of this structure are:
Rela entries contain an explicit addend. Entries of type Rel store an implicit addend in the location to be modified. 32-bit and 64-bit SPARC use only Elf32_Rela and Elf64_Rela relocation entries respectively. Thus, the r_addend member serves as the relocation addend. x86 uses only Elf32_Rel relocation entries. The field to be relocated holds the addend. In all cases, the addend and the computed result use the same byte order. A relocation section can reference two other sections: a symbol table, identified by the sh_info section header entry, and a section to modify, identified by the sh_link section header entry. Sections specifies these relationships. An sh_link entry is required when a relocation section exists in a relocatable object, but is optional for executables and shared objects. The relocation offset is sufficient to perform the relocation. Relocation Types (Processor-Specific)Relocation entries describe how to alter instruction and data fields in the following figures. Bit numbers appear in the lower box corners. On the SPARC platform, relocation entries apply to bytes (byte8), half-words (half16), or words (the others). ![]() On 64-bit SPARC, relocations also apply to extended-words (xword64): ![]() On x86, relocation entries apply to words (word32): ![]() word32 specifies a 32-bit field occupying 4 bytes with an arbitrary byte alignment. These values use the same byte order as other word values in the x86 architecture: ![]() In all cases, the r_offset value designates the offset or virtual address of the first byte of the affected storage unit. The relocation type specifies which bits to change and how to calculate their values. Calculations for the following relocation types assume the actions are transforming a relocatable file into either an executable or a shared object file. Conceptually, the link-editor merges one or more relocatable files to form the output. The link-editor first decides how to combine and locate the input files. Then it updates the symbol values. Finally the link-editor performs the relocation. Relocations applied to executable or shared object files are similar and accomplish the same result. Descriptions in the tables in this section use the following notation: | |||
| |||