]> granicus.if.org Git - llvm/commitdiff
Silence ubsan after r367926.
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 6 Aug 2019 00:21:30 +0000 (00:21 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 6 Aug 2019 00:21:30 +0000 (00:21 +0000)
Fixes e.g.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/14273

We can't left shift here because left shifting of a negative number is UB.
The same doesn't apply to unsigned arithmetic, but switching to unsigned
doesn't appear to stop ubsan from complaining, so we need to mask out the
high bits.

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

lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp

index 03c5c6b8e10ed726ed830bfc3b198b3f8bb7ad4a..d6596ea39262e2aac431a11b58837fe47bc29a09 100644 (file)
@@ -178,6 +178,7 @@ std::error_code SymbolizableObjectFile::addSymbol(const SymbolRef &Symbol,
   if (UntagAddresses) {
     // For kernel addresses, bits 56-63 need to be set, so we sign extend bit 55
     // into bits 56-63 instead of masking them out.
+    SymbolAddress &= (1ull << 56) - 1;
     SymbolAddress = (int64_t(SymbolAddress) << 8) >> 8;
   }
   if (OpdExtractor) {