Skip to content

Commit b39cbc7

Browse files
author
noneofyourbusiness
committed
riscv64-asm.c: parse_operand: document some ABI details
1 parent 5ec0e6f commit b39cbc7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

riscv64-asm.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,16 @@ static void parse_operand(TCCState *s1, Operand *op)
209209
if ((int) op->e.v >= -0x1000 && (int) op->e.v < 0x1000)
210210
op->type = OP_IM12S;
211211
} else if (op->e.sym->type.t & (VT_EXTERN | VT_STATIC)) {
212+
/* see also: "RISC-V ABIs Specification" V1.0
213+
214+
section 5.2 recommends using a GOT for
215+
"possibly-undefined weak symbols"
216+
217+
section 5.3: "Medium position independent code model"
218+
if this is a non-local symbol: use a GOT
219+
non-local: outside of a pc-relative +- 2 GiB range
220+
*/
221+
212222
label.type.t = VT_VOID | VT_STATIC;
213223

214224
/* use the medium PIC model: GOT, auipc, lw */

0 commit comments

Comments
 (0)