]> granicus.if.org Git - llvm/commitdiff
[RuntimeDyld] fix too-small-bitmask error
authorNick Desaulniers <ndesaulniers@google.com>
Sat, 1 Jun 2019 04:51:26 +0000 (04:51 +0000)
committerNick Desaulniers <ndesaulniers@google.com>
Sat, 1 Jun 2019 04:51:26 +0000 (04:51 +0000)
Summary:
This was flagged in https://www.viva64.com/en/b/0629/ under "Snippet No.
33".

It seems that this statement is doing the standard bitwise trick for
adjusting a value to have a specific alignment.

The issue is that getStubAlignment() returns an unsigned, while DataSize
is declared a uint64_t. The right hand side of the expression is not
extended to 64b before bitwise negation, resulting in the top half of
the mask being 0s, which is not correct for realignment.

Reviewers: lhames, MaskRay

Reviewed By: MaskRay

Subscribers: RKSimon, MaskRay, hiraditya, llvm-commits, srhines

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62227

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362286 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp

index e0642adbd31c704cbb812b1b7f7beb5fe45d439d..e26e6ce45db4cd2775f243bf2a82025b9513ea02 100644 (file)
@@ -842,7 +842,7 @@ RuntimeDyldImpl::emitSection(const ObjectFile &Obj,
       // Align DataSize to stub alignment if we have any stubs (PaddingSize will
       // have been increased above to account for this).
       if (StubBufSize > 0)
-        DataSize &= ~(getStubAlignment() - 1);
+        DataSize &= -(uint64_t)getStubAlignment();
     }
 
     LLVM_DEBUG(dbgs() << "emitSection SectionID: " << SectionID << " Name: "