[lld] [lld-macho] Support archives without index (PR #132942)
Leonard Grey via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 11:58:56 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.
----------------
speednoisemovement wrote:
I was going off the logic in Driver.cpp, specifically:
```
// Command-line loads take precedence. If file is previously loaded via
// command line, or is loaded via LC_LINKER_OPTION and being loaded via
// LC_LINKER_OPTION again, using the cached archive is enough.
```
so I guess it's your scenario but s/force_load/LC_LINKER_OPTION. I think we would actually drop the force load in that case. Is that a bug?
https://github.com/llvm/llvm-project/pull/132942
More information about the llvm-commits
mailing list