public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH v6 3/5] Add GLIBC_ABI_DT_RELR for DT_RELR support
Date: Wed, 30 Mar 2022 14:39:46 -0300	[thread overview]
Message-ID: <5151cd92-2401-cdb3-ca6d-542630ade06e@linaro.org> (raw)
In-Reply-To: <CAMe9rOp2542_OhDibOCk9UgU6YGstiE-hDAbPA7HBZEuA9GJ1g@mail.gmail.com>



On 30/03/2022 14:32, H.J. Lu wrote:
> Does the linker add the version dependency? Does ld.so support DT_RELR?
> 

$ readelf -V test | grep GLIBC_ABI_DT_RELR
  0x0030:   Name: GLIBC_ABI_DT_RELR  Flags: none  Version: 4

But ld.so does not support DT_RELR

$ grep libc_cv_dt_relr config.log 
libc_cv_dt_relr=no


> On Wed, Mar 30, 2022, 10:17 AM Adhemerval Zanella <adhemerval.zanella@linaro.org <mailto:adhemerval.zanella@linaro.org>> wrote:
> 
> 
> 
>     On 30/03/2022 11:41, H.J. Lu wrote:
>     > On Wed, Mar 30, 2022 at 7:18 AM Adhemerval Zanella
>     > <adhemerval.zanella@linaro.org <mailto:adhemerval.zanella@linaro.org>> wrote:
>     >>
>     >>
>     >>
>     >> On 29/03/2022 19:29, H.J. Lu wrote:
>     >>> On Tue, Mar 29, 2022 at 9:52 AM Adhemerval Zanella
>     >>> <adhemerval.zanella@linaro.org <mailto:adhemerval.zanella@linaro.org>> wrote:
>     >>>>
>     >>>>
>     >>>>
>     >>>> On 10/03/2022 17:03, H.J. Lu via Libc-alpha wrote:
>     >>>>> The EI_ABIVERSION field of the ELF header in executables and shared
>     >>>>> libraries can be bumped to indicate the minimum ABI requirement on the
>     >>>>> dynamic linker.  However, EI_ABIVERSION in executables isn't checked by
>     >>>>> the Linux kernel ELF loader nor the existing dynamic linker.  Executables
>     >>>>> will crash mysteriously if the dynamic linker doesn't support the ABI
>     >>>>> features required by the EI_ABIVERSION field.  The dynamic linker should
>     >>>>> be changed to check EI_ABIVERSION in executables.
>     >>>>>
>     >>>>> Add a glibc version, GLIBC_ABI_DT_RELR, to indicate DT_RELR support so
>     >>>>> that the existing dynamic linkers will issue an error on executables with
>     >>>>> GLIBC_ABI_DT_RELR dependency.  Issue an error if there is a DT_RELR entry
>     >>>>> without GLIBC_ABI_DT_RELR dependency nor GLIBC_PRIVATE definition.
>     >>>>>
>     >>>>> Support __placeholder_only_for_empty_version_map as the placeholder symbol
>     >>>>> used only for empty version map to generate GLIBC_ABI_DT_RELR without any
>     >>>>> symbols.
>     >>>>
>     >>>> I think it only make sense to add the GLIBC_ABI_DT_RELR if the ABI actually
>     >>>> supports DT_RELR, otherwise if the ABI start to support old glibcs might
>     >>>> wrongly assumes DT_RELR and fails with undefined behavior at runtime
>     >>>> (which this patch essentially tries to avoid).
>     >>>
>     >>> The DT_RELR set enables DT_RELR in glibc for all targets.
>     >> If I understood correctly, if we add GLIBC_ABI_DT_RELR on 2.36 but only enable
>     >> it on some architecture on 2.37 and try to run a binary with DT_RELR enabled
>     >> on glibc 2.36, _dl_check_map_versions won't accuse a failure and it will
>     >> eventually only fail at runtime (since relocation won't be applied).  My
>     >> understanding we are trying to avoid such failures.
>     >
>     > My patch set enables DT_RELR and GLIBC_ABI_DT_RELR on glibc 2.36
>     > for all, regardless of binutils version.   There is no per-arch
>     > behavior.    Only
>     > DT_RELR run-time tests are enabled for linkers with -z pack-relative-relocs.
> 
>     But it still does not fail when the architecture does not actually implement
>     RELR even when static linker does:
> 
>     $ clang --target=aarch64-linux-gnu -fuse-ld=lld -Wl,-z,pack-relative-relocs -fpie -o test -pie test.c
>     $ aarch64-glibc-linux-gnu-readelf -S test | grep relr\.dyn
>       [ 9] .relr.dyn         RELR             0000000000000528  00000528
>     $ ./elf/ld.so --library-path . ./test
>     $
> 
>     I would expect that even when binary adds GLIBC_ABI_DT_RELR, if dynamic linker
>     does not have DT_RELR it would fail early.
> 

  reply	other threads:[~2022-03-30 17:39 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 20:03 [PATCH v6 0/5] Support DT_RELR relative relocation format H.J. Lu
2022-03-10 20:03 ` [PATCH v6 1/5] elf: Support DT_RELR relative relocation format [BZ #27924] H.J. Lu
2022-03-29 16:34   ` Adhemerval Zanella
2022-03-29 22:34     ` H.J. Lu
2022-03-10 20:03 ` [PATCH v6 2/5] elf: Properly handle zero DT_RELA/DT_REL values H.J. Lu
2022-03-29 16:38   ` Adhemerval Zanella
2022-03-29 22:30     ` H.J. Lu
2022-03-10 20:03 ` [PATCH v6 3/5] Add GLIBC_ABI_DT_RELR for DT_RELR support H.J. Lu
2022-03-29 16:52   ` Adhemerval Zanella
2022-03-29 22:29     ` H.J. Lu
2022-03-30 14:18       ` Adhemerval Zanella
2022-03-30 14:41         ` H.J. Lu
2022-03-30 17:17           ` Adhemerval Zanella
2022-03-30 17:32             ` H.J. Lu
2022-03-30 17:39               ` Adhemerval Zanella [this message]
2022-03-30 19:22             ` Joseph Myers
2022-03-30 20:38               ` Adhemerval Zanella
2022-03-30 21:32                 ` Fangrui Song
2022-03-10 20:03 ` [PATCH v6 4/5] Add --disable-default-dt-relr H.J. Lu
2022-03-29 17:19   ` Adhemerval Zanella
2022-03-29 22:25     ` H.J. Lu
2022-03-10 20:03 ` [PATCH v6 5/5] NEWS: Mention DT_RELR support H.J. Lu
2022-03-29 17:25   ` Adhemerval Zanella
2022-03-29 22:22     ` H.J. Lu
2022-03-29 23:34       ` Fangrui Song
2022-03-30 14:20         ` Adhemerval Zanella
2022-03-10 20:09 ` [PATCH v6 0/5] Support DT_RELR relative relocation format Fangrui Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5151cd92-2401-cdb3-ca6d-542630ade06e@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=hjl.tools@gmail.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).