[llvm] r360392 - [JITLink] Fixed a signedness bug when processing X86_64_RELOC_SUBTRACTOR.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu May 9 16:17:41 PDT 2019
Author: lhames
Date: Thu May 9 16:17:41 2019
New Revision: 360392
URL: http://llvm.org/viewvc/llvm-project?rev=360392&view=rev
Log:
[JITLink] Fixed a signedness bug when processing X86_64_RELOC_SUBTRACTOR.
Subtractor relocation addends are signed, so we need to read them via signed
int pointers. Accidentally treating 32-bit addends as unsigned leads to
out-of-range errors when we try to add very large (>INT32_MAX) bogus addends.
Modified:
llvm/trunk/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
llvm/trunk/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s
Modified: llvm/trunk/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp?rev=360392&r1=360391&r2=360392&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp Thu May 9 16:17:41 2019
@@ -157,9 +157,9 @@ private:
// Read the current fixup value.
uint64_t FixupValue = 0;
if (SubRI.r_length == 3)
- FixupValue = *(const ulittle64_t *)FixupContent;
+ FixupValue = *(const little64_t *)FixupContent;
else
- FixupValue = *(const ulittle32_t *)FixupContent;
+ FixupValue = *(const little32_t *)FixupContent;
// Find 'ToAtom' using symbol number or address, depending on whether the
// paired UNSIGNED relocation is extern.
Modified: llvm/trunk/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s?rev=360392&r1=360391&r2=360392&view=diff
==============================================================================
--- llvm/trunk/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s (original)
+++ llvm/trunk/test/ExecutionEngine/JITLink/X86/MachO_x86-64_relocations.s Thu May 9 16:17:41 2019
@@ -180,32 +180,32 @@ anon_minuend_long1:
# Both forms "A: .quad A - B + C" and "A: .quad B - A + C" are tested.
#
# Check "A: .quad B - A + C".
-# jitlink-check: *{8}subtrahend_quad2 = (named_data - subtrahend_quad2 + 2)
+# jitlink-check: *{8}subtrahend_quad2 = (named_data - subtrahend_quad2 - 2)
.globl subtrahend_quad2
.p2align 3
subtrahend_quad2:
- .quad named_data - subtrahend_quad2 + 2
+ .quad named_data - subtrahend_quad2 - 2
# Check "A: .long B - A + C".
-# jitlink-check: *{4}subtrahend_long2 = (named_data - subtrahend_long2 + 2)[31:0]
+# jitlink-check: *{4}subtrahend_long2 = (named_data - subtrahend_long2 - 2)[31:0]
.globl subtrahend_long2
.p2align 2
subtrahend_long2:
- .long named_data - subtrahend_long2 + 2
+ .long named_data - subtrahend_long2 - 2
# Check "A: .quad A - B + C".
-# jitlink-check: *{8}minuend_quad3 = (minuend_quad3 - named_data + 2)
+# jitlink-check: *{8}minuend_quad3 = (minuend_quad3 - named_data - 2)
.globl minuend_quad3
.p2align 3
minuend_quad3:
- .quad minuend_quad3 - named_data + 2
+ .quad minuend_quad3 - named_data - 2
# Check "A: .long B - A + C".
-# jitlink-check: *{4}minuend_long3 = (minuend_long3 - named_data + 2)[31:0]
+# jitlink-check: *{4}minuend_long3 = (minuend_long3 - named_data - 2)[31:0]
.globl minuend_long3
.p2align 2
minuend_long3:
- .long minuend_long3 - named_data + 2
+ .long minuend_long3 - named_data - 2
# Check X86_64_RELOC_SUBTRACTOR handling for exprs of the form
# "A: .quad/long B - C + D", where 'B' or 'C' is at a fixed offset from 'A'
More information about the llvm-commits
mailing list