From: Lang Hames Date: Mon, 19 Oct 2015 20:37:52 +0000 (+0000) Subject: [RuntimeDyld][COFF] Fix some endianness issues, re-enable the regression test. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=17da9b2d152d3ef286561f64b0ad4d954de18cba;p=oota-llvm.git [RuntimeDyld][COFF] Fix some endianness issues, re-enable the regression test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250733 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h index 8b7d06930a1..adaeae0702e 100644 --- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h +++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h @@ -72,7 +72,6 @@ public: case COFF::IMAGE_REL_AMD64_REL32_3: case COFF::IMAGE_REL_AMD64_REL32_4: case COFF::IMAGE_REL_AMD64_REL32_5: { - uint32_t *TargetAddress = (uint32_t *)Target; uint64_t FinalAddress = Section.LoadAddress + RE.Offset; // Delta is the distance from the start of the reloc to the end of the // instruction with the reloc. @@ -81,7 +80,7 @@ public: uint64_t Result = Value + RE.Addend; assert(((int64_t)Result <= INT32_MAX) && "Relocation overflow"); assert(((int64_t)Result >= INT32_MIN) && "Relocation underflow"); - *TargetAddress = Result; + writeBytesUnaligned(Result, Target, 4); break; } @@ -92,14 +91,12 @@ public: // within a 32 bit offset from the base. // // For now we just set these to zero. - uint32_t *TargetAddress = (uint32_t *)Target; - *TargetAddress = 0; + writeBytesUnaligned(0, Target, 4); break; } case COFF::IMAGE_REL_AMD64_ADDR64: { - uint64_t *TargetAddress = (uint64_t *)Target; - *TargetAddress = Value + RE.Addend; + writeBytesUnaligned(0, Target, Value + RE.Addend); break; } @@ -139,14 +136,14 @@ public: case COFF::IMAGE_REL_AMD64_REL32_4: case COFF::IMAGE_REL_AMD64_REL32_5: case COFF::IMAGE_REL_AMD64_ADDR32NB: { - uint32_t *Displacement = (uint32_t *)ObjTarget; - Addend = *Displacement; + uint8_t *Displacement = (uint8_t *)ObjTarget; + Addend = readBytesUnaligned(Displacement, 4); break; } case COFF::IMAGE_REL_AMD64_ADDR64: { - uint64_t *Displacement = (uint64_t *)ObjTarget; - Addend = *Displacement; + uint8_t *Displacement = (uint8_t *)ObjTarget; + Addend = readBytesUnaligned(Displacement, 8); break; } diff --git a/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64 b/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64 deleted file mode 100644 index fc0f3e85147..00000000000 --- a/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64 +++ /dev/null @@ -1,34 +0,0 @@ -# RUN: llvm-mc -triple=x86_64-pc-win32 -filetype=obj -o %T/COFF_x86_64.o %s -# RUN: llvm-rtdyld -triple=x86_64-pc-win32 -verify -check=%s %/T/COFF_x86_64.o - .text - .def F; - .scl 2; - .type 32; - .endef - .globl __real400921f9f01b866e - .section .rdata,"dr",discard,__real400921f9f01b866e - .align 8 -__real400921f9f01b866e: - .quad 4614256650576692846 # double 3.1415899999999999 - .text - .globl F - .global inst1 - .align 16, 0x90 -F: # @F -.Ltmp0: -.seh_proc F -# BB#0: # %entry -.Ltmp1: - .seh_endprologue -# rtdyld-check: decode_operand(inst1, 4) = __real400921f9f01b866e - next_pc(inst1) -inst1: - movsd __real400921f9f01b866e(%rip), %xmm0 # xmm0 = mem[0],zero - retq -.Leh_func_end0: -.Ltmp2: - .seh_endproc - -# Make sure the JIT doesn't bail out on BSS sections. - .bss -bss_check: - .fill 8, 1, 0 diff --git a/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s b/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s new file mode 100644 index 00000000000..fc0f3e85147 --- /dev/null +++ b/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s @@ -0,0 +1,34 @@ +# RUN: llvm-mc -triple=x86_64-pc-win32 -filetype=obj -o %T/COFF_x86_64.o %s +# RUN: llvm-rtdyld -triple=x86_64-pc-win32 -verify -check=%s %/T/COFF_x86_64.o + .text + .def F; + .scl 2; + .type 32; + .endef + .globl __real400921f9f01b866e + .section .rdata,"dr",discard,__real400921f9f01b866e + .align 8 +__real400921f9f01b866e: + .quad 4614256650576692846 # double 3.1415899999999999 + .text + .globl F + .global inst1 + .align 16, 0x90 +F: # @F +.Ltmp0: +.seh_proc F +# BB#0: # %entry +.Ltmp1: + .seh_endprologue +# rtdyld-check: decode_operand(inst1, 4) = __real400921f9f01b866e - next_pc(inst1) +inst1: + movsd __real400921f9f01b866e(%rip), %xmm0 # xmm0 = mem[0],zero + retq +.Leh_func_end0: +.Ltmp2: + .seh_endproc + +# Make sure the JIT doesn't bail out on BSS sections. + .bss +bss_check: + .fill 8, 1, 0