summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2014-11-06 03:03:42 +0000
committerNick Kledzik <kledzik@apple.com>2014-11-06 03:03:42 +0000
commit8f75da0db335acc67d9982b50c509f508dd28706 (patch)
treebe7be77e851f9df2a7a3dc25b120ef193fea4aef
parentbf77ed68265cbf04981ffd1c1b7c6ee1a22945ba (diff)
downloadbcm5719-llvm-8f75da0db335acc67d9982b50c509f508dd28706.tar.gz
bcm5719-llvm-8f75da0db335acc67d9982b50c509f508dd28706.zip
[mach-o] Add support for -S option
The darwin linker does not process dwarf debug info. Instead it produces a "debug map" in the output file which points back to the original .o files for anything that wants debug info (e.g. debugger). The -S option means "don't add a debug map". lld for mach-o currently does not generate the debug map, so there is nothing to do when this option is used. But we need to process the option to get existing projects building. llvm-svn: 221432
-rw-r--r--lld/include/lld/ReaderWriter/MachOLinkingContext.h11
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp5
-rw-r--r--lld/lib/Driver/DarwinLdOptions.td2
-rw-r--r--lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp3
4 files changed, 20 insertions, 1 deletions
diff --git a/lld/include/lld/ReaderWriter/MachOLinkingContext.h b/lld/include/lld/ReaderWriter/MachOLinkingContext.h
index 4132c744acb..0792bd2e51b 100644
--- a/lld/include/lld/ReaderWriter/MachOLinkingContext.h
+++ b/lld/include/lld/ReaderWriter/MachOLinkingContext.h
@@ -57,6 +57,11 @@ public:
blackList // -unexported_symbol[s_list], no listed symbol exported.
};
+ enum class DebugInfoMode {
+ addDebugMap, // Default
+ noDebugMap // -S option
+ };
+
/// Initializes the context to sane default values given the specified output
/// file type, arch, os, and minimum os version. This should be called before
/// other setXXX() methods.
@@ -93,6 +98,11 @@ public:
bool exportRestrictMode() const { return _exportMode != ExportMode::globals; }
bool exportSymbolNamed(StringRef sym) const;
+ DebugInfoMode debugInfoMode() const { return _debugInfoMode; }
+ void setDebugInfoMode(DebugInfoMode mode) {
+ _debugInfoMode = mode;
+ }
+
bool keepPrivateExterns() const { return _keepPrivateExterns; }
void setKeepPrivateExterns(bool v) { _keepPrivateExterns = v; }
bool demangleSymbols() const { return _demangle; }
@@ -322,6 +332,7 @@ private:
mutable std::vector<std::unique_ptr<class MachOFileNode>> _indirectDylibs;
ExportMode _exportMode;
llvm::StringSet<> _exportedSymbols;
+ DebugInfoMode _debugInfoMode;
std::unique_ptr<llvm::raw_fd_ostream> _dependencyInfo;
};
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 452d6cc5289..645a3efb650 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -640,6 +640,11 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
}
}
+ // Handle debug info handling options: -S
+ if (parsedArgs->hasArg(OPT_S)) {
+ ctx.setDebugInfoMode(MachOLinkingContext::DebugInfoMode::noDebugMap);
+ }
+
// Handle input files
for (auto &arg : *parsedArgs) {
bool upward;
diff --git a/lld/lib/Driver/DarwinLdOptions.td b/lld/lib/Driver/DarwinLdOptions.td
index fff976cf06f..d819c03aac0 100644
--- a/lld/lib/Driver/DarwinLdOptions.td
+++ b/lld/lib/Driver/DarwinLdOptions.td
@@ -160,6 +160,8 @@ def demangle : Flag<["-"], "demangle">,
def dependency_info : Separate<["-"], "dependency_info">,
MetaVarName<"<file>">,
HelpText<"Write binary list of files used during link">;
+def S : Flag<["-"], "S">,
+ HelpText<"Remove debug information (STABS or DWARF) from the output file">;
def t : Flag<["-"], "t">,
HelpText<"Print the names of the input files as ld processes them">;
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index b99ecc8548e..85c20b3a932 100644
--- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -145,7 +145,8 @@ MachOLinkingContext::MachOLinkingContext()
_compatibilityVersion(0), _currentVersion(0), _deadStrippableDylib(false),
_printAtoms(false), _testingFileUsage(false), _keepPrivateExterns(false),
_demangle(false), _archHandler(nullptr),
- _exportMode(ExportMode::globals) {}
+ _exportMode(ExportMode::globals),
+ _debugInfoMode(DebugInfoMode::addDebugMap) {}
MachOLinkingContext::~MachOLinkingContext() {}
OpenPOWER on IntegriCloud