Register and add among JT reasons FunctionSymbol

The symbol handling has been extended to register whether a symbol
represents a function or not. This information is then used to register,
during the global data harvesting phase, all the function symbols and
explicitly mark them through the "FunctionSymbol" `JTReason`.

We use this information during the CFEP harvesting phase to integrate
the information produced by the function boundaries detection with
potential unidentified CFEPs.

This option can be enabled with the `--use-debug-symbols`, which
supersedes `--use-sections`.
This commit is contained in:
Andrea Gussoni
2018-04-26 18:19:06 +02:00
committed by Alessandro Di Federico
parent 6e642ea6f9
commit 500d77f43e
14 changed files with 69 additions and 33 deletions
+7 -3
View File
@@ -89,7 +89,8 @@ CodeGenerator::CodeGenerator(BinaryFile &Binary,
bool EnableOSRA,
bool DetectFunctionBoundaries,
bool EnableLinking,
bool ExternalCSVs) :
bool ExternalCSVs,
bool UseDebugSymbols) :
TargetArchitecture(Target),
Context(getGlobalContext()),
TheModule((new Module("top", Context))),
@@ -99,7 +100,8 @@ CodeGenerator::CodeGenerator(BinaryFile &Binary,
EnableOSRA(EnableOSRA),
DetectFunctionBoundaries(DetectFunctionBoundaries),
EnableLinking(EnableLinking),
ExternalCSVs(ExternalCSVs)
ExternalCSVs(ExternalCSVs),
UseDebugSymbols(UseDebugSymbols)
{
OriginalInstrMDKind = Context.getMDKindID("oi");
PTCInstrMDKind = Context.getMDKindID("pi");
@@ -964,7 +966,9 @@ void CodeGenerator::translate(uint64_t VirtualAddress) {
if (DetectFunctionBoundaries) {
legacy::FunctionPassManager FPM(&*TheModule);
FPM.add(new FunctionBoundariesDetectionPass(&JumpTargets, ""));
FPM.add(new FunctionBoundariesDetectionPass(&JumpTargets,
"",
UseDebugSymbols));
FPM.run(*MainFunction);
}