This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix an integer overflow in RISC-V relocation handling


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1d61f7949f77796ee407466f3ca7f42dcde9251b

commit 1d61f7949f77796ee407466f3ca7f42dcde9251b
Author: Andrew Waterman <andrew@sifive.com>
Date:   Sun Dec 18 22:53:49 2016 -0800

    Fix an integer overflow in RISC-V relocation handling
    
    	* elfnn-riscv.c (bfd_riscv_get_max_alignment): Return bfd_vma
    	instead of unsigned int.

Diff:
---
 bfd/ChangeLog     | 5 +++++
 bfd/elfnn-riscv.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b6bba2a..f2b1707 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,4 +1,9 @@
 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>
 
 	* reloc.c (BFD_RELOC_RISCV_TPREL_I): New relocation.
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 51a2a10..a9b0ac6 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -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.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]