//===----------------------------------------------------------------------===//
#include "llvm/Object/ObjectFile.h"
+#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/system_error.h"
-namespace llvm {
-namespace object {
+using namespace llvm;
+using namespace object;
ObjectFile::ObjectFile(MemoryBuffer *Object)
: MapFile(Object) {
case sys::Mach_O_Executable_FileType:
case sys::Mach_O_FixedVirtualMemorySharedLib_FileType:
case sys::Mach_O_Core_FileType:
- case sys::Mach_O_PreloadExectuable_FileType:
+ case sys::Mach_O_PreloadExecutable_FileType:
case sys::Mach_O_DynamicallyLinkedSharedLib_FileType:
case sys::Mach_O_DynamicLinker_FileType:
case sys::Mach_O_Bundle_FileType:
}
}
-ObjectFile *ObjectFile::createObjectFile(const sys::Path &ObjectPath) {
- return createObjectFile(MemoryBuffer::getFile(ObjectPath.c_str()));
+ObjectFile *ObjectFile::createObjectFile(StringRef ObjectPath) {
+ OwningPtr<MemoryBuffer> File;
+ if (error_code ec = MemoryBuffer::getFile(ObjectPath, File))
+ return NULL;
+ return createObjectFile(File.take());
}
-
-} // end namespace object
-} // end namespace llvm