summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorotto <>2008-09-19 06:09:01 +0000
committerotto <>2008-09-19 06:09:01 +0000
commitd8a728372d924a59e821c02139ecd7915c848b4d (patch)
tree4bd0fad7309fd9e5917f84ba519345a74823bc67 /src
parent404f42e023f74f798d3e32269dc691e855f21e4c (diff)
downloadopenbsd-d8a728372d924a59e821c02139ecd7915c848b4d.tar.gz
openbsd-d8a728372d924a59e821c02139ecd7915c848b4d.tar.bz2
openbsd-d8a728372d924a59e821c02139ecd7915c848b4d.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 'src')
-rw-r--r--src/lib/libcrypto/aes/asm/aes-586.pl8
-rwxr-xr-xsrc/lib/libcrypto/perlasm/x86_64-xlate.pl5
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl56
-rwxr-xr-xsrc/lib/libcrypto/rc4/asm/rc4-x86_64.pl5
-rw-r--r--src/lib/libcrypto/x86_64cpuid.pl4
-rw-r--r--src/lib/libssl/src/crypto/aes/asm/aes-586.pl8
-rwxr-xr-xsrc/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl5
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86unix.pl56
-rwxr-xr-xsrc/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl5
-rw-r--r--src/lib/libssl/src/crypto/x86_64cpuid.pl4
10 files changed, 128 insertions, 28 deletions
diff --git a/src/lib/libcrypto/aes/asm/aes-586.pl b/src/lib/libcrypto/aes/asm/aes-586.pl
index 89fa261794..3da307bef9 100644
--- a/src/lib/libcrypto/aes/asm/aes-586.pl
+++ b/src/lib/libcrypto/aes/asm/aes-586.pl
@@ -250,7 +250,7 @@ sub enclast()
250sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } } 250sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
251 251
252&public_label("AES_Te"); 252&public_label("AES_Te");
253&function_begin_B("_x86_AES_encrypt"); 253&function_begin_C("_x86_AES_encrypt");
254 if ($vertical_spin) { 254 if ($vertical_spin) {
255 # I need high parts of volatile registers to be accessible... 255 # I need high parts of volatile registers to be accessible...
256 &exch ($s1="edi",$key="ebx"); 256 &exch ($s1="edi",$key="ebx");
@@ -539,7 +539,7 @@ sub declast()
539} 539}
540 540
541&public_label("AES_Td"); 541&public_label("AES_Td");
542&function_begin_B("_x86_AES_decrypt"); 542&function_begin_C("_x86_AES_decrypt");
543 # note that caller is expected to allocate stack frame for me! 543 # note that caller is expected to allocate stack frame for me!
544 &mov (&DWP(12,"esp"),$key); # save key 544 &mov (&DWP(12,"esp"),$key); # save key
545 545
@@ -1240,7 +1240,7 @@ sub enckey()
1240# int AES_set_encrypt_key(const unsigned char *userKey, const int bits, 1240# int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
1241# AES_KEY *key) 1241# AES_KEY *key)
1242&public_label("AES_Te"); 1242&public_label("AES_Te");
1243&function_begin("AES_set_encrypt_key"); 1243&function_begin("AES_set_encrypt_key", "", "_x86_AES_set_encrypt_key");
1244 &mov ("esi",&wparam(0)); # user supplied key 1244 &mov ("esi",&wparam(0)); # user supplied key
1245 &mov ("edi",&wparam(2)); # private key schedule 1245 &mov ("edi",&wparam(2)); # private key schedule
1246 1246
@@ -1467,7 +1467,7 @@ sub deckey()
1467 &mov (&DWP(0,"esp"),"eax"); 1467 &mov (&DWP(0,"esp"),"eax");
1468 &mov (&DWP(4,"esp"),"ecx"); 1468 &mov (&DWP(4,"esp"),"ecx");
1469 &mov (&DWP(8,"esp"),"edx"); 1469 &mov (&DWP(8,"esp"),"edx");
1470 &call ("AES_set_encrypt_key"); 1470 &call ("_x86_AES_set_encrypt_key");
1471 &add ("esp",12); 1471 &add ("esp",12);
1472 &cmp ("eax",0); 1472 &cmp ("eax",0);
1473 &je (&label("proceed")); 1473 &je (&label("proceed"));
diff --git a/src/lib/libcrypto/perlasm/x86_64-xlate.pl b/src/lib/libcrypto/perlasm/x86_64-xlate.pl
index a4af769b4a..74153b017d 100755
--- a/src/lib/libcrypto/perlasm/x86_64-xlate.pl
+++ b/src/lib/libcrypto/perlasm/x86_64-xlate.pl
@@ -163,7 +163,8 @@ my $current_function;
163 local *line = shift; 163 local *line = shift;
164 undef $ret; 164 undef $ret;
165 165
166 if ($line =~ /^([^\(,]*)\(([%\w,]+)\)/) { 166 if ($line =~ /^([^\(,]*)\(([%\w,]+)\)/ &&
167 !($line =~ /^PIC_(GOT|PLT)/)) {
167 $self->{label} = $1; 168 $self->{label} = $1;
168 ($self->{base},$self->{index},$self->{scale})=split(/,/,$2); 169 ($self->{base},$self->{index},$self->{scale})=split(/,/,$2);
169 $self->{scale} = 1 if (!defined($self->{scale})); 170 $self->{scale} = 1 if (!defined($self->{scale}));
@@ -429,6 +430,8 @@ my $current_function;
429 } 430 }
430} 431}
431 432
433print "#include <machine/asm.h>\n";
434
432while($line=<>) { 435while($line=<>) {
433 436
434 chomp($line); 437 chomp($line);
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
index 02d72a32bc..ae8f0964dc 100644
--- a/src/lib/libcrypto/perlasm/x86unix.pl
+++ b/src/lib/libcrypto/perlasm/x86unix.pl
@@ -345,7 +345,7 @@ sub main'file
345 local($file)=@_; 345 local($file)=@_;
346 346
347 if ($main'openbsd) 347 if ($main'openbsd)
348 { push(@out,"#include <machine/asm.h>\n"); return; } 348 { push(@out,"#include <machine/asm.h>\n"); }
349 349
350 local($tmp)=<<"EOF"; 350 local($tmp)=<<"EOF";
351 .file "$file.s" 351 .file "$file.s"
@@ -355,13 +355,17 @@ EOF
355 355
356sub main'function_begin 356sub main'function_begin
357 { 357 {
358 local($func)=@_; 358 local($func,$junk,$llabel)=@_;
359 359
360 &main'external_label($func); 360 &main'external_label($func);
361 $func=$under.$func; 361 $func=$under.$func;
362 362
363 if ($main'openbsd) 363 if ($main'openbsd)
364 { push (@out, "\nENTRY($func)\n"); goto skip; } 364 {
365 push (@out, "\nENTRY($func)\n");
366 push (@out, "$llabel:\n") if $llabel;
367 goto skip;
368 }
365 369
366 local($tmp)=<<"EOF"; 370 local($tmp)=<<"EOF";
367.text 371.text
@@ -417,6 +421,44 @@ skip:
417 $stack=4; 421 $stack=4;
418 } 422 }
419 423
424# Like function_begin_B but with static linkage
425sub main'function_begin_C
426 {
427 local($func,$extra)=@_;
428
429 &main'external_label($func);
430 $func=$under.$func;
431
432 if ($main'openbsd)
433 {
434 local($tmp)=<<"EOF";
435.text
436_ALIGN_TEXT
437.type $func,\@function
438$func:
439EOF
440 push(@out, $tmp);
441 goto skip;
442 }
443
444 local($tmp)=<<"EOF";
445.text
446.globl $func
447EOF
448 push(@out,$tmp);
449 if ($main'cpp)
450 { push(@out,"TYPE($func,\@function)\n"); }
451 elsif ($main'coff)
452 { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
453 elsif ($main'aout and !$main'pic)
454 { }
455 else { push(@out,".type $func,\@function\n"); }
456 push(@out,".align\t$align\n");
457 push(@out,"$func:\n");
458skip:
459 $stack=4;
460 }
461
420sub main'function_end 462sub main'function_end
421 { 463 {
422 local($func)=@_; 464 local($func)=@_;
@@ -474,6 +516,8 @@ sub main'function_end_B
474 %label=(); 516 %label=();
475 } 517 }
476 518
519sub main'function_end_C { function_end_B(@_); }
520
477sub main'wparam 521sub main'wparam
478 { 522 {
479 local($num)=@_; 523 local($num)=@_;
@@ -510,7 +554,7 @@ sub main'swtmp
510 554
511sub main'comment 555sub main'comment
512 { 556 {
513 if (!defined($com_start) or $main'elf) 557 if (!defined($com_start) or (!$main'openbsd && $main'elf))
514 { # Regarding $main'elf above... 558 { # Regarding $main'elf above...
515 # GNU and SVR4 as'es use different comment delimiters, 559 # GNU and SVR4 as'es use different comment delimiters,
516 push(@out,"\n"); # so we just skip ELF comments... 560 push(@out,"\n"); # so we just skip ELF comments...
@@ -731,7 +775,9 @@ sub main'initseg
731 { 775 {
732 $tmp=<<___; 776 $tmp=<<___;
733.section .init 777.section .init
734 call $under$f 778 PIC_PROLOGUE
779 call PIC_PLT($under$f)
780 PIC_EPILOGUE
735 jmp .Linitalign 781 jmp .Linitalign
736.align $align 782.align $align
737.Linitalign: 783.Linitalign:
diff --git a/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl b/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl
index 2d47320485..92c52f3433 100755
--- a/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl
+++ b/src/lib/libcrypto/rc4/asm/rc4-x86_64.pl
@@ -269,8 +269,7 @@ RC4_set_key:
269 xor $ido,$ido 269 xor $ido,$ido
270 xor %r10,%r10 270 xor %r10,%r10
271 xor %r11,%r11 271 xor %r11,%r11
272 272 mov PIC_GOT(OPENSSL_ia32cap_P),$idx#d
273 mov OPENSSL_ia32cap_P(%rip),$idx#d
274 bt \$20,$idx#d 273 bt \$20,$idx#d
275 jnc .Lw1stloop 274 jnc .Lw1stloop
276 bt \$30,$idx#d 275 bt \$30,$idx#d
@@ -338,7 +337,7 @@ RC4_set_key:
338RC4_options: 337RC4_options:
339 .picmeup %rax 338 .picmeup %rax
340 lea .Lopts-.(%rax),%rax 339 lea .Lopts-.(%rax),%rax
341 mov OPENSSL_ia32cap_P(%rip),%edx 340 mov PIC_GOT(OPENSSL_ia32cap_P),%edx
342 bt \$20,%edx 341 bt \$20,%edx
343 jnc .Ldone 342 jnc .Ldone
344 add \$12,%rax 343 add \$12,%rax
diff --git a/src/lib/libcrypto/x86_64cpuid.pl b/src/lib/libcrypto/x86_64cpuid.pl
index 2616a03da6..8946b464a8 100644
--- a/src/lib/libcrypto/x86_64cpuid.pl
+++ b/src/lib/libcrypto/x86_64cpuid.pl
@@ -47,6 +47,8 @@ CRT\$XIU ENDS
47 47
48___ 48___
49print<<___ if(!defined($masm)); 49print<<___ if(!defined($masm));
50#include <machine/asm.h>
51
50.text 52.text
51 53
52.globl OPENSSL_atomic_add 54.globl OPENSSL_atomic_add
@@ -95,7 +97,7 @@ OPENSSL_wipe_cpu:
95.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu 97.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
96 98
97.section .init 99.section .init
98 call OPENSSL_cpuid_setup 100 call PIC_PLT(OPENSSL_cpuid_setup)
99 101
100___ 102___
101 103
diff --git a/src/lib/libssl/src/crypto/aes/asm/aes-586.pl b/src/lib/libssl/src/crypto/aes/asm/aes-586.pl
index 89fa261794..3da307bef9 100644
--- a/src/lib/libssl/src/crypto/aes/asm/aes-586.pl
+++ b/src/lib/libssl/src/crypto/aes/asm/aes-586.pl
@@ -250,7 +250,7 @@ sub enclast()
250sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } } 250sub _data_word() { my $i; while(defined($i=shift)) { &data_word($i,$i); } }
251 251
252&public_label("AES_Te"); 252&public_label("AES_Te");
253&function_begin_B("_x86_AES_encrypt"); 253&function_begin_C("_x86_AES_encrypt");
254 if ($vertical_spin) { 254 if ($vertical_spin) {
255 # I need high parts of volatile registers to be accessible... 255 # I need high parts of volatile registers to be accessible...
256 &exch ($s1="edi",$key="ebx"); 256 &exch ($s1="edi",$key="ebx");
@@ -539,7 +539,7 @@ sub declast()
539} 539}
540 540
541&public_label("AES_Td"); 541&public_label("AES_Td");
542&function_begin_B("_x86_AES_decrypt"); 542&function_begin_C("_x86_AES_decrypt");
543 # note that caller is expected to allocate stack frame for me! 543 # note that caller is expected to allocate stack frame for me!
544 &mov (&DWP(12,"esp"),$key); # save key 544 &mov (&DWP(12,"esp"),$key); # save key
545 545
@@ -1240,7 +1240,7 @@ sub enckey()
1240# int AES_set_encrypt_key(const unsigned char *userKey, const int bits, 1240# int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
1241# AES_KEY *key) 1241# AES_KEY *key)
1242&public_label("AES_Te"); 1242&public_label("AES_Te");
1243&function_begin("AES_set_encrypt_key"); 1243&function_begin("AES_set_encrypt_key", "", "_x86_AES_set_encrypt_key");
1244 &mov ("esi",&wparam(0)); # user supplied key 1244 &mov ("esi",&wparam(0)); # user supplied key
1245 &mov ("edi",&wparam(2)); # private key schedule 1245 &mov ("edi",&wparam(2)); # private key schedule
1246 1246
@@ -1467,7 +1467,7 @@ sub deckey()
1467 &mov (&DWP(0,"esp"),"eax"); 1467 &mov (&DWP(0,"esp"),"eax");
1468 &mov (&DWP(4,"esp"),"ecx"); 1468 &mov (&DWP(4,"esp"),"ecx");
1469 &mov (&DWP(8,"esp"),"edx"); 1469 &mov (&DWP(8,"esp"),"edx");
1470 &call ("AES_set_encrypt_key"); 1470 &call ("_x86_AES_set_encrypt_key");
1471 &add ("esp",12); 1471 &add ("esp",12);
1472 &cmp ("eax",0); 1472 &cmp ("eax",0);
1473 &je (&label("proceed")); 1473 &je (&label("proceed"));
diff --git a/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl b/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
index a4af769b4a..74153b017d 100755
--- a/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
@@ -163,7 +163,8 @@ my $current_function;
163 local *line = shift; 163 local *line = shift;
164 undef $ret; 164 undef $ret;
165 165
166 if ($line =~ /^([^\(,]*)\(([%\w,]+)\)/) { 166 if ($line =~ /^([^\(,]*)\(([%\w,]+)\)/ &&
167 !($line =~ /^PIC_(GOT|PLT)/)) {
167 $self->{label} = $1; 168 $self->{label} = $1;
168 ($self->{base},$self->{index},$self->{scale})=split(/,/,$2); 169 ($self->{base},$self->{index},$self->{scale})=split(/,/,$2);
169 $self->{scale} = 1 if (!defined($self->{scale})); 170 $self->{scale} = 1 if (!defined($self->{scale}));
@@ -429,6 +430,8 @@ my $current_function;
429 } 430 }
430} 431}
431 432
433print "#include <machine/asm.h>\n";
434
432while($line=<>) { 435while($line=<>) {
433 436
434 chomp($line); 437 chomp($line);
diff --git a/src/lib/libssl/src/crypto/perlasm/x86unix.pl b/src/lib/libssl/src/crypto/perlasm/x86unix.pl
index 02d72a32bc..ae8f0964dc 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86unix.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86unix.pl
@@ -345,7 +345,7 @@ sub main'file
345 local($file)=@_; 345 local($file)=@_;
346 346
347 if ($main'openbsd) 347 if ($main'openbsd)
348 { push(@out,"#include <machine/asm.h>\n"); return; } 348 { push(@out,"#include <machine/asm.h>\n"); }
349 349
350 local($tmp)=<<"EOF"; 350 local($tmp)=<<"EOF";
351 .file "$file.s" 351 .file "$file.s"
@@ -355,13 +355,17 @@ EOF
355 355
356sub main'function_begin 356sub main'function_begin
357 { 357 {
358 local($func)=@_; 358 local($func,$junk,$llabel)=@_;
359 359
360 &main'external_label($func); 360 &main'external_label($func);
361 $func=$under.$func; 361 $func=$under.$func;
362 362
363 if ($main'openbsd) 363 if ($main'openbsd)
364 { push (@out, "\nENTRY($func)\n"); goto skip; } 364 {
365 push (@out, "\nENTRY($func)\n");
366 push (@out, "$llabel:\n") if $llabel;
367 goto skip;
368 }
365 369
366 local($tmp)=<<"EOF"; 370 local($tmp)=<<"EOF";
367.text 371.text
@@ -417,6 +421,44 @@ skip:
417 $stack=4; 421 $stack=4;
418 } 422 }
419 423
424# Like function_begin_B but with static linkage
425sub main'function_begin_C
426 {
427 local($func,$extra)=@_;
428
429 &main'external_label($func);
430 $func=$under.$func;
431
432 if ($main'openbsd)
433 {
434 local($tmp)=<<"EOF";
435.text
436_ALIGN_TEXT
437.type $func,\@function
438$func:
439EOF
440 push(@out, $tmp);
441 goto skip;
442 }
443
444 local($tmp)=<<"EOF";
445.text
446.globl $func
447EOF
448 push(@out,$tmp);
449 if ($main'cpp)
450 { push(@out,"TYPE($func,\@function)\n"); }
451 elsif ($main'coff)
452 { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
453 elsif ($main'aout and !$main'pic)
454 { }
455 else { push(@out,".type $func,\@function\n"); }
456 push(@out,".align\t$align\n");
457 push(@out,"$func:\n");
458skip:
459 $stack=4;
460 }
461
420sub main'function_end 462sub main'function_end
421 { 463 {
422 local($func)=@_; 464 local($func)=@_;
@@ -474,6 +516,8 @@ sub main'function_end_B
474 %label=(); 516 %label=();
475 } 517 }
476 518
519sub main'function_end_C { function_end_B(@_); }
520
477sub main'wparam 521sub main'wparam
478 { 522 {
479 local($num)=@_; 523 local($num)=@_;
@@ -510,7 +554,7 @@ sub main'swtmp
510 554
511sub main'comment 555sub main'comment
512 { 556 {
513 if (!defined($com_start) or $main'elf) 557 if (!defined($com_start) or (!$main'openbsd && $main'elf))
514 { # Regarding $main'elf above... 558 { # Regarding $main'elf above...
515 # GNU and SVR4 as'es use different comment delimiters, 559 # GNU and SVR4 as'es use different comment delimiters,
516 push(@out,"\n"); # so we just skip ELF comments... 560 push(@out,"\n"); # so we just skip ELF comments...
@@ -731,7 +775,9 @@ sub main'initseg
731 { 775 {
732 $tmp=<<___; 776 $tmp=<<___;
733.section .init 777.section .init
734 call $under$f 778 PIC_PROLOGUE
779 call PIC_PLT($under$f)
780 PIC_EPILOGUE
735 jmp .Linitalign 781 jmp .Linitalign
736.align $align 782.align $align
737.Linitalign: 783.Linitalign:
diff --git a/src/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl b/src/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl
index 2d47320485..92c52f3433 100755
--- a/src/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl
+++ b/src/lib/libssl/src/crypto/rc4/asm/rc4-x86_64.pl
@@ -269,8 +269,7 @@ RC4_set_key:
269 xor $ido,$ido 269 xor $ido,$ido
270 xor %r10,%r10 270 xor %r10,%r10
271 xor %r11,%r11 271 xor %r11,%r11
272 272 mov PIC_GOT(OPENSSL_ia32cap_P),$idx#d
273 mov OPENSSL_ia32cap_P(%rip),$idx#d
274 bt \$20,$idx#d 273 bt \$20,$idx#d
275 jnc .Lw1stloop 274 jnc .Lw1stloop
276 bt \$30,$idx#d 275 bt \$30,$idx#d
@@ -338,7 +337,7 @@ RC4_set_key:
338RC4_options: 337RC4_options:
339 .picmeup %rax 338 .picmeup %rax
340 lea .Lopts-.(%rax),%rax 339 lea .Lopts-.(%rax),%rax
341 mov OPENSSL_ia32cap_P(%rip),%edx 340 mov PIC_GOT(OPENSSL_ia32cap_P),%edx
342 bt \$20,%edx 341 bt \$20,%edx
343 jnc .Ldone 342 jnc .Ldone
344 add \$12,%rax 343 add \$12,%rax
diff --git a/src/lib/libssl/src/crypto/x86_64cpuid.pl b/src/lib/libssl/src/crypto/x86_64cpuid.pl
index 2616a03da6..8946b464a8 100644
--- a/src/lib/libssl/src/crypto/x86_64cpuid.pl
+++ b/src/lib/libssl/src/crypto/x86_64cpuid.pl
@@ -47,6 +47,8 @@ CRT\$XIU ENDS
47 47
48___ 48___
49print<<___ if(!defined($masm)); 49print<<___ if(!defined($masm));
50#include <machine/asm.h>
51
50.text 52.text
51 53
52.globl OPENSSL_atomic_add 54.globl OPENSSL_atomic_add
@@ -95,7 +97,7 @@ OPENSSL_wipe_cpu:
95.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu 97.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
96 98
97.section .init 99.section .init
98 call OPENSSL_cpuid_setup 100 call PIC_PLT(OPENSSL_cpuid_setup)
99 101
100___ 102___
101 103