Skip to content

Commit ca8f82e

Browse files
committed
Clarify ELF Reloc Type
* "runtime relocation" is not a commonly used term. Use "dynamic relocation" instead. * "Runtime relocations can be resolved by both static and dynamic linkers" is inappropriate. Rewrite the description. * RELATIVE can appear in an executable (usually PIE). Reword the description. * IRELATIVE can appear in an executable. Just remove "shared object" as the previous paragraph has mentioned that "Dynamic" can be used in an executable. Change "local ifunc symbol" to the more appropriate "non-preemptible ifunc symbol". Fix #319
1 parent d522148 commit ca8f82e

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

riscv-elf.adoc

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,11 @@ Enum:: The number of the relocation, encoded in the r_info field
295295

296296
ELF Reloc Type:: The name of the relocation, omitting the prefix of `R_RISCV_`.
297297

298-
Type:: Whether the relocation is a static or runtime relocation:
298+
Type:: Whether the relocation is a static or dynamic relocation:
299299
+
300-
- Static relocations are always resolved by the static linker
301-
- Runtime relocations can be resolved by both static and dynamic linkers
300+
- A static relocation relocates a location in a relocatable file, processed by a static linker.
301+
- A dynamic relocation relocates a location in an executable or shared object, processed by a run-time linker.
302+
- `Both`: Some relocation types are used by both static relocations and dynamic relocations.
302303

303304
Field:: Describes the set of bits affected by this relocation; see <<Field Symbols>> for the definitions of the individual types
304305

@@ -312,31 +313,31 @@ Description:: Additional information about the relocation
312313
[cols=">2,6,3,6,11"]
313314
[width=100%]
314315
|===
315-
| Enum | ELF Reloc Type | Type | Field / Calculation | Description
316+
| Enum | ELF Reloc Type | Type | Field / Calculation | Description
316317

317318
.2+| 0 .2+| NONE .2+| None | .2+|
318319
<|
319-
.2+| 1 .2+| 32 .2+| Runtime | _word32_ .2+| 32-bit relocation
320+
.2+| 1 .2+| 32 .2+| Both | _word32_ .2+| 32-bit relocation
320321
<| S + A
321-
.2+| 2 .2+| 64 .2+| Runtime | _word64_ .2+| 64-bit relocation
322+
.2+| 2 .2+| 64 .2+| Both | _word64_ .2+| 64-bit relocation
322323
<| S + A
323-
.2+| 3 .2+| RELATIVE .2+| Runtime | _wordclass_ .2+| Relocation against a local symbol in a shared object
324+
.2+| 3 .2+| RELATIVE .2+| Dynamic | _wordclass_ .2+| Adjust a link address (A) to its load address (B + A)
324325
<| B + A
325-
.2+| 4 .2+| COPY .2+| Runtime | .2+| Must be in executable; not allowed in shared library
326+
.2+| 4 .2+| COPY .2+| Dynamic | .2+| Must be in executable; not allowed in shared library
326327
<|
327-
.2+| 5 .2+| JUMP_SLOT .2+| Runtime | _wordclass_ .2+| Indicates the symbol associated with a PLT entry
328+
.2+| 5 .2+| JUMP_SLOT .2+| Dynamic | _wordclass_ .2+| Indicates the symbol associated with a PLT entry
328329
<| S
329-
.2+| 6 .2+| TLS_DTPMOD32 .2+| Runtime | _word32_ .2+|
330+
.2+| 6 .2+| TLS_DTPMOD32 .2+| Dynamic | _word32_ .2+|
330331
<| TLSMODULE
331-
.2+| 7 .2+| TLS_DTPMOD64 .2+| Runtime | _word64_ .2+|
332+
.2+| 7 .2+| TLS_DTPMOD64 .2+| Dynamic | _word64_ .2+|
332333
<| TLSMODULE
333-
.2+| 8 .2+| TLS_DTPREL32 .2+| Runtime | _word32_ .2+|
334+
.2+| 8 .2+| TLS_DTPREL32 .2+| Dynamic | _word32_ .2+|
334335
<| S + A - TLS_DTV_OFFSET
335-
.2+| 9 .2+| TLS_DTPREL64 .2+| Runtime | _word64_ .2+|
336+
.2+| 9 .2+| TLS_DTPREL64 .2+| Dynamic | _word64_ .2+|
336337
<| S + A - TLS_DTV_OFFSET
337-
.2+| 10 .2+| TLS_TPREL32 .2+| Runtime | _word32_ .2+|
338+
.2+| 10 .2+| TLS_TPREL32 .2+| Dynamic | _word32_ .2+|
338339
<| S + A + TLSOFFSET
339-
.2+| 11 .2+| TLS_TPREL64 .2+| Runtime | _word64_ .2+|
340+
.2+| 11 .2+| TLS_TPREL64 .2+| Dynamic | _word64_ .2+|
340341
<| S + A + TLSOFFSET
341342
.2+| 16 .2+| BRANCH .2+| Static | _B-Type_ .2+| 12-bit PC-relative branch offset
342343
<| S + A - P
@@ -416,7 +417,7 @@ Description:: Additional information about the relocation
416417
<| S + A
417418
.2+| 57 .2+| 32_PCREL .2+| Static | _word32_ .2+| 32-bit PC relative
418419
<| S + A - P
419-
.2+| 58 .2+| IRELATIVE .2+| Runtime | _wordclass_ .2+| Relocation against a local ifunc symbol in a shared object
420+
.2+| 58 .2+| IRELATIVE .2+| Dynamic | _wordclass_ .2+| Relocation against a non-preemptible ifunc symbol
420421
<| `ifunc_resolver(B + A)`
421422
.2+| 59-191 .2+| *Reserved* .2+| - | .2+| Reserved for future standard use
422423
<|
@@ -532,7 +533,7 @@ global symbols (objects and functions) referred to by the dynamically
532533
linked shared object. The GOT in each shared library is filled in by the
533534
dynamic linker during program loading, or on the first call to extern functions.
534535

535-
To avoid runtime relocations within the text segment of position independent
536+
To avoid dynamic relocations within the text segment of position independent
536537
code the GOT is used for indirection. Instead of code loading virtual addresses
537538
directly, as can be done in static code, addresses are loaded from the GOT.
538539
This allows runtime binding to external objects and functions at the expense of

0 commit comments

Comments
 (0)