Force self to sub/add rsp before/after push/pop (instead of after/before push/pop) -- prevents popping wrong values, eventually (in callee, like what printf does)

This commit is contained in:
2025-07-10 01:38:25 +02:00
parent 2d1a4b9d56
commit 3951e50ab0

View File

@@ -168,10 +168,10 @@ printf:
.d_fromStack: .d_fromStack:
mov rsi, [rbp + RBP_OFFSET_CALLER + ((rdx-5) * SIZE_QWORD)] mov rsi, [rbp + RBP_OFFSET_CALLER + ((rdx-5) * SIZE_QWORD)]
.checkINTorUINT: .checkINTorUINT:
sub rsp, SIZE_QWORD
push rax push rax
push rdx push rdx
push rdi push rdi
sub rsp, SIZE_QWORD
cmp byte [rdi + 1], 'u' cmp byte [rdi + 1], 'u'
je .callUINT2STR je .callUINT2STR
mov rdi, rsi mov rdi, rsi
@@ -182,10 +182,10 @@ printf:
call udec2str call udec2str
.loadConvertedStr: .loadConvertedStr:
mov rsi, rax mov rsi, rax
add rsp, SIZE_QWORD
pop rdi pop rdi
pop rdx pop rdx
pop rax pop rax
add rsp, SIZE_QWORD
jmp .insertString jmp .insertString
;--- '%x' / '%X' ---; ;--- '%x' / '%X' ---;