Fix an integer overflow in RISC-V relocation handling
authorAndrew Waterman <andrew@sifive.com>
Mon, 19 Dec 2016 06:53:49 +0000 (22:53 -0800)
committerAlan Modra <amodra@gmail.com>
Tue, 20 Dec 2016 01:56:33 +0000 (12:26 +1030)
* elfnn-riscv.c (bfd_riscv_get_max_alignment): Return bfd_vma
instead of unsigned int.

bfd/ChangeLog
bfd/elfnn-riscv.c

index b6bba2ac3e0a0e02ed3919c7d1987227ffa3a394..f2b1707e5a18a456adbdc76a90df64862bd2efa0 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-20  Andrew Waterman  <andrew@sifive.com>
+
+       * elfnn-riscv.c (bfd_riscv_get_max_alignment): Return bfd_vma
+       instead of unsigned int.
+
 2016-12-20  Andrew Waterman  <andrew@sifive.com>
            Kuan-Lin Chen  <kuanlinchentw@gmail.com>
 
index 51a2a10e03a539589fc56902a80f0848eeebeee4..a9b0ac6be0936b50399e9f5d28162ab557a9ed02 100644 (file)
@@ -2759,7 +2759,7 @@ _bfd_riscv_relax_call (bfd *abfd, asection *sec, asection *sym_sec,
 
 /* Traverse all output sections and return the max alignment.  */
 
-static unsigned int
+static bfd_vma
 _bfd_riscv_get_max_alignment (asection *sec)
 {
   unsigned int max_alignment_power = 0;
@@ -2771,7 +2771,7 @@ _bfd_riscv_get_max_alignment (asection *sec)
        max_alignment_power = o->alignment_power;
     }
 
-  return 1 << max_alignment_power;
+  return (bfd_vma) 1 << max_alignment_power;
 }
 
 /* Relax non-PIC global variable references.  */