__INTERNAL_fmt: Assure correct stack arguments are loaded if FD=stderr

This commit is contained in:
2025-07-26 01:07:42 +02:00
parent 69d7a52c62
commit e8b47fff6d

View File

@@ -125,8 +125,8 @@ __INTERNAL_fmt:
mov %1, [printfArgs + SIZE_QWORD * r14]
jmp %%continue
%%fromStack:
cmp r15, FD_stdout
je %%stackNoShift
cmp r15, FD_stderr
jle %%stackNoShift ;simple jle (for test r15,2); entry of this wrapper quits early if passed FD is less than 1, so this simple check is safe enough
mov %1, [rbp + (RBP_OFFSET_CALLER*2 + SIZE_QWORD) + ((r14-5) * SIZE_QWORD)] ;non-printf functions calling __INTERNAL_fmt require RDI to be FD, all args shifted and rbp+RBP_OFFSET_CALLER to r9. Also requires function prologue and a CALL to __INTERNAL_fmt (not a JMP like in printf); hence the RBP_OFFSET_CALLER*2
jmp %%continue
%%stackNoShift: