binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
bfd

pru UB: left shift of negative value

Fixes undefined behavior in PRU ELF relocation by ensuring non-negative shift counts.

This change addresses undefined behavior in the PRU ELF relocation logic where a signed left shift of a negative value could occur. The modification ensures that the shift operation is performed on a non-negative value, preventing potential runtime errors and incorrect calculations.

In Details

The PRU ELF relocation code in bfd/elf32-pru.c incorrectly allowed a signed left shift of a negative value. This commit corrects the order of operations to ensure the value being shifted is treated as unsigned before the shift, avoiding UB.

For Context
PRU
Programmable Real-time Unit, a microcontroller core often found in Texas Instruments SoCs for real-time I/O processing.
Undefined Behavior (UB)
A situation in C/C++ where the result of an operation is not defined by the language standard. Compilers may generate incorrect code or crash when encountering UB.
ELF relocation
A process in executable and linkable format (ELF) object files that specifies how to modify code or data sections to allow them to be linked into a final executable or shared library.
Filed Under: pruelfrelocationub