[lld] r243199 - COFF: ARM: Set correct entry point address.
Rui Ueyama
ruiu at google.com
Fri Jul 24 19:25:14 PDT 2015
Author: ruiu
Date: Fri Jul 24 21:25:14 2015
New Revision: 243199
URL: http://llvm.org/viewvc/llvm-project?rev=243199&view=rev
Log:
COFF: ARM: Set correct entry point address.
Added:
lld/trunk/test/COFF/Inputs/armnt-executable.obj.yaml
lld/trunk/test/COFF/Inputs/armnt-executable.s
lld/trunk/test/COFF/armnt-entry-point.test
Modified:
lld/trunk/COFF/Config.h
lld/trunk/COFF/Writer.cpp
Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=243199&r1=243198&r2=243199&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Fri Jul 24 21:25:14 2015
@@ -31,7 +31,7 @@ class Undefined;
// Short aliases.
static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
-static const auto ARM = llvm::COFF::IMAGE_FILE_MACHINE_ARM;
+static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
// Represents an /export option.
Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=243199&r1=243198&r2=243199&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Fri Jul 24 21:25:14 2015
@@ -440,6 +440,9 @@ template <typename PEHeaderTy> void Writ
if (!Config->NoEntry) {
Defined *Entry = cast<Defined>(Config->Entry->repl());
PE->AddressOfEntryPoint = Entry->getRVA();
+ // Pointer to thumb code must have the LSB set, so adjust it.
+ if (Config->MachineType == ARMNT)
+ PE->AddressOfEntryPoint |= 1;
}
PE->SizeOfStackReserve = Config->StackReserve;
PE->SizeOfStackCommit = Config->StackCommit;
Added: lld/trunk/test/COFF/Inputs/armnt-executable.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/armnt-executable.obj.yaml?rev=243199&view=auto
==============================================================================
--- lld/trunk/test/COFF/Inputs/armnt-executable.obj.yaml (added)
+++ lld/trunk/test/COFF/Inputs/armnt-executable.obj.yaml Fri Jul 24 21:25:14 2015
@@ -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: mainCRTStartup
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
Added: lld/trunk/test/COFF/Inputs/armnt-executable.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/Inputs/armnt-executable.s?rev=243199&view=auto
==============================================================================
--- lld/trunk/test/COFF/Inputs/armnt-executable.s (added)
+++ lld/trunk/test/COFF/Inputs/armnt-executable.s Fri Jul 24 21:25:14 2015
@@ -0,0 +1,13 @@
+# void mainCRTStartup() {}
+ .syntax unified
+ .thumb
+ .text
+ .def mainCRTStartup
+ .scl 2
+ .type 32
+ .endef
+ .global mainCRTStartup
+ .align 2
+ .thumb_func
+mainCRTStartup:
+ bx lr
Added: lld/trunk/test/COFF/armnt-entry-point.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/armnt-entry-point.test?rev=243199&view=auto
==============================================================================
--- lld/trunk/test/COFF/armnt-entry-point.test (added)
+++ lld/trunk/test/COFF/armnt-entry-point.test Fri Jul 24 21:25:14 2015
@@ -0,0 +1,5 @@
+# RUN: yaml2obj < %p/Inputs/armnt-executable.obj.yaml > %t.obj
+# RUN: lld -flavor link2 /out:%t.exe /entry:mainCRTStartup /subsystem:console %t.obj
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
+
+CHECK: AddressOfEntryPoint: 0x1001
More information about the llvm-commits
mailing list