Skip to content

Instantly share code, notes, and snippets.

@Leandros
Created July 26, 2016 04:38
Show Gist options
  • Save Leandros/6cd91590afc85bf3c00464b5c4bd28b4 to your computer and use it in GitHub Desktop.
Save Leandros/6cd91590afc85bf3c00464b5c4bd28b4 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
$ptr='(BYTE|WORD|DWORD|QWORD|XMMWORD) PTR ';
$reg='(?:[er]?(?:[abcd]x|[sd]i|[sb]p)|[abcd][hl]|r1?[0-589][dwb]?|mm[0-7]|xmm1?[0-9])';
open FH, '-|', '/usr/bin/objdump', '-w', '-M', 'intel', @ARGV or die;
$prev = "";
while(<FH>){
if(/$ptr/o) {
s/$ptr(\[[^\[\]]+\],$reg)/$2/o or
s/($reg,)$ptr(\[[^\[\]]+\])/$1$3/o or
s/$ptr/lc $1/oe;
}
if($prev =~ /\t(repz )?ret / and
$_ =~ /\tnop |\txchg *ax,ax$/) {
# drop this line
} else {
print $prev;
$prev = $_;
}
}
print $prev;
close FH;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment