sbsv1/abld/platform/sym_lkup_util.pl
author jjkang
Fri, 25 Jun 2010 19:56:45 +0800
changeset 604 b33dd54aaa52
parent 599 fa7a3cc6effd
child 606 30b30f9da0b7
permissions -rw-r--r--
add cpptoolsplat
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
#!/usr/bin/perl
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
use FindBin;		# for FindBin::Bin
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
use Getopt::Long;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
BEGIN {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
# check user has a version of perl that will cope
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
	require 5.005_03;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
# establish the path to the Perl libraries: currently the same directory as this script
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
	$PerlLibPath = $FindBin::Bin;	# X:/epoc32/tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
	if ($^O eq "MSWin32")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
		$PerlLibPath =~ s/\//\\/g;	# X:\epoc32\tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
		$PerlLibPath .= "\\";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
use lib $PerlLibPath;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
my $IgnoreExportDir = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
my $ImportSymFile;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
my $CppFile;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
my $mapFile;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
my $SegmentContentSz = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
my $nSyms = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
my $nImports = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
my %Symbols = ();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
my @Imports = ();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
	unless (GetOptions(\%Options, 'sym=s', 'o=s', 'map=s', 'ignore_export_dir')) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
		exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
	$ImportSymFile = $Options{sym};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
	$CppFile = $Options{o};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
	$mapFile = $Options{map};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
	$IgnoreExportDir = $Options{ignore_export_dir};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
	ReadSymFile() if $ImportSymFile;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
	ReadMapFile() if $mapFile;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
	GenNamedSegment();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
sub ReadMapFile() {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
	open FILE, $mapFile or die "Error :SymLookup: Cannot open map file $mapFile\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
	my $GlbSyms = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
	while(<FILE>) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
		if($_ =~ /Public Symbols/) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
			$GlbSyms = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
		elsif( !$GlbSyms ) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
			next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
		if($_ =~ /([0-9a-fA-F]{8})\s+(\S+)\s+_?(\S+)\s/){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
			$addr = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
			$module = $2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
			$name = $3;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
			if( defined $Symbols{$name} ) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
				$Symbols{$name} = $addr;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
#	Remove symbols not found in map file
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
	foreach my $sym (keys %Symbols){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
		if( !$Symbols{$sym} ){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
			delete $Symbols{$sym};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    84
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    86
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
sub ReadSymFile() {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
	open FILE, $ImportSymFile or die "Error :SymLookup: Cannot open file $ImportSymFile\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91
	my $ImportDirSeen = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    92
	my $ExportDirSeen = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    93
	my $ExportNameTblSeen = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    94
	my $numOfExportNames = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    95
	my $nameCount = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    96
	while (<FILE>) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    97
# Ignore export table(s) if the flag '$IgnoreExportDir' is set. This flag is set for stddlls, as symbol listing 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    98
# is not required for them. The windows API GetProcAddr can be used directly. While for stdexe, the symbol names
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    99
# are filtered out and then looked up in the map file for their addresses.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   100
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   101
		if($_ =~ /\*\*\* EXPORT DIRECTORY \*\*\*/){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   102
			next if($IgnoreExportDir);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   103
			$ExportDirSeen = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   104
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   105
		elsif($_ =~ /\*\*\* Export Name Pointer Table \*\*\*/){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   106
			next if($IgnoreExportDir);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   107
			$ExportNameTblSeen = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   108
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   109
		elsif($_ =~ /\*\*\* IMPORT DIRECTORY \*\*\*/) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   110
			$ImportDirSeen = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   111
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   112
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   113
		if($ExportDirSeen){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   114
			if($_ =~ /numberofnames\s+=\s+0x(\S+)/){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   115
				$numOfExportNames = hex($1);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   116
# Reset the flag once done with the export table
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   117
				$ExportDirSeen = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   118
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   119
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   120
		elsif($ExportNameTblSeen && $numOfExportNames){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   121
			if($_ =~ /\d+\s+0x[0-9a-fA-F]+\s+(\S+)/){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   122
				$Symbols{$1}=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   123
# Keep track of the symbols seen in "Export Name Pointer Table"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   124
				$nameCount++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   125
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   126
			if($nameCount == $numOfExportNames){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   127
# Reset the flag once done with the name table
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   128
				$ExportNameTblSeen = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   129
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   130
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   131
		elsif($ImportDirSeen) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   132
			if($_ =~ /^DLL name\s+=\s+\S+\s+\((\S+)\)/) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   133
				my $dllname = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   134
				push @Imports, $dllname;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   135
				$ImportDirSeen = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   136
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   137
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   138
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   139
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   140
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   141
sub GenNamedSegment() {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   142
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   143
	my $SegContents = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   144
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   145
	&Header(\$SegContents);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   146
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   147
	&SymAddrTbl(\$SegContents);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   148
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   149
	&SymNames(\$SegContents);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   150
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   151
	&Footer(\$SegContents);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   152
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   153
	open OUTFILE, ">$CppFile" or die "Error :SymLookup:Cannot open file $CppFile\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   154
	print OUTFILE $SegContents;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   155
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   156
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   157
sub Header(){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   158
	my $SegContentsRef = shift @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   159
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   160
	$$SegContentsRef .= "\/\* $CppFile\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   161
	$$SegContentsRef .= " \* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).  All rights reserved.\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   162
	$$SegContentsRef .= " \* Makmake-generated source file for named symbol lookup\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   163
	$$SegContentsRef .= " \*\/\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   164
	$$SegContentsRef .= "#pragma data_seg(\".expdata\")";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   165
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   166
	$$SegContentsRef .= "\n\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   167
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   168
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   169
sub Footer() {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   170
	my $SegContentsRef = shift @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   171
	$$SegContentsRef .= "\n#pragma data_seg()\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   172
	$$SegContentsRef .= "\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   173
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   174
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   175
sub SymAddrTbl(){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   176
	my $SegContentsRef = shift @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   177
	$nSyms = keys %Symbols;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   178
	$nImports = @Imports;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   179
	$$SegContentsRef .= "int NSymbols = $nSyms;\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   180
	$$SegContentsRef .= "int NImports = $nImports;\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   181
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   182
	if(!$nSyms) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   183
		return;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   184
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   185
	$$SegContentsRef .= "int addresses[] = {\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   186
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   187
	foreach $key (sort keys %Symbols) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   188
		if($Symbols{$key}){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   189
			$$SegContentsRef .= "\t0x".$Symbols{$key}.",\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   190
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   191
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   192
	$$SegContentsRef .= "};\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   193
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   194
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   195
sub SymNames() {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   196
	if(!$nImports && !$nSyms){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   197
		return;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   198
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   199
	my $SegContentsRef = shift @_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   200
	$$SegContentsRef .= "\nchar data[] = {\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   201
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   202
	my $symnames ;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   203
	my $colCnt ;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   204
	foreach $symnames (sort keys %Symbols) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   205
		next if( $Symbols{$symnames} == 0);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   206
		my @chars = split(//,$symnames);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   207
		$$SegContentsRef .= "\t";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   208
		$colCnt =0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   209
		foreach $aChar (@chars) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   210
			if($colCnt >= 80) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   211
				$$SegContentsRef .= "\\\n\t";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   212
				$colCnt = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   213
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   214
			$$SegContentsRef .= "\'$aChar\',";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   215
			$colCnt += 4;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   216
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   217
		$$SegContentsRef .= "0,\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   218
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   219
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   220
	foreach my $dll (@Imports) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   221
		my @chars = split(//,$dll);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   222
		$$SegContentsRef .= "\t";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   223
		$colCnt =0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   224
		foreach $aChar (@chars) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   225
			if($colCnt >= 80) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   226
				$$SegContentsRef .= "\\\n\t";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   227
				$colCnt = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   228
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   229
			$$SegContentsRef .= "\'$aChar\',";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   230
			$colCnt += 4;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   231
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   232
		$$SegContentsRef .= "0,\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   233
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   234
	$$SegContentsRef .= "\n};\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   235
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   236