[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Wed Mar 30 09:23:14 UTC 2016


The branch master has been updated
       via  84af71a916d0bfce4dde135e4a5fe60d75f4940c (commit)
       via  2a08d1a05db937f8b1a62422b78ffe2fa07d3ead (commit)
      from  dcdb4028b3981585537c6d57635ea91cd59589fa (commit)


- Log -----------------------------------------------------------------
commit 84af71a916d0bfce4dde135e4a5fe60d75f4940c
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Mar 29 16:48:02 2016 +0200

    Break out DllMain from crypto/cryptlib.c and use it in shared libs only
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

commit 2a08d1a05db937f8b1a62422b78ffe2fa07d3ead
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Mar 29 16:45:03 2016 +0200

    Make it possible to specify source files that will only be used for shared libs
    
    There are rare cases when an object file will only be used when
    building a shared library.  To enable this, we introduce
    SHARED_SOURCE:
    
        SHARED_SOURCE[libfoo]=dllmain.c
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 Configurations/README        |  5 +++++
 Configurations/README.design |  4 ++++
 Configurations/common.tmpl   | 10 ++++++---
 Configure                    | 32 ++++++++++++++++++++++++++-
 crypto/build.info            |  4 ++++
 crypto/cryptlib.c            | 49 ------------------------------------------
 crypto/dllmain.c             | 51 ++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 102 insertions(+), 53 deletions(-)
 create mode 100644 crypto/dllmain.c

diff --git a/Configurations/README b/Configurations/README
index a4c1567..a5a006e 100644
--- a/Configurations/README
+++ b/Configurations/README
@@ -358,6 +358,11 @@ sense at all to just have a rename like that (why not just use
 "libbar" everywhere?), it does make sense when it can be used
 conditionally.  See a little further below for an example.
 
+In some cases, it's desirable to include some source files in the
+shared form of a library only:
+
+    SHARED_SOURCE[libfoo]=dllmain.c
+
 For any file to be built, it's also possible to tell what extra
 include paths the build of their source files should use:
 
diff --git a/Configurations/README.design b/Configurations/README.design
index 5065960..574982f 100644
--- a/Configurations/README.design
+++ b/Configurations/README.design
@@ -233,6 +233,10 @@ indexes:
                SOURCE variables, and AS source files for programs and
                libraries.
 
+  shared_sources =>
+               a hash table just like 'sources', but only as source
+               files (object files) for building shared libraries.
+
 As an example, here is how the build.info files example from the
 section above would be digested into a %unified_info table:
 
diff --git a/Configurations/common.tmpl b/Configurations/common.tmpl
index d89817e..9c80070 100644
--- a/Configurations/common.tmpl
+++ b/Configurations/common.tmpl
@@ -92,9 +92,11 @@
          $OUT .= libobj2shlib(shlib => $unified_info{sharednames}->{$lib},
                               lib => $lib,
                               objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
-                                        @{$unified_info{sources}->{$lib}} ],
+                                        (@{$unified_info{sources}->{$lib}},
+                                         @{$unified_info{shared_sources}->{$lib}}) ],
                               deps => [ reducedepends(resolvedepends($lib)) ],
                               %ordinals);
+         map { doobj($_, $lib, intent => "lib") } @{$unified_info{shared_sources}->{$lib}};
      }
      $OUT .= obj2lib(lib => $lib,
                      objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
@@ -111,9 +113,11 @@
      return "" if $cache{$lib};
      $OUT .= obj2dso(lib => $lib,
                      objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
-                               @{$unified_info{sources}->{$lib}} ],
+                               (@{$unified_info{sources}->{$lib}},
+                                @{$unified_info{shared_sources}->{$lib}}) ],
                      deps => [ resolvedepends($lib) ]);
-     map { doobj($_, $lib, intent => "dso") } @{$unified_info{sources}->{$lib}};
+     map { doobj($_, $lib, intent => "dso") } (@{$unified_info{sources}->{$lib}},
+                                               @{$unified_info{shared_sources}->{$lib}});
      $cache{$lib} = 1;
  }
 
