lld: remove old test support path

This removes the stub library that lld injected to satisfy the
dependency on the libSystem.  Now with TBD support, we can provide the
stub library to permit the tests to function properly as they would on a
real system.

Reviewed By: smeenai
Differential Revision: https://reviews.llvm.org/D81418
This commit is contained in:
Saleem Abdulrasool 2020-06-08 12:07:34 -07:00
parent 1a1849c99b
commit 73312976ad
5 changed files with 5 additions and 28 deletions

View File

@ -389,14 +389,6 @@ bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
if (!orderFile.empty())
parseOrderFile(orderFile);
// dyld requires us to load libSystem. Since we may run tests on non-OSX
// systems which do not have libSystem, we mock it out here.
// TODO: Replace this with a stub tbd file once we have TAPI support.
if (StringRef(getenv("LLD_IN_TEST")) == "1" &&
config->outputType == MH_EXECUTE) {
inputFiles.push_back(DylibFile::createLibSystemMock());
}
if (config->outputType == MH_EXECUTE && !isa<Defined>(config->entry)) {
error("undefined symbol: " + config->entry->getName());
return false;

View File

@ -398,16 +398,6 @@ DylibFile::DylibFile(std::shared_ptr<llvm::MachO::InterfaceFile> interface,
reexported.push_back(make<DylibFile>(document, umbrella));
}
DylibFile::DylibFile() : InputFile(DylibKind, MemoryBufferRef()) {}
DylibFile *DylibFile::createLibSystemMock() {
auto *file = make<DylibFile>();
file->mb = MemoryBufferRef("", "/usr/lib/libSystem.B.dylib");
file->dylibName = "/usr/lib/libSystem.B.dylib";
file->symbols.push_back(symtab->addDylib("dyld_stub_binder", file));
return file;
}
ArchiveFile::ArchiveFile(std::unique_ptr<llvm::object::Archive> &&f)
: InputFile(ArchiveKind, f->getMemoryBufferRef()), file(std::move(f)) {
for (const object::Archive::Symbol &sym : file->symbols())

View File

@ -89,11 +89,6 @@ public:
static bool classof(const InputFile *f) { return f->kind() == DylibKind; }
// Do not use this constructor!! This is meant only for createLibSystemMock(),
// but it cannot be made private as we call it via make().
DylibFile();
static DylibFile *createLibSystemMock();
StringRef dylibName;
uint64_t ordinal = 0; // Ordinal numbering starts from 1, so 0 is a sentinel
bool reexport = false;

View File

@ -10,7 +10,7 @@
# RUN: llvm-ar --format=darwin crs %t/libgoodbye.a %t/goodbye.o
#
# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test -Z -L%t -lhello -lgoodbye %t/test.o
# RUN: lld -flavor darwinnew -arch x86_64 -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z -L%t -lhello -lgoodbye -lSystem %t/test.o
#
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck %s

View File

@ -5,7 +5,7 @@
# RUN: echo ".global f; .section __TEXT,test_f2; f: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/f2.o
# RUN: echo ".global f, g; .section __TEXT,test_fg; f: ret; g: callq f" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/fg.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
# RUN: lld -flavor darwinnew -arch x86_64 -dylib -o %t/libf1.dylib %t/f1.o
# RUN: lld -flavor darwinnew -arch x86_64 -L%S/Inputs/MacOSX.sdk/usr/lib -dylib -o %t/libf1.dylib %t/f1.o -lSystem
# RUN: rm -f %t/libf2_g.a
# RUN: llvm-ar rcs %t/libf2_g.a %t/f2.o %t/g.o
@ -13,7 +13,7 @@
# RUN: rm -f %t/libfg.a
# RUN: llvm-ar rcs %t/libfg.a %t/fg.o
# RUN: lld -flavor darwinnew -arch x86_64 %t/libf1.dylib %t/libf2_g.a %t/test.o -o %t/test.out
# RUN: lld -flavor darwinnew -arch x86_64 -L%S/Inputs/MacOSX.sdk/usr/lib %t/libf1.dylib %t/libf2_g.a %t/test.o -o %t/test.out -lSystem
# RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix DYLIB-FIRST
# DYLIB-FIRST: SYMBOL TABLE:
# DYLIB-FIRST-DAG: __TEXT,test_g g
@ -21,7 +21,7 @@
# DYLIB-FIRST-NEXT: segment section address dylib symbol
# DYLIB-FIRST-NEXT: __DATA __la_symbol_ptr {{[0-9a-z]+}} libf1 f
# RUN: lld -flavor darwinnew -arch x86_64 %t/libf2_g.a %t/libf1.dylib %t/test.o -o %t/test.out
# RUN: lld -flavor darwinnew -arch x86_64 -L%S/Inputs/MacOSX.sdk/usr/lib %t/libf2_g.a %t/libf1.dylib %t/test.o -o %t/test.out -lSystem
# RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST
# ARCHIVE-FIRST: SYMBOL TABLE:
# ARCHIVE-FIRST-DAG: __TEXT,test_f2 f
@ -30,7 +30,7 @@
# ARCHIVE-FIRST-NEXT: segment section address dylib symbol
# ARCHIVE-FIRST-EMPTY:
# RUN: lld -flavor darwinnew -arch x86_64 %t/libf1.dylib %t/libfg.a %t/test.o -o %t/test.out
# RUN: lld -flavor darwinnew -arch x86_64 -L%S/Inputs/MacOSX.sdk/usr/lib %t/libf1.dylib %t/libfg.a %t/test.o -o %t/test.out -lSystem
# RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-PRIORITY
# ARCHIVE-PRIORITY: SYMBOL TABLE:
# ARCHIVE-PRIORITY-DAG: __TEXT,test_fg f