[RuntimeDyld] Add a framework for testing relocation logic in RuntimeDyld.

This patch adds a "-verify" mode to the llvm-rtdyld utility. In verify mode,
llvm-rtdyld will test supplied expressions against the linked program images
that it creates in memory. This scheme can be used to verify the correctness
of the relocation logic applied by RuntimeDyld.

The expressions to test will be read out of files passed via the -check option
(there may be more than one of these). Expressions to check are extracted from
lines of the form:
# rtdyld-check: <expression>

This system is designed to fit the llvm-lit regression test workflow. It is
format and target agnostic, and supports verification of images linked for
remote targets. The expression language is defined in
llvm/include/llvm/RuntimeDyldChecker.h . Examples can be found in
test/ExecutionEngine/RuntimeDyld.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211956 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames
2014-06-27 20:20:57 +00:00
parent 63195d7e5a
commit c3747f276a
9 changed files with 908 additions and 6 deletions

View File

@@ -20,6 +20,7 @@
#include "llvm/ADT/Triple.h"
#include "llvm/ExecutionEngine/ObjectImage.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -158,6 +159,15 @@ public:
};
class RuntimeDyldImpl {
friend class RuntimeDyldChecker;
private:
uint64_t getAnySymbolRemoteAddress(StringRef Symbol) {
if (uint64_t InternalSymbolAddr = getSymbolLoadAddress(Symbol))
return InternalSymbolAddr;
return MemMgr->getSymbolAddress(Symbol);
}
protected:
// The MemoryManager to load objects into.
RTDyldMemoryManager *MemMgr;
@@ -339,7 +349,8 @@ protected:
public:
RuntimeDyldImpl(RTDyldMemoryManager *mm)
: MemMgr(mm), ProcessAllSections(false), HasError(false) {}
: MemMgr(mm), ProcessAllSections(false), HasError(false) {
}
virtual ~RuntimeDyldImpl();
@@ -349,7 +360,7 @@ public:
ObjectImage *loadObject(ObjectImage *InputObject);
void *getSymbolAddress(StringRef Name) {
uint8_t* getSymbolAddress(StringRef Name) {
// FIXME: Just look up as a function for now. Overly simple of course.
// Work in progress.
SymbolTableMap::const_iterator pos = GlobalSymbolTable.find(Name);