Skip to content

Commit f655e06

Browse files
committed
Describe assembler relocation functions more precisely
ref. - RISC-V Unprivileged ISA V20191213, chapter 25 - gcc manual https://sourceware.org/binutils/docs/as/RISC_002dV_002dModifiers.html
1 parent a9945e1 commit f655e06

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

riscv-asm.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,30 @@ Push/pop current options to/from the options stack.
217217

218218
The following table lists assembler relocation expansions:
219219

220-
Assembler Notation | Description | Instruction / Macro
221-
:---------------------- | :--------------- | :-------------------
222-
%hi(symbol) | Absolute (HI20) | lui
223-
%lo(symbol) | Absolute (LO12) | load, store, add
224-
%pcrel_hi(symbol) | PC-relative (HI20) | auipc
225-
%pcrel_lo(label) | PC-relative (LO12) | load, store, add
226-
%tprel_hi(symbol) | TLS LE "Local Exec" | lui
227-
%tprel_lo(symbol) | TLS LE "Local Exec" | load, store, add
228-
%tprel_add(symbol) | TLS LE "Local Exec" | add
229-
%tls_ie_pcrel_hi(symbol) \* | TLS IE "Initial Exec" (HI20) | auipc
230-
%tls_gd_pcrel_hi(symbol) \* | TLS GD "Global Dynamic" (HI20) | auipc
231-
%got_pcrel_hi(symbol) \* | GOT PC-relative (HI20) | auipc
220+
Assembler Notation | Description | Instruction / Macro | delta
221+
:---------------------- | :--------------- | :------------------- | :--------------
222+
%hi(symbol) | Absolute (HI20) | lui | symbol
223+
%lo(symbol) | Absolute (LO12) | load, store, add | symbol
224+
%pcrel_hi(symbol) | PC-relative (HI20) | auipc | symbol - pc
225+
%pcrel_lo(label) | PC-relative (LO12) | load, store, add | symbol - pc
226+
%tprel_hi(symbol) | TLS LE "Local Exec" | lui | symbol - tp
227+
%tprel_lo(symbol) | TLS LE "Local Exec" | load, store, add | symbol - tp
228+
%tprel_add(symbol) | TLS LE "Local Exec" | add |
229+
%tls_ie_pcrel_hi(symbol) \* | TLS IE "Initial Exec" (HI20) | auipc | GOT[symbol] - pc
230+
%tls_gd_pcrel_hi(symbol) \* | TLS GD "Global Dynamic" (HI20) | auipc | GOT[symbol] - pc
231+
%got_pcrel_hi(symbol) \* | GOT PC-relative (HI20) | auipc | GOT[symbol] - pc
232232

233233
\* These reuse %pcrel_lo(label) for their lower half
234234

235+
The linker adds delta[11] to the 20-bit high part, counteracting sign extension
236+
of the 12-bit low part.
237+
238+
- %*hi(symbol) : delta[31:12] + delta[11]
239+
- %*lo(symbol) : delta[11:0]
240+
241+
%tprel_add(symbol) is used purely to associate the R_RISCV_TPREL_ADD relocation
242+
for TLS relaxation.
243+
235244
Labels
236245
------------
237246

0 commit comments

Comments
 (0)