binutils Newspaper
NOVEMBER 30, 2026
hppa — Committed

hppa: Fix register extraction logic for ldil instruction

Corrects register extraction for HPPA's ldil instruction, enabling proper relocation handling for dynamic linking.

This committed patch fixes two issues in the HPPA ELF linker’s handling of ldil and addl instruction sequences, which are used for dynamic linking relocations. It corrects the bit shifting for extracting the target address from ldil and allows for arbitrary base registers in the subsequent addl instruction, resolving issues with relocated code generation.

In the Thread 1 participant
  1. John David Anglin <dave.anglin@bell.net> proposer

    Submitted a patch to fix relocation handling for HPPA's ldil instruction.

    “This fixes two issues in the code to handle converting the relocation in ldil+addl sequences. I extracted the target address of the ldil instruction from the wrong bit position. Secondly as with addil, we need to accept any base register in the R_PARISC_DLTIND21L conversion to R_PARISC_DPREL21L.”

In Details

This change updates the HPPA ELF linker's final_link_relocate function to correctly handle relocations involving ldil and addl instruction pairs. Specifically, it fixes the bitmask used to extract the source/base register from the ldil instruction and broadens the addl instruction check to accommodate arbitrary target registers emitted by the compiler (likely related to Link-Time Relocation, LRA). This ensures correct address calculation for dynamically linked executables.

For Context
HPPA
Hewlett-Packard Precision Architecture. A RISC instruction set architecture.
ldil
Load Immediate Long. An HPPA instruction used to load a 21-bit immediate value.
addl
Add Long. An HPPA instruction for addition.
relocation
The process of updating symbolic references in object code to absolute or relocatable addresses during linking.
R_PARISC_DLTIND21L
A specific relocation type for HPPA, likely related to loading a 21-bit value.
R_PARISC_DPREL21L
Another HPPA relocation type, likely for a 21-bit data-relative address.
LRA
Likely refers to Link-Time Relocation, a feature where relocations are resolved at link time rather than load time.
Filed Under: hppalinkerrelocationdynamic-linking