2016-04-20 10:10:43 +08:00
|
|
|
#! /usr/bin/env perl
|
2021-04-22 21:38:44 +08:00
|
|
|
# Copyright 2018-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2016-04-20 10:10:43 +08:00
|
|
|
#
|
2018-12-06 20:03:50 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-04-20 10:10:43 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
# Generate a linker version script suitable for the given platform
|
|
|
|
# from a given ordinals file.
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Getopt::Long;
|
2017-08-02 04:43:56 +08:00
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/perl";
|
2018-09-14 20:59:40 +08:00
|
|
|
|
|
|
|
use OpenSSL::Ordinals;
|
|
|
|
|
|
|
|
use lib '.';
|
|
|
|
use configdata;
|
|
|
|
|
2018-10-23 21:42:46 +08:00
|
|
|
use File::Spec::Functions;
|
|
|
|
use lib catdir($config{sourcedir}, 'Configurations');
|
|
|
|
use platform;
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
my $name = undef; # internal library/module name
|
|
|
|
my $ordinals_file = undef; # the ordinals file to use
|
2018-10-04 23:14:13 +08:00
|
|
|
my $version = undef; # the version to use for the library
|
2018-09-14 20:59:40 +08:00
|
|
|
my $OS = undef; # the operating system family
|
2022-05-10 20:39:19 +08:00
|
|
|
my $type = 'lib'; # either lib or dso
|
2018-09-14 20:59:40 +08:00
|
|
|
my $verbose = 0;
|
|
|
|
my $ctest = 0;
|
2020-01-16 00:41:07 +08:00
|
|
|
my $debug = 0;
|
2018-09-14 20:59:40 +08:00
|
|
|
|
2018-10-05 06:10:35 +08:00
|
|
|
# For VMS, some modules may have case insensitive names
|
|
|
|
my $case_insensitive = 0;
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
GetOptions('name=s' => \$name,
|
|
|
|
'ordinals=s' => \$ordinals_file,
|
2018-10-04 23:14:13 +08:00
|
|
|
'version=s' => \$version,
|
2018-09-14 20:59:40 +08:00
|
|
|
'OS=s' => \$OS,
|
2022-05-10 20:39:19 +08:00
|
|
|
'type=s' => \$type,
|
2018-09-14 20:59:40 +08:00
|
|
|
'ctest' => \$ctest,
|
2018-10-05 06:10:35 +08:00
|
|
|
'verbose' => \$verbose,
|
|
|
|
# For VMS
|
|
|
|
'case-insensitive' => \$case_insensitive)
|
2018-09-14 20:59:40 +08:00
|
|
|
or die "Error in command line arguments\n";
|
|
|
|
|
|
|
|
die "Please supply arguments\n"
|
|
|
|
unless $name && $ordinals_file && $OS;
|
2022-05-10 20:39:19 +08:00
|
|
|
die "--type argument must be equal to 'lib' or 'dso'"
|
|
|
|
if $type ne 'lib' && $type ne 'dso';
|
2016-01-12 07:17:12 +08:00
|
|
|
|
2017-11-21 10:30:04 +08:00
|
|
|
# When building a "variant" shared library, with a custom SONAME, also customize
|
|
|
|
# all the symbol versions. This produces a shared object that can coexist
|
|
|
|
# without conflict in the same address space as a default build, or an object
|
|
|
|
# with a different variant tag.
|
|
|
|
#
|
|
|
|
# For example, with a target definition that includes:
|
|
|
|
#
|
|
|
|
# shlib_variant => "-opt",
|
|
|
|
#
|
|
|
|
# we build the following objects:
|
|
|
|
#
|
|
|
|
# $ perl -le '
|
|
|
|
# for (@ARGV) {
|
|
|
|
# if ($l = readlink) {
|
|
|
|
# printf "%s -> %s\n", $_, $l
|
|
|
|
# } else {
|
|
|
|
# print
|
|
|
|
# }
|
|
|
|
# }' *.so*
|
|
|
|
# libcrypto-opt.so.1.1
|
|
|
|
# libcrypto.so -> libcrypto-opt.so.1.1
|
|
|
|
# libssl-opt.so.1.1
|
|
|
|
# libssl.so -> libssl-opt.so.1.1
|
|
|
|
#
|
|
|
|
# whose SONAMEs and dependencies are:
|
|
|
|
#
|
|
|
|
# $ for l in *.so; do
|
|
|
|
# echo $l
|
|
|
|
# readelf -d $l | egrep 'SONAME|NEEDED.*(ssl|crypto)'
|
|
|
|
# done
|
|
|
|
# libcrypto.so
|
|
|
|
# 0x000000000000000e (SONAME) Library soname: [libcrypto-opt.so.1.1]
|
|
|
|
# libssl.so
|
|
|
|
# 0x0000000000000001 (NEEDED) Shared library: [libcrypto-opt.so.1.1]
|
|
|
|
# 0x000000000000000e (SONAME) Library soname: [libssl-opt.so.1.1]
|
|
|
|
#
|
2022-08-24 02:40:44 +08:00
|
|
|
# We case-fold the variant tag to uppercase and replace all non-alnum
|
2017-11-21 10:30:04 +08:00
|
|
|
# characters with "_". This yields the following symbol versions:
|
|
|
|
#
|
|
|
|
# $ nm libcrypto.so | grep -w A
|
|
|
|
# 0000000000000000 A OPENSSL_OPT_1_1_0
|
|
|
|
# 0000000000000000 A OPENSSL_OPT_1_1_0a
|
|
|
|
# 0000000000000000 A OPENSSL_OPT_1_1_0c
|
|
|
|
# 0000000000000000 A OPENSSL_OPT_1_1_0d
|
|
|
|
# 0000000000000000 A OPENSSL_OPT_1_1_0f
|
|
|
|
# 0000000000000000 A OPENSSL_OPT_1_1_0g
|
|
|
|
# $ nm libssl.so | grep -w A
|
|
|
|
# 0000000000000000 A OPENSSL_OPT_1_1_0
|
|
|
|
# 0000000000000000 A OPENSSL_OPT_1_1_0d
|
|
|
|
#
|
2018-09-14 20:59:40 +08:00
|
|
|
(my $SO_VARIANT = uc($target{"shlib_variant"} // '')) =~ s/\W/_/g;
|
|
|
|
|
2022-05-10 20:39:19 +08:00
|
|
|
my $libname = $type eq 'lib' ? platform->sharedname($name) : platform->dsoname($name);
|
2018-09-14 20:59:40 +08:00
|
|
|
|
|
|
|
my %OS_data = (
|
|
|
|
solaris => { writer => \&writer_linux,
|
|
|
|
sort => sorter_linux(),
|
2019-07-02 04:24:08 +08:00
|
|
|
platforms => { UNIX => 1 } },
|
2020-07-03 00:48:16 +08:00
|
|
|
"solaris-gcc" => 'solaris', # alias
|
2018-09-14 20:59:40 +08:00
|
|
|
linux => 'solaris', # alias
|
2018-10-09 22:27:11 +08:00
|
|
|
"bsd-gcc" => 'solaris', # alias
|
2018-09-14 20:59:40 +08:00
|
|
|
aix => { writer => \&writer_aix,
|
|
|
|
sort => sorter_unix(),
|
2019-07-02 04:24:08 +08:00
|
|
|
platforms => { UNIX => 1 } },
|
2018-09-14 20:59:40 +08:00
|
|
|
VMS => { writer => \&writer_VMS,
|
|
|
|
sort => OpenSSL::Ordinals::by_number(),
|
2019-07-02 04:24:08 +08:00
|
|
|
platforms => { VMS => 1 } },
|
2018-09-14 20:59:40 +08:00
|
|
|
vms => 'VMS', # alias
|
|
|
|
WINDOWS => { writer => \&writer_windows,
|
|
|
|
sort => OpenSSL::Ordinals::by_name(),
|
|
|
|
platforms => { WIN32 => 1,
|
2019-07-02 04:24:08 +08:00
|
|
|
_WIN32 => 1 } },
|
2018-09-14 20:59:40 +08:00
|
|
|
windows => 'WINDOWS', # alias
|
|
|
|
WIN32 => 'WINDOWS', # alias
|
|
|
|
win32 => 'WIN32', # alias
|
|
|
|
32 => 'WIN32', # alias
|
|
|
|
NT => 'WIN32', # alias
|
|
|
|
nt => 'WIN32', # alias
|
|
|
|
mingw => 'WINDOWS', # alias
|
2020-09-23 22:52:13 +08:00
|
|
|
nonstop => { writer => \&writer_nonstop,
|
|
|
|
sort => OpenSSL::Ordinals::by_name(),
|
|
|
|
platforms => { TANDEM => 1 } },
|
2018-09-14 20:59:40 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
do {
|
|
|
|
die "Unknown operating system family $OS\n"
|
|
|
|
unless exists $OS_data{$OS};
|
|
|
|
$OS = $OS_data{$OS};
|
|
|
|
} while(ref($OS) eq '');
|
|
|
|
|
|
|
|
my %disabled_uc = map { my $x = uc $_; $x =~ s|-|_|g; $x => 1 } keys %disabled;
|
|
|
|
|
|
|
|
my %ordinal_opts = ();
|
|
|
|
$ordinal_opts{sort} = $OS->{sort} if $OS->{sort};
|
|
|
|
$ordinal_opts{filter} =
|
|
|
|
sub {
|
|
|
|
my $item = shift;
|
|
|
|
return
|
|
|
|
$item->exists()
|
|
|
|
&& platform_filter($item)
|
|
|
|
&& feature_filter($item);
|
|
|
|
};
|
|
|
|
my $ordinals = OpenSSL::Ordinals->new(from => $ordinals_file);
|
|
|
|
|
|
|
|
my $writer = $OS->{writer};
|
|
|
|
$writer = \&writer_ctest if $ctest;
|
|
|
|
|
|
|
|
$writer->($ordinals->items(%ordinal_opts));
|
|
|
|
|
|
|
|
exit 0;
|
|
|
|
|
|
|
|
sub platform_filter {
|
|
|
|
my $item = shift;
|
|
|
|
my %platforms = ( $item->platforms() );
|
|
|
|
|
|
|
|
# True if no platforms are defined
|
|
|
|
return 1 if scalar keys %platforms == 0;
|
|
|
|
|
|
|
|
# For any item platform tag, return the equivalence with the
|
|
|
|
# current platform settings if it exists there, return 0 otherwise
|
|
|
|
# if the item platform tag is true
|
|
|
|
for (keys %platforms) {
|
|
|
|
if (exists $OS->{platforms}->{$_}) {
|
|
|
|
return $platforms{$_} == $OS->{platforms}->{$_};
|
|
|
|
}
|
|
|
|
if ($platforms{$_}) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2000-09-07 16:43:08 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
# Found no match? Then it's a go
|
|
|
|
return 1;
|
2000-09-07 16:43:08 +08:00
|
|
|
}
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
sub feature_filter {
|
|
|
|
my $item = shift;
|
|
|
|
my @features = ( $item->features() );
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
# True if no features are defined
|
2018-09-14 21:19:37 +08:00
|
|
|
return 1 if scalar @features == 0;
|
Introduce the possibility to access global variables through
functions on platform were that's the best way to handle exporting
global variables in shared libraries. To enable this functionality,
one must configure with "EXPORT_VAR_AS_FN" or defined the C macro
"OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter
is normally done by Configure or something similar).
To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL
in the source file (foo.c) like this:
OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1;
OPENSSL_IMPLEMENT_GLOBAL(double,bar);
To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL
and OPENSSL_GLOBAL_REF in the header file (foo.h) like this:
OPENSSL_DECLARE_GLOBAL(int,foo);
#define foo OPENSSL_GLOBAL_REF(foo)
OPENSSL_DECLARE_GLOBAL(double,bar);
#define bar OPENSSL_GLOBAL_REF(bar)
The #defines are very important, and therefore so is including the
header file everywere where the defined globals are used.
The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition
of ASN.1 items, but that structure is a bt different.
The largest change is in util/mkdef.pl which has been enhanced with
better and easier to understand logic to choose which symbols should
go into the Windows .def files as well as a number of fixes and code
cleanup (among others, algorithm keywords are now sorted
lexicographically to avoid constant rewrites).
2001-03-02 18:38:19 +08:00
|
|
|
|
2018-09-14 21:19:37 +08:00
|
|
|
my $verdict = ! grep { $disabled_uc{$_} } @features;
|
Introduce the possibility to access global variables through
functions on platform were that's the best way to handle exporting
global variables in shared libraries. To enable this functionality,
one must configure with "EXPORT_VAR_AS_FN" or defined the C macro
"OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter
is normally done by Configure or something similar).
To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL
in the source file (foo.c) like this:
OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1;
OPENSSL_IMPLEMENT_GLOBAL(double,bar);
To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL
and OPENSSL_GLOBAL_REF in the header file (foo.h) like this:
OPENSSL_DECLARE_GLOBAL(int,foo);
#define foo OPENSSL_GLOBAL_REF(foo)
OPENSSL_DECLARE_GLOBAL(double,bar);
#define bar OPENSSL_GLOBAL_REF(bar)
The #defines are very important, and therefore so is including the
header file everywere where the defined globals are used.
The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition
of ASN.1 items, but that structure is a bt different.
The largest change is in util/mkdef.pl which has been enhanced with
better and easier to understand logic to choose which symbols should
go into the Windows .def files as well as a number of fixes and code
cleanup (among others, algorithm keywords are now sorted
lexicographically to avoid constant rewrites).
2001-03-02 18:38:19 +08:00
|
|
|
|
Change the logic and behaviour surrounding '--api' and 'no-deprecated'
At some point in time, there was a 'no-deprecated' configuration
option, which had the effect of hiding all declarations of deprecated
stuff, i.e. make the public API look like they were all removed.
At some point in time, there was a '--api' configuration option, which
had the effect of having the public API look like it did in the version
given as value, on a best effort basis. In practice, this was used to
get different implementations of BN_zero(), depending on the desired
API compatibility level.
At some later point in time, '--api' was changed to mean the same as
'no-deprecated', but only for the deprecations up to and including the
desired API compatibility level. BN_zero() has been set to the
pre-1.0.0 implementation ever since, unless 'no-deprecation' has been
given.
This change turns these options back to their original meaning, but
with the slight twist that when combined, i.e. both '--api' and
'no-deprecated' is given, the declarations that are marked deprecated
up to an including the desired API compatibility level are hidden,
simulating that they have been removed.
If no desired API compatibility level has been given, then
configuration sets the current OpenSSL version by default.
Furthermore, the macro OPENSSL_API_LEVEL is now used exclusively to
check what API compatibility level is desired. For checking in code
if `no-deprecated` has been configured for the desired API
compatibility level, macros for each supported level is generated,
such as OPENSSL_NO_DEPRECATED_1_1_1, corresponding to the use of
DEPRECATEDIN_ macros, such as DEPRECATEDIN_1_1_1().
Just like before, to set an API compatibility level when building an
application, define OPENSSL_API_COMPAT with an appropriate value. If
it's desirable to hide deprecated functions up to and including that
level, additionally define OPENSSL_NO_DEPRECATED (the value is
ignored).
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10364)
2019-11-06 00:00:33 +08:00
|
|
|
if ($disabled{deprecated}) {
|
2018-09-14 20:59:40 +08:00
|
|
|
foreach (@features) {
|
Change the logic and behaviour surrounding '--api' and 'no-deprecated'
At some point in time, there was a 'no-deprecated' configuration
option, which had the effect of hiding all declarations of deprecated
stuff, i.e. make the public API look like they were all removed.
At some point in time, there was a '--api' configuration option, which
had the effect of having the public API look like it did in the version
given as value, on a best effort basis. In practice, this was used to
get different implementations of BN_zero(), depending on the desired
API compatibility level.
At some later point in time, '--api' was changed to mean the same as
'no-deprecated', but only for the deprecations up to and including the
desired API compatibility level. BN_zero() has been set to the
pre-1.0.0 implementation ever since, unless 'no-deprecation' has been
given.
This change turns these options back to their original meaning, but
with the slight twist that when combined, i.e. both '--api' and
'no-deprecated' is given, the declarations that are marked deprecated
up to an including the desired API compatibility level are hidden,
simulating that they have been removed.
If no desired API compatibility level has been given, then
configuration sets the current OpenSSL version by default.
Furthermore, the macro OPENSSL_API_LEVEL is now used exclusively to
check what API compatibility level is desired. For checking in code
if `no-deprecated` has been configured for the desired API
compatibility level, macros for each supported level is generated,
such as OPENSSL_NO_DEPRECATED_1_1_1, corresponding to the use of
DEPRECATEDIN_ macros, such as DEPRECATEDIN_1_1_1().
Just like before, to set an API compatibility level when building an
application, define OPENSSL_API_COMPAT with an appropriate value. If
it's desirable to hide deprecated functions up to and including that
level, additionally define OPENSSL_NO_DEPRECATED (the value is
ignored).
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10364)
2019-11-06 00:00:33 +08:00
|
|
|
next unless /^DEPRECATEDIN_(\d+)_(\d+)(?:_(\d+))?$/;
|
|
|
|
my $symdep = $1 * 10000 + $2 * 100 + ($3 // 0);
|
|
|
|
$verdict = 0 if $config{api} >= $symdep;
|
|
|
|
print STDERR "DEBUG: \$symdep = $symdep, \$verdict = $verdict\n"
|
2020-01-16 00:41:07 +08:00
|
|
|
if $debug && $1 == 0;
|
2018-09-14 20:59:40 +08:00
|
|
|
}
|
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
return $verdict;
|
2000-09-07 16:43:08 +08:00
|
|
|
}
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
sub sorter_unix {
|
|
|
|
my $by_name = OpenSSL::Ordinals::by_name();
|
|
|
|
my %weight = (
|
|
|
|
'FUNCTION' => 1,
|
|
|
|
'VARIABLE' => 2
|
|
|
|
);
|
2000-09-07 16:43:08 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
return sub {
|
|
|
|
my $item1 = shift;
|
|
|
|
my $item2 = shift;
|
2000-11-14 21:20:10 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
my $verdict = $weight{$item1->type()} <=> $weight{$item2->type()};
|
|
|
|
if ($verdict == 0) {
|
|
|
|
$verdict = $by_name->($item1, $item2);
|
|
|
|
}
|
|
|
|
return $verdict;
|
|
|
|
};
|
1999-04-26 08:23:10 +08:00
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
sub sorter_linux {
|
|
|
|
my $by_version = OpenSSL::Ordinals::by_version();
|
|
|
|
my $by_unix = sorter_unix();
|
Introduce the possibility to access global variables through
functions on platform were that's the best way to handle exporting
global variables in shared libraries. To enable this functionality,
one must configure with "EXPORT_VAR_AS_FN" or defined the C macro
"OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter
is normally done by Configure or something similar).
To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL
in the source file (foo.c) like this:
OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1;
OPENSSL_IMPLEMENT_GLOBAL(double,bar);
To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL
and OPENSSL_GLOBAL_REF in the header file (foo.h) like this:
OPENSSL_DECLARE_GLOBAL(int,foo);
#define foo OPENSSL_GLOBAL_REF(foo)
OPENSSL_DECLARE_GLOBAL(double,bar);
#define bar OPENSSL_GLOBAL_REF(bar)
The #defines are very important, and therefore so is including the
header file everywere where the defined globals are used.
The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition
of ASN.1 items, but that structure is a bt different.
The largest change is in util/mkdef.pl which has been enhanced with
better and easier to understand logic to choose which symbols should
go into the Windows .def files as well as a number of fixes and code
cleanup (among others, algorithm keywords are now sorted
lexicographically to avoid constant rewrites).
2001-03-02 18:38:19 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
return sub {
|
|
|
|
my $item1 = shift;
|
|
|
|
my $item2 = shift;
|
Introduce the possibility to access global variables through
functions on platform were that's the best way to handle exporting
global variables in shared libraries. To enable this functionality,
one must configure with "EXPORT_VAR_AS_FN" or defined the C macro
"OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter
is normally done by Configure or something similar).
To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL
in the source file (foo.c) like this:
OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1;
OPENSSL_IMPLEMENT_GLOBAL(double,bar);
To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL
and OPENSSL_GLOBAL_REF in the header file (foo.h) like this:
OPENSSL_DECLARE_GLOBAL(int,foo);
#define foo OPENSSL_GLOBAL_REF(foo)
OPENSSL_DECLARE_GLOBAL(double,bar);
#define bar OPENSSL_GLOBAL_REF(bar)
The #defines are very important, and therefore so is including the
header file everywere where the defined globals are used.
The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition
of ASN.1 items, but that structure is a bt different.
The largest change is in util/mkdef.pl which has been enhanced with
better and easier to understand logic to choose which symbols should
go into the Windows .def files as well as a number of fixes and code
cleanup (among others, algorithm keywords are now sorted
lexicographically to avoid constant rewrites).
2001-03-02 18:38:19 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
my $verdict = $by_version->($item1, $item2);
|
|
|
|
if ($verdict == 0) {
|
|
|
|
$verdict = $by_unix->($item1, $item2);
|
|
|
|
}
|
|
|
|
return $verdict;
|
|
|
|
};
|
Introduce the possibility to access global variables through
functions on platform were that's the best way to handle exporting
global variables in shared libraries. To enable this functionality,
one must configure with "EXPORT_VAR_AS_FN" or defined the C macro
"OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter
is normally done by Configure or something similar).
To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL
in the source file (foo.c) like this:
OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1;
OPENSSL_IMPLEMENT_GLOBAL(double,bar);
To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL
and OPENSSL_GLOBAL_REF in the header file (foo.h) like this:
OPENSSL_DECLARE_GLOBAL(int,foo);
#define foo OPENSSL_GLOBAL_REF(foo)
OPENSSL_DECLARE_GLOBAL(double,bar);
#define bar OPENSSL_GLOBAL_REF(bar)
The #defines are very important, and therefore so is including the
header file everywere where the defined globals are used.
The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition
of ASN.1 items, but that structure is a bt different.
The largest change is in util/mkdef.pl which has been enhanced with
better and easier to understand logic to choose which symbols should
go into the Windows .def files as well as a number of fixes and code
cleanup (among others, algorithm keywords are now sorted
lexicographically to avoid constant rewrites).
2001-03-02 18:38:19 +08:00
|
|
|
}
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
sub writer_linux {
|
|
|
|
my $thisversion = '';
|
2018-10-04 23:14:13 +08:00
|
|
|
my $currversion_s = '';
|
|
|
|
my $prevversion_s = '';
|
|
|
|
my $indent = 0;
|
2018-09-14 20:59:40 +08:00
|
|
|
|
|
|
|
for (@_) {
|
|
|
|
if ($thisversion && $_->version() ne $thisversion) {
|
2018-10-04 23:14:13 +08:00
|
|
|
die "$ordinals_file: It doesn't make sense to have both versioned ",
|
|
|
|
"and unversioned symbols"
|
|
|
|
if $thisversion eq '*';
|
2018-09-14 20:59:40 +08:00
|
|
|
print <<"_____";
|
2018-10-04 23:14:13 +08:00
|
|
|
}${prevversion_s};
|
2018-09-14 20:59:40 +08:00
|
|
|
_____
|
2018-10-04 23:14:13 +08:00
|
|
|
$prevversion_s = " OPENSSL${SO_VARIANT}_$thisversion";
|
2018-09-14 20:59:40 +08:00
|
|
|
$thisversion = ''; # Trigger start of next section
|
|
|
|
}
|
|
|
|
unless ($thisversion) {
|
2018-10-04 23:14:13 +08:00
|
|
|
$indent = 0;
|
2018-09-14 20:59:40 +08:00
|
|
|
$thisversion = $_->version();
|
2018-10-04 23:14:13 +08:00
|
|
|
$currversion_s = '';
|
|
|
|
$currversion_s = "OPENSSL${SO_VARIANT}_$thisversion "
|
|
|
|
if $thisversion ne '*';
|
2018-09-14 20:59:40 +08:00
|
|
|
print <<"_____";
|
2018-10-04 23:14:13 +08:00
|
|
|
${currversion_s}{
|
2018-09-14 20:59:40 +08:00
|
|
|
global:
|
|
|
|
_____
|
|
|
|
}
|
|
|
|
print ' ', $_->name(), ";\n";
|
|
|
|
}
|
Introduce the possibility to access global variables through
functions on platform were that's the best way to handle exporting
global variables in shared libraries. To enable this functionality,
one must configure with "EXPORT_VAR_AS_FN" or defined the C macro
"OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter
is normally done by Configure or something similar).
To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL
in the source file (foo.c) like this:
OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1;
OPENSSL_IMPLEMENT_GLOBAL(double,bar);
To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL
and OPENSSL_GLOBAL_REF in the header file (foo.h) like this:
OPENSSL_DECLARE_GLOBAL(int,foo);
#define foo OPENSSL_GLOBAL_REF(foo)
OPENSSL_DECLARE_GLOBAL(double,bar);
#define bar OPENSSL_GLOBAL_REF(bar)
The #defines are very important, and therefore so is including the
header file everywere where the defined globals are used.
The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition
of ASN.1 items, but that structure is a bt different.
The largest change is in util/mkdef.pl which has been enhanced with
better and easier to understand logic to choose which symbols should
go into the Windows .def files as well as a number of fixes and code
cleanup (among others, algorithm keywords are now sorted
lexicographically to avoid constant rewrites).
2001-03-02 18:38:19 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
print <<"_____";
|
|
|
|
local: *;
|
2018-10-04 23:14:13 +08:00
|
|
|
}${prevversion_s};
|
2018-09-14 20:59:40 +08:00
|
|
|
_____
|
1999-12-25 01:26:33 +08:00
|
|
|
}
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
sub writer_aix {
|
|
|
|
for (@_) {
|
|
|
|
print $_->name(),"\n";
|
|
|
|
}
|
2003-11-28 22:51:30 +08:00
|
|
|
}
|
|
|
|
|
2020-09-23 22:52:13 +08:00
|
|
|
sub writer_nonstop {
|
|
|
|
for (@_) {
|
|
|
|
print "-export ",$_->name(),"\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
sub writer_windows {
|
|
|
|
print <<"_____";
|
1998-12-21 18:52:47 +08:00
|
|
|
;
|
2018-09-14 20:59:40 +08:00
|
|
|
; Definition file for the DLL version of the $libname library from OpenSSL
|
1998-12-21 18:52:47 +08:00
|
|
|
;
|
|
|
|
|
2020-12-14 02:01:46 +08:00
|
|
|
LIBRARY "$libname"
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
EXPORTS
|
|
|
|
_____
|
|
|
|
for (@_) {
|
2020-12-14 02:01:46 +08:00
|
|
|
print " ",$_->name();
|
|
|
|
if (platform->can('export2internal')) {
|
|
|
|
print "=". platform->export2internal($_->name());
|
|
|
|
}
|
|
|
|
print "\n";
|
2018-09-14 20:59:40 +08:00
|
|
|
}
|
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2018-10-05 06:10:35 +08:00
|
|
|
sub collect_VMS_mixedcase {
|
|
|
|
return [ 'SPARE', 'SPARE' ] unless @_;
|
|
|
|
|
|
|
|
my $s = shift;
|
|
|
|
my $s_uc = uc($s);
|
|
|
|
my $type = shift;
|
|
|
|
|
|
|
|
return [ "$s=$type", 'SPARE' ] if $s_uc eq $s;
|
|
|
|
return [ "$s_uc/$s=$type", "$s=$type" ];
|
|
|
|
}
|
|
|
|
|
|
|
|
sub collect_VMS_uppercase {
|
|
|
|
return [ 'SPARE' ] unless @_;
|
|
|
|
|
|
|
|
my $s = shift;
|
|
|
|
my $s_uc = uc($s);
|
|
|
|
my $type = shift;
|
|
|
|
|
|
|
|
return [ "$s_uc=$type" ];
|
|
|
|
}
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
sub writer_VMS {
|
|
|
|
my @slot_collection = ();
|
2018-10-05 06:10:35 +08:00
|
|
|
my $collector =
|
|
|
|
$case_insensitive ? \&collect_VMS_uppercase : \&collect_VMS_mixedcase;
|
2018-09-14 20:59:40 +08:00
|
|
|
|
|
|
|
my $last_num = 0;
|
|
|
|
foreach (@_) {
|
2019-11-04 17:33:10 +08:00
|
|
|
my $this_num = $_->number();
|
|
|
|
$this_num = $last_num + 1 if $this_num =~ m|^\?|;
|
|
|
|
|
|
|
|
while (++$last_num < $this_num) {
|
2018-10-05 06:10:35 +08:00
|
|
|
push @slot_collection, $collector->(); # Just occupy a slot
|
2018-09-14 20:59:40 +08:00
|
|
|
}
|
|
|
|
my $type = {
|
|
|
|
FUNCTION => 'PROCEDURE',
|
|
|
|
VARIABLE => 'DATA'
|
|
|
|
} -> {$_->type()};
|
2018-10-05 06:10:35 +08:00
|
|
|
push @slot_collection, $collector->($_->name(), $type);
|
2018-09-14 20:59:40 +08:00
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2018-10-04 23:14:13 +08:00
|
|
|
print <<"_____" if defined $version;
|
|
|
|
IDENTIFICATION=$version
|
|
|
|
_____
|
2018-10-05 06:10:35 +08:00
|
|
|
print <<"_____" unless $case_insensitive;
|
2018-09-14 20:59:40 +08:00
|
|
|
CASE_SENSITIVE=YES
|
2018-10-05 06:10:35 +08:00
|
|
|
_____
|
|
|
|
print <<"_____";
|
2018-09-14 20:59:40 +08:00
|
|
|
SYMBOL_VECTOR=(-
|
|
|
|
_____
|
|
|
|
# It's uncertain how long aggregated lines the linker can handle,
|
|
|
|
# but it has been observed that at least 1024 characters is ok.
|
|
|
|
# Either way, this means that we need to keep track of the total
|
|
|
|
# line length of each "SYMBOL_VECTOR" statement. Fortunately, we
|
|
|
|
# can have more than one of those...
|
|
|
|
my $symvtextcount = 16; # The length of "SYMBOL_VECTOR=("
|
|
|
|
while (@slot_collection) {
|
2018-10-05 06:10:35 +08:00
|
|
|
my $set = shift @slot_collection;
|
|
|
|
my $settextlength = 0;
|
|
|
|
foreach (@$set) {
|
|
|
|
$settextlength +=
|
|
|
|
+ 3 # two space indentation and comma
|
|
|
|
+ length($_)
|
|
|
|
+ 1 # postdent
|
|
|
|
;
|
|
|
|
}
|
|
|
|
$settextlength--; # only one space indentation on the first one
|
2018-09-14 20:59:40 +08:00
|
|
|
my $firstcomma = ',';
|
|
|
|
|
2018-10-05 06:10:35 +08:00
|
|
|
if ($symvtextcount + $settextlength > 1024) {
|
2018-09-14 20:59:40 +08:00
|
|
|
print <<"_____";
|
|
|
|
)
|
|
|
|
SYMBOL_VECTOR=(-
|
|
|
|
_____
|
|
|
|
$symvtextcount = 16; # The length of "SYMBOL_VECTOR=("
|
2016-01-08 03:49:53 +08:00
|
|
|
}
|
2018-09-14 20:59:40 +08:00
|
|
|
if ($symvtextcount == 16) {
|
|
|
|
$firstcomma = '';
|
|
|
|
}
|
2018-10-05 06:10:35 +08:00
|
|
|
|
|
|
|
my $indent = ' '.$firstcomma;
|
|
|
|
foreach (@$set) {
|
|
|
|
print <<"_____";
|
|
|
|
$indent$_ -
|
2018-09-14 20:59:40 +08:00
|
|
|
_____
|
2018-10-05 06:10:35 +08:00
|
|
|
$symvtextcount += length($indent) + length($_) + 1;
|
|
|
|
$indent = ' ,';
|
|
|
|
}
|
2018-09-14 20:59:40 +08:00
|
|
|
}
|
|
|
|
print <<"_____";
|
|
|
|
)
|
|
|
|
_____
|
|
|
|
|
2018-10-04 23:14:13 +08:00
|
|
|
if (defined $version) {
|
2018-12-10 18:37:19 +08:00
|
|
|
$version =~ /^(\d+)\.(\d+)\.(\d+)/;
|
|
|
|
my $libvmajor = $1;
|
|
|
|
my $libvminor = $2 * 100 + $3;
|
2018-10-04 23:14:13 +08:00
|
|
|
print <<"_____";
|
2018-12-11 17:31:40 +08:00
|
|
|
GSMATCH=LEQUAL,$libvmajor,$libvminor
|
2018-09-14 20:59:40 +08:00
|
|
|
_____
|
2018-10-04 23:14:13 +08:00
|
|
|
}
|
2015-12-14 17:22:58 +08:00
|
|
|
}
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
sub writer_ctest {
|
|
|
|
print <<'_____';
|
|
|
|
/*
|
|
|
|
* Test file to check all DEF file symbols are present by trying
|
|
|
|
* to link to all of them. This is *not* intended to be run!
|
|
|
|
*/
|
2015-12-14 17:22:58 +08:00
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
int main()
|
2015-12-14 17:22:58 +08:00
|
|
|
{
|
2018-09-14 20:59:40 +08:00
|
|
|
_____
|
2015-12-14 17:22:58 +08:00
|
|
|
|
2019-11-04 17:33:10 +08:00
|
|
|
my $last_num = 0;
|
2018-09-14 20:59:40 +08:00
|
|
|
for (@_) {
|
2019-11-04 17:33:10 +08:00
|
|
|
my $this_num = $_->number();
|
|
|
|
$this_num = $last_num + 1 if $this_num =~ m|^\?|;
|
|
|
|
|
2018-09-14 20:59:40 +08:00
|
|
|
if ($_->type() eq 'VARIABLE') {
|
2019-11-04 17:33:10 +08:00
|
|
|
print "\textern int ", $_->name(), '; /* type unknown */ /* ',
|
|
|
|
$this_num, ' ', $_->version(), " */\n";
|
2018-09-14 20:59:40 +08:00
|
|
|
} else {
|
2019-11-04 17:33:10 +08:00
|
|
|
print "\textern int ", $_->name(), '(); /* type unknown */ /* ',
|
|
|
|
$this_num, ' ', $_->version(), " */\n";
|
2018-09-14 20:59:40 +08:00
|
|
|
}
|
2019-11-04 17:33:10 +08:00
|
|
|
|
|
|
|
$last_num = $this_num;
|
2018-09-14 20:59:40 +08:00
|
|
|
}
|
|
|
|
print <<'_____';
|
2015-12-14 17:22:58 +08:00
|
|
|
}
|
2018-09-14 20:59:40 +08:00
|
|
|
_____
|
2016-01-09 21:40:02 +08:00
|
|
|
}
|