[LLVMdev] about stackmap intrinsic

Andrew Trick atrick at apple.com
Sat Jun 28 09:37:31 PDT 2014


On Jun 28, 2014, at 4:24 AM, marwayusuf at feng.bu.edu.eg wrote:

> Dear All
> My MSc was about implementing some kind of On stack replacement in LLVM to enhance security by obfuscating running code periodically.
> I've tried to implement this job in JIT, but I couldn't. So I implemented it in interpreter, as an initial step.
> However, now I'm trying to make it in JIT.
> My first step is to extract function state at an arbitrary point. So, I interrupt function at any point (from within JIT) and pause to extract state. My problem now is with state.
> By searching I found about stackmap new intrinsic. I got idea about what it does and I think it may help greatly in my task. However, I could not find any source about how to use it exactly, specially, how to retrieve information stored in a stackmap. I'm not understanding the concept of intrinsics very well.​ Again, I tried to find any source that explains how intrinsic work, but I couldn't.
> So, any help will be greatly appreciated.

http://llvm.org/docs/StackMaps.html

The format of the stackmap section is defined in include/CodeGen/StackMaps.h. You currently have to intercept calls to RTDyldMemoryManager to find the stackmap section.

The intrinsics and stackmap format will probably change again before the next LLVM release.

You cannot arbitrarily stop a thread running compiled code and extract the state. You have to patch the code so that it calls back to your runtime at a known location. The stackmap intrinsic can be useful if you want to destrcutively patch the code and don't want control to resume in the JITed function. The patchpoint intrinsic works if you want to patch into the runtime and return back to the JIT function.

-Andy

> 
> 
> Regards,
> Marwa Yusuf
> Teaching Assistant - Computer Engineering Department
> Faculty of Engineering - Benha University
> E-JUST MSc Student
> Computer Science & Engineering Dept.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140628/5ec99909/attachment.html>


More information about the llvm-dev mailing list