Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixup masm asm mneumonics in perl generator instead of update.sh #1007

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
commit 3797e05de28ab07bb522898cbf022bdf67a71c99
Author: Brent Cook <[email protected]>
Date: Sun Feb 4 22:53:59 2024 -0600
From f46cbcb53dd94671184350d276ba99348116ddc3 Mon Sep 17 00:00:00 2001
From: Brent Cook <[email protected]>
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

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From 6495a168869f72d7a319bf1daa042c08a3dca65e Mon Sep 17 00:00:00 2001
From: Brent Cook <[email protected]>
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

26 changes: 6 additions & 20 deletions update.sh
Original file line number Diff line number Diff line change
@@ -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,24 +211,22 @@ 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
#if defined(HAVE_GNU_STACK)
.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
Loading