diff options
author | Nick Kledzik <kledzik@apple.com> | 2014-08-21 01:59:11 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2014-08-21 01:59:11 +0000 |
commit | 8c0bf75ef5cc4cb2585fdc42ac5ed987fc6ba0ef (patch) | |
tree | 825d26515eb6a35f468a0cfc37a86044f71824e9 /lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp | |
parent | 334e4ffc0d4e52498b2fd304981f1cbc3ca32554 (diff) | |
download | bcm5719-llvm-8c0bf75ef5cc4cb2585fdc42ac5ed987fc6ba0ef.tar.gz bcm5719-llvm-8c0bf75ef5cc4cb2585fdc42ac5ed987fc6ba0ef.zip |
[mach-o] Add support for -exported_symbols_list and -keep_private_externs
Both options control the final scope of atoms.
When -exported_symbols_list <file> is used, the file is parsed into one
symbol per line in the file. Only those symbols will be exported (global)
in the final linked image.
The -keep_private_externs option is only used with -r mode. Normally, -r
mode reduces private extern (scopeLinkageUnit) symbols to non-external. But
add the -keep_private_externs option keeps them private external.
llvm-svn: 216146
Diffstat (limited to 'lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp')
-rw-r--r-- | lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp index 66686fc87e8..8697b00d370 100644 --- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp +++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp @@ -130,7 +130,8 @@ MachOLinkingContext::MachOLinkingContext() _doNothing(false), _arch(arch_unknown), _os(OS::macOSX), _osMinVersion(0), _pageZeroSize(0), _pageSize(4096), _compatibilityVersion(0), _currentVersion(0), _deadStrippableDylib(false), _printAtoms(false), - _testingFileUsage(false), _archHandler(nullptr) {} + _testingFileUsage(false), _keepPrivateExterns(false), + _archHandler(nullptr), _exportMode(ExportMode::globals) {} MachOLinkingContext::~MachOLinkingContext() {} @@ -448,6 +449,12 @@ bool MachOLinkingContext::validateImpl(raw_ostream &diagnostics) { return false; } + // If -exported_symbols_list used, all exported symbols must be defined. + if (_exportMode == ExportMode::whiteList) { + for (const auto &symbol : _exportedSymbols) + addInitialUndefinedSymbol(symbol.getKey()); + } + return true; } @@ -572,4 +579,23 @@ bool MachOLinkingContext::sectionAligned(StringRef seg, StringRef sect, return false; } + +void MachOLinkingContext::addExportSymbol(StringRef sym) { + // FIXME: Support wildcards. + _exportedSymbols.insert(sym); +} + +bool MachOLinkingContext::exportSymbolNamed(StringRef sym) const { + switch (_exportMode) { + case ExportMode::globals: + llvm_unreachable("exportSymbolNamed() should not be called in this mode"); + break; + case ExportMode::whiteList: + return _exportedSymbols.count(sym); + case ExportMode::blackList: + return !_exportedSymbols.count(sym); + } +} + + } // end namespace lld |