diff options
author | Theo Buehler <tb@openbsd.org> | 2024-03-01 08:07:42 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-04-17 09:38:06 +0200 |
commit | 25391acc140e215774242bf3b0a51d59754a23f4 (patch) | |
tree | 451ad805e44b44e5ee27e439632f955f9ab9746b | |
parent | fc807a0349bbddb00273465097177025d9b4e25e (diff) |
Unable to run asm code on OpenBSD (amd64)
In order to get asm code running on OpenBSD we must place
all constants into .rodata sections.
davidben@ also pointed out we need to adjust `x86_64-xlate.pl` perlasm
script to adjust read-olny sections for various flavors (OSes). Those
changes were cherry-picked from boringssl.
closes #23312
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23997)
-rwxr-xr-x | crypto/aes/asm/aes-x86_64.pl | 2 | ||||
-rw-r--r-- | crypto/aes/asm/aesni-sha1-x86_64.pl | 2 | ||||
-rw-r--r-- | crypto/aes/asm/aesni-sha256-x86_64.pl | 2 | ||||
-rw-r--r-- | crypto/aes/asm/aesni-x86_64.pl | 2 | ||||
-rw-r--r-- | crypto/aes/asm/bsaes-x86_64.pl | 5 | ||||
-rw-r--r-- | crypto/aes/asm/vpaes-x86_64.pl | 3 | ||||
-rwxr-xr-x | crypto/bn/asm/rsaz-x86_64.pl | 2 | ||||
-rwxr-xr-x | crypto/bn/asm/x86_64-mont5.pl | 2 | ||||
-rw-r--r-- | crypto/camellia/asm/cmll-x86_64.pl | 2 | ||||
-rwxr-xr-x | crypto/chacha/asm/chacha-x86_64.pl | 2 | ||||
-rwxr-xr-x | crypto/ec/asm/ecp_nistz256-x86_64.pl | 4 | ||||
-rw-r--r-- | crypto/modes/asm/aesni-gcm-x86_64.pl | 2 | ||||
-rw-r--r-- | crypto/modes/asm/ghash-x86_64.pl | 4 | ||||
-rwxr-xr-x | crypto/poly1305/asm/poly1305-x86_64.pl | 8 | ||||
-rwxr-xr-x | crypto/sha/asm/keccak1600-x86_64.pl | 1 | ||||
-rw-r--r-- | crypto/sha/asm/sha1-mb-x86_64.pl | 3 | ||||
-rwxr-xr-x | crypto/sha/asm/sha1-x86_64.pl | 2 | ||||
-rw-r--r-- | crypto/sha/asm/sha256-mb-x86_64.pl | 2 | ||||
-rwxr-xr-x | crypto/sha/asm/sha512-x86_64.pl | 4 | ||||
-rw-r--r-- | crypto/whrlpool/asm/wp-x86_64.pl | 1 |
20 files changed, 51 insertions, 4 deletions
diff --git a/crypto/aes/asm/aes-x86_64.pl b/crypto/aes/asm/aes-x86_64.pl index 25f7ded947..a878c86662 100755 --- a/crypto/aes/asm/aes-x86_64.pl +++ b/crypto/aes/asm/aes-x86_64.pl @@ -2221,6 +2221,7 @@ ___ } $code.=<<___; +.section .rodata align=64 .align 64 .LAES_Te: ___ @@ -2643,6 +2644,7 @@ $code.=<<___; .long 0x1b1b1b1b, 0x1b1b1b1b, 0, 0 .asciz "AES for x86_64, CRYPTOGAMS by <appro\@openssl.org>" .align 64 +.previous ___ # EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, diff --git a/crypto/aes/asm/aesni-sha1-x86_64.pl b/crypto/aes/asm/aesni-sha1-x86_64.pl index dbe33a3f1a..9b58f31381 100644 --- a/crypto/aes/asm/aesni-sha1-x86_64.pl +++ b/crypto/aes/asm/aesni-sha1-x86_64.pl @@ -1738,6 +1738,7 @@ ___ }}} } $code.=<<___; +.section .rodata align=64 .align 64 K_XX_XX: .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 # K_00_19 @@ -1749,6 +1750,7 @@ K_XX_XX: .asciz "AESNI-CBC+SHA1 stitch for x86_64, CRYPTOGAMS by <appro\@openssl.org>" .align 64 +.previous ___ if ($shaext) {{{ ($in0,$out,$len,$key,$ivp,$ctx,$inp)=("%rdi","%rsi","%rdx","%rcx","%r8","%r9","%r10"); diff --git a/crypto/aes/asm/aesni-sha256-x86_64.pl b/crypto/aes/asm/aesni-sha256-x86_64.pl index 5521766a6a..5c8bb0fbcc 100644 --- a/crypto/aes/asm/aesni-sha256-x86_64.pl +++ b/crypto/aes/asm/aesni-sha256-x86_64.pl @@ -168,6 +168,7 @@ $code.=<<___; .cfi_endproc .size $func,.-$func +.section .rodata align=64 .align 64 .type $TABLE,\@object $TABLE: @@ -210,6 +211,7 @@ $TABLE: .long 0,0,0,0, 0,0,0,0 .asciz "AESNI-CBC+SHA256 stitch for x86_64, CRYPTOGAMS by <appro\@openssl.org>" .align 64 +.previous ___ ###################################################################### diff --git a/crypto/aes/asm/aesni-x86_64.pl b/crypto/aes/asm/aesni-x86_64.pl index 09c8f78890..fde5633f4b 100644 --- a/crypto/aes/asm/aesni-x86_64.pl +++ b/crypto/aes/asm/aesni-x86_64.pl @@ -4743,6 +4743,7 @@ ___ } $code.=<<___; +.section .rodata align=64 .align 64 .Lbswap_mask: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -4765,6 +4766,7 @@ $code.=<<___; .asciz "AES for Intel AES-NI, CRYPTOGAMS by <appro\@openssl.org>" .align 64 +.previous ___ # EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, diff --git a/crypto/aes/asm/bsaes-x86_64.pl b/crypto/aes/asm/bsaes-x86_64.pl index 6498cfe908..002a51a603 100644 --- a/crypto/aes/asm/bsaes-x86_64.pl +++ b/crypto/aes/asm/bsaes-x86_64.pl @@ -2182,6 +2182,7 @@ $code.=<<___; .align 16 ossl_bsaes_xts_encrypt: .cfi_startproc + endbranch mov %rsp, %rax .Lxts_enc_prologue: push %rbp @@ -2581,6 +2582,7 @@ $code.=<<___; .align 16 ossl_bsaes_xts_decrypt: .cfi_startproc + endbranch mov %rsp, %rax .Lxts_dec_prologue: push %rbp @@ -3003,6 +3005,7 @@ ___ } $code.=<<___; .type _bsaes_const,\@object +.section .rodata align=64 .align 64 _bsaes_const: .LM0ISR: # InvShiftRows constants @@ -3054,9 +3057,9 @@ _bsaes_const: .quad 0x02060a0e03070b0f, 0x0004080c0105090d .L63: .quad 0x6363636363636363, 0x6363636363636363 -.asciz "Bit-sliced AES for x86_64/SSSE3, Emilia Käsper, Peter Schwabe, Andy Polyakov" .align 64 .size _bsaes_const,.-_bsaes_const +.asciz "Bit-sliced AES for x86_64/SSSE3, Emilia Käsper, Peter Schwabe, Andy Polyakov" ___ # EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, diff --git a/crypto/aes/asm/vpaes-x86_64.pl b/crypto/aes/asm/vpaes-x86_64.pl index 845528f41a..eb8937684c 100644 --- a/crypto/aes/asm/vpaes-x86_64.pl +++ b/crypto/aes/asm/vpaes-x86_64.pl @@ -1006,6 +1006,7 @@ _vpaes_preheat: ## ## ######################################################## .type _vpaes_consts,\@object +.section .rodata align=64 .align 64 _vpaes_consts: .Lk_inv: # inv, inva @@ -1101,9 +1102,9 @@ _vpaes_consts: .Lk_dsbo: # decryption sbox final output .quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D .quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C -.asciz "Vector Permutation AES for x86_64/SSSE3, Mike Hamburg (Stanford University)" .align 64 .size _vpaes_consts,.-_vpaes_consts +.asciz "Vector Permutation AES for x86_64/SSSE3, Mike Hamburg (Stanford University)" ___ if ($win64) { diff --git a/crypto/bn/asm/rsaz-x86_64.pl b/crypto/bn/asm/rsaz-x86_64.pl index 5c7d526fa3..e004b4b3b5 100755 --- a/crypto/bn/asm/rsaz-x86_64.pl +++ b/crypto/bn/asm/rsaz-x86_64.pl @@ -2248,10 +2248,12 @@ $code.=<<___; .cfi_endproc .size rsaz_512_gather4,.-rsaz_512_gather4 +.section .rodata align=64 .align 64 .Linc: .long 0,0, 1,1 .long 2,2, 2,2 +.previous ___ } diff --git a/crypto/bn/asm/x86_64-mont5.pl b/crypto/bn/asm/x86_64-mont5.pl index 1faea0bcf8..2c48e56471 100755 --- a/crypto/bn/asm/x86_64-mont5.pl +++ b/crypto/bn/asm/x86_64-mont5.pl @@ -3577,11 +3577,13 @@ $code.=<<___; ___ } $code.=<<___; +.section .rodata align=64 .align 64 .Linc: .long 0,0, 1,1 .long 2,2, 2,2 .asciz "Montgomery Multiplication with scatter/gather for x86_64, CRYPTOGAMS by <appro\@openssl.org>" +.previous ___ # EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, diff --git a/crypto/camellia/asm/cmll-x86_64.pl b/crypto/camellia/asm/cmll-x86_64.pl index 7e069614d9..0dcf2bf6f5 100644 --- a/crypto/camellia/asm/cmll-x86_64.pl +++ b/crypto/camellia/asm/cmll-x86_64.pl @@ -657,6 +657,7 @@ sub S0222 { my $i=shift; $i=@SBOX[$i]; $i=($i<<1|$i>>7)&0xff; $i=$i<<16|$i<<8|$i sub S3033 { my $i=shift; $i=@SBOX[$i]; $i=($i>>1|$i<<7)&0xff; $i=$i<<24|$i<<8|$i; sprintf("0x%08x",$i); } $code.=<<___; +.section .rodata align=64 .align 64 .LCamellia_SIGMA: .long 0x3bcc908b, 0xa09e667f, 0x4caa73b2, 0xb67ae858 @@ -682,6 +683,7 @@ $_ivp="40(%rsp)"; $_rsp="48(%rsp)"; $code.=<<___; +.text .globl Camellia_cbc_encrypt .type Camellia_cbc_encrypt,\@function,6 .align 16 diff --git a/crypto/chacha/asm/chacha-x86_64.pl b/crypto/chacha/asm/chacha-x86_64.pl index cdb900c037..18eebbb97b 100755 --- a/crypto/chacha/asm/chacha-x86_64.pl +++ b/crypto/chacha/asm/chacha-x86_64.pl @@ -102,6 +102,7 @@ $code.=<<___; .extern OPENSSL_ia32cap_P +.section .rodata align=64 .align 64 .Lzero: .long 0,0,0,0 @@ -133,6 +134,7 @@ $code.=<<___; .Lsigma: .asciz "expand 32-byte k" .asciz "ChaCha20 for x86_64, CRYPTOGAMS by <appro\@openssl.org>" +.previous ___ sub AUTOLOAD() # thunk [simplified] 32-bit style perlasm diff --git a/crypto/ec/asm/ecp_nistz256-x86_64.pl b/crypto/ec/asm/ecp_nistz256-x86_64.pl index 430b14c86d..feeb8c5cb3 100755 --- a/crypto/ec/asm/ecp_nistz256-x86_64.pl +++ b/crypto/ec/asm/ecp_nistz256-x86_64.pl @@ -85,6 +85,7 @@ $code.=<<___; .extern OPENSSL_ia32cap_P # The polynomial +.section .rodata align=4096 .align 64 .Lpoly: .quad 0xffffffffffffffff, 0x00000000ffffffff, 0x0000000000000000, 0xffffffff00000001 @@ -107,6 +108,7 @@ $code.=<<___; .quad 0xf3b9cac2fc632551, 0xbce6faada7179e84, 0xffffffffffffffff, 0xffffffff00000000 .LordK: .quad 0xccd1c8aaee00bc4f +.previous ___ { @@ -4723,7 +4725,7 @@ close TABLE; die "insane number of elements" if ($#arr != 64*16*37-1); print <<___; -.text +.section .rodata align=4096 .globl ecp_nistz256_precomputed .type ecp_nistz256_precomputed,\@object .align 4096 diff --git a/crypto/modes/asm/aesni-gcm-x86_64.pl b/crypto/modes/asm/aesni-gcm-x86_64.pl index eaf4d9c755..47f1fd7a2f 100644 --- a/crypto/modes/asm/aesni-gcm-x86_64.pl +++ b/crypto/modes/asm/aesni-gcm-x86_64.pl @@ -943,6 +943,7 @@ $code.=<<___; ___ $code.=<<___; +.section .rodata align=64 .align 64 .Lbswap_mask: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -955,6 +956,7 @@ $code.=<<___; .Lone_lsb: .byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .asciz "AES-NI GCM module for x86_64, CRYPTOGAMS by <appro\@openssl.org>" +.previous .align 64 ___ if ($win64) { diff --git a/crypto/modes/asm/ghash-x86_64.pl b/crypto/modes/asm/ghash-x86_64.pl index 6709f96492..c7fb2a856d 100644 --- a/crypto/modes/asm/ghash-x86_64.pl +++ b/crypto/modes/asm/ghash-x86_64.pl @@ -534,6 +534,7 @@ $code.=<<___; .align 16 gcm_init_clmul: .cfi_startproc + endbranch .L_init_clmul: ___ $code.=<<___ if ($win64); @@ -1027,6 +1028,7 @@ $code.=<<___; .align 32 gcm_init_avx: .cfi_startproc + endbranch ___ if ($avx) { my ($Htbl,$Xip)=@_4args; @@ -1609,6 +1611,7 @@ ___ } $code.=<<___; +.section .rodata align=64 .align 64 .Lbswap_mask: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -1662,6 +1665,7 @@ $code.=<<___; .asciz "GHASH for x86_64, CRYPTOGAMS by <appro\@openssl.org>" .align 64 +.previous ___ # EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, diff --git a/crypto/poly1305/asm/poly1305-x86_64.pl b/crypto/poly1305/asm/poly1305-x86_64.pl index 4cddca1c51..5223207b83 100755 --- a/crypto/poly1305/asm/poly1305-x86_64.pl +++ b/crypto/poly1305/asm/poly1305-x86_64.pl @@ -229,6 +229,7 @@ $code.=<<___; .align 32 poly1305_blocks: .cfi_startproc + endbranch .Lblocks: shr \$4,$len jz .Lno_data # too short @@ -303,6 +304,7 @@ $code.=<<___; .align 32 poly1305_emit: .cfi_startproc + endbranch .Lemit: mov 0($ctx),%r8 # load hash value mov 8($ctx),%r9 @@ -524,6 +526,7 @@ __poly1305_init_avx: .align 32 poly1305_blocks_avx: .cfi_startproc + endbranch mov 20($ctx),%r8d # is_base2_26 cmp \$128,$len jae .Lblocks_avx @@ -1384,6 +1387,7 @@ $code.=<<___; .align 32 poly1305_emit_avx: .cfi_startproc + endbranch cmpl \$0,20($ctx) # is_base2_26? je .Lemit @@ -1448,6 +1452,7 @@ $code.=<<___; .align 32 poly1305_blocks_avx2: .cfi_startproc + endbranch mov 20($ctx),%r8d # is_base2_26 cmp \$128,$len jae .Lblocks_avx2 @@ -2144,6 +2149,7 @@ $code.=<<___; .align 32 poly1305_blocks_avx512: .cfi_startproc + endbranch .Lblocks_avx512: mov \$15,%eax kmovw %eax,%k2 @@ -3778,6 +3784,7 @@ poly1305_emit_base2_44: ___ } } } $code.=<<___; +.section .rodata align=64 .align 64 .Lconst: .Lmask24: @@ -3809,6 +3816,7 @@ $code.=<<___; .Lx_mask42: .quad 0x3ffffffffff,0x3ffffffffff,0x3ffffffffff,0x3ffffffffff .quad 0x3ffffffffff,0x3ffffffffff,0x3ffffffffff,0x3ffffffffff +.previous ___ } $code.=<<___; diff --git a/crypto/sha/asm/keccak1600-x86_64.pl b/crypto/sha/asm/keccak1600-x86_64.pl index 78aa5c64af..f5f2cd0742 100755 --- a/crypto/sha/asm/keccak1600-x86_64.pl +++ b/crypto/sha/asm/keccak1600-x86_64.pl @@ -567,6 +567,7 @@ SHA3_squeeze: ___ } $code.=<<___; +.section .rodata align=256 .align 256 .quad 0,0,0,0,0,0,0,0 .type iotas,\@object diff --git a/crypto/sha/asm/sha1-mb-x86_64.pl b/crypto/sha/asm/sha1-mb-x86_64.pl index 67faba136d..6136c5c878 100644 --- a/crypto/sha/asm/sha1-mb-x86_64.pl +++ b/crypto/sha/asm/sha1-mb-x86_64.pl @@ -1374,7 +1374,7 @@ $code.=<<___; ___ } }}} $code.=<<___; - +.section .rodata align=256 .align 256 .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 # K_00_19 .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 # K_00_19 @@ -1389,6 +1389,7 @@ K_XX_XX: .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f # pbswap .byte 0xf,0xe,0xd,0xc,0xb,0xa,0x9,0x8,0x7,0x6,0x5,0x4,0x3,0x2,0x1,0x0 .asciz "SHA1 multi-block transform for x86_64, CRYPTOGAMS by <appro\@openssl.org>" +.previous ___ if ($win64) { diff --git a/crypto/sha/asm/sha1-x86_64.pl b/crypto/sha/asm/sha1-x86_64.pl index c66b8fca87..a398b1c28f 100755 --- a/crypto/sha/asm/sha1-x86_64.pl +++ b/crypto/sha/asm/sha1-x86_64.pl @@ -1832,6 +1832,7 @@ ___ } } $code.=<<___; +.section .rodata align=64 .align 64 K_XX_XX: .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 # K_00_19 @@ -1845,6 +1846,7 @@ K_XX_XX: .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f # pbswap mask .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f # pbswap mask .byte 0xf,0xe,0xd,0xc,0xb,0xa,0x9,0x8,0x7,0x6,0x5,0x4,0x3,0x2,0x1,0x0 +.previous ___ }}} $code.=<<___; diff --git a/crypto/sha/asm/sha256-mb-x86_64.pl b/crypto/sha/asm/sha256-mb-x86_64.pl index fa2ca86046..0c9f8b1ca0 100644 --- a/crypto/sha/asm/sha256-mb-x86_64.pl +++ b/crypto/sha/asm/sha256-mb-x86_64.pl @@ -1340,6 +1340,7 @@ $code.=<<___; ___ } }}} $code.=<<___; +.section .rodata align=256 .align 256 K256: ___ @@ -1389,6 +1390,7 @@ K256_shaext: .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 .asciz "SHA256 multi-block transform for x86_64, CRYPTOGAMS by <appro\@openssl.org>" +.previous ___ if ($win64) { diff --git a/crypto/sha/asm/sha512-x86_64.pl b/crypto/sha/asm/sha512-x86_64.pl index 1bd0256954..6073520918 100755 --- a/crypto/sha/asm/sha512-x86_64.pl +++ b/crypto/sha/asm/sha512-x86_64.pl @@ -418,6 +418,7 @@ ___ if ($SZ==4) { $code.=<<___; +.section .rodata align=64 .align 64 .type $TABLE,\@object $TABLE: @@ -461,9 +462,11 @@ $TABLE: .long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 .long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 .asciz "SHA256 block transform for x86_64, CRYPTOGAMS by <appro\@openssl.org>" +.previous ___ } else { $code.=<<___; +.section .rodata align=64 .align 64 .type $TABLE,\@object $TABLE: @@ -551,6 +554,7 @@ $TABLE: .quad 0x0001020304050607,0x08090a0b0c0d0e0f .quad 0x0001020304050607,0x08090a0b0c0d0e0f .asciz "SHA512 block transform for x86_64, CRYPTOGAMS by <appro\@openssl.org>" +.previous ___ } diff --git a/crypto/whrlpool/asm/wp-x86_64.pl b/crypto/whrlpool/asm/wp-x86_64.pl index f94152af97..10f9ad1397 100644 --- a/crypto/whrlpool/asm/wp-x86_64.pl +++ b/crypto/whrlpool/asm/wp-x86_64.pl @@ -236,6 +236,7 @@ $code.=<<___; .cfi_endproc .size $func,.-$func +.section .rodata align=64 .align 64 .type $table,\@object $table: |