Add R_XTENSA_PDIFF_ULEB128 relocation for DWARF 5
Enables linker relaxation for DWARF 5 uleb128 encoded differences on Xtensa.
This commit introduces R_XTENSA_PDIFF_ULEB128, a new relocation type for the Xtensa architecture, to support DWARF 5’s use of unsigned LEB128 (uleb128) encoding for differences in location and range lists. Previously, such differences prevented linker relaxation for entire functions. The new relocation allows the assembler to pad the uleb128 to a fixed width, enabling the linker to rewrite the difference in place after relaxation, thus preserving relaxation for functions with DWARF 5 debug info.
In Details
DWARF 5 uses uleb128 to encode differences in location and range lists. On Xtensa, these differences were previously marked as no_transform, disabling linker relaxation for the containing code sections. This patch introduces R_XTENSA_PDIFF_ULEB128, analogous to R_XTENSA_PDIFF32. The assembler pads the uleb128 to a defined size, and the linker updates this padded value after relaxation. This change is implemented in elf32-xtensa.c and affects relax_section within BFD, and requires corresponding handling in readelf.c and gas to recognize and process this new relocation type.
- DWARF
- Debugging With Attributed Record Format. A standard file format that stores debugging information within executable files.
- uleb128
- Unsigned LEB128 (Little Endian Base 128). A variable-length encoding used in DWARF for small integers.
- relocation
- Information in an object file that specifies how to modify code or data after linking, typically to resolve symbol addresses or adjust offsets.
- linker relaxation
- A linker optimization process that adjusts instruction addresses and offsets to minimize code size, especially for position-dependent code.
- no_transform
- A flag or state indicating that a section or relocation should not be modified by the linker during relaxation or other optimization passes.
- BFD
- The Binary File Descriptor library, a low-level interface for reading and writing various object file formats.
- gas
- The GNU Assembler, part of the GNU Binutils project.