[PATCH] D25272: [ELF] - Fixed behavior when amount of inputsections is too large.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 11 00:57:10 PDT 2016


grimar added a comment.

In https://reviews.llvm.org/D25272#566393, @ruiu wrote:

> Isn't this the same as the previous code?


Not exactly. It has almost the same functionality. My motivation was following. When we have code like:

  uint64_t Size = this->ELFObj.getNumSections();
  Sections.resize(Size);

Then we are almost unable to do something with possible crash and overflow on lld side. Ideally I think we do not want to insert checks in getNumSections() probably as some utils like llvm-objdump for example may want to show the value even if it is incorrect. So issue checking should happen only if we try to access the section content.
So plan was to do some checking in Obj.sections().

At the same time current Object/ELF.h code already has some code that has checks for amount of sections. And it do that on object loading. Code does not work well though, and I posted first patch for it: https://reviews.llvm.org/D25432. Though I am not sure that doing a check during loading is the best way.

Lets put this on hold until some changes in ELF.h be landed.


https://reviews.llvm.org/D25272





More information about the llvm-commits mailing list