imgtools/romtools/maksym/maksymrofs.pl
author marvin shi <marvin.shi@nokia.com>
Tue, 30 Nov 2010 17:14:57 +0800
changeset 714 e5a58c351011
parent 654 7c11c3d8d025
permissions -rw-r--r--
feature bsym format symbol rombuild support
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
590
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
     1
#
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
     2
# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
     3
# All rights reserved.
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
     4
# This component and the accompanying materials are made available
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
     6
# which accompanies this distribution, and is available
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
     8
#
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
     9
# Initial Contributors:
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
    10
# Nokia Corporation - initial contribution.
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
    11
#
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
    12
# Contributors:
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
    13
#
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
    14
# Description: 
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
    15
# Produces symbolic information given a ROFS log file and .map files for relevant binary files
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
    16
#
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
    17
714
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    18
require 5.003_07;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    19
no strict 'vars';
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    20
use English;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    21
use FindBin;		# for FindBin::Bin
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    22
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    23
# Version
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    24
my $MajorVersion = 1;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    25
my $MinorVersion = 1;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    26
my $PatchVersion = 0;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    27
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    28
# Globals
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    29
my $maksym = "";
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    30
my $rofsbuild;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    31
my $debug = 0;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    32
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    33
&args;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    34
&main;
590
360bd6b35136 buildrom v3.24.0, rombuild v2.17.3, rofsbuild v2.10.4, resource compiler v8.4.001, image check v1.4.0, elftools v2.3, elf2e32 v2.3
jjkang
parents: 0
diff changeset
    35
exit 0;
714
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    36
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    37
#
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    38
# main
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    39
#
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    40
sub main()
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    41
{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    42
	my $symbolfile = $rofsbuild;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    43
  	$symbolfile =~ s/\.log$/\.symbol/i;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    44
  	my @cmdres = `rofsbuild -loginput=$rofsbuild`;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    45
  	print "@cmdres\n";
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    46
	if(($maksym ne "") && ($maksym ne $symbolfile))
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    47
 	{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    48
	 	rename($symbolfile, $maksym);
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    49
  	}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    50
}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    51
#
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    52
# args - get command line args
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    53
#
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    54
sub args
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    55
{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    56
	my $arg;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    57
	my @args;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    58
	my $flag;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    59
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    60
	&help if (!@ARGV);
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    61
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    62
	while (@ARGV) 
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    63
	{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    64
		$arg = shift @ARGV;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    65
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    66
		if ($arg=~/^[\-](\S*)$/) 
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    67
		{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    68
			$flag=$1;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    69
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    70
			if ($flag=~/^[\?h]$/i) 
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    71
			{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    72
				&help;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    73
			}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    74
			elsif ($flag=~/^d$/i) 
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    75
			{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    76
				$debug = 1;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    77
			}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    78
		       	else 
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    79
			{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    80
				print "\nERROR: Unknown flag \"-$flag\"\n";
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    81
				&usage;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    82
				exit 1;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    83
			}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    84
		}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    85
		else 
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    86
		{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    87
			push @args,$arg;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    88
		}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    89
	}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    90
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    91
	if (@args)
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    92
	{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    93
		$rofsbuild = shift @args;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    94
		if (@args) 
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    95
		{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    96
			$maksym = shift @args;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    97
			if (@args) 
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    98
			{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
    99
				print "\nERROR: Incorrect argument(s) \"@args\"\n";
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   100
				&usage;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   101
				exit 1;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   102
			}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   103
		}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   104
	}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   105
}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   106
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   107
sub help ()
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   108
{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   109
	my $build;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   110
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   111
	print "\nmaksymrofs - Produce symbolic information given a ROFS image V${MajorVersion}.${MinorVersion}.${PatchVersion}\n";
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   112
	&usage;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   113
	exit 0;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   114
}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   115
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   116
sub usage ()
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   117
{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   118
    print <<EOF
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   119
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   120
Usage:
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   121
  maksymrofs <logfile> [<outfile>]
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   122
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   123
Where:
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   124
  <logfile>   Log file from rofsbuild tool.
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   125
  <outfile>   Output file. Defaults to imagename.symbol.
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   126
EOF
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   127
    ;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   128
    exit 0;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 654
diff changeset
   129
}