summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/include/lld/ReaderWriter/MachOLinkingContext.h3
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp4
-rw-r--r--lld/lib/Driver/DarwinLdOptions.td3
-rw-r--r--lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp3
-rw-r--r--lld/lib/ReaderWriter/MachO/WriterMachO.cpp7
5 files changed, 17 insertions, 3 deletions
diff --git a/lld/include/lld/ReaderWriter/MachOLinkingContext.h b/lld/include/lld/ReaderWriter/MachOLinkingContext.h
index 0f897f4000d..8bac0ba0f66 100644
--- a/lld/include/lld/ReaderWriter/MachOLinkingContext.h
+++ b/lld/include/lld/ReaderWriter/MachOLinkingContext.h
@@ -77,6 +77,7 @@ public:
bool minOS(StringRef mac, StringRef iOS) const;
void setDoNothing(bool value) { _doNothing = value; }
bool doNothing() const { return _doNothing; }
+ bool printAtoms() const { return _printAtoms; }
/// \brief The dylib's binary compatibility version, in the raw uint32 format.
///
@@ -123,6 +124,7 @@ public:
_deadStrippableDylib = deadStrippable;
}
void setBundleLoader(StringRef loader) { _bundleLoader = loader; }
+ void setPrintAtoms(bool value=true) { _printAtoms = value; }
StringRef dyldPath() const { return "/usr/lib/dyld"; }
static Arch archFromCpuType(uint32_t cputype, uint32_t cpusubtype);
@@ -163,6 +165,7 @@ private:
uint32_t _currentVersion;
StringRef _installName;
bool _deadStrippableDylib;
+ bool _printAtoms;
StringRef _bundleLoader;
mutable std::unique_ptr<mach_o::KindHandler> _kindHandler;
mutable std::unique_ptr<Writer> _writer;
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 4dde6bae231..069ff3588fa 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -258,6 +258,10 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
ctx.appendLLVMOption((*it)->getValue());
}
+ // Handle -print_atoms a
+ if (parsedArgs->getLastArg(OPT_print_atoms))
+ ctx.setPrintAtoms();
+
std::unique_ptr<InputGraph> inputGraph(new InputGraph());
// Handle input files
diff --git a/lld/lib/Driver/DarwinLdOptions.td b/lld/lib/Driver/DarwinLdOptions.td
index ff09d6a00b2..61c151a20be 100644
--- a/lld/lib/Driver/DarwinLdOptions.td
+++ b/lld/lib/Driver/DarwinLdOptions.td
@@ -70,6 +70,9 @@ def all_load : Flag<["-"], "all_load">,
HelpText<"Forces all members of all static libraries to be loaded">,
Group<grp_libs>;
+// test case options
+def print_atoms : Flag<["-"], "print_atoms">,
+ HelpText<"Emit output as yaml atoms">;
// general options
def output : Separate<["-"], "o">, HelpText<"Output file path">;
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index 5bd9a5e5df6..8be2d767cfc 100644
--- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -122,7 +122,8 @@ MachOLinkingContext::MachOLinkingContext()
: _outputFileType(MH_EXECUTE), _outputFileTypeStatic(false),
_doNothing(false), _arch(arch_unknown), _os(OS::macOSX), _osMinVersion(0),
_pageZeroSize(0), _pageSize(4096), _compatibilityVersion(0),
- _currentVersion(0), _deadStrippableDylib(false), _kindHandler(nullptr) {}
+ _currentVersion(0), _deadStrippableDylib(false), _printAtoms(false),
+ _kindHandler(nullptr) {}
MachOLinkingContext::~MachOLinkingContext() {}
diff --git a/lld/lib/ReaderWriter/MachO/WriterMachO.cpp b/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
index e8eb3ff31da..504e8cdfad4 100644
--- a/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
+++ b/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
@@ -39,8 +39,11 @@ public:
if (error_code ec = nFile.getError())
return ec;
- // For debugging, write out yaml form of normalized file.
- //writeYaml(*nFile->get(), llvm::errs());
+ // For testing, write out yaml form of normalized file.
+ if (_context.printAtoms()) {
+ std::unique_ptr<Writer> yamlWriter = createWriterYAML(_context);
+ yamlWriter->writeFile(file, "-");
+ }
// Write normalized file as mach-o binary.
return writeBinary(*nFile->get(), path);
OpenPOWER on IntegriCloud