[llvm] [llvm-objcopy][ELF] Disable huge section offset (PR #97036)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 01:03:41 PDT 2024


================
@@ -2744,6 +2744,13 @@ Error BinaryWriter::finalize() {
     if (Sec.Type != SHT_NOBITS && Sec.Size > 0) {
       Sec.Offset = Sec.Addr - MinAddr;
       TotalSize = std::max(TotalSize, Sec.Offset + Sec.Size);
+
+      if (MaxHugeSectionOffset) {
+        if (Sec.Offset > *MaxHugeSectionOffset)
+          return createStringError(errc::file_too_large,
+                                   "writing section " + Sec.Name +
+                                       " at huge file offset");
----------------
jh7370 wrote:

Please include the specific offset, and the max limit in this. Something like "writing section <secname> at offset greater than max offset <value> specified by --max-file-offset".

https://github.com/llvm/llvm-project/pull/97036


More information about the llvm-commits mailing list