Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sdasgup3 committed Jul 7, 2018
1 parent 4f4d4a5 commit 2c851c5
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 27 deletions.
9 changes: 0 additions & 9 deletions docs/relatedwork/strata/current_support.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2869,15 +2869,6 @@ orb_rh_r8_1
orb_rh_rh_1
pextrw_r32_xmm_imm8_1
pextrw_r64_xmm_imm8_1
rep insb_m8_dx_1
rep lodsb_al_1
rep movsb_m8_m8_1
rep outsb_dx_m8_1
rep stosb_m8_1
repz cmpsb_m8_m8_1
repz scasb_m8_1
repnz cmpsb_m8_m8_1
repnz scasb_m8_1
sbbw_r16_r16_1
sbbl_r32_r32_1
sbbq_r64_r64_1
Expand Down
66 changes: 61 additions & 5 deletions scripts/kutils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4911,7 +4911,7 @@ sub assocateMcSemaXed {
push @{ $retmodel{$1} }, $line;
}
else {
#print "K1:$key1 K2:$key2 L:$line\n";
print "K1:$key1 K2:$key2 L:$line\n";
}
}
}
Expand Down Expand Up @@ -4966,6 +4966,63 @@ sub modelInstructions {
my $hint = shift @_;
my $print = shift @_;

if($hint eq "inIntel") {
return modelIntelInstructions($filename, $intelattfile, $hint, $print);
} else {
return modelAttInstructions($filename, $intelattfile, $hint, $print);
}
}

sub modelIntelInstructions {
my $filename = shift @_;
my $intelattfile = shift @_;
my $hint = shift @_;
my $print = shift @_;

## get intel <-> att
my ( $intel2att_ref, $att2intel_ref ) = assocIntelATT( $intelattfile, 0 );
my %intel2att = %{$intel2att_ref};
my %att2intel = %{$att2intel_ref};

## Model instruction in a map.
open( my $fp, "<", $filename ) or die "Can't open: $!";
my @lines = <$fp>;
close $fp;

my %model_att = ();
my %model_intel = ();
my $linecount = 0;
for my $line (@lines) {
chomp $line;
$linecount++;

my $key = "";
my $name = "";

$key = $line ;
$name = $line;
push @{ $model_intel{$key} }, $name;
}

## Get the corresponding intel keys
for my $intelkey ( sort keys %model_intel ) {
if ( exists $intel2att{$intelkey} ) {
$model_att{ $intel2att{$intelkey} } = $intelkey;
}
else {
print "No corresponding Opcode for: $intelkey\n";
}
}

return ( \%model_att, \%model_intel );
}

sub modelAttInstructions {
my $filename = shift @_;
my $intelattfile = shift @_;
my $hint = shift @_;
my $print = shift @_;

## get intel <-> att
my ( $intel2att_ref, $att2intel_ref ) = assocIntelATT( $intelattfile, 0 );
my %intel2att = %{$intel2att_ref};
Expand Down Expand Up @@ -5016,8 +5073,7 @@ sub modelInstructions {
}
}

if ( ( $hint eq "inIntel" )
or ( $hint eq "keep_instruction" ) )
if ( $hint eq "keep_instruction" )
{
return ( \%model_att, \%model_att );
}
Expand All @@ -5028,7 +5084,7 @@ sub modelInstructions {
$model_intel{ $att2intel{$attkey} } = $attkey;
}
else {
print "$attkey\n";
print "No corresponding Opcode for: $attkey\n";
}
}

Expand Down Expand Up @@ -5066,7 +5122,7 @@ sub assocIntelATT {
}
}

