sbsv1/abld/e32util/makedef.pl
author lorewang
Wed, 01 Dec 2010 16:05:36 +0800
changeset 715 e0739b8406dd
parent 606 30b30f9da0b7
permissions -rw-r--r--
Specify extenal tool with path
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) 1998-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
# all variables called *Path* are set up to end with a backslash
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
# all variables called *Path or *File are stored as absolute (file)paths
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
# all variables called UpPath* are stored as relative paths
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
# 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
use strict   ;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
use FindBin;		# for FindBin::Bin
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
use Getopt::Long;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
my $PerlBinPath;	# fully qualified pathname of the directory containing this script
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
my $EntryPoint;         
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
my $InternalEntryPoint;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
# establish the path to the Perl binaries
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
BEGIN {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
	require 5.005_03;				# check user has a version of perl that will cope
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
	$PerlBinPath = $FindBin::Bin;	# X:/epoc32/tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
	if ($^O eq "MSWin32")
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
		{	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
		$PerlBinPath =~ s/\//\\/g;		# X:\epoc32\tools
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
use lib $PerlBinPath;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
use Defutl;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
use File::Copy;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
# Version
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
my $MajorVersion = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
my $MinorVersion = 1;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    48
my $PatchVersion = 1;
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
my %Options;	# command line option information
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
my $NamedSymLkup = 0;			# This flag is used to enable named lookup on emulator
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
my $IgnoreUnfrozenExports = 0;	# This flag is used to ignore the 'unfrozen exports' warnings. This is 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
								# required for STDEXEs which export symbols just to enable 'named lookup'
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
								# from within the STDEXE (via 'dlsym') and are never exposed outside (via def files or
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
								# import libraries.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
my $ExportEntrypointE32Dll = 0;	 # Workaround: To export entry point _E32DLL for target type STDDLL
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
# THE MAIN PROGRAM SECTION
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
##########################
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
	my $INFILE;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
	my $FRZFILE;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
	my $OUTFILE;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
	my @ObjFiles;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
	# process the command-line
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
	unless (GetOptions(\%Options, '1=s', '2=s', 'deffile=s', 'frzfile=s', 'inffile=s', 'overwrite', 'absent=s', 'ignore_unfrozen_noncallable', 'SystemTargetType', 'sym_name_lkup', 'ignore_unfrozen_exports','export_entrypoint_E32Dll')) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
		exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
	unless (@ARGV==1) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
		&Usage;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
#	check the flags
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
	if (($Options{deffile} and $Options{inffile}) or (not ($Options{deffile} or $Options{inffile}))) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
		die "MAKEDEF ERROR: Must specify either -Deffile [file] or -Inf [file]\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
	if ($Options{2} && !$Options{1}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
		die "MAKEDEF ERROR: Can't specify second export name and not first export name\n";
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
#	process the flags
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
	if ($Options{deffile}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
		$INFILE=$Options{deffile};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
		unless (-e $INFILE) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
			die "MAKEDEF ERROR: $INFILE: Deffile not found\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    92
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    93
	else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    94
		$INFILE=$Options{inffile};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    95
		unless (-e $INFILE) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    96
			die "MAKEDEF ERROR: $INFILE: Inffile not found\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    97
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    98
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    99
	if ($Options{frzfile}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   100
		$FRZFILE=$Options{frzfile};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   101
#		check the frozen .DEF file exists
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   102
		unless (-e $FRZFILE) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   103
			die "MAKEDEF ERROR: $FRZFILE: Frzfile not found\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   104
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   105
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   106
	$OUTFILE=pop @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   107
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   108
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   109
	$NamedSymLkup = $Options{sym_name_lkup};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   110
	$IgnoreUnfrozenExports = $Options{ignore_unfrozen_exports};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   111
	$ExportEntrypointE32Dll = $Options{export_entrypoint_E32Dll};	# Workaround: To export entry point _E32DLL for target type STDDLL
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   112
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   113
#	Read the Frozen .DEF file if specified
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   114
	my @FrzDataStruct;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   115
	if ($FRZFILE) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   116
		eval { &Def_ReadFileL(\@FrzDataStruct, $FRZFILE); };
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   117
		die $@ if $@;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   118
		if ($Options{1}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   119
#			Check that frozen def file matches the -1 and -2 arguments given, if any
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   120
			my $export1="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   121
			my $export2="";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   122
			foreach my $FrzRef (@FrzDataStruct) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   123
				next unless $$FrzRef{Name};		# ignore lines not containing an export
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   124
				if ($$FrzRef{Ordinal} == 1) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   125
					$export1 = $$FrzRef{Name};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   126
					next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   127
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   128
				if ($$FrzRef{Ordinal} == 2) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   129
					$export2 = $$FrzRef{Name};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   130
					next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   131
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   132
				if ($Options{1} && ($Options{1} ne $export1)) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   133
					die "MAKEDEF ERROR: $FRZFILE: Frzfile ordinal 1 does not match command line\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   134
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   135
				if ($Options{2} && ($Options{2} ne $export2)) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   136
					die "MAKEDEF ERROR: $FRZFILE: Frzfile ordinal 2 does not match command line\n";
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
	elsif ($Options{1}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   142
#		create an export structure for the names passed on the command line
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   143
		push @FrzDataStruct, {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   144
			Name=>$Options{1},
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   145
			ExportName=>$Options{1},
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   146
			Ordinal=>1
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   147
		};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   148
		if ($Options{2}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   149
			push @FrzDataStruct, {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   150
				Name=>$Options{2},
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   151
				ExportName=>$Options{2},
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   152
				Ordinal=>2
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   153
			};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   154
		}
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
#	Read the Input .DEF file
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   158
	my @InDataStruct;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   159
	if ($Options{deffile}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   160
		eval { &Def_ReadFileL(\@InDataStruct, $INFILE); };
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   161
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   162
	else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   163
		eval { &ReadInfFileL(\@InDataStruct, $INFILE); };
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   164
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   165
	die $@ if $@;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   166
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   167
#	Compare the frozen .DEF data with the input .DEF or export info file data
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   168
	my (@NewDataStruct, @MissingDataStruct, @MatchedDataStruct);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   169
	eval { &CompareFrzInL (\@NewDataStruct, \@MissingDataStruct, \@MatchedDataStruct, \@FrzDataStruct, \@InDataStruct); };
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   170
	die $@ if $@;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   171
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   172
	# MAKEDEF should generate a warning if the def file has no exports (old or new)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   173
	# and the associated MMP 'targettype' is not a System Target type.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   174
	print "MAKEDEF WARNING: $OUTFILE has no EXPORTS\n" unless (@MatchedDataStruct || @NewDataStruct || $Options{SystemTargetType});
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   175
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   176
#	Create the output .DEF file
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   177
	eval { &CreateDefFileL(\@NewDataStruct, \@MatchedDataStruct, $OUTFILE, $FRZFILE); };
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   178
	die $@ if $@;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   179
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   180
#	report missing frozen export errors
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   181
	if (@MissingDataStruct) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   182
		my @Errors;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   183
		my $Num=@MissingDataStruct;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   184
		my $Ref;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   185
		if ($FRZFILE) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   186
			push @Errors, "MAKEDEF ERROR: $Num Frozen Export(s) missing from object files (POSSIBLE COMPATIBILITY BREAK):\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   187
			foreach $Ref (@MissingDataStruct) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   188
				push @Errors, "  $FRZFILE($$Ref{LineNum}) : $$Ref{Name} \@$$Ref{Ordinal}\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   189
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   190
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   191
		else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   192
			push @Errors, "MAKEDEF ERROR: command-line: $Num Frozen Export(s) missing from object files (POSSIBLE COMPATIBILITY BREAK):\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   193
			foreach $Ref (@MissingDataStruct) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   194
				push @Errors, "  $$Ref{Name} \@$$Ref{Ordinal}\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   195
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   196
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   197
		die "\n", @Errors;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   198
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   199
	elsif ($Options{overwrite} && -w $FRZFILE) #sag
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   200
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   201
		print "Copying $OUTFILE to $FRZFILE\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   202
		rename $FRZFILE, "$FRZFILE.bak";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   203
		copy($OUTFILE, $FRZFILE);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   204
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   205
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   206
	exit 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   207
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   208
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   209
#######################################################################
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   210
# SUBROUTINES
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   211
#######################################################################
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   212
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   213
sub Usage () {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   214
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   215
	print(
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   216
		"\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   217
		"MAKEDEF - .DEF file generator V$MajorVersion.$MinorVersion.$PatchVersion\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   218
		"\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   219
		"MAKEDEF {options} [Output .DEF file]\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   220
		"\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   221
		"options:   (case-insensitive)\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   222
		"  -Deffile [Input .DEF file]\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   223
		"  -Inffile [Input export information file]\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   224
		"  -Frzfile [Frozen .DEF file]\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   225
		"  -1 [first export name] {-2 [second export name]}\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   226
		"  -Overwrite\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   227
		"  -Absent [symbol to use for absent exports]\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   228
		"  -ignore_unfrozen_noncallable\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   229
		"  -SystemTargetType\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   230
		"  -sym_name_lkup [Enable symbol lookup by name]\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   231
		"  -ignore_unfrozen_exports \n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   232
		"\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   233
		"Either specify -Deffile or -Inffile, and\n",
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   234
		"either -Frzfile or -1 {-2} if required.\n"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   235
	);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   236
	exit 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   237
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   238
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   239
sub ReadInfFileL ($$$) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   240
	my ($DataStructRef, $FILE)=@_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   241
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   242
#	open export information file for reading
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   243
	open (FILE, "<$FILE") or die "could not open $FILE: $!";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   244
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   245
#	read the export info. file, and create dummy frozen .DEF file text
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   246
	my $LineNum=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   247
	my $Ordinal=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   248
	my $Comment='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   249
	my $Name='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   250
	my $InfType=0;	# dumpbin output
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   251
	my %exports;	# MWLD workaround - record mangled names in case we don't see the demangled ones
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   252
	my $Line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   253
	while ($Line=<FILE>) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   254
	        my $Data=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   255
			my $SymbolSize=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   256
		$LineNum++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   257
		if ($InfType == 0) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   258
			if ($Line =~ /\*\*\* ARCHIVE SYMBOL TABLE.* \*\*\*/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   259
				$InfType=1;	# mwld disassembly output
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   260
				next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   261
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   262
			if ($Line =~ /^\s+(\?\S+)(\s+\((.*)\))?$/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   263
#                   ??0TAgnAlarmDefaults@@QAE@XZ (public: __thiscall TAgnAlarmDefaults::TAgnAlarmDefaults(void))
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   264
				$Name=$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   265
				$Comment=$3;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   266
			} 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   267
			elsif ($Line =~ /^\s+_(\S+)(\s+\((.*)\))?$/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   268
# frozen ordinals like "UserNoLongerSupported01" seem to inherit a leading underscore in the dumpbin output
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   269
				$Name=$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   270
				$Comment=$3;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   271
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   272
			elsif ($Line =~ /^\s+_(\S+) DATA (\d+)(\s+\((.*)\))?$/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   273
#				Mark the data symbols and retain their sizes
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   274
				$Name=$1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   275
				$Data=1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   276
				$SymbolSize=$2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   277
				$Comment=$4;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   278
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   279
			else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   280
				next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   281
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   282
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   283
		else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   284
			# The Windows CW linker produces .inf files with a 'something' unmangled comment at the end, the Linux CW linker doesn't
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   285
			if ($Line =~ /^\s*\d+\s+\(.+\)\s+__imp_((.)(\S+))(\s+'__declspec\(dllimport\)\s+(.*)')?$/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   286
					if ($2 eq "_") {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   287
							$Name = $3;		# C symbol, so remove leading underscore
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   288
							$Comment = $5 if ($4);	# name isn't mangled anyway
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   289
					} else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   290
							$Name = $1;		# C++ mangled name
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   291
							$Comment = $5 if ($4);	# can't unmangle names...
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   292
					}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   293
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   294
					# One side-effect of ignoring comments if they're not present is that Windows entry points need to be
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   295
					# specifically ignored.  Previously they were ignored by virture of the fact they had no comment.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   296
					next if ($Name eq "_E32Dll" || $Name eq "_E32Startup");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   297
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   298
					$Comment = $4 ? $5 : $Name;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   299
					
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   300
					# need to save both the line number and
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   301
					# comment
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   302
					my %entry;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   303
					$entry{'lineNum'} = $LineNum;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   304
					$entry{'comment'} = $Comment;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   305
					$exports{$Name}=\%entry;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   306
					next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   307
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   308
			if ($Line =~ /\*\*\* Unmangled Symbols \*\*\*/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   309
				# Currently for Linux "Unmangled Symbols" section is blank
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   310
				<FILE>; 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   311
				$Line = <FILE>; 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   312
				$LineNum+=2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   313
				if ($^O eq "MSWin32") {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   314
					if ($Line !~ /^\s*\d+:\s+(\S+)$/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   315
						print STDERR "MAKEDEF WARNING: unknown inf file format\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   316
						next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   317
					}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   318
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   319
				$Name = length $1 ? $1 : '';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   320
# Workaround: if MWLD can't demangle the name, we will see only the __imp_ version.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   321
				if ($Name =~ /^__imp_(\S+)$/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   322
					$Name = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   323
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   324
				$Line = <FILE>; 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   325
				$LineNum++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   326
				next if ($Line !~ /^\s+(.+)$/o);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   327
				$Comment = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   328
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   329
			elsif ($Line =~ /^0x\S{8}\s+__imp__(\S+)$/o) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   330
				$Name = $1;	# leading underscore already removed
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   331
				$Comment = '';	# a C symbol, and therefore not mangled
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   332
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   333
			else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   334
				next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   335
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   336
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   337
# Check for WINS entrypoint symbols
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   338
		if ($Name eq "_E32Dll" || $Name eq "_E32Startup") {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   339
			$EntryPoint = $Name;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   340
			# when mwld resolves an exported symbol S coming from
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   341
			# the def file, it looks both for S() and _S() in
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   342
			# every object file but only for _S() in static
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   343
			# libraries.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   344
			#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   345
			# As a consequence, we need to distinguish the
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   346
			# internal entry point name from the external one.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   347
			$InternalEntryPoint = "_$Name" if ($InfType != 0);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   348
			my $entry = $exports{$Name};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   349
			$entry->{'lineNum'} = 0; # indicates processed name
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   350
			next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   351
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   352
		$Ordinal++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   353
		$Comment='' if (!defined $Comment);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   354
		push @$DataStructRef, {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   355
			Ordinal=>$Ordinal,
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   356
			Name=>$Name,
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   357
			Data=>$Data,
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   358
			Size=>$SymbolSize,
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   359
			ExportName=>$Name,
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   360
			Comment=>$Comment,
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   361
			LineNum=>$LineNum
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   362
		};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   363
		my $entry = $exports{$Name};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   364
		$entry->{'lineNum'} = 0; # indicates processed name
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   365
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   366
	foreach $Name (keys %exports) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   367
	    	my $entry = $exports{$Name};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   368
		$LineNum = $entry->{'lineNum'};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   369
		if ($LineNum > 0) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   370
			$Ordinal++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   371
			push @$DataStructRef, {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   372
				Ordinal=>$Ordinal,
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   373
				Name=>$Name,
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   374
				ExportName=>$Name,
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   375
				Comment=> $entry->{'comment'},
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   376
				LineNum=>$LineNum
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   377
			};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   378
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   379
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   380
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   381
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   382
sub CompareFrzInL ($$$$$) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   383
	my ($NewStructRef, $MissingStructRef, $MatchedStructRef, $FrzStructRef, $InStructRef)=@_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   384
	my $AbsentSubst = $Options{absent};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   385
	my $IgnoreNoncallable = $Options{ignore_unfrozen_noncallable};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   386
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   387
#	compare the input export data with the frozen data
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   388
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   389
#	this function trashes the frozen .DEF data structure and the new .DEF data structure
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   390
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   391
#	nullify non-export statements in the structures
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   392
	foreach (@$FrzStructRef,@$InStructRef) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   393
		next if $$_{Name};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   394
		undef $_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   395
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   396
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   397
	my $LastOrdinal=0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   398
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   399
	my $FrzRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   400
	my $InRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   401
	FRZLOOP: foreach $FrzRef (@$FrzStructRef) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   402
		next unless $$FrzRef{Name};		# ignore lines in the .DEF file not containing an export
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   403
		if ($LastOrdinal<$$FrzRef{Ordinal}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   404
			$LastOrdinal=$$FrzRef{Ordinal};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   405
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   406
		foreach $InRef (@$InStructRef) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   407
			next unless defined $InRef; # ignore nullified entries in the temporary array
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   408
#			does the function name match?
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   409
			if ($$InRef{Name} eq $$FrzRef{Name}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   410
#				give the generated export the same number as the corresponding frozen one
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   411
				$$InRef{Ordinal}=$$FrzRef{Ordinal};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   412
				$$InRef{Data}=$$FrzRef{Data};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   413
				$$InRef{Size}=$$FrzRef{Size};
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   414
#				if the export is marked as absent, redirect it appropriately
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   415
				if ($$FrzRef{Absent}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   416
					if ($AbsentSubst) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   417
						$$InRef{Name} = $AbsentSubst;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   418
						$$InRef{ExportName} = sprintf("\"_._.absent_export_%d\"", $$InRef{Ordinal});
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   419
					}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   420
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   421
				push @$MatchedStructRef, $InRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   422
				undef $InRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   423
				next FRZLOOP;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   424
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   425
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   426
#		these frozen exports haven't been found in the object files
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   427
#		first check for ABSENT declarations
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   428
		if ($AbsentSubst and $$FrzRef{Absent}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   429
			$$FrzRef{Name} = $AbsentSubst;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   430
			$$FrzRef{ExportName} = sprintf("\"_._.absent_export_%d\"", $$FrzRef{Ordinal});
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   431
			push @$MatchedStructRef, $FrzRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   432
			next FRZLOOP;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   433
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   434
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   435
#		No - it's really missing
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   436
		push @$MissingStructRef, $FrzRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   437
#		put a comment in the generated .DEF file to that effect
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   438
		$$FrzRef{Missing}=1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   439
		push @$MatchedStructRef, $FrzRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   440
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   441
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   442
#	all the exports left in the new .DEF file aren't frozen - give them the right ordinals
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   443
	foreach $InRef (@$InStructRef) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   444
		next unless defined $InRef; # ignore nullified entries
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   445
		if ($$InRef{Name} =~ /^_ZTV|_ZTI/) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   446
			# EABI non-callable exports
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   447
			next if ($IgnoreNoncallable);	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   448
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   449
		$LastOrdinal++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   450
		$$InRef{Ordinal}=$LastOrdinal;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   451
		push @$NewStructRef, $InRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   452
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   453
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   454
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   455
sub CreateDefFileL ($$$$) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   456
#	creates a new .DEF file
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   457
	my ($NewStructRef, $MatchedStructRef, $FILE, $FRZFILE)=@_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   458
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   459
	my @Text=("EXPORTS\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   460
	my $LineNum=1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   461
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   462
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   463
	my $InRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   464
	foreach $InRef (@$MatchedStructRef) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   465
		my $Comment='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   466
		if ($$InRef{Comment}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   467
			$Comment=" ; $$InRef{Comment}";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   468
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   469
		if ($$InRef{Missing}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   470
			push @Text, '; MISSING:';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   471
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   472
		my $Data = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   473
		if( defined $$InRef{Data} && $$InRef{Data} == 1) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   474
		$Data = " DATA $$InRef{Size}" ;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   475
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   476
		my $r3unused = $$InRef{R3Unused} ? " R3UNUSED" : "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   477
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   478
#		A def file entry with the keyword 'NONAME' indicates the MW linker that a named-lookup is not enabled. 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   479
#		Note that although it may seem, but named lookup is either enabled or disabled on a per-binary basis and not
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   480
#		per-symbol.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   481
		my $noname = $NamedSymLkup ? "": " NONAME";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   482
		if ($$InRef{ExportName} and ($$InRef{ExportName} ne $$InRef{Name})) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   483
			push @Text, "\t$$InRef{ExportName}=$$InRef{Name} \@ $$InRef{Ordinal} $noname$Data$r3unused$Comment\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   484
		} else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   485
			push @Text, "\t$$InRef{Name} \@ $$InRef{Ordinal} $noname$Data$r3unused$Comment\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   486
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   487
		$LineNum++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   488
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   489
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   490
	if (@$NewStructRef) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   491
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   492
#		warn about unfrozen exports and add them to the end of the generated .DEF file
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   493
		my $Num=@$NewStructRef;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   494
		my @Warnings;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   495
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   496
		if(!$IgnoreUnfrozenExports) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   497
			my $warning = "MAKEDEF WARNING: $Num export(s) not yet Frozen";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   498
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   499
			if ($FRZFILE)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   500
				{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   501
				$warning .= " in $FRZFILE";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   502
				}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   503
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   504
			$warning .= ":\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   505
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   506
			push @Warnings, $warning;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   507
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   508
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   509
		push @Text, "; NEW:\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   510
		$LineNum++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   511
		foreach $InRef (@$NewStructRef) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   512
			my $Comment='';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   513
			if ($$InRef{Comment}) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   514
				$Comment=" ; $$InRef{Comment}";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   515
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   516
			my $Data = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   517
			if(defined $$InRef{Data} && $$InRef{Data} == 1){
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   518
			$Data = " DATA $$InRef{Size}";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   519
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   520
			my $r3unused = $$InRef{R3Unused} ? " R3UNUSED" : "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   521
			my $noname = $NamedSymLkup ? "": " NONAME";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   522
			if ($$InRef{ExportName} and ($$InRef{ExportName} ne $$InRef{Name})) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   523
				push @Text, "\t$$InRef{ExportName}=$$InRef{Name} \@ $$InRef{Ordinal} $noname$Data$r3unused$Comment\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   524
			} else {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   525
				push @Text, "\t$$InRef{Name} \@ $$InRef{Ordinal} $noname$Data$r3unused$Comment\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   526
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   527
			$LineNum++;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   528
			if(!$IgnoreUnfrozenExports) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   529
				push @Warnings, "  $FILE($LineNum) : $$InRef{Name} \@$$InRef{Ordinal}\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   530
			}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   531
			next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   532
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   533
		print @Warnings;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   534
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   535
	if ($EntryPoint) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   536
		push @Text, "\t$EntryPoint";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   537
		push @Text, "=$InternalEntryPoint" if ($InternalEntryPoint);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   538
		push @Text, "\t; Entry point for emulation\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   539
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   540
	elsif ($ExportEntrypointE32Dll) {		# Workaround: To export entry point _E32DLL for target type STDDLL
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   541
		push @Text, "\t_E32Dll";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   542
		push @Text, "=__E32Dll" ;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   543
		push @Text, "\t; Entry point for STDDLL emulation\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   544
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   545
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   546
#	add a terminating newline
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   547
	push @Text, "\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   548
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   549
#	write the new .DEF file
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   550
	eval { &Def_WriteFileL(\@Text, $FILE); };
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   551
	die $@ if $@;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   552
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   553