summaryrefslogtreecommitdiffstats
path: root/Configurations
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2018-09-30 14:44:59 +0200
committerRichard Levitte <levitte@openssl.org>2018-10-01 09:49:16 +0200
commitef2dfc9902e015de91f015177bdf235c9000839e (patch)
tree61e6c5535dbf8c44096f6322defd2c88fdf4dfbf /Configurations
parentb44882a0bd0717e0aab84f5dc3ef81ab673155e9 (diff)
Refactor linker script generation
The generation of linker scripts was badly balanced, as all sorts of platform dependent stuff went into the top build.info, when that part should really be made as simply and generic as possible. Therefore, we move a lot of the "magic" to the build files templates, since they are the place for platform dependent things. What remains is to parametrize just enough in the build.info file to generate the linker scripts correctly for each associated library. "linker script" is a term usually reserved for certain Unix linkers. However, we only use them to say what symbols should be exported, so we use the term loosely for all platforms. The internal extension is '.ld', and is changed by the build file templates as appropriate for each target platform. Note that this adds extra meaning to the value of the shared_target attribute. Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7333)
Diffstat (limited to 'Configurations')
-rw-r--r--Configurations/10-main.conf8
-rw-r--r--Configurations/README9
-rw-r--r--Configurations/descrip.mms.tmpl21
-rw-r--r--Configurations/shared-info.pl2
-rw-r--r--Configurations/unix-Makefile.tmpl25
-rw-r--r--Configurations/windows-makefile.tmpl24
6 files changed, 71 insertions, 18 deletions
diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
index 8360bb3671..e3cc34c14b 100644
--- a/Configurations/10-main.conf
+++ b/Configurations/10-main.conf
@@ -211,7 +211,7 @@ my %targets = (
ex_libs => add("-lsocket -lnsl -ldl"),
dso_scheme => "dlfcn",
thread_scheme => "pthreads",
- shared_target => "self",
+ shared_target => "solaris",
shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
shared_ldflag => "-Wl,-Bsymbolic",
shared_defflag => "-Wl,-M,",
@@ -1113,7 +1113,7 @@ my %targets = (
lflags => "-Wl,-bsvr4",
thread_scheme => "pthreads",
dso_scheme => "dlfcn",
- shared_target => "self",
+ shared_target => "aix",
module_ldflags => "-Wl,-G,-bsymbolic,-bexpall",
shared_ldflag => "-Wl,-G,-bsymbolic",
shared_defflag => "-Wl,-bE:",
@@ -1230,6 +1230,8 @@ my %targets = (
lib_defines => add("L_ENDIAN"),
dso_cflags => "/Zi /Fddso.pdb",
bin_cflags => "/Zi /Fdapp.pdb",
+ # def_flag made to empty string so a .def file gets generated
+ shared_defflag => '',
shared_ldflag => "/dll",
shared_target => "win-shared", # meaningless except it gives Configure a hint
thread_scheme => "winthreads",
@@ -1743,6 +1745,8 @@ my %targets = (
dso_cflags => "",
ex_libs => add(sub { return vms_info()->{zlib} || (); }),
shared_target => "vms-shared",
+ # def_flag made to empty string so a .opt file gets generated
+ shared_defflag => '',
dso_scheme => "vms",
thread_scheme => "pthreads",
diff --git a/Configurations/README b/Configurations/README
index a03d445aea..9fd4922fd0 100644
--- a/Configurations/README
+++ b/Configurations/README
@@ -169,7 +169,14 @@ In each table entry, the following keys are significant:
assembler files used when compiling with
assembler implementations.
shared_target => The shared library building method used.
- This is a target found in Makefile.shared.
+ This serves multiple purposes:
+ - as index for targets found in shared_info.pl.
+ - as linker script generation selector.
+ To serve both purposes, the index for shared_info.pl
+ should end with '-shared', and this suffix will be
+ removed for use as a linker script generation
+ selector. Note that the latter is only used if
+ 'shared_defflag' is defined.
build_scheme => The scheme used to build up a Makefile.
In its simplest form, the value is a string
with the name of the build scheme.
diff --git a/Configurations/descrip.mms.tmpl b/Configurations/descrip.mms.tmpl
index b1c00b7dc3..7393e225bc 100644
--- a/Configurations/descrip.mms.tmpl
+++ b/Configurations/descrip.mms.tmpl
@@ -132,7 +132,10 @@ DEPS={- our @deps = map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
{- output_on() if $disabled{makedepend}; "" -}
GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
GENERATED={- # common0.tmpl provides @generated
- join(", ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; "-\n\t".$x }
+ join(", ", map { my $x = $_;
+ $x =~ s|\.[sS]$|.asm|;
+ $x =~ s|\.ld$|.OPT|;
+ "-\n\t".$x }
@generated) -}
INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
@@ -748,12 +751,19 @@ reconfigure reconf :
sub generatesrc {
my %args = @_;
- (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
my $generator = join(" ", @{$args{generator}});
my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
- if ($target !~ /\.asm$/) {
+ if ($args{src} =~ /\.ld$/) {
+ (my $target = $args{src}) =~ s/\.ld$/.OPT/;
+ my $mkdef = sourcefile('util', 'mkdef.pl');
+ return <<"EOF";
+$target : $args{generator}->[0] $deps
+ \$(PERL) $mkdef $args{generator}->[1] "VMS" > $target
+EOF
+ } elsif ($target !~ /\.[sS]$/) {
+ my $target = $args{src};
if ($args{generator}->[0] =~ m|^.*\.in$|) {
my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
"util", "dofile.pl")),
@@ -770,6 +780,7 @@ $target : $args{generator}->[0] $deps
EOF
}
} else {
+ (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
if ($args{generator}->[0] =~ /\.pl$/) {
$generator = '$(PERL)'.$generator_incs.' '.$generator;
} elsif ($args{generator}->[0] =~ /\.S$/) {
@@ -913,7 +924,9 @@ EOF
my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x }
grep { $_ =~ m|\.o$| }
@{$args{objs}};
- my @defs = grep { $_ =~ /\.opt$/ } @{$args{objs}};
+ my @defs = map { (my $x = $_) =~ s|\.ld$|.OPT|; $x }
+ grep { $_ =~ /\.ld$/ }
+ @{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
die "More than one symbol vector" if scalar @defs > 1;
my $deps = join(", -\n\t\t", @objs, @defs, @deps);
diff --git a/Configurations/shared-info.pl b/Configurations/shared-info.pl
index 47eddd6835..e3a40a92cb 100644
--- a/Configurations/shared-info.pl
+++ b/Configurations/shared-info.pl
@@ -53,7 +53,7 @@ my %shared_info;
'mingw-shared' => sub {
return {
%{$shared_info{'cygwin-shared'}},
- # def_flag made to empty string so it still generates
+ # def_flag made to empty string so it still generates
# something
shared_defflag => '',
};
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
index 17f76a5654..f67eae59e3 100644
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -4,6 +4,7 @@
## {- join("\n## ", @autowarntext) -}
{-
our $objext = $target{obj_extension} || ".o";
+ our $defext = $target{def_extension} || ".ld";
our $depext = $target{dep_extension} || ".d";
our $exeext = $target{exe_extension} || "";
our $libext = $target{lib_extension} || ".a";
@@ -112,7 +113,10 @@ DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
{- output_on() if $disabled{makedepend}; "" -}
GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
GENERATED={- # common0.tmpl provides @generated
- join(" ", @generated ) -}
+ join(" ", map { my $x = $_;
+ $x =~ s|\.ld$|$defext|;
+ $x }
+ @generated ) -}
INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
@@ -408,7 +412,7 @@ libclean:
fi; \
done
$(RM) $(LIBS)
- $(RM) *.map
+ $(RM) *.{- $defext -}
clean: libclean
$(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
@@ -956,7 +960,14 @@ reconfigure reconf:
my $incs = join("", map { " -I".$_ } @{$args{incs}});
my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
- if ($args{src} !~ /\.[sS]$/) {
+ if ($args{src} =~ /\.ld$/) {
+ (my $target = $args{src}) =~ s/\.ld$/${defext}/;
+ (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
+ return <<"EOF";
+$target: $args{generator}->[0] $deps
+ \$(PERL) \$(SRCDIR)/util/mkdef.pl $args{generator}->[1] $mkdef_os > $target
+EOF
+ } elsif ($args{src} !~ /\.[sS]$/) {
if ($args{generator}->[0] =~ m|^.*\.in$|) {
my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
"util", "dofile.pl")),
@@ -1102,9 +1113,11 @@ EOF
(my $l = $f) =~ s/^lib//;
" -l$l" } @{$args{deps}});
my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
- grep { $_ !~ m/\.(?:def|map)$/ }
+ grep { $_ !~ m/\.ld$/ }
+ @{$args{objs}};
+ my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
+ grep { $_ =~ /\.ld$/ }
@{$args{objs}};
- my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
die "More than one exported symbol map" if scalar @defs > 1;
my $objs = join(" ", @objs);
@@ -1169,7 +1182,7 @@ EOF
(my $l = $f) =~ s/^lib//;
" -l$l" } @{$args{deps}});
my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
- grep { $_ !~ m/\.(?:def|map)$/ }
+ grep { $_ !~ m/\.ld$/ }
@{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
my $objs = join(" ", @objs);
diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl
index 148ddf4c60..fb7ddca016 100644
--- a/Configurations/windows-makefile.tmpl
+++ b/Configurations/windows-makefile.tmpl
@@ -6,6 +6,7 @@
our $objext = $target{obj_extension} || ".obj";
our $resext = $target{res_extension} || ".res";
our $depext = $target{dep_extension} || ".d";
+ our $defext = $target{dep_extension} || ".def";
our $exeext = $target{exe_extension} || ".exe";
our $libext = $target{lib_extension} || ".lib";
our $shlibext = $target{shared_extension} || ".dll";
@@ -89,7 +90,10 @@ DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
{- output_on() if $disabled{makedepend}; "" -}
GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
GENERATED={- # common0.tmpl provides @generated
- join(" ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; $x }
+ join(" ", map { my $x = $_;
+ $x =~ s|\.[sS]$|.asm|;
+ $x =~ s|\.ld$|$defext|;
+ $x }
@generated) -}
INSTALL_LIBS={- join(" ", map { quotify1(lib($_)) } @{$unified_info{install}->{libraries}}) -}
@@ -496,7 +500,6 @@ reconfigure reconf:
sub generatesrc {
my %args = @_;
- (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
my ($gen0, @gens) = @{$args{generator}};
my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
@@ -504,7 +507,17 @@ reconfigure reconf:
my $deps = @{$args{deps}} ?
'"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
- if ($target !~ /\.asm$/) {
+ if ($args{src} =~ /\.ld$/) {
+ (my $target = $args{src}) =~ s/\.ld$/$defext/;
+ my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
+ "util", "mkdef.pl")),
+ rel2abs($config{builddir}));
+ return <<"EOF";
+$target: $args{generator}->[0] $deps
+ \$(PERL) $mkdef $args{generator}->[1] 32 > $target
+EOF
+ } elsif ($args{src} !~ /\.[sS]$/) {
+ my $target = $args{src};
if ($args{generator}->[0] =~ m|^.*\.in$|) {
my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
"util", "dofile.pl")),
@@ -521,6 +534,7 @@ $target: "$args{generator}->[0]" $deps
EOF
}
} else {
+ (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
if ($args{generator}->[0] =~ /\.pl$/) {
$generator = '"$(PERL)"'.$generator_incs.' '.$generator;
} elsif ($args{generator}->[0] =~ /\.S$/) {
@@ -623,7 +637,9 @@ EOF
my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
grep { $_ =~ m/\.(?:o|res)$/ }
@{$args{objs}};
- my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
+ my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
+ grep { $_ =~ /\.ld$/ }
+ @{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
die "More than one exported symbols list" if scalar @defs > 1;
my $linklibs = join("", map { "$_\n" } @deps);