Support: add support to identify WinCOFF/ARM objects

Add the Windows COFF ARM object file magic.  This enables the LLVM tools to
interact with COFF object files for Windows on ARM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203761 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Saleem Abdulrasool 2014-03-13 07:02:35 +00:00
parent ec7eedc5db
commit b0f12dfab6
4 changed files with 22 additions and 0 deletions

View File

@ -663,6 +663,8 @@ StringRef COFFObjectFile::getFileFormatName() const {
return "COFF-i386";
case COFF::IMAGE_FILE_MACHINE_AMD64:
return "COFF-x86-64";
case COFF::IMAGE_FILE_MACHINE_ARMNT:
return "COFF-ARM";
default:
return "COFF-<unknown arch>";
}
@ -674,6 +676,8 @@ unsigned COFFObjectFile::getArch() const {
return Triple::x86;
case COFF::IMAGE_FILE_MACHINE_AMD64:
return Triple::x86_64;
case COFF::IMAGE_FILE_MACHINE_ARMNT:
return Triple::thumb;
default:
return Triple::UnknownArch;
}

View File

@ -1016,6 +1016,7 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
case 0x66: // MPS R4000 Windows
case 0x50: // mc68K
case 0x4c: // 80386 Windows
case 0xc4: // ARMNT Windows
if (Magic[1] == 0x01)
return file_magic::coff_object;

Binary file not shown.

View File

@ -1,3 +1,5 @@
RUN: llvm-readobj -h %p/Inputs/trivial.obj.coff-arm \
RUN: | FileCheck %s -check-prefix COFF-ARM
RUN: llvm-readobj -h %p/Inputs/trivial.obj.coff-i386 \
RUN: | FileCheck %s -check-prefix COFF32
RUN: llvm-readobj -h %p/Inputs/trivial.obj.coff-x86-64 \
@ -13,6 +15,21 @@ RUN: | FileCheck %s -check-prefix COFF-UNKNOWN
RUN: llvm-readobj -h %p/Inputs/magic.coff-importlib \
RUN: | FileCheck %s -check-prefix COFF-IMPORTLIB
COFF-ARM: File: {{(.*[/\\])?}}trivial.obj.coff-arm
COFF-ARM-NEXT: Format: COFF-ARM
COFF-ARM-NEXT: Arch: thumb
COFF-ARM-NEXT: AddressSize: 32bit
COFF-ARM-NEXT: ImageFileHeader {
COFF-ARM-NEXT: Machine: IMAGE_FILE_MACHINE_ARMNT (0x1C4)
COFF-ARM-NEXT: SectionCount: 2
COFF-ARM-NEXT: TimeDateStamp: 2014-03-13 02:48:34 (0x53211C82)
COFF-ARM-NEXT: PointerToSymbolTable: 0xFF
COFF-ARM-NEXT: SymbolCount: 6
COFF-ARM-NEXT: OptionalHeaderSize: 0
COFF-ARM-NEXT: Characteristics [ (0x0)
COFF-ARM-NEXT: ]
COFF-ARM-NEXT: }
COFF32: File: {{(.*[/\\])?}}trivial.obj.coff-i386
COFF32-NEXT: Format: COFF-i386
COFF32-NEXT: Arch: i386