DT_RELR without libc.so dependency

Alan Modra amodra@gmail.com
Thu Apr 14 05:18:57 GMT 2022


On Wed, Apr 13, 2022 at 06:54:17PM -0700, H.J. Lu wrote:
> On Wed, Apr 13, 2022 at 5:34 PM Alan Modra <amodra@gmail.com> wrote:
> >
> > On Fri, Apr 08, 2022 at 05:14:12PM -0700, Fangrui Song wrote:
> > > HJ's DT_RELR patch series has been upgraded to v7
> > > (https://patchwork.sourceware.org/project/glibc/list/?series=8295)
> > >
> > >   git-pw series apply 8295
> > >   # `Add --disable-default-dt-relr` does not apply cleanly
> > >
> > > If no regressions with default DT_RELR, that will be cool!
> >
> > I did find one error when testing a build of glibc using Ubuntu gcc-8.
> > elf/filter fails with "error while loading shared libraries:
> > .../elf/filtmod1.so: DT_RELR without GLIBC_ABI_DT_RELR dependency".
> >
> > A little analysis shows the problem occurs when filtmod1.so is linked
> > with --as-needed and libc.so is not needed.  filtmod1.so ends up with
> > no .gnu.version or .gnu.version_r sections, and of course no
> > GLIBC_ABI_DT_RELR version.
> >
> > The error check is not one that belongs in ld.so.  If you have the
> > error checking code, then you have DT_RELR support in ld.so and there
> > is no reason at all to refuse to run the program!  The check should be
> > in the linker, if anywhere.
> >
> 
> The GLIBC_ABI_DT_RELR dependency is added to avoid the random
> crush at run-time with older glibc binaries.   Since it is possible to create
> a DSO with DT_RELR, but without the libc.so dependency.   Should ld.so
> skip the GLIBC_ABI_DT_RELR check if the DSO doesn't depend on
> libc.so?

I understand why you want a dependency, but I do not see a hard
requirement for l_abi_version or any code using it.  If you try to run
a new binary with DT_RELR using an old glibc or even current glibc
without relr support, you'll get "version `GLIBC_ABI_DT_RELR' not
found".  That is sufficient, presuming there is a GLIBC_ABI_DT_RELR
version in the binary.  If there *isn't* a GLIBC_ABI_DT_RELR version
then running that binary on an older glibc probably will crash.
Putting a check in a newer ld.so doesn't help much with that, except
show up this case where the dependency isn't there.  I guess the check
is justifiable under some DL_DEBUG flag.

Lack of a dependency is either a linker bug or a relr design bug.
Nitpick: isn't the actual dependency on ld.so rather than libc.so?

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Libc-alpha mailing list