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.

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

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!