[llvm] r280005 - ExecutionEngine: fix a bug in the movt/movw relocator
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 13:42:04 PDT 2016
Author: compnerd
Date: Mon Aug 29 15:42:03 2016
New Revision: 280005
URL: http://llvm.org/viewvc/llvm-project?rev=280005&view=rev
Log:
ExecutionEngine: fix a bug in the movt/movw relocator
According to the arm arm specifications, 4 bytes are needed for a shift instead
of 8, this was causing the movt instruction to write to a different register
sometimes.
Patch by Walter Erquinigo!
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h?rev=280005&r1=280004&r2=280005&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h Mon Aug 29 15:42:03 2016
@@ -225,7 +225,7 @@ public:
Bytes[0] |= ((Immediate & 0xf000) >> 12);
Bytes[1] |= ((Immediate & 0x0800) >> 11);
Bytes[2] |= ((Immediate & 0x00ff) >> 0);
- Bytes[3] |= ((Immediate & 0x0700) >> 8);
+ Bytes[3] |= (((Immediate & 0x0700) >> 8) << 4);
};
EncodeImmediate(&Target[0], static_cast<uint32_t>(Result) >> 00);
Modified: llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s?rev=280005&r1=280004&r2=280005&view=diff
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s (original)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s Mon Aug 29 15:42:03 2016
@@ -1,5 +1,5 @@
// RUN: llvm-mc -triple thumbv7-windows-itanium -filetype obj -o %t.obj %s
-// RUN: llvm-rtdyld -triple thumbv7-windows -dummy-extern OutputDebugStringA=0x78563412 -dummy-extern ExitProcess=0x54769890 -dummy-extern unnamed_addr=0x00001024 -verify -check %s %t.obj
+// RUN: llvm-rtdyld -triple thumbv7-windows -dummy-extern OutputDebugStringW=0x01310060 -dummy-extern OutputDebugStringA=0x78563412 -dummy-extern ExitProcess=0x54769890 -dummy-extern unnamed_addr=0x00001024 -verify -check %s %t.obj
.text
.syntax unified
@@ -104,4 +104,20 @@ rel10:
rel11:
.secrel32 relocations @ IMAGE_REL_ARM_SECREL
# rtdyld-check: *{4}rel11 = relocations - section_addr(COFF_Thumb.s.tmp.obj, .data)
+rel12: @ IMAGE_REL_ARM_MOV32T
+ movw r0, :lower16:__imp_OutputDebugStringW
+# rtdyld-check: decode_operand(rel12, 1) = (__imp_OutputDebugStringW&0x0000ffff)
+ movt r0, :upper16:__imp_OutputDebugStringW
+# TODO rtdyld-check: decode_operand(rel12, 1) = (__imp_OutputDebugStringW&0xffff0000>>16)
+ bx r0
+ trap
+ .data
+
+ .p2align 2
+__imp_OutputDebugStringW:
+@ rel13:
+ .long OutputDebugStringW @ IMAGE_REL_ARM_ADDR32
+# rtdyld-check: *{4}__imp_OutputDebugStringW = 0x01310060
+
+ .p2align 2
More information about the llvm-commits
mailing list