Created
July 26, 2016 04:38
-
-
Save Leandros/6cd91590afc85bf3c00464b5c4bd28b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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