@@ -217,21 +217,31 @@ Push/pop current options to/from the options stack.
217217
218218The 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 | N/A
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 | N/A
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+ - %* hi(symbol) : (delta + 0x800) >> 12
236+ - %* lo(symbol) : delta & 0xfff
237+ - %pcrel_lo(label) : ((symbol or GOT[ symbol] at label) - pc) & 0xfff
238+
239+ 0x800 is added to calculate the 20-bit high part, counteracting sign extension
240+ of the 12-bit low part.
241+
242+ %tprel_add(symbol) is used purely to associate the R_RISCV_TPREL_ADD relocation
243+ for TLS relaxation.
244+
235245Labels
236246------------
237247
0 commit comments