[PATCH] readelf: Handle R_RISCV_SET32

Fangrui Song maskray@sourceware.org
Tue Jan 13 18:01:54 GMT 2026


On Tue, Jan 13, 2026 at 12:23 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 12.01.2026 22:56, Andreas Schwab wrote:
> > ---
> >  binutils/readelf.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/binutils/readelf.c b/binutils/readelf.c
> > index 27cd854e9c2..d26e2bfa7b9 100644
> > --- a/binutils/readelf.c
> > +++ b/binutils/readelf.c
> > @@ -16000,7 +16000,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
> >      case EM_TI_PRU:
> >        return reloc_type == 11; /* R_PRU_BFD_RELOC_32.  */
> >      case EM_RISCV:
> > -      return reloc_type == 1; /* R_RISCV_32.  */
> > +      return (reloc_type == 1 /* R_RISCV_32.  */
> > +           || reloc_type == 56); /* R_RISCV_SET32.  */
> >      case EM_RL78:
> >        return reloc_type == 1; /* R_RL78_DIR32.  */
> >      case EM_RX:
>
> Okay (but Cc-ing the RISC-V maintainers just in case).
>
> Jan

Consider adding a commit message that this is for the readelf -x
feature. IIUC it attempts to apply certain relocations to make the -x
output look better.


More information about the Binutils mailing list