marwayusuf@feng.bu.edu.eg via llvm-dev
2015-Aug-09 14:43 UTC
[llvm-dev] About Stackmap section
Dear All I need to read the stackmap section at runtime of the inspected application. I've read the documentation of stackmap and found this paragraph: "A JIT compiler can easily access this section by providing its own memory manager via the LLVM C API LLVMCreateSimpleMCJITMemoryManager(). When creating the memory manager, the JIT provides a callback: LLVMMemoryManagerAllocateDataSectionCallback(). When LLVM creates this section, it invokes the callback and passes the section name. The JIT can record the in-memory address of the section at this time and later parse it to recover the stack map data. On Darwin, the stack map section name is "__llvm_stackmaps". The segment name is "__LLVM_STACKMAPS"." However I can't figure how to make LLVMCreateSimpleMCJITMemoryManager or LLVMMemoryManagerAllocateDataSectionCallback or make use of them. And I could not find examples for their useage. Any help is appreciated. Regards, Marwa Yusuf Teaching Assistant - Computer Engineering Department Faculty of Engineering - Benha University E-JUST PhD Student Computer Science & Engineering Dept. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150809/ff7f1982/attachment.html>
On 08/09/2015 07:43 AM, marwayusuf at feng.bu.edu.eg via llvm-dev wrote:> > Dear All > > I need to read the stackmap section at runtime of the inspected > application. I've read the documentation of stackmap and found this > paragraph: > > "A JIT compiler can easily access this section by providing its own > memory manager via the LLVM C APILLVMCreateSimpleMCJITMemoryManager(). > When creating the memory manager, the JIT provides a > callback:LLVMMemoryManagerAllocateDataSectionCallback(). When LLVM > creates this section, it invokes the callback and passes the section > name. The JIT can record the in-memory address of the section at this > time and later parse it to recover the stack map data. > > On Darwin, the stack map section name is “__llvm_stackmaps”. The > segment name is “__LLVM_STACKMAPS”." > > However I can't figure how to make LLVMCreateSimpleMCJITMemoryManager > or LLVMMemoryManagerAllocateDataSectionCallback or make use of them. > And I could not find examples for their useage. Any help is appreciated. >I'm going to completely ignore the C API because I'm not familiar with it, but the ideas should map over. You need to create a custom MCJIT memory manager object which implements the "allocateDataSection" method on "SectionMemoryManager" such that it captures information about the section being created when actually doing the allocation. If you're relocating sections, you'll also need to track this through mapSectionAddress. If you save information about the relevant section in a side structure, you can use the in tree stack map parser to decode the section. Hope that helps. Philip -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150812/1ef3524e/attachment.html>
marwayusuf@feng.bu.edu.eg via llvm-dev
2015-Aug-19 22:56 UTC
[llvm-dev] About Stackmap section
I've just seen this reply now. Thanks a million for your help. Actually I've gone in another direction to get the stackmap section. and it's working till now. I've used the JITEventListner interface. However, I could not manage to parse the section yet. I could not figure how to use the stackmap parser at all! Regards, Marwa Yusuf Teaching Assistant - Computer Engineering Department Faculty of Engineering - Benha University E-JUST PhD Student Computer Science & Engineering Dept. ________________________________ From: Philip Reames <listmail at philipreames.com> Sent: Wednesday, August 12, 2015 9:03 PM To: marwayusuf at feng.bu.edu.eg; llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] About Stackmap section On 08/09/2015 07:43 AM, marwayusuf at feng.bu.edu.eg<mailto:marwayusuf at feng.bu.edu.eg> via llvm-dev wrote: Dear All I need to read the stackmap section at runtime of the inspected application. I've read the documentation of stackmap and found this paragraph: "A JIT compiler can easily access this section by providing its own memory manager via the LLVM C API LLVMCreateSimpleMCJITMemoryManager(). When creating the memory manager, the JIT provides a callback: LLVMMemoryManagerAllocateDataSectionCallback(). When LLVM creates this section, it invokes the callback and passes the section name. The JIT can record the in-memory address of the section at this time and later parse it to recover the stack map data. On Darwin, the stack map section name is "__llvm_stackmaps". The segment name is "__LLVM_STACKMAPS"." However I can't figure how to make LLVMCreateSimpleMCJITMemoryManager or LLVMMemoryManagerAllocateDataSectionCallback or make use of them. And I could not find examples for their useage. Any help is appreciated. I'm going to completely ignore the C API because I'm not familiar with it, but the ideas should map over. You need to create a custom MCJIT memory manager object which implements the "allocateDataSection" method on "SectionMemoryManager" such that it captures information about the section being created when actually doing the allocation. If you're relocating sections, you'll also need to track this through mapSectionAddress. If you save information about the relevant section in a side structure, you can use the in tree stack map parser to decode the section. Hope that helps. Philip -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150819/8bb7ad3a/attachment.html>