diff options
| author | Leslie Zhai <zhaixiang@loongson.cn> | 2024-11-14 23:01:36 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-14 16:01:36 +0100 |
| commit | 12f4afcba28931ea6f367e11abc2f27ba68ee7f9 (patch) | |
| tree | 4dc742c23ba83f85b9614cc0c800d197f62b89f9 /src/libtools | |
| parent | cd2638d11a1ce7d1db868e47953740ac540c40ee (diff) | |
| download | box64-12f4afcba28931ea6f367e11abc2f27ba68ee7f9.tar.gz box64-12f4afcba28931ea6f367e11abc2f27ba68ee7f9.zip | |
[LA64] Implement convert x64_va_list_t to sysv_varargs for float (#2025) (#2031)
* [LA64] Implement convert x64_va_list_t to sysv_varargs for float (#2025) * [LA64] Implement myStackAlignGVariantNew (#2025) * [LA64] Limit the log to LOG_DEBUG (#2055) * [LA64] Add missing file (#2025)
Diffstat (limited to 'src/libtools')
| -rw-r--r-- | src/libtools/myalign.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/libtools/myalign.c b/src/libtools/myalign.c index d60070bd..796795c0 100644 --- a/src/libtools/myalign.c +++ b/src/libtools/myalign.c @@ -1139,6 +1139,66 @@ void myStackAlignScanfWValist(x64emu_t* emu, const char* fmt, uint64_t* mystack, } } +void myStackAlignGVariantNew(x64emu_t* emu, const char* fmt, uint64_t* scratch, x64_va_list_t* b) +{ + uintptr_t* p = (uintptr_t*)(emu->scratch); + uintptr_t* p2 = (uintptr_t*)scratch; + int n = (X64_VA_MAX_REG - (*b)->gp_offset)/8; + int m = (X64_VA_MAX_XMM - (*b)->fp_offset)/8; + if(n) memcpy(&p[0], (*b)->reg_save_area+X64_VA_MAX_REG-n*8, n*8+m*16); + memcpy(&p[n+m], (*b)->overflow_arg_area, 20*8); + if (box64_log == LOG_DEBUG) { + printf_log(LOG_DEBUG, "%s\n", __FUNCTION__); + for (int i = 0; i < n+m+20; i++) { + printf_log(LOG_DEBUG, "p%d: 0x%lx\n", i, p[i]); + } + } + int idx = 0; + int gr_offs = 0; // offset in the reg_save_area + int fr_offs = 0; + int oa_gr_offs = 0; // offset in the overflow_arg_area + int oa_fr_offs = 0; + const char* pfmt = fmt; + while (*pfmt) { + switch (*pfmt) { + case 'd': + // double + if (fr_offs > m-2) { + p2[idx] = p[n+m+oa_fr_offs]; + oa_gr_offs++; + oa_fr_offs++; + } else { + p2[idx] = p[n+fr_offs]; + fr_offs+=2; + } + idx++; + break; + case 'b': + case 'y': + case 'n': + case 'q': + case 'i': + case 'h': + case 'u': + case 'x': + case 't': + if (gr_offs > n-1) { + p2[idx] = p[n+m+oa_gr_offs]; + oa_gr_offs++; + oa_fr_offs++; + } else { + p2[idx] = p[gr_offs]; + gr_offs++; + } + idx++; + break; + default: + break; + } + pfmt++; + } +} + #endif #define MUTEX_SIZE_X64 40 |