Introduce the --no-link option

Introduce an option to prevent `revamb` from linking in all the QEMU
helpers. This is useful if the output doesn't need to be compiled, but
just analyzed.
This commit is contained in:
Alessandro Di Federico
2017-01-11 15:25:53 +01:00
parent 3f760876f7
commit 4501dad2c0
4 changed files with 27 additions and 11 deletions
+10 -7
View File
@@ -73,7 +73,8 @@ CodeGenerator::CodeGenerator(BinaryFile &Binary,
std::string BBSummary,
bool EnableOSRA,
bool EnableTracing,
bool DetectFunctionBoundaries) :
bool DetectFunctionBoundaries,
bool EnableLinking) :
TargetArchitecture(Target),
Context(getGlobalContext()),
TheModule((new Module("top", Context))),
@@ -82,7 +83,8 @@ CodeGenerator::CodeGenerator(BinaryFile &Binary,
Binary(Binary),
EnableOSRA(EnableOSRA),
EnableTracing(EnableTracing),
DetectFunctionBoundaries(DetectFunctionBoundaries)
DetectFunctionBoundaries(DetectFunctionBoundaries),
EnableLinking(EnableLinking)
{
OriginalInstrMDKind = Context.getMDKindID("oi");
PTCInstrMDKind = Context.getMDKindID("pi");
@@ -875,11 +877,12 @@ void CodeGenerator::translate(uint64_t VirtualAddress,
GV.setLinkage(GlobalValue::InternalLinkage);
}
Linker TheLinker(*TheModule);
bool Result = TheLinker.linkInModule(std::move(HelpersModule),
Linker::LinkOnlyNeeded);
assert(!Result && "Linking failed");
(void) Result;
if (EnableLinking) {
Linker TheLinker(*TheModule);
bool Result = TheLinker.linkInModule(std::move(HelpersModule),
Linker::LinkOnlyNeeded);
assert(!Result && "Linking failed");
}
Variables.setDataLayout(&TheModule->getDataLayout());