blob: b92c693af293133ee0e5ce4445d1c592ac038e9d [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001#!/usr/bin/perl
2#
3# Copyright Statement:
4# --------------------
5# This software is protected by Copyright and the information contained
6# herein is confidential. The software may not be copied and the information
7# contained herein may not be used or disclosed except with the written
8# permission of MediaTek Inc. (C) 2006
9#
10# BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
11# THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
12# RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
13# AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
14# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
15# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
16# NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
17# SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
18# SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
19# THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
20# NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
21# SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
22#
23# BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
24# LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
25# AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
26# OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
27# MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
28#
29# THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
30# WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
31# LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
32# RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
33# THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
34#
35#*****************************************************************************
36#*
37#* Filename:
38#* ---------
39#* QueryDiscardedSym.pl
40#*
41#* Project:
42#* --------
43#*
44#*
45#* Description:
46#* ------------
47#*
48#*
49#*
50#* Author:
51#* -------
52#* Carl Kao (mtk08237)
53#*
54#*------------------------------------------------------------------------------
55#* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
56#*============================================================================
57#****************************************************************************/
58use strict;
59BEGIN { push @INC, "./" , '../', './tools/', './tools/MemoryUtility/' }
60use MapFileParser;
61
62my ($option, $file1, $file2) = @ARGV;
63
64if(($option eq "-Q") || ($option eq "-q"))
65{
66 MapFileParser::ParseMAP($file1);
67 my %discard;
68 MapFileParser::GetDiscardSymbol(\%discard);
69 ListDiscardedSymbols(\%discard);
70}
71elsif(($option eq "-C") || ($option eq "-c"))
72{
73 MapFileParser::ParseMAP($file1);
74 my %discard1;
75 MapFileParser::GetDiscardSymbol(\%discard1);
76
77 MapFileParser::ParseMAP($file2);
78 my %discard2;
79 MapFileParser::GetDiscardSymbol(\%discard2);
80
81 DiffDiscardedSymbols(\%discard1, \%discard2);
82}
83
84
85
86
87sub ListDiscardedSymbols
88{
89 my ($DiscardSym_href) = @_;
90 print "SymbolName Size \n";
91 print "*********************************************************************************************************************\n";
92 foreach my $key (sort keys %$DiscardSym_href)
93 {
94 $~ = "AAA";
95 format AAA =
96@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
97$key,$DiscardSym_href->{$key}
98.
99write;
100 }
101}
102
103
104sub DiffDiscardedSymbols
105{
106 my ($DiscardSym1_href, $DiscardSym2_href) = @_;
107 my %CompareDiscard;
108 foreach my $key1 (sort keys %$DiscardSym1_href)
109 {
110 $CompareDiscard{$key1} = [$DiscardSym1_href->{$key1}, ""];
111 }
112 foreach my $key2 (keys %$DiscardSym2_href)
113 {
114 if(!exists $CompareDiscard{$key2})
115 {
116 $CompareDiscard{$key2} = ["", $DiscardSym2_href->{$key2}];
117 }
118 else
119 {
120 $CompareDiscard{$key2}->[1] = $DiscardSym2_href->{$key2};
121 }
122 }
123 print " $file1 \nvs. $file2\n";
124 print "Size1 Size2 SymbolName \n";
125 print "*********************************************************************************************************************\n";
126 my ($nTotalSize1, $nTotalSize2) = (0,0);
127 foreach my $key (sort keys %CompareDiscard)
128 {
129# print $key, $CompareDiscard{$key}->[0] , $CompareDiscard{$key}->[1] ."\n";
130 next if($CompareDiscard{$key}[0] eq $CompareDiscard{$key}[1]);
131 $nTotalSize1 += $CompareDiscard{$key}[0];
132 $nTotalSize2 += $CompareDiscard{$key}[1];
133 $~ = "SYMBOLS";
134 format SYMBOLS =
135@<<<<<<<<<<<<@<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
136$CompareDiscard{$key}[0],$CompareDiscard{$key}[1],$key
137.
138write;
139 }
140 print "*********************************************************************************************************************\nTotal\n";
141 $~ = "TOTALDIFF";
142 format TOTALDIFF =
143@<<<<<<<<<<<<@<<<<<<<<<<<<
144$nTotalSize1,$nTotalSize2
145.
146write;
147}