From 9a7319b0b0b9ddaa440b102dc8e197d267700756 Mon Sep 17 00:00:00 2001 From: Matthias Kraft Date: Mon, 25 May 2020 10:10:24 +0200 Subject: [PATCH] Configure DEPs for FIPS provider on AIX. The binder of the AIX linker needs to be told which functions to call on loading and initializing a shared object. Therefore another configuration variable shared_fipsflag is introduced, which is appended to shared_defflag when the providers/fips module gets configured. It was suggested to refactor the line in the build file template to become more generic and less magic. There is, however, currently no suggestion how to actually achive this, so we leave a TODO comment. The possible shared_fipsflag must only be appended to the shared_def iff this code is acting on behalf of the fips provider module build. Reviewed-by: Shane Lontis Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/11950) --- Configurations/10-main.conf | 1 + Configurations/unix-Makefile.tmpl | 3 ++- providers/fips/self_test.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf index a44a74cb32..3332f03765 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf @@ -1164,6 +1164,7 @@ my %targets = ( module_ldflags => "-Wl,-G,-bsymbolic,-bnoentry", shared_ldflag => "-Wl,-G,-bsymbolic,-bnoentry", shared_defflag => "-Wl,-bE:", + shared_fipsflag => "-Wl,-binitfini:init:cleanup", perl_platform => 'AIX', }, "aix-gcc" => { diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 126180ace7..fc4f60770b 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -1485,7 +1485,8 @@ EOF @{$args{objs}}; my @deps = compute_lib_depends(@{$args{deps}}); my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); - + # TODO(3.0): next line needs to become "less magic" (see PR #11950) + $shared_def .= ' '.$target{shared_fipsflag} if (m/providers\/fips/ && defined $target{shared_fipsflag}); my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs)); my $deps = join(" \\\n" . ' ' x (length($dso) + 2), fill_lines(' ', $COLUMNS - length($dso) - 2, diff --git a/providers/fips/self_test.c b/providers/fips/self_test.c index 4619fedef5..c482544346 100644 --- a/providers/fips/self_test.c +++ b/providers/fips/self_test.c @@ -92,7 +92,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) } return TRUE; } -#elif defined(__sun) +#elif defined(__sun) || defined(_AIX) DEP_DECLARE() /* must be declared before pragma */ # define DEP_INIT_ATTRIBUTE -- 2.25.1