@@ -1072,6 +1072,7 @@ non-standard ABI extensions.
10721072| Tag_RISCV_priv_spec | 8 | uleb128 | *Deprecated*, indicates the major version of the privileged specification.
10731073| Tag_RISCV_priv_spec_minor | 10 | uleb128 | *Deprecated*, indicates the minor version of the privileged specification.
10741074| Tag_RISCV_priv_spec_revision | 12 | uleb128 | *Deprecated*, indicates the revision version of the privileged specification.
1075+ | Tag_RISCV_x3_reg_usage | 16 | uleb128 | Indicates the usage definition of the X3 register.
10751076| Reserved for non-standard attribute | >= 32768 | - | -
10761077|===
10771078
@@ -1176,6 +1177,27 @@ Merge policy:::
11761177The linker should report errors if object files of different privileged
11771178specification versions are merged.
11781179
1180+ ===== Tag_RISCV_x3_reg_usage, 14, uleb128=value
1181+
1182+ Tag_RISCV_x3_reg_usage indicates the usage of `x3`/`gp` register. `x3`/`gp` could be used for
1183+ global pointer relaxation, as a reserved platform register, or as a temporary register.
1184+
1185+ [horizontal]
1186+ 0:: This object uses `x3` as a fixed register with unknown purpose.
1187+ 1:: This object uses `x3` as the global pointer, for relaxation purposes.
1188+ 2:: This object uses `x3` as the shadow stack pointer.
1189+ 3:: This object uses `X3` as a temporary register.
1190+ 4~1023:: Reserved for future standard defined platform register.
1191+ 1024~2047:: Reserved for nonstandard defined platform register.
1192+
1193+ --
1194+
1195+ Merge policy:::
1196+ The linker should issue errors when object files with differing `gp` usage are
1197+ combined. However, an exception exists: the value `0` can merge with `1` or `2`
1198+ value. After the merge, the resulting value will be the non-zero one.
1199+
1200+ --
11791201
11801202=== Mapping Symbol
11811203
@@ -1387,7 +1409,8 @@ Relaxation result:
13871409 load address of a symbol or load/store with a symbol reference into
13881410 global-pointer-relative instruction.
13891411
1390- Condition:: Offset between global-pointer and symbol is within +-2KiB,
1412+ Condition:: Global-pointer relaxation requires that Tag_RISCV_x3_reg_usage
1413+ must be 0 or 1, and offset between global-pointer and symbol is within +-2KiB,
13911414 `R_RISCV_PCREL_LO12_I` and `R_RISCV_PCREL_LO12_S` resolved as indirect
13921415 relocation pointer. It will always point to another `R_RISCV_PCREL_HI20`
13931416 relocation, the symbol pointed by `R_RISCV_PCREL_HI20` will be used in
@@ -1442,6 +1465,8 @@ many other targets, however, RISC-V uses PC-relative addressing rather than
14421465access GOT via the global pointer register (`gp`), so we use `gp` register to
14431466optimize code size and performance of the symbol accessing.
14441467
1468+ NOTE: Tag_RISCV_x3_reg_usage is treated as 0 if it is not present.
1469+
14451470==== Zero-page Relaxation
14461471
14471472 Target Relocation:: R_RISCV_HI20, R_RISCV_LO12_I, R_RISCV_LO12_S
0 commit comments