fix(gen): 裸名回退时 malloc/calloc/realloc/alloc/alloc_buf 的 size 参数按 i64 提升——desktop 第 4 次 mm.malloc 返回值被破坏收到 0x0、用户 App vpsdk malloc 同理
This commit is contained in:
1 parent
f185241a71
commit
07db560510
1 file changed
+17
@@ -166,6 +166,7 @@ class CallGenLib(CallGenBase.CallGenBase):
|
||||
if string.strcmp(bare_name, "parse") == 0 or string.strcmp(func_name, "parse") == 0 or string.strcmp(func_name, "json_parse") == 0:
|
||||
return i8_ptr_ty
|
||||
# MemBuddy 方法(当类型信息丢失时可能走外部函数路径)
|
||||
# 存疑
|
||||
# malloc:裸名 CExport 跨模块调用(uhci/desktop 等 mm.malloc → @malloc)
|
||||
# 在模块归属解析失败(mod_ret_sha1=None)或 vpi/text.ll 未命中时回退到
|
||||
# 此白名单。缺失导致返回类型被推断为 i32 → call i32 @malloc 截断 64 位
|
||||
@@ -350,6 +351,22 @@ class CallGenLib(CallGenBase.CallGenBase):
|
||||
if string.strcmp(api_name, func_name) == 0:
|
||||
return i64_ty
|
||||
|
||||
# 内存分配函数:size 参数在声明中为 i64(size_t),裸名回退时
|
||||
# 不提升则 call(i32 size) 与 define(i64 size) 不匹配(desktop start
|
||||
# 第 4 次 mm.malloc(w*4) 返回值被破坏收到 0x0 根因;HelloWorld
|
||||
# vpsdk 的 malloc 同理)。calloc/realloc 的 size 参数在 idx 1。
|
||||
if string.strcmp(func_name, "malloc") == 0 \
|
||||
or string.strcmp(func_name, "alloc") == 0 \
|
||||
or string.strcmp(func_name, "alloc_buf") == 0:
|
||||
if param_idx == 0:
|
||||
return i64_ty
|
||||
if string.strcmp(func_name, "calloc") == 0:
|
||||
if param_idx == 0 or param_idx == 1:
|
||||
return i64_ty
|
||||
if string.strcmp(func_name, "realloc") == 0:
|
||||
if param_idx == 1:
|
||||
return i64_ty
|
||||
|
||||
return None
|
||||
def _is_sha1_mangled_call(self, call_name: str) -> int:
|
||||
"""判断 call_name 是否为跨模块 Viper 函数("{16位hex}.func" 形式)
|
||||
|
||||
Reference in new issue
Block a user