[lld-macho] Fix "shift exponent too large" UBSAN error
authorJez Ng <jezng@fb.com>
Mon, 14 Jun 2021 03:20:30 +0000 (23:20 -0400)
committerJez Ng <jezng@fb.com>
Mon, 14 Jun 2021 17:47:25 +0000 (13:47 -0400)
UBSAN seems to have added this check somewhere along the way...

This might also fix the PPC buildbot, which is failing on the same test

lld/MachO/InputFiles.cpp

index 0b51292..3ee1959 100644 (file)
@@ -254,9 +254,12 @@ void ObjFile::parseSections(ArrayRef<Section> sections) {
     ArrayRef<uint8_t> data = {isZeroFill(sec.flags) ? nullptr
                                                     : buf + sec.offset,
                               static_cast<size_t>(sec.size)};
-    if (sec.align >= 32)
+    if (sec.align >= 32) {
       error("alignment " + std::to_string(sec.align) + " of section " + name +
             " is too large");
+      subsections.push_back({});
+      continue;
+    }
     uint32_t align = 1 << sec.align;
     uint32_t flags = sec.flags;