if ( $verifyCount != scalar( keys %att2intel ) + 6 ) {
if ( $verifyCount != scalar( keys %att2intel ) + 7 ) {
print $verifyCount. "\n";
print scalar( keys %att2intel ) . "\n";
utils::failInfo("assocIntelATT failed");
Expand Down
51 changes: 38 additions & 13 deletions scripts/process_spec.pl
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,28 @@
if ( "" ne $compareintel ) {
## file names
my $availfile = "docs/instruction_manuals/all.instrs";
my $intelatt = "/home/sdasgup3/Github/strata-data/output-strata/instruction-summary/misc-documents/intel_att.txt";

my $stratafile = "/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/strata/strata_orig_supported.txt";
my $currentfile = "/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/strata/current_support.txt";
my $bapfile = "/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/bap/baprunlog.txt";
my $angrfile = "/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/angrVex/support.txt";
my $intelatt =
"/home/sdasgup3/Github/strata-data/output-strata/instruction-summary/misc-documents/intel_att.txt";

my $stratafile =
"/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/strata/strata_orig_supported.txt";
my $currentfile =
"/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/strata/current_support.txt";
my $idealfile =
"/home/sdasgup3/Github/strata-data/output-strata/instruction-summary/clasification/all.txt";
my $bapfile =
"/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/bap/baprunlog.txt";
my $angrfile =
"/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/angrVex/support.txt";
my $stratavecimmfile =
"/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/strata/Immediates/stratum_vector_immediates.txt";
my $mcsemafile = "/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/mcsema/amd64.txt";
my $xedfile = "/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/mcsema/xed.txt";
my $acl2file = "/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/acl2/supportedOPcodes.txt";
"/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/strata/Immediates/stratum_vector_immediates.txt";
my $mcsemafile =
#"/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/mcsema/amd64.txt";
"/home/sdasgup3/x86-semantics/docs/relatedwork/mcsema/reportlist.txt";
my $xedfile =
"/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/mcsema/xed.txt";
my $acl2file =
"/home/sdasgup3/Github/binary-decompilation/x86-semantics/docs/relatedwork/acl2/supportedOPcodes.txt";
my $stoke_strata_unsup_file =
"docs/relatedwork/strata/strata_stoke_unsupported.txt";
my $ungeneralized_memory =
Expand All @@ -162,6 +173,16 @@
. scalar( keys %{intel2att} )
. "|\n" );

## Get the ideal supported instr
my ( $ideal_supp_att_ref, $ideal_supp_intel_ref ) =
modelInstructions( $idealfile, $intelatt, "", 0 );
my %ideal_supp_att = %{$ideal_supp_att_ref};
my %ideal_supp_intel = %{$ideal_supp_intel_ref};
print( "| Ideal Support(att/intel)| "
. scalar( keys %ideal_supp_att ) . "/"
. scalar( keys %ideal_supp_intel )
. "|\n" );

## Get the current supported instr
my ( $curr_supp_att_ref, $curr_supp_intel_ref ) =
modelInstructions( $currentfile, $intelatt, "", 0 );
Expand Down Expand Up @@ -192,7 +213,6 @@
. scalar( keys %angr_supp_intel )
. "|\n" );


## Get the strata supported instr
my ( $strata_supp_att_ref, $strata_supp_intel_ref ) =
modelInstructions( $stratafile, $intelatt, "", 0 );
Expand All @@ -204,16 +224,21 @@
. "|\n" );

## Get the mcsema supported instr
my $mcsema_supp_intel_ref =
assocateMcSemaXed( $mcsemafile, $xedfile, $debugprint );
#my $mcsema_supp_intel_ref =
# assocateMcSemaXed( $mcsemafile, $xedfile, $debugprint );
my ( $mcsema_supp_att_ref, $mcsema_supp_intel_ref ) =
modelInstructions( $mcsemafile, $intelatt, "inIntel", 0 );
my %mcsema_supp_att = %{$mcsema_supp_att_ref};
my %mcsema_supp_intel = %{$mcsema_supp_intel_ref};
print( "| McSema Support(Intel)| "
. scalar( keys %mcsema_supp_att ) . "/"
. scalar( keys %mcsema_supp_intel )
. "|\n" );

## Get the acl2 supported instr
my $acl2_intel_ref =
modelInstructions( $acl2file, $intelatt, "inIntel", $debugprint );
my %mcsema_supp_att = %{$mcsema_supp_att_ref};
my %acl2_intel = %{$acl2_intel_ref};
print( "| ACL2 Support(Intel)| " . scalar( keys %acl2_intel ) . "|\n" );

Expand Down

0 comments on commit 2c851c5

Please sign in to comment.