Skip to content

Commit 3a6efe1

Browse files
kito-chengcmuellner
authored andcommitted
Add code model link to psabi and add PIC model
We have add few document into RISC-V psABI, so put link here to prevent we need to repeat that here. Also add PIC mode into this doc.
1 parent 98ea9e7 commit 3a6efe1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.mkd

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impossible combinations of `-march` and `-mabi` such as `-march=rv32i` and
152152
## Specifying the target code model with -mcmodel
153153

154154
The target code model indicates constraints on symbols which the compiler can
155-
exploit these constraints to generate more efficient code. Two code models are
155+
exploit these constraints to generate more efficient code. Three code models are
156156
currently defined for RISC-V:
157157

158158
* `-mcmodel=medlow`. The program and its statically defined symbols must lie
@@ -161,6 +161,17 @@ within a single 2GiB address range, between the absolute addresses -2GiB and
161161
* `-mcmodel=medany`. The program and its statically defined symbols must lie
162162
within a single 4GiB address range. `auipc` and `addi` pairs are used to
163163
generate addresses.
164+
* Use of any PIC or PIE option (e.g. -fpic, -fPIC, -fpie or -fPIE) will enable
165+
the medium position independent code model. This model is similar to the medium
166+
any code model, but uses the global offset table (GOT) for non-local symbol
167+
addresses.
168+
169+
NOTE: When PIC or PIE mode enabled the `-mcmodel=medlow` will be suppressed.
170+
171+
RISC-V psABI has a contain sections to describe the code model:
172+
- [Medium low code model](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#medium-low-code-model): -mcmodel=medlow
173+
- [Medium any code model](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#medium-low-code-model): -mcmodel=medany
174+
- [Medium position independent code model](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#medium-position-independent-code-model): -fpic, -fPIC, -fpie or -fPIE.
164175

165176
## Disassembler (objdump) behaviour
166177

0 commit comments

Comments
 (0)