This is the mail archive of the binutils@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]

[PATCH][Binutils]: Fix range check in ihex PR/24065 for 32 bit hosts.


Hi All,

The change in PR binutils/24065 added a check to see if the value is in a 32-bit range.
It does this using two 64-bit masks that are stored inside a bfd_vma.

This now rejects all values on a 32-bit host as bfd_vma seems host dependent.  This
patch changes the type for the masks from bfd_vma to uint64_t.
    
build on native hardware and regtested on
  aarch64-none-elf, aarch64-none-elf (32 bit host),
  aarch64-none-linux-gnu, aarch64-none-linux-gnu (32 bit host)
  arm-none-eabi, arm-none-eabi (32 bit host),
  arm-none-linux-gnueabihf, arm-none-linux-gnueabihf (32 bit host)

Cross-compiled and regtested on
  aarch64-none-linux-gnu, aarch64_be-none-linux-gnu
  arm-none-eabi, armeb-none-eabi

and no issues.

Ok for master?

Thanks,
Tamar

bfd/ChangeLog:

2019-01-08  Tamar Christina  <tamar.christina@arm.com>

	PR binutils/24065
	* ihex.c (ihex_write_object_contents): Change bfd_vma to uint64_t.

binutils/ChangeLog:

2019-01-08  Tamar Christina  <tamar.christina@arm.com>

	PR binutils/24065
	* testsuite/binutils-all/copy-6.d: New test.
	* testsuite/binutils-all/objcopy.exp: Use it.

-- 
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 5d7d8fffeaaabc992e3923866e679e7e1daaf644..d5097f37307fcfb7cf757d6b215d53f20dd82e16 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -775,8 +775,8 @@ ihex_write_object_contents (bfd *abfd)
       bfd_vma where;
       bfd_byte *p;
       bfd_size_type count;
-      const bfd_vma sign = (bfd_vma) 0xffffffff80000000ULL;
-      const bfd_vma top = (bfd_vma) 0xffffffff00000000ULL;
+      const uint64_t sign = (uint64_t) 0xffffffff80000000ULL;
+      const uint64_t top = (uint64_t) 0xffffffff00000000ULL;
 
       where = l->where;
 
diff --git a/binutils/testsuite/binutils-all/copy-6.d b/binutils/testsuite/binutils-all/copy-6.d
new file mode 100644
index 0000000000000000000000000000000000000000..ec8365379eb1c0ebc5a0a68f7516748569900bff
--- /dev/null
+++ b/binutils/testsuite/binutils-all/copy-6.d
@@ -0,0 +1,8 @@
+#PROG: objcopy
+#source: bintest.s
+#objcopy: -O ihex
+# A few targets cannot assemble the bintest.s source file...
+#notarget: pdp11-* *-darwin
+#name: ihex objcopy test
+#objdump: -h
+#...
\ No newline at end of file
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index d8bfca8c11c6058b4e5771bc1c5807cfd938ee4f..921e6a23c4f2f3c12169d8941d1c4f7912589e81 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -1076,6 +1076,7 @@ run_dump_test "copy-2"
 run_dump_test "copy-3"
 run_dump_test "copy-4"
 run_dump_test "copy-5"
+run_dump_test "copy-6"
 
 # Use bintest.o from the copy-4 test to determine ELF reloc type
 set reloc_format rel


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