-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmerge_segments.pl
80 lines (73 loc) · 1.35 KB
/
merge_segments.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use strict;
use warnings;
use Data::Dumper;
our %variables;
sub variables
{
open IN,'variables.txt';
while(<IN>){
#if (/^[]\s+/);
my @d = split(/\s+/);
#warn join("|",@d);
$variables{$d[0]}=$d[1];
#die Dumper(\%variables);
}
close IN;
return \%variables;
}
our %segments;
sub segments{
open IN,'segments.txt' or die;
while(<IN>){
if (/\s+(0x[a-fA-F0-9]+)\s\-\s+(0x[a-fA-F0-9]+)\s+is\s+([\w\.]+)/)
{
#warn "$_";
$segments{$3}{from}=$1;
$segments{$3}{to}=$2;
#die Dumper(\%segments);
}
elsif (/Symbols from \"(.+)\"/){
#warn "file $1";
}
elsif (/Local core dump file:/) {
}
elsif(/\`(.+)\', file type elf64-x86-64./) {
#warn "file $1";
}
elsif(/Entry point: (.+)/){}
elsif(/Local exec file:/){}
else
{
die "Could not parse $_";
}
}
close IN;
return \%segments;
}
segments;
variables;
no warnings 'portable'; # Support for 64-bit ints required
for my $k (keys %variables) {
my $n = $variables{$k};
for my $s (keys %segments) {
my $sg = $segments{$s};
my $f = hex($sg->{from});
my $t = hex($sg->{to});
if ($f > $t) {
my $p = $t;
$t = $f;
$f = $p;
}
my $v = hex($k);
if (
($f ge $v) &&
($t le $v)
) {
print "FOUND: ${k}\-\>${v}\t$n\t$f\t$t\t$s\n";
}
else
{
print "No $k\-\>${v}\t$n\t$f\t$t\t$s\n";
}
}
}