From da20827f5169da523491e5dc12565584b941e33a Mon Sep 17 00:00:00 2001 From: Jim Tsung-Chun Lin Date: Mon, 9 Sep 2024 17:25:04 +0800 Subject: [PATCH] Add large code model Signed-off-by: Jim Tsung-Chun Lin --- src/toolchain-conventions.adoc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/toolchain-conventions.adoc b/src/toolchain-conventions.adoc index 46008f7..7692754 100644 --- a/src/toolchain-conventions.adoc +++ b/src/toolchain-conventions.adoc @@ -108,6 +108,9 @@ within a single 2GiB address range, between the absolute addresses -2GiB and - `-mcmodel=medany`. The program and its statically defined symbols must lie within a single 4GiB address range. `auipc` and `addi` pairs are used to generate addresses. +- `-mcmodel=large`. The program and its statically defined symbols can lie +within the whole 64-bit address range. `auipc`, `addi` and `ld` are used to +generate addresses. - Use of any PIC or PIE option (e.g. -fpic, -fPIC, -fpie or -fPIE) will enable the medium position independent code model. This model is similar to the medium any code model, but uses the global offset table (GOT) for non-local symbol @@ -119,6 +122,7 @@ RISC-V psABI has a contain sections to describe the code model: - https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#medium-low-code-model[Medium low code model]: -mcmodel=medlow - https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#medium-any-code-model[Medium any code model]: -mcmodel=medany +- https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#large-code-model[Large code model]: -mcmodel=large - https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#medium-position-independent-code-model[Medium position independent code model]: -fpic, -fPIC, -fpie or -fPIE. == Disassembler (objdump) behaviour @@ -172,8 +176,9 @@ toolchain defined `+__riscv__+`. - `+__riscv_float_abi_soft+`, `+__riscv_float_abi_single+`, `+__riscv_float_abi_double+`: one of these three will be defined, depending on target ABI. -- `+__riscv_cmodel_medlow+`, `+__riscv_cmodel_medany+`: one of these two will be -defined, depending on the target code model. +- `+__riscv_cmodel_medlow+`, `+__riscv_cmodel_medany+`, +`+__riscv_cmodel_large+`: one of these three will be defined, depending on +the target code model. - `+__riscv_mul+`: defined when targeting the 'M' ISA extension. - `+__riscv_muldiv+`: defined when targeting the 'M' ISA extension and `-mno-div` has not been used.