From b58d6a5655574a5bbb61833c61cd867b42a9c14b Mon Sep 17 00:00:00 2001 From: Walter Erquinigo Date: Mon, 17 Oct 2016 18:56:18 +0000 Subject: Handle relocations to thumb functions when dynamic linking COFF modules Summary: This adds the necessary logic to support relocations to thumb functions in the COFF dynamic linker. The jumps to function addresses are mostly blx, which requires the ISA selection bit when jumping to a thumb function. Note: I'm determining if the relocation requires the ISA bit when creating the relocation entries and not when resolving the relocation. I have to do that because I need the ObjectFile and the actual Symbol, which are available only when creating the entries. It would require a gross refactor if I do it otherwise, but I'm okay with doing it if you think it's better. Reviewers: peter.smith, compnerd Subscribers: rengolin, sas Differential Revision: https://reviews.llvm.org/D25151 llvm-svn: 284410 --- .../ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'llvm/test') diff --git a/llvm/test/ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s b/llvm/test/ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s index 14e74cb39ac..991e88d01f5 100644 --- a/llvm/test/ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s +++ b/llvm/test/ExecutionEngine/RuntimeDyld/ARM/COFF_Thumb.s @@ -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 OutputDebugStringW=0x01310060 -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=0x01310061 -dummy-extern OutputDebugStringA=0x78563413 -dummy-extern ExitProcess=0x54769891 -dummy-extern unnamed_addr=0x00001024 -verify -check %s %t.obj .text .syntax unified @@ -82,13 +82,13 @@ string: __imp_OutputDebugStringA: @ rel6: .long OutputDebugStringA @ IMAGE_REL_ARM_ADDR32 -# rtdyld-check: *{4}__imp_OutputDebugStringA = 0x78563412 +# rtdyld-check: *{4}__imp_OutputDebugStringA = 0x78563413 .p2align 2 __imp_ExitProcess: @ rel7: .long ExitProcess @ IMAGE_REL_ARM_ADDR32 -# rtdyld-check: *{4}__imp_ExitProcess = 0x54769890 +# rtdyld-check: *{4}__imp_ExitProcess = 0x54769891 .global relocations relocations: @@ -118,6 +118,32 @@ rel12: @ IMAGE_REL_ARM_MOV32T __imp_OutputDebugStringW: @ rel13: .long OutputDebugStringW @ IMAGE_REL_ARM_ADDR32 -# rtdyld-check: *{4}__imp_OutputDebugStringW = 0x01310060 +# rtdyld-check: *{4}__imp_OutputDebugStringW = 0x01310061 .p2align 2 + +branch_to_thumb_func: +@ rel14: @ IMAGE_REL_ARM_MOV32T + movw r0, :lower16:function +# rtdyld-check: decode_operand(branch_to_thumb_func, 1) = (function&0x0000ffff|1) + movt r0, :upper16:function +# TODO rtdyld-check: decode_operand(branch_to_thumb_func, 1) = (function&0xffff0000>>16) + bx r0 + trap + + .data + + .p2align 2 +a_data_symbol: + .long 1073741822 + + .p2align 2 + + .text + +ref_to_data_symbol_addr: +@ rel15: @ IMAGE_REL_ARM_MOV32T + movw r0, :lower16:a_data_symbol +# rtdyld-check: decode_operand(ref_to_data_symbol_addr, 1) = (a_data_symbol&0x0000ffff) + movt r0, :upper16:a_data_symbol +# TODO rtdyld-check: decode_operand(ref_to_data_symbol_addr, 1) = (a_data_symbol&0xffff0000>>16) -- cgit v1.2.3