On 6/30/23 10:11 AM, Siddhesh Poyarekar wrote: > Subject: > Re: [PATCH v3 06/16] asprintf_chk: Ensure compatibility for both s390x > and ppc64le > From: > Siddhesh Poyarekar > Date: > 6/30/23, 10:11 AM > > To: > Frédéric Bérat , libc-alpha@sourceware.org > CC: > Stefan Liebler , Rajalakshmi Srinivasaraghavan > > > > > > On 2023-06-28 04:42, Frédéric Bérat wrote: >> If ldbl_* macros are used for asprintf, ABI gets broken on s390x, >> if it isn't, ppc64le isn't building due to multiple asm redirections. >> >> This is due to the inclusion of bits/stdio-lbdl.h for ppc64le whereas it >> isn't for s390x. This header creates redirections, which are not >> compatible with the ones generated using libc_hidden_builtin_def. >> Yet, we can't use libc_hidden_ldbl_proto on s390x since it will not >> create a simple strong alias (e.g. as done on x86_64), but a versioned >> alias, leading to ABI breakage. >> --- > > Looks OK to me, but deferring to the IBM maintainers.  Raji, Stefan, > does this look right to you? Paul Murphy is our expert on this topic.  Paul,  Can you comment on this too?  Thanks. > > Thanks, > Sid > > >> debug/asprintf_chk.c | 12 ++++++++++++ >>   include/stdio.h      |  5 +++++ >>   2 files changed, 17 insertions(+) >> >> diff --git a/debug/asprintf_chk.c b/debug/asprintf_chk.c >> index 06d112de00..7da1cddacb 100644 >> --- a/debug/asprintf_chk.c >> +++ b/debug/asprintf_chk.c >> @@ -36,5 +36,17 @@ ___asprintf_chk (char **result_ptr, int flag, >> const char *format, ...) >>       return ret; >>   } >> +#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 >> +/* This is needed since is included in this >> case, leading to >> + * multiple asm redirection of the same symbol >> + */ >>   ldbl_hidden_def (___asprintf_chk, __asprintf_chk) >>   ldbl_strong_alias (___asprintf_chk, __asprintf_chk) >> +#else >> +/* Yet, we can't use ldbl_* macros on some systems, even if they >> don't fall in >> + * the first case as this leads to ABI breakage due to the >> long_double_symbol >> + * aliasing, which is versionned. >> + */ >> +strong_alias (___asprintf_chk, __asprintf_chk) >> +libc_hidden_builtin_def (__asprintf_chk) >> +#endif >> diff --git a/include/stdio.h b/include/stdio.h >> index 3afb0ff77b..6755877911 100644 >> --- a/include/stdio.h >> +++ b/include/stdio.h >> @@ -279,7 +279,12 @@ rtld_hidden_proto (__libc_fatal) >>     libc_hidden_proto (__fgets_unlocked_chk) >>   +#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 >>   libc_hidden_ldbl_proto (__asprintf_chk) >> +#else >> +libc_hidden_proto (__asprintf_chk) >> +#endif >> + >>   libc_hidden_ldbl_proto (__fprintf_chk) >>   libc_hidden_ldbl_proto (__sprintf_chk) >>   libc_hidden_ldbl_proto (__vsprintf_chk)