如何在 LLVM 中保持固定代码的原子性
我使用自己的通道将一些指令插入到程序的基本块中。生成可执行文件后,反汇编可以发现一些插入指令的顺序被优化,特别是一些插入指令与非插入指令(程序的原始指令)混合在一起。我想问如何禁用指令重新排序并保留仪器代码的整体原子性?也许选择无? 检测代码如下:
/* Load */
LoadInst *MapPtr = IRB.CreateLoad(MAP);
MapPtr->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
/* Store */
IRB.CreateStore(Num, MAP)
->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
I used my own pass to insert some instructions into the basic block of the program. After the executable file was generated, disassembly could find that the order of some insert instructions was optimized, especially some inserting instructions were mixed with non-inserting instructions (the original instructions of the program). I would like to ask how can I disable the reordering of instructions and preserve the overall atomicity of my instrumentation code? Maybe optnone?
The instrumentation code like this:
/* Load */
LoadInst *MapPtr = IRB.CreateLoad(MAP);
MapPtr->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
/* Store */
IRB.CreateStore(Num, MAP)
->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论