2011-03-19 01:11:39 +08:00
|
|
|
//===-- llvm-rtdyld.cpp - MCJIT Testing Tool ------------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-03-19 01:11:39 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This is a testing tool for use with the MC-JIT LLVM components.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-04 18:44:52 +08:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
2015-04-24 01:37:47 +08:00
|
|
|
#include "llvm/DebugInfo/DIContext.h"
|
|
|
|
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
[MCJIT][Orc] Refactor RTDyldMemoryManager, weave RuntimeDyld::SymbolInfo through
MCJIT.
This patch decouples the two responsibilities of the RTDyldMemoryManager class,
memory management and symbol resolution, into two new classes:
RuntimeDyld::MemoryManager and RuntimeDyld::SymbolResolver.
The symbol resolution interface is modified slightly, from:
uint64_t getSymbolAddress(const std::string &Name);
to:
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name);
The latter passes symbol flags along with symbol addresses, allowing RuntimeDyld
and others to reason about non-strong/non-exported symbols.
The memory management interface removes the following method:
void notifyObjectLoaded(ExecutionEngine *EE,
const object::ObjectFile &) {}
as it is not related to memory management. (Note: Backwards compatibility *is*
maintained for this method in MCJIT and OrcMCJITReplacement, see below).
The RTDyldMemoryManager class remains in-tree for backwards compatibility.
It inherits directly from RuntimeDyld::SymbolResolver, and indirectly from
RuntimeDyld::MemoryManager via the new MCJITMemoryManager class, which
just subclasses RuntimeDyld::MemoryManager and reintroduces the
notifyObjectLoaded method for backwards compatibility).
The EngineBuilder class retains the existing method:
EngineBuilder&
setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm);
and includes two new methods:
EngineBuilder&
setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM);
EngineBuilder&
setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR);
Clients should use EITHER:
A single call to setMCJITMemoryManager with an RTDyldMemoryManager.
OR (exclusive)
One call each to each of setMemoryManager and setSymbolResolver.
This patch should be fully compatible with existing uses of RTDyldMemoryManager.
If it is not it should be considered a bug, and the patch either fixed or
reverted.
If clients find the new API to be an improvement the goal will be to deprecate
and eventually remove the RTDyldMemoryManager class in favor of the new classes.
llvm-svn: 233509
2015-03-30 11:37:06 +08:00
|
|
|
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
|
2012-12-04 18:44:52 +08:00
|
|
|
#include "llvm/ExecutionEngine/RuntimeDyld.h"
|
2014-06-28 04:20:57 +08:00
|
|
|
#include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
|
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
|
|
|
#include "llvm/MC/MCContext.h"
|
2016-01-27 00:44:37 +08:00
|
|
|
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
|
2014-06-28 04:20:57 +08:00
|
|
|
#include "llvm/MC/MCInstPrinter.h"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
2014-06-28 04:20:57 +08:00
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
2015-05-16 05:58:42 +08:00
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
2019-10-23 18:24:35 +08:00
|
|
|
#include "llvm/MC/MCTargetOptions.h"
|
2015-06-23 10:08:48 +08:00
|
|
|
#include "llvm/Object/SymbolSize.h"
|
2011-03-19 01:11:39 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2014-05-14 06:37:41 +08:00
|
|
|
#include "llvm/Support/DynamicLibrary.h"
|
2021-04-21 22:00:30 +08:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
2018-04-14 02:26:06 +08:00
|
|
|
#include "llvm/Support/InitLLVM.h"
|
2019-09-05 04:26:25 +08:00
|
|
|
#include "llvm/Support/MSVCErrorWorkarounds.h"
|
2011-03-19 01:11:39 +08:00
|
|
|
#include "llvm/Support/Memory.h"
|
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
2019-04-09 05:50:48 +08:00
|
|
|
#include "llvm/Support/Path.h"
|
2014-06-28 04:20:57 +08:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
#include "llvm/Support/TargetSelect.h"
|
2019-09-05 04:26:25 +08:00
|
|
|
#include "llvm/Support/Timer.h"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2019-04-09 05:50:48 +08:00
|
|
|
|
|
|
|
#include <future>
|
2014-09-04 12:19:54 +08:00
|
|
|
#include <list>
|
2014-06-28 04:20:57 +08:00
|
|
|
|
2011-03-19 01:11:39 +08:00
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::object;
|
|
|
|
|
2021-07-21 18:03:05 +08:00
|
|
|
static cl::OptionCategory RTDyldCategory("RTDyld Options");
|
|
|
|
|
|
|
|
static cl::list<std::string> InputFileList(cl::Positional, cl::ZeroOrMore,
|
|
|
|
cl::desc("<input files>"),
|
|
|
|
cl::cat(RTDyldCategory));
|
2011-03-19 01:11:39 +08:00
|
|
|
|
|
|
|
enum ActionType {
|
2013-01-26 06:50:58 +08:00
|
|
|
AC_Execute,
|
2015-05-31 03:44:53 +08:00
|
|
|
AC_PrintObjectLineInfo,
|
2014-06-28 04:20:57 +08:00
|
|
|
AC_PrintLineInfo,
|
2015-05-22 05:24:32 +08:00
|
|
|
AC_PrintDebugLineInfo,
|
2014-06-28 04:20:57 +08:00
|
|
|
AC_Verify
|
2011-03-19 01:11:39 +08:00
|
|
|
};
|
|
|
|
|
2021-07-21 18:03:05 +08:00
|
|
|
static cl::opt<ActionType> Action(
|
|
|
|
cl::desc("Action to perform:"), cl::init(AC_Execute),
|
|
|
|
cl::values(
|
|
|
|
clEnumValN(AC_Execute, "execute",
|
|
|
|
"Load, link, and execute the inputs."),
|
|
|
|
clEnumValN(AC_PrintLineInfo, "printline",
|
|
|
|
"Load, link, and print line information for each function."),
|
|
|
|
clEnumValN(AC_PrintDebugLineInfo, "printdebugline",
|
|
|
|
"Load, link, and print line information for each function "
|
|
|
|
"using the debug object"),
|
|
|
|
clEnumValN(AC_PrintObjectLineInfo, "printobjline",
|
|
|
|
"Like -printlineinfo but does not load the object first"),
|
|
|
|
clEnumValN(AC_Verify, "verify",
|
|
|
|
"Load, link and verify the resulting memory image.")),
|
|
|
|
cl::cat(RTDyldCategory));
|
2011-03-19 01:11:39 +08:00
|
|
|
|
2011-04-13 23:38:30 +08:00
|
|
|
static cl::opt<std::string>
|
2021-07-21 18:03:05 +08:00
|
|
|
EntryPoint("entry", cl::desc("Function to call as entry point."),
|
|
|
|
cl::init("_main"), cl::cat(RTDyldCategory));
|
2011-04-13 23:38:30 +08:00
|
|
|
|
2021-07-21 18:03:05 +08:00
|
|
|
static cl::list<std::string> Dylibs("dylib", cl::desc("Add library."),
|
|
|
|
cl::ZeroOrMore, cl::cat(RTDyldCategory));
|
2014-05-14 06:37:41 +08:00
|
|
|
|
2019-04-25 13:02:10 +08:00
|
|
|
static cl::list<std::string> InputArgv("args", cl::Positional,
|
|
|
|
cl::desc("<program arguments>..."),
|
2021-07-21 18:03:05 +08:00
|
|
|
cl::ZeroOrMore, cl::PositionalEatsArgs,
|
|
|
|
cl::cat(RTDyldCategory));
|
2019-04-25 13:02:10 +08:00
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
static cl::opt<std::string>
|
2021-07-21 18:03:05 +08:00
|
|
|
TripleName("triple", cl::desc("Target triple for disassembler"),
|
|
|
|
cl::cat(RTDyldCategory));
|
2014-06-28 04:20:57 +08:00
|
|
|
|
2015-06-24 06:52:19 +08:00
|
|
|
static cl::opt<std::string>
|
2021-07-21 18:03:05 +08:00
|
|
|
MCPU("mcpu",
|
|
|
|
cl::desc("Target a specific cpu type (-mcpu=help for details)"),
|
|
|
|
cl::value_desc("cpu-name"), cl::init(""), cl::cat(RTDyldCategory));
|
2015-06-24 06:52:19 +08:00
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
static cl::list<std::string>
|
2021-07-21 18:03:05 +08:00
|
|
|
CheckFiles("check",
|
|
|
|
cl::desc("File containing RuntimeDyld verifier checks."),
|
|
|
|
cl::ZeroOrMore, cl::cat(RTDyldCategory));
|
2014-06-28 04:20:57 +08:00
|
|
|
|
2019-04-24 10:40:20 +08:00
|
|
|
static cl::opt<uint64_t>
|
|
|
|
PreallocMemory("preallocate",
|
|
|
|
cl::desc("Allocate memory upfront rather than on-demand"),
|
2021-07-21 18:03:05 +08:00
|
|
|
cl::init(0), cl::cat(RTDyldCategory));
|
2019-04-24 10:40:20 +08:00
|
|
|
|
|
|
|
static cl::opt<uint64_t> TargetAddrStart(
|
|
|
|
"target-addr-start",
|
|
|
|
cl::desc("For -verify only: start of phony target address "
|
|
|
|
"range."),
|
|
|
|
cl::init(4096), // Start at "page 1" - no allocating at "null".
|
2021-07-21 18:03:05 +08:00
|
|
|
cl::Hidden, cl::cat(RTDyldCategory));
|
2019-04-24 10:40:20 +08:00
|
|
|
|
|
|
|
static cl::opt<uint64_t> TargetAddrEnd(
|
|
|
|
"target-addr-end",
|
|
|
|
cl::desc("For -verify only: end of phony target address range."),
|
2021-07-21 18:03:05 +08:00
|
|
|
cl::init(~0ULL), cl::Hidden, cl::cat(RTDyldCategory));
|
2019-04-24 10:40:20 +08:00
|
|
|
|
|
|
|
static cl::opt<uint64_t> TargetSectionSep(
|
|
|
|
"target-section-sep",
|
|
|
|
cl::desc("For -verify only: Separation between sections in "
|
|
|
|
"phony target address space."),
|
2021-07-21 18:03:05 +08:00
|
|
|
cl::init(0), cl::Hidden, cl::cat(RTDyldCategory));
|
2015-07-04 09:35:26 +08:00
|
|
|
|
|
|
|
static cl::list<std::string>
|
2021-07-21 18:03:05 +08:00
|
|
|
SpecificSectionMappings("map-section",
|
|
|
|
cl::desc("For -verify only: Map a section to a "
|
|
|
|
"specific address."),
|
|
|
|
cl::ZeroOrMore, cl::Hidden,
|
|
|
|
cl::cat(RTDyldCategory));
|
|
|
|
|
|
|
|
static cl::list<std::string> DummySymbolMappings(
|
|
|
|
"dummy-extern",
|
|
|
|
cl::desc("For -verify only: Inject a symbol into the extern "
|
|
|
|
"symbol table."),
|
|
|
|
cl::ZeroOrMore, cl::Hidden, cl::cat(RTDyldCategory));
|
|
|
|
|
|
|
|
static cl::opt<bool> PrintAllocationRequests(
|
|
|
|
"print-alloc-requests",
|
|
|
|
cl::desc("Print allocation requests made to the memory "
|
|
|
|
"manager by RuntimeDyld"),
|
|
|
|
cl::Hidden, cl::cat(RTDyldCategory));
|
2015-11-24 05:47:51 +08:00
|
|
|
|
2019-09-05 04:26:25 +08:00
|
|
|
static cl::opt<bool> ShowTimes("show-times",
|
|
|
|
cl::desc("Show times for llvm-rtdyld phases"),
|
2021-07-21 18:03:05 +08:00
|
|
|
cl::init(false), cl::cat(RTDyldCategory));
|
2019-09-05 04:26:25 +08:00
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
ExitOnError ExitOnErr;
|
|
|
|
|
2019-09-05 04:26:25 +08:00
|
|
|
struct RTDyldTimers {
|
2019-09-05 04:26:26 +08:00
|
|
|
TimerGroup RTDyldTG{"llvm-rtdyld timers", "timers for llvm-rtdyld phases"};
|
|
|
|
Timer LoadObjectsTimer{"load", "time to load/add object files", RTDyldTG};
|
|
|
|
Timer LinkTimer{"link", "time to link object files", RTDyldTG};
|
|
|
|
Timer RunTimer{"run", "time to execute jitlink'd code", RTDyldTG};
|
2019-09-05 04:26:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr<RTDyldTimers> Timers;
|
|
|
|
|
2011-03-19 01:11:39 +08:00
|
|
|
/* *** */
|
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
using SectionIDMap = StringMap<unsigned>;
|
|
|
|
using FileToSectionIDMap = StringMap<SectionIDMap>;
|
|
|
|
|
|
|
|
void dumpFileToSectionIDMap(const FileToSectionIDMap &FileToSecIDMap) {
|
|
|
|
for (const auto &KV : FileToSecIDMap) {
|
|
|
|
llvm::dbgs() << "In " << KV.first() << "\n";
|
|
|
|
for (auto &KV2 : KV.second)
|
|
|
|
llvm::dbgs() << " \"" << KV2.first() << "\" -> " << KV2.second << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Expected<unsigned> getSectionId(const FileToSectionIDMap &FileToSecIDMap,
|
|
|
|
StringRef FileName, StringRef SectionName) {
|
|
|
|
auto I = FileToSecIDMap.find(FileName);
|
|
|
|
if (I == FileToSecIDMap.end())
|
|
|
|
return make_error<StringError>("No file named " + FileName,
|
|
|
|
inconvertibleErrorCode());
|
|
|
|
auto &SectionIDs = I->second;
|
|
|
|
auto J = SectionIDs.find(SectionName);
|
|
|
|
if (J == SectionIDs.end())
|
|
|
|
return make_error<StringError>("No section named \"" + SectionName +
|
|
|
|
"\" in file " + FileName,
|
|
|
|
inconvertibleErrorCode());
|
|
|
|
return J->second;
|
|
|
|
}
|
|
|
|
|
2011-04-05 07:04:39 +08:00
|
|
|
// A trivial memory manager that doesn't do anything fancy, just uses the
|
|
|
|
// support library allocation routines directly.
|
|
|
|
class TrivialMemoryManager : public RTDyldMemoryManager {
|
|
|
|
public:
|
2019-04-09 05:50:48 +08:00
|
|
|
struct SectionInfo {
|
|
|
|
SectionInfo(StringRef Name, sys::MemoryBlock MB, unsigned SectionID)
|
2020-01-29 03:23:46 +08:00
|
|
|
: Name(std::string(Name)), MB(std::move(MB)), SectionID(SectionID) {}
|
2019-04-09 05:50:48 +08:00
|
|
|
std::string Name;
|
|
|
|
sys::MemoryBlock MB;
|
|
|
|
unsigned SectionID = ~0U;
|
|
|
|
};
|
|
|
|
|
|
|
|
SmallVector<SectionInfo, 16> FunctionMemory;
|
|
|
|
SmallVector<SectionInfo, 16> DataMemory;
|
2012-01-17 06:26:39 +08:00
|
|
|
|
|
|
|
uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
|
2014-03-08 16:27:28 +08:00
|
|
|
unsigned SectionID,
|
|
|
|
StringRef SectionName) override;
|
2012-01-17 06:26:39 +08:00
|
|
|
uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
|
2013-10-02 08:59:25 +08:00
|
|
|
unsigned SectionID, StringRef SectionName,
|
2014-03-08 16:27:28 +08:00
|
|
|
bool IsReadOnly) override;
|
2011-04-12 08:23:32 +08:00
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
/// If non null, records subsequent Name -> SectionID mappings.
|
|
|
|
void setSectionIDsMap(SectionIDMap *SecIDMap) {
|
|
|
|
this->SecIDMap = SecIDMap;
|
|
|
|
}
|
|
|
|
|
2014-03-08 16:27:28 +08:00
|
|
|
void *getPointerToNamedFunction(const std::string &Name,
|
|
|
|
bool AbortOnFailure = true) override {
|
2014-04-25 12:24:47 +08:00
|
|
|
return nullptr;
|
2012-03-29 05:46:36 +08:00
|
|
|
}
|
|
|
|
|
2014-03-08 16:27:28 +08:00
|
|
|
bool finalizeMemory(std::string *ErrMsg) override { return false; }
|
2012-11-16 07:50:01 +08:00
|
|
|
|
2015-07-04 09:35:26 +08:00
|
|
|
void addDummySymbol(const std::string &Name, uint64_t Addr) {
|
|
|
|
DummyExterns[Name] = Addr;
|
|
|
|
}
|
|
|
|
|
2016-08-02 04:49:11 +08:00
|
|
|
JITSymbol findSymbol(const std::string &Name) override {
|
2015-07-04 09:35:26 +08:00
|
|
|
auto I = DummyExterns.find(Name);
|
|
|
|
|
|
|
|
if (I != DummyExterns.end())
|
2016-08-02 04:49:11 +08:00
|
|
|
return JITSymbol(I->second, JITSymbolFlags::Exported);
|
2015-07-04 09:35:26 +08:00
|
|
|
|
2019-04-25 13:02:10 +08:00
|
|
|
if (auto Sym = RTDyldMemoryManager::findSymbol(Name))
|
|
|
|
return Sym;
|
|
|
|
else if (auto Err = Sym.takeError())
|
|
|
|
ExitOnErr(std::move(Err));
|
|
|
|
else
|
|
|
|
ExitOnErr(make_error<StringError>("Could not find definition for \"" +
|
|
|
|
Name + "\"",
|
|
|
|
inconvertibleErrorCode()));
|
|
|
|
llvm_unreachable("Should have returned or exited by now");
|
2015-07-04 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
2015-06-04 02:26:52 +08:00
|
|
|
void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr,
|
|
|
|
size_t Size) override {}
|
2017-05-10 05:32:18 +08:00
|
|
|
void deregisterEHFrames() override {}
|
2015-10-22 06:12:03 +08:00
|
|
|
|
|
|
|
void preallocateSlab(uint64_t Size) {
|
2017-11-17 07:04:44 +08:00
|
|
|
std::error_code EC;
|
|
|
|
sys::MemoryBlock MB =
|
|
|
|
sys::Memory::allocateMappedMemory(Size, nullptr,
|
|
|
|
sys::Memory::MF_READ |
|
|
|
|
sys::Memory::MF_WRITE,
|
|
|
|
EC);
|
2015-10-22 06:12:03 +08:00
|
|
|
if (!MB.base())
|
2017-11-17 07:04:44 +08:00
|
|
|
report_fatal_error("Can't allocate enough memory: " + EC.message());
|
2015-10-22 06:12:03 +08:00
|
|
|
|
|
|
|
PreallocSlab = MB;
|
|
|
|
UsePreallocation = true;
|
|
|
|
SlabSize = Size;
|
|
|
|
}
|
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
uint8_t *allocateFromSlab(uintptr_t Size, unsigned Alignment, bool isCode,
|
|
|
|
StringRef SectionName, unsigned SectionID) {
|
2016-01-15 05:06:47 +08:00
|
|
|
Size = alignTo(Size, Alignment);
|
2015-10-22 06:12:03 +08:00
|
|
|
if (CurrentSlabOffset + Size > SlabSize)
|
|
|
|
report_fatal_error("Can't allocate enough memory. Tune --preallocate");
|
|
|
|
|
|
|
|
uintptr_t OldSlabOffset = CurrentSlabOffset;
|
|
|
|
sys::MemoryBlock MB((void *)OldSlabOffset, Size);
|
|
|
|
if (isCode)
|
2019-04-09 05:50:48 +08:00
|
|
|
FunctionMemory.push_back(SectionInfo(SectionName, MB, SectionID));
|
2015-10-22 06:12:03 +08:00
|
|
|
else
|
2019-04-09 05:50:48 +08:00
|
|
|
DataMemory.push_back(SectionInfo(SectionName, MB, SectionID));
|
2015-10-22 06:12:03 +08:00
|
|
|
CurrentSlabOffset += Size;
|
|
|
|
return (uint8_t*)OldSlabOffset;
|
|
|
|
}
|
|
|
|
|
2015-07-04 09:35:26 +08:00
|
|
|
private:
|
|
|
|
std::map<std::string, uint64_t> DummyExterns;
|
2015-10-22 06:12:03 +08:00
|
|
|
sys::MemoryBlock PreallocSlab;
|
|
|
|
bool UsePreallocation = false;
|
|
|
|
uintptr_t SlabSize = 0;
|
|
|
|
uintptr_t CurrentSlabOffset = 0;
|
2019-04-09 05:50:48 +08:00
|
|
|
SectionIDMap *SecIDMap = nullptr;
|
2011-04-05 07:04:39 +08:00
|
|
|
};
|
|
|
|
|
2012-01-17 06:26:39 +08:00
|
|
|
uint8_t *TrivialMemoryManager::allocateCodeSection(uintptr_t Size,
|
|
|
|
unsigned Alignment,
|
2013-10-02 08:59:25 +08:00
|
|
|
unsigned SectionID,
|
|
|
|
StringRef SectionName) {
|
2015-11-24 05:47:51 +08:00
|
|
|
if (PrintAllocationRequests)
|
|
|
|
outs() << "allocateCodeSection(Size = " << Size << ", Alignment = "
|
|
|
|
<< Alignment << ", SectionName = " << SectionName << ")\n";
|
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
if (SecIDMap)
|
|
|
|
(*SecIDMap)[SectionName] = SectionID;
|
|
|
|
|
2015-10-22 06:12:03 +08:00
|
|
|
if (UsePreallocation)
|
2019-04-09 05:50:48 +08:00
|
|
|
return allocateFromSlab(Size, Alignment, true /* isCode */,
|
|
|
|
SectionName, SectionID);
|
2015-10-22 06:12:03 +08:00
|
|
|
|
2017-11-17 07:04:44 +08:00
|
|
|
std::error_code EC;
|
|
|
|
sys::MemoryBlock MB =
|
|
|
|
sys::Memory::allocateMappedMemory(Size, nullptr,
|
|
|
|
sys::Memory::MF_READ |
|
|
|
|
sys::Memory::MF_WRITE,
|
|
|
|
EC);
|
2015-10-15 08:05:32 +08:00
|
|
|
if (!MB.base())
|
2017-11-17 07:04:44 +08:00
|
|
|
report_fatal_error("MemoryManager allocation failed: " + EC.message());
|
2019-04-09 05:50:48 +08:00
|
|
|
FunctionMemory.push_back(SectionInfo(SectionName, MB, SectionID));
|
2012-05-17 02:50:11 +08:00
|
|
|
return (uint8_t*)MB.base();
|
2012-01-17 06:26:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t *TrivialMemoryManager::allocateDataSection(uintptr_t Size,
|
|
|
|
unsigned Alignment,
|
2012-11-16 07:50:01 +08:00
|
|
|
unsigned SectionID,
|
2013-10-02 08:59:25 +08:00
|
|
|
StringRef SectionName,
|
2012-11-16 07:50:01 +08:00
|
|
|
bool IsReadOnly) {
|
2015-11-24 05:47:51 +08:00
|
|
|
if (PrintAllocationRequests)
|
|
|
|
outs() << "allocateDataSection(Size = " << Size << ", Alignment = "
|
|
|
|
<< Alignment << ", SectionName = " << SectionName << ")\n";
|
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
if (SecIDMap)
|
|
|
|
(*SecIDMap)[SectionName] = SectionID;
|
|
|
|
|
2015-10-22 06:12:03 +08:00
|
|
|
if (UsePreallocation)
|
2019-04-09 05:50:48 +08:00
|
|
|
return allocateFromSlab(Size, Alignment, false /* isCode */, SectionName,
|
|
|
|
SectionID);
|
2015-10-22 06:12:03 +08:00
|
|
|
|
2017-11-17 07:04:44 +08:00
|
|
|
std::error_code EC;
|
|
|
|
sys::MemoryBlock MB =
|
|
|
|
sys::Memory::allocateMappedMemory(Size, nullptr,
|
|
|
|
sys::Memory::MF_READ |
|
|
|
|
sys::Memory::MF_WRITE,
|
|
|
|
EC);
|
2015-10-15 08:05:32 +08:00
|
|
|
if (!MB.base())
|
2017-11-17 07:04:44 +08:00
|
|
|
report_fatal_error("MemoryManager allocation failed: " + EC.message());
|
2019-04-09 05:50:48 +08:00
|
|
|
DataMemory.push_back(SectionInfo(SectionName, MB, SectionID));
|
2012-05-17 02:50:11 +08:00
|
|
|
return (uint8_t*)MB.base();
|
|
|
|
}
|
|
|
|
|
2011-03-19 01:11:39 +08:00
|
|
|
static const char *ProgramName;
|
|
|
|
|
2016-04-06 04:11:24 +08:00
|
|
|
static void ErrorAndExit(const Twine &Msg) {
|
2015-11-21 07:12:15 +08:00
|
|
|
errs() << ProgramName << ": error: " << Msg << "\n";
|
2016-03-26 01:25:34 +08:00
|
|
|
exit(1);
|
2011-03-19 01:11:39 +08:00
|
|
|
}
|
|
|
|
|
2014-05-14 06:37:41 +08:00
|
|
|
static void loadDylibs() {
|
|
|
|
for (const std::string &Dylib : Dylibs) {
|
2015-11-22 09:58:33 +08:00
|
|
|
if (!sys::fs::is_regular_file(Dylib))
|
2015-11-21 13:58:19 +08:00
|
|
|
report_fatal_error("Dylib not found: '" + Dylib + "'.");
|
2015-11-22 09:58:33 +08:00
|
|
|
std::string ErrMsg;
|
|
|
|
if (sys::DynamicLibrary::LoadLibraryPermanently(Dylib.c_str(), &ErrMsg))
|
|
|
|
report_fatal_error("Error loading '" + Dylib + "': " + ErrMsg);
|
2014-05-14 06:37:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-19 01:11:39 +08:00
|
|
|
/* *** */
|
2011-03-19 02:54:32 +08:00
|
|
|
|
2015-05-22 05:24:32 +08:00
|
|
|
static int printLineInfoForInput(bool LoadObjects, bool UseDebugObj) {
|
|
|
|
assert(LoadObjects || !UseDebugObj);
|
|
|
|
|
2014-05-14 06:37:41 +08:00
|
|
|
// Load any dylibs requested on the command line.
|
|
|
|
loadDylibs();
|
|
|
|
|
2013-01-26 06:50:58 +08:00
|
|
|
// If we don't have any input files, read from stdin.
|
|
|
|
if (!InputFileList.size())
|
|
|
|
InputFileList.push_back("-");
|
2015-10-12 08:57:29 +08:00
|
|
|
for (auto &File : InputFileList) {
|
2013-01-26 06:50:58 +08:00
|
|
|
// Instantiate a dynamic linker.
|
2013-08-04 06:16:31 +08:00
|
|
|
TrivialMemoryManager MemMgr;
|
[MCJIT][Orc] Refactor RTDyldMemoryManager, weave RuntimeDyld::SymbolInfo through
MCJIT.
This patch decouples the two responsibilities of the RTDyldMemoryManager class,
memory management and symbol resolution, into two new classes:
RuntimeDyld::MemoryManager and RuntimeDyld::SymbolResolver.
The symbol resolution interface is modified slightly, from:
uint64_t getSymbolAddress(const std::string &Name);
to:
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name);
The latter passes symbol flags along with symbol addresses, allowing RuntimeDyld
and others to reason about non-strong/non-exported symbols.
The memory management interface removes the following method:
void notifyObjectLoaded(ExecutionEngine *EE,
const object::ObjectFile &) {}
as it is not related to memory management. (Note: Backwards compatibility *is*
maintained for this method in MCJIT and OrcMCJITReplacement, see below).
The RTDyldMemoryManager class remains in-tree for backwards compatibility.
It inherits directly from RuntimeDyld::SymbolResolver, and indirectly from
RuntimeDyld::MemoryManager via the new MCJITMemoryManager class, which
just subclasses RuntimeDyld::MemoryManager and reintroduces the
notifyObjectLoaded method for backwards compatibility).
The EngineBuilder class retains the existing method:
EngineBuilder&
setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm);
and includes two new methods:
EngineBuilder&
setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM);
EngineBuilder&
setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR);
Clients should use EITHER:
A single call to setMCJITMemoryManager with an RTDyldMemoryManager.
OR (exclusive)
One call each to each of setMemoryManager and setSymbolResolver.
This patch should be fully compatible with existing uses of RTDyldMemoryManager.
If it is not it should be considered a bug, and the patch either fixed or
reverted.
If clients find the new API to be an improvement the goal will be to deprecate
and eventually remove the RTDyldMemoryManager class in favor of the new classes.
llvm-svn: 233509
2015-03-30 11:37:06 +08:00
|
|
|
RuntimeDyld Dyld(MemMgr, MemMgr);
|
2013-01-26 06:50:58 +08:00
|
|
|
|
|
|
|
// Load the input memory buffer.
|
|
|
|
|
2014-07-07 01:43:13 +08:00
|
|
|
ErrorOr<std::unique_ptr<MemoryBuffer>> InputBuffer =
|
2015-10-12 08:57:29 +08:00
|
|
|
MemoryBuffer::getFileOrSTDIN(File);
|
2014-07-07 01:43:13 +08:00
|
|
|
if (std::error_code EC = InputBuffer.getError())
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("unable to read input: '" + EC.message() + "'");
|
2014-07-07 01:43:13 +08:00
|
|
|
|
2016-04-07 06:14:09 +08:00
|
|
|
Expected<std::unique_ptr<ObjectFile>> MaybeObj(
|
2014-11-27 00:54:40 +08:00
|
|
|
ObjectFile::createObjectFile((*InputBuffer)->getMemBufferRef()));
|
|
|
|
|
2016-04-07 06:14:09 +08:00
|
|
|
if (!MaybeObj) {
|
|
|
|
std::string Buf;
|
|
|
|
raw_string_ostream OS(Buf);
|
2018-11-11 09:46:03 +08:00
|
|
|
logAllUnhandledErrors(MaybeObj.takeError(), OS);
|
2016-04-07 06:14:09 +08:00
|
|
|
OS.flush();
|
|
|
|
ErrorAndExit("unable to create object file: '" + Buf + "'");
|
|
|
|
}
|
2014-11-27 00:54:40 +08:00
|
|
|
|
|
|
|
ObjectFile &Obj = **MaybeObj;
|
|
|
|
|
2015-05-22 05:24:32 +08:00
|
|
|
OwningBinary<ObjectFile> DebugObj;
|
|
|
|
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> LoadedObjInfo = nullptr;
|
|
|
|
ObjectFile *SymbolObj = &Obj;
|
|
|
|
if (LoadObjects) {
|
|
|
|
// Load the object file
|
|
|
|
LoadedObjInfo =
|
|
|
|
Dyld.loadObject(Obj);
|
2014-11-27 00:54:40 +08:00
|
|
|
|
2015-05-22 05:24:32 +08:00
|
|
|
if (Dyld.hasError())
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit(Dyld.getErrorString());
|
2013-01-26 06:50:58 +08:00
|
|
|
|
2015-05-22 05:24:32 +08:00
|
|
|
// Resolve all the relocations we can.
|
|
|
|
Dyld.resolveRelocations();
|
2013-01-26 06:50:58 +08:00
|
|
|
|
2015-05-22 05:24:32 +08:00
|
|
|
if (UseDebugObj) {
|
|
|
|
DebugObj = LoadedObjInfo->getObjectForDebug(Obj);
|
|
|
|
SymbolObj = DebugObj.getBinary();
|
2015-07-29 04:51:53 +08:00
|
|
|
LoadedObjInfo.reset();
|
2015-05-22 05:24:32 +08:00
|
|
|
}
|
|
|
|
}
|
2014-11-27 00:54:40 +08:00
|
|
|
|
2021-08-03 01:41:35 +08:00
|
|
|
std::unique_ptr<DIContext> Context = DWARFContext::create(
|
|
|
|
*SymbolObj, DWARFContext::ProcessDebugRelocations::Process,
|
|
|
|
LoadedObjInfo.get());
|
2013-01-26 06:50:58 +08:00
|
|
|
|
2015-06-25 03:57:32 +08:00
|
|
|
std::vector<std::pair<SymbolRef, uint64_t>> SymAddr =
|
2015-06-23 10:08:48 +08:00
|
|
|
object::computeSymbolSizes(*SymbolObj);
|
2015-06-01 07:15:35 +08:00
|
|
|
|
2013-01-26 06:50:58 +08:00
|
|
|
// Use symbol info to iterate functions in the object.
|
2015-06-25 03:57:32 +08:00
|
|
|
for (const auto &P : SymAddr) {
|
2015-06-23 10:08:48 +08:00
|
|
|
object::SymbolRef Sym = P.first;
|
2016-05-03 04:28:12 +08:00
|
|
|
Expected<SymbolRef::Type> TypeOrErr = Sym.getType();
|
|
|
|
if (!TypeOrErr) {
|
|
|
|
// TODO: Actually report errors helpfully.
|
|
|
|
consumeError(TypeOrErr.takeError());
|
2016-03-24 04:27:00 +08:00
|
|
|
continue;
|
2016-05-03 04:28:12 +08:00
|
|
|
}
|
2016-03-24 04:27:00 +08:00
|
|
|
SymbolRef::Type Type = *TypeOrErr;
|
|
|
|
if (Type == object::SymbolRef::ST_Function) {
|
2016-04-21 05:24:34 +08:00
|
|
|
Expected<StringRef> Name = Sym.getName();
|
|
|
|
if (!Name) {
|
|
|
|
// TODO: Actually report errors helpfully.
|
|
|
|
consumeError(Name.takeError());
|
2015-06-01 06:13:51 +08:00
|
|
|
continue;
|
2016-04-21 05:24:34 +08:00
|
|
|
}
|
2016-06-25 02:24:42 +08:00
|
|
|
Expected<uint64_t> AddrOrErr = Sym.getAddress();
|
|
|
|
if (!AddrOrErr) {
|
|
|
|
// TODO: Actually report errors helpfully.
|
|
|
|
consumeError(AddrOrErr.takeError());
|
2015-06-01 06:13:51 +08:00
|
|
|
continue;
|
2016-06-25 02:24:42 +08:00
|
|
|
}
|
2015-07-04 02:19:00 +08:00
|
|
|
uint64_t Addr = *AddrOrErr;
|
2015-06-01 07:15:35 +08:00
|
|
|
|
2019-02-27 21:17:36 +08:00
|
|
|
object::SectionedAddress Address;
|
|
|
|
|
2015-06-23 10:08:48 +08:00
|
|
|
uint64_t Size = P.second;
|
2015-05-22 05:24:32 +08:00
|
|
|
// If we're not using the debug object, compute the address of the
|
|
|
|
// symbol in memory (rather than that in the unrelocated object file)
|
|
|
|
// and use that to query the DWARFContext.
|
|
|
|
if (!UseDebugObj && LoadObjects) {
|
2016-05-03 04:28:12 +08:00
|
|
|
auto SecOrErr = Sym.getSection();
|
|
|
|
if (!SecOrErr) {
|
|
|
|
// TODO: Actually report errors helpfully.
|
|
|
|
consumeError(SecOrErr.takeError());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
object::section_iterator Sec = *SecOrErr;
|
2019-02-27 21:17:36 +08:00
|
|
|
Address.SectionIndex = Sec->getIndex();
|
2015-05-22 05:24:32 +08:00
|
|
|
uint64_t SectionLoadAddress =
|
2015-07-29 01:52:11 +08:00
|
|
|
LoadedObjInfo->getSectionLoadAddress(*Sec);
|
2015-05-22 05:24:32 +08:00
|
|
|
if (SectionLoadAddress != 0)
|
|
|
|
Addr += SectionLoadAddress - Sec->getAddress();
|
2019-02-27 21:17:36 +08:00
|
|
|
} else if (auto SecOrErr = Sym.getSection())
|
|
|
|
Address.SectionIndex = SecOrErr.get()->getIndex();
|
2015-05-22 05:24:32 +08:00
|
|
|
|
2015-07-03 04:55:21 +08:00
|
|
|
outs() << "Function: " << *Name << ", Size = " << Size
|
|
|
|
<< ", Addr = " << Addr << "\n";
|
2013-01-26 06:50:58 +08:00
|
|
|
|
2019-02-27 21:17:36 +08:00
|
|
|
Address.Address = Addr;
|
|
|
|
DILineInfoTable Lines =
|
|
|
|
Context->getLineInfoForAddressRange(Address, Size);
|
2015-10-12 08:57:29 +08:00
|
|
|
for (auto &D : Lines) {
|
|
|
|
outs() << " Line info @ " << D.first - Addr << ": "
|
|
|
|
<< D.second.FileName << ", line:" << D.second.Line << "\n";
|
2013-01-26 08:28:05 +08:00
|
|
|
}
|
2013-01-26 06:50:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-22 06:12:03 +08:00
|
|
|
static void doPreallocation(TrivialMemoryManager &MemMgr) {
|
|
|
|
// Allocate a slab of memory upfront, if required. This is used if
|
|
|
|
// we want to test small code models.
|
|
|
|
if (static_cast<intptr_t>(PreallocMemory) < 0)
|
|
|
|
report_fatal_error("Pre-allocated bytes of memory must be a positive integer.");
|
|
|
|
|
|
|
|
// FIXME: Limit the amount of memory that can be preallocated?
|
|
|
|
if (PreallocMemory != 0)
|
|
|
|
MemMgr.preallocateSlab(PreallocMemory);
|
|
|
|
}
|
|
|
|
|
2011-03-19 02:54:32 +08:00
|
|
|
static int executeInput() {
|
2014-05-14 06:37:41 +08:00
|
|
|
// Load any dylibs requested on the command line.
|
|
|
|
loadDylibs();
|
|
|
|
|
2011-03-22 06:15:52 +08:00
|
|
|
// Instantiate a dynamic linker.
|
2013-08-04 06:16:31 +08:00
|
|
|
TrivialMemoryManager MemMgr;
|
2015-10-22 06:12:03 +08:00
|
|
|
doPreallocation(MemMgr);
|
[MCJIT][Orc] Refactor RTDyldMemoryManager, weave RuntimeDyld::SymbolInfo through
MCJIT.
This patch decouples the two responsibilities of the RTDyldMemoryManager class,
memory management and symbol resolution, into two new classes:
RuntimeDyld::MemoryManager and RuntimeDyld::SymbolResolver.
The symbol resolution interface is modified slightly, from:
uint64_t getSymbolAddress(const std::string &Name);
to:
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name);
The latter passes symbol flags along with symbol addresses, allowing RuntimeDyld
and others to reason about non-strong/non-exported symbols.
The memory management interface removes the following method:
void notifyObjectLoaded(ExecutionEngine *EE,
const object::ObjectFile &) {}
as it is not related to memory management. (Note: Backwards compatibility *is*
maintained for this method in MCJIT and OrcMCJITReplacement, see below).
The RTDyldMemoryManager class remains in-tree for backwards compatibility.
It inherits directly from RuntimeDyld::SymbolResolver, and indirectly from
RuntimeDyld::MemoryManager via the new MCJITMemoryManager class, which
just subclasses RuntimeDyld::MemoryManager and reintroduces the
notifyObjectLoaded method for backwards compatibility).
The EngineBuilder class retains the existing method:
EngineBuilder&
setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm);
and includes two new methods:
EngineBuilder&
setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM);
EngineBuilder&
setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR);
Clients should use EITHER:
A single call to setMCJITMemoryManager with an RTDyldMemoryManager.
OR (exclusive)
One call each to each of setMemoryManager and setSymbolResolver.
This patch should be fully compatible with existing uses of RTDyldMemoryManager.
If it is not it should be considered a bug, and the patch either fixed or
reverted.
If clients find the new API to be an improvement the goal will be to deprecate
and eventually remove the RTDyldMemoryManager class in favor of the new classes.
llvm-svn: 233509
2015-03-30 11:37:06 +08:00
|
|
|
RuntimeDyld Dyld(MemMgr, MemMgr);
|
2011-03-19 02:54:32 +08:00
|
|
|
|
2011-04-13 23:49:40 +08:00
|
|
|
// If we don't have any input files, read from stdin.
|
|
|
|
if (!InputFileList.size())
|
|
|
|
InputFileList.push_back("-");
|
2019-09-05 04:26:25 +08:00
|
|
|
{
|
|
|
|
TimeRegion TR(Timers ? &Timers->LoadObjectsTimer : nullptr);
|
|
|
|
for (auto &File : InputFileList) {
|
|
|
|
// Load the input memory buffer.
|
|
|
|
ErrorOr<std::unique_ptr<MemoryBuffer>> InputBuffer =
|
|
|
|
MemoryBuffer::getFileOrSTDIN(File);
|
|
|
|
if (std::error_code EC = InputBuffer.getError())
|
|
|
|
ErrorAndExit("unable to read input: '" + EC.message() + "'");
|
|
|
|
Expected<std::unique_ptr<ObjectFile>> MaybeObj(
|
|
|
|
ObjectFile::createObjectFile((*InputBuffer)->getMemBufferRef()));
|
|
|
|
|
|
|
|
if (!MaybeObj) {
|
|
|
|
std::string Buf;
|
|
|
|
raw_string_ostream OS(Buf);
|
|
|
|
logAllUnhandledErrors(MaybeObj.takeError(), OS);
|
|
|
|
OS.flush();
|
|
|
|
ErrorAndExit("unable to create object file: '" + Buf + "'");
|
|
|
|
}
|
2014-11-27 00:54:40 +08:00
|
|
|
|
2019-09-05 04:26:25 +08:00
|
|
|
ObjectFile &Obj = **MaybeObj;
|
2014-11-27 00:54:40 +08:00
|
|
|
|
2019-09-05 04:26:25 +08:00
|
|
|
// Load the object file
|
|
|
|
Dyld.loadObject(Obj);
|
|
|
|
if (Dyld.hasError()) {
|
|
|
|
ErrorAndExit(Dyld.getErrorString());
|
|
|
|
}
|
2011-04-13 23:49:40 +08:00
|
|
|
}
|
2011-03-23 02:19:42 +08:00
|
|
|
}
|
2011-04-13 23:49:40 +08:00
|
|
|
|
2019-09-05 04:26:25 +08:00
|
|
|
{
|
|
|
|
TimeRegion TR(Timers ? &Timers->LinkTimer : nullptr);
|
|
|
|
// Resove all the relocations we can.
|
|
|
|
// FIXME: Error out if there are unresolved relocations.
|
|
|
|
Dyld.resolveRelocations();
|
|
|
|
}
|
2011-04-13 23:49:40 +08:00
|
|
|
|
2011-04-13 23:38:30 +08:00
|
|
|
// Get the address of the entry point (_main by default).
|
2015-03-11 08:43:26 +08:00
|
|
|
void *MainAddress = Dyld.getSymbolLocalAddress(EntryPoint);
|
2014-04-25 12:24:47 +08:00
|
|
|
if (!MainAddress)
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("no definition for '" + EntryPoint + "'");
|
2011-03-19 01:11:39 +08:00
|
|
|
|
2011-04-12 08:23:32 +08:00
|
|
|
// Invalidate the instruction cache for each loaded function.
|
2015-10-12 08:57:29 +08:00
|
|
|
for (auto &FM : MemMgr.FunctionMemory) {
|
2015-11-18 00:37:52 +08:00
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
auto &FM_MB = FM.MB;
|
|
|
|
|
2011-04-12 08:23:32 +08:00
|
|
|
// Make sure the memory is executable.
|
2015-11-18 00:37:52 +08:00
|
|
|
// setExecutable will call InvalidateInstructionCache.
|
2019-04-09 05:50:48 +08:00
|
|
|
if (auto EC = sys::Memory::protectMappedMemory(FM_MB,
|
2017-11-17 07:04:44 +08:00
|
|
|
sys::Memory::MF_READ |
|
|
|
|
sys::Memory::MF_EXEC))
|
|
|
|
ErrorAndExit("unable to mark function executable: '" + EC.message() +
|
|
|
|
"'");
|
2011-04-12 08:23:32 +08:00
|
|
|
}
|
2011-03-19 01:11:39 +08:00
|
|
|
|
|
|
|
// Dispatch to _main().
|
2011-04-13 23:49:40 +08:00
|
|
|
errs() << "loaded '" << EntryPoint << "' at: " << (void*)MainAddress << "\n";
|
2011-03-19 01:11:39 +08:00
|
|
|
|
|
|
|
int (*Main)(int, const char**) =
|
|
|
|
(int(*)(int,const char**)) uintptr_t(MainAddress);
|
2019-04-25 13:02:10 +08:00
|
|
|
std::vector<const char *> Argv;
|
2011-04-13 23:49:40 +08:00
|
|
|
// Use the name of the first input object module as argv[0] for the target.
|
2019-04-25 13:02:10 +08:00
|
|
|
Argv.push_back(InputFileList[0].data());
|
|
|
|
for (auto &Arg : InputArgv)
|
|
|
|
Argv.push_back(Arg.data());
|
|
|
|
Argv.push_back(nullptr);
|
2019-09-05 04:26:25 +08:00
|
|
|
int Result = 0;
|
|
|
|
{
|
|
|
|
TimeRegion TR(Timers ? &Timers->RunTimer : nullptr);
|
|
|
|
Result = Main(Argv.size() - 1, Argv.data());
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
2011-03-19 01:11:39 +08:00
|
|
|
}
|
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
static int checkAllExpressions(RuntimeDyldChecker &Checker) {
|
|
|
|
for (const auto& CheckerFileName : CheckFiles) {
|
2014-07-07 01:43:13 +08:00
|
|
|
ErrorOr<std::unique_ptr<MemoryBuffer>> CheckerFileBuf =
|
|
|
|
MemoryBuffer::getFileOrSTDIN(CheckerFileName);
|
|
|
|
if (std::error_code EC = CheckerFileBuf.getError())
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("unable to read input '" + CheckerFileName + "': " +
|
2014-06-28 04:20:57 +08:00
|
|
|
EC.message());
|
|
|
|
|
2014-07-07 01:43:13 +08:00
|
|
|
if (!Checker.checkAllRulesInBuffer("# rtdyld-check:",
|
|
|
|
CheckerFileBuf.get().get()))
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("some checks in '" + CheckerFileName + "' failed");
|
2014-06-28 04:20:57 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
void applySpecificSectionMappings(RuntimeDyld &Dyld,
|
|
|
|
const FileToSectionIDMap &FileToSecIDMap) {
|
2014-09-04 12:19:54 +08:00
|
|
|
|
|
|
|
for (StringRef Mapping : SpecificSectionMappings) {
|
|
|
|
size_t EqualsIdx = Mapping.find_first_of("=");
|
2020-01-29 03:23:46 +08:00
|
|
|
std::string SectionIDStr = std::string(Mapping.substr(0, EqualsIdx));
|
2014-09-04 12:19:54 +08:00
|
|
|
size_t ComaIdx = Mapping.find_first_of(",");
|
|
|
|
|
2015-11-21 10:15:51 +08:00
|
|
|
if (ComaIdx == StringRef::npos)
|
|
|
|
report_fatal_error("Invalid section specification '" + Mapping +
|
|
|
|
"'. Should be '<file name>,<section name>=<addr>'");
|
2014-09-04 12:19:54 +08:00
|
|
|
|
2015-07-04 09:35:26 +08:00
|
|
|
std::string FileName = SectionIDStr.substr(0, ComaIdx);
|
|
|
|
std::string SectionName = SectionIDStr.substr(ComaIdx + 1);
|
2019-04-09 05:50:48 +08:00
|
|
|
unsigned SectionID =
|
|
|
|
ExitOnErr(getSectionId(FileToSecIDMap, FileName, SectionName));
|
2014-09-04 12:19:54 +08:00
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
auto* OldAddr = Dyld.getSectionContent(SectionID).data();
|
2020-01-29 03:23:46 +08:00
|
|
|
std::string NewAddrStr = std::string(Mapping.substr(EqualsIdx + 1));
|
2014-09-04 12:19:54 +08:00
|
|
|
uint64_t NewAddr;
|
|
|
|
|
2015-11-21 10:15:51 +08:00
|
|
|
if (StringRef(NewAddrStr).getAsInteger(0, NewAddr))
|
|
|
|
report_fatal_error("Invalid section address in mapping '" + Mapping +
|
|
|
|
"'.");
|
2014-09-04 12:19:54 +08:00
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
Dyld.mapSectionAddress(OldAddr, NewAddr);
|
2014-09-04 12:19:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-30 07:43:13 +08:00
|
|
|
// Scatter sections in all directions!
|
|
|
|
// Remaps section addresses for -verify mode. The following command line options
|
|
|
|
// can be used to customize the layout of the memory within the phony target's
|
|
|
|
// address space:
|
2016-11-20 21:31:13 +08:00
|
|
|
// -target-addr-start <s> -- Specify where the phony target address range starts.
|
2014-07-30 07:43:13 +08:00
|
|
|
// -target-addr-end <e> -- Specify where the phony target address range ends.
|
|
|
|
// -target-section-sep <d> -- Specify how big a gap should be left between the
|
|
|
|
// end of one section and the start of the next.
|
|
|
|
// Defaults to zero. Set to something big
|
|
|
|
// (e.g. 1 << 32) to stress-test stubs, GOTs, etc.
|
|
|
|
//
|
2015-07-04 09:35:26 +08:00
|
|
|
static void remapSectionsAndSymbols(const llvm::Triple &TargetTriple,
|
2019-04-09 05:50:48 +08:00
|
|
|
RuntimeDyld &Dyld,
|
|
|
|
TrivialMemoryManager &MemMgr) {
|
2014-09-04 12:19:54 +08:00
|
|
|
|
|
|
|
// Set up a work list (section addr/size pairs).
|
2019-04-09 05:50:48 +08:00
|
|
|
typedef std::list<const TrivialMemoryManager::SectionInfo*> WorklistT;
|
2014-09-04 12:19:54 +08:00
|
|
|
WorklistT Worklist;
|
|
|
|
|
|
|
|
for (const auto& CodeSection : MemMgr.FunctionMemory)
|
2019-04-09 05:50:48 +08:00
|
|
|
Worklist.push_back(&CodeSection);
|
2014-09-04 12:19:54 +08:00
|
|
|
for (const auto& DataSection : MemMgr.DataMemory)
|
2019-04-09 05:50:48 +08:00
|
|
|
Worklist.push_back(&DataSection);
|
2014-09-04 12:19:54 +08:00
|
|
|
|
|
|
|
// Keep an "already allocated" mapping of section target addresses to sizes.
|
|
|
|
// Sections whose address mappings aren't specified on the command line will
|
|
|
|
// allocated around the explicitly mapped sections while maintaining the
|
|
|
|
// minimum separation.
|
|
|
|
std::map<uint64_t, uint64_t> AlreadyAllocated;
|
|
|
|
|
2017-05-08 01:19:53 +08:00
|
|
|
// Move the previously applied mappings (whether explicitly specified on the
|
|
|
|
// command line, or implicitly set by RuntimeDyld) into the already-allocated
|
|
|
|
// map.
|
2014-09-04 12:19:54 +08:00
|
|
|
for (WorklistT::iterator I = Worklist.begin(), E = Worklist.end();
|
|
|
|
I != E;) {
|
|
|
|
WorklistT::iterator Tmp = I;
|
|
|
|
++I;
|
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
auto LoadAddr = Dyld.getSectionLoadAddress((*Tmp)->SectionID);
|
|
|
|
|
|
|
|
if (LoadAddr != static_cast<uint64_t>(
|
|
|
|
reinterpret_cast<uintptr_t>((*Tmp)->MB.base()))) {
|
2018-10-23 09:36:33 +08:00
|
|
|
// A section will have a LoadAddr of 0 if it wasn't loaded for whatever
|
|
|
|
// reason (e.g. zero byte COFF sections). Don't include those sections in
|
|
|
|
// the allocation map.
|
2019-04-09 05:50:48 +08:00
|
|
|
if (LoadAddr != 0)
|
2019-05-21 04:53:05 +08:00
|
|
|
AlreadyAllocated[LoadAddr] = (*Tmp)->MB.allocatedSize();
|
2014-09-04 12:19:54 +08:00
|
|
|
Worklist.erase(Tmp);
|
|
|
|
}
|
|
|
|
}
|
2014-07-30 07:43:13 +08:00
|
|
|
|
|
|
|
// If the -target-addr-end option wasn't explicitly passed, then set it to a
|
|
|
|
// sensible default based on the target triple.
|
|
|
|
if (TargetAddrEnd.getNumOccurrences() == 0) {
|
|
|
|
if (TargetTriple.isArch16Bit())
|
|
|
|
TargetAddrEnd = (1ULL << 16) - 1;
|
|
|
|
else if (TargetTriple.isArch32Bit())
|
|
|
|
TargetAddrEnd = (1ULL << 32) - 1;
|
|
|
|
// TargetAddrEnd already has a sensible default for 64-bit systems, so
|
|
|
|
// there's nothing to do in the 64-bit case.
|
|
|
|
}
|
|
|
|
|
2014-09-04 12:19:54 +08:00
|
|
|
// Process any elements remaining in the worklist.
|
|
|
|
while (!Worklist.empty()) {
|
2019-04-09 05:50:48 +08:00
|
|
|
auto *CurEntry = Worklist.front();
|
2014-09-04 12:19:54 +08:00
|
|
|
Worklist.pop_front();
|
2014-07-30 07:43:13 +08:00
|
|
|
|
2014-09-04 12:19:54 +08:00
|
|
|
uint64_t NextSectionAddr = TargetAddrStart;
|
|
|
|
|
|
|
|
for (const auto &Alloc : AlreadyAllocated)
|
2019-05-21 04:53:05 +08:00
|
|
|
if (NextSectionAddr + CurEntry->MB.allocatedSize() + TargetSectionSep <=
|
|
|
|
Alloc.first)
|
2014-09-04 12:19:54 +08:00
|
|
|
break;
|
|
|
|
else
|
|
|
|
NextSectionAddr = Alloc.first + Alloc.second + TargetSectionSep;
|
2014-07-30 07:43:13 +08:00
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
Dyld.mapSectionAddress(CurEntry->MB.base(), NextSectionAddr);
|
2019-05-21 04:53:05 +08:00
|
|
|
AlreadyAllocated[NextSectionAddr] = CurEntry->MB.allocatedSize();
|
2014-07-30 07:43:13 +08:00
|
|
|
}
|
2014-09-04 12:19:54 +08:00
|
|
|
|
2015-07-04 09:35:26 +08:00
|
|
|
// Add dummy symbols to the memory manager.
|
|
|
|
for (const auto &Mapping : DummySymbolMappings) {
|
2016-11-30 18:01:11 +08:00
|
|
|
size_t EqualsIdx = Mapping.find_first_of('=');
|
2015-07-04 09:35:26 +08:00
|
|
|
|
2015-11-21 10:15:51 +08:00
|
|
|
if (EqualsIdx == StringRef::npos)
|
|
|
|
report_fatal_error("Invalid dummy symbol specification '" + Mapping +
|
|
|
|
"'. Should be '<symbol name>=<addr>'");
|
2015-07-04 09:35:26 +08:00
|
|
|
|
|
|
|
std::string Symbol = Mapping.substr(0, EqualsIdx);
|
|
|
|
std::string AddrStr = Mapping.substr(EqualsIdx + 1);
|
|
|
|
|
|
|
|
uint64_t Addr;
|
2015-11-21 10:15:51 +08:00
|
|
|
if (StringRef(AddrStr).getAsInteger(0, Addr))
|
|
|
|
report_fatal_error("Invalid symbol mapping '" + Mapping + "'.");
|
2015-07-04 09:35:26 +08:00
|
|
|
|
|
|
|
MemMgr.addDummySymbol(Symbol, Addr);
|
|
|
|
}
|
2014-07-30 07:43:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Load and link the objects specified on the command line, but do not execute
|
|
|
|
// anything. Instead, attach a RuntimeDyldChecker instance and call it to
|
|
|
|
// verify the correctness of the linked memory.
|
2014-06-28 04:20:57 +08:00
|
|
|
static int linkAndVerify() {
|
|
|
|
|
|
|
|
// Check for missing triple.
|
2015-11-21 13:44:41 +08:00
|
|
|
if (TripleName == "")
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("-triple required when running in -verify mode.");
|
2014-06-28 04:20:57 +08:00
|
|
|
|
|
|
|
// Look up the target and build the disassembler.
|
|
|
|
Triple TheTriple(Triple::normalize(TripleName));
|
|
|
|
std::string ErrorStr;
|
|
|
|
const Target *TheTarget =
|
|
|
|
TargetRegistry::lookupTarget("", TheTriple, ErrorStr);
|
2015-11-21 13:44:41 +08:00
|
|
|
if (!TheTarget)
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("Error accessing target '" + TripleName + "': " + ErrorStr);
|
2015-11-21 13:44:41 +08:00
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
TripleName = TheTriple.getTriple();
|
|
|
|
|
|
|
|
std::unique_ptr<MCSubtargetInfo> STI(
|
2015-06-24 06:52:19 +08:00
|
|
|
TheTarget->createMCSubtargetInfo(TripleName, MCPU, ""));
|
2015-11-21 13:49:07 +08:00
|
|
|
if (!STI)
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("Unable to create subtarget info!");
|
2014-06-28 04:20:57 +08:00
|
|
|
|
|
|
|
std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
|
2015-11-21 13:49:07 +08:00
|
|
|
if (!MRI)
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("Unable to create target register info!");
|
2014-06-28 04:20:57 +08:00
|
|
|
|
2019-10-23 18:24:35 +08:00
|
|
|
MCTargetOptions MCOptions;
|
|
|
|
std::unique_ptr<MCAsmInfo> MAI(
|
|
|
|
TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
|
2015-11-21 13:49:07 +08:00
|
|
|
if (!MAI)
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("Unable to create target asm info!");
|
2014-06-28 04:20:57 +08:00
|
|
|
|
2021-05-24 05:15:23 +08:00
|
|
|
MCContext Ctx(Triple(TripleName), MAI.get(), MRI.get(), STI.get());
|
2014-06-28 04:20:57 +08:00
|
|
|
|
|
|
|
std::unique_ptr<MCDisassembler> Disassembler(
|
|
|
|
TheTarget->createMCDisassembler(*STI, Ctx));
|
2015-11-21 13:49:07 +08:00
|
|
|
if (!Disassembler)
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("Unable to create disassembler!");
|
2014-06-28 04:20:57 +08:00
|
|
|
|
|
|
|
std::unique_ptr<MCInstrInfo> MII(TheTarget->createMCInstrInfo());
|
2020-11-22 13:04:12 +08:00
|
|
|
if (!MII)
|
|
|
|
ErrorAndExit("Unable to create target instruction info!");
|
2014-06-28 04:20:57 +08:00
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
std::unique_ptr<MCInstPrinter> InstPrinter(
|
|
|
|
TheTarget->createMCInstPrinter(Triple(TripleName), 0, *MAI, *MII, *MRI));
|
2014-06-28 04:20:57 +08:00
|
|
|
|
|
|
|
// Load any dylibs requested on the command line.
|
|
|
|
loadDylibs();
|
|
|
|
|
|
|
|
// Instantiate a dynamic linker.
|
|
|
|
TrivialMemoryManager MemMgr;
|
2015-10-22 06:12:03 +08:00
|
|
|
doPreallocation(MemMgr);
|
2019-04-09 05:50:48 +08:00
|
|
|
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
struct StubID {
|
|
|
|
unsigned SectionID;
|
|
|
|
uint32_t Offset;
|
|
|
|
};
|
|
|
|
using StubInfos = StringMap<StubID>;
|
|
|
|
using StubContainers = StringMap<StubInfos>;
|
2019-04-09 05:50:48 +08:00
|
|
|
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
StubContainers StubMap;
|
[MCJIT][Orc] Refactor RTDyldMemoryManager, weave RuntimeDyld::SymbolInfo through
MCJIT.
This patch decouples the two responsibilities of the RTDyldMemoryManager class,
memory management and symbol resolution, into two new classes:
RuntimeDyld::MemoryManager and RuntimeDyld::SymbolResolver.
The symbol resolution interface is modified slightly, from:
uint64_t getSymbolAddress(const std::string &Name);
to:
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name);
The latter passes symbol flags along with symbol addresses, allowing RuntimeDyld
and others to reason about non-strong/non-exported symbols.
The memory management interface removes the following method:
void notifyObjectLoaded(ExecutionEngine *EE,
const object::ObjectFile &) {}
as it is not related to memory management. (Note: Backwards compatibility *is*
maintained for this method in MCJIT and OrcMCJITReplacement, see below).
The RTDyldMemoryManager class remains in-tree for backwards compatibility.
It inherits directly from RuntimeDyld::SymbolResolver, and indirectly from
RuntimeDyld::MemoryManager via the new MCJITMemoryManager class, which
just subclasses RuntimeDyld::MemoryManager and reintroduces the
notifyObjectLoaded method for backwards compatibility).
The EngineBuilder class retains the existing method:
EngineBuilder&
setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm);
and includes two new methods:
EngineBuilder&
setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM);
EngineBuilder&
setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR);
Clients should use EITHER:
A single call to setMCJITMemoryManager with an RTDyldMemoryManager.
OR (exclusive)
One call each to each of setMemoryManager and setSymbolResolver.
This patch should be fully compatible with existing uses of RTDyldMemoryManager.
If it is not it should be considered a bug, and the patch either fixed or
reverted.
If clients find the new API to be an improvement the goal will be to deprecate
and eventually remove the RTDyldMemoryManager class in favor of the new classes.
llvm-svn: 233509
2015-03-30 11:37:06 +08:00
|
|
|
RuntimeDyld Dyld(MemMgr, MemMgr);
|
2014-09-03 13:42:52 +08:00
|
|
|
Dyld.setProcessAllSections(true);
|
2019-04-09 05:50:48 +08:00
|
|
|
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
Dyld.setNotifyStubEmitted([&StubMap](StringRef FilePath,
|
|
|
|
StringRef SectionName,
|
|
|
|
StringRef SymbolName, unsigned SectionID,
|
|
|
|
uint32_t StubOffset) {
|
|
|
|
std::string ContainerName =
|
|
|
|
(sys::path::filename(FilePath) + "/" + SectionName).str();
|
|
|
|
StubMap[ContainerName][SymbolName] = {SectionID, StubOffset};
|
|
|
|
});
|
|
|
|
|
|
|
|
auto GetSymbolInfo =
|
|
|
|
[&Dyld, &MemMgr](
|
|
|
|
StringRef Symbol) -> Expected<RuntimeDyldChecker::MemoryRegionInfo> {
|
|
|
|
RuntimeDyldChecker::MemoryRegionInfo SymInfo;
|
|
|
|
|
|
|
|
// First get the target address.
|
|
|
|
if (auto InternalSymbol = Dyld.getSymbol(Symbol))
|
2019-05-13 06:26:33 +08:00
|
|
|
SymInfo.setTargetAddress(InternalSymbol.getAddress());
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
else {
|
|
|
|
// Symbol not found in RuntimeDyld. Fall back to external lookup.
|
2019-04-09 05:50:48 +08:00
|
|
|
#ifdef _MSC_VER
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
using ExpectedLookupResult =
|
|
|
|
MSVCPExpected<JITSymbolResolver::LookupResult>;
|
2019-04-09 05:50:48 +08:00
|
|
|
#else
|
|
|
|
using ExpectedLookupResult = Expected<JITSymbolResolver::LookupResult>;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
auto ResultP = std::make_shared<std::promise<ExpectedLookupResult>>();
|
|
|
|
auto ResultF = ResultP->get_future();
|
|
|
|
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
MemMgr.lookup(JITSymbolResolver::LookupSet({Symbol}),
|
|
|
|
[=](Expected<JITSymbolResolver::LookupResult> Result) {
|
|
|
|
ResultP->set_value(std::move(Result));
|
|
|
|
});
|
2019-04-09 05:50:48 +08:00
|
|
|
|
|
|
|
auto Result = ResultF.get();
|
|
|
|
if (!Result)
|
|
|
|
return Result.takeError();
|
|
|
|
|
|
|
|
auto I = Result->find(Symbol);
|
|
|
|
assert(I != Result->end() &&
|
|
|
|
"Expected symbol address if no error occurred");
|
2019-05-13 06:26:33 +08:00
|
|
|
SymInfo.setTargetAddress(I->second.getAddress());
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now find the symbol content if possible (otherwise leave content as a
|
|
|
|
// default-constructed StringRef).
|
|
|
|
if (auto *SymAddr = Dyld.getSymbolLocalAddress(Symbol)) {
|
|
|
|
unsigned SectionID = Dyld.getSymbolSectionID(Symbol);
|
|
|
|
if (SectionID != ~0U) {
|
|
|
|
char *CSymAddr = static_cast<char *>(SymAddr);
|
|
|
|
StringRef SecContent = Dyld.getSectionContent(SectionID);
|
|
|
|
uint64_t SymSize = SecContent.size() - (CSymAddr - SecContent.data());
|
2021-03-31 11:56:03 +08:00
|
|
|
SymInfo.setContent(ArrayRef<char>(CSymAddr, SymSize));
|
2019-04-09 05:50:48 +08:00
|
|
|
}
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
}
|
|
|
|
return SymInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto IsSymbolValid = [&Dyld, GetSymbolInfo](StringRef Symbol) {
|
|
|
|
if (Dyld.getSymbol(Symbol))
|
|
|
|
return true;
|
|
|
|
auto SymInfo = GetSymbolInfo(Symbol);
|
|
|
|
if (!SymInfo) {
|
|
|
|
logAllUnhandledErrors(SymInfo.takeError(), errs(), "RTDyldChecker: ");
|
|
|
|
return false;
|
|
|
|
}
|
2019-05-13 06:26:33 +08:00
|
|
|
return SymInfo->getTargetAddress() != 0;
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
};
|
2019-04-09 05:50:48 +08:00
|
|
|
|
|
|
|
FileToSectionIDMap FileToSecIDMap;
|
|
|
|
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
auto GetSectionInfo = [&Dyld, &FileToSecIDMap](StringRef FileName,
|
|
|
|
StringRef SectionName)
|
|
|
|
-> Expected<RuntimeDyldChecker::MemoryRegionInfo> {
|
|
|
|
auto SectionID = getSectionId(FileToSecIDMap, FileName, SectionName);
|
|
|
|
if (!SectionID)
|
|
|
|
return SectionID.takeError();
|
|
|
|
RuntimeDyldChecker::MemoryRegionInfo SecInfo;
|
2019-05-13 06:26:33 +08:00
|
|
|
SecInfo.setTargetAddress(Dyld.getSectionLoadAddress(*SectionID));
|
2021-03-31 11:56:03 +08:00
|
|
|
StringRef SecContent = Dyld.getSectionContent(*SectionID);
|
|
|
|
SecInfo.setContent(ArrayRef<char>(SecContent.data(), SecContent.size()));
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
return SecInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto GetStubInfo = [&Dyld, &StubMap](StringRef StubContainer,
|
|
|
|
StringRef SymbolName)
|
|
|
|
-> Expected<RuntimeDyldChecker::MemoryRegionInfo> {
|
|
|
|
if (!StubMap.count(StubContainer))
|
|
|
|
return make_error<StringError>("Stub container not found: " +
|
|
|
|
StubContainer,
|
|
|
|
inconvertibleErrorCode());
|
|
|
|
if (!StubMap[StubContainer].count(SymbolName))
|
|
|
|
return make_error<StringError>("Symbol name " + SymbolName +
|
|
|
|
" in stub container " + StubContainer,
|
|
|
|
inconvertibleErrorCode());
|
|
|
|
auto &SI = StubMap[StubContainer][SymbolName];
|
|
|
|
RuntimeDyldChecker::MemoryRegionInfo StubMemInfo;
|
2019-05-13 06:26:33 +08:00
|
|
|
StubMemInfo.setTargetAddress(Dyld.getSectionLoadAddress(SI.SectionID) +
|
|
|
|
SI.Offset);
|
2021-03-31 11:56:03 +08:00
|
|
|
StringRef SecContent =
|
|
|
|
Dyld.getSectionContent(SI.SectionID).substr(SI.Offset);
|
2019-05-13 06:26:33 +08:00
|
|
|
StubMemInfo.setContent(
|
2021-03-31 11:56:03 +08:00
|
|
|
ArrayRef<char>(SecContent.data(), SecContent.size()));
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
return StubMemInfo;
|
|
|
|
};
|
2019-04-09 05:50:48 +08:00
|
|
|
|
|
|
|
// We will initialize this below once we have the first object file and can
|
|
|
|
// know the endianness.
|
|
|
|
std::unique_ptr<RuntimeDyldChecker> Checker;
|
2014-06-28 04:20:57 +08:00
|
|
|
|
|
|
|
// If we don't have any input files, read from stdin.
|
|
|
|
if (!InputFileList.size())
|
|
|
|
InputFileList.push_back("-");
|
2019-04-09 05:50:48 +08:00
|
|
|
for (auto &InputFile : InputFileList) {
|
2014-06-28 04:20:57 +08:00
|
|
|
// Load the input memory buffer.
|
2014-07-07 01:43:13 +08:00
|
|
|
ErrorOr<std::unique_ptr<MemoryBuffer>> InputBuffer =
|
2019-04-09 05:50:48 +08:00
|
|
|
MemoryBuffer::getFileOrSTDIN(InputFile);
|
2014-11-27 00:54:40 +08:00
|
|
|
|
2014-07-07 01:43:13 +08:00
|
|
|
if (std::error_code EC = InputBuffer.getError())
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("unable to read input: '" + EC.message() + "'");
|
2014-06-28 04:20:57 +08:00
|
|
|
|
2016-04-07 06:14:09 +08:00
|
|
|
Expected<std::unique_ptr<ObjectFile>> MaybeObj(
|
2014-11-27 00:54:40 +08:00
|
|
|
ObjectFile::createObjectFile((*InputBuffer)->getMemBufferRef()));
|
|
|
|
|
2016-04-07 06:14:09 +08:00
|
|
|
if (!MaybeObj) {
|
|
|
|
std::string Buf;
|
|
|
|
raw_string_ostream OS(Buf);
|
2018-11-11 09:46:03 +08:00
|
|
|
logAllUnhandledErrors(MaybeObj.takeError(), OS);
|
2016-04-07 06:14:09 +08:00
|
|
|
OS.flush();
|
|
|
|
ErrorAndExit("unable to create object file: '" + Buf + "'");
|
|
|
|
}
|
2014-11-27 00:54:40 +08:00
|
|
|
|
|
|
|
ObjectFile &Obj = **MaybeObj;
|
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
if (!Checker)
|
2019-08-15 23:54:37 +08:00
|
|
|
Checker = std::make_unique<RuntimeDyldChecker>(
|
Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.
This patch reduces the number of functions in the interface between RuntimeDyld
and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions
into "GetXInfo" functions that return a struct describing both the address and
content. The GetStubOffset function is also replaced with a pair of utilities,
GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of
these functions will return the same result, but for the new JITLink linker
(https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs
and GOT entries respectively.
For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check
language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both
functions now take two arguments, a 'stub container name' and a target symbol
name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file
name and section name, separated by a slash. E.g.:
rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y
For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis
rather than a per-section basis, the container name is just the file name. E.g.:
jitlink-check: *{8}(got_addr(foo.o, y)) = y
llvm-svn: 358295
2019-04-13 02:07:28 +08:00
|
|
|
IsSymbolValid, GetSymbolInfo, GetSectionInfo, GetStubInfo,
|
|
|
|
GetStubInfo, Obj.isLittleEndian() ? support::little : support::big,
|
|
|
|
Disassembler.get(), InstPrinter.get(), dbgs());
|
2019-04-09 05:50:48 +08:00
|
|
|
|
|
|
|
auto FileName = sys::path::filename(InputFile);
|
|
|
|
MemMgr.setSectionIDsMap(&FileToSecIDMap[FileName]);
|
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
// Load the object file
|
2014-11-27 00:54:40 +08:00
|
|
|
Dyld.loadObject(Obj);
|
|
|
|
if (Dyld.hasError()) {
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit(Dyld.getErrorString());
|
2014-06-28 04:20:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-04 09:35:26 +08:00
|
|
|
// Re-map the section addresses into the phony target address space and add
|
|
|
|
// dummy symbols.
|
2019-04-09 05:50:48 +08:00
|
|
|
applySpecificSectionMappings(Dyld, FileToSecIDMap);
|
|
|
|
remapSectionsAndSymbols(TheTriple, Dyld, MemMgr);
|
2014-07-30 11:12:41 +08:00
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
// Resolve all the relocations we can.
|
|
|
|
Dyld.resolveRelocations();
|
|
|
|
|
2014-09-03 13:42:52 +08:00
|
|
|
// Register EH frames.
|
|
|
|
Dyld.registerEHFrames();
|
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
int ErrorCode = checkAllExpressions(*Checker);
|
2015-11-21 13:44:41 +08:00
|
|
|
if (Dyld.hasError())
|
2016-03-26 01:25:34 +08:00
|
|
|
ErrorAndExit("RTDyld reported an error applying relocations:\n " +
|
2015-11-21 13:44:41 +08:00
|
|
|
Dyld.getErrorString());
|
2014-08-06 04:51:46 +08:00
|
|
|
|
|
|
|
return ErrorCode;
|
2014-06-28 04:20:57 +08:00
|
|
|
}
|
|
|
|
|
2011-03-19 01:11:39 +08:00
|
|
|
int main(int argc, char **argv) {
|
2018-04-14 02:26:06 +08:00
|
|
|
InitLLVM X(argc, argv);
|
2011-03-19 01:11:39 +08:00
|
|
|
ProgramName = argv[0];
|
|
|
|
|
2014-06-28 04:20:57 +08:00
|
|
|
llvm::InitializeAllTargetInfos();
|
|
|
|
llvm::InitializeAllTargetMCs();
|
|
|
|
llvm::InitializeAllDisassemblers();
|
|
|
|
|
2021-07-21 18:03:05 +08:00
|
|
|
cl::HideUnrelatedOptions({&RTDyldCategory, &getColorCategory()});
|
2011-03-19 01:11:39 +08:00
|
|
|
cl::ParseCommandLineOptions(argc, argv, "llvm MC-JIT tool\n");
|
|
|
|
|
2019-04-09 05:50:48 +08:00
|
|
|
ExitOnErr.setBanner(std::string(argv[0]) + ": ");
|
|
|
|
|
2019-09-05 04:26:25 +08:00
|
|
|
Timers = ShowTimes ? std::make_unique<RTDyldTimers>() : nullptr;
|
|
|
|
|
|
|
|
int Result;
|
2011-03-19 01:11:39 +08:00
|
|
|
switch (Action) {
|
|
|
|
case AC_Execute:
|
2019-09-05 04:26:25 +08:00
|
|
|
Result = executeInput();
|
|
|
|
break;
|
2015-05-22 05:24:32 +08:00
|
|
|
case AC_PrintDebugLineInfo:
|
2019-09-05 04:26:25 +08:00
|
|
|
Result =
|
|
|
|
printLineInfoForInput(/* LoadObjects */ true, /* UseDebugObj */ true);
|
|
|
|
break;
|
2013-01-26 06:50:58 +08:00
|
|
|
case AC_PrintLineInfo:
|
2019-09-05 04:26:25 +08:00
|
|
|
Result =
|
|
|
|
printLineInfoForInput(/* LoadObjects */ true, /* UseDebugObj */ false);
|
|
|
|
break;
|
2015-05-31 03:44:53 +08:00
|
|
|
case AC_PrintObjectLineInfo:
|
2019-09-05 04:26:25 +08:00
|
|
|
Result =
|
|
|
|
printLineInfoForInput(/* LoadObjects */ false, /* UseDebugObj */ false);
|
|
|
|
break;
|
2014-06-28 04:20:57 +08:00
|
|
|
case AC_Verify:
|
2019-09-05 04:26:25 +08:00
|
|
|
Result = linkAndVerify();
|
|
|
|
break;
|
2011-03-19 01:11:39 +08:00
|
|
|
}
|
2019-09-16 18:30:37 +08:00
|
|
|
return Result;
|
2011-03-19 01:11:39 +08:00
|
|
|
}
|