[lld] r316280 - Assume that mergeable input sections are smaller than 4 GiB.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 11:53:20 PDT 2017


Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:

>  template <class ELFT>
>  MergeInputSection::MergeInputSection(ObjFile<ELFT> *F,
>                                       const typename ELFT::Shdr *Header,
>                                       StringRef Name)
> -    : InputSectionBase(F, Header, Name, InputSectionBase::Merge) {}
> +    : InputSectionBase(F, Header, Name, InputSectionBase::Merge) {
> +  // In order to reduce memory allocation, we assume that mergeable
> +  // sections are smaller than 4 GiB, which is not an unreasonable
> +  // assumption as of 2017.
> +  if (Data.size() > UINT32_MAX)
> +    error(toString(this) + ": section too large");
> +}

Unless I am missing something, nothing in the code actually fails if a
section is larger than 4GB, only if a SectionPiece is that big, no?

Cheers,
Rafael


More information about the llvm-commits mailing list