diff --git a/Configure b/Configure
index d8064d1..b4afea9 100755
--- a/Configure
+++ b/Configure
@@ -1303,6 +1303,7 @@ if ($builder eq "unified") {
 
         my %ordinals = ();
         my %sources = ();
+        my %shared_sources = ();
         my %includes = ();
         my %depends = ();
         my %renames = ();
@@ -1382,6 +1383,9 @@ if ($builder eq "unified") {
             qr/^\s*SOURCE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
             => sub { push @{$sources{$1}}, split(/\s+/, $2)
                          if !@skip || $skip[$#skip] > 0 },
+            qr/^\s*SHARED_SOURCE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
+            => sub { push @{$shared_sources{$1}}, split(/\s+/, $2)
+                         if !@skip || $skip[$#skip] > 0 },
             qr/^\s*INCLUDE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
             => sub { push @{$includes{$1}}, split(/\s+/, $2)
                          if !@skip || $skip[$#skip] > 0 },
@@ -1567,6 +1571,32 @@ EOF
             }
         }
 
+        foreach (keys %shared_sources) {
+            my $dest = $_;
+            my $ddest = cleanfile($buildd, $_, $blddir);
+            if ($unified_info{rename}->{$ddest}) {
+                $ddest = $unified_info{rename}->{$ddest};
+            }
+            foreach (@{$shared_sources{$dest}}) {
+                my $s = cleanfile($sourced, $_, $blddir);
+
+                # If it isn't in the source tree, we assume it's generated
+                # in the build tree
+                if (! -f $s) {
+                    $s = cleanfile($buildd, $_, $blddir);
+                }
+                # We recognise C and asm files
+                if ($s =~ /\.[csS]\b$/) {
+                    (my $o = $_) =~ s/\.[csS]\b$/.o/;
+                    $o = cleanfile($buildd, $o, $blddir);
+                    $unified_info{shared_sources}->{$ddest}->{$o} = 1;
+                    $unified_info{sources}->{$o}->{$s} = 1;
+                } else {
+                    die "unrecognised source file type for shared library: $s\n";
+                }
+            }
+        }
+
         foreach (keys %generate) {
             my $dest = $_;
             my $ddest = cleanfile($buildd, $_, $blddir);
@@ -1636,7 +1666,7 @@ EOF
         $unified_info{$_} = [ sort keys %{$unified_info{$_}} ];
     }
     # Two level structures
-    foreach my $l1 (("sources", "ldadd", "depends")) {
+    foreach my $l1 (("sources", "shared_sources", "ldadd", "depends")) {
         foreach my $l2 (sort keys %{$unified_info{$l1}}) {
             $unified_info{$l1}->{$l2} =
                 [ sort keys %{$unified_info{$l1}->{$l2}} ];
diff --git a/crypto/build.info b/crypto/build.info
index 217dc62..1b4ed14 100644
--- a/crypto/build.info
+++ b/crypto/build.info
@@ -31,3 +31,7 @@ GENERATE[arm64cpuid.S]=arm64cpuid.pl $(PERLASM_SCHEME)
 INCLUDE[arm64cpuid.o]=.
 GENERATE[armv4cpuid.S]=armv4cpuid.pl $(PERLASM_SCHEME)
 INCLUDE[armv4cpuid.o]=.
+
+IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-)/ -}]
+  SHARED_SOURCE[../libcrypto]=dllmain.c
+ENDIF
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index e41a6fc..7e1d780 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -195,55 +195,6 @@ void OPENSSL_cpuid_setup(void)
 }
 #endif
 
-#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(_WINDLL)
-# ifdef __CYGWIN__
-/* pick DLL_[PROCESS|THREAD]_[ATTACH|DETACH] definitions */
-#  include <windows.h>
-/*
- * this has side-effect of _WIN32 getting defined, which otherwise is
- * mutually exclusive with __CYGWIN__...
- */
-# endif
-
-/*
- * All we really need to do is remove the 'error' state when a thread
- * detaches
- */
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
-    switch (fdwReason) {
-    case DLL_PROCESS_ATTACH:
-        OPENSSL_cpuid_setup();
-# if defined(_WIN32_WINNT)
-        {
-            IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *) hinstDLL;
-            IMAGE_NT_HEADERS *nt_headers;
-
-            if (dos_header->e_magic == IMAGE_DOS_SIGNATURE) {
-                nt_headers = (IMAGE_NT_HEADERS *) ((char *)dos_header
-                                                   + dos_header->e_lfanew);
-                if (nt_headers->Signature == IMAGE_NT_SIGNATURE &&
-                    hinstDLL !=
-                    (HINSTANCE) (nt_headers->OptionalHeader.ImageBase))
-                    OPENSSL_NONPIC_relocated = 1;
-            }
-        }
-# endif
-        break;
-    case DLL_THREAD_ATTACH:
-        break;
-    case DLL_THREAD_DETACH:
-        OPENSSL_thread_stop();
-        break;
-    case DLL_PROCESS_DETACH:
-        break;
-    }
-    return (TRUE);
-}
-#endif
-
 #if defined(_WIN32) && !defined(__CYGWIN__)
 # include <tchar.h>
 # include <signal.h>
diff --git a/crypto/dllmain.c b/crypto/dllmain.c
new file mode 100644
index 0000000..0a229b5
--- /dev/null
+++ b/crypto/dllmain.c
@@ -0,0 +1,51 @@
+#include "internal/cryptlib_int.h"
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+# ifdef __CYGWIN__
+/* pick DLL_[PROCESS|THREAD]_[ATTACH|DETACH] definitions */
+#  include <windows.h>
+/*
+ * this has side-effect of _WIN32 getting defined, which otherwise is
+ * mutually exclusive with __CYGWIN__...
+ */
+# endif
+
+/*
+ * All we really need to do is remove the 'error' state when a thread
+ * detaches
+ */
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    switch (fdwReason) {
+    case DLL_PROCESS_ATTACH:
+        OPENSSL_cpuid_setup();
+# if defined(_WIN32_WINNT)
+        {
+            IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *) hinstDLL;
+            IMAGE_NT_HEADERS *nt_headers;
+
+            if (dos_header->e_magic == IMAGE_DOS_SIGNATURE) {
+                nt_headers = (IMAGE_NT_HEADERS *) ((char *)dos_header
+                                                   + dos_header->e_lfanew);
+                if (nt_headers->Signature == IMAGE_NT_SIGNATURE &&
+                    hinstDLL !=
+                    (HINSTANCE) (nt_headers->OptionalHeader.ImageBase))
+                    OPENSSL_NONPIC_relocated = 1;
+            }
+        }
+# endif
+        break;
+    case DLL_THREAD_ATTACH:
+        break;
+    case DLL_THREAD_DETACH:
+        OPENSSL_thread_stop();
+        break;
+    case DLL_PROCESS_DETACH:
+        break;
+    }
+    return (TRUE);
+}
+#endif
+


More information about the openssl-commits mailing list