Index: llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h =================================================================== --- llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h +++ llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h @@ -126,6 +126,24 @@ /// BranchPCRel32, + /// A 32-bit PC-relative relocation. + /// + /// Represents a data/control flow instruction using PC-relative addressing + /// to a target. + /// + /// The fixup expression for this kind includes an implicit offset to account + /// for the PC (unlike the Delta edges) so that a PCRel32 with a target + /// T and addend zero is a call/branch to the start (offset zero) of T. + /// + /// Fixup expression: + /// Fixup <- Target - (Fixup + 4) + Addend : int32 + /// + /// Errors: + /// - The result of the fixup expression must fit into an int32, otherwise + /// an out-of-range error will be returned. + /// + PCRel32, + /// A 32-bit PC-relative branch to a pointer jump stub. /// /// The target of this relocation should be a pointer jump stub of the form: @@ -343,7 +361,9 @@ /// - *ASSERTION* Failure to handle edges of this kind prior to the fixup /// phase will result in an assert/unreachable during the fixup phase. /// - RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable + RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable, + // First platform specific relocation. + FirstPlatformRelocation }; /// Returns a string name for the given x86-64 edge. For debugging purposes @@ -395,6 +415,7 @@ break; } + case PCRel32: case BranchPCRel32: case BranchPCRel32ToPtrJumpStub: case BranchPCRel32ToPtrJumpStubBypassable: Index: llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp =================================================================== --- llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp +++ llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp @@ -18,13 +18,19 @@ namespace llvm { namespace jitlink { +static Triple createTripleWithCOFFFormat(Triple T) { + T.setObjectFormat(Triple::COFF); + return T; +} + COFFLinkGraphBuilder::COFFLinkGraphBuilder( const object::COFFObjectFile &Obj, Triple TT, LinkGraph::GetEdgeKindNameFunction GetEdgeKindName) : Obj(Obj), - G(std::make_unique( - Obj.getFileName().str(), Triple(std::move(TT)), getPointerSize(Obj), - getEndianness(Obj), std::move(GetEdgeKindName))) { + G(std::make_unique(Obj.getFileName().str(), + createTripleWithCOFFFormat(TT), + getPointerSize(Obj), getEndianness(Obj), + std::move(GetEdgeKindName))) { LLVM_DEBUG({ dbgs() << "Created COFFLinkGraphBuilder for \"" << Obj.getFileName() << "\"\n"; @@ -128,16 +134,6 @@ if (Expected SecNameOrErr = Obj.getSectionName(*Sec)) SectionName = *SecNameOrErr; - bool IsDiscardable = - (*Sec)->Characteristics & - (COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_LNK_INFO); - if (IsDiscardable) { - LLVM_DEBUG(dbgs() << " " << SecIndex << ": \"" << SectionName - << "\" is discardable: " - "No graph section will be created.\n"); - continue; - } - // FIXME: Skip debug info sections LLVM_DEBUG({ @@ -145,6 +141,8 @@ << "Creating section for \"" << SectionName << "\"\n"; }); + // FIXME: Revisit crash when dropping IMAGE_SCN_MEM_DISCARDABLE sections + // Get the section's memory protection flags. MemProt Prot = MemProt::None; if ((*Sec)->Characteristics & COFF::IMAGE_SCN_MEM_EXECUTE) @@ -325,6 +323,8 @@ SecIndex <= static_cast(Obj.getNumberOfSections()); SecIndex++) { auto &SymbolSet = SymbolSets[SecIndex]; + if (SymbolSet.empty()) + continue; jitlink::Block *B = getGraphBlock(SecIndex); orc::ExecutorAddrDiff LastOffset = B->getSize(); orc::ExecutorAddrDiff LastDifferentOffset = B->getSize(); @@ -394,6 +394,17 @@ formatv("{0:d}", SymIndex)); Block *B = getGraphBlock(Symbol.getSectionNumber()); + if (!B) { + LLVM_DEBUG({ + dbgs() << " " << SymIndex + << ": Skipping graph symbol since section was not created for " + "COFF symbol \"" + << SymbolName << "\" in section " << Symbol.getSectionNumber() + << "\n"; + }); + return nullptr; + } + if (Symbol.isExternal()) { // This is not a comdat sequence, export the symbol as it is if (!isComdatSection(Section)) { Index: llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp =================================================================== --- llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp +++ llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp @@ -26,6 +26,11 @@ namespace { +enum EdgeKind_coff_x86_64 : Edge::Kind { + PCRel32 = x86_64::FirstPlatformRelocation, + Pointer32NB, +}; + class COFFJITLinker_x86_64 : public JITLinker { friend class JITLinker; @@ -43,27 +48,7 @@ class COFFLinkGraphBuilder_x86_64 : public COFFLinkGraphBuilder { private: - uint64_t ImageBase = 0; - enum COFFX86RelocationKind { - COFFAddr32NB, - COFFRel32, - }; - - static Expected - getRelocationKind(const uint32_t Type) { - switch (Type) { - case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_ADDR32NB: - return COFFAddr32NB; - case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_REL32: - return COFFRel32; - } - - return make_error("Unsupported x86_64 relocation:" + - formatv("{0:d}", Type)); - } - Error addRelocations() override { - LLVM_DEBUG(dbgs() << "Processing relocations:\n"); for (const auto &RelSect : sections()) @@ -74,21 +59,9 @@ return Error::success(); } - uint64_t getImageBase() { - if (!ImageBase) { - ImageBase = std::numeric_limits::max(); - for (const auto &Block : getGraph().blocks()) { - if (Block->getAddress().getValue()) - ImageBase = std::min(ImageBase, Block->getAddress().getValue()); - } - } - return ImageBase; - } - Error addSingleRelocation(const object::RelocationRef &Rel, const object::SectionRef &FixupSect, Block &BlockToFix) { - const object::coff_relocation *COFFRel = getObject().getCOFFRelocation(Rel); auto SymbolIt = Rel.getSymbol(); if (SymbolIt == getObject().symbol_end()) { @@ -110,62 +83,122 @@ SymIndex, FixupSect.getIndex()), inconvertibleErrorCode()); - Expected RelocKind = - getRelocationKind(Rel.getType()); - if (!RelocKind) - return RelocKind.takeError(); - int64_t Addend = 0; orc::ExecutorAddr FixupAddress = orc::ExecutorAddr(FixupSect.getAddress()) + Rel.getOffset(); Edge::OffsetT Offset = FixupAddress - BlockToFix.getAddress(); Edge::Kind Kind = Edge::Invalid; + const char *FixupPtr = BlockToFix.getContent().data() + Offset; - switch (*RelocKind) { - case COFFAddr32NB: { - Kind = x86_64::Pointer32; - Offset -= getImageBase(); + switch (Rel.getType()) { + case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_ADDR32NB: { + Kind = EdgeKind_coff_x86_64::Pointer32NB; + Addend = *reinterpret_cast(FixupPtr); + break; + } + case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_REL32: { + Kind = EdgeKind_coff_x86_64::PCRel32; + Addend = *reinterpret_cast(FixupPtr); break; } - case COFFRel32: { - Kind = x86_64::BranchPCRel32; + case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_REL32_1: { + Kind = EdgeKind_coff_x86_64::PCRel32; + Addend = *reinterpret_cast(FixupPtr); + Addend -= 1; break; } - }; + default: { + return make_error("Unsupported x86_64 relocation:" + + formatv("{0:d}", Rel.getType())); + } + }; Edge GE(Kind, Offset, *GraphSymbol, Addend); LLVM_DEBUG({ dbgs() << " "; - printEdge(dbgs(), BlockToFix, GE, x86_64::getEdgeKindName(Kind)); + printEdge(dbgs(), BlockToFix, GE, getCOFFX86RelocationKindName(Kind)); dbgs() << "\n"; }); BlockToFix.addEdge(std::move(GE)); + return Error::success(); } - /// Return the string name of the given COFF x86_64 edge kind. - const char *getCOFFX86RelocationKindName(COFFX86RelocationKind R) { - switch (R) { - case COFFAddr32NB: - return "COFFAddr32NB"; - case COFFRel32: - return "COFFRel32"; +public: + COFFLinkGraphBuilder_x86_64(const object::COFFObjectFile &Obj, const Triple T) + : COFFLinkGraphBuilder(Obj, std::move(T), getCOFFX86RelocationKindName) {} +}; + +class COFFLinkGraphLowering_x86_64 { +public: + // Lowers COFF x86_64 specific edges to generic x86_64 edges. + Error lowerCOFFRelocationEdges(LinkGraph &G, JITLinkContext &Ctx) { + for (auto *B : G.blocks()) { + for (auto &E : B->edges()) { + switch (E.getKind()) { + case EdgeKind_coff_x86_64::Pointer32NB: { + auto ImageBase = getImageBaseAddress(G, Ctx); + if (!ImageBase) + return ImageBase.takeError(); + E.setAddend(E.getAddend() - *ImageBase); + E.setKind(x86_64::Pointer32); + break; + } + case EdgeKind_coff_x86_64::PCRel32: { + E.setKind(x86_64::PCRel32); + break; + } + default: + break; + } + } } + return Error::success(); } -public: - COFFLinkGraphBuilder_x86_64(const object::COFFObjectFile &Obj, const Triple T) - : COFFLinkGraphBuilder(Obj, std::move(T), x86_64::getEdgeKindName) {} +private: + static StringRef getImageBaseSymbolName() { return "__ImageBase"; } + Expected getImageBaseAddress(LinkGraph &G, + JITLinkContext &Ctx) { + if (this->ImageBase) + return this->ImageBase; + for (auto *S : G.defined_symbols()) + if (S->getName() == getImageBaseSymbolName()) { + this->ImageBase = S->getAddress().getValue(); + return this->ImageBase; + } + + JITLinkContext::LookupMap Symbols; + Symbols[getImageBaseSymbolName()] = SymbolLookupFlags::RequiredSymbol; + JITTargetAddress ImageBase; + Error Err = Error::success(); + Ctx.lookup(Symbols, + createLookupContinuation([&](Expected LR) { + ErrorAsOutParameter EAO(&Err); + if (!LR) { + Err = LR.takeError(); + return; + } + auto &ImageBaseSymbol = LR->begin()->second; + ImageBase = ImageBaseSymbol.getAddress(); + })); + if (Err) + return std::move(Err); + this->ImageBase = ImageBase; + return ImageBase; + } + JITTargetAddress ImageBase = 0; }; -Error buildTables_COFF_x86_64(LinkGraph &G) { - LLVM_DEBUG(dbgs() << "Visiting edges in graph:\n"); +Error lowerEdges_COFF_x86_64(LinkGraph &G, JITLinkContext *Ctx) { + LLVM_DEBUG(dbgs() << "Lowering COFF x86_64 edges:\n"); + COFFLinkGraphLowering_x86_64 GraphLowering; + + if (auto Err = GraphLowering.lowerCOFFRelocationEdges(G, *Ctx)) + return Err; - x86_64::GOTTableManager GOT; - x86_64::PLTTableManager PLT(GOT); - visitExistingEdges(G, GOT, PLT); return Error::success(); } } // namespace @@ -173,6 +206,18 @@ namespace llvm { namespace jitlink { +/// Return the string name of the given COFF x86_64 edge kind. +const char *getCOFFX86RelocationKindName(Edge::Kind R) { + switch (R) { + case PCRel32: + return "PCRel32"; + case Pointer32NB: + return "Pointer32NB"; + default: + return x86_64::getEdgeKindName(R); + } +} + Expected> createLinkGraphFromCOFFObject_x86_64(MemoryBufferRef ObjectBuffer) { LLVM_DEBUG({ @@ -199,11 +244,10 @@ else Config.PrePrunePasses.push_back(markAllSymbolsLive); - // Add an in-place GOT/Stubs/TLSInfoEntry build pass. - Config.PostPrunePasses.push_back(buildTables_COFF_x86_64); - - // Add GOT/Stubs optimizer pass. - Config.PreFixupPasses.push_back(x86_64::optimizeGOTAndStubAccesses); + // Add COFF edge lowering passes. + JITLinkContext *CtxPtr = Ctx.get(); + Config.PreFixupPasses.push_back( + [CtxPtr](LinkGraph &G) { return lowerEdges_COFF_x86_64(G, CtxPtr); }); } if (auto Err = Ctx->modifyPassConfig(*G, Config)) Index: llvm/lib/ExecutionEngine/JITLink/x86_64.cpp =================================================================== --- llvm/lib/ExecutionEngine/JITLink/x86_64.cpp +++ llvm/lib/ExecutionEngine/JITLink/x86_64.cpp @@ -36,6 +36,8 @@ return "NegDelta32"; case Delta64FromGOT: return "Delta64FromGOT"; + case PCRel32: + return "PCRel32"; case BranchPCRel32: return "BranchPCRel32"; case BranchPCRel32ToPtrJumpStub: Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc.test =================================================================== --- /dev/null +++ llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc.test @@ -0,0 +1,85 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-jitlink -noexec -abs __ImageBase=0xfff00000 \ +# RUN: -slab-allocate 100Kb -slab-address 0xfff00000 -slab-page-size 4096 \ +# RUN: -check %s %t +# +# Check IMAGE_REL_AMD64_ADDR32NB relocation properly sets the delta of target +# from imagebase. +# +# jitlink-check: *{4}(pdata) = func - __ImageBase +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: '0000000000000000' + - Name: .func + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: '0000000000000000' + - Name: .pdata + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '0000000000000000' + Relocations: + - VirtualAddress: 0 + SymbolTableIndex: 7 + Type: IMAGE_REL_AMD64_ADDR32NB +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + CheckSum: 0 + NumberOfLinenumbers: 0 + Number: 1 + - Name: .func + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + CheckSum: 0 + NumberOfLinenumbers: 0 + Number: 2 + - Name: .pdata + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 1 + CheckSum: 0 + NumberOfLinenumbers: 0 + Number: 3 + - Name: main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: func + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: pdata + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc_neg_addend.test =================================================================== --- /dev/null +++ llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc_neg_addend.test @@ -0,0 +1,85 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-jitlink -noexec -abs __ImageBase=0xfff00000 \ +# RUN: -slab-allocate 100Kb -slab-address 0xfff00000 -slab-page-size 4096 \ +# RUN: -check %s %t +# +# Check IMAGE_REL_AMD64_ADDR32NB relocation properly sets the delta of target +# from imagebase with a negative addend. +# +# jitlink-check: *{4}(pdata) = func - __ImageBase - 4 +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: '000000000000000B' + - Name: .func + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: '000000000000000A' + - Name: .pdata + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 'FCFFFFFF00000000' + Relocations: + - VirtualAddress: 0 + SymbolTableIndex: 7 + Type: IMAGE_REL_AMD64_ADDR32NB +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + CheckSum: 0 + NumberOfLinenumbers: 0 + Number: 1 + - Name: .func + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + CheckSum: 0 + NumberOfLinenumbers: 0 + Number: 2 + - Name: .pdata + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 1 + CheckSum: 0 + NumberOfLinenumbers: 0 + Number: 3 + - Name: main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: func + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: pdata + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_basic.s =================================================================== --- llvm/test/ExecutionEngine/JITLink/X86/COFF_basic.s +++ /dev/null @@ -1,29 +0,0 @@ -# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc %s -o %t -# RUN: llvm-jitlink -noexec %t -# -# Check a basic COFF object file loads successfully. - - .text - .def @feat.00; - .scl 3; - .type 0; - .endef - .globl @feat.00 -.set @feat.00, 0 - .file "main.c" - .def main; - .scl 2; - .type 32; - .endef - .globl main - .p2align 4, 0x90 -main: - .seh_proc main - pushq %rax - .seh_stackalloc 8 - .seh_endprologue - movl $0, 4(%rsp) - xorl %eax, %eax - popq %rcx - retq - .seh_endproc Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_comdat_weak_duplicate.s =================================================================== --- llvm/test/ExecutionEngine/JITLink/X86/COFF_comdat_weak_duplicate.s +++ llvm/test/ExecutionEngine/JITLink/X86/COFF_comdat_weak_duplicate.s @@ -11,9 +11,9 @@ # # CHECK: section weakfunc: # CHECK-EMPTY: -# CHECK-NEXT: block 0xfff02000 size = 0x00000001, align = 16, alignment-offset = 0 +# CHECK-NEXT: block 0xfff01000 size = 0x00000001, align = 16, alignment-offset = 0 # CHECK-NEXT: symbols: -# CHECK-NEXT: 0xfff02000 (block + 0x00000000): size: 0x00000001, linkage: weak, scope: default, live - func +# CHECK-NEXT: 0xfff01000 (block + 0x00000000): size: 0x00000001, linkage: weak, scope: default, live - func # CHECK-NEXT: no edges .text Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_external_func.s =================================================================== --- llvm/test/ExecutionEngine/JITLink/X86/COFF_external_func.s +++ /dev/null @@ -1,20 +0,0 @@ -# REQUIRES: asserts -# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc %s -o %t -# RUN: llvm-jitlink -abs func=0xcafef00d --debug-only=jitlink -noexec %t 2>&1 | FileCheck %s -# -# Check an external symbol to a functon is created. -# -# CHECK: Creating graph symbols... -# CHECK: 7: Creating external graph symbol for COFF symbol "func" in (external) (index: 0) - - .text - - .def main; - .scl 2; - .type 32; - .endef - .globl main - .p2align 4, 0x90 -main: - callq func - retq Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_external_var.s =================================================================== --- llvm/test/ExecutionEngine/JITLink/X86/COFF_external_var.s +++ llvm/test/ExecutionEngine/JITLink/X86/COFF_external_var.s @@ -1,11 +1,9 @@ -# REQUIRES: asserts # RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc %s -o %t -# RUN: llvm-jitlink -abs var=0xcafef00d --debug-only=jitlink -noexec %t 2>&1 | FileCheck %s +# RUN: not llvm-jitlink -slab-allocate 100Kb -slab-address 0xfff00000 -slab-page-size 4096 \ +# RUN: -abs var=0x7fff00000000 -noexec %t # -# Check an external symbol to a variable is created. +# Check data access to a external variable out of reach causes an error. # -# CHECK: Creating graph symbols... -# CHECK: 7: Creating external graph symbol for COFF symbol "var" in (external) (index: 0) .text Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_file_debug.s =================================================================== --- llvm/test/ExecutionEngine/JITLink/X86/COFF_file_debug.s +++ llvm/test/ExecutionEngine/JITLink/X86/COFF_file_debug.s @@ -5,7 +5,7 @@ # Check a file debug symbol is skipped. # # CHECK: Creating graph symbols... -# CHECK: 8: Skipping FileRecord symbol ".file" in (debug) (index: -2) +# CHECK: 7: Skipping FileRecord symbol ".file" in (debug) (index: -2) .text @@ -18,5 +18,4 @@ .globl main .p2align 4, 0x90 main: - callq func retq Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_label.test =================================================================== --- llvm/test/ExecutionEngine/JITLink/X86/COFF_label.test +++ llvm/test/ExecutionEngine/JITLink/X86/COFF_label.test @@ -19,7 +19,7 @@ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 4883EC28488D542438E8000000004883C428C34883EC28488D54243033C9E8000000004883C428C3 - - Name: '.text$mn' + - Name: '.func' Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 4883EC28488D542438E8000000004883C428C34883EC28488D54243033C9E8000000004883C428C3 Index: llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s =================================================================== --- llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s +++ llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s @@ -40,26 +40,6 @@ test_rel32_data: leaq named_data(%rip), %rax -# Check that calls to external functions out-of-range from the callsite trigger -# the generation of stubs and GOT entries. This produces a BranchPCRel32 edge, -# but STUB table manager will create a STUB sequence because external function -# is out-of-range from the callsite. -# -# jitlink-check: decode_operand(test_call_extern_out_of_range32, 0) = \ -# jitlink-check: stub_addr(coff_sm_reloc.o, extern_out_of_range32) - \ -# jitlink-check: next_pc(test_call_extern_out_of_range32) -# jitlink-check: *{8}(got_addr(coff_sm_reloc.o, extern_out_of_range32)) = \ -# jitlink-check: extern_out_of_range32 - .def test_call_extern_out_of_range32; - .scl 2; - .type 32; - .endef - .globl main - .p2align 4, 0x90 -test_call_extern_out_of_range32: - callq extern_out_of_range32 - retq - # Local named data/func that is used in conjunction with other test cases .text .def named_func;