[llvm] [Archive][COFF] Split hybrid COFF files when adding them to an archive (PR #205160)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 05:18:28 PDT 2026


================
@@ -887,12 +916,16 @@ computeMemberData(raw_ostream &StringTable, raw_ostream &SymNames,
   uint64_t PrevOffset = 0;
   uint64_t NextMemHeadPadSize = 0;
 
-  for (uint32_t Index = 0; Index < Ret.size(); ++Index) {
+  for (uint32_t Index = 0, MemberIndex = 0; Index < Ret.size(); ++Index) {
     MemberData &D = Ret[Index];
-    const NewArchiveMember *M = &NewMembers[Index];
+    const NewArchiveMember *M = &NewMembers[MemberIndex];
+    if (!D.HybridBuf.get())
+      ++MemberIndex;
     raw_string_ostream Out(D.Header);
 
-    MemoryBufferRef Buf = M->Buf->getMemBufferRef();
+    MemoryBufferRef Buf = D.HybridBuf.get() ? D.HybridBuf->getMemBufferRef()
+                          : D.SymFile       ? D.SymFile->getMemoryBufferRef()
----------------
cjacek wrote:

I moved the logic closer to where we split the object. By setting `D.Data` there, we don't need the logic here and I think it's more straightforward.

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


More information about the llvm-commits mailing list