]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Make cpuid_setup non-constructor
authorHongren Zheng <i@zenithal.me>
Tue, 22 Apr 2025 10:49:45 +0000 (18:49 +0800)
committerTomas Mraz <tomas@openssl.org>
Tue, 29 Apr 2025 12:19:51 +0000 (14:19 +0200)
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27466)

crypto/armcap.c
crypto/dllmain.c
crypto/perlasm/x86gas.pl
crypto/perlasm/x86masm.pl
crypto/perlasm/x86nasm.pl
crypto/ppccap.c
crypto/riscvcap.c
crypto/s390xcpuid.pl
crypto/sparccpuid.S
crypto/x86_64cpuid.pl
crypto/x86cpuid.pl

index c64a3ca0fe55c1cc19d0914cd91c0bc0c6a494da..c5f3624d034cc60a741fa0053bae9e81f4861404 100644 (file)
@@ -62,10 +62,6 @@ uint32_t OPENSSL_rdtsc(void)
 
  /* First determine if getauxval() is available (OSSL_IMPLEMENT_GETAUXVAL) */
 
-# if defined(__GNUC__) && __GNUC__>=2
-void OPENSSL_cpuid_setup(void) __attribute__ ((constructor));
-# endif
-
 # if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
 #  if __GLIBC_PREREQ(2, 16)
 #   include <sys/auxv.h>
index 96198a9397371aaa1e8a8cd289634ff4ff9e16ab..42c009bced4e2bb89faed4beeead0191db1ff6e6 100644 (file)
@@ -30,7 +30,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
     switch (fdwReason) {
     case DLL_PROCESS_ATTACH:
-        OPENSSL_cpuid_setup();
         break;
     case DLL_THREAD_ATTACH:
         break;
index f3c01ea89b4b4849a107c8c12890147a10ad94fd..c6054953f7ba45d7fa122b2dc6159acc43575dbb 100644 (file)
@@ -14,8 +14,6 @@ package x86gas;
 $::lbdecor=$::aout?"L":".L";           # local label decoration
 $nmdecor=($::aout or $::coff)?"_":"";  # external name decoration
 
-$initseg="";
-
 $align=16;
 $align=log($align)/log(2) if ($::aout);
 $com_start="#" if ($::aout or $::coff);
@@ -173,7 +171,6 @@ sub ::file_end
        elsif ($::elf)  { push (@out,"$tmp,4\n"); }
        else            { push (@out,"$tmp\n"); }
     }
-    push(@out,$initseg) if ($initseg);
     if ($::elf) {
        push(@out,"
        .section \".note.gnu.property\", \"a\"
@@ -237,48 +234,6 @@ sub ::picmeup
     {  &::lea($dst,&::DWP($sym));      }
 }
 
-sub ::initseg
-{ my $f=$nmdecor.shift;
-
-    if ($::android)
-    {  $initseg.=<<___;
-.section       .init_array
-.align 4
-.long  $f
-___
-    }
-    elsif ($::elf)
-    {  $initseg.=<<___;
-.section       .init
-       call    $f
-___
-    }
-    elsif ($::coff)
-    {   $initseg.=<<___;       # applies to both Cygwin and Mingw
-.section       .ctors
-.long  $f
-___
-    }
-    elsif ($::macosx)
-    {  $initseg.=<<___;
-.mod_init_func
-.align 2
-.long   $f
-___
-    }
-    elsif ($::aout)
-    {  my $ctor="${nmdecor}_GLOBAL_\$I\$$f";
-       $initseg.=".text\n";
-       $initseg.=".type        $ctor,\@function\n" if ($::pic);
-       $initseg.=<<___;        # OpenBSD way...
-.globl $ctor
-.align 2
-$ctor:
-       jmp     $f
-___
-    }
-}
-
 sub ::dataseg
 {   push(@out,".data\n");   }
 
index ccdba757dc28e39650f373921a7fbd0e18a42076..5c4e687c0cb377406e92808cbbb25315bc2e897f 100644 (file)
@@ -14,7 +14,6 @@ package x86masm;
 $::lbdecor="\$L";      # local label decoration
 $nmdecor="_";          # external name decoration
 
-$initseg="";
 $segment="";
 
 sub ::generic
@@ -149,7 +148,6 @@ ___
        grep {s/(^EXTERN\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out;
        push (@out,$comm);
     }
-    push (@out,$initseg) if ($initseg);
     push (@out,"END\n");
 }
 
@@ -183,17 +181,6 @@ sub ::picmeup
     &::lea($dst,&::DWP($sym));
 }
 
