llvm.org GIT mirror llvm / b850a05
Recognize 0x0000 as a COFF file magic. Summary: Some machine-type-neutral object files containing only undefined symbols actually do exist in the Windows standard library. Need to recognize them as COFF files. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2164 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194734 91177308-0d34-0410-b5e6-96231b3b80d8 Rui Ueyama 5 years ago
4 changed file(s) with 21 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
852852 if (Magic.size() >= sizeof(Expected) &&
853853 memcmp(Magic.data(), Expected, sizeof(Expected)) == 0)
854854 return file_magic::windows_resource;
855 // 0x0000 = COFF unknown machine type
856 if (Magic[1] == 0)
857 return file_magic::coff_object;
855858 break;
856859 }
857860 case 0xDE: // 0x0B17C0DE = BC wraper
77 RUN: | FileCheck %s -check-prefix ELF32
88 RUN: llvm-readobj -h %p/Inputs/trivial.obj.elf-x86-64 \
99 RUN: | FileCheck %s -check-prefix ELF64
10 RUN: llvm-readobj -h %p/Inputs/magic.coff-unknown \
11 RUN: | FileCheck %s -check-prefix COFF-UNKNOWN
1012
1113 COFF32: File: {{(.*[/\\])?}}trivial.obj.coff-i386
1214 COFF32-NEXT: Format: COFF-i386
182184 PE32-NEXT: ReservedSize: 0x0
183185 PE32-NEXT: }
184186 PE32-NEXT: }
187
188 COFF-UNKNOWN: Format: COFF-
189 COFF-UNKNOWN-NEXT: Arch: unknown
190 COFF-UNKNOWN-NEXT: AddressSize: 32bit
191 COFF-UNKNOWN-NEXT: ImageFileHeader {
192 COFF-UNKNOWN-NEXT: Machine: IMAGE_FILE_MACHINE_UNKNOWN (0x0)
193 COFF-UNKNOWN-NEXT: SectionCount: 3
194 COFF-UNKNOWN-NEXT: TimeDateStamp: 2013-11-14 21:19:28 (0x52853E60)
195 COFF-UNKNOWN-NEXT: PointerToSymbolTable: 0xF8
196 COFF-UNKNOWN-NEXT: SymbolCount: 11
197 COFF-UNKNOWN-NEXT: OptionalHeaderSize: 0
198 COFF-UNKNOWN-NEXT: Characteristics [ (0x0)
199 COFF-UNKNOWN-NEXT: ]
200 COFF-UNKNOWN-NEXT: }
417417
418418 const char archive[] = "!\x0A";
419419 const char bitcode[] = "\xde\xc0\x17\x0b";
420 const char coff_object[] = "\x00\x00......";
420421 const char elf_relocatable[] = { 0x7f, 'E', 'L', 'F', 1, 2, 1, 0, 0,
421422 0, 0, 0, 0, 0, 0, 0, 0, 1 };
422423 const char macho_universal_binary[] = "\xca\xfe\xba\xbe...\0x00";
444445 { #magic, magic, sizeof(magic), fs::file_magic::magic }
445446 DEFINE(archive),
446447 DEFINE(bitcode),
448 DEFINE(coff_object),
447449 DEFINE(elf_relocatable),
448450 DEFINE(macho_universal_binary),
449451 DEFINE(macho_object),