Relocations - 2024.2 English

MicroBlaze Processor Reference Guide (UG984)

Document ID
UG984
Release Date
2024-11-27
Version
2024.2 English

Relocation information is used by linkers to bind symbols and addresses that could not be determined when the initial object was generated.

Relocation entries describe how to alter the instruction and data relocation fields Relocations applied to executable or shared object files are similar and accomplish the same result.

All relocations are listed and described in the following table, including the operation performed to compute the value of the relocation.

Table 1. Relocation Entries
Code Name Description Operation
1 R_MICROBLAZE_NONE This relocation does nothing. none
2 R_MICROBLAZE_32 A standard 32 bit relocation. S+A
3 R_MICROBLAZE_32_PCREL A standard PCREL 32 bit relocation. S+A-P
4 R_MICROBLAZE_64_PCREL A 64 bit PCREL relocation. Table-entry only used for 64-bit implementation. (S+A-P)&0xFFFF (#imm)
5 R_MICROBLAZE_32_PCREL_LO The low half of a PCREL 32 bit relocation. (S+A-P)&0xFFFF
6 R_MICROBLAZE_64 A 64 bit relocation. Table entry only used for 64-bit implementation. (S+A)&0xFFFF (#imm)
7 R_MICROBLAZE_32_LO The low half of a 32 bit relocation. (S+A)&0xFFFF
8 R_MICROBLAZE_SRO32 Read-only small data section relocation. (S+A -_SDA_BASE_)
9 R_MICROBLAZE_SRW32 Read-write small data area relocation. (S+A-_SDA_BASE_)
10 R_MICROBLAZE_64_NONE This relocation does nothing. Used for relaxation. none
11 R_MICROBLAZE_32_SYM_OP_SYM Symbol Op Symbol relocation. none
12 R_MICROBLAZE_GNU_VTINHERIT GNU extension to record C++ vtable hierarchy.
13 R_MICROBLAZE_GNU_VTENTRY GNU extension to record C++ vtable member usage.
14 R_MICROBLAZE_GOTPC_64 A 64 bit GOTPC relocation. Table-entry only used for 64-bit implementation. G+A–P (#imm)
15 R_MICROBLAZE_GOT_64 A 64 bit GOT relocation. Table-entry only used for 64-bit implementation. G+A (#imm)
16 R_MICROBLAZE_PLT_64 A 64 bit PLT relocation. Table-entry only used for 64-bit implementation. L+A (#imm)
17 R_MICROBLAZE_REL Table-entry not used. ((B + A)>>16) & 0xFFFF
18 R_MICROBLAZE_JUMP_SLOT Table-entry not used. (S >> 16) & 0xFFFF
19 R_MICROBLAZE_GLOB_DAT Table-entry not used. (S >> 16) & 0xFFFF
20 R_MICROBLAZE_GOTOFF_64 A 64 bit GOT relative relocation. (S+A-GOT)&0xFFFF
21 R_MICROBLAZE_GOTOFF_32 A 32 bit GOT relative relocation. (S+A-GOT)&0xFFFF
22 R_MICROBLAZE_COPY COPY relocation. none
23 R_MICROBLAZE_TLS TLS relocations for TLS. none
24 R_MICROBLAZE_TLSGD TLSGD relocations for TLS. @got@tlsgd
25 R_MICROBLAZE_TLSLD TLSLD relocations for TLS. @got@tlsld
26 R_MICROBLAZE_TLSDTPMOD32 Computes the load module. @got@dtpmod
27 R_MICROBLAZE_TLSDTPREL32 Computes a dtv-relative displacement. @got@dtprel
28 R_MICROBLAZE_TLSDTPREL64 Computes a dtv-relative displacement. @got@dtprel
29 R_MICROBLAZE_TLSGOTTPREL32 Computes a tp-relative displacement. @got@prel
30 R_MICROBLAZE_TLSTPREL32 Computes a tp-relative displacement. @got@prel
31 R_MICROBLAZE_32_NONE Standard 32-bit relocation. none

The symbol nomenclature and relocation calculations with thread-local symbols used in the relocation entries table are explained in the following table.

Table 2. Symbol Notation
Symbol Meaning
A The addend used to compute the value of the relocatable field.
B The base address at which a shared object has been loaded into memory during execution. Generally, a shared object file is built with a 0 base virtual address, but the execution address will be different.
G The offset into the global offset table at which the address of the relocation entry’s symbol will reside during execution.
GOT The address of the global offset table.
L The place (section offset or address) of the procedure linkage table entry for a symbol. A procedure linkage table entry redirects a function call to the proper destination. The link editor builds the initial procedure linkage table, and the dynamic linker modifies the entries during execution.
P The place (section offset or address) of the storage unit being relocated (computed using r_offset).
S The value of the symbol whose index resides in the relocation entry.
@dtpmod Computes the load module index of the load module that contain the definition of a symbol. The addend, if present, is ignored
@dtprel Computes a dtv-relative displacement, the difference between the value of S + A and the base address of the thread-local storage block that contains the definition of the symbol, minus 0x8000.
@got@tlsgd Allocates entries in the GOT to hold a tls_index structure, with values @dtpmod and @dtprel, and computes the offset to the first entry relative to the TOC base.
@got@tlsld Allocates entries in the GOT to hold a tls_index structure, with values @dtpmod and zero, and computes the offset to the first entry relative to the TOC base.
@got@dtpmod Computes the load module index of the load module that contains the definition of its TLS symbol.
@got@dtprel Computes a dtv-relative displacement, the difference between the value of symbol + add and the base address of the thread-local storage block that contains the definition of the symbol, minus 0x8000. Used for initializing GOT.
@got@prel Computes a tp-relative displacement, the difference between the value of symbol + add and the value of the thread pointer (r13).
#imm Inserts imm instruction if the immediate value is greater than 16 bits in the instruction.