[lld] [lld-macho] Support archives without index (PR #132942)
Leonard Grey via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 15:00:44 PDT 2025
================
@@ -2156,9 +2156,34 @@ ArchiveFile::ArchiveFile(std::unique_ptr<object::Archive> &&f, bool forceHidden)
void ArchiveFile::addLazySymbols() {
// Avoid calling getMemoryBufferRef() on zero-symbol archive
// since that crashes.
- if (file->isEmpty() || file->getNumberOfSymbols() == 0)
+ if (file->isEmpty())
return;
+ if (file->getNumberOfSymbols() == 0) {
+ // No index, treat each child as a lazy object file.
+ Error e = Error::success();
+ for (const object::Archive::Child &c : file->children(e)) {
+ // Check `seen` but don't insert so a future eager load can still happen.
+ if (seen.contains(c.getChildOffset()))
+ continue;
+ if (!seenLazy.insert(c.getChildOffset()).second) {
+ continue;
+ }
+ // First check seen.
+ // Then, write to and check seenLazy
----------------
speednoisemovement wrote:
Old diff that got cleaned up, this was my todo list :D
https://github.com/llvm/llvm-project/pull/132942
More information about the llvm-commits
mailing list