【发布时间】:2013-12-19 22:26:48
【问题描述】:
我阅读了JIT Interface 章节并遇到了问题:如何为最简单的代码编写一个最简单的示例(最好在 C++ 中,至少在 x86-64 中平台)?说,我要调试以下代码(即code_.data()函数):
#include "eallocator.hpp"
#include <iostream>
#include <vector>
#include <cstdlib>
int main()
{
std::vector< std::uint8_t, eallocator< std::uint8_t > > code_;
code_.push_back(0b11011001u); code_.push_back(0b11101011u); // fldpi
code_.push_back(0b11000011u); // ret
double result_;
__asm("call *%1"
: "=&t"(result_)
: "r"(code_.data())
:
);
std::cout << result_ << std::endl;
return EXIT_SUCCESS;
}
我应该(最少)做什么来使用这个界面?特别是,如果可能的话,我希望能够提供一些伪代码(内存中的任意文本)作为“源”(带有相应的行信息)。
如何在保持简洁的同时检测上述代码(或类似代码)。
#include "eallocator.hpp" 应该使用来自this for Windows 或来自this for Linux 的方法。
【问题讨论】:
-
-450 赏金。很抱歉,但我不能提供其他任何东西。