[lld] r317528 - Report an error if an inferred alignment for a shared symbol is too large.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 16:12:06 PST 2017


Author: ruiu
Date: Mon Nov  6 16:12:05 2017
New Revision: 317528

URL: http://llvm.org/viewvc/llvm-project?rev=317528&view=rev
Log:
Report an error if an inferred alignment for a shared symbol is too large.

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

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=317528&r1=317527&r2=317528&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Mon Nov  6 16:12:05 2017
@@ -809,13 +809,15 @@ 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;
+    uint64_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;
+      uint64_t SecAlign = Sections[Sym.st_shndx].sh_addralign;
       Alignment = std::min(Alignment, SecAlign);
     }
+    if (Alignment > UINT32_MAX)
+      error(toString(this) + ": alignment too large: " + Name);
 
     if (!Hidden)
       Symtab->addShared(Name, this, Sym, Alignment, Ver);




More information about the llvm-commits mailing list