From 108f6f97bd862e969f898c1347903ae1cf38ead4 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 31 Aug 2020 10:15:34 +0930 Subject: [PATCH] PR26461 UBSAN: elfxx-ia64.c:747 cannot be represented PR 26461 * elfxx-ia64.c (ia64_elf_install_value): Make expressions unsigned that might shift values into sign bit. --- bfd/ChangeLog | 6 ++++++ bfd/elfxx-ia64.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 04f6f4c77e..85fd9f42d1 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-08-31 Alan Modra + + PR 26461 + * elfxx-ia64.c (ia64_elf_install_value): Make expressions unsigned + that might shift values into sign bit. + 2020-08-31 Alan Modra PR 26445 diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index b2e55df2b1..a559008c37 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -685,7 +685,7 @@ ia64_elf_install_value (bfd_byte *hit_addr, bfd_vma v, unsigned int r_type) slot 2: bits 23..63 in t1 */ /* First, clear the bits that form the 64 bit constant. */ - t0 &= ~(0x3ffffLL << 46); + t0 &= ~(0x3ffffULL << 46); t1 &= ~(0x7fffffLL | (( (0x07fLL << 13) | (0x1ffLL << 27) | (0x01fLL << 22) | (0x001LL << 21) @@ -714,7 +714,7 @@ ia64_elf_install_value (bfd_byte *hit_addr, bfd_vma v, unsigned int r_type) slot 2: bits 23..63 in t1 */ /* First, clear the bits that form the 64 bit constant. */ - t0 &= ~(0x3ffffLL << 46); + t0 &= ~(0x3ffffULL << 46); t1 &= ~(0x7fffffLL | ((1LL << 36 | 0xfffffLL << 13) << 23)); @@ -744,7 +744,7 @@ ia64_elf_install_value (bfd_byte *hit_addr, bfd_vma v, unsigned int r_type) if (err) return bfd_reloc_overflow; - dword &= ~(0x1ffffffffffLL << shift); + dword &= ~(0x1ffffffffffULL << shift); dword |= (insn << shift); bfd_putl64 (dword, hit_addr); break; -- 2.34.1