[0/2] xtensa: add R_XTENSA_32_ABS

Message ID 20260923170020.757213-1-alexey.lapshin@espressif.com
Headers
Series xtensa: add R_XTENSA_32_ABS |

Message

Alexey Lapshin Sept. 23, 2026, 4:59 p.m. UTC
  This series adds R_XTENSA_32_ABS, a 32-bit absolute relocation with
the standard RELA meaning (S + A, relocated word ignored), unlike the
partial_inplace R_XTENSA_32.  This lets LLVM and lld follow the generic
ABI, while objects using either relocation still link together.  gas
keeps emitting R_XTENSA_32 unless asked for the new relocation.
Patch 1 reserves the relocation number, patch 2 implements it.
For more details see the discussion:
https://discourse.llvm.org/t/rfc-add-xtensa-support-to-lld-elf-static-linking-for-embedded-targets/91608
Tested on xtensa-elf with the gas, ld and binutils testsuites, no
regressions.

Alexey Lapshin (2):
  xtensa: reserve relocation number for R_XTENSA_32_ABS
  xtensa: implement R_XTENSA_32_ABS

 bfd/bfd-in2.h                                 |  6 ++
 bfd/elf32-xtensa.c                            | 78 +++++++++++++++----
 bfd/libbfd.h                                  |  1 +
 bfd/reloc.c                                   |  8 ++
 binutils/readelf.c                            |  3 +-
 gas/config.in                                 |  4 +
 gas/config/tc-xtensa.c                        | 36 ++++++++-
 gas/configure                                 | 29 ++++++-
 gas/configure.ac                              | 20 +++++
 gas/doc/as.texi                               |  1 +
 gas/doc/c-xtensa.texi                         | 11 +++
 .../gas/xtensa/pdiff-uleb128-norelax.d        |  2 +-
 .../gas/xtensa/reloc-abs32-no-rela.d          | 20 +++++
 gas/testsuite/gas/xtensa/reloc-abs32.d        | 18 +++++
 gas/testsuite/gas/xtensa/reloc-abs32.s        | 13 ++++
 include/elf/xtensa.h                          |  5 ++
 ld/testsuite/ld-xtensa/reloc-abs32-1.s        | 15 ++++
 ld/testsuite/ld-xtensa/reloc-abs32-2.s        |  6 ++
 ld/testsuite/ld-xtensa/reloc-abs32-3.s        | 11 +++
 ld/testsuite/ld-xtensa/reloc-abs32-r.d        | 23 ++++++
 ld/testsuite/ld-xtensa/reloc-abs32.d          | 16 ++++
 ld/testsuite/ld-xtensa/reloc-abs32.t          |  5 ++
 .../ld-xtensa/reloc-coalesce-abs32-1.s        | 18 +++++
 .../ld-xtensa/reloc-coalesce-abs32-2.s        | 14 ++++
 ld/testsuite/ld-xtensa/reloc-coalesce-abs32.d | 21 +++++
 ld/testsuite/ld-xtensa/reloc-prop-abs32.d     | 13 ++++
 ld/testsuite/ld-xtensa/reloc-prop-abs32.s     | 19 +++++
 ld/testsuite/ld-xtensa/reloc-prop-abs32.t     |  5 ++
 ld/testsuite/ld-xtensa/xtensa.exp             |  5 ++
 29 files changed, 402 insertions(+), 24 deletions(-)
 create mode 100644 gas/testsuite/gas/xtensa/reloc-abs32-no-rela.d
 create mode 100644 gas/testsuite/gas/xtensa/reloc-abs32.d
 create mode 100644 gas/testsuite/gas/xtensa/reloc-abs32.s
 create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32-1.s
 create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32-2.s
 create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32-3.s
 create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32-r.d
 create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32.d
 create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32.t
 create mode 100644 ld/testsuite/ld-xtensa/reloc-coalesce-abs32-1.s
 create mode 100644 ld/testsuite/ld-xtensa/reloc-coalesce-abs32-2.s
 create mode 100644 ld/testsuite/ld-xtensa/reloc-coalesce-abs32.d
 create mode 100644 ld/testsuite/ld-xtensa/reloc-prop-abs32.d
 create mode 100644 ld/testsuite/ld-xtensa/reloc-prop-abs32.s
 create mode 100644 ld/testsuite/ld-xtensa/reloc-prop-abs32.t
  

Comments

Alexey Lapshin Sept. 30, 2026, 9:57 a.m. UTC | #1
Ping
  
Alan Modra Oct. 8, 2026, 1:57 a.m. UTC | #2
On Wed, Sep 30, 2026 at 09:57:59AM +0000, Alexey Lapshin wrote:
> Ping

