[lld] [LLD][COFF] Add support for IMPORT_NAME_EXPORTAS import library names. (PR #83211)

Daniel Paoliello via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 10:44:38 PST 2024


================
@@ -944,18 +944,20 @@ ImportFile::ImportFile(COFFLinkerContext &ctx, MemoryBufferRef m)
     : InputFile(ctx, ImportKind, m), live(!ctx.config.doGC), thunkLive(live) {}
 
 void ImportFile::parse() {
-  const char *buf = mb.getBufferStart();
-  const auto *hdr = reinterpret_cast<const coff_import_header *>(buf);
+  const auto *hdr =
+      reinterpret_cast<const coff_import_header *>(mb.getBufferStart());
 
   // Check if the total size is valid.
-  if (mb.getBufferSize() != sizeof(*hdr) + hdr->SizeOfData)
+  if (mb.getBufferSize() < sizeof(*hdr) ||
+      mb.getBufferSize() != sizeof(*hdr) + hdr->SizeOfData)
----------------
dpaoliello wrote:

Not sure if this is required: isn't `SizeOfData` unsigned?

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


More information about the llvm-commits mailing list