[lld] r316863 - Fix ubsan error that shift amount 64 is too large.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 29 09:49:42 PDT 2017


Author: ruiu
Date: Sun Oct 29 09:49:42 2017
New Revision: 316863

URL: http://llvm.org/viewvc/llvm-project?rev=316863&view=rev
Log:
Fix ubsan error that shift amount 64 is too large.

Modified:
    lld/trunk/ELF/InputFiles.cpp

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=316863&r1=316862&r2=316863&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Sun Oct 29 09:49:42 2017
@@ -763,7 +763,9 @@ template <class ELFT> void SharedFile<EL
     // files because the loader takes care of it. However, if we promote a
     // DSO symbol to point to .bss due to copy relocation, we need to keep
     // the original alignment requirements. We infer it here.
-    uint32_t Alignment = 1ULL << countTrailingZeros((uint64_t)Sym.st_value);
+    uint32_t Alignment = 1;
+    if (Sym.st_value)
+      Alignment = 1ULL << countTrailingZeros((uint64_t)Sym.st_value);
     if (0 < Sym.st_shndx && Sym.st_shndx < Sections.size()) {
       uint32_t SecAlign = Sections[Sym.st_shndx].sh_addralign;
       Alignment = std::min(Alignment, SecAlign);




More information about the llvm-commits mailing list