aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/include/llvm/Object/Binary.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/include/llvm/Object/Binary.h')
-rw-r--r--contrib/llvm/include/llvm/Object/Binary.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/contrib/llvm/include/llvm/Object/Binary.h b/contrib/llvm/include/llvm/Object/Binary.h
index d555de3accc2..78fcf6feb851 100644
--- a/contrib/llvm/include/llvm/Object/Binary.h
+++ b/contrib/llvm/include/llvm/Object/Binary.h
@@ -41,21 +41,34 @@ protected:
// Object and children.
ID_StartObjects,
ID_COFF,
+
ID_ELF32L, // ELF 32-bit, little endian
ID_ELF32B, // ELF 32-bit, big endian
ID_ELF64L, // ELF 64-bit, little endian
ID_ELF64B, // ELF 64-bit, big endian
- ID_MachO,
+
+ ID_MachO32L, // MachO 32-bit, little endian
+ ID_MachO32B, // MachO 32-bit, big endian
+ ID_MachO64L, // MachO 64-bit, little endian
+ ID_MachO64B, // MachO 64-bit, big endian
+
ID_EndObjects
};
- static inline unsigned int getELFType(bool isLittleEndian, bool is64Bits) {
- if (isLittleEndian)
+ static inline unsigned int getELFType(bool isLE, bool is64Bits) {
+ if (isLE)
return is64Bits ? ID_ELF64L : ID_ELF32L;
else
return is64Bits ? ID_ELF64B : ID_ELF32B;
}
+ static unsigned int getMachOType(bool isLE, bool is64Bits) {
+ if (isLE)
+ return is64Bits ? ID_MachO64L : ID_MachO32L;
+ else
+ return is64Bits ? ID_MachO64B : ID_MachO32B;
+ }
+
public:
virtual ~Binary();
@@ -79,12 +92,17 @@ public:
}
bool isMachO() const {
- return TypeID == ID_MachO;
+ return TypeID >= ID_MachO32L && TypeID <= ID_MachO64B;
}
bool isCOFF() const {
return TypeID == ID_COFF;
}
+
+ bool isLittleEndian() const {
+ return !(TypeID == ID_ELF32B || TypeID == ID_ELF64B ||
+ TypeID == ID_MachO32B || TypeID == ID_MachO64B);
+ }
};
/// @brief Create a Binary from Source, autodetecting the file type.