[PATCH] ldconfig: Test the behaviour of _dl_cache_libcmp (Bug, 26101)

Florian Weimer fweimer@redhat.com
Mon Jun 22 08:41:29 GMT 2020


* Carlos O'Donell via Libc-alpha:

> We move _dl_cache_libcmp to compile the implementation of the
> library name sorting routine into a distinct *.os file during
> the PIE build.  Then we add a new PIE test tst-_dl_cache_libcmp
> which links directly to the compiled implementation and provides
> unit testing for the implementation.

It is not possible to reuse object files in this way.  If something is
built with IS_IN (rtld), it uses different symbol visibility than an
application build.

I don't see why you need a PIE test here.  It does not make the object
file more usable.  Static linking against the .o file (not .os file)
would help because with static dlopen, everything is linked together
anyway.

The build fails on microblaze with an assertion failure in binutils:

/home/bmg/install/compilers/microblaze-linux-gnu/lib/gcc/microblaze-glibc-linux-gnu/10.1.1/../../../../microblaze-glibc-linux-gnu/bin/ld: BFD (GNU Binutils) 2.34.0.20200622 assertion fail /home/bmg/src/binutils/bfd/elf32-microblaze.c:1542
/home/bmg/install/compilers/microblaze-linux-gnu/lib/gcc/microblaze-glibc-linux-gnu/10.1.1/../../../../microblaze-glibc-linux-gnu/bin/ld: /home/bmg/build/glibcs/microblaze-linux-gnu/glibc/elf/tst-_dl_cache_libcmp.o: probably compiled without -fPIC?
/home/bmg/install/compilers/microblaze-linux-gnu/lib/gcc/microblaze-glibc-linux-gnu/10.1.1/../../../../microblaze-glibc-linux-gnu/bin/ld: final link failed: bad value

The assertion failure is a binutils bug, but the link failure is
probably valid.

On arm-linux-gnueabihf-v7a-disable-multi-arch, it looks like this:

/home/bmg/install/compilers/arm-linux-gnueabihf/lib/gcc/arm-glibc-linux-gnueabihf/10.1.1/../../../../arm-glibc-linux-gnueabihf/bin/ld: /home/bmg/build/glibcs/arm-linux-gnueabihf-v7a-disable-multi-arch/glibc/elf/tst-_dl_cache_libcmp.o(.text.startup+0x1c): unresolvable R_ARM_CALL relocation against symbol `memset@@GLIBC_2.4'

Something is clearly wrong with how the PIE test is being built.

> diff --git a/elf/ldconfig.c b/elf/ldconfig.c
> index 0c090dca15..21072d3ea9 100644
> --- a/elf/ldconfig.c
> +++ b/elf/ldconfig.c
> @@ -967,7 +967,8 @@ search_dir (const struct dir_entry *entry)
>  	  if (strcmp (dlib_ptr->soname, soname) == 0)
>  	    {
>  	      /* Prefer a file to a link, otherwise check which one
> -		 is newer.  */
> +		 is a later version number based on the existing cache
> +		 choices made by _dl_cache_libcmp.  */

What is a cache choice?

Please also add a comment to cache.c that the use of _dl_cache_libcmp
for cache keys there is not semantically required, but now part of ABI
because dl-cache.c must use exactly the same sort order.

> diff --git a/elf/tst-_dl_cache_libcmp.c b/elf/tst-_dl_cache_libcmp.c
> new file mode 100644
> index 0000000000..6e2a3fee0f
> --- /dev/null
> +++ b/elf/tst-_dl_cache_libcmp.c
> @@ -0,0 +1,158 @@
> +/* Testing of the ld.so/ldconfig library version comparison.

I would expect some explicit tests for leading and trailing zeros.

Thanks,
Florian



More information about the Libc-alpha mailing list