[PATCH] Path: Recognize Windows compiled resource file.
Rui Ueyama
ruiu at google.com
Tue Oct 15 14:07:54 PDT 2013
- Fix -Wswitch warnings
Hi Bigcheese,
http://llvm-reviews.chandlerc.com/D1943
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1943?vs=4933&id=4934#toc
Files:
include/llvm/Support/FileSystem.h
lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
lib/Object/Binary.cpp
lib/Object/ObjectFile.cpp
lib/Support/Path.cpp
Index: include/llvm/Support/FileSystem.h
===================================================================
--- include/llvm/Support/FileSystem.h
+++ include/llvm/Support/FileSystem.h
@@ -238,7 +238,8 @@
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
+ resource, ///< Windows compiled resource file (.rc)
};
bool is_object() const {
Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
===================================================================
--- lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -551,6 +551,7 @@
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::resource:
report_fatal_error("Incompatible object format!");
}
} else {
Index: lib/Object/Binary.cpp
===================================================================
--- lib/Object/Binary.cpp
+++ lib/Object/Binary.cpp
@@ -100,7 +100,8 @@
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::resource: {
// Unrecognized object file format.
return object_error::invalid_file_type;
}
Index: lib/Object/ObjectFile.cpp
===================================================================
--- lib/Object/ObjectFile.cpp
+++ lib/Object/ObjectFile.cpp
@@ -49,6 +49,7 @@
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::resource:
delete Object;
return 0;
case sys::fs::file_magic::elf_relocatable:
Index: lib/Support/Path.cpp
===================================================================
--- lib/Support/Path.cpp
+++ lib/Support/Path.cpp
@@ -847,6 +847,14 @@
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::resource;
+ break;
+ }
case 0xDE: // 0x0B17C0DE = BC wraper
if (Magic[1] == (char)0xC0 && Magic[2] == (char)0x17 &&
Magic[3] == (char)0x0B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1943.2.patch
Type: text/x-patch
Size: 2707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131015/0b7e6652/attachment.bin>
More information about the llvm-commits
mailing list