aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShoaib Meenai <smeenai@fb.com>2017-10-17 01:41:14 +0000
committerShoaib Meenai <smeenai@fb.com>2017-10-17 01:41:14 +0000
commitd8da420012a40fa195a788fc393a0b8cfbad49f0 (patch)
treec256631c78038db79cbfd4924548dc4aa15e614f
parent5128bb371a5f35197e5cd7f66909d2447358e4e7 (diff)
[ExecutionEngine] Correct the size of a write in a COFF i386 relocation
We want to be writing a 32bit value, so we should be writing 4 bytes instead of 2. Patch by Alex Langford <apl@fb.com>. Differential Revision: https://reviews.llvm.org/D38872 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315964 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h2
-rw-r--r--test/ExecutionEngine/RuntimeDyld/X86/COFF_i386.s18
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
index 901f77865ba..76c8f956300 100644
--- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
+++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
@@ -209,7 +209,7 @@ public:
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_SECREL Value: " << RE.Addend
<< '\n');
- writeBytesUnaligned(RE.Addend, Target, 2);
+ writeBytesUnaligned(RE.Addend, Target, 4);
break;
default:
llvm_unreachable("unsupported relocation type");
diff --git a/test/ExecutionEngine/RuntimeDyld/X86/COFF_i386.s b/test/ExecutionEngine/RuntimeDyld/X86/COFF_i386.s
index ddf154e4320..869df79bbdc 100644
--- a/test/ExecutionEngine/RuntimeDyld/X86/COFF_i386.s
+++ b/test/ExecutionEngine/RuntimeDyld/X86/COFF_i386.s
@@ -49,11 +49,6 @@ __imp__ExitProcess:
.long "_ExitProcess@4" // IMAGE_REL_I386_DIR32
# rtdyld-check: *{4}__imp__ExitProcess = 0xffffffff
- .global string
- .align 1
-string:
- .asciz "Hello World!\n"
-
.global relocations
relocations:
rel5:
@@ -63,8 +58,8 @@ rel6:
# rtdyld-check: *{2}rel6 = 1
.secidx __imp__OutputDebugStringA // IMAGE_REL_I386_SECTION
rel7:
-# rtdyld-check: *{4}rel7 = relocations - section_addr(COFF_i386.s.tmp.obj, .data)
- .secrel32 relocations // IMAGE_REL_I386_SECREL
+# rtdyld-check: *{4}rel7 = string - section_addr(COFF_i386.s.tmp.obj, .data)
+ .secrel32 string // IMAGE_REL_I386_SECREL
# Test that addends work.
rel8:
@@ -79,3 +74,12 @@ rel10:
rel11:
# rtdyld-check: *{4}rel11 = string - section_addr(COFF_i386.s.tmp.obj, .data) + 1
.long string@SECREL32+1 // IMAGE_REL_I386_SECREL
+
+# We explicitly add padding to put string outside of the 16bit address space
+# (absolute and as an offset from .data), so that relocations involving
+# 32bit addresses / offsets are not accidentally truncated to 16 bits.
+ .space 65536
+ .global string
+ .align 1
+string:
+ .asciz "Hello World!\n"