From 31e03317633909c50ead53edf8a19b60698075cc Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 3 Mar 2020 16:02:46 -0800 Subject: [PATCH] [ORC] Skip ST_File symbols in MaterializationUnit interfaces / resolution. ST_File symbols aren't relevant for linking purposes, but can end up shadowing real symbols if they're not filtered. No test case yet: The ideal testcase for this would be an ELF llvm-jitlink test, but llvm-jitlink support for ELF is still under development. We should add a testcase for this once support lands in tree. --- llvm/lib/ExecutionEngine/Orc/Mangling.cpp | 7 +++++++ llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/llvm/lib/ExecutionEngine/Orc/Mangling.cpp b/llvm/lib/ExecutionEngine/Orc/Mangling.cpp index 0f73eff..b21a0d7 100644 --- a/llvm/lib/ExecutionEngine/Orc/Mangling.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Mangling.cpp @@ -99,6 +99,13 @@ getObjectSymbolInfo(ExecutionSession &ES, MemoryBufferRef ObjBuffer) { if (!(Sym.getFlags() & object::BasicSymbolRef::SF_Global)) continue; + // Skip symbols that have type SF_File. + if (auto SymType = Sym.getType()) { + if (*SymType == object::SymbolRef::ST_File) + continue; + } else + return SymType.takeError(); + auto Name = Sym.getName(); if (!Name) return Name.takeError(); diff --git a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp index 895edf8..f51bd9d 100644 --- a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp @@ -116,6 +116,18 @@ void RTDyldObjectLinkingLayer::emit(MaterializationResponsibility R, auto InternalSymbols = std::make_shared>(); { for (auto &Sym : (*Obj)->symbols()) { + + // Skip file symbols. + if (auto SymType = Sym.getType()) { + if (*SymType == object::SymbolRef::ST_File) + continue; + } else { + ES.reportError(SymType.takeError()); + R.failMaterialization(); + return; + } + + // Don't include symbols that aren't global. if (!(Sym.getFlags() & object::BasicSymbolRef::SF_Global)) { if (auto SymName = Sym.getName()) InternalSymbols->insert(*SymName); -- 2.7.4