-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #8 Go 会为泛型函数生成中间函数。但实际需要 mock 的是中间函数所 调用的公共函数。为此,我们需要遍历中间函数机器码,通过 CALL 指令确定公共函数的地址。 如果函数使用了 struct 值传递,Go 在一些场景下会插入若干额外 的 CALL 指令。这样 monkey 就会拿到错误的公共函数地址。 为此,我们需要跳过因为 struct 传值而需要执行的 CALL 指令。 通过观察生成的汇编代码,我发现这些 CALL 指令用 BP 寄存器,而 调用公共函数用的是 AX 寄存器。所以可以根据寄存器参数来过滤。
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters