diff options
author | Richard Levitte <levitte@openssl.org> | 2018-09-30 14:44:59 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2018-10-01 09:49:16 +0200 |
commit | ef2dfc9902e015de91f015177bdf235c9000839e (patch) | |
tree | 61e6c5535dbf8c44096f6322defd2c88fdf4dfbf /Configurations/unix-Makefile.tmpl | |
parent | b44882a0bd0717e0aab84f5dc3ef81ab673155e9 (diff) | |
download | openssl-ef2dfc9902e015de91f015177bdf235c9000839e.tar.gz |
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/unix-Makefile.tmpl')
-rw-r--r-- | Configurations/unix-Makefile.tmpl | 25 |
1 files changed, 19 insertions, 6 deletions
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); |