No fprintf in the txt_db component
[openssl.git] / util / incore
index 299e75b736e64a4232151d1302779c4263d3a258..bb765b1966bd0bba1f14e4cabca072a41dcaf36f 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 #
-# Copyrifgr (c) 2011 The OpenSSL Project.
+# Copyright (c) 2011 The OpenSSL Project.
 #
 # The script embeds fingerprint into ELF executable object, either
 # application binary or shared library.
@@ -34,6 +34,7 @@
        @e_ident{magic,class,data,version,osabi,abiver,pad}=
                unpack("a4C*",$elf);
 
+       $!=42;          # signal fipsld to revert to two-step link
        die "not ELF file" if ($e_ident{magic} ne chr(0177)."ELF");
 
        my $elf_bits   = $e_ident{class}*32;    # 32 or 64
@@ -377,11 +378,11 @@ $FIPS_text_endX           = $exe->Lookup("FIPS_text_endX");
 if (!$legacy_mode) {
     if (!$FIPS_text_startX || !$FIPS_text_endX) {
        print STDERR "@ARGV[$#ARGV] is not cross-compiler aware.\n";
-       exit(1);
+       exit(42);       # signal fipsld to revert to two-step link
     }
 
     $FINGERPRINT_ascii_value
-                       = $exe->Lookup("FINGERPRINT_ascii_value")       or die;
+                       = $exe->Lookup("FINGERPRINT_ascii_value");
 
 }
 if ($FIPS_text_startX && $FIPS_text_endX) {
@@ -438,9 +439,12 @@ $fingerprint = FIPS_incore_fingerprint();
 
 if ($legacy_mode) {
     print unpack("H*",$fingerprint);
-} else {
+} elsif (defined($FINGERPRINT_ascii_value)) {
     seek(FD,$FINGERPRINT_ascii_value->{st_offset},0)   or die "$!";
     print FD unpack("H*",$fingerprint)                 or die "$!";
+} else {
+    seek(FD,$FIPS_signature->{st_offset},0)            or die "$!";
+    print FD $fingerprint                              or die "$!";
 }
 
 close (FD);