summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2008-09-19 06:09:01 +0000
committerotto <otto@openbsd.org>2008-09-19 06:09:01 +0000
commit554f6078d424c1b5df3a85316ba130428560694b (patch)
treeec547c06f8b497ba3b22746dea25c5011df4fe78 /lib/libssl/src
parentincrease MAXINTERP from 64 to 128 and allow a little extra room on top (diff)
downloadwireguard-openbsd-554f6078d424c1b5df3a85316ba130428560694b.tar.xz
wireguard-openbsd-554f6078d424c1b5df3a85316ba130428560694b.zip
fix some cause of bad TEXTREL on i386 and amd64
- global function calls in .init sections (diff makes them via PLT) - calls to global functions in aes-586.S (made static or local) - global variable accesses in rc4-x86_64.S (now made via GOT) from djm@large; ok miod@
Diffstat (limited to 'lib/libssl/src')
-rw-r--r--lib/libssl/src/crypto/aes/asm/aes-586.pl8
-rwxr-xr-xlib/libssl/src/crypto/perlasm/x86_64-xlate.pl5
-rw-r--r--lib/libssl/src/crypto/perlasm/x86unix.pl56
-rwxr-xr-xlib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl5
-rw-r--r--lib/libssl/src/crypto/x86_64cpuid.pl4
5 files changed, 64 insertions, 14 deletions
diff --git a/lib/libssl/src/crypto/aes/asm/aes-586.pl b/lib/libssl/src/crypto/aes/asm/aes-586.pl
index 89fa2617944..3da307bef94 100644
--- a/lib/libssl/src/crypto/aes/asm/aes-586.pl
+++ b/lib/libssl/src/crypto/aes/asm/aes-586.pl
@@ -250,7 +250,7 @@ sub enclast()
sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
&public_label("AES_Te");
-&function_begin_B("_x86_AES_encrypt");
+&function_begin_C("_x86_AES_encrypt");
if ($vertical_spin) {
# I need high parts of volatile registers to be accessible...
&exch ($s1="edi",$key="ebx");
@@ -539,7 +539,7 @@ sub declast()
}
&public_label("AES_Td");
-&function_begin_B("_x86_AES_decrypt");
+&function_begin_C("_x86_AES_decrypt");
# note that caller is expected to allocate stack frame for me!
&mov (&DWP(12,"esp"),$key); # save key
@@ -1240,7 +1240,7 @@ sub enckey()
# int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
# AES_KEY *key)
&public_label("AES_Te");
-&function_begin("AES_set_encrypt_key");
+&function_begin("AES_set_encrypt_key", "", "_x86_AES_set_encrypt_key");
&mov ("esi",&wparam(0)); # user supplied key
&mov ("edi",&wparam(2)); # private key schedule
@@ -1467,7 +1467,7 @@ sub deckey()
&mov (&DWP(0,"esp"),"eax");
&mov (&DWP(4,"esp"),"ecx");
&mov (&DWP(8,"esp"),"edx");
- &call ("AES_set_encrypt_key");
+ &call ("_x86_AES_set_encrypt_key");
&add ("esp",12);
&cmp ("eax",0);
&je (&label("proceed"));
diff --git a/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl b/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
index a4af769b4a6..74153b017d4 100755
--- a/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
+++ b/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
@@ -163,7 +163,8 @@ my $current_function;
local *line = shift;
undef $ret;
- if ($line =~ /^([^\(,]*)\(([%\w,]+)\)/) {
+ if ($line =~ /^([^\(,]*)\(([%\w,]+)\)/ &&
+ !($line =~ /^PIC_(GOT|PLT)/)) {
$self->{label} = $1;
($self->{base},$self->{index},$self->{scale})=split(/,/,$2);
$self->{scale} = 1 if (!defined($self->{scale}));
@@ -429,6 +430,8 @@ my $current_function;
}
}
+print "#include <machine/asm.h>\n";
+
while($line=<>) {
chomp($line);
diff --git a/lib/libssl/src/crypto/perlasm/x86unix.pl b/lib/libssl/src/crypto/perlasm/x86unix.pl
index 02d72a32bcd..ae8f0964dc0 100644
--- a/lib/libssl/src/crypto/perlasm/x86unix.pl
+++ b/lib/libssl/src/crypto/perlasm/x86unix.pl
@@ -345,7 +345,7 @@ sub main'file
local($file)=@_;
if ($main'openbsd)
- { push(@out,"#include <machine/asm.h>\n"); return; }
+ { push(@out,"#include <machine/asm.h>\n"); }
local($tmp)=<<"EOF";
.file "$file.s"
@@ -355,13 +355,17 @@ EOF
sub main'function_begin
{
- local($func)=@_;
+ local($func,$junk,$llabel)=@_;
&main'external_label($func);
$func=$under.$func;
if ($main'openbsd)
- { push (@out, "\nENTRY($func)\n"); goto skip; }
+ {
+ push (@out, "\nENTRY($func)\n");
+ push (@out, "$llabel:\n") if $llabel;
+ goto skip;
+ }
local($tmp)=<<"EOF";
.text
@@ -417,6 +421,44 @@ skip:
$stack=4;
}
+# Like function_begin_B but with static linkage
+sub main'function_begin_C
+ {
+ local($func,$extra)=@_;
+
+ &main'external_label($func);
+ $func=$under.$func;
+
+ if ($main'openbsd)
+ {
+ local($tmp)=<<"EOF";
+.text
+_ALIGN_TEXT
+.type $func,\@function
+$func:
+EOF
+ push(@out, $tmp);
+ goto skip;
+ }
+
+ local($tmp)=<<"EOF";
+.text
+.globl $func
+EOF
+ push(@out,$tmp);
+ if ($main'cpp)
+ { push(@out,"TYPE($func,\@function)\n"); }
+ elsif ($main'coff)
+ { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
+ elsif ($main'aout and !$main'pic)
+ { }
+ else { push(@out,".type $func,\@function\n"); }
+ push(@out,".align\t$align\n");
+ push(@out,"$func:\n");
+skip:
+ $stack=4;
+ }
+
sub main'function_end
{
local($func)=@_;
@@ -474,6 +516,8 @@ sub main'function_end_B
%label=();
}
+sub main'function_end_C { function_end_B(@_); }
+
sub main'wparam
{
local($num)=@_;
@@ -510,7 +554,7 @@ sub main'swtmp
sub main'comment
{
- if (!defined($com_start) or $main'elf)
+ if (!defined($com_start) or (!$main'openbsd && $main'elf))
{ # Regarding $main'elf above...
# GNU and SVR4 as'es use different comment delimiters,
push(@out,"\n"); # so we just skip ELF comments...
@@ -731,7 +775,9 @@ sub main'initseg
{
$tmp=<<___;
.section .init
- call $under$f
+ PIC_PROLOGUE
+ call PIC_PLT($under$f)
+ PIC_EPILOGUE
jmp .Linitalign
.align $align
.Linitalign:
diff --git a/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl b/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl
index 2d473204854..92c52f34333 100755
--- a/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl
+++ b/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl
@@ -269,8 +269,7 @@ RC4_set_key:
xor $ido,$ido
xor %r10,%r10
xor %r11,%r11
-
- mov OPENSSL_ia32cap_P(%rip),$idx#d
+ mov PIC_GOT(OPENSSL_ia32cap_P),$idx#d
bt \$20,$idx#d
jnc .Lw1stloop
bt \$30,$idx#d
@@ -338,7 +337,7 @@ RC4_set_key:
RC4_options:
.picmeup %rax
lea .Lopts-.(%rax),%rax
- mov OPENSSL_ia32cap_P(%rip),%edx
+ mov PIC_GOT(OPENSSL_ia32cap_P),%edx
bt \$20,%edx
jnc .Ldone
add \$12,%rax
diff --git a/lib/libssl/src/crypto/x86_64cpuid.pl b/lib/libssl/src/crypto/x86_64cpuid.pl
index 2616a03da69..8946b464a8f 100644
--- a/lib/libssl/src/crypto/x86_64cpuid.pl
+++ b/lib/libssl/src/crypto/x86_64cpuid.pl
@@ -47,6 +47,8 @@ CRT\$XIU ENDS
___
print<<___ if(!defined($masm));
+#include <machine/asm.h>
+
.text
.globl OPENSSL_atomic_add
@@ -95,7 +97,7 @@ OPENSSL_wipe_cpu:
.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
.section .init
- call OPENSSL_cpuid_setup
+ call PIC_PLT(OPENSSL_cpuid_setup)
___