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