public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <i@maskray.me>
To: Nick Clifton <nickc@redhat.com>
Cc: binutils@sourceware.org
Subject: Re: Commit: readelf: Improve display of RELR relocations
Date: Wed, 17 Apr 2024 19:28:13 -0700	[thread overview]
Message-ID: <DS7PR12MB57655664B9595FDC43314942CB0E2@DS7PR12MB5765.namprd12.prod.outlook.com> (raw)
In-Reply-To: <d562b8ac-2545-4799-b633-4fc5b0e39bb5@redhat.com>

On Tue, Apr 16, 2024 at 5:22 AM Nick Clifton <nickc@redhat.com> wrote:
>
> Hi Fangrui,
>
> >> I have some minor suggestions.
> >>
> >> * Do we need the ":" in "Entry:"? I presume not because the strings
> >> don't end with ":".
>
> No - it was just a minor formatting thing on my part.
>
> >> * "Address relocated" feels verbose. Would a simple "Address" be
> >> acceptable? That aligns with "Offset" (instead of "Offset relocated")
> >> for REL/RELA output.
>
> Well I wanted to emphasise that the address was for the location to which
> the relocation would be applied, rather than the address of the relocation
> itself.
>
> >> * Do we need the "Notes" column (new starting address, start of
> >> bitmap)?
>
> Not really.  I confess that I wrote this code as a way of teaching
> myself about the RELR format and the notes were there mainly as a
> reminder to myself.
>
> > Let's see if some of the ideas in the attached patch are practical :)
>
> It is, and I have gone ahead and checked it in on your behalf. :)
>
> Cheers
>    Nick

Thanks!

I just recall another two things.


Relocation section '.relr.dyn' at offset 0x1f4 contains 2 entries:

Considering REL/RELA output, users might misinterpret "entries" as
"relocation entries" instead of referring to RELR words.
Overall, the number of relocation entries seems more valuable than the
number of RELR words (users can infer the number from the section
size, or the new "Index:" column).

If we don't want another loop to count the number of relocation
entries, we can possibly remove the misleading "X entries"...

>   The patch also checks for malformed RELR entries (such as an entry
>  with a value of just 1).

Trailing 1 can be utilized by linkers to avoid convergence issues
(https://reviews.llvm.org/D67164):

// The last RELR entry may or may not reach .data.
.relr.dyn
.dynamic   // end of a PT_LOAD
.data    // start a new PT_LOAD

It is possible for the linker to find that the last entry can cover
the relative relocation at .data and decide to shrink .relr.dyn,
while in the next iteration, a smaller .relr.dyn causes the last entry
to unable to cover the relative relocation at .data, and the linker
decide to enlarge .relr.dyn.
This would run into an endless iteration situation.

  reply	other threads:[~2024-04-18  2:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 15:56 Nick Clifton
2024-04-12 18:44 ` Fangrui Song
     [not found] ` <CAN30aBFj+_Yfs8+WrC7aM0ZWQihGoZ8nMk2DHO7Xkxzw6PgqSA@mail.gmail.com>
2024-04-12 22:04   ` Fangrui Song
     [not found]   ` <DS7PR12MB576532E4BB26A2211E7A75AACB042@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-04-16 12:22     ` Nick Clifton
2024-04-18  2:28       ` Fangrui Song [this message]
     [not found]       ` <DS7PR12MB57659F007C5FA3B3CE38A2ECCB0E2@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-04-19 10:55         ` Nick Clifton
2024-04-23 19:37           ` Fangrui Song
     [not found]           ` <MN0PR12MB5761E8D41391C97D0666D300CB112@MN0PR12MB5761.namprd12.prod.outlook.com>
2024-04-24 11:25             ` Nick Clifton

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=DS7PR12MB57655664B9595FDC43314942CB0E2@DS7PR12MB5765.namprd12.prod.outlook.com \
    --to=i@maskray.me \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.com \
    /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).