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