From f6d22ef048e58aac41d5ac4bd6534966d2002b35 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sun, 25 Feb 2024 11:29:55 -0600 Subject: [PATCH] fixup masm asm mneumonics in perl generator instead of update.sh removes dependency on cpp --- ...ections-on-masm-windows-to-64-bytes.patch} | 21 ++++++++----- ...fic-operations-in-the-perl-generator.patch | 30 +++++++++++++++++++ update.sh | 26 ++++------------ 3 files changed, 49 insertions(+), 28 deletions(-) rename patches/asm/{masm-align-64.patch => 0001-align-read-only-sections-on-masm-windows-to-64-bytes.patch} (61%) create mode 100644 patches/asm/0002-fixup-masm-specific-operations-in-the-perl-generator.patch diff --git a/patches/asm/masm-align-64.patch b/patches/asm/0001-align-read-only-sections-on-masm-windows-to-64-bytes.patch similarity index 61% rename from patches/asm/masm-align-64.patch rename to patches/asm/0001-align-read-only-sections-on-masm-windows-to-64-bytes.patch index ba41c71024..db33516757 100644 --- a/patches/asm/masm-align-64.patch +++ b/patches/asm/0001-align-read-only-sections-on-masm-windows-to-64-bytes.patch @@ -1,14 +1,16 @@ -commit 3797e05de28ab07bb522898cbf022bdf67a71c99 -Author: Brent Cook -Date: Sun Feb 4 22:53:59 2024 -0600 +From f46cbcb53dd94671184350d276ba99348116ddc3 Mon Sep 17 00:00:00 2001 +From: Brent Cook +Date: Sun, 4 Feb 2024 22:53:59 -0600 +Subject: [PATCH 1/2] align read-only sections on masm/windows to 64 bytes - align read-only sections on masm/windows to 64 bytes - - Avoid conflicts where alignment is specified later in the underlying - assembly. +Avoid conflicts where alignment is specified later in the underlying +assembly. +--- + src/lib/libcrypto/perlasm/x86_64-xlate.pl | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/libcrypto/perlasm/x86_64-xlate.pl b/src/lib/libcrypto/perlasm/x86_64-xlate.pl -index 5dbed2a8c..d8b607b5c 100755 +index 325e7cf58..1e5475312 100755 --- a/src/lib/libcrypto/perlasm/x86_64-xlate.pl +++ b/src/lib/libcrypto/perlasm/x86_64-xlate.pl @@ -567,7 +567,15 @@ my %globals; @@ -28,3 +30,6 @@ index 5dbed2a8c..d8b607b5c 100755 } elsif ($line=~/\.CRT\$/i) { $v.=" READONLY "; $v.=$masm>=$masmref ? "ALIGN(8)" : "DWORD"; +-- +2.43.0 + diff --git a/patches/asm/0002-fixup-masm-specific-operations-in-the-perl-generator.patch b/patches/asm/0002-fixup-masm-specific-operations-in-the-perl-generator.patch new file mode 100644 index 0000000000..d89b3b30d3 --- /dev/null +++ b/patches/asm/0002-fixup-masm-specific-operations-in-the-perl-generator.patch @@ -0,0 +1,30 @@ +From 6495a168869f72d7a319bf1daa042c08a3dca65e Mon Sep 17 00:00:00 2001 +From: Brent Cook +Date: Sun, 25 Feb 2024 11:21:50 -0600 +Subject: [PATCH 2/2] fixup masm-specific operations in the perl generator + +--- + src/lib/libcrypto/perlasm/x86_64-xlate.pl | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/lib/libcrypto/perlasm/x86_64-xlate.pl b/src/lib/libcrypto/perlasm/x86_64-xlate.pl +index 1e5475312..c68a466f3 100755 +--- a/src/lib/libcrypto/perlasm/x86_64-xlate.pl ++++ b/src/lib/libcrypto/perlasm/x86_64-xlate.pl +@@ -815,6 +815,13 @@ while($line=<>) { + $line =~ s|/\*.*\*/||; # ... and C-style comments... + $line =~ s|^\s+||; # ... and skip white spaces in beginning + ++ if ($masm) { ++ $line =~ s/^#/;/; ++ $line =~ s/|/OR/g; ++ $line =~ s/~/NOT/g; ++ $line =~ s/1 << \([0-9]*\)/1 SHL \1/g ++ } ++ + undef $label; + undef $opcode; + undef @args; +-- +2.43.0 + diff --git a/update.sh b/update.sh index d6a8aa6f13..1186beaccc 100755 --- a/update.sh +++ b/update.sh @@ -185,15 +185,6 @@ $CP crypto/compat/ui_openssl_win.c crypto/ui # add the libcrypto symbol export list $GREP -v OPENSSL_ia32cap_P $libcrypto_src/Symbols.list | $GREP '^[A-Za-z0-9_]' > crypto/crypto.sym -fixup_masm() { - cpp -I./crypto $1 \ - | sed -e 's/^#/;/' \ - | sed -e 's/|/OR/g' \ - | sed -e 's/~/NOT/g' \ - | sed -e 's/1 << \([0-9]*\)/1 SHL \1/g' \ - > $2 -} - # generate assembly crypto algorithms asm_src=$CWD/asm @@ -204,12 +195,9 @@ gen_asm_stdout() { .section .note.GNU-stack,"",%progbits #endif EOF - if [ $1 = "masm" ]; then - fixup_masm crypto/$3.tmp crypto/$3 - else - $MV crypto/$3.tmp crypto/$3 - fi + $MV crypto/$3.tmp crypto/$3 } + gen_asm_mips() { abi=$1 dir=$2 @@ -223,6 +211,7 @@ gen_asm_mips() { EOF mv $dst.S crypto/$dir/$dst.S } + gen_asm() { CC=true perl $asm_src/$2 $1 crypto/$3.tmp [ $1 = "elf" ] && cat <<-EOF >> crypto/$3.tmp @@ -230,17 +219,14 @@ gen_asm() { .section .note.GNU-stack,"",%progbits #endif EOF - if [ $1 = "masm" ]; then - fixup_masm crypto/$3.tmp crypto/$3 - else - $MV crypto/$3.tmp crypto/$3 - fi + $MV crypto/$3.tmp crypto/$3 } setup_asm_generator() { rm -fr $asm_src cp -a $libcrypto_src $asm_src - patch -d $asm_src -p4 < patches/asm/masm-align-64.patch + patch -d $asm_src -p4 < patches/asm/0001-align-read-only-sections-on-masm-windows-to-64-bytes.patch + patch -d $asm_src -p4 < patches/asm/0002-fixup-masm-specific-operations-in-the-perl-generator.patch } setup_asm_generator