Skip to content

Instantly share code, notes, and snippets.

@dgryski
Created November 23, 2016 14:06
Show Gist options
  • Save dgryski/99ac147faf2891c9816d3f4f925c4e6b to your computer and use it in GitHub Desktop.
Save dgryski/99ac147faf2891c9816d3f4f925c4e6b to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use warnings;
use strict;
my $bin=$ARGV[0];
my @line = split /\s+/, `nm $bin |grep runtime.buildVersion`;
my $addr = hex($line[0]);
my $end = $addr + 16;
@line = split /\s+/, `objdump -s --start-addr=$addr --stop-addr=$end $bin |grep '^ '`;
($addr, $end) = (unpack("V", pack("H*", $line[2])), unpack("V", pack("H*", $line[4])));
$end += $addr;
@line = split /\s+/, `objdump -s --start-addr=$addr --stop-addr=$end $bin |grep '^ '`;
print $line[$#line], "\n";
@zirkome
Copy link

zirkome commented Dec 2, 2016

For Mac users this doesn't work out of the box, you need to install binutils with homebrew and replace nm and objdump with gnm and gobjdump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment