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/libaout.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bfd/libaout.h') diff --git a/bfd/libaout.h b/bfd/libaout.h index 5b6424c..0702ed3 100644 --- a/bfd/libaout.h +++ b/bfd/libaout.h @@ -309,7 +309,7 @@ enum machine_type # define N_SET_INFO(execp, magic, type, flags) \ ((execp)->a_info = ((magic) & 0xffff) \ | (((int)(type) & 0xff) << 16) \ - | (((flags) & 0xff) << 24)) + | (((flags) & 0xffu) << 24)) #endif #ifndef N_SET_DYNAMIC @@ -332,7 +332,7 @@ enum machine_type #ifndef N_SET_FLAGS # define N_SET_FLAGS(execp, flags) \ ((execp)->a_info = \ - ((execp)->a_info & 0x00ffffff) | (((flags) & 0xff) << 24)) + ((execp)->a_info & 0x00ffffff) | (((flags) & 0xffu) << 24)) #endif typedef struct aout_symbol -- cgit v1.1