blob: 3a0a07b1c1ef74a305b4f9d91fc2059d3afdd51d [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#!/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#* BasicMemInfoQuery.pm
40#*
41#* Project:
42#* --------
43#*
44#*
45#* Description:
46#* ------------
47#* This perl module is used to collect information from map file
48#*
49#*
50#* History:
51#* --------
52#* 2015/10/28, Carl, Support LinkerSymPostfix::ZILength
53#*
54#*
55#* Author:
56#* -------
57#* Carl Kao (mtk08237)
58#*
59#****************************************************************************/
60package LinkerOutputParser;
61BEGIN { push @INC, './tools/', './tools/MemoryUtility/', '../' }
62use Storable;
63use MapFileParser;
64use SymFileParser;
65
66my $strFilePath;
67my $strFileType;
68
69my $check_parse = undef;
70
71my $VERNO = " u0.01";
72 # u0.01 , 2015/01/19, Initial revision
73
74
75return 1;
76
77#****************************************************************************
78# subroutine: FileParse
79# Must be called first if you want to call other sub functions
80# input: MAP Path string
81# output: x
82#****************************************************************************
83sub FileParse
84{
85 $check_parse = 1;
86 ($strFilePath) = @_;
87 if ($strFilePath =~ /map$/)
88 {
89 &MapFileParser::ParseMAP($strFilePath);
90 $strFileType =~ s/map//ig;
91 $strFileType .= "MAP";
92 }
93 elsif ($strFilePath =~ /sym$/)
94 {
95 &SymFileParser::ParseSYM($strFilePath);
96 $strFileType =~ s/sym//ig;
97 $strFileType .= "SYM";
98 }
99}
100
101#****************************************************************************
102# subroutine: StoreIntoTempFile
103# input: N/A
104# output: temp files which contain perl data structure
105# MapParser_Temp.dat
106# SymParser_Temp.dat
107# data is stored into hash in xxxParser_Temp.dat
108#****************************************************************************
109sub StoreIntoTempFile
110{
111 die "Must run &FileParse subroutine before run &StoreIntoTempFile\n" if (!defined $check_parse);
112 my ($strPath) = @_;
113 if ($strFileType =~ /MAP/i)
114 {
115 &MapFileParser::StoreIntoTempFile($strPath);
116 }
117 elsif ($strFileType =~ /SYM/i)
118 {
119 &SymFileParser::StoreIntoTempFile($strPath);
120 }
121}
122
123#****************************************************************************
124# subroutine: GetParentOfSymbol
125# input: Symbol Name, $strOption (Case sensitive)
126# $strOption = "all" or "lib" or "obj"
127# output: For map file, output is array reference,
128# $strOption = "all", array content:[array1,array2,...]
129# array1:[obj1,lib1]
130# $strOption = "obj", array content:[obj1,obj2,...]
131# $strOption = "lib", array content:[lib1,lib2,...]
132#****************************************************************************
133sub GetParentOfSymbol
134{
135 die "Must run &FileParse subroutine before run &GetParentOfSymbol\n" if (!defined $check_parse);
136 my ($strSymbolName, $strOption) = @_;
137 my $parent_aref;
138if($strFileType =~ /MAP/i)
139 {
140 die "Option should be all/obj/lib\n" if (($strOption ne "all") && ($strOption ne "obj") && ($strOption ne "lib"));
141 $parent_aref = &MapFileParser::GetParentOfSymbol($strSymbolName, $strOption);
142 }
143 return $parent_aref;
144}
145
146#****************************************************************************
147# subroutine: GetChildOfSymbol
148# input: Symbol Name (Case sensitive)
149# output: For map file, output is array reference,
150# array content:[sym1,sym2,...]
151#****************************************************************************
152sub GetChildOfSymbol
153{
154 die "Must run &FileParse subroutine before run &GetChildOfSymbol\n" if (!defined $check_parse);
155 my ($strSymbolName) = @_;
156 my $child_aref;
157 if($strFileType =~ /MAP/i)
158 {
159 $child_aref = &MapFileParser::GetChildOfSymbol($strSymbolName);
160 }
161 return $child_aref;
162}
163
164#****************************************************************************
165# subroutine: ListAllExeRegion
166# input: $bTrimDebugRegion: only useful for GCC.
167# 1= NeedtoTrimDebugRegion, 0 or undef=NoNeedToTrimDebugRegion
168# output: For map file, output is array reference,
169# array content:[ExeRegionName1,ExeRegionName2,...]
170#****************************************************************************
171sub ListAllExeRegion
172{
173 die "Must run &FileParse subroutine before run &ListAllExeRegion\n" if (!defined $check_parse);
174 my ($bTrimDebugRegion) = @_;
175 my $ExeRegion_aref;
176
177 if($strFileType =~ /SYM/i)
178 {
179 $ExeRegion_aref = &SymFileParser::ListAllExeRegion($bTrimDebugRegion);
180 }
181 return $ExeRegion_aref;
182}
183
184#****************************************************************************
185# subroutine: ListAllLoadRegion
186# input: N/A
187# output: for map file, output array reference
188# array content: [LoadRegionName1,LoadRegionName2,...]
189#****************************************************************************
190sub ListAllLoadRegion
191{
192 die "Must run &FileParse subroutine before run &ListAllLoadRegion\n" if (!defined $check_parse);
193 my $LoadRegion_aref;
194 if($strFileType =~ /MAP/i)
195 {
196 $LoadRegion_aref = &MapFileParser::ListAllLoadRegion;
197 }
198 return $LoadRegion_aref;
199}
200
201#****************************************************************************
202# subroutine: ListPadInfo
203# input: N/A
204# output: array reference
205# for map file, array content:[pad_array1,pad_array2,...]
206# pad_array1:[strPadBaseAddress,[strPreObjName,strPreLibName],strPreObjAddress,[strPostObjName,strPostLibName],strPostObjAddress]
207#****************************************************************************
208sub ListPadInfo
209{
210 die "Must run &FileParse subroutine before run &ListPadInfo\n" if (!defined $check_parse);
211 my $pad_aref;
212 if($strFileType =~ /MAP/i)
213 {
214 $pad_aref = &MapFileParser::ListPadInfo;
215 }
216 return $pad_aref;
217}
218
219#****************************************************************************
220# subroutine: GetVeneerInfo
221# input: N/A
222# output: array reference, array content:[veneer_array1,veneer_arry2,...]
223# for map file,
224# veneer_array1 content:[strExeRegionName,strBaseAddress,strSize]
225#****************************************************************************
226sub GetVeneerInfo
227{
228 die "Must run &FileParse subroutine before run &GetVeneerInfo\n" if (!defined $check_parse);
229 my $veneer_aref;
230 if($strFileType =~ /MAP/i)
231 {
232 $veneer_aref = &MapFileParser::GetVeneerInfo;
233 }
234 return $veneer_aref;
235}
236
237#****************************************************************************
238# subroutine: GetObjSizeByExeRegion
239# input: ExeRegion Name, Object Name, Library Name(Case sensitive)
240# Object Name should contain ".obj"
241# Library Name should contain ".lib"
242# output: size of object in given execution region
243#****************************************************************************
244sub GetObjSizeByExeRegion
245{
246 die "Must run &FileParse subroutine before run &GetObjSizeByExeRegion\n" if (!defined $check_parse);
247 my ($strExeRegionName, $strObjName, $strLibName) = @_;
248 die "Object name must contain .obj/.o postfix\n" if ($strObjName !~ /\.o|\*\S*\*|stub|DSP/);
249 die "Library name must contain .lib/.a postfix\n" if ($strLibName !~ /\.l|\.a|\*\S*\*|\*stub\*|DSP/);
250 my $n_size;
251 if($strFileType =~ /MAP/i)
252 {
253 $n_size = &MapFileParser::GetObjSizeByExeRegion($strExeRegionName, $strObjName, $strLibName);
254 }
255 return $n_size;
256}
257
258#****************************************************************************
259# subroutine: GetObjSizeByCatExeRegion
260# input: ExeRegion Name, Object Name, $strCategory(Case sensitive)
261# Object Name should contain ".obj"
262# $strCategory: RO Data/RW Data/ZI Data/Code for lis
263# RO/RW/ZI for map
264# output: RO/RW/ZI/RWZI size of object in given execution region
265#****************************************************************************
266sub GetObjSizeByCatExeRegion
267{
268 die "Must run &FileParse subroutine before run &GetObjSizeByExeRegion\n" if (!defined $check_parse);
269 my ($strExeRegionName, $strObjName, $strCategory) = @_;
270 my $n_size = 0;
271 die "Object name must contain .obj/.o postfix\n" if ($strObjName !~ /\.o|\*\S*\*|stub|DSP/);
272 if($strFileType =~ /MAP/i)
273 {
274 die "Category should be RO/RW/ZI\n"
275 if (($strCategory ne "RO") && ($strCategory ne "RW") && ($strCategory ne "ZI"));
276 my $nObjCateSize_ref = &MapFileParser::GetObjSizeByCatExeRegion($strExeRegionName, $strCategory);
277 $n_size = $$nObjCateSize_ref{$strObjName};
278 }
279 return $n_size;
280}
281
282#****************************************************************************
283# subroutine: GetLibSizeByExeRegion
284# input: Execution Region Name, Library Name (Case sensitive)
285# Library Name should contain ".lib"
286# output: size of given library in givin execution region
287#****************************************************************************
288sub GetLibSizeByExeRegion
289{
290 die "Must run &FileParse subroutine before run &GetLibSizeByExeRegion\n" if (!defined $check_parse);
291 my ($strExeRegionName, $strLibName) = @_;
292 die "Library name must contain .lib/.a postfix\n" if (($strLibName !~ /\.l|\.a|\*\S*\*|\*stub\*|DSP/));
293 my $n_size;
294 if($strFileType =~ /MAP/i)
295 {
296 $n_size = &MapFileParser::GetLibSizeByExeRegion($strExeRegionName, $strLibName);
297 }
298 return $n_size;
299}
300
301#****************************************************************************
302# subroutine: GetObjByExeRegion
303# input: Execution Region Name (Case sensitive)
304# output: array reference which given execution region contains
305# array content:[strObjName1,strObjName2,...]
306#****************************************************************************
307sub GetObjByExeRegion
308{
309 die "Must run &FileParse subroutine before run &GetObjByExeRegion\n" if (!defined $check_parse);
310 my ($strExeRegionName) = @_;
311 my $obj_aref;
312 if($strFileType =~ /MAP/i)
313 {
314 $obj_aref = &MapFileParser::GetObjByExeRegion($strExeRegionName);
315 }
316 return $obj_aref;
317}
318
319#****************************************************************************
320# subroutine: GetLibByExeRegion
321# input: Execution Region Name (Case sensitive)
322# output: array reference which given execution region contains
323# array content:[strLibName1,strLibName2,...]
324#****************************************************************************
325sub GetLibByExeRegion
326{
327 die "Must run &FileParse subroutine before run &GetLibByExeRegion\n" if (!defined $check_parse);
328 my ($strExeRegionName) = @_;
329 my $lib_aref;
330 if($strFileType =~ /MAP/i)
331 {
332 $lib_aref = &MapFileParser::GetLibByExeRegion($strExeRegionName);
333 }
334 return $lib_aref;
335}
336
337#****************************************************************************
338# subroutine: ListObjSummaryInfo
339# input: obj name, strOption represents which column to show(Case sensitive)
340# OBJ name should contain ".obj"
341# strOption = "Code"
342# = "inc.data"
343# = "RO Data"
344# = "RW Data"
345# = "ZI Data"
346# = "Debug"
347# output: for map file, output undef
348#****************************************************************************
349sub ListObjSummaryInfo
350{
351 die "Must run &FileParse subroutine before run &ListObjSummaryInfo\n" if (!defined $check_parse);
352 my ($strObjName, $strOption) = @_;
353 die "Object name must contain .obj/.o postfix\n" if ($strObjName !~ /\.o|\*\S*\*|stub|DSP/);
354 my $n_size;
355 if($strFileType =~ /MAP/i)
356 {
357 die "Input should be RO/RW/ZI/Debug\n" if (($strOption ne "RO") && ($strOption ne "RW") && ($strOption ne "ZI") && ($strOption ne "Debug"));
358 $n_size = &MapFileParser::ListObjSummaryInfo($strObjName, $strOption);
359 }
360 $n_size = 0 if(!defined $n_size or $n_size eq "");
361 return $n_size;
362}
363
364#****************************************************************************
365# subroutine: ListLibSummaryInfo
366# input: lib name, strOption represents which column to show(Case sensitive)
367# Lib name should contain ".lib"
368# strOption = "Code"
369# = "inc.data"
370# = "RO Data"
371# = "RW Data"
372# = "ZI Data"
373# = "Debug"
374# output: for map file, output undef
375#****************************************************************************
376sub ListLibSummaryInfo
377{
378 die "Must run &FileParse subroutine before run &ListLibSummaryInfo\n" if (!defined $check_parse);
379 my ($strLibName, $strOption) = @_;
380 die "Library name must contain .lib/.a postfix\n" if ($strLibName !~ /\.l|\.a|\*\S*\*|\*stub\*|DSP/);
381 my $n_size = 0;
382 if($strFileType =~ /MAP/i)
383 {
384 die "Input should be RO/RW/ZI/Debug\n" if (($strOption ne "RO") && ($strOption ne "RW") && ($strOption ne "ZI") && ($strOption ne "Debug"));
385 $n_size = &MapFileParser::ListLibSummaryInfo($strLibName, $strOption);
386 }
387 $n_size = 0 if(!defined $n_size or $n_size eq "");
388 return $n_size;
389}
390
391#****************************************************************************
392# subroutine: GetVMAByExeRegion
393# input: $strRegionName: Execution Region Name (Case sensitive)
394# output: VMA for given execution region
395#****************************************************************************
396sub GetVMAByExeRegion
397{
398 die "Must run &FileParse subroutine before run &GetBaseAddrByExeRegion\n" if (!defined $check_parse);
399 my ($strExeRegionName) = @_;
400 my $n_size;
401 if($strFileType =~ /SYM/i)
402 {
403 $n_size = hex(&SymFileParser::GetExeRegionInfo($strExeRegionName, Region::VMA));
404 }
405 return $n_size;
406}
407
408#****************************************************************************
409# subroutine: GetTotalSizeByExeRegion
410# input: $strRegionName: Execution Region Name (Case sensitive)
411# output: total size for given execution region
412#****************************************************************************
413sub GetTotalSizeByExeRegion
414{
415 die "Must run &FileParse subroutine before run &GetTotalSizeByExeRegion\n" if (!defined $check_parse);
416 my ($strExeRegionName) = @_;
417 my $n_size;
418 if($strFileType =~ /SYM/i)
419 {
420 $n_size = hex(&SymFileParser::GetExeRegionInfo($strExeRegionName, Region::Size));
421 }
422 return $n_size;
423}
424
425#****************************************************************************
426# subroutine: GetTotalSizeByLib
427# input: $strLibName: Library Name (Case sensitive)
428# Library Name should contain ".lib"
429# output: total size for given library
430#****************************************************************************
431sub GetTotalSizeByLib
432{
433 die "Must run &FileParse subroutine before run &GetTotalSizeByLib\n" if (!defined $check_parse);
434 my ($strLibName) = @_;
435 die "Library name must contain .lib/.a postfix\n" if (($strLibName !~ /\.l|\.a|\*\S*\*|\*stub\*|DSP/));
436 my $n_size;
437 if($strFileType =~ /MAP/i)
438 {
439 $n_size = &MapFileParser::GetTotalSizeByLib($strLibName);
440 }
441 return $n_size;
442}
443
444#****************************************************************************
445# subroutine: GetTotalSizeByObj
446# input: $strObjName: Obj Name, $strLibName: Library Name (Case sensitive)
447# Object Name should contain ".obj"
448# Library Name should contain ".lib"
449# output: total size for given (obj, library)
450#****************************************************************************
451sub GetTotalSizeByObj
452{
453 die "Must run &FileParse subroutine before run &GetTotalSizeByObj\n" if (!defined $check_parse);
454 my ($strObjName, $strLibName) = @_;
455 die "Object name must contain .obj/.o postfix\n" if ($strObjName !~ /\.o|\*\S*\*|stub|DSP/);
456 die "Library name must contain .lib/.a postfix\n" if (($strLibName !~ /\.l|\.a|\*\S*\*|\*stub\*|DSP/));
457 my $n_size;
458 if($strFileType =~ /MAP/i)
459 {
460 $n_size = &MapFileParser::GetTotalSizeByObj($strObjName, $strLibName);
461 }
462 return $n_size;
463}
464
465#****************************************************************************
466# subroutine: ListObjLibBySymbol
467# input: $strSymName: Symbol Name (Case sensitive)
468# output: for map file, output array reference
469# array content:[[strObjName1,strLibName1],[strObjName2,strLibName2],...]
470#****************************************************************************
471sub ListObjLibBySymbol
472{
473 die "Must run &FileParse subroutine before run &ListObjLibBySymbol\n" if (!defined $check_parse);
474 my ($strSymName) = @_;
475 my $obj_lib_aref;
476 if($strFileType =~ /MAP/i)
477 {
478 $obj_lib_aref = &MapFileParser::ListObjLibBySymbol($strSymName);
479 }
480 return $obj_lib_aref;
481}
482
483#****************************************************************************
484# subroutine: ListObjByLib
485# input: $strLibName: Library Name (Case sensitive)
486# Library Name should contain ".lib"
487# output: obj array reference associated with given library
488# array content:[strObjName1,strObjName2,...]
489#****************************************************************************
490sub ListObjByLib
491{
492 die "Must run &FileParse subroutine before run &ListObjByLib\n" if (!defined $check_parse);
493 my ($strLibName) = @_;
494 die "Library name must contain .lib/.a postfix\n" if (($strLibName !~ /\.l|\.a|\*\S*\*|\*stub\*|DSP/));
495 my $obj_aref;
496 if($strFileType =~ /MAP/i)
497 {
498 $obj_aref = &MapFileParser::ListObjByLib($strLibName);
499 }
500 return $obj_aref;
501}
502
503#****************************************************************************
504# subroutine: ListLibByObj
505# input: $ObjName: Object Name (Case sensitive)
506# Object Name should contain ".obj"
507# output: Library array reference associated with given object
508# array content:[strLibName1,strLibName2,...]
509#****************************************************************************
510sub ListLibByObj
511{
512 die "Must run &FileParse subroutine before run &ListLibByObj\n" if (!defined $check_parse);
513 my ($strObjName) = @_;
514 die "Object name must contain .obj/.o postfix\n" if ($strObjName !~ /\.o|\*\S*\*|stub|DSP/);
515 my $lib_aref;
516 if($strFileType =~ /MAP/i)
517 {
518 $lib_aref = &MapFileParser::ListLibByObj($strObjName);
519 }
520 return $lib_aref;
521}
522
523#****************************************************************************
524# subroutine: ListObjLibByAddr
525# input: symbol address
526# output: objeck and lib info
527#****************************************************************************
528sub ListObjLibByAddr
529{
530 die "Must run &FileParse subroutine before run &ListObjLibByAddr\n" if (!defined $check_parse);
531
532 my ($strAddress) = @_;
533 my $obj_lib_by_addr;
534
535 if($strFileType =~ /MAP/i)
536 {
537 $obj_lib_by_addr = &MapFileParser::ListObjLibByAddr($strAddress);
538 }
539 return $obj_lib_by_addr;
540}
541
542#****************************************************************************
543# subroutine: GetObjDebugInfoSize
544# input: $strObjName: Obj Name (Case sensitive)
545# Object Name should contain ".obj"
546# output: debug info size for given obj
547#****************************************************************************
548sub GetObjDebugInfoSize
549{
550 die "Must run &FileParse subroutine before run &GetObjDebugInfoSize\n" if (!defined $check_parse);
551 my ($strObjName) = @_;
552 die "Object name must contain .obj/.o postfix\n" if ($strObjName !~ /\.o|\*\S*\*|stub|DSP/);
553 my $n_debugsize;
554 if($strFileType =~ /MAP/i)
555 {
556 $n_debugsize = &MapFileParser::GetObjDebugInfoSize($strObjName);
557 }
558 return $n_debugsize;
559}
560
561#****************************************************************************
562# subroutine: FootprintAnalyzeBySymbol
563# input: $strSymName: Symbol Name, $strObjName: Obj Name (Case sensitive)
564# Object Name should contain ".obj" (Not necessary input for GCC SYM file)
565# output: symbol info array reference
566# for non Ven/Pad symbol in lis file,[strExeRegionName,strAttr,strBaseAddress,strSize]
567# for Ven symbol in lis file,[strExeRegionName,strAttr,strBaseAddress,strSize,strDestinationSymbol]
568# for symbol in sym file,[strExeRegionName,strAttr,strBaseAddress,strSize]
569#****************************************************************************
570sub FootprintAnalyzeBySymbol
571{
572 die "Must run &FileParse subroutine before run &FootprintAnalyzeBySymbol\n" if (!defined $check_parse);
573 my ($strSymName, $strObjName) = @_;
574 my $SymbolInfo_ref;
575 if($strFileType =~ /SYM/i)
576 {
577 $SymbolInfo_ref = &SymFileParser::FootprintAnalyzeBySymbol($strSymName);
578 }
579 return $SymbolInfo_ref;
580}
581#****************************************************************************
582# subroutine: GetSymbolTable
583# input: N/A
584# output: symbol info hash reference in the following format:
585# $strAddress.$strSymbolName => [strSymbol, $strAddress, strGroup, strRegion, nSize]
586#****************************************************************************
587sub GetSymbolTable
588{
589 die "Must run &FileParse subroutine before run &GetSymbolTable\n" if (!defined $check_parse);
590 my $SymbolInfo_aref;
591 if($strFileType =~ /SYM/i)
592 {
593 $SymbolInfo_aref = &SymFileParser::GetSymbolTable();
594 }
595 return $SymbolInfo_aref;
596}
597
598#****************************************************************************
599# subroutine: GrepSymbolBySection
600# input: $strSectionName
601# output: symbol info array reference in order of address in the following format:
602# [[strSymbol, $strAddress, strGroup, strRegion, nSize], ...]
603#****************************************************************************
604sub GrepSymbolBySection
605{
606 die "Must run &FileParse subroutine before run &GrepSymbolBySection\n" if (!defined $check_parse);
607 my ($strSectionName) = @_;
608 my $SymbolInfo_aref;
609 if($strFileType =~ /SYM/i)
610 {
611 $SymbolInfo_aref = &SymFileParser::GrepSymbolBySection($strSectionName);
612 }
613 return $SymbolInfo_aref;
614}
615
616#****************************************************************************
617# subroutine: GetSymbolInfo
618# input: $strAddress.".".$SymbolName
619# output: [$SymbolName, $strAddress, $strObjName, $strLibName, $strPreExeRegion, $strInputSectionName, $nInputSectionSize]
620#
621#****************************************************************************
622sub GetSymbolInfo{
623
624 die "Must run &FileParse subroutine before run &GetSymbolInfo\n" if (!defined $check_parse);
625 my ($symbol_key) = @_;
626 my @symbol_info;
627
628 if($strFileType =~ /MAP/i)
629 {
630 @symbol_info = &MapFileParser::GetSymbolInfo($symbol_key);
631 }
632 return @symbol_info;
633}
634
635sub GetSymbol
636{
637 my $SymbolInfo_aref;
638 if($strFileType =~ /SYM/i)
639 {
640 $SymbolInfo_aref = &SymFileParser::GetSymbol();
641 }
642 return $SymbolInfo_aref;
643}
644
645sub GetFillInfo
646{
647 my $FillInfo_href;
648 if($strFileType =~ /MAP/i)
649 {
650 $FillInfo_href = &MapFileParser::GetFillInfo();
651 }
652 return $FillInfo_href;
653}
654
655#****************************************************************************
656# subroutine: GetLinkerSymbolAddress
657# input: nRegionType = 0: Execution Region
658# nRegionType = 1: Load Region
659# nRegionType = 2: Input Section
660# nLocation: Base => LinkerSymPostfix::Base;
661# Limit => LinkerSymPostfix::Limit;
662# ZIBase => LinkerSymPostfix::ZIBase;
663# ZILimit => LinkerSymPostfix::ZILimit;
664# Length => LinkerSymPostfix::Length;
665# ZILength => LinkerSymPostfix::ZILength;
666# output: address in string
667#****************************************************************************
668sub GetLinkerSymbolAddress
669{
670 die "Must run &FileParse subroutine before run &GetLinkerSymbolAddress\n" if (!defined $check_parse);
671 my ($strRegionName, $nLocation, $nRegionType) = @_;
672 my $strAddr;
673 if($strFileType =~ /SYM/i)
674 {
675 $strAddr = &SymFileParser::GetLinkerSymbolAddress($strRegionName, $nLocation, $nRegionType);
676 }
677 return $strAddr;
678}
679
680#****************************************************************************
681# subroutine: Get_DUMMY_END_Size
682# input: N/A
683# output: size of DUMMY_END region
684#****************************************************************************
685sub Get_DUMMY_END_Size
686{
687 my $DUMMY_END_size;
688 if($strFileType =~ /SYM/i)
689 {
690 $DUMMY_END_size = &SymFileParser::Get_DUMMY_END_Size;
691 }
692 return $DUMMY_END_size;
693}
694
695#****************************************************************************
696# subroutine: Get_DUMMY_END_Base
697# input: N/A
698# output: base address of DUMMY_END region
699#****************************************************************************
700sub Get_DUMMY_END_Base
701{
702 my $DUMMY_END_base;
703 if($strFileType =~ /SYM/i)
704 {
705 $DUMMY_END_base = &SymFileParser::Get_DUMMY_END_Base;
706 }
707 return $DUMMY_END_base;
708}
709
710#****************************************************************************
711# subroutine: GetExeRegionInfo - Get Execution Region information
712# input: $strRegionName: Execution Name (Case sensitive)
713# $nOption for MAP file: Region::VMA
714# Region::LMA
715# Region::Size
716# Region::Offsets
717# Region::Align
718# Region::Attr
719# output: required ExeRegion Base address, Used Size, Region MaxSize, Attribute info...
720#****************************************************************************
721sub GetExeRegionInfo
722{
723 die "Must run &FileParse subroutine before run &GetExeRegionInfo\n" if (!defined $check_parse);
724 my ($strRegionName, $nOption) = @_;
725 my $strInfo;
726 if($strFileType =~ /SYM/i)
727 {
728 die "Option should be Region::VMA/Region::LMA/Region::Size/Region::Offsets/Region::Align/Region::Attr\n" if (($nOption ne Region::VMA) && ($nOption ne Region::LMA) && ($nOption ne Region::Size) && ($nOption ne Region::Offsets) && ($nOption ne Region::Align) && ($nOption ne Region::Attr));
729 $strInfo = &SymFileParser::GetExeRegionInfo($strRegionName, $nOption);
730 }
731 return $strInfo;
732}
733
734#****************************************************************************
735# subroutine: GetLoadRegionInfo - Get Load Region information
736# $nOption for map file: LoadRegion::Base
737# LoadRegion::Size
738# LoadRegion::MaxSize
739# LoadRegion::Attr
740# output: required LoadRegion Base address, Used Size, Region MaxSize, Attribute info
741#****************************************************************************
742sub GetLoadRegionInfo
743{
744 die "Must run &FileParse subroutine before run &GetLoadRegionInfo\n" if (!defined $check_parse);
745 my ($strRegionName, $nOption) = @_;
746 my $strInfo;
747 if($strFileType =~ /MAP/i)
748 {
749 $strInfo = &MapFileParser::GetLoadRegionInfo;
750 }
751 return $strInfo;
752}
753
754#****************************************************************************
755# subroutine: GetExeRegionAttr - Get Region attribution
756# output: region attribution =>[RO RW ZI]
757#****************************************************************************
758sub GetExeRegionAttr
759{
760 die "Must run &FileParse subroutine before run &GetExeRegionAttr\n" if (!defined $check_parse);
761 my $region_attr;
762 if($strFileType =~ /MAP/i)
763 {
764 $region_attr = &MapFileParser::GetExeRegionAttr;
765 }
766 return $region_attr;
767}
768
769#****************************************************************************
770# subroutine: GetTotalROSize - Get total RO size
771# input: $bNeedString: 1=Return string, 0/default/no input=Return int
772# output: $bNeedString=0:nROSize/ $bNeedString=1:strROSize
773#****************************************************************************
774sub GetTotalROSize
775{
776 die "Must run &FileParse subroutine before run &GetTotalROSize\n" if (!defined $check_parse);
777 my ($bNeedString) = @_;
778 my $n_size;
779 if($strFileType =~ /MAP/i)
780 {
781 $n_size = &MapFileParser::GetTotalROSize($bNeedString);
782 }
783 return $n_size;
784}
785
786#****************************************************************************
787# subroutine: GetTotalRWZISize - Get total RWZI size
788# input: $bNeedString: 1=Return string, 0/default/no input=Return int
789# output: $bNeedString=0:nRWZISize/ $bNeedString=1:strRWZISize
790#****************************************************************************
791sub GetTotalRWZISize
792{
793 die "Must run &FileParse subroutine before run &GetTotalRWZISize\n" if (!defined $check_parse);
794 my ($bNeedString) = @_;
795 my $n_size;
796 if($strFileType =~ /MAP/i)
797 {
798 $n_size = &MapFileParser::GetTotalRWZISize($bNeedString);
799 }
800 return $n_size;
801}
802
803#****************************************************************************
804# subroutine: GetTotalROMSize - Get total ROM size
805# input: $bNeedString: 1=Return string, 0/default/no input=Return int
806# output: $bNeedString=0:nROMSize/ $bNeedString=1:strROMSize
807#****************************************************************************
808sub GetTotalROMSize
809{
810 die "Must run &FileParse subroutine before run &GetTotalROMSize\n" if (!defined $check_parse);
811 my ($bNeedString) = @_;
812 my $n_size;
813 if($strFileType =~ /MAP/i)
814 {
815 $n_size = &MapFileParser::GetTotalROMSize($bNeedString);
816 }
817 return $n_size;
818}
819
820#****************************************************************************
821# subroutine: PadFillExeregSize -- search *fill* padding info for RO and RWZI in INTSRAM region
822# input: execution region name, memory type
823# output: memory size
824#****************************************************************************
825sub PadFillExeregSize
826{
827 my ($exeregion, $type)= @_;
828 my $size;
829 $size = &MapFileParser::PadFillExeregSize($exeregion, $type);
830 return $size;
831}
832
833#****************************************************************************
834# subroutine: GrepSymbolByInputSection
835# input: input section name represent in regular expression
836# ex: INTSRAM_ROCODE.*
837# INTSRAM_ROCODE_A
838# INTSRAM_ROCODE_B
839#
840# output: symbol info array reference in order of address in the following format:
841# [[$strSymbolName, $strAddress, $strObjName, $strLibName, $strOutputSectionName, $strInputSectionName, $nSize], ...]
842#****************************************************************************
843sub GrepSymbolByInputSection
844{
845 die "Must run &FileParse subroutine before run &GrepSymbolByInputSection\n" if (!defined $check_parse);
846 my ($strSectionNameInRegularExp) = @_;
847 my $syminfo_aref;
848 if($strFileType =~ /MAP/i)
849 {
850 $syminfo_aref = &MapFileParser::GrepSymbolByInputSection($strSectionNameInRegularExp);
851 }
852 return $syminfo_aref;
853}
854
855
856#****************************************************************************
857# subroutine: GrepSymbolByOutputSection
858# input: input section name represent in regular expression
859# ex: CACHED_EXTSRAM_L2CACHE_LOCK_DATA
860# CACHED_EXTSRAM_L2CACHE_LOCK_DATA
861# CACHED_EXTSRAM_L2CACHE_LOCK_DATA_ZI
862#
863# output: symbol info array reference in order of address in the following format:
864# [[$strObjName, $strLibName], [$strObjName, $strLibName] ...]
865#****************************************************************************
866sub GrepSymbolByOutputSection
867{
868 die "Must run &FileParse subroutine before run &GrepSymbolByInputSection\n" if (!defined $check_parse);
869 my ($strSectionNameInRegularExp) = @_;
870 my $syminfo_aref;
871 if($strFileType =~ /SYM/i)
872 {
873 $syminfo_aref = &SymFileParser::GrepSymbolByOutputSection($strSectionNameInRegularExp);
874 }
875 return $syminfo_aref;
876}
877
878
879__END__
880
881=head1 NAME
882
883LinkerOutputParser - Perl module to parse linker output files: .lis/.map/.sym
884
885=head1 SYNOPSIS
886
887 use LinkerOutputParser;
888
889=head2 Table of Contents
890
891LinkerOutputParser consists of a collection of modules whose details
892are too big to fit in one document. This POD itself explains the
893top-level APIs and general topics at a glance. For other topics and
894more details, see the PODs below:
895
896 Name Description
897 --------------------------------------------------------
898 LisFileParser Parser module for .lis file
899 MapFileParser Parser module for .map file
900 SymFileParser Parser module for .sym file
901 --------------------------------------------------------
902
903=head1 DESCRIPTION
904
905The module provides the interfaces to parse RVCT/GCC linker output files.
906
907=head1 EXAMPLES
908
909Here are some code samples showing a possible usage of LinkerOutputParser:
910
9111. How do I get all execution region list from .lis/.sym file?
912
913 use LinkerOutputParser;
914
915 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
916
917 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
918
919 my $exeregion_aref = &LinkerOutputParser::ListAllExeRegion;
920 if (defined $exeregion_aref)
921 {
922 foreach my $temp(@$exeregion_aref)
923 {
924 print "$temp\n";
925 }
926 }
927
928which prints (on my machine):
929
930 BL_GFH_SECTION
931 READ_ONLY
932 READ_ONLY_HEAD
933 READ_ONLY_TAIL
934 READ_WRITE
935 READ_ONLY_INT
936 READ_WRITE_INT
937 EMIINIT_CODE
938 STACK_AREA
939 EXT_UN_INIT
940 SHARE_BUF
941 READ_WRITE_SYS_RAM
942 DUMMY_END
943 BL_SIGNATURE_SECTION
944
9452. How do I get al load region list from .lis file?
946
947 use LinkerOutputParser;
948
949 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
950
951 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
952
953 my $loadregion_aref = &LinkerOutputParser::ListAllLoadRegion;
954 if (defined $loadregion_aref)
955 {
956 foreach my $temp(@$loadregion_aref)
957 {
958 print "$temp\n";
959 }
960 }
961
962which prints (on my machine):
963
964 READ_ONLY
965
9663. How do I get base address/size/maxsize/attribute of an execution region?
967
968 use LinkerOutputParser;
969
970 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
971
972 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
973
974 my $base_address = &LinkerOutputParser::GetExeRegionInfo('BL_GFH_SECTION', ExecutionRegion::Base);
975 print "$base_address\n";
976
977 my $size = &LinkerOutputParser::GetExeRegionInfo('BL_GFH_SECTION', ExecutionRegion::Size);
978 print "$size\n";
979
980which prints (on my machine):
981
982 0x40000900
983 0x150
984
9854. How do I get base address/size/maxsize/attribute of an load region?
986
987 use LinkerOutputParser;
988
989 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
990
991 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
992
993 my $base_address = &LinkerOutputParser::GetLoadRegionInfo('READ_ONLY', LoadRegion::Base);
994 print "$base_address\n";
995
996 my $size = &LinkerOutputParser::GetLoadRegionInfo('READ_ONLY', LoadRegion::Size);
997 print "$size\n";
998
999which prints (on my machine):
1000
1001 0x40000900
1002 0x4114
1003
10045. How do I get all objects in an execution region?
1005
1006 use LinkerOutputParser;
1007
1008 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1009
1010 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1011
1012 my $obj_aref = &LinkerOutputParser::GetObjByExeRegion("BL_GFH_SECTION");
1013 if (defined $obj_aref)
1014 {
1015 foreach my $temp(@$obj_aref)
1016 {
1017 print "$temp\n";
1018 }
1019 }
1020
1021which prints (on my machine):
1022
1023 bl_GFH_body.obj
1024 custom_emi_MT6255.obj
1025 bl_Secure_v5.obj
1026
10276. How do I get all libraries in an execution region?
1028
1029 use LinkerOutputParser;
1030
1031 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1032
1033 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1034
1035 my $lib_aref = &LinkerOutputParser::GetLibByExeRegion("READ_ONLY_TAIL");
1036 if (defined $lib_aref)
1037 {
1038 foreach my $temp(@$lib_aref)
1039 {
1040 print "$temp\n";
1041 }
1042 }
1043
1044which prints (on my machine):
1045
1046 bootloader.lib
1047 sss_rvct_sv5.lib
1048 c_5.l
1049 h_5.l
1050 f_5s.l
1051 sst_sec.lib
1052
10537. How do I get object, library associated with a symbol?
1054
1055 use LinkerOutputParser;
1056
1057 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1058
1059 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1060
1061 my $objlib_aref = &LinkerOutputParser::ListObjLibBySymbol(".text");
1062 foreach my $temp(@$objlib_aref)
1063 {
1064 print "$temp->[0], $temp->[1]\n";
1065 }
1066
1067which prints (on my machine):
1068
1069 strcpy.o, c_5.l
1070 _fptrap.o, c_5.l
1071 defsig_fpe_outer.o, c_5.l
1072 defsig_exit.o, c_5.l
1073 defsig_fpe_inner.o, c_5.l
1074 defsig_general.o, c_5.l
1075 sys_wrch.o, c_5.l
1076 rt_memcpy_w.o, c_5.l
1077 rt_memclr_w.o, c_5.l
1078 llmullu.o, h_5.l
1079 rt_memmove_w.o, c_5.l
1080 llmul.o, c_5.l
1081 rt_fp_status_addr.o, c_5.l
1082 sys_exit.o, c_5.l
1083 use_no_semi.o, c_5.l
1084
10858. How do I get all objects in a library?
1086
1087 use LinkerOutputParser;
1088
1089 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1090
1091 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1092
1093 my $obj_aref = &LinkerOutputParser::ListObjByLib("sst_sec.lib");
1094 if(defined $obj_aref)
1095 {
1096 foreach my $temp(@$obj_aref)
1097 {
1098 print "$temp\n";
1099 }
1100 }
1101
1102which prints (on my machine):
1103
1104 SSS_interface.obj
1105 br_crypto_platform.obj
1106
11079. How do I get all libraries associated with an object?
1108
1109 use LinkerOutputParser;
1110
1111 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1112
1113 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1114
1115 my $lib_aref = &LinkerOutputParser::ListLibByObj("lpwr.obj");
1116 if(defined $lib_aref)
1117 {
1118 foreach my $temp(@$lib_aref)
1119 {
1120 print "$temp\n";
1121 }
1122 }
1123
1124which prints (on my machine):
1125
1126 bootloader.lib
1127
112810. How do I get execution region total size?
1129
1130 use LinkerOutputParser;
1131
1132 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1133
1134 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1135
1136 my $exeregion_size = &LinkerOutputParser::GetTotalSizeByExeRegion("BL_GFH_SECTION");
1137 print "$exeregion_size\n";
1138
1139which prints (on my machine):
1140
1141 336
1142
114311. How do I get total size of a library?
1144
1145 use LinkerOutputParser;
1146
1147 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1148
1149 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1150
1151 my $lib_size = &LinkerOutputParser::GetTotalSizeByLib("f_5s.l");
1152 print "$lib_size\n";
1153
1154which prints (on my machine):
1155
1156 1320
1157
115812. How do I get total size of an object?
1159
1160 use LinkerOutputParser;
1161
1162 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1163
1164 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1165
1166 my $obj_size = &LinkerOutputParser::GetTotalSizeByObj("bl_BOOTARM.obj","bootloader.lib");
1167 print "$obj_size\n";
1168
1169which prints (on my machine):
1170
1171 4304
1172
117313. How do I get size of an object in a certain execution region?
1174
1175 use LinkerOutputParser;
1176
1177 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1178
1179 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1180
1181 my $obj_size = &LinkerOutputParser::GetObjSizeByExeRegion("READ_ONLY_TAIL", "bl_FTL.obj", "bootloader.lib");
1182 print "$obj_size\n";
1183
1184which prints (on my machine):
1185
1186 256
1187
118814. How do I get size of a library in a certain execution region?
1189
1190 use LinkerOutputParser;
1191
1192 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1193
1194 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1195
1196 my $lib_size = &LinkerOutputParser::GetLibSizeByExeRegion("BL_GFH_SECTION", "bootloader.lib"); ##300
1197 print "$lib_size\n";
1198
1199which prints (on my machine):
1200
1201 288
1202
120315. How do I get total RO size for a .lis file?
1204
1205 use LinkerOutputParser;
1206
1207 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1208
1209 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1210
1211 my $ROSize = &LinkerOutputParser::GetTotalROSize;
1212 print "Total ROSize is $ROSize\n";
1213
1214which prints (on my machine):
1215
1216 Total ROSize is 16452
1217
121816. How do I get total RWZI size for a .lis file?
1219
1220 use LinkerOutputParser;
1221
1222 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1223
1224 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1225
1226 my $RWZISize = &LinkerOutputParser::GetTotalRWZISize;
1227 print "Total RWZISize is $RWZISize\n";
1228
1229which prints (on my machine):
1230
1231 Total RWZISize is 52864
1232
123317. How do I get total ROM size for a .lis file?
1234
1235 use LinkerOutputParser;
1236
1237 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1238
1239 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1240
1241 my $ROMSize = &LinkerOutputParser::GetTotalROMSize;
1242 print "Total ROMSize is $ROMSize\n";
1243
1244which prints (on my machine):
1245
1246 Total ROMSize is 16660
1247
124818. How do I get debug info size for an object?
1249
1250 use LinkerOutputParser;
1251
1252 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1253
1254 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1255
1256 my $debug_size = &LinkerOutputParser::GetObjDebugInfoSize('SSS_Secure_v5.obj');
1257 print "$debug_size\n";
1258
1259which prints (on my machine):
1260
1261 4683
1262
126319. How do I get footprint infomation of a symbol?
1264
1265 use LinkerOutputParser;
1266
1267 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1268
1269 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1270
1271 my $footprint_info_ref = &LinkerOutputParser::FootprintAnalyzeBySymbol("i.CacheInitMini", "bl_Cache.obj");
1272 foreach my $temp(@$footprint_info_ref) ### array content: [ExecutionRegionName, Attribute, BaseAddress, Size] for common symbols
1273 { ### array content: [ExecutionRegionName, Attribute, BaseAddress, Size, DestinationSymbol] for veneers
1274 print "$temp\n";
1275 }
1276 print "\n";
1277
1278which prints (on my machine):
1279
1280 READ_ONLY_TAIL
1281 RO-Code
1282 0x40000b8c
1283 0x0000000c
1284
128520. How do I get parent symbols which refer to certain symbol?
1286
1287 use LinkerOutputParser;
1288
1289 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1290
1291 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1292
1293 my $parent_aref = &LinkerOutputParser::GetParentOfSymbol("NFIDriverInit");
1294 if(defined $parent_aref)
1295 {
1296 foreach my $temp(@$parent_aref)
1297 {
1298 print "$temp\n";
1299 }
1300 }
1301
1302which prints (on my machine):
1303
1304 Init
1305
130621. How do I get child symbols which certain symbol refers to?
1307
1308 use LinkerOutputParser;
1309
1310 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1311
1312 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1313
1314 my $child_aref = &LinkerOutputParser::GetChildOfSymbol("itoa");
1315 if(defined $child_aref)
1316 {
1317 foreach my $temp(@$child_aref)
1318 {
1319 print "$temp\n";
1320 }
1321 }
1322
1323which prints (on my machine):
1324
1325 __aeabi_idivmod
1326 .bss
1327
132822. How do I know pad infomation?
1329
1330 use LinkerOutputParser;
1331
1332 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1333
1334 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1335
1336 my $pad_aref = &LinkerOutputParser::ListPadInfo;
1337 if (defined $pad_aref)
1338 {
1339 foreach my $temp(@$pad_aref)
1340 {
1341 print "$temp->[0], $temp->[1], $temp->[2], $temp->[3], $temp->[4]\n";
1342 ### array content: [pad_address, previous_symbol_name, previous_symbol_address, post_symbol_name, post_symbol_address]
1343 }
1344 }
1345
1346which prints (on my machine):
1347
1348 0x40004075, x$divrt, 0x40003e80, x$fpl$dcmpinfnan, 0x40004078
1349 0x40004545, .constdata, 0x40004544, .constdata, 0x40004548
1350 0x40004652, .constdata, 0x40004548, .constdata, 0x40004654
1351 0x4000471a, .constdata, 0x40004654, .constdata, 0x4000471c
1352 0x40004822, .constdata, 0x4000471c, .constdata, 0x40004824
1353 0x40004b97, .bss, 0x4000496c, .bss, 0x40004b98
1354 0x40004bed, .bss, 0x40004bec, .bss, 0x40004bf0
1355 0x50000076, INTERNCODE, 0x50000068, INTERNCODE, 0x50000078
1356 0x40000e9e, i.TimeStampInit, 0x40000e9c, i.VerifyExtBootloader, 0x40000ea0
1357 0x40000ef2, EMIINITCODE, 0x40000eea, EMIINITCODE, 0x40000ef4
1358 0x40001cbe, i.GFH_Find, 0x40001cac, i.GFH_Internal_Parser, 0x40001cc0
1359 0x40003302, i.dbg_print, 0x400032ec, i.lpwr_default_callback, 0x40003304
1360
136123. How do I know veneer infomation?
1362
1363 use LinkerOutputParser;
1364
1365 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1366
1367 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1368
1369 my $veneer_aref = &LinkerOutputParser::GetVeneerInfo;
1370 if(defined $veneer_aref)
1371 {
1372 foreach my $temp(@$veneer_aref)
1373 {
1374 print "$temp->[0], $temp->[1], $temp->[2], $temp->[3]\n";
1375 ### array content: [ExecutionRegionName, BaseAddress, Size, DestinationSymbolName]
1376 }
1377 }
1378
1379which prints (on my machine):
1380
1381 READ_ONLY_TAIL, 0x40000c84, 0x00000008, JumpToExtBootloader
1382 READ_ONLY_TAIL, 0x40002808, 0x00000008, CP_Crypto_Init
1383 READ_ONLY_TAIL, 0x40002810, 0x00000008, CP_Get_MTK_Cipher_Key_Len
1384 READ_ONLY_TAIL, 0x40002818, 0x00000008, SaveAndSetIRQMask
1385 READ_ONLY_TAIL, 0x40002820, 0x00000008, RestoreIRQMask
1386 READ_ONLY_TAIL, 0x40002828, 0x00000008, JumpCmd
1387 READ_ONLY_INT, 0x5000004c, 0x00000008, SSS_Crypto_Config_Init
1388 READ_ONLY_INT, 0x50000054, 0x00000008, SSS_Crypto_Context_Validation
1389 READ_ONLY_INT, 0x5000005c, 0x00000008, ASSERT
1390
139124. What if I want to know Code/RO/RW/ZI/Debug size of an object?
1392
1393 use LinkerOutputParser;
1394
1395 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1396
1397 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1398
1399 my $ZIData_size = &LinkerOutputParser::ListObjSummaryInfo("lpwr.obj", "ZI Data");
1400 print "$ZIData_size\n";
1401
1402 my $Debug_size = &LinkerOutputParser::ListObjSummaryInfo("lpwr.obj", "Debug");
1403 print "$Debug_size\n";
1404
1405which prints (on my machine):
1406
1407 1946
1408 6344
1409
141025. What if I want to know Code/RO/RW/ZI/Debug size of a library?
1411
1412 use LinkerOutputParser;
1413
1414 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1415
1416 &LinkerOutputParser::FileParse($file); # Must run this subroutine first for other activities
1417
1418 my $ROData_size = &LinkerOutputParser::ListLibSummaryInfo("bootloader.lib", "RO Data");
1419 print "$ROData_size\n";
1420
1421 my $RWData_size = &LinkerOutputParser::ListLibSummaryInfo("bootloader.lib", "RW Data");
1422 print "$RWData_size\n";
1423
1424which prints (on my machine):
1425
1426 917
1427 208
1428
142926. How to retrieve data from temp files which reserved when parsing?
1430
1431 use LinkerOutputParser;
1432
1433 my $file = "E:\\APOLLO55N_V2_DEMO_BOOTLOADER_V005_MT6255_MAUI_11B_W12_08.lis";
1434
1435 &LinkerOutputParser::FileParse($file);
1436 &LinkerOutputParser::StoreIntoTempFile("E:\\mtk80506"); ## You can identify your preferred path to store temp files
1437
1438 my $data_hash = retrieve 'E:\\mtk80506\\LisParser_Temp.dat'; ## temp file names: your_path\LisParser_Temp.dat or your_path\SymParser_Temp.dat or your_path\MapParser_Temp.dat
1439 foreach my $key (keys %$data_hash)
1440 {
1441 print "$key\n";
1442 }
1443
1444which prints (on my machine):
1445
1446 debug_size
1447 parent_reference
1448 symbol_info
1449 obj_summary
1450 execution_region
1451 child_reference
1452 load_region
1453 lib_summary
1454
1455 Then you can retrieve more detailed data, for example, you want to retrieve "child_reference" data (usually are hash/array reference):
1456
1457 my $child_value = $$data_hash{"child_reference"};
1458
1459 foreach my $key (keys %$child_value)
1460 {
1461 my $array_ref = $$child_value{$key};
1462 foreach my $temp(@$array_ref)
1463 {
1464 print "$key->$temp\n";
1465 }
1466 }
1467
1468which prints (on my machine):
1469
1470 lpwr_group_init->.bss
1471 lpwr_group_init->.constdata
1472 _3DES_KeyOptionHandler->__aeabi_memcpy
1473 Init->uart_init
1474 Init->set_debug_level
1475 Init->bl_print
1476 Init->DclF32K_Initialize
1477 Init->WaitFor32KStable
1478 Init->lpwr_init
1479 Init->DRVPDN_ini
1480 Init->NFIDriverInit
1481 Init->bl_Is_Brom_Cmd_Mode_Disabled
1482 Init->DummyReference
1483 Init->SSS_Init_Share_Crypto_Drv
1484 Init->SST_SWB_Init
1485 Init->bootloader_debug_level
1486 Init->g_randomSeed
1487 Init->BL_RESV_REGION
1488 Init->g_bromCmdModeDisabled
1489 Init->EMI_INFO_2
1490 Init->__user_initial_stackheap
1491 kal_assert_fail_specific_ext->dbg_print
1492 drv_get_duration_ms->drv_get_duration_tick
1493 ...
1494
1495=cut