aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Lanza <nathan@lanza.io>2018-12-12 00:04:06 +0000
committerNathan Lanza <nathan@lanza.io>2018-12-12 00:04:06 +0000
commit893083ae5e8e8ec8490b83e087a473c51b62f53f (patch)
treeff2d5f1a8af4888170d6985f96654dbc80b45768
parente4a68d1df79287df9580974119d24d515e42d059 (diff)
downloadllvm-893083ae5e8e8ec8490b83e087a473c51b62f53f.zip
llvm-893083ae5e8e8ec8490b83e087a473c51b62f53f.tar.gz
llvm-893083ae5e8e8ec8490b83e087a473c51b62f53f.tar.bz2
Implement IMAGE_REL_AMD64_SECREL for RuntimeDyldCOFFX86_64
lldb on Windows uses the ExecutionEngine for expression evaluation and hits the llvm_unreachable due to this relocation. Thus, implement the relocation and add a test to verify it's function. llvm-svn: 348904
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h7
-rw-r--r--llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64_IMGREL.s14
2 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
index 39bdc4b..aee5f6d 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
@@ -128,6 +128,13 @@ public:
break;
}
+ case COFF::IMAGE_REL_AMD64_SECREL: {
+ assert(static_cast<int64_t>(RE.Addend) <= INT32_MAX && "Relocation overflow");
+ assert(static_cast<int64_t>(RE.Addend) >= INT32_MIN && "Relocation underflow");
+ writeBytesUnaligned(RE.Addend, Target, 4);
+ break;
+ }
+
default:
llvm_unreachable("Relocation type not implemented yet!");
break;
diff --git a/llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64_IMGREL.s b/llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64_IMGREL.s
index ac097c4..3522bee 100644
--- a/llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64_IMGREL.s
+++ b/llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64_IMGREL.s
@@ -24,3 +24,17 @@ inst1:
# rtdyld-check: decode_operand(inst2, 3) = section_addr(COFF_x86_64_IMGREL.o, .rdata)+5-40960000000000
inst2:
mov %ebx, (__constdata@imgrel+5)
+ .data
+ .space 375
+rel1:
+# rtdyld-check: *{4}rel1 = string - section_addr(COFF_x86_64_IMGREL.o, .data)
+ .secrel32 string
+
+# 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"