summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2015-09-28 20:25:14 +0000
committerLang Hames <lhames@gmail.com>2015-09-28 20:25:14 +0000
commit5c692009bc346c732c1ff58a7242812ef7373b1f (patch)
treee8449408d670239d52ce5ff4ce401fae7997a21e /lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
parent085a8f5ea750721d541bec9d632e33f9fbc80996 (diff)
downloadbcm5719-llvm-5c692009bc346c732c1ff58a7242812ef7373b1f.tar.gz
bcm5719-llvm-5c692009bc346c732c1ff58a7242812ef7373b1f.zip
[lld][MachO] Initial implementation of -flat_namespace and -undefined.
This is a basic initial implementation of the -flat_namespace and -undefined options for LLD-darwin. It ignores several subtlties, but the result is close enough that we can now link LLVM (but not clang) on Darwin and pass all regression tests. llvm-svn: 248732
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp')
-rw-r--r--lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index c29bcdd7387..3b9406d745c 100644
--- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -10,6 +10,7 @@
#include "lld/ReaderWriter/MachOLinkingContext.h"
#include "ArchHandler.h"
#include "File.h"
+#include "FlatNamespaceFile.h"
#include "MachONormalizedFile.h"
#include "MachOPasses.h"
#include "lld/Core/ArchiveLibraryFile.h"
@@ -143,10 +144,12 @@ MachOLinkingContext::MachOLinkingContext()
_doNothing(false), _pie(false), _arch(arch_unknown), _os(OS::macOSX),
_osMinVersion(0), _pageZeroSize(0), _pageSize(4096), _baseAddress(0),
_stackSize(0), _compatibilityVersion(0), _currentVersion(0),
+ _flatNamespace(false), _undefinedMode(UndefinedMode::error),
_deadStrippableDylib(false), _printAtoms(false), _testingFileUsage(false),
_keepPrivateExterns(false), _demangle(false), _archHandler(nullptr),
_exportMode(ExportMode::globals),
- _debugInfoMode(DebugInfoMode::addDebugMap), _orderFileEntries(0) {}
+ _debugInfoMode(DebugInfoMode::addDebugMap), _orderFileEntries(0),
+ _flatNamespaceFile(nullptr) {}
MachOLinkingContext::~MachOLinkingContext() {}
@@ -716,6 +719,15 @@ void MachOLinkingContext::createImplicitFiles(
// Let writer add output type specific extras.
writer().createImplicitFiles(result);
+
+ // If we're using flat namespace or undefinedMode is != error, add a
+ // FlatNamespaceFile instance. This will provide a SharedLibraryAtom for
+ // symbols that aren't defined elsewhere.
+ if (useFlatNamespace() && undefinedMode() != UndefinedMode::error) {
+ bool warnOnUndef = undefinedMode() == UndefinedMode::warning;
+ result.emplace_back(new mach_o::FlatNamespaceFile(*this, warnOnUndef));
+ _flatNamespaceFile = result.back().get();
+ }
}
OpenPOWER on IntegriCloud