I have now created an actual patch to fix this.
It turns out to be a small pattern bug in x86_64xlate.pl

Patch attached as openssl-1.0.0a-x86_64attr.patch.

While debugging this patch I ran into an unrelated issue where nmake would invoke nasm before the .asm file had been completely output.
This is probably a bug in the perl build used on one of the test
machines, but I think the patch to kludge around that race condition
might be useful too.

Patch attached as openssl-1.0.0a-x86_64cpuid-build-race.patch.

Comment: This patch fixes incorrect attributes of the ".init" segment in
  translated assemply for x86_64 when linked with Visual C code.
   This fix is applicable even if it is also decided to not use an .init
  seg anymore in x86_64cpuid.pl.
Author: WiseMo A/S, licensed under the Openssl license
diff -Naur openssl-1.0.0a.orig/crypto/perlasm/x86_64-xlate.pl 
openssl-1.0.0a/crypto/perlasm/x86_64-xlate.pl
--- openssl-1.0.0a.orig/crypto/perlasm/x86_64-xlate.pl  2010-06-01 
05:57:26.000000000 +0000
+++ openssl-1.0.0a/crypto/perlasm/x86_64-xlate.pl       2010-10-13 
17:53:21.000000000 +0000
@@ -542,16 +542,16 @@
                                    $line = ".CRT\$XCU" if ($line eq ".init");
                                    if ($nasm) {
                                        $v="section     $line";
-                                       if ($line=~/\.([px])data/) {
+                                       if ($line=~/\.(pdata|xdata|CRT\$)/) {
                                            $v.=" rdata align=";
-                                           $v.=$1 eq "p"? 4 : 8;
+                                           $v.=$1 eq "pdata"? 4 : 8;
                                        }
                                    } else {
                                        $v="$current_segment\tENDS\n" if 
($current_segment);
                                        $v.="$line\tSEGMENT";
-                                       if ($line=~/\.([px])data/) {
+                                       if ($line=~/\.(pdata|xdata|CRT\$)/) {
                                            $v.=" READONLY";
-                                           $v.=" ALIGN(".($1 eq "p" ? 4 : 
8).")" if ($masm>=$masmref);
+                                           $v.=" ALIGN(".($1 eq "pdata" ? 4 : 
8).")" if ($masm>=$masmref);
                                        }
                                    }
                                    $current_segment = $line;
Comment: Some perl interpreters will not always wait for the child pipe
   filter to exit before the parent perl interpreter exits (on platforms
   where doing so does not kill the filter process).  This in turn causes
   a race condition between the x86_64-xlate.pl script and make invoking the
   assembler on the output file.
    This patch tries harder to avoid that race condition by increasing the
   flush mode of perl just before closing the pipe AND adding a grace sleep
   after closing the pipe.
Author: WiseMo A/S, licensed under the Openssl license
diff -Naur openssl-1.0.0a.orig/crypto/x86_64cpuid.pl 
openssl-1.0.0a/crypto/x86_64cpuid.pl
--- openssl-1.0.0a.orig/crypto/x86_64cpuid.pl   2010-04-14 19:25:09.000000000 
+0000
+++ openssl-1.0.0a/crypto/x86_64cpuid.pl        2010-10-13 17:31:32.000000000 
+0000
@@ -229,4 +229,6 @@
 .size  OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
 ___
 
+$|=1; # flush more thoroughly
 close STDOUT;  # flush
+sleep(2); # Break race against background pipe completion

Reply via email to