From 38bae7baa5beec3a1bd4cb32b1d0fa3410b2d780 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 17 Feb 2011 18:08:59 +0000 Subject: [PATCH] Experimental perl script to edit assembly language source files, call the assembler, then restore original file. This makes OPENSSL_FIPSSYMS work for assembly language builds. --- util/fipsas.pl | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 util/fipsas.pl diff --git a/util/fipsas.pl b/util/fipsas.pl new file mode 100644 index 0000000000..cd8b8c02f4 --- /dev/null +++ b/util/fipsas.pl @@ -0,0 +1,57 @@ + +# FIPS assembly language preprocessor +# Renames all symbols in the file to +# their modified fips versions. + + +my @ARGS = @ARGV; + +my $top = shift @ARGS; +my $target = shift @ARGS; + +# Open symbol rename file. +open(IN, "$top/fips/fipssyms.h") || die "Can't open fipssyms.h"; + +# Skip to assembler symbols +while () + { + last if (/assembler/) + } + +# Store all renames. +while () + { + if (/^#define\s+(\w+)\s+(\w+)\b/) + { + $edits{$1} = $2; + } + } + +my ($from, $to); + +#rename target temporarily +rename($target, "tmptarg.s") || die "Can't rename $target\n"; + +#edit target +open IN,"tmptarg.s"; +open OUT, ">$target"; + +while () +{ + while (($from, $to) = each %edits) + { + s/(\b)$from(\b)/$1$to$2/g; + } + print OUT $_; +} +# run assembler +system @ARGS; + +my $rv = $?; + +# restore target +unlink $target; +rename "tmptarg.s", $target; + +die "Error executing assembler!" if $rv != 0; + -- 2.25.1