Recommit r283733 "[ELF] - Do not crash if common symbol alignment set to value greate...
authorGeorge Rimar <grimar@accesssoftek.com>
Mon, 10 Oct 2016 10:31:03 +0000 (10:31 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Mon, 10 Oct 2016 10:31:03 +0000 (10:31 +0000)
commit27e651d4f69527b12d02e1f02dd6da9f423f1d4d
tree541f2f409df34f51417f1bc6bb1a28933f3d7995
parenta1b82456541f1dd47cf01d42754c227270b472b4
Recommit r283733 "[ELF] - Do not crash if common symbol alignment set to value greater than UINT32_MAX.

With fix: commit changes from InputFiles.cpp too.

Original commit message:
We have following code in lld, that truncates the alignment value to 32 bit. Big alignment in this case
may give result 0 and crash later.

template <class ELFT>
CommonInputSection<ELFT>::CommonInputSection(std::vector<DefinedCommon *> Syms)
    : InputSection<ELFT>(nullptr, &Hdr, "") {
....
  for (DefinedCommon *Sym : Syms) {
    this->Alignment = std::max<uintX_t>(this->Alignment, Sym->Alignment);
...
  }
}

Patch fixes the issue.

Differential revision: https://reviews.llvm.org/D25235

llvm-svn: 283738
lld/ELF/InputFiles.cpp
lld/test/ELF/invalid/Inputs/common-symbol-alignment2.elf [new file with mode: 0644]
lld/test/ELF/invalid/common-symbol-alignment.s