Skip to content

Commit

Permalink
Define new tag for atomic ABI.
Browse files Browse the repository at this point in the history
Alternative version of #383

Defined 4 atomic abi variant.

- unknown, nonatomic, A6C and A6S

Unknown is compatilbe with exising object file.
Nonatomic is used when A-extension is absent
A6C is the table A.6 mapping defined in ISA spec.
And the A6S is the mapping defined in psABI spec.
  • Loading branch information
kito-cheng committed Jun 9, 2023
1 parent 9401f64 commit cf79b9d
Showing 1 changed file with 48 additions and 6 deletions.
54 changes: 48 additions & 6 deletions riscv-elf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ below.
[cols="1,2,1,1,3,5"]
[width=80%]
|===
| Bit 0 | Bits 1 - 2 | Bit 3 | Bit 4 | Bits 5 - 23 | Bits 24 - 31
| Bit 0 | Bits 1 - 2 | Bit 3 | Bit 4 - 6 | Bits 7 - 23 | Bits 24 - 31

| RVC | Float ABI | RVE | TSO | *Reserved* | *Non-standard extensions*
| RVC | Float ABI | RVE | Atomic ABI | *Reserved* | *Non-standard extensions*
|===

+
Expand Down Expand Up @@ -231,8 +231,20 @@ below.
[[EF_RISCV_RVE]]
EF_RISCV_RVE (0x0008)::: This bit is set when the binary targets the E ABI.

EF_RISCV_TSO (0x0010)::: This bit is set when the binary requires the RVTSO
memory consistency model.
EF_RISCV_ATOMIC_ABI_UNKNOWN (0x0000):::
EF_RISCV_ATOMIC_ABI_TSO (0x0010):::
EF_RISCV_ATOMIC_ABI_A6C (0x0020):::
EF_RISCV_ATOMIC_ABI_A6S (0x0030):::
These flags identify the atomic ABI in use for this ELF file. For detailed
mapping, refer to the _RISC-V atomics mappings_, 0x0040, 0x0050, 0x0060 and
0x0070 are reserved for future atomic ABIs.

EF_RISCV_ATOMIC_ABI (0x0070)::: This macro is used as a mask to test for one
of the above floating-point ABIs, e.g.,
`(e_flags & EF_RISCV_ATOMIC_ABI) == EF_RISCV_ATOMIC_ABI_TSO`.

EF_RISCV_TSO (0x0010)::: Legacy name for EF_RISCV_ATOMIC_ABI_TSO, the behavior
is compatible with EF_RISCV_ATOMIC_ABI_TSO.

Until such a time that the *Reserved* bits (0x00ffffe0) are allocated by future
versions of this specification, they shall not be set by standard software.
Expand Down Expand Up @@ -266,8 +278,12 @@ raise an error.
RVE::: Linker should report errors if object files of different value
for RVE field.

TSO::: Linker should report errors if object files of different value
for TSO field.
Atomic ABI::: The linker should report errors if the object files have
incompatible values for atomic ABI fields. The compatibility rules are as
follows:
EF_RISCV_ATOMIC_ABI_UNKNOWN is compatible with EF_RISCV_ATOMIC_ABI_A6C and
EF_RISCV_ATOMIC_ABI_A6S; EF_RISCV_ATOMIC_ABI_A6C is compatible with
EF_RISCV_ATOMIC_ABI_A6S.

NOTE: The static linker may ignore the compatibility checks if all fields in the
`e_flags` are zero and all sections in the input file are non-executable
Expand Down Expand Up @@ -1072,6 +1088,7 @@ non-standard ABI extensions.
| Tag_RISCV_priv_spec | 8 | uleb128 | *Deprecated*, indicates the major version of the privileged specification.
| Tag_RISCV_priv_spec_minor | 10 | uleb128 | *Deprecated*, indicates the minor version of the privileged specification.
| Tag_RISCV_priv_spec_revision | 12 | uleb128 | *Deprecated*, indicates the revision version of the privileged specification.
| Tag_RISCV_atomic_abi | 14 | uleb128 | Indicates for the atomic ABI.
| Reserved for non-standard attribute | >= 32768 | - | -
|===

Expand Down Expand Up @@ -1176,6 +1193,27 @@ Merge policy:::
The linker should report errors if object files of different privileged
specification versions are merged.

===== Tag_RISCV_atomic_abi, 14, uleb128=version

Tag_RISCV_atomic_abi denotes the atomic for this object
file. Its values are defined as follows:

.RISC-V attributes
[cols="4,>2,2,5"]
[width=100%]
|===
| Value | Symbolic Name | Compatibility | Description

| 0 | UNKNOWN_ATOMIC_ABI | Compatible with all other value. | This object use unknown atomic ABI.
| 1 | NON_ATOMIC_ABI | Incompatible with all other atomic ABI other than unknown. | Atomic opertiaon all using plain load store operaion, this ABI should only used when A-extension is absent.
| 2 | A6C_ATOMIC_ABI | Compatible with unknown and A6S_ATOMIC_ABI. | This object use the A6 classical atomic ABI, which defined in table A.6 in <<riscv-unpriv-20191213>>.
| 3 | A6S_ATOMIC_ABI | Compatible with unknown and A6C_ATOMIC_ABI. | This object use the strengthened A6 ABI, which defined in <<Mappings from C/C++ primitives to RISC-V primitives>>.
|===

Merge policy:::
The linker should report errors if object files of incompatible atomic ABI
beginning merged, the compatibility rules for atomic ABIs can be found in
compatibility column in the above table.

=== Mapping Symbol

Expand Down Expand Up @@ -1635,5 +1673,9 @@ https://www.akkadia.org/drepper/tls.pdf, Ulrich Drepper
ISA, Document", Editors Andrew Waterman and Krste Asanovi´c,
RISC-V International.

* [[[riscv-unpriv-20191213]]] "The RISC-V Instruction Set Manual, Volume I: User-Level
ISA, Document release 20191213", Editors Andrew Waterman and Krste Asanovi´c,
RISC-V International.

* [[[riscv-zc-extension-group]]] "ZC* extension specification"
https://github.com/riscv/riscv-code-size-reduction

0 comments on commit cf79b9d

Please sign in to comment.