From b6ef40891c7fb076a2f4ea860f8ee4135ae72aae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20Gr=C3=A4nitz?= Date: Sat, 24 Oct 2020 16:53:06 +0200 Subject: [PATCH] [JITLink][ELF] PCRel32GOTLoad edge offset can be smaller three Offset is 2 for MOVL instruction in test ELF_x86-64_common. This should fix the test failures. Differential Revision: https://reviews.llvm.org/D89795 --- llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp index 821a7b3..fb931c3 100644 --- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp @@ -127,12 +127,11 @@ static Error optimizeELF_x86_64_GOTAndStubs(LinkGraph &G) { if (E.getKind() == PCRel32GOTLoad) { // Replace GOT load with LEA only for MOVQ instructions. constexpr uint8_t MOVQRIPRel[] = {0x48, 0x8b}; - if (strncmp(B->getContent().data() + E.getOffset() - 3, + if (E.getOffset() < 3 || + strncmp(B->getContent().data() + E.getOffset() - 3, reinterpret_cast(MOVQRIPRel), 2) != 0) continue; - assert(E.getOffset() >= 3 && "GOT edge occurs too early in block"); - auto &GOTBlock = E.getTarget().getBlock(); assert(GOTBlock.getSize() == G.getPointerSize() && "GOT entry block should be pointer sized"); -- 2.7.4