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: Nick Clifton <nickc@redhat.com>,
	"Maciej W. Rozycki" <macro@linux-mips.org>,
	Fangrui Song <i@maskray.me>, Binutils <binutils@sourceware.org>
Subject: V4 [PATCH] ELF: Don't check relocations in non-loaded, non-alloced sections
Date: Thu, 4 Jun 2020 04:24:36 -0700	[thread overview]
Message-ID: <CAMe9rOrZ1DQ3yMV0w0U+SumNbTHLTMoF1Krc5YR9NsQLAggANw@mail.gmail.com> (raw)
In-Reply-To: <20200604074749.GP29024@bubble.grove.modra.org>

[-- Attachment #1: Type: text/plain, Size: 1828 bytes --]

On Thu, Jun 4, 2020 at 12:47 AM Alan Modra <amodra@gmail.com> wrote:
>
> On Wed, Jun 03, 2020 at 11:55:08AM -0700, H.J. Lu wrote:
> > --- a/bfd/elfxx-mips.c
> > +++ b/bfd/elfxx-mips.c
> > @@ -8618,7 +8618,6 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
> >        struct elf_link_hash_entry *h;
> >        bfd_boolean can_make_dynamic_p;
> >        bfd_boolean call_reloc_p;
> > -      bfd_boolean constrain_symbol_p;
> >
> >        r_symndx = ELF_R_SYM (abfd, rel->r_info);
> >        r_type = ELF_R_TYPE (abfd, rel->r_info);
> > @@ -8653,12 +8652,6 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
> >        and if pointer equality therefore doesn't matter.  */
> >        call_reloc_p = FALSE;
> >
> > -      /* Set CONSTRAIN_SYMBOL_P if we need to take the relocation
> > -      into account when deciding how to define the symbol.
> > -      Relocations in nonallocatable sections such as .pdr and
> > -      .debug* should have no effect.  */
> > -      constrain_symbol_p = ((sec->flags & SEC_ALLOC) != 0);
> > -
>
> So "normal" sections will result in constrain_symbol_p being true.
>
> >        switch (r_type)
> >       {
> >       case R_MIPS_CALL16:
> > @@ -8740,21 +8733,10 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
> >       case R_MIPS_NONE:
> >       case R_MIPS_JALR:
> >       case R_MICROMIPS_JALR:
> > -       /* These relocations have empty fields and are purely there to
> > -          provide link information.  The symbol value doesn't matter.  */
> > -       constrain_symbol_p = FALSE;
> > -       break;
> > -
>
> But in for some special relocs it should be false.  I think removing
> constrain_symbol_p is just wrong.  You should keep it but initialise
> to true.

Done.

Here is the updated patch.   OK for master?

-- 
H.J.

[-- Attachment #2: 0001-ELF-Don-t-check-relocations-in-non-loaded-non-alloce.patch --]
[-- Type: application/x-patch, Size: 19234 bytes --]

  reply	other threads:[~2020-06-04 11:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02 20:38 H.J. Lu
2020-06-03  0:05 ` Fangrui Song
     [not found] ` <MWHPR12MB14567E24AED5430AAE2497A8CB880@MWHPR12MB1456.namprd12.prod.outlook.com>
2020-06-03  1:29   ` H.J. Lu
2020-06-03 16:48     ` V2 " H.J. Lu
2020-06-03 18:55       ` V3 " H.J. Lu
2020-06-04  7:47         ` Alan Modra
2020-06-04 11:24           ` H.J. Lu [this message]
2020-06-04 12:41             ` V4 " Alan Modra
2020-06-05  3:07               ` Alan Modra
2020-06-05 12:32                 ` [PATCH] bfin: Skip non SEC_ALLOC section H.J. Lu

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=CAMe9rOrZ1DQ3yMV0w0U+SumNbTHLTMoF1Krc5YR9NsQLAggANw@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=i@maskray.me \
    --cc=macro@linux-mips.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).