aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-arm.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-12-11 13:32:25 +1030
committerAlan Modra <amodra@gmail.com>2019-12-11 21:14:19 +1030
commit13c9c48599ebc8ad2f3a1fb9f672740219cd3841 (patch)
treeb304237be09f4f06469122cdcdda658299ebb1ba /bfd/elf32-arm.c
parent09c78487342254de6a4498f8b3aa1f3f1d508898 (diff)
downloadbinutils-13c9c48599ebc8ad2f3a1fb9f672740219cd3841.zip
binutils-13c9c48599ebc8ad2f3a1fb9f672740219cd3841.tar.gz
binutils-13c9c48599ebc8ad2f3a1fb9f672740219cd3841.tar.bz2
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.
Diffstat (limited to 'bfd/elf32-arm.c')
-rw-r--r--bfd/elf32-arm.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 37b5b64..ebe199c 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -8506,14 +8506,14 @@ bfd_elf32_arm_vfp11_erratum_scan (bfd *abfd, struct bfd_link_info *link_info)
{
unsigned int next_i = i + 4;
unsigned int insn = bfd_big_endian (abfd)
- ? (contents[i] << 24)
- | (contents[i + 1] << 16)
- | (contents[i + 2] << 8)
- | contents[i + 3]
- : (contents[i + 3] << 24)
- | (contents[i + 2] << 16)
- | (contents[i + 1] << 8)
- | contents[i];
+ ? (((unsigned) contents[i] << 24)
+ | (contents[i + 1] << 16)
+ | (contents[i + 2] << 8)
+ | contents[i + 3])
+ : (((unsigned) contents[i + 3] << 24)
+ | (contents[i + 2] << 16)
+ | (contents[i + 1] << 8)
+ | contents[i]);
unsigned int writemask = 0;
enum bfd_arm_vfp11_pipe vpipe;
@@ -19356,7 +19356,7 @@ stm32l4xx_create_replacing_stub_vldm (struct elf32_arm_link_hash_table * htab,
const bfd_byte *const initial_insn_addr,
bfd_byte *const base_stub_contents)
{
- int num_words = ((unsigned int) initial_insn << 24) >> 24;
+ int num_words = initial_insn & 0xff;
bfd_byte *current_stub_contents = base_stub_contents;
BFD_ASSERT (is_thumb2_vldm (initial_insn));