public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@orcam.me.uk>
To: YunQiang Su <syq@gcc.gnu.org>
Cc: Hans-Peter Nilsson <hp@bitrange.com>,
	Nick Clifton <nickc@redhat.com>,
	 binutils@sourceware.org, xry111@xry111.site
Subject: Re: [PATCH v6] MIPS: Reject branch absolute relocs for PIC for linking
Date: Fri, 1 Mar 2024 17:23:22 +0000 (GMT)	[thread overview]
Message-ID: <alpine.DEB.2.21.2403011712080.42226@angie.orcam.me.uk> (raw)
In-Reply-To: <CAKcpw6XN=Vatw_iSNKZo=mDS-1HwqjQGCQg+B81=Ku__-pypGQ@mail.gmail.com>

On Sun, 25 Feb 2024, YunQiang Su wrote:

> > > Good idea. I think that we should use "...against an absolute value".
> > > "absolute symbol"  is not included in this code, as it's r_symndx is
> > > not STN_UNDEF.
> >
> >  Well code says otherwise:
> >
> > +             if (branch_reloc_p (r_type) && r_symndx == STN_UNDEF)
> >
> > did you mean "the relocation's r_symndx is STN_UNDEF"?
> >
> >  But it can be a relocation against an absolute symbol, for example if the
> > symbol referred to by a relocation is supplied by another module in the
> > link or a linker script and said symbol is absolute.  This case has to be
> 
> I have no idea whether we should emit this error for this case:
>    If the symbol is set by a linker script, and is near enough with
> our instruction,
>    the object should be ok for PIC?
> If not near enough, a "relocation truncated to fit" error will emit.

 If the symbol referred is absolute, then the case is no different from an 
absolute relocation.  You just can't calculate a PC-relative reference to 
an absolute value at static link time, because the distance from PC to 
that value will depend on the base address at load time.  It is different 
from a reference to a regular (non-absolute) symbol that just turns out 
too distant for a PC-relative relocation to reach (where the "relocation 
truncated to fit" case applies).

  Maciej

      reply	other threads:[~2024-03-01 17:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 14:52 YunQiang Su
2024-02-22  3:13 ` Hans-Peter Nilsson
2024-02-22  6:29   ` YunQiang Su
2024-02-22 13:13     ` Maciej W. Rozycki
2024-02-25 14:08       ` YunQiang Su
2024-03-01 17:23         ` Maciej W. Rozycki [this message]

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=alpine.DEB.2.21.2403011712080.42226@angie.orcam.me.uk \
    --to=macro@orcam.me.uk \
    --cc=binutils@sourceware.org \
    --cc=hp@bitrange.com \
    --cc=nickc@redhat.com \
    --cc=syq@gcc.gnu.org \
    --cc=xry111@xry111.site \
    /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).