* add p cc
[mascara-docs.git] / i386 / linux / linux-2.3.21 / arch / arm / lib / extractconstants.pl
blob8c96b3f28993d6a2630f24f53380f9acb4cef519
1 #!/usr/bin/perl
3 $OBJDUMP=$ARGV[0];
5 sub swapdata {
6 local ($num) = @_;
8 return substr($num, 6, 2).substr($num, 4, 2).substr ($num, 2, 2).substr ($num, 0, 2);
11 open (DATA, $OBJDUMP.' --full-contents --section=.data getconsdata.o | grep \'^ 00\' |') ||
12 die ('Cant objdump!');
13 while (<DATA>) {
14 ($addr, $data0, $data1, $data2, $data3) = split (' ');
15 $dat[hex($addr)] = hex(&swapdata($data0));
16 $dat[hex($addr)+4] = hex(&swapdata($data1));
17 $dat[hex($addr)+8] = hex(&swapdata($data2));
18 $dat[hex($addr)+12] = hex(&swapdata($data3));
20 close (DATA);
22 open (DATA, $OBJDUMP.' --syms getconsdata.o |') || die ('Cant objdump!');
23 while (<DATA>) {
24 /elf32/ && ( $elf = 1 );
25 /a.out/ && ( $aout = 1 );
26 next if ($aout && ! / 07 /);
27 next if ($elf && ! (/^0*0...... g/ && /.data/));
28 next if (!$aout && !$elf);
30 if ($aout) {
31 ($addr, $flags, $sect, $a1, $a2, $a3, $name) = split (' ');
32 $nam[hex($addr)] = substr($name, 1);
34 if ($elf) {
35 chomp;
36 $addr = substr ($_, 0, index($_, " "));
37 $name = substr ($_, rindex($_, " ") + 1);
38 $nam[hex($addr)] = $name;
41 close (DATA);
43 print "/*\n * *** This file is automatically generated from getconsdata.c. Do not edit! ***\n */\n";
44 for ($i = 0; $i < hex($addr)+4; $i += 4) {
45 print "#define $nam[$i] $dat[$i]\n";