<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 08/09/2015 07:43 AM,
<a class="moz-txt-link-abbreviated" href="mailto:marwayusuf@feng.bu.edu.eg">marwayusuf@feng.bu.edu.eg</a> via llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:AM2PR01MB0804C3B5840B73EDAB421B01BB710@AM2PR01MB0804.eurprd01.prod.exchangelabs.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Dear All</p>
<p>I need to read the stackmap section at runtime of the
inspected application. I've read the documentation of stackmap
and found this paragraph:</p>
<p>"<span style="font-family: 'Lucida Grande', 'Lucida Sans
Unicode', Geneva, Verdana, sans-serif; font-size: 14px;
line-height: 21px;">A JIT compiler can easily access this
section by providing its own memory manager via the LLVM C
API</span><span style="font-family: 'Lucida Grande', 'Lucida
Sans Unicode', Geneva, Verdana, sans-serif; font-size: 14px;
line-height: 21px;"> </span><tt class="docutils literal"
style="line-height: 21px; font-family: Consolas, 'Deja Vu
Sans Mono', 'Bitstream Vera Sans Mono', monospace;
font-size: 0.95em;"><span class="pre">LLVMCreateSimpleMCJITMemoryManager()</span></tt><span
style="font-family: 'Lucida Grande', 'Lucida Sans Unicode',
Geneva, Verdana, sans-serif; font-size: 14px; line-height:
21px;">. When creating the memory manager, the JIT provides
a callback:</span><span style="font-family: 'Lucida Grande',
'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 14px; line-height: 21px;"> </span><tt
class="docutils literal" style="line-height: 21px;
font-family: Consolas, 'Deja Vu Sans Mono', 'Bitstream Vera
Sans Mono', monospace; font-size: 0.95em;"><span class="pre">LLVMMemoryManagerAllocateDataSectionCallback()</span></tt><span
style="font-family: 'Lucida Grande', 'Lucida Sans Unicode',
Geneva, Verdana, sans-serif; font-size: 14px; line-height:
21px;">. 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.</span></p>
<p style="margin: 0.8em 0px 0.5em; font-family: 'Lucida Grande',
'Lucida Sans Unicode', Geneva, Verdana, sans-serif; font-size:
14px; line-height: 21px;">
On Darwin, the stack map section name is “__llvm_stackmaps”.
The segment name is “__LLVM_STACKMAPS”."</p>
<p style="margin: 0.8em 0px 0.5em; font-family: 'Lucida Grande',
'Lucida Sans Unicode', Geneva, Verdana, sans-serif; font-size:
14px; line-height: 21px;">
However I can't figure how to make <span style="font-family:
Consolas, 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono',
monospace; font-size: 15.1999998092651px;">LLVMCreateSimpleMCJITMemoryManager
or </span><span style="font-family: Consolas, 'Deja Vu Sans
Mono', 'Bitstream Vera Sans Mono', monospace; font-size:
15.1999998092651px;">LLVMMemoryManagerAllocateDataSectionCallback
or make use of them. And I could not find examples for their
useage. Any help is appreciated.</span></p>
</div>
</blockquote>
I'm going to completely ignore the C API because I'm not familiar
with it, but the ideas should map over.<br>
<br>
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.<br>
<br>
Hope that helps. <br>
<br>
Philip<br>
</body>
</html>