Skip to content

Commit 87aecf6

Browse files
authored
Merge pull request #458 from lenary/pr/riscv-vendor-symbol
Rework Nonstandard Relocations
2 parents 2484f95 + 2acb329 commit 87aecf6

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

riscv-elf.adoc

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -566,15 +566,6 @@ Description:: Additional information about the relocation
566566
<|
567567
|===
568568

569-
Nonstandard extensions are free to use relocation numbers 192-255 for any
570-
purpose. These vendor-specific relocations must be preceded by a
571-
`R_RISCV_VENDOR` relocation against a vendor ID symbol.
572-
573-
Where possible, tools should present relocation as their vendor-specific
574-
relocation types, otherwise a generic name of `R_RISCV_CUSTOM<enum value>` must
575-
be shown. Data contained in paired `RISCV_VENDOR` can be used to select the
576-
appropriate vendor when performing relocations.
577-
578569
This section and later ones contain fragments written in assembler. The precise
579570
assembler syntax, including that of the relocations, is described in the
580571
_RISC-V Assembly Programmer's Manual_ <<rv-asm>>.
@@ -586,15 +577,27 @@ and fill the space with a single ULEB128-encoded value.
586577
This is achieved by prepending the redundant `0x80` byte as necessary.
587578
The linker must not alter the length of the ULEB128-encoded value.
588579

589-
==== Vendor identifiers
580+
==== Nonstandard Relocations (a.k.a. Vendor-Specific Relocations)
590581

591-
Vendor identifiers are dummy symbols used in the corresponding `R_RISCV_VENDOR`
592-
relocation (irrespective of ELF class/XLEN) and must be unique amongst all
593-
vendors providing custom relocations. Vendor identifiers may be suffixed with a
594-
tag to provide extra relocations for a given vendor.
582+
Nonstandard extensions are free to use relocation numbers 192-255 for any
583+
purpose. These vendor-specific relocations must be preceded by a
584+
`R_RISCV_VENDOR` relocation against a vendor identifier symbol. The preceding
585+
`R_RISCV_VENDOR` relocation is used by the linker to choose the correct
586+
implementation for the associated nonstandard relocation.
587+
588+
The vendor identifier symbol should be a defined symbol and should set the type
589+
to `STT_NOTYPE`, binding to `STB_LOCAL`, and the size of symbol to zero.
590+
591+
Vendor identifiers must be unique amongst all vendors providing custom
592+
relocations. Vendor identifiers may be suffixed with a tag to provide extra
593+
relocations for a given vendor.
595594

596595
NOTE: Please refer to the _RISC-V Toolchain Conventions_
597-
<<rv-toolchain-conventions>> for the full list.
596+
<<rv-toolchain-conventions>> for the full list of vendor identifiers.
597+
598+
Where possible, tools should present relocation as their vendor-specific
599+
relocation types, otherwise a generic name of `R_RISCV_CUSTOM<enum value>` must
600+
be shown.
598601

599602
==== Calculation Symbols
600603

0 commit comments

Comments
 (0)