18 #if !defined(_MSC_VER) && !defined(__MINGW32__)
25 using namespace llvm::support::endian;
26 using namespace llvm::sys::fs;
37 switch ((
unsigned char)Magic[0]) {
43 if (Magic.
size() < MinSize)
79 bool Data2MSB = Magic[5] == 2;
80 unsigned high = Data2MSB ? 16 : 17;
81 unsigned low = Data2MSB ? 17 : 16;
82 if (Magic[high] == 0) {
106 if (Magic.
size() >= 8 && Magic[7] < 43)
122 if (Magic[3] ==
char(0xCE))
126 if (Magic.
size() >= MinSize)
127 type = Magic[12] << 24 | Magic[13] << 12 | Magic[14] << 8 | Magic[15];
128 }
else if (
startswith(Magic,
"\xCE\xFA\xED\xFE") ||
132 if (Magic[0] ==
char(0xCE))
136 if (Magic.
size() >= MinSize)
137 type = Magic[15] << 24 | Magic[14] << 12 | Magic[13] << 8 | Magic[12];
174 if (Magic[1] == 0x01)
180 if (Magic[1] == 0x02)
188 if (off < Magic.
size() &&
195 if (Magic[1] ==
char(0x86) || Magic[1] == char(0xaa))
211 int Length =
read(FD, Buffer,
sizeof(Buffer));
212 if (close(FD) != 0 || Length < 0)
213 return std::error_code(errno, std::generic_category());
216 return std::error_code();
Microsoft cl.exe's intermediate code file.
ELF dynamically linked shared lib.
std::error_code openFileForRead(const Twine &Name, int &ResultFD, SmallVectorImpl< char > *RealPath=nullptr)
Windows compiled resource file (.res)
Mach-O Preloaded Executable.
static const char BigObjMagic[]
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
The Mach-O dynamic linker.
ELF Relocatable object file.
static bool startswith(StringRef Magic, const char(&S)[N])
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static const char ClGlObjMagic[]
Mach-O dSYM companion file.
static const char *const Magic
Mach-O dynlinked shared lib.
value_type read(const void *memory, endianness endian)
Read a value of a particular endianness from memory.
uint32_t read32le(const void *P)
static const char PEMagic[]
static const char WinResMagic[]
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
StringRef - Represent a constant reference to a string, i.e.
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...