mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-05 07:32:36 +00:00
Add -print_atoms options to DarwinLdDriver which dumps final state of all atoms in yaml
llvm-svn: 208813
This commit is contained in:
parent
e858a65323
commit
0224e3475d
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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">;
|
||||
|
@ -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() {}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user