[PATCH] bfd: check for truncation with R_RISCV_32 relocations

Andreas Schwab schwab@suse.de
Wed Jan 31 09:14:20 GMT 2024


On Jan 30 2024, Joseph Faulls wrote:

> diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
> index 8b27e3b8d6a..975b40e5f53 100644
> --- a/bfd/elfnn-riscv.c
> +++ b/bfd/elfnn-riscv.c
> @@ -1865,6 +1865,9 @@ perform_relocation (const reloc_howto_type *howto,
>        }
>
>      case R_RISCV_32:
> +      if (value & ~howto->dst_mask)
> +       return bfd_reloc_overflow;
> +      break;

The overflow check belongs to the howto table.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


More information about the Binutils mailing list