# Object files Hexagon object files are stored in the ELF file format (short for *Executable and Linkable Format*). This chapter describes object file compatibility and how various ELF elements are defined in Hexagon. It covers the following topics: - Compatibility - ELF header - ELF sections - Relocation ## Compatibility Object files for the Hexagon V4, V5x, and V6x processors are backward compatible when executed in User mode. Kernel-mode object files are not backward compatible due to changes in the system-level instruction set. ## ELF header The ELF header member e\_machine is set to the symbolic value EM\_HEXAGON (which has the decimal numeric value 164). The member e\_type can additionally be set to the symbolic value ET\_HEXAGON\_IR (numeric value 0xff00) to indicate that an object file contains compiler-generated intermediary representation language. Bits [11:0] of the member e\_flags indicate the version of the Hexagon processor that the object file was created for. The following table lists the possible values for this bit field. **Object processor version flags** | **Name** | **Value** | **Processor Version** | | --- | --- | --- | | EF\_HEXAGON\_MACH\_V4 | 0x3 | Hexagon V4 | | EF\_HEXAGON\_MACH\_V5 | 0x4 | Hexagon V5 | | EF\_HEXAGON\_MACH\_V55 | 0x5 | Hexagon V55 | | EF\_HEXAGON\_MACH\_V60 | 0x60 | Hexagon V60 | | EF\_HEXAGON\_MACH\_V61 | 0x61 | Hexagon V61 | | EF\_HEXAGON\_MACH\_V62 | 0x62 | Hexagon V62 | | EF\_HEXAGON\_MACH\_V65 | 0x65 | Hexagon V65 | | EF\_HEXAGON\_MACH\_V66 | 0x66 | Hexagon V66 | | EF\_HEXAGON\_MACH\_V67 | 0x67 | Hexagon V67 | | EF\_HEXAGON\_MACH\_V67T | 0x8067 | Hexagon V67 Small Core (V67t) | Note ISA is short for *Instruction Set Architecture*. In this context, it is considered equivalent to *processor version*. ## Sections In addition to supporting the standard ELF section indexes, Hexagon object files can also include processor-specific section indexes for common symbols stored in the small data area ([Special registers](https://docs.qualcomm.com/doc/80-N2040-23/topic/process-initialization.html#special-registers)). These indexes are listed in the following table. The suffix on the processor-specific section index names indicates the access size (in bytes) of the data in the corresponding section. The one name lacking a suffix is used to specify sections that have an access size other than one of the explicitly-specified values. **Section indexes for common small data** | **Name** | **Value** | **Description** | | --- | --- | --- | | SHN\_HEXAGON\_SCOMMON | 0xff00 | Other access sizes | | SHN\_HEXAGON\_SCOMMON\_1 | 0xff01 | Byte-sized access | | SHN\_HEXAGON\_SCOMMON\_2 | 0xff02 | Half-word-sized access | | SHN\_HEXAGON\_SCOMMON\_4 | 0xff03 | Word-sized access | | SHN\_HEXAGON\_SCOMMON\_8 | 0xff04 | Double-word-size access | To mark a section as residing in the small data area, the member, sh\_flags, can be set to the symbolic value, SHF\_HEXAGON\_GPREL (numeric value 0x10000000). ## Relocation Many different types of relocations are performed on the instructions and data stored in a Hexagon object file. The relocation types differ according to the instruction and data fields that are affected, and the kinds of calculations that are applied to the fields to perform the relocation. ### Relocation fields The relocation types are expressed using the data fields defined in the *relocation fields* table: > > > - Name – Specifies the name of the relocatable field (referenced in > the *relocation types* table). > - Width – Specifies the width (in bits) of the relocatable bit field. > Depending on the relocation type, either all or some of these bits > are modified by the relocation. > - Effective bits – Specifies how many of the bits in the relocation > field are modified. > - Bitmap – Specifies a bit pattern which indicates the bits in the > relocation field that are actually modified by the relocation. > - Byte address alignment – Specifies the byte address alignment (1, 2, > or 4) that is required for the relocation field. **Relocation fields** | **Name** | **Width** | **Effective bits** | **Bitmap** | **Byte address alignment** | | --- | --- | --- | --- | --- | | Word8 | 8 | 8 | 0xff | 1 | | Word16 | 16 | 16 | 0xffff | 2 | | Word32 | 32 | 32 | 0xffffffff | 4 | | Word32\_LO | 32 | 16 | 0x00c03fff | 4 | | Word32\_HL | 64 ^a^ | 16 and 16 | 0x00c03fff


