@@ -236,6 +236,48 @@ type-name = identifier-nondigit *identifier-char
236236identifier-nondigit = ALPHA / "_"
237237identifier-char = identifier-nondigit / "_"
238238----
239+
240+ == Data Representation
241+
242+ The data representation for RISC-V follows the conventions of the target endianness.
243+ RISC-V supports both little-endian and big-endian byte ordering.
244+
245+ === Byte Ordering
246+
247+ RISC-V implementations can support either little-endian or big-endian byte ordering:
248+
249+ * **Little-endian**: The least significant byte is stored at the lowest memory address.
250+ This is the default and most common byte ordering for RISC-V.
251+ * **Big-endian**: The most significant byte is stored at the lowest memory address.
252+
253+ The endianness is fixed at the system level and cannot be changed dynamically.
254+ All data types follow the byte ordering of the target system.
255+
256+ IMPORTANT: RISC-V instructions are always stored in little-endian format,
257+ regardless of the data endianness. This means that in big-endian systems,
258+ data is big-endian but instructions remain little-endian.
259+
260+ === Relocations and Byte Ordering
261+
262+ When generating big-endian output, the following relocations write their
263+ data values in big-endian byte order:
264+
265+ * `R_RISCV_32` - 32-bit data relocation
266+ * `R_RISCV_64` - 64-bit data relocation
267+ * `R_RISCV_ADD16` - 16-bit label addition
268+ * `R_RISCV_ADD32` - 32-bit label addition
269+ * `R_RISCV_ADD64` - 64-bit label addition
270+ * `R_RISCV_SUB16` - 16-bit label subtraction
271+ * `R_RISCV_SUB32` - 32-bit label subtraction
272+ * `R_RISCV_SUB64` - 64-bit label subtraction
273+ * `R_RISCV_SET16` - 16-bit local label assignment
274+ * `R_RISCV_SET32` - 32-bit local label assignment
275+ * `R_RISCV_32_PCREL` - 32-bit PC-relative relocation
276+ * `R_RISCV_PLT32` - 32-bit relative offset to PLT entry
277+
278+ All other relocations that modify instruction fields continue to use
279+ little-endian byte order, as RISC-V instructions are always little-endian.
280+
239281== ELF Object Files
240282
241283The ELF object file format for RISC-V follows the
0 commit comments