public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	Binutils <binutils@sourceware.org>
Subject: Re: [PATCH v2] elf: Support DT_RELR relative relocation format [BZ #27924]
Date: Fri, 29 Oct 2021 12:15:12 -0700	[thread overview]
Message-ID: <20211029191512.unestea3abnny6qt@google.com> (raw)
In-Reply-To: <CAMe9rOqiFJhPzi98j-WNkiHDKTGD+Hxss4+u8-c1-dxo7SLEOg@mail.gmail.com>

On 2021-10-29, H.J. Lu wrote:
>On Fri, Oct 29, 2021 at 11:22 AM Carlos O'Donell via Binutils
><binutils@sourceware.org> wrote:
>>
>> On 10/16/21 20:50, Fangrui Song via Binutils wrote:
>> > PIE and shared objects usually have many relative relocations. In
>> > 2017/2018, SHT_RELR/DT_RELR was proposed on
>> > https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/GxjM0L-PBAAJ
>> > ("Proposal for a new section type SHT_RELR") and is a pre-standard. RELR
>> > usually takes 3% or smaller space than R_*_RELATIVE relocations. The
>> > virtual memory size of a mostly statically linked PIE is typically 5~10%
>> > smaller.
>>
>> We've been going over this patch on the weekly Monday patch queue review.
>>
>> I took a note to point out that one of the blockers here is that it is difficult
>> to immediately test this work because it requires a working glibc build using
>> ldd (which has support for DT_RELR).
>>
>> What is the status of the lld support patches for glibc?
>>
>> If we made progress on the lld support then we'd be able to more easily review
>> a testable configuration and keep the review going forward.
>>
>
>I raised the mysterious crash issue:
>
>https://groups.google.com/g/generic-abi/c/bX460iggiKg
>
>We need an updated proposal without mysterious crashes.  One option is
>that the linker should bump EI_ABIVERSION when generating DT_RELR.

The generic ABI says :  "EI_ABIVERSION: ... The interpretation of this
version number is dependent on the ABI identified by the EI_OSABI
field."

Operating systems decide their EI_ABIVERSION.  Having a linker option
not bumping the ABI version can benefit some operating systems. We know
that FreeBSD (ELFOSABI_FREEBSD)/Fuchsia/ChromeOS don't find it necessary
(or don't want) to bump the ABI version.

See https://groups.google.com/g/generic-abi/c/vdG_G4l3N-Y for Solaris'
development model. They simply don't support (new object, old system) (I
believe that means a diagnostic is good but not required). "it's been
pretty drama free over many decades of SunOS."

---

So many folks on binutils/glibc are more interested on Linux and let's
discuss Linux:

Even within ELFOSABI_GNU, different architectures may have different
EI_ABIVERSION values.
I know that mips may use EI_ABIVERSION==1 for
(e_eflags & (EF_MIPS_PIC | EF_MIPS_CPIC)) == EF_MIPS_CPIC
position-dependent executables.


If you think a linker option like -z relr=glibc or --pack-dyn-relocs=relr-glibc
is useful to rule out (DT_RELR object, glibc not supporting DT_RELR)
loudly, you may choose the `_dl_have_relr` in .dynsym scheme
(https://sourceware.org/pipermail/binutils/2021-October/118347.html).

I will probably just make such an option an alias for
--pack-dyn-relocs=relr because LLD has (1) some users who don't need this
checking (2) --pack-dyn-relocs=relr semantic change would be unnecessary
(3) I don't want them to migrate away from --pack-dyn-relocs=relr just
because glibc has a different development model.

>After this issue is resolved, I can look into the bfd linker support.

Will the above said, I grealy appreciate that you can take a stab on the
GNU ld support. This will benefit so many Linux distributions.

I learned that my /usr/bin/perf_* can be 20% smaller if switching to
DT_RELR :) Perhaps 5~10% is more typical for other executables.


  reply	other threads:[~2021-10-29 19:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-17  0:50 Fangrui Song
2021-10-18 14:42 ` H.J. Lu
2021-10-18 16:16   ` Fāng-ruì Sòng
2021-10-18 17:28     ` H.J. Lu
2021-10-18 18:15       ` Fāng-ruì Sòng
2021-10-18 18:27         ` H.J. Lu
2021-10-18 19:19           ` Fāng-ruì Sòng
2021-10-18 19:44             ` H.J. Lu
2021-10-18 20:11               ` Fāng-ruì Sòng
2021-10-18 21:10                 ` Joseph Myers
2021-10-18 22:27                   ` H.J. Lu
2021-10-18 22:30                     ` Joseph Myers
2021-10-18 22:42                       ` H.J. Lu
2021-10-18 23:00                         ` Joseph Myers
2021-10-18 23:36                           ` H.J. Lu
2021-10-18 23:44                             ` Joseph Myers
2021-10-19  1:05                               ` H.J. Lu
2021-10-18 19:21       ` Joseph Myers
2021-10-18 19:45         ` H.J. Lu
2021-10-29 18:21 ` Carlos O'Donell
2021-10-29 18:36   ` H.J. Lu
2021-10-29 19:15     ` Fangrui Song [this message]
2021-10-29 18:38   ` Fāng-ruì Sòng
2021-10-29 19:35     ` Carlos O'Donell
2021-10-29 19:53       ` Adhemerval Zanella
2021-11-01  4:50         ` Fāng-ruì Sòng

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=20211029191512.unestea3abnny6qt@google.com \
    --to=maskray@google.com \
    --cc=binutils@sourceware.org \
    --cc=carlos@redhat.com \
    --cc=hjl.tools@gmail.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).