#ifndef LLVM_OBJECT_BINARY_H
#define LLVM_OBJECT_BINARY_H
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Object/Error.h"
namespace llvm {
class MemoryBuffer;
class StringRef;
namespace object {
class Binary {
private:
Binary() LLVM_DELETED_FUNCTION;
Binary(const Binary &other) LLVM_DELETED_FUNCTION;
unsigned int TypeID;
protected:
MemoryBuffer *Data;
Binary(unsigned int Type, MemoryBuffer *Source);
enum {
ID_Archive,
ID_StartObjects,
ID_COFF,
ID_ELF32L, ID_ELF32B, ID_ELF64L, ID_ELF64B, ID_MachO,
ID_EndObjects
};
static inline unsigned int getELFType(bool isLittleEndian, bool is64Bits) {
if (isLittleEndian)
return is64Bits ? ID_ELF64L : ID_ELF32L;
else
return is64Bits ? ID_ELF64B : ID_ELF32B;
}
public:
virtual ~Binary();
StringRef getData() const;
StringRef getFileName() const;
unsigned int getType() const { return TypeID; }
static inline bool classof(const Binary *v) { return true; }
bool isObject() const {
return TypeID > ID_StartObjects && TypeID < ID_EndObjects;
}
bool isArchive() const {
return TypeID == ID_Archive;
}
bool isELF() const {
return TypeID >= ID_ELF32L && TypeID <= ID_ELF64B;
}
bool isMachO() const {
return TypeID == ID_MachO;
}
bool isCOFF() const {
return TypeID == ID_COFF;
}
};
error_code createBinary(MemoryBuffer *Source, OwningPtr<Binary> &Result);
error_code createBinary(StringRef Path, OwningPtr<Binary> &Result);
}
}
#endif