<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 6, 2015 at 11:27 PM, Lang Hames <span dir="ltr"><<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: lhames<br>
Date: Tue Apr 7 01:27:56 2015<br>
New Revision: 234299<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=234299&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=234299&view=rev</a><br>
Log:<br>
[RuntimeDyld] Always allocate at least 1 byte for object sections in the JIT to<br>
ensure that section addresses are distinct.<br>
<br>
mapSectionAddress will fail if two sections are allocated the same address,<br>
which can happen if any section has zero size (since malloc(0) is implementation<br>
defined). Unfortunately I've been unable to repro this with a simple test case.<br></blockquote><div><br>Not sure about malloc, but new is guaranteed to give unique addresses even for zero size allocations... <br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Fixes <rdar://problem/20314015>.<br>
<br>
<br>
Modified:<br>
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=234299&r1=234298&r2=234299&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=234299&r1=234298&r2=234299&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Tue Apr 7 01:27:56 2015<br>
@@ -361,19 +361,20 @@ void RuntimeDyldImpl::computeTotalAllocS<br>
if (Name == ".eh_frame")<br>
SectionSize += 4;<br>
<br>
- if (SectionSize > 0) {<br>
- // save the total size of the section<br>
- if (IsCode) {<br>
- CodeSectionSizes.push_back(SectionSize);<br>
- } else if (IsReadOnly) {<br>
- ROSectionSizes.push_back(SectionSize);<br>
- } else {<br>
- RWSectionSizes.push_back(SectionSize);<br>
- }<br>
- // update the max alignment<br>
- if (Alignment > MaxAlignment) {<br>
- MaxAlignment = Alignment;<br>
- }<br>
+ if (!SectionSize)<br>
+ SectionSize = 1;<br>
+<br>
+ if (IsCode) {<br>
+ CodeSectionSizes.push_back(SectionSize);<br>
+ } else if (IsReadOnly) {<br>
+ ROSectionSizes.push_back(SectionSize);<br>
+ } else {<br>
+ RWSectionSizes.push_back(SectionSize);<br>
+ }<br>
+<br>
+ // update the max alignment<br>
+ if (Alignment > MaxAlignment) {<br>
+ MaxAlignment = Alignment;<br>
}<br>
}<br>
}<br>
@@ -578,6 +579,8 @@ unsigned RuntimeDyldImpl::emitSection(co<br>
if (IsRequired) {<br>
Check(Section.getContents(data));<br>
Allocate = DataSize + PaddingSize + StubBufSize;<br>
+ if (!Allocate)<br>
+ Allocate = 1;<br>
Addr = IsCode ? MemMgr.allocateCodeSection(Allocate, Alignment, SectionID,<br>
Name)<br>
: MemMgr.allocateDataSection(Allocate, Alignment, SectionID,<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>