Move data from .text to .rodata on x86_64
Various constants and strings identifying the authors are currently misplaced in .text. This change allows using execute-only .text on platforms that enforce it by default, such as OpenBSD. Modify x86_64-xlate.pl to replace .rodata with __DATA,__const for macs. Adapt the nasm/masm path to emit an .rdata segment with alignment of 8. This last change is not strictly needed but makes things explicit. Change-Id: If716b892c1faabd85c6c70bdd75e145304841f83 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/57445 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com>
This commit is contained in:
committed by
Boringssl LUCI CQ
parent
7864b1489f
commit
ebd43ef8dd
@@ -78,6 +78,7 @@ $code.=<<___;
|
||||
|
||||
.extern OPENSSL_ia32cap_P
|
||||
|
||||
.section .rodata
|
||||
.align 64
|
||||
.Lzero:
|
||||
.long 0,0,0,0
|
||||
@@ -107,6 +108,7 @@ $code.=<<___;
|
||||
.Lsixteen:
|
||||
.long 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
|
||||
.asciz "ChaCha20 for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.text
|
||||
___
|
||||
|
||||
sub AUTOLOAD() # thunk [simplified] 32-bit style perlasm
|
||||
|
||||
@@ -32,7 +32,7 @@ open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$code.=<<___;
|
||||
.data
|
||||
.section .rodata
|
||||
|
||||
.align 16
|
||||
one:
|
||||
|
||||
@@ -42,6 +42,7 @@ $code.=<<___;
|
||||
|
||||
chacha20_poly1305_constants:
|
||||
|
||||
.section .rodata
|
||||
.align 64
|
||||
.Lchacha20_consts:
|
||||
.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k'
|
||||
@@ -79,6 +80,7 @@ chacha20_poly1305_constants:
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00
|
||||
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
||||
.text
|
||||
___
|
||||
|
||||
my ($oup,$inp,$inl,$adp,$keyp,$itr1,$itr2,$adl)=("%rdi","%rsi","%rbx","%rcx","%r9","%rcx","%r8","%r8");
|
||||
|
||||
@@ -3778,6 +3778,7 @@ ___
|
||||
}
|
||||
|
||||
$code.=<<___;
|
||||
.section .rodata
|
||||
.align 64
|
||||
.Lbswap_mask:
|
||||
.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
|
||||
@@ -3800,6 +3801,7 @@ $code.=<<___;
|
||||
|
||||
.asciz "AES for Intel AES-NI, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 64
|
||||
.text
|
||||
___
|
||||
|
||||
# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
|
||||
|
||||
@@ -1288,6 +1288,7 @@ _vpaes_preheat:
|
||||
## ##
|
||||
########################################################
|
||||
.type _vpaes_consts,\@object
|
||||
.section .rodata
|
||||
.align 64
|
||||
_vpaes_consts:
|
||||
.Lk_inv: # inv, inva
|
||||
@@ -1397,6 +1398,7 @@ _vpaes_consts:
|
||||
.asciz "Vector Permutation AES for x86_64/SSSE3, Mike Hamburg (Stanford University)"
|
||||
.align 64
|
||||
.size _vpaes_consts,.-_vpaes_consts
|
||||
.text
|
||||
___
|
||||
|
||||
if ($win64) {
|
||||
|
||||
@@ -1738,6 +1738,7 @@ ___
|
||||
}
|
||||
|
||||
$code.=<<___;
|
||||
.section .rodata
|
||||
.align 64
|
||||
.Land_mask:
|
||||
.quad 0x1fffffff,0x1fffffff,0x1fffffff,0x1fffffff
|
||||
@@ -1750,6 +1751,7 @@ $code.=<<___;
|
||||
.long 2,2,2,2, 3,3,3,3
|
||||
.long 4,4,4,4, 4,4,4,4
|
||||
.align 64
|
||||
.text
|
||||
___
|
||||
|
||||
if ($win64) {
|
||||
|
||||
@@ -3576,11 +3576,13 @@ $code.=<<___;
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
.section .rodata
|
||||
.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>"
|
||||
.text
|
||||
___
|
||||
|
||||
# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
|
||||
|
||||
@@ -62,6 +62,7 @@ $code.=<<___;
|
||||
.extern OPENSSL_ia32cap_P
|
||||
|
||||
# The polynomial
|
||||
.section .rodata
|
||||
.align 64
|
||||
.Lpoly:
|
||||
.quad 0xffffffffffffffff, 0x00000000ffffffff, 0x0000000000000000, 0xffffffff00000001
|
||||
@@ -80,6 +81,7 @@ $code.=<<___;
|
||||
.quad 0xf3b9cac2fc632551, 0xbce6faada7179e84, 0xffffffffffffffff, 0xffffffff00000000
|
||||
.LordK:
|
||||
.quad 0xccd1c8aaee00bc4f
|
||||
.text
|
||||
___
|
||||
|
||||
{
|
||||
|
||||
@@ -1053,6 +1053,7 @@ $code.=<<___;
|
||||
___
|
||||
|
||||
$code.=<<___;
|
||||
.section .rodata
|
||||
.align 64
|
||||
.Lbswap_mask:
|
||||
.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
|
||||
@@ -1066,6 +1067,7 @@ $code.=<<___;
|
||||
.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>"
|
||||
.align 64
|
||||
.text
|
||||
___
|
||||
}}} else {{{
|
||||
$code=<<___; # assembler is too old
|
||||
|
||||
@@ -331,6 +331,7 @@ $code .= <<____;
|
||||
.seh_endproc
|
||||
.size gcm_ghash_ssse3,.-gcm_ghash_ssse3
|
||||
|
||||
.section .rodata
|
||||
.align 16
|
||||
# .Lreverse_bytes is a permutation which, if applied with pshufb, reverses the
|
||||
# bytes in an XMM register.
|
||||
@@ -339,6 +340,7 @@ $code .= <<____;
|
||||
# .Llow4_mask is an XMM mask which selects the low four bits of each byte.
|
||||
.Llow4_mask:
|
||||
.quad 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f
|
||||
.text
|
||||
____
|
||||
|
||||
print $code;
|
||||
|
||||
@@ -1297,6 +1297,7 @@ ___
|
||||
}
|
||||
|
||||
$code.=<<___;
|
||||
.section .rodata
|
||||
.align 64
|
||||
.Lbswap_mask:
|
||||
.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
|
||||
@@ -1308,6 +1309,7 @@ $code.=<<___;
|
||||
|
||||
.asciz "GHASH for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 64
|
||||
.text
|
||||
___
|
||||
|
||||
$code =~ s/\`([^\`]*)\`/eval($1)/gem;
|
||||
|
||||
@@ -1815,6 +1815,7 @@ ___
|
||||
}
|
||||
}
|
||||
$code.=<<___;
|
||||
.section .rodata
|
||||
.align 64
|
||||
K_XX_XX:
|
||||
.long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 # K_00_19
|
||||
@@ -1833,6 +1834,7 @@ ___
|
||||
$code.=<<___;
|
||||
.asciz "SHA1 block transform for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 64
|
||||
.text
|
||||
___
|
||||
|
||||
# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
|
||||
|
||||
@@ -404,6 +404,7 @@ ___
|
||||
|
||||
if ($SZ==4) {
|
||||
$code.=<<___;
|
||||
.section .rodata
|
||||
.align 64
|
||||
.type $TABLE,\@object
|
||||
$TABLE:
|
||||
@@ -447,9 +448,11 @@ $TABLE:
|
||||
.long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908
|
||||
.long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908
|
||||
.asciz "SHA256 block transform for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.text
|
||||
___
|
||||
} else {
|
||||
$code.=<<___;
|
||||
.section .rodata
|
||||
.align 64
|
||||
.type $TABLE,\@object
|
||||
$TABLE:
|
||||
@@ -537,6 +540,7 @@ $TABLE:
|
||||
.quad 0x0001020304050607,0x08090a0b0c0d0e0f
|
||||
.quad 0x0001020304050607,0x08090a0b0c0d0e0f
|
||||
.asciz "SHA512 block transform for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.text
|
||||
___
|
||||
}
|
||||
|
||||
|
||||
@@ -1107,6 +1107,9 @@ ____
|
||||
$self->{value} = ".p2align\t" . (log($$line)/log(2));
|
||||
} elsif ($dir eq ".section") {
|
||||
$current_segment=$$line;
|
||||
if (!$elf && $current_segment eq ".rodata") {
|
||||
if ($flavour eq "macosx") { $self->{value} = ".section\t__DATA,__const"; }
|
||||
}
|
||||
if (!$elf && $current_segment eq ".init") {
|
||||
if ($flavour eq "macosx") { $self->{value} = ".mod_init_func"; }
|
||||
elsif ($flavour eq "mingw64") { $self->{value} = ".section\t.ctors"; }
|
||||
@@ -1159,9 +1162,10 @@ ____
|
||||
/\.section/ && do { my $v=undef;
|
||||
$$line =~ s/([^,]*).*/$1/;
|
||||
$$line = ".CRT\$XCU" if ($$line eq ".init");
|
||||
$$line = ".rdata" if ($$line eq ".rodata");
|
||||
if ($nasm) {
|
||||
$v="section $$line";
|
||||
if ($$line=~/\.([px])data/) {
|
||||
if ($$line=~/\.([prx])data/) {
|
||||
$v.=" rdata align=";
|
||||
$v.=$1 eq "p"? 4 : 8;
|
||||
} elsif ($$line=~/\.CRT\$/i) {
|
||||
@@ -1170,7 +1174,7 @@ ____
|
||||
} else {
|
||||
$v="$current_segment\tENDS\n" if ($current_segment);
|
||||
$v.="$$line\tSEGMENT";
|
||||
if ($$line=~/\.([px])data/) {
|
||||
if ($$line=~/\.([prx])data/) {
|
||||
$v.=" READONLY";
|
||||
$v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref);
|
||||
} elsif ($$line=~/\.CRT\$/i) {
|
||||
|
||||
Reference in New Issue
Block a user