Add additional OPENSSL_init() handling add dummy call to (hopefully)
authorDr. Stephen Henson <steve@openssl.org>
Fri, 1 Apr 2011 15:46:03 +0000 (15:46 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 1 Apr 2011 15:46:03 +0000 (15:46 +0000)
ensure OPENSSL_init() is always linked into an application.

crypto/Makefile
crypto/crypto.h
crypto/mem.c
crypto/o_init.c

index faacc01a54a3cf524f7d5fe0895e2c8fca2e0201..33503a4d71d9a6d9e240289b620764c81506db28 100644 (file)
@@ -89,7 +89,15 @@ alphacpuid.s:        alphacpuid.pl
        $(PERL) $< | $(CC) -E - | tee $@ > /dev/null
 
 o_init.o: o_init.c
-       $(CC) $(CFLAGS) -c -o $@ $<
+       case "`(uname -s) 2>/dev/null`" in \
+       OSF1|IRIX*)     _WL_INIT="-Wl,-init,OPENSSL_init"       ;; \
+       HP-UX)          _WL_INIT="-Wl,+init,OPENSSL_init"       ;; \
+       AIX)            _WL_INIT="-Wl,-binitfini:OPENSSL_init,-bnoobjreorder";; \
+       Darwin)         (   while [ "x$1" != "x" -a "x$1" != "x-dynamiclib" ]; do shift; done; \
+                           [ $# -ge 1 ] \
+                       ) && _WL_INIT="-Wl,-init,_OPENSSL_init" ;; \
+       esac ; \
+       $(CC) $(CFLAGS) $(_WL_INIT) -c -o $@ $<
 
 testapps:
        [ -z "$(THIS)" ] || (   if expr " $(SDIRS) " : ".* des " >/dev/null; \
index 469790d7a91d9968239d43dc5e205aca8ed1ee2c..443486d70e3adfccf596a8e1a89d9f4499609b7f 100644 (file)
@@ -560,8 +560,6 @@ unsigned int *OPENSSL_ia32cap_loc(void);
 #define OPENSSL_ia32cap ((OPENSSL_ia32cap_loc())[0])
 int OPENSSL_isservice(void);
 
-void OPENSSL_init(void);
-
 /* BEGIN ERROR CODES */
 /* The following lines are auto generated by the script mkerr.pl. Any changes
  * made after this point may be overwritten when the script is next run.
index 347c0d81843c90c2ec0fbc11154f55fc60bbfb9b..7bd29d6766ea3f00d7d5a3f7782add2200822626 100644 (file)
@@ -121,10 +121,13 @@ static void (*set_debug_options_func)(long) = NULL;
 static long (*get_debug_options_func)(void) = NULL;
 #endif
 
+extern void OPENSSL_init(void);
 
 int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
        void (*f)(void *))
        {
+       /* Dummy call just to ensure OPENSSL_init() gets linked in */
+       OPENSSL_init();
        if (!allow_customize)
                return 0;
        if ((m == 0) || (r == 0) || (f == 0))
index c6bc754df1b71b0489260199d31b2bfbe89ec478..1a042ffc99103ef38f3f3a5104ea75acae55b6e5 100644 (file)
 
 void OPENSSL_init(void)
        {
+       static int done = 0;
+       if (done)
+               return;
+       done = 1;
+#if 1
        fprintf(stderr, "Called OPENSSL_init\n");
+#endif
        }
 
-