summaryrefslogtreecommitdiffstats
path: root/lld/lib/Driver/DarwinLdDriver.cpp
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2014-08-13 23:55:41 +0000
committerNick Kledzik <kledzik@apple.com>2014-08-13 23:55:41 +0000
commit8fc67fba019505eb9ee542acf74c4a9e86bd1de7 (patch)
tree6699599f89df5bbd1c49798104df55f974d51e3c /lld/lib/Driver/DarwinLdDriver.cpp
parent57fb040beb5bf376cbd8cef0c941ac976aa2fa27 (diff)
downloadbcm5719-llvm-8fc67fba019505eb9ee542acf74c4a9e86bd1de7.tar.gz
bcm5719-llvm-8fc67fba019505eb9ee542acf74c4a9e86bd1de7.zip
[mach-o] Support re-exported dylibs
In general two-level namespace means each program records exactly which dylib each undefined (imported) symbol comes from. But, sometimes the implementor wants to hide the implementation dylib. For instance libSytem.dylib is the base dylib all Darwin programs must link with. A few years ago it was split up into two dozen dylibs by all are hidden behind libSystem.dylib which re-exports each sub-dylib. All clients still think libSystem.dylib is the implementor. To support this, the linker must load "indirect" dylibs and not just the "direct" dylibs specified on the command line. This is done in the createImplicitFiles() method after all command line specified files are loaded. Since an indirect dylib may have already been loaded as a direct dylib (or indirectly via a previous direct dylib), the MachOLinkingContext keeps a list of all loaded dylibs. With this change hello world can now be linked against the real OS or SDK. llvm-svn: 215605
Diffstat (limited to 'lld/lib/Driver/DarwinLdDriver.cpp')
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 64d77a971a1..fe255fbc0df 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -321,26 +321,25 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
// skipped.
// 3. If the last -syslibroot is "/", all of them are ignored entirely.
// 4. If { syslibroots } x path == {}, the original path is kept.
- std::vector<StringRef> syslibRoots;
for (auto syslibRoot : parsedArgs->filtered(OPT_syslibroot)) {
- syslibRoots.push_back(syslibRoot->getValue());
+ ctx.addSysLibRoot(syslibRoot->getValue());
}
// Paths specified with -L come first, and are not considered system paths for
// the case where there is precisely 1 -syslibroot.
for (auto libPath : parsedArgs->filtered(OPT_L)) {
- ctx.addModifiedSearchDir(libPath->getValue(), syslibRoots, false);
+ ctx.addModifiedSearchDir(libPath->getValue());
}
// -Z suppresses the standard search paths.
if (!parsedArgs->hasArg(OPT_Z)) {
- ctx.addModifiedSearchDir("/usr/lib", syslibRoots, true);
- ctx.addModifiedSearchDir("/usr/local/lib", syslibRoots, true);
+ ctx.addModifiedSearchDir("/usr/lib", true);
+ ctx.addModifiedSearchDir("/usr/local/lib", true);
}
// Now that we've constructed the final set of search paths, print out what
// we'll be using for testing purposes.
- if (ctx.testingLibResolution()) {
+ if (ctx.testingLibResolution() || parsedArgs->getLastArg(OPT_v)) {
diagnostics << "Library search paths:\n";
for (auto path : ctx.searchDirs()) {
diagnostics << " " << path << '\n';
@@ -373,7 +372,7 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
}
}
inputGraph->addInputElement(std::unique_ptr<InputElement>(
- new MachOFileNode(ctx, inputPath, globalWholeArchive)));
+ new MachOFileNode(inputPath, globalWholeArchive)));
}
if (!inputGraph->size()) {
OpenPOWER on IntegriCloud