[lld] r316849 - Fix ubsan error.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 28 15:18:29 PDT 2017
Author: ruiu
Date: Sat Oct 28 15:18:29 2017
New Revision: 316849
URL: http://llvm.org/viewvc/llvm-project?rev=316849&view=rev
Log:
Fix ubsan error.
This patch fixes ubsan's "shift exponent 64 is too large for 32-bit type
'int'" error.
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=316849&r1=316848&r2=316849&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Sat Oct 28 15:18:29 2017
@@ -763,7 +763,7 @@ 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 = 1 << countTrailingZeros((uint64_t)Sym.st_value);
+ uint32_t 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