[PATCH v4 3/5] Add GLIBC_ABI_DT_RELR for DT_RELR support

Peter O'Connor sunnyflunk@serpentos.com
Tue Mar 1 23:42:05 GMT 2022

I've been testing out and using patches (1,2,4) for about 2-3 weeks and
have now made it the default for all packages. The reason for excluding patch 3
(and reverted the relevant binutils patch) was due to the enforcement of
GLIBC_ABI_DT_RELR as it was not supported by the LLD linker (with clang I use

Other than the size benefits I was able to measure a 1.7s time reduction (about
1.5% of total) in the configure/build of gettext with clang (shared lib build),
just from enabling RELR in the full LLVM stack (and not in any other package).
Seems fairly significant given that loading clang would only be a portion of
the total build time.

On Wed, Mar 2, 2022 at 3:19 AM H.J. Lu via Libc-alpha
<libc-alpha@sourceware.org> wrote:
> @@ -352,6 +370,17 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode)
>         }
>      }
> +  /* Issue an error if there is a DT_RELR entry without GLIBC_ABI_DT_RELR
> +     dependency nor GLIBC_PRIVATE definition.  */
> +  if (map->l_info[DT_RELR] != NULL
> +      && __glibc_unlikely (map->l_abi_version == lav_none))
> +    {
> +      _dl_exception_create
> +       (&exception, DSO_FILENAME (map->l_name),
> +        N_("DT_RELR without GLIBC_ABI_DT_RELR dependency"));
> +      goto call_error;
> +    }
> +
>    return result;
>  }

I have now retested this patch series with most of patch 3, but excluding this
section (which would immediately break the container). As expected, no
problems encountered. But it does make one wonder the value in making glibc
refuse to load a library it is perfectly able to load, just because it lacks
the GLIBC_ABI_DT_RELR dependency. There are four scenarios:

Glibc without this series (<2.36):
(1) RELR file without symbol - Fails to load (or crashes) without good error
(2) RELR file with symbol - Fails to load due to missing symbol (much clearer)

Glibc with this series (2.36+):
(3) RELR file without symbol - Refuses to load with "DT_RELR without
    GLIBC_ABI_DT_RELR dependency" message
(4) RELR file with symbol - Loads and works fine

The main driver of GLIBC_ABI_DT_RELR seemed to be to avoid 'time-travel'
compatibility, essentially to avoid situation (1) where you have no idea why the
file won't load.

Once you have a glibc that includes the "DT_RELR without GLIBC_ABI_DT_RELR
dependency" error, you also have support for RELR and the ability to load it.
There's no time-travel issue in this case, but merely enforcing the requirement
for all linkers wanting to support RELR to add the symbol for glibc.


More information about the Libc-alpha mailing list