Skip to content

Commit 711402e

Browse files
Comments
1 parent ee75bea commit 711402e

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

lld/MachO/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static InputFile *addFile(StringRef path, LoadType loadType,
360360
": Archive::children failed: " + toString(std::move(e)));
361361
}
362362
} else if (isCommandLineLoad && config->forceLoadObjC) {
363-
if (file->getArchive().getNumberOfSymbols() > 0) {
363+
if (file->getArchive().hasSymbolTable()) {
364364
for (const object::Archive::Symbol &sym : file->getArchive().symbols())
365365
if (sym.getName().starts_with(objc::symbol_names::klass))
366366
file->fetch(sym);

lld/MachO/InputFiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,7 @@ void ArchiveFile::addLazySymbols() {
21622162
if (file->isEmpty())
21632163
return;
21642164

2165-
if (file->getNumberOfSymbols() == 0) {
2165+
if (!file->hasSymbolTable()) {
21662166
// No index, treat each child as a lazy object file.
21672167
Error e = Error::success();
21682168
for (const object::Archive::Child &c : file->children(e)) {

lld/test/MachO/archive-no-index.ll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; REQUIRES: x86
2+
; RUN: rm -rf %t; split-file %s %t
3+
4+
; RUN: llvm-as %t/lib.ll -o %t/lib.o
5+
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main.o %t/main.s
6+
; RUN: llvm-ar rcST %t/lib.a %t/lib.o
7+
# RUN: %lld %t/main.o %t/lib.a -o %t/out
8+
9+
;--- main.s
10+
.global _main
11+
_main:
12+
call _foo
13+
mov $0, %rax
14+
ret
15+
16+
;--- lib.ll
17+
target triple = "x86_64-apple-darwin"
18+
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
19+
20+
define void @foo() {
21+
entry:
22+
ret void
23+
}

0 commit comments

Comments
 (0)