Re: [PATCH] xtensa: add R_XTENSA_PDIFF_ULEB128 for DWARF uleb128 diffs

Max Filippov <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <CAMo8BfLrZcC3YVp2uhHeWBK3Y7c9tuFujub4x6SZj2psD929ng@mail.gmail.com>
Hi Alexey,

this patch does not apply to the current matser, what version
of binutils is it against?
It's also not in a plain text format...

On Mon, Aug 3, 2026 at 4:38 AM Alexey Lapshin
<[email protected]> wrote:
>
> DWARF 5 location and range lists encode many same-section symbol
> differences as uleb128.  Today the assembler must mark all covered code
> no_transform so linker relaxation cannot change those differences, which
> effectively disables relaxation for nearly every function that has DWARF 5
> debug info.
>
> Emit R_XTENSA_PDIFF_ULEB128 instead: like R_XTENSA_PDIFF32 the difference
> stays in the section contents and the reloc records the subtracted symbol,
> but the assembler pads the uleb128 to a fixed width (minimal encoding plus
> one spare byte) and the linker rewrites the value in place after
> relaxation.
>
> sleb128 and cross-section differences still fall back to no_transform.
> Growth that needs more than the reserved spare byte is reported as a
> relocation overflow.
>
> bfd/
>         * bfd-in2.h: Regenerated.
>         * elf32-xtensa.c (elf_howto_table): New entry for
>         R_XTENSA_PDIFF_ULEB128.
>         (elf_xtensa_reloc_type_lookup, elf_xtensa_do_reloc): Handle it.
>         (relax_section): Rewrite padded uleb128 differences in place.
>         * libbfd.h (bfd_reloc_code_real_names): Add
>         BFD_RELOC_XTENSA_PDIFF_ULEB128.
>         * reloc.c: Document BFD_RELOC_XTENSA_PDIFF_ULEB128.
>
> binutils/
>         * readelf.c (is_none_reloc): Recognize R_XTENSA_PDIFF_ULEB128.
>
> gas/
>         * write.c (cvt_frag_to_fill): Pad leb128 frags to the reserved
>         size when md_leb128_frag_size grew them.
>         (relax_segment): Call md_leb128_frag_size if defined.
>         * config/tc-xtensa.h (xtensa_symfield_type): Add
>         has_leb128_diff_reloc.
>         (md_leb128_frag_size): Define.
>         * config/tc-xtensa.c (xtensa_md_finish): Insert uleb128 fixes.
>         (xtensa_insert_uleb128_fixes, xtensa_leb128_frag_size): New.
>         (xtensa_mark_difference_of_two_symbols): Skip relocated diffs.
>         (md_apply_fix): Ignore BFD_RELOC_XTENSA_PDIFF_ULEB128.
>         * testsuite/gas/xtensa/pdiff-uleb128.s: New test.
>         * testsuite/gas/xtensa/pdiff-uleb128.d: New test.
>         * testsuite/gas/xtensa/pdiff-uleb128-norelax.d: New test.
>
> include/
>         * elf/xtensa.h (elf_xtensa_reloc_type): Add
>         R_XTENSA_PDIFF_ULEB128.
>
> ld/
>         * testsuite/ld-xtensa/relax-uleb128.s: New test.
>         * testsuite/ld-xtensa/relax-uleb128.d: New test.
>         * testsuite/ld-xtensa/relax-uleb128-2.s: New test.
>         * testsuite/ld-xtensa/relax-uleb128-2.d: New test.
>         * testsuite/ld-xtensa/xtensa.exp: Run them.
> ---
>  bfd/bfd-in2.h                                 | 10 +++
>  bfd/elf32-xtensa.c                            | 80 +++++++++++++++++
>  bfd/libbfd.h                                  |  1 +
>  bfd/reloc.c                                   | 12 +++
>  binutils/readelf.c                            |  3 +-
>  gas/config/tc-xtensa.c                        | 86 ++++++++++++++++++-
>  gas/config/tc-xtensa.h                        |  5 ++
>  .../gas/xtensa/pdiff-uleb128-norelax.d        | 20 +++++
>  gas/testsuite/gas/xtensa/pdiff-uleb128.d      | 12 +++
>  gas/testsuite/gas/xtensa/pdiff-uleb128.s      |  7 ++
>  gas/write.c                                   | 20 +++++
>  include/elf/xtensa.h                          |  3 +
>  ld/testsuite/ld-xtensa/relax-uleb128-2.d      | 12 +++
>  ld/testsuite/ld-xtensa/relax-uleb128-2.s      | 18 ++++
>  ld/testsuite/ld-xtensa/relax-uleb128.d        | 11 +++
>  ld/testsuite/ld-xtensa/relax-uleb128.s        | 16 ++++
>  ld/testsuite/ld-xtensa/xtensa.exp             |  2 +
>  17 files changed, 314 insertions(+), 4 deletions(-)
>  create mode 100644 gas/testsuite/gas/xtensa/pdiff-uleb128-norelax.d
>  create mode 100644 gas/testsuite/gas/xtensa/pdiff-uleb128.d
>  create mode 100644 gas/testsuite/gas/xtensa/pdiff-uleb128.s
>  create mode 100644 ld/testsuite/ld-xtensa/relax-uleb128-2.d
>  create mode 100644 ld/testsuite/ld-xtensa/relax-uleb128-2.s
>  create mode 100644 ld/testsuite/ld-xtensa/relax-uleb128.d
>  create mode 100644 ld/testsuite/ld-xtensa/relax-uleb128.s

-- 
Thanks.
-- Max
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.