forked from bajdcc/tinix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map2idc.pl
46 lines (45 loc) · 1.07 KB
/
map2idc.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
my $mode;
print "#include <idc.idc>\n";
print "static main()\n{\n";
open(FD, "system.map") or die "error open map file!";
while (<FD>)
{
my $line = $_;
if ($line =~ /\.text/)
{
$mode = 0;
}
if ($line =~ /(\.data|\.bss|\.ro?data)/i)
{
$mode = 1;
}
if ($line =~ /^\s+(0x\w+)\s+(\w+)$/)
{
if ($mode == 0)
{
my $ea = $1;
my $name = $2;
print "\tMakeCode($ea);\n";
print "\tMakeName($ea,\"$name\");\n";
print "\tMakeFunction($ea,BADADDR);\n";
}
else
{
my $ea = $1;
my $name = $2;
print "\tMakeName($ea,\"$name\");\n";
}
}
if ($line =~ /^ (\.text|\.data|\.bss|\.ro?data)\s+(0x\w+)\s+(0x\w+)\s+(\w+)\.o$/i)
{
my $seg = $1;
my $base = $2;
my $len = $3;
my $module = $4;
next if $len eq "0x0";
print "\n\tAddSeg($base, $base+$len, 0, 1, 0, 0);\n";
print "\tRenameSeg($base, \"".lc($seg)."_$module\");\n\n";
}
}
close(FD);
print "}\n";