1 //===- MachOObject.h - Mach-O Object File Wrapper ---------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_OBJECT_MACHOOBJECT_H
11 #define LLVM_OBJECT_MACHOOBJECT_H
14 #include "llvm/ADT/OwningPtr.h"
22 /// \brief Wrapper object for manipulating Mach-O object files.
24 /// This class is designed to implement a full-featured, efficient, portable,
25 /// and robust Mach-O interface to Mach-O object files. It does not attempt to
26 /// smooth over rough edges in the Mach-O format or generalize access to object
27 /// independent features.
29 /// The class is designed around accessing the Mach-O object which is expected
30 /// to be fully loaded into memory.
32 /// This class is *not* suitable for concurrent use. For efficient operation,
33 /// the class uses APIs which rely on the ability to cache the results of
34 /// certain calls in internal objects which are not safe for concurrent
35 /// access. This allows the API to be zero-copy on the common paths.
37 // FIXME: It would be cool if we supported a "paged" MemoryBuffer
38 // implementation. This would allow us to implement a more sensible version of
39 // MemoryObject which can work like a MemoryBuffer, but be more efficient for
40 // objects which are in the current address space.
45 OwningPtr<MemoryBuffer> Buffer;
48 MachOObject(MemoryBuffer *Buffer);
50 /// \brief Load a Mach-O object from a MemoryBuffer object.
52 /// \param Buffer - The buffer to load the object from. This routine takes
53 /// exclusive ownership of the buffer (which is passed to the returned object
55 /// \param ErrorStr [out] - If given, will be set to a user readable error
56 /// message on failure.
57 /// \returns The loaded object, or null on error.
58 static MachOObject *LoadFromBuffer(MemoryBuffer *Buffer,
59 std::string *ErrorStr = 0);
61 /// @name Object Header Information
66 } // end namespace object
67 } // end namespace llvm