6 my %sym_tab = (new Math::BigInt(0) => "ERRRRRRROR");
7 my $sections = "BdDdTtVvWwuU";
16 my $h = substr $i->as_hex(), 2;
17 $h = ('0' x (16-length($h))) . $h;
24 print " input is read from stdin\n";
29 $nm = 'arm-softfloat-elf-nm' if !(system("file -L $img | grep -qw ARM") >> 8);
31 foreach my $l (split('\n', qx{$nm $img | c++filt}))
33 if ($l =~ /^([0-9a-fA-F]*)\s+([$sections])\s+(.*)$/)
35 my ($addr, $sec, $sym) = (new Math::BigInt("0x$1"), $2, $3);
36 if (defined $addr && ref $addr && !$addr->is_nan())
38 $sym_tab{as_hex($addr)} = $sym;
39 $sec_tab{as_hex($addr)} = $sec;
43 my @sorted_sym_tab_keys = sort keys %sym_tab;
44 my $min_addr = $sorted_sym_tab_keys[0];
45 my $max_addr = $sorted_sym_tab_keys[@sorted_sym_tab_keys - 1];
47 print "Scanning image done, proceed.\n";
51 my $addr = as_hex(shift);
54 return new Math::BigInt(0)
55 if $addr lt $min_addr or $addr gt $max_addr;
57 foreach my $s (@sorted_sym_tab_keys)
61 return new Math::BigInt("0x$hit");
67 return new Math::BigInt(0);
72 my $addr = new Math::BigInt("0x".shift);
73 my $hit = find_sym($addr);
74 my $offset = $addr-$hit;
75 my $o = $hit->as_hex();
79 printf " %s %30s(%s) + %6s = %s\n",
80 $addr->as_hex(), $sym_tab{as_hex($hit)}, $sec_tab{as_hex($hit)},
81 $offset->as_hex(), $hit->as_hex();
88 if (/^\s+#(\d+)\s+([0-9a-f]+)\s+([0-9a-f]+)/i) # fiasco bt without debuginfo
91 my $stack = new Math::BigInt("0x$2");
93 my $fsize = $stack - $last_f;
96 printf "%2d %s ", $fn, $stack->as_hex();
97 if ($fsize >= 0 && $fsize <= 2000)
105 elsif (/^(?:.*?\|)?\s*(0x)?([0-9a-f]+)\s*$/i) # simple figure
109 elsif (/^[\da-f]+:([\d\sa-f]+)$/i) # fiasco memory dump (mostly user stack)
112 for my $addr (split(/\s+/, $l))
117 elsif (/^\s*[\da-f]+\s+([\d\sa-f]+)\s*$/i) # fiasco tcb view stack
120 for my $val (split(/\s+/, $l))
122 next if $val eq '35353535'; # stack poison
123 if ($val =~ /^f.......(?:........)?$/i) {
126 print " 0x$val ... value ...\n";