ReaderWriter: teach PE/COFF backend about ARM NT

This teaches lld about the ARM NT object types.  Add a trivial test to ensure
that it can handle ARM NT object file inputs.  It is still unable to perform the
necessary relocations for ARM NT, but this allows the linker to at least read
the objects.

llvm-svn: 225052
This commit is contained in:
Saleem Abdulrasool 2014-12-31 22:32:21 +00:00
parent 508d29d5b7
commit 0ba09e6b84
5 changed files with 53 additions and 0 deletions

View File

@ -932,6 +932,9 @@ std::error_code FileCOFF::getReferenceArch(Reference::KindArch &result) {
case llvm::COFF::IMAGE_FILE_MACHINE_AMD64: case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
result = Reference::KindArch::x86_64; result = Reference::KindArch::x86_64;
return std::error_code(); return std::error_code();
case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
result = Reference::KindArch::ARM;
return std::error_code();
case llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN: case llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN:
result = Reference::KindArch::all; result = Reference::KindArch::all;
return std::error_code(); return std::error_code();

View File

@ -697,6 +697,9 @@ void AtomChunk::addBaseRelocations(std::vector<uint64_t> &relocSites) const {
case llvm::COFF::IMAGE_FILE_MACHINE_AMD64: case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
relType = llvm::COFF::IMAGE_REL_AMD64_ADDR64; relType = llvm::COFF::IMAGE_REL_AMD64_ADDR64;
break; break;
case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
relType = llvm::COFF::IMAGE_REL_ARM_ADDR32;
break;
} }
for (const auto *layout : _atomLayouts) { for (const auto *layout : _atomLayouts) {

View File

@ -0,0 +1,12 @@
.syntax unified
.thumb
.text
.def main
.scl 2
.type 32
.endef
main:
bx lr

View File

@ -0,0 +1,29 @@
---
header:
Machine: IMAGE_FILE_MACHINE_ARMNT
Characteristics: [ ]
sections:
- Name: .text
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_PURGEABLE, IMAGE_SCN_MEM_16BIT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
Alignment: 4
SectionData: '7047'
symbols:
- Name: .text
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC
SectionDefinition:
Length: 2
NumberOfRelocations: 0
NumberOfLinenumbers: 0
CheckSum: 0
Number: 1
- Name: main
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_FUNCTION
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
...

View File

@ -0,0 +1,6 @@
# RUN: yaml2obj -format coff -o %t.obj %p/Inputs/armnt-obj.yaml
# RUN: lld -flavor link /out:%t.dll /subsystem:console /entry:main %t.obj
# RUN: llvm-readobj -sections %t.dll | FileCheck %s
CHECK: Format: COFF-ARM