[lld] r225052 - ReaderWriter: teach PE/COFF backend about ARM NT

Saleem Abdulrasool compnerd at compnerd.org
Wed Dec 31 14:32:21 PST 2014


Author: compnerd
Date: Wed Dec 31 16:32:21 2014
New Revision: 225052

URL: http://llvm.org/viewvc/llvm-project?rev=225052&view=rev
Log:
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.

Added:
    lld/trunk/test/pecoff/Inputs/armnt-obj.s
    lld/trunk/test/pecoff/Inputs/armnt-obj.yaml
    lld/trunk/test/pecoff/armnt.test
Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp

Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=225052&r1=225051&r2=225052&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Wed Dec 31 16:32:21 2014
@@ -932,6 +932,9 @@ std::error_code FileCOFF::getReferenceAr
   case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
     result = Reference::KindArch::x86_64;
     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:
     result = Reference::KindArch::all;
     return std::error_code();

Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=225052&r1=225051&r2=225052&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Wed Dec 31 16:32:21 2014
@@ -697,6 +697,9 @@ void AtomChunk::addBaseRelocations(std::
   case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
     relType = llvm::COFF::IMAGE_REL_AMD64_ADDR64;
     break;
+  case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
+    relType = llvm::COFF::IMAGE_REL_ARM_ADDR32;
+    break;
   }
 
   for (const auto *layout : _atomLayouts) {

Added: lld/trunk/test/pecoff/Inputs/armnt-obj.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/armnt-obj.s?rev=225052&view=auto
==============================================================================
--- lld/trunk/test/pecoff/Inputs/armnt-obj.s (added)
+++ lld/trunk/test/pecoff/Inputs/armnt-obj.s Wed Dec 31 16:32:21 2014
@@ -0,0 +1,12 @@
+
+	.syntax unified
+	.thumb
+	.text
+
+	.def main
+		.scl 2
+		.type 32
+	.endef
+main:
+	bx lr
+

Added: lld/trunk/test/pecoff/Inputs/armnt-obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/armnt-obj.yaml?rev=225052&view=auto
==============================================================================
--- lld/trunk/test/pecoff/Inputs/armnt-obj.yaml (added)
+++ lld/trunk/test/pecoff/Inputs/armnt-obj.yaml Wed Dec 31 16:32:21 2014
@@ -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
+...

Added: lld/trunk/test/pecoff/armnt.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/armnt.test?rev=225052&view=auto
==============================================================================
--- lld/trunk/test/pecoff/armnt.test (added)
+++ lld/trunk/test/pecoff/armnt.test Wed Dec 31 16:32:21 2014
@@ -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
+





More information about the llvm-commits mailing list