From: "H.J. Lu" <hjl.tools@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH] x86-64: Ignore r_addend for R_X86_64_GLOB_DAT/R_X86_64_JUMP_SLOT
Date: Wed, 25 May 2022 10:49:58 -0700 [thread overview]
Message-ID: <CAMe9rOpxHvkVJZU=vwkLYyUkOVP1LtL5UEcLFiRztcZ-H+Lt-A@mail.gmail.com> (raw)
In-Reply-To: <874k1dy2pf.fsf@oldenburg.str.redhat.com>
On Wed, May 25, 2022 at 9:52 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Libc-alpha:
>
> > According to x86-64 psABI, r_addend should be ignored for R_X86_64_GLOB_DAT
> > and R_X86_64_JUMP_SLOT.
> > ---
> > sysdeps/x86_64/dl-machine.h | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
> > index c70af7ab1e..7f607f6dff 100644
> > --- a/sysdeps/x86_64/dl-machine.h
> > +++ b/sysdeps/x86_64/dl-machine.h
> > @@ -325,11 +325,13 @@ and creates an unsatisfiable circular dependency.\n",
> > # endif
> > /* Set to symbol size plus addend. */
> > value = sym->st_size;
> > + *reloc_addr = value + reloc->r_addend;
> > + break;
> > # endif
> > - /* Fall through. */
> > +
> > case R_X86_64_GLOB_DAT:
> > case R_X86_64_JUMP_SLOT:
> > - *reloc_addr = value + reloc->r_addend;
> > + *reloc_addr = value;
> > break;
> >
> > case R_X86_64_DTPMOD64:
>
> Context:
>
> {
> # ifndef RTLD_BOOTSTRAP
> # ifdef __ILP32__
> case R_X86_64_SIZE64:
> /* Set to symbol size plus addend. */
> *(Elf64_Addr *) (uintptr_t) reloc_addr
> = (Elf64_Addr) sym->st_size + reloc->r_addend;
> break;
>
> case R_X86_64_SIZE32:
> # else
> case R_X86_64_SIZE64:
> # endif
> /* Set to symbol size plus addend. */
> value = sym->st_size;
> # endif
> /* Fall through. */
> case R_X86_64_GLOB_DAT:
> case R_X86_64_JUMP_SLOT:
> *reloc_addr = value + reloc->r_addend;
> break;
>
>
> The new version is:
>
> {
> # ifndef RTLD_BOOTSTRAP
> # ifdef __ILP32__
> case R_X86_64_SIZE64:
> /* Set to symbol size plus addend. */
> *(Elf64_Addr *) (uintptr_t) reloc_addr
> = (Elf64_Addr) sym->st_size + reloc->r_addend;
> break;
>
> case R_X86_64_SIZE32:
> # else
> case R_X86_64_SIZE64:
> # endif
> /* Set to symbol size plus addend. */
> value = sym->st_size;
> *reloc_addr = value + reloc->r_addend;
> break;
> # endif
> case R_X86_64_GLOB_DAT:
> case R_X86_64_JUMP_SLOT:
> *reloc_addr = value;
> break;
>
> So that “break” is actually in the right place.
>
> Are there binaries out there with a non-zero addend? I'm a bit worried
Linker always sets r_addend to 0 for R_X86_64_GLOB_DAT and
R_X86_64_JUMP_SLOT.
> that this change introduces hard-to-diagnose regressions.
>
> Thanks,
> Florian
>
--
H.J.
next prev parent reply other threads:[~2022-05-25 17:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-21 2:23 H.J. Lu
2022-05-22 22:10 ` Fangrui Song
2022-05-25 16:52 ` Florian Weimer
2022-05-25 17:49 ` H.J. Lu [this message]
2022-05-25 18:19 ` Florian Weimer
2022-05-25 18:28 ` Adhemerval Zanella
2022-05-25 19:29 ` H.J. Lu
2022-05-25 20:24 ` Fangrui Song
2022-05-26 20:59 ` H.J. Lu
2022-07-14 0:06 ` Sunil Pandey
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='CAMe9rOpxHvkVJZU=vwkLYyUkOVP1LtL5UEcLFiRztcZ-H+Lt-A@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=fweimer@redhat.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).