[ELF] - Do not crash if common symbol alignment set to value greater than UINT32_MAX.
authorGeorge Rimar <grimar@accesssoftek.com>
Mon, 10 Oct 2016 10:10:09 +0000 (10:10 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Mon, 10 Oct 2016 10:10:09 +0000 (10:10 +0000)
commit50188b2771c7ef81c4d439ac6133d51bdfa775a0
tree9235176f6fa110584a1a213af5dd1fd55cd6436a
parenta9b79e666cabe80f08b4c7c80501de9b354fe1d1
[ELF] - Do not crash if common symbol alignment set to value greater than UINT32_MAX.

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: 283733
lld/test/ELF/invalid/Inputs/common-symbol-alignment2.elf [new file with mode: 0644]
lld/test/ELF/invalid/common-symbol-alignment.s