Make -DOPENSSL_FIPSSYMS work under WIN32: run perl script when

WIN32 assembly language files are created, add norunasm option
to just translate and not run the assembler.
This commit is contained in:
Dr. Stephen Henson 2011-02-23 15:03:43 +00:00
parent 227d6a9347
commit 548b4763e1
2 changed files with 38 additions and 11 deletions

View File

@ -9,6 +9,14 @@ my @ARGS = @ARGV;
my $top = shift @ARGS; my $top = shift @ARGS;
my $target = shift @ARGS; my $target = shift @ARGS;
my $runasm = 1;
if ($ARGS[0] eq "norunasm")
{
$runasm = 0;
shift @ARGS;
}
# HACK to disable operation if no OPENSSL_FIPSSYMS option. # HACK to disable operation if no OPENSSL_FIPSSYMS option.
# will go away when tested more fully. # will go away when tested more fully.
@ -16,12 +24,13 @@ my $enabled = 0;
foreach (@ARGS) { $enabled = 1 if /-DOPENSSL_FIPSSYMS/ ; } foreach (@ARGS) { $enabled = 1 if /-DOPENSSL_FIPSSYMS/ ; }
if ($enabled == 0) if ($enabled == 0 && $runasm)
{ {
system @ARGS; system @ARGS;
exit $? exit $?
} }
# Open symbol rename file. # Open symbol rename file.
open(IN, "$top/fips/fipssyms.h") || die "Can't open fipssyms.h"; open(IN, "$top/fips/fipssyms.h") || die "Can't open fipssyms.h";
@ -53,18 +62,32 @@ while (<IN>)
{ {
while (($from, $to) = each %edits) while (($from, $to) = each %edits)
{ {
s/(\b)$from(\b)/$1$to$2/g; s/(\b_*)$from(\b)/$1$to$2/g;
} }
print OUT $_; print OUT $_;
} }
# run assembler
system @ARGS;
my $rv = $?; close OUT;
if ($runasm)
{
# run assembler
system @ARGS;
my $rv = $?;
# restore target
unlink $target;
rename "tmptarg.s", $target;
die "Error executing assembler!" if $rv != 0;
}
else
{
# Don't care about target
unlink "tmptarg.s";
}
# restore target
unlink $target;
rename "tmptarg.s", $target;
die "Error executing assembler!" if $rv != 0;

View File

@ -1163,10 +1163,14 @@ sub perlasm_compile_target
{ {
my($target,$source,$bname)=@_; my($target,$source,$bname)=@_;
my($ret); my($ret);
$bname =~ s/(.*)\.[^\.]$/$1/; $bname =~ s/(.*)\.[^\.]$/$1/;
$ret ="\$(TMP_D)$o$bname.asm: $source\n"; $ret ="\$(TMP_D)$o$bname.asm: $source\n";
$ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n"; $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n";
if ($cflags =~ /-DOPENSSL_FIPSSYMS/)
{
$ret .= "\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n";
}
$ret .= "\n";
$ret.="$target: \$(TMP_D)$o$bname.asm\n"; $ret.="$target: \$(TMP_D)$o$bname.asm\n";
$ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
return($ret); return($ret);