<div dir="ltr">Hi Dana,<div><br></div><div>Thanks for your patience. This looks good to me. Do you have commit access, or would you like me to commit on your behalf?</div><div><br></div><div>Regards,</div><div>Lang.</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 29, 2020 at 1:20 PM Dana Koch <<a href="mailto:dsk@google.com" target="_blank">dsk@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">JITted code may include relocations between sections, and the<br>
relocations often chosen to do this are 32-bit PC-relative relocation<br>
types. Thus, consideration must be made to ensure sections are allocated<br>
sufficiently close to one another.<br>
<br>
The SectionMemoryManager provides three memory groups, one for Code<br>
data, one for ROData, and one for RWdata. Sections are allocated with<br>
mmap (via allocateMappedMemory) which allows the caller to provide a<br>
hint to the system to suggest where to position mmap'ped memory. A<br>
memory group has a Near block which lets successive allocations to that<br>
memory group be positioned near other mappings in that group via the<br>
mmap hint. Initially, this Near block is empty, that is, its address is<br>
nullptr. When mmap is passed a nullptr hint, the system may choose any<br>
location to position the mapping.<br>
<br>
This means, prior to this commit, the first Code section mapping, ROData<br>
section mapping, and RWData section mapping will all be placed at a<br>
location of the system's choosing, and the system may choose distant<br>
enough locations in memory such that a 32-bit PC-relative relocation<br>
would overflow.<br>
<br>
Therefore, once allocateMappedMemory allocates the first mapping, copy<br>
that Near block hint to the other memory groups. This ensures that<br>
sections are allocated close to another so relative relocations are less<br>
likely to overflow.<br>
</blockquote></div>