[PATCH] Recognize 0x0000 as a COFF file magic.
Rafael EspĂndola
rafael.espindola at gmail.com
Thu Nov 14 06:13:26 PST 2013
For the same reason as the other one, please use a real object file for testing.
On 14 November 2013 00:36, Rui Ueyama <ruiu at google.com> wrote:
> - 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),
More information about the llvm-commits
mailing list