Skip to content

Commit 6cda892

Browse files
authored
Merge pull request #196 from riscv-non-isa/mapping-symbol
Proposal: Add mapping symbol
2 parents 3d9938a + b1adeb0 commit 6cda892

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

riscv-elf.adoc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,44 @@ Merge policy:::
11641164
The linker should report errors if object files of different privileged
11651165
specification versions are merged.
11661166

1167+
1168+
=== Mapping Symbol
1169+
1170+
The section can have a mixture of code and data or code with different ISAs.
1171+
A number of symbols, named mapping symbols, describe the boundaries.
1172+
1173+
[%autowidth]
1174+
|===
1175+
| Symbol Name | Meaning
1176+
| $d | Start of a sequence of data.
1177+
| $x | Start of a sequence of instructions.
1178+
| $x<ISA> | Start of a sequence of instructions with <ISA> extension.
1179+
|===
1180+
1181+
The mapping symbol should set the type to `STT_NOTYPE`, binding to `STB_LOCAL`,
1182+
and the size of symbol to zero.
1183+
1184+
The mapping symbol for data(`$d`) indicates the start of a sequence of data bytes.
1185+
1186+
The mapping symbol for instruction(`$x`) indicates the start of a sequence of
1187+
instructions.
1188+
and it has an optional ISA string, which means the following code regions are
1189+
using ISA is different than the ISA recorded in the arch attribute;
1190+
the ISA information will used until the next instruction mapping symbol;
1191+
an instruction mapping symbol without ISA string means using ISA configuration
1192+
from ELF attribute.
1193+
1194+
Format and rule of the optional ISA string are same as `Tag_RISCV_arch`, must
1195+
having explicit version, more detailed rule please refer to <<Attributes>>.
1196+
1197+
NOTE: The use case for mapping symbol for instruction(`$x`) with ISA information
1198+
is used with ifunc, e.g. libraries are built with `rv64gc`, but few functions
1199+
like memcpy provides two versions, one built with `rv64gc`, and one built with
1200+
`rv64gcv`, and select by ifunc mechanism at run-time; however, the arch
1201+
attribute is recording for minimal execution environment requirements, so the
1202+
ISA information from arch attribute is not enough for the disassembler to
1203+
disassemble the `rv64gcv` version correctly.
1204+
11671205
== Linker Relaxation
11681206

11691207
At link time, when all the memory objects have been resolved, the code sequence

0 commit comments

Comments
 (0)