1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

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.

llvm-svn: 269243
This commit is contained in:
Chris Bieneman 2016-05-11 22:07:45 +00:00
parent 05127ecda9
commit 80178ca710
6 changed files with 48 additions and 2 deletions

View File

@ -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
)

View File

@ -34,6 +34,8 @@ std::string _obj2yaml_error_category::message(int ev) const {
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.");

View File

@ -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) {

View File

@ -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;
}

View File

@ -24,6 +24,8 @@ static std::error_code dumpObject(const ObjectFile &Obj) {
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;
}

View File

@ -21,5 +21,7 @@ std::error_code coff2yaml(llvm::raw_ostream &Out,
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