Merge from vendor branch BINUTILS:
[dragonfly.git] / sys / bus / pci / locate.pl
1 #!/usr/bin/perl
2 # $FreeBSD: src/sys/pci/locate.pl,v 1.2.2.1 2000/08/03 01:09:11 peter Exp $
3 # $DragonFly: src/sys/bus/pci/Attic/locate.pl,v 1.2 2003/06/17 04:28:57 dillon Exp $
4
5 $errpos = hex($ARGV[0])/4;
6 $ofs=0;
7
8 open (INPUT, "cc -E ncr.c 2>/dev/null |");
9
10 while ($_ = <INPUT>)
11 {
12     last if /^struct script \{/;
13 }
14
15 while ($_ = <INPUT>)
16 {
17     last if /^\}\;/;
18     ($label, $size) = /ncrcmd\s+(\S+)\s+\[([^]]+)/;
19     $size = eval($size);
20     if ($label) {
21         if ($errpos) {
22             if ($ofs + $size > $errpos) {
23                 printf ("%4x: %s\n", $ofs * 4, $label);
24                 printf ("%4x: %s + %d\n", $errpos * 4, $label, $errpos - $ofs);
25                 last;
26             }
27             $ofs += $size;
28         } else {
29             printf ("%4x: %s\n", $ofs * 4, $label);
30         }
31     }
32 }
33