Skip to content

Commit

Permalink
Add large code model
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Tsung-Chun Lin <[email protected]>
  • Loading branch information
tclin914 authored and cmuellner committed Sep 10, 2024
1 parent 9423bf0 commit da20827
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/toolchain-conventions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit da20827

Please sign in to comment.