public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Alan Modra <amodra@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: PowerPC64 DT_RELR
Date: Wed, 19 Jan 2022 14:56:07 -0800	[thread overview]
Message-ID: <CAMe9rOquOhtuedKmEqMAxjhybKv-xiVz6KzMs4MGTjyb-i=3FA@mail.gmail.com> (raw)
In-Reply-To: <YedMH7D6Nxzrc/rD@squeak.grove.modra.org>

On Tue, Jan 18, 2022 at 3:24 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Tue, Jan 18, 2022 at 05:32:37AM -0800, H.J. Lu wrote:
> > I tried binutils master branch on glibc master branch:
> >
> > $ readelf -r libc.so.6
> >
> > Relocation section '.rela.dyn' at offset 0x21d38 contains 562 entries:
> >   Offset          Info           Type           Sym. Value    Sym. Name + Addend
> > 000000000000  000000000000 R_PPC64_NONE                         0
> > 000000000000  000000000000 R_PPC64_NONE                         0
> >
> > There are 238 R_PPC64_NONEs in libc.so.6 alone.  There is none
> > for i686, x32 and x86-64.
>
> Thanks for testing and finding the problem.  I did warn that DT_RELR
> on ppc64 is experimental.  :-)
>
> I had the SYMBOL_REFERENCES_LOCAL test in the wrong place.
> check_relocs is too early to know whether a symbol is dynamic in a
> shared library.  Lots of glibc symbols are made local by version
> script, but that doesn't happen until size_dynamic_sections.
>
>         * elf64-ppc.c (ppc64_elf_check_relocs): Don't count relative relocs
>         here depending on SYMBOL_REFERENCES_LOCAL.
>         (dec_dynrel_count): Likewise.
>         (allocate_dynrelocs): Do so here instead.
>
> diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
> index 923c7a3b407..aeae3b7e640 100644
> --- a/bfd/elf64-ppc.c
> +++ b/bfd/elf64-ppc.c
> @@ -5390,8 +5390,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
>                   if ((r_type == R_PPC64_ADDR64 || r_type == R_PPC64_TOC)
>                       && rel->r_offset % 2 == 0
>                       && sec->alignment_power != 0
> -                     && ((!NO_OPD_RELOCS && is_opd)
> -                         || (!ifunc && SYMBOL_REFERENCES_LOCAL (info, h))))
> +                     && ((!NO_OPD_RELOCS && is_opd) || !ifunc))
>                     p->rel_count += 1;
>                 }
>               else
> @@ -7287,8 +7286,7 @@ dec_dynrel_count (const Elf_Internal_Rela *rel,
>                   && sec->alignment_power != 0
>                   && ((!NO_OPD_RELOCS
>                        && ppc64_elf_section_data (sec)->sec_type == sec_opd)
> -                     || (h->type != STT_GNU_IFUNC
> -                         && SYMBOL_REFERENCES_LOCAL (info, h))))
> +                     || h->type != STT_GNU_IFUNC))
>                 p->rel_count -= 1;
>               p->count -= 1;
>               if (p->count == 0)
> @@ -10016,7 +10014,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
>           if (eh->elf.type == STT_GNU_IFUNC)
>             sreloc = htab->elf.irelplt;
>           count = p->count;
> -         if (info->enable_dt_relr)
> +         if (info->enable_dt_relr && SYMBOL_REFERENCES_LOCAL (info, h))
>             count -= p->rel_count;
>           sreloc->size += count * sizeof (Elf64_External_Rela);
>         }
>
> --
> Alan Modra
> Australia Development Lab, IBM

Does PowerPC64 support static PIE?  If yes, it may need more linker changes.

-- 
H.J.

  reply	other threads:[~2022-01-19 22:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18  0:53 Alan Modra
2022-01-18  1:08 ` H.J. Lu
2022-01-18 13:32   ` H.J. Lu
2022-01-18 23:24     ` Alan Modra
2022-01-19 22:56       ` H.J. Lu [this message]
2022-01-22  4:28         ` Alan Modra
2022-01-22 13:04           ` H.J. Lu
2022-01-23 13:51           ` H.J. Lu
2022-03-02  8:41             ` Alan Modra
2022-03-03  2:33               ` PowerPC64 DT_RELR relative reloc addresses Alan Modra
2022-03-09  1:25               ` PowerPC64 DT_RELR Fangrui Song
     [not found]               ` <MWHPR1201MB0110441CD99C43F8215D15EBCB0A9@MWHPR1201MB0110.namprd12.prod.outlook.com>
2022-03-09 21:07                 ` Alan Modra
2022-06-09 10:57 ` Florian Weimer
2022-06-09 22:57   ` Alan Modra
2022-06-09 23:53     ` Alan Modra

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='CAMe9rOquOhtuedKmEqMAxjhybKv-xiVz6KzMs4MGTjyb-i=3FA@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@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).