pic.patch 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. Index: openssl-1.0.1c/crypto/des/asm/desboth.pl
  2. ===================================================================
  3. --- openssl-1.0.1c.orig/crypto/des/asm/desboth.pl 2001-10-24 23:20:56.000000000 +0200
  4. +++ openssl-1.0.1c/crypto/des/asm/desboth.pl 2012-07-29 14:15:26.000000000 +0200
  5. @@ -16,6 +16,11 @@
  6. &push("edi");
  7. + &call (&label("pic_point0"));
  8. + &set_label("pic_point0");
  9. + &blindpop("ebp");
  10. + &add ("ebp", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point0") . "]");
  11. +
  12. &comment("");
  13. &comment("Load the data words");
  14. &mov($L,&DWP(0,"ebx","",0));
  15. @@ -47,15 +52,21 @@
  16. &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
  17. &mov(&swtmp(1), "eax");
  18. &mov(&swtmp(0), "ebx");
  19. - &call("DES_encrypt2");
  20. + &exch("ebx", "ebp");
  21. + &call("DES_encrypt2\@PLT");
  22. + &exch("ebx", "ebp");
  23. &mov(&swtmp(2), (DWC(($enc)?"0":"1")));
  24. &mov(&swtmp(1), "edi");
  25. &mov(&swtmp(0), "ebx");
  26. - &call("DES_encrypt2");
  27. + &exch("ebx", "ebp");
  28. + &call("DES_encrypt2\@PLT");
  29. + &exch("ebx", "ebp");
  30. &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
  31. &mov(&swtmp(1), "esi");
  32. &mov(&swtmp(0), "ebx");
  33. - &call("DES_encrypt2");
  34. + &exch("ebx", "ebp");
  35. + &call("DES_encrypt2\@PLT");
  36. + &exch("ebx", "ebp");
  37. &stack_pop(3);
  38. &mov($L,&DWP(0,"ebx","",0));
  39. Index: openssl-1.0.1c/crypto/perlasm/cbc.pl
  40. ===================================================================
  41. --- openssl-1.0.1c.orig/crypto/perlasm/cbc.pl 2011-07-13 08:22:46.000000000 +0200
  42. +++ openssl-1.0.1c/crypto/perlasm/cbc.pl 2012-07-29 14:15:26.000000000 +0200
  43. @@ -122,7 +122,11 @@
  44. &mov(&DWP($data_off,"esp","",0), "eax"); # put in array for call
  45. &mov(&DWP($data_off+4,"esp","",0), "ebx"); #
  46. - &call($enc_func);
  47. + &call (&label("pic_point0"));
  48. + &set_label("pic_point0");
  49. + &blindpop("ebx");
  50. + &add ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point0") . "]");
  51. + &call("$enc_func\@PLT");
  52. &mov("eax", &DWP($data_off,"esp","",0));
  53. &mov("ebx", &DWP($data_off+4,"esp","",0));
  54. @@ -185,7 +189,11 @@
  55. &mov(&DWP($data_off,"esp","",0), "eax"); # put in array for call
  56. &mov(&DWP($data_off+4,"esp","",0), "ebx"); #
  57. - &call($enc_func);
  58. + &call (&label("pic_point1"));
  59. + &set_label("pic_point1");
  60. + &blindpop("ebx");
  61. + &add ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point1") . "]");
  62. + &call("$enc_func\@PLT");
  63. &mov("eax", &DWP($data_off,"esp","",0));
  64. &mov("ebx", &DWP($data_off+4,"esp","",0));
  65. @@ -218,7 +226,11 @@
  66. &mov(&DWP($data_off,"esp","",0), "eax"); # put back
  67. &mov(&DWP($data_off+4,"esp","",0), "ebx"); #
  68. - &call($dec_func);
  69. + &call (&label("pic_point2"));
  70. + &set_label("pic_point2");
  71. + &blindpop("ebx");
  72. + &add ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point2") . "]");
  73. + &call("$dec_func\@PLT");
  74. &mov("eax", &DWP($data_off,"esp","",0)); # get return
  75. &mov("ebx", &DWP($data_off+4,"esp","",0)); #
  76. @@ -261,7 +273,11 @@
  77. &mov(&DWP($data_off,"esp","",0), "eax"); # put back
  78. &mov(&DWP($data_off+4,"esp","",0), "ebx"); #
  79. - &call($dec_func);
  80. + &call (&label("pic_point3"));
  81. + &set_label("pic_point3");
  82. + &blindpop("ebx");
  83. + &add ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point3") . "]");
  84. + &call("$dec_func\@PLT");
  85. &mov("eax", &DWP($data_off,"esp","",0)); # get return
  86. &mov("ebx", &DWP($data_off+4,"esp","",0)); #
  87. Index: openssl-1.0.1c/crypto/perlasm/x86gas.pl
  88. ===================================================================
  89. --- openssl-1.0.1c.orig/crypto/perlasm/x86gas.pl 2011-12-09 20:16:35.000000000 +0100
  90. +++ openssl-1.0.1c/crypto/perlasm/x86gas.pl 2012-07-29 14:15:26.000000000 +0200
  91. @@ -161,6 +161,7 @@
  92. if ($::macosx) { push (@out,"$tmp,2\n"); }
  93. elsif ($::elf) { push (@out,"$tmp,4\n"); }
  94. else { push (@out,"$tmp\n"); }
  95. + if ($::elf) { push (@out,".hidden\tOPENSSL_ia32cap_P\n"); }
  96. }
  97. push(@out,$initseg) if ($initseg);
  98. }
  99. @@ -218,8 +219,23 @@
  100. elsif ($::elf)
  101. { $initseg.=<<___;
  102. .section .init
  103. +___
  104. + if ($::pic)
  105. + { $initseg.=<<___;
  106. + pushl %ebx
  107. + call .pic_point0
  108. +.pic_point0:
  109. + popl %ebx
  110. + addl \$_GLOBAL_OFFSET_TABLE_+[.-.pic_point0],%ebx
  111. + call $f\@PLT
  112. + popl %ebx
  113. +___
  114. + }
  115. + else
  116. + { $initseg.=<<___;
  117. call $f
  118. ___
  119. + }
  120. }
  121. elsif ($::coff)
  122. { $initseg.=<<___; # applies to both Cygwin and Mingw
  123. Index: openssl-1.0.1c/crypto/x86cpuid.pl
  124. ===================================================================
  125. --- openssl-1.0.1c.orig/crypto/x86cpuid.pl 2012-02-28 15:20:34.000000000 +0100
  126. +++ openssl-1.0.1c/crypto/x86cpuid.pl 2012-07-29 14:15:26.000000000 +0200
  127. @@ -8,6 +8,8 @@
  128. for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
  129. +push(@out, ".hidden OPENSSL_ia32cap_P\n");
  130. +
  131. &function_begin("OPENSSL_ia32_cpuid");
  132. &xor ("edx","edx");
  133. &pushf ();
  134. @@ -139,9 +141,7 @@
  135. &set_label("nocpuid");
  136. &function_end("OPENSSL_ia32_cpuid");
  137. -&external_label("OPENSSL_ia32cap_P");
  138. -
  139. -&function_begin_B("OPENSSL_rdtsc","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
  140. +&function_begin_B("OPENSSL_rdtsc");
  141. &xor ("eax","eax");
  142. &xor ("edx","edx");
  143. &picmeup("ecx","OPENSSL_ia32cap_P");
  144. @@ -155,7 +155,7 @@
  145. # This works in Ring 0 only [read DJGPP+MS-DOS+privileged DPMI host],
  146. # but it's safe to call it on any [supported] 32-bit platform...
  147. # Just check for [non-]zero return value...
  148. -&function_begin_B("OPENSSL_instrument_halt","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
  149. +&function_begin_B("OPENSSL_instrument_halt");
  150. &picmeup("ecx","OPENSSL_ia32cap_P");
  151. &bt (&DWP(0,"ecx"),4);
  152. &jnc (&label("nohalt")); # no TSC
  153. @@ -222,7 +222,7 @@
  154. &ret ();
  155. &function_end_B("OPENSSL_far_spin");
  156. -&function_begin_B("OPENSSL_wipe_cpu","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
  157. +&function_begin_B("OPENSSL_wipe_cpu");
  158. &xor ("eax","eax");
  159. &xor ("edx","edx");
  160. &picmeup("ecx","OPENSSL_ia32cap_P");