PR26493 UBSAN: elfnn-riscv.c left shift of negative value

include/
	PR 26493
	* opcode/riscv.h (OP_MASK_CSR, OP_MASK_CUSTOM_IMM)
	(OP_MASK_FUNCT7, OP_MASK_RS3): Make unsigned.
bfd/
	PR 26493
	* elfnn-riscv.c (riscv_make_plt_header): Cast PLT_HEADER_SIZE to
	unsigned when using with RISCV_ITYPE.
	(_bfd_riscv_relax_call): Use an unsigned foff.
This commit is contained in:
Alan Modra
2020-08-31 13:17:06 +09:30
parent 227d539b17
commit 1174d92070
4 changed files with 20 additions and 7 deletions

View File

@@ -204,7 +204,7 @@ static const char * const riscv_pred_succ[16] =
#define OP_SH_RS2 20
#define OP_MASK_RS1 0x1f
#define OP_SH_RS1 15
#define OP_MASK_RS3 0x1f
#define OP_MASK_RS3 0x1fU
#define OP_SH_RS3 27
#define OP_MASK_RD 0x1f
#define OP_SH_RD 7
@@ -223,14 +223,14 @@ static const char * const riscv_pred_succ[16] =
#define OP_MASK_RL 0x1
#define OP_SH_RL 25
#define OP_MASK_CUSTOM_IMM 0x7f
#define OP_MASK_CUSTOM_IMM 0x7fU
#define OP_SH_CUSTOM_IMM 25
#define OP_MASK_CSR 0xfff
#define OP_MASK_CSR 0xfffU
#define OP_SH_CSR 20
#define OP_MASK_FUNCT3 0x7
#define OP_SH_FUNCT3 12
#define OP_MASK_FUNCT7 0x7f
#define OP_MASK_FUNCT7 0x7fU
#define OP_SH_FUNCT7 25
#define OP_MASK_FUNCT2 0x3
#define OP_SH_FUNCT2 25