[PATCH] D38005: [COFF] Check for sections larger than 4 GiB

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 15:41:46 PDT 2017


smeenai created this revision.

Sections are limited to 4 GiB. Error out early if a section exceeds this
size, rather than overflowing the section size and getting confusing
assertion failures/segfaults later.


https://reviews.llvm.org/D38005

Files:
  COFF/Writer.cpp


Index: COFF/Writer.cpp
===================================================================
--- COFF/Writer.cpp
+++ COFF/Writer.cpp
@@ -187,6 +187,8 @@
   C->setRVA(Off);
   C->OutputSectionOff = Off;
   Off += C->getSize();
+  if (Off > UINT32_MAX)
+    fatal("section larger than 4 GiB: " + Name);
   Header.VirtualSize = Off;
   if (C->hasData())
     Header.SizeOfRawData = alignTo(Off, SectorSize);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38005.115736.patch
Type: text/x-patch
Size: 403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170918/e2c60dda/attachment.bin>


More information about the llvm-commits mailing list