Skip to content
Snippets Groups Projects
Commit d7e9701f authored by jdh8d's avatar jdh8d
Browse files

Added options to protect returns and/or jumps separately.

parent d88766ef
No related branches found
No related tags found
No related merge requests found
......@@ -53,12 +53,22 @@ int main(int argc, char **argv)
}
bool do_coloring=false;
bool do_jumps=true;
bool do_rets=true;
for(int i=0;i<argc;i++)
{
if(string(argv[i])=="--color")
do_coloring=true;
else if(string(argv[i])=="--no-color")
do_coloring=false;
else if(string(argv[i])=="--protect-jumps")
do_jumps=true;
else if(string(argv[i])=="--no-protect-jumps")
do_jumps=false;
else if(string(argv[i])=="--protect-rets")
do_rets=true;
else if(string(argv[i])=="--no-protect-rets")
do_rets=false;
}
string programName(argv[0]);
......@@ -89,7 +99,7 @@ int main(int argc, char **argv)
try
{
SCFI_Instrument scfii(firp, do_coloring);
SCFI_Instrument scfii(firp, do_coloring, do_jumps, do_rets);
int success=scfii.execute();
......
......@@ -398,6 +398,9 @@ void mov_reloc(Instruction_t* from, Instruction_t* to, string type )
void SCFI_Instrument::AddJumpCFI(Instruction_t* insn)
{
if(!do_jumps)
return;
assert(do_rets);
ColoredSlotValue_t v2;
if(insn->GetIBTargets() && color_map)
v2=color_map->GetColorOfIB(insn);
......@@ -440,6 +443,8 @@ void SCFI_Instrument::AddJumpCFI(Instruction_t* insn)
void SCFI_Instrument::AddReturnCFI(Instruction_t* insn, ColoredSlotValue_t *v)
{
if(!do_rets)
return;
ColoredSlotValue_t v2;
if(v==NULL && color_map)
{
......
......@@ -29,8 +29,15 @@
class SCFI_Instrument
{
public:
SCFI_Instrument(libIRDB::FileIR_t *the_firp, bool p_do_coloring=true)
: firp(the_firp), do_coloring(p_do_coloring), color_map(NULL) {}
SCFI_Instrument(libIRDB::FileIR_t *the_firp,
bool p_do_coloring=true,
bool p_do_jumps=true,
bool p_do_rets=true)
: firp(the_firp),
do_coloring(p_do_coloring),
do_jumps(p_do_jumps),
do_rets(p_do_rets),
color_map(NULL) {}
bool execute();
private:
......@@ -64,6 +71,8 @@ class SCFI_Instrument
libIRDB::FileIR_t* firp;
bool do_coloring;
bool do_jumps;
bool do_rets;
ColoredInstructionNonces_t *color_map;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment