19 #if !defined(_MSC_VER) && !defined(__MINGW32__) 38 switch ((
unsigned char)Magic[0]) {
44 if (Magic.
size() < MinSize)
80 bool Data2MSB = Magic[5] == 2;
81 unsigned high = Data2MSB ? 16 : 17;
82 unsigned low = Data2MSB ? 17 : 16;
83 if (Magic[high] == 0) {
107 if (Magic.
size() >= 8 && Magic[7] < 43)
123 if (Magic[3] ==
char(0xCE))
127 if (Magic.
size() >= MinSize)
128 type = Magic[12] << 24 | Magic[13] << 12 | Magic[14] << 8 | Magic[15];
129 }
else if (
startswith(Magic,
"\xCE\xFA\xED\xFE") ||
133 if (Magic[0] ==
char(0xCE))
137 if (Magic.
size() >= MinSize)
138 type = Magic[15] << 24 | Magic[14] << 12 | Magic[13] << 8 | Magic[12];
175 if (Magic[1] == 0x01)
181 if (Magic[1] == 0x02)
193 if (Magic.
startswith(
"Microsoft C/C++ MSF 7.00\r\n"))
198 if (Magic[1] ==
char(0x86) || Magic[1] == char(0xaa))
211 return FileOrError.getError();
213 std::unique_ptr<MemoryBuffer> FileBuffer = std::move(*FileOrError);
216 return std::error_code();
This class represents lattice values for constants.
Microsoft cl.exe's intermediate code file.
ELF dynamically linked shared lib.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Windows compiled resource file (.res)
Mach-O Preloaded Executable.
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).
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 StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static const char ClGlObjMagic[]
Mach-O dSYM companion file.
#define offsetof(TYPE, MEMBER)
static const char *const Magic
Mach-O dynlinked shared lib.
Merge contiguous icmps into a memcmp
uint32_t read32le(const void *P)
static const char PEMagic[]
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
static const char WinResMagic[]
StringRef - Represent a constant reference to a string, i.e.
Windows PDB debug info file.
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...