| Relocation / Symbol Type | Purpose / Description | Usage Examples / Notes | |------------------------------|-----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------| | **R_RISCV_HI20** | High 20 bits of a 32-bit address | Loads the upper 20 bits of an address into a register; paired with LO12 to form complete addresses. Example symbols: `randomval`, `usrid`, `pi`, `e`. | | **R_RISCV_LO12_I** | Low 12 bits for I-type instructions | Completes address formation started by HI20; used for load/store and immediate operations. ā€œIā€ = I-type format. | | **R_RISCV_CALL** | Function call relocations | Used for `jal` (jump and link) instructions to call functions; supports local (`is_prime`, `square`, `pick_prime`) and external (`printf`) functions; can span multiple instructions for far targets. | | **R_RISCV_BRANCH** | Conditional branch instructions | Used for `if` statements and loops; targets local labels like `.L4`, `.L6`, `.L10`. | | **R_RISCV_RVC_BRANCH** | Compressed branch instructions | 16-bit compressed versions of branch instructions; more efficient encoding for short branches. | | **R_RISCV_RVC_JUMP** | Compressed jump instructions | 16-bit compressed unconditional jumps to nearby labels. | | **R_RISCV_RELAX** | Linker relaxation hint | Appears with `*ABS*` value; tells the linker it can optimize instruction sequences, possibly shortening them. | | **Global Symbols** | Externally visible symbols | e.g., `pi`, `e`. | | **Static Symbol** | Internal symbol within the file | e.g., `randomval`. | | **External Symbol** | Defined elsewhere | e.g., `usrid`. | | **String Literals** | Format strings for functions like `printf` | e.g., `.LC0`, `.LC1`, etc. | | **Local Functions** | Functions defined within the file | e.g., `is_prime`, `square`, `pick_prime`. | | **External Function** | Functions defined externally | e.g., `printf`. |