summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/FileSystem.h3
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp1
-rw-r--r--lib/Object/Binary.cpp3
-rw-r--r--lib/Object/ObjectFile.cpp1
-rw-r--r--lib/Support/Path.cpp8
5 files changed, 14 insertions, 2 deletions
diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h
index 9d72a66512..24bb8ea63e 100644
--- a/include/llvm/Support/FileSystem.h
+++ b/include/llvm/Support/FileSystem.h
@@ -238,7 +238,8 @@ struct file_magic {
macho_dsym_companion, ///< Mach-O dSYM companion file
macho_universal_binary, ///< Mach-O universal binary
coff_object, ///< COFF object file
- pecoff_executable ///< PECOFF executable file
+ pecoff_executable, ///< PECOFF executable file
+ windows_resource, ///< Windows compiled resource file (.rc)
};
bool is_object() const {
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index f04f8c29f6..bda32d4154 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -553,6 +553,7 @@ ObjectImage *RuntimeDyld::loadObject(ObjectBuffer *InputBuffer) {
case sys::fs::file_magic::coff_object:
case sys::fs::file_magic::pecoff_executable:
case sys::fs::file_magic::macho_universal_binary:
+ case sys::fs::file_magic::windows_resource:
report_fatal_error("Incompatible object format!");
}
} else {
diff --git a/lib/Object/Binary.cpp b/lib/Object/Binary.cpp
index fd9d3b4bd7..d0a7009144 100644
--- a/lib/Object/Binary.cpp
+++ b/lib/Object/Binary.cpp
@@ -100,7 +100,8 @@ error_code object::createBinary(MemoryBuffer *Source,
return object_error::success;
}
case sys::fs::file_magic::unknown:
- case sys::fs::file_magic::bitcode: {
+ case sys::fs::file_magic::bitcode:
+ case sys::fs::file_magic::windows_resource: {
// Unrecognized object file format.
return object_error::invalid_file_type;
}
diff --git a/lib/Object/ObjectFile.cpp b/lib/Object/ObjectFile.cpp
index 1d1dafdc8f..59395c640f 100644
--- a/lib/Object/ObjectFile.cpp
+++ b/lib/Object/ObjectFile.cpp
@@ -49,6 +49,7 @@ ObjectFile *ObjectFile::createObjectFile(MemoryBuffer *Object) {
case sys::fs::file_magic::bitcode:
case sys::fs::file_magic::archive:
case sys::fs::file_magic::macho_universal_binary:
+ case sys::fs::file_magic::windows_resource:
delete Object;
return 0;
case sys::fs::file_magic::elf_relocatable:
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp
index 8d707aedde..390614b9a5 100644
--- a/lib/Support/Path.cpp
+++ b/lib/Support/Path.cpp
@@ -847,6 +847,14 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
if (Magic.size() < 4)
return file_magic::unknown;
switch ((unsigned char)Magic[0]) {
+ case 0x00: {
+ // Windows resource file
+ const char Expected[] = "\0\0\0\0\x20\0\0\0\xff";
+ if (Magic.size() >= sizeof(Expected) &&
+ memcmp(Magic.data(), Expected, sizeof(Expected)) == 0)
+ return file_magic::windows_resource;
+ break;
+ }
case 0xDE: // 0x0B17C0DE = BC wraper
if (Magic[1] == (char)0xC0 && Magic[2] == (char)0x17 &&
Magic[3] == (char)0x0B)