From b39cbc70c4ccc0540c2ef65010b8241caf005ad4 Mon Sep 17 00:00:00 2001 From: noneofyourbusiness Date: Sat, 17 Jan 2026 11:27:30 +0100 Subject: [PATCH] riscv64-asm.c: parse_operand: document some ABI details --- riscv64-asm.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/riscv64-asm.c b/riscv64-asm.c index 74cf4452..63aa468e 100644 --- a/riscv64-asm.c +++ b/riscv64-asm.c @@ -209,6 +209,16 @@ static void parse_operand(TCCState *s1, Operand *op) if ((int) op->e.v >= -0x1000 && (int) op->e.v < 0x1000) op->type = OP_IM12S; } else if (op->e.sym->type.t & (VT_EXTERN | VT_STATIC)) { + /* see also: "RISC-V ABIs Specification" V1.0 + + section 5.2 recommends using a GOT for + "possibly-undefined weak symbols" + + section 5.3: "Medium position independent code model" + if this is a non-local symbol: use a GOT + non-local: outside of a pc-relative +- 2 GiB range + */ + label.type.t = VT_VOID | VT_STATIC; /* use the medium PIC model: GOT, auipc, lw */