[PATCH v4 05/15] stdio: Ensure *_chk routines have their hidden builtin definition available

Paul E Murphy murphyp@linux.ibm.com
Thu Jul 6 21:15:41 GMT 2023



On 7/4/23 6:49 PM, Siddhesh Poyarekar wrote:
> On 2023-07-04 12:55, Frédéric Bérat wrote:
>> If libc_hidden_builtin_{def,proto} isn't properly set for *_chk routines,
>> there are unwanted PLT entries in libc.so.
>>
>> There is a special case with __asprintf_chk:
>> 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_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.
>>
>> This results in errors on s390x:
>> /usr/bin/ld: glibc/iconv/../libio/bits/stdio2.h:137: undefined reference
>> to `__asprintf_chk'
>>
>> Original __asprintf_chk symbols:
>> 00000000001395b0 T __asprintf_chk
>> 0000000000177e90 T __nldbl___asprintf_chk
>>
>> __asprintf_chk symbols with ldbl_* macros:
>> 000000000012d590 t ___asprintf_chk
>> 000000000012d590 t __asprintf_chk@@GLIBC_2.4
>> 000000000012d590 t __GI___asprintf_chk
>> 000000000012d590 t __GL____asprintf_chk___asprintf_chk
>> 0000000000172240 T __nldbl___asprintf_chk
>>
>> __asprintf_chk symbols with the patch:
>> 000000000012d590 t ___asprintf_chk
>> 000000000012d590 T __asprintf_chk
>> 000000000012d590 t __GI___asprintf_chk
>> 0000000000172240 T __nldbl___asprintf_chk
>> ---
> 
> I'm leaving this one for you Paul.

__asprintf_chk is an oddball as it was introduced in 2.8, but all the 
current targets who switched to a distinct long double switched, did so 
at 2.4.  For those targets, they shouldn't be using any ldbl macros, 
there was never a concern for backwards compatibility.

powerpc64le is where things get weird.  Internally, everything is 
compiled to use ibm long double.  I suspect the special cases can be 
removed entirely, I think they only get used when building the 
nldbl/ieee128 variants of __asprintf_chk.  These variants should never 
need any internal PLT redirection.  I don't think the special case for 
them is needed, but should be harmless.

I think this patch is OK.


More information about the Libc-alpha mailing list