[lld] r225339 - PE/COFF: teach ARMNT backend about ADDR32NB for exports
Saleem Abdulrasool
compnerd at compnerd.org
Tue Jan 6 20:20:26 PST 2015
Author: compnerd
Date: Tue Jan 6 22:20:26 2015
New Revision: 225339
URL: http://llvm.org/viewvc/llvm-project?rev=225339&view=rev
Log:
PE/COFF: teach ARMNT backend about ADDR32NB for exports
This adds the ability to export symbols from a DLL built for ARMNT. Add this
support first to help work towards adding support for import thunks on Windows
on ARM. In order to generate the exports, add support for
IMAGE_REL_ARM_ADDR32NB relocations.
Added:
lld/trunk/test/pecoff/Inputs/armnt-exports.def
lld/trunk/test/pecoff/Inputs/armnt-exports.obj.yaml
lld/trunk/test/pecoff/armnt-exports.s
lld/trunk/test/pecoff/armnt-exports.test
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
Modified: lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp?rev=225339&r1=225338&r2=225339&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp Tue Jan 6 22:20:26 2015
@@ -65,6 +65,10 @@ void addDir32NBReloc(COFFBaseDefinedAtom
addReloc(atom, target, offsetInAtom, Reference::KindArch::x86_64,
llvm::COFF::IMAGE_REL_AMD64_ADDR32NB);
return;
+ case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
+ addReloc(atom, target, offsetInAtom, Reference::KindArch::ARM,
+ llvm::COFF::IMAGE_REL_ARM_ADDR32NB);
+ return;
default:
llvm_unreachable("unsupported machine type");
}
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=225339&r1=225338&r2=225339&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Tue Jan 6 22:20:26 2015
@@ -605,6 +605,9 @@ void AtomChunk::applyRelocationsARM(uint
case llvm::COFF::IMAGE_REL_ARM_ADDR32:
*RelocSite32 = *RelocSite32 + TargetAddr + ImageBase;
break;
+ case llvm::COFF::IMAGE_REL_ARM_ADDR32NB:
+ *RelocSite32 = *RelocSite32 + TargetAddr;
+ break;
case llvm::COFF::IMAGE_REL_ARM_MOV32T:
applyThumbMoveImmediate(&RelocSite16[0], (TargetAddr + ImageBase) >> 0);
applyThumbMoveImmediate(&RelocSite16[2], (TargetAddr + ImageBase) >> 16);
Added: lld/trunk/test/pecoff/Inputs/armnt-exports.def
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/armnt-exports.def?rev=225339&view=auto
==============================================================================
--- lld/trunk/test/pecoff/Inputs/armnt-exports.def (added)
+++ lld/trunk/test/pecoff/Inputs/armnt-exports.def Tue Jan 6 22:20:26 2015
@@ -0,0 +1,4 @@
+LIBRARY "armnt-exports"
+EXPORTS
+ function
+
Added: lld/trunk/test/pecoff/Inputs/armnt-exports.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/armnt-exports.obj.yaml?rev=225339&view=auto
==============================================================================
--- lld/trunk/test/pecoff/Inputs/armnt-exports.obj.yaml (added)
+++ lld/trunk/test/pecoff/Inputs/armnt-exports.obj.yaml Tue Jan 6 22:20:26 2015
@@ -0,0 +1,35 @@
+---
+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: 704700BF7047
+symbols:
+ - Name: .text
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 6
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 1
+ - Name: function
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: _DllMainCRTStartup
+ Value: 4
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
Added: lld/trunk/test/pecoff/armnt-exports.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/armnt-exports.s?rev=225339&view=auto
==============================================================================
--- lld/trunk/test/pecoff/armnt-exports.s (added)
+++ lld/trunk/test/pecoff/armnt-exports.s Tue Jan 6 22:20:26 2015
@@ -0,0 +1,28 @@
+
+# void __declspec(dllexport) function() {}
+# void _DllMainCRTStartup() {}
+
+ .syntax unified
+ .thumb
+ .text
+
+ .def function
+ .scl 2
+ .type 32
+ .endef
+ .global function
+ .align 2
+ .thumb_func
+function:
+ bx lr
+
+ .def _DllMainCRTStartup
+ .scl 2
+ .type 32
+ .endef
+ .global _DllMainCRTStartup
+ .align 2
+ .thumb_func
+_DllMainCRTStartup
+ bx lr
+
Added: lld/trunk/test/pecoff/armnt-exports.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/armnt-exports.test?rev=225339&view=auto
==============================================================================
--- lld/trunk/test/pecoff/armnt-exports.test (added)
+++ lld/trunk/test/pecoff/armnt-exports.test Tue Jan 6 22:20:26 2015
@@ -0,0 +1,10 @@
+# RUN: yaml2obj -format coff -o %t.obj %p/Inputs/armnt-exports.obj.yaml
+# RUN: lld -flavor link /dll /def:%p/Inputs/armnt-exports.def /out:%t.dll %t.obj
+# RUN: llvm-readobj -coff-exports %t.dll | FileCheck %s
+
+CHECK: Export {
+CHECK: Ordinal: 1
+CHECK: Name: function
+CHECK: RVA: 0x2001
+CHECK: }
+
More information about the llvm-commits
mailing list