[llvm] r269243 - Initial add for MachO support for obj2yaml
Chris Bieneman via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 15:07:46 PDT 2016
Author: cbieneman
Date: Wed May 11 17:07:45 2016
New Revision: 269243
URL: http://llvm.org/viewvc/llvm-project?rev=269243&view=rev
Log:
Initial add for MachO support for obj2yaml
Adding the initial files for adding MachO support to obj2yaml. Passing a MachO file will result in a new not_implemented error.
I will be implementing obj2yaml and yaml2obj for MachO in parallel so that one can be used to test the other.
Added:
llvm/trunk/tools/obj2yaml/macho2yaml.cpp
Modified:
llvm/trunk/tools/obj2yaml/CMakeLists.txt
llvm/trunk/tools/obj2yaml/Error.cpp
llvm/trunk/tools/obj2yaml/Error.h
llvm/trunk/tools/obj2yaml/obj2yaml.cpp
llvm/trunk/tools/obj2yaml/obj2yaml.h
Modified: llvm/trunk/tools/obj2yaml/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/CMakeLists.txt?rev=269243&r1=269242&r2=269243&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/CMakeLists.txt (original)
+++ llvm/trunk/tools/obj2yaml/CMakeLists.txt Wed May 11 17:07:45 2016
@@ -5,5 +5,9 @@ set(LLVM_LINK_COMPONENTS
)
add_llvm_tool(obj2yaml
- obj2yaml.cpp coff2yaml.cpp elf2yaml.cpp Error.cpp
+ obj2yaml.cpp
+ coff2yaml.cpp
+ elf2yaml.cpp
+ macho2yaml.cpp
+ Error.cpp
)
Modified: llvm/trunk/tools/obj2yaml/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/Error.cpp?rev=269243&r1=269242&r2=269243&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/Error.cpp (original)
+++ llvm/trunk/tools/obj2yaml/Error.cpp Wed May 11 17:07:45 2016
@@ -34,6 +34,8 @@ std::string _obj2yaml_error_category::me
return "Unrecognized file type.";
case obj2yaml_error::unsupported_obj_file_format:
return "Unsupported object file format.";
+ case obj2yaml_error::not_implemented:
+ return "Feature not yet implemented.";
}
llvm_unreachable("An enumerator of obj2yaml_error does not have a message "
"defined.");
Modified: llvm/trunk/tools/obj2yaml/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/Error.h?rev=269243&r1=269242&r2=269243&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/Error.h (original)
+++ llvm/trunk/tools/obj2yaml/Error.h Wed May 11 17:07:45 2016
@@ -19,7 +19,8 @@ enum class obj2yaml_error {
success = 0,
file_not_found,
unrecognized_file_format,
- unsupported_obj_file_format
+ unsupported_obj_file_format,
+ not_implemented
};
inline std::error_code make_error_code(obj2yaml_error e) {
Added: llvm/trunk/tools/obj2yaml/macho2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/macho2yaml.cpp?rev=269243&view=auto
==============================================================================
--- llvm/trunk/tools/obj2yaml/macho2yaml.cpp (added)
+++ llvm/trunk/tools/obj2yaml/macho2yaml.cpp Wed May 11 17:07:45 2016
@@ -0,0 +1,35 @@
+//===------ macho2yaml.cpp - obj2yaml conversion tool -----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Error.h"
+#include "obj2yaml.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Object/MachOUniversal.h"
+
+using namespace llvm;
+
+std::error_code macho2yaml(raw_ostream &Out,
+ const object::MachOObjectFile &Obj) {
+ return obj2yaml_error::not_implemented;
+}
+
+std::error_code macho2yaml(raw_ostream &Out,
+ const object::MachOUniversalBinary &Obj) {
+ return obj2yaml_error::not_implemented;
+}
+
+std::error_code macho2yaml(raw_ostream &Out, const object::ObjectFile &Obj) {
+ if (const auto *MachOObj = dyn_cast<object::MachOUniversalBinary>(&Obj))
+ return macho2yaml(Out, *MachOObj);
+
+ if (const auto *MachOObj = dyn_cast<object::MachOObjectFile>(&Obj))
+ return macho2yaml(Out, *MachOObj);
+
+ return obj2yaml_error::unsupported_obj_file_format;
+}
Modified: llvm/trunk/tools/obj2yaml/obj2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/obj2yaml.cpp?rev=269243&r1=269242&r2=269243&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/obj2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/obj2yaml.cpp Wed May 11 17:07:45 2016
@@ -24,6 +24,8 @@ static std::error_code dumpObject(const
return coff2yaml(outs(), cast<COFFObjectFile>(Obj));
if (Obj.isELF())
return elf2yaml(outs(), Obj);
+ if (Obj.isMachO() || Obj.isMachOUniversalBinary())
+ return macho2yaml(outs(), Obj);
return obj2yaml_error::unsupported_obj_file_format;
}
Modified: llvm/trunk/tools/obj2yaml/obj2yaml.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/obj2yaml.h?rev=269243&r1=269242&r2=269243&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/obj2yaml.h (original)
+++ llvm/trunk/tools/obj2yaml/obj2yaml.h Wed May 11 17:07:45 2016
@@ -21,5 +21,7 @@ std::error_code coff2yaml(llvm::raw_ostr
const llvm::object::COFFObjectFile &Obj);
std::error_code elf2yaml(llvm::raw_ostream &Out,
const llvm::object::ObjectFile &Obj);
+std::error_code macho2yaml(llvm::raw_ostream &Out,
+ const llvm::object::ObjectFile &Obj);
#endif
More information about the llvm-commits
mailing list