From: Rui Ueyama Date: Sun, 29 Oct 2017 16:49:42 +0000 (+0000) Subject: Fix ubsan error that shift amount 64 is too large. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6f4e722b1e82b25643239b33b773a22af166050;p=platform%2Fupstream%2Fllvm.git Fix ubsan error that shift amount 64 is too large. llvm-svn: 316863 --- diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 9b884d9..24ab052 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -763,7 +763,9 @@ template void SharedFile::parseRest() { // 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);