From 13c9c48599ebc8ad2f3a1fb9f672740219cd3841 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 11 Dec 2019 13:32:25 +1030 Subject: bfd signed overflow fixes Aimed at quietening ubsan. include/ * opcode/mmix.h (PUSHGO_INSN_BYTE): Make unsigned. (GO_INSN_BYTE, SETL_INSN_BYTE, INCML_INSN_BYTE, INCMH_INSN_BYTE), (INCH_INSN_BYTE, SWYM_INSN_BYTE, JMP_INSN_BYTE): Likewise. bfd/ * elf32-rx.c (elf32_rx_relax_section): Avoid signed overflow. * libaout.h (N_SET_INFO, N_SET_FLAGS): Likewise. * netbsd.h (write_object_contents): Likewise. * elf32-arm.c (bfd_elf32_arm_vfp11_erratum_scan): Likewise. * libhppa.h (HPPA_R_CONSTANT): Don't signed extend with shifts. (stm32l4xx_create_replacing_stub_vldm): Don't truncate high bits with shifts. * elf32-nds32.h (R_NDS32_RELAX_ENTRY_DISABLE_RELAX_FLAG): Define using 1u shifted left. Ditto for other macros. * mmo.c (LOP): Make unsigned. --- bfd/libhppa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bfd/libhppa.h') diff --git a/bfd/libhppa.h b/bfd/libhppa.h index df50b7d..632f524 100644 --- a/bfd/libhppa.h +++ b/bfd/libhppa.h @@ -148,7 +148,7 @@ enum hppa_reloc_expr_type_alt #define HPPA_R_ARG_RELOC(a) \ (((a) >> 22) & 0x3ff) #define HPPA_R_CONSTANT(a) \ - ((((bfd_signed_vma)(a)) << (BFD_ARCH_SIZE-22)) >> (BFD_ARCH_SIZE-22)) + ((((bfd_signed_vma) (a) & 0x3fffff) ^ 0x200000) - 0x200000) #define HPPA_R_ADDEND(r, c) \ (((r) << 22) + ((c) & 0x3fffff)) -- cgit v1.1