This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Do not crash if common symbol alignment set to value greater than UINT32_MAX.
ClosedPublic

Authored by grimar on Oct 4 2016, 6:57 AM.

Details

Summary

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. I did not find the way to generate object using yaml2obj for that case.

Diff Detail

Event Timeline

grimar updated this revision to Diff 73471.Oct 4 2016, 6:57 AM
grimar retitled this revision from to [ELF] - Do not crash if common symbol alignment set to value greater than UINT32_MAX..
grimar updated this object.
grimar added reviewers: ruiu, rafael, davide.
grimar added subscribers: llvm-commits, grimar, evgeny777.
rafael accepted this revision.Oct 7 2016, 12:47 PM
rafael edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 7 2016, 12:47 PM
ruiu added inline comments.Oct 7 2016, 1:12 PM
ELF/InputFiles.cpp
405
"': invalid alignment: " + Twine(Sym->st_value

is probably more helpful.

grimar closed this revision.Oct 10 2016, 4:08 AM

Revision: 283738