-sub ::initseg
-{ my $f=$nmdecor.shift;
-
-    $initseg.=<<___;
-.CRT\$XCU      SEGMENT DWORD PUBLIC 'DATA'
-EXTERN $f:NEAR
-DD     $f
-.CRT\$XCU      ENDS
-___
-}
-
 sub ::dataseg
 {   push(@out,"$segment\tENDS\n_DATA\tSEGMENT\n"); $segment="_DATA";   }
 
index a8cdd2d0bbe5421ec26a600b775beb189dfbe60c..82fcce6bbd9501897a0c537af06d4ef18de2dce0 100644 (file)
@@ -15,8 +15,6 @@ $::lbdecor="L\$";             # local label decoration
 $nmdecor="_";                  # external name decoration
 $drdecor=$::mwerks?".":"";     # directive decoration
 
-$initseg="";
-
 sub ::generic
 { my $opcode=shift;
   my $tmp;
@@ -133,7 +131,6 @@ ___
        grep {s/(^extern\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out;
        push (@out,$comm)
     }
-    push (@out,$initseg) if ($initseg);
 }
 
 sub ::comment {   foreach (@_) { push(@out,"\t; $_\n"); }   }
@@ -161,17 +158,6 @@ sub ::picmeup
     &::lea($dst,&::DWP($sym));
 }
 
-sub ::initseg
-{ my $f=$nmdecor.shift;
-    if ($::win32)
-    {  $initseg=<<___;
-segment        .CRT\$XCU data align=4
-extern $f
-dd     $f
-___
-    }
-}
-
 sub ::dataseg
 {   if ($mwerks)       { push(@out,".section\t.data,4\n");   }
     else               { push(@out,"section\t.data align=4\n"); }
index 08794a3ba62e78aa8def7210ff76c9da95a15ec1..f42a43d4e1289534878274611438eb97fc436c9f 100644 (file)
@@ -135,9 +135,6 @@ static unsigned long getauxval(unsigned long key)
 #define HWCAP_ARCH_3_00         (1U << 23)
 #define HWCAP_ARCH_3_1          (1U << 18)
 
-# if defined(__GNUC__) && __GNUC__>=2
-__attribute__ ((constructor))
-# endif
 void OPENSSL_cpuid_setup(void)
 {
     char *e;
index cf089be43b34de60609c623aaa6450b32bfba12c..0c44b93eedb6a8b357ebc9f5f22972155d307e46 100644 (file)
@@ -120,9 +120,6 @@ size_t riscv_vlen(void)
     return vlen;
 }
 
-# if defined(__GNUC__) && __GNUC__>=2
-__attribute__ ((constructor))
-# endif
 void OPENSSL_cpuid_setup(void)
 {
     char *e;
index 23ac82a92268021cd2c13b117b1f32ad7cbbba6f..d9eb84bab138db8409795e8d27aebdb81955ac57 100755 (executable)
@@ -531,11 +531,6 @@ s390x_flip_endian64:
 ___
 }
 
-$code.=<<___;
-.section       .init
-       brasl   $ra,OPENSSL_cpuid_setup
-___
-
 $code =~ s/\`([^\`]*)\`/eval $1/gem;
 print $code;
 close STDOUT or die "error closing STDOUT: $!";        # force flush
index 0487ce57689b73adb0a324701a4583b09a9a70e3..7ced433c94795892cd514c052c0ed3cfb1a8a5c6 100644 (file)
@@ -422,7 +422,3 @@ _sparcv9_vis1_instrument_bus2:
        sub     %o3,%o1,%o0
 .type  _sparcv9_vis1_instrument_bus2,#function
 .size  _sparcv9_vis1_instrument_bus2,.-_sparcv9_vis1_instrument_bus2
-
-.section       ".init",#alloc,#execinstr
-       call    OPENSSL_cpuid_setup
-       nop
index 3229d7d8fa688d6468b81ad1d463dc676d6f0fac..ce4cf1f51b872d6c1ec71a0e77c934d1a5d212e8 100644 (file)
@@ -30,9 +30,6 @@ print<<___;
 #include crypto/cryptlib.h
 .extern                OPENSSL_cpuid_setup
 .hidden                OPENSSL_cpuid_setup
-.section       .init
-       call    OPENSSL_cpuid_setup
-
 .hidden        OPENSSL_ia32cap_P
 .comm  OPENSSL_ia32cap_P,40,4  # <--Should match with internal/cryptlib.h OPENSSL_IA32CAP_P_MAX_INDEXES
 .text
index 2b05bc53dfe9f0bf2af59dadbedcabde06e193dd..f66c941b19c67c8585fca8202ab1befffaa32f8e 100644 (file)
@@ -493,8 +493,6 @@ my $rdop = shift;
 &gen_random("rdrand");
 &gen_random("rdseed");
 
-&initseg("OPENSSL_cpuid_setup");
-
 &hidden("OPENSSL_cpuid_setup");
 &hidden("OPENSSL_ia32cap_P");