Re: [PATCH] x86: Disallow ".long foo@PLT - .L4" for PLT32 relocation

"Maciej W. Rozycki" <[email protected]> Sat, 1 Aug 2026 14:47:54 +0100 (BST)
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
On Sat, 1 Aug 2026, H.J. Lu wrote:

> > >> Why? .slong was introduced because of a peculiarity of x86-64. If that
> > >> was straightforward to achieve, it may better not have been exposed to
> > >> 16- and 32-bit code in the first place. While that ship has sailed,
> > >> suddenly making its use mandatory for certain constructs even outside
> > >> of 64-bit code feels outright wrong.
> > > 
> > > What is wrong with using " .long foo4@PLT - .L4" in 64-bit?
> > > The possible reason could be wrong code.  You don't like it
> > > doesn't count.
> >
> > It's not a matter of liking it (or not). The distinction between both is
> > what relocation is (supposed to be) used when one is needed. .long should
> > only ever use zero-extending ones; .slong was added such that want for a
> > sign-extending one can be expressed. Without distinct directives, the
> > assembler has to guess, and such guessing can only go wrong. I'm pretty
> > certain this isn't properly dealt with everywhere, but when adding new
> > functionality we shouldn't extend existing flaws.
> >
> > Jan
> 
> Given that there are no issues with ".long foo - .L4",
> ".long foo1@PLT - .L4" should have no issues at all.
> If you believe that it isn't true, please show me a case.

 I gather this is about the overflow case, handled differently depending 
on the signedness or the lack of, of the datum relocated by the static 
linker or dynamic loader as appropriate.

 Jan, please correct me if I'm wrong since commit d182319b0955 has no 
change description and there's no documentation for `.slong' in the GAS 
manual either.  What are the x86 psABI ELF relocation types corresponding 
to `.long' and `.slong' respectively in this context?

  Maciej