PR26461 UBSAN: elfxx-ia64.c:747 cannot be represented

Alan Modra amodra@gmail.com
Mon Aug 31 10:50:27 GMT 2020


	PR 26461
	* elfxx-ia64.c (ia64_elf_install_value): Make expressions unsigned
	that might shift values into sign bit.

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;


More information about the Binutils mailing list