[PATCH] D140518: [lld-macho] Fix assert when splitting section

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 22 13:19:13 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG63173d11ecb5: [lld-macho] Fix assert when splitting section (authored by keith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140518/new/

https://reviews.llvm.org/D140518

Files:
  lld/MachO/InputFiles.cpp


Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -329,14 +329,14 @@
                                                     : buf + sec.offset,
                               static_cast<size_t>(sec.size)};
 
-    auto splitRecords = [&](int recordSize) -> void {
+    auto splitRecords = [&](size_t recordSize) -> void {
       if (data.empty())
         return;
       Subsections &subsections = section.subsections;
       subsections.reserve(data.size() / recordSize);
       for (uint64_t off = 0; off < data.size(); off += recordSize) {
         auto *isec = make<ConcatInputSection>(
-            section, data.slice(off, recordSize), align);
+            section, data.slice(off, std::min(data.size(), recordSize)), align);
         subsections.push_back({off, isec});
       }
       section.doneSplitting = true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140518.484952.patch
Type: text/x-patch
Size: 932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221222/8773f0d8/attachment.bin>


More information about the llvm-commits mailing list