[binutils-gdb] PR26419, ASAN: mn10300_elf_relax_section elf-m10300.c:3943

Alan Modra amodra@sourceware.org
Tue Aug 25 13:37:55 GMT 2020


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

commit b8ff233b54d66c5dce5a6d1409fe57e7ea359f43
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Aug 25 09:37:23 2020 +0930

    PR26419, ASAN: mn10300_elf_relax_section elf-m10300.c:3943
    
            PR 26419
            * elf-m10300.c (mn10300_elf_relax_section): Don't attempt access
            before start of section.

Diff:
---
 bfd/ChangeLog    | 6 ++++++
 bfd/elf-m10300.c | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 0c638590fce..f1f0e322fe1 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2020-08-25  Alan Modra  <amodra@gmail.com>
+
+	PR 26419
+	* elf-m10300.c (mn10300_elf_relax_section): Don't attempt access
+	before start of section.
+
 2020-08-25  Alan Modra  <amodra@gmail.com>
 
 	* elf-m10300.c (elf32_mn10300_hash_table): Test is_elf_hash_table
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index ae8cac84e67..7c63ce4cd12 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -3932,7 +3932,7 @@ mn10300_elf_relax_section (bfd *abfd,
 	  /* See if the value will fit in 24 bits.
 	     We allow any 16bit match here.  We prune those we can't
 	     handle below.  */
-	  if ((long) value < 0x7fffff && (long) value > -0x800000)
+	  if (value + 0x800000 < 0x1000000 && irel->r_offset >= 3)
 	    {
 	      unsigned char code;
 
@@ -4003,7 +4003,7 @@ mn10300_elf_relax_section (bfd *abfd,
 	  /* See if the value will fit in 16 bits.
 	     We allow any 16bit match here.  We prune those we can't
 	     handle below.  */
-	  if ((long) value < 0x7fff && (long) value > -0x8000)
+	  if (value + 0x8000 < 0x10000 && irel->r_offset >= 2)
 	    {
 	      unsigned char code;


More information about the Binutils-cvs mailing list