i386-asm: fix pc-relative label ariths

See test. We need to use 'ind' from later when the address
field of the instruction is put.

Also: fix crash when the substracted symbol is undefined
Also: assume asm-symbols to be lvalues (except func/array)
This commit is contained in:
grischka
2024-03-02 12:48:44 +01:00
parent 9675c1e245
commit ca061f3a96
4 changed files with 17 additions and 2 deletions

View File

@@ -487,7 +487,7 @@ ST_FUNC void gen_expr32(ExprValue *pe)
if (pe->pcrel)
/* If PC-relative, always set VT_SYM, even without symbol,
so as to force a relocation to be emitted. */
gen_addrpc32(VT_SYM, pe->sym, pe->v);
gen_addrpc32(VT_SYM, pe->sym, pe->v + (ind + 4));
else
gen_addr32(pe->sym ? VT_SYM : 0, pe->sym, pe->v);
}