Skip to content

Commit

Permalink
Support: add support to identify WinCOFF/ARM objects
Browse files Browse the repository at this point in the history
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
  • Loading branch information
compnerd committed Mar 13, 2014
1 parent ec7eedc commit b0f12df
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Object/COFFObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>";
}
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Support/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Binary file added test/tools/llvm-readobj/Inputs/trivial.obj.coff-arm
Binary file not shown.
17 changes: 17 additions & 0 deletions test/tools/llvm-readobj/file-headers.test
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
Expand Down

0 comments on commit b0f12df

Please sign in to comment.