From: Alan Modra <amodra@gmail.com>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Chenghua Xu <paul.hua.gm@gmail.com>, binutils@sourceware.org
Subject: Re: PR28306, segfault in _bfd_mips_elf_reloc_unshuffle
Date: Thu, 9 Sep 2021 23:44:38 +0930 [thread overview]
Message-ID: <YToWzhkFbzJ8Qs/P@squeak.grove.modra.org> (raw)
In-Reply-To: <alpine.DEB.2.21.2109091128060.38640@angie.orcam.me.uk>
On Thu, Sep 09, 2021 at 11:51:48AM +0200, Maciej W. Rozycki wrote:
> On Wed, 8 Sep 2021, Alan Modra wrote:
> > + /* ld -r or gas. */
> > relocatable = (output_bfd != NULL);
> >
> > - if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
> > + /* We only use bfd_reloc_offset_in_range for final linking because
> > + mips object files may use relocations that seem to access beyond
> > + section limits. gas/testsuite/gas/mips/dla-reloc.s is an example
> > + that puts R_MIPS_SUB, a 64-bit relocation, on the last
> > + instruction in the section. If final linking that object file
> > + the R_MIPS_SUB won't be processed here since it applies to the
> > + addend for the next reloc rather than the section contents. */
> > + if (!relocatable
> > + && !bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
> > + input_section, reloc_entry->address))
> > return bfd_reloc_outofrange;
>
> Would a correct check be feasible here? For a composed relocation only
> the final entry is applied to output, so could we instead check if there
> is a follow-up relocation?
I don't think there is any easy and safe way of doing that. Even
though there is a nice tidy array of NULL terminated arelent pointers,
the special_function doesn't see an arelent** but rather an arelent*.
Hmm, how about replacing !relocatable above with
!(relocatable && !reloc_entry->howto->partial_inplace) ie. the
condition under which _bfd_mips_elf_generic_reloc writes section
contents?
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2021-09-09 14:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 11:00 Alan Modra
2021-09-09 9:51 ` Maciej W. Rozycki
2021-09-09 14:14 ` Alan Modra [this message]
2021-09-10 8:27 ` Alan Modra
2021-09-10 9:50 ` Maciej W. Rozycki
2021-09-10 11:01 ` Alan Modra
2022-12-09 11:08 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=YToWzhkFbzJ8Qs/P@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=macro@orcam.me.uk \
--cc=paul.hua.gm@gmail.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).