[llvm] 0f00e58 - [JITLink][COFF][x86_64] Reimplement ADDR32NB/REL32.
Sunho Kim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 25 07:43:24 PDT 2022
Author: Sunho Kim
Date: 2022-07-25T23:41:53+09:00
New Revision: 0f00e588418e75422d42502eaa8ad491b8a4b7a2
URL: https://github.com/llvm/llvm-project/commit/0f00e588418e75422d42502eaa8ad491b8a4b7a2
DIFF: https://github.com/llvm/llvm-project/commit/0f00e588418e75422d42502eaa8ad491b8a4b7a2.diff
LOG: [JITLink][COFF][x86_64] Reimplement ADDR32NB/REL32.
Reimplements ADDR32NB/REL32 relocations properly, out-of-reach targets will be dealt in the separate patch that will generate the stub for dllimport symbols.
Reviewed By: sgraenitz
Differential Revision: https://reviews.llvm.org/D129936
Added:
llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc.test
llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc_neg_addend.test
Modified:
llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h
llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
llvm/lib/ExecutionEngine/JITLink/x86_64.cpp
llvm/test/ExecutionEngine/JITLink/X86/COFF_comdat_weak_duplicate.s
llvm/test/ExecutionEngine/JITLink/X86/COFF_external_var.s
llvm/test/ExecutionEngine/JITLink/X86/COFF_file_debug.s
llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
Removed:
llvm/test/ExecutionEngine/JITLink/X86/COFF_basic.s
llvm/test/ExecutionEngine/JITLink/X86/COFF_external_func.s
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h b/llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h
index 9a2bc9b09350e..d68dccac3fa98 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h
@@ -126,6 +126,24 @@ enum EdgeKind_x86_64 : Edge::Kind {
///
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 @@ enum EdgeKind_x86_64 : Edge::Kind {
/// - *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 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
break;
}
+ case PCRel32:
case BranchPCRel32:
case BranchPCRel32ToPtrJumpStub:
case BranchPCRel32ToPtrJumpStubBypassable:
diff --git a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
index 3c5542adb22f2..fd9c2d5683b34 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
@@ -18,13 +18,19 @@ static const char *CommonSectionName = "__common";
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<LinkGraph>(
- Obj.getFileName().str(), Triple(std::move(TT)), getPointerSize(Obj),
- getEndianness(Obj), std::move(GetEdgeKindName))) {
+ G(std::make_unique<LinkGraph>(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 @@ Error COFFLinkGraphBuilder::graphifySections() {
if (Expected<StringRef> 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 @@ Error COFFLinkGraphBuilder::graphifySections() {
<< "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 @@ Error COFFLinkGraphBuilder::calculateImplicitSizeOfSymbols() {
SecIndex <= static_cast<COFFSectionIndex>(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();
@@ -395,6 +395,17 @@ Expected<Symbol *> COFFLinkGraphBuilder::createDefinedSymbol(
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)) {
diff --git a/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
index 3d36ad1ed767d..2276a10616fd8 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp
@@ -26,6 +26,11 @@ using namespace llvm::jitlink;
namespace {
+enum EdgeKind_coff_x86_64 : Edge::Kind {
+ PCRel32 = x86_64::FirstPlatformRelocation,
+ Pointer32NB,
+};
+
class COFFJITLinker_x86_64 : public JITLinker<COFFJITLinker_x86_64> {
friend class JITLinker<COFFJITLinker_x86_64>;
@@ -43,27 +48,7 @@ class COFFJITLinker_x86_64 : public JITLinker<COFFJITLinker_x86_64> {
class COFFLinkGraphBuilder_x86_64 : public COFFLinkGraphBuilder {
private:
- uint64_t ImageBase = 0;
- enum COFFX86RelocationKind {
- COFFAddr32NB,
- COFFRel32,
- };
-
- static Expected<COFFX86RelocationKind>
- 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<JITLinkError>("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 @@ class COFFLinkGraphBuilder_x86_64 : public COFFLinkGraphBuilder {
return Error::success();
}
- uint64_t getImageBase() {
- if (!ImageBase) {
- ImageBase = std::numeric_limits<uint64_t>::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 @@ class COFFLinkGraphBuilder_x86_64 : public COFFLinkGraphBuilder {
SymIndex, FixupSect.getIndex()),
inconvertibleErrorCode());
- Expected<COFFX86RelocationKind> 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<const support::little32_t *>(FixupPtr);
break;
}
- case COFFRel32: {
- Kind = x86_64::BranchPCRel32;
+ case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_REL32: {
+ Kind = EdgeKind_coff_x86_64::PCRel32;
+ Addend = *reinterpret_cast<const support::little32_t *>(FixupPtr);
break;
}
+ case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_REL32_1: {
+ Kind = EdgeKind_coff_x86_64::PCRel32;
+ Addend = *reinterpret_cast<const support::little32_t *>(FixupPtr);
+ Addend -= 1;
+ break;
+ }
+ default: {
+ return make_error<JITLinkError>("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<JITTargetAddress> 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<AsyncLookupResult> 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 @@ Error buildTables_COFF_x86_64(LinkGraph &G) {
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<std::unique_ptr<LinkGraph>>
createLinkGraphFromCOFFObject_x86_64(MemoryBufferRef ObjectBuffer) {
LLVM_DEBUG({
@@ -199,11 +244,10 @@ void link_COFF_x86_64(std::unique_ptr<LinkGraph> G,
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))
diff --git a/llvm/lib/ExecutionEngine/JITLink/x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/x86_64.cpp
index df9979b47e888..393250a5578b7 100644
--- a/llvm/lib/ExecutionEngine/JITLink/x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/x86_64.cpp
@@ -36,6 +36,8 @@ const char *getEdgeKindName(Edge::Kind K) {
return "NegDelta32";
case Delta64FromGOT:
return "Delta64FromGOT";
+ case PCRel32:
+ return "PCRel32";
case BranchPCRel32:
return "BranchPCRel32";
case BranchPCRel32ToPtrJumpStub:
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc.test b/llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc.test
new file mode 100644
index 0000000000000..3c896f15f8da8
--- /dev/null
+++ b/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
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc_neg_addend.test b/llvm/test/ExecutionEngine/JITLink/X86/COFF_addr32nb_reloc_neg_addend.test
new file mode 100644
index 0000000000000..142c9b272f554
--- /dev/null
+++ b/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
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/COFF_basic.s b/llvm/test/ExecutionEngine/JITLink/X86/COFF_basic.s
deleted file mode 100644
index 1965c2820c123..0000000000000
--- a/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
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/COFF_comdat_weak_duplicate.s b/llvm/test/ExecutionEngine/JITLink/X86/COFF_comdat_weak_duplicate.s
index 6a0c0015ca729..a740ce1b41afc 100644
--- a/llvm/test/ExecutionEngine/JITLink/X86/COFF_comdat_weak_duplicate.s
+++ b/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
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/COFF_external_func.s b/llvm/test/ExecutionEngine/JITLink/X86/COFF_external_func.s
deleted file mode 100644
index 85cbaed863be3..0000000000000
--- a/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
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/COFF_external_var.s b/llvm/test/ExecutionEngine/JITLink/X86/COFF_external_var.s
index 95e29c4e63e4a..f7f17a5f8a1b4 100644
--- a/llvm/test/ExecutionEngine/JITLink/X86/COFF_external_var.s
+++ b/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
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/COFF_file_debug.s b/llvm/test/ExecutionEngine/JITLink/X86/COFF_file_debug.s
index dc438429f49fc..3980f81801ac2 100644
--- a/llvm/test/ExecutionEngine/JITLink/X86/COFF_file_debug.s
+++ b/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
diff --git a/llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s b/llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
index 1118cf74abaf2..ae9bf1f423dec 100644
--- a/llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
+++ b/llvm/test/ExecutionEngine/JITLink/X86/COFF_x86-64_small_pic_relocations.s
@@ -40,26 +40,6 @@ test_rel32_func:
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;
More information about the llvm-commits
mailing list