summaryrefslogtreecommitdiff
path: root/software/get_discards
blob: 5436118893b0d18a941f74559dd4236417f7e522 (plain)
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
#!/usr/bin/php

<?php
/*
 * Written by Jared Smith and Kevin P. Fleming
 *
 * Copyright (C) 2006, Jared Smith and Digium, Inc.
 *
 */

# create an array of all the different prefixes you want to match on,
# as Perl-compatible regular expressions
# (yes, this is a stupid example, as the second one is just a simplified
# version of the first, but it's just an example)
$prefixes = array('\.text\.Oct');

$fp = fopen('test.map','r');

while (!feof($fp))
{
        # Loop until we find the top of section we want
        while ($line = fgets($fp))
        {
                if (preg_match('/Discarded input sections/i',$line))
                {
                        break;
                }
        }

        # Now loop until we find the next section
        while ($line = fgets($fp))
        {
                if (preg_match('/Memory Configuration/i',$line))
                {
                        # we found it!
                        break;
                }
                foreach ($prefixes as $prefix)
                {
                        if (preg_match("/$prefix/i",$line))
                        {
				preg_match("/Oct.*/", $line, $matches);
                                $line2 = fgets($fp);
				echo "#define SKIP_".$matches[0]." 1\n";
                                break;
                        }
                }
        }
}
fclose($fp);
?>