0x00c03fff | 4 | | Word32\_GP | 32 | 16 | N/A ^b^ | 4 | | Word32\_B7 | 32 | 7 | 0x00001f18 | 4 | | Word32\_B9 | 32 | 9 | 0x003000fe | 4 | | Word32\_B13 | 32 | 13 | 0x00202ffe | 4 | | Word32\_B15 | 32 | 15 | 0x00df20fe | 4 | | Word32\_B22 | 32 | 22 | 0x01ff3ffe | | | Word32\_M21 | 32 | 21 | 0x0fff3fe0 | 4 | | Word32\_M25 | 32 | 25 | 0x0fff3fef | 4 | | Word32\_R6 | 32 | 6 | 0x000007e0 | 4 | | Word32\_U6 | 32 | 6 | N/A^b^ | 4 | | Word32\_U16 | 32 | 16 | N/A^b^ | 4 | | Word32\_X26 | 32 | 26 | 0x0fff3fff | 4 | - ^a^ The relocation calculations are applied to two 32-bit words in sequential addresses: first “(S + A) >> 16”, then “(S + A)”. - ^b^ – The bitmap varies according to the instruction opcode. Note Bitmaps are used to specify operands in instruction op-codes that must be relocated. When applying a relocation in these cases, the bits that are not specified in the bitmap must be protected from accidental modification. ### Relocation symbols Each relocation type is defined as a formula which is expressed in terms of the symbols listed in the following table. **Relocation symbols** | **Symbol** | **Description** | | --- | --- | | A | Addend used to compute value of relocatable field. | | B | Base address of object loaded into memory. | | G | Offset into global offset table ([Global offset table](https://docs.qualcomm.com/doc/80-N2040-23/topic/dynamic-linking.html#global-offset-table)) for the entry of a symbol. | | GOT | Address of entry zero in global offset table ([Global offset table](https://docs.qualcomm.com/doc/80-N2040-23/topic/dynamic-linking.html#global-offset-table)). | | GP | Value of GP register, typically the base address of the small
data area (\_SDA\_BASE\_). | | L | Offset into procedure linkage table ([Procedure linkage table](https://docs.qualcomm.com/doc/80-N2040-23/topic/dynamic-linking.html#linkage-table)) for the entry of a symbol. | | MB | Base address of all strings consumed by compiler message base
optimization (\_MSG\_BASE\_). | | P | Place address of the field being relocated.


Note


This value is computed using r\_offset in the
relocation entry. | | S | Value of the symbol whose index resides in the relocation entry
(unless the object is a shared object and the symbol index is
SHN\_UNDEF, in which case this is equivalent to symbol B). | | TLS | Thread-pointer-relative offset to a thread-local symbol. | | T | Base address of the static thread-local template that contains a
thread-local symbol. | ### Relocation types The relocation types are applied in a similar manner to relocatable, executable, and shared object files, except where noted otherwise. Only Elf32\_Rela relocation entries are used. Therefore, the original content of the instruction and data fields is irrelevant when calculating the relocation. The relocation types are defined in the following table: - Name – Specifies the symbolic name of the relocation type. - Value – Specifies the corresponding numeric identifier for the relocation type. - Field – Specifies the data field affected by the relocation type (see *relocation type* table). - Relocation – Sspecifies the algebraic formula used to perform the relocation (with the formula symbols defined in the *relocation symbols* table). - Result – Specifies the numeric format (signed or unsigned) of the relocated value. - Action – Specifies an additional operation performed on the relocated value as part of the relocation: - Truncate – Truncate the relocated value to fit the relocation field. - Verify – Check that the relocated value can fit in the relocation field, and generate an error if the value is too big to fit in its relocation field. - None – Perform no operation on the relocated value. **Relocation types** | **Name** | **Value** | **Field** | **Relocation** | **Result** | **Action** | | --- | --- | --- | --- | --- | --- | | R\_HEX\_NONE | 0 | None | None | None | None | | R\_HEX\_B22\_PCREL | 1 | Word32\_B22 | (S + A - P) >> 2 | Signed | Verify | | R\_HEX\_B15\_PCREL | 2 | Word32\_B15 | (S + A - P) >> 2 | Signed | Verify | | R\_HEX\_B7\_PCREL | 3 | Word32\_B7 | (S + A - P) >> 2 | Signed | Verify | | R\_HEX\_LO16 | 4 | Word32\_LO | (S + A) | Unsigned | Truncate | | R\_HEX\_HI16 | 5 | Word32\_LO | (S + A) >> 16 | Unsigned | Truncate | | R\_HEX\_32 | 6 | Word32 | (S + A) | Unsigned | Truncate | | R\_HEX\_16 | 7 | Word16 | (S + A) | Unsigned | Truncate | | R\_HEX\_8 | 8 | Word8 | (S + A) | Unsigned | Truncate | | R\_HEX\_GPREL16\_0 | 9 | Word32\_GP | (S + A - GP) | Unsigned | Verify | | R\_HEX\_GPREL16\_1 | 10 | Word32\_GP | (S + A - GP) >> 1 | Unsigned | Verify | | R\_HEX\_GPREL16\_2 | 11 | Word32\_GP | (S + A - GP) >> 2 | Unsigned | Verify | | R\_HEX\_GPREL16\_3 | 12 | Word32\_GP | (S + A - GP) >> 3 | Unsigned | Verify | | R\_HEX\_HL16 | 13 | Word32\_HL | (S + A) >> 16 and (S + A) | Unsigned | Truncate | | R\_HEX\_B13\_PCREL | 14 | Word32\_B13 | (S + A - P) >> 2 | Signed | Verify | | R\_HEX\_B9\_PCREL | 15 | Word32\_B9 | (S + A - P) >> 2 | Signed | Verify | | R\_HEX\_B32\_PCREL\_X | 16 | Word32\_X26 | (S + A - P) >> 6 | Signed | Truncate | | R\_HEX\_32\_6\_X | 17 | Word32\_X26 | (S + A) >> 6 | Unsigned | Verify | | R\_HEX\_B22\_PCREL\_X | 18 | Word32\_B22 | (S + A - P) & 0x3f | Signed | Verify | | R\_HEX\_B15\_PCREL\_X | 19 | Word32\_B15 | (S + A - P) & 0x3f | Signed | Verify | | R\_HEX\_B13\_PCREL\_X | 20 | Word32\_B13 | (S + A - P) & 0x3f | Signed | Verify | | R\_HEX\_B9\_PCREL\_X | 21 | Word32\_B9 | (S + A - P) & 0x3f | Signed | Verify | | R\_HEX\_B7\_PCREL\_X | 22 | Word32\_B7 | (S + A - P) & 0x3f | Signed | Verify | | R\_HEX\_16\_X | 23 | Word32\_U6 | (S + A) | Unsigned | Truncate | | R\_HEX\_12\_X | 24 | Word32\_R6 | (S + A) | Unsigned | Truncate | | R\_HEX\_11\_X | 25 | Word32\_U6 | (S + A) | Unsigned | Truncate | | R\_HEX\_10\_X | 26 | Word32\_U6 | (S + A) | Unsigned | Truncate | | R\_HEX\_9\_X | 27 | Word32\_U6 | (S + A) | Unsigned | Truncate | | R\_HEX\_8\_X | 28 | Word32\_U6 | (S + A) | Unsigned | Truncate | | R\_HEX\_7\_X | 29 | Word32\_U6 | (S + A) | Unsigned | Truncate | | R\_HEX\_6\_X | 30 | Word32\_U6 | (S + A) | Unsigned | Truncate | | R\_HEX\_32\_PCREL | 31 | Word32 | (S + A - P) | Signed | Verify | | R\_HEX\_COPY | 32 | Word32 | (see below) | | | | R\_HEX\_GLOB\_DAT | 33 | Word32 | (S + A) (see below) | Unsigned | Truncate | | R\_HEX\_JMP\_SLOT | 34 | Word32 | (S + A) (see below) | Unsigned | Truncate | | R\_HEX\_RELATIVE | 35 | Word32 | (B + A) (see below) | Unsigned | Truncate | | R\_HEX\_PLT\_B22\_PCREL | 36 | Word32\_B22 | (L + A - P) >> 2 | Signed | Verify | | R\_HEX\_GOTREL\_LO16 | 37 | Word32\_LO | (S + A - GOT) | Signed | Truncate | | R\_HEX\_GOTREL\_HI16 | 38 | Word32\_LO | (S + A - GOT) >> 16 | Signed | Truncate | | R\_HEX\_GOTREL\_32 | 39 | Word32 | (S + A - GOT) | Signed | Truncate | | R\_HEX\_GOT\_LO16 | 40 | Word32\_LO |


| Signed | Truncate | | R\_HEX\_GOT\_HI16 | 41 | Word32\_LO |

  1. >> 16


| Signed | Truncate | | R\_HEX\_GOT\_32 | 42 | Word32 |


| Signed | Truncate | | R\_HEX\_GOT\_16 | 43 | Word32\_U16 |


| Signed | Verify | | R\_HEX\_DTPMOD\_32 | 44 | Word32 | | | | | R\_HEX\_DTPREL\_LO16 | 45 | Word32\_LO | (S + A - T) | Signed | Truncate | | R\_HEX\_DTPREL\_HI16 | 46 | Word32\_LO | (S + A - T) >> 16 | Signed | Truncate | | R\_HEX\_DTPREL\_32 | 47 | Word32 | (S + A - T) | Signed | Truncate | | R\_HEX\_DTPREL\_16 | 48 | Word32\_U16 | (S + A - T) | Signed | Verify | | R\_HEX\_GD\_PLT\_B22\_PCREL | 49 | Word32\_B22 | (L + A - P) >> 2 | Signed | Verify | | R\_HEX\_GD\_GOT\_LO16 | 50 | Word32\_LO |


| Signed | Truncate | | R\_HEX\_GD\_GOT\_HI16 | 51 | Word32\_LO |

  1. >> 16


| Signed | Truncate | | R\_HEX\_GD\_GOT\_32 | 52 | Word32 |


| Signed | Truncate | | R\_HEX\_GD\_GOT\_16 | 53 | Word32\_U16 |


| Signed | Verify | | R\_HEX\_IE\_LO16 | 54 | Word32\_LO | (G + GOT) | Signed | Truncate | | R\_HEX\_IE\_HI16 | 55 | Word32\_LO | (G + GOT) >> 16 | Signed | Truncate | | R\_HEX\_IE\_32 | 56 | Word32 | (G + GOT) | Signed | Truncate | | R\_HEX\_IE\_GOT\_LO16 | 57 | Word32\_LO |


| Signed | Truncate | | R\_HEX\_IE\_GOT\_HI16 | 58 | Word32\_LO |

  1. >> 16


| Signed | Truncate | | R\_HEX\_IE\_GOT\_32 | 59 | Word32 |


| Signed | Truncate | | R\_HEX\_IE\_GOT\_16 | 60 | Word32\_U16 |


| Signed | Verify | | R\_HEX\_TPREL\_LO16 | 61 | Word32\_LO | (TLS - S - A) | Signed | Truncate | | R\_HEX\_TPREL\_HI16 | 62 | Word32\_LO | (TLS - S - A) >> 16 | Signed | Truncate | | R\_HEX\_TPREL\_32 | 63 | Word32 | (TLS - S - A) | Signed | Truncate | | R\_HEX\_TPREL\_16 | 64 | Word32\_U16 | (TLS - S - A) | Signed | Verify | | R\_HEX\_6\_PCREL\_X | 65 | Word32\_U6 | (S + A - P) | Unsigned | Truncate | | R\_HEX\_GOTREL\_32\_6\_X | 66 | Word32\_X26 | (S + A - GOT) >> 6 | Signed | Truncate | | R\_HEX\_GOTREL\_16\_X | 67 | Word32\_U6 | (S + A - GOT) | Unsigned | Truncate | | R\_HEX\_GOTREL\_11\_X | 68 | Word32\_U6 | (S + A - GOT) | Unsigned | Truncate | | R\_HEX\_GOT\_32\_6\_X | 69 | Word32\_X26 |

  1. >> 6


| Signed | Truncate | | R\_HEX\_GOT\_16\_X | 70 | Word32\_U6 |


| Signed | Truncate | | R\_HEX\_GOT\_11\_X | 71 | Word32\_U6 |


| Unsigned | Truncate | | R\_HEX\_DTPREL\_32\_6\_X | 72 | Word32\_X26 | (S + A - T) >> 6 | Signed | Truncate | | R\_HEX\_DTPREL\_16\_X | 73 | Word32\_U6 | (S + A - T) | Unsigned | Truncate | | R\_HEX\_DTPREL\_11\_X | 74 | Word32\_U6 | (S + A - T) | Unsigned | Truncate | | R\_HEX\_GD\_GOT\_32\_6\_X | 75 | Word32\_X26 |

  1. >> 6


| Signed | Truncate | | R\_HEX\_GD\_GOT\_16\_X | 76 | Word32\_U6 |


| Unsigned | Truncate | | R\_HEX\_GD\_GOT\_11\_X | 77 | Word32\_U6 |


| Unsigned | Truncate | | R\_HEX\_IE\_32\_6\_X | 78 | Word32\_X26 | (G + GOT) >> 6 | Signed | Truncate | | R\_HEX\_IE\_16\_X | 79 | Word32\_U6 | (G + GOT) | Unsigned | Truncate | | R\_HEX\_IE\_GOT\_32\_6\_X | 80 | Word32\_X26 |

  1. >> 6


| Signed | Truncate | | R\_HEX\_IE\_GOT\_16\_X | 81 | Word32\_U6 |


| Unsigned | Truncate | | R\_HEX\_IE\_GOT\_11\_X | 82 | Word32\_U6 |


| Unsigned | Truncate | | R\_HEX\_TPREL\_32\_6\_X | 83 | Word32\_X26 | (TLS - S - A) >> 6 | Signed | Truncate | | R\_HEX\_TPREL\_16\_X | 84 | Word32\_U6 | (TLS - S - A) | Unsigned | Truncate | | R\_HEX\_TPREL\_11\_X | 85 | Word32\_U6 | (TLS - S - A) | Unsigned | Truncate | | R\_HEX\_LD\_PLT\_B22\_PCREL | 86 | Word32\_B22 | (L + A - P) >> 2 | Signed | Verify | | R\_HEX\_LD\_GOT\_LO16 | 87 | Word32\_LO |


| Signed | Truncate | | R\_HEX\_LD\_GOT\_HI16 | 88 | Word32\_LO |

  1. >> 16


| Signed | Truncate | | R\_HEX\_LD\_GOT\_32 | 89 | Word32 |


| Signed | Truncate | | R\_HEX\_LD\_GOT\_16 | 90 | Word32\_R16 |


| Signed | Verify | | R\_HEX\_LD\_GOT\_32\_6\_X | 91 | Word32\_X26 |

  1. >> 6


| Signed | Truncate | | R\_HEX\_LD\_GOT\_16\_X | 92 | Word32\_U6 |


| Unsigned | Truncate | | R\_HEX\_LD\_GOT\_11\_X | 93 | Word32\_U6 |


| Unsigned | Truncate | | R\_HEX\_23\_REG | 94 | Word32\_B21 | (S + A - MB) >> 2 | Unsigned | Verify | | R\_HEX\_GD\_PLT\_B22\_PCREL\_X | 95 | Word32\_B22 | (S + A - P) & 0x3f | Signed | Truncate | | R\_HEX\_GD\_PLT\_B32\_PCREL\_X | 96 | Word32\_X26 | (S + A - P) >> 6 | Signed | Truncate | | R\_HEX\_LD\_PLT\_B22\_PCREL\_X | 97 | Word32\_B22 | (S + A - P) & 0x3f | Signed | Truncate | | R\_HEX\_LD\_PLT\_B32\_PCREL\_X | 98 | Word32\_X26 | (S + A - P) >> 6 | Signed | Truncate | | R\_HEX\_27\_REG | 99 | Word32\_M25 | (S + A - MB) >> 2 | Unsigned | Verify | Note If a relocation formula contains a reference to either G or GOT, an entry for the indicated symbol is implicitly created in the global offset table (GOT). If a relocation formula contains a reference to L, an entry for the indicated symbol is implicitly created in the procedure linkage table (PLT). ### Special relocation types Four of the relocation types listed in the *relocation types* table have special semantics – they are the only types the loader supports, while generating an error for the other relocation types. **Special relocation types** | **Name** | **Description** | | --- | --- | | R\_HEX\_COPY | Dynamic linking support – The offset refers to a location in a
writable segment, and the symbol table index specifies a symbol
that exists in both the current object file and a shared
object.


During execution, the dynamic linker copies the field
associated with the shared object’s symbol into the location in
the current object specified by the offset. | | R\_HEX\_GLOB\_DAT | Similar to relocation type R\_HEX\_32, except that it sets a GOT
entry to the address of the specified symbol. | | R\_HEX\_JMP\_SLOT | Dynamic linking support – The offset refers to the location of a
GOT entry, which the dynamic linker modifies with the address
of the specified symbol. | | R\_HEX\_RELATIVE | Dynamic linking support – The offset refers to a location in a
shared object that contains a value representing a relative
address.


The loader computes the corresponding virtual address by adding
the relative address to the virtual address that the shared
object was loaded at. | Note The symbol table index must be set to 0. ## Linker-generated symbols The following special symbols are generated by the linker and affect runtime. **Table 12-7 Linker-generated symbols** | **Name** | **Description** | | --- | --- | | \_SDA\_BASE\_ | Denotes the value of the GP register and the beginning of the
small data area. | | \_TLS\_START\_ | Denotes the beginning of the TLS template area in the current
image. | | \_TLS\_DATA\_END\_ | Denotes the end of the initialized TLS data within the TLS
template area of the current image. | | \_TLS\_END\_ | Denotes the end of the TLS template area of the current image. | | end | Denotes one byte past the highest virtual address occupied by
the present image. | Last Published: Oct 06, 2026 [Previous Topic Position-independent objects](https://docs.qualcomm.com/bundle/publicresource/80-N2040-23/topics/program-loading.md) [Next Topic Program headers](https://docs.qualcomm.com/bundle/publicresource/80-N2040-23/topics/program-headers.md)