You might need to ping the xtensa maintainers (cc'd) directly.  Also,
I found your patches and this ping in my gmail spam, so for some
reason google didn't like your posts.
  
augustine.sterling@gmail.com Oct. 8, 2026, 2:38 a.m. UTC | #3
I wrote a patch a long time ago with a more aggressive version of the
change. This addition instead of an abi compatibility break is a solid
improvement to that idea.

I am in no position to test it and my binutils skills are rusty to say the
least. But the approach is sound and a good improvement.

So I approve the patch unless Max has any objection.

On Wed, Oct 7, 2026 at 6:57 PM Alan Modra <amodra@gmail.com> wrote:

> On Wed, Sep 30, 2026 at 09:57:59AM +0000, Alexey Lapshin wrote:
> > Ping
>
> You might need to ping the xtensa maintainers (cc'd) directly.  Also,
> I found your patches and this ping in my gmail spam, so for some
> reason google didn't like your posts.
>
> --
> Alan Modra
>
  
Max Filippov Oct. 9, 2026, 4:27 a.m. UTC | #4
On Wed, Sep 23, 2026 at 10:01 AM Alexey Lapshin
<alexey.lapshin@espressif.com> wrote:
>
> This series adds R_XTENSA_32_ABS, a 32-bit absolute relocation with
> the standard RELA meaning (S + A, relocated word ignored), unlike the
> partial_inplace R_XTENSA_32.  This lets LLVM and lld follow the generic
> ABI, while objects using either relocation still link together.  gas
> keeps emitting R_XTENSA_32 unless asked for the new relocation.
> Patch 1 reserves the relocation number, patch 2 implements it.
> For more details see the discussion:
> https://discourse.llvm.org/t/rfc-add-xtensa-support-to-lld-elf-static-linking-for-embedded-targets/91608
> Tested on xtensa-elf with the gas, ld and binutils testsuites, no
> regressions.
>
> Alexey Lapshin (2):
>   xtensa: reserve relocation number for R_XTENSA_32_ABS
>   xtensa: implement R_XTENSA_32_ABS
>
>  bfd/bfd-in2.h                                 |  6 ++
>  bfd/elf32-xtensa.c                            | 78 +++++++++++++++----
>  bfd/libbfd.h                                  |  1 +
>  bfd/reloc.c                                   |  8 ++
>  binutils/readelf.c                            |  3 +-
>  gas/config.in                                 |  4 +
>  gas/config/tc-xtensa.c                        | 36 ++++++++-
>  gas/configure                                 | 29 ++++++-
>  gas/configure.ac                              | 20 +++++
>  gas/doc/as.texi                               |  1 +
>  gas/doc/c-xtensa.texi                         | 11 +++
>  .../gas/xtensa/pdiff-uleb128-norelax.d        |  2 +-
>  .../gas/xtensa/reloc-abs32-no-rela.d          | 20 +++++
>  gas/testsuite/gas/xtensa/reloc-abs32.d        | 18 +++++
>  gas/testsuite/gas/xtensa/reloc-abs32.s        | 13 ++++
>  include/elf/xtensa.h                          |  5 ++
>  ld/testsuite/ld-xtensa/reloc-abs32-1.s        | 15 ++++
>  ld/testsuite/ld-xtensa/reloc-abs32-2.s        |  6 ++
>  ld/testsuite/ld-xtensa/reloc-abs32-3.s        | 11 +++
>  ld/testsuite/ld-xtensa/reloc-abs32-r.d        | 23 ++++++
>  ld/testsuite/ld-xtensa/reloc-abs32.d          | 16 ++++
>  ld/testsuite/ld-xtensa/reloc-abs32.t          |  5 ++
>  .../ld-xtensa/reloc-coalesce-abs32-1.s        | 18 +++++
>  .../ld-xtensa/reloc-coalesce-abs32-2.s        | 14 ++++
>  ld/testsuite/ld-xtensa/reloc-coalesce-abs32.d | 21 +++++
>  ld/testsuite/ld-xtensa/reloc-prop-abs32.d     | 13 ++++
>  ld/testsuite/ld-xtensa/reloc-prop-abs32.s     | 19 +++++
>  ld/testsuite/ld-xtensa/reloc-prop-abs32.t     |  5 ++
>  ld/testsuite/ld-xtensa/xtensa.exp             |  5 ++
>  29 files changed, 402 insertions(+), 24 deletions(-)
>  create mode 100644 gas/testsuite/gas/xtensa/reloc-abs32-no-rela.d
>  create mode 100644 gas/testsuite/gas/xtensa/reloc-abs32.d
>  create mode 100644 gas/testsuite/gas/xtensa/reloc-abs32.s
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32-1.s
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32-2.s
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32-3.s
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32-r.d
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32.d
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-abs32.t
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-coalesce-abs32-1.s
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-coalesce-abs32-2.s
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-coalesce-abs32.d
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-prop-abs32.d
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-prop-abs32.s
>  create mode 100644 ld/testsuite/ld-xtensa/reloc-prop-abs32.t

Regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master.