[PATCH] Recognize 0x0000 as a COFF file magic.
Rui Ueyama
ruiu at google.com
Wed Nov 13 21:36:50 PST 2013
- updated as per Rafael's comments.
Hi Bigcheese,
http://llvm-reviews.chandlerc.com/D2164
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2164?vs=5519&id=5535#toc
Files:
lib/Support/Path.cpp
unittests/Support/Path.cpp
Index: lib/Support/Path.cpp
===================================================================
--- lib/Support/Path.cpp
+++ lib/Support/Path.cpp
@@ -853,6 +853,9 @@
if (Magic.size() >= sizeof(Expected) &&
memcmp(Magic.data(), Expected, sizeof(Expected)) == 0)
return file_magic::windows_resource;
+ // 0x0000 = COFF unknown machine type
+ if (Magic[1] == 0)
+ return file_magic::coff_object;
break;
}
case 0xDE: // 0x0B17C0DE = BC wraper
Index: unittests/Support/Path.cpp
===================================================================
--- unittests/Support/Path.cpp
+++ unittests/Support/Path.cpp
@@ -418,6 +418,7 @@
const char archive[] = "!<arch>\x0A";
const char bitcode[] = "\xde\xc0\x17\x0b";
+const char coff_object[] = "\x00\x00";
const char elf_relocatable[] = { 0x7f, 'E', 'L', 'F', 1, 2, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1 };
const char macho_universal_binary[] = "\xca\xfe\xba\xbe...\0x00";
@@ -445,6 +446,7 @@
{ #magic, magic, sizeof(magic), fs::file_magic::magic }
DEFINE(archive),
DEFINE(bitcode),
+ DEFINE(coff_object),
DEFINE(elf_relocatable),
DEFINE(macho_universal_binary),
DEFINE(macho_object),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2164.3.patch
Type: text/x-patch
Size: 1264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131113/81735f47/attachment.bin>
More information about the llvm-commits
mailing list